MipsRegisterInfo.td revision 208599
1193323Sed//===- MipsRegisterInfo.td - Mips Register defs -----------------*- C++ -*-===// 2193323Sed// 3193323Sed// The LLVM Compiler Infrastructure 4193323Sed// 5193323Sed// This file is distributed under the University of Illinois Open Source 6193323Sed// License. See LICENSE.TXT for details. 7193323Sed// 8193323Sed//===----------------------------------------------------------------------===// 9193323Sed 10193323Sed//===----------------------------------------------------------------------===// 11193323Sed// Declarations that describe the MIPS register file 12193323Sed//===----------------------------------------------------------------------===// 13193323Sed 14193323Sed// We have banks of 32 registers each. 15193323Sedclass MipsReg<string n> : Register<n> { 16193323Sed field bits<5> Num; 17193323Sed let Namespace = "Mips"; 18193323Sed} 19193323Sed 20193323Sedclass MipsRegWithSubRegs<string n, list<Register> subregs> 21193323Sed : RegisterWithSubRegs<n, subregs> { 22193323Sed field bits<5> Num; 23193323Sed let Namespace = "Mips"; 24193323Sed} 25193323Sed 26193323Sed// Mips CPU Registers 27193323Sedclass MipsGPRReg<bits<5> num, string n> : MipsReg<n> { 28193323Sed let Num = num; 29193323Sed} 30193323Sed 31193323Sed// Mips 32-bit FPU Registers 32193323Sedclass FPR<bits<5> num, string n> : MipsReg<n> { 33193323Sed let Num = num; 34193323Sed} 35193323Sed 36193323Sed// Mips 64-bit (aliased) FPU Registers 37193323Sedlet Namespace = "Mips" in { 38193323Seddef sub_fpeven : SubRegIndex; 39193323Seddef sub_fpodd : SubRegIndex; 40193323Sed} 41193323Sedclass AFPR<bits<5> num, string n, list<Register> subregs> 42193323Sed : MipsRegWithSubRegs<n, subregs> { 43193323Sed let Num = num; 44193323Sed let SubRegIndices = [sub_fpeven, sub_fpodd]; 45193323Sed} 46193323Sed 47193323Sed//===----------------------------------------------------------------------===// 48193323Sed// Registers 49193323Sed//===----------------------------------------------------------------------===// 50193323Sed 51193323Sedlet Namespace = "Mips" in { 52193323Sed 53193323Sed // General Purpose Registers 54193323Sed def ZERO : MipsGPRReg< 0, "ZERO">, DwarfRegNum<[0]>; 55193323Sed def AT : MipsGPRReg< 1, "AT">, DwarfRegNum<[1]>; 56193323Sed def V0 : MipsGPRReg< 2, "2">, DwarfRegNum<[2]>; 57193323Sed def V1 : MipsGPRReg< 3, "3">, DwarfRegNum<[3]>; 58193323Sed def A0 : MipsGPRReg< 4, "4">, DwarfRegNum<[5]>; 59193323Sed def A1 : MipsGPRReg< 5, "5">, DwarfRegNum<[5]>; 60193323Sed def A2 : MipsGPRReg< 6, "6">, DwarfRegNum<[6]>; 61193323Sed def A3 : MipsGPRReg< 7, "7">, DwarfRegNum<[7]>; 62193323Sed def T0 : MipsGPRReg< 8, "8">, DwarfRegNum<[8]>; 63193323Sed def T1 : MipsGPRReg< 9, "9">, DwarfRegNum<[9]>; 64193323Sed def T2 : MipsGPRReg< 10, "10">, DwarfRegNum<[10]>; 65193323Sed def T3 : MipsGPRReg< 11, "11">, DwarfRegNum<[11]>; 66193323Sed def T4 : MipsGPRReg< 12, "12">, DwarfRegNum<[12]>; 67193323Sed def T5 : MipsGPRReg< 13, "13">, DwarfRegNum<[13]>; 68193323Sed def T6 : MipsGPRReg< 14, "14">, DwarfRegNum<[14]>; 69193323Sed def T7 : MipsGPRReg< 15, "15">, DwarfRegNum<[15]>; 70193323Sed def S0 : MipsGPRReg< 16, "16">, DwarfRegNum<[16]>; 71193323Sed def S1 : MipsGPRReg< 17, "17">, DwarfRegNum<[17]>; 72193323Sed def S2 : MipsGPRReg< 18, "18">, DwarfRegNum<[18]>; 73193323Sed def S3 : MipsGPRReg< 19, "19">, DwarfRegNum<[19]>; 74193323Sed def S4 : MipsGPRReg< 20, "20">, DwarfRegNum<[20]>; 75193323Sed def S5 : MipsGPRReg< 21, "21">, DwarfRegNum<[21]>; 76193323Sed def S6 : MipsGPRReg< 22, "22">, DwarfRegNum<[22]>; 77193323Sed def S7 : MipsGPRReg< 23, "23">, DwarfRegNum<[23]>; 78193323Sed def T8 : MipsGPRReg< 24, "24">, DwarfRegNum<[24]>; 79193323Sed def T9 : MipsGPRReg< 25, "25">, DwarfRegNum<[25]>; 80193323Sed def K0 : MipsGPRReg< 26, "26">, DwarfRegNum<[26]>; 81193323Sed def K1 : MipsGPRReg< 27, "27">, DwarfRegNum<[27]>; 82193323Sed def GP : MipsGPRReg< 28, "GP">, DwarfRegNum<[28]>; 83193323Sed def SP : MipsGPRReg< 29, "SP">, DwarfRegNum<[29]>; 84193323Sed def FP : MipsGPRReg< 30, "FP">, DwarfRegNum<[30]>; 85193323Sed def RA : MipsGPRReg< 31, "RA">, DwarfRegNum<[31]>; 86198090Srdivacky 87198090Srdivacky /// Mips Single point precision FPU Registers 88198090Srdivacky def F0 : FPR< 0, "F0">, DwarfRegNum<[32]>; 89198090Srdivacky def F1 : FPR< 1, "F1">, DwarfRegNum<[33]>; 90198090Srdivacky def F2 : FPR< 2, "F2">, DwarfRegNum<[34]>; 91198090Srdivacky def F3 : FPR< 3, "F3">, DwarfRegNum<[35]>; 92193323Sed def F4 : FPR< 4, "F4">, DwarfRegNum<[36]>; 93193323Sed def F5 : FPR< 5, "F5">, DwarfRegNum<[37]>; 94193323Sed def F6 : FPR< 6, "F6">, DwarfRegNum<[38]>; 95193323Sed def F7 : FPR< 7, "F7">, DwarfRegNum<[39]>; 96193323Sed def F8 : FPR< 8, "F8">, DwarfRegNum<[40]>; 97193323Sed def F9 : FPR< 9, "F9">, DwarfRegNum<[41]>; 98193323Sed def F10 : FPR<10, "F10">, DwarfRegNum<[42]>; 99193323Sed def F11 : FPR<11, "F11">, DwarfRegNum<[43]>; 100193323Sed def F12 : FPR<12, "F12">, DwarfRegNum<[44]>; 101193323Sed def F13 : FPR<13, "F13">, DwarfRegNum<[45]>; 102193323Sed def F14 : FPR<14, "F14">, DwarfRegNum<[46]>; 103193323Sed def F15 : FPR<15, "F15">, DwarfRegNum<[47]>; 104193323Sed def F16 : FPR<16, "F16">, DwarfRegNum<[48]>; 105193323Sed def F17 : FPR<17, "F17">, DwarfRegNum<[49]>; 106193323Sed def F18 : FPR<18, "F18">, DwarfRegNum<[50]>; 107193323Sed def F19 : FPR<19, "F19">, DwarfRegNum<[51]>; 108193323Sed def F20 : FPR<20, "F20">, DwarfRegNum<[52]>; 109193323Sed def F21 : FPR<21, "F21">, DwarfRegNum<[53]>; 110193323Sed def F22 : FPR<22, "F22">, DwarfRegNum<[54]>; 111193323Sed def F23 : FPR<23, "F23">, DwarfRegNum<[55]>; 112193323Sed def F24 : FPR<24, "F24">, DwarfRegNum<[56]>; 113193323Sed def F25 : FPR<25, "F25">, DwarfRegNum<[57]>; 114193323Sed def F26 : FPR<26, "F26">, DwarfRegNum<[58]>; 115193323Sed def F27 : FPR<27, "F27">, DwarfRegNum<[59]>; 116193323Sed def F28 : FPR<28, "F28">, DwarfRegNum<[60]>; 117193323Sed def F29 : FPR<29, "F29">, DwarfRegNum<[61]>; 118193323Sed def F30 : FPR<30, "F30">, DwarfRegNum<[62]>; 119193323Sed def F31 : FPR<31, "F31">, DwarfRegNum<[63]>; 120193323Sed 121193323Sed /// Mips Double point precision FPU Registers (aliased 122193323Sed /// with the single precision to hold 64 bit values) 123193323Sed def D0 : AFPR< 0, "F0", [F0, F1]>, DwarfRegNum<[32]>; 124193323Sed def D1 : AFPR< 2, "F2", [F2, F3]>, DwarfRegNum<[34]>; 125193323Sed def D2 : AFPR< 4, "F4", [F4, F5]>, DwarfRegNum<[36]>; 126193323Sed def D3 : AFPR< 6, "F6", [F6, F7]>, DwarfRegNum<[38]>; 127193323Sed def D4 : AFPR< 8, "F8", [F8, F9]>, DwarfRegNum<[40]>; 128193323Sed def D5 : AFPR<10, "F10", [F10, F11]>, DwarfRegNum<[42]>; 129193323Sed def D6 : AFPR<12, "F12", [F12, F13]>, DwarfRegNum<[44]>; 130193323Sed def D7 : AFPR<14, "F14", [F14, F15]>, DwarfRegNum<[46]>; 131193323Sed def D8 : AFPR<16, "F16", [F16, F17]>, DwarfRegNum<[48]>; 132193323Sed def D9 : AFPR<18, "F18", [F18, F19]>, DwarfRegNum<[50]>; 133193323Sed def D10 : AFPR<20, "F20", [F20, F21]>, DwarfRegNum<[52]>; 134193323Sed def D11 : AFPR<22, "F22", [F22, F23]>, DwarfRegNum<[54]>; 135193323Sed def D12 : AFPR<24, "F24", [F24, F25]>, DwarfRegNum<[56]>; 136193323Sed def D13 : AFPR<26, "F26", [F26, F27]>, DwarfRegNum<[58]>; 137193323Sed def D14 : AFPR<28, "F28", [F28, F29]>, DwarfRegNum<[60]>; 138193323Sed def D15 : AFPR<30, "F30", [F30, F31]>, DwarfRegNum<[62]>; 139193323Sed 140193323Sed // Hi/Lo registers 141193323Sed def HI : Register<"hi">, DwarfRegNum<[64]>; 142193323Sed def LO : Register<"lo">, DwarfRegNum<[65]>; 143193323Sed 144193323Sed // Status flags register 145193323Sed def FCR31 : Register<"31">; 146193323Sed} 147193323Sed 148193323Sed//===----------------------------------------------------------------------===// 149193323Sed// Register Classes 150193323Sed//===----------------------------------------------------------------------===// 151193323Sed 152193323Seddef CPURegs : RegisterClass<"Mips", [i32], 32, 153198090Srdivacky // Return Values and Arguments 154198090Srdivacky [V0, V1, A0, A1, A2, A3, 155198090Srdivacky // Not preserved across procedure calls 156198090Srdivacky T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, 157198090Srdivacky // Callee save 158198090Srdivacky S0, S1, S2, S3, S4, S5, S6, S7, 159198090Srdivacky // Reserved 160198090Srdivacky ZERO, AT, K0, K1, GP, SP, FP, RA]> 161193323Sed{ 162193323Sed let MethodProtos = [{ 163193323Sed iterator allocation_order_end(const MachineFunction &MF) const; 164193323Sed }]; 165193323Sed let MethodBodies = [{ 166193323Sed CPURegsClass::iterator 167193323Sed CPURegsClass::allocation_order_end(const MachineFunction &MF) const { 168193323Sed // The last 8 registers on the list above are reserved 169193323Sed return end()-8; 170193323Sed } 171193323Sed }]; 172193323Sed} 173193323Sed 174193323Sed// 64bit fp: 175193323Sed// * FGR64 - 32 64-bit registers 176193323Sed// * AFGR64 - 16 32-bit even registers (32-bit FP Mode) 177193323Sed// 178193323Sed// 32bit fp: 179193323Sed// * FGR32 - 16 32-bit even registers 180193323Sed// * FGR32 - 32 32-bit registers (single float only mode) 181193323Seddef FGR32 : RegisterClass<"Mips", [f32], 32, 182193323Sed // Return Values and Arguments 183193323Sed [F0, F1, F2, F3, F12, F13, F14, F15, 184193323Sed // Not preserved across procedure calls 185193323Sed F4, F5, F6, F7, F8, F9, F10, F11, F16, F17, F18, F19, 186193323Sed // Callee save 187193323Sed F20, F21, F22, F23, F24, F25, F26, F27, F28, F29, F30, 188193323Sed // Reserved 189193323Sed F31]> 190193323Sed{ 191193323Sed let MethodProtos = [{ 192193323Sed iterator allocation_order_begin(const MachineFunction &MF) const; 193193323Sed iterator allocation_order_end(const MachineFunction &MF) const; 194193323Sed }]; 195193323Sed let MethodBodies = [{ 196193323Sed 197193323Sed static const unsigned MIPS_FGR32[] = { 198193323Sed Mips::F0, Mips::F1, Mips::F2, Mips::F3, Mips::F12, Mips::F13, 199193323Sed Mips::F14, Mips::F15, Mips::F4, Mips::F5, Mips::F6, Mips::F7, 200193323Sed Mips::F8, Mips::F9, Mips::F10, Mips::F11, Mips::F16, Mips::F17, 201193323Sed Mips::F18, Mips::F19, Mips::F20, Mips::F21, Mips::F22, Mips::F23, 202193323Sed Mips::F24, Mips::F25, Mips::F26, Mips::F27, Mips::F28, Mips::F29, 203193323Sed Mips::F30 204193323Sed }; 205193323Sed 206193323Sed static const unsigned MIPS_SVR4_FGR32[] = { 207193323Sed Mips::F0, Mips::F2, Mips::F12, Mips::F14, Mips::F4, 208193323Sed Mips::F6, Mips::F8, Mips::F10, Mips::F16, Mips::F18, 209193323Sed Mips::F20, Mips::F22, Mips::F24, Mips::F26, Mips::F28, Mips::F30, 210193323Sed }; 211193323Sed 212193323Sed FGR32Class::iterator 213193323Sed FGR32Class::allocation_order_begin(const MachineFunction &MF) const { 214193323Sed const TargetMachine &TM = MF.getTarget(); 215193323Sed const MipsSubtarget &Subtarget = TM.getSubtarget<MipsSubtarget>(); 216193323Sed 217193323Sed if (Subtarget.isSingleFloat()) 218193323Sed return MIPS_FGR32; 219193323Sed else 220193323Sed return MIPS_SVR4_FGR32; 221193323Sed } 222193323Sed 223193323Sed FGR32Class::iterator 224193323Sed FGR32Class::allocation_order_end(const MachineFunction &MF) const { 225193323Sed const TargetMachine &TM = MF.getTarget(); 226193323Sed const MipsSubtarget &Subtarget = TM.getSubtarget<MipsSubtarget>(); 227193323Sed 228193323Sed if (Subtarget.isSingleFloat()) 229193323Sed return MIPS_FGR32 + (sizeof(MIPS_FGR32) / sizeof(unsigned)); 230193323Sed else 231193323Sed return MIPS_SVR4_FGR32 + (sizeof(MIPS_SVR4_FGR32) / sizeof(unsigned)); 232193323Sed } 233193323Sed }]; 234193323Sed} 235193323Sed 236193323Seddef AFGR64 : RegisterClass<"Mips", [f64], 64, 237193323Sed // Return Values and Arguments 238193323Sed [D0, D1, D6, D7, 239193323Sed // Not preserved across procedure calls 240193323Sed D2, D3, D4, D5, D8, D9, 241193323Sed // Callee save 242193323Sed D10, D11, D12, D13, D14, 243193323Sed // Reserved 244193323Sed D15]> 245193323Sed{ 246193323Sed let SubRegClasses = [(FGR32 sub_fpeven, sub_fpodd)]; 247193323Sed let MethodProtos = [{ 248193323Sed iterator allocation_order_end(const MachineFunction &MF) const; 249193323Sed }]; 250193323Sed let MethodBodies = [{ 251193323Sed AFGR64Class::iterator 252193323Sed AFGR64Class::allocation_order_end(const MachineFunction &MF) const { 253193323Sed // The last register on the list above is reserved 254193323Sed return end()-1; 255193323Sed } 256193323Sed }]; 257193323Sed} 258193323Sed 259193323Sed// Condition Register for floating point operations 260193323Seddef CCR : RegisterClass<"Mips", [i32], 32, [FCR31]>; 261193323Sed 262193323Sed// Hi/Lo Registers 263193323Seddef HILO : RegisterClass<"Mips", [i32], 32, [HI, LO]>; 264193323Sed 265193323Sed