blob: 768fba3f2fabdbbbf76cb890496417ce351b9cae [file] [log] [blame]
Tom Stellard1dc90202018-05-10 20:53:06 +00001//===-- AMDGPUGIsel.td - AMDGPU GlobalISel Patterns---------*- tablegen -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9// This files contains patterns that should only be used by GlobalISel. For
10// example patterns for V_* instructions that have S_* equivalents.
11// SelectionDAG does not support selecting V_* instructions.
12//===----------------------------------------------------------------------===//
13
14include "AMDGPU.td"
15
16def sd_vsrc0 : ComplexPattern<i32, 1, "">;
17def gi_vsrc0 :
18 GIComplexOperandMatcher<s32, "selectVSRC0">,
19 GIComplexPatternEquiv<sd_vsrc0>;
20
Tom Stellarddcc95e92018-05-11 05:44:16 +000021def gi_vop3mods0 :
22 GIComplexOperandMatcher<s32, "selectVOP3Mods0">,
23 GIComplexPatternEquiv<VOP3Mods0>;
24
Tom Stellard46bbbc32018-06-13 22:30:47 +000025def gi_vop3mods :
26 GIComplexOperandMatcher<s32, "selectVOP3Mods">,
27 GIComplexPatternEquiv<VOP3Mods>;
28
Tom Stellard1dc90202018-05-10 20:53:06 +000029class GISelSop2Pat <
30 SDPatternOperator node,
31 Instruction inst,
32 ValueType dst_vt,
33 ValueType src0_vt = dst_vt, ValueType src1_vt = src0_vt> : GCNPat <
34
35 (dst_vt (node (src0_vt SReg_32:$src0), (src1_vt SReg_32:$src1))),
36 (inst src0_vt:$src0, src1_vt:$src1)
37>;
38
39class GISelVop2Pat <
40 SDPatternOperator node,
41 Instruction inst,
42 ValueType dst_vt,
43 ValueType src0_vt = dst_vt, ValueType src1_vt = src0_vt> : GCNPat <
44
45 (dst_vt (node (src0_vt (sd_vsrc0 src0_vt:$src0)), (src1_vt VGPR_32:$src1))),
46 (inst src0_vt:$src0, src1_vt:$src1)
47>;
48
Tom Stellarda9284732018-06-14 19:26:37 +000049class GISelVop2CommutePat <
50 SDPatternOperator node,
51 Instruction inst,
52 ValueType dst_vt,
53 ValueType src0_vt = dst_vt, ValueType src1_vt = src0_vt> : GCNPat <
54
55 (dst_vt (node (src1_vt VGPR_32:$src1), (src0_vt (sd_vsrc0 src0_vt:$src0)))),
56 (inst src0_vt:$src0, src1_vt:$src1)
57>;
58
59multiclass GISelVop2IntrPat <
60 SDPatternOperator node, Instruction inst,
61 ValueType dst_vt, ValueType src_vt = dst_vt> {
62
63 def : GISelVop2Pat <node, inst, dst_vt, src_vt>;
64
65 // FIXME: Intrinsics aren't marked as commutable, so we need to add an explcit
66 // pattern to handle commuting. This is another reason why legalizing to a
67 // generic machine instruction may be better that matching the intrinsic
68 // directly.
69 def : GISelVop2CommutePat <node, inst, dst_vt, src_vt>;
70}
71
Tom Stellard1dc90202018-05-10 20:53:06 +000072def : GISelSop2Pat <or, S_OR_B32, i32>;
73def : GISelVop2Pat <or, V_OR_B32_e32, i32>;
Tom Stellarda9284732018-06-14 19:26:37 +000074
75// FIXME: Select directly to _e32 so we don't need to deal with modifiers.
76// FIXME: We can't re-use SelectionDAG patterns here because they match
77// against a custom SDNode and we would need to create a generic machine
78// instruction that is equivalent to the custom SDNode. This would also require
79// us to custom legalize the intrinsic to the new generic machine instruction,
80// but I can't get custom legalizing of intrinsic to work and I'm not sure if
81// this is even supported yet.
82defm : GISelVop2IntrPat <
83 int_amdgcn_cvt_pkrtz, V_CVT_PKRTZ_F16_F32_e32, v2f16, f32>;