1 //===---- SparcInstrVIS.td - Visual Instruction Set extensions (VIS) -----===//
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
7 //===----------------------------------------------------------------------===//
9 // This file contains instruction formats, definitions and patterns needed for
10 // VIS, VIS II, VIS II instructions on SPARC.
11 //===----------------------------------------------------------------------===//
13 // VIS Instruction Format.
14 class VISInstFormat<bits<9> opfval, dag outs, dag ins, string asmstr,
16 : F3_3<0b10, 0b110110, opfval, outs, ins, asmstr, pattern>;
18 class VISInst<bits<9> opfval, string OpcStr, RegisterClass RC = DFPRegs>
19 : VISInstFormat<opfval,
20 (outs RC:$rd), (ins RC:$rs1, RC:$rs2),
21 !strconcat(OpcStr, " $rs1, $rs2, $rd"), []>;
23 // VIS Instruction with integer destination register.
24 class VISInstID<bits<9> opfval, string OpcStr>
25 : VISInstFormat<opfval,
26 (outs I64Regs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
27 !strconcat(OpcStr, " $rs1, $rs2, $rd"), []>;
29 // For VIS Instructions with no operand.
30 let rd = 0, rs1 = 0, rs2 = 0 in
31 class VISInst0<bits<9> opfval, string asmstr>
32 : VISInstFormat<opfval, (outs), (ins), asmstr, []>;
34 // For VIS Instructions with only rs1, rd operands.
36 class VISInst1<bits<9> opfval, string OpcStr, RegisterClass RC = DFPRegs>
37 : VISInstFormat<opfval,
38 (outs RC:$rd), (ins RC:$rs1),
39 !strconcat(OpcStr, " $rs1, $rd"), []>;
41 // For VIS Instructions with only rs2, rd operands.
43 class VISInst2<bits<9> opfval, string OpcStr, RegisterClass RC = DFPRegs>
44 : VISInstFormat<opfval,
45 (outs RC:$rd), (ins RC:$rs2),
46 !strconcat(OpcStr, " $rs2, $rd"), []>;
48 // For VIS Instructions with only rd operand.
49 let Constraints = "$rd = $f", rs1 = 0, rs2 = 0 in
50 class VISInstD<bits<9> opfval, string OpcStr, RegisterClass RC = DFPRegs>
51 : VISInstFormat<opfval,
52 (outs RC:$rd), (ins RC:$f),
53 !strconcat(OpcStr, " $rd"), []>;
56 let Predicates = [HasVIS] in {
58 def FPADD16 : VISInst<0b001010000, "fpadd16">;
59 def FPADD16S : VISInst<0b001010001, "fpadd16s">;
60 def FPADD32 : VISInst<0b001010010, "fpadd32">;
61 def FPADD32S : VISInst<0b001010011, "fpadd32s">;
62 def FPSUB16 : VISInst<0b001010100, "fpsub16">;
63 def FPSUB16S : VISInst<0b001010101, "fpsub16S">;
64 def FPSUB32 : VISInst<0b001010110, "fpsub32">;
65 def FPSUB32S : VISInst<0b001010111, "fpsub32S">;
67 def FPACK16 : VISInst2<0b000111011, "fpack16">;
68 def FPACK32 : VISInst <0b000111010, "fpack32">;
69 def FPACKFIX : VISInst2<0b000111101, "fpackfix">;
70 def FEXPAND : VISInst2<0b001001101, "fexpand">;
71 def FPMERGE : VISInst <0b001001011, "fpmerge">;
73 def FMUL8X16 : VISInst<0b000110001, "fmul8x16">;
74 def FMUL8X16AU : VISInst<0b000110011, "fmul8x16au">;
75 def FMUL8X16AL : VISInst<0b000110101, "fmul8x16al">;
76 def FMUL8SUX16 : VISInst<0b000110110, "fmul8sux16">;
77 def FMUL8ULX16 : VISInst<0b000110111, "fmul8ulx16">;
78 def FMULD8SUX16 : VISInst<0b000111000, "fmuld8sux16">;
79 def FMULD8ULX16 : VISInst<0b000111001, "fmuld8ulx16">;
81 def ALIGNADDR : VISInst<0b000011000, "alignaddr", I64Regs>;
82 def ALIGNADDRL : VISInst<0b000011010, "alignaddrl", I64Regs>;
83 def FALIGNADATA : VISInst<0b001001000, "faligndata">;
85 def FZERO : VISInstD<0b001100000, "fzero">;
86 def FZEROS : VISInstD<0b001100001, "fzeros", FPRegs>;
87 def FONE : VISInstD<0b001111110, "fone">;
88 def FONES : VISInstD<0b001111111, "fones", FPRegs>;
89 def FSRC1 : VISInst1<0b001110100, "fsrc1">;
90 def FSRC1S : VISInst1<0b001110101, "fsrc1s", FPRegs>;
91 def FSRC2 : VISInst2<0b001111000, "fsrc2">;
92 def FSRC2S : VISInst2<0b001111001, "fsrc2s", FPRegs>;
93 def FNOT1 : VISInst1<0b001101010, "fnot1">;
94 def FNOT1S : VISInst1<0b001101011, "fnot1s", FPRegs>;
95 def FNOT2 : VISInst2<0b001100110, "fnot2">;
96 def FNOT2S : VISInst2<0b001100111, "fnot2s", FPRegs>;
97 def FOR : VISInst<0b001111100, "for">;
98 def FORS : VISInst<0b001111101, "fors", FPRegs>;
99 def FNOR : VISInst<0b001100010, "fnor">;
100 def FNORS : VISInst<0b001100011, "fnors", FPRegs>;
101 def FAND : VISInst<0b001110000, "fand">;
102 def FANDS : VISInst<0b001110001, "fands", FPRegs>;
103 def FNAND : VISInst<0b001101110, "fnand">;
104 def FNANDS : VISInst<0b001101111, "fnands", FPRegs>;
105 def FXOR : VISInst<0b001101100, "fxor">;
106 def FXORS : VISInst<0b001101101, "fxors", FPRegs>;
107 def FXNOR : VISInst<0b001110010, "fxnor">;
108 def FXNORS : VISInst<0b001110011, "fxnors", FPRegs>;
110 def FORNOT1 : VISInst<0b001111010, "fornot1">;
111 def FORNOT1S : VISInst<0b001111011, "fornot1s", FPRegs>;
112 def FORNOT2 : VISInst<0b001110110, "fornot2">;
113 def FORNOT2S : VISInst<0b001110111, "fornot2s", FPRegs>;
114 def FANDNOT1 : VISInst<0b001101000, "fandnot1">;
115 def FANDNOT1S : VISInst<0b001101001, "fandnot1s", FPRegs>;
116 def FANDNOT2 : VISInst<0b001100100, "fandnot2">;
117 def FANDNOT2S : VISInst<0b001100101, "fandnot2s", FPRegs>;
119 def FCMPGT16 : VISInstID<0b000101000, "fcmpgt16">;
120 def FCMPGT32 : VISInstID<0b000101100, "fcmpgt32">;
121 def FCMPLE16 : VISInstID<0b000100000, "fcmple16">;
122 def FCMPLE32 : VISInstID<0b000100100, "fcmple32">;
123 def FCMPNE16 : VISInstID<0b000100010, "fcmpne16">;
124 def FCMPNE32 : VISInstID<0b000100110, "fcmpne32">;
125 def FCMPEQ16 : VISInstID<0b000101010, "fcmpeq16">;
126 def FCMPEQ32 : VISInstID<0b000101110, "fcmpeq32">;
129 def EDGE8 : VISInst<0b000000000, "edge8", I64Regs>;
130 def EDGE8L : VISInst<0b000000010, "edge8l", I64Regs>;
131 def EDGE16 : VISInst<0b000000100, "edge16", I64Regs>;
132 def EDGE16L : VISInst<0b000000110, "edge16l", I64Regs>;
133 def EDGE32 : VISInst<0b000001000, "edge32", I64Regs>;
134 def EDGE32L : VISInst<0b000001010, "edge32l", I64Regs>;
136 def PDIST : VISInst<0b000111110, "pdist">;
138 def ARRAY8 : VISInst<0b000010000, "array8", I64Regs>;
139 def ARRAY16 : VISInst<0b000010010, "array16", I64Regs>;
140 def ARRAY32 : VISInst<0b000010100, "array32", I64Regs>;
142 def SHUTDOWN : VISInst0<0b010000000, "shutdown">;
144 } // Predicates = [HasVIS]
147 // VIS 2 Instructions.
148 let Predicates = [HasVIS2] in {
150 def BMASK : VISInst<0b000011001, "bmask", I64Regs>;
151 def BSHUFFLE : VISInst<0b000011100, "bshuffle">;
153 def SIAM : VISInst0<0b010000001, "siam">;
155 def EDGE8N : VISInst<0b000000001, "edge8n", I64Regs>;
156 def EDGE8LN : VISInst<0b000000011, "edge8ln", I64Regs>;
157 def EDGE16N : VISInst<0b000000101, "edge16n", I64Regs>;
158 def EDGE16LN : VISInst<0b000000111, "edge16ln", I64Regs>;
159 def EDGE32N : VISInst<0b000001001, "edge32n", I64Regs>;
160 def EDGE32LN : VISInst<0b000001011, "edge32ln", I64Regs>;
161 } // Predicates = [HasVIS2]
164 // VIS 3 Instructions.
165 let Predicates = [HasVIS3] in {
168 def ADDXC : VISInst<0b000010001, "addxc", I64Regs>;
170 let Defs = [ICC], Uses = [ICC] in
171 def ADDXCCC : VISInst<0b000010011, "addxccc", I64Regs>;
173 let rd = 0, rs1 = 0 in {
174 def CMASK8 : VISInstFormat<0b000011011, (outs), (ins I64Regs:$rs2),
176 def CMASK16 : VISInstFormat<0b000011101, (outs), (ins I64Regs:$rs2),
178 def CMASK32 : VISInstFormat<0b000011111, (outs), (ins I64Regs:$rs2),
183 def FCHKSM16 : VISInst<0b001000100, "fchksm16">;
185 def FHADDS : F3_3<0b10, 0b110100, 0b001100001,
186 (outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
187 "fhadds $rs1, $rs2, $rd", []>;
188 def FHADDD : F3_3<0b10, 0b110100, 0b001100010,
189 (outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
190 "fhaddd $rs1, $rs2, $rd", []>;
191 def FHSUBS : F3_3<0b10, 0b110100, 0b001100101,
192 (outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
193 "fhsubs $rs1, $rs2, $rd", []>;
194 def FHSUBD : F3_3<0b10, 0b110100, 0b001100110,
195 (outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
196 "fhsubd $rs1, $rs2, $rd", []>;
197 def FLCMPS : VISInstFormat<0b101010001, (outs FCCRegs:$rd),
198 (ins DFPRegs:$rs1, DFPRegs:$rs2),
199 "flcmps $rd, $rs1, $rs2", []>;
200 def FLCMPD : VISInstFormat<0b101010010, (outs FCCRegs:$rd),
201 (ins DFPRegs:$rs1, DFPRegs:$rs2),
202 "flcmpd $rd, $rs1, $rs2", []>;
204 def FMEAN16 : VISInst<0b001000000, "fmean16">;
206 def FNADDS : F3_3<0b10, 0b110100, 0b001010001,
207 (outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
208 "fnadds $rs1, $rs2, $rd", []>;
209 def FNADDD : F3_3<0b10, 0b110100, 0b001010010,
210 (outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
211 "fnaddd $rs1, $rs2, $rd", []>;
212 def FNHADDS : F3_3<0b10, 0b110100, 0b001110001,
213 (outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
214 "fnhadds $rs1, $rs2, $rd", []>;
215 def FNHADDD : F3_3<0b10, 0b110100, 0b001110010,
216 (outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
217 "fnhaddd $rs1, $rs2, $rd", []>;
219 def FNMULS : F3_3<0b10, 0b110100, 0b001011001,
220 (outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
221 "fnhadds $rs1, $rs2, $rd", []>;
222 def FNMULD : F3_3<0b10, 0b110100, 0b001011010,
223 (outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
224 "fnhaddd $rs1, $rs2, $rd", []>;
225 def FNSMULD : F3_3<0b10, 0b110100, 0b001111001,
226 (outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
227 "fnhadds $rs1, $rs2, $rd", []>;
229 def FPADD64 : VISInst<0b001000010, "fpadd64">;
231 def FSLL16 : VISInst<0b000100001, "fsll16">;
232 def FSRL16 : VISInst<0b000100011, "fsrl16">;
233 def FSLL32 : VISInst<0b000100101, "fsll32">;
234 def FSRL32 : VISInst<0b000100111, "fsrl32">;
235 def FSLAS16 : VISInst<0b000101001, "fslas16">;
236 def FSRA16 : VISInst<0b000101011, "fsra16">;
237 def FSLAS32 : VISInst<0b000101101, "fslas32">;
238 def FSRA32 : VISInst<0b000101111, "fsra32">;
241 def LZCNT : VISInstFormat<0b000010111, (outs I64Regs:$rd),
242 (ins I64Regs:$rs2), "lzcnt $rs2, $rd", []>;
245 def MOVSTOSW : VISInstFormat<0b100010011, (outs I64Regs:$rd),
246 (ins DFPRegs:$rs2), "movstosw $rs2, $rd", []>;
247 def MOVSTOUW : VISInstFormat<0b100010001, (outs I64Regs:$rd),
248 (ins DFPRegs:$rs2), "movstouw $rs2, $rd", []>;
249 def MOVDTOX : VISInstFormat<0b100010000, (outs I64Regs:$rd),
250 (ins DFPRegs:$rs2), "movdtox $rs2, $rd", []>;
251 def MOVWTOS : VISInstFormat<0b100011001, (outs DFPRegs:$rd),
252 (ins I64Regs:$rs2), "movdtox $rs2, $rd", []>;
253 def MOVXTOD : VISInstFormat<0b100011000, (outs DFPRegs:$rd),
254 (ins I64Regs:$rs2), "movdtox $rs2, $rd", []>;
257 def PDISTN : VISInst<0b000111111, "pdistn">;
259 def UMULXHI : VISInst<0b000010110, "umulxhi", I64Regs>;
260 def XMULX : VISInst<0b100010101, "xmulx", I64Regs>;
261 def XMULXHI : VISInst<0b100010111, "xmulxhi", I64Regs>;
262 } // Predicates = [IsVIS3]