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;
42 std::unique_ptr<Record>
Rec;
43 std::unique_ptr<ForeachLoop>
Loop;
82 std::map<std::string, Init *, std::less<>> vars;
83 std::unique_ptr<TGLocalVarScope> parent;
97 auto It = vars.find(
Name);
101 return parent->getVar(
Name);
110 return vars.find(
Name) != vars.end();
114 bool Ins = vars.insert(std::make_pair(std::string(
Name),
I)).second;
116 assert(
Ins &&
"Local variable already exists");
132 std::vector<SmallVector<LetRecord, 4>> LetStack;
133 std::map<std::string, std::unique_ptr<MultiClass>> MultiClasses;
137 std::vector<std::unique_ptr<ForeachLoop>> Loops;
147 std::unique_ptr<TGLocalVarScope> CurLocalScope;
163 bool NoWarnOnUnusedTemplateArgs =
false;
167 const bool NoWarnOnUnusedTemplateArgs =
false)
168 : Lex(SM, Macros), CurMultiClass(nullptr), Records(records),
169 NoWarnOnUnusedTemplateArgs(NoWarnOnUnusedTemplateArgs) {}
187 CurLocalScope = std::make_unique<TGLocalVarScope>(
std::move(CurLocalScope));
191 return CurLocalScope.get();
194 assert(ExpectedStackTop == CurLocalScope.get() &&
195 "Mismatched pushes and pops of local variable scopes");
196 CurLocalScope = CurLocalScope->extractParent();
203 bool AllowSelfAssignment =
false);
213 std::vector<RecordsEntry> *Dest,
SMLoc *Loc =
nullptr);
214 bool resolve(
const std::vector<RecordsEntry> &
Source, SubstStack &Substs,
215 bool Final, std::vector<RecordsEntry> *Dest,
216 SMLoc *Loc =
nullptr);
217 bool addDefOne(std::unique_ptr<Record> Rec);
221 bool ParseObjectList(
MultiClass *MC =
nullptr);
224 bool ParseMultiClass();
233 bool ParseTopLevelLet(
MultiClass *CurMultiClass);
236 bool ParseObjectBody(
Record *CurRec);
237 bool ParseBody(
Record *CurRec);
238 bool ParseBodyItem(
Record *CurRec);
240 bool ParseTemplateArgList(
Record *CurRec);
241 Init *ParseDeclaration(
Record *CurRec,
bool ParsingTemplateArgs);
242 VarInit *ParseForeachDeclaration(
Init *&ForeachListValue);
248 IDParseMode
Mode = ParseValueMode);
250 IDParseMode
Mode = ParseValueMode);
252 IDParseMode
Mode = ParseValueMode);
257 void ParseDagArgList(
271 RecTy *ParseOperatorType();
275 bool ApplyLetStack(
Record *CurRec);
RecordsEntry(std::unique_ptr< ForeachLoop > Loop)
This is an optimization pass for GlobalISel generic memory operations.
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 - Holds exactly one of a Record, ForeachLoop, or AssertionInfo.
bool Error(SMLoc L, const Twine &Msg) const
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
TGParser(SourceMgr &SM, ArrayRef< std::string > Macros, RecordKeeper &records, const bool NoWarnOnUnusedTemplateArgs=false)
ForeachLoop - Record the iteration state associated with a for loop.
RecordsEntry(std::unique_ptr< Record::AssertionInfo > Assertion)
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.
const CustomOperand< const MCSubtargetInfo & > Msg[]
LetRecord(StringInit *N, ArrayRef< unsigned > B, Init *V, SMLoc L)
std::unique_ptr< Record::AssertionInfo > Assertion
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.
This is the common superclass of types that have a specific, explicit type, stored in ValueTy.