llvm.org GIT mirror llvm / d122009
TableGen: record anonymous instantiations of classes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172084 91177308-0d34-0410-b5e6-96231b3b80d8 Jordan Rose 7 years ago
2 changed file(s) with 28 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
13921392 RecordKeeper &TrackedRecords;
13931393
13941394 DefInit *TheInit;
1395 bool IsAnonymous;
13951396
13961397 void init();
13971398 void checkName();
14001401
14011402 // Constructs a record.
14021403 explicit Record(const std::string &N, ArrayRef locs,
1403 RecordKeeper &records) :
1404 RecordKeeper &records, bool Anonymous = false) :
14041405 ID(LastID++), Name(StringInit::get(N)), Locs(locs.begin(), locs.end()),
1405 TrackedRecords(records), TheInit(0) {
1406 TrackedRecords(records), TheInit(0), IsAnonymous(Anonymous) {
14061407 init();
14071408 }
1408 explicit Record(Init *N, ArrayRef locs, RecordKeeper &records) :
1409 explicit Record(Init *N, ArrayRef locs, RecordKeeper &records,
1410 bool Anonymous = false) :
14091411 ID(LastID++), Name(N), Locs(locs.begin(), locs.end()),
1410 TrackedRecords(records), TheInit(0) {
1412 TrackedRecords(records), TheInit(0), IsAnonymous(Anonymous) {
14111413 init();
14121414 }
14131415
14161418 Record(const Record &O) :
14171419 ID(LastID++), Name(O.Name), Locs(O.Locs), TemplateArgs(O.TemplateArgs),
14181420 Values(O.Values), SuperClasses(O.SuperClasses),
1419 TrackedRecords(O.TrackedRecords), TheInit(O.TheInit) { }
1421 TrackedRecords(O.TrackedRecords), TheInit(O.TheInit),
1422 IsAnonymous(O.IsAnonymous) { }
14201423
14211424 ~Record() {}
14221425
15401543 return TrackedRecords;
15411544 }
15421545
1546 bool isAnonymous() const {
1547 return IsAnonymous;
1548 }
1549
15431550 void dump() const;
15441551
15451552 //===--------------------------------------------------------------------===//
382382 }
383383
384384 /// ParseObjectName - If an object name is specified, return it. Otherwise,
385 /// return an anonymous name.
385 /// return 0.
386386 /// ObjectName ::= Value [ '#' Value ]*
387387 /// ObjectName ::= /*empty*/
388388 ///
394394 // These are all of the tokens that can begin an object body.
395395 // Some of these can also begin values but we disallow those cases
396396 // because they are unlikely to be useful.
397 return StringInit::get(GetNewAnonymousName());
397 return 0;
398398 default:
399399 break;
400400 }
12031203 static unsigned AnonCounter = 0;
12041204 Record *NewRec = new Record("anonymous.val."+utostr(AnonCounter++),
12051205 NameLoc,
1206 Records);
1206 Records,
1207 /*IsAnonymous=*/true);
12071208 SubClassReference SCRef;
12081209 SCRef.RefLoc = NameLoc;
12091210 SCRef.Rec = Class;
19181919 Lex.Lex(); // Eat the 'def' token.
19191920
19201921 // Parse ObjectName and make a record for it.
1921 Record *CurRec = new Record(ParseObjectName(CurMultiClass), DefLoc, Records);
1922 Record *CurRec;
1923 Init *Name = ParseObjectName(CurMultiClass);
1924 if (Name)
1925 CurRec = new Record(Name, DefLoc, Records);
1926 else
1927 CurRec = new Record(GetNewAnonymousName(), DefLoc, Records,
1928 /*IsAnonymous=*/true);
19221929
19231930 if (!CurMultiClass && Loops.empty()) {
19241931 // Top-level def definition.
22472254 // name, substitute the prefix for #NAME#. Otherwise, use the defm name
22482255 // as a prefix.
22492256
2250 if (DefmPrefix == 0)
2257 bool IsAnonymous = false;
2258 if (DefmPrefix == 0) {
22512259 DefmPrefix = StringInit::get(GetNewAnonymousName());
2260 IsAnonymous = true;
2261 }
22522262
22532263 Init *DefName = DefProto->getNameInit();
22542264
22672277 // Make a trail of SMLocs from the multiclass instantiations.
22682278 SmallVector Locs(1, DefmPrefixLoc);
22692279 Locs.append(DefProto->getLoc().begin(), DefProto->getLoc().end());
2270 Record *CurRec = new Record(DefName, Locs, Records);
2280 Record *CurRec = new Record(DefName, Locs, Records, IsAnonymous);
22712281
22722282 SubClassReference Ref;
22732283 Ref.RefLoc = DefmPrefixLoc;