mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-13 22:24:07 +00:00
TableGen: record anonymous instantiations of classes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172084 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -1393,6 +1393,7 @@ class Record {
|
|||||||
RecordKeeper &TrackedRecords;
|
RecordKeeper &TrackedRecords;
|
||||||
|
|
||||||
DefInit *TheInit;
|
DefInit *TheInit;
|
||||||
|
bool IsAnonymous;
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
void checkName();
|
void checkName();
|
||||||
@ -1401,14 +1402,15 @@ public:
|
|||||||
|
|
||||||
// Constructs a record.
|
// Constructs a record.
|
||||||
explicit Record(const std::string &N, ArrayRef<SMLoc> locs,
|
explicit Record(const std::string &N, ArrayRef<SMLoc> locs,
|
||||||
RecordKeeper &records) :
|
RecordKeeper &records, bool Anonymous = false) :
|
||||||
ID(LastID++), Name(StringInit::get(N)), Locs(locs.begin(), locs.end()),
|
ID(LastID++), Name(StringInit::get(N)), Locs(locs.begin(), locs.end()),
|
||||||
TrackedRecords(records), TheInit(0) {
|
TrackedRecords(records), TheInit(0), IsAnonymous(Anonymous) {
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
explicit Record(Init *N, ArrayRef<SMLoc> locs, RecordKeeper &records) :
|
explicit Record(Init *N, ArrayRef<SMLoc> locs, RecordKeeper &records,
|
||||||
|
bool Anonymous = false) :
|
||||||
ID(LastID++), Name(N), Locs(locs.begin(), locs.end()),
|
ID(LastID++), Name(N), Locs(locs.begin(), locs.end()),
|
||||||
TrackedRecords(records), TheInit(0) {
|
TrackedRecords(records), TheInit(0), IsAnonymous(Anonymous) {
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1417,7 +1419,8 @@ public:
|
|||||||
Record(const Record &O) :
|
Record(const Record &O) :
|
||||||
ID(LastID++), Name(O.Name), Locs(O.Locs), TemplateArgs(O.TemplateArgs),
|
ID(LastID++), Name(O.Name), Locs(O.Locs), TemplateArgs(O.TemplateArgs),
|
||||||
Values(O.Values), SuperClasses(O.SuperClasses),
|
Values(O.Values), SuperClasses(O.SuperClasses),
|
||||||
TrackedRecords(O.TrackedRecords), TheInit(O.TheInit) { }
|
TrackedRecords(O.TrackedRecords), TheInit(O.TheInit),
|
||||||
|
IsAnonymous(O.IsAnonymous) { }
|
||||||
|
|
||||||
~Record() {}
|
~Record() {}
|
||||||
|
|
||||||
@ -1541,6 +1544,10 @@ public:
|
|||||||
return TrackedRecords;
|
return TrackedRecords;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isAnonymous() const {
|
||||||
|
return IsAnonymous;
|
||||||
|
}
|
||||||
|
|
||||||
void dump() const;
|
void dump() const;
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
|
@ -383,7 +383,7 @@ static std::string GetNewAnonymousName() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// ParseObjectName - If an object name is specified, return it. Otherwise,
|
/// ParseObjectName - If an object name is specified, return it. Otherwise,
|
||||||
/// return an anonymous name.
|
/// return 0.
|
||||||
/// ObjectName ::= Value [ '#' Value ]*
|
/// ObjectName ::= Value [ '#' Value ]*
|
||||||
/// ObjectName ::= /*empty*/
|
/// ObjectName ::= /*empty*/
|
||||||
///
|
///
|
||||||
@ -395,7 +395,7 @@ Init *TGParser::ParseObjectName(MultiClass *CurMultiClass) {
|
|||||||
// These are all of the tokens that can begin an object body.
|
// These are all of the tokens that can begin an object body.
|
||||||
// Some of these can also begin values but we disallow those cases
|
// Some of these can also begin values but we disallow those cases
|
||||||
// because they are unlikely to be useful.
|
// because they are unlikely to be useful.
|
||||||
return StringInit::get(GetNewAnonymousName());
|
return 0;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1204,7 +1204,8 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType,
|
|||||||
static unsigned AnonCounter = 0;
|
static unsigned AnonCounter = 0;
|
||||||
Record *NewRec = new Record("anonymous.val."+utostr(AnonCounter++),
|
Record *NewRec = new Record("anonymous.val."+utostr(AnonCounter++),
|
||||||
NameLoc,
|
NameLoc,
|
||||||
Records);
|
Records,
|
||||||
|
/*IsAnonymous=*/true);
|
||||||
SubClassReference SCRef;
|
SubClassReference SCRef;
|
||||||
SCRef.RefLoc = NameLoc;
|
SCRef.RefLoc = NameLoc;
|
||||||
SCRef.Rec = Class;
|
SCRef.Rec = Class;
|
||||||
@ -1919,7 +1920,13 @@ bool TGParser::ParseDef(MultiClass *CurMultiClass) {
|
|||||||
Lex.Lex(); // Eat the 'def' token.
|
Lex.Lex(); // Eat the 'def' token.
|
||||||
|
|
||||||
// Parse ObjectName and make a record for it.
|
// Parse ObjectName and make a record for it.
|
||||||
Record *CurRec = new Record(ParseObjectName(CurMultiClass), DefLoc, Records);
|
Record *CurRec;
|
||||||
|
Init *Name = ParseObjectName(CurMultiClass);
|
||||||
|
if (Name)
|
||||||
|
CurRec = new Record(Name, DefLoc, Records);
|
||||||
|
else
|
||||||
|
CurRec = new Record(GetNewAnonymousName(), DefLoc, Records,
|
||||||
|
/*IsAnonymous=*/true);
|
||||||
|
|
||||||
if (!CurMultiClass && Loops.empty()) {
|
if (!CurMultiClass && Loops.empty()) {
|
||||||
// Top-level def definition.
|
// Top-level def definition.
|
||||||
@ -2248,8 +2255,11 @@ InstantiateMulticlassDef(MultiClass &MC,
|
|||||||
// name, substitute the prefix for #NAME#. Otherwise, use the defm name
|
// name, substitute the prefix for #NAME#. Otherwise, use the defm name
|
||||||
// as a prefix.
|
// as a prefix.
|
||||||
|
|
||||||
if (DefmPrefix == 0)
|
bool IsAnonymous = false;
|
||||||
|
if (DefmPrefix == 0) {
|
||||||
DefmPrefix = StringInit::get(GetNewAnonymousName());
|
DefmPrefix = StringInit::get(GetNewAnonymousName());
|
||||||
|
IsAnonymous = true;
|
||||||
|
}
|
||||||
|
|
||||||
Init *DefName = DefProto->getNameInit();
|
Init *DefName = DefProto->getNameInit();
|
||||||
|
|
||||||
@ -2268,7 +2278,7 @@ InstantiateMulticlassDef(MultiClass &MC,
|
|||||||
// Make a trail of SMLocs from the multiclass instantiations.
|
// Make a trail of SMLocs from the multiclass instantiations.
|
||||||
SmallVector<SMLoc, 4> Locs(1, DefmPrefixLoc);
|
SmallVector<SMLoc, 4> Locs(1, DefmPrefixLoc);
|
||||||
Locs.append(DefProto->getLoc().begin(), DefProto->getLoc().end());
|
Locs.append(DefProto->getLoc().begin(), DefProto->getLoc().end());
|
||||||
Record *CurRec = new Record(DefName, Locs, Records);
|
Record *CurRec = new Record(DefName, Locs, Records, IsAnonymous);
|
||||||
|
|
||||||
SubClassReference Ref;
|
SubClassReference Ref;
|
||||||
Ref.RefLoc = DefmPrefixLoc;
|
Ref.RefLoc = DefmPrefixLoc;
|
||||||
|
Reference in New Issue
Block a user