summaryrefslogtreecommitdiff
path: root/utils/TableGen/CodeEmitterGen.cpp
diff options
context:
space:
mode:
authorJim Grosbach <grosbach@apple.com>2010-10-12 22:21:57 +0000
committerJim Grosbach <grosbach@apple.com>2010-10-12 22:21:57 +0000
commit5013f7469ec44adba127de65517e699180ee532f (patch)
treeddf704f7ba1a25a5b3c1b7bdad0f34dced014f9a /utils/TableGen/CodeEmitterGen.cpp
parent174777bb2b0a1896afb5dc5ff96a91d162d00149 (diff)
downloadllvm-5013f7469ec44adba127de65517e699180ee532f.tar.gz
llvm-5013f7469ec44adba127de65517e699180ee532f.tar.bz2
llvm-5013f7469ec44adba127de65517e699180ee532f.tar.xz
Allow targets to optionally specify custom binary encoder functions for
operand values. This is useful for operands which require additional trickery to encode into the instruction. For example, the ARM shifted immediate and shifted register operands. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116353 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/CodeEmitterGen.cpp')
-rw-r--r--utils/TableGen/CodeEmitterGen.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/utils/TableGen/CodeEmitterGen.cpp b/utils/TableGen/CodeEmitterGen.cpp
index 64ea16e362..b7b62d502b 100644
--- a/utils/TableGen/CodeEmitterGen.cpp
+++ b/utils/TableGen/CodeEmitterGen.cpp
@@ -154,7 +154,6 @@ void CodeEmitterGen::run(raw_ostream &o) {
}
if (!gotOp) {
-
// If the operand matches by name, reference according to that
// operand number. Non-matching operands are assumed to be in
// order.
@@ -171,10 +170,26 @@ void CodeEmitterGen::run(raw_ostream &o) {
++NumberedOp;
OpIdx = NumberedOp++;
}
-
- Case += " // op: " + VarName + "\n"
- + " op = getMachineOpValue(MI, MI.getOperand("
- + utostr(OpIdx) + "));\n";
+ std::pair<unsigned, unsigned> SO = CGI.getSubOperandNumber(OpIdx);
+ std::string &EncoderMethodName =
+ CGI.OperandList[SO.first].EncoderMethodName;
+
+ // If the source operand has a custom encoder, use it. This will
+ // get the encoding for all of the suboperands.
+ if (!EncoderMethodName.empty()) {
+ // A custom encoder has all of the information for the
+ // sub-operands, if there are more than one, so only
+ // query the encoder once per source operand.
+ if (SO.second == 0) {
+ Case += " // op: " + VarName + "\n"
+ + " op = " + EncoderMethodName + "(MI, "
+ + utostr(OpIdx) + ");\n";
+ }
+ } else {
+ Case += " // op: " + VarName + "\n"
+ + " op = getMachineOpValue(MI, MI.getOperand("
+ + utostr(OpIdx) + "));\n";
+ }
gotOp = true;
}