Go to the documentation of this file.
13 #ifndef LLVM_LIB_TABLEGEN_TGPARSER_H
14 #define LLVM_LIB_TABLEGEN_TGPARSER_H
26 struct SubClassReference;
27 struct SubMultiClassReference;
31 std::vector<unsigned>
Bits;
41 std::unique_ptr<Record>
Rec;
42 std::unique_ptr<ForeachLoop>
Loop;
78 std::map<std::string, Init *, std::less<>> vars;
79 std::unique_ptr<TGLocalVarScope> parent;
93 auto It = vars.find(
Name);
97 return parent->getVar(
Name);
106 return vars.find(
Name) != vars.end();
110 bool Ins = vars.insert(std::make_pair(std::string(
Name),
I)).second;
112 assert(
Ins &&
"Local variable already exists");
128 std::vector<SmallVector<LetRecord, 4>> LetStack;
129 std::map<std::string, std::unique_ptr<MultiClass>> MultiClasses;
133 std::vector<std::unique_ptr<ForeachLoop>> Loops;
143 std::unique_ptr<TGLocalVarScope> CurLocalScope;
162 : Lex(SM, Macros), CurMultiClass(nullptr), Records(records) {}
180 CurLocalScope = std::make_unique<TGLocalVarScope>(
std::move(CurLocalScope));
184 return CurLocalScope.get();
187 assert(ExpectedStackTop == CurLocalScope.get() &&
188 "Mismatched pushes and pops of local variable scopes");
189 CurLocalScope = CurLocalScope->extractParent();
196 bool AllowSelfAssignment =
false);
206 std::vector<RecordsEntry> *Dest,
SMLoc *Loc =
nullptr);
207 bool resolve(
const std::vector<RecordsEntry> &
Source, SubstStack &Substs,
208 bool Final, std::vector<RecordsEntry> *Dest,
209 SMLoc *Loc =
nullptr);
210 bool addDefOne(std::unique_ptr<Record> Rec);
214 bool ParseObjectList(
MultiClass *MC =
nullptr);
217 bool ParseMultiClass();
226 bool ParseTopLevelLet(
MultiClass *CurMultiClass);
229 bool ParseObjectBody(
Record *CurRec);
230 bool ParseBody(
Record *CurRec);
231 bool ParseBodyItem(
Record *CurRec);
233 bool ParseTemplateArgList(
Record *CurRec);
234 Init *ParseDeclaration(
Record *CurRec,
bool ParsingTemplateArgs);
235 VarInit *ParseForeachDeclaration(
Init *&ForeachListValue);
241 IDParseMode
Mode = ParseValueMode);
243 IDParseMode
Mode = ParseValueMode);
245 IDParseMode
Mode = ParseValueMode);
247 Record *ArgsRec =
nullptr,
RecTy *EltTy =
nullptr);
248 void ParseDagArgList(
261 RecTy *ParseOperatorType();
265 bool ApplyLetStack(
Record *CurRec);
268 void CheckRecordAsserts(
Record &Rec);
RecordsEntry(std::unique_ptr< ForeachLoop > Loop)
This class represents lattice values for constants.
bool TokError(const Twine &Msg) const
RecordsEntry(std::unique_ptr< Record > Rec)
Represents a single loop in the control flow graph.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
TGLocalVarScope * PushLocalScope()
bool varAlreadyDefined(StringRef Name) const
'Opcode' - Represent a reference to an entire variable object.
MultiClass(StringRef Name, SMLoc Loc, RecordKeeper &Records)
SmallVector< Init *, 16 > Elements
const DependenciesSetTy & getDependencies() const
std::unique_ptr< TGLocalVarScope > extractParent()
Represents a location in source code.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
TGLexer - TableGen Lexer class.
RecordsEntry - Can be either a record or a foreach loop.
bool Error(SMLoc L, const Twine &Msg) const
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
ForeachLoop - Record the iteration state associated with a for loop.
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
TGLocalVarScope()=default
TGLocalVarScope(std::unique_ptr< TGLocalVarScope > parent)
std::unique_ptr< ForeachLoop > Loop
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Init * getVar(StringRef Name) const
std::unique_ptr< Record > Rec
"foo" - Represent an initialization by a string value.
std::vector< RecordsEntry > Entries
StringRef - Represent a constant reference to a string, i.e.
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.
LetRecord(StringInit *N, ArrayRef< unsigned > B, Init *V, SMLoc L)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
void addVar(StringRef Name, Init *I)
ForeachLoop(SMLoc Loc, VarInit *IVar, Init *LValue)
const TGLexer::DependenciesSetTy & getDependencies() const
std::vector< RecordsEntry > Entries
void PrintError(const Twine &Msg)
std::vector< unsigned > Bits
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
std::set< std::string > DependenciesSetTy
This class represents a field in a record, including its name, type, value, and source location.
LLVM Value Representation.
void PopLocalScope(TGLocalVarScope *ExpectedStackTop)
bool ParseFile()
ParseFile - Main entrypoint for parsing a tblgen file.
TGParser(SourceMgr &SM, ArrayRef< std::string > Macros, RecordKeeper &records)
This is the common superclass of types that have a specific, explicit type, stored in ValueTy.