14#ifndef LLVM_TABLEGEN_RECORD_H
15#define LLVM_TABLEGEN_RECORD_H
44struct RecordKeeperImpl;
79 mutable const ListRecTy *ListTy =
nullptr;
191 const RecTy *ElementTy;
247 void operator delete(
void *p) { ::operator
delete(p); }
261 return ArrayRef(getTrailingObjects<const Record *>(), NumClasses);
336 virtual void anchor();
411 I.print(
OS);
return OS;
417 const RecTy *ValueTy;
476 const Init *
getBit(
unsigned Bit)
const override {
return this; }
520 return std::get<Positional>(Aux);
524 return std::get<Named>(Aux);
546 return Value->getCastTo(Ty);
549 return Value->convertInitializerTo(Ty);
577 assert(Bit < 1 &&
"Bit index out of range!");
600 void operator delete(
void *p) { ::operator
delete(p); }
635 assert(Bit < NumBits &&
"Bit index out of range!");
636 return getTrailingObjects<const Init *>()[Bit];
741 return "\"" +
Value.str() +
"\"";
743 return "[{" +
Value.str() +
"}]";
747 return std::string(
Value);
774 void operator delete(
void *p) { ::operator
delete(p); }
784 assert(i < NumValues &&
"List element index out of range!");
785 return getTrailingObjects<const Init *>()[i];
788 return cast<ListRecTy>(
getType())->getElementType();
807 return ArrayRef(getTrailingObjects<const Init *>(), NumValues);
813 size_t size ()
const {
return NumValues; }
814 bool empty()
const {
return NumValues == 0; }
843 const Init *
getBit(
unsigned Bit)
const override;
887 "Wrong number of operands for unary operation");
894 assert(i == 0 &&
"Invalid operand id for unary operator");
903 const Init *
Fold(
const Record *CurRec,
bool IsFinal =
false)
const;
945 const Init *LHS, *RHS;
968 "Wrong number of operands for binary operation");
986 const Init *RHS)
const;
1014 const Init *LHS, *MHS, *RHS;
1036 "Wrong number of operands for ternary operation");
1076 const RecTy *ValType;
1081 size_t numTrailingObjects(OverloadToken<Init *>)
const {
1103 assert(Num < NumConds &&
"Condition number out of range!");
1104 return getTrailingObjects<const Init *>()[Num];
1108 assert(Num < NumConds &&
"Val number out of range!");
1109 return getTrailingObjects<const Init *>()[Num + NumConds];
1113 return ArrayRef(getTrailingObjects<const Init *>(), NumConds);
1117 return ArrayRef(getTrailingObjects<const Init *>() + NumConds, NumConds);
1143 const Init *
getBit(
unsigned Bit)
const override;
1149 const Init *Start, *List, *A, *B, *Expr;
1176 const Init *
getBit(
unsigned Bit)
const override;
1184 const RecTy *CheckType;
1189 CheckType(CheckType), Expr(Expr) {}
1209 const Init *
getBit(
unsigned Bit)
const override;
1218 const RecTy *CheckType;
1223 CheckType(CheckType), Expr(Expr) {}
1237 const Init *
Fold(
const Record *CurRec,
bool IsFinal =
false)
const;
1243 const Init *
getBit(
unsigned Bit)
const override;
1250 const Init *VarName;
1280 const Init *
getBit(
unsigned Bit)
const override;
1294 (isa<IntRecTy>(
T->getType()) ||
1295 (isa<BitsRecTy>(
T->getType()) &&
1296 cast<BitsRecTy>(
T->getType())->getNumBits() >
B)) &&
1297 "Illegal VarBitInit expression!");
1317 assert(
B < 1 &&
"Bit index out of range!");
1372 void operator delete(
void *p) { ::operator
delete(p); }
1388 assert(i < NumArgs &&
"Argument index out of range!");
1389 return getTrailingObjects<const ArgumentInit *>()[i];
1395 return getTrailingObjects<const ArgumentInit *>();
1421 <<
", got FieldName = " << *FieldName
1422 <<
" with non-record type!\n";
1441 const Init *
getBit(
unsigned Bit)
const override;
1464 unsigned NumArgNames;
1467 unsigned NumArgNames)
1469 ValName(VN), NumArgs(NumArgs), NumArgNames(NumArgNames) {}
1471 size_t numTrailingObjects(OverloadToken<const Init *>)
const {
1488 ArrayRef<std::pair<const Init *, const StringInit *>> Args);
1504 assert(Num < NumArgs &&
"Arg number out of range!");
1505 return getTrailingObjects<const Init *>()[Num];
1513 assert(Num < NumArgNames &&
"Arg number out of range!");
1514 return getTrailingObjects<const StringInit *>()[Num];
1523 return ArrayRef(getTrailingObjects<const Init *>(), NumArgs);
1527 return ArrayRef(getTrailingObjects<const StringInit *>(), NumArgNames);
1577 bool IsUsed =
false;
1695 mutable DefInit *CorrespondingDefInit =
nullptr;
1708 : Name(
N), Locs(locs), TrackedRecords(records),
1722 Values(O.Values), Assertions(O.Assertions),
1723 SuperClasses(O.SuperClasses), TrackedRecords(O.TrackedRecords),
1744 return ForwardDeclarationLocs;
1776 return SuperClasses;
1791 if (Val.Name == Name)
return &Val;
1820 for (
unsigned i = 0, e = Values.
size(); i != e; ++i)
1841 Assertions.
append(Rec->Assertions);
1851 for (
const auto &[SC,
_] : SuperClasses)
1858 for (
const auto &[SC,
_] : SuperClasses) {
1859 if (
const auto *SI = dyn_cast<StringInit>(SC->getNameInit())) {
1860 if (SI->getValue() == Name)
1862 }
else if (SC->getNameInitAsString() == Name) {
1870 assert(!CorrespondingDefInit &&
1871 "changing type of record after it has been referenced");
1891 return TrackedRecords;
1978raw_ostream &
operator<<(raw_ostream &
OS,
const Record &R);
1981 using RecordMap = std::map<std::string, std::unique_ptr<Record>, std::less<>>;
1982 using GlobalMap = std::map<std::string, const Init *, std::less<>>;
2005 auto I = Classes.find(
Name);
2006 return I == Classes.end() ? nullptr :
I->second.get();
2011 auto I = Defs.find(
Name);
2012 return I == Defs.end() ? nullptr :
I->second.get();
2018 return R->getDefInit();
2019 auto It = ExtraGlobals.find(
Name);
2020 return It == ExtraGlobals.end() ? nullptr : It->second;
2024 InputFilename = Filename;
2028 bool Ins = Classes.insert(std::make_pair(std::string(R->getName()),
2029 std::move(R))).second;
2031 assert(Ins &&
"Class already exists");
2035 bool Ins = Defs.insert(std::make_pair(std::string(R->getName()),
2036 std::move(R))).second;
2038 assert(Ins &&
"Record already exists");
2042 bool Ins = ExtraGlobals.insert(std::make_pair(std::string(
Name),
I)).second;
2045 assert(Ins &&
"Global already exists");
2061 std::vector<const Record *>
2079 std::string InputFilename;
2080 RecordMap Classes, Defs;
2081 mutable std::map<std::string, std::vector<const Record *>> Cache;
2082 GlobalMap ExtraGlobals;
2085 std::unique_ptr<detail::RecordKeeperImpl> Impl;
2086 std::unique_ptr<TGTimer>
Timer;
2102 return LHS->getID() <
RHS->getID();
2122 const char *Start = Rec.
data();
2123 const char *Curr = Start;
2124 bool IsDigitPart =
isDigit(Curr[0]);
2125 for (
size_t I = 0,
E = Rec.
size();
I !=
E; ++
I, ++Len) {
2127 if (IsDigit != IsDigitPart) {
2128 Parts.push_back(std::make_pair(IsDigitPart,
StringRef(Start, Len)));
2135 Parts.push_back(std::make_pair(IsDigitPart,
StringRef(Start, Len)));
2147 int64_t LHSPositionOrder = Rec1->
getValueAsInt(
"PositionOrder");
2148 int64_t RHSPositionOrder = Rec2->
getValueAsInt(
"PositionOrder");
2149 if (LHSPositionOrder != RHSPositionOrder)
2150 return LHSPositionOrder < RHSPositionOrder;
2155 size_t LHSNumParts = LHSParts.
size();
2156 size_t RHSNumParts = RHSParts.
size();
2157 assert (LHSNumParts && RHSNumParts &&
"Expected at least one part!");
2159 if (LHSNumParts != RHSNumParts)
2160 return LHSNumParts < RHSNumParts;
2163 for (
size_t I = 0,
E = LHSNumParts;
I <
E;
I+=2) {
2164 std::pair<bool, StringRef> LHSPart = LHSParts.
getPart(
I);
2165 std::pair<bool, StringRef> RHSPart = RHSParts.
getPart(
I);
2167 assert (LHSPart.first ==
false && RHSPart.first ==
false &&
2168 "Expected both parts to be alpha.");
2169 if (
int Res = LHSPart.second.compare(RHSPart.second))
2172 for (
size_t I = 1,
E = LHSNumParts;
I <
E;
I+=2) {
2173 std::pair<bool, StringRef> LHSPart = LHSParts.
getPart(
I);
2174 std::pair<bool, StringRef> RHSPart = RHSParts.
getPart(
I);
2176 assert (LHSPart.first ==
true && RHSPart.first ==
true &&
2177 "Expected both parts to be numeric.");
2178 if (LHSPart.second.size() != RHSPart.second.size())
2179 return LHSPart.second.size() < RHSPart.second.size();
2181 unsigned LHSVal, RHSVal;
2183 bool LHSFailed = LHSPart.second.getAsInteger(10, LHSVal); (void)LHSFailed;
2184 assert(!LHSFailed &&
"Unable to convert LHS to integer.");
2185 bool RHSFailed = RHSPart.second.getAsInteger(10, RHSVal); (void)RHSFailed;
2186 assert(!RHSFailed &&
"Unable to convert RHS to integer.");
2188 if (LHSVal != RHSVal)
2189 return LHSVal < RHSVal;
2191 return LHSNumParts < RHSNumParts;
2195raw_ostream &
operator<<(raw_ostream &
OS,
const RecordKeeper &RK);
2205 bool IsFinal =
false;
2232 struct MappedValue {
2236 MappedValue() : V(
nullptr), Resolved(
false) {}
2237 MappedValue(
const Init *V,
bool Resolved) : V(V), Resolved(Resolved) {}
2248 auto It = Map.find(VarName);
2249 assert(It != Map.end() &&
"key must be present in map");
2250 return It->second.V->isComplete();
2260 const Init *Name =
nullptr;
2286 if (Shadowed.
count(VarName))
2288 return R.resolve(VarName);
2296 bool FoundUnresolved =
false;
2310 const Init *VarNameToTrack;
2315 :
Resolver(nullptr), VarNameToTrack(VarNameToTrack) {}
2323void EmitJSON(
const RecordKeeper &RK, raw_ostream &
OS);
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
This file defines a hash set that can be used to remove duplication of nodes in a graph.
mir Rename Register Operands
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
This file defines the PointerIntPair class.
static bool isDigit(const char C)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
This header defines support for implementing classes that have some trailing object (or arrays of obj...
"anonymous_n" - Represent an anonymous record name
unsigned getValue() const
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.
const OpInit * clone(ArrayRef< const Init * > Operands) const override
unsigned getNumOperands() const override
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 * getOperand(unsigned i) const override
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.
bool isComplete() const override
Is this a complete value with no unset (uninitialized) subvalues?
bool allInComplete() const
std::string getAsString() const override
Convert this value to a literal form.
static bool classof(const Init *I)
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.
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
static const CondOpInit * get(ArrayRef< const Init * > C, ArrayRef< const Init * > V, const RecTy *Type)
const Init * Fold(const Record *CurRec) const
SmallVectorImpl< const Init * >::const_iterator const_val_iterator
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.
unsigned getNumConds() const
const RecTy * getValType() const
bool isComplete() const override
Is this a complete value with no unset (uninitialized) subvalues?
static bool classof(const Init *I)
const Init * getVal(unsigned Num) const
const_case_iterator arg_begin() const
ArrayRef< const Init * > getConds() const
(v a, b) - Represent a DAG tree value.
SmallVectorImpl< const StringInit * >::const_iterator const_name_iterator
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
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
static const DagInit * get(const Init *V, const StringInit *VN, ArrayRef< const Init * > ArgRange, ArrayRef< const StringInit * > NameRange)
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...
ArrayRef< const StringInit * > getArgNames() const
const_name_iterator name_end() const
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
ArrayRef< const Init * > getArgs() const
std::string getAsString() const override
Convert this value to a literal form.
'dag' - Represent a dag fragment
std::string getAsString() const override
static bool classof(const RecTy *RT)
static const DagRecTy * get(RecordKeeper &RK)
AL - Represent a reference to a 'def' in the description.
DefInit & operator=(const DefInit &)=delete
std::string getAsString() const override
Convert this value to a literal form.
const RecTy * getFieldType(const StringInit *FieldName) const override
This method is used to implement the FieldInit class.
const Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
const Init * convertInitializerTo(const RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
DefInit(const DefInit &)=delete
static bool classof(const Init *I)
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
const Record * getDef() const
Implements a dense probed hash-table based set.
!exists<type>(expr) - Dynamically determine if a record of type named expr exists.
static bool classof(const Init *I)
ExistsOpInit(const ExistsOpInit &)=delete
bool isComplete() const override
Is this a complete value with no unset (uninitialized) subvalues?
static const ExistsOpInit * get(const RecTy *CheckType, const Init *Expr)
std::string getAsString() const override
Convert this value to a literal form.
ExistsOpInit & operator=(const ExistsOpInit &)=delete
const Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
const Init * Fold(const Record *CurRec, bool IsFinal=false) const
const Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
X.Y - Represent a reference to a subfield of a variable.
static bool classof(const Init *I)
std::string getAsString() const override
Convert this value to a literal form.
const Init * Fold(const Record *CurRec) const
const StringInit * getFieldName() const
const Init * getRecord() const
const Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
static const FieldInit * get(const Init *R, const StringInit *FN)
FieldInit & operator=(const FieldInit &)=delete
const Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
FieldInit(const FieldInit &)=delete
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
!foldl (a, b, expr, start, lst) - Fold over a list.
const Init * Fold(const Record *CurRec) const
static bool classof(const Init *I)
FoldOpInit & operator=(const FoldOpInit &)=delete
std::string getAsString() const override
Convert this value to a literal form.
FoldOpInit(const FoldOpInit &)=delete
static const FoldOpInit * get(const Init *Start, const Init *List, const Init *A, const Init *B, const Init *Expr, const RecTy *Type)
const Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
bool isComplete() const override
Is this a complete value with no unset (uninitialized) subvalues?
const Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
Node - This class is used to maintain the singly linked bucket list in a folding set.
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
Do not resolve anything, but keep track of whether a given variable was referenced.
HasReferenceResolver(const Init *VarNameToTrack)
const Init * resolve(const Init *VarName) override
Return the initializer for the given variable name (should normally be a StringInit),...
virtual const Init * resolveReferences(Resolver &R) const
This function is used by classes that refer to other variables which may not be defined at the time t...
virtual const Init * convertInitializerBitRange(ArrayRef< unsigned > Bits) const
This function is used to implement the bit range selection operator.
virtual std::string getAsUnquotedString() const
Convert this value to a literal form, without adding quotes around a string.
void dump() const
Debugging method that may be called through a debugger; just invokes print on stderr.
void print(raw_ostream &OS) const
Print this value.
virtual std::string getAsString() const =0
Convert this value to a literal form.
InitKind
Discriminator enum (for isa<>, dyn_cast<>, et al.)
InitKind getKind() const
Get the kind (type) of the value.
virtual bool isConcrete() const
Is this a concrete and fully resolved value without any references or stuck operations?...
virtual bool isComplete() const
Is this a complete value with no unset (uninitialized) subvalues?
virtual const Init * getBit(unsigned Bit) const =0
Get the Init value of the specified bit.
virtual const RecTy * getFieldType(const StringInit *FieldName) const
This function is used to implement the FieldInit class.
Init(const Init &)=delete
virtual const Init * convertInitializerTo(const RecTy *Ty) const =0
Convert to a value whose type is Ty, or return null if this is not possible.
Init & operator=(const Init &)=delete
virtual const Init * getCastTo(const RecTy *Ty) const =0
If this value is convertible to type Ty, return a value whose type is Ty, generating a !...
RecordKeeper & getRecordKeeper() const
Get the record keeper that initialized this Init.
Init(InitKind K, uint8_t Opc=0)
'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
const Record * getElementAsRecord(unsigned i) const
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 * getElement(unsigned i) 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.
ArrayRef< const Init * > getValues() const
const_iterator begin() const
const_iterator end() const
const Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
static bool classof(const Init *I)
'list<Ty>' - Represent a list of element values, all of which must be of the specified type.
const RecTy * getElementType() const
static bool classof(const RecTy *RT)
bool typeIsA(const RecTy *RHS) const override
Return true if 'this' type is equal to or a subtype of RHS.
static const ListRecTy * get(const RecTy *T)
std::string getAsString() const override
bool typeIsConvertibleTo(const RecTy *RHS) const override
Return true if all values of 'this' type can be converted to the specified type.
Resolve arbitrary mappings.
void set(const Init *Key, const Init *Value)
bool isComplete(Init *VarName) const
MapResolver(const Record *CurRec=nullptr)
const Init * resolve(const Init *VarName) override
Return the initializer for the given variable name (should normally be a StringInit),...
Base class for operators.
virtual unsigned getNumOperands() const =0
OpInit & operator=(OpInit &)=delete
static bool classof(const Init *I)
virtual const OpInit * clone(ArrayRef< const Init * > Operands) const =0
OpInit(const OpInit &)=delete
const Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
OpInit(InitKind K, const RecTy *Type, uint8_t Opc)
virtual const Init * getOperand(unsigned i) const =0
PointerIntPair - This class implements a pair of a pointer and small integer.
PointerTy getPointer() const
RecordKeeper & getRecordKeeper() const
Return the RecordKeeper that uniqued this Type.
virtual bool typeIsA(const RecTy *RHS) const
Return true if 'this' type is equal to or a subtype of RHS.
virtual bool typeIsConvertibleTo(const RecTy *RHS) const
Return true if all values of 'this' type can be converted to the specified type.
RecTyKind
Subclass discriminator (for dyn_cast<> et al.)
RecTy(RecTyKind K, RecordKeeper &RK)
virtual std::string getAsString() const =0
RecTyKind getRecTyKind() const
const ListRecTy * getListTy() const
Returns the type representing list<thistype>.
void print(raw_ostream &OS) const
void addDef(std::unique_ptr< Record > R)
void addClass(std::unique_ptr< Record > R)
TGTimer & getTimer() const
const Record * getClass(StringRef Name) const
Get the class with the specified name.
const RecordMap & getClasses() const
Get the map of classes.
const Init * getNewAnonymousName()
GetNewAnonymousName - Generate a unique anonymous name that can be used as an identifier.
const RecordMap & getDefs() const
Get the map of records (defs).
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.
const std::string getInputFilename() const
Get the main TableGen input file's name.
ArrayRef< const Record * > getAllDerivedDefinitions(StringRef ClassName) const
Get all the concrete records that inherit from the one specified class.
'[classname]' - Type of record values that have zero or more superclasses.
bool typeIsConvertibleTo(const RecTy *RHS) const override
Return true if all values of 'this' type can be converted to the specified type.
RecordRecTy & operator=(const RecordRecTy &)=delete
bool isSubClassOf(const Record *Class) const
const Record *const * const_record_iterator
ArrayRef< const Record * > getClasses() const
const_record_iterator classes_begin() const
const_record_iterator classes_end() const
std::string getAsString() const override
RecordRecTy(const RecordRecTy &)=delete
bool typeIsA(const RecTy *RHS) const override
Return true if 'this' type is equal to or a subtype of RHS.
static bool classof(const RecTy *RT)
static const RecordRecTy * get(RecordKeeper &RK, ArrayRef< const Record * > Classes)
Get the record type with the given non-redundant list of superclasses.
Resolve all variables from a record except for unset variables.
bool keepUnsetBits() const override
RecordResolver(const Record &R)
const Init * resolve(const Init *VarName) override
Return the initializer for the given variable name (should normally be a StringInit),...
void setName(const Init *NewName)
This class represents a field in a record, including its name, type, value, and source location.
bool isTemplateArg() const
Is this a template argument?
std::string getNameInitAsString() const
Get the name of the field as a std::string.
void setUsed(bool Used)
Whether this value is used.
bool isNonconcreteOK() const
Is this a field where nonconcrete values are okay?
bool setValue(const Init *V)
Set the value of the field from an Init.
RecordKeeper & getRecordKeeper() const
Get the record keeper used to unique this value.
const SMLoc & getLoc() const
Get the source location of the point where the field was defined.
const Init * getValue() const
Get the value of the field as an Init.
StringRef getName() const
Get the name of the field as a StringRef.
void addReferenceLoc(SMRange Loc)
Add a reference to this record value.
void print(raw_ostream &OS, bool PrintSem=true) const
Print the value to an output stream, possibly with a semicolon.
const Init * getNameInit() const
Get the name of the field as an Init.
ArrayRef< SMRange > getReferenceLocs() const
Return the references of this record value.
std::string getPrintType() const
Get the type of the field for printing purposes.
const RecTy * getType() const
Get the type of the field value as a RecTy.
std::vector< int64_t > getValueAsListOfInts(StringRef FieldName) const
This method looks up the specified field and returns its value as a vector of integers,...
const RecordRecTy * getType() const
const Init * getValueInit(StringRef FieldName) const
Return the initializer for a value with the specified name, or throw an exception if the field does n...
bool getValueAsBitOrUnset(StringRef FieldName, bool &Unset) const
This method looks up the specified field and returns its value as a bit.
bool getValueAsBit(StringRef FieldName) const
This method looks up the specified field and returns its value as a bit, throwing an exception if the...
ArrayRef< std::pair< const Record *, SMRange > > getSuperClasses() const
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.
bool isMultiClass() const
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)
bool hasDirectSuperClass(const Record *SuperClass) const
Determine whether this record has the specified direct superclass.
Record(StringRef N, ArrayRef< SMLoc > locs, RecordKeeper &records, RecordKind Kind=RK_Def)
StringRef getName() const
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 getDirectSuperClasses(SmallVectorImpl< const Record * > &Classes) const
Append the direct superclasses of this record to Classes.
void appendAssertions(const Record *Rec)
const Init * getNameInit() const
int64_t getValueAsInt(StringRef FieldName) const
This method looks up the specified field and returns its value as an int64_t, throwing an exception i...
void addSuperClass(const Record *R, SMRange Range)
RecordVal * getValue(StringRef Name)
void checkRecordAssertions()
void appendReferenceLoc(SMRange Loc) const
Add a reference to this record value.
StringRef getValueAsString(StringRef FieldName) const
This method looks up the specified field and returns its value as a string, throwing an exception if ...
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
virtual ~Resolver()=default
Resolver(const Record *CurRec)
const Record * getCurrentRecord() const
void setFinal(bool Final)
virtual bool keepUnsetBits() const
virtual const Init * resolve(const Init *VarName)=0
Return the initializer for the given variable name (should normally be a StringInit),...
Represents a location in source code.
Represents a range in source code.
Delegate resolving to a sub-resolver, but shadow some variable names.
ShadowResolver(Resolver &R)
const Init * resolve(const Init *VarName) override
Return the initializer for the given variable name (should normally be a StringInit),...
void addShadow(const Init *Key)
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
iterator erase(const_iterator CI)
typename SuperClass::const_iterator const_iterator
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
"foo" - Represent an initialization by a string value.
StringInit(const StringInit &)=delete
std::string getAsString() const override
Convert this value to a literal form.
StringInit & operator=(const StringInit &)=delete
static const StringInit * get(RecordKeeper &RK, StringRef, StringFormat Fmt=SF_String)
StringFormat getFormat() const
bool hasCodeFormat() const
StringRef getValue() const
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
static StringFormat determineFormat(StringFormat Fmt1, StringFormat Fmt2)
static bool classof(const Init *I)
std::string getAsUnquotedString() const override
Convert this value to a literal form, without adding quotes around a string.
const Init * convertInitializerTo(const RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
const Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
'string' - Represent an string value
static bool classof(const RecTy *RT)
std::string getAsString() const override
static const StringRecTy * get(RecordKeeper &RK)
bool typeIsConvertibleTo(const RecTy *RHS) const override
Return true if all values of 'this' type can be converted to the specified type.
StringRef - Represent a constant reference to a string, i.e.
std::string str() const
str - Get the contents as an std::string.
constexpr bool empty() const
empty - Check if the string is empty.
constexpr size_t size() const
size - Get the string size.
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
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?
unsigned getNumOperands() const override
static bool classof(const Init *I)
const Init * getMHS() const
const Init * getRHS() const
const Init * getOperand(unsigned i) const override
const OpInit * clone(ArrayRef< const Init * > Operands) const override
static const TernOpInit * get(TernaryOp opc, const Init *lhs, const Init *mhs, const Init *rhs, const RecTy *Type)
std::string getAsString() const override
Convert this value to a literal form.
const Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
TernOpInit & operator=(const TernOpInit &)=delete
TernaryOp getOpcode() const
This class is used to track the amount of time spent between invocations of its startTimer()/stopTime...
(Optionally) delegate resolving to a sub-resolver, and keep track whether there were unresolved refer...
const Init * resolve(const Init *VarName) override
Return the initializer for the given variable name (should normally be a StringInit),...
bool foundUnresolved() const
TrackUnresolvedResolver(Resolver *R=nullptr)
See the file comment for details on the usage of the TrailingObjects type.
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
const Init * getOperand(unsigned i) const override
UnOpInit & operator=(const UnOpInit &)=delete
static bool classof(const Init *I)
UnaryOp getOpcode() const
unsigned getNumOperands() const override
const OpInit * clone(ArrayRef< const Init * > Operands) const override
static const UnOpInit * get(UnaryOp opc, const Init *lhs, const RecTy *Type)
UnOpInit(const UnOpInit &)=delete
const Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
std::string getAsString() const override
Convert this value to a literal form.
const Init * Fold(const Record *CurRec, bool IsFinal=false) const
'?' - Represents an uninitialized value.
UnsetInit & operator=(const UnsetInit &)=delete
bool isComplete() const override
Is this a complete value with no unset (uninitialized) subvalues?
const Init * getCastTo(const RecTy *Ty) const override
If this value is convertible to type Ty, return a value whose type is Ty, generating a !...
UnsetInit(const UnsetInit &)=delete
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
const Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
const Init * convertInitializerTo(const RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
static UnsetInit * get(RecordKeeper &RK)
Get the singleton unset Init.
static bool classof(const Init *I)
std::string getAsString() const override
Get the string representation of the Init.
RecordKeeper & getRecordKeeper() const
Get the record keeper that initialized this Init.
LLVM Value Representation.
Opcode{0} - Represent access to one bit of a variable or field.
static const VarBitInit * get(const TypedInit *T, unsigned B)
unsigned getBitNum() const
VarBitInit(const VarBitInit &)=delete
std::string getAsString() const override
Convert this value to a literal form.
const Init * getBitVar() const
static bool classof(const Init *I)
const Init * getBit(unsigned B) const override
Get the Init value of the specified bit.
VarBitInit & operator=(const VarBitInit &)=delete
const Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
classname<targs...> - Represent an uninstantiated anonymous class instantiation.
ArrayRef< const ArgumentInit * > args() const
const ArgumentInit * getArg(unsigned i) const
const_iterator args_end() const
static const VarDefInit * get(SMLoc Loc, const Record *Class, ArrayRef< const ArgumentInit * > Args)
const_iterator args_begin() const
const Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
const Init * Fold() const
VarDefInit & operator=(const VarDefInit &)=delete
const Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
const ArgumentInit *const * const_iterator
static bool classof(const Init *I)
VarDefInit(const VarDefInit &)=delete
std::string getAsString() const override
Convert this value to a literal form.
'Opcode' - Represent a reference to an entire variable object.
static const VarInit * get(StringRef VN, const RecTy *T)
VarInit & operator=(const VarInit &)=delete
static bool classof(const Init *I)
const Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
StringRef getName() const
std::string getAsString() const override
Convert this value to a literal form.
VarInit(const VarInit &)=delete
const Init * getNameInit() const
const Init * resolveReferences(Resolver &R) const override
This method is used by classes that refer to other variables which may not be defined at the time the...
std::string getNameInitAsString() const
std::pair< iterator, bool > insert(const ValueT &V)
size_type count(const_arg_type_t< ValueT > V) const
Return 1 if the specified key is in the set, 0 otherwise.
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
void EmitJSON(const RecordKeeper &RK, raw_ostream &OS)
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
std::variant< unsigned, const Init * > ArgAuxType
void EmitDetailedRecords(const RecordKeeper &RK, raw_ostream &OS)
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
const RecTy * resolveTypes(const RecTy *T1, const RecTy *T2)
Find a common type that T1 and T2 convert to.
Sorting predicate to sort record pointers by their unique ID.
bool operator()(const Record *LHS, const Record *RHS) const
Sorting predicate to sort record pointers by their Name field.
bool operator()(const Record *Rec1, const Record *Rec2) const
SmallVector< std::pair< bool, StringRef >, 4 > Parts
RecordParts(StringRef Rec)
std::pair< bool, StringRef > getPart(size_t i)
bool operator()(const Record *Rec1, const Record *Rec2) const
Sorting predicate to sort record pointers by name.
bool operator()(const Record *Rec1, const Record *Rec2) const
AssertionInfo(SMLoc Loc, const Init *Condition, const Init *Message)
DumpInfo(SMLoc Loc, const Init *Message)
This class represents the internal implementation of the RecordKeeper.