diff options
author | Jim Grosbach <grosbach@apple.com> | 2010-10-11 18:25:51 +0000 |
---|---|---|
committer | Jim Grosbach <grosbach@apple.com> | 2010-10-11 18:25:51 +0000 |
commit | 191ad7c473b506280cb24ade7d0ab25ae63a2594 (patch) | |
tree | d4f06e389af4939fe5afcf790b784986185cb115 /llvm/utils/TableGen/CodeEmitterGen.cpp | |
parent | 2f6531eb8cec7cb918245377229b29578b52564c (diff) | |
download | bcm5719-llvm-191ad7c473b506280cb24ade7d0ab25ae63a2594.tar.gz bcm5719-llvm-191ad7c473b506280cb24ade7d0ab25ae63a2594.zip |
When figuring out which operands match which encoding fields in an instruction,
try to match them by name first. If there is no by-name match, fall back to
assuming they are in order (this was the previous behavior).
llvm-svn: 116211
Diffstat (limited to 'llvm/utils/TableGen/CodeEmitterGen.cpp')
-rw-r--r-- | llvm/utils/TableGen/CodeEmitterGen.cpp | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/llvm/utils/TableGen/CodeEmitterGen.cpp b/llvm/utils/TableGen/CodeEmitterGen.cpp index a039e0b1e35..1a967e9742c 100644 --- a/llvm/utils/TableGen/CodeEmitterGen.cpp +++ b/llvm/utils/TableGen/CodeEmitterGen.cpp @@ -128,7 +128,7 @@ void CodeEmitterGen::run(raw_ostream &o) { // Loop over all of the fields in the instruction, determining which are the // operands to the instruction. - unsigned op = 0; + unsigned NumberedOp = 0; for (unsigned i = 0, e = Vals.size(); i != e; ++i) { if (!Vals[i].getPrefix() && !Vals[i].getValue()->isComplete()) { // Is the operand continuous? If so, we can just mask and OR it in @@ -154,14 +154,25 @@ void CodeEmitterGen::run(raw_ostream &o) { } if (!gotOp) { - /// If this operand is not supposed to be emitted by the generated - /// emitter, skip it. - while (CGI.isFlatOperandNotEmitted(op)) - ++op; + + // If the operand matches by name, reference according to that + // operand number. Non-matching operands are assumed to be in + // order. + unsigned OpIdx; + if (CGI.hasOperandNamed(VarName, OpIdx)) { + assert (!CGI.isFlatOperandNotEmitted(OpIdx) && + "Explicitly used operand also marked as not emitted!"); + } else { + /// If this operand is not supposed to be emitted by the + /// generated emitter, skip it. + while (CGI.isFlatOperandNotEmitted(NumberedOp)) + ++NumberedOp; + OpIdx = NumberedOp++; + } Case += " // op: " + VarName + "\n" + " op = getMachineOpValue(MI, MI.getOperand(" - + utostr(op++) + "));\n"; + + utostr(OpIdx) + "));\n"; gotOp = true; } |