mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-07 11:51:13 +00:00
TableGen: Some more std::string->StringInit* replacements
llvm-svn: 288653
This commit is contained in:
parent
38cd0376b5
commit
f4f8cc9e75
@ -1231,7 +1231,7 @@ public:
|
|||||||
RecordVal(StringRef N, RecTy *T, bool P);
|
RecordVal(StringRef N, RecTy *T, bool P);
|
||||||
|
|
||||||
StringRef getName() const;
|
StringRef getName() const;
|
||||||
const Init *getNameInit() const { return Name; }
|
Init *getNameInit() const { return Name; }
|
||||||
|
|
||||||
std::string getNameInitAsString() const {
|
std::string getNameInitAsString() const {
|
||||||
return getNameInit()->getAsUnquotedString();
|
return getNameInit()->getAsUnquotedString();
|
||||||
|
@ -1702,10 +1702,10 @@ raw_ostream &llvm::operator<<(raw_ostream &OS, const Record &R) {
|
|||||||
OS << "\n";
|
OS << "\n";
|
||||||
|
|
||||||
for (const RecordVal &Val : R.getValues())
|
for (const RecordVal &Val : R.getValues())
|
||||||
if (Val.getPrefix() && !R.isTemplateArg(Val.getName()))
|
if (Val.getPrefix() && !R.isTemplateArg(Val.getNameInit()))
|
||||||
OS << Val;
|
OS << Val;
|
||||||
for (const RecordVal &Val : R.getValues())
|
for (const RecordVal &Val : R.getValues())
|
||||||
if (!Val.getPrefix() && !R.isTemplateArg(Val.getName()))
|
if (!Val.getPrefix() && !R.isTemplateArg(Val.getNameInit()))
|
||||||
OS << Val;
|
OS << Val;
|
||||||
|
|
||||||
return OS << "}\n";
|
return OS << "}\n";
|
||||||
|
@ -339,14 +339,14 @@ bool TGParser::ProcessForeachDefs(Record *CurRec, SMLoc Loc, IterSet &IterVals){
|
|||||||
|
|
||||||
IterRec->addValue(RecordVal(IterVar->getName(), IVal->getType(), false));
|
IterRec->addValue(RecordVal(IterVar->getName(), IVal->getType(), false));
|
||||||
|
|
||||||
if (SetValue(IterRec.get(), Loc, IterVar->getName(), None, IVal))
|
if (SetValue(IterRec.get(), Loc, IterVar->getNameInit(), None, IVal))
|
||||||
return Error(Loc, "when instantiating this def");
|
return Error(Loc, "when instantiating this def");
|
||||||
|
|
||||||
// Resolve it next.
|
// Resolve it next.
|
||||||
IterRec->resolveReferencesTo(IterRec->getValue(IterVar->getName()));
|
IterRec->resolveReferencesTo(IterRec->getValue(IterVar->getNameInit()));
|
||||||
|
|
||||||
// Remove it.
|
// Remove it.
|
||||||
IterRec->removeValue(IterVar->getName());
|
IterRec->removeValue(IterVar->getNameInit());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Records.getDef(IterRec->getNameInitAsString())) {
|
if (Records.getDef(IterRec->getNameInitAsString())) {
|
||||||
@ -716,18 +716,16 @@ RecTy *TGParser::ParseType() {
|
|||||||
|
|
||||||
/// ParseIDValue - This is just like ParseIDValue above, but it assumes the ID
|
/// ParseIDValue - This is just like ParseIDValue above, but it assumes the ID
|
||||||
/// has already been read.
|
/// has already been read.
|
||||||
Init *TGParser::ParseIDValue(Record *CurRec, StringRef Name, SMLoc NameLoc,
|
Init *TGParser::ParseIDValue(Record *CurRec, StringInit *Name, SMLoc NameLoc,
|
||||||
IDParseMode Mode) {
|
IDParseMode Mode) {
|
||||||
StringInit *NameInit;
|
|
||||||
if (CurRec) {
|
if (CurRec) {
|
||||||
if (const RecordVal *RV = CurRec->getValue(Name))
|
if (const RecordVal *RV = CurRec->getValue(Name))
|
||||||
return VarInit::get(Name, RV->getType());
|
return VarInit::get(Name, RV->getType());
|
||||||
|
|
||||||
NameInit = StringInit::get(Name);
|
Init *TemplateArgName = QualifyName(*CurRec, CurMultiClass, Name, ":");
|
||||||
Init *TemplateArgName = QualifyName(*CurRec, CurMultiClass, NameInit, ":");
|
|
||||||
|
|
||||||
if (CurMultiClass)
|
if (CurMultiClass)
|
||||||
TemplateArgName = QualifyName(CurMultiClass->Rec, CurMultiClass, NameInit,
|
TemplateArgName = QualifyName(CurMultiClass->Rec, CurMultiClass, Name,
|
||||||
"::");
|
"::");
|
||||||
|
|
||||||
if (CurRec->isTemplateArg(TemplateArgName)) {
|
if (CurRec->isTemplateArg(TemplateArgName)) {
|
||||||
@ -735,12 +733,10 @@ Init *TGParser::ParseIDValue(Record *CurRec, StringRef Name, SMLoc NameLoc,
|
|||||||
assert(RV && "Template arg doesn't exist??");
|
assert(RV && "Template arg doesn't exist??");
|
||||||
return VarInit::get(TemplateArgName, RV->getType());
|
return VarInit::get(TemplateArgName, RV->getType());
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
NameInit = StringInit::get(Name);
|
|
||||||
|
|
||||||
if (CurMultiClass) {
|
if (CurMultiClass) {
|
||||||
Init *MCName = QualifyName(CurMultiClass->Rec, CurMultiClass, NameInit,
|
Init *MCName = QualifyName(CurMultiClass->Rec, CurMultiClass, Name, "::");
|
||||||
"::");
|
|
||||||
|
|
||||||
if (CurMultiClass->Rec.isTemplateArg(MCName)) {
|
if (CurMultiClass->Rec.isTemplateArg(MCName)) {
|
||||||
const RecordVal *RV = CurMultiClass->Rec.getValue(MCName);
|
const RecordVal *RV = CurMultiClass->Rec.getValue(MCName);
|
||||||
@ -752,22 +748,22 @@ Init *TGParser::ParseIDValue(Record *CurRec, StringRef Name, SMLoc NameLoc,
|
|||||||
// If this is in a foreach loop, make sure it's not a loop iterator
|
// If this is in a foreach loop, make sure it's not a loop iterator
|
||||||
for (const auto &L : Loops) {
|
for (const auto &L : Loops) {
|
||||||
VarInit *IterVar = dyn_cast<VarInit>(L.IterVar);
|
VarInit *IterVar = dyn_cast<VarInit>(L.IterVar);
|
||||||
if (IterVar && IterVar->getNameInit() == NameInit)
|
if (IterVar && IterVar->getNameInit() == Name)
|
||||||
return IterVar;
|
return IterVar;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Mode == ParseNameMode)
|
if (Mode == ParseNameMode)
|
||||||
return NameInit;
|
return Name;
|
||||||
|
|
||||||
if (Record *D = Records.getDef(Name))
|
if (Record *D = Records.getDef(Name->getValue()))
|
||||||
return DefInit::get(D);
|
return DefInit::get(D);
|
||||||
|
|
||||||
if (Mode == ParseValueMode) {
|
if (Mode == ParseValueMode) {
|
||||||
Error(NameLoc, "Variable not defined: '" + Name + "'");
|
Error(NameLoc, "Variable not defined: '" + Name->getValue() + "'");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NameInit;
|
return Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ParseOperation - Parse an operator. This returns null on error.
|
/// ParseOperation - Parse an operator. This returns null on error.
|
||||||
@ -1187,7 +1183,7 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType,
|
|||||||
break;
|
break;
|
||||||
case tgtok::Id: {
|
case tgtok::Id: {
|
||||||
SMLoc NameLoc = Lex.getLoc();
|
SMLoc NameLoc = Lex.getLoc();
|
||||||
std::string Name = Lex.getCurStrVal();
|
StringInit *Name = StringInit::get(Lex.getCurStrVal());
|
||||||
if (Lex.Lex() != tgtok::less) // consume the Id.
|
if (Lex.Lex() != tgtok::less) // consume the Id.
|
||||||
return ParseIDValue(CurRec, Name, NameLoc, Mode); // Value ::= IDValue
|
return ParseIDValue(CurRec, Name, NameLoc, Mode); // Value ::= IDValue
|
||||||
|
|
||||||
@ -1200,9 +1196,9 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType,
|
|||||||
// This is a CLASS<initvalslist> expression. This is supposed to synthesize
|
// This is a CLASS<initvalslist> expression. This is supposed to synthesize
|
||||||
// a new anonymous definition, deriving from CLASS<initvalslist> with no
|
// a new anonymous definition, deriving from CLASS<initvalslist> with no
|
||||||
// body.
|
// body.
|
||||||
Record *Class = Records.getClass(Name);
|
Record *Class = Records.getClass(Name->getValue());
|
||||||
if (!Class) {
|
if (!Class) {
|
||||||
Error(NameLoc, "Expected a class name, got '" + Name + "'");
|
Error(NameLoc, "Expected a class name, got '" + Name->getValue() + "'");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1891,7 +1887,7 @@ bool TGParser::ParseBodyItem(Record *CurRec) {
|
|||||||
return TokError("expected field identifier after let");
|
return TokError("expected field identifier after let");
|
||||||
|
|
||||||
SMLoc IdLoc = Lex.getLoc();
|
SMLoc IdLoc = Lex.getLoc();
|
||||||
std::string FieldName = Lex.getCurStrVal();
|
StringInit *FieldName = StringInit::get(Lex.getCurStrVal());
|
||||||
Lex.Lex(); // eat the field name.
|
Lex.Lex(); // eat the field name.
|
||||||
|
|
||||||
SmallVector<unsigned, 16> BitList;
|
SmallVector<unsigned, 16> BitList;
|
||||||
@ -1905,7 +1901,7 @@ bool TGParser::ParseBodyItem(Record *CurRec) {
|
|||||||
|
|
||||||
RecordVal *Field = CurRec->getValue(FieldName);
|
RecordVal *Field = CurRec->getValue(FieldName);
|
||||||
if (!Field)
|
if (!Field)
|
||||||
return TokError("Value '" + FieldName + "' unknown!");
|
return TokError("Value '" + FieldName->getValue() + "' unknown!");
|
||||||
|
|
||||||
RecTy *Type = Field->getType();
|
RecTy *Type = Field->getType();
|
||||||
|
|
||||||
@ -2169,7 +2165,7 @@ void TGParser::ParseLetList(SmallVectorImpl<LetRecord> &Result) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Name = Lex.getCurStrVal();
|
StringInit *Name = StringInit::get(Lex.getCurStrVal());
|
||||||
SMLoc NameLoc = Lex.getLoc();
|
SMLoc NameLoc = Lex.getLoc();
|
||||||
Lex.Lex(); // Eat the identifier.
|
Lex.Lex(); // Eat the identifier.
|
||||||
|
|
||||||
@ -2195,7 +2191,7 @@ void TGParser::ParseLetList(SmallVectorImpl<LetRecord> &Result) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now that we have everything, add the record.
|
// Now that we have everything, add the record.
|
||||||
Result.emplace_back(std::move(Name), Bits, Val, NameLoc);
|
Result.emplace_back(Name, Bits, Val, NameLoc);
|
||||||
|
|
||||||
if (Lex.getCode() != tgtok::comma)
|
if (Lex.getCode() != tgtok::comma)
|
||||||
return;
|
return;
|
||||||
@ -2382,8 +2378,8 @@ Record *TGParser::InstantiateMulticlassDef(MultiClass &MC, Record *DefProto,
|
|||||||
// Set the value for NAME. We don't resolve references to it 'til later,
|
// Set the value for NAME. We don't resolve references to it 'til later,
|
||||||
// though, so that uses in nested multiclass names don't get
|
// though, so that uses in nested multiclass names don't get
|
||||||
// confused.
|
// confused.
|
||||||
if (SetValue(CurRec.get(), Ref.RefRange.Start, "NAME", None, DefmPrefix,
|
if (SetValue(CurRec.get(), Ref.RefRange.Start, StringInit::get("NAME"), None,
|
||||||
/*AllowSelfAssignment*/true)) {
|
DefmPrefix, /*AllowSelfAssignment*/true)) {
|
||||||
Error(DefmPrefixRange.Start, "Could not resolve " +
|
Error(DefmPrefixRange.Start, "Could not resolve " +
|
||||||
CurRec->getNameInitAsString() + ":NAME to '" +
|
CurRec->getNameInitAsString() + ":NAME to '" +
|
||||||
DefmPrefix->getAsUnquotedString() + "'");
|
DefmPrefix->getAsUnquotedString() + "'");
|
||||||
|
@ -32,11 +32,11 @@ namespace llvm {
|
|||||||
struct SubMultiClassReference;
|
struct SubMultiClassReference;
|
||||||
|
|
||||||
struct LetRecord {
|
struct LetRecord {
|
||||||
std::string Name;
|
StringInit *Name;
|
||||||
std::vector<unsigned> Bits;
|
std::vector<unsigned> Bits;
|
||||||
Init *Value;
|
Init *Value;
|
||||||
SMLoc Loc;
|
SMLoc Loc;
|
||||||
LetRecord(StringRef N, ArrayRef<unsigned> B, Init *V, SMLoc L)
|
LetRecord(StringInit *N, ArrayRef<unsigned> B, Init *V, SMLoc L)
|
||||||
: Name(N), Bits(B), Value(V), Loc(L) {
|
: Name(N), Bits(B), Value(V), Loc(L) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -106,12 +106,6 @@ private: // Semantic analysis methods.
|
|||||||
bool SetValue(Record *TheRec, SMLoc Loc, Init *ValName,
|
bool SetValue(Record *TheRec, SMLoc Loc, Init *ValName,
|
||||||
ArrayRef<unsigned> BitList, Init *V,
|
ArrayRef<unsigned> BitList, Init *V,
|
||||||
bool AllowSelfAssignment = false);
|
bool AllowSelfAssignment = false);
|
||||||
bool SetValue(Record *TheRec, SMLoc Loc, StringRef ValName,
|
|
||||||
ArrayRef<unsigned> BitList, Init *V,
|
|
||||||
bool AllowSelfAssignment = false) {
|
|
||||||
return SetValue(TheRec, Loc, StringInit::get(ValName), BitList, V,
|
|
||||||
AllowSelfAssignment);
|
|
||||||
}
|
|
||||||
bool AddSubClass(Record *Rec, SubClassReference &SubClass);
|
bool AddSubClass(Record *Rec, SubClassReference &SubClass);
|
||||||
bool AddSubMultiClass(MultiClass *CurMC,
|
bool AddSubMultiClass(MultiClass *CurMC,
|
||||||
SubMultiClassReference &SubMultiClass);
|
SubMultiClassReference &SubMultiClass);
|
||||||
@ -166,7 +160,7 @@ private: // Parser methods.
|
|||||||
SubClassReference ParseSubClassReference(Record *CurRec, bool isDefm);
|
SubClassReference ParseSubClassReference(Record *CurRec, bool isDefm);
|
||||||
SubMultiClassReference ParseSubMultiClassReference(MultiClass *CurMC);
|
SubMultiClassReference ParseSubMultiClassReference(MultiClass *CurMC);
|
||||||
|
|
||||||
Init *ParseIDValue(Record *CurRec, StringRef Name, SMLoc NameLoc,
|
Init *ParseIDValue(Record *CurRec, StringInit *Name, SMLoc NameLoc,
|
||||||
IDParseMode Mode = ParseValueMode);
|
IDParseMode Mode = ParseValueMode);
|
||||||
Init *ParseSimpleValue(Record *CurRec, RecTy *ItemType = nullptr,
|
Init *ParseSimpleValue(Record *CurRec, RecTy *ItemType = nullptr,
|
||||||
IDParseMode Mode = ParseValueMode);
|
IDParseMode Mode = ParseValueMode);
|
||||||
|
Loading…
Reference in New Issue
Block a user