summaryrefslogtreecommitdiff
path: root/utils/TableGen/CodeGenInstruction.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-11-06 19:57:21 +0000
committerChris Lattner <sabre@nondot.org>2010-11-06 19:57:21 +0000
commit90fd797dc739319347861d4f3984bc8952ae9a29 (patch)
tree606f6e49e3dc37ec32c49d07519667df46bba585 /utils/TableGen/CodeGenInstruction.cpp
parent8d5acb7007decaf0c30bf4a3d4c55e5cc2cce0a7 (diff)
downloadllvm-90fd797dc739319347861d4f3984bc8952ae9a29.tar.gz
llvm-90fd797dc739319347861d4f3984bc8952ae9a29.tar.bz2
llvm-90fd797dc739319347861d4f3984bc8952ae9a29.tar.xz
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
Diffstat (limited to 'utils/TableGen/CodeGenInstruction.cpp')
-rw-r--r--utils/TableGen/CodeGenInstruction.cpp32
1 files changed, 28 insertions, 4 deletions
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<DefInit*>(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;