aboutsummaryrefslogtreecommitdiff
path: root/test/TableGen
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@intel.com>2018-12-05 00:47:59 +0000
committerCraig Topper <craig.topper@intel.com>2018-12-05 00:47:59 +0000
commit0f562feb0b1fa9157d0bb5027ce066d3db229c88 (patch)
tree43c18ad15a725887f6ca5ff73bdd58c20f0cfc2c /test/TableGen
parentcdd2e8326ef898d280d53894bffa7b2d52e69721 (diff)
downloadllvm-0f562feb0b1fa9157d0bb5027ce066d3db229c88.tar.gz
[TableGen] Preserve order of output operands in DAGISelMatcherGen
Summary: This fixes support in DAGISelMatcher backend for DAG nodes with multiple result values. Previously the order of results in selected DAG nodes always matched the order of results in ISel patterns. After the change the order of results matches the order of operands in OutOperandList instead. For example, given this definition from the attached test case: def INSTR : Instruction { let OutOperandList = (outs GPR:$r1, GPR:$r0); let InOperandList = (ins GPR:$t0, GPR:$t1); let Pattern = [(set i32:$r0, i32:$r1, (udivrem i32:$t0, i32:$t1))]; } the DAGISelMatcher backend currently produces a matcher that creates INSTR nodes with the first result `$r0` and the second result `$r1`, contrary to the order in the OutOperandList. The order of operands in OutOperandList does not matter at all, which is unexpected (and unfortunate) because the order of results of a DAG node does matters, perhaps a lot. With this change, if the order in OutOperandList does not match the order in Pattern, DAGISelMatcherGen emits CompleteMatch opcodes with the order of results taken from OutOperandList. Backend writers can use it to express result reorderings in TableGen. If the order in OutOperandList matches the order in Pattern, the result of DAGISelMatcherGen is unaffected. Patch by Eugene Sharygin Reviewers: andreadb, bjope, hfinkel, RKSimon, craig.topper Reviewed By: craig.topper Subscribers: nhaehnle, craig.topper, llvm-commits Differential Revision: https://reviews.llvm.org/D55055 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@348326 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/TableGen')
-rw-r--r--test/TableGen/dag-isel-res-order.td22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/TableGen/dag-isel-res-order.td b/test/TableGen/dag-isel-res-order.td
new file mode 100644
index 00000000000..4da6b6d6867
--- /dev/null
+++ b/test/TableGen/dag-isel-res-order.td
@@ -0,0 +1,22 @@
+// RUN: llvm-tblgen -gen-dag-isel -I %p/../../include %s | FileCheck %s
+
+include "llvm/Target/Target.td"
+
+def TestTargetInstrInfo : InstrInfo;
+
+def TestTarget : Target {
+ let InstructionSet = TestTargetInstrInfo;
+}
+
+def REG : Register<"REG">;
+def GPR : RegisterClass<"TestTarget", [i32], 32, (add REG)>;
+
+// CHECK-LABEL: OPC_CheckOpcode, TARGET_VAL(ISD::UDIVREM)
+// CHECK: OPC_EmitNode2, TARGET_VAL(::INSTR)
+// CHECK: Results = #2 #3
+// CHECK: OPC_CompleteMatch, 2, 3, 2
+def INSTR : Instruction {
+ let OutOperandList = (outs GPR:$r1, GPR:$r0);
+ let InOperandList = (ins GPR:$t0, GPR:$t1);
+ let Pattern = [(set i32:$r0, i32:$r1, (udivrem i32:$t0, i32:$t1))];
+}