40e37aa9260f3f2d4cdcb3807ed6e5a1ebb549ed
[oota-llvm.git] / lib / Target / R600 / SIInstrFormats.td
1 //===-- SIInstrFormats.td - SI Instruction Formats ------------------------===//
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 //
10 // SI Instruction format definitions.
11 //
12 // Instructions with _32 take 32-bit operands.
13 // Instructions with _64 take 64-bit operands.
14 //
15 // VOP_* instructions can use either a 32-bit or 64-bit encoding.  The 32-bit
16 // encoding is the standard encoding, but instruction that make use of
17 // any of the instruction modifiers must use the 64-bit encoding.
18 //
19 // Instructions with _e32 use the 32-bit encoding.
20 // Instructions with _e64 use the 64-bit encoding.
21 //
22 //===----------------------------------------------------------------------===//
23
24 class VOP3_32 <bits<9> op, string opName, list<dag> pattern>
25   : VOP3 <op, (outs VReg_32:$dst), (ins VSrc_32:$src0, VReg_32:$src1, VReg_32:$src2, i32imm:$src3, i32imm:$src4, i32imm:$src5, i32imm:$src6), opName, pattern>;
26
27 class VOP3_64 <bits<9> op, string opName, list<dag> pattern>
28   : VOP3 <op, (outs VReg_64:$dst), (ins VSrc_64:$src0, VReg_64:$src1, VReg_64:$src2, i32imm:$src3, i32imm:$src4, i32imm:$src5, i32imm:$src6), opName, pattern>;
29
30 class SOP1_32 <bits<8> op, string opName, list<dag> pattern>
31   : SOP1 <op, (outs SReg_32:$dst), (ins SSrc_32:$src0), opName, pattern>;
32
33 class SOP1_64 <bits<8> op, string opName, list<dag> pattern>
34   : SOP1 <op, (outs SReg_64:$dst), (ins SSrc_64:$src0), opName, pattern>;
35
36 class SOP2_32 <bits<7> op, string opName, list<dag> pattern>
37   : SOP2 <op, (outs SReg_32:$dst), (ins SSrc_32:$src0, SSrc_32:$src1), opName, pattern>;
38
39 class SOP2_64 <bits<7> op, string opName, list<dag> pattern>
40   : SOP2 <op, (outs SReg_64:$dst), (ins SSrc_64:$src0, SSrc_64:$src1), opName, pattern>;
41
42 class VOP1_Helper <bits<8> op, RegisterClass vrc, RegisterClass arc,
43                    string opName, list<dag> pattern> : 
44   VOP1 <
45     op, (outs vrc:$dst), (ins arc:$src0), opName, pattern
46   >;
47
48 multiclass VOP1_32 <bits<8> op, string opName, list<dag> pattern> {
49   def _e32: VOP1_Helper <op, VReg_32, VSrc_32, opName, pattern>;
50   def _e64 : VOP3_32 <{1, 1, op{6}, op{5}, op{4}, op{3}, op{2}, op{1}, op{0}},
51                       opName, []
52   >;
53 }
54
55 multiclass VOP1_64 <bits<8> op, string opName, list<dag> pattern> {
56
57   def _e32 : VOP1_Helper <op, VReg_64, VSrc_64, opName, pattern>;
58
59   def _e64 : VOP3_64 <
60     {1, 1, op{6}, op{5}, op{4}, op{3}, op{2}, op{1}, op{0}},
61     opName, []
62   >;
63 }
64
65 class VOP2_Helper <bits<6> op, RegisterClass vrc, RegisterClass arc,
66                    string opName, list<dag> pattern> :
67   VOP2 <
68     op, (outs vrc:$dst), (ins arc:$src0, vrc:$src1), opName, pattern
69   >;
70
71 multiclass VOP2_32 <bits<6> op, string opName, list<dag> pattern> {
72
73   def _e32 : VOP2_Helper <op, VReg_32, VSrc_32, opName, pattern>;
74
75   def _e64 : VOP3_32 <{1, 0, 0, op{5}, op{4}, op{3}, op{2}, op{1}, op{0}},
76                       opName, []
77   >;
78 }
79
80 multiclass VOP2_64 <bits<6> op, string opName, list<dag> pattern> {
81   def _e32: VOP2_Helper <op, VReg_64, VSrc_64, opName, pattern>;
82
83   def _e64 : VOP3_64 <
84     {1, 0, 0, op{5}, op{4}, op{3}, op{2}, op{1}, op{0}},
85     opName, []
86   >;
87 }
88
89 class SOPK_32 <bits<5> op, string opName, list<dag> pattern>
90   : SOPK <op, (outs SReg_32:$dst), (ins i16imm:$src0), opName, pattern>;
91
92 class SOPK_64 <bits<5> op, string opName, list<dag> pattern>
93   : SOPK <op, (outs SReg_64:$dst), (ins i16imm:$src0), opName, pattern>;
94
95 multiclass VOPC_Helper <bits<8> op, RegisterClass vrc, RegisterClass arc,
96                         string opName, list<dag> pattern> {
97
98   def _e32 : VOPC <op, (ins arc:$src0, vrc:$src1), opName, pattern>;
99   def _e64 : VOP3 <
100     {0, op{7}, op{6}, op{5}, op{4}, op{3}, op{2}, op{1}, op{0}},
101     (outs SReg_64:$dst),
102     (ins arc:$src0, vrc:$src1,
103          InstFlag:$abs, InstFlag:$clamp,
104          InstFlag:$omod, InstFlag:$neg),
105     opName, pattern
106   > {
107     let SRC2 = 0x80;
108   }
109 }
110
111 multiclass VOPC_32 <bits<8> op, string opName, list<dag> pattern>
112   : VOPC_Helper <op, VReg_32, VSrc_32, opName, pattern>;
113
114 multiclass VOPC_64 <bits<8> op, string opName, list<dag> pattern>
115   : VOPC_Helper <op, VReg_64, VSrc_64, opName, pattern>;
116
117 class SOPC_32 <bits<7> op, string opName, list<dag> pattern>
118   : SOPC <op, (outs SCCReg:$dst), (ins SSrc_32:$src0, SSrc_32:$src1), opName, pattern>;
119
120 class SOPC_64 <bits<7> op, string opName, list<dag> pattern>
121   : SOPC <op, (outs SCCReg:$dst), (ins SSrc_64:$src0, SSrc_64:$src1), opName, pattern>;
122
123 class MIMG_Load_Helper <bits<7> op, string asm> : MIMG <
124   op,
125   (outs VReg_128:$vdata),
126   (ins i32imm:$dmask, i1imm:$unorm, i1imm:$glc, i1imm:$da, i1imm:$r128,
127        i1imm:$tfe, i1imm:$lwe, i1imm:$slc, VReg_32:$vaddr,
128        GPR4Align<SReg_256>:$srsrc, GPR4Align<SReg_128>:$ssamp),
129   asm,
130   []> {
131   let mayLoad = 1;
132   let mayStore = 0;
133 }
134
135 class MTBUF_Store_Helper <bits<3> op, string asm, RegisterClass regClass> : MTBUF <
136   op,
137   (outs),
138   (ins regClass:$vdata, i16imm:$offset, i1imm:$offen, i1imm:$idxen, i1imm:$glc,
139    i1imm:$addr64, i8imm:$dfmt, i8imm:$nfmt, VReg_32:$vaddr,
140    GPR4Align<SReg_128>:$srsrc, i1imm:$slc, i1imm:$tfe, SSrc_32:$soffset),
141   asm,
142   []> {
143   let mayStore = 1;
144   let mayLoad = 0;
145 }
146
147 class MUBUF_Load_Helper <bits<7> op, string asm, RegisterClass regClass> : MUBUF <
148   op,
149   (outs regClass:$dst),
150   (ins i16imm:$offset, i1imm:$offen, i1imm:$idxen, i1imm:$glc, i1imm:$addr64,
151        i1imm:$lds, VReg_32:$vaddr, GPR4Align<SReg_128>:$srsrc, i1imm:$slc,
152        i1imm:$tfe, SSrc_32:$soffset),
153   asm,
154   []> {
155   let mayLoad = 1;
156   let mayStore = 0;
157 }
158
159 class MTBUF_Load_Helper <bits<3> op, string asm, RegisterClass regClass> : MTBUF <
160   op,
161   (outs regClass:$dst),
162   (ins i16imm:$offset, i1imm:$offen, i1imm:$idxen, i1imm:$glc, i1imm:$addr64,
163        i8imm:$dfmt, i8imm:$nfmt, VReg_32:$vaddr, GPR4Align<SReg_128>:$srsrc,
164        i1imm:$slc, i1imm:$tfe, SSrc_32:$soffset),
165   asm,
166   []> {
167   let mayLoad = 1;
168   let mayStore = 0;
169 }
170
171 multiclass SMRD_Helper <bits<5> op, string asm, RegisterClass dstClass> {
172   def _IMM : SMRD <
173              op, 1,
174              (outs dstClass:$dst),
175              (ins GPR2Align<SReg_64>:$sbase, i32imm:$offset),
176              asm,
177              []
178   >;
179
180   def _SGPR : SMRD <
181               op, 0,
182               (outs dstClass:$dst),
183               (ins GPR2Align<SReg_64>:$sbase, SReg_32:$soff),
184               asm,
185               []
186   >;
187 }
188