13#ifndef LLVM_LIB_TABLEGEN_TGPARSER_H
14#define LLVM_LIB_TABLEGEN_TGPARSER_H
26struct SubClassReference;
27struct SubMultiClassReference;
31 std::vector<unsigned>
Bits;
41 std::unique_ptr<Record>
Rec;
42 std::unique_ptr<ForeachLoop>
Loop;
44 std::unique_ptr<Record::DumpInfo>
Dump;
97 std::unique_ptr<TGVarScope> Parent;
99 std::map<std::string, Init *, std::less<>> Vars;
113 CurMultiClass(Multiclass) {}
118 return std::move(Parent);
123 bool TrackReferenceLocs)
const;
130 return Vars.find(
Name) != Vars.end();
134 bool Ins = Vars.insert(std::make_pair(std::string(
Name),
I)).second;
136 assert(Ins &&
"Local variable already exists");
144 std::vector<SmallVector<LetRecord, 4>> LetStack;
145 std::map<std::string, std::unique_ptr<MultiClass>> MultiClasses;
146 std::map<std::string, RecTy *> TypeAliases;
150 std::vector<std::unique_ptr<ForeachLoop>> Loops;
159 std::unique_ptr<TGVarScope> CurScope;
175 bool NoWarnOnUnusedTemplateArgs =
false;
176 bool TrackReferenceLocs =
false;
180 const bool NoWarnOnUnusedTemplateArgs =
false,
181 const bool TrackReferenceLocs =
false)
182 : Lex(SM, Macros), CurMultiClass(nullptr), Records(records),
183 NoWarnOnUnusedTemplateArgs(NoWarnOnUnusedTemplateArgs),
184 TrackReferenceLocs(TrackReferenceLocs) {}
202 CurScope = std::make_unique<TGVarScope>(std::move(CurScope));
206 return CurScope.get();
209 CurScope = std::make_unique<TGVarScope>(std::move(CurScope), Rec);
210 return CurScope.get();
213 CurScope = std::make_unique<TGVarScope>(std::move(CurScope),
Loop);
214 return CurScope.get();
217 CurScope = std::make_unique<TGVarScope>(std::move(CurScope), Multiclass);
218 return CurScope.get();
221 assert(ExpectedStackTop == CurScope.get() &&
222 "Mismatched pushes and pops of local variable scopes");
223 CurScope = CurScope->extractParent();
233 bool AllowSelfAssignment =
false,
bool OverrideDefLoc =
true);
243 std::vector<RecordsEntry> *Dest,
SMLoc *Loc =
nullptr);
244 bool resolve(
const std::vector<RecordsEntry> &Source, SubstStack &Substs,
245 bool Final, std::vector<RecordsEntry> *Dest,
246 SMLoc *Loc =
nullptr);
247 bool addDefOne(std::unique_ptr<Record> Rec);
249 using ArgValueHandler = std::function<void(
Init *,
Init *)>;
250 bool resolveArguments(
252 ArgValueHandler ArgValueHandler = [](
Init *,
Init *) {});
253 bool resolveArgumentsOfClass(MapResolver &R, Record *Rec,
254 ArrayRef<ArgumentInit *> ArgValues, SMLoc Loc);
255 bool resolveArgumentsOfMultiClass(SubstStack &Substs, MultiClass *MC,
256 ArrayRef<ArgumentInit *> ArgValues,
257 Init *DefmName, SMLoc Loc);
261 bool ParseObjectList(MultiClass *MC =
nullptr);
262 bool ParseObject(MultiClass *MC);
264 bool ParseMultiClass();
265 bool ParseDefm(MultiClass *CurMultiClass);
266 bool ParseDef(MultiClass *CurMultiClass);
269 bool ParseDefvar(Record *CurRec =
nullptr);
270 bool ParseDump(MultiClass *CurMultiClass, Record *CurRec =
nullptr);
271 bool ParseForeach(MultiClass *CurMultiClass);
272 bool ParseIf(MultiClass *CurMultiClass);
273 bool ParseIfBody(MultiClass *CurMultiClass, StringRef Kind);
274 bool ParseAssert(MultiClass *CurMultiClass, Record *CurRec =
nullptr);
275 bool ParseTopLevelLet(MultiClass *CurMultiClass);
276 void ParseLetList(SmallVectorImpl<LetRecord> &Result);
278 bool ParseObjectBody(Record *CurRec);
279 bool ParseBody(Record *CurRec);
280 bool ParseBodyItem(Record *CurRec);
282 bool ParseTemplateArgList(Record *CurRec);
283 Init *ParseDeclaration(Record *CurRec,
bool ParsingTemplateArgs);
284 VarInit *ParseForeachDeclaration(Init *&ForeachListValue);
286 SubClassReference ParseSubClassReference(Record *CurRec,
bool isDefm);
287 SubMultiClassReference ParseSubMultiClassReference(MultiClass *CurMC);
289 Init *ParseIDValue(Record *CurRec, StringInit *
Name, SMRange NameLoc,
290 IDParseMode
Mode = ParseValueMode);
291 Init *ParseSimpleValue(Record *CurRec, RecTy *ItemType =
nullptr,
292 IDParseMode
Mode = ParseValueMode);
293 Init *ParseValue(Record *CurRec, RecTy *ItemType =
nullptr,
294 IDParseMode
Mode = ParseValueMode);
295 void ParseValueList(SmallVectorImpl<llvm::Init*> &Result,
296 Record *CurRec, RecTy *ItemType =
nullptr);
297 bool ParseTemplateArgValueList(SmallVectorImpl<llvm::ArgumentInit *> &Result,
298 Record *CurRec, Record *ArgsRec);
299 void ParseDagArgList(
300 SmallVectorImpl<std::pair<llvm::Init*, StringInit*>> &Result,
302 bool ParseOptionalRangeList(SmallVectorImpl<unsigned> &Ranges);
303 bool ParseOptionalBitList(SmallVectorImpl<unsigned> &Ranges);
304 TypedInit *ParseSliceElement(Record *CurRec);
305 TypedInit *ParseSliceElements(Record *CurRec,
bool Single =
false);
306 void ParseRangeList(SmallVectorImpl<unsigned> &Result);
307 bool ParseRangePiece(SmallVectorImpl<unsigned> &Ranges,
308 TypedInit *FirstItem =
nullptr);
310 Init *ParseOperation(Record *CurRec, RecTy *ItemType);
311 Init *ParseOperationSubstr(Record *CurRec, RecTy *ItemType);
312 Init *ParseOperationFind(Record *CurRec, RecTy *ItemType);
313 Init *ParseOperationForEachFilter(Record *CurRec, RecTy *ItemType);
314 Init *ParseOperationCond(Record *CurRec, RecTy *ItemType);
315 RecTy *ParseOperatorType();
316 Init *ParseObjectName(MultiClass *CurMultiClass);
317 Record *ParseClassID();
318 MultiClass *ParseMultiClassID();
319 bool ApplyLetStack(Record *CurRec);
320 bool ApplyLetStack(RecordsEntry &Entry);
321 bool CheckTemplateArgValues(SmallVectorImpl<llvm::ArgumentInit *> &Values,
322 SMLoc Loc, Record *ArgsRec);
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 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...
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.
Implement std::hash so that hash_code can be used in STL containers.
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< Record::DumpInfo > Dump)
RecordsEntry(std::unique_ptr< ForeachLoop > Loop)
std::unique_ptr< ForeachLoop > Loop
std::unique_ptr< Record::AssertionInfo > Assertion
std::unique_ptr< Record::DumpInfo > Dump
RecordsEntry(std::unique_ptr< Record > Rec)
std::unique_ptr< Record > Rec
RecordsEntry(std::unique_ptr< Record::AssertionInfo > Assertion)