Fix a subtle multiclass bug: when using class inheritance on

a toplevel 'defm', make sure to properly resolve references.

llvm-svn: 106570
This commit is contained in:
Bruno Cardoso Lopes 2010-06-22 20:30:50 +00:00
parent 7e35d39fee
commit dc883cf45a
2 changed files with 6 additions and 4 deletions

View File

@ -16,6 +16,7 @@ class BaseI {
class I<bits<4> op> : BaseI {
bits<4> opcode = op;
int val = !if(!eq(Prefix, xd.Prefix), 7, 21);
int check = !if(hasVEX_4VPrefix, 0, 10);
}
multiclass R {
@ -33,4 +34,5 @@ multiclass Y {
defm SD : R, M, XS;
}
// CHECK: int check = 0;
defm Instr : Y, VEX;

View File

@ -2020,7 +2020,6 @@ bool TGParser::ParseDefm(MultiClass *CurMultiClass) {
}
} else {
Records.addDef(CurRec);
CurRec->resolveReferences();
}
NewRecDefs.push_back(CurRec);
@ -2064,9 +2063,6 @@ bool TGParser::ParseDefm(MultiClass *CurMultiClass) {
if (SetValue(CurRec, LetStack[i][j].Loc, LetStack[i][j].Name,
LetStack[i][j].Bits, LetStack[i][j].Value))
return true;
if (!CurMultiClass)
CurRec->resolveReferences();
}
if (Lex.getCode() != tgtok::comma) break;
@ -2075,6 +2071,10 @@ bool TGParser::ParseDefm(MultiClass *CurMultiClass) {
}
}
if (!CurMultiClass)
for (unsigned i = 0, e = NewRecDefs.size(); i != e; ++i)
NewRecDefs[i]->resolveReferences();
if (Lex.getCode() != tgtok::semi)
return TokError("expected ';' at end of defm");
Lex.Lex();