xref: /freebsd/contrib/llvm-project/llvm/lib/Target/ARC/ARCRegisterInfo.td (revision 349cc55c9796c4596a5b9904cd3281af295f878f)
10b57cec5SDimitry Andric//===- ARCRegisterInfo.td - ARC 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 ARC register file
110b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
120b57cec5SDimitry Andric
130b57cec5SDimitry Andricclass ARCReg<string n, list<string> altNames> : Register<n, altNames> {
140b57cec5SDimitry Andric  field bits<6> HwEncoding;
150b57cec5SDimitry Andric  let Namespace = "ARC";
160b57cec5SDimitry Andric}
170b57cec5SDimitry Andric
180b57cec5SDimitry Andric// Registers are identified with 6-bit ID numbers.
190b57cec5SDimitry Andric// Core - 32-bit core registers
200b57cec5SDimitry Andricclass Core<int num, string n, list<string>altNames=[]> : ARCReg<n, altNames> {
210b57cec5SDimitry Andric  let HWEncoding = num;
220b57cec5SDimitry Andric}
230b57cec5SDimitry Andric
24*349cc55cSDimitry Andric// Auxilary register
25*349cc55cSDimitry Andricclass Aux<int num, string n, list<string> altNames=[]> : ARCReg<n, altNames> {
26*349cc55cSDimitry Andric  let HWEncoding = num;
270b57cec5SDimitry Andric}
280b57cec5SDimitry Andric
290b57cec5SDimitry Andric// Integer registers
30*349cc55cSDimitry Andricforeach i = 0 - 3 in
31*349cc55cSDimitry Andric  def R#i : Core<i, "%r"#i>, DwarfRegNum<[i]>;
320b57cec5SDimitry Andric
33fe6060f1SDimitry Andriclet CostPerUse=[1] in {
34*349cc55cSDimitry Andric  foreach i = 4 - 11 in
35*349cc55cSDimitry Andric    def R#i : Core<i, "%r"#i>, DwarfRegNum<[i]>;
36*349cc55cSDimitry Andric}
37*349cc55cSDimitry Andric
38*349cc55cSDimitry Andricforeach i = 12 - 15 in
39*349cc55cSDimitry Andric  def R#i : Core<i, "%r"#i>, DwarfRegNum<[i]>;
40*349cc55cSDimitry Andric
41*349cc55cSDimitry Andriclet CostPerUse=[1] in {
42*349cc55cSDimitry Andric
43*349cc55cSDimitry Andric  foreach i = 16 - 25 in
44*349cc55cSDimitry Andric    def R#i : Core<i, "%r"#i>, DwarfRegNum<[i]>;
45*349cc55cSDimitry Andric
460b57cec5SDimitry Andric  def GP : Core<26, "%gp",["%r26"]>, DwarfRegNum<[26]>;
470b57cec5SDimitry Andric  def FP : Core<27, "%fp", ["%r27"]>, DwarfRegNum<[27]>;
480b57cec5SDimitry Andric  def SP : Core<28, "%sp", ["%r28"]>, DwarfRegNum<[28]>;
490b57cec5SDimitry Andric  def ILINK : Core<29, "%ilink">, DwarfRegNum<[29]>;
500b57cec5SDimitry Andric  def R30 : Core<30, "%r30">, DwarfRegNum<[30]>;
510b57cec5SDimitry Andric  def BLINK : Core<31, "%blink">, DwarfRegNum<[31]>;
520b57cec5SDimitry Andric
53*349cc55cSDimitry Andric  // Define extended core registers R32..R63
54*349cc55cSDimitry Andric  foreach i = 32 - 63 in
55*349cc55cSDimitry Andric    def R#i : Core<i, "%r"#i>, DwarfRegNum<[i]>;
560b57cec5SDimitry Andric}
570b57cec5SDimitry Andric
58*349cc55cSDimitry Andric// Auxilary registers
59*349cc55cSDimitry Andriclet CostPerUse=[1] in {
60*349cc55cSDimitry Andric  def STATUS32 : Aux<10, "status32">; // No DwarfRegNum defined in the ARC ABI
61*349cc55cSDimitry Andric}
62*349cc55cSDimitry Andric
630b57cec5SDimitry Andricdef GPR32: RegisterClass<"ARC", [i32], 32,
64*349cc55cSDimitry Andric  (add (sequence "R%u", 0, 25), GP, FP, SP, ILINK, R30, BLINK, (sequence "R%u", 32, 63))> {
65*349cc55cSDimitry Andric  let AltOrders=[(add (sequence "R%u", 0, 25), GP, FP, SP, ILINK, R30, BLINK)];
66*349cc55cSDimitry Andric  let AltOrderSelect = [{
67*349cc55cSDimitry Andric      // When referenced in a C++ code block like this
68*349cc55cSDimitry Andric      // 0 is all Core32 regs
69*349cc55cSDimitry Andric      // 1 is AltOrders[0]
70*349cc55cSDimitry Andric      // 2 is AltOrders[1] and so on
71*349cc55cSDimitry Andric      return 1;
72*349cc55cSDimitry Andric    }];
73*349cc55cSDimitry Andric}
740b57cec5SDimitry Andric
750b57cec5SDimitry Andricdef SREG : RegisterClass<"ARC", [i32], 1, (add STATUS32)>;
760b57cec5SDimitry Andric
770b57cec5SDimitry Andricdef GPR_S : RegisterClass<"ARC", [i32], 8,
780b57cec5SDimitry Andric  (add R0, R1, R2, R3, R12, R13, R14, R15)>;
790b57cec5SDimitry Andric
80