51 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
62 assert(RHS &&
"NULL pointer");
69 if (
const BitsRecTy *BitsTy = dyn_cast<BitsRecTy>(RHS))
70 return BitsTy->getNumBits() == 1;
75 static std::vector<BitsRecTy*> Shared;
76 if (Sz >= Shared.size())
77 Shared.resize(Sz + 1);
85 return "bits<" +
utostr(Size) +
">";
90 return cast<BitsRecTy>(RHS)->Size == Size;
109 if (
const auto *ListTy = dyn_cast<ListRecTy>(RHS))
148 if (
RecordRecTy *RecTy1 = dyn_cast<RecordRecTy>(T1)) {
150 for (
const auto &SuperPair1 : RecTy1->getRecord()->getSuperClasses()) {
157 if (
RecordRecTy *RecTy2 = dyn_cast<RecordRecTy>(T2)) {
159 for (
const auto &SuperPair2 : RecTy2->getRecord()->getSuperClasses()) {
173 void Init::anchor() {}
175 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
185 if (
auto *BRT = dyn_cast<BitsRecTy>(Ty)) {
188 for (
unsigned i = 0; i != BRT->getNumBits(); ++i)
202 return V ? &True : &False;
206 if (isa<BitRecTy>(Ty))
207 return const_cast<BitInit *
>(
this);
209 if (isa<IntRecTy>(Ty))
212 if (
auto *BRT = dyn_cast<BitsRecTy>(Ty)) {
214 if (BRT->getNumBits() == 1)
225 for (
Init *
I : Range)
242 std::uninitialized_copy(Range.
begin(), Range.
end(),
253 if (isa<BitRecTy>(Ty)) {
258 if (
auto *BRT = dyn_cast<BitsRecTy>(Ty)) {
261 if (
getNumBits() != BRT->getNumBits())
return nullptr;
262 return const_cast<BitsInit *
>(
this);
265 if (isa<IntRecTy>(Ty)) {
267 for (
unsigned i = 0, e =
getNumBits(); i != e; ++i)
268 if (
auto *
Bit = dyn_cast<BitInit>(
getBit(i)))
269 Result |=
static_cast<int64_t
>(
Bit->getValue()) << i;
282 for (
unsigned i = 0, e = Bits.
size(); i != e; ++i) {
285 NewBits[i] =
getBit(Bits[i]);
291 std::string Result =
"{ ";
292 for (
unsigned i = 0, e =
getNumBits(); i != e; ++i) {
293 if (i) Result +=
", ";
295 Result +=
Bit->getAsString();
299 return Result +
" }";
306 if (RV || !isa<UnsetInit>(After))
314 bool Changed =
false;
317 Init *CachedInit =
nullptr;
318 Init *CachedBitVar =
nullptr;
319 bool CachedBitVarChanged =
false;
321 for (
unsigned i = 0, e =
getNumBits(); i != e; ++i) {
327 if (CurBitVar == CachedBitVar) {
328 if (CachedBitVarChanged) {
334 CachedBitVar = CurBitVar;
335 CachedBitVarChanged =
false;
341 CachedBitVarChanged |= B != CurBitVar;
342 Changed |= B != CurBitVar;
343 }
while (B != CurBitVar);
344 CachedInit = CurBitVar;
346 if (CachedBitVarChanged) {
355 return const_cast<BitsInit *
>(
this);
372 return (NumBits >=
sizeof(Value) * 8) ||
373 (Value >> NumBits == 0) || (Value >> (NumBits-1) == -1);
377 if (isa<IntRecTy>(Ty))
378 return const_cast<IntInit *
>(
this);
380 if (isa<BitRecTy>(Ty)) {
382 if (Val != 0 && Val != 1)
return nullptr;
386 if (
auto *BRT = dyn_cast<BitsRecTy>(Ty)) {
393 for (
unsigned i = 0; i != BRT->getNumBits(); ++i)
406 for (
unsigned i = 0, e = Bits.
size(); i != e; ++i) {
418 auto &Entry = *ThePool.
insert(std::make_pair(V,
nullptr)).first;
427 auto &Entry = *ThePool.
insert(std::make_pair(V,
nullptr)).first;
434 if (isa<StringRecTy>(Ty))
441 if (isa<CodeRecTy>(Ty))
442 return const_cast<CodeInit *
>(
this);
453 for (
Init *
I : Range)
470 std::uninitialized_copy(Range.
begin(), Range.
end(),
477 RecTy *EltTy = cast<ListRecTy>(
getType())->getElementType();
486 if (
auto *LRT = dyn_cast<ListRecTy>(Ty)) {
492 bool Changed =
false;
493 RecTy *ElementType = LRT->getElementType();
495 if (
Init *CI =
I->convertInitializerTo(ElementType)) {
513 for (
unsigned Element : Elements) {
514 if (Element >=
size())
522 assert(i < NumValues &&
"List element index out of range!");
532 bool Changed =
false;
540 Changed |= E != CurElt;
541 }
while (E != CurElt);
547 return const_cast<ListInit *
>(
this);
551 unsigned Elt)
const {
558 if (IRV || !isa<UnsetInit>(E))
564 std::string Result =
"[";
565 const char *sep =
"";
566 for (
Init *Element : *
this) {
575 unsigned Elt)
const {
579 Resolved = OResolved->
Fold(&R,
nullptr);
582 if (Resolved !=
this) {
583 TypedInit *Typed = cast<TypedInit>(Resolved);
594 return const_cast<OpInit*
>(
this);
627 if (isa<StringRecTy>(
getType())) {
628 if (
StringInit *LHSs = dyn_cast<StringInit>(LHS))
631 if (
DefInit *LHSd = dyn_cast<DefInit>(LHS))
634 if (
IntInit *LHSi = dyn_cast<IntInit>(LHS))
641 if (RV->getType() !=
getType())
651 assert(RV &&
"Template arg doesn't exist??");
666 assert(RV &&
"Template arg doesn't exist??");
674 assert(CurRec &&
"NULL pointer");
679 "Undefined reference:'" +
Name->getValue() +
"'\n");
682 if (isa<IntRecTy>(
getType())) {
683 if (
BitsInit *BI = dyn_cast<BitsInit>(LHS)) {
693 if (
ListInit *LHSl = dyn_cast<ListInit>(LHS)) {
694 assert(!LHSl->empty() &&
"Empty list in head");
695 return LHSl->getElement(0);
700 if (
ListInit *LHSl = dyn_cast<ListInit>(LHS)) {
701 assert(!LHSl->empty() &&
"Empty list in tail");
704 return ListInit::get(LHSl->getValues().slice(1), LHSl->getType());
709 if (
ListInit *LHSl = dyn_cast<ListInit>(LHS))
711 if (
StringInit *LHSs = dyn_cast<StringInit>(LHS))
715 return const_cast<UnOpInit *
>(
this);
723 return Fold(&R,
nullptr);
730 case HEAD: Result =
"!head";
break;
731 case TAIL: Result =
"!tail";
break;
732 case EMPTY: Result =
"!empty";
break;
781 if (!LOp || !ROp || LOp->
getDef() != ROp->getDef())
785 for (
unsigned i = 0, e = LHSs->
getNumArgs(); i != e; ++i) {
789 for (
unsigned i = 0, e = RHSs->getNumArgs(); i != e; ++i) {
803 Args.
insert(Args.
end(), RHSs->begin(), RHSs->end());
805 Args, cast<ListRecTy>(LHSs->
getType())->getElementType());
832 return IntInit::get(LHSs->getValue() == RHSs->getValue());
847 int64_t LHSv = LHSi->
getValue(), RHSv = RHSi->getValue();
851 case ADD: Result = LHSv + RHSv;
break;
852 case AND: Result = LHSv & RHSv;
break;
853 case OR: Result = LHSv | RHSv;
break;
854 case SHL: Result = LHSv << RHSv;
break;
855 case SRA: Result = LHSv >> RHSv;
break;
856 case SRL: Result = (uint64_t)LHSv >> (uint64_t)RHSv;
break;
870 if (LHS != lhs || RHS != rhs)
872 return Fold(&R,
nullptr);
878 case CONCAT: Result =
"!con";
break;
879 case ADD: Result =
"!add";
break;
880 case AND: Result =
"!and";
break;
881 case OR: Result =
"!or";
break;
882 case SHL: Result =
"!shl";
break;
883 case SRA: Result =
"!sra";
break;
884 case SRL: Result =
"!srl";
break;
885 case EQ: Result =
"!eq";
break;
886 case LISTCONCAT: Result =
"!listconcat";
break;
887 case STRCONCAT: Result =
"!strconcat";
break;
929 if (
auto *TArg = dyn_cast<TypedInit>(Arg))
930 if (isa<DagRecTy>(TArg->getType()))
931 return ForeachHelper(LHS, Arg, RHSo, Type, CurRec, CurMultiClass);
936 if (
auto *RHSoo = dyn_cast<OpInit>(RHSo->
getOperand(i))) {
938 Type, CurRec, CurMultiClass))
951 Init *NewVal = NewOp->
Fold(CurRec, CurMultiClass);
952 return (NewVal != NewOp) ? NewVal :
nullptr;
968 if (MHSd && isa<DagRecTy>(Type)) {
969 Init *Val = MHSd->getOperator();
971 Type, CurRec, CurMultiClass))
975 for (
unsigned int i = 0; i < MHSd->getNumArgs(); ++i) {
976 Init *Arg = MHSd->getArg(i);
981 CurRec, CurMultiClass))
985 args.
push_back(std::make_pair(Arg, ArgName));
992 if (MHSl && isa<ListRecTy>(Type)) {
996 for (
Init *&Item : NewList) {
1008 Init *NewItem = NewOp->
Fold(CurRec, CurMultiClass);
1009 if (NewItem != NewOp)
1032 if (LHSd && MHSd && RHSd) {
1033 Record *Val = RHSd->getDef();
1035 Val = MHSd->getDef();
1038 if (LHSv && MHSv && RHSv) {
1039 std::string Val = RHSv->getName();
1040 if (LHSv->getAsString() == RHSv->getAsString())
1041 Val = MHSv->getName();
1044 if (LHSs && MHSs && RHSs) {
1045 std::string Val = RHSs->getValue();
1047 std::string::size_type found;
1048 std::string::size_type idx = 0;
1050 found = Val.find(LHSs->getValue(), idx);
1051 if (found == std::string::npos)
1053 Val.replace(found, LHSs->getValue().size(), MHSs->getValue());
1054 idx = found + MHSs->getValue().size();
1064 CurRec, CurMultiClass))
1072 LHSi = dyn_cast<IntInit>(
I);
1092 Value = dyn_cast<IntInit>(
I);
1098 RHS,
getType()))->Fold(&R,
nullptr);
1102 rhs,
getType()))->Fold(&R,
nullptr);
1109 if (LHS != lhs || MHS != mhs || RHS != rhs)
1111 getType()))->Fold(&R,
nullptr);
1112 return Fold(&R,
nullptr);
1118 case SUBST: Result =
"!subst";
break;
1119 case FOREACH: Result =
"!foreach";
break;
1120 case IF: Result =
"!if";
break;
1128 if (
RecordVal *
Field = RecordType->getRecord()->getValue(FieldName))
1129 return Field->getType();
1135 if (isa<IntRecTy>(Ty)) {
1136 if (
getType()->typeIsConvertibleTo(Ty))
1141 if (isa<StringRecTy>(Ty)) {
1142 if (isa<StringRecTy>(
getType()))
1143 return const_cast<TypedInit *>(
this);
1147 if (isa<CodeRecTy>(Ty)) {
1148 if (isa<CodeRecTy>(
getType()))
1149 return const_cast<TypedInit *>(
this);
1153 if (isa<BitRecTy>(Ty)) {
1156 return const_cast<TypedInit *>(
this);
1157 if (
auto *BitsTy = dyn_cast<BitsRecTy>(
getType())) {
1159 if (BitsTy->getNumBits() == 1)
1160 return const_cast<TypedInit *>(
this);
1165 if (
const auto *TOI = dyn_cast<TernOpInit>(
this)) {
1169 return const_cast<TypedInit *>(
this);
1175 if (
auto *BRT = dyn_cast<BitsRecTy>(Ty)) {
1176 if (BRT->getNumBits() == 1 && isa<BitRecTy>(
getType()))
1179 if (
getType()->typeIsConvertibleTo(BRT)) {
1182 for (
unsigned i = 0; i != BRT->getNumBits(); ++i)
1190 if (
auto *DLRT = dyn_cast<ListRecTy>(Ty)) {
1191 if (
auto *SLRT = dyn_cast<ListRecTy>(
getType()))
1192 if (SLRT->getElementType()->typeIsConvertibleTo(DLRT->getElementType()))
1197 if (
auto *DRT = dyn_cast<DagRecTy>(Ty)) {
1199 return const_cast<TypedInit *>(
this);
1203 if (
auto *SRRT = dyn_cast<RecordRecTy>(Ty)) {
1206 if (DRRT->getRecord()->isSubClassOf(SRRT->getRecord()) ||
1207 DRRT->getRecord() == SRRT->getRecord())
1208 return const_cast<TypedInit *>(
this);
1217 if (!T)
return nullptr;
1222 for (
unsigned Bit : Bits) {
1233 if (!T)
return nullptr;
1235 if (Elements.
size() == 1)
1240 for (
unsigned Element : Elements)
1253 using Key = std::pair<RecTy *, Init *>;
1256 Key TheKey(std::make_pair(T, VN));
1271 return const_cast<VarInit*
>(
this);
1277 unsigned Elt)
const {
1282 assert(RV &&
"Reference to a non-existent variable?");
1287 if (Elt >= LI->
size())
1293 if (IRV || !isa<UnsetInit>(E))
1301 return RV->getType();
1307 if (isa<RecordRecTy>(
getType()))
1309 if (RV != Val && (RV || isa<UnsetInit>(Val->getValue())))
1311 Init *TheInit = Val->getValue();
1312 assert(TheInit !=
this &&
"Infinite loop detected!");
1322 if (RV == Val || (!RV && !isa<UnsetInit>(Val->getValue())))
1323 return Val->getValue();
1324 return const_cast<VarInit *
>(
this);
1328 using Key = std::pair<TypedInit *, unsigned>;
1331 Key TheKey(std::make_pair(T, B));
1340 if (isa<BitRecTy>(Ty))
1360 using Key = std::pair<TypedInit *, unsigned>;
1363 Key TheKey(std::make_pair(T, E));
1390 unsigned Elt)
const {
1392 if (
TypedInit *TInit = dyn_cast<TypedInit>(Result)) {
1393 if (
Init *Result2 = TInit->resolveListElementReference(R, RV, Elt))
1408 if (
auto *RRT = dyn_cast<RecordRecTy>(Ty))
1409 if (
getDef()->isSubClassOf(RRT->getRecord()))
1410 return const_cast<DefInit *
>(
this);
1416 return RV->getType();
1430 using Key = std::pair<Init *, StringInit *>;
1433 Key TheKey(std::make_pair(R, FN));
1447 unsigned Elt)
const {
1449 if (
ListInit *LI = dyn_cast<ListInit>(ListVal)) {
1450 if (Elt >= LI->size())
return nullptr;
1451 Init *
E = LI->getElement(Elt);
1456 if (RV || !isa<UnsetInit>(E))
1483 while (Arg != ArgRange.
end()) {
1484 assert(Name != NameRange.
end() &&
"Arg name underflow!");
1488 assert(Name == NameRange.
end() &&
"Arg name overflow!");
1505 std::uninitialized_copy(ArgRange.
begin(), ArgRange.
end(),
1507 std::uninitialized_copy(NameRange.
begin(), NameRange.
end(),
1515 ArrayRef<std::pair<Init*, StringInit*>> args) {
1519 for (
const auto &Arg : args) {
1532 if (isa<DagRecTy>(Ty))
1533 return const_cast<DagInit *
>(
this);
1541 bool ArgsChanged =
false;
1545 ArgsChanged |= NewArg != Arg;
1549 if (Op != Val || ArgsChanged)
1552 return const_cast<DagInit *
>(
this);
1562 for (
unsigned i = 1, e =
getNumArgs(); i != e; ++i) {
1567 return Result +
")";
1575 :
Name(N), TyAndPrefix(T, P) {
1577 assert(
Value &&
"Cannot create unset value for current type!");
1584 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1595 if (PrintSem) OS <<
";\n";
1598 unsigned Record::LastID = 0;
1600 void Record::init() {
1608 void Record::checkName() {
1610 const TypedInit *TypedName = cast<const TypedInit>(Name);
1611 if (!isa<StringRecTy>(TypedName->
getType()))
1622 return cast<StringInit>(Name)->
getValue();
1646 if (
Value.setValue(V->resolveReferences(*
this, RV)))
1648 Value.getNameInitAsString() +
1649 "' after resolving references" +
1657 if (NewName != OldName) {
1663 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1671 if (!TArgs.
empty()) {
1673 bool NeedComma =
false;
1674 for (
const Init *
TA : TArgs) {
1675 if (NeedComma) OS <<
", ";
1678 assert(RV &&
"Template argument record not found??");
1679 RV->
print(OS,
false);
1688 for (
const auto &SuperPair : SC)
1689 OS <<
" " << SuperPair.first->getNameInitAsString();
1697 if (!Val.getPrefix() && !R.
isTemplateArg(Val.getNameInit()))
1707 "' does not have a field named `" + FieldName +
"'!\n");
1715 "' does not have a field named `" + FieldName +
"'!\n");
1718 return SI->getValue();
1720 return CI->getValue();
1723 FieldName +
"' does not have a string initializer!");
1730 "' does not have a field named `" + FieldName +
"'!\n");
1735 FieldName +
"' does not have a BitsInit initializer!");
1742 "' does not have a field named `" + FieldName +
"'!\n");
1747 FieldName +
"' does not have a list initializer!");
1750 std::vector<Record*>
1753 std::vector<Record*> Defs;
1755 if (
DefInit *DI = dyn_cast<DefInit>(
I))
1756 Defs.push_back(DI->getDef());
1759 FieldName +
"' list is not entirely DefInit!");
1768 "' does not have a field named `" + FieldName +
"'!\n");
1771 return II->getValue();
1773 FieldName +
"' does not have an int initializer!");
1776 std::vector<int64_t>
1779 std::vector<int64_t> Ints;
1781 if (
IntInit *II = dyn_cast<IntInit>(
I))
1782 Ints.push_back(II->getValue());
1785 FieldName +
"' does not have a list of ints initializer!");
1790 std::vector<StringRef>
1793 std::vector<StringRef> Strings;
1796 Strings.push_back(
SI->getValue());
1799 FieldName +
"' does not have a list of strings initializer!");
1808 "' does not have a field named `" + FieldName +
"'!\n");
1811 return DI->getDef();
1813 FieldName +
"' does not have a def initializer!");
1820 "' does not have a field named `" + FieldName +
"'!\n");
1823 return BI->getValue();
1825 FieldName +
"' does not have a bit initializer!");
1832 "' does not have a field named `" + FieldName.
str() +
"'!\n");
1834 if (isa<UnsetInit>(R->
getValue())) {
1840 return BI->getValue();
1842 FieldName +
"' does not have a bit initializer!");
1849 "' does not have a field named `" + FieldName +
"'!\n");
1854 FieldName +
"' does not have a dag initializer!");
1857 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1859 errs() <<
"Record:\n";
1862 errs() <<
"Defs:\n";
1871 OS <<
"------------- Classes -----------------\n";
1873 OS <<
"class " << *
C.second;
1875 OS <<
"------------- Defs -----------------\n";
1877 OS <<
"def " << *
D.second;
1881 std::vector<Record *>
1885 PrintFatalError(
"ERROR: Couldn't find the `" + ClassName +
"' class!\n");
1887 std::vector<Record*> Defs;
1889 if (
D.second->isSubClassOf(Class))
1890 Defs.push_back(
D.second.get());
1897 if (
const StringInit *I0s = dyn_cast<StringInit>(I0))
1898 if (
const StringInit *I1s = dyn_cast<StringInit>(I1))
1907 if (CurMultiClass && Scoper !=
"::") {
1913 if (
BinOpInit *BinOp = dyn_cast<BinOpInit>(NewName))
1914 NewName = BinOp->Fold(&CurRec, CurMultiClass);
Init * resolveReferences(Record &R, const RecordVal *RV) const override
This method is used by classes that refer to other variables which may not be defined at the time the...
static BinOpInit * get(BinaryOp opc, Init *lhs, Init *rhs, RecTy *Type)
static Init * GetStrConcat(Init *I0, Init *I1)
void AddPointer(const void *Ptr)
Add* - Add various data types to Bit data.
Init * convertInitializerTo(RecTy *Ty) const override
This virtual function converts to the appropriate Init based on the passed in type.
void print(raw_ostream &OS) const
void push_back(const T &Elt)
Init * resolveReferences(Record &R, const RecordVal *RV) const override
This method is used by classes that refer to other variables which may not be defined at the time the...
Init * resolveReferences(Record &R, const RecordVal *RV) const override
This method is used by classes that refer to other variables which may not be defined at the time the...
RecTyKind
Subclass discriminator (for dyn_cast<> et al.)
ArrayRef< StringInit * > getArgNames() const
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
virtual bool isComplete() const
This virtual method should be overridden by values that may not be completely specified yet...
StringRef getValueAsString(StringRef FieldName) const
This method looks up the specified field and returns its value as a string, throwing an exception if ...
void Profile(FoldingSetNodeID &ID) const
unsigned getNumBits() const
unsigned getNumArgs() const
bool getValueAsBit(StringRef FieldName) const
This method looks up the specified field and returns its value as a bit, throwing an exception if the...
X.Y - Represent a reference to a subfield of a variable.
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds...
Init * convertInitializerBitRange(ArrayRef< unsigned > Bits) const override
This method is used to implement the bitrange selection operator.
[AL, AH, CL] - Represent a list of defs
'7' - Represent an initialization by a literal integer value.
'list<Ty>' - Represent a list of values, all of which must be of the specified type.
!op (X, Y) - Combine two inits.
Init * getBit(unsigned Bit) const override
This method is used to return the initializer for the specified bit.
Record * getElementAsRecord(unsigned i) const
virtual bool typeIsConvertibleTo(const RecTy *RHS) const
Return true if all values of 'this' type can be converted to the specified type.
Init * resolveReferences(Record &R, const RecordVal *RV) const override
This method is used by classes that refer to other variables which may not be defined at the time the...
Init * convertInitializerTo(RecTy *Ty) const override
This virtual function converts to the appropriate Init based on the passed in type.
AL - Represent a reference to a 'def' in the description.
StringRef getName() const
std::string getNameInitAsString() const
T * FindNodeOrInsertPos(const FoldingSetNodeID &ID, void *&InsertPos)
FindNodeOrInsertPos - Look up the node specified by ID.
static UnOpInit * get(UnaryOp opc, Init *lhs, RecTy *Type)
Init * resolveListElementReference(Record &R, const RecordVal *RV, unsigned Elt) const override
This method is used to implement VarListElementInit::resolveReferences.
Init * convertInitializerBitRange(ArrayRef< unsigned > Bits) const override
This method is used to implement the bitrange selection operator.
Init * getValueInit(StringRef FieldName) const
Return the initializer for a value with the specified name, or throw an exception if the field does n...
RecTy * getFieldType(StringInit *FieldName) const override
This method is used to implement the FieldInit class.
Init * resolveListElementReference(Record &R, const RecordVal *RV, unsigned Elt) const override
This method is used to implement VarListElementInit::resolveReferences.
Init * resolveReferences(Record &R, const RecordVal *RV) const override
This method is used by classes that refer to other variables which may not be defined at the time the...
StringInit * getArgName(unsigned Num) const
std::string getAsString() const override
Convert this value to a string form.
Init * Fold(Record *CurRec, MultiClass *CurMultiClass) const override
void Profile(FoldingSetNodeID &ID) const
BinaryOp getOpcode() const
Record * getValueAsDef(StringRef FieldName) const
This method looks up the specified field and returns its value as a Record, throwing an exception if ...
static VarInit * get(StringRef VN, RecTy *T)
Init * getElement(unsigned i) const
static BumpPtrAllocator Allocator
void reserve(size_type N)
Init * getOperator() const
'{ a, b, c }' - Represents an initializer for a BitsRecTy value.
std::string getAsString() const override
virtual std::string getAsUnquotedString() const
Convert this value to a string form, without adding quote markers.
ArrayRef< Init * > getTemplateArgs() const
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
void print(raw_ostream &OS) const
Print out this value.
static IntInit * get(int64_t V)
'?' - Represents an uninitialized value
'true'/'false' - Represent a concrete initializer for a bit.
Init * convertInitializerBitRange(ArrayRef< unsigned > Bits) const override
This method is used to implement the bitrange selection operator.
StringRef getName() const
static BitsRecTy * get(unsigned Sz)
virtual Init * resolveListElementReference(Record &R, const RecordVal *RV, unsigned Elt) const =0
This method is used to implement VarListElementInit::resolveReferences.
This is the common super-class of types that have a specific, explicit, type.
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
static void ProfileBitsInit(FoldingSetNodeID &ID, ArrayRef< Init * > Range)
bool typeIsConvertibleTo(const RecTy *RHS) const override
Return true if all values of 'this' type can be converted to the specified type.
Init * getBit(unsigned Bit) const override
This method is used to return the initializer for the specified bit.
static StringRecTy * get()
static DagInit * get(Init *V, StringInit *VN, ArrayRef< Init * > ArgRange, ArrayRef< StringInit * > NameRange)
Init * getOperand() const
std::string getAsString() const override
std::string getAsString() const override
List[4] - Represent access to one element of a var or field.
'[classname]' - Represent an instance of a class, such as: (R32 X = EAX).
Init * convertInitializerTo(RecTy *Ty) const override
This virtual function converts to the appropriate Init based on the passed in type.
std::string getAsString() const override
Convert this value to a string form.
StringRef getName() const
void AddInteger(signed I)
Init * resolveReferences(Record &R, const RecordVal *RV) const override
This method is used by classes that refer to other variables which may not be defined at the time the...
static Init * ForeachHelper(Init *LHS, Init *MHS, Init *RHS, RecTy *Type, Record *CurRec, MultiClass *CurMultiClass)
virtual Init * getFieldInit(Record &R, const RecordVal *RV, StringInit *FieldName) const
This method complements getFieldType to return the initializer for the specified field.
std::string getAsString() const override
Convert this value to a string form.
virtual unsigned getNumOperands() const =0
void print(raw_ostream &OS, bool PrintSem=true) 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 InsertNode(T *N, void *InsertPos)
InsertNode - Insert the specified node into the folding set, knowing that it is not already in the fo...
const_iterator begin() const
const T * getTrailingObjects() const
Returns a pointer to the trailing object array of the given type (which must be one of those specifie...
std::vector< StringRef > getValueAsListOfStrings(StringRef FieldName) const
This method looks up the specified field and returns its value as a vector of strings, throwing an exception if the field does not exist or if the value is not the right type.
'bits<n>' - Represent a fixed number of bits
ListInit * getValueAsListInit(StringRef FieldName) const
This method looks up the specified field and returns its value as a ListInit, throwing an exception i...
Init * resolveReferences(Record &R, const RecordVal *RV) const override
This method is used by classes that refer to other variables which may not be defined at the time the...
const std::string getNameInitAsString() const
Init * getArg(unsigned Num) const
void Profile(FoldingSetNodeID &ID) const
std::string getAsString() const override
Convert this value to a string form.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
static std::string utostr(uint64_t X, bool isNeg=false)
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
virtual unsigned getBitNum() const
This method is used to retrieve the bit number of a bit reference.
Init * Fold(Record *CurRec, MultiClass *CurMultiClass) const override
virtual Init * getBit(unsigned Bit) const =0
This method is used to return the initializer for the specified bit.
DagInit * getValueAsDag(StringRef FieldName) const
This method looks up the specified field and returns its value as an Dag, throwing an exception if th...
Init * resolveListElementReference(Record &R, const RecordVal *RV, unsigned Elt) const override
This method is used to implement VarListElementInit::resolveReferences.
virtual Init * getOperand(unsigned i) const =0
size_t size() const
size - Get the array size.
Init * convertInitListSlice(ArrayRef< unsigned > Elements) const override
This method is used to implement the list slice selection operator.
'code' - Represent a code fragment
static BitsInit * get(ArrayRef< Init * > Range)
void resolveReferencesTo(const RecordVal *RV)
If anything in this record refers to RV, replace the reference to RV with the RHS of RV...
Init * convertInitializerTo(RecTy *Ty) const override
This virtual function converts to the appropriate Init based on the passed in type.
std::vector< Record * > getAllDerivedDefinitions(StringRef ClassName) const
This method returns all concrete definitions that derive from the specified class name...
virtual Init * convertInitializerTo(RecTy *Ty) const =0
This virtual function converts to the appropriate Init based on the passed in type.
void append(in_iter S, in_iter E)
Append from an iterator pair.
Init * convertInitializerTo(RecTy *Ty) const override
This virtual function converts to the appropriate Init based on the passed in type.
bool typeIsConvertibleTo(const RecTy *RHS) const override
Return true if all values of 'this' type can be converted to the specified type.
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
void dump() const
Debugging method that may be called through a debugger, just invokes print on stderr.
Base class for operators.
Init * convertInitializerTo(RecTy *Ty) const override
This virtual function converts to the appropriate Init based on the passed in type.
void Profile(FoldingSetNodeID &ID) const
ArrayRef< Init * > getArgs() const
bool typeIsConvertibleTo(const RecTy *RHS) const override
Return true if all values of 'this' type can be converted to the specified type.
The instances of the Type class are immutable: once they are created, they are never changed...
Allocate memory in an ever growing pool, as if by bump-pointer.
virtual OpInit * clone(ArrayRef< Init * > Operands) const =0
Init * resolveListElementReference(Record &R, const RecordVal *RV, unsigned Elt) const override
This method is used to implement VarListElementInit::resolveReferences.
"foo" - Represent an initialization by a string value.
RecTy * getFieldType(StringInit *FieldName) const override
This method is used to implement the FieldInit class.
RecordVector DefPrototypes
static void ProfileTernOpInit(FoldingSetNodeID &ID, unsigned Opcode, Init *LHS, Init *MHS, Init *RHS, RecTy *Type)
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
void Profile(FoldingSetNodeID &ID) const
LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * Allocate(size_t Size, size_t Alignment)
Allocate space at the specified alignment.
static void ProfileUnOpInit(FoldingSetNodeID &ID, unsigned Opcode, Init *Op, RecTy *Type)
!op (X) - Transform an init.
TypedInit * getVariable() const
Init * convertInitializerTo(RecTy *Ty) const override
This virtual function converts to the appropriate Init based on the passed in type.
const RecordVal * getValue(const Init *Name) const
for(unsigned i=0, e=MI->getNumOperands();i!=e;++i)
std::vector< int64_t > getValueAsListOfInts(StringRef FieldName) const
This method looks up the specified field and returns its value as a vector of integers, throwing an exception if the field does not exist or if the value is not the right type.
'string' - Represent an string value
RecTyKind getRecTyKind() const
static BitInit * get(bool V)
static bool canFitInBitfield(int64_t Value, unsigned NumBits)
bool empty() const
empty - Check if the array is empty.
std::string getAsString() const override
Convert this value to a string form.
static CodeInit * get(StringRef)
static void ProfileBinOpInit(FoldingSetNodeID &ID, unsigned Opcode, Init *LHS, Init *RHS, RecTy *Type)
ArrayRef< Init * > getValues() const
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
DefInit * getDefInit()
get the corresponding DefInit.
static std::string itostr(int64_t X)
std::vector< Record * > getValueAsListOfDefs(StringRef FieldName) const
This method looks up the specified field and returns its value as a vector of records, throwing an exception if the field does not exist or if the value is not the right type.
FoldingSet - This template class is used to instantiate a specialized implementation of the folding s...
std::string getAsString() const override
Convert this value to a string form.
virtual Init * resolveReferences(Record &R, const RecordVal *RV) const
This method is used by classes that refer to other variables which may not be defined at the time the...
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...
const RecordMap & getClasses() const
Init * convertInitializerTo(RecTy *Ty) const override
This virtual function converts to the appropriate Init based on the passed in type.
virtual Init * Fold(Record *CurRec, MultiClass *CurMultiClass) const =0
static FieldInit * get(Init *R, StringInit *FN)
static Init * EvaluateOperation(OpInit *RHSo, Init *LHS, Init *Arg, RecTy *Type, Record *CurRec, MultiClass *CurMultiClass)
std::string getAsString() const override
Init * convertInitListSlice(ArrayRef< unsigned > Elements) const override
This method is used to implement the list slice selection operator.
static StringInit * ConcatStringInits(const StringInit *I0, const StringInit *I1)
ArrayRef< SMLoc > getLoc() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
static VarBitInit * get(TypedInit *T, unsigned B)
static StringInit * get(StringRef)
Init * QualifyName(Record &CurRec, MultiClass *CurMultiClass, Init *Name, StringRef Scoper)
Return an Init with a qualifier prefix referring to CurRec's name.
static RecordRecTy * get(Record *R)
std::string getAsString() const override
Convert this value to a string form.
CHAIN = SC CHAIN, Imm128 - System call.
Init * convertInitializerTo(RecTy *Ty) const override
This virtual function converts to the appropriate Init based on the passed in type.
Init * getNameInit() const
const_iterator end() const
Init * getNameInit() const
static DefInit * get(Record *)
Record * getClass(StringRef Name) const
Init * convertInitializerTo(RecTy *Ty) const override
This virtual function converts to the appropriate Init based on the passed in type.
Init * getFieldInit(Record &R, const RecordVal *RV, StringInit *FieldName) const override
This method complements getFieldType to return the initializer for the specified field.
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
Init * resolveReferences(Record &R, const RecordVal *RV) const override
This method is used by classes that refer to other variables which may not be defined at the time the...
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
unsigned getElementNum() const
static void ProfileListInit(FoldingSetNodeID &ID, ArrayRef< Init * > Range, RecTy *EltTy)
LLVM_ATTRIBUTE_NORETURN void PrintFatalError(const Twine &Msg)
bool isTemplateArg(Init *Name) const
const RecordMap & getDefs() const
iterator insert(iterator I, T &&Elt)
Init * getBit(unsigned Bit) const override
This method is used to return the initializer for the specified bit.
'int' - Represent an integer value of no particular size
static Init * fixBitInit(const RecordVal *RV, Init *Before, Init *After)
llvm_unreachable("Unknown RegBank!")
ArrayRef< RecordVal > getValues() const
Init * resolveListElementReference(Record &R, const RecordVal *RV, unsigned Elt) const override
This method is used to implement VarListElementInit::resolveReferences.
Init * getBit(unsigned Bit) const override
This method is used to return the initializer for the specified bit.
RecordKeeper & getRecords() const
static MachineInstr * getDef(unsigned Reg, const MachineRegisterInfo *MRI)
std::string getAsString() const override
Convert this value to a string form.
bool typeIsConvertibleTo(const RecTy *RHS) const override
Return true if all values of 'this' type can be converted to the specified type.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
unsigned getNumBits() const
virtual Init * getBitVar() const
This method is used to retrieve the initializer for bit reference.
bool isSubClassOf(const Record *R) const
bool typeIsConvertibleTo(const RecTy *RHS) const override
Return true if all values of 'this' type can be converted to the specified type.
void addValue(const RecordVal &RV)
static TernOpInit * get(TernaryOp opc, Init *lhs, Init *mhs, Init *rhs, RecTy *Type)
static VarListElementInit * get(TypedInit *T, unsigned E)
RecTy * resolveTypes(RecTy *T1, RecTy *T2)
Find a common type that T1 and T2 convert to.
Opcode{0} - Represent access to one bit of a variable or field.
'Opcode' - Represent a reference to an entire variable object.
static ListInit * get(ArrayRef< Init * > Range, RecTy *EltTy)
std::string getAsString() const override
Convert this value to a string form.
std::string getAsString() const override
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
UnaryOp getOpcode() const
'bit' - Represent a single bit
!op (X, Y, Z) - Combine two inits.
Init * Fold(Record *CurRec, MultiClass *CurMultiClass) const override
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
Record * getRecord() const
bool getValueAsBitOrUnset(StringRef FieldName, bool &Unset) const
This method looks up the specified field and returns its value as a bit.
Init * resolveReferences(Record &R, const RecordVal *RV) const override
This method is used by classes that refer to other variables which may not be defined at the time the...
'dag' - Represent a dag fragment
Init * resolveReferences(Record &R, const RecordVal *RV) const override
This method is used by classes that refer to other variables which may not be defined at the time the...
static void ProfileDagInit(FoldingSetNodeID &ID, Init *V, StringInit *VN, ArrayRef< Init * > ArgRange, ArrayRef< StringInit * > NameRange)
Init * getFieldInit(Record &R, const RecordVal *RV, StringInit *FieldName) const override
This method complements getFieldType to return the initializer for the specified field.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Init * getBit(unsigned Bit) const override
This method is used to return the initializer for the specified bit.
StringRef getValue() const
Init * getNameInit() const
LLVM Value Representation.
(v a, b) - Represent a DAG tree value.
virtual std::string getAsString() const =0
Convert this value to a string form.
This class implements an extremely fast bulk output stream that can only output to a stream...
TernaryOp getOpcode() const
StringRef - Represent a constant reference to a string, i.e.
unsigned getBitNum() const override
This method is used to retrieve the bit number of a bit reference.
std::string getAsUnquotedString() const override
Convert this value to a string form, without adding quote markers.
void Profile(FoldingSetNodeID &ID) const
virtual std::string getAsString() const =0
Init * convertInitializerTo(RecTy *Ty) const override
This virtual function converts to the appropriate Init based on the passed in type.
ListRecTy * getListTy()
Returns the type representing list<this>.
ArrayRef< std::pair< Record *, SMRange > > getSuperClasses() const
RecTy * getFieldType(StringInit *FieldName) const override
This method is used to implement the FieldInit class.
std::string getAsString() const override
Convert this value to a string form.
RecordVal(Init *N, RecTy *T, bool P)