1*06c3fb27SDimitry Andric//===-- RISCVInstrFormatsV.td - RISC-V V Instruction Formats -*- tablegen -*-=// 25ffd83dbSDimitry Andric// 35ffd83dbSDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 45ffd83dbSDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 55ffd83dbSDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 65ffd83dbSDimitry Andric// 75ffd83dbSDimitry Andric//===----------------------------------------------------------------------===// 85ffd83dbSDimitry Andric// 95ffd83dbSDimitry Andric// This file describes the RISC-V V extension instruction formats. 105ffd83dbSDimitry Andric// 115ffd83dbSDimitry Andric//===----------------------------------------------------------------------===// 125ffd83dbSDimitry Andric 135ffd83dbSDimitry Andricclass RISCVVFormat<bits<3> val> { 145ffd83dbSDimitry Andric bits<3> Value = val; 155ffd83dbSDimitry Andric} 165ffd83dbSDimitry Andricdef OPIVV : RISCVVFormat<0b000>; 175ffd83dbSDimitry Andricdef OPFVV : RISCVVFormat<0b001>; 185ffd83dbSDimitry Andricdef OPMVV : RISCVVFormat<0b010>; 195ffd83dbSDimitry Andricdef OPIVI : RISCVVFormat<0b011>; 205ffd83dbSDimitry Andricdef OPIVX : RISCVVFormat<0b100>; 215ffd83dbSDimitry Andricdef OPFVF : RISCVVFormat<0b101>; 225ffd83dbSDimitry Andricdef OPMVX : RISCVVFormat<0b110>; 23bdd1243dSDimitry Andricdef OPCFG : RISCVVFormat<0b111>; 245ffd83dbSDimitry Andric 25e8d8bef9SDimitry Andricclass RISCVMOP<bits<2> val> { 26e8d8bef9SDimitry Andric bits<2> Value = val; 275ffd83dbSDimitry Andric} 28e8d8bef9SDimitry Andricdef MOPLDUnitStride : RISCVMOP<0b00>; 29e8d8bef9SDimitry Andricdef MOPLDIndexedUnord : RISCVMOP<0b01>; 30e8d8bef9SDimitry Andricdef MOPLDStrided : RISCVMOP<0b10>; 31e8d8bef9SDimitry Andricdef MOPLDIndexedOrder : RISCVMOP<0b11>; 325ffd83dbSDimitry Andric 33e8d8bef9SDimitry Andricdef MOPSTUnitStride : RISCVMOP<0b00>; 34e8d8bef9SDimitry Andricdef MOPSTIndexedUnord : RISCVMOP<0b01>; 35e8d8bef9SDimitry Andricdef MOPSTStrided : RISCVMOP<0b10>; 36e8d8bef9SDimitry Andricdef MOPSTIndexedOrder : RISCVMOP<0b11>; 375ffd83dbSDimitry Andric 385ffd83dbSDimitry Andricclass RISCVLSUMOP<bits<5> val> { 395ffd83dbSDimitry Andric bits<5> Value = val; 405ffd83dbSDimitry Andric} 415ffd83dbSDimitry Andricdef LUMOPUnitStride : RISCVLSUMOP<0b00000>; 42d409305fSDimitry Andricdef LUMOPUnitStrideMask : RISCVLSUMOP<0b01011>; 435ffd83dbSDimitry Andricdef LUMOPUnitStrideWholeReg : RISCVLSUMOP<0b01000>; 445ffd83dbSDimitry Andricdef LUMOPUnitStrideFF: RISCVLSUMOP<0b10000>; 455ffd83dbSDimitry Andricdef SUMOPUnitStride : RISCVLSUMOP<0b00000>; 46d409305fSDimitry Andricdef SUMOPUnitStrideMask : RISCVLSUMOP<0b01011>; 475ffd83dbSDimitry Andricdef SUMOPUnitStrideWholeReg : RISCVLSUMOP<0b01000>; 485ffd83dbSDimitry Andric 49e8d8bef9SDimitry Andricclass RISCVWidth<bits<4> val> { 50e8d8bef9SDimitry Andric bits<4> Value = val; 51e8d8bef9SDimitry Andric} 52e8d8bef9SDimitry Andricdef LSWidth8 : RISCVWidth<0b0000>; 53e8d8bef9SDimitry Andricdef LSWidth16 : RISCVWidth<0b0101>; 54e8d8bef9SDimitry Andricdef LSWidth32 : RISCVWidth<0b0110>; 55e8d8bef9SDimitry Andricdef LSWidth64 : RISCVWidth<0b0111>; 56d409305fSDimitry Andric 57d409305fSDimitry Andricclass RVInstSetiVLi<dag outs, dag ins, string opcodestr, string argstr> 58d409305fSDimitry Andric : RVInst<outs, ins, opcodestr, argstr, [], InstFormatI> { 59d409305fSDimitry Andric bits<5> uimm; 60d409305fSDimitry Andric bits<5> rd; 61d409305fSDimitry Andric bits<10> vtypei; 62d409305fSDimitry Andric 63d409305fSDimitry Andric let Inst{31} = 1; 64d409305fSDimitry Andric let Inst{30} = 1; 65d409305fSDimitry Andric let Inst{29-20} = vtypei{9-0}; 66d409305fSDimitry Andric let Inst{19-15} = uimm; 67bdd1243dSDimitry Andric let Inst{14-12} = OPCFG.Value; 68d409305fSDimitry Andric let Inst{11-7} = rd; 69*06c3fb27SDimitry Andric let Inst{6-0} = OPC_OP_V.Value; 70d409305fSDimitry Andric 71d409305fSDimitry Andric let Defs = [VTYPE, VL]; 72d409305fSDimitry Andric} 735ffd83dbSDimitry Andric 745ffd83dbSDimitry Andricclass RVInstSetVLi<dag outs, dag ins, string opcodestr, string argstr> 755ffd83dbSDimitry Andric : RVInst<outs, ins, opcodestr, argstr, [], InstFormatI> { 765ffd83dbSDimitry Andric bits<5> rs1; 775ffd83dbSDimitry Andric bits<5> rd; 785ffd83dbSDimitry Andric bits<11> vtypei; 795ffd83dbSDimitry Andric 805ffd83dbSDimitry Andric let Inst{31} = 0; 815ffd83dbSDimitry Andric let Inst{30-20} = vtypei; 825ffd83dbSDimitry Andric let Inst{19-15} = rs1; 83bdd1243dSDimitry Andric let Inst{14-12} = OPCFG.Value; 845ffd83dbSDimitry Andric let Inst{11-7} = rd; 85*06c3fb27SDimitry Andric let Inst{6-0} = OPC_OP_V.Value; 865ffd83dbSDimitry Andric 875ffd83dbSDimitry Andric let Defs = [VTYPE, VL]; 885ffd83dbSDimitry Andric} 895ffd83dbSDimitry Andric 905ffd83dbSDimitry Andricclass RVInstSetVL<dag outs, dag ins, string opcodestr, string argstr> 915ffd83dbSDimitry Andric : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> { 925ffd83dbSDimitry Andric bits<5> rs2; 935ffd83dbSDimitry Andric bits<5> rs1; 945ffd83dbSDimitry Andric bits<5> rd; 955ffd83dbSDimitry Andric 965ffd83dbSDimitry Andric let Inst{31} = 1; 975ffd83dbSDimitry Andric let Inst{30-25} = 0b000000; 985ffd83dbSDimitry Andric let Inst{24-20} = rs2; 995ffd83dbSDimitry Andric let Inst{19-15} = rs1; 100bdd1243dSDimitry Andric let Inst{14-12} = OPCFG.Value; 1015ffd83dbSDimitry Andric let Inst{11-7} = rd; 102*06c3fb27SDimitry Andric let Inst{6-0} = OPC_OP_V.Value; 1035ffd83dbSDimitry Andric 1045ffd83dbSDimitry Andric let Defs = [VTYPE, VL]; 1055ffd83dbSDimitry Andric} 1065ffd83dbSDimitry Andric 1075ffd83dbSDimitry Andricclass RVInstVV<bits<6> funct6, RISCVVFormat opv, dag outs, dag ins, 1085ffd83dbSDimitry Andric string opcodestr, string argstr> 1095ffd83dbSDimitry Andric : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> { 1105ffd83dbSDimitry Andric bits<5> vs2; 1115ffd83dbSDimitry Andric bits<5> vs1; 1125ffd83dbSDimitry Andric bits<5> vd; 1135ffd83dbSDimitry Andric bit vm; 1145ffd83dbSDimitry Andric 1155ffd83dbSDimitry Andric let Inst{31-26} = funct6; 1165ffd83dbSDimitry Andric let Inst{25} = vm; 1175ffd83dbSDimitry Andric let Inst{24-20} = vs2; 1185ffd83dbSDimitry Andric let Inst{19-15} = vs1; 1195ffd83dbSDimitry Andric let Inst{14-12} = opv.Value; 1205ffd83dbSDimitry Andric let Inst{11-7} = vd; 121*06c3fb27SDimitry Andric let Inst{6-0} = OPC_OP_V.Value; 1225ffd83dbSDimitry Andric 1235ffd83dbSDimitry Andric let Uses = [VTYPE, VL]; 124e8d8bef9SDimitry Andric let RVVConstraint = VMConstraint; 1255ffd83dbSDimitry Andric} 1265ffd83dbSDimitry Andric 1275ffd83dbSDimitry Andricclass RVInstVX<bits<6> funct6, RISCVVFormat opv, dag outs, dag ins, 1285ffd83dbSDimitry Andric string opcodestr, string argstr> 1295ffd83dbSDimitry Andric : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> { 1305ffd83dbSDimitry Andric bits<5> vs2; 1315ffd83dbSDimitry Andric bits<5> rs1; 1325ffd83dbSDimitry Andric bits<5> vd; 1335ffd83dbSDimitry Andric bit vm; 1345ffd83dbSDimitry Andric 1355ffd83dbSDimitry Andric let Inst{31-26} = funct6; 1365ffd83dbSDimitry Andric let Inst{25} = vm; 1375ffd83dbSDimitry Andric let Inst{24-20} = vs2; 1385ffd83dbSDimitry Andric let Inst{19-15} = rs1; 1395ffd83dbSDimitry Andric let Inst{14-12} = opv.Value; 1405ffd83dbSDimitry Andric let Inst{11-7} = vd; 141*06c3fb27SDimitry Andric let Inst{6-0} = OPC_OP_V.Value; 1425ffd83dbSDimitry Andric 1435ffd83dbSDimitry Andric let Uses = [VTYPE, VL]; 144e8d8bef9SDimitry Andric let RVVConstraint = VMConstraint; 1455ffd83dbSDimitry Andric} 1465ffd83dbSDimitry Andric 1475ffd83dbSDimitry Andricclass RVInstV2<bits<6> funct6, bits<5> vs2, RISCVVFormat opv, dag outs, dag ins, 1485ffd83dbSDimitry Andric string opcodestr, string argstr> 1495ffd83dbSDimitry Andric : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> { 1505ffd83dbSDimitry Andric bits<5> rs1; 1515ffd83dbSDimitry Andric bits<5> vd; 1525ffd83dbSDimitry Andric bit vm; 1535ffd83dbSDimitry Andric 1545ffd83dbSDimitry Andric let Inst{31-26} = funct6; 1555ffd83dbSDimitry Andric let Inst{25} = vm; 1565ffd83dbSDimitry Andric let Inst{24-20} = vs2; 1575ffd83dbSDimitry Andric let Inst{19-15} = rs1; 1585ffd83dbSDimitry Andric let Inst{14-12} = opv.Value; 1595ffd83dbSDimitry Andric let Inst{11-7} = vd; 160*06c3fb27SDimitry Andric let Inst{6-0} = OPC_OP_V.Value; 1615ffd83dbSDimitry Andric 1625ffd83dbSDimitry Andric let Uses = [VTYPE, VL]; 163e8d8bef9SDimitry Andric let RVVConstraint = VMConstraint; 1645ffd83dbSDimitry Andric} 1655ffd83dbSDimitry Andric 1665ffd83dbSDimitry Andricclass RVInstIVI<bits<6> funct6, dag outs, dag ins, string opcodestr, 1675ffd83dbSDimitry Andric string argstr> 1685ffd83dbSDimitry Andric : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> { 1695ffd83dbSDimitry Andric bits<5> vs2; 1705ffd83dbSDimitry Andric bits<5> imm; 1715ffd83dbSDimitry Andric bits<5> vd; 1725ffd83dbSDimitry Andric bit vm; 1735ffd83dbSDimitry Andric 1745ffd83dbSDimitry Andric let Inst{31-26} = funct6; 1755ffd83dbSDimitry Andric let Inst{25} = vm; 1765ffd83dbSDimitry Andric let Inst{24-20} = vs2; 1775ffd83dbSDimitry Andric let Inst{19-15} = imm; 178bdd1243dSDimitry Andric let Inst{14-12} = OPIVI.Value; 1795ffd83dbSDimitry Andric let Inst{11-7} = vd; 180*06c3fb27SDimitry Andric let Inst{6-0} = OPC_OP_V.Value; 1815ffd83dbSDimitry Andric 1825ffd83dbSDimitry Andric let Uses = [VTYPE, VL]; 183e8d8bef9SDimitry Andric let RVVConstraint = VMConstraint; 1845ffd83dbSDimitry Andric} 1855ffd83dbSDimitry Andric 1865ffd83dbSDimitry Andricclass RVInstV<bits<6> funct6, bits<5> vs1, RISCVVFormat opv, dag outs, 1875ffd83dbSDimitry Andric dag ins, string opcodestr, string argstr> 1885ffd83dbSDimitry Andric : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> { 1895ffd83dbSDimitry Andric bits<5> vs2; 1905ffd83dbSDimitry Andric bits<5> vd; 1915ffd83dbSDimitry Andric bit vm; 1925ffd83dbSDimitry Andric 1935ffd83dbSDimitry Andric let Inst{31-26} = funct6; 1945ffd83dbSDimitry Andric let Inst{25} = vm; 1955ffd83dbSDimitry Andric let Inst{24-20} = vs2; 1965ffd83dbSDimitry Andric let Inst{19-15} = vs1; 1975ffd83dbSDimitry Andric let Inst{14-12} = opv.Value; 1985ffd83dbSDimitry Andric let Inst{11-7} = vd; 199*06c3fb27SDimitry Andric let Inst{6-0} = OPC_OP_V.Value; 2005ffd83dbSDimitry Andric 2015ffd83dbSDimitry Andric let Uses = [VTYPE, VL]; 202e8d8bef9SDimitry Andric let RVVConstraint = VMConstraint; 2035ffd83dbSDimitry Andric} 2045ffd83dbSDimitry Andric 205e8d8bef9SDimitry Andricclass RVInstVLU<bits<3> nf, bit mew, RISCVLSUMOP lumop, 206e8d8bef9SDimitry Andric bits<3> width, dag outs, dag ins, string opcodestr, 2075ffd83dbSDimitry Andric string argstr> 2085ffd83dbSDimitry Andric : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> { 2095ffd83dbSDimitry Andric bits<5> rs1; 2105ffd83dbSDimitry Andric bits<5> vd; 2115ffd83dbSDimitry Andric bit vm; 2125ffd83dbSDimitry Andric 2135ffd83dbSDimitry Andric let Inst{31-29} = nf; 214e8d8bef9SDimitry Andric let Inst{28} = mew; 215e8d8bef9SDimitry Andric let Inst{27-26} = MOPLDUnitStride.Value; 2165ffd83dbSDimitry Andric let Inst{25} = vm; 2175ffd83dbSDimitry Andric let Inst{24-20} = lumop.Value; 2185ffd83dbSDimitry Andric let Inst{19-15} = rs1; 219e8d8bef9SDimitry Andric let Inst{14-12} = width; 2205ffd83dbSDimitry Andric let Inst{11-7} = vd; 221*06c3fb27SDimitry Andric let Inst{6-0} = OPC_LOAD_FP.Value; 2225ffd83dbSDimitry Andric 2235ffd83dbSDimitry Andric let Uses = [VTYPE, VL]; 224e8d8bef9SDimitry Andric let RVVConstraint = VMConstraint; 2255ffd83dbSDimitry Andric} 2265ffd83dbSDimitry Andric 227e8d8bef9SDimitry Andricclass RVInstVLS<bits<3> nf, bit mew, bits<3> width, 2285ffd83dbSDimitry Andric dag outs, dag ins, string opcodestr, string argstr> 2295ffd83dbSDimitry Andric : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> { 2305ffd83dbSDimitry Andric bits<5> rs2; 2315ffd83dbSDimitry Andric bits<5> rs1; 2325ffd83dbSDimitry Andric bits<5> vd; 2335ffd83dbSDimitry Andric bit vm; 2345ffd83dbSDimitry Andric 2355ffd83dbSDimitry Andric let Inst{31-29} = nf; 236e8d8bef9SDimitry Andric let Inst{28} = mew; 237e8d8bef9SDimitry Andric let Inst{27-26} = MOPLDStrided.Value; 2385ffd83dbSDimitry Andric let Inst{25} = vm; 2395ffd83dbSDimitry Andric let Inst{24-20} = rs2; 2405ffd83dbSDimitry Andric let Inst{19-15} = rs1; 241e8d8bef9SDimitry Andric let Inst{14-12} = width; 2425ffd83dbSDimitry Andric let Inst{11-7} = vd; 243*06c3fb27SDimitry Andric let Inst{6-0} = OPC_LOAD_FP.Value; 2445ffd83dbSDimitry Andric 2455ffd83dbSDimitry Andric let Uses = [VTYPE, VL]; 246e8d8bef9SDimitry Andric let RVVConstraint = VMConstraint; 2475ffd83dbSDimitry Andric} 2485ffd83dbSDimitry Andric 249e8d8bef9SDimitry Andricclass RVInstVLX<bits<3> nf, bit mew, RISCVMOP mop, bits<3> width, 2505ffd83dbSDimitry Andric dag outs, dag ins, string opcodestr, string argstr> 2515ffd83dbSDimitry Andric : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> { 2525ffd83dbSDimitry Andric bits<5> vs2; 2535ffd83dbSDimitry Andric bits<5> rs1; 2545ffd83dbSDimitry Andric bits<5> vd; 2555ffd83dbSDimitry Andric bit vm; 2565ffd83dbSDimitry Andric 2575ffd83dbSDimitry Andric let Inst{31-29} = nf; 258e8d8bef9SDimitry Andric let Inst{28} = mew; 259e8d8bef9SDimitry Andric let Inst{27-26} = mop.Value; 2605ffd83dbSDimitry Andric let Inst{25} = vm; 2615ffd83dbSDimitry Andric let Inst{24-20} = vs2; 2625ffd83dbSDimitry Andric let Inst{19-15} = rs1; 263e8d8bef9SDimitry Andric let Inst{14-12} = width; 2645ffd83dbSDimitry Andric let Inst{11-7} = vd; 265*06c3fb27SDimitry Andric let Inst{6-0} = OPC_LOAD_FP.Value; 2665ffd83dbSDimitry Andric 2675ffd83dbSDimitry Andric let Uses = [VTYPE, VL]; 268e8d8bef9SDimitry Andric let RVVConstraint = VMConstraint; 2695ffd83dbSDimitry Andric} 2705ffd83dbSDimitry Andric 271e8d8bef9SDimitry Andricclass RVInstVSU<bits<3> nf, bit mew, RISCVLSUMOP sumop, 272e8d8bef9SDimitry Andric bits<3> width, dag outs, dag ins, string opcodestr, 2735ffd83dbSDimitry Andric string argstr> 2745ffd83dbSDimitry Andric : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> { 2755ffd83dbSDimitry Andric bits<5> rs1; 2765ffd83dbSDimitry Andric bits<5> vs3; 2775ffd83dbSDimitry Andric bit vm; 2785ffd83dbSDimitry Andric 2795ffd83dbSDimitry Andric let Inst{31-29} = nf; 280e8d8bef9SDimitry Andric let Inst{28} = mew; 281e8d8bef9SDimitry Andric let Inst{27-26} = MOPSTUnitStride.Value; 2825ffd83dbSDimitry Andric let Inst{25} = vm; 2835ffd83dbSDimitry Andric let Inst{24-20} = sumop.Value; 2845ffd83dbSDimitry Andric let Inst{19-15} = rs1; 285e8d8bef9SDimitry Andric let Inst{14-12} = width; 2865ffd83dbSDimitry Andric let Inst{11-7} = vs3; 287*06c3fb27SDimitry Andric let Inst{6-0} = OPC_STORE_FP.Value; 2885ffd83dbSDimitry Andric 2895ffd83dbSDimitry Andric let Uses = [VTYPE, VL]; 2905ffd83dbSDimitry Andric} 2915ffd83dbSDimitry Andric 292e8d8bef9SDimitry Andricclass RVInstVSS<bits<3> nf, bit mew, bits<3> width, 2935ffd83dbSDimitry Andric dag outs, dag ins, string opcodestr, string argstr> 2945ffd83dbSDimitry Andric : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> { 2955ffd83dbSDimitry Andric bits<5> rs2; 2965ffd83dbSDimitry Andric bits<5> rs1; 2975ffd83dbSDimitry Andric bits<5> vs3; 2985ffd83dbSDimitry Andric bit vm; 2995ffd83dbSDimitry Andric 3005ffd83dbSDimitry Andric let Inst{31-29} = nf; 301e8d8bef9SDimitry Andric let Inst{28} = mew; 302e8d8bef9SDimitry Andric let Inst{27-26} = MOPSTStrided.Value; 3035ffd83dbSDimitry Andric let Inst{25} = vm; 3045ffd83dbSDimitry Andric let Inst{24-20} = rs2; 3055ffd83dbSDimitry Andric let Inst{19-15} = rs1; 306e8d8bef9SDimitry Andric let Inst{14-12} = width; 3075ffd83dbSDimitry Andric let Inst{11-7} = vs3; 308*06c3fb27SDimitry Andric let Inst{6-0} = OPC_STORE_FP.Value; 3095ffd83dbSDimitry Andric 3105ffd83dbSDimitry Andric let Uses = [VTYPE, VL]; 3115ffd83dbSDimitry Andric} 3125ffd83dbSDimitry Andric 313e8d8bef9SDimitry Andricclass RVInstVSX<bits<3> nf, bit mew, RISCVMOP mop, bits<3> width, 3145ffd83dbSDimitry Andric dag outs, dag ins, string opcodestr, string argstr> 3155ffd83dbSDimitry Andric : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> { 3165ffd83dbSDimitry Andric bits<5> vs2; 3175ffd83dbSDimitry Andric bits<5> rs1; 3185ffd83dbSDimitry Andric bits<5> vs3; 3195ffd83dbSDimitry Andric bit vm; 3205ffd83dbSDimitry Andric 3215ffd83dbSDimitry Andric let Inst{31-29} = nf; 322e8d8bef9SDimitry Andric let Inst{28} = mew; 323e8d8bef9SDimitry Andric let Inst{27-26} = mop.Value; 3245ffd83dbSDimitry Andric let Inst{25} = vm; 3255ffd83dbSDimitry Andric let Inst{24-20} = vs2; 3265ffd83dbSDimitry Andric let Inst{19-15} = rs1; 327e8d8bef9SDimitry Andric let Inst{14-12} = width; 3285ffd83dbSDimitry Andric let Inst{11-7} = vs3; 329*06c3fb27SDimitry Andric let Inst{6-0} = OPC_STORE_FP.Value; 3305ffd83dbSDimitry Andric 3315ffd83dbSDimitry Andric let Uses = [VTYPE, VL]; 3325ffd83dbSDimitry Andric} 333