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;
96 std::unique_ptr<TGVarScope> Parent;
98 std::map<std::string, Init *, std::less<>> Vars;
112 CurMultiClass(Multiclass) {}
117 return std::move(Parent);
122 bool TrackReferenceLocs)
const;
129 return Vars.find(
Name) != Vars.end();
133 bool Ins = Vars.insert(std::make_pair(std::string(
Name),
I)).second;
135 assert(Ins &&
"Local variable already exists");
143 std::vector<SmallVector<LetRecord, 4>> LetStack;
144 std::map<std::string, std::unique_ptr<MultiClass>> MultiClasses;
148 std::vector<std::unique_ptr<ForeachLoop>> Loops;
157 std::unique_ptr<TGVarScope> CurScope;
173 bool NoWarnOnUnusedTemplateArgs =
false;
174 bool TrackReferenceLocs =
false;
178 const bool NoWarnOnUnusedTemplateArgs =
false,
179 const bool TrackReferenceLocs =
false)
180 : Lex(SM, Macros), CurMultiClass(nullptr), Records(records),
181 NoWarnOnUnusedTemplateArgs(NoWarnOnUnusedTemplateArgs),
182 TrackReferenceLocs(TrackReferenceLocs) {}
200 CurScope = std::make_unique<TGVarScope>(std::move(CurScope));
204 return CurScope.get();
207 CurScope = std::make_unique<TGVarScope>(std::move(CurScope), Rec);
208 return CurScope.get();
211 CurScope = std::make_unique<TGVarScope>(std::move(CurScope),
Loop);
212 return CurScope.get();
215 CurScope = std::make_unique<TGVarScope>(std::move(CurScope), Multiclass);
216 return CurScope.get();
219 assert(ExpectedStackTop == CurScope.get() &&
220 "Mismatched pushes and pops of local variable scopes");
221 CurScope = CurScope->extractParent();
231 bool AllowSelfAssignment =
false,
bool OverrideDefLoc =
true);
241 std::vector<RecordsEntry> *Dest,
SMLoc *Loc =
nullptr);
242 bool resolve(
const std::vector<RecordsEntry> &Source, SubstStack &Substs,
243 bool Final, std::vector<RecordsEntry> *Dest,
244 SMLoc *Loc =
nullptr);
245 bool addDefOne(std::unique_ptr<Record> Rec);
249 bool ParseObjectList(
MultiClass *MC =
nullptr);
252 bool ParseMultiClass();
256 bool ParseDefvar(
Record *CurRec =
nullptr);
261 bool ParseTopLevelLet(
MultiClass *CurMultiClass);
264 bool ParseObjectBody(
Record *CurRec);
265 bool ParseBody(
Record *CurRec);
266 bool ParseBodyItem(
Record *CurRec);
268 bool ParseTemplateArgList(
Record *CurRec);
269 Init *ParseDeclaration(
Record *CurRec,
bool ParsingTemplateArgs);
270 VarInit *ParseForeachDeclaration(
Init *&ForeachListValue);
276 IDParseMode
Mode = ParseValueMode);
278 IDParseMode
Mode = ParseValueMode);
280 IDParseMode
Mode = ParseValueMode);
285 void ParseDagArgList(
301 RecTy *ParseOperatorType();
305 bool ApplyLetStack(
Record *CurRec);
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static cl::opt< RegAllocEvictionAdvisorAnalysis::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Development, "development", "for training")))
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Lightweight error class with error context and mandatory checking.
Represents a single loop in the control flow graph.
This class represents a field in a record, including its name, type, value, and source location.
Represents a location in source code.
Represents a range in source code.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.
"foo" - Represent an initialization by a string value.
StringRef - Represent a constant reference to a string, i.e.
TGLexer - TableGen Lexer class.
std::set< std::string > DependenciesSetTy
const DependenciesSetTy & getDependencies() const
void PopScope(TGVarScope *ExpectedStackTop)
const TGLexer::DependenciesSetTy & getDependencies() const
bool Error(SMLoc L, const Twine &Msg) const
TGVarScope * PushScope(ForeachLoop *Loop)
TGVarScope * PushScope(Record *Rec)
bool TokError(const Twine &Msg) const
TGParser(SourceMgr &SM, ArrayRef< std::string > Macros, RecordKeeper &records, const bool NoWarnOnUnusedTemplateArgs=false, const bool TrackReferenceLocs=false)
TGVarScope * PushScope(MultiClass *Multiclass)
bool ParseFile()
ParseFile - Main entrypoint for parsing a tblgen file.
Init * getVar(RecordKeeper &Records, MultiClass *ParsingMultiClass, StringInit *Name, SMRange NameLoc, bool TrackReferenceLocs) const
TGVarScope(std::unique_ptr< TGVarScope > Parent, Record *Rec)
std::unique_ptr< TGVarScope > extractParent()
TGVarScope(std::unique_ptr< TGVarScope > Parent, ForeachLoop *Loop)
void addVar(StringRef Name, Init *I)
bool varAlreadyDefined(StringRef Name) const
TGVarScope(std::unique_ptr< TGVarScope > Parent, MultiClass *Multiclass)
TGVarScope(std::unique_ptr< TGVarScope > Parent)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
This is the common superclass of types that have a specific, explicit type, stored in ValueTy.
LLVM Value Representation.
'Opcode' - Represent a reference to an entire variable object.
This is an optimization pass for GlobalISel generic memory operations.
void PrintError(const Twine &Msg)
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
SmallVector< Init *, 16 > Elements
ForeachLoop - Record the iteration state associated with a for loop.
std::vector< RecordsEntry > Entries
ForeachLoop(SMLoc Loc, VarInit *IVar, Init *LValue)
std::vector< unsigned > Bits
LetRecord(StringInit *N, ArrayRef< unsigned > B, Init *V, SMLoc L)
std::vector< RecordsEntry > Entries
MultiClass(StringRef Name, SMLoc Loc, RecordKeeper &Records)
RecordsEntry - Holds exactly one of a Record, ForeachLoop, or AssertionInfo.
RecordsEntry(std::unique_ptr< ForeachLoop > Loop)
std::unique_ptr< ForeachLoop > Loop
std::unique_ptr< Record::AssertionInfo > Assertion
RecordsEntry(std::unique_ptr< Record > Rec)
std::unique_ptr< Record > Rec
RecordsEntry(std::unique_ptr< Record::AssertionInfo > Assertion)