23 #include "llvm/Config/llvm-config.h" 42 #define DEBUG_TYPE "tblgen-records" 47 "The total number of unique CodeInits constructed");
59 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 70 assert(RHS &&
"NULL pointer");
79 if (
const BitsRecTy *BitsTy = dyn_cast<BitsRecTy>(RHS))
80 return BitsTy->getNumBits() == 1;
85 static std::vector<BitsRecTy*> Shared;
86 if (Sz >= Shared.size())
87 Shared.resize(Sz + 1);
100 return cast<BitsRecTy>(RHS)->
Size ==
Size;
106 if (
const BitsRecTy *RHSb = dyn_cast<BitsRecTy>(RHS))
107 return RHSb->Size ==
Size;
131 return "list<" + Ty->getAsString() +
">";
135 if (
const auto *ListTy = dyn_cast<ListRecTy>(RHS))
141 if (
const ListRecTy *RHSl = dyn_cast<ListRecTy>(RHS))
142 return getElementType()->typeIsA(RHSl->getElementType());
158 if (UnsortedClasses.
empty()) {
164 UnsortedClasses[0]->getRecords().RecordTypePool;
167 UnsortedClasses.
end());
181 for (
unsigned i = 0; i < Classes.size(); ++i) {
182 for (
unsigned j = 0; j < Classes.size(); ++j) {
183 assert(i == j || !Classes[i]->isSubClassOf(Classes[j]));
185 assert(&Classes[0]->getRecords() == &Classes[i]->getRecords());
189 void *Mem = Allocator.
Allocate(totalSizeToAlloc<Record *>(Classes.size()),
192 std::uninitialized_copy(Classes.begin(), Classes.end(),
204 return getClasses()[0]->getNameInitAsString();
206 std::string Str =
"{";
208 for (
Record *R : getClasses()) {
212 Str += R->getNameInitAsString();
220 return MySuperClass == Class ||
234 return isSubClassOf(TargetClass);
248 while (!Stack.
empty()) {
266 if (
RecordRecTy *RecTy1 = dyn_cast<RecordRecTy>(T1)) {
267 if (
RecordRecTy *RecTy2 = dyn_cast<RecordRecTy>(T2))
276 if (
ListRecTy *ListTy1 = dyn_cast<ListRecTy>(T1)) {
277 if (
ListRecTy *ListTy2 = dyn_cast<ListRecTy>(T2)) {
279 ListTy2->getElementType());
292 void Init::anchor() {}
294 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 315 return V ? &True : &False;
319 if (isa<BitRecTy>(Ty))
320 return const_cast<BitInit *
>(
this);
322 if (isa<IntRecTy>(Ty))
325 if (
auto *BRT = dyn_cast<BitsRecTy>(Ty)) {
327 if (BRT->getNumBits() == 1)
338 for (
Init *
I : Range)
352 void *Mem = Allocator.
Allocate(totalSizeToAlloc<Init *>(Range.
size()),
355 std::uninitialized_copy(Range.
begin(), Range.
end(),
366 if (isa<BitRecTy>(Ty)) {
367 if (getNumBits() != 1)
return nullptr;
371 if (
auto *BRT = dyn_cast<BitsRecTy>(Ty)) {
374 if (getNumBits() != BRT->getNumBits())
return nullptr;
375 return const_cast<BitsInit *
>(
this);
378 if (isa<IntRecTy>(Ty)) {
380 for (
unsigned i = 0,
e = getNumBits(); i !=
e; ++i)
381 if (
auto *
Bit = dyn_cast<BitInit>(getBit(i)))
382 Result |=
static_cast<int64_t
>(
Bit->getValue()) << i;
395 for (
unsigned i = 0,
e = Bits.
size(); i !=
e; ++i) {
396 if (Bits[i] >= getNumBits())
398 NewBits[i] = getBit(Bits[i]);
404 for (
unsigned i = 0,
e = getNumBits(); i !=
e; ++i) {
405 if (!getBit(i)->isConcrete())
412 std::string Result =
"{ ";
413 for (
unsigned i = 0,
e = getNumBits(); i !=
e; ++i) {
414 if (i) Result +=
", ";
416 Result +=
Bit->getAsString();
420 return Result +
" }";
426 bool Changed =
false;
429 Init *CachedBitVarRef =
nullptr;
430 Init *CachedBitVarResolved =
nullptr;
432 for (
unsigned i = 0,
e = getNumBits(); i !=
e; ++i) {
433 Init *CurBit = getBit(i);
434 Init *NewBit = CurBit;
436 if (
VarBitInit *CurBitVar = dyn_cast<VarBitInit>(CurBit)) {
437 if (CurBitVar->getBitVar() != CachedBitVarRef) {
438 CachedBitVarRef = CurBitVar->getBitVar();
441 assert(CachedBitVarResolved &&
"Unresolved bitvar reference");
442 NewBit = CachedBitVarResolved->
getBit(CurBitVar->getBitNum());
451 Changed |= CurBit != NewBit;
457 return const_cast<BitsInit *
>(
this);
461 static std::map<int64_t, IntInit*> ThePool;
474 return (NumBits >=
sizeof(Value) * 8) ||
475 (Value >> NumBits == 0) || (Value >> (NumBits-1) == -1);
479 if (isa<IntRecTy>(Ty))
480 return const_cast<IntInit *
>(
this);
482 if (isa<BitRecTy>(Ty)) {
483 int64_t Val = getValue();
484 if (Val != 0 && Val != 1)
return nullptr;
488 if (
auto *BRT = dyn_cast<BitsRecTy>(Ty)) {
489 int64_t
Value = getValue();
495 for (
unsigned i = 0; i != BRT->getNumBits(); ++i)
496 NewBits[i] =
BitInit::get(Value & ((i < 64) ? (1LL << i) : 0));
508 for (
unsigned i = 0,
e = Bits.
size(); i !=
e; ++i) {
520 CodeInitsConstructed++;
524 return new (Allocator)
CodeInit(
"", Loc);
536 auto &
Entry = *ThePool.
insert(std::make_pair(V,
nullptr)).first;
543 if (isa<StringRecTy>(Ty))
545 if (isa<CodeRecTy>(Ty))
552 if (isa<CodeRecTy>(Ty))
553 return const_cast<CodeInit *
>(
this);
554 if (isa<StringRecTy>(Ty))
566 for (
Init *
I : Range)
580 assert(Range.
empty() || !isa<TypedInit>(Range[0]) ||
581 cast<TypedInit>(Range[0])->getType()->typeIsConvertibleTo(EltTy));
583 void *Mem = Allocator.
Allocate(totalSizeToAlloc<Init *>(Range.
size()),
586 std::uninitialized_copy(Range.
begin(), Range.
end(),
593 RecTy *EltTy = cast<ListRecTy>(
getType())->getElementType();
602 if (
auto *LRT = dyn_cast<ListRecTy>(Ty)) {
608 bool Changed =
false;
609 RecTy *ElementType = LRT->getElementType();
610 for (
Init *
I : getValues())
611 if (
Init *CI =
I->convertInitializerTo(ElementType)) {
629 for (
unsigned Element : Elements) {
630 if (Element >=
size())
638 assert(i < NumValues &&
"List element index out of range!");
648 bool Changed =
false;
650 for (
Init *CurElt : getValues()) {
651 Init *
E = CurElt->resolveReferences(R);
652 Changed |= E != CurElt;
658 return const_cast<ListInit *
>(
this);
662 for (
Init *Element : *
this) {
670 std::string Result =
"[";
671 const char *sep =
"";
672 for (
Init *Element : *
this) {
682 return const_cast<OpInit*
>(
this);
715 if (isa<StringRecTy>(
getType())) {
716 if (
StringInit *LHSs = dyn_cast<StringInit>(LHS))
719 if (
DefInit *LHSd = dyn_cast<DefInit>(LHS))
722 if (
IntInit *LHSi = dyn_cast<IntInit>(LHS))
724 }
else if (isa<RecordRecTy>(
getType())) {
726 if (!CurRec && !IsFinal)
728 assert(CurRec &&
"NULL pointer");
742 Twine(
"Undefined reference to record: '") +
743 Name->getValue() +
"'\n");
751 Twine(
"Expected type '") +
752 getType()->getAsString() +
"', got '" +
765 if (
ListInit *LHSl = dyn_cast<ListInit>(LHS)) {
766 assert(!LHSl->empty() &&
"Empty list in head");
767 return LHSl->getElement(0);
772 if (
ListInit *LHSl = dyn_cast<ListInit>(LHS)) {
773 assert(!LHSl->empty() &&
"Empty list in tail");
776 return ListInit::get(LHSl->getValues().slice(1), LHSl->getElementType());
781 if (
ListInit *LHSl = dyn_cast<ListInit>(LHS))
786 if (
ListInit *LHSl = dyn_cast<ListInit>(LHS))
788 if (
StringInit *LHSs = dyn_cast<StringInit>(LHS))
797 Twine(
"Expected type '") +
798 getType()->getAsString() +
"', got '" +
807 return const_cast<UnOpInit *
>(
this);
816 return const_cast<UnOpInit *
>(
this);
822 case CAST: Result =
"!cast<" +
getType()->getAsString() +
">";
break;
823 case HEAD: Result =
"!head";
break;
824 case TAIL: Result =
"!tail";
break;
825 case SIZE: Result =
"!size";
break;
826 case EMPTY: Result =
"!empty";
break;
827 case GETOP: Result =
"!getop";
break;
829 return Result +
"(" + LHS->getAsString() +
")";
870 if (
const StringInit *I0s = dyn_cast<StringInit>(I0))
871 if (
const StringInit *I1s = dyn_cast<StringInit>(I1))
885 assert(isa<ListRecTy>(LHS->
getType()) &&
"First arg must be a list");
888 if (
const ListInit *LHSList = dyn_cast<ListInit>(LHS))
889 if (
const ListInit *RHSList = dyn_cast<ListInit>(RHS))
906 if ((!LOp && !isa<UnsetInit>(LHSs->
getOperator())) ||
907 (!ROp && !isa<UnsetInit>(RHSs->getOperator())))
909 if (LOp && ROp && LOp->
getDef() != ROp->getDef()) {
911 LHSs->
getAsString() +
"' vs. '" + RHSs->getAsString() +
914 Init *
Op = LOp ? LOp : ROp;
920 for (
unsigned i = 0,
e = LHSs->
getNumArgs(); i !=
e; ++i) {
924 for (
unsigned i = 0,
e = RHSs->getNumArgs(); i !=
e; ++i) {
938 Args.
insert(Args.
end(), RHSs->begin(), RHSs->end());
968 dyn_cast_or_null<IntInit>(LHS->convertInitializerTo(
IntRecTy::get()));
970 dyn_cast_or_null<IntInit>(RHS->convertInitializerTo(
IntRecTy::get()));
975 case EQ: Result = L->
getValue() == R->getValue();
break;
976 case NE: Result = L->
getValue() != R->getValue();
break;
977 case LE: Result = L->
getValue() <= R->getValue();
break;
978 case LT: Result = L->
getValue() < R->getValue();
break;
979 case GE: Result = L->
getValue() >= R->getValue();
break;
980 case GT: Result = L->
getValue() > R->getValue();
break;
1005 for (
unsigned i = 0,
e = Dag->
getNumArgs(); i !=
e; ++i) {
1021 dyn_cast_or_null<IntInit>(LHS->convertInitializerTo(
IntRecTy::get()));
1023 dyn_cast_or_null<IntInit>(RHS->convertInitializerTo(
IntRecTy::get()));
1025 int64_t LHSv = LHSi->
getValue(), RHSv = RHSi->getValue();
1029 case ADD: Result = LHSv + RHSv;
break;
1030 case MUL: Result = LHSv * RHSv;
break;
1031 case AND: Result = LHSv & RHSv;
break;
1032 case OR: Result = LHSv | RHSv;
break;
1033 case SHL: Result = LHSv << RHSv;
break;
1034 case SRA: Result = LHSv >> RHSv;
break;
1035 case SRL: Result = (uint64_t)LHSv >> (uint64_t)RHSv;
break;
1049 if (LHS != lhs || RHS != rhs)
1058 case CONCAT: Result =
"!con";
break;
1059 case ADD: Result =
"!add";
break;
1060 case MUL: Result =
"!mul";
break;
1061 case AND: Result =
"!and";
break;
1062 case OR: Result =
"!or";
break;
1063 case SHL: Result =
"!shl";
break;
1064 case SRA: Result =
"!sra";
break;
1065 case SRL: Result =
"!srl";
break;
1066 case EQ: Result =
"!eq";
break;
1067 case NE: Result =
"!ne";
break;
1068 case LE: Result =
"!le";
break;
1069 case LT: Result =
"!lt";
break;
1070 case GE: Result =
"!ge";
break;
1071 case GT: Result =
"!gt";
break;
1072 case LISTCONCAT: Result =
"!listconcat";
break;
1073 case LISTSPLAT: Result =
"!listsplat";
break;
1074 case STRCONCAT: Result =
"!strconcat";
break;
1075 case SETOP: Result =
"!setop";
break;
1077 return Result +
"(" + LHS->getAsString() +
", " + RHS->getAsString() +
")";
1118 bool Change =
false;
1124 for (
unsigned int i = 0; i < MHSd->
getNumArgs(); ++i) {
1129 if (
DagInit *Argd = dyn_cast<DagInit>(Arg))
1134 NewArgs.
push_back(std::make_pair(NewArg, ArgName));
1147 if (
DagInit *MHSd = dyn_cast<DagInit>(MHS))
1150 if (
ListInit *MHSl = dyn_cast<ListInit>(MHS)) {
1153 for (
Init *&Item : NewList) {
1155 if (NewItem != Item)
1158 return ListInit::get(NewList, cast<ListRecTy>(Type)->getElementType());
1179 if (LHSd && MHSd && RHSd) {
1180 Record *Val = RHSd->getDef();
1182 Val = MHSd->getDef();
1185 if (LHSv && MHSv && RHSv) {
1186 std::string Val = RHSv->getName();
1187 if (LHSv->getAsString() == RHSv->getAsString())
1188 Val = MHSv->getName();
1191 if (LHSs && MHSs && RHSs) {
1192 std::string Val = RHSs->getValue();
1194 std::string::size_type found;
1195 std::string::size_type idx = 0;
1197 found = Val.find(LHSs->getValue(), idx);
1198 if (found == std::string::npos)
1200 Val.replace(found, LHSs->getValue().size(), MHSs->getValue());
1201 idx = found + MHSs->getValue().size();
1216 if (
IntInit *LHSi = dyn_cast_or_null<IntInit>(
1218 if (LHSi->getValue())
1228 bool MHSok = MHSl || isa<UnsetInit>(MHS);
1229 bool RHSok = RHSl || isa<UnsetInit>(RHS);
1231 if (isa<UnsetInit>(MHS) && isa<UnsetInit>(RHS))
1234 if (MHSok && RHSok && (!MHSl || !RHSl || MHSl->
size() == RHSl->size())) {
1236 unsigned Size = MHSl ? MHSl->
size() : RHSl->size();
1237 for (
unsigned i = 0; i !=
Size; ++i) {
1240 if (!isa<StringInit>(Name) && !isa<UnsetInit>(Name))
1242 Children.
emplace_back(Node, dyn_cast<StringInit>(Name));
1260 if (
Value->getValue())
1277 if (LHS != lhs || MHS != mhs || RHS != rhs)
1285 bool UnquotedLHS =
false;
1287 case SUBST: Result =
"!subst";
break;
1288 case FOREACH: Result =
"!foreach"; UnquotedLHS =
true;
break;
1289 case IF: Result =
"!if";
break;
1290 case DAG: Result =
"!dag";
break;
1292 return (Result +
"(" +
1293 (UnquotedLHS ? LHS->getAsUnquotedString() : LHS->getAsString()) +
1294 ", " + MHS->getAsString() +
", " + RHS->getAsString() +
")");
1330 Init *Accum = Start;
1331 for (
Init *Elt : *LI) {
1343 Init *NewStart = Start->resolveReferences(R);
1344 Init *NewList =
List->resolveReferences(R);
1350 if (Start == NewStart &&
List == NewList && Expr == NewExpr)
1353 return get(NewStart, NewList, A,
B, NewExpr,
getType())
1362 return (
Twine(
"!foldl(") + Start->getAsString() +
", " +
List->getAsString() +
1363 ", " + A->getAsUnquotedString() +
", " +
B->getAsUnquotedString() +
1364 ", " + Expr->getAsString() +
")")
1394 if (
TypedInit *TI = dyn_cast<TypedInit>(Expr)) {
1396 if (TI->getType()->typeIsConvertibleTo(
CheckType))
1403 if (!
CheckType->typeIsConvertibleTo(TI->getType()) || isa<DefInit>(Expr))
1415 if (Expr != NewExpr)
1426 Expr->getAsString() +
")")
1432 for (
Record *Rec : RecordType->getClasses()) {
1434 return Field->getType();
1445 if (isa<BitRecTy>(
getType()) && isa<BitsRecTy>(Ty) &&
1446 cast<BitsRecTy>(Ty)->getNumBits() == 1)
1454 if (!T)
return nullptr;
1459 for (
unsigned Bit : Bits) {
1473 if (
Init *Converted = convertInitializerTo(Ty)) {
1474 assert(!isa<TypedInit>(Converted) ||
1488 if (!T)
return nullptr;
1490 if (Elements.
size() == 1)
1495 for (
unsigned Element : Elements)
1508 using Key = std::pair<RecTy *, Init *>;
1511 Key TheKey(std::make_pair(T, VN));
1520 StringInit *NameString = cast<StringInit>(getNameInit());
1526 return const_cast<VarInit*
>(
this);
1533 return const_cast<VarInit *
>(
this);
1537 using Key = std::pair<TypedInit *, unsigned>;
1540 Key TheKey(std::make_pair(T, B));
1549 return TI->getAsString() +
"{" +
utostr(
Bit) +
"}";
1553 Init *
I = TI->resolveReferences(R);
1555 return I->
getBit(getBitNum());
1562 using Key = std::pair<TypedInit *, unsigned>;
1565 Key TheKey(std::make_pair(T, E));
1573 return TI->getAsString() +
"[" +
utostr(Element) +
"]";
1581 if (getElementNum() <
List->size())
1582 return List->getElement(getElementNum());
1584 if (NewTI != TI && isa<TypedInit>(NewTI))
1603 if (
auto *RRT = dyn_cast<RecordRecTy>(Ty))
1605 return const_cast<DefInit *
>(
this);
1611 return RV->getType();
1616 return Def->getName();
1625 for (
Init *
I : Args)
1639 void *Mem = Allocator.
Allocate(totalSizeToAlloc<Init *>(Args.
size()),
1642 std::uninitialized_copy(Args.
begin(), Args.
end(),
1652 DefInit *VarDefInit::instantiate() {
1656 Class->getLoc(), Records,
1658 Record *NewRec = NewRecOwner.get();
1661 for (
const RecordVal &Val : Class->getValues())
1668 for (
unsigned i = 0,
e = TArgs.
size(); i !=
e; ++i) {
1669 if (i < args_size())
1670 R.
set(TArgs[i], getArg(i));
1672 R.
set(TArgs[i], NewRec->getValue(TArgs[i])->getValue());
1674 NewRec->removeValue(TArgs[i]);
1677 NewRec->resolveReferences(R);
1681 for (
const auto &SCPair : SCs)
1682 NewRec->addSuperClass(SCPair.first, SCPair.second);
1684 NewRec->addSuperClass(Class,
1685 SMRange(Class->getLoc().back(),
1686 Class->getLoc().back()));
1689 NewRec->resolveReferences();
1690 Records.
addDef(std::move(NewRecOwner));
1700 bool Changed =
false;
1705 Init *NewArg =
Arg->resolveReferences(UR);
1707 Changed |= NewArg !=
Arg;
1713 return New->instantiate();
1725 Arg->resolveReferences(R);
1728 return const_cast<VarDefInit *>(
this)->instantiate();
1733 std::string Result = Class->getNameInitAsString() +
"<";
1734 const char *sep =
"";
1738 Result +=
Arg->getAsString();
1740 return Result +
">";
1744 using Key = std::pair<Init *, StringInit *>;
1747 Key TheKey(std::make_pair(R, FN));
1768 if (
DefInit *DI = dyn_cast<DefInit>(Rec)) {
1772 Twine(
"Attempting to access field '") +
1773 FieldName->getAsUnquotedString() +
"' of '" +
1774 Rec->getAsString() +
"' is a forbidden self-reference");
1776 if (FieldVal->isComplete())
1787 "Number of conditions and values must match!");
1792 while (Case != CondRange.
end()) {
1801 makeArrayRef(getTrailingObjects<Init *>() + NumConds, NumConds),
1809 "Number of conditions and values must match!");
1816 if (
CondOpInit *
I = ThePool.FindNodeOrInsertPos(ID, IP))
1819 void *Mem = Allocator.
Allocate(totalSizeToAlloc<Init *>(2*CondRange.
size()),
1823 std::uninitialized_copy(CondRange.
begin(), CondRange.
end(),
1825 std::uninitialized_copy(ValRange.
begin(), ValRange.
end(),
1827 ThePool.InsertNode(I, IP);
1833 bool Changed =
false;
1834 for (
const Init *Case : getConds()) {
1837 Changed |= NewCase != Case;
1841 for (
const Init *Val : getVals()) {
1844 Changed |= NewVal != Val;
1855 for (
unsigned i = 0; i < NumConds; ++i) {
1856 Init *Cond = getCond(i);
1859 if (
IntInit *CondI = dyn_cast_or_null<IntInit>(
1861 if (CondI->getValue())
1869 " does not have any true condition in:" +
1875 for (
const Init *Case : getConds())
1876 if (!Case->isConcrete())
1879 for (
const Init *Val : getVals())
1880 if (!Val->isConcrete())
1887 for (
const Init *Case : getConds())
1888 if (!Case->isComplete())
1891 for (
const Init *Val : getVals())
1892 if (!Val->isConcrete())
1899 std::string Result =
"!cond(";
1900 for (
unsigned i = 0; i < getNumConds(); i++) {
1901 Result += getCond(i)->getAsString() +
": ";
1902 Result +=
getVal(i)->getAsString();
1903 if (i != getNumConds()-1)
1906 return Result +
")";
1921 while (Arg != ArgRange.
end()) {
1922 assert(Name != NameRange.
end() &&
"Arg name underflow!");
1926 assert(Name == NameRange.
end() &&
"Arg name overflow!");
1941 void *Mem = Allocator.
Allocate(totalSizeToAlloc<Init *, StringInit *>(ArgRange.
size(), NameRange.
size()),
alignof(
BitsInit));
1943 std::uninitialized_copy(ArgRange.
begin(), ArgRange.
end(),
1945 std::uninitialized_copy(NameRange.
begin(), NameRange.
end(),
1953 ArrayRef<std::pair<Init*, StringInit*>> args) {
1957 for (
const auto &
Arg : args) {
1970 if (
DefInit *DefI = dyn_cast<DefInit>(Val))
1971 return DefI->getDef();
1979 bool ArgsChanged =
false;
1980 for (
const Init *
Arg : getArgs()) {
1981 Init *NewArg =
Arg->resolveReferences(R);
1983 ArgsChanged |= NewArg !=
Arg;
1986 Init *
Op = Val->resolveReferences(R);
1987 if (Op != Val || ArgsChanged)
1988 return DagInit::get(Op, ValName, NewArgs, getArgNames());
1990 return const_cast<DagInit *
>(
this);
1994 if (!Val->isConcrete())
1996 for (
const Init *Elt : getArgs()) {
1997 if (!Elt->isConcrete())
2004 std::string Result =
"(" + Val->getAsString();
2006 Result +=
":" + ValName->getAsUnquotedString();
2008 Result +=
" " + getArg(0)->getAsString();
2009 if (getArgName(0)) Result +=
":$" + getArgName(0)->getAsUnquotedString();
2010 for (
unsigned i = 1,
e = getNumArgs(); i !=
e; ++i) {
2011 Result +=
", " + getArg(i)->getAsString();
2012 if (getArgName(i)) Result +=
":$" + getArgName(i)->getAsUnquotedString();
2015 return Result +
")";
2023 :
Name(N), TyAndPrefix(T, P) {
2025 assert(
Value &&
"Cannot create unset value for current type!");
2039 if (!isa<BitsInit>(
Value)) {
2041 Bits.
reserve(BTy->getNumBits());
2042 for (
unsigned i = 0,
e = BTy->getNumBits(); i <
e; ++i)
2048 return Value ==
nullptr;
2054 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 2065 if (PrintSem) OS <<
";\n";
2068 unsigned Record::LastID = 0;
2070 void Record::checkName() {
2072 const TypedInit *TypedName = cast<const TypedInit>(Name);
2073 if (!isa<StringRecTy>(TypedName->
getType()))
2075 "' is not a string!");
2080 getDirectSuperClasses(DirectSCs);
2108 while (!SCs.
empty()) {
2119 if (SkipVal == &
Value)
2123 if (
Value.setValue(VR)) {
2125 if (
TypedInit *VRT = dyn_cast<TypedInit>(VR))
2127 (
Twine(
"of type '") + VRT->getType()->getAsString() +
"' ").str();
2129 "is found when setting '" +
2130 Value.getNameInitAsString() +
2133 "' after resolving references: " +
2140 if (NewName != OldName) {
2149 resolveReferences(R);
2154 resolveReferences(R, RV);
2157 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 2165 if (!TArgs.
empty()) {
2167 bool NeedComma =
false;
2168 for (
const Init *
TA : TArgs) {
2169 if (NeedComma) OS <<
", ";
2172 assert(RV &&
"Template argument record not found??");
2173 RV->
print(OS,
false);
2182 for (
const auto &SuperPair : SC)
2183 OS <<
" " << SuperPair.first->getNameInitAsString();
2191 if (!Val.getPrefix() && !R.
isTemplateArg(Val.getNameInit()))
2201 "' does not have a field named `" + FieldName +
"'!\n");
2209 "' does not have a field named `" + FieldName +
"'!\n");
2212 return SI->getValue();
2214 return CI->getValue();
2217 FieldName +
"' does not have a string initializer!");
2224 "' does not have a field named `" + FieldName +
"'!\n");
2229 FieldName +
"' does not have a BitsInit initializer!");
2236 "' does not have a field named `" + FieldName +
"'!\n");
2241 FieldName +
"' does not have a list initializer!");
2244 std::vector<Record*>
2247 std::vector<Record*> Defs;
2249 if (
DefInit *DI = dyn_cast<DefInit>(
I))
2250 Defs.push_back(DI->getDef());
2253 FieldName +
"' list is not entirely DefInit!");
2262 "' does not have a field named `" + FieldName +
"'!\n");
2265 return II->getValue();
2268 "' does not have an int initializer: " +
2272 std::vector<int64_t>
2275 std::vector<int64_t> Ints;
2277 if (
IntInit *II = dyn_cast<IntInit>(
I))
2278 Ints.push_back(II->getValue());
2281 Twine(
"Record `") +
getName() +
"', field `" + FieldName +
2282 "' does not have a list of ints initializer: " +
2288 std::vector<StringRef>
2291 std::vector<StringRef> Strings;
2294 Strings.push_back(
SI->getValue());
2297 Twine(
"Record `") +
getName() +
"', field `" + FieldName +
2298 "' does not have a list of strings initializer: " +
2308 "' does not have a field named `" + FieldName +
"'!\n");
2311 return DI->getDef();
2313 FieldName +
"' does not have a def initializer!");
2320 "' does not have a field named `" + FieldName +
"'!\n");
2323 return DI->getDef();
2327 FieldName +
"' does not have either a def initializer or '?'!");
2335 "' does not have a field named `" + FieldName +
"'!\n");
2338 return BI->getValue();
2340 FieldName +
"' does not have a bit initializer!");
2347 "' does not have a field named `" + FieldName.
str() +
"'!\n");
2349 if (isa<UnsetInit>(R->
getValue())) {
2355 return BI->getValue();
2357 FieldName +
"' does not have a bit initializer!");
2364 "' does not have a field named `" + FieldName +
"'!\n");
2369 FieldName +
"' does not have a dag initializer!");
2372 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 2377 OS <<
"------------- Classes -----------------\n";
2379 OS <<
"class " << *
C.second;
2381 OS <<
"------------- Defs -----------------\n";
2383 OS <<
"def " << *D.second;
2393 std::vector<Record *>
2395 Record *Class = getClass(ClassName);
2397 PrintFatalError(
"ERROR: Couldn't find the `" + ClassName +
"' class!\n");
2399 std::vector<Record*> Defs;
2400 for (
const auto &D : getDefs())
2402 Defs.push_back(D.second.get());
2408 auto It = Map.find(VarName);
2409 if (It == Map.end())
2412 Init *
I = It->second.V;
2414 if (!It->second.Resolved && Map.size() > 1) {
2426 Init *Val = Cache.lookup(VarName);
2430 for (
Init *S : Stack) {
2436 if (!isa<UnsetInit>(RV->getValue())) {
2437 Val = RV->getValue();
2438 Stack.push_back(VarName);
2452 I = R->resolve(VarName);
2453 if (I && !FoundUnresolved) {
2459 FoundUnresolved |= Sub.FoundUnresolved;
2464 FoundUnresolved =
true;
2470 if (VarName == VarNameToTrack)
static BinOpInit * get(BinaryOp opc, Init *lhs, Init *rhs, RecTy *Type)
Represents a range in source code.
void AddPointer(const void *Ptr)
Add* - Add various data types to Bit data.
Init * convertInitializerTo(RecTy *Ty) const override
Convert to an initializer whose type is-a Ty, or return nullptr if this is not possible (this can hap...
StringRef getName() const
reference emplace_back(ArgTypes &&... Args)
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...
RecTyKind
Subclass discriminator (for dyn_cast<> et al.)
void print(raw_ostream &OS) const
Init * getBit(unsigned Bit) const override
This method is used to return the initializer for the specified bit.
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
StringRef getName() 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...
Record * getValueAsDef(StringRef FieldName) const
This method looks up the specified field and returns its value as a Record, throwing an exception if ...
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
BitsInit * getValueAsBitsInit(StringRef FieldName) const
This method looks up the specified field and returns its value as a BitsInit, throwing an exception i...
const T & back() const
back - Get the last element.
This class represents lattice values for constants.
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.
virtual std::string getAsUnquotedString() const
Convert this value to a string form, without adding quote markers.
Record * getCurrentRecord() const
bool foundUnresolved() const
[AL, AH, CL] - Represent a list of defs
'7' - Represent an initialization by a literal integer value.
static void ProfileFoldOpInit(FoldingSetNodeID &ID, Init *A, Init *B, Init *Start, Init *List, Init *Expr, RecTy *Type)
'list<Ty>' - Represent a list of values, all of which must be of the specified type.
void getDirectSuperClasses(SmallVectorImpl< Record *> &Classes) const
Append the direct super classes of this record to Classes.
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
!op (X, Y) - Combine two inits.
Init * getBit(unsigned Bit) const override
This method is used to return the initializer for the specified bit.
bool typeIsA(const RecTy *RHS) const override
Return true if 'this' type is equal to or a subtype of RHS.
void Profile(FoldingSetNodeID &ID) 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::string getAsString() const override
Convert this value to a string form.
Init * convertInitializerTo(RecTy *Ty) const override
Convert to an initializer whose type is-a Ty, or return nullptr if this is not possible (this can hap...
void push_back(const T &Elt)
AL - Represent a reference to a 'def' in the description.
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...
static Init * getListConcat(TypedInit *lhs, Init *rhs)
Init * resolve(Init *VarName) override
Return the initializer for the given variable name (should normally be a StringInit), or nullptr if the name could not be resolved.
Init * getBit(unsigned Bit) const override
This method is used to return the initializer for the specified bit.
T * FindNodeOrInsertPos(const FoldingSetNodeID &ID, void *&InsertPos)
FindNodeOrInsertPos - Look up the node specified by ID.
static UnOpInit * get(UnaryOp opc, Init *lhs, RecTy *Type)
void addDef(std::unique_ptr< Record > R)
Init * convertInitializerBitRange(ArrayRef< unsigned > Bits) const override
This method is used to implement the bitrange selection operator.
RecTy * getFieldType(StringInit *FieldName) const override
This method is used to implement the FieldInit class.
Init * getCastTo(RecTy *Ty) const override
If this initializer is convertible to Ty, return an initializer whose type is-a Ty, generating a !cast operation if required.
Init * Fold(Record *CurRec, bool IsFinal=false) const
std::string getAsString() const override
Convert this value to a string form.
static Init * getStrConcat(Init *lhs, Init *rhs)
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly...
static VarInit * get(StringRef VN, RecTy *T)
STATISTIC(NumFunctions, "Total number of functions")
ListInit * getValueAsListInit(StringRef FieldName) const
This method looks up the specified field and returns its value as a ListInit, throwing an exception i...
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...
Resolve all references to a specific RecordVal.
const_record_iterator classes_begin() const
static ListInit * ConcatListInits(const ListInit *LHS, const ListInit *RHS)
static BumpPtrAllocator Allocator
void reserve(size_type N)
virtual Init * getCastTo(RecTy *Ty) const =0
If this initializer is convertible to Ty, return an initializer whose type is-a Ty, generating a !cast operation if required.
Resolve all variables from a record except for unset variables.
bool typeIsA(const RecTy *RHS) const override
Return true if 'this' type is equal to or a subtype of RHS.
'{ a, b, c }' - Represents an initializer for a BitsRecTy value.
Record * getElementAsRecord(unsigned i) const
std::string getAsString() const override
std::string getNameInitAsString() const
void dump() const
Debugging method that may be called through a debugger, just invokes print on stderr.
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
static bool getVal(MDTuple *MD, const char *Key, uint64_t &Val)
static IntInit * get(int64_t V)
static BitsInit * get(ArrayRef< Init *> Range)
(Optionally) delegate resolving to a sub-resolver, and keep track whether there were unresolved refer...
bool getValueAsBitOrUnset(StringRef FieldName, bool &Unset) const
This method looks up the specified field and returns its value as a bit.
Init * getArg(unsigned Num) const
ArrayRef< std::pair< Record *, SMRange > > getSuperClasses() const
'?' - 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.
static Init * ForeachApply(Init *LHS, Init *MHSe, Init *RHS, Record *CurRec)
static BitsRecTy * get(unsigned Sz)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
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 RecordRecTy * resolveRecordTypes(RecordRecTy *T1, RecordRecTy *T2)
Shift and rotation operations.
bool typeIsConvertibleTo(const RecTy *RHS) const override
Return true if all values of 'this' type can be converted to the specified type.
void Profile(FoldingSetNodeID &ID) const
Init * getBit(unsigned Bit) const override
This method is used to return the initializer for the specified bit.
RecTy * getElementType() const
static StringRecTy * get()
void Profile(FoldingSetNodeID &ID) const
static Optional< unsigned > getOpcode(ArrayRef< VPValue *> Values)
Returns the opcode of Values or ~0 if they do not all agree.
ArrayRef< Init * > getTemplateArgs() const
std::string getAsString() const override
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
std::string getAsString() const override
List[4] - Represent access to one element of a var or field.
'[classname]' - Type of record values that have zero or more superclasses.
Init * convertInitializerTo(RecTy *Ty) const override
Convert to an initializer whose type is-a Ty, or return nullptr if this is not possible (this can hap...
std::string getAsString() const override
Convert this value to a string form.
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.
void AddInteger(signed I)
!foldl (a, b, expr, start, lst) - Fold over a list.
Init * getValueInit(StringRef FieldName) const
Return the initializer for a value with the specified name, or throw an exception if the field does n...
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
!cond(condition_1: value1, ...
void print(raw_ostream &OS, bool PrintSem=true) const
std::string getAsString() const override
Convert this value to a string form.
const_iterator end() const
virtual Init * resolve(Init *VarName)=0
Return the initializer for the given variable name (should normally be a StringInit), or nullptr if the name could not be resolved.
StringInit * getArgName(unsigned Num) const
void InsertNode(T *N, void *InsertPos)
InsertNode - Insert the specified node into the folding set, knowing that it is not already in the fo...
ArrayRef< SMLoc > getLoc() const
Type * getType() const
All values are typed, get the type of this value.
'bits<n>' - Represent a fixed number of bits
ArrayRef< Record * > getClasses() const
std::string itostr(int64_t X)
void Profile(FoldingSetNodeID &ID) const
bool isTemplateArg(Init *Name) 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...
Simple integer binary arithmetic operators.
bool isSubClassOf(const Record *R) const
ArrayRef< Init * > getValues() 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)...
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Record * getOperatorAsDef(ArrayRef< SMLoc > Loc) const
unsigned getNumBits() 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...
bool typeIsConvertibleTo(const RecTy *RHS) const override
Return true if all values of 'this' type can be converted to the specified type.
Init * resolve(Init *VarName) override
Return the initializer for the given variable name (should normally be a StringInit), or nullptr if the name could not be resolved.
virtual Init * getBit(unsigned Bit) const =0
This method is used to return the initializer for the specified bit.
static CodeInit * get(StringRef, const SMLoc &Loc)
ArrayRef< RecordVal > getValues() const
const_record_iterator classes_end() const
Init * convertInitListSlice(ArrayRef< unsigned > Elements) const override
This method is used to implement the list slice selection operator.
'code' - Represent a code fragment
void resolveReferencesTo(const RecordVal *RV)
If anything in this record refers to RV, replace the reference to RV with the RHS of RV...
bool isSubClassOf(Record *Class) const
Init * convertInitializerTo(RecTy *Ty) const override
Convert to an initializer whose type is-a Ty, or return nullptr if this is not possible (this can hap...
virtual Init * convertInitializerTo(RecTy *Ty) const =0
Convert to an initializer whose type is-a Ty, or return nullptr if this is not possible (this can hap...
void addShadow(Init *Key)
Init * convertInitializerTo(RecTy *Ty) const override
Convert to an initializer whose type is-a Ty, or return nullptr if this is not possible (this can hap...
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 Profile(FoldingSetNodeID &ID) const
Base class for operators.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
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...
bool typeIsConvertibleTo(const RecTy *RHS) const override
Return true if all values of 'this' type can be converted to the specified type.
Init * getElement(unsigned i) const
Resolve arbitrary mappings.
Init * getNameInit() const
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 bool isConcrete() const
Is this a concrete and fully resolved value without any references or stuck operations? Unset values are concrete.
void resolveReferences()
If there are any field references that refer to fields that have been filled in, we can propagate the...
size_t size() const
size - Get the array size.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
void set(Init *Key, Init *Value)
"foo" - Represent an initialization by a string value.
RecTy * getFieldType(StringInit *FieldName) const override
This method is used to implement the FieldInit class.
static void ProfileTernOpInit(FoldingSetNodeID &ID, unsigned Opcode, Init *LHS, Init *MHS, Init *RHS, RecTy *Type)
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
static void ProfileUnOpInit(FoldingSetNodeID &ID, unsigned Opcode, Init *Op, RecTy *Type)
const T * getTrailingObjects() const
Returns a pointer to the trailing object array of the given type (which must be one of those specifie...
bool typeIsConvertibleTo(const RecTy *RHS) const override
Return true if all values of 'this' type can be converted to the specified type.
!op (X) - Transform an init.
Init * getCastTo(RecTy *Ty) const override
If this initializer is convertible to Ty, return an initializer whose type is-a Ty, generating a !cast operation if required.
const std::string getNameInitAsString() const
static void ProfileDagInit(FoldingSetNodeID &ID, Init *V, StringInit *VN, ArrayRef< Init *> ArgRange, ArrayRef< StringInit *> NameRange)
static DagInit * get(Init *V, StringInit *VN, ArrayRef< Init *> ArgRange, ArrayRef< StringInit *> NameRange)
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...
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly...
StringRef getValueAsString(StringRef FieldName) const
This method looks up the specified field and returns its value as a string, throwing an exception if ...
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
'string' - Represent an string value
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations? Unset values are concrete.
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...
static BitInit * get(bool V)
static bool canFitInBitfield(int64_t Value, unsigned NumBits)
std::string getAsString() const override
Convert this value to a string form.
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...
static void ProfileBinOpInit(FoldingSetNodeID &ID, unsigned Opcode, Init *LHS, Init *RHS, RecTy *Type)
DefInit * getDefInit()
get the corresponding DefInit.
static wasm::ValType getType(const TargetRegisterClass *RC)
static Init * ForeachHelper(Init *LHS, Init *MHS, Init *RHS, RecTy *Type, Record *CurRec)
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.
std::pair< typename base::iterator, bool > insert(StringRef Key)
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.
static RecordRecTy * get(ArrayRef< Record *> Classes)
Get the record type with the given non-redundant list of superclasses.
void sort(IteratorTy Start, IteratorTy End)
Init * convertInitializerTo(RecTy *Ty) const override
Convert to an initializer whose type is-a Ty, or return nullptr if this is not possible (this can hap...
std::vector< Record * > getAllDerivedDefinitions(StringRef ClassName) const
This method returns all concrete definitions that derive from the specified class name...
Delegate resolving to a sub-resolver, but shadow some variable names.
void setFinal(bool Final)
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.
static FieldInit * get(Init *R, StringInit *FN)
virtual Init * resolveReferences(Resolver &R) const
This method is used by classes that refer to other variables which may not be defined at the time the...
Init * Fold(Record *CurRec) const
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)
bool typeIsA(const RecTy *RHS) const override
Return true if 'this' type is equal to or a subtype of RHS.
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
virtual bool typeIsA(const RecTy *RHS) const
Return true if 'this' type is equal to or a subtype of RHS.
Init * resolve(Init *VarName) override
Return the initializer for the given variable name (should normally be a StringInit), or nullptr if the name could not be resolved.
const RecordVal * getValue(const Init *Name) 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 RecordMap & getClasses() const
Init * getOperator() 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)
RecordKeeper & getRecords() const
std::string getAsString() const override
Convert this value to a string form.
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...
CHAIN = SC CHAIN, Imm128 - System call.
Init * Fold(Record *CurRec) const
unsigned getNumArgs() const
Init * convertInitializerTo(RecTy *Ty) const override
Convert to an initializer whose type is-a Ty, or return nullptr if this is not possible (this can hap...
std::string getAsString() const override
Convert this value to a string form.
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
RecTy * getElementType() const
static DefInit * get(Record *)
ArrayRef< T > drop_back(size_t N=1) const
Drop the last N elements of the array.
classname<targs...> - Represent an uninstantiated anonymous class instantiation.
std::string utostr(uint64_t X, bool isNeg=false)
Init * convertInitializerTo(RecTy *Ty) const override
Convert to an initializer whose type is-a Ty, or return nullptr if this is not possible (this can hap...
static VarDefInit * get(Record *Class, ArrayRef< Init *> Args)
Init * getBit(unsigned Bit) const override
This method is used to return the initializer for the specified bit.
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
static IsAOpInit * get(RecTy *CheckType, Init *Expr)
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * Allocate(size_t Size, Align Alignment)
Allocate space at the specified alignment.
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...
Init * resolve(Init *VarName) override
Return the initializer for the given variable name (should normally be a StringInit), or nullptr if the name could not be resolved.
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...
LLVM_ATTRIBUTE_NORETURN void PrintFatalError(const Twine &Msg)
void Profile(FoldingSetNodeID &ID) const
void Profile(FoldingSetNodeID &ID) const
!isa<type>(expr) - Dynamically determine the type of an expression.
iterator insert(iterator I, T &&Elt)
static FoldOpInit * get(Init *Start, Init *List, Init *A, Init *B, Init *Expr, RecTy *Type)
static void ProfileIsAOpInit(FoldingSetNodeID &ID, RecTy *CheckType, Init *Expr)
'int' - Represent an integer value of no particular size
Init * getBit(unsigned Bit) const override
This method is used to return the initializer for the specified 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...
std::string getAsString() const override
Convert this value to a string form.
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.
Bitwise operators - logical and, logical or, logical xor.
Init * getNameInit() const
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations? Unset values are concrete.
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations? Unset values are concrete.
static Init * ForeachDagApply(Init *LHS, DagInit *MHSd, Init *RHS, Record *CurRec)
LLVM_NODISCARD bool empty() const
Init * Fold(Record *CurRec) 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)
const_iterator begin() const
static VarListElementInit * get(TypedInit *T, unsigned E)
RecTy * resolveTypes(RecTy *T1, RecTy *T2)
Find a common type that T1 and T2 convert to.
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...
static void ProfileVarDefInit(FoldingSetNodeID &ID, Record *Class, ArrayRef< Init *> Args)
void Profile(FoldingSetNodeID &ID) const
Opcode{0} - Represent access to one bit of a variable or field.
'Opcode' - Represent a reference to an entire variable object.
void Profile(FoldingSetNodeID &ID) const
std::string getAsString() const override
Convert this value to a string form.
static void ProfileCondOpInit(FoldingSetNodeID &ID, ArrayRef< Init *> CondRange, ArrayRef< Init *> ValRange, const RecTy *ValType)
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 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)
'bit' - Represent a single bit
!op (X, Y, Z) - Combine two inits.
static void ProfileBitsInit(FoldingSetNodeID &ID, ArrayRef< Init *> Range)
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
Init * Fold(Record *CurRec) const
static ListInit * get(ArrayRef< Init *> Range, RecTy *EltTy)
virtual bool keepUnsetBits() const
RecTyKind getRecTyKind() const
virtual bool typeIsConvertibleTo(const RecTy *RHS) const
Return true if all values of 'this' type can be converted to the specified type.
StringRef getValue() const
'dag' - Represent a dag fragment
Record * getDef(StringRef Name) const
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckType(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDValue N, const TargetLowering *TLI, const DataLayout &DL)
StringRef getName() const
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.
LLVM Value Representation.
(v a, b) - Represent a DAG tree value.
virtual std::string getAsString() const =0
Convert this value to a string form.
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations? Unset values are concrete.
static void ProfileListInit(FoldingSetNodeID &ID, ArrayRef< Init *> Range, RecTy *EltTy)
StringSet - A wrapper for StringMap that provides set-like functionality.
This class implements an extremely fast bulk output stream that can only output to a stream...
static CondOpInit * get(ArrayRef< Init *> C, ArrayRef< Init *> V, RecTy *Type)
StringRef - Represent a constant reference to a string, i.e.
void Profile(FoldingSetNodeID &ID) const
static void ProfileRecordRecTy(FoldingSetNodeID &ID, ArrayRef< Record *> Classes)
std::string getAsString() const override
Convert this value to a string form.
bool isComplete() const override
This virtual method should be overridden by values that may not be completely specified yet...
virtual std::string getAsString() const =0
Init * convertInitializerTo(RecTy *Ty) const override
Convert to an initializer whose type is-a Ty, or return nullptr if this is not possible (this can hap...
Represents a location in source code.
ListRecTy * getListTy()
Returns the type representing list<this>.
Init * getNewAnonymousName()
GetNewAnonymousName - Generate a unique anonymous name that can be used as an identifier.
for(unsigned i=Desc.getNumOperands(), e=OldMI.getNumOperands();i !=e;++i)
const RecordMap & getDefs() const
std::string getAsString() const override
Convert this value to a string form.
Init * Fold(Record *CurRec) const
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
std::string getAsString() const override
Convert this value to a string form.
bool empty() const
empty - Check if the array is empty.
RecordVal(Init *N, RecTy *T, bool P)
static Init * getListSplat(TypedInit *lhs, Init *rhs)