1 //==-- M68kRegisterInfo.td - M68k register definitions ------*- tablegen -*-==//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
10 /// This file describes the M68k Register file, defining the registers
11 /// aliases between the registers, and the register classes built out of the
14 //===----------------------------------------------------------------------===//
16 class MxReg<string N, bits<16> ENC,
17 list<Register> SUBREGS = [], list<SubRegIndex> SUBIDX,
18 list<int> DWREGS = [], list<string> ALTNAMES = []>
19 : Register<N, ALTNAMES>, DwarfRegNum<DWREGS> {
20 let Namespace = "M68k";
22 let SubRegs = SUBREGS;
23 let SubRegIndices = SUBIDX;
26 // Subregister indices.
27 let Namespace = "M68k" in {
28 def MxSubRegIndex8Lo : SubRegIndex<8, 0>;
29 def MxSubRegIndex16Lo : SubRegIndex<16, 0>;
32 multiclass MxDataRegister<int INDEX, string REG_NAME, list<string> ALTNAMES = []> {
33 def "B"#NAME : MxReg<REG_NAME, INDEX, [], [], [INDEX], ALTNAMES>;
35 : MxReg<REG_NAME, INDEX,
36 [!cast<Register>("B"#NAME)], [MxSubRegIndex8Lo],
39 : MxReg<REG_NAME, INDEX,
40 [!cast<Register>("W"#NAME)], [MxSubRegIndex16Lo],
44 multiclass MxAddressRegister<int INDEX, string REG_NAME, list<string> ALTNAMES = []> {
46 : MxReg<REG_NAME, INDEX, [], [], [!add(8,INDEX)], ALTNAMES>;
48 : MxReg<REG_NAME, INDEX,
49 [!cast<Register>("W"#NAME)], [MxSubRegIndex16Lo],
50 [!add(8,INDEX)], ALTNAMES>;
53 defm D0 : MxDataRegister<0, "d0">;
54 defm D1 : MxDataRegister<1, "d1">;
55 defm D2 : MxDataRegister<2, "d2">;
56 defm D3 : MxDataRegister<3, "d3">;
57 defm D4 : MxDataRegister<4, "d4">;
58 defm D5 : MxDataRegister<5, "d5">;
59 defm D6 : MxDataRegister<6, "d6">;
60 defm D7 : MxDataRegister<7, "d7">;
62 defm A0 : MxAddressRegister<0, "a0">;
63 defm A1 : MxAddressRegister<1, "a1">;
64 defm A2 : MxAddressRegister<2, "a2">;
65 defm A3 : MxAddressRegister<3, "a3">;
66 defm A4 : MxAddressRegister<4, "a4">;
67 defm A5 : MxAddressRegister<5, "a5", ["bp"]>;
68 defm A6 : MxAddressRegister<6, "a6", ["fp"]>;
69 defm SP : MxAddressRegister<7, "sp", ["usp", "ssp", "isp", "a7"]>;
71 // Floating Point Registers
72 class MxFPRegister<int INDEX, string REG_NAME, list<string> ALTNAMES = []>
73 : MxReg<REG_NAME, INDEX, /*SUBREGS=*/[], /*SUBIDX=*/[],
74 /*DWREGS=*/[!add(18,INDEX)], ALTNAMES>;
77 def FP#i : MxFPRegister<i, "fp"#i>;
79 // Unlike their counterparts in integer registers, these
80 // control registers can be accessed and modified by instructions.
81 def FPC : MxFPRegister<8, "fpcr", ["fpc"]>;
82 def FPS : MxFPRegister<9, "fpsr", ["fps"]>;
83 def FPIAR : MxFPRegister<10, "fpiar", ["fpi"]>;
86 class MxPseudoReg<string N, list<Register> SUBREGS = [], list<SubRegIndex> SUBIDX = []>
87 : MxReg<N, 0, SUBREGS, SUBIDX>;
89 def CCR : MxPseudoReg<"ccr">;
90 def SR : MxPseudoReg<"sr">;
92 def PC : MxPseudoReg<"pc">;
94 //===----------------------------------------------------------------------===//
96 //===----------------------------------------------------------------------===//
98 class MxRegClass<list<ValueType> regTypes, int alignment, dag regList>
99 : RegisterClass<"M68k", regTypes, alignment, regList>;
102 def DR8 : MxRegClass<[i8], 16, (sequence "BD%u", 0, 7)>;
103 def DR16 : MxRegClass<[i16], 16, (sequence "WD%u", 0, 7)>;
104 def DR32 : MxRegClass<[i32], 32, (sequence "D%u", 0, 7)>;
107 def AR16 : MxRegClass<[i16], 16, (add (sequence "WA%u", 0, 6), WSP)>;
108 def AR32 : MxRegClass<[i32], 32, (add (sequence "A%u", 0, 6), SP)>;
110 def AR32_NOSP : MxRegClass<[i32], 32, (sequence "A%u", 0, 6)>;
112 // Index Register Classes
113 // FIXME try alternative ordering like `D0, D1, A0, A1, ...`
114 def XR16 : MxRegClass<[i16], 16, (add DR16, AR16)>;
115 def XR32 : MxRegClass<[i32], 32, (add DR32, AR32)>;
117 def SPC : MxRegClass<[i32], 32, (add SP)>;
119 // Floating Point Data Registers
120 def FPDR32 : MxRegClass<[f32], 32, (sequence "FP%u", 0, 7)>;
121 def FPDR64 : MxRegClass<[f64], 32, (add FPDR32)>;
122 def FPDR80 : MxRegClass<[f80], 32, (add FPDR32)>;
124 let CopyCost = -1 in {
125 def CCRC : MxRegClass<[i8], 16, (add CCR)>;
126 def SRC : MxRegClass<[i16], 16, (add SR)>;
128 // Float Point System Control Registers
129 def FPIC : MxRegClass<[i32], 32, (add FPIAR)>;
130 def FPCSC : MxRegClass<[i32], 32, (add FPC, FPS)>;
131 def FPSYSC : MxRegClass<[i32], 32, (add FPCSC, FPIC)>;
134 let isAllocatable = 0 in {
135 def PCC : MxRegClass<[i32], 32, (add PC)>;
138 // Register used with tail call
139 def DR16_TC : MxRegClass<[i16], 16, (add D0, D1)>;
140 def DR32_TC : MxRegClass<[i32], 32, (add D0, D1)>;
142 def AR16_TC : MxRegClass<[i16], 16, (add A0, A1)>;
143 def AR32_TC : MxRegClass<[i32], 32, (add A0, A1)>;
145 def XR16_TC : MxRegClass<[i16], 16, (add DR16_TC, AR16_TC)>;
146 def XR32_TC : MxRegClass<[i32], 32, (add DR32_TC, AR32_TC)>;
148 // These classes provide spill/restore order if used with MOVEM instruction
149 def SPILL : MxRegClass<[i32], 32, (add XR32)>;
150 def SPILL_R : MxRegClass<[i32], 32, (add SP, (sequence "A%u", 6, 0), (sequence "D%u", 7, 0))>;