From 90fd797dc739319347861d4f3984bc8952ae9a29 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 6 Nov 2010 19:57:21 +0000 Subject: add (and document) the ability for alias results to have fixed physical registers. Start moving fp comparison aliases to the .td file (which default to using %st1 if nothing is specified). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118352 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/CodeGenInstruction.cpp | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'utils/TableGen/CodeGenInstruction.cpp') diff --git a/utils/TableGen/CodeGenInstruction.cpp b/utils/TableGen/CodeGenInstruction.cpp index 924608cbf0..84a8b9137e 100644 --- a/utils/TableGen/CodeGenInstruction.cpp +++ b/utils/TableGen/CodeGenInstruction.cpp @@ -419,6 +419,30 @@ CodeGenInstAlias::CodeGenInstAlias(Record *R, CodeGenTarget &T) : TheDef(R) { Init *Arg = Result->getArg(AliasOpNo); + Record *ResultOpRec = ResultInst->Operands[i].Rec; + + // Handle explicit registers. + if (DefInit *ADI = dynamic_cast(Arg)) { + if (ADI->getDef()->isSubClassOf("Register")) { + if (!Result->getArgName(AliasOpNo).empty()) + throw TGError(R->getLoc(), "result fixed register argument must " + "not have a name!"); + + if (!ResultOpRec->isSubClassOf("RegisterClass")) + throw TGError(R->getLoc(), "result fixed register argument is not " + "passed to a RegisterClass operand!"); + + if (!T.getRegisterClass(ResultOpRec).containsRegister(ADI->getDef())) + throw TGError(R->getLoc(), "fixed register " +ADI->getDef()->getName() + + " is not a member of the " + ResultOpRec->getName() + + " register class!"); + + // Now that it is validated, add it. + ResultOperands.push_back(ResultOperand(ADI->getDef())); + ++AliasOpNo; + continue; + } + } // If the operand is a record, it must have a name, and the record type must // match up with the instruction's argument type. @@ -427,11 +451,11 @@ CodeGenInstAlias::CodeGenInstAlias(Record *R, CodeGenTarget &T) : TheDef(R) { throw TGError(R->getLoc(), "result argument #" + utostr(AliasOpNo) + " must have a name!"); - if (ADI->getDef() != ResultInst->Operands[i].Rec) + if (ADI->getDef() != ResultOpRec) throw TGError(R->getLoc(), "result argument #" + utostr(AliasOpNo) + " declared with class " + ADI->getDef()->getName() + ", instruction operand is class " + - ResultInst->Operands[i].Rec->getName()); + ResultOpRec->getName()); // Verify we don't have something like: (someinst GR16:$foo, GR32:$foo) // $foo can exist multiple times in the result list, but it must have the @@ -456,9 +480,9 @@ CodeGenInstAlias::CodeGenInstAlias(Record *R, CodeGenTarget &T) : TheDef(R) { throw TGError(R->getLoc(), "result argument #" + utostr(AliasOpNo) + " must not have a name!"); if (ResultInst->Operands[i].MINumOperands != 1 || - !ResultInst->Operands[i].Rec->isSubClassOf("Operand")) + !ResultOpRec->isSubClassOf("Operand")) throw TGError(R->getLoc(), "invalid argument class " + - ResultInst->Operands[i].Rec->getName() + + ResultOpRec->getName() + " for integer result operand!"); ResultOperands.push_back(ResultOperand(II->getValue())); ++AliasOpNo; -- cgit v1.2.3