14#ifndef LLVM_TABLEGEN_RECORD_H
15#define LLVM_TABLEGEN_RECORD_H
45struct RecordKeeperImpl;
80 mutable const ListRecTy *ListTy =
nullptr;
192 const RecTy *ElementTy;
248 void operator delete(
void *
Ptr) { ::operator
delete(
Ptr); }
338 virtual void anchor();
413 I.print(
OS);
return OS;
419 const RecTy *ValueTy;
478 const Init *
getBit(
unsigned Bit)
const override {
return this; }
522 return std::get<Positional>(Aux);
526 return std::get<Named>(Aux);
548 return Value->getCastTo(Ty);
551 return Value->convertInitializerTo(Ty);
579 assert(Bit < 1 &&
"Bit index out of range!");
602 void operator delete(
void *
Ptr) { ::operator
delete(
Ptr); }
732 return "\"" +
Value.str() +
"\"";
734 return "[{" +
Value.str() +
"}]";
750 unsigned NumElements;
763 void operator delete(
void *
Ptr) { ::operator
delete(
Ptr); }
782 return cast<ListRecTy>(
getType())->getElementType();
803 size_t size()
const {
return NumElements; }
804 bool empty()
const {
return NumElements == 0; }
874 const Init *
Fold(
const Record *CurRec,
bool IsFinal =
false)
const;
918 const Init *LHS, *RHS;
943 const Init *RHS)
const;
971 const Init *LHS, *MHS, *RHS;
1016 const RecTy *ValType;
1076 const Init *
getBit(
unsigned Bit)
const override;
1082 const Init *Start, *List, *A, *B, *Expr;
1109 const Init *
getBit(
unsigned Bit)
const override;
1142 const Init *
getBit(
unsigned Bit)
const override;
1170 const Init *
Fold(
const Record *CurRec,
bool IsFinal =
false)
const;
1176 const Init *
getBit(
unsigned Bit)
const override;
1205 const Init *
Fold(
const Record *CurRec,
bool IsFinal =
false)
const;
1211 const Init *
getBit(
unsigned Bit)
const override;
1218 const Init *VarName;
1248 const Init *
getBit(
unsigned Bit)
const override;
1262 (isa<IntRecTy>(
T->getType()) ||
1263 (isa<BitsRecTy>(
T->getType()) &&
1264 cast<BitsRecTy>(
T->getType())->getNumBits() >
B)) &&
1265 "Illegal VarBitInit expression!");
1285 assert(
B < 1 &&
"Bit index out of range!");
1342 void operator delete(
void *
Ptr) { ::operator
delete(
Ptr); }
1385 llvm::errs() <<
"In Record = " << Rec->getAsString()
1386 <<
", got FieldName = " << *FieldName
1387 <<
" with non-record type!\n";
1406 const Init *
getBit(
unsigned Bit)
const override;
1413 return Rec->getAsString() +
"." + FieldName->
getValue().
str();
1433 size_t numTrailingObjects(OverloadToken<const Init *>)
const {
1456 ArrayRef<std::pair<const Init *, const StringInit *>> ArgAndNames);
1460 ArrayRef<std::pair<const Init *, const StringInit *>> ArgAndNames) {
1493 return getTrailingObjects<const Init *>(NumArgs);
1497 return getTrailingObjects<const StringInit *>(NumArgs);
1503 using EltTy =
decltype(*
adl_begin(Zip));
1505 return std::make_pair(std::get<0>(
E), std::get<1>(
E));
1553 bool IsUsed =
false;
1671 mutable DefInit *CorrespondingDefInit =
nullptr;
1684 : Name(
N), Locs(locs), TrackedRecords(records),
1698 Values(O.Values), Assertions(O.Assertions),
1699 DirectSuperClasses(O.DirectSuperClasses),
1721 return ForwardDeclarationLocs;
1755 SC->getSuperClasses(Classes);
1756 Classes.push_back(SC);
1762 std::vector<const Record *> Classes;
1774 return DirectSuperClasses;
1783 if (Val.Name == Name)
return &Val;
1813 Values, [Name](
const RecordVal &V) {
return V.getNameInit() == Name; });
1814 if (It == Values.
end())
1832 Assertions.
append(Rec->Assertions);
1843 if (SC == R || SC->isSubClassOf(R))
1851 if (
const auto *SI = dyn_cast<StringInit>(SC->getNameInit())) {
1852 if (SI->getValue() == Name)
1854 }
else if (SC->getNameInitAsString() == Name) {
1857 if (SC->isSubClassOf(Name))
1864 assert(!CorrespondingDefInit &&
1865 "changing type of record after it has been referenced");
1885 return TrackedRecords;
1972raw_ostream &
operator<<(raw_ostream &
OS,
const Record &R);
1975 using RecordMap = std::map<std::string, std::unique_ptr<Record>, std::less<>>;
1976 using GlobalMap = std::map<std::string, const Init *, std::less<>>;
1999 auto I = Classes.find(
Name);
2000 return I == Classes.end() ? nullptr :
I->second.get();
2005 auto I = Defs.find(
Name);
2006 return I == Defs.end() ? nullptr :
I->second.get();
2012 return R->getDefInit();
2013 auto It = ExtraGlobals.find(
Name);
2014 return It == ExtraGlobals.end() ? nullptr : It->second;
2018 InputFilename = std::move(Filename);
2023 Classes.try_emplace(std::string(R->getName()), std::move(R)).second;
2025 assert(Ins &&
"Class already exists");
2029 bool Ins = Defs.try_emplace(std::string(R->getName()), std::move(R)).second;
2031 assert(Ins &&
"Record already exists");
2038 bool Ins = ExtraGlobals.try_emplace(std::string(
Name),
I).second;
2041 assert(Ins &&
"Global already exists");
2057 std::vector<const Record *>
2075 std::string InputFilename;
2076 RecordMap Classes, Defs;
2077 mutable std::map<std::string, std::vector<const Record *>> Cache;
2078 GlobalMap ExtraGlobals;
2081 std::unique_ptr<detail::RecordKeeperImpl> Impl;
2082 std::unique_ptr<TGTimer>
Timer;
2098 return LHS->getID() <
RHS->getID();
2118 const char *Start = Rec.
data();
2119 const char *Curr = Start;
2120 bool IsDigitPart =
isDigit(Curr[0]);
2121 for (
size_t I = 0,
E = Rec.
size();
I !=
E; ++
I, ++Len) {
2123 if (IsDigit != IsDigitPart) {
2140 int64_t LHSPositionOrder = Rec1->
getValueAsInt(
"PositionOrder");
2141 int64_t RHSPositionOrder = Rec2->
getValueAsInt(
"PositionOrder");
2142 if (LHSPositionOrder != RHSPositionOrder)
2143 return LHSPositionOrder < RHSPositionOrder;
2148 size_t LHSNumParts = LHSParts.
size();
2149 size_t RHSNumParts = RHSParts.
size();
2150 assert (LHSNumParts && RHSNumParts &&
"Expected at least one part!");
2152 if (LHSNumParts != RHSNumParts)
2153 return LHSNumParts < RHSNumParts;
2156 for (
size_t I = 0,
E = LHSNumParts;
I <
E;
I+=2) {
2157 std::pair<bool, StringRef> LHSPart = LHSParts.
getPart(
I);
2158 std::pair<bool, StringRef> RHSPart = RHSParts.
getPart(
I);
2160 assert (LHSPart.first ==
false && RHSPart.first ==
false &&
2161 "Expected both parts to be alpha.");
2162 if (
int Res = LHSPart.second.compare(RHSPart.second))
2165 for (
size_t I = 1,
E = LHSNumParts;
I <
E;
I+=2) {
2166 std::pair<bool, StringRef> LHSPart = LHSParts.
getPart(
I);
2167 std::pair<bool, StringRef> RHSPart = RHSParts.
getPart(
I);
2169 assert (LHSPart.first ==
true && RHSPart.first ==
true &&
2170 "Expected both parts to be numeric.");
2171 if (LHSPart.second.size() != RHSPart.second.size())
2172 return LHSPart.second.size() < RHSPart.second.size();
2174 unsigned LHSVal, RHSVal;
2176 bool LHSFailed = LHSPart.second.getAsInteger(10, LHSVal); (void)LHSFailed;
2177 assert(!LHSFailed &&
"Unable to convert LHS to integer.");
2178 bool RHSFailed = RHSPart.second.getAsInteger(10, RHSVal); (void)RHSFailed;
2179 assert(!RHSFailed &&
"Unable to convert RHS to integer.");
2181 if (LHSVal != RHSVal)
2182 return LHSVal < RHSVal;
2184 return LHSNumParts < RHSNumParts;
2188raw_ostream &
operator<<(raw_ostream &
OS,
const RecordKeeper &RK);
2198 bool IsFinal =
false;
2225 struct MappedValue {
2229 MappedValue() : V(
nullptr), Resolved(
false) {}
2230 MappedValue(
const Init *V,
bool Resolved) : V(V), Resolved(Resolved) {}
2241 auto It = Map.find(VarName);
2242 assert(It != Map.end() &&
"key must be present in map");
2243 return It->second.V->isComplete();
2253 const Init *Name =
nullptr;
2279 if (Shadowed.
count(VarName))
2281 return R.resolve(VarName);
2289 bool FoundUnresolved =
false;
2303 const Init *VarNameToTrack;
2308 :
Resolver(nullptr), VarNameToTrack(VarNameToTrack) {}
2316void EmitJSON(
const RecordKeeper &RK, raw_ostream &
OS);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
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")
#define LLVM_DEPRECATED(MSG, FIX)
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
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.
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
This file defines the PointerIntPair class.
static bool isDigit(const char C)
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
const Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
static AnonymousNameInit * get(RecordKeeper &RK, unsigned)
const StringInit * getNameInit() const
AnonymousNameInit(const AnonymousNameInit &)=delete
static bool classof(const Init *I)
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.
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?...
const Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
const ArgumentInit * cloneWithValue(const Init *Value) const
const Init * convertInitializerTo(const RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
bool isPositional() const
ArgumentInit(const ArgumentInit &)=delete
static const ArgumentInit * get(const Init *Value, ArgAuxType Aux)
const Init * getCastTo(const RecTy *Ty) const override
If this value is convertible to type Ty, return a value whose type is Ty, generating a !...
const Init * getName() const
ArgumentInit & operator=(const ArgumentInit &)=delete
ArgumentInit(const Init *Value, ArgAuxType Aux)
RecordKeeper & getRecordKeeper() const
const Init * getValue() const
bool isComplete() const override
Is this a complete value with no unset (uninitialized) subvalues?
unsigned getIndex() const
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.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
!op (X, Y) - Combine two inits.
static const BinOpInit * get(BinaryOp opc, const Init *lhs, const Init *rhs, const RecTy *Type)
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 const Init * getStrConcat(const Init *lhs, const Init *rhs)
std::string getAsString() const override
Convert this value to a literal form.
BinaryOp getOpcode() const
BinOpInit & operator=(const BinOpInit &)=delete
const Init * getRHS() const
std::optional< bool > CompareInit(unsigned Opc, const Init *LHS, const Init *RHS) const
const Init * getLHS() const
static bool classof(const Init *I)
static const Init * getListConcat(const TypedInit *lhs, const Init *rhs)
BinOpInit(const BinOpInit &)=delete
const Init * Fold(const Record *CurRec) const
'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
const Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
static bool classof(const Init *I)
const Init * convertInitializerTo(const 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?...
'bit' - Represent a single bit
static const 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.
std::string getAsString() const override
Convert this value to a literal form.
static bool classof(const Init *I)
bool isComplete() const override
Is this a complete value with no unset (uninitialized) subvalues?
unsigned getNumBits() const
std::optional< int64_t > convertInitializerToInt() const
BitsInit & operator=(const BitsInit &)=delete
const Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
const Init * convertInitializerBitRange(ArrayRef< unsigned > Bits) const override
This function is used to implement the bit range selection operator.
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...
const Init * convertInitializerTo(const RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
ArrayRef< const Init * > getBits() const
bool allInComplete() const
static BitsInit * get(RecordKeeper &RK, ArrayRef< const Init * > Range)
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
BitsInit(const BitsInit &)=delete
'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)
static const BitsRecTy * get(RecordKeeper &RK, unsigned Sz)
std::string getAsString() const override
!cond(condition_1: value1, ... , condition_n: value) Selects the first value for which condition is t...
CondOpInit & operator=(const CondOpInit &)=delete
SmallVectorImpl< const Init * >::const_iterator const_case_iterator
const Init * Fold(const Record *CurRec) const
SmallVectorImpl< const Init * >::const_iterator const_val_iterator
auto getCondAndVals() const
const_val_iterator name_end() const
const_case_iterator arg_end() const
ArrayRef< const Init * > getVals() const
CondOpInit(const CondOpInit &)=delete
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...
const Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
const Init * getCond(unsigned Num) const
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
const_val_iterator name_begin() const
std::string getAsString() const override
Convert this value to a literal form.
static const CondOpInit * get(ArrayRef< const Init * > Conds, ArrayRef< const Init * > Values, const RecTy *Type)
unsigned getNumConds() const
const RecTy * getValType() const
bool isComplete() const override
Is this a complete value with no unset (uninitialized) subvalues?
static bool classof(const Init *I)
const Init * getVal(unsigned Num) const
const_case_iterator arg_begin() const
ArrayRef< const Init * > getConds() const
(v a, b) - Represent a DAG tree value.
SmallVectorImpl< const StringInit * >::const_iterator const_name_iterator
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
static const DagInit * get(const Init *V, ArrayRef< std::pair< const Init *, const StringInit * > > ArgAndNames)
unsigned getNumArgs() const
const StringInit * getArgName(unsigned Num) 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...
DagInit(const DagInit &)=delete
StringRef getArgNameStr(unsigned Num) const
const_arg_iterator arg_begin() const
const_arg_iterator arg_end() const
const StringInit * getName() const
const Init * getOperator() const
SmallVectorImpl< const Init * >::const_iterator const_arg_iterator
static bool classof(const Init *I)
const Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
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 const DagInit * get(const Init *V, ArrayRef< const Init * > Args, ArrayRef< const StringInit * > ArgNames)
ArrayRef< const StringInit * > getArgNames() const
const_name_iterator name_end() const
static const DagInit * get(const Init *V, const StringInit *VN, ArrayRef< const Init * > Args, ArrayRef< const StringInit * > ArgNames)
const_name_iterator name_begin() const
const Record * getOperatorAsDef(ArrayRef< SMLoc > Loc) const
const Init * getArg(unsigned Num) const
StringRef getNameStr() const
DagInit & operator=(const DagInit &)=delete
auto getArgAndNames() const
ArrayRef< const Init * > getArgs() const
std::string getAsString() const override
Convert this value to a literal form.
'dag' - Represent a dag fragment
std::string getAsString() const override
static bool classof(const RecTy *RT)
static const DagRecTy * get(RecordKeeper &RK)
AL - Represent a reference to a 'def' in the description.
DefInit & operator=(const DefInit &)=delete
std::string getAsString() const override
Convert this value to a literal form.
const RecTy * getFieldType(const StringInit *FieldName) const override
This method is used to implement the FieldInit class.
const Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
const Init * convertInitializerTo(const RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
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?...
const Record * getDef() const
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)
ExistsOpInit(const ExistsOpInit &)=delete
bool isComplete() const override
Is this a complete value with no unset (uninitialized) subvalues?
static const ExistsOpInit * get(const RecTy *CheckType, const Init *Expr)
std::string getAsString() const override
Convert this value to a literal form.
ExistsOpInit & operator=(const ExistsOpInit &)=delete
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...
const Init * Fold(const Record *CurRec, bool IsFinal=false) const
const 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.
const Init * Fold(const Record *CurRec) const
const StringInit * getFieldName() const
const Init * getRecord() const
const Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
static const FieldInit * get(const Init *R, const StringInit *FN)
FieldInit & operator=(const FieldInit &)=delete
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...
FieldInit(const FieldInit &)=delete
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.
const Init * Fold(const Record *CurRec) const
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
static const FoldOpInit * get(const Init *Start, const Init *List, const Init *A, const Init *B, const Init *Expr, const RecTy *Type)
const Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
bool isComplete() const override
Is this a complete value with no unset (uninitialized) subvalues?
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...
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(const Init *VarNameToTrack)
const Init * resolve(const Init *VarName) override
Return the initializer for the given variable name (should normally be a StringInit),...
virtual const 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 const Init * convertInitializerBitRange(ArrayRef< unsigned > Bits) const
This function is used to implement the bit range selection operator.
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 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?
virtual const Init * getBit(unsigned Bit) const =0
Get the Init value of the specified bit.
virtual const RecTy * getFieldType(const StringInit *FieldName) const
This function is used to implement the FieldInit class.
Init(const Init &)=delete
virtual const Init * convertInitializerTo(const RecTy *Ty) const =0
Convert to a value whose type is Ty, or return null if this is not possible.
Init & operator=(const Init &)=delete
virtual const Init * getCastTo(const RecTy *Ty) const =0
If this value is convertible to type Ty, return a value whose type is Ty, generating a !...
RecordKeeper & getRecordKeeper() const
Get the record keeper that initialized this Init.
Init(InitKind K, uint8_t Opc=0)
!instances<type>([regex]) - Produces a list of records whose type is type.
const Init * Fold(const Record *CurRec, bool IsFinal=false) const
const Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
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)
InstancesOpInit(const InstancesOpInit &)=delete
bool isComplete() const override
Is this a complete value with no unset (uninitialized) subvalues?
static const InstancesOpInit * get(const RecTy *Type, const Init *Regex)
InstancesOpInit & operator=(const InstancesOpInit &)=delete
'7' - Represent an initialization by a literal integer value.
IntInit(const IntInit &)=delete
static IntInit * get(RecordKeeper &RK, int64_t V)
const Init * convertInitializerBitRange(ArrayRef< unsigned > Bits) const override
This function is used to implement the bit range selection operator.
const 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
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.
const Init * convertInitializerTo(const RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
'int' - Represent an integer value of no particular size
static const IntRecTy * get(RecordKeeper &RK)
bool typeIsConvertibleTo(const RecTy *RHS) const override
Return true if all values of 'this' type can be converted to the specified type.
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 const IsAOpInit * get(const RecTy *CheckType, const Init *Expr)
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?
std::string getAsString() const override
Convert this value to a literal form.
const Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
const Init * Fold() const
[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
const RecTy * getElementType() const
const Init *const * const_iterator
static const ListInit * get(ArrayRef< const Init * > Range, const RecTy *EltTy)
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
ListInit(const ListInit &)=delete
bool isComplete() const override
Is this a complete value with no unset (uninitialized) subvalues?
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...
const Init * convertInitializerTo(const RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
ArrayRef< const Init * > getValues() const
const Record * getElementAsRecord(unsigned Idx) const
const_iterator begin() const
const_iterator end() const
ArrayRef< const Init * > getElements() const
const Init * getElement(unsigned Idx) const
const Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
static bool classof(const Init *I)
'list<Ty>' - Represent a list of element values, all of which must be of the specified type.
const RecTy * getElementType() const
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.
static const ListRecTy * get(const RecTy *T)
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.
Resolve arbitrary mappings.
void set(const Init *Key, const Init *Value)
bool isComplete(Init *VarName) const
MapResolver(const Record *CurRec=nullptr)
const Init * resolve(const Init *VarName) override
Return the initializer for the given variable name (should normally be a StringInit),...
Base class for operators.
OpInit & operator=(OpInit &)=delete
static bool classof(const Init *I)
OpInit(const OpInit &)=delete
const Init * getBit(unsigned Bit) const final
Get the Init value of the specified bit.
OpInit(InitKind K, const RecTy *Type, uint8_t Opc)
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.
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
const ListRecTy * getListTy() const
Returns the type representing list<thistype>.
void print(raw_ostream &OS) const
void addDef(std::unique_ptr< Record > R)
void addClass(std::unique_ptr< Record > R)
TGTimer & getTimer() const
const Record * getClass(StringRef Name) const
Get the class with the specified name.
const RecordMap & getClasses() const
Get the map of classes.
const Init * getNewAnonymousName()
GetNewAnonymousName - Generate a unique anonymous name that can be used as an identifier.
const RecordMap & getDefs() const
Get the map of records (defs).
StringRef getInputFilename() const
Get the main TableGen input file's name.
detail::RecordKeeperImpl & getImpl()
Return the internal implementation of the RecordKeeper.
void saveInputFilename(std::string Filename)
const GlobalMap & getGlobals() const
Get the map of global variables.
const Init * getGlobal(StringRef Name) const
Get the Init value of the specified global variable.
void dumpAllocationStats(raw_ostream &OS) const
ArrayRef< const Record * > getAllDerivedDefinitionsIfDefined(StringRef ClassName) const
Get all the concrete records that inherit from specified class, if the class is defined.
void addExtraGlobal(StringRef Name, const Init *I)
const Record * getDef(StringRef Name) const
Get the concrete record with the specified name.
ArrayRef< const Record * > getAllDerivedDefinitions(StringRef ClassName) const
Get all the concrete records that inherit from the one specified class.
'[classname]' - Type of record values that have zero or more superclasses.
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
bool isSubClassOf(const Record *Class) const
const Record *const * const_record_iterator
ArrayRef< const Record * > getClasses() const
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)
static const RecordRecTy * get(RecordKeeper &RK, ArrayRef< const Record * > Classes)
Get the record type with the given non-redundant list of superclasses.
Resolve all variables from a record except for unset variables.
bool keepUnsetBits() const override
RecordResolver(const Record &R)
const Init * resolve(const Init *VarName) override
Return the initializer for the given variable name (should normally be a StringInit),...
void setName(const Init *NewName)
This class represents a field in a record, including its name, type, value, and source location.
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?
bool setValue(const Init *V)
Set the value of the field from an Init.
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.
const Init * getValue() const
Get the value of the field as an Init.
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.
const 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.
const RecTy * getType() const
Get the type of the field value as a RecTy.
std::vector< int64_t > getValueAsListOfInts(StringRef FieldName) const
This method looks up the specified field and returns its value as a vector of integers,...
const RecordRecTy * getType() const
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...
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 addDump(SMLoc Loc, const Init *Message)
void checkUnusedTemplateArgs()
ArrayRef< DumpInfo > getDumps() const
std::vector< const Record * > getValueAsListOfDefs(StringRef FieldName) const
This method looks up the specified field and returns its value as a vector of records,...
ArrayRef< AssertionInfo > getAssertions() const
std::string getNameInitAsString() const
void removeValue(StringRef 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 ...
RecordKeeper & getRecords() const
const DagInit * getValueAsDag(StringRef FieldName) const
This method looks up the specified field and returns its value as an Dag, throwing an exception if th...
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
void addTemplateArg(const Init *Name)
void appendLoc(SMLoc Loc)
bool isValueUnset(StringRef FieldName) const
Return true if the named field is unset.
std::vector< const Record * > getSuperClasses() const
Return all superclasses in post-order.
bool isMultiClass() const
bool hasDirectSuperClass(const Record *SuperClass) const
Determine whether this record has the specified direct superclass.
void addValue(const RecordVal &RV)
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...
void addAssertion(SMLoc Loc, const Init *Condition, const Init *Message)
Record(StringRef N, ArrayRef< SMLoc > locs, RecordKeeper &records, RecordKind Kind=RK_Def)
ArrayRef< std::pair< const Record *, SMRange > > getDirectSuperClasses() const
Return the direct superclasses of this record.
StringRef getName() const
Record(const Init *N, ArrayRef< SMLoc > locs, RecordKeeper &records, RecordKind Kind=RK_Def)
bool isTemplateArg(const Init *Name) const
void setName(const Init *Name)
bool isSubClassOf(StringRef Name) const
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 appendDumps(const Record *Rec)
bool isSubClassOf(const Record *R) const
DefInit * getDefInit() const
get the corresponding DefInit.
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
void resolveReferences(const Init *NewName=nullptr)
If there are any field references that refer to fields that have been filled in, we can propagate the...
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 ...
void removeValue(const Init *Name)
ArrayRef< const Init * > getTemplateArgs() const
ArrayRef< SMRange > getReferenceLocs() const
Return the references of this record value.
void updateClassLoc(SMLoc Loc)
RecordVal * getValue(const Init *Name)
const BitsInit * getValueAsBitsInit(StringRef FieldName) const
This method looks up the specified field and returns its value as a BitsInit, throwing an exception i...
void addDirectSuperClass(const Record *R, SMRange Range)
void appendAssertions(const Record *Rec)
const Init * getNameInit() const
void getSuperClasses(std::vector< const Record * > &Classes) const
Append all superclasses in post-order to Classes.
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...
RecordVal * getValue(StringRef Name)
void checkRecordAssertions()
void appendReferenceLoc(SMRange Loc) const
Add a reference to this record value.
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
Resolver(const Record *CurRec)
const Record * getCurrentRecord() const
void setFinal(bool Final)
virtual bool keepUnsetBits() const
virtual const Init * resolve(const Init *VarName)=0
Return the initializer for the given variable name (should normally be a StringInit),...
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)
const Init * resolve(const Init *VarName) override
Return the initializer for the given variable name (should normally be a StringInit),...
void addShadow(const Init *Key)
reference emplace_back(ArgTypes &&... Args)
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
static const StringInit * get(RecordKeeper &RK, StringRef, StringFormat Fmt=SF_String)
StringFormat getFormat() const
bool hasCodeFormat() const
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 bool classof(const Init *I)
std::string getAsUnquotedString() const override
Convert this value to a literal form, without adding quotes around a string.
const Init * convertInitializerTo(const RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
const Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
'string' - Represent an string value
static bool classof(const RecTy *RT)
std::string getAsString() const override
static const StringRecTy * get(RecordKeeper &RK)
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).
LLVM_ABI int compare_numeric(StringRef RHS) const
compare_numeric - Compare two strings, treating sequences of digits as numbers.
!op (X, Y, Z) - Combine two inits.
TernOpInit(const TernOpInit &)=delete
const Init * Fold(const Record *CurRec) const
const Init * getLHS() const
bool isComplete() const override
Is this a complete value with no unset (uninitialized) subvalues?
static bool classof(const Init *I)
const Init * getMHS() const
const Init * getRHS() const
static const TernOpInit * get(TernaryOp opc, const Init *lhs, const Init *mhs, const Init *rhs, const RecTy *Type)
std::string getAsString() const override
Convert this value to a literal form.
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...
TernOpInit & operator=(const TernOpInit &)=delete
TernaryOp getOpcode() const
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...
const Init * resolve(const Init *VarName) override
Return the initializer for the given variable name (should normally be a StringInit),...
bool foundUnresolved() const
TrackUnresolvedResolver(Resolver *R=nullptr)
See the file comment for details on the usage of the TrailingObjects type.
const T * getTrailingObjects() const
Returns a pointer to the trailing object array of the given type (which must be one of those specifie...
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.
const RecTy * getFieldType(const StringInit *FieldName) const override
This method is used to implement the FieldInit class.
static bool classof(const Init *I)
TypedInit(InitKind K, const RecTy *T, uint8_t Opc=0)
const Init * convertInitializerBitRange(ArrayRef< unsigned > Bits) const override
This function is used to implement the bit range selection operator.
RecordKeeper & getRecordKeeper() const
Get the record keeper that initialized this Init.
TypedInit(const TypedInit &)=delete
TypedInit & operator=(const TypedInit &)=delete
const Init * getCastTo(const RecTy *Ty) const override
If this value is convertible to type Ty, return a value whose type is Ty, generating a !...
const Init * convertInitializerTo(const RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
const RecTy * getType() const
Get the type of the Init as a RecTy.
!op (X) - Transform an init.
const Init * getOperand() const
UnOpInit & operator=(const UnOpInit &)=delete
static bool classof(const Init *I)
UnaryOp getOpcode() const
static const UnOpInit * get(UnaryOp opc, const Init *lhs, const RecTy *Type)
UnOpInit(const UnOpInit &)=delete
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.
const Init * Fold(const Record *CurRec, bool IsFinal=false) const
'?' - Represents an uninitialized value.
UnsetInit & operator=(const UnsetInit &)=delete
bool isComplete() const override
Is this a complete value with no unset (uninitialized) subvalues?
const Init * getCastTo(const RecTy *Ty) const override
If this value is convertible to type Ty, return a value whose type is Ty, generating a !...
UnsetInit(const UnsetInit &)=delete
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
const Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
const Init * convertInitializerTo(const RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
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.
LLVM Value Representation.
Opcode{0} - Represent access to one bit of a variable or field.
static const VarBitInit * get(const TypedInit *T, unsigned B)
unsigned getBitNum() const
VarBitInit(const VarBitInit &)=delete
std::string getAsString() const override
Convert this value to a literal form.
const Init * getBitVar() const
static bool classof(const Init *I)
const Init * getBit(unsigned B) const override
Get the Init value of the specified bit.
VarBitInit & operator=(const VarBitInit &)=delete
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...
classname<targs...> - Represent an uninstantiated anonymous class instantiation.
ArrayRef< const ArgumentInit * > args() const
const ArgumentInit * getArg(unsigned i) const
const_iterator args_end() const
static const VarDefInit * get(SMLoc Loc, const Record *Class, ArrayRef< const ArgumentInit * > Args)
const_iterator args_begin() const
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...
const Init * Fold() const
VarDefInit & operator=(const VarDefInit &)=delete
const Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
const ArgumentInit *const * const_iterator
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.
static const VarInit * get(StringRef VN, const RecTy *T)
VarInit & operator=(const VarInit &)=delete
static bool classof(const Init *I)
const Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
StringRef getName() const
std::string getAsString() const override
Convert this value to a literal form.
VarInit(const VarInit &)=delete
const Init * getNameInit() const
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...
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.
This is an optimization pass for GlobalISel generic memory operations.
detail::zippy< detail::zip_first, T, U, Args... > zip_equal(T &&t, U &&u, Args &&...args)
zip iterator that assumes that all iteratees have the same length.
constexpr auto adl_begin(RangeT &&range) -> decltype(adl_detail::begin_impl(std::forward< RangeT >(range)))
Returns the begin iterator to range using std::begin and function found through Argument-Dependent Lo...
auto map_range(ContainerTy &&C, FuncTy F)
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
auto make_first_range(ContainerTy &&c)
Given a container of pairs, return a range over the first elements.
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
void EmitJSON(const RecordKeeper &RK, raw_ostream &OS)
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
std::variant< unsigned, const Init * > ArgAuxType
void EmitDetailedRecords(const RecordKeeper &RK, raw_ostream &OS)
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
const RecTy * resolveTypes(const RecTy *T1, const RecTy *T2)
Find a common type that T1 and T2 convert to.
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
std::pair< bool, StringRef > getPart(size_t Idx)
SmallVector< std::pair< bool, StringRef >, 4 > Parts
RecordParts(StringRef Rec)
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, const Init *Condition, const Init *Message)
DumpInfo(SMLoc Loc, const Init *Message)
This class represents the internal implementation of the RecordKeeper.