diff options
author | River Riddle <riddleriver@gmail.com> | 2022-05-06 18:05:54 -0700 |
---|---|---|
committer | River Riddle <riddleriver@gmail.com> | 2022-05-11 11:55:33 -0700 |
commit | 2ac3cd20cacdf37135eeb64ad2b7baefb9769e99 (patch) | |
tree | 08cae2495aeaabec60a39287d12198e6dbff8a0b /llvm/lib/TableGen/TGParser.cpp | |
parent | 3ca6328637b3f42096c652e4df53282649956bdb (diff) | |
download | llvm-2ac3cd20cacdf37135eeb64ad2b7baefb9769e99.zip llvm-2ac3cd20cacdf37135eeb64ad2b7baefb9769e99.tar.gz llvm-2ac3cd20cacdf37135eeb64ad2b7baefb9769e99.tar.bz2 |
[TableGen] Remove the use of global Record state
This commits removes TableGens reliance on managed static global record state
by moving the RecordContext into the RecordKeeper. The RecordKeeper is now
treated similarly to a (LLVM|MLIR|etc)Context object and is passed to static
construction functions. This is an important step forward in removing TableGens
reliance on global state, and in a followup will allow for users that parse tablegen
to parse multiple tablegen files without worrying about Record lifetime.
Differential Revision: https://reviews.llvm.org/D125276
Diffstat (limited to 'llvm/lib/TableGen/TGParser.cpp')
-rw-r--r-- | llvm/lib/TableGen/TGParser.cpp | 200 |
1 files changed, 106 insertions, 94 deletions
diff --git a/llvm/lib/TableGen/TGParser.cpp b/llvm/lib/TableGen/TGParser.cpp index 90646a0..c92ab5d 100644 --- a/llvm/lib/TableGen/TGParser.cpp +++ b/llvm/lib/TableGen/TGParser.cpp @@ -112,14 +112,15 @@ static void checkConcrete(Record &R) { /// Return an Init with a qualifier prefix referring /// to CurRec's name. -static Init *QualifyName(Record &CurRec, MultiClass *CurMultiClass, - Init *Name, StringRef Scoper) { - Init *NewName = - BinOpInit::getStrConcat(CurRec.getNameInit(), StringInit::get(Scoper)); +static Init *QualifyName(Record &CurRec, MultiClass *CurMultiClass, Init *Name, + StringRef Scoper) { + RecordKeeper &RK = CurRec.getRecords(); + Init *NewName = BinOpInit::getStrConcat(CurRec.getNameInit(), + StringInit::get(RK, Scoper)); NewName = BinOpInit::getStrConcat(NewName, Name); if (CurMultiClass && Scoper != "::") { Init *Prefix = BinOpInit::getStrConcat(CurMultiClass->Rec.getNameInit(), - StringInit::get("::")); + StringInit::get(RK, "::")); NewName = BinOpInit::getStrConcat(Prefix, NewName); } @@ -131,7 +132,8 @@ static Init *QualifyName(Record &CurRec, MultiClass *CurMultiClass, /// Return the qualified version of the implicit 'NAME' template argument. static Init *QualifiedNameOfImplicitName(Record &Rec, MultiClass *MC = nullptr) { - return QualifyName(Rec, MC, StringInit::get("NAME"), MC ? "::" : ":"); + return QualifyName(Rec, MC, StringInit::get(Rec.getRecords(), "NAME"), + MC ? "::" : ":"); } static Init *QualifiedNameOfImplicitName(MultiClass *MC) { @@ -187,7 +189,7 @@ bool TGParser::SetValue(Record *CurRec, SMLoc Loc, Init *ValName, "' is not a bits type"); // Convert the incoming value to a bits type of the appropriate size... - Init *BI = V->getCastTo(BitsRecTy::get(BitList.size())); + Init *BI = V->getCastTo(BitsRecTy::get(Records, BitList.size())); if (!BI) return Error(Loc, "Initializer is not compatible with bit range"); @@ -206,7 +208,7 @@ bool TGParser::SetValue(Record *CurRec, SMLoc Loc, Init *ValName, if (!NewBits[i]) NewBits[i] = CurVal->getBit(i); - V = BitsInit::get(NewBits); + V = BitsInit::get(Records, NewBits); } if (RV->setValue(V, Loc)) { @@ -262,8 +264,8 @@ bool TGParser::AddSubClass(Record *CurRec, SubClassReference &SubClass) { Init *Name; if (CurRec->isClass()) - Name = - VarInit::get(QualifiedNameOfImplicitName(*CurRec), StringRecTy::get()); + Name = VarInit::get(QualifiedNameOfImplicitName(*CurRec), + StringRecTy::get(Records)); else Name = CurRec->getNameInit(); R.set(QualifiedNameOfImplicitName(*SC), Name); @@ -333,9 +335,9 @@ bool TGParser::AddSubMultiClass(MultiClass *CurMC, } } - TemplateArgs.emplace_back( - QualifiedNameOfImplicitName(SMC), - VarInit::get(QualifiedNameOfImplicitName(CurMC), StringRecTy::get())); + TemplateArgs.emplace_back(QualifiedNameOfImplicitName(SMC), + VarInit::get(QualifiedNameOfImplicitName(CurMC), + StringRecTy::get(Records))); // Add all of the defs in the subclass into the current multiclass. return resolve(SMC->Entries, TemplateArgs, false, &CurMC->Entries); @@ -540,7 +542,7 @@ Init *TGParser::ParseObjectName(MultiClass *CurMultiClass) { // These are all of the tokens that can begin an object body. // Some of these can also begin values but we disallow those cases // because they are unlikely to be useful. - return UnsetInit::get(); + return UnsetInit::get(Records); default: break; } @@ -549,7 +551,7 @@ Init *TGParser::ParseObjectName(MultiClass *CurMultiClass) { if (CurMultiClass) CurRec = &CurMultiClass->Rec; - Init *Name = ParseValue(CurRec, StringRecTy::get(), ParseNameMode); + Init *Name = ParseValue(CurRec, StringRecTy::get(Records), ParseNameMode); if (!Name) return nullptr; @@ -558,8 +560,8 @@ Init *TGParser::ParseObjectName(MultiClass *CurMultiClass) { HasReferenceResolver R(NameStr); Name->resolveReferences(R); if (!R.found()) - Name = BinOpInit::getStrConcat(VarInit::get(NameStr, StringRecTy::get()), - Name); + Name = BinOpInit::getStrConcat( + VarInit::get(NameStr, StringRecTy::get(Records)), Name); } return Name; @@ -812,12 +814,21 @@ RecTy *TGParser::ParseType() { switch (Lex.getCode()) { default: TokError("Unknown token when expecting a type"); return nullptr; case tgtok::String: - case tgtok::Code: Lex.Lex(); return StringRecTy::get(); - case tgtok::Bit: Lex.Lex(); return BitRecTy::get(); - case tgtok::Int: Lex.Lex(); return IntRecTy::get(); - case tgtok::Dag: Lex.Lex(); return DagRecTy::get(); + case tgtok::Code: + Lex.Lex(); + return StringRecTy::get(Records); + case tgtok::Bit: + Lex.Lex(); + return BitRecTy::get(Records); + case tgtok::Int: + Lex.Lex(); + return IntRecTy::get(Records); + case tgtok::Dag: + Lex.Lex(); + return DagRecTy::get(Records); case tgtok::Id: - if (Record *R = ParseClassID()) return RecordRecTy::get(R); + if (Record *R = ParseClassID()) + return RecordRecTy::get(R); TokError("unknown class name"); return nullptr; case tgtok::Bits: { @@ -835,7 +846,7 @@ RecTy *TGParser::ParseType() { return nullptr; } Lex.Lex(); // Eat '>' - return BitsRecTy::get(Val); + return BitsRecTy::get(Records, Val); } case tgtok::List: { if (Lex.Lex() != tgtok::less) { // Eat 'bits' @@ -878,7 +889,7 @@ Init *TGParser::ParseIDValue(Record *CurRec, StringInit *Name, SMLoc NameLoc, RV->setUsed(true); return VarInit::get(TemplateArgName, RV->getType()); } else if (Name->getValue() == "NAME") { - return VarInit::get(TemplateArgName, StringRecTy::get()); + return VarInit::get(TemplateArgName, StringRecTy::get(Records)); } } @@ -947,7 +958,7 @@ Init *TGParser::ParseOperation(Record *CurRec, RecTy *ItemType) { case tgtok::XNOT: Lex.Lex(); // eat the operation Code = UnOpInit::NOT; - Type = IntRecTy::get(); + Type = IntRecTy::get(Records); break; case tgtok::XHead: Lex.Lex(); // eat the operation @@ -960,12 +971,12 @@ Init *TGParser::ParseOperation(Record *CurRec, RecTy *ItemType) { case tgtok::XSize: Lex.Lex(); Code = UnOpInit::SIZE; - Type = IntRecTy::get(); + Type = IntRecTy::get(Records); break; case tgtok::XEmpty: Lex.Lex(); // eat the operation Code = UnOpInit::EMPTY; - Type = IntRecTy::get(); + Type = IntRecTy::get(Records); break; case tgtok::XGetDagOp: Lex.Lex(); // eat the operation @@ -985,7 +996,7 @@ Init *TGParser::ParseOperation(Record *CurRec, RecTy *ItemType) { // but keep parsing, to consume the operand } } else { - Type = RecordRecTy::get({}); + Type = RecordRecTy::get(Records, {}); } Code = UnOpInit::GETDAGOP; break; @@ -1143,8 +1154,8 @@ Init *TGParser::ParseOperation(Record *CurRec, RecTy *ItemType) { llvm_unreachable("Unhandled code!"); case tgtok::XConcat: case tgtok::XSetDagOp: - Type = DagRecTy::get(); - ArgType = DagRecTy::get(); + Type = DagRecTy::get(Records); + ArgType = DagRecTy::get(Records); break; case tgtok::XAND: case tgtok::XOR: @@ -1155,8 +1166,8 @@ Init *TGParser::ParseOperation(Record *CurRec, RecTy *ItemType) { case tgtok::XADD: case tgtok::XSUB: case tgtok::XMUL: - Type = IntRecTy::get(); - ArgType = IntRecTy::get(); + Type = IntRecTy::get(Records); + ArgType = IntRecTy::get(Records); break; case tgtok::XEq: case tgtok::XNe: @@ -1164,7 +1175,7 @@ Init *TGParser::ParseOperation(Record *CurRec, RecTy *ItemType) { case tgtok::XLt: case tgtok::XGe: case tgtok::XGt: - Type = BitRecTy::get(); + Type = BitRecTy::get(Records); // ArgType for the comparison operators is not yet known. break; case tgtok::XListConcat: @@ -1175,11 +1186,11 @@ Init *TGParser::ParseOperation(Record *CurRec, RecTy *ItemType) { // Can't do any typechecking until we parse the first argument. break; case tgtok::XStrConcat: - Type = StringRecTy::get(); - ArgType = StringRecTy::get(); + Type = StringRecTy::get(Records); + ArgType = StringRecTy::get(Records); break; case tgtok::XInterleave: - Type = StringRecTy::get(); + Type = StringRecTy::get(Records); // The first argument type is not yet known. } @@ -1253,9 +1264,9 @@ Init *TGParser::ParseOperation(Record *CurRec, RecTy *ItemType) { break; case BinOpInit::EQ: case BinOpInit::NE: - if (!ArgType->typeIsConvertibleTo(IntRecTy::get()) && - !ArgType->typeIsConvertibleTo(StringRecTy::get()) && - !ArgType->typeIsConvertibleTo(RecordRecTy::get({}))) { + if (!ArgType->typeIsConvertibleTo(IntRecTy::get(Records)) && + !ArgType->typeIsConvertibleTo(StringRecTy::get(Records)) && + !ArgType->typeIsConvertibleTo(RecordRecTy::get(Records, {}))) { Error(InitLoc, Twine("expected bit, bits, int, string, or record; " "got value of type '") + ArgType->getAsString() + "'"); @@ -1266,8 +1277,8 @@ Init *TGParser::ParseOperation(Record *CurRec, RecTy *ItemType) { case BinOpInit::LT: case BinOpInit::GE: case BinOpInit::GT: - if (!ArgType->typeIsConvertibleTo(IntRecTy::get()) && - !ArgType->typeIsConvertibleTo(StringRecTy::get())) { + if (!ArgType->typeIsConvertibleTo(IntRecTy::get(Records)) && + !ArgType->typeIsConvertibleTo(StringRecTy::get(Records))) { Error(InitLoc, Twine("expected bit, bits, int, or string; " "got value of type '") + ArgType->getAsString() + "'"); @@ -1277,8 +1288,9 @@ Init *TGParser::ParseOperation(Record *CurRec, RecTy *ItemType) { case BinOpInit::INTERLEAVE: switch (InitList.size()) { case 1: // First argument must be a list of strings or integers. - if (ArgType != StringRecTy::get()->getListTy() && - !ArgType->typeIsConvertibleTo(IntRecTy::get()->getListTy())) { + if (ArgType != StringRecTy::get(Records)->getListTy() && + !ArgType->typeIsConvertibleTo( + IntRecTy::get(Records)->getListTy())) { Error(InitLoc, Twine("expected list of string, int, bits, or bit; " "got value of type '") + ArgType->getAsString() + "'"); @@ -1323,7 +1335,7 @@ Init *TGParser::ParseOperation(Record *CurRec, RecTy *ItemType) { case BinOpInit::SETDAGOP: // After parsing the first dag argument, switch to expecting // a record, with no restriction on its superclasses. - ArgType = RecordRecTy::get({}); + ArgType = RecordRecTy::get(Records, {}); break; default: break; @@ -1383,7 +1395,7 @@ Init *TGParser::ParseOperation(Record *CurRec, RecTy *ItemType) { default: llvm_unreachable("Unhandled code!"); case tgtok::XDag: Code = TernOpInit::DAG; - Type = DagRecTy::get(); + Type = DagRecTy::get(Records); ItemType = nullptr; break; case tgtok::XIf: @@ -1445,7 +1457,7 @@ Init *TGParser::ParseOperation(Record *CurRec, RecTy *ItemType) { Error(RHSLoc, "could not determine type of the name list in !dag"); return nullptr; } - if (RHSt && StringRecTy::get()->getListTy() != RHSt->getType()) { + if (RHSt && StringRecTy::get(Records)->getListTy() != RHSt->getType()) { Error(RHSLoc, Twine("expected list<string>, got type '") + RHSt->getType()->getAsString() + "'"); return nullptr; @@ -1465,16 +1477,16 @@ Init *TGParser::ParseOperation(Record *CurRec, RecTy *ItemType) { if (TypedInit *MHSt = dyn_cast<TypedInit>(MHS)) MHSTy = MHSt->getType(); if (BitsInit *MHSbits = dyn_cast<BitsInit>(MHS)) - MHSTy = BitsRecTy::get(MHSbits->getNumBits()); + MHSTy = BitsRecTy::get(Records, MHSbits->getNumBits()); if (isa<BitInit>(MHS)) - MHSTy = BitRecTy::get(); + MHSTy = BitRecTy::get(Records); if (TypedInit *RHSt = dyn_cast<TypedInit>(RHS)) RHSTy = RHSt->getType(); if (BitsInit *RHSbits = dyn_cast<BitsInit>(RHS)) - RHSTy = BitsRecTy::get(RHSbits->getNumBits()); + RHSTy = BitsRecTy::get(Records, RHSbits->getNumBits()); if (isa<BitInit>(RHS)) - RHSTy = BitRecTy::get(); + RHSTy = BitRecTy::get(Records); // For UnsetInit, it's typed from the other hand. if (isa<UnsetInit>(MHS)) @@ -1569,7 +1581,7 @@ Init *TGParser::ParseOperation(Record *CurRec, RecTy *ItemType) { return nullptr; } - Init *A = StringInit::get(Lex.getCurStrVal()); + Init *A = StringInit::get(Records, Lex.getCurStrVal()); if (CurRec && CurRec->getValue(A)) { TokError((Twine("left !foldl variable '") + A->getAsString() + "' already defined") @@ -1587,7 +1599,7 @@ Init *TGParser::ParseOperation(Record *CurRec, RecTy *ItemType) { return nullptr; } - Init *B = StringInit::get(Lex.getCurStrVal()); + Init *B = StringInit::get(Records, Lex.getCurStrVal()); if (CurRec && CurRec->getValue(B)) { TokError((Twine("right !foldl variable '") + B->getAsString() + "' already defined") @@ -1679,7 +1691,7 @@ RecTy *TGParser::ParseOperatorType() { /// Substr ::= !substr(string, start-int [, length-int]) => string Init *TGParser::ParseOperationSubstr(Record *CurRec, RecTy *ItemType) { TernOpInit::TernaryOp Code = TernOpInit::SUBSTR; - RecTy *Type = StringRecTy::get(); + RecTy *Type = StringRecTy::get(Records); Lex.Lex(); // eat the operation @@ -1710,7 +1722,7 @@ Init *TGParser::ParseOperationSubstr(Record *CurRec, RecTy *ItemType) { if (!RHS) return nullptr; } else { - RHS = IntInit::get(std::numeric_limits<int64_t>::max()); + RHS = IntInit::get(Records, std::numeric_limits<int64_t>::max()); } if (!consume(tgtok::r_paren)) { @@ -1767,7 +1779,7 @@ Init *TGParser::ParseOperationSubstr(Record *CurRec, RecTy *ItemType) { /// Substr ::= !find(string, string [, start-int]) => int Init *TGParser::ParseOperationFind(Record *CurRec, RecTy *ItemType) { TernOpInit::TernaryOp Code = TernOpInit::FIND; - RecTy *Type = IntRecTy::get(); + RecTy *Type = IntRecTy::get(Records); Lex.Lex(); // eat the operation @@ -1798,7 +1810,7 @@ Init *TGParser::ParseOperationFind(Record *CurRec, RecTy *ItemType) { if (!RHS) return nullptr; } else { - RHS = IntInit::get(0); + RHS = IntInit::get(Records, 0); } if (!consume(tgtok::r_paren)) { @@ -1868,7 +1880,7 @@ Init *TGParser::ParseOperationForEachFilter(Record *CurRec, RecTy *ItemType) { return nullptr; } - Init *LHS = StringInit::get(Lex.getCurStrVal()); + Init *LHS = StringInit::get(Records, Lex.getCurStrVal()); Lex.Lex(); // eat the ID. if (CurRec && CurRec->getValue(LHS)) { @@ -1908,7 +1920,7 @@ Init *TGParser::ParseOperationForEachFilter(Record *CurRec, RecTy *ItemType) { if (ListRecTy *OutListTy = dyn_cast<ListRecTy>(ItemType)) { ExprEltType = (Operation == tgtok::XForEach) ? OutListTy->getElementType() - : IntRecTy::get(); + : IntRecTy::get(Records); } else { Error(OpLoc, "expected value of type '" + @@ -2028,9 +2040,9 @@ Init *TGParser::ParseOperationCond(Record *CurRec, RecTy *ItemType) { if (TypedInit *Vt = dyn_cast<TypedInit>(V)) VTy = Vt->getType(); if (BitsInit *Vbits = dyn_cast<BitsInit>(V)) - VTy = BitsRecTy::get(Vbits->getNumBits()); + VTy = BitsRecTy::get(Records, Vbits->getNumBits()); if (isa<BitInit>(V)) - VTy = BitRecTy::get(); + VTy = BitRecTy::get(Records); if (Type == nullptr) { if (!isa<UnsetInit>(V)) @@ -2084,23 +2096,23 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType, default: TokError("Unknown or reserved token when parsing a value"); break; case tgtok::TrueVal: - R = IntInit::get(1); + R = IntInit::get(Records, 1); Lex.Lex(); break; case tgtok::FalseVal: - R = IntInit::get(0); + R = IntInit::get(Records, 0); Lex.Lex(); break; case tgtok::IntVal: - R = IntInit::get(Lex.getCurIntVal()); + R = IntInit::get(Records, Lex.getCurIntVal()); Lex.Lex(); break; case tgtok::BinaryIntVal: { auto BinaryVal = Lex.getCurBinaryIntVal(); SmallVector<Init*, 16> Bits(BinaryVal.second); for (unsigned i = 0, e = BinaryVal.second; i != e; ++i) - Bits[i] = BitInit::get(BinaryVal.first & (1LL << i)); - R = BitsInit::get(Bits); + Bits[i] = BitInit::get(Records, BinaryVal.first & (1LL << i)); + R = BitsInit::get(Records, Bits); Lex.Lex(); break; } @@ -2114,20 +2126,20 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType, Lex.Lex(); } - R = StringInit::get(Val); + R = StringInit::get(Records, Val); break; } case tgtok::CodeFragment: - R = StringInit::get(Lex.getCurStrVal(), StringInit::SF_Code); + R = StringInit::get(Records, Lex.getCurStrVal(), StringInit::SF_Code); Lex.Lex(); break; case tgtok::question: - R = UnsetInit::get(); + R = UnsetInit::get(Records); Lex.Lex(); break; case tgtok::Id: { SMLoc NameLoc = Lex.getLoc(); - StringInit *Name = StringInit::get(Lex.getCurStrVal()); + StringInit *Name = StringInit::get(Records, Lex.getCurStrVal()); if (Lex.Lex() != tgtok::less) // consume the Id. return ParseIDValue(CurRec, Name, NameLoc, Mode); // Value ::= IDValue @@ -2202,7 +2214,7 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType, // Fallthrough to try convert this to a bit. } // All other values must be convertible to just a single bit. - Init *Bit = Vals[i]->getCastTo(BitRecTy::get()); + Init *Bit = Vals[i]->getCastTo(BitRecTy::get(Records)); if (!Bit) { Error(BraceLoc, "Element #" + Twine(i) + " (" + Vals[i]->getAsString() + ") is not convertable to a bit"); @@ -2211,7 +2223,7 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType, NewBits.push_back(Bit); } std::reverse(NewBits.begin(), NewBits.end()); - return BitsInit::get(NewBits); + return BitsInit::get(Records, NewBits); } case tgtok::l_square: { // Value ::= '[' ValueList ']' Lex.Lex(); // eat the '[' @@ -2322,7 +2334,7 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType, TokError("expected variable name in dag operator"); return nullptr; } - OperatorName = StringInit::get(Lex.getCurStrVal()); + OperatorName = StringInit::get(Records, Lex.getCurStrVal()); Lex.Lex(); // eat the VarName. } @@ -2451,7 +2463,7 @@ Init *TGParser::ParseValue(Record *CurRec, RecTy *ItemType, IDParseMode Mode) { TokError("expected field identifier after '.'"); return nullptr; } - StringInit *FieldName = StringInit::get(Lex.getCurStrVal()); + StringInit *FieldName = StringInit::get(Records, Lex.getCurStrVal()); if (!Result->getFieldType(FieldName)) { TokError("Cannot access field '" + Lex.getCurStrVal() + "' of value '" + Result->getAsString() + "'"); @@ -2494,9 +2506,9 @@ Init *TGParser::ParseValue(Record *CurRec, RecTy *ItemType, IDParseMode Mode) { // Create a !strconcat() operation, first casting each operand to // a string if necessary. - if (LHS->getType() != StringRecTy::get()) { + if (LHS->getType() != StringRecTy::get(Records)) { auto CastLHS = dyn_cast<TypedInit>( - UnOpInit::get(UnOpInit::CAST, LHS, StringRecTy::get()) + UnOpInit::get(UnOpInit::CAST, LHS, StringRecTy::get(Records)) ->Fold(CurRec)); if (!CastLHS) { Error(PasteLoc, @@ -2518,7 +2530,7 @@ Init *TGParser::ParseValue(Record *CurRec, RecTy *ItemType, IDParseMode Mode) { // because they are unlikely to be useful. // Trailing paste, concat with an empty string. - RHS = StringInit::get(""); + RHS = StringInit::get(Records, ""); break; default: @@ -2531,9 +2543,9 @@ Init *TGParser::ParseValue(Record *CurRec, RecTy *ItemType, IDParseMode Mode) { return nullptr; } - if (RHS->getType() != StringRecTy::get()) { + if (RHS->getType() != StringRecTy::get(Records)) { auto CastRHS = dyn_cast<TypedInit>( - UnOpInit::get(UnOpInit::CAST, RHS, StringRecTy::get()) + UnOpInit::get(UnOpInit::CAST, RHS, StringRecTy::get(Records)) ->Fold(CurRec)); if (!CastRHS) { Error(PasteLoc, @@ -2566,8 +2578,8 @@ void TGParser::ParseDagArgList( // DagArg ::= VARNAME if (Lex.getCode() == tgtok::VarName) { // A missing value is treated like '?'. - StringInit *VarName = StringInit::get(Lex.getCurStrVal()); - Result.emplace_back(UnsetInit::get(), VarName); + StringInit *VarName = StringInit::get(Records, Lex.getCurStrVal()); + Result.emplace_back(UnsetInit::get(Records), VarName); Lex.Lex(); } else { // DagArg ::= Value (':' VARNAME)? @@ -2585,7 +2597,7 @@ void TGParser::ParseDagArgList( Result.clear(); return; } - VarName = StringInit::get(Lex.getCurStrVal()); + VarName = StringInit::get(Records, Lex.getCurStrVal()); Lex.Lex(); // eat the VarName. } @@ -2692,7 +2704,7 @@ Init *TGParser::ParseDeclaration(Record *CurRec, } SMLoc IdLoc = Lex.getLoc(); - Init *DeclName = StringInit::get(Str); + Init *DeclName = StringInit::get(Records, Str); Lex.Lex(); bool BadField; @@ -2745,7 +2757,7 @@ VarInit *TGParser::ParseForeachDeclaration(Init *&ForeachListValue) { return nullptr; } - Init *DeclName = StringInit::get(Lex.getCurStrVal()); + Init *DeclName = StringInit::get(Records, Lex.getCurStrVal()); Lex.Lex(); // If a value is present, parse it. @@ -2799,10 +2811,10 @@ VarInit *TGParser::ParseForeachDeclaration(Init *&ForeachListValue) { if (!Ranges.empty()) { assert(!IterType && "Type already initialized?"); - IterType = IntRecTy::get(); + IterType = IntRecTy::get(Records); std::vector<Init *> Values; for (unsigned R : Ranges) - Values.push_back(IntInit::get(R)); + Values.push_back(IntInit::get(Records, R)); ForeachListValue = ListInit::get(Values, IterType); } @@ -2879,7 +2891,7 @@ bool TGParser::ParseBodyItem(Record *CurRec) { return TokError("expected field identifier after let"); SMLoc IdLoc = Lex.getLoc(); - StringInit *FieldName = StringInit::get(Lex.getCurStrVal()); + StringInit *FieldName = StringInit::get(Records, Lex.getCurStrVal()); Lex.Lex(); // eat the field name. SmallVector<unsigned, 16> BitList; @@ -2898,7 +2910,7 @@ bool TGParser::ParseBodyItem(Record *CurRec) { if (!BitList.empty() && isa<BitsRecTy>(Type)) { // When assigning to a subset of a 'bits' object, expect the RHS to have // the type of that subset instead of the type of the whole object. - Type = BitsRecTy::get(BitList.size()); + Type = BitsRecTy::get(Records, BitList.size()); } Init *Val = ParseValue(CurRec, Type); @@ -3056,7 +3068,7 @@ bool TGParser::ParseDefset() { if (Lex.getCode() != tgtok::Id) return TokError("expected identifier"); - StringInit *DeclName = StringInit::get(Lex.getCurStrVal()); + StringInit *DeclName = StringInit::get(Records, Lex.getCurStrVal()); if (Records.getGlobal(DeclName->getValue())) return TokError("def or global variable of this name already exists"); @@ -3093,7 +3105,7 @@ bool TGParser::ParseDefvar() { if (Lex.getCode() != tgtok::Id) return TokError("expected identifier"); - StringInit *DeclName = StringInit::get(Lex.getCurStrVal()); + StringInit *DeclName = StringInit::get(Records, Lex.getCurStrVal()); if (CurLocalScope) { if (CurLocalScope->varAlreadyDefined(DeclName->getValue())) return TokError("local variable of this name already exists"); @@ -3201,10 +3213,10 @@ bool TGParser::ParseIf(MultiClass *CurMultiClass) { // loop, over a list of length 0 or 1 depending on the condition, and with no // iteration variable being assigned. - ListInit *EmptyList = ListInit::get({}, BitRecTy::get()); + ListInit *EmptyList = ListInit::get({}, BitRecTy::get(Records)); ListInit *SingletonList = - ListInit::get({BitInit::get(true)}, BitRecTy::get()); - RecTy *BitListTy = ListRecTy::get(BitRecTy::get()); + ListInit::get({BitInit::get(Records, true)}, BitRecTy::get(Records)); + RecTy *BitListTy = ListRecTy::get(BitRecTy::get(Records)); // The foreach containing the then-clause selects SingletonList if // the condition is true. @@ -3369,7 +3381,7 @@ void TGParser::ParseLetList(SmallVectorImpl<LetRecord> &Result) { return; } - StringInit *Name = StringInit::get(Lex.getCurStrVal()); + StringInit *Name = StringInit::get(Records, Lex.getCurStrVal()); SMLoc NameLoc = Lex.getLoc(); Lex.Lex(); // Eat the identifier. @@ -3570,7 +3582,7 @@ bool TGParser::ParseDefm(MultiClass *CurMultiClass) { if (CurMultiClass) DefmName = BinOpInit::getStrConcat( VarInit::get(QualifiedNameOfImplicitName(CurMultiClass), - StringRecTy::get()), + StringRecTy::get(Records)), DefmName); } |