14#ifndef LLVM_TABLEGEN_RECORD_H
15#define LLVM_TABLEGEN_RECORD_H
44struct RecordKeeperImpl;
244 void operator delete(
void *p) { ::operator
delete(p); }
257 return ArrayRef(getTrailingObjects<Record *>(), NumClasses);
332 virtual void anchor();
400 return const_cast<Init *
>(
this);
408 I.print(
OS);
return OS;
518 return std::get<Positional>(Aux);
522 return std::get<Named>(Aux);
543 return Value->convertInitializerTo(Ty);
570 assert(Bit < 1 &&
"Bit index out of range!");
571 return const_cast<BitInit*
>(
this);
592 void operator delete(
void *p) { ::operator
delete(p); }
625 assert(Bit < NumBits &&
"Bit index out of range!");
626 return getTrailingObjects<Init *>()[Bit];
730 return "\"" +
Value.str() +
"\"";
732 return "[{" +
Value.str() +
"}]";
736 return std::string(
Value);
762 void operator delete(
void *p) { ::operator
delete(p); }
772 assert(i < NumValues &&
"List element index out of range!");
773 return getTrailingObjects<Init *>()[i];
776 return cast<ListRecTy>(
getType())->getElementType();
795 return ArrayRef(getTrailingObjects<Init *>(), NumValues);
801 size_t size ()
const {
return NumValues; }
802 bool empty()
const {
return NumValues == 0; }
873 "Wrong number of operands for unary operation");
880 assert(i == 0 &&
"Invalid operand id for unary operator");
954 "Wrong number of operands for binary operation");
999 Init *LHS, *MHS, *RHS;
1022 "Wrong number of operands for ternary operation");
1065 NumConds(
NC), ValType(
Type) {}
1067 size_t numTrailingObjects(OverloadToken<Init *>)
const {
1089 assert(Num < NumConds &&
"Condition number out of range!");
1090 return getTrailingObjects<Init *>()[Num];
1094 assert(Num < NumConds &&
"Val number out of range!");
1095 return getTrailingObjects<Init *>()[Num+NumConds];
1099 return ArrayRef(getTrailingObjects<Init *>(), NumConds);
1103 return ArrayRef(getTrailingObjects<Init *>() + NumConds, NumConds);
1177 CheckType(CheckType), Expr(Expr) {}
1211 CheckType(CheckType), Expr(Expr) {}
1282 (isa<IntRecTy>(
T->getType()) ||
1283 (isa<BitsRecTy>(
T->getType()) &&
1284 cast<BitsRecTy>(
T->getType())->getNumBits() >
B)) &&
1285 "Illegal VarBitInit expression!");
1305 assert(
B < 1 &&
"Bit index out of range!");
1362 void operator delete(
void *p) { ::operator
delete(p); }
1377 assert(i < NumArgs &&
"Argument index out of range!");
1378 return getTrailingObjects<ArgumentInit *>()[i];
1384 return getTrailingObjects<ArgumentInit *>();
1410 <<
", got FieldName = " << *FieldName
1411 <<
" with non-record type!\n";
1451 unsigned NumArgNames;
1455 ValName(VN), NumArgs(NumArgs), NumArgNames(NumArgNames) {}
1457 size_t numTrailingObjects(OverloadToken<Init *>)
const {
return NumArgs; }
1470 ArrayRef<std::pair<Init*, StringInit*>> Args);
1486 assert(Num < NumArgs &&
"Arg number out of range!");
1487 return getTrailingObjects<Init *>()[Num];
1495 assert(Num < NumArgNames &&
"Arg number out of range!");
1496 return getTrailingObjects<StringInit *>()[Num];
1505 return ArrayRef(getTrailingObjects<Init *>(), NumArgs);
1509 return ArrayRef(getTrailingObjects<StringInit *>(), NumArgNames);
1558 bool IsUsed =
false;
1676 DefInit *CorrespondingDefInit =
nullptr;
1689 : Name(
N), Locs(locs), TrackedRecords(records),
1703 Values(O.Values), Assertions(O.Assertions),
1704 SuperClasses(O.SuperClasses), TrackedRecords(O.TrackedRecords),
1727 return ForwardDeclarationLocs;
1761 return SuperClasses;
1776 if (Val.Name == Name)
return &Val;
1803 for (
unsigned i = 0, e = Values.
size(); i != e; ++i)
1824 Assertions.
append(Rec->Assertions);
1834 for (
const auto &SCPair : SuperClasses)
1835 if (SCPair.first == R)
1841 for (
const auto &SCPair : SuperClasses) {
1842 if (
const auto *SI = dyn_cast<StringInit>(SCPair.first->getNameInit())) {
1843 if (SI->getValue() == Name)
1845 }
else if (SCPair.first->getNameInitAsString() == Name) {
1853 assert(!CorrespondingDefInit &&
1854 "changing type of record after it has been referenced");
1874 return TrackedRecords;
1961raw_ostream &
operator<<(raw_ostream &
OS,
const Record &R);
1964 using RecordMap = std::map<std::string, std::unique_ptr<Record>, std::less<>>;
1965 using GlobalMap = std::map<std::string, Init *, std::less<>>;
1988 auto I = Classes.find(
Name);
1989 return I == Classes.end() ? nullptr :
I->second.get();
1994 auto I = Defs.find(
Name);
1995 return I == Defs.end() ? nullptr :
I->second.get();
2001 return R->getDefInit();
2002 auto It = ExtraGlobals.find(
Name);
2003 return It == ExtraGlobals.end() ? nullptr : It->second;
2007 InputFilename = Filename;
2011 bool Ins = Classes.insert(std::make_pair(std::string(R->getName()),
2012 std::move(R))).second;
2014 assert(Ins &&
"Class already exists");
2018 bool Ins = Defs.insert(std::make_pair(std::string(R->getName()),
2019 std::move(R))).second;
2021 assert(Ins &&
"Record already exists");
2025 bool Ins = ExtraGlobals.insert(std::make_pair(std::string(
Name),
I)).second;
2028 assert(Ins &&
"Global already exists");
2035 TimingGroup =
new TimerGroup(
"TableGen",
"TableGen Phase Timing");
2071 std::vector<Record *>
2082 std::string InputFilename;
2083 RecordMap Classes, Defs;
2085 GlobalMap ExtraGlobals;
2091 Timer *LastTimer =
nullptr;
2092 bool BackendTimer =
false;
2095 std::unique_ptr<detail::RecordKeeperImpl> Impl;
2111 return LHS->getID() <
RHS->getID();
2131 const char *Start = Rec.
data();
2132 const char *Curr = Start;
2133 bool IsDigitPart =
isDigit(Curr[0]);
2134 for (
size_t I = 0,
E = Rec.
size();
I !=
E; ++
I, ++Len) {
2136 if (IsDigit != IsDigitPart) {
2137 Parts.push_back(std::make_pair(IsDigitPart,
StringRef(Start, Len)));
2144 Parts.push_back(std::make_pair(IsDigitPart,
StringRef(Start, Len)));
2156 int64_t LHSPositionOrder = Rec1->
getValueAsInt(
"PositionOrder");
2157 int64_t RHSPositionOrder = Rec2->
getValueAsInt(
"PositionOrder");
2158 if (LHSPositionOrder != RHSPositionOrder)
2159 return LHSPositionOrder < RHSPositionOrder;
2164 size_t LHSNumParts = LHSParts.
size();
2165 size_t RHSNumParts = RHSParts.
size();
2166 assert (LHSNumParts && RHSNumParts &&
"Expected at least one part!");
2168 if (LHSNumParts != RHSNumParts)
2169 return LHSNumParts < RHSNumParts;
2172 for (
size_t I = 0,
E = LHSNumParts;
I <
E;
I+=2) {
2173 std::pair<bool, StringRef> LHSPart = LHSParts.
getPart(
I);
2174 std::pair<bool, StringRef> RHSPart = RHSParts.
getPart(
I);
2176 assert (LHSPart.first ==
false && RHSPart.first ==
false &&
2177 "Expected both parts to be alpha.");
2178 if (
int Res = LHSPart.second.compare(RHSPart.second))
2181 for (
size_t I = 1,
E = LHSNumParts;
I <
E;
I+=2) {
2182 std::pair<bool, StringRef> LHSPart = LHSParts.
getPart(
I);
2183 std::pair<bool, StringRef> RHSPart = RHSParts.
getPart(
I);
2185 assert (LHSPart.first ==
true && RHSPart.first ==
true &&
2186 "Expected both parts to be numeric.");
2187 if (LHSPart.second.size() != RHSPart.second.size())
2188 return LHSPart.second.size() < RHSPart.second.size();
2190 unsigned LHSVal, RHSVal;
2192 bool LHSFailed = LHSPart.second.getAsInteger(10, LHSVal); (void)LHSFailed;
2193 assert(!LHSFailed &&
"Unable to convert LHS to integer.");
2194 bool RHSFailed = RHSPart.second.getAsInteger(10, RHSVal); (void)RHSFailed;
2195 assert(!RHSFailed &&
"Unable to convert RHS to integer.");
2197 if (LHSVal != RHSVal)
2198 return LHSVal < RHSVal;
2200 return LHSNumParts < RHSNumParts;
2204raw_ostream &
operator<<(raw_ostream &
OS,
const RecordKeeper &RK);
2214 bool IsFinal =
false;
2241 struct MappedValue {
2245 MappedValue() : V(
nullptr), Resolved(
false) {}
2246 MappedValue(
Init *V,
bool Resolved) : V(V), Resolved(Resolved) {}
2257 auto It = Map.find(VarName);
2258 assert(It != Map.end() &&
"key must be present in map");
2259 return It->second.V->isComplete();
2269 Init *Name =
nullptr;
2295 if (Shadowed.
count(VarName))
2297 return R.resolve(VarName);
2305 bool FoundUnresolved =
false;
2319 Init *VarNameToTrack;
2324 :
Resolver(nullptr), VarNameToTrack(VarNameToTrack) {}
2332void EmitJSON(RecordKeeper &RK, raw_ostream &
OS);
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
This file defines a hash set that can be used to remove duplication of nodes in a graph.
mir Rename Register Operands
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
This file defines the PointerIntPair class.
static bool isDigit(const char C)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
This header defines support for implementing classes that have some trailing object (or arrays of obj...
"anonymous_n" - Represent an anonymous record name
unsigned getValue() const
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
StringInit * getNameInit() const
static AnonymousNameInit * get(RecordKeeper &RK, unsigned)
AnonymousNameInit(const AnonymousNameInit &)=delete
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
static bool classof(const Init *I)
std::string getAsString() const override
Convert this value to a literal form.
AnonymousNameInit & operator=(const AnonymousNameInit &)=delete
static bool classof(const Init *I)
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
ArgumentInit * cloneWithValue(Init *Value) const
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
Init * getCastTo(RecTy *Ty) const override
If this value is convertible to type Ty, return a value whose type is Ty, generating a !...
ArgumentInit(Init *Value, ArgAuxType Aux)
Init * convertInitializerTo(RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
bool isPositional() const
static ArgumentInit * get(Init *Value, ArgAuxType Aux)
ArgumentInit(const ArgumentInit &)=delete
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
ArgumentInit & operator=(const ArgumentInit &)=delete
RecordKeeper & getRecordKeeper() const
bool isComplete() const override
Is this a complete value with no unset (uninitialized) subvalues?
unsigned getIndex() const
std::string getAsString() const override
Convert this value to a literal form.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
!op (X, Y) - Combine two inits.
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
OpInit * clone(ArrayRef< Init * > Operands) const override
std::optional< bool > CompareInit(unsigned Opc, Init *LHS, Init *RHS) const
std::string getAsString() const override
Convert this value to a literal form.
unsigned getNumOperands() const override
BinaryOp getOpcode() const
BinOpInit & operator=(const BinOpInit &)=delete
Init * getOperand(unsigned i) const override
Init * Fold(Record *CurRec) const
static Init * getStrConcat(Init *lhs, Init *rhs)
static bool classof(const Init *I)
static Init * getListConcat(TypedInit *lhs, Init *rhs)
static BinOpInit * get(BinaryOp opc, Init *lhs, Init *rhs, RecTy *Type)
BinOpInit(const BinOpInit &)=delete
'true'/'false' - Represent a concrete initializer for a bit.
BitInit(const BitInit &)=delete
static BitInit * get(RecordKeeper &RK, bool V)
std::string getAsString() const override
Convert this value to a literal form.
BitInit & operator=(BitInit &)=delete
Init * convertInitializerTo(RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
static bool classof(const Init *I)
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
'bit' - Represent a single bit
static BitRecTy * get(RecordKeeper &RK)
static bool classof(const RecTy *RT)
std::string getAsString() const override
bool typeIsConvertibleTo(const RecTy *RHS) const override
Return true if all values of 'this' type can be converted to the specified type.
'{ a, b, c }' - Represents an initializer for a BitsRecTy value.
bool isComplete() const override
Is this a complete value with no unset (uninitialized) subvalues?
bool allInComplete() const
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
std::string getAsString() const override
Convert this value to a literal form.
static bool classof(const Init *I)
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
unsigned getNumBits() const
Init * convertInitializerBitRange(ArrayRef< unsigned > Bits) const override
This function is used to implement the bit range selection operator.
BitsInit & operator=(const BitsInit &)=delete
Init * convertInitializerTo(RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
BitsInit(const BitsInit &)=delete
static BitsInit * get(RecordKeeper &RK, ArrayRef< Init * > Range)
'bits<n>' - Represent a fixed number of bits
bool typeIsConvertibleTo(const RecTy *RHS) const override
Return true if all values of 'this' type can be converted to the specified type.
unsigned getNumBits() const
static bool classof(const RecTy *RT)
std::string getAsString() const override
static BitsRecTy * get(RecordKeeper &RK, unsigned Sz)
!cond(condition_1: value1, ... , condition_n: value) Selects the first value for which condition is t...
CondOpInit & operator=(const CondOpInit &)=delete
Init * getCond(unsigned Num) const
const_val_iterator name_end() const
const_case_iterator arg_end() const
ArrayRef< Init * > getVals() const
static CondOpInit * get(ArrayRef< Init * > C, ArrayRef< Init * > V, RecTy *Type)
CondOpInit(const CondOpInit &)=delete
ArrayRef< Init * > getConds() const
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
SmallVectorImpl< Init * >::const_iterator const_case_iterator
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
const_val_iterator name_begin() const
SmallVectorImpl< Init * >::const_iterator const_val_iterator
std::string getAsString() const override
Convert this value to a literal form.
Init * Fold(Record *CurRec) const
unsigned getNumConds() const
RecTy * getValType() const
Init * getVal(unsigned Num) const
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
bool isComplete() const override
Is this a complete value with no unset (uninitialized) subvalues?
static bool classof(const Init *I)
const_case_iterator arg_begin() const
(v a, b) - Represent a DAG tree value.
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
unsigned getNumArgs() const
std::optional< unsigned > getArgNo(StringRef Name) const
This method looks up the specified argument name and returns its argument number or std::nullopt if t...
StringInit * getName() const
Init * getOperator() const
DagInit(const DagInit &)=delete
StringInit * getArgName(unsigned Num) const
StringRef getArgNameStr(unsigned Num) const
Record * getOperatorAsDef(ArrayRef< SMLoc > Loc) const
const_arg_iterator arg_begin() const
const_arg_iterator arg_end() const
ArrayRef< StringInit * > getArgNames() const
static DagInit * get(Init *V, StringInit *VN, ArrayRef< Init * > ArgRange, ArrayRef< StringInit * > NameRange)
Init * getArg(unsigned Num) const
static bool classof(const Init *I)
SmallVectorImpl< StringInit * >::const_iterator const_name_iterator
const_name_iterator name_end() const
ArrayRef< Init * > getArgs() const
const_name_iterator name_begin() const
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
StringRef getNameStr() const
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
DagInit & operator=(const DagInit &)=delete
SmallVectorImpl< Init * >::const_iterator const_arg_iterator
std::string getAsString() const override
Convert this value to a literal form.
'dag' - Represent a dag fragment
std::string getAsString() const override
static DagRecTy * get(RecordKeeper &RK)
static bool classof(const RecTy *RT)
AL - Represent a reference to a 'def' in the description.
Init * convertInitializerTo(RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
DefInit & operator=(const DefInit &)=delete
std::string getAsString() const override
Convert this value to a literal form.
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
RecTy * getFieldType(StringInit *FieldName) const override
This method is used to implement the FieldInit class.
DefInit(const DefInit &)=delete
static bool classof(const Init *I)
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
static DefInit * get(Record *)
Implements a dense probed hash-table based set.
!exists<type>(expr) - Dynamically determine if a record of type named expr exists.
static bool classof(const Init *I)
Init * Fold(Record *CurRec, bool IsFinal=false) const
ExistsOpInit(const ExistsOpInit &)=delete
bool isComplete() const override
Is this a complete value with no unset (uninitialized) subvalues?
static ExistsOpInit * get(RecTy *CheckType, Init *Expr)
std::string getAsString() const override
Convert this value to a literal form.
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
ExistsOpInit & operator=(const ExistsOpInit &)=delete
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
X.Y - Represent a reference to a subfield of a variable.
static bool classof(const Init *I)
std::string getAsString() const override
Convert this value to a literal form.
StringInit * getFieldName() const
Init * Fold(Record *CurRec) const
static FieldInit * get(Init *R, StringInit *FN)
FieldInit & operator=(const FieldInit &)=delete
FieldInit(const FieldInit &)=delete
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
!foldl (a, b, expr, start, lst) - Fold over a list.
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
static bool classof(const Init *I)
FoldOpInit & operator=(const FoldOpInit &)=delete
std::string getAsString() const override
Convert this value to a literal form.
FoldOpInit(const FoldOpInit &)=delete
Init * Fold(Record *CurRec) const
bool isComplete() const override
Is this a complete value with no unset (uninitialized) subvalues?
static FoldOpInit * get(Init *Start, Init *List, Init *A, Init *B, Init *Expr, RecTy *Type)
Node - This class is used to maintain the singly linked bucket list in a folding set.
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
Do not resolve anything, but keep track of whether a given variable was referenced.
HasReferenceResolver(Init *VarNameToTrack)
Init * resolve(Init *VarName) override
Return the initializer for the given variable name (should normally be a StringInit),...
virtual Init * getBit(unsigned Bit) const =0
Get the Init value of the specified bit.
virtual Init * resolveReferences(Resolver &R) const
This function is used by classes that refer to other variables which may not be defined at the time t...
virtual std::string getAsUnquotedString() const
Convert this value to a literal form, without adding quotes around a string.
void dump() const
Debugging method that may be called through a debugger; just invokes print on stderr.
void print(raw_ostream &OS) const
Print this value.
virtual std::string getAsString() const =0
Convert this value to a literal form.
InitKind
Discriminator enum (for isa<>, dyn_cast<>, et al.)
InitKind getKind() const
Get the kind (type) of the value.
virtual Init * convertInitializerBitRange(ArrayRef< unsigned > Bits) const
This function is used to implement the bit range selection operator.
virtual bool isConcrete() const
Is this a concrete and fully resolved value without any references or stuck operations?...
virtual bool isComplete() const
Is this a complete value with no unset (uninitialized) subvalues?
Init(const Init &)=delete
virtual Init * getCastTo(RecTy *Ty) const =0
If this value is convertible to type Ty, return a value whose type is Ty, generating a !...
Init & operator=(const Init &)=delete
RecordKeeper & getRecordKeeper() const
Get the record keeper that initialized this Init.
virtual RecTy * getFieldType(StringInit *FieldName) const
This function is used to implement the FieldInit class.
virtual Init * convertInitializerTo(RecTy *Ty) const =0
Convert to a value whose type is Ty, or return null if this is not possible.
Init(InitKind K, uint8_t Opc=0)
'7' - Represent an initialization by a literal integer value.
Init * convertInitializerBitRange(ArrayRef< unsigned > Bits) const override
This function is used to implement the bit range selection operator.
IntInit(const IntInit &)=delete
static IntInit * get(RecordKeeper &RK, int64_t V)
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
static bool classof(const Init *I)
IntInit & operator=(const IntInit &)=delete
Init * convertInitializerTo(RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
std::string getAsString() const override
Convert this value to a literal form.
'int' - Represent an integer value of no particular size
bool typeIsConvertibleTo(const RecTy *RHS) const override
Return true if all values of 'this' type can be converted to the specified type.
static IntRecTy * get(RecordKeeper &RK)
std::string getAsString() const override
static bool classof(const RecTy *RT)
!isa<type>(expr) - Dynamically determine the type of an expression.
IsAOpInit(const IsAOpInit &)=delete
IsAOpInit & operator=(const IsAOpInit &)=delete
static bool classof(const Init *I)
static IsAOpInit * get(RecTy *CheckType, Init *Expr)
bool isComplete() const override
Is this a complete value with no unset (uninitialized) subvalues?
std::string getAsString() const override
Convert this value to a literal form.
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
[AL, AH, CL] - Represent a list of defs
std::string getAsString() const override
Convert this value to a literal form.
ListInit & operator=(const ListInit &)=delete
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
static ListInit * get(ArrayRef< Init * > Range, RecTy *EltTy)
RecTy * getElementType() const
ListInit(const ListInit &)=delete
Init * getElement(unsigned i) const
bool isComplete() const override
Is this a complete value with no unset (uninitialized) subvalues?
Init *const * const_iterator
Init * convertInitializerTo(RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
ArrayRef< Init * > getValues() const
Record * getElementAsRecord(unsigned i) const
const_iterator begin() const
const_iterator end() const
Init * resolveReferences(Resolver &R) const override
This method is used by classes that refer to other variables which may not be defined at the time the...
static bool classof(const Init *I)
'list<Ty>' - Represent a list of element values, all of which must be of the specified type.
static bool classof(const RecTy *RT)
bool typeIsA(const RecTy *RHS) const override
Return true if 'this' type is equal to or a subtype of RHS.
std::string getAsString() const override
bool typeIsConvertibleTo(const RecTy *RHS) const override
Return true if all values of 'this' type can be converted to the specified type.
RecTy * getElementType() const
static ListRecTy * get(RecTy *T)
Resolve arbitrary mappings.
void set(Init *Key, Init *Value)
MapResolver(Record *CurRec=nullptr)
bool isComplete(Init *VarName) const
Init * resolve(Init *VarName) override
Return the initializer for the given variable name (should normally be a StringInit),...
Base class for operators.
virtual Init * getOperand(unsigned i) const =0
virtual unsigned getNumOperands() const =0
OpInit & operator=(OpInit &)=delete
static bool classof(const Init *I)
OpInit(const OpInit &)=delete
virtual OpInit * clone(ArrayRef< Init * > Operands) const =0
OpInit(InitKind K, RecTy *Type, uint8_t Opc)
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
PointerIntPair - This class implements a pair of a pointer and small integer.
PointerTy getPointer() const
RecordKeeper & getRecordKeeper() const
Return the RecordKeeper that uniqued this Type.
ListRecTy * getListTy()
Returns the type representing list<thistype>.
virtual bool typeIsA(const RecTy *RHS) const
Return true if 'this' type is equal to or a subtype of RHS.
virtual bool typeIsConvertibleTo(const RecTy *RHS) const
Return true if all values of 'this' type can be converted to the specified type.
RecTyKind
Subclass discriminator (for dyn_cast<> et al.)
RecTy(RecTyKind K, RecordKeeper &RK)
virtual std::string getAsString() const =0
RecTyKind getRecTyKind() const
void print(raw_ostream &OS) const
void addDef(std::unique_ptr< Record > R)
void addClass(std::unique_ptr< Record > R)
std::vector< Record * > getAllDerivedDefinitions(StringRef ClassName) const
Get all the concrete records that inherit from the one specified class.
Record * getDef(StringRef Name) const
Get the concrete record with the specified name.
const RecordMap & getClasses() const
Get the map of classes.
Record * getClass(StringRef Name) const
Get the class with the specified name.
void stopPhaseTiming()
Stop phase timing and print the report.
std::vector< Record * > getAllDerivedDefinitionsIfDefined(StringRef ClassName) const
Get all the concrete records that inherit from specified class, if the class is defined.
const RecordMap & getDefs() const
Get the map of records (defs).
detail::RecordKeeperImpl & getImpl()
Return the internal implementation of the RecordKeeper.
void stopBackendTimer()
Stop timing the overall backend.
void saveInputFilename(std::string Filename)
void startPhaseTiming()
Start phase timing; called if the –time-phases option is specified.
const GlobalMap & getGlobals() const
Get the map of global variables.
void stopTimer()
Stop timing a phase.
void startTimer(StringRef Name)
Start timing a phase. Automatically stops any previous phase timer.
void addExtraGlobal(StringRef Name, Init *I)
Init * getNewAnonymousName()
GetNewAnonymousName - Generate a unique anonymous name that can be used as an identifier.
Init * getGlobal(StringRef Name) const
Get the Init value of the specified global variable.
const std::string getInputFilename() const
Get the main TableGen input file's name.
void startBackendTimer(StringRef Name)
Start timing the overall backend.
'[classname]' - Type of record values that have zero or more superclasses.
Record *const * const_record_iterator
bool typeIsConvertibleTo(const RecTy *RHS) const override
Return true if all values of 'this' type can be converted to the specified type.
RecordRecTy & operator=(const RecordRecTy &)=delete
static RecordRecTy * get(RecordKeeper &RK, ArrayRef< Record * > Classes)
Get the record type with the given non-redundant list of superclasses.
const_record_iterator classes_begin() const
const_record_iterator classes_end() const
std::string getAsString() const override
RecordRecTy(const RecordRecTy &)=delete
bool typeIsA(const RecTy *RHS) const override
Return true if 'this' type is equal to or a subtype of RHS.
static bool classof(const RecTy *RT)
bool isSubClassOf(Record *Class) const
ArrayRef< Record * > getClasses() const
Resolve all variables from a record except for unset variables.
void setName(Init *NewName)
bool keepUnsetBits() const override
Init * resolve(Init *VarName) override
Return the initializer for the given variable name (should normally be a StringInit),...
RecordResolver(Record &R)
This class represents a field in a record, including its name, type, value, and source location.
bool setValue(Init *V)
Set the value of the field from an Init.
bool isTemplateArg() const
Is this a template argument?
std::string getNameInitAsString() const
Get the name of the field as a std::string.
void setUsed(bool Used)
Whether this value is used.
bool isNonconcreteOK() const
Is this a field where nonconcrete values are okay?
RecordKeeper & getRecordKeeper() const
Get the record keeper used to unique this value.
const SMLoc & getLoc() const
Get the source location of the point where the field was defined.
StringRef getName() const
Get the name of the field as a StringRef.
void addReferenceLoc(SMRange Loc)
Add a reference to this record value.
void print(raw_ostream &OS, bool PrintSem=true) const
Print the value to an output stream, possibly with a semicolon.
RecTy * getType() const
Get the type of the field value as a RecTy.
Init * getNameInit() const
Get the name of the field as an Init.
ArrayRef< SMRange > getReferenceLocs() const
Return the references of this record value.
std::string getPrintType() const
Get the type of the field for printing purposes.
Init * getValue() const
Get the value of the field as an Init.
std::vector< int64_t > getValueAsListOfInts(StringRef FieldName) const
This method looks up the specified field and returns its value as a vector of integers,...
void addAssertion(SMLoc Loc, Init *Condition, Init *Message)
void addDump(SMLoc Loc, Init *Message)
bool getValueAsBitOrUnset(StringRef FieldName, bool &Unset) const
This method looks up the specified field and returns its value as a bit.
bool getValueAsBit(StringRef FieldName) const
This method looks up the specified field and returns its value as a bit, throwing an exception if the...
static unsigned getNewUID(RecordKeeper &RK)
ArrayRef< SMLoc > getLoc() const
void appendReferenceLoc(SMRange Loc)
Add a reference to this record value.
void checkUnusedTemplateArgs()
Record(Init *N, ArrayRef< SMLoc > locs, RecordKeeper &records, RecordKind Kind=RK_Def)
ArrayRef< DumpInfo > getDumps() const
Record * getValueAsOptionalDef(StringRef FieldName) const
This method looks up the specified field and returns its value as a Record, returning null if the fie...
ArrayRef< AssertionInfo > getAssertions() const
std::string getNameInitAsString() const
Init * getNameInit() const
ListInit * getValueAsListInit(StringRef FieldName) const
This method looks up the specified field and returns its value as a ListInit, throwing an exception i...
void removeValue(StringRef Name)
void getDirectSuperClasses(SmallVectorImpl< Record * > &Classes) const
Append the direct superclasses of this record to Classes.
RecordKeeper & getRecords() const
BitsInit * getValueAsBitsInit(StringRef FieldName) const
This method looks up the specified field and returns its value as a BitsInit, throwing an exception i...
std::vector< StringRef > getValueAsListOfStrings(StringRef FieldName) const
This method looks up the specified field and returns its value as a vector of strings,...
const RecordVal * getValue(const Init *Name) const
Record * getValueAsDef(StringRef FieldName) const
This method looks up the specified field and returns its value as a Record, throwing an exception if ...
void appendLoc(SMLoc Loc)
bool isValueUnset(StringRef FieldName) const
Return true if the named field is unset.
bool isMultiClass() const
void addValue(const RecordVal &RV)
DagInit * getValueAsDag(StringRef FieldName) const
This method looks up the specified field and returns its value as an Dag, throwing an exception if th...
bool hasDirectSuperClass(const Record *SuperClass) const
Determine whether this record has the specified direct superclass.
Record(StringRef N, ArrayRef< SMLoc > locs, RecordKeeper &records, RecordKind Kind=RK_Def)
StringRef getName() const
bool isSubClassOf(StringRef Name) const
void appendDumps(const Record *Rec)
void addTemplateArg(Init *Name)
ArrayRef< Init * > getTemplateArgs() const
bool isSubClassOf(const Record *R) const
Init * getValueInit(StringRef FieldName) const
Return the initializer for a value with the specified name, or throw an exception if the field does n...
ArrayRef< RecordVal > getValues() const
SMLoc getFieldLoc(StringRef FieldName) const
Return the source location for the named field.
ArrayRef< SMLoc > getForwardDeclarationLocs() const
const RecordVal * getValue(StringRef Name) const
std::vector< Record * > getValueAsListOfDefs(StringRef FieldName) const
This method looks up the specified field and returns its value as a vector of records,...
void addSuperClass(Record *R, SMRange Range)
bool isTemplateArg(Init *Name) const
std::optional< StringRef > getValueAsOptionalString(StringRef FieldName) const
This method looks up the specified field and returns its value as a string, throwing an exception if ...
DefInit * getDefInit()
get the corresponding DefInit.
ArrayRef< SMRange > getReferenceLocs() const
Return the references of this record value.
void updateClassLoc(SMLoc Loc)
RecordVal * getValue(const Init *Name)
void resolveReferences(Init *NewName=nullptr)
If there are any field references that refer to fields that have been filled in, we can propagate the...
void appendAssertions(const Record *Rec)
ArrayRef< std::pair< Record *, SMRange > > getSuperClasses() const
int64_t getValueAsInt(StringRef FieldName) const
This method looks up the specified field and returns its value as an int64_t, throwing an exception i...
void removeValue(Init *Name)
RecordVal * getValue(StringRef Name)
void checkRecordAssertions()
StringRef getValueAsString(StringRef FieldName) const
This method looks up the specified field and returns its value as a string, throwing an exception if ...
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
virtual ~Resolver()=default
Record * getCurrentRecord() const
void setFinal(bool Final)
virtual Init * resolve(Init *VarName)=0
Return the initializer for the given variable name (should normally be a StringInit),...
virtual bool keepUnsetBits() const
Represents a location in source code.
Represents a range in source code.
Delegate resolving to a sub-resolver, but shadow some variable names.
ShadowResolver(Resolver &R)
void addShadow(Init *Key)
Init * resolve(Init *VarName) override
Return the initializer for the given variable name (should normally be a StringInit),...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
iterator erase(const_iterator CI)
typename SuperClass::const_iterator const_iterator
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
"foo" - Represent an initialization by a string value.
StringInit(const StringInit &)=delete
std::string getAsString() const override
Convert this value to a literal form.
StringInit & operator=(const StringInit &)=delete
StringFormat getFormat() const
bool hasCodeFormat() const
Init * convertInitializerTo(RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
StringRef getValue() const
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
static StringFormat determineFormat(StringFormat Fmt1, StringFormat Fmt2)
static StringInit * get(RecordKeeper &RK, StringRef, StringFormat Fmt=SF_String)
static bool classof(const Init *I)
std::string getAsUnquotedString() const override
Convert this value to a literal form, without adding quotes around a string.
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
'string' - Represent an string value
static bool classof(const RecTy *RT)
static StringRecTy * get(RecordKeeper &RK)
std::string getAsString() const override
bool typeIsConvertibleTo(const RecTy *RHS) const override
Return true if all values of 'this' type can be converted to the specified type.
StringRef - Represent a constant reference to a string, i.e.
std::string str() const
str - Get the contents as an std::string.
constexpr bool empty() const
empty - Check if the string is empty.
constexpr size_t size() const
size - Get the string size.
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
int compare_numeric(StringRef RHS) const
compare_numeric - Compare two strings, treating sequences of digits as numbers.
!op (X, Y, Z) - Combine two inits.
OpInit * clone(ArrayRef< Init * > Operands) const override
TernOpInit(const TernOpInit &)=delete
bool isComplete() const override
Is this a complete value with no unset (uninitialized) subvalues?
Init * Fold(Record *CurRec) const
unsigned getNumOperands() const override
static bool classof(const Init *I)
Init * getOperand(unsigned i) const override
std::string getAsString() const override
Convert this value to a literal form.
TernOpInit & operator=(const TernOpInit &)=delete
TernaryOp getOpcode() const
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
static TernOpInit * get(TernaryOp opc, Init *lhs, Init *mhs, Init *rhs, RecTy *Type)
The TimerGroup class is used to group together related timers into a single report that is printed wh...
This class is used to track the amount of time spent between invocations of its startTimer()/stopTime...
(Optionally) delegate resolving to a sub-resolver, and keep track whether there were unresolved refer...
bool foundUnresolved() const
TrackUnresolvedResolver(Resolver *R=nullptr)
Init * resolve(Init *VarName) override
Return the initializer for the given variable name (should normally be a StringInit),...
See the file comment for details on the usage of the TrailingObjects type.
The instances of the Type class are immutable: once they are created, they are never changed.
This is the common superclass of types that have a specific, explicit type, stored in ValueTy.
static bool classof(const Init *I)
TypedInit(InitKind K, RecTy *T, uint8_t Opc=0)
Init * getCastTo(RecTy *Ty) const override
If this value is convertible to type Ty, return a value whose type is Ty, generating a !...
RecTy * getFieldType(StringInit *FieldName) const override
This method is used to implement the FieldInit class.
RecordKeeper & getRecordKeeper() const
Get the record keeper that initialized this Init.
TypedInit(const TypedInit &)=delete
Init * convertInitializerTo(RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
TypedInit & operator=(const TypedInit &)=delete
RecTy * getType() const
Get the type of the Init as a RecTy.
Init * convertInitializerBitRange(ArrayRef< unsigned > Bits) const override
This function is used to implement the bit range selection operator.
!op (X) - Transform an init.
Init * getOperand() const
UnOpInit & operator=(const UnOpInit &)=delete
Init * Fold(Record *CurRec, bool IsFinal=false) const
static bool classof(const Init *I)
UnaryOp getOpcode() const
OpInit * clone(ArrayRef< Init * > Operands) const override
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
unsigned getNumOperands() const override
UnOpInit(const UnOpInit &)=delete
static UnOpInit * get(UnaryOp opc, Init *lhs, RecTy *Type)
Init * getOperand(unsigned i) const override
std::string getAsString() const override
Convert this value to a literal form.
'?' - Represents an uninitialized value.
UnsetInit & operator=(const UnsetInit &)=delete
bool isComplete() const override
Is this a complete value with no unset (uninitialized) subvalues?
Init * getCastTo(RecTy *Ty) const override
If this value is convertible to type Ty, return a value whose type is Ty, generating a !...
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
UnsetInit(const UnsetInit &)=delete
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
static UnsetInit * get(RecordKeeper &RK)
Get the singleton unset Init.
static bool classof(const Init *I)
std::string getAsString() const override
Get the string representation of the Init.
RecordKeeper & getRecordKeeper() const
Get the record keeper that initialized this Init.
Init * convertInitializerTo(RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
LLVM Value Representation.
Opcode{0} - Represent access to one bit of a variable or field.
unsigned getBitNum() const
VarBitInit(const VarBitInit &)=delete
std::string getAsString() const override
Convert this value to a literal form.
Init * getBit(unsigned B) const override
Get the Init value of the specified bit.
static bool classof(const Init *I)
static VarBitInit * get(TypedInit *T, unsigned B)
VarBitInit & operator=(const VarBitInit &)=delete
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
classname<targs...> - Represent an uninstantiated anonymous class instantiation.
static VarDefInit * get(Record *Class, ArrayRef< ArgumentInit * > Args)
ArgumentInit * getArg(unsigned i) const
ArrayRef< ArgumentInit * > args() const
ArgumentInit *const * const_iterator
const_iterator args_end() const
const_iterator args_begin() const
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
VarDefInit & operator=(const VarDefInit &)=delete
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
static bool classof(const Init *I)
VarDefInit(const VarDefInit &)=delete
std::string getAsString() const override
Convert this value to a literal form.
'Opcode' - Represent a reference to an entire variable object.
VarInit & operator=(const VarInit &)=delete
static bool classof(const Init *I)
Init * resolveReferences(Resolver &R) const override
This method is used by classes that refer to other variables which may not be defined at the time the...
Init * getNameInit() const
StringRef getName() const
std::string getAsString() const override
Convert this value to a literal form.
VarInit(const VarInit &)=delete
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
static VarInit * get(StringRef VN, RecTy *T)
std::string getNameInitAsString() const
std::pair< iterator, bool > insert(const ValueT &V)
size_type count(const_arg_type_t< ValueT > V) const
Return 1 if the specified key is in the set, 0 otherwise.
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
std::variant< unsigned, Init * > ArgAuxType
RecTy * resolveTypes(RecTy *T1, RecTy *T2)
Find a common type that T1 and T2 convert to.
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
void EmitJSON(RecordKeeper &RK, raw_ostream &OS)
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
void EmitDetailedRecords(RecordKeeper &RK, raw_ostream &OS)
Sorting predicate to sort record pointers by their unique ID.
bool operator()(const Record *LHS, const Record *RHS) const
Sorting predicate to sort record pointers by their Name field.
bool operator()(const Record *Rec1, const Record *Rec2) const
SmallVector< std::pair< bool, StringRef >, 4 > Parts
RecordParts(StringRef Rec)
std::pair< bool, StringRef > getPart(size_t i)
bool operator()(const Record *Rec1, const Record *Rec2) const
Sorting predicate to sort record pointers by name.
bool operator()(const Record *Rec1, const Record *Rec2) const
AssertionInfo(SMLoc Loc, Init *Condition, Init *Message)
DumpInfo(SMLoc Loc, Init *Message)
This class represents the internal implementation of the RecordKeeper.