[llvm] [llvm][TableGen] Allow physical registers in patterns for GlobalISel emitter (PR #113127)
Sergei Barannikov via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 29 23:48:51 PDT 2024
================
@@ -3,10 +3,34 @@
include "llvm/Target/Target.td"
include "GlobalISelEmitterCommon.td"
-// CHECK: Skipped pattern: Pattern defines a physical register
let Uses = [B0], Defs = [B0] in
def tst1 : I<(outs), (ins), [(set B0, (add B0, 1))]>;
-// CHECK: Skipped pattern: Src pattern result has 1 def(s) without the HasNoUse predicate set to true but Dst MI has no def
+// CHECK: Skipped pattern: unhandled discarded def
let Uses = [B0] in
def tst2 : I<(outs), (ins), [(set B0, (add B0, 1))]>;
+
+// test courtesy @s-barannikov
+def SDTBinOpWithFlagsOut : SDTypeProfile<2, 2, [
+ SDTCisInt<0>, // result
+ SDTCisVT<1, i32>, // out flags
+ SDTCisSameAs<2, 0>, // lhs
+ SDTCisSameAs<3, 0> // rhs
+]>;
+
+def my_sub : SDNode<"MyTargetISD::SUB", SDTBinOpWithFlagsOut>;
+def my_ineg : PatFrag<(ops node:$val), (my_sub 0, node:$val)>;
+
+let Defs = [R1], Constraints = "$rd = $rs2" in
+def tst3 : I<(outs GPR32:$rd), (ins GPR32:$rs2), []>;
+
+// CHECK: Skipped pattern: Src pattern result has more defs than dst MI (2 def(s) vs 1 def(s))
+def : Pat<(my_ineg i32:$val), (tst3 i32:$val)>;
----------------
s-barannikov wrote:
The implicit def _is_ (or, at least, supposed to be) used for the second result of the custom node.
https://github.com/llvm/llvm-project/pull/113127
More information about the llvm-commits
mailing list