10b57cec5SDimitry Andric//===-- RISCVRegisterInfo.td - RISC-V Register defs --------*- tablegen -*-===// 20b57cec5SDimitry Andric// 30b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric// 70b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric 90b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 100b57cec5SDimitry Andric// Declarations that describe the RISC-V register files 110b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 120b57cec5SDimitry Andric 130b57cec5SDimitry Andriclet Namespace = "RISCV" in { 140b57cec5SDimitry Andricclass RISCVReg<bits<5> Enc, string n, list<string> alt = []> : Register<n> { 150b57cec5SDimitry Andric let HWEncoding{4-0} = Enc; 160b57cec5SDimitry Andric let AltNames = alt; 170b57cec5SDimitry Andric} 180b57cec5SDimitry Andric 19e8d8bef9SDimitry Andricclass RISCVReg16<bits<5> Enc, string n, list<string> alt = []> : Register<n> { 200b57cec5SDimitry Andric let HWEncoding{4-0} = Enc; 210b57cec5SDimitry Andric let AltNames = alt; 220b57cec5SDimitry Andric} 230b57cec5SDimitry Andric 24e8d8bef9SDimitry Andricdef sub_16 : SubRegIndex<16>; 25e8d8bef9SDimitry Andricclass RISCVReg32<RISCVReg16 subreg> : Register<""> { 26e8d8bef9SDimitry Andric let HWEncoding{4-0} = subreg.HWEncoding{4-0}; 27e8d8bef9SDimitry Andric let SubRegs = [subreg]; 28e8d8bef9SDimitry Andric let SubRegIndices = [sub_16]; 29e8d8bef9SDimitry Andric let AsmName = subreg.AsmName; 30e8d8bef9SDimitry Andric let AltNames = subreg.AltNames; 31e8d8bef9SDimitry Andric} 32e8d8bef9SDimitry Andric 330b57cec5SDimitry Andric// Because RISCVReg64 register have AsmName and AltNames that alias with their 34e8d8bef9SDimitry Andric// 16/32-bit sub-register, RISCVAsmParser will need to coerce a register number 35e8d8bef9SDimitry Andric// from a RISCVReg16/RISCVReg32 to the equivalent RISCVReg64 when appropriate. 360b57cec5SDimitry Andricdef sub_32 : SubRegIndex<32>; 370b57cec5SDimitry Andricclass RISCVReg64<RISCVReg32 subreg> : Register<""> { 380b57cec5SDimitry Andric let HWEncoding{4-0} = subreg.HWEncoding{4-0}; 390b57cec5SDimitry Andric let SubRegs = [subreg]; 400b57cec5SDimitry Andric let SubRegIndices = [sub_32]; 410b57cec5SDimitry Andric let AsmName = subreg.AsmName; 420b57cec5SDimitry Andric let AltNames = subreg.AltNames; 430b57cec5SDimitry Andric} 440b57cec5SDimitry Andric 455ffd83dbSDimitry Andricclass RISCVRegWithSubRegs<bits<5> Enc, string n, list<Register> subregs, 465ffd83dbSDimitry Andric list<string> alt = []> 475ffd83dbSDimitry Andric : RegisterWithSubRegs<n, subregs> { 485ffd83dbSDimitry Andric let HWEncoding{4-0} = Enc; 495ffd83dbSDimitry Andric let AltNames = alt; 505ffd83dbSDimitry Andric} 515ffd83dbSDimitry Andric 520b57cec5SDimitry Andricdef ABIRegAltName : RegAltNameIndex; 535ffd83dbSDimitry Andric 54fe6060f1SDimitry Andricdef sub_vrm4_0 : SubRegIndex<256>; 55fe6060f1SDimitry Andricdef sub_vrm4_1 : SubRegIndex<256, 256>; 56fe6060f1SDimitry Andricdef sub_vrm2_0 : SubRegIndex<128>; 57fe6060f1SDimitry Andricdef sub_vrm2_1 : SubRegIndex<128, 128>; 58fe6060f1SDimitry Andricdef sub_vrm2_2 : ComposedSubRegIndex<sub_vrm4_1, sub_vrm2_0>; 59fe6060f1SDimitry Andricdef sub_vrm2_3 : ComposedSubRegIndex<sub_vrm4_1, sub_vrm2_1>; 60fe6060f1SDimitry Andricdef sub_vrm1_0 : SubRegIndex<64>; 61fe6060f1SDimitry Andricdef sub_vrm1_1 : SubRegIndex<64, 64>; 62fe6060f1SDimitry Andricdef sub_vrm1_2 : ComposedSubRegIndex<sub_vrm2_1, sub_vrm1_0>; 63fe6060f1SDimitry Andricdef sub_vrm1_3 : ComposedSubRegIndex<sub_vrm2_1, sub_vrm1_1>; 64fe6060f1SDimitry Andricdef sub_vrm1_4 : ComposedSubRegIndex<sub_vrm2_2, sub_vrm1_0>; 65fe6060f1SDimitry Andricdef sub_vrm1_5 : ComposedSubRegIndex<sub_vrm2_2, sub_vrm1_1>; 66fe6060f1SDimitry Andricdef sub_vrm1_6 : ComposedSubRegIndex<sub_vrm2_3, sub_vrm1_0>; 67fe6060f1SDimitry Andricdef sub_vrm1_7 : ComposedSubRegIndex<sub_vrm2_3, sub_vrm1_1>; 68e8d8bef9SDimitry Andric 69d56accc7SDimitry Andricdef sub_32_hi : SubRegIndex<32, 32>; 700b57cec5SDimitry Andric} // Namespace = "RISCV" 710b57cec5SDimitry Andric 720b57cec5SDimitry Andric// Integer registers 730b57cec5SDimitry Andric// CostPerUse is set higher for registers that may not be compressible as they 740b57cec5SDimitry Andric// are not part of GPRC, the most restrictive register class used by the 750b57cec5SDimitry Andric// compressed instruction set. This will influence the greedy register 760b57cec5SDimitry Andric// allocator to reduce the use of registers that can't be encoded in 16 bit 7704eeddc0SDimitry Andric// instructions. 780b57cec5SDimitry Andric 790b57cec5SDimitry Andriclet RegAltNameIndices = [ABIRegAltName] in { 80*bdd1243dSDimitry Andric let isConstant = true in 810b57cec5SDimitry Andric def X0 : RISCVReg<0, "x0", ["zero"]>, DwarfRegNum<[0]>; 8204eeddc0SDimitry Andric let CostPerUse = [0, 1] in { 830b57cec5SDimitry Andric def X1 : RISCVReg<1, "x1", ["ra"]>, DwarfRegNum<[1]>; 840b57cec5SDimitry Andric def X2 : RISCVReg<2, "x2", ["sp"]>, DwarfRegNum<[2]>; 850b57cec5SDimitry Andric def X3 : RISCVReg<3, "x3", ["gp"]>, DwarfRegNum<[3]>; 860b57cec5SDimitry Andric def X4 : RISCVReg<4, "x4", ["tp"]>, DwarfRegNum<[4]>; 870b57cec5SDimitry Andric def X5 : RISCVReg<5, "x5", ["t0"]>, DwarfRegNum<[5]>; 880b57cec5SDimitry Andric def X6 : RISCVReg<6, "x6", ["t1"]>, DwarfRegNum<[6]>; 890b57cec5SDimitry Andric def X7 : RISCVReg<7, "x7", ["t2"]>, DwarfRegNum<[7]>; 900b57cec5SDimitry Andric } 910b57cec5SDimitry Andric def X8 : RISCVReg<8, "x8", ["s0", "fp"]>, DwarfRegNum<[8]>; 920b57cec5SDimitry Andric def X9 : RISCVReg<9, "x9", ["s1"]>, DwarfRegNum<[9]>; 930b57cec5SDimitry Andric def X10 : RISCVReg<10,"x10", ["a0"]>, DwarfRegNum<[10]>; 940b57cec5SDimitry Andric def X11 : RISCVReg<11,"x11", ["a1"]>, DwarfRegNum<[11]>; 950b57cec5SDimitry Andric def X12 : RISCVReg<12,"x12", ["a2"]>, DwarfRegNum<[12]>; 960b57cec5SDimitry Andric def X13 : RISCVReg<13,"x13", ["a3"]>, DwarfRegNum<[13]>; 970b57cec5SDimitry Andric def X14 : RISCVReg<14,"x14", ["a4"]>, DwarfRegNum<[14]>; 980b57cec5SDimitry Andric def X15 : RISCVReg<15,"x15", ["a5"]>, DwarfRegNum<[15]>; 9904eeddc0SDimitry Andric let CostPerUse = [0, 1] in { 1000b57cec5SDimitry Andric def X16 : RISCVReg<16,"x16", ["a6"]>, DwarfRegNum<[16]>; 1010b57cec5SDimitry Andric def X17 : RISCVReg<17,"x17", ["a7"]>, DwarfRegNum<[17]>; 1020b57cec5SDimitry Andric def X18 : RISCVReg<18,"x18", ["s2"]>, DwarfRegNum<[18]>; 1030b57cec5SDimitry Andric def X19 : RISCVReg<19,"x19", ["s3"]>, DwarfRegNum<[19]>; 1040b57cec5SDimitry Andric def X20 : RISCVReg<20,"x20", ["s4"]>, DwarfRegNum<[20]>; 1050b57cec5SDimitry Andric def X21 : RISCVReg<21,"x21", ["s5"]>, DwarfRegNum<[21]>; 1060b57cec5SDimitry Andric def X22 : RISCVReg<22,"x22", ["s6"]>, DwarfRegNum<[22]>; 1070b57cec5SDimitry Andric def X23 : RISCVReg<23,"x23", ["s7"]>, DwarfRegNum<[23]>; 1080b57cec5SDimitry Andric def X24 : RISCVReg<24,"x24", ["s8"]>, DwarfRegNum<[24]>; 1090b57cec5SDimitry Andric def X25 : RISCVReg<25,"x25", ["s9"]>, DwarfRegNum<[25]>; 1100b57cec5SDimitry Andric def X26 : RISCVReg<26,"x26", ["s10"]>, DwarfRegNum<[26]>; 1110b57cec5SDimitry Andric def X27 : RISCVReg<27,"x27", ["s11"]>, DwarfRegNum<[27]>; 1120b57cec5SDimitry Andric def X28 : RISCVReg<28,"x28", ["t3"]>, DwarfRegNum<[28]>; 1130b57cec5SDimitry Andric def X29 : RISCVReg<29,"x29", ["t4"]>, DwarfRegNum<[29]>; 1140b57cec5SDimitry Andric def X30 : RISCVReg<30,"x30", ["t5"]>, DwarfRegNum<[30]>; 1150b57cec5SDimitry Andric def X31 : RISCVReg<31,"x31", ["t6"]>, DwarfRegNum<[31]>; 1160b57cec5SDimitry Andric } 1170b57cec5SDimitry Andric} 1180b57cec5SDimitry Andric 119e8d8bef9SDimitry Andricdef XLenVT : ValueTypeByHwMode<[RV32, RV64], 120e8d8bef9SDimitry Andric [i32, i64]>; 121fe6060f1SDimitry Andricdef XLenRI : RegInfoByHwMode< 122fe6060f1SDimitry Andric [RV32, RV64], 123fe6060f1SDimitry Andric [RegInfo<32,32,32>, RegInfo<64,64,64>]>; 1240b57cec5SDimitry Andric 1250b57cec5SDimitry Andric// The order of registers represents the preferred allocation sequence. 1260b57cec5SDimitry Andric// Registers are listed in the order caller-save, callee-save, specials. 1270b57cec5SDimitry Andricdef GPR : RegisterClass<"RISCV", [XLenVT], 32, (add 1280b57cec5SDimitry Andric (sequence "X%u", 10, 17), 1290b57cec5SDimitry Andric (sequence "X%u", 5, 7), 1300b57cec5SDimitry Andric (sequence "X%u", 28, 31), 1310b57cec5SDimitry Andric (sequence "X%u", 8, 9), 1320b57cec5SDimitry Andric (sequence "X%u", 18, 27), 1330b57cec5SDimitry Andric (sequence "X%u", 0, 4) 1340b57cec5SDimitry Andric )> { 135fe6060f1SDimitry Andric let RegInfos = XLenRI; 1360b57cec5SDimitry Andric} 1370b57cec5SDimitry Andric 1388bcb0991SDimitry Andricdef GPRX0 : RegisterClass<"RISCV", [XLenVT], 32, (add X0)> { 139fe6060f1SDimitry Andric let RegInfos = XLenRI; 1408bcb0991SDimitry Andric} 1418bcb0991SDimitry Andric 14204eeddc0SDimitry Andricdef GPRNoX0 : RegisterClass<"RISCV", [XLenVT], 32, (sub GPR, X0)> { 143fe6060f1SDimitry Andric let RegInfos = XLenRI; 1440b57cec5SDimitry Andric} 1450b57cec5SDimitry Andric 14604eeddc0SDimitry Andricdef GPRNoX0X2 : RegisterClass<"RISCV", [XLenVT], 32, (sub GPR, X0, X2)> { 147fe6060f1SDimitry Andric let RegInfos = XLenRI; 148fe6060f1SDimitry Andric} 149fe6060f1SDimitry Andric 150fe6060f1SDimitry Andric// Don't use X1 or X5 for JALR since that is a hint to pop the return address 151fe6060f1SDimitry Andric// stack on some microarchitectures. Also remove the reserved registers X0, X2, 152fe6060f1SDimitry Andric// X3, and X4 as it reduces the number of register classes that get synthesized 153fe6060f1SDimitry Andric// by tablegen. 15404eeddc0SDimitry Andricdef GPRJALR : RegisterClass<"RISCV", [XLenVT], 32, (sub GPR, (sequence "X%u", 0, 5))> { 155fe6060f1SDimitry Andric let RegInfos = XLenRI; 1560b57cec5SDimitry Andric} 1570b57cec5SDimitry Andric 1580b57cec5SDimitry Andricdef GPRC : RegisterClass<"RISCV", [XLenVT], 32, (add 1590b57cec5SDimitry Andric (sequence "X%u", 10, 15), 1600b57cec5SDimitry Andric (sequence "X%u", 8, 9) 1610b57cec5SDimitry Andric )> { 162fe6060f1SDimitry Andric let RegInfos = XLenRI; 1630b57cec5SDimitry Andric} 1640b57cec5SDimitry Andric 1650b57cec5SDimitry Andric// For indirect tail calls, we can't use callee-saved registers, as they are 1660b57cec5SDimitry Andric// restored to the saved value before the tail call, which would clobber a call 167fe6060f1SDimitry Andric// address. We shouldn't use x5 since that is a hint for to pop the return 168fe6060f1SDimitry Andric// address stack on some microarchitectures. 1690b57cec5SDimitry Andricdef GPRTC : RegisterClass<"RISCV", [XLenVT], 32, (add 170fe6060f1SDimitry Andric (sequence "X%u", 6, 7), 1710b57cec5SDimitry Andric (sequence "X%u", 10, 17), 1720b57cec5SDimitry Andric (sequence "X%u", 28, 31) 1730b57cec5SDimitry Andric )> { 174fe6060f1SDimitry Andric let RegInfos = XLenRI; 1750b57cec5SDimitry Andric} 1760b57cec5SDimitry Andric 1770b57cec5SDimitry Andricdef SP : RegisterClass<"RISCV", [XLenVT], 32, (add X2)> { 178fe6060f1SDimitry Andric let RegInfos = XLenRI; 1790b57cec5SDimitry Andric} 1800b57cec5SDimitry Andric 1810b57cec5SDimitry Andric// Floating point registers 1820b57cec5SDimitry Andriclet RegAltNameIndices = [ABIRegAltName] in { 183e8d8bef9SDimitry Andric def F0_H : RISCVReg16<0, "f0", ["ft0"]>, DwarfRegNum<[32]>; 184e8d8bef9SDimitry Andric def F1_H : RISCVReg16<1, "f1", ["ft1"]>, DwarfRegNum<[33]>; 185e8d8bef9SDimitry Andric def F2_H : RISCVReg16<2, "f2", ["ft2"]>, DwarfRegNum<[34]>; 186e8d8bef9SDimitry Andric def F3_H : RISCVReg16<3, "f3", ["ft3"]>, DwarfRegNum<[35]>; 187e8d8bef9SDimitry Andric def F4_H : RISCVReg16<4, "f4", ["ft4"]>, DwarfRegNum<[36]>; 188e8d8bef9SDimitry Andric def F5_H : RISCVReg16<5, "f5", ["ft5"]>, DwarfRegNum<[37]>; 189e8d8bef9SDimitry Andric def F6_H : RISCVReg16<6, "f6", ["ft6"]>, DwarfRegNum<[38]>; 190e8d8bef9SDimitry Andric def F7_H : RISCVReg16<7, "f7", ["ft7"]>, DwarfRegNum<[39]>; 191e8d8bef9SDimitry Andric def F8_H : RISCVReg16<8, "f8", ["fs0"]>, DwarfRegNum<[40]>; 192e8d8bef9SDimitry Andric def F9_H : RISCVReg16<9, "f9", ["fs1"]>, DwarfRegNum<[41]>; 193e8d8bef9SDimitry Andric def F10_H : RISCVReg16<10,"f10", ["fa0"]>, DwarfRegNum<[42]>; 194e8d8bef9SDimitry Andric def F11_H : RISCVReg16<11,"f11", ["fa1"]>, DwarfRegNum<[43]>; 195e8d8bef9SDimitry Andric def F12_H : RISCVReg16<12,"f12", ["fa2"]>, DwarfRegNum<[44]>; 196e8d8bef9SDimitry Andric def F13_H : RISCVReg16<13,"f13", ["fa3"]>, DwarfRegNum<[45]>; 197e8d8bef9SDimitry Andric def F14_H : RISCVReg16<14,"f14", ["fa4"]>, DwarfRegNum<[46]>; 198e8d8bef9SDimitry Andric def F15_H : RISCVReg16<15,"f15", ["fa5"]>, DwarfRegNum<[47]>; 199e8d8bef9SDimitry Andric def F16_H : RISCVReg16<16,"f16", ["fa6"]>, DwarfRegNum<[48]>; 200e8d8bef9SDimitry Andric def F17_H : RISCVReg16<17,"f17", ["fa7"]>, DwarfRegNum<[49]>; 201e8d8bef9SDimitry Andric def F18_H : RISCVReg16<18,"f18", ["fs2"]>, DwarfRegNum<[50]>; 202e8d8bef9SDimitry Andric def F19_H : RISCVReg16<19,"f19", ["fs3"]>, DwarfRegNum<[51]>; 203e8d8bef9SDimitry Andric def F20_H : RISCVReg16<20,"f20", ["fs4"]>, DwarfRegNum<[52]>; 204e8d8bef9SDimitry Andric def F21_H : RISCVReg16<21,"f21", ["fs5"]>, DwarfRegNum<[53]>; 205e8d8bef9SDimitry Andric def F22_H : RISCVReg16<22,"f22", ["fs6"]>, DwarfRegNum<[54]>; 206e8d8bef9SDimitry Andric def F23_H : RISCVReg16<23,"f23", ["fs7"]>, DwarfRegNum<[55]>; 207e8d8bef9SDimitry Andric def F24_H : RISCVReg16<24,"f24", ["fs8"]>, DwarfRegNum<[56]>; 208e8d8bef9SDimitry Andric def F25_H : RISCVReg16<25,"f25", ["fs9"]>, DwarfRegNum<[57]>; 209e8d8bef9SDimitry Andric def F26_H : RISCVReg16<26,"f26", ["fs10"]>, DwarfRegNum<[58]>; 210e8d8bef9SDimitry Andric def F27_H : RISCVReg16<27,"f27", ["fs11"]>, DwarfRegNum<[59]>; 211e8d8bef9SDimitry Andric def F28_H : RISCVReg16<28,"f28", ["ft8"]>, DwarfRegNum<[60]>; 212e8d8bef9SDimitry Andric def F29_H : RISCVReg16<29,"f29", ["ft9"]>, DwarfRegNum<[61]>; 213e8d8bef9SDimitry Andric def F30_H : RISCVReg16<30,"f30", ["ft10"]>, DwarfRegNum<[62]>; 214e8d8bef9SDimitry Andric def F31_H : RISCVReg16<31,"f31", ["ft11"]>, DwarfRegNum<[63]>; 215e8d8bef9SDimitry Andric 216e8d8bef9SDimitry Andric foreach Index = 0-31 in { 217e8d8bef9SDimitry Andric def F#Index#_F : RISCVReg32<!cast<RISCVReg16>("F"#Index#"_H")>, 218e8d8bef9SDimitry Andric DwarfRegNum<[!add(Index, 32)]>; 219e8d8bef9SDimitry Andric } 2200b57cec5SDimitry Andric 2210b57cec5SDimitry Andric foreach Index = 0-31 in { 2228bcb0991SDimitry Andric def F#Index#_D : RISCVReg64<!cast<RISCVReg32>("F"#Index#"_F")>, 2230b57cec5SDimitry Andric DwarfRegNum<[!add(Index, 32)]>; 2240b57cec5SDimitry Andric } 2250b57cec5SDimitry Andric} 2260b57cec5SDimitry Andric 2270b57cec5SDimitry Andric// The order of registers represents the preferred allocation sequence, 2280b57cec5SDimitry Andric// meaning caller-save regs are listed before callee-save. 229e8d8bef9SDimitry Andricdef FPR16 : RegisterClass<"RISCV", [f16], 16, (add 230e8d8bef9SDimitry Andric (sequence "F%u_H", 0, 7), 231e8d8bef9SDimitry Andric (sequence "F%u_H", 10, 17), 232e8d8bef9SDimitry Andric (sequence "F%u_H", 28, 31), 233e8d8bef9SDimitry Andric (sequence "F%u_H", 8, 9), 234e8d8bef9SDimitry Andric (sequence "F%u_H", 18, 27) 235e8d8bef9SDimitry Andric)>; 236e8d8bef9SDimitry Andric 2370b57cec5SDimitry Andricdef FPR32 : RegisterClass<"RISCV", [f32], 32, (add 2388bcb0991SDimitry Andric (sequence "F%u_F", 0, 7), 2398bcb0991SDimitry Andric (sequence "F%u_F", 10, 17), 2408bcb0991SDimitry Andric (sequence "F%u_F", 28, 31), 2418bcb0991SDimitry Andric (sequence "F%u_F", 8, 9), 2428bcb0991SDimitry Andric (sequence "F%u_F", 18, 27) 2430b57cec5SDimitry Andric)>; 2440b57cec5SDimitry Andric 2450b57cec5SDimitry Andricdef FPR32C : RegisterClass<"RISCV", [f32], 32, (add 2468bcb0991SDimitry Andric (sequence "F%u_F", 10, 15), 2478bcb0991SDimitry Andric (sequence "F%u_F", 8, 9) 2480b57cec5SDimitry Andric)>; 2490b57cec5SDimitry Andric 2500b57cec5SDimitry Andric// The order of registers represents the preferred allocation sequence, 2510b57cec5SDimitry Andric// meaning caller-save regs are listed before callee-save. 2520b57cec5SDimitry Andricdef FPR64 : RegisterClass<"RISCV", [f64], 64, (add 2538bcb0991SDimitry Andric (sequence "F%u_D", 0, 7), 2548bcb0991SDimitry Andric (sequence "F%u_D", 10, 17), 2558bcb0991SDimitry Andric (sequence "F%u_D", 28, 31), 2568bcb0991SDimitry Andric (sequence "F%u_D", 8, 9), 2578bcb0991SDimitry Andric (sequence "F%u_D", 18, 27) 2580b57cec5SDimitry Andric)>; 2590b57cec5SDimitry Andric 2600b57cec5SDimitry Andricdef FPR64C : RegisterClass<"RISCV", [f64], 64, (add 2618bcb0991SDimitry Andric (sequence "F%u_D", 10, 15), 2628bcb0991SDimitry Andric (sequence "F%u_D", 8, 9) 2630b57cec5SDimitry Andric)>; 2645ffd83dbSDimitry Andric 265e8d8bef9SDimitry Andric// Vector type mapping to LLVM types. 266e8d8bef9SDimitry Andric// 267fe6060f1SDimitry Andric// The V vector extension requires that VLEN >= 128 and <= 65536. 268e8d8bef9SDimitry Andric// Additionally, the only supported ELEN values are 32 and 64, 269e8d8bef9SDimitry Andric// thus `vscale` can be defined as VLEN/64, 270e8d8bef9SDimitry Andric// allowing the same types with either ELEN value. 271e8d8bef9SDimitry Andric// 272e8d8bef9SDimitry Andric// MF8 MF4 MF2 M1 M2 M4 M8 273e8d8bef9SDimitry Andric// i64* N/A N/A N/A nxv1i64 nxv2i64 nxv4i64 nxv8i64 274e8d8bef9SDimitry Andric// i32 N/A N/A nxv1i32 nxv2i32 nxv4i32 nxv8i32 nxv16i32 275e8d8bef9SDimitry Andric// i16 N/A nxv1i16 nxv2i16 nxv4i16 nxv8i16 nxv16i16 nxv32i16 276e8d8bef9SDimitry Andric// i8 nxv1i8 nxv2i8 nxv4i8 nxv8i8 nxv16i8 nxv32i8 nxv64i8 277e8d8bef9SDimitry Andric// double* N/A N/A N/A nxv1f64 nxv2f64 nxv4f64 nxv8f64 278e8d8bef9SDimitry Andric// float N/A N/A nxv1f32 nxv2f32 nxv4f32 nxv8f32 nxv16f32 279e8d8bef9SDimitry Andric// half N/A nxv1f16 nxv2f16 nxv4f16 nxv8f16 nxv16f16 nxv32f16 280e8d8bef9SDimitry Andric// * ELEN=64 281e8d8bef9SDimitry Andric 282e8d8bef9SDimitry Andricdefvar vint8mf8_t = nxv1i8; 283e8d8bef9SDimitry Andricdefvar vint8mf4_t = nxv2i8; 284e8d8bef9SDimitry Andricdefvar vint8mf2_t = nxv4i8; 285e8d8bef9SDimitry Andricdefvar vint8m1_t = nxv8i8; 286e8d8bef9SDimitry Andricdefvar vint8m2_t = nxv16i8; 287e8d8bef9SDimitry Andricdefvar vint8m4_t = nxv32i8; 288e8d8bef9SDimitry Andricdefvar vint8m8_t = nxv64i8; 289e8d8bef9SDimitry Andric 290e8d8bef9SDimitry Andricdefvar vint16mf4_t = nxv1i16; 291e8d8bef9SDimitry Andricdefvar vint16mf2_t = nxv2i16; 292e8d8bef9SDimitry Andricdefvar vint16m1_t = nxv4i16; 293e8d8bef9SDimitry Andricdefvar vint16m2_t = nxv8i16; 294e8d8bef9SDimitry Andricdefvar vint16m4_t = nxv16i16; 295e8d8bef9SDimitry Andricdefvar vint16m8_t = nxv32i16; 296e8d8bef9SDimitry Andric 297e8d8bef9SDimitry Andricdefvar vint32mf2_t = nxv1i32; 298e8d8bef9SDimitry Andricdefvar vint32m1_t = nxv2i32; 299e8d8bef9SDimitry Andricdefvar vint32m2_t = nxv4i32; 300e8d8bef9SDimitry Andricdefvar vint32m4_t = nxv8i32; 301e8d8bef9SDimitry Andricdefvar vint32m8_t = nxv16i32; 302e8d8bef9SDimitry Andric 303e8d8bef9SDimitry Andricdefvar vint64m1_t = nxv1i64; 304e8d8bef9SDimitry Andricdefvar vint64m2_t = nxv2i64; 305e8d8bef9SDimitry Andricdefvar vint64m4_t = nxv4i64; 306e8d8bef9SDimitry Andricdefvar vint64m8_t = nxv8i64; 307e8d8bef9SDimitry Andric 308e8d8bef9SDimitry Andricdefvar vfloat16mf4_t = nxv1f16; 309e8d8bef9SDimitry Andricdefvar vfloat16mf2_t = nxv2f16; 310e8d8bef9SDimitry Andricdefvar vfloat16m1_t = nxv4f16; 311e8d8bef9SDimitry Andricdefvar vfloat16m2_t = nxv8f16; 312e8d8bef9SDimitry Andricdefvar vfloat16m4_t = nxv16f16; 313e8d8bef9SDimitry Andricdefvar vfloat16m8_t = nxv32f16; 314e8d8bef9SDimitry Andric 315e8d8bef9SDimitry Andricdefvar vfloat32mf2_t = nxv1f32; 316e8d8bef9SDimitry Andricdefvar vfloat32m1_t = nxv2f32; 317e8d8bef9SDimitry Andricdefvar vfloat32m2_t = nxv4f32; 318e8d8bef9SDimitry Andricdefvar vfloat32m4_t = nxv8f32; 319e8d8bef9SDimitry Andricdefvar vfloat32m8_t = nxv16f32; 320e8d8bef9SDimitry Andric 321e8d8bef9SDimitry Andricdefvar vfloat64m1_t = nxv1f64; 322e8d8bef9SDimitry Andricdefvar vfloat64m2_t = nxv2f64; 323e8d8bef9SDimitry Andricdefvar vfloat64m4_t = nxv4f64; 324e8d8bef9SDimitry Andricdefvar vfloat64m8_t = nxv8f64; 325e8d8bef9SDimitry Andric 326e8d8bef9SDimitry Andricdefvar vbool1_t = nxv64i1; 327e8d8bef9SDimitry Andricdefvar vbool2_t = nxv32i1; 328e8d8bef9SDimitry Andricdefvar vbool4_t = nxv16i1; 329e8d8bef9SDimitry Andricdefvar vbool8_t = nxv8i1; 330e8d8bef9SDimitry Andricdefvar vbool16_t = nxv4i1; 331e8d8bef9SDimitry Andricdefvar vbool32_t = nxv2i1; 332e8d8bef9SDimitry Andricdefvar vbool64_t = nxv1i1; 333e8d8bef9SDimitry Andric 334e8d8bef9SDimitry Andric// There is no need to define register classes for fractional LMUL. 335e8d8bef9SDimitry Andricdef LMULList { 336e8d8bef9SDimitry Andric list<int> m = [1, 2, 4, 8]; 337e8d8bef9SDimitry Andric} 338e8d8bef9SDimitry Andric 339e8d8bef9SDimitry Andric//===----------------------------------------------------------------------===// 340e8d8bef9SDimitry Andric// Utility classes for segment load/store. 341e8d8bef9SDimitry Andric//===----------------------------------------------------------------------===// 342e8d8bef9SDimitry Andric// The set of legal NF for LMUL = lmul. 343e8d8bef9SDimitry Andric// LMUL == 1, NF = 2, 3, 4, 5, 6, 7, 8 344e8d8bef9SDimitry Andric// LMUL == 2, NF = 2, 3, 4 345e8d8bef9SDimitry Andric// LMUL == 4, NF = 2 346e8d8bef9SDimitry Andricclass NFList<int lmul> { 347e8d8bef9SDimitry Andric list<int> L = !cond(!eq(lmul, 1): [2, 3, 4, 5, 6, 7, 8], 348e8d8bef9SDimitry Andric !eq(lmul, 2): [2, 3, 4], 349e8d8bef9SDimitry Andric !eq(lmul, 4): [2], 350e8d8bef9SDimitry Andric !eq(lmul, 8): []); 351e8d8bef9SDimitry Andric} 352e8d8bef9SDimitry Andric 353e8d8bef9SDimitry Andric// Generate [start, end) SubRegIndex list. 354349cc55cSDimitry Andricclass SubRegSet<int nf, int lmul> { 355e8d8bef9SDimitry Andric list<SubRegIndex> L = !foldl([]<SubRegIndex>, 356e8d8bef9SDimitry Andric [0, 1, 2, 3, 4, 5, 6, 7], 357e8d8bef9SDimitry Andric AccList, i, 358e8d8bef9SDimitry Andric !listconcat(AccList, 359e8d8bef9SDimitry Andric !if(!lt(i, nf), 360e8d8bef9SDimitry Andric [!cast<SubRegIndex>("sub_vrm" # lmul # "_" # i)], 361e8d8bef9SDimitry Andric []))); 362e8d8bef9SDimitry Andric} 363e8d8bef9SDimitry Andric 364349cc55cSDimitry Andric// Collect the valid indexes into 'R' under NF and LMUL values from TUPLE_INDEX. 365349cc55cSDimitry Andric// When NF = 2, the valid TUPLE_INDEX is 0 and 1. 366349cc55cSDimitry Andric// For example, when LMUL = 4, the potential valid indexes is 367349cc55cSDimitry Andric// [8, 12, 16, 20, 24, 28, 4]. However, not all these indexes are valid under 368349cc55cSDimitry Andric// NF = 2. For example, 28 is not valid under LMUL = 4, NF = 2 and TUPLE_INDEX = 0. 369349cc55cSDimitry Andric// The filter is 370349cc55cSDimitry Andric// (tuple_index + i) x lmul <= (tuple_index x lmul) + 32 - (nf x lmul) 371349cc55cSDimitry Andric// 372349cc55cSDimitry Andric// Use START = 0, LMUL = 4 and NF = 2 as the example, 373349cc55cSDimitry Andric// i x 4 <= 24 374349cc55cSDimitry Andric// The class will return [8, 12, 16, 20, 24, 4]. 375349cc55cSDimitry Andric// Use START = 1, LMUL = 4 and NF = 2 as the example, 376349cc55cSDimitry Andric// (1 + i) x 4 <= 28 377349cc55cSDimitry Andric// The class will return [12, 16, 20, 24, 28, 8]. 378349cc55cSDimitry Andric// 379349cc55cSDimitry Andricclass IndexSet<int tuple_index, int nf, int lmul, bit isV0 = false> { 380e8d8bef9SDimitry Andric list<int> R = 381e8d8bef9SDimitry Andric !foldl([]<int>, 382349cc55cSDimitry Andric !if(isV0, [0], 383349cc55cSDimitry Andric !cond( 384349cc55cSDimitry Andric !eq(lmul, 1): 385349cc55cSDimitry Andric [8, 9, 10, 11, 12, 13, 14, 15, 386349cc55cSDimitry Andric 16, 17, 18, 19, 20, 21, 22, 23, 387349cc55cSDimitry Andric 24, 25, 26, 27, 28, 29, 30, 31, 388349cc55cSDimitry Andric 1, 2, 3, 4, 5, 6, 7], 389349cc55cSDimitry Andric !eq(lmul, 2): 390349cc55cSDimitry Andric [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3], 391349cc55cSDimitry Andric !eq(lmul, 4): 392349cc55cSDimitry Andric [2, 3, 4, 5, 6, 7, 1])), 393e8d8bef9SDimitry Andric L, i, 394e8d8bef9SDimitry Andric !listconcat(L, 395349cc55cSDimitry Andric !if(!le(!mul(!add(i, tuple_index), lmul), 396349cc55cSDimitry Andric !sub(!add(32, !mul(tuple_index, lmul)), !mul(nf, lmul))), 397349cc55cSDimitry Andric [!mul(!add(i, tuple_index), lmul)], []))); 398e8d8bef9SDimitry Andric} 399e8d8bef9SDimitry Andric 400349cc55cSDimitry Andric// This class returns a list of vector register collections. 401349cc55cSDimitry Andric// For example, for NF = 2 and LMUL = 4, 402349cc55cSDimitry Andric// it will return 403349cc55cSDimitry Andric// ([ V8M4, V12M4, V16M4, V20M4, V24M4, V4M4], 404349cc55cSDimitry Andric// [V12M4, V16M4, V20M4, V24M4, V28M4, V8M4]) 405349cc55cSDimitry Andric// 406349cc55cSDimitry Andricclass VRegList<list<dag> LIn, int start, int nf, int lmul, bit isV0> { 407e8d8bef9SDimitry Andric list<dag> L = 408e8d8bef9SDimitry Andric !if(!ge(start, nf), 409e8d8bef9SDimitry Andric LIn, 410e8d8bef9SDimitry Andric !listconcat( 411e8d8bef9SDimitry Andric [!dag(add, 412349cc55cSDimitry Andric !foreach(i, IndexSet<start, nf, lmul, isV0>.R, 413e8d8bef9SDimitry Andric !cast<Register>("V" # i # !cond(!eq(lmul, 2): "M2", 414e8d8bef9SDimitry Andric !eq(lmul, 4): "M4", 415e8d8bef9SDimitry Andric true: ""))), 416fe6060f1SDimitry Andric !listsplat("", 417349cc55cSDimitry Andric !size(IndexSet<start, nf, lmul, isV0>.R)))], 418349cc55cSDimitry Andric VRegList<LIn, !add(start, 1), nf, lmul, isV0>.L)); 419e8d8bef9SDimitry Andric} 420e8d8bef9SDimitry Andric 4215ffd83dbSDimitry Andric// Vector registers 4225ffd83dbSDimitry Andriclet RegAltNameIndices = [ABIRegAltName] in { 4235ffd83dbSDimitry Andric foreach Index = 0-31 in { 424e8d8bef9SDimitry Andric def V#Index : RISCVReg<Index, "v"#Index, ["v"#Index]>, DwarfRegNum<[!add(Index, 96)]>; 4255ffd83dbSDimitry Andric } 4265ffd83dbSDimitry Andric 4275ffd83dbSDimitry Andric foreach Index = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 4285ffd83dbSDimitry Andric 24, 26, 28, 30] in { 4295ffd83dbSDimitry Andric def V#Index#M2 : RISCVRegWithSubRegs<Index, "v"#Index, 4305ffd83dbSDimitry Andric [!cast<Register>("V"#Index), 4315ffd83dbSDimitry Andric !cast<Register>("V"#!add(Index, 1))], 4325ffd83dbSDimitry Andric ["v"#Index]>, 4335ffd83dbSDimitry Andric DwarfRegAlias<!cast<Register>("V"#Index)> { 434e8d8bef9SDimitry Andric let SubRegIndices = [sub_vrm1_0, sub_vrm1_1]; 4355ffd83dbSDimitry Andric } 4365ffd83dbSDimitry Andric } 4375ffd83dbSDimitry Andric 4385ffd83dbSDimitry Andric foreach Index = [0, 4, 8, 12, 16, 20, 24, 28] in { 4395ffd83dbSDimitry Andric def V#Index#M4 : RISCVRegWithSubRegs<Index, "v"#Index, 4405ffd83dbSDimitry Andric [!cast<Register>("V"#Index#"M2"), 4415ffd83dbSDimitry Andric !cast<Register>("V"#!add(Index, 2)#"M2")], 4425ffd83dbSDimitry Andric ["v"#Index]>, 4435ffd83dbSDimitry Andric DwarfRegAlias<!cast<Register>("V"#Index)> { 444e8d8bef9SDimitry Andric let SubRegIndices = [sub_vrm2_0, sub_vrm2_1]; 4455ffd83dbSDimitry Andric } 4465ffd83dbSDimitry Andric } 4475ffd83dbSDimitry Andric 4485ffd83dbSDimitry Andric foreach Index = [0, 8, 16, 24] in { 4495ffd83dbSDimitry Andric def V#Index#M8 : RISCVRegWithSubRegs<Index, "v"#Index, 4505ffd83dbSDimitry Andric [!cast<Register>("V"#Index#"M4"), 4515ffd83dbSDimitry Andric !cast<Register>("V"#!add(Index, 4)#"M4")], 4525ffd83dbSDimitry Andric ["v"#Index]>, 4535ffd83dbSDimitry Andric DwarfRegAlias<!cast<Register>("V"#Index)> { 454e8d8bef9SDimitry Andric let SubRegIndices = [sub_vrm4_0, sub_vrm4_1]; 4555ffd83dbSDimitry Andric } 4565ffd83dbSDimitry Andric } 4575ffd83dbSDimitry Andric 4585ffd83dbSDimitry Andric def VTYPE : RISCVReg<0, "vtype", ["vtype"]>; 4595ffd83dbSDimitry Andric def VL : RISCVReg<0, "vl", ["vl"]>; 460e8d8bef9SDimitry Andric def VXSAT : RISCVReg<0, "vxsat", ["vxsat"]>; 461e8d8bef9SDimitry Andric def VXRM : RISCVReg<0, "vxrm", ["vxrm"]>; 462*bdd1243dSDimitry Andric let isConstant = true in 4634824e7fdSDimitry Andric def VLENB : RISCVReg<0, "vlenb", ["vlenb"]>, 4644824e7fdSDimitry Andric DwarfRegNum<[!add(4096, SysRegVLENB.Encoding)]>; 4655ffd83dbSDimitry Andric} 4665ffd83dbSDimitry Andric 46781ad6265SDimitry Andricdef VCSR : RegisterClass<"RISCV", [XLenVT], 32, 46881ad6265SDimitry Andric (add VTYPE, VL, VLENB)> { 46981ad6265SDimitry Andric let RegInfos = XLenRI; 47081ad6265SDimitry Andric} 47181ad6265SDimitry Andric 47281ad6265SDimitry Andric 473e8d8bef9SDimitry Andricforeach m = [1, 2, 4] in { 474e8d8bef9SDimitry Andric foreach n = NFList<m>.L in { 475fe6060f1SDimitry Andric def "VN" # n # "M" # m # "NoV0": RegisterTuples< 476349cc55cSDimitry Andric SubRegSet<n, m>.L, 477349cc55cSDimitry Andric VRegList<[], 0, n, m, false>.L>; 478fe6060f1SDimitry Andric def "VN" # n # "M" # m # "V0" : RegisterTuples< 479349cc55cSDimitry Andric SubRegSet<n, m>.L, 480349cc55cSDimitry Andric VRegList<[], 0, n, m, true>.L>; 481e8d8bef9SDimitry Andric } 4825ffd83dbSDimitry Andric} 4835ffd83dbSDimitry Andric 484e8d8bef9SDimitry Andricclass VReg<list<ValueType> regTypes, dag regList, int Vlmul> 485e8d8bef9SDimitry Andric : RegisterClass<"RISCV", 486e8d8bef9SDimitry Andric regTypes, 487e8d8bef9SDimitry Andric 64, // The maximum supported ELEN is 64. 488e8d8bef9SDimitry Andric regList> { 489e8d8bef9SDimitry Andric int VLMul = Vlmul; 490e8d8bef9SDimitry Andric int Size = !mul(Vlmul, 64); 491e8d8bef9SDimitry Andric} 492e8d8bef9SDimitry Andric 493*bdd1243dSDimitry Andricdefvar VMaskVTs = [vbool1_t, vbool2_t, vbool4_t, vbool8_t, vbool16_t, 494*bdd1243dSDimitry Andric vbool32_t, vbool64_t]; 495*bdd1243dSDimitry Andric 496*bdd1243dSDimitry Andricdefvar VM1VTs = [vint8m1_t, vint16m1_t, vint32m1_t, vint64m1_t, 497fe6060f1SDimitry Andric vfloat16m1_t, vfloat32m1_t, vfloat64m1_t, 498fe6060f1SDimitry Andric vint8mf2_t, vint8mf4_t, vint8mf8_t, 499e8d8bef9SDimitry Andric vint16mf2_t, vint16mf4_t, vint32mf2_t, 500*bdd1243dSDimitry Andric vfloat16mf4_t, vfloat16mf2_t, vfloat32mf2_t]; 501*bdd1243dSDimitry Andric 502*bdd1243dSDimitry Andricdefvar VM2VTs = [vint8m2_t, vint16m2_t, vint32m2_t, vint64m2_t, 503*bdd1243dSDimitry Andric vfloat16m2_t, vfloat32m2_t, vfloat64m2_t]; 504*bdd1243dSDimitry Andric 505*bdd1243dSDimitry Andricdefvar VM4VTs = [vint8m4_t, vint16m4_t, vint32m4_t, vint64m4_t, 506*bdd1243dSDimitry Andric vfloat16m4_t, vfloat32m4_t, vfloat64m4_t]; 507*bdd1243dSDimitry Andric 508*bdd1243dSDimitry Andricdefvar VM8VTs = [vint8m8_t, vint16m8_t, vint32m8_t, vint64m8_t, 509*bdd1243dSDimitry Andric vfloat16m8_t, vfloat32m8_t, vfloat64m8_t]; 510*bdd1243dSDimitry Andric 511*bdd1243dSDimitry Andricdef VR : VReg<!listconcat(VM1VTs, VMaskVTs), 512349cc55cSDimitry Andric (add (sequence "V%u", 8, 31), 513e8d8bef9SDimitry Andric (sequence "V%u", 0, 7)), 1>; 5145ffd83dbSDimitry Andric 515*bdd1243dSDimitry Andricdef VRNoV0 : VReg<!listconcat(VM1VTs, VMaskVTs), 516349cc55cSDimitry Andric (add (sequence "V%u", 8, 31), 517e8d8bef9SDimitry Andric (sequence "V%u", 1, 7)), 1>; 518e8d8bef9SDimitry Andric 519*bdd1243dSDimitry Andricdef VRM2 : VReg<VM2VTs, (add (sequence "V%uM2", 8, 31, 2), 520349cc55cSDimitry Andric (sequence "V%uM2", 0, 7, 2)), 2>; 5215ffd83dbSDimitry Andric 522*bdd1243dSDimitry Andricdef VRM2NoV0 : VReg<VM2VTs, (add (sequence "V%uM2", 8, 31, 2), 523349cc55cSDimitry Andric (sequence "V%uM2", 2, 7, 2)), 2>; 5245ffd83dbSDimitry Andric 525*bdd1243dSDimitry Andricdef VRM4 : VReg<VM4VTs, 526349cc55cSDimitry Andric (add V8M4, V12M4, V16M4, V20M4, V24M4, V28M4, V0M4, V4M4), 4>; 5275ffd83dbSDimitry Andric 528*bdd1243dSDimitry Andricdef VRM4NoV0 : VReg<VM4VTs, 529349cc55cSDimitry Andric (add V8M4, V12M4, V16M4, V20M4, V24M4, V28M4, V4M4), 4>; 5305ffd83dbSDimitry Andric 531*bdd1243dSDimitry Andricdef VRM8 : VReg<VM8VTs, (add V8M8, V16M8, V24M8, V0M8), 8>; 532e8d8bef9SDimitry Andric 533*bdd1243dSDimitry Andricdef VRM8NoV0 : VReg<VM8VTs, (add V8M8, V16M8, V24M8), 8>; 534e8d8bef9SDimitry Andric 535e8d8bef9SDimitry Andricdef VMV0 : RegisterClass<"RISCV", VMaskVTs, 64, (add V0)> { 5365ffd83dbSDimitry Andric let Size = 64; 5375ffd83dbSDimitry Andric} 5385ffd83dbSDimitry Andric 539d56accc7SDimitry Andriclet RegInfos = XLenRI in { 540d56accc7SDimitry Andricdef GPRF16 : RegisterClass<"RISCV", [f16], 16, (add GPR)>; 541d56accc7SDimitry Andricdef GPRF32 : RegisterClass<"RISCV", [f32], 32, (add GPR)>; 542d56accc7SDimitry Andricdef GPRF64 : RegisterClass<"RISCV", [f64], 64, (add GPR)>; 543d56accc7SDimitry Andric} // RegInfos = XLenRI 544d56accc7SDimitry Andric 545d56accc7SDimitry Andriclet RegAltNameIndices = [ABIRegAltName] in { 546d56accc7SDimitry Andric foreach Index = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 547d56accc7SDimitry Andric 24, 26, 28, 30] in { 548d56accc7SDimitry Andric defvar Reg = !cast<Register>("X"#Index); 549d56accc7SDimitry Andric def X#Index#_PD : RISCVRegWithSubRegs<Index, Reg.AsmName, 550d56accc7SDimitry Andric [!cast<Register>("X"#Index), 551d56accc7SDimitry Andric !cast<Register>("X"#!add(Index, 1))], 552d56accc7SDimitry Andric Reg.AltNames> { 553d56accc7SDimitry Andric let SubRegIndices = [sub_32, sub_32_hi]; 554d56accc7SDimitry Andric } 555d56accc7SDimitry Andric } 556d56accc7SDimitry Andric} 557d56accc7SDimitry Andric 558d56accc7SDimitry Andriclet RegInfos = RegInfoByHwMode<[RV64], [RegInfo<64, 64, 64>]> in 559d56accc7SDimitry Andricdef GPRPF64 : RegisterClass<"RISCV", [f64], 64, (add 560d56accc7SDimitry Andric X10_PD, X12_PD, X14_PD, X16_PD, 561d56accc7SDimitry Andric X6_PD, 562d56accc7SDimitry Andric X28_PD, X30_PD, 563d56accc7SDimitry Andric X8_PD, 564d56accc7SDimitry Andric X18_PD, X20_PD, X22_PD, X24_PD, X26_PD, 565d56accc7SDimitry Andric X0_PD, X2_PD, X4_PD 566d56accc7SDimitry Andric)>; 567d56accc7SDimitry Andric 568fe6060f1SDimitry Andric// The register class is added for inline assembly for vector mask types. 5690eae32dcSDimitry Andricdef VM : VReg<VMaskVTs, 570349cc55cSDimitry Andric (add (sequence "V%u", 8, 31), 571fe6060f1SDimitry Andric (sequence "V%u", 0, 7)), 1>; 572fe6060f1SDimitry Andric 573e8d8bef9SDimitry Andricforeach m = LMULList.m in { 574e8d8bef9SDimitry Andric foreach nf = NFList<m>.L in { 575fe6060f1SDimitry Andric def "VRN" # nf # "M" # m # "NoV0": VReg<[untyped], 576fe6060f1SDimitry Andric (add !cast<RegisterTuples>("VN" # nf # "M" # m # "NoV0")), 577e8d8bef9SDimitry Andric !mul(nf, m)>; 578349cc55cSDimitry Andric def "VRN" # nf # "M" # m: VReg<[untyped], 579349cc55cSDimitry Andric (add !cast<RegisterTuples>("VN" # nf # "M" # m # "NoV0"), 580349cc55cSDimitry Andric !cast<RegisterTuples>("VN" # nf # "M" # m # "V0")), 581349cc55cSDimitry Andric !mul(nf, m)>; 582e8d8bef9SDimitry Andric } 5835ffd83dbSDimitry Andric} 584fe6060f1SDimitry Andric 585fe6060f1SDimitry Andric// Special registers 586fe6060f1SDimitry Andricdef FFLAGS : RISCVReg<0, "fflags">; 587fe6060f1SDimitry Andricdef FRM : RISCVReg<0, "frm">; 588349cc55cSDimitry Andric 589349cc55cSDimitry Andric// Any type register. Used for .insn directives when we don't know what the 590349cc55cSDimitry Andric// register types could be. 591349cc55cSDimitry Andric// NOTE: The alignment and size are bogus values. The Size needs to be non-zero 592349cc55cSDimitry Andric// or tablegen will use "untyped" to determine the size which will assert. 593349cc55cSDimitry Andriclet isAllocatable = 0 in 594349cc55cSDimitry Andricdef AnyReg : RegisterClass<"RISCV", [untyped], 32, 595349cc55cSDimitry Andric (add (sequence "X%u", 0, 31), 596349cc55cSDimitry Andric (sequence "F%u_D", 0, 31), 597349cc55cSDimitry Andric (sequence "V%u", 0, 31))> { 598349cc55cSDimitry Andric let Size = 32; 599349cc55cSDimitry Andric} 600