1//===-- LDSDIRInstructions.td - LDS Direct 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// LDSDIR encoding
11//===----------------------------------------------------------------------===//
12
13class LDSDIRe<bits<2> op, bit is_direct> : Enc32 {
14  // encoding fields
15  bits<2> attrchan;
16  bits<6> attr;
17  bits<4> waitvdst;
18  bits<8> vdst;
19
20  // encoding
21  let Inst{31-24} = 0xce; // encoding
22  let Inst{23-22} = 0x0; // reserved
23  let Inst{21-20} = op;
24  let Inst{19-16} = waitvdst;
25  let Inst{15-10} = !if(is_direct, ?, attr);
26  let Inst{9-8} = !if(is_direct, ?, attrchan);
27  let Inst{7-0} = vdst;
28}
29
30//===----------------------------------------------------------------------===//
31// LDSDIR Classes
32//===----------------------------------------------------------------------===//
33
34class LDSDIR_getIns<bit direct> {
35  dag ret = !if(direct,
36    (ins wait_vdst:$waitvdst),
37    (ins Attr:$attr, AttrChan:$attrchan, wait_vdst:$waitvdst)
38  );
39}
40
41class LDSDIR_Common<string opName, string asm = "", bit direct> : InstSI<
42    (outs VGPR_32:$vdst),
43    LDSDIR_getIns<direct>.ret,
44    asm> {
45  let LDSDIR = 1;
46  let EXP_CNT = 1;
47
48  let hasSideEffects = 0;
49  let mayLoad = 1;
50  let mayStore = 0;
51
52  string Mnemonic = opName;
53  let UseNamedOperandTable = 1;
54
55  let Uses = [M0, EXEC];
56  let DisableWQM = 0;
57  let SchedRW = [WriteLDS];
58
59  bit is_direct;
60  let is_direct = direct;
61}
62
63class LDSDIR_Pseudo<string opName, bit direct> :
64  LDSDIR_Common<opName, "", direct>,
65  SIMCInstr<opName, SIEncodingFamily.NONE> {
66  let isPseudo = 1;
67  let isCodeGenOnly = 1;
68}
69
70class LDSDIR_getAsm<bit direct> {
71  string ret = !if(direct,
72    " $vdst$waitvdst",
73    " $vdst, $attr$attrchan$waitvdst"
74  );
75}
76
77class LDSDIR_Real<bits<2> op, LDSDIR_Pseudo lds, int subtarget> :
78  LDSDIR_Common<lds.Mnemonic,
79                lds.Mnemonic # LDSDIR_getAsm<lds.is_direct>.ret,
80                lds.is_direct>,
81  SIMCInstr <lds.Mnemonic, subtarget>,
82  LDSDIRe<op, lds.is_direct> {
83  let isPseudo = 0;
84  let isCodeGenOnly = 0;
85}
86
87//===----------------------------------------------------------------------===//
88// LDS Direct Instructions
89//===----------------------------------------------------------------------===//
90
91def LDS_DIRECT_LOAD : LDSDIR_Pseudo<"lds_direct_load", 1>;
92def LDS_PARAM_LOAD : LDSDIR_Pseudo<"lds_param_load", 0>;
93
94def : GCNPat <
95  (f32 (int_amdgcn_lds_direct_load M0)),
96  (LDS_DIRECT_LOAD 0)
97>;
98
99def : GCNPat <
100  (f32 (int_amdgcn_lds_param_load timm:$attrchan, timm:$attr, M0)),
101  (LDS_PARAM_LOAD timm:$attr, timm:$attrchan, 0)
102>;
103
104//===----------------------------------------------------------------------===//
105// GFX11+
106//===----------------------------------------------------------------------===//
107
108multiclass LDSDIR_Real_gfx11<bits<2> op, LDSDIR_Pseudo lds = !cast<LDSDIR_Pseudo>(NAME)> {
109  def _gfx11 : LDSDIR_Real<op, lds, SIEncodingFamily.GFX11> {
110    let AssemblerPredicate = isGFX11Plus;
111    let DecoderNamespace = "GFX11";
112  }
113}
114
115defm LDS_PARAM_LOAD : LDSDIR_Real_gfx11<0x0>;
116defm LDS_DIRECT_LOAD : LDSDIR_Real_gfx11<0x1>;
117