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;
93 return std::move(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;
164 bool TrackReferenceLocs =
false;
168 const bool NoWarnOnUnusedTemplateArgs =
false,
169 const bool TrackReferenceLocs =
false)
170 : Lex(SM, Macros), CurMultiClass(nullptr), Records(records),
171 NoWarnOnUnusedTemplateArgs(NoWarnOnUnusedTemplateArgs),
172 TrackReferenceLocs(TrackReferenceLocs) {}
190 CurLocalScope = std::make_unique<TGLocalVarScope>(std::move(CurLocalScope));
194 return CurLocalScope.get();
197 assert(ExpectedStackTop == CurLocalScope.get() &&
198 "Mismatched pushes and pops of local variable scopes");
199 CurLocalScope = CurLocalScope->extractParent();
209 bool AllowSelfAssignment =
false,
bool OverrideDefLoc =
true);
219 std::vector<RecordsEntry> *Dest,
SMLoc *Loc =
nullptr);
220 bool resolve(
const std::vector<RecordsEntry> &Source, SubstStack &Substs,
221 bool Final, std::vector<RecordsEntry> *Dest,
222 SMLoc *Loc =
nullptr);
223 bool addDefOne(std::unique_ptr<Record> Rec);
227 bool ParseObjectList(
MultiClass *MC =
nullptr);
230 bool ParseMultiClass();
239 bool ParseTopLevelLet(
MultiClass *CurMultiClass);
242 bool ParseObjectBody(
Record *CurRec);
243 bool ParseBody(
Record *CurRec);
244 bool ParseBodyItem(
Record *CurRec);
246 bool ParseTemplateArgList(
Record *CurRec);
247 Init *ParseDeclaration(
Record *CurRec,
bool ParsingTemplateArgs);
248 VarInit *ParseForeachDeclaration(
Init *&ForeachListValue);
254 IDParseMode
Mode = ParseValueMode);
256 IDParseMode
Mode = ParseValueMode);
258 IDParseMode
Mode = ParseValueMode);
263 void ParseDagArgList(
277 RecTy *ParseOperatorType();
281 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
Init * getVar(StringRef Name) const
TGLocalVarScope()=default
std::unique_ptr< TGLocalVarScope > extractParent()
TGLocalVarScope(std::unique_ptr< TGLocalVarScope > parent)
bool varAlreadyDefined(StringRef Name) const
void addVar(StringRef Name, Init *I)
const TGLexer::DependenciesSetTy & getDependencies() const
bool Error(SMLoc L, const Twine &Msg) const
bool TokError(const Twine &Msg) const
TGLocalVarScope * PushLocalScope()
TGParser(SourceMgr &SM, ArrayRef< std::string > Macros, RecordKeeper &records, const bool NoWarnOnUnusedTemplateArgs=false, const bool TrackReferenceLocs=false)
bool ParseFile()
ParseFile - Main entrypoint for parsing a tblgen file.
void PopLocalScope(TGLocalVarScope *ExpectedStackTop)
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)