xref: /freebsd/contrib/llvm-project/llvm/lib/Target/AMDGPU/EXPInstructions.td (revision 77013d11e6483b970af25e13c9b892075742f7e5)
1//===-- EXPInstructions.td - Export Instruction Definitions ---------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9//===----------------------------------------------------------------------===//
10// EXP classes
11//===----------------------------------------------------------------------===//
12
13class EXPCommon<bit done, string asm = ""> : InstSI<
14  (outs),
15  (ins exp_tgt:$tgt,
16       ExpSrc0:$src0, ExpSrc1:$src1, ExpSrc2:$src2, ExpSrc3:$src3,
17       exp_vm:$vm, exp_compr:$compr, i32imm:$en),
18  asm> {
19  let EXP = 1;
20  let EXP_CNT = 1;
21  let mayLoad = done;
22  let mayStore = 1;
23  let UseNamedOperandTable = 1;
24  let Uses = [EXEC];
25  let SchedRW = [WriteExport];
26  let DisableWQM = 1;
27}
28
29class EXP_Pseudo<bit done> : EXPCommon<done>,
30                             SIMCInstr <NAME, SIEncodingFamily.NONE> {
31  let isPseudo = 1;
32  let isCodeGenOnly = 1;
33}
34
35class EXP_Real<bit done, string pseudo, int subtarget>
36  : EXPCommon<done, "exp$tgt $src0, $src1, $src2, $src3"#!if(done, " done", "")
37                    #"$compr$vm">,
38    SIMCInstr <pseudo, subtarget> {
39  let AsmMatchConverter = "cvtExp";
40}
41
42//===----------------------------------------------------------------------===//
43// EXP Instructions
44//===----------------------------------------------------------------------===//
45
46// Split EXP instruction into EXP and EXP_DONE so we can set
47// mayLoad for done=1.
48def EXP : EXP_Pseudo<0>;
49def EXP_DONE : EXP_Pseudo<1>;
50
51//===----------------------------------------------------------------------===//
52// SI
53//===----------------------------------------------------------------------===//
54
55class EXP_Real_si<bit _done, string pseudo>
56  : EXP_Real<_done, pseudo, SIEncodingFamily.SI>, EXPe {
57  let AssemblerPredicate = isGFX6GFX7;
58  let DecoderNamespace = "GFX6GFX7";
59  let done = _done;
60}
61
62def EXP_si      : EXP_Real_si<0, "EXP">;
63def EXP_DONE_si : EXP_Real_si<1, "EXP_DONE">;
64
65//===----------------------------------------------------------------------===//
66// VI
67//===----------------------------------------------------------------------===//
68
69class EXP_Real_vi<bit _done, string pseudo>
70  : EXP_Real<_done, pseudo, SIEncodingFamily.VI>, EXPe_vi {
71  let AssemblerPredicate = isGFX8GFX9;
72  let DecoderNamespace = "GFX8";
73  let done = _done;
74}
75
76def EXP_vi      : EXP_Real_vi<0, "EXP">;
77def EXP_DONE_vi : EXP_Real_vi<1, "EXP_DONE">;
78
79//===----------------------------------------------------------------------===//
80// GFX10+
81//===----------------------------------------------------------------------===//
82
83class EXP_Real_gfx10<bit _done, string pseudo>
84  : EXP_Real<_done, pseudo, SIEncodingFamily.GFX10>, EXPe {
85  let AssemblerPredicate = isGFX10Plus;
86  let DecoderNamespace = "GFX10";
87  let done = _done;
88}
89
90def EXP_gfx10      : EXP_Real_gfx10<0, "EXP">;
91def EXP_DONE_gfx10 : EXP_Real_gfx10<1, "EXP_DONE">;
92
93//===----------------------------------------------------------------------===//
94// EXP Patterns
95//===----------------------------------------------------------------------===//
96
97class ExpPattern<ValueType vt, Instruction Inst, int done_val> : GCNPat<
98  (int_amdgcn_exp timm:$tgt, timm:$en,
99                  (vt ExpSrc0:$src0), (vt ExpSrc1:$src1),
100                  (vt ExpSrc2:$src2), (vt ExpSrc3:$src3),
101                  done_val, timm:$vm),
102  (Inst timm:$tgt, ExpSrc0:$src0, ExpSrc1:$src1,
103        ExpSrc2:$src2, ExpSrc3:$src3, timm:$vm, 0, timm:$en)
104>;
105
106class ExpComprPattern<ValueType vt, Instruction Inst, int done_val> : GCNPat<
107  (int_amdgcn_exp_compr timm:$tgt, timm:$en,
108                        (vt ExpSrc0:$src0), (vt ExpSrc1:$src1),
109                        done_val, timm:$vm),
110  (Inst timm:$tgt, ExpSrc0:$src0, ExpSrc1:$src1,
111        (IMPLICIT_DEF), (IMPLICIT_DEF), timm:$vm, 1, timm:$en)
112>;
113
114// FIXME: The generated DAG matcher seems to have strange behavior
115// with a 1-bit literal to match, so use a -1 for checking a true
116// 1-bit value.
117def : ExpPattern<i32, EXP, 0>;
118def : ExpPattern<i32, EXP_DONE, -1>;
119def : ExpPattern<f32, EXP, 0>;
120def : ExpPattern<f32, EXP_DONE, -1>;
121
122def : ExpComprPattern<v2i16, EXP, 0>;
123def : ExpComprPattern<v2i16, EXP_DONE, -1>;
124def : ExpComprPattern<v2f16, EXP, 0>;
125def : ExpComprPattern<v2f16, EXP_DONE, -1>;
126