summaryrefslogtreecommitdiffstats
path: root/llvm/lib/TableGen
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/TableGen')
-rw-r--r--llvm/lib/TableGen/Record.cpp27
-rw-r--r--llvm/lib/TableGen/TGParser.cpp25
2 files changed, 25 insertions, 27 deletions
diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp
index 8c2f5a1dcd3..f84a917de79 100644
--- a/llvm/lib/TableGen/Record.cpp
+++ b/llvm/lib/TableGen/Record.cpp
@@ -678,9 +678,7 @@ Init *UnOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const {
if (IntInit *LHSi = dyn_cast<IntInit>(LHS))
return StringInit::get(LHSi->getAsString());
} else {
- if (StringInit *LHSs = dyn_cast<StringInit>(LHS)) {
- StringRef Name = LHSs->getValue();
-
+ if (StringInit *Name = dyn_cast<StringInit>(LHS)) {
// From TGParser::ParseIDValue
if (CurRec) {
if (const RecordVal *RV = CurRec->getValue(Name)) {
@@ -718,11 +716,11 @@ Init *UnOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const {
}
}
assert(CurRec && "NULL pointer");
- if (Record *D = (CurRec->getRecords()).getDef(Name))
+ if (Record *D = (CurRec->getRecords()).getDef(Name->getValue()))
return DefInit::get(D);
PrintFatalError(CurRec->getLoc(),
- "Undefined reference:'" + Name + "'\n");
+ "Undefined reference:'" + Name->getValue() + "'\n");
}
if (isa<IntRecTy>(getType())) {
@@ -1175,7 +1173,7 @@ std::string TernOpInit::getAsString() const {
RHS->getAsString() + ")";
}
-RecTy *TypedInit::getFieldType(StringRef FieldName) const {
+RecTy *TypedInit::getFieldType(StringInit *FieldName) const {
if (RecordRecTy *RecordType = dyn_cast<RecordRecTy>(getType()))
if (RecordVal *Field = RecordType->getRecord()->getValue(FieldName))
return Field->getType();
@@ -1348,7 +1346,7 @@ Init *VarInit::resolveListElementReference(Record &R,
return nullptr;
}
-RecTy *VarInit::getFieldType(StringRef FieldName) const {
+RecTy *VarInit::getFieldType(StringInit *FieldName) const {
if (RecordRecTy *RTy = dyn_cast<RecordRecTy>(getType()))
if (const RecordVal *RV = RTy->getRecord()->getValue(FieldName))
return RV->getType();
@@ -1356,7 +1354,7 @@ RecTy *VarInit::getFieldType(StringRef FieldName) const {
}
Init *VarInit::getFieldInit(Record &R, const RecordVal *RV,
- StringRef FieldName) const {
+ StringInit *FieldName) const {
if (isa<RecordRecTy>(getType()))
if (const RecordVal *Val = R.getValue(VarName)) {
if (RV != Val && (RV || isa<UnsetInit>(Val->getValue())))
@@ -1464,14 +1462,14 @@ Init *DefInit::convertInitializerTo(RecTy *Ty) const {
return nullptr;
}
-RecTy *DefInit::getFieldType(StringRef FieldName) const {
+RecTy *DefInit::getFieldType(StringInit *FieldName) const {
if (const RecordVal *RV = Def->getValue(FieldName))
return RV->getType();
return nullptr;
}
Init *DefInit::getFieldInit(Record &R, const RecordVal *RV,
- StringRef FieldName) const {
+ StringInit *FieldName) const {
return Def->getValue(FieldName)->getValue();
}
@@ -1479,8 +1477,8 @@ std::string DefInit::getAsString() const {
return Def->getName();
}
-FieldInit *FieldInit::get(Init *R, StringRef FN) {
- typedef std::pair<Init *, TableGenStringKey> Key;
+FieldInit *FieldInit::get(Init *R, StringInit *FN) {
+ typedef std::pair<Init *, StringInit *> Key;
static DenseMap<Key, FieldInit*> ThePool;
Key TheKey(std::make_pair(R, FN));
@@ -1965,8 +1963,3 @@ Init *llvm::QualifyName(Record &CurRec, MultiClass *CurMultiClass,
NewName = BinOp->Fold(&CurRec, CurMultiClass);
return NewName;
}
-
-Init *llvm::QualifyName(Record &CurRec, MultiClass *CurMultiClass,
- StringRef Name, StringRef Scoper) {
- return QualifyName(CurRec, CurMultiClass, StringInit::get(Name), Scoper);
-}
diff --git a/llvm/lib/TableGen/TGParser.cpp b/llvm/lib/TableGen/TGParser.cpp
index 3d0e4875f96..5b8d730942b 100644
--- a/llvm/lib/TableGen/TGParser.cpp
+++ b/llvm/lib/TableGen/TGParser.cpp
@@ -717,14 +717,16 @@ RecTy *TGParser::ParseType() {
/// has already been read.
Init *TGParser::ParseIDValue(Record *CurRec, StringRef Name, SMLoc NameLoc,
IDParseMode Mode) {
+ StringInit *NameInit;
if (CurRec) {
if (const RecordVal *RV = CurRec->getValue(Name))
return VarInit::get(Name, RV->getType());
- Init *TemplateArgName = QualifyName(*CurRec, CurMultiClass, Name, ":");
+ NameInit = StringInit::get(Name);
+ Init *TemplateArgName = QualifyName(*CurRec, CurMultiClass, NameInit, ":");
if (CurMultiClass)
- TemplateArgName = QualifyName(CurMultiClass->Rec, CurMultiClass, Name,
+ TemplateArgName = QualifyName(CurMultiClass->Rec, CurMultiClass, NameInit,
"::");
if (CurRec->isTemplateArg(TemplateArgName)) {
@@ -732,10 +734,11 @@ Init *TGParser::ParseIDValue(Record *CurRec, StringRef Name, SMLoc NameLoc,
assert(RV && "Template arg doesn't exist??");
return VarInit::get(TemplateArgName, RV->getType());
}
- }
+ } else
+ NameInit = StringInit::get(Name);
if (CurMultiClass) {
- Init *MCName = QualifyName(CurMultiClass->Rec, CurMultiClass, Name,
+ Init *MCName = QualifyName(CurMultiClass->Rec, CurMultiClass, NameInit,
"::");
if (CurMultiClass->Rec.isTemplateArg(MCName)) {
@@ -748,12 +751,12 @@ Init *TGParser::ParseIDValue(Record *CurRec, StringRef Name, SMLoc NameLoc,
// If this is in a foreach loop, make sure it's not a loop iterator
for (const auto &L : Loops) {
VarInit *IterVar = dyn_cast<VarInit>(L.IterVar);
- if (IterVar && IterVar->getName() == Name)
+ if (IterVar && IterVar->getNameInit() == NameInit)
return IterVar;
}
if (Mode == ParseNameMode)
- return StringInit::get(Name);
+ return NameInit;
if (Record *D = Records.getDef(Name))
return DefInit::get(D);
@@ -763,7 +766,7 @@ Init *TGParser::ParseIDValue(Record *CurRec, StringRef Name, SMLoc NameLoc,
return nullptr;
}
- return StringInit::get(Name);
+ return NameInit;
}
/// ParseOperation - Parse an operator. This returns null on error.
@@ -1525,19 +1528,21 @@ Init *TGParser::ParseValue(Record *CurRec, RecTy *ItemType, IDParseMode Mode) {
Lex.Lex();
break;
}
- case tgtok::period:
+ case tgtok::period: {
if (Lex.Lex() != tgtok::Id) { // eat the .
TokError("expected field identifier after '.'");
return nullptr;
}
- if (!Result->getFieldType(Lex.getCurStrVal())) {
+ StringInit *FieldName = StringInit::get(Lex.getCurStrVal());
+ if (!Result->getFieldType(FieldName)) {
TokError("Cannot access field '" + Lex.getCurStrVal() + "' of value '" +
Result->getAsString() + "'");
return nullptr;
}
- Result = FieldInit::get(Result, Lex.getCurStrVal());
+ Result = FieldInit::get(Result, FieldName);
Lex.Lex(); // eat field name
break;
+ }
case tgtok::paste:
SMLoc PasteLoc = Lex.getLoc();
OpenPOWER on IntegriCloud