LLVM  16.0.0git
BitstreamRemarkParser.h
Go to the documentation of this file.
1 //===-- BitstreamRemarkParser.h - Parser for Bitstream remarks --*- C++/-*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file provides the impementation of the Bitstream remark parser.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_LIB_REMARKS_BITSTREAM_REMARK_PARSER_H
14 #define LLVM_LIB_REMARKS_BITSTREAM_REMARK_PARSER_H
15 
16 #include "llvm/ADT/Optional.h"
21 #include <cstdint>
22 #include <memory>
23 
24 namespace llvm {
25 namespace remarks {
26 
27 struct Remark;
28 
29 /// Parses and holds the state of the latest parsed remark.
31  /// The buffer to parse.
33  /// The string table used for parsing strings.
35  /// Temporary remark buffer used when the remarks are stored separately.
36  std::unique_ptr<MemoryBuffer> TmpRemarkBuffer;
37  /// The common metadata used to decide how to parse the buffer.
38  /// This is filled when parsing the metadata block.
43  /// Wether the parser is ready to parse remarks.
44  bool ReadyToParseRemarks = false;
45 
46  /// Create a parser that expects to find a string table embedded in the
47  /// stream.
50 
51  /// Create a parser that uses a pre-parsed string table.
54  StrTab(std::move(StrTab)) {}
55 
57 
58  static bool classof(const RemarkParser *P) {
59  return P->ParserFormat == Format::Bitstream;
60  }
61 
62  /// Parse and process the metadata of the buffer.
63  Error parseMeta();
64 
65  /// Parse a Bitstream remark.
67 
68 private:
69  /// Helper functions.
70  Error processCommonMeta(BitstreamMetaParserHelper &Helper);
71  Error processStandaloneMeta(BitstreamMetaParserHelper &Helper);
72  Error processSeparateRemarksFileMeta(BitstreamMetaParserHelper &Helper);
73  Error processSeparateRemarksMetaMeta(BitstreamMetaParserHelper &Helper);
75  processRemark(BitstreamRemarkParserHelper &Helper);
76  Error processExternalFilePath(Optional<StringRef> ExternalFilePath);
77 };
78 
80  StringRef Buf, Optional<ParsedStringTable> StrTab = None,
81  Optional<StringRef> ExternalFilePrependPath = None);
82 
83 } // end namespace remarks
84 } // end namespace llvm
85 
86 #endif /* LLVM_LIB_REMARKS_BITSTREAM_REMARK_PARSER_H */
llvm::remarks::BitstreamParserHelper
Helper to parse any bitstream remark container.
Definition: BitstreamRemarkParser.h:89
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::remarks::BitstreamRemarkParser::parseMeta
Error parseMeta()
Parse and process the metadata of the buffer.
Definition: BitstreamRemarkParser.cpp:344
llvm::remarks::Format::Bitstream
@ Bitstream
Optional.h
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
RemarkParser.h
llvm::remarks::BitstreamMetaParserHelper
Helper to parse a META_BLOCK for a bitstream remark container.
Definition: BitstreamRemarkParser.h:29
llvm::remarks::BitstreamRemarkParser::classof
static bool classof(const RemarkParser *P)
Definition: BitstreamRemarkParser.h:58
llvm::Optional
Definition: APInt.h:33
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:41
llvm::remarks::BitstreamRemarkParser::RemarkVersion
uint64_t RemarkVersion
Definition: BitstreamRemarkParser.h:40
llvm::remarks::BitstreamRemarkParser::ReadyToParseRemarks
bool ReadyToParseRemarks
Wether the parser is ready to parse remarks.
Definition: BitstreamRemarkParser.h:44
remarks
annotation remarks
Definition: AnnotationRemarks.cpp:114
llvm::remarks::BitstreamRemarkParser::ContainerVersion
uint64_t ContainerVersion
The common metadata used to decide how to parse the buffer.
Definition: BitstreamRemarkParser.h:39
RemarkFormat.h
llvm::remarks::BitstreamRemarkParserHelper
Helper to parse a REMARK_BLOCK for a bitstream remark container.
Definition: BitstreamRemarkParser.h:54
llvm::HighlightColor::Remark
@ Remark
uint64_t
llvm::remarks::BitstreamRemarkContainerType::Standalone
@ Standalone
Everything is emitted together.
BitstreamRemarkParser.h
llvm::remarks::BitstreamRemarkParser
Parses and holds the state of the latest parsed remark.
Definition: BitstreamRemarkParser.h:30
BitstreamRemarkContainer.h
llvm::move
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1676
llvm::remarks::BitstreamRemarkParser::next
Expected< std::unique_ptr< Remark > > next() override
If no error occurs, this returns a valid Remark object.
Definition: BitstreamRemarkParser.cpp:331
llvm::remarks::BitstreamRemarkParser::parseRemark
Expected< std::unique_ptr< Remark > > parseRemark()
Parse a Bitstream remark.
Definition: BitstreamRemarkParser.cpp:491
llvm::remarks::BitstreamRemarkParser::ParserHelper
BitstreamParserHelper ParserHelper
The buffer to parse.
Definition: BitstreamRemarkParser.h:32
llvm::remarks::ParsedStringTable
In-memory representation of the string table parsed from a buffer (e.g.
Definition: RemarkParser.h:59
llvm::remarks::BitstreamRemarkParser::BitstreamRemarkParser
BitstreamRemarkParser(StringRef Buf, ParsedStringTable StrTab)
Create a parser that uses a pre-parsed string table.
Definition: BitstreamRemarkParser.h:52
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
llvm::remarks::BitstreamRemarkParser::BitstreamRemarkParser
BitstreamRemarkParser(StringRef Buf)
Create a parser that expects to find a string table embedded in the stream.
Definition: BitstreamRemarkParser.h:48
llvm::remarks::BitstreamRemarkParser::ContainerType
BitstreamRemarkContainerType ContainerType
Definition: BitstreamRemarkParser.h:41
llvm::remarks::BitstreamRemarkParser::StrTab
Optional< ParsedStringTable > StrTab
The string table used for parsing strings.
Definition: BitstreamRemarkParser.h:34
llvm::remarks::RemarkParser
Parser used to parse a raw buffer to remarks::Remark objects.
Definition: RemarkParser.h:39
std
Definition: BitVector.h:851
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155
llvm::remarks::BitstreamRemarkParser::TmpRemarkBuffer
std::unique_ptr< MemoryBuffer > TmpRemarkBuffer
Temporary remark buffer used when the remarks are stored separately.
Definition: BitstreamRemarkParser.h:36
llvm::remarks::createBitstreamParserFromMeta
Expected< std::unique_ptr< BitstreamRemarkParser > > createBitstreamParserFromMeta(StringRef Buf, Optional< ParsedStringTable > StrTab=None, Optional< StringRef > ExternalFilePrependPath=None)
Definition: BitstreamRemarkParser.cpp:309
llvm::remarks::BitstreamRemarkContainerType
BitstreamRemarkContainerType
Type of the remark container.
Definition: BitstreamRemarkContainer.h:35
llvm::remarks::Format
Format
The format used for serializing/deserializing remarks.
Definition: RemarkFormat.h:25