1 //===-- MipsRegisterInfo.td - Mips Register defs -----------*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 //===----------------------------------------------------------------------===//
11 // Declarations that describe the MIPS register file
12 //===----------------------------------------------------------------------===//
13 let Namespace = "Mips" in {
14 def sub_32 : SubRegIndex<32>;
15 def sub_64 : SubRegIndex<64>;
16 def sub_lo : SubRegIndex<32>;
17 def sub_hi : SubRegIndex<32, 32>;
18 def sub_dsp16_19 : SubRegIndex<4, 16>;
19 def sub_dsp20 : SubRegIndex<1, 20>;
20 def sub_dsp21 : SubRegIndex<1, 21>;
21 def sub_dsp22 : SubRegIndex<1, 22>;
22 def sub_dsp23 : SubRegIndex<1, 23>;
26 bit isAllocatable = 0;
29 // We have banks of 32 registers each.
30 class MipsReg<bits<16> Enc, string n> : Register<n> {
32 let Namespace = "Mips";
35 class MipsRegWithSubRegs<bits<16> Enc, string n, list<Register> subregs>
36 : RegisterWithSubRegs<n, subregs> {
38 let Namespace = "Mips";
42 class MipsGPRReg<bits<16> Enc, string n> : MipsReg<Enc, n>;
44 // Mips 64-bit CPU Registers
45 class Mips64GPRReg<bits<16> Enc, string n, list<Register> subregs>
46 : MipsRegWithSubRegs<Enc, n, subregs> {
47 let SubRegIndices = [sub_32];
50 // Mips 32-bit FPU Registers
51 class FPR<bits<16> Enc, string n> : MipsReg<Enc, n>;
53 // Mips 64-bit (aliased) FPU Registers
54 class AFPR<bits<16> Enc, string n, list<Register> subregs>
55 : MipsRegWithSubRegs<Enc, n, subregs> {
56 let SubRegIndices = [sub_lo, sub_hi];
57 let CoveredBySubRegs = 1;
60 class AFPR64<bits<16> Enc, string n, list<Register> subregs>
61 : MipsRegWithSubRegs<Enc, n, subregs> {
62 let SubRegIndices = [sub_lo, sub_hi];
63 let CoveredBySubRegs = 1;
66 // Mips 128-bit (aliased) MSA Registers
67 class AFPR128<bits<16> Enc, string n, list<Register> subregs>
68 : MipsRegWithSubRegs<Enc, n, subregs> {
69 let SubRegIndices = [sub_64];
72 // Accumulator Registers
73 class ACCReg<bits<16> Enc, string n, list<Register> subregs>
74 : MipsRegWithSubRegs<Enc, n, subregs> {
75 let SubRegIndices = [sub_lo, sub_hi];
76 let CoveredBySubRegs = 1;
79 // Mips Hardware Registers
80 class HWR<bits<16> Enc, string n> : MipsReg<Enc, n>;
82 //===----------------------------------------------------------------------===//
84 //===----------------------------------------------------------------------===//
86 let Namespace = "Mips" in {
87 // General Purpose Registers
88 def ZERO : MipsGPRReg< 0, "zero">, DwarfRegNum<[0]>;
89 def AT : MipsGPRReg< 1, "1">, DwarfRegNum<[1]>;
90 def V0 : MipsGPRReg< 2, "2">, DwarfRegNum<[2]>;
91 def V1 : MipsGPRReg< 3, "3">, DwarfRegNum<[3]>;
92 def A0 : MipsGPRReg< 4, "4">, DwarfRegNum<[4]>;
93 def A1 : MipsGPRReg< 5, "5">, DwarfRegNum<[5]>;
94 def A2 : MipsGPRReg< 6, "6">, DwarfRegNum<[6]>;
95 def A3 : MipsGPRReg< 7, "7">, DwarfRegNum<[7]>;
96 def T0 : MipsGPRReg< 8, "8">, DwarfRegNum<[8]>;
97 def T1 : MipsGPRReg< 9, "9">, DwarfRegNum<[9]>;
98 def T2 : MipsGPRReg< 10, "10">, DwarfRegNum<[10]>;
99 def T3 : MipsGPRReg< 11, "11">, DwarfRegNum<[11]>;
100 def T4 : MipsGPRReg< 12, "12">, DwarfRegNum<[12]>;
101 def T5 : MipsGPRReg< 13, "13">, DwarfRegNum<[13]>;
102 def T6 : MipsGPRReg< 14, "14">, DwarfRegNum<[14]>;
103 def T7 : MipsGPRReg< 15, "15">, DwarfRegNum<[15]>;
104 def S0 : MipsGPRReg< 16, "16">, DwarfRegNum<[16]>;
105 def S1 : MipsGPRReg< 17, "17">, DwarfRegNum<[17]>;
106 def S2 : MipsGPRReg< 18, "18">, DwarfRegNum<[18]>;
107 def S3 : MipsGPRReg< 19, "19">, DwarfRegNum<[19]>;
108 def S4 : MipsGPRReg< 20, "20">, DwarfRegNum<[20]>;
109 def S5 : MipsGPRReg< 21, "21">, DwarfRegNum<[21]>;
110 def S6 : MipsGPRReg< 22, "22">, DwarfRegNum<[22]>;
111 def S7 : MipsGPRReg< 23, "23">, DwarfRegNum<[23]>;
112 def T8 : MipsGPRReg< 24, "24">, DwarfRegNum<[24]>;
113 def T9 : MipsGPRReg< 25, "25">, DwarfRegNum<[25]>;
114 def K0 : MipsGPRReg< 26, "26">, DwarfRegNum<[26]>;
115 def K1 : MipsGPRReg< 27, "27">, DwarfRegNum<[27]>;
116 def GP : MipsGPRReg< 28, "gp">, DwarfRegNum<[28]>;
117 def SP : MipsGPRReg< 29, "sp">, DwarfRegNum<[29]>;
118 def FP : MipsGPRReg< 30, "fp">, DwarfRegNum<[30]>;
119 def RA : MipsGPRReg< 31, "ra">, DwarfRegNum<[31]>;
121 // General Purpose 64-bit Registers
122 def ZERO_64 : Mips64GPRReg< 0, "zero", [ZERO]>, DwarfRegNum<[0]>;
123 def AT_64 : Mips64GPRReg< 1, "1", [AT]>, DwarfRegNum<[1]>;
124 def V0_64 : Mips64GPRReg< 2, "2", [V0]>, DwarfRegNum<[2]>;
125 def V1_64 : Mips64GPRReg< 3, "3", [V1]>, DwarfRegNum<[3]>;
126 def A0_64 : Mips64GPRReg< 4, "4", [A0]>, DwarfRegNum<[4]>;
127 def A1_64 : Mips64GPRReg< 5, "5", [A1]>, DwarfRegNum<[5]>;
128 def A2_64 : Mips64GPRReg< 6, "6", [A2]>, DwarfRegNum<[6]>;
129 def A3_64 : Mips64GPRReg< 7, "7", [A3]>, DwarfRegNum<[7]>;
130 def T0_64 : Mips64GPRReg< 8, "8", [T0]>, DwarfRegNum<[8]>;
131 def T1_64 : Mips64GPRReg< 9, "9", [T1]>, DwarfRegNum<[9]>;
132 def T2_64 : Mips64GPRReg< 10, "10", [T2]>, DwarfRegNum<[10]>;
133 def T3_64 : Mips64GPRReg< 11, "11", [T3]>, DwarfRegNum<[11]>;
134 def T4_64 : Mips64GPRReg< 12, "12", [T4]>, DwarfRegNum<[12]>;
135 def T5_64 : Mips64GPRReg< 13, "13", [T5]>, DwarfRegNum<[13]>;
136 def T6_64 : Mips64GPRReg< 14, "14", [T6]>, DwarfRegNum<[14]>;
137 def T7_64 : Mips64GPRReg< 15, "15", [T7]>, DwarfRegNum<[15]>;
138 def S0_64 : Mips64GPRReg< 16, "16", [S0]>, DwarfRegNum<[16]>;
139 def S1_64 : Mips64GPRReg< 17, "17", [S1]>, DwarfRegNum<[17]>;
140 def S2_64 : Mips64GPRReg< 18, "18", [S2]>, DwarfRegNum<[18]>;
141 def S3_64 : Mips64GPRReg< 19, "19", [S3]>, DwarfRegNum<[19]>;
142 def S4_64 : Mips64GPRReg< 20, "20", [S4]>, DwarfRegNum<[20]>;
143 def S5_64 : Mips64GPRReg< 21, "21", [S5]>, DwarfRegNum<[21]>;
144 def S6_64 : Mips64GPRReg< 22, "22", [S6]>, DwarfRegNum<[22]>;
145 def S7_64 : Mips64GPRReg< 23, "23", [S7]>, DwarfRegNum<[23]>;
146 def T8_64 : Mips64GPRReg< 24, "24", [T8]>, DwarfRegNum<[24]>;
147 def T9_64 : Mips64GPRReg< 25, "25", [T9]>, DwarfRegNum<[25]>;
148 def K0_64 : Mips64GPRReg< 26, "26", [K0]>, DwarfRegNum<[26]>;
149 def K1_64 : Mips64GPRReg< 27, "27", [K1]>, DwarfRegNum<[27]>;
150 def GP_64 : Mips64GPRReg< 28, "gp", [GP]>, DwarfRegNum<[28]>;
151 def SP_64 : Mips64GPRReg< 29, "sp", [SP]>, DwarfRegNum<[29]>;
152 def FP_64 : Mips64GPRReg< 30, "fp", [FP]>, DwarfRegNum<[30]>;
153 def RA_64 : Mips64GPRReg< 31, "ra", [RA]>, DwarfRegNum<[31]>;
155 /// Mips Single point precision FPU Registers
157 def F#I : FPR<I, "f"#I>, DwarfRegNum<[!add(I, 32)]>;
159 // Higher half of 64-bit FP registers.
161 def F_HI#I : FPR<I, "f"#I>, DwarfRegNum<[!add(I, 32)]>;
163 /// Mips Double point precision FPU Registers (aliased
164 /// with the single precision to hold 64 bit values)
166 def D#I : AFPR<!shl(I, 1), "f"#!shl(I, 1),
167 [!cast<FPR>("F"#!shl(I, 1)),
168 !cast<FPR>("F"#!add(!shl(I, 1), 1))]>;
170 /// Mips Double point precision FPU Registers in MFP64 mode.
172 def D#I#_64 : AFPR64<I, "f"#I, [!cast<FPR>("F"#I), !cast<FPR>("F_HI"#I)]>,
173 DwarfRegNum<[!add(I, 32)]>;
175 /// Mips MSA registers
176 /// MSA and FPU cannot both be present unless the FPU has 64-bit registers
178 def W#I : AFPR128<I, "w"#I, [!cast<AFPR64>("D"#I#"_64")]>,
179 DwarfRegNum<[!add(I, 32)]>;
182 def HI0 : Register<"ac0">, DwarfRegNum<[64]>;
183 def HI1 : Register<"ac1">, DwarfRegNum<[176]>;
184 def HI2 : Register<"ac2">, DwarfRegNum<[178]>;
185 def HI3 : Register<"ac3">, DwarfRegNum<[180]>;
186 def LO0 : Register<"ac0">, DwarfRegNum<[65]>;
187 def LO1 : Register<"ac1">, DwarfRegNum<[177]>;
188 def LO2 : Register<"ac2">, DwarfRegNum<[179]>;
189 def LO3 : Register<"ac3">, DwarfRegNum<[181]>;
191 let SubRegIndices = [sub_32] in {
192 def HI0_64 : RegisterWithSubRegs<"hi", [HI0]>;
193 def LO0_64 : RegisterWithSubRegs<"lo", [LO0]>;
196 // FP control registers.
198 def FCR#I : MipsReg<#I, ""#I>;
200 // FP condition code registers.
202 def FCC#I : MipsReg<#I, "fcc"#I>;
206 def COP2#I : MipsReg<#I, ""#I>;
209 def PC : Register<"pc">;
211 // Hardware register $29
212 def HWR29 : MipsReg<29, "29">;
216 def AC#I : ACCReg<#I, "ac"#I,
217 [!cast<Register>("LO"#I), !cast<Register>("HI"#I)]>;
219 def AC0_64 : ACCReg<0, "ac0", [LO0_64, HI0_64]>;
221 // DSP-ASE control register fields.
222 def DSPPos : Register<"">;
223 def DSPSCount : Register<"">;
224 def DSPCarry : Register<"">;
225 def DSPEFI : Register<"">;
226 def DSPOutFlag16_19 : Register<"">;
227 def DSPOutFlag20 : Register<"">;
228 def DSPOutFlag21 : Register<"">;
229 def DSPOutFlag22 : Register<"">;
230 def DSPOutFlag23 : Register<"">;
231 def DSPCCond : Register<"">;
233 let SubRegIndices = [sub_dsp16_19, sub_dsp20, sub_dsp21, sub_dsp22,
235 def DSPOutFlag : RegisterWithSubRegs<"", [DSPOutFlag16_19, DSPOutFlag20,
236 DSPOutFlag21, DSPOutFlag22,
239 // MSA-ASE control registers.
240 def MSAIR : Register<"0">;
241 def MSACSR : Register<"1">;
242 def MSAAccess : Register<"2">;
243 def MSASave : Register<"3">;
244 def MSAModify : Register<"4">;
245 def MSARequest : Register<"5">;
246 def MSAMap : Register<"6">;
247 def MSAUnmap : Register<"7">;
250 //===----------------------------------------------------------------------===//
252 //===----------------------------------------------------------------------===//
254 class GPR32Class<list<ValueType> regTypes> :
255 RegisterClass<"Mips", regTypes, 32, (add
258 // Return Values and Arguments
259 V0, V1, A0, A1, A2, A3,
260 // Not preserved across procedure calls
261 T0, T1, T2, T3, T4, T5, T6, T7,
263 S0, S1, S2, S3, S4, S5, S6, S7,
264 // Not preserved across procedure calls
267 K0, K1, GP, SP, FP, RA)>;
269 def GPR32 : GPR32Class<[i32]>;
270 def DSPR : GPR32Class<[v4i8, v2i16]>;
272 def GPR64 : RegisterClass<"Mips", [i64], 64, (add
275 // Return Values and Arguments
276 V0_64, V1_64, A0_64, A1_64, A2_64, A3_64,
277 // Not preserved across procedure calls
278 T0_64, T1_64, T2_64, T3_64, T4_64, T5_64, T6_64, T7_64,
280 S0_64, S1_64, S2_64, S3_64, S4_64, S5_64, S6_64, S7_64,
281 // Not preserved across procedure calls
284 K0_64, K1_64, GP_64, SP_64, FP_64, RA_64)>;
286 def CPU16Regs : RegisterClass<"Mips", [i32], 32, (add
287 // Return Values and Arguments
288 V0, V1, A0, A1, A2, A3,
292 def CPU16RegsPlusSP : RegisterClass<"Mips", [i32], 32, (add
293 // Return Values and Arguments
294 V0, V1, A0, A1, A2, A3,
299 def CPURAReg : RegisterClass<"Mips", [i32], 32, (add RA)>, Unallocatable;
301 def CPUSPReg : RegisterClass<"Mips", [i32], 32, (add SP)>, Unallocatable;
304 // * FGR64 - 32 64-bit registers
305 // * AFGR64 - 16 32-bit even registers (32-bit FP Mode)
308 // * FGR32 - 16 32-bit even registers
309 // * FGR32 - 32 32-bit registers (single float only mode)
310 def FGR32 : RegisterClass<"Mips", [f32], 32, (sequence "F%u", 0, 31)>;
312 def FGRH32 : RegisterClass<"Mips", [f32], 32, (sequence "F_HI%u", 0, 31)>,
315 def AFGR64 : RegisterClass<"Mips", [f64], 64, (add
316 // Return Values and Arguments
318 // Not preserved across procedure calls
320 // Return Values and Arguments
322 // Not preserved across procedure calls
325 D10, D11, D12, D13, D14, D15)>;
327 def FGR64 : RegisterClass<"Mips", [f64], 64, (sequence "D%u_64", 0, 31)>;
329 // FP control registers.
330 def CCR : RegisterClass<"Mips", [i32], 32, (sequence "FCR%u", 0, 31)>,
333 // FP condition code registers.
334 def FCC : RegisterClass<"Mips", [i32], 32, (sequence "FCC%u", 0, 7)>,
337 def MSA128B: RegisterClass<"Mips", [v16i8], 128,
338 (sequence "W%u", 0, 31)>;
339 def MSA128H: RegisterClass<"Mips", [v8i16, v8f16], 128,
340 (sequence "W%u", 0, 31)>;
341 def MSA128W: RegisterClass<"Mips", [v4i32, v4f32], 128,
342 (sequence "W%u", 0, 31)>;
343 def MSA128D: RegisterClass<"Mips", [v2i64, v2f64], 128,
344 (sequence "W%u", 0, 31)>;
346 def MSACtrl: RegisterClass<"Mips", [i32], 32, (add
347 MSAIR, MSACSR, MSAAccess, MSASave, MSAModify, MSARequest, MSAMap, MSAUnmap)>;
350 def LO32 : RegisterClass<"Mips", [i32], 32, (add LO0)>;
351 def HI32 : RegisterClass<"Mips", [i32], 32, (add HI0)>;
352 def LO32DSP : RegisterClass<"Mips", [i32], 32, (sequence "LO%u", 0, 3)>;
353 def HI32DSP : RegisterClass<"Mips", [i32], 32, (sequence "HI%u", 0, 3)>;
354 def LO64 : RegisterClass<"Mips", [i64], 64, (add LO0_64)>;
355 def HI64 : RegisterClass<"Mips", [i64], 64, (add HI0_64)>;
357 // Hardware registers
358 def HWRegs : RegisterClass<"Mips", [i32], 32, (add HWR29)>, Unallocatable;
360 // Accumulator Registers
361 def ACC64 : RegisterClass<"Mips", [untyped], 64, (add AC0)> {
365 def ACC128 : RegisterClass<"Mips", [untyped], 128, (add AC0_64)> {
369 def ACC64DSP : RegisterClass<"Mips", [untyped], 64, (sequence "AC%u", 0, 3)> {
373 def DSPCC : RegisterClass<"Mips", [v4i8, v2i16], 32, (add DSPCCond)>;
375 // Coprocessor 2 registers.
376 def COP2 : RegisterClass<"Mips", [i32], 32, (sequence "COP2%u", 0, 31)>,
379 // Register Operands.
381 class MipsAsmRegOperand : AsmOperandClass {
382 let RenderMethod = "addRegAsmOperands";
384 def GPR32AsmOperand : MipsAsmRegOperand {
385 let Name = "GPR32Asm";
386 let ParserMethod = "parseGPR32";
389 def GPR64AsmOperand : MipsAsmRegOperand {
390 let Name = "GPR64Asm";
391 let ParserMethod = "parseGPR64";
394 def ACC64DSPAsmOperand : MipsAsmRegOperand {
395 let Name = "ACC64DSPAsm";
396 let ParserMethod = "parseACC64DSP";
399 def LO32DSPAsmOperand : MipsAsmRegOperand {
400 let Name = "LO32DSPAsm";
401 let ParserMethod = "parseLO32DSP";
404 def HI32DSPAsmOperand : MipsAsmRegOperand {
405 let Name = "HI32DSPAsm";
406 let ParserMethod = "parseHI32DSP";
409 def CCRAsmOperand : MipsAsmRegOperand {
411 let ParserMethod = "parseCCRRegs";
414 def AFGR64AsmOperand : MipsAsmRegOperand {
415 let Name = "AFGR64Asm";
416 let ParserMethod = "parseAFGR64Regs";
419 def FGR64AsmOperand : MipsAsmRegOperand {
420 let Name = "FGR64Asm";
421 let ParserMethod = "parseFGR64Regs";
424 def FGR32AsmOperand : MipsAsmRegOperand {
425 let Name = "FGR32Asm";
426 let ParserMethod = "parseFGR32Regs";
429 def FGRH32AsmOperand : MipsAsmRegOperand {
430 let Name = "FGRH32Asm";
431 let ParserMethod = "parseFGRH32Regs";
434 def FCCRegsAsmOperand : MipsAsmRegOperand {
435 let Name = "FCCRegsAsm";
436 let ParserMethod = "parseFCCRegs";
439 def MSA128BAsmOperand : MipsAsmRegOperand {
440 let Name = "MSA128BAsm";
441 let ParserMethod = "parseMSA128BRegs";
444 def MSA128HAsmOperand : MipsAsmRegOperand {
445 let Name = "MSA128HAsm";
446 let ParserMethod = "parseMSA128HRegs";
449 def MSA128WAsmOperand : MipsAsmRegOperand {
450 let Name = "MSA128WAsm";
451 let ParserMethod = "parseMSA128WRegs";
454 def MSA128DAsmOperand : MipsAsmRegOperand {
455 let Name = "MSA128DAsm";
456 let ParserMethod = "parseMSA128DRegs";
459 def GPR32Opnd : RegisterOperand<GPR32> {
460 let ParserMatchClass = GPR32AsmOperand;
463 def GPR64Opnd : RegisterOperand<GPR64> {
464 let ParserMatchClass = GPR64AsmOperand;
467 def DSPROpnd : RegisterOperand<DSPR> {
468 let ParserMatchClass = GPR32AsmOperand;
471 def CCROpnd : RegisterOperand<CCR> {
472 let ParserMatchClass = CCRAsmOperand;
475 def HWRegsAsmOperand : MipsAsmRegOperand {
476 let Name = "HWRegsAsm";
477 let ParserMethod = "parseHWRegs";
480 def COP2AsmOperand : MipsAsmRegOperand {
481 let Name = "COP2Asm";
482 let ParserMethod = "parseCOP2";
485 def HWRegsOpnd : RegisterOperand<HWRegs> {
486 let ParserMatchClass = HWRegsAsmOperand;
489 def AFGR64Opnd : RegisterOperand<AFGR64> {
490 let ParserMatchClass = AFGR64AsmOperand;
493 def FGR64Opnd : RegisterOperand<FGR64> {
494 let ParserMatchClass = FGR64AsmOperand;
497 def FGR32Opnd : RegisterOperand<FGR32> {
498 let ParserMatchClass = FGR32AsmOperand;
501 def FGRH32Opnd : RegisterOperand<FGRH32> {
502 let ParserMatchClass = FGRH32AsmOperand;
505 def FCCRegsOpnd : RegisterOperand<FCC> {
506 let ParserMatchClass = FCCRegsAsmOperand;
509 def LO32DSPOpnd : RegisterOperand<LO32DSP> {
510 let ParserMatchClass = LO32DSPAsmOperand;
513 def HI32DSPOpnd : RegisterOperand<HI32DSP> {
514 let ParserMatchClass = HI32DSPAsmOperand;
517 def ACC64DSPOpnd : RegisterOperand<ACC64DSP> {
518 let ParserMatchClass = ACC64DSPAsmOperand;
521 def COP2Opnd : RegisterOperand<COP2> {
522 let ParserMatchClass = COP2AsmOperand;
525 def MSA128BOpnd : RegisterOperand<MSA128B> {
526 let ParserMatchClass = MSA128BAsmOperand;
529 def MSA128HOpnd : RegisterOperand<MSA128H> {
530 let ParserMatchClass = MSA128HAsmOperand;
533 def MSA128WOpnd : RegisterOperand<MSA128W> {
534 let ParserMatchClass = MSA128WAsmOperand;
537 def MSA128DOpnd : RegisterOperand<MSA128D> {
538 let ParserMatchClass = MSA128DAsmOperand;