mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-03 09:21:13 +00:00
Add support for automatically created anonymous definitions.
This implements Regression/TableGen/AnonDefinitionOnDemand.td git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23274 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d0d1d39541
commit
a1207a5add
@ -291,6 +291,34 @@ Value : INTVAL {
|
|||||||
}
|
}
|
||||||
|
|
||||||
delete $1;
|
delete $1;
|
||||||
|
} | ID '<' ValueListNE '>' {
|
||||||
|
// This is a CLASS<initvalslist> expression. This is supposed to synthesize
|
||||||
|
// a new anonymous definition, deriving from CLASS<initvalslist> with no
|
||||||
|
// body.
|
||||||
|
Record *Class = Records.getClass(*$1);
|
||||||
|
if (!Class) {
|
||||||
|
err() << "Expected a class, got '" << *$1 << "'!\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
delete $1;
|
||||||
|
|
||||||
|
static unsigned AnonCounter = 0;
|
||||||
|
Record *OldRec = CurRec; // Save CurRec.
|
||||||
|
|
||||||
|
// Create the new record, set it as CurRec temporarily.
|
||||||
|
CurRec = new Record("anonymous.val."+utostr(AnonCounter++));
|
||||||
|
addSubClass(Class, *$3); // Add info about the subclass to CurRec.
|
||||||
|
delete $3; // Free up the template args.
|
||||||
|
|
||||||
|
CurRec->resolveReferences();
|
||||||
|
|
||||||
|
Records.addDef(CurRec);
|
||||||
|
|
||||||
|
// The result of the expression is a reference to the new record.
|
||||||
|
$$ = new DefInit(CurRec);
|
||||||
|
|
||||||
|
// Restore the old CurRec
|
||||||
|
CurRec = OldRec;
|
||||||
} | Value '{' BitList '}' {
|
} | Value '{' BitList '}' {
|
||||||
$$ = $1->convertInitializerBitRange(*$3);
|
$$ = $1->convertInitializerBitRange(*$3);
|
||||||
if ($$ == 0) {
|
if ($$ == 0) {
|
||||||
@ -543,12 +571,13 @@ ClassInst : CLASS ObjectBody {
|
|||||||
DefInst : DEF ObjectBody {
|
DefInst : DEF ObjectBody {
|
||||||
$2->resolveReferences();
|
$2->resolveReferences();
|
||||||
|
|
||||||
|
// If ObjectBody has template arguments, it's an error.
|
||||||
if (!$2->getTemplateArgs().empty()) {
|
if (!$2->getTemplateArgs().empty()) {
|
||||||
err() << "Def '" << $2->getName()
|
err() << "Def '" << $2->getName()
|
||||||
<< "' is not permitted to have template arguments!\n";
|
<< "' is not permitted to have template arguments!\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
// If ObjectBody has template arguments, it's an error.
|
// Ensure redefinition doesn't happen.
|
||||||
if (Records.getDef($2->getName())) {
|
if (Records.getDef($2->getName())) {
|
||||||
err() << "Def '" << $2->getName() << "' already defined!\n";
|
err() << "Def '" << $2->getName() << "' already defined!\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user