14#ifndef LLVM_TABLEGEN_RECORD_H
15#define LLVM_TABLEGEN_RECORD_H
80 mutable const ListRecTy *ListTy =
nullptr;
192 const RecTy *ElementTy;
194 explicit ListRecTy(
const RecTy *
T)
202 static const ListRecTy *
get(
const RecTy *
T) {
return T->getListTy(); }
232class RecordRecTy final :
public RecTy,
234 private TrailingObjects<RecordRecTy, const Record *> {
235 friend TrailingObjects;
248 void operator delete(
void *
Ptr) { ::operator
delete(
Ptr); }
338 virtual void anchor();
413 I.print(OS);
return OS;
419 const RecTy *ValueTy;
453class UnsetInit final :
public Init {
478 const Init *
getBit(
unsigned Bit)
const override {
return this; }
522 return std::get<Positional>(Aux);
526 return std::get<Named>(Aux);
529 return get(Value, Aux);
561 explicit BitInit(
bool V,
const RecTy *
T)
579 assert(Bit < 1 &&
"Bit index out of range!");
584 std::string
getAsString()
const override {
return Value ?
"1" :
"0"; }
591 private TrailingObjects<BitsInit, const Init *> {
592 friend TrailingObjects;
602 void operator delete(
void *
Ptr) { ::operator
delete(
Ptr); }
669 explicit AnonymousNameInit(
RecordKeeper &RK,
unsigned V)
674 AnonymousNameInit &
operator=(
const AnonymousNameInit &) =
delete;
735 return "\"" + Value.str() +
"\"";
737 return "[{" + Value.str() +
"}]";
751 private TrailingObjects<ListInit, const Init *> {
752 friend TrailingObjects;
753 unsigned NumElements;
766 void operator delete(
void *
Ptr) { ::operator
delete(
Ptr); }
806 size_t size()
const {
return NumElements; }
807 bool empty()
const {
return NumElements == 0; }
877 const Init *
Fold(
const Record *CurRec,
bool IsFinal =
false)
const;
1003 return LHS->isComplete() && MHS->isComplete() && RHS->isComplete();
1016 private TrailingObjects<CondOpInit, const Init *> {
1017 friend TrailingObjects;
1019 const RecTy *ValType;
1079 const Init *
getBit(
unsigned Bit)
const override;
1085 const Init *Start, *List, *A, *B, *Expr;
1087 FoldOpInit(
const Init *Start,
const Init *List,
const Init *A,
const Init *B,
1112 const Init *
getBit(
unsigned Bit)
const override;
1120 const RecTy *CheckType;
1123 IsAOpInit(
const RecTy *CheckType,
const Init *Expr)
1125 CheckType(CheckType), Expr(Expr) {}
1145 const Init *
getBit(
unsigned Bit)
const override;
1154 const RecTy *CheckType;
1157 ExistsOpInit(
const RecTy *CheckType,
const Init *Expr)
1159 CheckType(CheckType), Expr(Expr) {}
1173 const Init *
Fold(
const Record *CurRec,
bool IsFinal =
false)
const;
1179 const Init *
getBit(
unsigned Bit)
const override;
1192 InstancesOpInit(
const RecTy *Type,
const Init *Regex)
1198 InstancesOpInit &
operator=(
const InstancesOpInit &) =
delete;
1208 const Init *
Fold(
const Record *CurRec,
bool IsFinal =
false)
const;
1214 const Init *
getBit(
unsigned Bit)
const override;
1221 const Init *VarName;
1223 explicit VarInit(
const Init *VN,
const RecTy *
T)
1251 const Init *
getBit(
unsigned Bit)
const override;
1268 "Illegal VarBitInit expression!");
1288 assert(
B < 1 &&
"Bit index out of range!");
1299 explicit DefInit(
const Record *
D);
1325class VarDefInit final
1328 private TrailingObjects<VarDefInit, const ArgumentInit *> {
1329 friend TrailingObjects;
1335 explicit VarDefInit(
SMLoc Loc,
const Record *Class,
1345 void operator delete(
void *
Ptr) { ::operator
delete(
Ptr); }
1388 llvm::errs() <<
"In Record = " << Rec->getAsString()
1389 <<
", got FieldName = " << *FieldName
1390 <<
" with non-record type!\n";
1409 const Init *
getBit(
unsigned Bit)
const override;
1416 return Rec->getAsString() +
"." + FieldName->getValue().str();
1426 private TrailingObjects<DagInit, const Init *, const StringInit *> {
1427 friend TrailingObjects;
1436 size_t numTrailingObjects(OverloadToken<const Init *>)
const {
1459 ArrayRef<std::pair<const Init *, const StringInit *>> ArgAndNames);
1463 ArrayRef<std::pair<const Init *, const StringInit *>> ArgAndNames) {
1475 return ValName ? ValName->getValue() :
StringRef();
1506 using EltTy =
decltype(*
adl_begin(Zip));
1508 return std::make_pair(std::get<0>(
E), std::get<1>(
E));
1556 bool IsUsed =
false;
1625 RV.
print(OS <<
" ");
1674 mutable DefInit *CorrespondingDefInit =
nullptr;
1687 : Name(
N), Locs(locs), TrackedRecords(records),
1688 ID(
getNewUID(
N->getRecordKeeper())), Kind(Kind) {
1700 : Name(O.Name), Locs(O.Locs), TemplateArgs(O.TemplateArgs),
1701 Values(O.Values), Assertions(O.Assertions),
1702 DirectSuperClasses(O.DirectSuperClasses),
1724 return ForwardDeclarationLocs;
1758 SC->getSuperClasses(Classes);
1759 Classes.push_back(SC);
1765 std::vector<const Record *> Classes;
1777 return DirectSuperClasses;
1786 if (Val.Name == Name)
return &Val;
1796 static_cast<const Record *
>(
this)->getValue(Name));
1801 static_cast<const Record *
>(
this)->getValue(Name));
1806 TemplateArgs.push_back(Name);
1811 Values.push_back(RV);
1816 Values, [Name](
const RecordVal &V) {
return V.getNameInit() == Name; });
1817 if (It == Values.end())
1835 Assertions.append(Rec->Assertions);
1846 if (SC == R || SC->isSubClassOf(R))
1855 if (
SI->getValue() == Name)
1857 }
else if (SC->getNameInitAsString() == Name) {
1860 if (SC->isSubClassOf(Name))
1867 assert(!CorrespondingDefInit &&
1868 "changing type of record after it has been referenced");
1870 DirectSuperClasses.emplace_back(R,
Range);
1888 return TrackedRecords;
1975raw_ostream &
operator<<(raw_ostream &OS,
const Record &R);
1978 using RecordMap = std::map<std::string, std::unique_ptr<Record>, std::less<>>;
1979 using GlobalMap = std::map<std::string, const Init *, std::less<>>;
2002 auto I = Classes.find(Name);
2003 return I == Classes.end() ? nullptr :
I->second.get();
2008 auto I = Defs.find(Name);
2009 return I == Defs.end() ? nullptr :
I->second.get();
2015 return R->getDefInit();
2016 auto It = ExtraGlobals.find(Name);
2017 return It == ExtraGlobals.end() ? nullptr : It->second;
2021 InputFilename = std::move(Filename);
2026 Classes.try_emplace(std::string(R->getName()), std::move(R)).second;
2028 assert(Ins &&
"Class already exists");
2032 bool Ins = Defs.try_emplace(std::string(R->getName()), std::move(R)).second;
2034 assert(Ins &&
"Record already exists");
2041 bool Ins = ExtraGlobals.try_emplace(std::string(Name),
I).second;
2044 assert(Ins &&
"Global already exists");
2060 std::vector<const Record *>
2079 RecordMap Classes, Defs;
2080 mutable std::map<std::string, std::vector<const Record *>> Cache;
2081 GlobalMap ExtraGlobals;
2084 std::unique_ptr<detail::RecordKeeperImpl> Impl;
2085 std::unique_ptr<TGTimer>
Timer;
2101 return LHS->getID() <
RHS->getID();
2121 const char *Start = Rec.
data();
2122 const char *Curr = Start;
2123 bool IsDigitPart =
isDigit(Curr[0]);
2124 for (
size_t I = 0,
E = Rec.
size();
I !=
E; ++
I, ++Len) {
2126 if (IsDigit != IsDigitPart) {
2143 int64_t LHSPositionOrder = Rec1->
getValueAsInt(
"PositionOrder");
2144 int64_t RHSPositionOrder = Rec2->
getValueAsInt(
"PositionOrder");
2145 if (LHSPositionOrder != RHSPositionOrder)
2146 return LHSPositionOrder < RHSPositionOrder;
2151 size_t LHSNumParts = LHSParts.
size();
2152 size_t RHSNumParts = RHSParts.
size();
2153 assert (LHSNumParts && RHSNumParts &&
"Expected at least one part!");
2155 if (LHSNumParts != RHSNumParts)
2156 return LHSNumParts < RHSNumParts;
2159 for (
size_t I = 0,
E = LHSNumParts;
I <
E;
I+=2) {
2160 std::pair<bool, StringRef> LHSPart = LHSParts.
getPart(
I);
2161 std::pair<bool, StringRef> RHSPart = RHSParts.
getPart(
I);
2163 assert (LHSPart.first ==
false && RHSPart.first ==
false &&
2164 "Expected both parts to be alpha.");
2165 if (
int Res = LHSPart.second.compare(RHSPart.second))
2168 for (
size_t I = 1,
E = LHSNumParts;
I <
E;
I+=2) {
2169 std::pair<bool, StringRef> LHSPart = LHSParts.
getPart(
I);
2170 std::pair<bool, StringRef> RHSPart = RHSParts.
getPart(
I);
2172 assert (LHSPart.first ==
true && RHSPart.first ==
true &&
2173 "Expected both parts to be numeric.");
2174 if (LHSPart.second.size() != RHSPart.second.size())
2175 return LHSPart.second.size() < RHSPart.second.size();
2177 unsigned LHSVal, RHSVal;
2179 bool LHSFailed = LHSPart.second.getAsInteger(10, LHSVal); (void)LHSFailed;
2180 assert(!LHSFailed &&
"Unable to convert LHS to integer.");
2181 bool RHSFailed = RHSPart.second.getAsInteger(10, RHSVal); (void)RHSFailed;
2182 assert(!RHSFailed &&
"Unable to convert RHS to integer.");
2184 if (LHSVal != RHSVal)
2185 return LHSVal < RHSVal;
2187 return LHSNumParts < RHSNumParts;
2191raw_ostream &
operator<<(raw_ostream &OS,
const RecordKeeper &RK);
2201 bool IsFinal =
false;
2228 struct MappedValue {
2232 MappedValue() : V(
nullptr), Resolved(
false) {}
2233 MappedValue(
const Init *V,
bool Resolved) : V(V), Resolved(Resolved) {}
2244 auto It = Map.find(VarName);
2245 assert(It != Map.end() &&
"key must be present in map");
2246 return It->second.V->isComplete();
2256 const Init *Name =
nullptr;
2282 if (Shadowed.count(VarName))
2284 return R.resolve(VarName);
2292 bool FoundUnresolved =
false;
2306 const Init *VarNameToTrack;
2311 :
Resolver(nullptr), VarNameToTrack(VarNameToTrack) {}
2319void EmitJSON(
const RecordKeeper &RK, raw_ostream &OS);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_DEPRECATED(MSG, FIX)
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.
static cl::opt< std::string > InputFilename(cl::Positional, cl::desc("<input file>"), cl::init("-"))
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
This file defines the PointerIntPair class.
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
uint64_t convertKnownBitsToInt() 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.
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 StringInit * >::const_iterator const_name_iterator
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 function 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...
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
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.
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.
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.
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.
RecordVal(const Init *N, const RecTy *T, FieldKind K)
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.
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)
typename SuperClass::const_iterator const_iterator
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.
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...
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)
const T * getTrailingObjects() const
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
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.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
These are wrappers over isa* function that allow them to be used in generic algorithms such as llvm:a...
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
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...
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
FoldingSetBase::Node FoldingSetNode
std::string utostr(uint64_t X, bool isNeg=false)
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.
bool isDigit(char C)
Checks if character C is one of the 10 decimal digits.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
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)
ArrayRef(const T &OneElt) -> ArrayRef< T >
void EmitDetailedRecords(const RecordKeeper &RK, raw_ostream &OS)
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
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.
std::variant< unsigned, const Init * > ArgAuxType
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.