diff options
author | Jim Grosbach <grosbach@apple.com> | 2010-10-12 22:21:57 +0000 |
---|---|---|
committer | Jim Grosbach <grosbach@apple.com> | 2010-10-12 22:21:57 +0000 |
commit | 51a12eb11dcad334deed6cc3db8006a344291fee (patch) | |
tree | 0c6795f8be2044bd6157c6e342de987e58983599 /llvm/utils/TableGen/CodeEmitterGen.cpp | |
parent | 62d16fc738da59211f5d125a2d3a3ce671e8500b (diff) | |
download | llvm-51a12eb11dcad334deed6cc3db8006a344291fee.zip llvm-51a12eb11dcad334deed6cc3db8006a344291fee.tar.gz llvm-51a12eb11dcad334deed6cc3db8006a344291fee.tar.bz2 |
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.
llvm-svn: 116353
Diffstat (limited to 'llvm/utils/TableGen/CodeEmitterGen.cpp')
-rw-r--r-- | llvm/utils/TableGen/CodeEmitterGen.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/llvm/utils/TableGen/CodeEmitterGen.cpp b/llvm/utils/TableGen/CodeEmitterGen.cpp index 64ea16e..b7b62d5 100644 --- a/llvm/utils/TableGen/CodeEmitterGen.cpp +++ b/llvm/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; } |