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 { 800b57cec5SDimitry Andric def X0 : RISCVReg<0, "x0", ["zero"]>, DwarfRegNum<[0]>; 8104eeddc0SDimitry Andric let CostPerUse = [0, 1] in { 820b57cec5SDimitry Andric def X1 : RISCVReg<1, "x1", ["ra"]>, DwarfRegNum<[1]>; 830b57cec5SDimitry Andric def X2 : RISCVReg<2, "x2", ["sp"]>, DwarfRegNum<[2]>; 840b57cec5SDimitry Andric def X3 : RISCVReg<3, "x3", ["gp"]>, DwarfRegNum<[3]>; 850b57cec5SDimitry Andric def X4 : RISCVReg<4, "x4", ["tp"]>, DwarfRegNum<[4]>; 860b57cec5SDimitry Andric def X5 : RISCVReg<5, "x5", ["t0"]>, DwarfRegNum<[5]>; 870b57cec5SDimitry Andric def X6 : RISCVReg<6, "x6", ["t1"]>, DwarfRegNum<[6]>; 880b57cec5SDimitry Andric def X7 : RISCVReg<7, "x7", ["t2"]>, DwarfRegNum<[7]>; 890b57cec5SDimitry Andric } 900b57cec5SDimitry Andric def X8 : RISCVReg<8, "x8", ["s0", "fp"]>, DwarfRegNum<[8]>; 910b57cec5SDimitry Andric def X9 : RISCVReg<9, "x9", ["s1"]>, DwarfRegNum<[9]>; 920b57cec5SDimitry Andric def X10 : RISCVReg<10,"x10", ["a0"]>, DwarfRegNum<[10]>; 930b57cec5SDimitry Andric def X11 : RISCVReg<11,"x11", ["a1"]>, DwarfRegNum<[11]>; 940b57cec5SDimitry Andric def X12 : RISCVReg<12,"x12", ["a2"]>, DwarfRegNum<[12]>; 950b57cec5SDimitry Andric def X13 : RISCVReg<13,"x13", ["a3"]>, DwarfRegNum<[13]>; 960b57cec5SDimitry Andric def X14 : RISCVReg<14,"x14", ["a4"]>, DwarfRegNum<[14]>; 970b57cec5SDimitry Andric def X15 : RISCVReg<15,"x15", ["a5"]>, DwarfRegNum<[15]>; 9804eeddc0SDimitry Andric let CostPerUse = [0, 1] in { 990b57cec5SDimitry Andric def X16 : RISCVReg<16,"x16", ["a6"]>, DwarfRegNum<[16]>; 1000b57cec5SDimitry Andric def X17 : RISCVReg<17,"x17", ["a7"]>, DwarfRegNum<[17]>; 1010b57cec5SDimitry Andric def X18 : RISCVReg<18,"x18", ["s2"]>, DwarfRegNum<[18]>; 1020b57cec5SDimitry Andric def X19 : RISCVReg<19,"x19", ["s3"]>, DwarfRegNum<[19]>; 1030b57cec5SDimitry Andric def X20 : RISCVReg<20,"x20", ["s4"]>, DwarfRegNum<[20]>; 1040b57cec5SDimitry Andric def X21 : RISCVReg<21,"x21", ["s5"]>, DwarfRegNum<[21]>; 1050b57cec5SDimitry Andric def X22 : RISCVReg<22,"x22", ["s6"]>, DwarfRegNum<[22]>; 1060b57cec5SDimitry Andric def X23 : RISCVReg<23,"x23", ["s7"]>, DwarfRegNum<[23]>; 1070b57cec5SDimitry Andric def X24 : RISCVReg<24,"x24", ["s8"]>, DwarfRegNum<[24]>; 1080b57cec5SDimitry Andric def X25 : RISCVReg<25,"x25", ["s9"]>, DwarfRegNum<[25]>; 1090b57cec5SDimitry Andric def X26 : RISCVReg<26,"x26", ["s10"]>, DwarfRegNum<[26]>; 1100b57cec5SDimitry Andric def X27 : RISCVReg<27,"x27", ["s11"]>, DwarfRegNum<[27]>; 1110b57cec5SDimitry Andric def X28 : RISCVReg<28,"x28", ["t3"]>, DwarfRegNum<[28]>; 1120b57cec5SDimitry Andric def X29 : RISCVReg<29,"x29", ["t4"]>, DwarfRegNum<[29]>; 1130b57cec5SDimitry Andric def X30 : RISCVReg<30,"x30", ["t5"]>, DwarfRegNum<[30]>; 1140b57cec5SDimitry Andric def X31 : RISCVReg<31,"x31", ["t6"]>, DwarfRegNum<[31]>; 1150b57cec5SDimitry Andric } 1160b57cec5SDimitry Andric} 1170b57cec5SDimitry Andric 118e8d8bef9SDimitry Andricdef XLenVT : ValueTypeByHwMode<[RV32, RV64], 119e8d8bef9SDimitry Andric [i32, i64]>; 120fe6060f1SDimitry Andricdef XLenRI : RegInfoByHwMode< 121fe6060f1SDimitry Andric [RV32, RV64], 122fe6060f1SDimitry Andric [RegInfo<32,32,32>, RegInfo<64,64,64>]>; 1230b57cec5SDimitry Andric 1240b57cec5SDimitry Andric// The order of registers represents the preferred allocation sequence. 1250b57cec5SDimitry Andric// Registers are listed in the order caller-save, callee-save, specials. 1260b57cec5SDimitry Andricdef GPR : RegisterClass<"RISCV", [XLenVT], 32, (add 1270b57cec5SDimitry Andric (sequence "X%u", 10, 17), 1280b57cec5SDimitry Andric (sequence "X%u", 5, 7), 1290b57cec5SDimitry Andric (sequence "X%u", 28, 31), 1300b57cec5SDimitry Andric (sequence "X%u", 8, 9), 1310b57cec5SDimitry Andric (sequence "X%u", 18, 27), 1320b57cec5SDimitry Andric (sequence "X%u", 0, 4) 1330b57cec5SDimitry Andric )> { 134fe6060f1SDimitry Andric let RegInfos = XLenRI; 1350b57cec5SDimitry Andric} 1360b57cec5SDimitry Andric 1378bcb0991SDimitry Andricdef GPRX0 : RegisterClass<"RISCV", [XLenVT], 32, (add X0)> { 138fe6060f1SDimitry Andric let RegInfos = XLenRI; 1398bcb0991SDimitry Andric} 1408bcb0991SDimitry Andric 14104eeddc0SDimitry Andricdef GPRNoX0 : RegisterClass<"RISCV", [XLenVT], 32, (sub GPR, X0)> { 142fe6060f1SDimitry Andric let RegInfos = XLenRI; 1430b57cec5SDimitry Andric} 1440b57cec5SDimitry Andric 14504eeddc0SDimitry Andricdef GPRNoX0X2 : RegisterClass<"RISCV", [XLenVT], 32, (sub GPR, X0, X2)> { 146fe6060f1SDimitry Andric let RegInfos = XLenRI; 147fe6060f1SDimitry Andric} 148fe6060f1SDimitry Andric 149fe6060f1SDimitry Andric// Don't use X1 or X5 for JALR since that is a hint to pop the return address 150fe6060f1SDimitry Andric// stack on some microarchitectures. Also remove the reserved registers X0, X2, 151fe6060f1SDimitry Andric// X3, and X4 as it reduces the number of register classes that get synthesized 152fe6060f1SDimitry Andric// by tablegen. 15304eeddc0SDimitry Andricdef GPRJALR : RegisterClass<"RISCV", [XLenVT], 32, (sub GPR, (sequence "X%u", 0, 5))> { 154fe6060f1SDimitry Andric let RegInfos = XLenRI; 1550b57cec5SDimitry Andric} 1560b57cec5SDimitry Andric 1570b57cec5SDimitry Andricdef GPRC : RegisterClass<"RISCV", [XLenVT], 32, (add 1580b57cec5SDimitry Andric (sequence "X%u", 10, 15), 1590b57cec5SDimitry Andric (sequence "X%u", 8, 9) 1600b57cec5SDimitry Andric )> { 161fe6060f1SDimitry Andric let RegInfos = XLenRI; 1620b57cec5SDimitry Andric} 1630b57cec5SDimitry Andric 1640b57cec5SDimitry Andric// For indirect tail calls, we can't use callee-saved registers, as they are 1650b57cec5SDimitry Andric// restored to the saved value before the tail call, which would clobber a call 166fe6060f1SDimitry Andric// address. We shouldn't use x5 since that is a hint for to pop the return 167fe6060f1SDimitry Andric// address stack on some microarchitectures. 1680b57cec5SDimitry Andricdef GPRTC : RegisterClass<"RISCV", [XLenVT], 32, (add 169fe6060f1SDimitry Andric (sequence "X%u", 6, 7), 1700b57cec5SDimitry Andric (sequence "X%u", 10, 17), 1710b57cec5SDimitry Andric (sequence "X%u", 28, 31) 1720b57cec5SDimitry Andric )> { 173fe6060f1SDimitry Andric let RegInfos = XLenRI; 1740b57cec5SDimitry Andric} 1750b57cec5SDimitry Andric 1760b57cec5SDimitry Andricdef SP : RegisterClass<"RISCV", [XLenVT], 32, (add X2)> { 177fe6060f1SDimitry Andric let RegInfos = XLenRI; 1780b57cec5SDimitry Andric} 1790b57cec5SDimitry Andric 1800b57cec5SDimitry Andric// Floating point registers 1810b57cec5SDimitry Andriclet RegAltNameIndices = [ABIRegAltName] in { 182e8d8bef9SDimitry Andric def F0_H : RISCVReg16<0, "f0", ["ft0"]>, DwarfRegNum<[32]>; 183e8d8bef9SDimitry Andric def F1_H : RISCVReg16<1, "f1", ["ft1"]>, DwarfRegNum<[33]>; 184e8d8bef9SDimitry Andric def F2_H : RISCVReg16<2, "f2", ["ft2"]>, DwarfRegNum<[34]>; 185e8d8bef9SDimitry Andric def F3_H : RISCVReg16<3, "f3", ["ft3"]>, DwarfRegNum<[35]>; 186e8d8bef9SDimitry Andric def F4_H : RISCVReg16<4, "f4", ["ft4"]>, DwarfRegNum<[36]>; 187e8d8bef9SDimitry Andric def F5_H : RISCVReg16<5, "f5", ["ft5"]>, DwarfRegNum<[37]>; 188e8d8bef9SDimitry Andric def F6_H : RISCVReg16<6, "f6", ["ft6"]>, DwarfRegNum<[38]>; 189e8d8bef9SDimitry Andric def F7_H : RISCVReg16<7, "f7", ["ft7"]>, DwarfRegNum<[39]>; 190e8d8bef9SDimitry Andric def F8_H : RISCVReg16<8, "f8", ["fs0"]>, DwarfRegNum<[40]>; 191e8d8bef9SDimitry Andric def F9_H : RISCVReg16<9, "f9", ["fs1"]>, DwarfRegNum<[41]>; 192e8d8bef9SDimitry Andric def F10_H : RISCVReg16<10,"f10", ["fa0"]>, DwarfRegNum<[42]>; 193e8d8bef9SDimitry Andric def F11_H : RISCVReg16<11,"f11", ["fa1"]>, DwarfRegNum<[43]>; 194e8d8bef9SDimitry Andric def F12_H : RISCVReg16<12,"f12", ["fa2"]>, DwarfRegNum<[44]>; 195e8d8bef9SDimitry Andric def F13_H : RISCVReg16<13,"f13", ["fa3"]>, DwarfRegNum<[45]>; 196e8d8bef9SDimitry Andric def F14_H : RISCVReg16<14,"f14", ["fa4"]>, DwarfRegNum<[46]>; 197e8d8bef9SDimitry Andric def F15_H : RISCVReg16<15,"f15", ["fa5"]>, DwarfRegNum<[47]>; 198e8d8bef9SDimitry Andric def F16_H : RISCVReg16<16,"f16", ["fa6"]>, DwarfRegNum<[48]>; 199e8d8bef9SDimitry Andric def F17_H : RISCVReg16<17,"f17", ["fa7"]>, DwarfRegNum<[49]>; 200e8d8bef9SDimitry Andric def F18_H : RISCVReg16<18,"f18", ["fs2"]>, DwarfRegNum<[50]>; 201e8d8bef9SDimitry Andric def F19_H : RISCVReg16<19,"f19", ["fs3"]>, DwarfRegNum<[51]>; 202e8d8bef9SDimitry Andric def F20_H : RISCVReg16<20,"f20", ["fs4"]>, DwarfRegNum<[52]>; 203e8d8bef9SDimitry Andric def F21_H : RISCVReg16<21,"f21", ["fs5"]>, DwarfRegNum<[53]>; 204e8d8bef9SDimitry Andric def F22_H : RISCVReg16<22,"f22", ["fs6"]>, DwarfRegNum<[54]>; 205e8d8bef9SDimitry Andric def F23_H : RISCVReg16<23,"f23", ["fs7"]>, DwarfRegNum<[55]>; 206e8d8bef9SDimitry Andric def F24_H : RISCVReg16<24,"f24", ["fs8"]>, DwarfRegNum<[56]>; 207e8d8bef9SDimitry Andric def F25_H : RISCVReg16<25,"f25", ["fs9"]>, DwarfRegNum<[57]>; 208e8d8bef9SDimitry Andric def F26_H : RISCVReg16<26,"f26", ["fs10"]>, DwarfRegNum<[58]>; 209e8d8bef9SDimitry Andric def F27_H : RISCVReg16<27,"f27", ["fs11"]>, DwarfRegNum<[59]>; 210e8d8bef9SDimitry Andric def F28_H : RISCVReg16<28,"f28", ["ft8"]>, DwarfRegNum<[60]>; 211e8d8bef9SDimitry Andric def F29_H : RISCVReg16<29,"f29", ["ft9"]>, DwarfRegNum<[61]>; 212e8d8bef9SDimitry Andric def F30_H : RISCVReg16<30,"f30", ["ft10"]>, DwarfRegNum<[62]>; 213e8d8bef9SDimitry Andric def F31_H : RISCVReg16<31,"f31", ["ft11"]>, DwarfRegNum<[63]>; 214e8d8bef9SDimitry Andric 215e8d8bef9SDimitry Andric foreach Index = 0-31 in { 216e8d8bef9SDimitry Andric def F#Index#_F : RISCVReg32<!cast<RISCVReg16>("F"#Index#"_H")>, 217e8d8bef9SDimitry Andric DwarfRegNum<[!add(Index, 32)]>; 218e8d8bef9SDimitry Andric } 2190b57cec5SDimitry Andric 2200b57cec5SDimitry Andric foreach Index = 0-31 in { 2218bcb0991SDimitry Andric def F#Index#_D : RISCVReg64<!cast<RISCVReg32>("F"#Index#"_F")>, 2220b57cec5SDimitry Andric DwarfRegNum<[!add(Index, 32)]>; 2230b57cec5SDimitry Andric } 2240b57cec5SDimitry Andric} 2250b57cec5SDimitry Andric 2260b57cec5SDimitry Andric// The order of registers represents the preferred allocation sequence, 2270b57cec5SDimitry Andric// meaning caller-save regs are listed before callee-save. 228e8d8bef9SDimitry Andricdef FPR16 : RegisterClass<"RISCV", [f16], 16, (add 229e8d8bef9SDimitry Andric (sequence "F%u_H", 0, 7), 230e8d8bef9SDimitry Andric (sequence "F%u_H", 10, 17), 231e8d8bef9SDimitry Andric (sequence "F%u_H", 28, 31), 232e8d8bef9SDimitry Andric (sequence "F%u_H", 8, 9), 233e8d8bef9SDimitry Andric (sequence "F%u_H", 18, 27) 234e8d8bef9SDimitry Andric)>; 235e8d8bef9SDimitry Andric 2360b57cec5SDimitry Andricdef FPR32 : RegisterClass<"RISCV", [f32], 32, (add 2378bcb0991SDimitry Andric (sequence "F%u_F", 0, 7), 2388bcb0991SDimitry Andric (sequence "F%u_F", 10, 17), 2398bcb0991SDimitry Andric (sequence "F%u_F", 28, 31), 2408bcb0991SDimitry Andric (sequence "F%u_F", 8, 9), 2418bcb0991SDimitry Andric (sequence "F%u_F", 18, 27) 2420b57cec5SDimitry Andric)>; 2430b57cec5SDimitry Andric 2440b57cec5SDimitry Andricdef FPR32C : RegisterClass<"RISCV", [f32], 32, (add 2458bcb0991SDimitry Andric (sequence "F%u_F", 10, 15), 2468bcb0991SDimitry Andric (sequence "F%u_F", 8, 9) 2470b57cec5SDimitry Andric)>; 2480b57cec5SDimitry Andric 2490b57cec5SDimitry Andric// The order of registers represents the preferred allocation sequence, 2500b57cec5SDimitry Andric// meaning caller-save regs are listed before callee-save. 2510b57cec5SDimitry Andricdef FPR64 : RegisterClass<"RISCV", [f64], 64, (add 2528bcb0991SDimitry Andric (sequence "F%u_D", 0, 7), 2538bcb0991SDimitry Andric (sequence "F%u_D", 10, 17), 2548bcb0991SDimitry Andric (sequence "F%u_D", 28, 31), 2558bcb0991SDimitry Andric (sequence "F%u_D", 8, 9), 2568bcb0991SDimitry Andric (sequence "F%u_D", 18, 27) 2570b57cec5SDimitry Andric)>; 2580b57cec5SDimitry Andric 2590b57cec5SDimitry Andricdef FPR64C : RegisterClass<"RISCV", [f64], 64, (add 2608bcb0991SDimitry Andric (sequence "F%u_D", 10, 15), 2618bcb0991SDimitry Andric (sequence "F%u_D", 8, 9) 2620b57cec5SDimitry Andric)>; 2635ffd83dbSDimitry Andric 264e8d8bef9SDimitry Andric// Vector type mapping to LLVM types. 265e8d8bef9SDimitry Andric// 266fe6060f1SDimitry Andric// The V vector extension requires that VLEN >= 128 and <= 65536. 267e8d8bef9SDimitry Andric// Additionally, the only supported ELEN values are 32 and 64, 268e8d8bef9SDimitry Andric// thus `vscale` can be defined as VLEN/64, 269e8d8bef9SDimitry Andric// allowing the same types with either ELEN value. 270e8d8bef9SDimitry Andric// 271e8d8bef9SDimitry Andric// MF8 MF4 MF2 M1 M2 M4 M8 272e8d8bef9SDimitry Andric// i64* N/A N/A N/A nxv1i64 nxv2i64 nxv4i64 nxv8i64 273e8d8bef9SDimitry Andric// i32 N/A N/A nxv1i32 nxv2i32 nxv4i32 nxv8i32 nxv16i32 274e8d8bef9SDimitry Andric// i16 N/A nxv1i16 nxv2i16 nxv4i16 nxv8i16 nxv16i16 nxv32i16 275e8d8bef9SDimitry Andric// i8 nxv1i8 nxv2i8 nxv4i8 nxv8i8 nxv16i8 nxv32i8 nxv64i8 276e8d8bef9SDimitry Andric// double* N/A N/A N/A nxv1f64 nxv2f64 nxv4f64 nxv8f64 277e8d8bef9SDimitry Andric// float N/A N/A nxv1f32 nxv2f32 nxv4f32 nxv8f32 nxv16f32 278e8d8bef9SDimitry Andric// half N/A nxv1f16 nxv2f16 nxv4f16 nxv8f16 nxv16f16 nxv32f16 279e8d8bef9SDimitry Andric// * ELEN=64 280e8d8bef9SDimitry Andric 281e8d8bef9SDimitry Andricdefvar vint8mf8_t = nxv1i8; 282e8d8bef9SDimitry Andricdefvar vint8mf4_t = nxv2i8; 283e8d8bef9SDimitry Andricdefvar vint8mf2_t = nxv4i8; 284e8d8bef9SDimitry Andricdefvar vint8m1_t = nxv8i8; 285e8d8bef9SDimitry Andricdefvar vint8m2_t = nxv16i8; 286e8d8bef9SDimitry Andricdefvar vint8m4_t = nxv32i8; 287e8d8bef9SDimitry Andricdefvar vint8m8_t = nxv64i8; 288e8d8bef9SDimitry Andric 289e8d8bef9SDimitry Andricdefvar vint16mf4_t = nxv1i16; 290e8d8bef9SDimitry Andricdefvar vint16mf2_t = nxv2i16; 291e8d8bef9SDimitry Andricdefvar vint16m1_t = nxv4i16; 292e8d8bef9SDimitry Andricdefvar vint16m2_t = nxv8i16; 293e8d8bef9SDimitry Andricdefvar vint16m4_t = nxv16i16; 294e8d8bef9SDimitry Andricdefvar vint16m8_t = nxv32i16; 295e8d8bef9SDimitry Andric 296e8d8bef9SDimitry Andricdefvar vint32mf2_t = nxv1i32; 297e8d8bef9SDimitry Andricdefvar vint32m1_t = nxv2i32; 298e8d8bef9SDimitry Andricdefvar vint32m2_t = nxv4i32; 299e8d8bef9SDimitry Andricdefvar vint32m4_t = nxv8i32; 300e8d8bef9SDimitry Andricdefvar vint32m8_t = nxv16i32; 301e8d8bef9SDimitry Andric 302e8d8bef9SDimitry Andricdefvar vint64m1_t = nxv1i64; 303e8d8bef9SDimitry Andricdefvar vint64m2_t = nxv2i64; 304e8d8bef9SDimitry Andricdefvar vint64m4_t = nxv4i64; 305e8d8bef9SDimitry Andricdefvar vint64m8_t = nxv8i64; 306e8d8bef9SDimitry Andric 307e8d8bef9SDimitry Andricdefvar vfloat16mf4_t = nxv1f16; 308e8d8bef9SDimitry Andricdefvar vfloat16mf2_t = nxv2f16; 309e8d8bef9SDimitry Andricdefvar vfloat16m1_t = nxv4f16; 310e8d8bef9SDimitry Andricdefvar vfloat16m2_t = nxv8f16; 311e8d8bef9SDimitry Andricdefvar vfloat16m4_t = nxv16f16; 312e8d8bef9SDimitry Andricdefvar vfloat16m8_t = nxv32f16; 313e8d8bef9SDimitry Andric 314e8d8bef9SDimitry Andricdefvar vfloat32mf2_t = nxv1f32; 315e8d8bef9SDimitry Andricdefvar vfloat32m1_t = nxv2f32; 316e8d8bef9SDimitry Andricdefvar vfloat32m2_t = nxv4f32; 317e8d8bef9SDimitry Andricdefvar vfloat32m4_t = nxv8f32; 318e8d8bef9SDimitry Andricdefvar vfloat32m8_t = nxv16f32; 319e8d8bef9SDimitry Andric 320e8d8bef9SDimitry Andricdefvar vfloat64m1_t = nxv1f64; 321e8d8bef9SDimitry Andricdefvar vfloat64m2_t = nxv2f64; 322e8d8bef9SDimitry Andricdefvar vfloat64m4_t = nxv4f64; 323e8d8bef9SDimitry Andricdefvar vfloat64m8_t = nxv8f64; 324e8d8bef9SDimitry Andric 325e8d8bef9SDimitry Andricdefvar vbool1_t = nxv64i1; 326e8d8bef9SDimitry Andricdefvar vbool2_t = nxv32i1; 327e8d8bef9SDimitry Andricdefvar vbool4_t = nxv16i1; 328e8d8bef9SDimitry Andricdefvar vbool8_t = nxv8i1; 329e8d8bef9SDimitry Andricdefvar vbool16_t = nxv4i1; 330e8d8bef9SDimitry Andricdefvar vbool32_t = nxv2i1; 331e8d8bef9SDimitry Andricdefvar vbool64_t = nxv1i1; 332e8d8bef9SDimitry Andric 333e8d8bef9SDimitry Andric// There is no need to define register classes for fractional LMUL. 334e8d8bef9SDimitry Andricdef LMULList { 335e8d8bef9SDimitry Andric list<int> m = [1, 2, 4, 8]; 336e8d8bef9SDimitry Andric} 337e8d8bef9SDimitry Andric 338e8d8bef9SDimitry Andric//===----------------------------------------------------------------------===// 339e8d8bef9SDimitry Andric// Utility classes for segment load/store. 340e8d8bef9SDimitry Andric//===----------------------------------------------------------------------===// 341e8d8bef9SDimitry Andric// The set of legal NF for LMUL = lmul. 342e8d8bef9SDimitry Andric// LMUL == 1, NF = 2, 3, 4, 5, 6, 7, 8 343e8d8bef9SDimitry Andric// LMUL == 2, NF = 2, 3, 4 344e8d8bef9SDimitry Andric// LMUL == 4, NF = 2 345e8d8bef9SDimitry Andricclass NFList<int lmul> { 346e8d8bef9SDimitry Andric list<int> L = !cond(!eq(lmul, 1): [2, 3, 4, 5, 6, 7, 8], 347e8d8bef9SDimitry Andric !eq(lmul, 2): [2, 3, 4], 348e8d8bef9SDimitry Andric !eq(lmul, 4): [2], 349e8d8bef9SDimitry Andric !eq(lmul, 8): []); 350e8d8bef9SDimitry Andric} 351e8d8bef9SDimitry Andric 352e8d8bef9SDimitry Andric// Generate [start, end) SubRegIndex list. 353349cc55cSDimitry Andricclass SubRegSet<int nf, int lmul> { 354e8d8bef9SDimitry Andric list<SubRegIndex> L = !foldl([]<SubRegIndex>, 355e8d8bef9SDimitry Andric [0, 1, 2, 3, 4, 5, 6, 7], 356e8d8bef9SDimitry Andric AccList, i, 357e8d8bef9SDimitry Andric !listconcat(AccList, 358e8d8bef9SDimitry Andric !if(!lt(i, nf), 359e8d8bef9SDimitry Andric [!cast<SubRegIndex>("sub_vrm" # lmul # "_" # i)], 360e8d8bef9SDimitry Andric []))); 361e8d8bef9SDimitry Andric} 362e8d8bef9SDimitry Andric 363349cc55cSDimitry Andric// Collect the valid indexes into 'R' under NF and LMUL values from TUPLE_INDEX. 364349cc55cSDimitry Andric// When NF = 2, the valid TUPLE_INDEX is 0 and 1. 365349cc55cSDimitry Andric// For example, when LMUL = 4, the potential valid indexes is 366349cc55cSDimitry Andric// [8, 12, 16, 20, 24, 28, 4]. However, not all these indexes are valid under 367349cc55cSDimitry Andric// NF = 2. For example, 28 is not valid under LMUL = 4, NF = 2 and TUPLE_INDEX = 0. 368349cc55cSDimitry Andric// The filter is 369349cc55cSDimitry Andric// (tuple_index + i) x lmul <= (tuple_index x lmul) + 32 - (nf x lmul) 370349cc55cSDimitry Andric// 371349cc55cSDimitry Andric// Use START = 0, LMUL = 4 and NF = 2 as the example, 372349cc55cSDimitry Andric// i x 4 <= 24 373349cc55cSDimitry Andric// The class will return [8, 12, 16, 20, 24, 4]. 374349cc55cSDimitry Andric// Use START = 1, LMUL = 4 and NF = 2 as the example, 375349cc55cSDimitry Andric// (1 + i) x 4 <= 28 376349cc55cSDimitry Andric// The class will return [12, 16, 20, 24, 28, 8]. 377349cc55cSDimitry Andric// 378349cc55cSDimitry Andricclass IndexSet<int tuple_index, int nf, int lmul, bit isV0 = false> { 379e8d8bef9SDimitry Andric list<int> R = 380e8d8bef9SDimitry Andric !foldl([]<int>, 381349cc55cSDimitry Andric !if(isV0, [0], 382349cc55cSDimitry Andric !cond( 383349cc55cSDimitry Andric !eq(lmul, 1): 384349cc55cSDimitry Andric [8, 9, 10, 11, 12, 13, 14, 15, 385349cc55cSDimitry Andric 16, 17, 18, 19, 20, 21, 22, 23, 386349cc55cSDimitry Andric 24, 25, 26, 27, 28, 29, 30, 31, 387349cc55cSDimitry Andric 1, 2, 3, 4, 5, 6, 7], 388349cc55cSDimitry Andric !eq(lmul, 2): 389349cc55cSDimitry Andric [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3], 390349cc55cSDimitry Andric !eq(lmul, 4): 391349cc55cSDimitry Andric [2, 3, 4, 5, 6, 7, 1])), 392e8d8bef9SDimitry Andric L, i, 393e8d8bef9SDimitry Andric !listconcat(L, 394349cc55cSDimitry Andric !if(!le(!mul(!add(i, tuple_index), lmul), 395349cc55cSDimitry Andric !sub(!add(32, !mul(tuple_index, lmul)), !mul(nf, lmul))), 396349cc55cSDimitry Andric [!mul(!add(i, tuple_index), lmul)], []))); 397e8d8bef9SDimitry Andric} 398e8d8bef9SDimitry Andric 399349cc55cSDimitry Andric// This class returns a list of vector register collections. 400349cc55cSDimitry Andric// For example, for NF = 2 and LMUL = 4, 401349cc55cSDimitry Andric// it will return 402349cc55cSDimitry Andric// ([ V8M4, V12M4, V16M4, V20M4, V24M4, V4M4], 403349cc55cSDimitry Andric// [V12M4, V16M4, V20M4, V24M4, V28M4, V8M4]) 404349cc55cSDimitry Andric// 405349cc55cSDimitry Andricclass VRegList<list<dag> LIn, int start, int nf, int lmul, bit isV0> { 406e8d8bef9SDimitry Andric list<dag> L = 407e8d8bef9SDimitry Andric !if(!ge(start, nf), 408e8d8bef9SDimitry Andric LIn, 409e8d8bef9SDimitry Andric !listconcat( 410e8d8bef9SDimitry Andric [!dag(add, 411349cc55cSDimitry Andric !foreach(i, IndexSet<start, nf, lmul, isV0>.R, 412e8d8bef9SDimitry Andric !cast<Register>("V" # i # !cond(!eq(lmul, 2): "M2", 413e8d8bef9SDimitry Andric !eq(lmul, 4): "M4", 414e8d8bef9SDimitry Andric true: ""))), 415fe6060f1SDimitry Andric !listsplat("", 416349cc55cSDimitry Andric !size(IndexSet<start, nf, lmul, isV0>.R)))], 417349cc55cSDimitry Andric VRegList<LIn, !add(start, 1), nf, lmul, isV0>.L)); 418e8d8bef9SDimitry Andric} 419e8d8bef9SDimitry Andric 4205ffd83dbSDimitry Andric// Vector registers 4215ffd83dbSDimitry Andriclet RegAltNameIndices = [ABIRegAltName] in { 4225ffd83dbSDimitry Andric foreach Index = 0-31 in { 423e8d8bef9SDimitry Andric def V#Index : RISCVReg<Index, "v"#Index, ["v"#Index]>, DwarfRegNum<[!add(Index, 96)]>; 4245ffd83dbSDimitry Andric } 4255ffd83dbSDimitry Andric 4265ffd83dbSDimitry Andric foreach Index = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 4275ffd83dbSDimitry Andric 24, 26, 28, 30] in { 4285ffd83dbSDimitry Andric def V#Index#M2 : RISCVRegWithSubRegs<Index, "v"#Index, 4295ffd83dbSDimitry Andric [!cast<Register>("V"#Index), 4305ffd83dbSDimitry Andric !cast<Register>("V"#!add(Index, 1))], 4315ffd83dbSDimitry Andric ["v"#Index]>, 4325ffd83dbSDimitry Andric DwarfRegAlias<!cast<Register>("V"#Index)> { 433e8d8bef9SDimitry Andric let SubRegIndices = [sub_vrm1_0, sub_vrm1_1]; 4345ffd83dbSDimitry Andric } 4355ffd83dbSDimitry Andric } 4365ffd83dbSDimitry Andric 4375ffd83dbSDimitry Andric foreach Index = [0, 4, 8, 12, 16, 20, 24, 28] in { 4385ffd83dbSDimitry Andric def V#Index#M4 : RISCVRegWithSubRegs<Index, "v"#Index, 4395ffd83dbSDimitry Andric [!cast<Register>("V"#Index#"M2"), 4405ffd83dbSDimitry Andric !cast<Register>("V"#!add(Index, 2)#"M2")], 4415ffd83dbSDimitry Andric ["v"#Index]>, 4425ffd83dbSDimitry Andric DwarfRegAlias<!cast<Register>("V"#Index)> { 443e8d8bef9SDimitry Andric let SubRegIndices = [sub_vrm2_0, sub_vrm2_1]; 4445ffd83dbSDimitry Andric } 4455ffd83dbSDimitry Andric } 4465ffd83dbSDimitry Andric 4475ffd83dbSDimitry Andric foreach Index = [0, 8, 16, 24] in { 4485ffd83dbSDimitry Andric def V#Index#M8 : RISCVRegWithSubRegs<Index, "v"#Index, 4495ffd83dbSDimitry Andric [!cast<Register>("V"#Index#"M4"), 4505ffd83dbSDimitry Andric !cast<Register>("V"#!add(Index, 4)#"M4")], 4515ffd83dbSDimitry Andric ["v"#Index]>, 4525ffd83dbSDimitry Andric DwarfRegAlias<!cast<Register>("V"#Index)> { 453e8d8bef9SDimitry Andric let SubRegIndices = [sub_vrm4_0, sub_vrm4_1]; 4545ffd83dbSDimitry Andric } 4555ffd83dbSDimitry Andric } 4565ffd83dbSDimitry Andric 4575ffd83dbSDimitry Andric def VTYPE : RISCVReg<0, "vtype", ["vtype"]>; 4585ffd83dbSDimitry Andric def VL : RISCVReg<0, "vl", ["vl"]>; 459e8d8bef9SDimitry Andric def VXSAT : RISCVReg<0, "vxsat", ["vxsat"]>; 460e8d8bef9SDimitry Andric def VXRM : RISCVReg<0, "vxrm", ["vxrm"]>; 4614824e7fdSDimitry Andric def VLENB : RISCVReg<0, "vlenb", ["vlenb"]>, 4624824e7fdSDimitry Andric DwarfRegNum<[!add(4096, SysRegVLENB.Encoding)]>; 4635ffd83dbSDimitry Andric} 4645ffd83dbSDimitry Andric 465*81ad6265SDimitry Andricdef VCSR : RegisterClass<"RISCV", [XLenVT], 32, 466*81ad6265SDimitry Andric (add VTYPE, VL, VLENB)> { 467*81ad6265SDimitry Andric let RegInfos = XLenRI; 468*81ad6265SDimitry Andric} 469*81ad6265SDimitry Andric 470*81ad6265SDimitry Andric 471e8d8bef9SDimitry Andricforeach m = [1, 2, 4] in { 472e8d8bef9SDimitry Andric foreach n = NFList<m>.L in { 473fe6060f1SDimitry Andric def "VN" # n # "M" # m # "NoV0": RegisterTuples< 474349cc55cSDimitry Andric SubRegSet<n, m>.L, 475349cc55cSDimitry Andric VRegList<[], 0, n, m, false>.L>; 476fe6060f1SDimitry Andric def "VN" # n # "M" # m # "V0" : RegisterTuples< 477349cc55cSDimitry Andric SubRegSet<n, m>.L, 478349cc55cSDimitry Andric VRegList<[], 0, n, m, true>.L>; 479e8d8bef9SDimitry Andric } 4805ffd83dbSDimitry Andric} 4815ffd83dbSDimitry Andric 482e8d8bef9SDimitry Andricclass VReg<list<ValueType> regTypes, dag regList, int Vlmul> 483e8d8bef9SDimitry Andric : RegisterClass<"RISCV", 484e8d8bef9SDimitry Andric regTypes, 485e8d8bef9SDimitry Andric 64, // The maximum supported ELEN is 64. 486e8d8bef9SDimitry Andric regList> { 487e8d8bef9SDimitry Andric int VLMul = Vlmul; 488e8d8bef9SDimitry Andric int Size = !mul(Vlmul, 64); 489e8d8bef9SDimitry Andric} 490e8d8bef9SDimitry Andric 491fe6060f1SDimitry Andricdef VR : VReg<[vint8m1_t, vint16m1_t, vint32m1_t, vint64m1_t, 492fe6060f1SDimitry Andric vfloat16m1_t, vfloat32m1_t, vfloat64m1_t, 493fe6060f1SDimitry Andric vint8mf2_t, vint8mf4_t, vint8mf8_t, 494e8d8bef9SDimitry Andric vint16mf2_t, vint16mf4_t, vint32mf2_t, 495fe6060f1SDimitry Andric vfloat16mf4_t, vfloat16mf2_t, vfloat32mf2_t, 496e8d8bef9SDimitry Andric vbool64_t, vbool32_t, vbool16_t, vbool8_t, vbool4_t, 497e8d8bef9SDimitry Andric vbool2_t, vbool1_t], 498349cc55cSDimitry Andric (add (sequence "V%u", 8, 31), 499e8d8bef9SDimitry Andric (sequence "V%u", 0, 7)), 1>; 5005ffd83dbSDimitry Andric 501fe6060f1SDimitry Andricdef VRNoV0 : VReg<[vint8m1_t, vint16m1_t, vint32m1_t, vint64m1_t, 502fe6060f1SDimitry Andric vfloat16m1_t, vfloat32m1_t, vfloat64m1_t, 503fe6060f1SDimitry Andric vint8mf2_t, vint8mf4_t, vint8mf8_t, 504e8d8bef9SDimitry Andric vint16mf2_t, vint16mf4_t, vint32mf2_t, 505fe6060f1SDimitry Andric vfloat16mf4_t, vfloat16mf2_t, vfloat32mf2_t, 506e8d8bef9SDimitry Andric vbool64_t, vbool32_t, vbool16_t, vbool8_t, vbool4_t, 507e8d8bef9SDimitry Andric vbool2_t, vbool1_t], 508349cc55cSDimitry Andric (add (sequence "V%u", 8, 31), 509e8d8bef9SDimitry Andric (sequence "V%u", 1, 7)), 1>; 510e8d8bef9SDimitry Andric 511e8d8bef9SDimitry Andricdef VRM2 : VReg<[vint8m2_t, vint16m2_t, vint32m2_t, vint64m2_t, 512e8d8bef9SDimitry Andric vfloat16m2_t, vfloat32m2_t, vfloat64m2_t], 513349cc55cSDimitry Andric (add (sequence "V%uM2", 8, 31, 2), 514349cc55cSDimitry Andric (sequence "V%uM2", 0, 7, 2)), 2>; 5155ffd83dbSDimitry Andric 516e8d8bef9SDimitry Andricdef VRM2NoV0 : VReg<[vint8m2_t, vint16m2_t, vint32m2_t, vint64m2_t, 517e8d8bef9SDimitry Andric vfloat16m2_t, vfloat32m2_t, vfloat64m2_t], 518349cc55cSDimitry Andric (add (sequence "V%uM2", 8, 31, 2), 519349cc55cSDimitry Andric (sequence "V%uM2", 2, 7, 2)), 2>; 5205ffd83dbSDimitry Andric 521e8d8bef9SDimitry Andricdef VRM4 : VReg<[vint8m4_t, vint16m4_t, vint32m4_t, vint64m4_t, 522e8d8bef9SDimitry Andric vfloat16m4_t, vfloat32m4_t, vfloat64m4_t], 523349cc55cSDimitry Andric (add V8M4, V12M4, V16M4, V20M4, V24M4, V28M4, V0M4, V4M4), 4>; 5245ffd83dbSDimitry Andric 525e8d8bef9SDimitry Andricdef VRM4NoV0 : VReg<[vint8m4_t, vint16m4_t, vint32m4_t, vint64m4_t, 526e8d8bef9SDimitry Andric vfloat16m4_t, vfloat32m4_t, vfloat64m4_t], 527349cc55cSDimitry Andric (add V8M4, V12M4, V16M4, V20M4, V24M4, V28M4, V4M4), 4>; 5285ffd83dbSDimitry Andric 529e8d8bef9SDimitry Andricdef VRM8 : VReg<[vint8m8_t, vint16m8_t, vint32m8_t, vint64m8_t, 530e8d8bef9SDimitry Andric vfloat16m8_t, vfloat32m8_t, vfloat64m8_t], 531e8d8bef9SDimitry Andric (add V8M8, V16M8, V24M8, V0M8), 8>; 532e8d8bef9SDimitry Andric 533e8d8bef9SDimitry Andricdef VRM8NoV0 : VReg<[vint8m8_t, vint16m8_t, vint32m8_t, vint64m8_t, 534e8d8bef9SDimitry Andric vfloat16m8_t, vfloat32m8_t, vfloat64m8_t], 535e8d8bef9SDimitry Andric (add V8M8, V16M8, V24M8), 8>; 536e8d8bef9SDimitry Andric 5370eae32dcSDimitry Andricdefvar VMaskVTs = [vbool1_t, vbool2_t, vbool4_t, vbool8_t, vbool16_t, 5380eae32dcSDimitry Andric vbool32_t, vbool64_t]; 539e8d8bef9SDimitry Andric 540e8d8bef9SDimitry Andricdef VMV0 : RegisterClass<"RISCV", VMaskVTs, 64, (add V0)> { 5415ffd83dbSDimitry Andric let Size = 64; 5425ffd83dbSDimitry Andric} 5435ffd83dbSDimitry Andric 544d56accc7SDimitry Andriclet RegInfos = XLenRI in { 545d56accc7SDimitry Andricdef GPRF16 : RegisterClass<"RISCV", [f16], 16, (add GPR)>; 546d56accc7SDimitry Andricdef GPRF32 : RegisterClass<"RISCV", [f32], 32, (add GPR)>; 547d56accc7SDimitry Andricdef GPRF64 : RegisterClass<"RISCV", [f64], 64, (add GPR)>; 548d56accc7SDimitry Andric} // RegInfos = XLenRI 549d56accc7SDimitry Andric 550d56accc7SDimitry Andriclet RegAltNameIndices = [ABIRegAltName] in { 551d56accc7SDimitry Andric foreach Index = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 552d56accc7SDimitry Andric 24, 26, 28, 30] in { 553d56accc7SDimitry Andric defvar Reg = !cast<Register>("X"#Index); 554d56accc7SDimitry Andric def X#Index#_PD : RISCVRegWithSubRegs<Index, Reg.AsmName, 555d56accc7SDimitry Andric [!cast<Register>("X"#Index), 556d56accc7SDimitry Andric !cast<Register>("X"#!add(Index, 1))], 557d56accc7SDimitry Andric Reg.AltNames> { 558d56accc7SDimitry Andric let SubRegIndices = [sub_32, sub_32_hi]; 559d56accc7SDimitry Andric } 560d56accc7SDimitry Andric } 561d56accc7SDimitry Andric} 562d56accc7SDimitry Andric 563d56accc7SDimitry Andriclet RegInfos = RegInfoByHwMode<[RV64], [RegInfo<64, 64, 64>]> in 564d56accc7SDimitry Andricdef GPRPF64 : RegisterClass<"RISCV", [f64], 64, (add 565d56accc7SDimitry Andric X10_PD, X12_PD, X14_PD, X16_PD, 566d56accc7SDimitry Andric X6_PD, 567d56accc7SDimitry Andric X28_PD, X30_PD, 568d56accc7SDimitry Andric X8_PD, 569d56accc7SDimitry Andric X18_PD, X20_PD, X22_PD, X24_PD, X26_PD, 570d56accc7SDimitry Andric X0_PD, X2_PD, X4_PD 571d56accc7SDimitry Andric)>; 572d56accc7SDimitry Andric 573fe6060f1SDimitry Andric// The register class is added for inline assembly for vector mask types. 5740eae32dcSDimitry Andricdef VM : VReg<VMaskVTs, 575349cc55cSDimitry Andric (add (sequence "V%u", 8, 31), 576fe6060f1SDimitry Andric (sequence "V%u", 0, 7)), 1>; 577fe6060f1SDimitry Andric 578e8d8bef9SDimitry Andricforeach m = LMULList.m in { 579e8d8bef9SDimitry Andric foreach nf = NFList<m>.L in { 580fe6060f1SDimitry Andric def "VRN" # nf # "M" # m # "NoV0": VReg<[untyped], 581fe6060f1SDimitry Andric (add !cast<RegisterTuples>("VN" # nf # "M" # m # "NoV0")), 582e8d8bef9SDimitry Andric !mul(nf, m)>; 583349cc55cSDimitry Andric def "VRN" # nf # "M" # m: VReg<[untyped], 584349cc55cSDimitry Andric (add !cast<RegisterTuples>("VN" # nf # "M" # m # "NoV0"), 585349cc55cSDimitry Andric !cast<RegisterTuples>("VN" # nf # "M" # m # "V0")), 586349cc55cSDimitry Andric !mul(nf, m)>; 587e8d8bef9SDimitry Andric } 5885ffd83dbSDimitry Andric} 589fe6060f1SDimitry Andric 590fe6060f1SDimitry Andric// Special registers 591fe6060f1SDimitry Andricdef FFLAGS : RISCVReg<0, "fflags">; 592fe6060f1SDimitry Andricdef FRM : RISCVReg<0, "frm">; 593349cc55cSDimitry Andric 594349cc55cSDimitry Andric// Any type register. Used for .insn directives when we don't know what the 595349cc55cSDimitry Andric// register types could be. 596349cc55cSDimitry Andric// NOTE: The alignment and size are bogus values. The Size needs to be non-zero 597349cc55cSDimitry Andric// or tablegen will use "untyped" to determine the size which will assert. 598349cc55cSDimitry Andriclet isAllocatable = 0 in 599349cc55cSDimitry Andricdef AnyReg : RegisterClass<"RISCV", [untyped], 32, 600349cc55cSDimitry Andric (add (sequence "X%u", 0, 31), 601349cc55cSDimitry Andric (sequence "F%u_D", 0, 31), 602349cc55cSDimitry Andric (sequence "V%u", 0, 31))> { 603349cc55cSDimitry Andric let Size = 32; 604349cc55cSDimitry Andric} 605