22 #include "llvm/Support/DataTypes.h"
48 const std::string &
str()
const {
return data; }
74 return LHS.
str() == RHS.
str();
98 assert(RHS &&
"NULL pointer");
105 if (
const BitsRecTy *BitsTy = dyn_cast<BitsRecTy>(RHS))
106 return BitsTy->getNumBits() == 1;
111 static std::vector<std::unique_ptr<BitsRecTy>> Shared;
112 if (Sz >= Shared.size())
113 Shared.resize(Sz + 1);
114 std::unique_ptr<BitsRecTy> &Ty = Shared[Sz];
121 return "bits<" +
utostr(Size) +
">";
126 return cast<BitsRecTy>(RHS)->Size == Size;
145 if (
const auto *ListTy = dyn_cast<ListRecTy>(RHS))
187 if (
RecordRecTy *RecTy1 = dyn_cast<RecordRecTy>(T1)) {
196 if (
RecordRecTy *RecTy2 = dyn_cast<RecordRecTy>(T2)) {
213 void Init::anchor() { }
222 if (
auto *BRT = dyn_cast<BitsRecTy>(Ty)) {
225 for (
unsigned i = 0; i != BRT->getNumBits(); ++i)
239 return V ? &True : &False;
243 if (isa<BitRecTy>(Ty))
244 return const_cast<BitInit *
>(
this);
246 if (isa<IntRecTy>(Ty))
249 if (
auto *BRT = dyn_cast<BitsRecTy>(Ty)) {
251 if (BRT->getNumBits() == 1)
262 for (
Init *
I : Range)
268 static std::vector<std::unique_ptr<BitsInit>> TheActualPool;
279 TheActualPool.push_back(std::unique_ptr<BitsInit>(I));
288 if (isa<BitRecTy>(Ty)) {
293 if (
auto *BRT = dyn_cast<BitsRecTy>(Ty)) {
296 if (
getNumBits() != BRT->getNumBits())
return nullptr;
297 return const_cast<BitsInit *
>(
this);
300 if (isa<IntRecTy>(Ty)) {
302 for (
unsigned i = 0, e =
getNumBits(); i != e; ++i)
303 if (
auto *
Bit = dyn_cast<BitInit>(
getBit(i)))
304 Result |=
static_cast<int64_t
>(
Bit->getValue()) << i;
317 for (
unsigned i = 0, e = Bits.size(); i != e; ++i) {
320 NewBits[i] =
getBit(Bits[i]);
326 std::string Result =
"{ ";
327 for (
unsigned i = 0, e =
getNumBits(); i != e; ++i) {
328 if (i) Result +=
", ";
330 Result +=
Bit->getAsString();
334 return Result +
" }";
341 if (RV || !isa<UnsetInit>(After))
350 bool Changed =
false;
353 Init *CachedInit =
nullptr;
354 Init *CachedBitVar =
nullptr;
355 bool CachedBitVarChanged =
false;
357 for (
unsigned i = 0, e =
getNumBits(); i != e; ++i) {
358 Init *CurBit = Bits[i];
363 if (CurBitVar == CachedBitVar) {
364 if (CachedBitVarChanged) {
370 CachedBitVar = CurBitVar;
371 CachedBitVarChanged =
false;
377 CachedBitVarChanged |= B != CurBitVar;
378 Changed |= B != CurBitVar;
379 }
while (B != CurBitVar);
380 CachedInit = CurBitVar;
382 if (CachedBitVarChanged) {
391 return const_cast<BitsInit *
>(
this);
397 std::unique_ptr<IntInit> &
I = ThePool[V];
398 if (!I) I.reset(
new IntInit(V));
410 return (NumBits >=
sizeof(Value) * 8) ||
411 (Value >> NumBits == 0) || (Value >> (NumBits-1) == -1);
415 if (isa<IntRecTy>(Ty))
416 return const_cast<IntInit *
>(
this);
418 if (isa<BitRecTy>(Ty)) {
420 if (Val != 0 && Val != 1)
return nullptr;
424 if (
auto *BRT = dyn_cast<BitsRecTy>(Ty)) {
431 for (
unsigned i = 0; i != BRT->getNumBits(); ++i)
444 for (
unsigned i = 0, e = Bits.size(); i != e; ++i) {
456 std::unique_ptr<StringInit> &
I = ThePool[V];
462 if (isa<StringRecTy>(Ty))
474 for (
Init *
I : Range)
480 static std::vector<std::unique_ptr<ListInit>> TheActualPool;
491 TheActualPool.push_back(std::unique_ptr<ListInit>(I));
496 RecTy *EltTy = cast<ListRecTy>(
getType())->getElementType();
502 if (
auto *LRT = dyn_cast<ListRecTy>(Ty)) {
503 std::vector<Init*> Elements;
508 if (
Init *CI =
I->convertInitializerTo(LRT->getElementType()))
509 Elements.push_back(CI);
522 std::vector<Init*> Vals;
523 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
524 if (Elements[i] >=
size())
532 assert(i < Values.size() &&
"List element index out of range!");
540 std::vector<Init*> Resolved;
541 Resolved.reserve(
size());
542 bool Changed =
false;
550 Changed |= E != CurElt;
551 }
while (E != CurElt);
552 Resolved.push_back(E);
557 return const_cast<ListInit *
>(
this);
561 unsigned Elt)
const {
568 if (IRV || !isa<UnsetInit>(E))
574 std::string Result =
"[";
575 for (
unsigned i = 0, e = Values.size(); i != e; ++i) {
576 if (i) Result +=
", ";
577 Result += Values[i]->getAsString();
583 unsigned Elt)
const {
587 Resolved = OResolved->
Fold(&R,
nullptr);
590 if (Resolved !=
this) {
591 TypedInit *Typed = cast<TypedInit>(Resolved);
602 return const_cast<OpInit*
>(
this);
607 typedef std::pair<std::pair<unsigned, Init *>,
RecTy *> Key;
610 Key TheKey(std::make_pair(std::make_pair(opc, lhs), Type));
612 std::unique_ptr<UnOpInit> &
I = ThePool[TheKey];
613 if (!I) I.reset(
new UnOpInit(opc, lhs, Type));
620 if (isa<StringRecTy>(
getType())) {
621 if (
StringInit *LHSs = dyn_cast<StringInit>(LHS))
624 if (
DefInit *LHSd = dyn_cast<DefInit>(LHS))
627 if (
IntInit *LHSi = dyn_cast<IntInit>(LHS))
630 if (
StringInit *LHSs = dyn_cast<StringInit>(LHS)) {
631 std::string
Name = LHSs->getValue();
636 if (RV->getType() !=
getType())
646 assert(RV &&
"Template arg doesn't exist??");
661 assert(RV &&
"Template arg doesn't exist??");
669 assert(CurRec &&
"NULL pointer");
674 "Undefined reference:'" + Name +
"'\n");
680 if (
ListInit *LHSl = dyn_cast<ListInit>(LHS)) {
681 assert(!LHSl->empty() &&
"Empty list in head");
682 return LHSl->getElement(0);
687 if (
ListInit *LHSl = dyn_cast<ListInit>(LHS)) {
688 assert(!LHSl->empty() &&
"Empty list in tail");
691 return ListInit::get(LHSl->getValues().slice(1), LHSl->getType());
696 if (
ListInit *LHSl = dyn_cast<ListInit>(LHS))
698 if (
StringInit *LHSs = dyn_cast<StringInit>(LHS))
704 return const_cast<UnOpInit *
>(
this);
712 return Fold(&R,
nullptr);
719 case HEAD: Result =
"!head";
break;
720 case TAIL: Result =
"!tail";
break;
721 case EMPTY: Result =
"!empty";
break;
729 std::pair<std::pair<unsigned, Init *>,
Init *>,
735 Key TheKey(std::make_pair(std::make_pair(std::make_pair(opc, lhs), rhs),
738 std::unique_ptr<BinOpInit> &
I = ThePool[TheKey];
739 if (!I) I.reset(
new BinOpInit(opc, lhs, rhs, Type));
751 if (!LOp || !ROp || LOp->
getDef() != ROp->getDef())
753 std::vector<Init*> Args;
754 std::vector<std::string> ArgNames;
755 for (
unsigned i = 0, e = LHSs->
getNumArgs(); i != e; ++i) {
756 Args.push_back(LHSs->
getArg(i));
759 for (
unsigned i = 0, e = RHSs->getNumArgs(); i != e; ++i) {
760 Args.push_back(RHSs->getArg(i));
761 ArgNames.push_back(RHSs->getArgName(i));
771 std::vector<Init *> Args;
772 Args.insert(Args.end(), LHSs->
begin(), LHSs->
end());
773 Args.insert(Args.end(), RHSs->begin(), RHSs->end());
775 Args, cast<ListRecTy>(LHSs->
getType())->getElementType());
802 return IntInit::get(LHSs->getValue() == RHSs->getValue());
816 int64_t LHSv = LHSi->
getValue(), RHSv = RHSi->getValue();
820 case ADD: Result = LHSv + RHSv;
break;
821 case AND: Result = LHSv & RHSv;
break;
822 case SHL: Result = LHSv << RHSv;
break;
823 case SRA: Result = LHSv >> RHSv;
break;
824 case SRL: Result = (uint64_t)LHSv >> (uint64_t)RHSv;
break;
838 if (LHS != lhs || RHS != rhs)
840 return Fold(&R,
nullptr);
846 case CONCAT: Result =
"!con";
break;
847 case ADD: Result =
"!add";
break;
848 case AND: Result =
"!and";
break;
849 case SHL: Result =
"!shl";
break;
850 case SRA: Result =
"!sra";
break;
851 case SRL: Result =
"!srl";
break;
852 case EQ: Result =
"!eq";
break;
853 case LISTCONCAT: Result =
"!listconcat";
break;
854 case STRCONCAT: Result =
"!strconcat";
break;
863 std::pair<std::pair<unsigned, RecTy *>,
Init *>,
871 Key TheKey(std::make_pair(std::make_pair(std::make_pair(std::make_pair(opc,
877 std::unique_ptr<TernOpInit> &
I = ThePool[TheKey];
878 if (!I) I.reset(
new TernOpInit(opc, lhs, mhs, rhs, Type));
889 if (
auto *TArg = dyn_cast<TypedInit>(Arg))
890 if (isa<DagRecTy>(TArg->getType()))
891 return ForeachHelper(LHS, Arg, RHSo, Type, CurRec, CurMultiClass);
893 std::vector<Init *> NewOperands;
895 if (
auto *RHSoo = dyn_cast<OpInit>(RHSo->
getOperand(i))) {
897 Type, CurRec, CurMultiClass))
898 NewOperands.push_back(Result);
900 NewOperands.push_back(Arg);
902 NewOperands.push_back(Arg);
910 Init *NewVal = NewOp->
Fold(CurRec, CurMultiClass);
911 return (NewVal != NewOp) ? NewVal :
nullptr;
928 if (MHSd && isa<DagRecTy>(Type)) {
929 Init *Val = MHSd->getOperator();
931 Type, CurRec, CurMultiClass))
934 std::vector<std::pair<Init *, std::string> > args;
935 for (
unsigned int i = 0; i < MHSd->getNumArgs(); ++i) {
936 Init *Arg = MHSd->getArg(i);
937 std::string ArgName = MHSd->getArgName(i);
941 CurRec, CurMultiClass))
945 args.push_back(std::make_pair(Arg, ArgName));
952 if (MHSl && isa<ListRecTy>(Type)) {
953 std::vector<Init *> NewOperands;
954 std::vector<Init *> NewList(MHSl->
begin(), MHSl->
end());
956 for (
Init *&Item : NewList) {
961 NewOperands.push_back(Item);
968 Init *NewItem = NewOp->
Fold(CurRec, CurMultiClass);
969 if (NewItem != NewOp)
992 if (LHSd && MHSd && RHSd) {
993 Record *Val = RHSd->getDef();
995 Val = MHSd->getDef();
998 if (LHSv && MHSv && RHSv) {
999 std::string Val = RHSv->getName();
1000 if (LHSv->getAsString() == RHSv->getAsString())
1001 Val = MHSv->getName();
1004 if (LHSs && MHSs && RHSs) {
1005 std::string Val = RHSs->getValue();
1007 std::string::size_type found;
1008 std::string::size_type idx = 0;
1010 found = Val.find(LHSs->getValue(), idx);
1011 if (found == std::string::npos)
1013 Val.replace(found, LHSs->getValue().size(), MHSs->getValue());
1014 idx = found + MHSs->getValue().size();
1024 CurRec, CurMultiClass))
1032 LHSi = dyn_cast<IntInit>(
I);
1049 if (Opc ==
IF && lhs != LHS) {
1052 Value = dyn_cast<IntInit>(
I);
1058 RHS,
getType()))->Fold(&R,
nullptr);
1062 rhs,
getType()))->Fold(&R,
nullptr);
1069 if (LHS != lhs || MHS != mhs || RHS != rhs)
1071 getType()))->Fold(&R,
nullptr);
1072 return Fold(&R,
nullptr);
1078 case SUBST: Result =
"!subst";
break;
1079 case FOREACH: Result =
"!foreach";
break;
1080 case IF: Result =
"!if";
break;
1088 if (
RecordVal *
Field = RecordType->getRecord()->getValue(FieldName))
1089 return Field->getType();
1095 if (isa<IntRecTy>(Ty)) {
1096 if (
getType()->typeIsConvertibleTo(Ty))
1101 if (isa<StringRecTy>(Ty)) {
1102 if (isa<StringRecTy>(
getType()))
1103 return const_cast<TypedInit *>(
this);
1107 if (isa<BitRecTy>(Ty)) {
1110 return const_cast<TypedInit *>(
this);
1111 if (
auto *BitsTy = dyn_cast<BitsRecTy>(
getType())) {
1113 if (BitsTy->getNumBits() == 1)
1114 return const_cast<TypedInit *>(
this);
1119 if (
const auto *TOI = dyn_cast<TernOpInit>(
this)) {
1120 if (TOI->getOpcode() == TernOpInit::TernaryOp::IF &&
1123 return const_cast<TypedInit *>(
this);
1129 if (
auto *BRT = dyn_cast<BitsRecTy>(Ty)) {
1130 if (BRT->getNumBits() == 1 && isa<BitRecTy>(
getType()))
1133 if (
getType()->typeIsConvertibleTo(BRT)) {
1136 for (
unsigned i = 0; i != BRT->getNumBits(); ++i)
1144 if (
auto *DLRT = dyn_cast<ListRecTy>(Ty)) {
1145 if (
auto *SLRT = dyn_cast<ListRecTy>(
getType()))
1146 if (SLRT->getElementType()->typeIsConvertibleTo(DLRT->getElementType()))
1151 if (
auto *DRT = dyn_cast<DagRecTy>(Ty)) {
1153 return const_cast<TypedInit *>(
this);
1157 if (
auto *SRRT = dyn_cast<RecordRecTy>(Ty)) {
1160 if (DRRT->getRecord()->isSubClassOf(SRRT->getRecord()) ||
1161 DRRT->getRecord() == SRRT->getRecord())
1162 return const_cast<TypedInit *>(
this);
1172 if (!T)
return nullptr;
1176 for (
unsigned i = 0, e = Bits.size(); i != e; ++i) {
1177 if (Bits[i] >= NumBits)
1188 if (!T)
return nullptr;
1190 if (Elements.size() == 1)
1193 std::vector<Init*> ListInits;
1194 ListInits.reserve(Elements.size());
1195 for (
unsigned i = 0, e = Elements.size(); i != e; ++i)
1208 typedef std::pair<RecTy *, Init *> Key;
1211 Key TheKey(std::make_pair(T, VN));
1213 std::unique_ptr<VarInit> &
I = ThePool[TheKey];
1214 if (!I) I.reset(
new VarInit(VN, T));
1225 return const_cast<VarInit*
>(
this);
1231 unsigned Elt)
const {
1236 assert(RV &&
"Reference to a non-existent variable?");
1241 if (Elt >= LI->
size())
1247 if (IRV || !isa<UnsetInit>(E))
1256 return RV->getType();
1261 const std::string &FieldName)
const {
1262 if (isa<RecordRecTy>(
getType()))
1264 if (RV != Val && (RV || isa<UnsetInit>(Val->getValue())))
1266 Init *TheInit = Val->getValue();
1267 assert(TheInit !=
this &&
"Infinite loop detected!");
1282 if (RV == Val || (!RV && !isa<UnsetInit>(Val->getValue())))
1283 return Val->getValue();
1284 return const_cast<VarInit *
>(
this);
1288 typedef std::pair<TypedInit *, unsigned> Key;
1291 Key TheKey(std::make_pair(T, B));
1293 std::unique_ptr<VarBitInit> &
I = ThePool[TheKey];
1299 if (isa<BitRecTy>(Ty))
1319 typedef std::pair<TypedInit *, unsigned> Key;
1322 Key TheKey(std::make_pair(T, E));
1324 std::unique_ptr<VarListElementInit> &
I = ThePool[TheKey];
1349 unsigned Elt)
const {
1351 if (
TypedInit *TInit = dyn_cast<TypedInit>(Result)) {
1352 if (
Init *Result2 = TInit->resolveListElementReference(R, RV, Elt))
1367 if (
auto *RRT = dyn_cast<RecordRecTy>(Ty))
1368 if (
getDef()->isSubClassOf(RRT->getRecord()))
1369 return const_cast<DefInit *
>(
this);
1375 return RV->getType();
1380 const std::string &FieldName)
const {
1390 typedef std::pair<Init *, TableGenStringKey> Key;
1393 Key TheKey(std::make_pair(R, FN));
1395 std::unique_ptr<FieldInit> &
I = ThePool[TheKey];
1407 unsigned Elt)
const {
1409 if (
ListInit *LI = dyn_cast<ListInit>(ListVal)) {
1410 if (Elt >= LI->size())
return nullptr;
1411 Init *E = LI->getElement(Elt);
1416 if (RV || !isa<UnsetInit>(E))
1443 while (Arg != ArgRange.
end()) {
1444 assert(Name != NameRange.
end() &&
"Arg name underflow!");
1448 assert(Name == NameRange.
end() &&
"Arg name overflow!");
1456 static std::vector<std::unique_ptr<DagInit>> TheActualPool;
1467 TheActualPool.push_back(std::unique_ptr<DagInit>(I));
1473 const std::vector<std::pair<Init*, std::string> > &args) {
1474 std::vector<Init *> Args;
1475 std::vector<std::string> Names;
1477 for (
const auto &Arg : args) {
1478 Args.push_back(Arg.first);
1479 Names.push_back(Arg.second);
1490 if (isa<DagRecTy>(Ty))
1491 return const_cast<DagInit *
>(
this);
1497 std::vector<Init*> NewArgs;
1498 for (
unsigned i = 0, e = Args.size(); i != e; ++i)
1499 NewArgs.push_back(Args[i]->resolveReferences(R, RV));
1503 if (Args != NewArgs || Op != Val)
1506 return const_cast<DagInit *
>(
this);
1512 if (!ValName.empty())
1513 Result +=
":" + ValName;
1514 if (!Args.empty()) {
1515 Result +=
" " + Args[0]->getAsString();
1516 if (!ArgNames[0].empty()) Result +=
":$" + ArgNames[0];
1517 for (
unsigned i = 1, e = Args.size(); i != e; ++i) {
1518 Result +=
", " + Args[i]->getAsString();
1519 if (!ArgNames[i].empty()) Result +=
":$" + ArgNames[i];
1522 return Result +
")";
1531 : NameAndPrefix(N, P), Ty(T) {
1533 assert(
Value &&
"Cannot create unset value for current type!");
1537 : NameAndPrefix(
StringInit::get(N), P), Ty(T) {
1539 assert(
Value &&
"Cannot create unset value for current type!");
1555 if (PrintSem) OS <<
";\n";
1558 unsigned Record::LastID = 0;
1560 void Record::init() {
1569 void Record::checkName() {
1571 const TypedInit *TypedName = cast<const TypedInit>(Name);
1572 if (!isa<StringRecTy>(TypedName->
getType()))
1579 return TheInit.get();
1583 return cast<StringInit>(Name)->
getValue();
1610 for (
unsigned i = 0, e = Values.size(); i != e; ++i) {
1611 if (RV == &Values[i])
1614 if (Values[i].setValue(V->resolveReferences(*
this, RV)))
1617 "' after resolving references" +
1625 if (NewName != OldName) {
1637 if (!TArgs.empty()) {
1639 bool NeedComma =
false;
1640 for (
const Init *
TA : TArgs) {
1641 if (NeedComma) OS <<
", ";
1644 assert(RV &&
"Template argument record not found??");
1645 RV->
print(OS,
false);
1654 for (
const Record *Super : SC)
1655 OS <<
" " << Super->getNameInitAsString();
1676 "' does not have a field named `" + FieldName +
"'!\n");
1689 "' does not have a field named `" + FieldName +
"'!\n");
1692 return SI->getValue();
1694 FieldName +
"' does not have a string initializer!");
1705 "' does not have a field named `" + FieldName +
"'!\n");
1710 FieldName +
"' does not have a BitsInit initializer!");
1721 "' does not have a field named `" + FieldName +
"'!\n");
1726 FieldName +
"' does not have a list initializer!");
1733 std::vector<Record*>
1736 std::vector<Record*> Defs;
1739 Defs.push_back(
DI->getDef());
1742 FieldName +
"' list is not entirely DefInit!");
1755 "' does not have a field named `" + FieldName +
"'!\n");
1758 return II->getValue();
1760 FieldName +
"' does not have an int initializer!");
1767 std::vector<int64_t>
1770 std::vector<int64_t> Ints;
1772 if (
IntInit *II = dyn_cast<IntInit>(
I))
1773 Ints.push_back(II->getValue());
1776 FieldName +
"' does not have a list of ints initializer!");
1785 std::vector<std::string>
1788 std::vector<std::string> Strings;
1791 Strings.push_back(
SI->getValue());
1794 FieldName +
"' does not have a list of strings initializer!");
1807 "' does not have a field named `" + FieldName +
"'!\n");
1810 return DI->getDef();
1812 FieldName +
"' does not have a def initializer!");
1823 "' does not have a field named `" + FieldName +
"'!\n");
1826 return BI->getValue();
1828 FieldName +
"' does not have a bit initializer!");
1835 "' does not have a field named `" + FieldName.
str() +
"'!\n");
1837 if (isa<UnsetInit>(R->
getValue())) {
1843 return BI->getValue();
1845 FieldName +
"' does not have a bit initializer!");
1856 "' does not have a field named `" + FieldName +
"'!\n");
1861 FieldName +
"' does not have a dag initializer!");
1866 errs() <<
"Record:\n";
1869 errs() <<
"Defs:\n";
1878 OS <<
"------------- Classes -----------------\n";
1880 OS <<
"class " << *C.second;
1882 OS <<
"------------- Defs -----------------\n";
1884 OS <<
"def " << *D.second;
1892 std::vector<Record*>
1896 PrintFatalError(
"ERROR: Couldn't find the `" + ClassName +
"' class!\n");
1898 std::vector<Record*> Defs;
1899 for (
const auto &D :
getDefs())
1900 if (D.second->isSubClassOf(Class))
1901 Defs.push_back(D.second.get());
1909 Init *
Name,
const std::string &Scoper) {
1917 Type)->Fold(&CurRec, CurMultiClass),
1921 if (CurMultiClass && Scoper !=
"::") {
1927 Type)->Fold(&CurRec, CurMultiClass),
1928 NewName->
Fold(&CurRec, CurMultiClass),
1932 return NewName->
Fold(&CurRec, CurMultiClass);
1938 const std::string &
Name,
1939 const std::string &Scoper) {
Init * resolveReferences(Record &R, const RecordVal *RV) const override
resolveReferences - This method is used by classes that refer to other variables which may not be def...
static BinOpInit * get(BinaryOp opc, Init *lhs, Init *rhs, RecTy *Type)
void AddPointer(const void *Ptr)
Add* - Add various data types to Bit data.
Init * convertInitializerTo(RecTy *Ty) const override
convertInitializerTo - This virtual function converts to the appropriate Init based on the passed in ...
void print(raw_ostream &OS) const
Init * resolveReferences(Record &R, const RecordVal *RV) const override
resolveReferences - This method is used by classes that refer to other variables which may not be def...
Init * resolveReferences(Record &R, const RecordVal *RV) const override
resolveReferences - This method is used by classes that refer to other variables which may not be def...
RecTyKind
Subclass discriminator (for dyn_cast<> et al.)
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
virtual bool isComplete() const
isComplete - This virtual method should be overridden by values that may not be completely specified ...
RecTy * getFieldType(const std::string &FieldName) const override
getFieldType - This method is used to implement the FieldInit class.
const std::string & getValue() const
void Profile(FoldingSetNodeID &ID) const
unsigned getNumBits() const
unsigned getNumArgs() const
bool getValueAsBit(StringRef FieldName) const
getValueAsBit - This method looks up the specified field and returns its value as a bit...
const std::string & getArgName(unsigned Num) const
FieldInit - X.Y - Represent a reference to a subfield of a variable.
friend hash_code hash_value(const TableGenStringKey &Value)
Init * getFieldInit(Record &R, const RecordVal *RV, const std::string &FieldName) const override
getFieldInit - This method complements getFieldType to return the initializer for the specified field...
ListInit - [AL, AH, CL] - Represent a list of defs.
IntInit - 7 - Represent an initialization by a literal integer value.
ListRecTy - 'list<Ty>' - Represent a list of values, all of which must be of the specified type...
BinOpInit - !op (X, Y) - Combine two inits.
Init * getBit(unsigned Bit) const override
getBit - This method is used to return the initializer for the specified bit.
Record * getElementAsRecord(unsigned i) const
virtual bool typeIsConvertibleTo(const RecTy *RHS) const
typeIsConvertibleTo - Return true if all values of 'this' type can be converted to the specified type...
Init * resolveReferences(Record &R, const RecordVal *RV) const override
resolveReferences - This method is used by classes that refer to other variables which may not be def...
Init * convertInitializerTo(RecTy *Ty) const override
convertInitializerTo - This virtual function converts to the appropriate Init based on the passed in ...
DefInit - AL - Represent a reference to a 'def' in the description.
std::string getNameInitAsString() const
static UnOpInit * get(UnaryOp opc, Init *lhs, RecTy *Type)
Init * resolveListElementReference(Record &R, const RecordVal *RV, unsigned Elt) const override
resolveListElementReference - This method is used to implement VarListElementInit::resolveReferences...
Init * getValueInit(StringRef FieldName) const
getValueInit - Return the initializer for a value with the specified name, or throw an exception if t...
const std::string & str() const
Init * resolveListElementReference(Record &R, const RecordVal *RV, unsigned Elt) const override
resolveListElementReference - This method is used to implement VarListElementInit::resolveReferences...
RecTy * getFieldType(const std::string &FieldName) const override
getFieldType - This method is used to implement the FieldInit class.
Init * resolveReferences(Record &R, const RecordVal *RV) const override
resolveReferences - This method is used by classes that refer to other variables which may not be def...
std::string getAsString() const override
getAsString - Convert this value to a string form.
Init * Fold(Record *CurRec, MultiClass *CurMultiClass) const override
virtual Init * getFieldInit(Record &R, const RecordVal *RV, const std::string &FieldName) const
getFieldInit - This method complements getFieldType to return the initializer for the specified field...
std::string str() const
str - Get the contents as an std::string.
void Profile(FoldingSetNodeID &ID) const
BinaryOp getOpcode() const
Record * getValueAsDef(StringRef FieldName) const
getValueAsDef - This method looks up the specified field and returns its value as a Record...
Init * getElement(unsigned i) const
void InsertNode(Node *N, void *InsertPos)
InsertNode - Insert the specified node into the folding set, knowing that it is not already in the fo...
FunctionType * getType(LLVMContext &Context, ID id, ArrayRef< Type * > Tys=None)
Return the function type for an intrinsic.
Init * convertInitListSlice(const std::vector< unsigned > &Elements) const override
convertInitListSlice - This method is used to implement the list slice selection operator.
static TableGenStringKey getEmptyKey()
std::string getValueAsString(StringRef FieldName) const
getValueAsString - This method looks up the specified field and returns its value as a string...
Init * getOperator() const
BitsInit - { a, b, c } - Represents an initializer for a BitsRecTy value.
std::string getAsString() const override
virtual std::string getAsUnquotedString() const
getAsUnquotedString - Convert this value to a string form, without adding quote markers.
ArrayRef< Init * > getTemplateArgs() const
void print(raw_ostream &OS) const
print - Print out this value.
const std::string & getName() const
static IntInit * get(int64_t V)
UnsetInit - ? - Represents an uninitialized value.
BitInit - true/false - Represent a concrete initializer for a bit.
static BitsRecTy * get(unsigned Sz)
virtual Init * resolveListElementReference(Record &R, const RecordVal *RV, unsigned Elt) const =0
resolveListElementReference - This method is used to implement VarListElementInit::resolveReferences...
TypedInit - This is the common super-class of types that have a specific, explicit, type.
static void ProfileBitsInit(FoldingSetNodeID &ID, ArrayRef< Init * > Range)
bool typeIsConvertibleTo(const RecTy *RHS) const override
typeIsConvertibleTo - Return true if all values of 'this' type can be converted to the specified type...
Init * getBit(unsigned Bit) const override
getBit - This method is used to return the initializer for the specified bit.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static StringRecTy * get()
std::string getAsString() const override
std::string getAsString() const override
VarListElementInit - List[4] - Represent access to one element of a var or field. ...
RecordRecTy - '[classname]' - Represent an instance of a class, such as: (R32 X = EAX)...
Init * convertInitializerTo(RecTy *Ty) const override
convertInitializerTo - This virtual function converts to the appropriate Init based on the passed in ...
std::string getAsString() const override
getAsString - Convert this value to a string form.
void AddInteger(signed I)
Record * getClass(const std::string &Name) const
Init * resolveReferences(Record &R, const RecordVal *RV) const override
resolveReferences - This method is used by classes that refer to other variables which may not be def...
static Init * ForeachHelper(Init *LHS, Init *MHS, Init *RHS, RecTy *Type, Record *CurRec, MultiClass *CurMultiClass)
std::string getAsString() const override
getAsString - Convert this value to a string form.
virtual unsigned getNumOperands() const =0
void print(raw_ostream &OS, bool PrintSem=true) const
BitsInit * getValueAsBitsInit(StringRef FieldName) const
getValueAsBitsInit - This method looks up the specified field and returns its value as a BitsInit...
const_iterator begin() const
BitsRecTy - 'bits<n>' - Represent a fixed number of bits.
ListInit * getValueAsListInit(StringRef FieldName) const
getValueAsListInit - This method looks up the specified field and returns its value as a ListInit...
virtual OpInit * clone(std::vector< Init * > &Operands) const =0
Init * resolveReferences(Record &R, const RecordVal *RV) const override
resolveReferences - This method is used by classes that refer to other variables which may not be def...
const std::string getNameInitAsString() const
Init * getArg(unsigned Num) const
void Profile(FoldingSetNodeID &ID) const
std::string getAsString() const override
getAsString - Convert this value to a string form.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
static std::string utostr(uint64_t X, bool isNeg=false)
hash_code hash_value(const APFloat &Arg)
See friend declarations above.
virtual unsigned getBitNum() const
getBitNum - This method is used to retrieve the bit number of a bit reference.
Init * convertInitializerBitRange(const std::vector< unsigned > &Bits) const override
convertInitializerBitRange - This method is used to implement the bitrange selection operator...
const std::string & getName() const
Init * Fold(Record *CurRec, MultiClass *CurMultiClass) const override
virtual Init * getBit(unsigned Bit) const =0
getBit - This method is used to return the initializer for the specified bit.
DagInit * getValueAsDag(StringRef FieldName) const
getValueAsDag - This method looks up the specified field and returns its value as an Dag...
Init * resolveListElementReference(Record &R, const RecordVal *RV, unsigned Elt) const override
resolveListElementReference - This method is used to implement VarListElementInit::resolveReferences...
virtual Init * getOperand(unsigned i) const =0
size_t size() const
size - Get the array size.
std::vector< std::string > getValueAsListOfStrings(StringRef FieldName) const
getValueAsListOfStrings - This method looks up the specified field and returns its value as a vector ...
static BitsInit * get(ArrayRef< Init * > Range)
void resolveReferencesTo(const RecordVal *RV)
resolveReferencesTo - If anything in this record refers to RV, replace the reference to RV with the R...
virtual Init * convertInitializerTo(RecTy *Ty) const =0
convertInitializerTo - This virtual function converts to the appropriate Init based on the passed in ...
Init * convertInitializerTo(RecTy *Ty) const override
convertInitializerTo - This virtual function converts to the appropriate Init based on the passed in ...
static unsigned getHashValue(const TableGenStringKey &Val)
bool typeIsConvertibleTo(const RecTy *RHS) const override
typeIsConvertibleTo - 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.
OpInit - Base class for operators.
Init * convertInitializerTo(RecTy *Ty) const override
convertInitializerTo - This virtual function converts to the appropriate Init based on the passed in ...
static VarInit * get(const std::string &VN, RecTy *T)
bool typeIsConvertibleTo(const RecTy *RHS) const override
typeIsConvertibleTo - Return true if all values of 'this' type can be converted to the specified type...
std::vector< Record * > getAllDerivedDefinitions(const std::string &ClassName) const
getAllDerivedDefinitions - This method returns all concrete definitions that derive from the specifie...
The instances of the Type class are immutable: once they are created, they are never changed...
Init * getFieldInit(Record &R, const RecordVal *RV, const std::string &FieldName) const override
getFieldInit - This method complements getFieldType to return the initializer for the specified field...
Init * resolveListElementReference(Record &R, const RecordVal *RV, unsigned Elt) const override
resolveListElementReference - This method is used to implement VarListElementInit::resolveReferences...
StringInit - "foo" - Represent an initialization by a string value.
RecordVector DefPrototypes
UnOpInit - !op (X) - Transform an init.
TypedInit * getVariable() const
Init * convertInitializerTo(RecTy *Ty) const override
convertInitializerTo - This virtual function converts to the appropriate Init based on the passed in ...
T * FindNodeOrInsertPos(const FoldingSetNodeID &ID, void *&InsertPos)
FindNodeOrInsertPos - Look up the node specified by ID.
const RecordVal * getValue(const Init *Name) const
for(unsigned i=0, e=MI->getNumOperands();i!=e;++i)
std::vector< int64_t > getValueAsListOfInts(StringRef FieldName) const
getValueAsListOfInts - This method looks up the specified field and returns its value as a vector of ...
static TableGenStringKey getTombstoneKey()
TableGenStringKey - This is a wrapper for std::string suitable for using as a key to a DenseMap...
StringRecTy - 'string' - Represent an string value.
RecTyKind getRecTyKind() const
static BitInit * get(bool V)
TableGenStringKey(const std::string &str)
static FieldInit * get(Init *R, const std::string &FN)
static bool canFitInBitfield(int64_t Value, unsigned NumBits)
canFitInBitfield - Return true if the number of bits is large enough to hold the integer value...
bool empty() const
empty - Check if the array is empty.
std::string getAsString() const override
getAsString - Convert this value to a string form.
ArrayRef< Init * > getValues() const
DefInit * getDefInit()
get the corresponding DefInit.
static std::string itostr(int64_t X)
std::vector< Record * > getValueAsListOfDefs(StringRef FieldName) const
getValueAsListOfDefs - This method looks up the specified field and returns its value as a vector of ...
FoldingSet - This template class is used to instantiate a specialized implementation of the folding s...
std::string getAsString() const override
getAsString - Convert this value to a string form.
virtual Init * resolveReferences(Record &R, const RecordVal *RV) const
resolveReferences - This method is used by classes that refer to other variables which may not be def...
Init * QualifyName(Record &CurRec, MultiClass *CurMultiClass, Init *Name, const std::string &Scoper)
QualifyName - Return an Init with a qualifier prefix referring to CurRec's name.
const Init * getNameInit() const
int64_t getValueAsInt(StringRef FieldName) const
getValueAsInt - This method looks up the specified field and returns its value as an int64_t...
const RecordMap & getClasses() const
Init * convertInitListSlice(const std::vector< unsigned > &Elements) const override
convertInitListSlice - This method is used to implement the list slice selection operator.
Init * convertInitializerTo(RecTy *Ty) const override
convertInitializerTo - This virtual function converts to the appropriate Init based on the passed in ...
virtual Init * Fold(Record *CurRec, MultiClass *CurMultiClass) const =0
static Init * EvaluateOperation(OpInit *RHSo, Init *LHS, Init *Arg, RecTy *Type, Record *CurRec, MultiClass *CurMultiClass)
Init * convertInitializerBitRange(const std::vector< unsigned > &Bits) const override
convertInitializerBitRange - This method is used to implement the bitrange selection operator...
std::string getAsString() const override
RecTy * getFieldType(const std::string &FieldName) const override
getFieldType - This method is used to implement the FieldInit class.
ArrayRef< SMLoc > getLoc() const
static bool isEqual(const TableGenStringKey &LHS, const TableGenStringKey &RHS)
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)
static RecordRecTy * get(Record *R)
std::string getAsString() const override
getAsString - Convert this value to a string form.
CHAIN = SC CHAIN, Imm128 - System call.
Init * convertInitializerTo(RecTy *Ty) const override
convertInitializerTo - This virtual function converts to the appropriate Init based on the passed in ...
Init * getNameInit() const
const_iterator end() const
static DefInit * get(Record *)
Init * convertInitializerTo(RecTy *Ty) const override
convertInitializerTo - This virtual function converts to the appropriate Init based on the passed in ...
TableGenStringKey(const char *str)
Init * resolveReferences(Record &R, const RecordVal *RV) const override
resolveReferences - This method is used by classes that refer to other variables which may not be def...
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
unsigned getElementNum() const
ArrayRef< Record * > getSuperClasses() const
static void ProfileListInit(FoldingSetNodeID &ID, ArrayRef< Init * > Range, RecTy *EltTy)
LLVM_ATTRIBUTE_NORETURN void PrintFatalError(const Twine &Msg)
bool isTemplateArg(Init *Name) const
LLVM_ATTRIBUTE_UNUSED_RESULT std::enable_if< !is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
An opaque object representing a hash code.
const RecordMap & getDefs() const
Init * getBit(unsigned Bit) const override
getBit - This method is used to return the initializer for the specified bit.
IntRecTy - 'int' - Represent an integer value of no particular size.
static Init * fixBitInit(const RecordVal *RV, Init *Before, Init *After)
ArrayRef< RecordVal > getValues() const
Init * resolveListElementReference(Record &R, const RecordVal *RV, unsigned Elt) const override
resolveListElementReference - This method is used to implement VarListElementInit::resolveReferences...
Init * getBit(unsigned Bit) const override
getBit - This method is used to return the initializer for the specified bit.
RecordKeeper & getRecords() const
static DagInit * get(Init *V, const std::string &VN, ArrayRef< Init * > ArgRange, ArrayRef< std::string > NameRange)
static MachineInstr * getDef(unsigned Reg, const MachineRegisterInfo *MRI)
std::string getAsString() const override
getAsString - Convert this value to a string form.
bool typeIsConvertibleTo(const RecTy *RHS) const override
typeIsConvertibleTo - Return true if all values of 'this' type can be converted to the specified type...
unsigned getNumBits() const
virtual Init * getBitVar() const
getBitVar - This method is used to retrieve the initializer for bit reference.
bool isSubClassOf(const Record *R) const
bool typeIsConvertibleTo(const RecTy *RHS) const override
typeIsConvertibleTo - Return true if all values of 'this' type can be converted to the specified type...
void addValue(const RecordVal &RV)
static TernOpInit * get(TernaryOp opc, Init *lhs, Init *mhs, Init *rhs, RecTy *Type)
static VarListElementInit * get(TypedInit *T, unsigned E)
RecTy * resolveTypes(RecTy *T1, RecTy *T2)
resolveTypes - Find a common type that T1 and T2 convert to.
VarBitInit - Opcode{0} - Represent access to one bit of a variable or field.
VarInit - 'Opcode' - Represent a reference to an entire variable object.
static ListInit * get(ArrayRef< Init * > Range, RecTy *EltTy)
std::string getAsString() const override
getAsString - Convert this value to a string form.
std::string getAsString() const override
void AddString(StringRef String)
UnaryOp getOpcode() const
BitRecTy - 'bit' - Represent a single bit.
TernOpInit - !op (X, Y, Z) - Combine two inits.
Init * Fold(Record *CurRec, MultiClass *CurMultiClass) const override
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
Record * getRecord() const
bool getValueAsBitOrUnset(StringRef FieldName, bool &Unset) const
getValueAsBitOrUnset - This method looks up the specified field and returns its value as a bit...
Init * resolveReferences(Record &R, const RecordVal *RV) const override
resolveReferences - This method is used by classes that refer to other variables which may not be def...
DagRecTy - 'dag' - Represent a dag fragment.
Init * resolveReferences(Record &R, const RecordVal *RV) const override
resolveReferences - This method is used by classes that refer to other variables which may not be def...
Init * getBit(unsigned Bit) const override
getBit - This method is used to return the initializer for the specified bit.
const std::string & getName() const
Init * getNameInit() const
LLVM Value Representation.
DagInit - (v a, b) - Represent a DAG tree value.
virtual std::string getAsString() const =0
getAsString - Convert this value to a string form.
static void ProfileDagInit(FoldingSetNodeID &ID, Init *V, const std::string &VN, ArrayRef< Init * > ArgRange, ArrayRef< std::string > NameRange)
This class implements an extremely fast bulk output stream that can only output to a stream...
TernaryOp getOpcode() const
void dump() const
dump - Debugging method that may be called through a debugger, just invokes print on stderr...
StringRef - Represent a constant reference to a string, i.e.
unsigned getBitNum() const override
getBitNum - This method is used to retrieve the bit number of a bit reference.
virtual std::string getAsString() const =0
Init * convertInitializerTo(RecTy *Ty) const override
convertInitializerTo - This virtual function converts to the appropriate Init based on the passed in ...
ListRecTy * getListTy()
getListTy - Returns the type representing list<this>.
Init * convertInitializerBitRange(const std::vector< unsigned > &Bits) const override
convertInitializerBitRange - This method is used to implement the bitrange selection operator...
std::string getAsString() const override
getAsString - Convert this value to a string form.
RecordVal(Init *N, RecTy *T, bool P)