R600/SI: fix VOPC encoding v2
[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 AllReg_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 AllReg_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 SReg_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 SReg_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 SReg_32:$src0, SReg_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 SReg_64:$src0, SReg_64:$src1), opName, pattern>;
41
42 class SOP2_VCC <bits<7> op, string opName, list<dag> pattern>
43   : SOP2 <op, (outs SReg_1:$vcc), (ins SReg_64:$src0, SReg_64:$src1), opName, pattern>;
44
45 class VOP1_Helper <bits<8> op, RegisterClass vrc, RegisterClass arc,
46                    string opName, list<dag> pattern> : 
47   VOP1 <
48     op, (outs vrc:$dst), (ins arc:$src0), opName, pattern
49   >;
50
51 multiclass VOP1_32 <bits<8> op, string opName, list<dag> pattern> {
52   def _e32: VOP1_Helper <op, VReg_32, AllReg_32, opName, pattern>;
53   def _e64 : VOP3_32 <{1, 1, op{6}, op{5}, op{4}, op{3}, op{2}, op{1}, op{0}},
54                       opName, []
55   >;
56 }
57
58 multiclass VOP1_64 <bits<8> op, string opName, list<dag> pattern> {
59
60   def _e32 : VOP1_Helper <op, VReg_64, AllReg_64, opName, pattern>;
61
62   def _e64 : VOP3_64 <
63     {1, 1, op{6}, op{5}, op{4}, op{3}, op{2}, op{1}, op{0}},
64     opName, []
65   >;
66 }
67
68 class VOP2_Helper <bits<6> op, RegisterClass vrc, RegisterClass arc,
69                    string opName, list<dag> pattern> :
70   VOP2 <
71     op, (outs vrc:$dst), (ins arc:$src0, vrc:$src1), opName, pattern
72   >;
73
74 multiclass VOP2_32 <bits<6> op, string opName, list<dag> pattern> {
75
76   def _e32 : VOP2_Helper <op, VReg_32, AllReg_32, opName, pattern>;
77
78   def _e64 : VOP3_32 <{1, 0, 0, op{5}, op{4}, op{3}, op{2}, op{1}, op{0}},
79                       opName, []
80   >;
81 }
82
83 multiclass VOP2_64 <bits<6> op, string opName, list<dag> pattern> {
84   def _e32: VOP2_Helper <op, VReg_64, AllReg_64, opName, pattern>;
85
86   def _e64 : VOP3_64 <
87     {1, 0, 0, op{5}, op{4}, op{3}, op{2}, op{1}, op{0}},
88     opName, []
89   >;
90 }
91
92 class SOPK_32 <bits<5> op, string opName, list<dag> pattern>
93   : SOPK <op, (outs SReg_32:$dst), (ins i16imm:$src0), opName, pattern>;
94
95 class SOPK_64 <bits<5> op, string opName, list<dag> pattern>
96   : SOPK <op, (outs SReg_64:$dst), (ins i16imm:$src0), opName, pattern>;
97
98 multiclass VOPC_Helper <bits<8> op, RegisterClass vrc, RegisterClass arc,
99                         string opName, list<dag> pattern> {
100
101   def _e32 : VOPC <op, (ins arc:$src0, vrc:$src1), opName, pattern>;
102   def _e64 : VOP3 <
103     {0, op{7}, op{6}, op{5}, op{4}, op{3}, op{2}, op{1}, op{0}},
104     (outs SReg_1:$dst),
105     (ins arc:$src0, vrc:$src1,
106          InstFlag:$abs, InstFlag:$clamp,
107          InstFlag:$omod, InstFlag:$neg),
108     opName, pattern
109   > {
110     let SRC2 = 0x80;
111   }
112 }
113
114 multiclass VOPC_32 <bits<8> op, string opName, list<dag> pattern>
115   : VOPC_Helper <op, VReg_32, AllReg_32, opName, pattern>;
116
117 multiclass VOPC_64 <bits<8> op, string opName, list<dag> pattern>
118   : VOPC_Helper <op, VReg_64, AllReg_64, opName, pattern>;
119
120 class SOPC_32 <bits<7> op, string opName, list<dag> pattern>
121   : SOPC <op, (outs SCCReg:$dst), (ins SReg_32:$src0, SReg_32:$src1), opName, pattern>;
122
123 class SOPC_64 <bits<7> op, string opName, list<dag> pattern>
124   : SOPC <op, (outs SCCReg:$dst), (ins SReg_64:$src0, SReg_64:$src1), opName, pattern>;
125
126 class MIMG_Load_Helper <bits<7> op, string asm> : MIMG <
127   op,
128   (outs VReg_128:$vdata),
129   (ins i32imm:$dmask, i1imm:$unorm, i1imm:$glc, i1imm:$da, i1imm:$r128,
130        i1imm:$tfe, i1imm:$lwe, i1imm:$slc, VReg_32:$vaddr,
131        GPR4Align<SReg_256>:$srsrc, GPR4Align<SReg_128>:$ssamp),
132   asm,
133   []> {
134   let mayLoad = 1;
135   let mayStore = 0;
136 }
137
138 class MTBUF_Store_Helper <bits<3> op, string asm, RegisterClass regClass> : MTBUF <
139   op,
140   (outs),
141   (ins regClass:$vdata, i16imm:$offset, i1imm:$offen, i1imm:$idxen, i1imm:$glc,
142    i1imm:$addr64, i8imm:$dfmt, i8imm:$nfmt, VReg_32:$vaddr,
143    GPR4Align<SReg_128>:$srsrc, i1imm:$slc, i1imm:$tfe, SReg_32:$soffset),
144   asm,
145   []> {
146   let mayStore = 1;
147   let mayLoad = 0;
148 }
149
150 class MUBUF_Load_Helper <bits<7> op, string asm, RegisterClass regClass> : MUBUF <
151   op,
152   (outs regClass:$dst),
153   (ins i16imm:$offset, i1imm:$offen, i1imm:$idxen, i1imm:$glc, i1imm:$addr64,
154        i1imm:$lds, VReg_32:$vaddr, GPR4Align<SReg_128>:$srsrc, i1imm:$slc,
155        i1imm:$tfe, SReg_32:$soffset),
156   asm,
157   []> {
158   let mayLoad = 1;
159   let mayStore = 0;
160 }
161
162 class MTBUF_Load_Helper <bits<3> op, string asm, RegisterClass regClass> : MTBUF <
163   op,
164   (outs regClass:$dst),
165   (ins i16imm:$offset, i1imm:$offen, i1imm:$idxen, i1imm:$glc, i1imm:$addr64,
166        i8imm:$dfmt, i8imm:$nfmt, VReg_32:$vaddr, GPR4Align<SReg_128>:$srsrc,
167        i1imm:$slc, i1imm:$tfe, SReg_32:$soffset),
168   asm,
169   []> {
170   let mayLoad = 1;
171   let mayStore = 0;
172 }
173
174 multiclass SMRD_Helper <bits<5> op, string asm, RegisterClass dstClass> {
175   def _IMM : SMRD <
176              op, 1,
177              (outs dstClass:$dst),
178              (ins GPR2Align<SReg_64>:$sbase, i32imm:$offset),
179              asm,
180              []
181   >;
182
183   def _SGPR : SMRD <
184               op, 0,
185               (outs dstClass:$dst),
186               (ins GPR2Align<SReg_64>:$sbase, SReg_32:$soff),
187               asm,
188               []
189   >;
190 }
191