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