52 assert(RHS &&
"NULL pointer");
59 if (
const BitsRecTy *BitsTy = dyn_cast<BitsRecTy>(RHS))
60 return BitsTy->getNumBits() == 1;
65 static std::vector<BitsRecTy*> Shared;
66 if (Sz >= Shared.size())
67 Shared.resize(Sz + 1);
75 return "bits<" +
utostr(Size) +
">";
80 return cast<BitsRecTy>(RHS)->Size == Size;
99 if (
const auto *ListTy = dyn_cast<ListRecTy>(RHS))
138 if (
RecordRecTy *RecTy1 = dyn_cast<RecordRecTy>(T1)) {
140 for (
const auto &SuperPair1 : RecTy1->getRecord()->getSuperClasses()) {
147 if (
RecordRecTy *RecTy2 = dyn_cast<RecordRecTy>(T2)) {
149 for (
const auto &SuperPair2 : RecTy2->getRecord()->getSuperClasses()) {
163 void Init::anchor() { }
172 if (
auto *BRT = dyn_cast<BitsRecTy>(Ty)) {
175 for (
unsigned i = 0;
i != BRT->getNumBits(); ++
i)
189 return V ? &True : &False;
193 if (isa<BitRecTy>(Ty))
194 return const_cast<BitInit *
>(
this);
196 if (isa<IntRecTy>(Ty))
199 if (
auto *BRT = dyn_cast<BitsRecTy>(Ty)) {
201 if (BRT->getNumBits() == 1)
212 for (
Init *
I : Range)
218 static std::vector<BitsInit*> TheActualPool;
230 std::uninitialized_copy(Range.
begin(), Range.
end(),
233 TheActualPool.push_back(I);
242 if (isa<BitRecTy>(Ty)) {
247 if (
auto *BRT = dyn_cast<BitsRecTy>(Ty)) {
250 if (
getNumBits() != BRT->getNumBits())
return nullptr;
251 return const_cast<BitsInit *
>(
this);
254 if (isa<IntRecTy>(Ty)) {
258 Result |=
static_cast<int64_t
>(
Bit->getValue()) <<
i;
271 for (
unsigned i = 0, e = Bits.
size();
i != e; ++
i) {
280 std::string Result =
"{ ";
282 if (
i) Result +=
", ";
284 Result +=
Bit->getAsString();
288 return Result +
" }";
295 if (RV || !isa<UnsetInit>(After))
304 bool Changed =
false;
307 Init *CachedInit =
nullptr;
308 Init *CachedBitVar =
nullptr;
309 bool CachedBitVarChanged =
false;
317 if (CurBitVar == CachedBitVar) {
318 if (CachedBitVarChanged) {
324 CachedBitVar = CurBitVar;
325 CachedBitVarChanged =
false;
331 CachedBitVarChanged |= B != CurBitVar;
332 Changed |= B != CurBitVar;
333 }
while (B != CurBitVar);
334 CachedInit = CurBitVar;
336 if (CachedBitVarChanged) {
345 return const_cast<BitsInit *
>(
this);
362 return (NumBits >=
sizeof(Value) * 8) ||
363 (Value >> NumBits == 0) || (Value >> (NumBits-1) == -1);
367 if (isa<IntRecTy>(Ty))
368 return const_cast<IntInit *
>(
this);
370 if (isa<BitRecTy>(Ty)) {
372 if (Val != 0 && Val != 1)
return nullptr;
376 if (
auto *BRT = dyn_cast<BitsRecTy>(Ty)) {
383 for (
unsigned i = 0;
i != BRT->getNumBits(); ++
i)
396 for (
unsigned i = 0, e = Bits.
size();
i != e; ++
i) {
408 auto I = ThePool.
insert(std::make_pair(V,
nullptr));
411 I.first->first = VCopy;
414 return I.first->second;
420 auto I = ThePool.
insert(std::make_pair(V,
nullptr));
423 I.first->first = VCopy;
426 return I.first->second;
430 if (isa<StringRecTy>(Ty))
437 if (isa<CodeRecTy>(Ty))
438 return const_cast<CodeInit *
>(
this);
449 for (
Init *
I : Range)
455 static std::vector<ListInit*> TheActualPool;
467 std::uninitialized_copy(Range.
begin(), Range.
end(),
470 TheActualPool.push_back(I);
475 RecTy *EltTy = cast<ListRecTy>(
getType())->getElementType();
484 if (
auto *LRT = dyn_cast<ListRecTy>(Ty)) {
490 bool Changed =
false;
491 RecTy *ElementType = LRT->getElementType();
493 if (
Init *CI =
I->convertInitializerTo(ElementType)) {
511 for (
unsigned Element : Elements) {
512 if (Element >=
size())
520 assert(i < NumValues &&
"List element index out of range!");
530 bool Changed =
false;
538 Changed |= E != CurElt;
539 }
while (E != CurElt);
545 return const_cast<ListInit *
>(
this);
549 unsigned Elt)
const {
556 if (IRV || !isa<UnsetInit>(E))
562 std::string Result =
"[";
563 const char *sep =
"";
564 for (
Init *Element : *
this) {
573 unsigned Elt)
const {
577 Resolved = OResolved->
Fold(&R,
nullptr);
580 if (Resolved !=
this) {
581 TypedInit *Typed = cast<TypedInit>(Resolved);
592 return const_cast<OpInit*
>(
this);
605 static std::vector<UnOpInit*> TheActualPool;
616 TheActualPool.push_back(I);
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))
717 return const_cast<UnOpInit *
>(
this);
725 return Fold(&R,
nullptr);
732 case HEAD: Result =
"!head";
break;
733 case TAIL: Result =
"!tail";
break;
734 case EMPTY: Result =
"!empty";
break;
751 static std::vector<BinOpInit*> TheActualPool;
762 TheActualPool.push_back(I);
785 if (!LOp || !ROp || LOp->
getDef() != ROp->getDef())
793 for (
unsigned i = 0, e = RHSs->getNumArgs();
i != e; ++
i) {
807 Args.
insert(Args.
end(), RHSs->begin(), RHSs->end());
809 Args, cast<ListRecTy>(LHSs->
getType())->getElementType());
836 return IntInit::get(LHSs->getValue() == RHSs->getValue());
851 int64_t LHSv = LHSi->
getValue(), RHSv = RHSi->getValue();
855 case ADD: Result = LHSv + RHSv;
break;
856 case AND: Result = LHSv & RHSv;
break;
857 case OR: Result = LHSv | RHSv;
break;
858 case SHL: Result = LHSv << RHSv;
break;
859 case SRA: Result = LHSv >> RHSv;
break;
860 case SRL: Result = (uint64_t)LHSv >> (uint64_t)RHSv;
break;
874 if (LHS != lhs || RHS != rhs)
876 return Fold(&R,
nullptr);
882 case CONCAT: Result =
"!con";
break;
883 case ADD: Result =
"!add";
break;
884 case AND: Result =
"!and";
break;
885 case OR: Result =
"!or";
break;
886 case SHL: Result =
"!shl";
break;
887 case SRA: Result =
"!sra";
break;
888 case SRL: Result =
"!srl";
break;
889 case EQ: Result =
"!eq";
break;
890 case LISTCONCAT: Result =
"!listconcat";
break;
891 case STRCONCAT: Result =
"!strconcat";
break;
909 static std::vector<TernOpInit*> TheActualPool;
920 TheActualPool.push_back(I);
935 if (
auto *TArg = dyn_cast<TypedInit>(Arg))
936 if (isa<DagRecTy>(TArg->getType()))
937 return ForeachHelper(LHS, Arg, RHSo, Type, CurRec, CurMultiClass);
942 if (
auto *RHSoo = dyn_cast<OpInit>(RHSo->
getOperand(
i))) {
944 Type, CurRec, CurMultiClass))
957 Init *NewVal = NewOp->
Fold(CurRec, CurMultiClass);
958 return (NewVal != NewOp) ? NewVal :
nullptr;
975 if (MHSd && isa<DagRecTy>(Type)) {
976 Init *Val = MHSd->getOperator();
978 Type, CurRec, CurMultiClass))
982 for (
unsigned int i = 0;
i < MHSd->getNumArgs(); ++
i) {
983 Init *Arg = MHSd->getArg(
i);
988 CurRec, CurMultiClass))
992 args.
push_back(std::make_pair(Arg, ArgName));
999 if (MHSl && isa<ListRecTy>(Type)) {
1003 for (
Init *&Item : NewList) {
1004 NewOperands.
clear();
1015 Init *NewItem = NewOp->
Fold(CurRec, CurMultiClass);
1016 if (NewItem != NewOp)
1039 if (LHSd && MHSd && RHSd) {
1040 Record *Val = RHSd->getDef();
1042 Val = MHSd->getDef();
1045 if (LHSv && MHSv && RHSv) {
1046 std::string Val = RHSv->getName();
1047 if (LHSv->getAsString() == RHSv->getAsString())
1048 Val = MHSv->getName();
1051 if (LHSs && MHSs && RHSs) {
1052 std::string Val = RHSs->getValue();
1054 std::string::size_type found;
1055 std::string::size_type idx = 0;
1057 found = Val.find(LHSs->getValue(), idx);
1058 if (found == std::string::npos)
1060 Val.replace(found, LHSs->getValue().size(), MHSs->getValue());
1061 idx = found + MHSs->getValue().size();
1071 CurRec, CurMultiClass))
1079 LHSi = dyn_cast<IntInit>(
I);
1099 Value = dyn_cast<IntInit>(
I);
1105 RHS,
getType()))->Fold(&R,
nullptr);
1109 rhs,
getType()))->Fold(&R,
nullptr);
1116 if (LHS != lhs || MHS != mhs || RHS != rhs)
1118 getType()))->Fold(&R,
nullptr);
1119 return Fold(&R,
nullptr);
1125 case SUBST: Result =
"!subst";
break;
1126 case FOREACH: Result =
"!foreach";
break;
1127 case IF: Result =
"!if";
break;
1135 if (
RecordVal *
Field = RecordType->getRecord()->getValue(FieldName))
1136 return Field->getType();
1142 if (isa<IntRecTy>(Ty)) {
1143 if (
getType()->typeIsConvertibleTo(Ty))
1148 if (isa<StringRecTy>(Ty)) {
1149 if (isa<StringRecTy>(
getType()))
1150 return const_cast<TypedInit *>(
this);
1154 if (isa<CodeRecTy>(Ty)) {
1155 if (isa<CodeRecTy>(
getType()))
1156 return const_cast<TypedInit *>(
this);
1160 if (isa<BitRecTy>(Ty)) {
1163 return const_cast<TypedInit *>(
this);
1164 if (
auto *BitsTy = dyn_cast<BitsRecTy>(
getType())) {
1166 if (BitsTy->getNumBits() == 1)
1167 return const_cast<TypedInit *>(
this);
1172 if (
const auto *TOI = dyn_cast<TernOpInit>(
this)) {
1173 if (TOI->getOpcode() == TernOpInit::TernaryOp::IF &&
1176 return const_cast<TypedInit *>(
this);
1182 if (
auto *BRT = dyn_cast<BitsRecTy>(Ty)) {
1183 if (BRT->getNumBits() == 1 && isa<BitRecTy>(
getType()))
1186 if (
getType()->typeIsConvertibleTo(BRT)) {
1189 for (
unsigned i = 0;
i != BRT->getNumBits(); ++
i)
1197 if (
auto *DLRT = dyn_cast<ListRecTy>(Ty)) {
1198 if (
auto *SLRT = dyn_cast<ListRecTy>(
getType()))
1199 if (SLRT->getElementType()->typeIsConvertibleTo(DLRT->getElementType()))
1204 if (
auto *DRT = dyn_cast<DagRecTy>(Ty)) {
1206 return const_cast<TypedInit *>(
this);
1210 if (
auto *SRRT = dyn_cast<RecordRecTy>(Ty)) {
1213 if (DRRT->getRecord()->isSubClassOf(SRRT->getRecord()) ||
1214 DRRT->getRecord() == SRRT->getRecord())
1215 return const_cast<TypedInit *>(
this);
1224 if (!T)
return nullptr;
1229 for (
unsigned Bit : Bits) {
1240 if (!T)
return nullptr;
1242 if (Elements.
size() == 1)
1247 for (
unsigned Element : Elements)
1260 typedef std::pair<RecTy *, Init *> Key;
1263 Key TheKey(std::make_pair(T, VN));
1278 return const_cast<VarInit*
>(
this);
1284 unsigned Elt)
const {
1289 assert(RV &&
"Reference to a non-existent variable?");
1294 if (Elt >= LI->
size())
1300 if (IRV || !isa<UnsetInit>(E))
1308 return RV->getType();
1314 if (isa<RecordRecTy>(
getType()))
1316 if (RV != Val && (RV || isa<UnsetInit>(Val->getValue())))
1318 Init *TheInit = Val->getValue();
1319 assert(TheInit !=
this &&
"Infinite loop detected!");
1329 if (RV == Val || (!RV && !isa<UnsetInit>(Val->getValue())))
1330 return Val->getValue();
1331 return const_cast<VarInit *
>(
this);
1335 typedef std::pair<TypedInit *, unsigned> Key;
1338 Key TheKey(std::make_pair(T, B));
1347 if (isa<BitRecTy>(Ty))
1367 typedef std::pair<TypedInit *, unsigned> Key;
1370 Key TheKey(std::make_pair(T, E));
1397 unsigned Elt)
const {
1399 if (
TypedInit *TInit = dyn_cast<TypedInit>(Result)) {
1400 if (
Init *Result2 = TInit->resolveListElementReference(R, RV, Elt))
1415 if (
auto *RRT = dyn_cast<RecordRecTy>(Ty))
1416 if (
getDef()->isSubClassOf(RRT->getRecord()))
1417 return const_cast<DefInit *
>(
this);
1423 return RV->getType();
1437 typedef std::pair<Init *, StringInit *> Key;
1440 Key TheKey(std::make_pair(R, FN));
1454 unsigned Elt)
const {
1456 if (
ListInit *LI = dyn_cast<ListInit>(ListVal)) {
1457 if (Elt >= LI->size())
return nullptr;
1458 Init *
E = LI->getElement(Elt);
1463 if (RV || !isa<UnsetInit>(E))
1490 while (Arg != ArgRange.
end()) {
1491 assert(Name != NameRange.
end() &&
"Arg name underflow!");
1495 assert(Name == NameRange.
end() &&
"Arg name overflow!");
1502 static std::vector<DagInit*> TheActualPool;
1513 TheActualPool.push_back(I);
1519 ArrayRef<std::pair<Init*, StringInit*>> args) {
1523 for (
const auto &Arg : args) {
1536 if (isa<DagRecTy>(Ty))
1537 return const_cast<DagInit *
>(
this);
1545 bool ArgsChanged =
false;
1546 for (
const Init *Arg : Args) {
1549 ArgsChanged |= NewArg != Arg;
1553 if (Op != Val || ArgsChanged)
1556 return const_cast<DagInit *
>(
this);
1563 if (!Args.empty()) {
1564 Result +=
" " + Args[0]->getAsString();
1565 if (ArgNames[0]) Result +=
":$" + ArgNames[0]->getAsUnquotedString();
1566 for (
unsigned i = 1, e = Args.size();
i != e; ++
i) {
1567 Result +=
", " + Args[
i]->getAsString();
1568 if (ArgNames[
i]) Result +=
":$" + ArgNames[
i]->getAsUnquotedString();
1571 return Result +
")";
1579 :
Name(N), TyAndPrefix(T, P) {
1581 assert(
Value &&
"Cannot create unset value for current type!");
1587 assert(
Value &&
"Cannot create unset value for current type!");
1603 if (PrintSem) OS <<
";\n";
1606 unsigned Record::LastID = 0;
1608 void Record::init() {
1617 void Record::checkName() {
1619 const TypedInit *TypedName = cast<const TypedInit>(Name);
1620 if (!isa<StringRecTy>(TypedName->
getType()))
1631 return cast<StringInit>(Name)->
getValue();
1659 if (
Value.setValue(V->resolveReferences(*
this, RV)))
1661 Value.getNameInitAsString() +
1662 "' after resolving references" +
1670 if (NewName != OldName) {
1682 if (!TArgs.
empty()) {
1684 bool NeedComma =
false;
1685 for (
const Init *
TA : TArgs) {
1686 if (NeedComma) OS <<
", ";
1689 assert(RV &&
"Template argument record not found??");
1690 RV->
print(OS,
false);
1699 for (
const auto &SuperPair : SC)
1700 OS <<
" " << SuperPair.first->getNameInitAsString();
1708 if (!Val.getPrefix() && !R.
isTemplateArg(Val.getNameInit()))
1718 "' does not have a field named `" + FieldName +
"'!\n");
1726 "' does not have a field named `" + FieldName +
"'!\n");
1729 return SI->getValue();
1731 return CI->getValue();
1734 FieldName +
"' does not have a string initializer!");
1741 "' does not have a field named `" + FieldName +
"'!\n");
1746 FieldName +
"' does not have a BitsInit initializer!");
1753 "' does not have a field named `" + FieldName +
"'!\n");
1758 FieldName +
"' does not have a list initializer!");
1761 std::vector<Record*>
1764 std::vector<Record*> Defs;
1766 if (
DefInit *DI = dyn_cast<DefInit>(
I))
1767 Defs.push_back(DI->getDef());
1770 FieldName +
"' list is not entirely DefInit!");
1779 "' does not have a field named `" + FieldName +
"'!\n");
1782 return II->getValue();
1784 FieldName +
"' does not have an int initializer!");
1787 std::vector<int64_t>
1790 std::vector<int64_t> Ints;
1792 if (
IntInit *II = dyn_cast<IntInit>(
I))
1793 Ints.push_back(II->getValue());
1796 FieldName +
"' does not have a list of ints initializer!");
1801 std::vector<std::string>
1804 std::vector<std::string> Strings;
1807 Strings.push_back(
SI->getValue());
1810 FieldName +
"' does not have a list of strings initializer!");
1819 "' does not have a field named `" + FieldName +
"'!\n");
1822 return DI->getDef();
1824 FieldName +
"' does not have a def initializer!");
1831 "' does not have a field named `" + FieldName +
"'!\n");
1834 return BI->getValue();
1836 FieldName +
"' does not have a bit initializer!");
1843 "' does not have a field named `" + FieldName.
str() +
"'!\n");
1845 if (isa<UnsetInit>(R->
getValue())) {
1851 return BI->getValue();
1853 FieldName +
"' does not have a bit initializer!");
1860 "' does not have a field named `" + FieldName +
"'!\n");
1865 FieldName +
"' does not have a dag initializer!");
1869 errs() <<
"Record:\n";
1872 errs() <<
"Defs:\n";
1880 OS <<
"------------- Classes -----------------\n";
1882 OS <<
"class " << *
C.second;
1884 OS <<
"------------- Defs -----------------\n";
1886 OS <<
"def " << *
D.second;
1890 std::vector<Record *>
1894 PrintFatalError(
"ERROR: Couldn't find the `" + ClassName +
"' class!\n");
1896 std::vector<Record*> Defs;
1898 if (
D.second->isSubClassOf(Class))
1899 Defs.push_back(
D.second.get());
1906 if (
const StringInit *I0s = dyn_cast<StringInit>(I0))
1907 if (
const StringInit *I1s = dyn_cast<StringInit>(I1))
1916 if (CurMultiClass && Scoper !=
"::") {
1922 if (
BinOpInit *BinOp = dyn_cast<BinOpInit>(NewName))
1923 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.)
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...
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
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
void InsertNode(Node *N, void *InsertPos)
InsertNode - Insert the specified node into the folding set, knowing that it is not already in the fo...
static BumpPtrAllocator Allocator
void reserve(size_type N)
std::string getValueAsString(StringRef FieldName) const
This method looks up the specified field and returns its value as a string, throwing an exception if ...
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
void print(raw_ostream &OS) const
Print out this value.
static IntInit * get(int64_t V)
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
'?' - 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
static GCRegistry::Add< StatepointGC > D("statepoint-example","an example strategy for statepoint")
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...
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...
'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...
static GCRegistry::Add< OcamlGC > B("ocaml","ocaml 3.10-compatible GC")
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.
std::vector< std::string > 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.
Init * convertInitListSlice(ArrayRef< unsigned > Elements) const override
This method is used to implement the list slice selection operator.
'code' - Represent a code fragment
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
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
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)
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.
T * FindNodeOrInsertPos(const FoldingSetNodeID &ID, void *&InsertPos)
FindNodeOrInsertPos - Look up the node specified by ID.
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.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
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.
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 GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
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)
LLVM_NODISCARD StringRef copy(Allocator &A) const
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)
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)