14#ifndef LLVM_TABLEGEN_RECORD_H
15#define LLVM_TABLEGEN_RECORD_H
46struct RecordKeeperImpl;
81 mutable const ListRecTy *ListTy =
nullptr;
193 const RecTy *ElementTy;
195 explicit ListRecTy(
const RecTy *
T)
203 static const ListRecTy *
get(
const RecTy *
T) {
return T->getListTy(); }
233class RecordRecTy final :
public RecTy,
235 private TrailingObjects<RecordRecTy, const Record *> {
236 friend TrailingObjects;
249 void operator delete(
void *Ptr) { ::operator
delete(Ptr); }
339 virtual void anchor();
414 I.print(OS);
return OS;
420 const RecTy *ValueTy;
454class UnsetInit final :
public Init {
479 const Init *
getBit(
unsigned Bit)
const override {
return this; }
523 return std::get<Positional>(Aux);
527 return std::get<Named>(Aux);
530 return get(Value, Aux);
562 explicit BitInit(
bool V,
const RecTy *
T)
580 assert(Bit < 1 &&
"Bit index out of range!");
585 std::string
getAsString()
const override {
return Value ?
"1" :
"0"; }
592 private TrailingObjects<BitsInit, const Init *> {
593 friend TrailingObjects;
603 void operator delete(
void *Ptr) { ::operator
delete(Ptr); }
670 explicit AnonymousNameInit(
RecordKeeper &RK,
unsigned V)
675 AnonymousNameInit &
operator=(
const AnonymousNameInit &) =
delete;
736 return "\"" + Value.str() +
"\"";
738 return "[{" + Value.str() +
"}]";
752 private TrailingObjects<ListInit, const Init *> {
753 friend TrailingObjects;
754 unsigned NumElements;
767 void operator delete(
void *Ptr) { ::operator
delete(Ptr); }
809 size_t size()
const {
return NumElements; }
810 bool empty()
const {
return NumElements == 0; }
876 std::tuple<UnaryOp, const Init *, const RecTy *>
getKey()
const {
882 const Init *
Fold(
const Record *CurRec,
bool IsFinal =
false)
const;
948 std::tuple<BinaryOp, const Init *, const Init *, const RecTy *>
1005 std::tuple<TernaryOp, const Init *, const Init *, const Init *, const RecTy *>
1015 return LHS->isComplete() && MHS->isComplete() && RHS->isComplete();
1028 private TrailingObjects<CondOpInit, const Init *> {
1029 friend TrailingObjects;
1031 const RecTy *ValType;
1091 const Init *
getBit(
unsigned Bit)
const override;
1097 const Init *Start, *List, *A, *B, *Expr;
1099 FoldOpInit(
const Init *Start,
const Init *List,
const Init *A,
const Init *B,
1124 const Init *
getBit(
unsigned Bit)
const override;
1132 const RecTy *CheckType;
1135 IsAOpInit(
const RecTy *CheckType,
const Init *Expr)
1137 CheckType(CheckType), Expr(Expr) {}
1157 const Init *
getBit(
unsigned Bit)
const override;
1166 const RecTy *CheckType;
1169 ExistsOpInit(
const RecTy *CheckType,
const Init *Expr)
1171 CheckType(CheckType), Expr(Expr) {}
1185 const Init *
Fold(
const Record *CurRec,
bool IsFinal =
false)
const;
1191 const Init *
getBit(
unsigned Bit)
const override;
1204 InstancesOpInit(
const RecTy *Type,
const Init *Regex)
1210 InstancesOpInit &
operator=(
const InstancesOpInit &) =
delete;
1220 const Init *
Fold(
const Record *CurRec,
bool IsFinal =
false)
const;
1235 const Init *VarName;
1237 explicit VarInit(
const Init *VN,
const RecTy *
T)
1265 const Init *
getBit(
unsigned Bit)
const override;
1282 "Illegal VarBitInit expression!");
1302 assert(
B < 1 &&
"Bit index out of range!");
1313 explicit DefInit(
const Record *
D);
1339class VarDefInit final
1342 private TrailingObjects<VarDefInit, const ArgumentInit *> {
1343 friend TrailingObjects;
1349 explicit VarDefInit(
SMLoc Loc,
const Record *Class,
1359 void operator delete(
void *Ptr) { ::operator
delete(Ptr); }
1402 llvm::errs() <<
"In Record = " << Rec->getAsString()
1403 <<
", got FieldName = " << *FieldName
1404 <<
" with non-record type!\n";
1423 const Init *
getBit(
unsigned Bit)
const override;
1430 return Rec->getAsString() +
"." + FieldName->getValue().str();
1440 private TrailingObjects<DagInit, const Init *, const StringInit *> {
1441 friend TrailingObjects;
1450 size_t numTrailingObjects(OverloadToken<const Init *>)
const {
1473 ArrayRef<std::pair<const Init *, const StringInit *>> ArgAndNames);
1477 ArrayRef<std::pair<const Init *, const StringInit *>> ArgAndNames) {
1489 return ValName ? ValName->getValue() :
StringRef();
1520 using EltTy =
decltype(*
adl_begin(Zip));
1522 return std::make_pair(std::get<0>(
E), std::get<1>(
E));
1570 bool IsUsed =
false;
1639 RV.
print(OS <<
" ");
1688 mutable DefInit *CorrespondingDefInit =
nullptr;
1701 : Name(
N), Locs(locs), TrackedRecords(records),
1702 ID(
getNewUID(
N->getRecordKeeper())), Kind(Kind) {
1714 : Name(O.Name), Locs(O.Locs), TemplateArgs(O.TemplateArgs),
1715 Values(O.Values), Assertions(O.Assertions),
1716 DirectSuperClasses(O.DirectSuperClasses),
1738 return ForwardDeclarationLocs;
1772 SC->getSuperClasses(Classes);
1773 Classes.push_back(SC);
1779 std::vector<const Record *> Classes;
1791 return DirectSuperClasses;
1800 if (Val.Name == Name)
return &Val;
1810 static_cast<const Record *
>(
this)->getValue(Name));
1815 static_cast<const Record *
>(
this)->getValue(Name));
1820 TemplateArgs.push_back(Name);
1825 Values.push_back(RV);
1830 Values, [Name](
const RecordVal &V) {
return V.getNameInit() == Name; });
1831 if (It == Values.end())
1849 Assertions.append(Rec->Assertions);
1860 if (SC == R || SC->isSubClassOf(R))
1869 if (
SI->getValue() == Name)
1871 }
else if (SC->getNameInitAsString() == Name) {
1874 if (SC->isSubClassOf(Name))
1881 assert(!CorrespondingDefInit &&
1882 "changing type of record after it has been referenced");
1884 DirectSuperClasses.emplace_back(R,
Range);
1902 return TrackedRecords;
1989raw_ostream &
operator<<(raw_ostream &OS,
const Record &R);
1992 using RecordMap = std::map<std::string, std::unique_ptr<Record>, std::less<>>;
1993 using GlobalMap = std::map<std::string, const Init *, std::less<>>;
2016 auto I = Classes.find(Name);
2017 return I == Classes.end() ? nullptr :
I->second.get();
2022 auto I = Defs.find(Name);
2023 return I == Defs.end() ? nullptr :
I->second.get();
2029 return R->getDefInit();
2030 auto It = ExtraGlobals.find(Name);
2031 return It == ExtraGlobals.end() ? nullptr : It->second;
2035 InputFilename = std::move(
Filename);
2040 Classes.try_emplace(std::string(R->getName()), std::move(R)).second;
2042 assert(Ins &&
"Class already exists");
2046 bool Ins = Defs.try_emplace(std::string(R->getName()), std::move(R)).second;
2048 assert(Ins &&
"Record already exists");
2055 bool Ins = ExtraGlobals.try_emplace(std::string(Name),
I).second;
2058 assert(Ins &&
"Global already exists");
2074 std::vector<const Record *>
2093 RecordMap Classes, Defs;
2094 mutable std::map<std::string, std::vector<const Record *>> Cache;
2095 GlobalMap ExtraGlobals;
2098 std::unique_ptr<detail::RecordKeeperImpl> Impl;
2099 std::unique_ptr<TGTimer>
Timer;
2115 return LHS->getID() <
RHS->getID();
2135 const char *Start = Rec.
data();
2136 const char *Curr = Start;
2137 bool IsDigitPart =
isDigit(Curr[0]);
2138 for (
size_t I = 0,
E = Rec.
size();
I !=
E; ++
I, ++Len) {
2140 if (IsDigit != IsDigitPart) {
2157 int64_t LHSPositionOrder = Rec1->
getValueAsInt(
"PositionOrder");
2158 int64_t RHSPositionOrder = Rec2->
getValueAsInt(
"PositionOrder");
2159 if (LHSPositionOrder != RHSPositionOrder)
2160 return LHSPositionOrder < RHSPositionOrder;
2165 size_t LHSNumParts = LHSParts.
size();
2166 size_t RHSNumParts = RHSParts.
size();
2167 assert (LHSNumParts && RHSNumParts &&
"Expected at least one part!");
2169 if (LHSNumParts != RHSNumParts)
2170 return LHSNumParts < RHSNumParts;
2173 for (
size_t I = 0,
E = LHSNumParts;
I <
E;
I+=2) {
2174 std::pair<bool, StringRef> LHSPart = LHSParts.
getPart(
I);
2175 std::pair<bool, StringRef> RHSPart = RHSParts.
getPart(
I);
2177 assert (LHSPart.first ==
false && RHSPart.first ==
false &&
2178 "Expected both parts to be alpha.");
2179 if (
int Res = LHSPart.second.compare(RHSPart.second))
2182 for (
size_t I = 1,
E = LHSNumParts;
I <
E;
I+=2) {
2183 std::pair<bool, StringRef> LHSPart = LHSParts.
getPart(
I);
2184 std::pair<bool, StringRef> RHSPart = RHSParts.
getPart(
I);
2186 assert (LHSPart.first ==
true && RHSPart.first ==
true &&
2187 "Expected both parts to be numeric.");
2188 if (LHSPart.second.size() != RHSPart.second.size())
2189 return LHSPart.second.size() < RHSPart.second.size();
2191 unsigned LHSVal, RHSVal;
2193 bool LHSFailed = LHSPart.second.getAsInteger(10, LHSVal); (void)LHSFailed;
2194 assert(!LHSFailed &&
"Unable to convert LHS to integer.");
2195 bool RHSFailed = RHSPart.second.getAsInteger(10, RHSVal); (void)RHSFailed;
2196 assert(!RHSFailed &&
"Unable to convert RHS to integer.");
2198 if (LHSVal != RHSVal)
2199 return LHSVal < RHSVal;
2201 return LHSNumParts < RHSNumParts;
2205raw_ostream &
operator<<(raw_ostream &OS,
const RecordKeeper &RK);
2215 bool IsFinal =
false;
2242 struct MappedValue {
2246 MappedValue() : V(
nullptr), Resolved(
false) {}
2247 MappedValue(
const Init *V,
bool Resolved) : V(V), Resolved(Resolved) {}
2258 auto It = Map.find(VarName);
2259 assert(It != Map.end() &&
"key must be present in map");
2260 return It->second.V->isComplete();
2270 const Init *Name =
nullptr;
2296 if (Shadowed.count(VarName))
2298 return R.resolve(VarName);
2306 bool FoundUnresolved =
false;
2320 const Init *VarNameToTrack;
2325 :
Resolver(nullptr), VarNameToTrack(VarNameToTrack) {}
2333void 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))
static constexpr StringLiteral Filename
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.
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)
std::tuple< BinaryOp, const Init *, const Init *, const RecTy * > getKey() 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...
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...
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 * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
const Init * Fold(const Record *CurRec, bool IsFinal=false) 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.
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
std::pair< ArrayRef< const Init * >, const RecTy * > getKey() 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.
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.
Represent a constant reference to a string, i.e.
constexpr bool empty() const
Check if the string is empty.
constexpr size_t size() const
Get the string size.
constexpr const char * data() const
Get a pointer to the start of the string (which may not be null terminated).
LLVM_ABI int compare_numeric(StringRef RHS) const
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)
std::tuple< TernaryOp, const Init *, const Init *, const Init *, const RecTy * > getKey() const
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.
std::tuple< UnaryOp, const Init *, const RecTy * > getKey() const
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.
A self-contained host- and target-independent arbitrary-precision floating-point software implementat...
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.
RelativeUniformCounterPtr Values
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.
@ BinaryOp
One of the operands is a binary op.
std::string utostr(uint64_t X, bool isNeg=false)
auto map_range(ContainerTy &&C, FuncTy F)
Return a range that applies F to the elements of C.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
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
This class represents the internal implementation of the RecordKeeper.
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)