Go to the documentation of this file.
22 #include "llvm/Config/llvm-config.h"
40 #define DEBUG_TYPE "tblgen-records"
103 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
115 return Kind ==
RHS->getRecTyKind();
128 return BitsTy->getNumBits() == 1;
143 return "bits<" + utostr(Size) +
">";
148 return cast<BitsRecTy>(
RHS)->Size == Size;
155 return RHSb->Size == Size;
186 if (
const auto *ListTy = dyn_cast<ListRecTy>(
RHS))
207 ID.AddInteger(Classes.
size());
215 if (UnsortedClasses.
empty())
221 UnsortedClasses.
end());
223 return LHS->getNameInitAsString() <
RHS->getNameInitAsString();
235 for (
unsigned i = 0;
i < Classes.size(); ++
i) {
236 for (
unsigned j = 0;
j < Classes.size(); ++
j) {
239 assert(&Classes[0]->getRecords() == &Classes[
i]->getRecords());
244 totalSizeToAlloc<Record *>(Classes.size()),
alignof(
RecordRecTy));
246 std::uninitialized_copy(Classes.begin(), Classes.end(),
252 assert(Class &&
"unexpected null class");
253 return get(Class->getRecords(), Class);
262 return getClasses()[0]->getNameInitAsString();
264 std::string Str =
"{";
270 Str += R->getNameInitAsString();
278 return MySuperClass == Class ||
292 return isSubClassOf(TargetClass);
304 while (!Stack.empty()) {
305 Record *R = Stack.pop_back_val();
308 CommonSuperClasses.push_back(R);
310 R->getDirectSuperClasses(Stack);
322 if (
RecordRecTy *RecTy2 = dyn_cast<RecordRecTy>(T2))
326 if (
T1->typeIsConvertibleTo(T2))
331 if (
ListRecTy *ListTy1 = dyn_cast<ListRecTy>(
T1)) {
332 if (
ListRecTy *ListTy2 = dyn_cast<ListRecTy>(T2)) {
334 ListTy2->getElementType());
347 void Init::anchor() {}
349 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
354 if (
auto *TyInit = dyn_cast<TypedInit>(
this))
355 return TyInit->getType()->getRecordKeeper();
356 return cast<UnsetInit>(
this)->getRecordKeeper();
376 if (isa<BitRecTy>(Ty))
377 return const_cast<BitInit *
>(
this);
379 if (isa<IntRecTy>(Ty))
382 if (
auto *BRT = dyn_cast<BitsRecTy>(Ty)) {
384 if (BRT->getNumBits() == 1)
393 ID.AddInteger(Range.
size());
395 for (
Init *
I : Range)
411 std::uninitialized_copy(Range.
begin(), Range.
end(),
412 I->getTrailingObjects<
Init *>());
422 if (isa<BitRecTy>(Ty)) {
427 if (
auto *BRT = dyn_cast<BitsRecTy>(Ty)) {
430 if (
getNumBits() != BRT->getNumBits())
return nullptr;
431 return const_cast<BitsInit *
>(
this);
434 if (isa<IntRecTy>(Ty)) {
438 Result |=
static_cast<int64_t
>(
Bit->getValue()) <<
i;
451 for (
unsigned i = 0,
e =
Bits.size();
i !=
e; ++
i) {
468 std::string Result =
"{ ";
470 if (
i) Result +=
", ";
472 Result +=
Bit->getAsString();
476 return Result +
" }";
482 bool Changed =
false;
485 Init *CachedBitVarRef =
nullptr;
486 Init *CachedBitVarResolved =
nullptr;
490 Init *NewBit = CurBit;
492 if (
VarBitInit *CurBitVar = dyn_cast<VarBitInit>(CurBit)) {
493 if (CurBitVar->getBitVar() != CachedBitVarRef) {
494 CachedBitVarRef = CurBitVar->getBitVar();
497 assert(CachedBitVarResolved &&
"Unresolved bitvar reference");
498 NewBit = CachedBitVarResolved->
getBit(CurBitVar->getBitNum());
504 if (isa<UnsetInit>(NewBit) && R.keepUnsetBits())
507 Changed |= CurBit != NewBit;
513 return const_cast<BitsInit *
>(
this);
524 return itostr(
Value);
529 return (NumBits >=
sizeof(
Value) * 8) ||
530 (
Value >> NumBits == 0) || (
Value >> (NumBits-1) == -1);
534 if (isa<IntRecTy>(Ty))
535 return const_cast<IntInit *
>(
this);
537 if (isa<BitRecTy>(Ty)) {
539 if (Val != 0 && Val != 1)
return nullptr;
543 if (
auto *BRT = dyn_cast<BitsRecTy>(Ty)) {
550 for (
unsigned i = 0;
i != BRT->getNumBits(); ++
i)
564 for (
unsigned i = 0,
e =
Bits.size();
i !=
e; ++
i) {
583 return "anonymous_" + utostr(
Value);
587 auto *Old =
const_cast<Init *
>(
static_cast<const Init *
>(
this));
588 auto *New = R.resolve(Old);
589 New = New ? New : Old;
591 if (
auto *Anonymous = dyn_cast<AnonymousNameInit>(New))
592 return Anonymous->getNameInit();
600 auto &Entry = *InitMap.insert(std::make_pair(V,
nullptr)).first;
607 if (isa<StringRecTy>(Ty))
616 ID.AddInteger(Range.
size());
617 ID.AddPointer(EltTy);
619 for (
Init *
I : Range)
632 assert(Range.
empty() || !isa<TypedInit>(Range[0]) ||
633 cast<TypedInit>(Range[0])->getType()->typeIsConvertibleTo(EltTy));
638 std::uninitialized_copy(Range.
begin(), Range.
end(),
639 I->getTrailingObjects<
Init *>());
645 RecTy *EltTy = cast<ListRecTy>(
getType())->getElementType();
654 if (
auto *LRT = dyn_cast<ListRecTy>(Ty)) {
660 bool Changed =
false;
661 RecTy *ElementType = LRT->getElementType();
663 if (
Init *CI =
I->convertInitializerTo(ElementType)) {
664 Elements.push_back(CI);
679 if (Elements.
size() == 1) {
680 if (Elements[0] >=
size())
687 for (
unsigned Element : Elements) {
688 if (Element >=
size())
696 assert(
i < NumValues &&
"List element index out of range!");
705 Resolved.reserve(
size());
706 bool Changed =
false;
709 Init *
E = CurElt->resolveReferences(R);
710 Changed |=
E != CurElt;
711 Resolved.push_back(
E);
716 return const_cast<ListInit *
>(
this);
720 for (
Init *Element : *
this) {
728 for (
Init *Element : *
this) {
736 std::string Result =
"[";
737 const char *sep =
"";
738 for (
Init *Element : *
this) {
748 return const_cast<OpInit*
>(
this);
754 ID.AddInteger(Opcode);
781 if (isa<StringRecTy>(
getType())) {
782 if (
StringInit *LHSs = dyn_cast<StringInit>(LHS))
785 if (
DefInit *LHSd = dyn_cast<DefInit>(LHS))
788 if (
IntInit *LHSi = dyn_cast_or_null<IntInit>(
792 }
else if (isa<RecordRecTy>(
getType())) {
794 if (!CurRec && !IsFinal)
796 assert(CurRec &&
"NULL pointer");
801 auto *Anonymous = dyn_cast<AnonymousNameInit>(CurRec->
getNameInit());
803 (Anonymous &&
Name == Anonymous->getNameInit())) {
812 Twine(
"Undefined reference to record: '") +
813 Name->getValue() +
"'\n");
821 Twine(
"Expected type '") +
835 if (
IntInit *LHSi = dyn_cast_or_null<IntInit>(
841 if (
ListInit *LHSl = dyn_cast<ListInit>(LHS)) {
842 assert(!LHSl->empty() &&
"Empty list in head");
843 return LHSl->getElement(0);
848 if (
ListInit *LHSl = dyn_cast<ListInit>(LHS)) {
849 assert(!LHSl->empty() &&
"Empty list in tail");
852 return ListInit::get(LHSl->getValues().slice(1), LHSl->getElementType());
857 if (
ListInit *LHSl = dyn_cast<ListInit>(LHS))
859 if (
DagInit *LHSd = dyn_cast<DagInit>(LHS))
861 if (
StringInit *LHSs = dyn_cast<StringInit>(LHS))
866 if (
ListInit *LHSl = dyn_cast<ListInit>(LHS))
868 if (
DagInit *LHSd = dyn_cast<DagInit>(LHS))
870 if (
StringInit *LHSs = dyn_cast<StringInit>(LHS))
879 Twine(
"Expected type '") +
889 return const_cast<UnOpInit *
>(
this);
897 ->Fold(R.getCurrentRecord(), R.isFinal());
898 return const_cast<UnOpInit *
>(
this);
905 case NOT: Result =
"!not";
break;
906 case HEAD: Result =
"!head";
break;
907 case TAIL: Result =
"!tail";
break;
908 case SIZE: Result =
"!size";
break;
909 case EMPTY: Result =
"!empty";
break;
910 case GETDAGOP: Result =
"!getdagop";
break;
918 ID.AddInteger(Opcode);
953 if (
List->size() == 0)
961 for (
unsigned I = 1,
E =
List->size();
I <
E; ++
I) {
975 if (
List->size() == 0)
977 IntInit *Element = dyn_cast_or_null<IntInit>(
983 for (
unsigned I = 1,
E =
List->size();
I <
E; ++
I) {
985 IntInit *Element = dyn_cast_or_null<IntInit>(
996 if (
const StringInit *I0s = dyn_cast<StringInit>(I0))
1015 if (
const ListInit *LHSList = dyn_cast<ListInit>(
LHS))
1016 if (
const ListInit *RHSList = dyn_cast<ListInit>(
RHS))
1024 DagInit *LHSs = dyn_cast<DagInit>(LHS);
1025 DagInit *RHSs = dyn_cast<DagInit>(RHS);
1029 if ((!LOp && !isa<UnsetInit>(LHSs->
getOperator())) ||
1037 Init *
Op = LOp ? LOp : ROp;
1056 ListInit *LHSs = dyn_cast<ListInit>(LHS);
1057 ListInit *RHSs = dyn_cast<ListInit>(RHS);
1068 IntInit *Size = dyn_cast<IntInit>(RHS);
1069 if (
Value && Size) {
1076 StringInit *LHSs = dyn_cast<StringInit>(LHS);
1077 StringInit *RHSs = dyn_cast<StringInit>(RHS);
1084 StringInit *Delim = dyn_cast<StringInit>(RHS);
1085 if (
List && Delim) {
1087 if (isa<StringRecTy>(
List->getElementType()))
1103 IntInit *LHSi = dyn_cast_or_null<IntInit>(
1105 IntInit *RHSi = dyn_cast_or_null<IntInit>(
1123 StringInit *LHSs = dyn_cast<StringInit>(LHS);
1124 StringInit *RHSs = dyn_cast<StringInit>(RHS);
1142 DefInit *LHSd = dyn_cast<DefInit>(LHS);
1143 DefInit *RHSd = dyn_cast<DefInit>(RHS);
1146 (
getOpcode() ==
EQ) ? LHSd == RHSd : LHSd != RHSd);
1157 for (
unsigned i = 0,
e =
Dag->getNumArgs();
i !=
e; ++
i) {
1159 ArgNames.push_back(
Dag->getArgName(
i));
1174 IntInit *LHSi = dyn_cast_or_null<IntInit>(
1176 IntInit *RHSi = dyn_cast_or_null<IntInit>(
1183 case ADD: Result = LHSv + RHSv;
break;
1184 case SUB: Result = LHSv - RHSv;
break;
1185 case MUL: Result = LHSv * RHSv;
break;
1186 case AND: Result = LHSv & RHSv;
break;
1187 case OR: Result = LHSv | RHSv;
break;
1188 case XOR: Result = LHSv ^ RHSv;
break;
1190 case SRA: Result = LHSv >> RHSv;
break;
1205 if (LHS != lhs || RHS != rhs)
1207 ->Fold(R.getCurrentRecord());
1214 case CONCAT: Result =
"!con";
break;
1215 case ADD: Result =
"!add";
break;
1216 case SUB: Result =
"!sub";
break;
1217 case MUL: Result =
"!mul";
break;
1218 case AND: Result =
"!and";
break;
1219 case OR: Result =
"!or";
break;
1220 case XOR: Result =
"!xor";
break;
1221 case SHL: Result =
"!shl";
break;
1222 case SRA: Result =
"!sra";
break;
1223 case SRL: Result =
"!srl";
break;
1224 case EQ: Result =
"!eq";
break;
1225 case NE: Result =
"!ne";
break;
1226 case LE: Result =
"!le";
break;
1227 case LT: Result =
"!lt";
break;
1228 case GE: Result =
"!ge";
break;
1229 case GT: Result =
"!gt";
break;
1230 case LISTCONCAT: Result =
"!listconcat";
break;
1231 case LISTSPLAT: Result =
"!listsplat";
break;
1232 case STRCONCAT: Result =
"!strconcat";
break;
1233 case INTERLEAVE: Result =
"!interleave";
break;
1234 case SETDAGOP: Result =
"!setdagop";
break;
1242 ID.AddInteger(Opcode);
1271 return RHS->resolveReferences(R);
1276 bool Change =
false;
1292 NewArgs.push_back(std::make_pair(NewArg, ArgName));
1305 if (
DagInit *MHSd = dyn_cast<DagInit>(MHS))
1308 if (
ListInit *MHSl = dyn_cast<ListInit>(MHS)) {
1311 for (
Init *&Item : NewList) {
1313 if (NewItem != Item)
1326 if (
ListInit *MHSl = dyn_cast<ListInit>(MHS)) {
1329 for (
Init *Item : MHSl->getValues()) {
1334 dyn_cast_or_null<IntInit>(Include->convertInitializerTo(
1336 if (IncludeInt->getValue())
1337 NewList.push_back(Item);
1352 DefInit *LHSd = dyn_cast<DefInit>(LHS);
1353 VarInit *LHSv = dyn_cast<VarInit>(LHS);
1354 StringInit *LHSs = dyn_cast<StringInit>(LHS);
1356 DefInit *MHSd = dyn_cast<DefInit>(MHS);
1357 VarInit *MHSv = dyn_cast<VarInit>(MHS);
1358 StringInit *MHSs = dyn_cast<StringInit>(MHS);
1360 DefInit *RHSd = dyn_cast<DefInit>(RHS);
1361 VarInit *RHSv = dyn_cast<VarInit>(RHS);
1362 StringInit *RHSs = dyn_cast<StringInit>(RHS);
1364 if (LHSd && MHSd && RHSd) {
1370 if (LHSv && MHSv && RHSv) {
1371 std::string Val = std::string(RHSv->
getName());
1373 Val = std::string(MHSv->
getName());
1376 if (LHSs && MHSs && RHSs) {
1377 std::string Val = std::string(RHSs->
getValue());
1379 std::string::size_type found;
1380 std::string::size_type idx = 0;
1382 found = Val.find(std::string(LHSs->
getValue()), idx);
1383 if (found == std::string::npos)
1408 if (
IntInit *LHSi = dyn_cast_or_null<IntInit>(
1410 if (LHSi->getValue())
1418 ListInit *MHSl = dyn_cast<ListInit>(MHS);
1419 ListInit *RHSl = dyn_cast<ListInit>(RHS);
1420 bool MHSok = MHSl || isa<UnsetInit>(MHS);
1421 bool RHSok = RHSl || isa<UnsetInit>(RHS);
1423 if (isa<UnsetInit>(MHS) && isa<UnsetInit>(RHS))
1426 if (MHSok && RHSok && (!MHSl || !RHSl || MHSl->
size() == RHSl->
size())) {
1428 unsigned Size = MHSl ? MHSl->
size() : RHSl->
size();
1429 for (
unsigned i = 0;
i != Size; ++
i) {
1432 if (!isa<StringInit>(
Name) && !isa<UnsetInit>(
Name))
1442 StringInit *LHSs = dyn_cast<StringInit>(LHS);
1443 IntInit *MHSi = dyn_cast<IntInit>(MHS);
1444 IntInit *RHSi = dyn_cast<IntInit>(RHS);
1445 if (LHSs && MHSi && RHSi) {
1449 if (Start < 0 || Start > StringSize)
1451 Twine(
"!substr start position is out of range 0...") +
1463 StringInit *LHSs = dyn_cast<StringInit>(LHS);
1464 StringInit *MHSs = dyn_cast<StringInit>(MHS);
1465 IntInit *RHSi = dyn_cast<IntInit>(RHS);
1466 if (LHSs && MHSs && RHSi) {
1469 if (Start < 0 || Start > SourceSize)
1471 Twine(
"!find start position is out of range 0...") +
1475 if (
I == std::string::npos)
1493 if (
Value->getValue())
1510 if (LHS != lhs || MHS != mhs || RHS != rhs)
1512 ->Fold(R.getCurrentRecord());
1518 bool UnquotedLHS =
false;
1520 case DAG: Result =
"!dag";
break;
1521 case FILTER: Result =
"!filter"; UnquotedLHS =
true;
break;
1522 case FOREACH: Result =
"!foreach"; UnquotedLHS =
true;
break;
1523 case IF: Result =
"!if";
break;
1524 case SUBST: Result =
"!subst";
break;
1525 case SUBSTR: Result =
"!substr";
break;
1526 case FIND: Result =
"!find";
break;
1528 return (Result +
"(" +
1535 ID.AddPointer(Start);
1539 ID.AddPointer(Expr);
1563 if (
ListInit *LI = dyn_cast<ListInit>(List)) {
1564 Init *Accum = Start;
1565 for (
Init *Elt : *LI) {
1584 if (Start == NewStart && List == NewList && Expr ==
NewExpr)
1588 ->
Fold(R.getCurrentRecord());
1605 ID.AddPointer(Expr);
1628 if (
TypedInit *TI = dyn_cast<TypedInit>(Expr)) {
1630 if (TI->getType()->typeIsConvertibleTo(CheckType))
1633 if (isa<RecordRecTy>(CheckType)) {
1667 ID.AddPointer(Expr);
1690 if (!CurRec && !IsFinal)
1695 auto *Anonymous = dyn_cast<AnonymousNameInit>(CurRec->
getNameInit());
1697 (Anonymous &&
Name == Anonymous->getNameInit())) {
1724 if (Expr !=
NewExpr || R.isFinal())
1725 return get(CheckType,
NewExpr)->
Fold(R.getCurrentRecord(), R.isFinal());
1743 return Field->getType();
1754 if (isa<BitRecTy>(
getType()) && isa<BitsRecTy>(Ty) &&
1755 cast<BitsRecTy>(Ty)->getNumBits() == 1)
1763 if (!
T)
return nullptr;
1764 unsigned NumBits =
T->getNumBits();
1783 assert(!isa<TypedInit>(Converted) ||
1784 cast<TypedInit>(Converted)->
getType()->typeIsA(Ty));
1788 if (!
getType()->typeIsConvertibleTo(Ty))
1797 if (!
T)
return nullptr;
1799 if (Elements.
size() == 1)
1804 for (
unsigned Element : Elements)
1831 return const_cast<VarInit*
>(
this);
1836 if (
Init *Val = R.resolve(VarName))
1838 return const_cast<VarInit *
>(
this);
1850 return TI->
getAsString() +
"{" + utostr(Bit) +
"}";
1870 return TI->
getAsString() +
"[" + utostr(Element) +
"]";
1881 if (NewTI != TI && isa<TypedInit>(NewTI))
1896 return R->getDefInit();
1900 if (
auto *RRT = dyn_cast<RecordRecTy>(Ty))
1901 if (
getType()->typeIsConvertibleTo(RRT))
1902 return const_cast<DefInit *
>(
this);
1908 return RV->getType();
1917 ID.AddInteger(
Args.size());
1918 ID.AddPointer(Class);
1924 VarDefInit::VarDefInit(
Record *Class,
unsigned N)
1940 std::uninitialized_copy(
Args.begin(),
Args.end(),
1941 I->getTrailingObjects<
Init *>());
1950 DefInit *VarDefInit::instantiate() {
1954 Class->
getLoc(), Records,
1956 Record *NewRec = NewRecOwner.get();
1969 for (
unsigned i = 0,
e = TArgs.
size();
i !=
e; ++
i) {
1982 for (
const auto &SCPair : SCs)
1987 Class->
getLoc().back()));
2004 bool Changed =
false;
2009 Init *NewArg =
Arg->resolveReferences(UR);
2010 NewArgs.push_back(NewArg);
2011 Changed |= NewArg !=
Arg;
2017 return New->instantiate();
2029 Arg->resolveReferences(R);
2031 if (!R.foundUnresolved())
2032 return const_cast<VarDefInit *
>(
this)->instantiate();
2038 const char *sep =
"";
2042 Result +=
Arg->getAsString();
2044 return Result +
">";
2069 if (
DefInit *DI = dyn_cast<DefInit>(Rec)) {
2073 Twine(
"Attempting to access field '") +
2075 Rec->
getAsString() +
"' is a forbidden self-reference");
2076 Init *FieldVal =
Def->getValue(FieldName)->getValue();
2084 if (
DefInit *DI = dyn_cast<DefInit>(Rec)) {
2085 Init *FieldVal = DI->getDef()->getValue(FieldName)->getValue();
2096 "Number of conditions and values must match!");
2101 while (Case != CondRange.
end()) {
2102 ID.AddPointer(*Case++);
2103 ID.AddPointer(*Val++);
2110 makeArrayRef(getTrailingObjects<Init *>() + NumConds, NumConds),
2117 "Number of conditions and values must match!");
2128 totalSizeToAlloc<Init *>(2 * CondRange.
size()),
alignof(
BitsInit));
2131 std::uninitialized_copy(CondRange.
begin(), CondRange.
end(),
2132 I->getTrailingObjects<
Init *>());
2133 std::uninitialized_copy(ValRange.
begin(), ValRange.
end(),
2134 I->getTrailingObjects<
Init *>()+CondRange.
size());
2141 bool Changed =
false;
2144 NewConds.push_back(NewCase);
2145 Changed |= NewCase != Case;
2151 NewVals.push_back(NewVal);
2152 Changed |= NewVal != Val;
2164 for (
unsigned i = 0;
i < NumConds; ++
i) {
2168 if (
IntInit *CondI = dyn_cast_or_null<IntInit>(
2170 if (CondI->getValue())
2179 " does not have any true condition in:" +
2180 this->getAsString());
2186 if (!Case->isConcrete())
2190 if (!Val->isConcrete())
2198 if (!Case->isComplete())
2202 if (!Val->isConcrete())
2209 std::string Result =
"!cond(";
2216 return Result +
")";
2231 while (
Arg != ArgRange.
end()) {
2233 ID.AddPointer(*
Arg++);
2250 totalSizeToAlloc<Init *, StringInit *>(ArgRange.
size(), NameRange.
size()),
2253 std::uninitialized_copy(ArgRange.
begin(), ArgRange.
end(),
2254 I->getTrailingObjects<
Init *>());
2255 std::uninitialized_copy(NameRange.
begin(), NameRange.
end(),
2263 ArrayRef<std::pair<Init*, StringInit*>> args) {
2267 for (
const auto &
Arg : args) {
2269 Names.push_back(
Arg.second);
2280 if (
DefInit *DefI = dyn_cast<DefInit>(Val))
2281 return DefI->getDef();
2289 bool ArgsChanged =
false;
2291 Init *NewArg =
Arg->resolveReferences(R);
2292 NewArgs.push_back(NewArg);
2293 ArgsChanged |= NewArg !=
Arg;
2297 if (
Op != Val || ArgsChanged)
2300 return const_cast<DagInit *
>(
this);
2307 if (!Elt->isConcrete())
2325 return Result +
")";
2333 :
Name(
N), TyAndKind(
T, K) {
2335 assert(
Value &&
"Cannot create unset value for current type!");
2341 :
Name(
N), Loc(Loc), TyAndKind(
T, K) {
2343 assert(
Value &&
"Cannot create unset value for current type!");
2347 return cast<StringInit>(
getNameInit())->getValue();
2352 if (
auto *StrInit = dyn_cast<StringInit>(
Value)) {
2353 if (StrInit->hasCodeFormat())
2361 return TyAndKind.getPointer()->getAsString();
2372 if (!isa<BitsInit>(
Value)) {
2374 Bits.reserve(BTy->getNumBits());
2375 for (
unsigned I = 0,
E = BTy->getNumBits();
I <
E; ++
I)
2381 return Value ==
nullptr;
2397 if (!isa<BitsInit>(
Value)) {
2399 Bits.reserve(BTy->getNumBits());
2400 for (
unsigned I = 0,
E = BTy->getNumBits();
I <
E; ++
I)
2406 return Value ==
nullptr;
2412 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2424 if (PrintSem) OS <<
";\n";
2427 void Record::checkName() {
2429 const TypedInit *TypedName = cast<const TypedInit>(Name);
2430 if (!isa<StringRecTy>(TypedName->
getType()))
2432 "' is not a string!");
2442 if (!CorrespondingDefInit) {
2443 CorrespondingDefInit =
2446 return CorrespondingDefInit;
2477 for (
int I = SCs.
size() - 1;
I >= 0; --
I) {
2479 if (
SC == Superclass)
2481 I -=
SC->getSuperClasses().size();
2490 while (!SCs.
empty()) {
2492 SCs = SCs.
drop_back(1 +
SC->getSuperClasses().size());
2493 Classes.push_back(
SC);
2500 if (NewName != OldName) {
2507 if (SkipVal == &
Value)
2511 if (
Value.setValue(VR)) {
2513 if (
TypedInit *VRT = dyn_cast<TypedInit>(VR))
2515 (
Twine(
"of type '") + VRT->getType()->getAsString() +
"' ").str();
2518 Twine(
"Invalid value ") +
Type +
"found when setting field '" +
2519 Value.getNameInitAsString() +
"' of type '" +
2528 for (
auto &Assertion : Assertions) {
2529 Init *
Value = Assertion.Condition->resolveReferences(R);
2530 Assertion.Condition =
Value;
2531 Value = Assertion.Message->resolveReferences(R);
2532 Assertion.Message =
Value;
2543 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2548 OS << R.getNameInitAsString();
2551 if (!TArgs.
empty()) {
2553 bool NeedComma =
false;
2554 for (
const Init *
TA : TArgs) {
2555 if (NeedComma) OS <<
", ";
2558 assert(RV &&
"Template argument record not found??");
2559 RV->
print(OS,
false);
2568 for (
const auto &SuperPair :
SC)
2569 OS <<
" " << SuperPair.first->getNameInitAsString();
2573 for (
const RecordVal &Val : R.getValues())
2574 if (Val.isNonconcreteOK() && !R.isTemplateArg(Val.getNameInit()))
2576 for (
const RecordVal &Val : R.getValues())
2577 if (!Val.isNonconcreteOK() && !R.isTemplateArg(Val.getNameInit()))
2587 "' does not have a field named `" + FieldName +
"'!\n");
2593 if (!R || !R->getValue())
2595 "' does not have a field named `" + FieldName +
"'!\n");
2596 return R->getValue();
2603 "' does not have a field named `" + FieldName +
"'!\n");
2604 return S.getValue();
2610 if (!R || !R->getValue())
2612 if (isa<UnsetInit>(R->getValue()))
2615 if (
StringInit *
SI = dyn_cast<StringInit>(R->getValue()))
2616 return SI->getValue();
2619 "Record `" +
getName() +
"', ` field `" + FieldName +
2620 "' exists but does not have a string initializer!");
2625 if (!R || !R->getValue())
2627 "' does not have a field named `" + FieldName +
"'!\n");
2629 if (
BitsInit *BI = dyn_cast<BitsInit>(R->getValue()))
2632 "' exists but does not have a bits value");
2637 if (!R || !R->getValue())
2639 "' does not have a field named `" + FieldName +
"'!\n");
2641 if (
ListInit *LI = dyn_cast<ListInit>(R->getValue()))
2644 "' exists but does not have a list value");
2647 std::vector<Record*>
2650 std::vector<Record*> Defs;
2652 if (
DefInit *DI = dyn_cast<DefInit>(
I))
2653 Defs.push_back(DI->getDef());
2656 FieldName +
"' list is not entirely DefInit!");
2663 if (!R || !R->getValue())
2665 "' does not have a field named `" + FieldName +
"'!\n");
2667 if (
IntInit *II = dyn_cast<IntInit>(R->getValue()))
2668 return II->getValue();
2671 "' exists but does not have an int value: " +
2672 R->getValue()->getAsString());
2675 std::vector<int64_t>
2678 std::vector<int64_t> Ints;
2680 if (
IntInit *II = dyn_cast<IntInit>(
I))
2681 Ints.push_back(II->getValue());
2684 Twine(
"Record `") +
getName() +
"', field `" + FieldName +
2685 "' exists but does not have a list of ints value: " +
2691 std::vector<StringRef>
2694 std::vector<StringRef> Strings;
2697 Strings.push_back(
SI->getValue());
2700 Twine(
"Record `") +
getName() +
"', field `" + FieldName +
2701 "' exists but does not have a list of strings value: " +
2709 if (!R || !R->getValue())
2711 "' does not have a field named `" + FieldName +
"'!\n");
2713 if (
DefInit *DI = dyn_cast<DefInit>(R->getValue()))
2714 return DI->getDef();
2716 FieldName +
"' does not have a def initializer!");
2721 if (!R || !R->getValue())
2723 "' does not have a field named `" + FieldName +
"'!\n");
2725 if (
DefInit *DI = dyn_cast<DefInit>(R->getValue()))
2726 return DI->getDef();
2727 if (isa<UnsetInit>(R->getValue()))
2730 FieldName +
"' does not have either a def initializer or '?'!");
2736 if (!R || !R->getValue())
2738 "' does not have a field named `" + FieldName +
"'!\n");
2740 if (
BitInit *BI = dyn_cast<BitInit>(R->getValue()))
2741 return BI->getValue();
2743 FieldName +
"' does not have a bit initializer!");
2748 if (!R || !R->getValue())
2750 "' does not have a field named `" + FieldName.
str() +
"'!\n");
2752 if (isa<UnsetInit>(R->getValue())) {
2757 if (
BitInit *BI = dyn_cast<BitInit>(R->getValue()))
2758 return BI->getValue();
2760 FieldName +
"' does not have a bit initializer!");
2765 if (!R || !R->getValue())
2767 "' does not have a field named `" + FieldName +
"'!\n");
2769 if (
DagInit *DI = dyn_cast<DagInit>(R->getValue()))
2772 FieldName +
"' does not have a dag initializer!");
2796 "unused template argument: " +
Twine(
Arg->getName()));
2801 : Impl(
std::make_unique<detail::RecordKeeperImpl>(*
this)) {}
2804 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2809 OS <<
"------------- Classes -----------------\n";
2811 OS <<
"class " << *
C.second;
2813 OS <<
"------------- Defs -----------------\n";
2815 OS <<
"def " << *
D.second;
2830 if (LastTimer && LastTimer->
isRunning()) {
2834 BackendTimer =
false;
2838 LastTimer =
new Timer(
"",
Name, *TimingGroup);
2845 assert(LastTimer &&
"No phase timer was started");
2853 BackendTimer =
true;
2861 BackendTimer =
false;
2866 std::vector<Record *>
2870 auto Pair = ClassRecordsMap.try_emplace(ClassName);
2874 return Pair.first->second;
2880 std::vector<Record *> Defs;
2882 assert(ClassNames.
size() > 0 &&
"At least one class must be passed.");
2883 for (
const auto &ClassName : ClassNames) {
2887 ClassRecs.push_back(Class);
2890 for (
const auto &OneDef :
getDefs()) {
2892 return OneDef.second->isSubClassOf(Class);
2894 Defs.push_back(OneDef.second.get());
2900 std::vector<Record *>
2903 : std::vector<Record *>();
2908 if (It == Map.end())
2911 Init *
I = It->second.V;
2913 if (!It->second.Resolved && Map.size() > 1) {
2917 I =
I->resolveReferences(*
this);
2933 if (!isa<UnsetInit>(RV->getValue())) {
2934 Val = RV->getValue();
2954 if (
I && !FoundUnresolved) {
2959 I->resolveReferences(Sub);
2960 FoundUnresolved |= Sub.FoundUnresolved;
2965 FoundUnresolved =
true;
2971 if (
VarName == VarNameToTrack)
virtual bool isComplete() const
Is this a complete value with no unset (uninitialized) subvalues?
ArrayRef< Init * > getConds() const
Init * Fold(Record *CurRec) const
bool isSubClassOf(const Record *R) const
bool isComplete() const override
Is this a complete value with no unset (uninitialized) subvalues?
RecTy * getFieldType(StringInit *FieldName) const override
This method is used to implement the FieldInit class.
TernaryOp getOpcode() const
std::string getAsString() const override
Convert this value to a literal form.
Init * convertInitListSlice(ArrayRef< unsigned > Elements) const override
This function is used to implement the list slice selection operator.
ArrayRef< T > drop_back(size_t N=1) const
Drop the last N elements of the array.
std::string getPrintType() const
Get the type of the field for printing purposes.
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
void clear()
Clear the timer state.
This is an optimization pass for GlobalISel generic memory operations.
'string' - Represent an string value
Init * convertInitializerTo(RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
ArrayRef< Init * > args() const
std::string getAsString() const override
Convert this value to a literal form.
virtual Init * convertInitializerTo(RecTy *Ty) const =0
Convert to a value whose type is Ty, or return null if this is not possible.
Init * getCond(unsigned Num) const
Init * getCastTo(RecTy *Ty) const override
If this value is convertible to type Ty, return a value whose type is Ty, generating a !...
std::string getAsString() const override
Convert this value to a literal form.
virtual Init * getCastTo(RecTy *Ty) const =0
If this value is convertible to type Ty, return a value whose type is Ty, generating a !...
void getDirectSuperClasses(SmallVectorImpl< Record * > &Classes) const
Append the direct superclasses of this record to Classes.
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
std::string getAsString() const override
Convert this value to a literal form.
Base class for operators.
Init * convertInitializerTo(RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
static BinOpInit * get(BinaryOp opc, Init *lhs, Init *rhs, RecTy *Type)
Init * convertInitializerBitRange(ArrayRef< unsigned > Bits) const override
This function is used to implement the bit range selection operator.
std::vector< Record * > getValueAsListOfDefs(StringRef FieldName) const
This method looks up the specified field and returns its value as a vector of records,...
std::string getAsString() const override
Convert this value to a literal form.
RecTy * getFieldType(StringInit *FieldName) const override
This method is used to implement the FieldInit class.
void InsertNode(T *N, void *InsertPos)
InsertNode - Insert the specified node into the folding set, knowing that it is not already in the fo...
detail::RecordKeeperImpl & getImpl()
Return the internal implementation of the RecordKeeper.
LLVM_NODISCARD size_t find(char C, size_t From=0) const
Search for the first character C in the string.
!isa<type>(expr) - Dynamically determine the type of an expression.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
bool typeIsConvertibleTo(const RecTy *RHS) const override
Return true if all values of 'this' type can be converted to the specified type.
Helper object to track which of three possible relocation mechanisms are used for a particular value ...
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckType(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDValue N, const TargetLowering *TLI, const DataLayout &DL)
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
static DagRecTy * get(RecordKeeper &RK)
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
ArrayRef< std::pair< Record *, SMRange > > getSuperClasses() const
static void ProfileCondOpInit(FoldingSetNodeID &ID, ArrayRef< Init * > CondRange, ArrayRef< Init * > ValRange, const RecTy *ValType)
(v a, b) - Represent a DAG tree value.
static FieldInit * get(Init *R, StringInit *FN)
FoldingSet< BinOpInit > TheBinOpInitPool
T * FindNodeOrInsertPos(const FoldingSetNodeID &ID, void *&InsertPos)
FindNodeOrInsertPos - Look up the node specified by ID.
RecordKeeper & getRecordKeeper() const
Get the record keeper used to unique this value.
(Optionally) delegate resolving to a sub-resolver, and keep track whether there were unresolved refer...
std::string getNameInitAsString() const
Get the name of the field as a std::string.
void print(raw_ostream &OS) const
The instances of the Type class are immutable: once they are created, they are never changed.
static unsigned getNewUID(RecordKeeper &RK)
This class is used to track the amount of time spent between invocations of its startTimer()/stopTime...
'int' - Represent an integer value of no particular size
!op (X, Y) - Combine two inits.
StringInit * getNameInit() const
!op (X, Y, Z) - Combine two inits.
'dag' - Represent a dag fragment
std::string getAsString() const override
Convert this value to a literal form.
Record * getOperatorAsDef(ArrayRef< SMLoc > Loc) const
bool typeIsConvertibleTo(const RecTy *RHS) const override
Return true if all values of 'this' type can be converted to the specified type.
std::string getAsString() const override
Convert this value to a literal form.
ArrayRef< SMLoc > getLoc() const
static VarBitInit * get(TypedInit *T, unsigned B)
static ListInit * get(ArrayRef< Init * > Range, RecTy *EltTy)
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
void checkUnusedTemplateArgs()
static FoldOpInit * get(Init *Start, Init *List, Init *A, Init *B, Init *Expr, RecTy *Type)
FoldingSet< IsAOpInit > TheIsAOpInitPool
static Init * ItemApply(Init *LHS, Init *MHSe, Init *RHS, Record *CurRec)
static StringInit * interleaveStringList(const ListInit *List, const StringInit *Delim)
static void ProfileDagInit(FoldingSetNodeID &ID, Init *V, StringInit *VN, ArrayRef< Init * > ArgRange, ArrayRef< StringInit * > NameRange)
virtual Init * getBit(unsigned Bit) const =0
Get the Init value of the specified bit.
static Init * getStrConcat(Init *lhs, Init *rhs)
static RecordRecTy * resolveRecordTypes(RecordRecTy *T1, RecordRecTy *T2)
Record * getValueAsOptionalDef(StringRef FieldName) const
This method looks up the specified field and returns its value as a Record, returning null if the fie...
void startTimer()
Start the timer running.
Init * getArg(unsigned Num) const
'Opcode' - Represent a reference to an entire variable object.
SMLoc getFieldLoc(StringRef FieldName) const
Return the source location for the named field.
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
Init * getOperator() const
bool empty() const
empty - Check if the array is empty.
FoldingSet< ExistsOpInit > TheExistsOpInitPool
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
'bit' - Represent a single bit
Init * Fold(Record *CurRec) const
ListInit * getValueAsListInit(StringRef FieldName) const
This method looks up the specified field and returns its value as a ListInit, throwing an exception i...
DenseMap< std::pair< TypedInit *, unsigned >, VarListElementInit * > TheVarListElementInitPool
Init * Fold(Record *CurRec) const
RecTy * getElementType() const
'bits<n>' - Represent a fixed number of bits
void startBackendTimer(StringRef Name)
Start timing the overall backend.
bool isRunning() const
Check if the timer is currently running.
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
LLVM_NODISCARD StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
ArrayRef< Init * > getTemplateArgs() const
FoldingSet< RecordRecTy > RecordTypePool
StringRecTy SharedStringRecTy
FunctionType * getType(LLVMContext &Context, ID id, ArrayRef< Type * > Tys=None)
Return the function type for an intrinsic.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
void resolveReferences(Init *NewName=nullptr)
If there are any field references that refer to fields that have been filled in, we can propagate the...
RecordKeeper & getRecordKeeper() const
Return the RecordKeeper that uniqued this Type.
void startTimer(StringRef Name)
Start timing a phase. Automatically stops any previous phase timer.
const T & back() const
back - Get the last element.
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
RecordKeeperImpl(RecordKeeper &RK)
ArrayRef< Init * > getVals() const
@ SC
CHAIN = SC CHAIN, Imm128 - System call.
Represents a location in source code.
static BitInit * get(RecordKeeper &RK, bool V)
Init * getArg(unsigned i) const
unsigned getElementNum() const
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
bool typeIsConvertibleTo(const RecTy *RHS) const override
Return true if all values of 'this' type can be converted to the specified type.
!foldl (a, b, expr, start, lst) - Fold over a list.
std::string getAsString() const override
Convert this value to a literal form.
void CheckAssert(SMLoc Loc, Init *Condition, Init *Message)
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
(vector float) vec_cmpeq(*A, *B) C
RecTy * getElementType() const
Init * resolve(Init *VarName) override
Return the initializer for the given variable name (should normally be a StringInit),...
RecordKeeper & getRecordKeeper() const
Get the record keeper that initialized this Init.
void addDef(std::unique_ptr< Record > R)
!cond(condition_1: value1, ...
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
std::string getAsString() const override
void dump() const
Debugging method that may be called through a debugger; just invokes print on stderr.
void stopBackendTimer()
Stop timing the overall backend.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
into llvm powi allowing the code generator to produce balanced multiplication trees First
FoldingSet< ListInit > TheListInitPool
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 constexpr int Concat[]
RecTy * getType() const
Get the type of the Init as a RecTy.
void PrintFatalError(const Twine &Msg)
static void ProfileListInit(FoldingSetNodeID &ID, ArrayRef< Init * > Range, RecTy *EltTy)
std::string getAsString() const override
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
This class implements an extremely fast bulk output stream that can only output to a stream.
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
static Init * getListConcat(TypedInit *lhs, Init *rhs)
FoldingSet< FoldOpInit > TheFoldOpInitPool
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
BumpPtrAllocator Allocator
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
void Profile(FoldingSetNodeID &ID) const
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
static TernOpInit * get(TernaryOp opc, Init *lhs, Init *mhs, Init *rhs, RecTy *Type)
Init * getValue() const
Get the value of the field as an Init.
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
unsigned getNumConds() const
std::string getAsString() const override
Convert this value to a literal form.
static CondOpInit * get(ArrayRef< Init * > C, ArrayRef< Init * > V, RecTy *Type)
void addShadow(Init *Key)
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
"anonymous_n" - Represent an anonymous record name
X.Y - Represent a reference to a subfield of a variable.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
std::string getAsString() const override
Convert this value to a literal form.
Init * convertInitializerTo(RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
bool typeIsA(const RecTy *RHS) const override
Return true if 'this' type is equal to or a subtype of RHS.
ArrayRef< AssertionInfo > getAssertions() const
std::string getAsString() const override
Convert this value to a literal form.
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
FoldingSet< TernOpInit > TheTernOpInitPool
static void ProfileBinOpInit(FoldingSetNodeID &ID, unsigned Opcode, Init *LHS, Init *RHS, RecTy *Type)
!op (X) - Transform an init.
static Init * FilterHelper(Init *LHS, Init *MHS, Init *RHS, RecTy *Type, Record *CurRec)
bool setValue(Init *V)
Set the value of the field from an Init.
Record * getCurrentRecord() const
virtual bool isConcrete() const
Is this a concrete and fully resolved value without any references or stuck operations?...
Init * convertInitializerTo(RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
static IsAOpInit * get(RecTy *CheckType, Init *Expr)
'7' - Represent an initialization by a literal integer value.
DefInit * getDefInit()
get the corresponding DefInit.
std::string getAsString() const override
Convert this value to a literal form.
Init * convertInitializerTo(RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
[AL, AH, CL] - Represent a list of defs
Init * convertInitializerTo(RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
Resolve arbitrary mappings.
void print(raw_ostream &OS, bool PrintSem=true) const
Print the value to an output stream, possibly with a semicolon.
static BitsInit * get(RecordKeeper &RK, ArrayRef< Init * > Range)
FoldingSet< BitsInit > TheBitsInitPool
ArrayRef< RecordVal > getValues() const
AL - Represent a reference to a 'def' in the description.
Allocate memory in an ever growing pool, as if by bump-pointer.
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
static VarInit * get(StringRef VN, RecTy *T)
'[classname]' - Type of record values that have zero or more superclasses.
Delegate resolving to a sub-resolver, but shadow some variable names.
DenseMap< std::pair< RecTy *, Init * >, VarInit * > TheVarInitPool
void addValue(const RecordVal &RV)
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.
const std::string getNameInitAsString() const
static void ProfileTernOpInit(FoldingSetNodeID &ID, unsigned Opcode, Init *LHS, Init *MHS, Init *RHS, RecTy *Type)
void checkRecordAssertions()
FoldingSet< DagInit > TheDagInitPool
bool typeIsA(const RecTy *RHS) const override
Return true if 'this' type is equal to or a subtype of RHS.
RecTy * resolveTypes(RecTy *T1, RecTy *T2)
Find a common type that T1 and T2 convert to.
static ExistsOpInit * get(RecTy *CheckType, Init *Expr)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
'list<Ty>' - Represent a list of element values, all of which must be of the specified type.
std::vector< StringRef > getValueAsListOfStrings(StringRef FieldName) const
This method looks up the specified field and returns its value as a vector of strings,...
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
StandardInstrumentations SI(Debug, VerifyEach)
Init * convertInitializerBitRange(ArrayRef< unsigned > Bits) const override
This function is used to implement the bit range selection operator.
Init * Fold(Record *CurRec) const
std::vector< Record * > getAllDerivedDefinitionsIfDefined(StringRef ClassName) const
Get all the concrete records that inherit from specified class, if the class is defined.
virtual Init * resolveReferences(Resolver &R) const
This function is used by classes that refer to other variables which may not be defined at the time t...
virtual std::string getAsUnquotedString() const
Convert this value to a literal form, without adding quotes around a string.
static void ProfileExistsOpInit(FoldingSetNodeID &ID, RecTy *CheckType, Init *Expr)
void removeValue(Init *Name)
std::vector< int64_t > getValueAsListOfInts(StringRef FieldName) const
This method looks up the specified field and returns its value as a vector of integers,...
void stopTimer()
Stop the timer.
static IntInit * get(RecordKeeper &RK, int64_t V)
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional ldr LCPI1_0 ldr ldr tst movne lsr ldr LCPI1_1 and r0 bx lr it saves an instruction and a register It might be profitable to cse MOVi16 if there are lots of bit immediates with the same bottom half Robert Muth started working on an alternate jump table implementation that does not put the tables in line in the text This is more like the llvm default jump table implementation This might be useful sometime Several revisions of patches are on the mailing beginning while CMP sets them like a subtract Therefore to be able to use CMN for comparisons other than the Z we ll need additional logic to reverse the conditionals associated with the comparison Perhaps a pseudo instruction for the with a post codegen pass to clean up and handle the condition codes See PR5694 for testcase Given the following on int B
static void ProfileRecordRecTy(FoldingSetNodeID &ID, ArrayRef< Record * > Classes)
DagInit * getValueAsDag(StringRef FieldName) const
This method looks up the specified field and returns its value as an Dag, throwing an exception if th...
const RecordMap & getDefs() const
Get the map of records (defs).
static ListInit * ConcatListInits(const ListInit *LHS, const ListInit *RHS)
StringRef getName() const
static void ProfileIsAOpInit(FoldingSetNodeID &ID, RecTy *CheckType, Init *Expr)
Init * resolve(Init *VarName) override
Return the initializer for the given variable name (should normally be a StringInit),...
!exists<type>(expr) - Dynamically determine if a record of type named expr exists.
Record * getClass(StringRef Name) const
Get the class with the specified name.
virtual std::string getAsString() const =0
Convert this value to a literal form.
std::string getAsString() const override
BitsInit * getValueAsBitsInit(StringRef FieldName) const
This method looks up the specified field and returns its value as a BitsInit, throwing an exception i...
std::string getAsString() const override
Convert this value to a literal form.
const RecordMap & getClasses() const
Get the map of classes.
Init * convertInitializerTo(RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
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...
"foo" - Represent an initialization by a string value.
Init * convertInitializerTo(RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
FoldingSet - This template class is used to instantiate a specialized implementation of the folding s...
std::vector< Record * > getAllDerivedDefinitions(StringRef ClassName) const
Get all the concrete records that inherit from the one specified class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
void addSuperClass(Record *R, SMRange Range)
std::string getAsString() const override
Convert this value to a literal form.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
void Profile(FoldingSetNodeID &ID) const
SmallVector< MachineOperand, 4 > Cond
StringRef - Represent a constant reference to a string, i.e.
Analysis the ScalarEvolution expression for r is this
unsigned getNumBits() const
'true'/'false' - Represent a concrete initializer for a bit.
const T * getTrailingObjects() const
Returns a pointer to the trailing object array of the given type (which must be one of those specifie...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Init * getVal(unsigned Num) const
Type * getType() const
All values are typed, get the type of this value.
Init * getNameInit() const
Get the name of the field as an Init.
virtual bool typeIsA(const RecTy *RHS) const
Return true if 'this' type is equal to or a subtype of RHS.
Init * getNameInit() const
ArrayRef< Record * > getClasses() const
bool isComplete() const override
Is this a complete value with no unset (uninitialized) subvalues?
void append_range(Container &C, Range &&R)
Wrapper function to append a range to a container.
void Profile(FoldingSetNodeID &ID) const
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
void Profile(FoldingSetNodeID &ID) const
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
ArrayRef< StringInit * > getArgNames() const
static Init * ForeachHelper(Init *LHS, Init *MHS, Init *RHS, RecTy *Type, Record *CurRec)
ArrayRef< Init * > getArgs() const
bool getValueAsBitOrUnset(StringRef FieldName, bool &Unset) const
This method looks up the specified field and returns its value as a bit.
ListRecTy * getListTy()
Returns the type representing list<thistype>.
void Profile(FoldingSetNodeID &ID) const
StringRef getName() const
Get the name of the field as a StringRef.
void stopTimer()
Stop timing a phase.
int64_t getValueAsInt(StringRef FieldName) const
This method looks up the specified field and returns its value as an int64_t, throwing an exception i...
void Profile(FoldingSetNodeID &ID) const
unsigned getNumArgs() const
RecTy * getValType() const
constexpr LLVM_NODISCARD size_t size() const
size - Get the string size.
Init * resolve(Init *VarName) override
Return the initializer for the given variable name (should normally be a StringInit),...
Init * convertInitializerBitRange(ArrayRef< unsigned > Bits) const override
This function is used to implement the bit range selection operator.
static BitsRecTy * get(RecordKeeper &RK, unsigned Sz)
ArrayRef< Init * > getValues() const
'?' - Represents an uninitialized value.
static DagInit * get(Init *V, StringInit *VN, ArrayRef< Init * > ArgRange, ArrayRef< StringInit * > NameRange)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
std::string getAsString() const override
Convert this value to a literal form.
static void ProfileFoldOpInit(FoldingSetNodeID &ID, Init *Start, Init *List, Init *A, Init *B, Init *Expr, RecTy *Type)
RecTy * getType() const
Get the type of the field value as a RecTy.
static UnOpInit * get(UnaryOp opc, Init *lhs, RecTy *Type)
static StringRecTy * get(RecordKeeper &RK)
Should compile to something r4 addze r3 instead we get
virtual Init * resolve(Init *VarName)=0
Return the initializer for the given variable name (should normally be a StringInit),...
bool isNonconcreteOK() const
Is this a field where nonconcrete values are okay?
FoldingSet< UnOpInit > TheUnOpInitPool
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
RecordKeeper & getRecords() const
BinaryOp getOpcode() const
LLVM_ATTRIBUTE_RETURNS_NONNULL void * Allocate(size_t Size, Align Alignment)
Allocate space at the specified alignment.
const RecordVal * getValue(const Init *Name) const
Init * getNameInit() const
StringRef getValue() const
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
Init * resolve(Init *VarName) override
Return the initializer for the given variable name (should normally be a StringInit),...
void sort(IteratorTy Start, IteratorTy End)
static StringInit * interleaveIntList(const ListInit *List, const StringInit *Delim)
unsigned getBitNum() const
RecordKeeper & getRecordKeeper() const
Get the record keeper that initialized this Init.
This class represents the internal implementation of the RecordKeeper.
bool typeIsConvertibleTo(const RecTy *RHS) const override
Return true if all values of 'this' type can be converted to the specified type.
Init * getValueInit(StringRef FieldName) const
Return the initializer for a value with the specified name, or throw an exception if the field does n...
static void ProfileVarDefInit(FoldingSetNodeID &ID, Record *Class, ArrayRef< Init * > Args)
std::string getAsString() const override
static void ProfileBitsInit(FoldingSetNodeID &ID, ArrayRef< Init * > Range)
void print(raw_ostream &OS) const
Print this value.
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
void Profile(FoldingSetNodeID &ID) const
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
static VarListElementInit * get(TypedInit *T, unsigned E)
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Init * getCastTo(RecTy *Ty) const override
If this value is convertible to type Ty, return a value whose type is Ty, generating a !...
DenseMap< std::pair< TypedInit *, unsigned >, VarBitInit * > TheVarBitInitPool
virtual bool typeIsConvertibleTo(const RecTy *RHS) const
Return true if all values of 'this' type can be converted to the specified type.
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
virtual std::string getAsString() const =0
RecordVal(Init *N, RecTy *T, FieldKind K)
static void ProfileUnOpInit(FoldingSetNodeID &ID, unsigned Opcode, Init *Op, RecTy *Type)
StringRef getName() const
DenseMap< std::pair< Init *, StringInit * >, FieldInit * > TheFieldInitPool
static RecordRecTy * get(RecordKeeper &RK, ArrayRef< Record * > Classes)
Get the record type with the given non-redundant list of superclasses.
Record * getElementAsRecord(unsigned i) const
void PrintError(const Twine &Msg)
Init * Fold(Record *CurRec) const
Represents a range in source code.
Init * Fold(Record *CurRec, bool IsFinal=false) const
static StringFormat determineFormat(StringFormat Fmt1, StringFormat Fmt2)
bool getValueAsBit(StringRef FieldName) const
This method looks up the specified field and returns its value as a bit, throwing an exception if the...
void appendAssertions(const Record *Rec)
StringMap< StringInit *, BumpPtrAllocator & > StringInitStringPool
RecTyKind
Subclass discriminator (for dyn_cast<> et al.)
Opcode{0} - Represent access to one bit of a variable or field.
void Profile(FoldingSetNodeID &ID) const
bool foundUnresolved() const
std::string to_string(const T &Value)
void PrintWarning(const Twine &Msg)
size_t size() const
size - Get the array size.
StringRef getValueAsString(StringRef FieldName) const
This method looks up the specified field and returns its value as a string, throwing an exception if ...
Init * getNewAnonymousName()
GetNewAnonymousName - Generate a unique anonymous name that can be used as an identifier.
StringInit * getArgName(unsigned Num) const
static bool canFitInBitfield(int64_t Value, unsigned NumBits)
std::string getAsString() const override
Init * getOperand() const
FoldingSet< VarDefInit > TheVarDefInitPool
std::vector< BitsRecTy * > SharedBitsRecTys
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
FoldingSet< CondOpInit > TheCondOpInitPool
StringMap< StringInit *, BumpPtrAllocator & > StringInitCodePool
StringFormat getFormat() const
Resolve all variables from a record except for unset variables.
std::string getAsUnquotedString() const override
Convert this value to a literal form, without adding quotes around a string.
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
static Init * ForeachDagApply(Init *LHS, DagInit *MHSd, Init *RHS, Record *CurRec)
static VarDefInit * get(Record *Class, ArrayRef< Init * > Args)
'{ a, b, c }' - Represents an initializer for a BitsRecTy value.
List[4] - Represent access to one element of a var or field.
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Record * getDef(StringRef Name) const
Get the concrete record with the specified name.
UnaryOp getOpcode() const
void Profile(FoldingSetNodeID &ID) const
This class represents a field in a record, including its name, type, value, and source location.
bool typeIsConvertibleTo(const RecTy *RHS) const override
Return true if all values of 'this' type can be converted to the specified type.
void reserve(size_type N)
bool isSubClassOf(Record *Class) const
std::map< int64_t, IntInit * > TheIntInitPool
classname<targs...> - Represent an uninstantiated anonymous class instantiation.
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
llvm::Optional< StringRef > getValueAsOptionalString(StringRef FieldName) const
This method looks up the specified field and returns its value as a string, throwing an exception if ...
static BitRecTy * get(RecordKeeper &RK)
static IntRecTy * get(RecordKeeper &RK)
bool hasDirectSuperClass(const Record *SuperClass) const
Determine whether this record has the specified direct superclass.
LLVM Value Representation.
Init * convertInitListSlice(ArrayRef< unsigned > Elements) const override
This function is used to implement the list slice selection operator.
Init * Fold(Record *CurRec, bool IsFinal=false) const
Init * getElement(unsigned i) const
static DefInit * get(Record *)
void Profile(FoldingSetNodeID &ID) const
static StringInit * get(RecordKeeper &RK, StringRef, StringFormat Fmt=SF_String)
std::string getAsString() const override
Convert this value to a literal form.
Record * getValueAsDef(StringRef FieldName) const
This method looks up the specified field and returns its value as a Record, throwing an exception if ...
static UnsetInit * get(RecordKeeper &RK)
Get the singleton unset Init.
reference emplace_back(ArgTypes &&... Args)
static StringInit * ConcatStringInits(const StringInit *I0, const StringInit *I1)
static AnonymousNameInit * get(RecordKeeper &RK, unsigned)
This is the common superclass of types that have a specific, explicit type, stored in ValueTy.
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
std::string getAsString() const override
Convert this value to a literal form.