@@ -339,14 +339,14 @@ bool TGParser::ProcessForeachDefs(Record *CurRec, SMLoc Loc, IterSet &IterVals){
339
339
340
340
IterRec->addValue (RecordVal (IterVar->getName (), IVal->getType (), false ));
341
341
342
- if (SetValue (IterRec.get (), Loc, IterVar->getName (), None, IVal))
342
+ if (SetValue (IterRec.get (), Loc, IterVar->getNameInit (), None, IVal))
343
343
return Error (Loc, " when instantiating this def" );
344
344
345
345
// Resolve it next.
346
- IterRec->resolveReferencesTo (IterRec->getValue (IterVar->getName ()));
346
+ IterRec->resolveReferencesTo (IterRec->getValue (IterVar->getNameInit ()));
347
347
348
348
// Remove it.
349
- IterRec->removeValue (IterVar->getName ());
349
+ IterRec->removeValue (IterVar->getNameInit ());
350
350
}
351
351
352
352
if (Records.getDef (IterRec->getNameInitAsString ())) {
@@ -716,31 +716,27 @@ RecTy *TGParser::ParseType() {
716
716
717
717
// / ParseIDValue - This is just like ParseIDValue above, but it assumes the ID
718
718
// / has already been read.
719
- Init *TGParser::ParseIDValue (Record *CurRec, StringRef Name, SMLoc NameLoc,
719
+ Init *TGParser::ParseIDValue (Record *CurRec, StringInit * Name, SMLoc NameLoc,
720
720
IDParseMode Mode) {
721
- StringInit *NameInit;
722
721
if (CurRec) {
723
722
if (const RecordVal *RV = CurRec->getValue (Name))
724
723
return VarInit::get (Name, RV->getType ());
725
724
726
- NameInit = StringInit::get (Name);
727
- Init *TemplateArgName = QualifyName (*CurRec, CurMultiClass, NameInit, " :" );
725
+ Init *TemplateArgName = QualifyName (*CurRec, CurMultiClass, Name, " :" );
728
726
729
727
if (CurMultiClass)
730
- TemplateArgName = QualifyName (CurMultiClass->Rec , CurMultiClass, NameInit ,
728
+ TemplateArgName = QualifyName (CurMultiClass->Rec , CurMultiClass, Name ,
731
729
" ::" );
732
730
733
731
if (CurRec->isTemplateArg (TemplateArgName)) {
734
732
const RecordVal *RV = CurRec->getValue (TemplateArgName);
735
733
assert (RV && " Template arg doesn't exist??" );
736
734
return VarInit::get (TemplateArgName, RV->getType ());
737
735
}
738
- } else
739
- NameInit = StringInit::get (Name);
736
+ }
740
737
741
738
if (CurMultiClass) {
742
- Init *MCName = QualifyName (CurMultiClass->Rec , CurMultiClass, NameInit,
743
- " ::" );
739
+ Init *MCName = QualifyName (CurMultiClass->Rec , CurMultiClass, Name, " ::" );
744
740
745
741
if (CurMultiClass->Rec .isTemplateArg (MCName)) {
746
742
const RecordVal *RV = CurMultiClass->Rec .getValue (MCName);
@@ -752,22 +748,22 @@ Init *TGParser::ParseIDValue(Record *CurRec, StringRef Name, SMLoc NameLoc,
752
748
// If this is in a foreach loop, make sure it's not a loop iterator
753
749
for (const auto &L : Loops) {
754
750
VarInit *IterVar = dyn_cast<VarInit>(L.IterVar );
755
- if (IterVar && IterVar->getNameInit () == NameInit )
751
+ if (IterVar && IterVar->getNameInit () == Name )
756
752
return IterVar;
757
753
}
758
754
759
755
if (Mode == ParseNameMode)
760
- return NameInit ;
756
+ return Name ;
761
757
762
- if (Record *D = Records.getDef (Name))
758
+ if (Record *D = Records.getDef (Name-> getValue () ))
763
759
return DefInit::get (D);
764
760
765
761
if (Mode == ParseValueMode) {
766
- Error (NameLoc, " Variable not defined: '" + Name + " '" );
762
+ Error (NameLoc, " Variable not defined: '" + Name-> getValue () + " '" );
767
763
return nullptr ;
768
764
}
769
765
770
- return NameInit ;
766
+ return Name ;
771
767
}
772
768
773
769
// / ParseOperation - Parse an operator. This returns null on error.
@@ -1187,7 +1183,7 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType,
1187
1183
break ;
1188
1184
case tgtok::Id: {
1189
1185
SMLoc NameLoc = Lex.getLoc ();
1190
- std::string Name = Lex.getCurStrVal ();
1186
+ StringInit * Name = StringInit::get ( Lex.getCurStrVal () );
1191
1187
if (Lex.Lex () != tgtok::less) // consume the Id.
1192
1188
return ParseIDValue (CurRec, Name, NameLoc, Mode); // Value ::= IDValue
1193
1189
@@ -1200,9 +1196,9 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType,
1200
1196
// This is a CLASS<initvalslist> expression. This is supposed to synthesize
1201
1197
// a new anonymous definition, deriving from CLASS<initvalslist> with no
1202
1198
// body.
1203
- Record *Class = Records.getClass (Name);
1199
+ Record *Class = Records.getClass (Name-> getValue () );
1204
1200
if (!Class) {
1205
- Error (NameLoc, " Expected a class name, got '" + Name + " '" );
1201
+ Error (NameLoc, " Expected a class name, got '" + Name-> getValue () + " '" );
1206
1202
return nullptr ;
1207
1203
}
1208
1204
@@ -1891,7 +1887,7 @@ bool TGParser::ParseBodyItem(Record *CurRec) {
1891
1887
return TokError (" expected field identifier after let" );
1892
1888
1893
1889
SMLoc IdLoc = Lex.getLoc ();
1894
- std::string FieldName = Lex.getCurStrVal ();
1890
+ StringInit * FieldName = StringInit::get ( Lex.getCurStrVal () );
1895
1891
Lex.Lex (); // eat the field name.
1896
1892
1897
1893
SmallVector<unsigned , 16 > BitList;
@@ -1905,7 +1901,7 @@ bool TGParser::ParseBodyItem(Record *CurRec) {
1905
1901
1906
1902
RecordVal *Field = CurRec->getValue (FieldName);
1907
1903
if (!Field)
1908
- return TokError (" Value '" + FieldName + " ' unknown!" );
1904
+ return TokError (" Value '" + FieldName-> getValue () + " ' unknown!" );
1909
1905
1910
1906
RecTy *Type = Field->getType ();
1911
1907
@@ -2169,7 +2165,7 @@ void TGParser::ParseLetList(SmallVectorImpl<LetRecord> &Result) {
2169
2165
return ;
2170
2166
}
2171
2167
2172
- std::string Name = Lex.getCurStrVal ();
2168
+ StringInit * Name = StringInit::get ( Lex.getCurStrVal () );
2173
2169
SMLoc NameLoc = Lex.getLoc ();
2174
2170
Lex.Lex (); // Eat the identifier.
2175
2171
@@ -2195,7 +2191,7 @@ void TGParser::ParseLetList(SmallVectorImpl<LetRecord> &Result) {
2195
2191
}
2196
2192
2197
2193
// Now that we have everything, add the record.
2198
- Result.emplace_back (std::move ( Name) , Bits, Val, NameLoc);
2194
+ Result.emplace_back (Name, Bits, Val, NameLoc);
2199
2195
2200
2196
if (Lex.getCode () != tgtok::comma)
2201
2197
return ;
@@ -2382,8 +2378,8 @@ Record *TGParser::InstantiateMulticlassDef(MultiClass &MC, Record *DefProto,
2382
2378
// Set the value for NAME. We don't resolve references to it 'til later,
2383
2379
// though, so that uses in nested multiclass names don't get
2384
2380
// confused.
2385
- if (SetValue (CurRec.get (), Ref.RefRange .Start , " NAME" , None, DefmPrefix ,
2386
- /* AllowSelfAssignment*/ true )) {
2381
+ if (SetValue (CurRec.get (), Ref.RefRange .Start , StringInit::get ( " NAME" ) , None,
2382
+ DefmPrefix, /* AllowSelfAssignment*/ true )) {
2387
2383
Error (DefmPrefixRange.Start , " Could not resolve " +
2388
2384
CurRec->getNameInitAsString () + " :NAME to '" +
2389
2385
DefmPrefix->getAsUnquotedString () + " '" );
0 commit comments