summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2008-08-28 18:06:12 +0000
committerOwen Anderson <resistor@mac.com>2008-08-28 18:06:12 +0000
commitb5dbcb538b2ecfde2c94a1981301ac9beea3ea3c (patch)
tree773da24a92c92d238354543373aefb22e17e4153 /utils
parent97efa365869d3b7b62836434585360a232836f0e (diff)
downloadllvm-b5dbcb538b2ecfde2c94a1981301ac9beea3ea3c.tar.gz
llvm-b5dbcb538b2ecfde2c94a1981301ac9beea3ea3c.tar.bz2
llvm-b5dbcb538b2ecfde2c94a1981301ac9beea3ea3c.tar.xz
Add support for fast-isel of opcodes that require use of extract_subreg. Because of how extract_subreg is treated, it requires special case handling.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55480 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r--utils/TableGen/FastISelEmitter.cpp64
1 files changed, 43 insertions, 21 deletions
diff --git a/utils/TableGen/FastISelEmitter.cpp b/utils/TableGen/FastISelEmitter.cpp
index 967054a161..305158f471 100644
--- a/utils/TableGen/FastISelEmitter.cpp
+++ b/utils/TableGen/FastISelEmitter.cpp
@@ -172,6 +172,7 @@ struct OperandsSignature {
struct InstructionMemo {
std::string Name;
const CodeGenRegisterClass *RC;
+ unsigned char SubRegNo;
};
class FastISelMap {
@@ -235,12 +236,19 @@ void FastISelMap::CollectPatterns(CodeGenDAGPatterns &CGP) {
// For now, ignore instructions where the first operand is not an
// output register.
- Record *Op0Rec = II.OperandList[0].Rec;
- if (!Op0Rec->isSubClassOf("RegisterClass"))
- continue;
- const CodeGenRegisterClass *DstRC = &Target.getRegisterClass(Op0Rec);
- if (!DstRC)
- continue;
+ const CodeGenRegisterClass *DstRC = 0;
+ unsigned SubRegNo = ~0;
+ if (Op->getName() != "EXTRACT_SUBREG") {
+ Record *Op0Rec = II.OperandList[0].Rec;
+ if (!Op0Rec->isSubClassOf("RegisterClass"))
+ continue;
+ DstRC = &Target.getRegisterClass(Op0Rec);
+ if (!DstRC)
+ continue;
+ } else {
+ SubRegNo = static_cast<IntInit*>(
+ Dst->getChild(1)->getLeafValue())->getValue();
+ }
// Inspect the pattern.
TreePatternNode *InstPatNode = Pattern.getSrcPattern();
@@ -274,7 +282,8 @@ void FastISelMap::CollectPatterns(CodeGenDAGPatterns &CGP) {
// Ok, we found a pattern that we can handle. Remember it.
InstructionMemo Memo = {
Pattern.getDstPattern()->getOperator()->getName(),
- DstRC
+ DstRC,
+ SubRegNo
};
assert(!SimplePatterns[Operands][OpcodeName][VT][RetVT].count(PredicateCheck) &&
"Duplicate pattern!");
@@ -410,13 +419,19 @@ void FastISelMap::PrintFunctionDefinitions(std::ostream &OS) {
HasPred = true;
}
OS << " return FastEmitInst_";
- Operands.PrintManglingSuffix(OS);
- OS << "(" << InstNS << Memo.Name << ", ";
- OS << InstNS << Memo.RC->getName() << "RegisterClass";
- if (!Operands.empty())
- OS << ", ";
- Operands.PrintArguments(OS);
- OS << ");\n";
+ if (Memo.SubRegNo == (unsigned char)~0) {
+ Operands.PrintManglingSuffix(OS);
+ OS << "(" << InstNS << Memo.Name << ", ";
+ OS << InstNS << Memo.RC->getName() << "RegisterClass";
+ if (!Operands.empty())
+ OS << ", ";
+ Operands.PrintArguments(OS);
+ OS << ");\n";
+ } else {
+ OS << "extractsubreg(Op0, ";
+ OS << (unsigned)Memo.SubRegNo;
+ OS << ");\n";
+ }
}
// Return 0 if none of the predicates were satisfied.
if (HasPred)
@@ -482,13 +497,20 @@ void FastISelMap::PrintFunctionDefinitions(std::ostream &OS) {
HasPred = true;
}
OS << " return FastEmitInst_";
- Operands.PrintManglingSuffix(OS);
- OS << "(" << InstNS << Memo.Name << ", ";
- OS << InstNS << Memo.RC->getName() << "RegisterClass";
- if (!Operands.empty())
- OS << ", ";
- Operands.PrintArguments(OS);
- OS << ");\n";
+
+ if (Memo.SubRegNo == (unsigned char)~0) {
+ Operands.PrintManglingSuffix(OS);
+ OS << "(" << InstNS << Memo.Name << ", ";
+ OS << InstNS << Memo.RC->getName() << "RegisterClass";
+ if (!Operands.empty())
+ OS << ", ";
+ Operands.PrintArguments(OS);
+ OS << ");\n";
+ } else {
+ OS << "extractsubreg(Op0, ";
+ OS << (unsigned)Memo.SubRegNo;
+ OS << ");\n";
+ }
}
// Return 0 if none of the predicates were satisfied.