summaryrefslogtreecommitdiff
path: root/utils/TableGen/TGParser.cpp
diff options
context:
space:
mode:
authorDavid Greene <greened@obbligato.org>2011-07-11 18:25:51 +0000
committerDavid Greene <greened@obbligato.org>2011-07-11 18:25:51 +0000
commitd4a9066c93da9a5aab47ca228d82e796fdec70c0 (patch)
treef4533e3a9fe75aa310bd4682b254a053af0bfd73 /utils/TableGen/TGParser.cpp
parent7ae0df41422193e65231a0f9526bfe66067c6532 (diff)
downloadllvm-d4a9066c93da9a5aab47ca228d82e796fdec70c0.tar.gz
llvm-d4a9066c93da9a5aab47ca228d82e796fdec70c0.tar.bz2
llvm-d4a9066c93da9a5aab47ca228d82e796fdec70c0.tar.xz
[AVX] Make Inits Foldable
Manage Inits in a FoldingSet. This provides several benefits: - Memory for Inits is properly managed - Duplicate Inits are folded into Flyweights, saving memory - It enforces const-correctness, protecting against certain classes of bugs The above benefits allow Inits to be used in more contexts, which in turn provides more dynamism to TableGen. This enhanced capability will be used by the AVX code generator to a fold common patterns together. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134907 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/TGParser.cpp')
-rw-r--r--utils/TableGen/TGParser.cpp166
1 files changed, 84 insertions, 82 deletions
diff --git a/utils/TableGen/TGParser.cpp b/utils/TableGen/TGParser.cpp
index 59097f986f..3e48e64537 100644
--- a/utils/TableGen/TGParser.cpp
+++ b/utils/TableGen/TGParser.cpp
@@ -28,7 +28,7 @@ namespace llvm {
struct SubClassReference {
SMLoc RefLoc;
Record *Rec;
- std::vector<Init*> TemplateArgs;
+ std::vector<const Init*> TemplateArgs;
SubClassReference() : Rec(0) {}
bool isInvalid() const { return Rec == 0; }
@@ -37,7 +37,7 @@ struct SubClassReference {
struct SubMultiClassReference {
SMLoc RefLoc;
MultiClass *MC;
- std::vector<Init*> TemplateArgs;
+ std::vector<const Init*> TemplateArgs;
SubMultiClassReference() : MC(0) {}
bool isInvalid() const { return MC == 0; }
@@ -50,7 +50,7 @@ void SubMultiClassReference::dump() const {
MC->dump();
errs() << "Template args:\n";
- for (std::vector<Init *>::const_iterator i = TemplateArgs.begin(),
+ for (std::vector<const Init *>::const_iterator i = TemplateArgs.begin(),
iend = TemplateArgs.end();
i != iend;
++i) {
@@ -80,7 +80,7 @@ bool TGParser::AddValue(Record *CurRec, SMLoc Loc, const RecordVal &RV) {
/// SetValue -
/// Return true on error, false on success.
bool TGParser::SetValue(Record *CurRec, SMLoc Loc, const std::string &ValName,
- const std::vector<unsigned> &BitList, Init *V) {
+ const std::vector<unsigned> &BitList, const Init *V) {
if (!V) return false;
if (CurRec == 0) CurRec = &CurMultiClass->Rec;
@@ -92,7 +92,7 @@ bool TGParser::SetValue(Record *CurRec, SMLoc Loc, const std::string &ValName,
// Do not allow assignments like 'X = X'. This will just cause infinite loops
// in the resolution machinery.
if (BitList.empty())
- if (VarInit *VI = dynamic_cast<VarInit*>(V))
+ if (const VarInit *VI = dynamic_cast<const VarInit*>(V))
if (VI->getName() == ValName)
return false;
@@ -101,37 +101,37 @@ bool TGParser::SetValue(Record *CurRec, SMLoc Loc, const std::string &ValName,
// initializer.
//
if (!BitList.empty()) {
- BitsInit *CurVal = dynamic_cast<BitsInit*>(RV->getValue());
+ const BitsInit *CurVal = dynamic_cast<const BitsInit*>(RV->getValue());
if (CurVal == 0)
return Error(Loc, "Value '" + ValName + "' is not a bits type");
// Convert the incoming value to a bits type of the appropriate size...
- Init *BI = V->convertInitializerTo(new BitsRecTy(BitList.size()));
+ const Init *BI = V->convertInitializerTo(new BitsRecTy(BitList.size()));
if (BI == 0) {
V->convertInitializerTo(new BitsRecTy(BitList.size()));
return Error(Loc, "Initializer is not compatible with bit range");
}
// We should have a BitsInit type now.
- BitsInit *BInit = dynamic_cast<BitsInit*>(BI);
+ const BitsInit *BInit = dynamic_cast<const BitsInit*>(BI);
assert(BInit != 0);
- BitsInit *NewVal = new BitsInit(CurVal->getNumBits());
+ SmallVector<const Init *, 16> NewBits(CurVal->getNumBits());
// Loop over bits, assigning values as appropriate.
for (unsigned i = 0, e = BitList.size(); i != e; ++i) {
unsigned Bit = BitList[i];
- if (NewVal->getBit(Bit))
+ if (NewBits[Bit])
return Error(Loc, "Cannot set bit #" + utostr(Bit) + " of value '" +
ValName + "' more than once");
- NewVal->setBit(Bit, BInit->getBit(i));
+ NewBits[Bit] = BInit->getBit(i);
}
for (unsigned i = 0, e = CurVal->getNumBits(); i != e; ++i)
- if (NewVal->getBit(i) == 0)
- NewVal->setBit(i, CurVal->getBit(i));
+ if (NewBits[i] == 0)
+ NewBits[i] = CurVal->getBit(i);
- V = NewVal;
+ V = BitsInit::Create(NewBits.begin(), NewBits.end());
}
if (RV->setValue(V))
@@ -633,7 +633,7 @@ RecTy *TGParser::ParseType() {
/// IDValue ::= ID [multiclass template argument]
/// IDValue ::= ID [def name]
///
-Init *TGParser::ParseIDValue(Record *CurRec) {
+const Init *TGParser::ParseIDValue(Record *CurRec) {
assert(Lex.getCode() == tgtok::Id && "Expected ID in ParseIDValue");
std::string Name = Lex.getCurStrVal();
SMLoc Loc = Lex.getLoc();
@@ -643,17 +643,17 @@ Init *TGParser::ParseIDValue(Record *CurRec) {
/// ParseIDValue - This is just like ParseIDValue above, but it assumes the ID
/// has already been read.
-Init *TGParser::ParseIDValue(Record *CurRec,
+const Init *TGParser::ParseIDValue(Record *CurRec,
const std::string &Name, SMLoc NameLoc) {
if (CurRec) {
if (const RecordVal *RV = CurRec->getValue(Name))
- return new VarInit(Name, RV->getType());
+ return VarInit::Create(Name, RV->getType());
std::string TemplateArgName = CurRec->getName()+":"+Name;
if (CurRec->isTemplateArg(TemplateArgName)) {
const RecordVal *RV = CurRec->getValue(TemplateArgName);
assert(RV && "Template arg doesn't exist??");
- return new VarInit(TemplateArgName, RV->getType());
+ return VarInit::Create(TemplateArgName, RV->getType());
}
}
@@ -662,12 +662,12 @@ Init *TGParser::ParseIDValue(Record *CurRec,
if (CurMultiClass->Rec.isTemplateArg(MCName)) {
const RecordVal *RV = CurMultiClass->Rec.getValue(MCName);
assert(RV && "Template arg doesn't exist??");
- return new VarInit(MCName, RV->getType());
+ return VarInit::Create(MCName, RV->getType());
}
}
if (Record *D = Records.getDef(Name))
- return new DefInit(D);
+ return DefInit::Create(D);
Error(NameLoc, "Variable not defined: '" + Name + "'");
return 0;
@@ -677,7 +677,7 @@ Init *TGParser::ParseIDValue(Record *CurRec,
///
/// Operation ::= XOperator ['<' Type '>'] '(' Args ')'
///
-Init *TGParser::ParseOperation(Record *CurRec) {
+const Init *TGParser::ParseOperation(Record *CurRec) {
switch (Lex.getCode()) {
default:
TokError("unknown operation");
@@ -724,15 +724,15 @@ Init *TGParser::ParseOperation(Record *CurRec) {
}
Lex.Lex(); // eat the '('
- Init *LHS = ParseValue(CurRec);
+ const Init *LHS = ParseValue(CurRec);
if (LHS == 0) return 0;
if (Code == UnOpInit::HEAD
|| Code == UnOpInit::TAIL
|| Code == UnOpInit::EMPTY) {
- ListInit *LHSl = dynamic_cast<ListInit*>(LHS);
- StringInit *LHSs = dynamic_cast<StringInit*>(LHS);
- TypedInit *LHSt = dynamic_cast<TypedInit*>(LHS);
+ const ListInit *LHSl = dynamic_cast<const ListInit*>(LHS);
+ const StringInit *LHSs = dynamic_cast<const StringInit*>(LHS);
+ const TypedInit *LHSt = dynamic_cast<const TypedInit*>(LHS);
if (LHSl == 0 && LHSs == 0 && LHSt == 0) {
TokError("expected list or string type argument in unary operator");
return 0;
@@ -758,8 +758,8 @@ Init *TGParser::ParseOperation(Record *CurRec) {
return 0;
}
if (LHSl) {
- Init *Item = LHSl->getElement(0);
- TypedInit *Itemt = dynamic_cast<TypedInit*>(Item);
+ const Init *Item = LHSl->getElement(0);
+ const TypedInit *Itemt = dynamic_cast<const TypedInit*>(Item);
if (Itemt == 0) {
TokError("untyped list element in unary operator");
return 0;
@@ -790,7 +790,7 @@ Init *TGParser::ParseOperation(Record *CurRec) {
return 0;
}
Lex.Lex(); // eat the ')'
- return (new UnOpInit(Code, LHS, Type))->Fold(CurRec, CurMultiClass);
+ return (UnOpInit::Create(Code, LHS, Type))->Fold(CurRec, CurMultiClass);
}
case tgtok::XConcat:
@@ -825,7 +825,7 @@ Init *TGParser::ParseOperation(Record *CurRec) {
}
Lex.Lex(); // eat the '('
- SmallVector<Init*, 2> InitList;
+ SmallVector<const Init*, 2> InitList;
InitList.push_back(ParseValue(CurRec));
if (InitList.back() == 0) return 0;
@@ -847,15 +847,15 @@ Init *TGParser::ParseOperation(Record *CurRec) {
// shorthand for nesting them.
if (Code == BinOpInit::STRCONCAT) {
while (InitList.size() > 2) {
- Init *RHS = InitList.pop_back_val();
- RHS = (new BinOpInit(Code, InitList.back(), RHS, Type))
+ const Init *RHS = InitList.pop_back_val();
+ RHS = (BinOpInit::Create(Code, InitList.back(), RHS, Type))
->Fold(CurRec, CurMultiClass);
InitList.back() = RHS;
}
}
if (InitList.size() == 2)
- return (new BinOpInit(Code, InitList[0], InitList[1], Type))
+ return (BinOpInit::Create(Code, InitList[0], InitList[1], Type))
->Fold(CurRec, CurMultiClass);
Error(OpLoc, "expected two operands to operator");
@@ -888,7 +888,7 @@ Init *TGParser::ParseOperation(Record *CurRec) {
}
Lex.Lex(); // eat the '('
- Init *LHS = ParseValue(CurRec);
+ const Init *LHS = ParseValue(CurRec);
if (LHS == 0) return 0;
if (Lex.getCode() != tgtok::comma) {
@@ -897,7 +897,7 @@ Init *TGParser::ParseOperation(Record *CurRec) {
}
Lex.Lex(); // eat the ','
- Init *MHS = ParseValue(CurRec);
+ const Init *MHS = ParseValue(CurRec);
if (MHS == 0) return 0;
if (Lex.getCode() != tgtok::comma) {
@@ -906,7 +906,7 @@ Init *TGParser::ParseOperation(Record *CurRec) {
}
Lex.Lex(); // eat the ','
- Init *RHS = ParseValue(CurRec);
+ const Init *RHS = ParseValue(CurRec);
if (RHS == 0) return 0;
if (Lex.getCode() != tgtok::r_paren) {
@@ -920,23 +920,23 @@ Init *TGParser::ParseOperation(Record *CurRec) {
case tgtok::XIf: {
// FIXME: The `!if' operator doesn't handle non-TypedInit well at
// all. This can be made much more robust.
- TypedInit *MHSt = dynamic_cast<TypedInit*>(MHS);
- TypedInit *RHSt = dynamic_cast<TypedInit*>(RHS);
+ const TypedInit *MHSt = dynamic_cast<const TypedInit*>(MHS);
+ const TypedInit *RHSt = dynamic_cast<const TypedInit*>(RHS);
RecTy *MHSTy = 0;
RecTy *RHSTy = 0;
if (MHSt == 0 && RHSt == 0) {
- BitsInit *MHSbits = dynamic_cast<BitsInit*>(MHS);
- BitsInit *RHSbits = dynamic_cast<BitsInit*>(RHS);
+ const BitsInit *MHSbits = dynamic_cast<const BitsInit*>(MHS);
+ const BitsInit *RHSbits = dynamic_cast<const BitsInit*>(RHS);
if (MHSbits && RHSbits &&
MHSbits->getNumBits() == RHSbits->getNumBits()) {
Type = new BitRecTy();
break;
} else {
- BitInit *MHSbit = dynamic_cast<BitInit*>(MHS);
- BitInit *RHSbit = dynamic_cast<BitInit*>(RHS);
+ const BitInit *MHSbit = dynamic_cast<const BitInit*>(MHS);
+ const BitInit *RHSbit = dynamic_cast<const BitInit*>(RHS);
if (MHSbit && RHSbit) {
Type = new BitRecTy();
@@ -964,7 +964,7 @@ Init *TGParser::ParseOperation(Record *CurRec) {
break;
}
case tgtok::XForEach: {
- TypedInit *MHSt = dynamic_cast<TypedInit *>(MHS);
+ const TypedInit *MHSt = dynamic_cast<const TypedInit *>(MHS);
if (MHSt == 0) {
TokError("could not get type for !foreach");
return 0;
@@ -973,7 +973,7 @@ Init *TGParser::ParseOperation(Record *CurRec) {
break;
}
case tgtok::XSubst: {
- TypedInit *RHSt = dynamic_cast<TypedInit *>(RHS);
+ const TypedInit *RHSt = dynamic_cast<const TypedInit *>(RHS);
if (RHSt == 0) {
TokError("could not get type for !subst");
return 0;
@@ -982,7 +982,7 @@ Init *TGParser::ParseOperation(Record *CurRec) {
break;
}
}
- return (new TernOpInit(Code, LHS, MHS, RHS, Type))->Fold(CurRec,
+ return (TernOpInit::Create(Code, LHS, MHS, RHS, Type))->Fold(CurRec,
CurMultiClass);
}
}
@@ -1038,11 +1038,11 @@ RecTy *TGParser::ParseOperatorType() {
/// SimpleValue ::= SRLTOK '(' Value ',' Value ')'
/// SimpleValue ::= STRCONCATTOK '(' Value ',' Value ')'
///
-Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType) {
- Init *R = 0;
+const Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType) {
+ const Init *R = 0;
switch (Lex.getCode()) {
default: TokError("Unknown token when parsing a value"); break;
- case tgtok::IntVal: R = new IntInit(Lex.getCurIntVal()); Lex.Lex(); break;
+ case tgtok::IntVal: R = IntInit::Create(Lex.getCurIntVal()); Lex.Lex(); break;
case tgtok::StrVal: {
std::string Val = Lex.getCurStrVal();
Lex.Lex();
@@ -1053,15 +1053,15 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType) {
Lex.Lex();
}
- R = new StringInit(Val);
+ R = StringInit::Create(Val);
break;
}
case tgtok::CodeFragment:
- R = new CodeInit(Lex.getCurStrVal());
+ R = CodeInit::Create(Lex.getCurStrVal());
Lex.Lex();
break;
case tgtok::question:
- R = new UnsetInit();
+ R = UnsetInit::Create();
Lex.Lex();
break;
case tgtok::Id: {
@@ -1085,7 +1085,7 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType) {
return 0;
}
- std::vector<Init*> ValueList = ParseValueList(CurRec, Class);
+ std::vector<const Init*> ValueList = ParseValueList(CurRec, Class);
if (ValueList.empty()) return 0;
if (Lex.getCode() != tgtok::greater) {
@@ -1110,12 +1110,12 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType) {
Records.addDef(NewRec);
// The result of the expression is a reference to the new record.
- return new DefInit(NewRec);
+ return DefInit::Create(NewRec);
}
case tgtok::l_brace: { // Value ::= '{' ValueList '}'
SMLoc BraceLoc = Lex.getLoc();
Lex.Lex(); // eat the '{'
- std::vector<Init*> Vals;
+ std::vector<const Init*> Vals;
if (Lex.getCode() != tgtok::r_brace) {
Vals = ParseValueList(CurRec);
@@ -1127,21 +1127,22 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType) {
}
Lex.Lex(); // eat the '}'
- BitsInit *Result = new BitsInit(Vals.size());
+ SmallVector<const Init *, 16> NewBits(Vals.size());
+
for (unsigned i = 0, e = Vals.size(); i != e; ++i) {
- Init *Bit = Vals[i]->convertInitializerTo(new BitRecTy());
+ const Init *Bit = Vals[i]->convertInitializerTo(new BitRecTy());
if (Bit == 0) {
Error(BraceLoc, "Element #" + utostr(i) + " (" + Vals[i]->getAsString()+
") is not convertable to a bit");
return 0;
}
- Result->setBit(Vals.size()-i-1, Bit);
+ NewBits[Vals.size()-i-1] = Bit;
}
- return Result;
+ return BitsInit::Create(NewBits.begin(), NewBits.end());
}
case tgtok::l_square: { // Value ::= '[' ValueList ']'
Lex.Lex(); // eat the '['
- std::vector<Init*> Vals;
+ std::vector<const Init*> Vals;
RecTy *DeducedEltTy = 0;
ListRecTy *GivenListTy = 0;
@@ -1189,10 +1190,10 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType) {
// Check elements
RecTy *EltTy = 0;
- for (std::vector<Init *>::iterator i = Vals.begin(), ie = Vals.end();
+ for (std::vector<const Init *>::iterator i = Vals.begin(), ie = Vals.end();
i != ie;
++i) {
- TypedInit *TArg = dynamic_cast<TypedInit*>(*i);
+ const TypedInit *TArg = dynamic_cast<const TypedInit*>(*i);
if (TArg == 0) {
TokError("Untyped list element");
return 0;
@@ -1236,7 +1237,7 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType) {
DeducedEltTy = EltTy;
}
- return new ListInit(Vals, DeducedEltTy);
+ return ListInit::Create(Vals, DeducedEltTy);
}
case tgtok::l_paren: { // Value ::= '(' IDValue DagArgList ')'
Lex.Lex(); // eat the '('
@@ -1245,7 +1246,7 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType) {
return 0;
}
- Init *Operator = ParseValue(CurRec);
+ const Init *Operator = ParseValue(CurRec);
if (Operator == 0) return 0;
// If the operator name is present, parse it.
@@ -1259,7 +1260,7 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType) {
Lex.Lex(); // eat the VarName.
}
- std::vector<std::pair<llvm::Init*, std::string> > DagArgs;
+ std::vector<std::pair<const Init*, std::string> > DagArgs;
if (Lex.getCode() != tgtok::r_paren) {
DagArgs = ParseDagArgList(CurRec);
if (DagArgs.empty()) return 0;
@@ -1271,7 +1272,7 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType) {
}
Lex.Lex(); // eat the ')'
- return new DagInit(Operator, OperatorName, DagArgs);
+ return DagInit::Create(Operator, OperatorName, DagArgs);
}
case tgtok::XHead:
@@ -1301,8 +1302,8 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType) {
/// ValueSuffix ::= '[' BitList ']'
/// ValueSuffix ::= '.' ID
///
-Init *TGParser::ParseValue(Record *CurRec, RecTy *ItemType) {
- Init *Result = ParseSimpleValue(CurRec, ItemType);
+const Init *TGParser::ParseValue(Record *CurRec, RecTy *ItemType) {
+ const Init *Result = ParseSimpleValue(CurRec, ItemType);
if (Result == 0) return 0;
// Parse the suffixes now if present.
@@ -1361,7 +1362,7 @@ Init *TGParser::ParseValue(Record *CurRec, RecTy *ItemType) {
Result->getAsString() + "'");
return 0;
}
- Result = new FieldInit(Result, Lex.getCurStrVal());
+ Result = FieldInit::Create(Result, Lex.getCurStrVal());
Lex.Lex(); // eat field name
break;
}
@@ -1372,20 +1373,20 @@ Init *TGParser::ParseValue(Record *CurRec, RecTy *ItemType) {
///
/// ParseDagArgList ::= Value (':' VARNAME)?
/// ParseDagArgList ::= ParseDagArgList ',' Value (':' VARNAME)?
-std::vector<std::pair<llvm::Init*, std::string> >
+std::vector<std::pair<const Init*, std::string> >
TGParser::ParseDagArgList(Record *CurRec) {
- std::vector<std::pair<llvm::Init*, std::string> > Result;
+ std::vector<std::pair<const Init*, std::string> > Result;
while (1) {
- Init *Val = ParseValue(CurRec);
- if (Val == 0) return std::vector<std::pair<llvm::Init*, std::string> >();
+ const Init *Val = ParseValue(CurRec);
+ if (Val == 0) return std::vector<std::pair<const Init*, std::string> >();
// If the variable name is present, add it.
std::string VarName;
if (Lex.getCode() == tgtok::colon) {
if (Lex.Lex() != tgtok::VarName) { // eat the ':'
TokError("expected variable name in dag literal");
- return std::vector<std::pair<llvm::Init*, std::string> >();
+ return std::vector<std::pair<const Init*, std::string> >();
}
VarName = Lex.getCurStrVal();
Lex.Lex(); // eat the VarName.
@@ -1407,9 +1408,10 @@ TGParser::ParseDagArgList(Record *CurRec) {
///
/// ValueList ::= Value (',' Value)
///
-std::vector<Init*> TGParser::ParseValueList(Record *CurRec, Record *ArgsRec,
- RecTy *EltTy) {
- std::vector<Init*> Result;
+std::vector<const Init*> TGParser::ParseValueList(Record *CurRec,
+ Record *ArgsRec,
+ RecTy *EltTy) {
+ std::vector<const Init*> Result;
RecTy *ItemType = EltTy;
unsigned int ArgN = 0;
if (ArgsRec != 0 && EltTy == 0) {
@@ -1420,7 +1422,7 @@ std::vector<Init*> TGParser::ParseValueList(Record *CurRec, Record *ArgsRec,
++ArgN;
}
Result.push_back(ParseValue(CurRec, ItemType));
- if (Result.back() == 0) return std::vector<Init*>();
+ if (Result.back() == 0) return std::vector<const Init*>();
while (Lex.getCode() == tgtok::comma) {
Lex.Lex(); // Eat the comma
@@ -1429,7 +1431,7 @@ std::vector<Init*> TGParser::ParseValueList(Record *CurRec, Record *ArgsRec,
const std::vector<std::string> &TArgs = ArgsRec->getTemplateArgs();
if (ArgN >= TArgs.size()) {
TokError("too many template arguments");
- return std::vector<Init*>();
+ return std::vector<const Init*>();
}
const RecordVal *RV = ArgsRec->getValue(TArgs[ArgN]);
assert(RV && "Template argument record not found??");
@@ -1437,7 +1439,7 @@ std::vector<Init*> TGParser::ParseValueList(Record *CurRec, Record *ArgsRec,
++ArgN;
}
Result.push_back(ParseValue(CurRec, ItemType));
- if (Result.back() == 0) return std::vector<Init*>();
+ if (Result.back() == 0) return std::vector<const Init*>();
}
return Result;
@@ -1490,7 +1492,7 @@ std::string TGParser::ParseDeclaration(Record *CurRec,
if (Lex.getCode() == tgtok::equal) {
Lex.Lex();
SMLoc ValLoc = Lex.getLoc();
- Init *Val = ParseValue(CurRec, Type);
+ const Init *Val = ParseValue(CurRec, Type);
if (Val == 0 ||
SetValue(CurRec, ValLoc, DeclName, std::vector<unsigned>(), Val))
return "";
@@ -1574,7 +1576,7 @@ bool TGParser::ParseBodyItem(Record *CurRec) {
RecTy *Type = Field->getType();
- Init *Val = ParseValue(CurRec, Type);
+ const Init *Val = ParseValue(CurRec, Type);
if (Val == 0) return true;
if (Lex.getCode() != tgtok::semi)
@@ -1774,7 +1776,7 @@ std::vector<LetRecord> TGParser::ParseLetList() {
}
Lex.Lex(); // eat the '='.
- Init *Val = ParseValue(0);
+ const Init *Val = ParseValue(0);
if (Val == 0) return std::vector<LetRecord>();
// Now that we have everything, add the record.
@@ -1948,7 +1950,7 @@ bool TGParser::ParseDefm(MultiClass *CurMultiClass) {
// template parameters.
MultiClass *MC = MultiClasses[Ref.Rec->getName()];
assert(MC && "Didn't lookup multiclass correctly?");
- std::vector<Init*> &TemplateVals = Ref.TemplateArgs;
+ std::vector<const Init*> &TemplateVals = Ref.TemplateArgs;
// Verify that the correct number of template arguments were specified.
const std::vector<std::string> &TArgs = MC->Rec.getTemplateArgs();