xref: /freebsd/contrib/llvm-project/llvm/lib/Target/PowerPC/PPCRegisterInfo.td (revision 52418fc2be8efa5172b90a3a9e617017173612c4)
10b57cec5SDimitry Andric//===-- PPCRegisterInfo.td - The PowerPC Register File -----*- 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//===----------------------------------------------------------------------===//
110b57cec5SDimitry Andric
120b57cec5SDimitry Andriclet Namespace = "PPC" in {
130b57cec5SDimitry Andricdef sub_lt : SubRegIndex<1>;
140b57cec5SDimitry Andricdef sub_gt : SubRegIndex<1, 1>;
150b57cec5SDimitry Andricdef sub_eq : SubRegIndex<1, 2>;
160b57cec5SDimitry Andricdef sub_un : SubRegIndex<1, 3>;
170b57cec5SDimitry Andricdef sub_32 : SubRegIndex<32>;
1806c3fb27SDimitry Andricdef sub_32_hi_phony : SubRegIndex<32,32>;
190b57cec5SDimitry Andricdef sub_64 : SubRegIndex<64>;
20*52418fc2SDimitry Andricdef sub_64_hi_phony : SubRegIndex<64,64>;
21e8d8bef9SDimitry Andricdef sub_vsx0 : SubRegIndex<128>;
22e8d8bef9SDimitry Andricdef sub_vsx1 : SubRegIndex<128, 128>;
23fe6060f1SDimitry Andricdef sub_gp8_x0 : SubRegIndex<64>;
24fe6060f1SDimitry Andricdef sub_gp8_x1 : SubRegIndex<64, 64>;
2506c3fb27SDimitry Andricdef sub_fp0 : SubRegIndex<64>;
2606c3fb27SDimitry Andricdef sub_fp1 : SubRegIndex<64, 64>;
270b57cec5SDimitry Andric}
280b57cec5SDimitry Andric
290b57cec5SDimitry Andric
300b57cec5SDimitry Andricclass PPCReg<string n> : Register<n> {
310b57cec5SDimitry Andric  let Namespace = "PPC";
320b57cec5SDimitry Andric}
330b57cec5SDimitry Andric
340b57cec5SDimitry Andric// We identify all our registers with a 5-bit ID, for consistency's sake.
350b57cec5SDimitry Andric
360b57cec5SDimitry Andric// GPR - One of the 32 32-bit general-purpose registers
370b57cec5SDimitry Andricclass GPR<bits<5> num, string n> : PPCReg<n> {
380b57cec5SDimitry Andric  let HWEncoding{4-0} = num;
390b57cec5SDimitry Andric}
400b57cec5SDimitry Andric
410b57cec5SDimitry Andric// GP8 - One of the 32 64-bit general-purpose registers
420b57cec5SDimitry Andricclass GP8<GPR SubReg, string n> : PPCReg<n> {
430b57cec5SDimitry Andric  let HWEncoding = SubReg.HWEncoding;
440b57cec5SDimitry Andric  let SubRegs = [SubReg];
450b57cec5SDimitry Andric  let SubRegIndices = [sub_32];
460b57cec5SDimitry Andric}
470b57cec5SDimitry Andric
4806c3fb27SDimitry Andricclass SPE<string n, bits<5> Enc, list<Register> subregs = []> : PPCReg<n> {
4906c3fb27SDimitry Andric  let HWEncoding{4-0} = Enc;
5006c3fb27SDimitry Andric  let SubRegs = subregs;
5106c3fb27SDimitry Andric  let SubRegIndices = [sub_32, sub_32_hi_phony];
5206c3fb27SDimitry Andric  let CoveredBySubRegs = 1;
530b57cec5SDimitry Andric}
540b57cec5SDimitry Andric// SPR - One of the 32-bit special-purpose registers
550b57cec5SDimitry Andricclass SPR<bits<10> num, string n> : PPCReg<n> {
560b57cec5SDimitry Andric  let HWEncoding{9-0} = num;
570b57cec5SDimitry Andric}
580b57cec5SDimitry Andric
590b57cec5SDimitry Andric// FPR - One of the 32 64-bit floating-point registers
600b57cec5SDimitry Andricclass FPR<bits<5> num, string n> : PPCReg<n> {
610b57cec5SDimitry Andric  let HWEncoding{4-0} = num;
620b57cec5SDimitry Andric}
630b57cec5SDimitry Andric
6406c3fb27SDimitry Andric// FPPair - A pair of 64-bit floating-point registers.
6506c3fb27SDimitry Andricclass FPPair<string n, bits<5> EvenIndex> : PPCReg<n> {
6606c3fb27SDimitry Andric  assert !eq(EvenIndex{0}, 0), "Index should be even.";
6706c3fb27SDimitry Andric  let HWEncoding{4-0} = EvenIndex;
6806c3fb27SDimitry Andric  let SubRegs = [!cast<FPR>("F"#EvenIndex), !cast<FPR>("F"#!add(EvenIndex, 1))];
6906c3fb27SDimitry Andric  let DwarfNumbers = [-1, -1];
7006c3fb27SDimitry Andric  let SubRegIndices = [sub_fp0, sub_fp1];
7106c3fb27SDimitry Andric}
7206c3fb27SDimitry Andric
730b57cec5SDimitry Andric// VF - One of the 32 64-bit floating-point subregisters of the vector
740b57cec5SDimitry Andric// registers (used by VSX).
750b57cec5SDimitry Andricclass VF<bits<5> num, string n> : PPCReg<n> {
760b57cec5SDimitry Andric  let HWEncoding{4-0} = num;
770b57cec5SDimitry Andric  let HWEncoding{5} = 1;
780b57cec5SDimitry Andric}
790b57cec5SDimitry Andric
800b57cec5SDimitry Andric// VR - One of the 32 128-bit vector registers
81*52418fc2SDimitry Andricclass VR<VF SubReg, VF SubRegH, string n> : PPCReg<n> {
820b57cec5SDimitry Andric  let HWEncoding{4-0} = SubReg.HWEncoding{4-0};
830b57cec5SDimitry Andric  let HWEncoding{5} = 0;
84*52418fc2SDimitry Andric  let SubRegs = [SubReg, SubRegH];
85*52418fc2SDimitry Andric  let SubRegIndices = [sub_64, sub_64_hi_phony];
860b57cec5SDimitry Andric}
870b57cec5SDimitry Andric
880b57cec5SDimitry Andric// VSRL - One of the 32 128-bit VSX registers that overlap with the scalar
890b57cec5SDimitry Andric// floating-point registers.
90*52418fc2SDimitry Andricclass VSRL<FPR SubReg, FPR SubRegH, string n> : PPCReg<n> {
910b57cec5SDimitry Andric  let HWEncoding = SubReg.HWEncoding;
92*52418fc2SDimitry Andric  let SubRegs = [SubReg, SubRegH];
93*52418fc2SDimitry Andric  let SubRegIndices = [sub_64, sub_64_hi_phony];
940b57cec5SDimitry Andric}
950b57cec5SDimitry Andric
960b57cec5SDimitry Andric// VSXReg - One of the VSX registers in the range vs32-vs63 with numbering
970b57cec5SDimitry Andric// and encoding to match.
980b57cec5SDimitry Andricclass VSXReg<bits<6> num, string n> : PPCReg<n> {
990b57cec5SDimitry Andric  let HWEncoding{5-0} = num;
1000b57cec5SDimitry Andric}
1010b57cec5SDimitry Andric
1020b57cec5SDimitry Andric// CR - One of the 8 4-bit condition registers
1030b57cec5SDimitry Andricclass CR<bits<3> num, string n, list<Register> subregs> : PPCReg<n> {
1040b57cec5SDimitry Andric  let HWEncoding{2-0} = num;
1050b57cec5SDimitry Andric  let SubRegs = subregs;
1060b57cec5SDimitry Andric}
1070b57cec5SDimitry Andric
1080b57cec5SDimitry Andric// CRBIT - One of the 32 1-bit condition register fields
1090b57cec5SDimitry Andricclass CRBIT<bits<5> num, string n> : PPCReg<n> {
1100b57cec5SDimitry Andric  let HWEncoding{4-0} = num;
1110b57cec5SDimitry Andric}
1120b57cec5SDimitry Andric
113e8d8bef9SDimitry Andric// VSR Pairs - One of the 32 paired even-odd consecutive VSRs.
114e8d8bef9SDimitry Andricclass VSRPair<bits<5> num, string n, list<Register> subregs> : PPCReg<n> {
115e8d8bef9SDimitry Andric  let HWEncoding{4-0} = num;
116e8d8bef9SDimitry Andric  let SubRegs = subregs;
117e8d8bef9SDimitry Andric}
118e8d8bef9SDimitry Andric
119fe6060f1SDimitry Andric// GP8Pair - Consecutive even-odd paired GP8.
120fe6060f1SDimitry Andricclass GP8Pair<string n, bits<5> EvenIndex> : PPCReg<n> {
121fe6060f1SDimitry Andric  assert !eq(EvenIndex{0}, 0), "Index should be even.";
122fe6060f1SDimitry Andric  let HWEncoding{4-0} = EvenIndex;
123fe6060f1SDimitry Andric  let SubRegs = [!cast<GP8>("X"#EvenIndex), !cast<GP8>("X"#!add(EvenIndex, 1))];
124fe6060f1SDimitry Andric  let DwarfNumbers = [-1, -1];
125fe6060f1SDimitry Andric  let SubRegIndices = [sub_gp8_x0, sub_gp8_x1];
126fe6060f1SDimitry Andric}
127fe6060f1SDimitry Andric
1280b57cec5SDimitry Andric// General-purpose registers
1290b57cec5SDimitry Andricforeach Index = 0-31 in {
1300b57cec5SDimitry Andric  def R#Index : GPR<Index, "r"#Index>, DwarfRegNum<[-2, Index]>;
1310b57cec5SDimitry Andric}
1320b57cec5SDimitry Andric
13306c3fb27SDimitry Andriclet isArtificial = 1 in {
13406c3fb27SDimitry Andric  foreach Index = 0-31 in {
13506c3fb27SDimitry Andric    def H#Index : GPR<-1,"">;
13606c3fb27SDimitry Andric  }
13706c3fb27SDimitry Andric}
13806c3fb27SDimitry Andric
1390b57cec5SDimitry Andric// 64-bit General-purpose registers
1400b57cec5SDimitry Andricforeach Index = 0-31 in {
1410b57cec5SDimitry Andric  def X#Index : GP8<!cast<GPR>("R"#Index), "r"#Index>,
1420b57cec5SDimitry Andric                    DwarfRegNum<[Index, -2]>;
1430b57cec5SDimitry Andric}
1440b57cec5SDimitry Andric
1450b57cec5SDimitry Andric// SPE registers
1460b57cec5SDimitry Andricforeach Index = 0-31 in {
14706c3fb27SDimitry Andric  def S#Index : SPE<"r"#Index, Index, [!cast<GPR>("R"#Index), !cast<GPR>("H"#Index)]>,
1480b57cec5SDimitry Andric                    DwarfRegNum<[!add(Index, 1200), !add(Index, 1200)]>;
14906c3fb27SDimitry Andric
1500b57cec5SDimitry Andric}
1510b57cec5SDimitry Andric
15206c3fb27SDimitry Andric
1530b57cec5SDimitry Andric// Floating-point registers
1540b57cec5SDimitry Andricforeach Index = 0-31 in {
1550b57cec5SDimitry Andric  def F#Index : FPR<Index, "f"#Index>,
1560b57cec5SDimitry Andric                DwarfRegNum<[!add(Index, 32), !add(Index, 32)]>;
1570b57cec5SDimitry Andric}
1580b57cec5SDimitry Andric
159*52418fc2SDimitry Andric// The FH and VFH registers have been marked as Artifical because there are no
160*52418fc2SDimitry Andric// instructions on PowerPC that use those register classes. They only exist
161*52418fc2SDimitry Andric// in order to ensure that the super registers (V and VSL) are covered by their
162*52418fc2SDimitry Andric// subregisters and have correct subregister lane masks.
163*52418fc2SDimitry Andriclet isArtificial = 1 in {
164*52418fc2SDimitry Andric  foreach Index = 0-31 in {
165*52418fc2SDimitry Andric    def FH#Index : FPR<-1, "">;
166*52418fc2SDimitry Andric    def VFH#Index : VF<-1, "">;
167*52418fc2SDimitry Andric  }
168*52418fc2SDimitry Andric}
169*52418fc2SDimitry Andric
170*52418fc2SDimitry Andriclet isAllocatable = 0, CopyCost = -1 in {
171*52418fc2SDimitry Andric  def VFHRC : RegisterClass<"PPC", [f64], 64, (sequence "VFH%u", 0, 31)>;
172*52418fc2SDimitry Andric  def FHRC : RegisterClass<"PPC", [f64], 64, (sequence "FH%u", 0, 31)>;
173*52418fc2SDimitry Andric}
174*52418fc2SDimitry Andric
17506c3fb27SDimitry Andric// Floating-point pair registers
17606c3fb27SDimitry Andricforeach Index = { 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30 } in {
17706c3fb27SDimitry Andric  def Fpair#Index : FPPair<"fp"#Index, Index>;
17806c3fb27SDimitry Andric}
17906c3fb27SDimitry Andric
1800b57cec5SDimitry Andric// 64-bit Floating-point subregisters of Altivec registers
1810b57cec5SDimitry Andric// Note: the register names are v0-v31 or vs32-vs63 depending on the use.
1820b57cec5SDimitry Andric//       Custom C++ code is used to produce the correct name and encoding.
1830b57cec5SDimitry Andricforeach Index = 0-31 in {
1840b57cec5SDimitry Andric  def VF#Index : VF<Index, "v" #Index>,
1850b57cec5SDimitry Andric                 DwarfRegNum<[!add(Index, 77), !add(Index, 77)]>;
1860b57cec5SDimitry Andric}
1870b57cec5SDimitry Andric
188*52418fc2SDimitry Andriclet CoveredBySubRegs = 1 in {
1890b57cec5SDimitry Andric// Vector registers
1900b57cec5SDimitry Andricforeach Index = 0-31 in {
191*52418fc2SDimitry Andric  def V#Index : VR<!cast<VF>("VF"#Index), !cast<VF>("VFH"#Index), "v"#Index>,
1920b57cec5SDimitry Andric                DwarfRegNum<[!add(Index, 77), !add(Index, 77)]>;
1930b57cec5SDimitry Andric}
1940b57cec5SDimitry Andric
1950b57cec5SDimitry Andric// VSX registers
1960b57cec5SDimitry Andricforeach Index = 0-31 in {
197*52418fc2SDimitry Andric  def VSL#Index : VSRL<!cast<FPR>("F"#Index), !cast<FPR>("FH"#Index), "vs"#Index>,
1980b57cec5SDimitry Andric                  DwarfRegAlias<!cast<FPR>("F"#Index)>;
1990b57cec5SDimitry Andric}
200*52418fc2SDimitry Andric}
2010b57cec5SDimitry Andric
2020b57cec5SDimitry Andric// Dummy VSX registers, this defines string: "vs32"-"vs63", and is only used for
2030b57cec5SDimitry Andric// asm printing.
2040b57cec5SDimitry Andricforeach Index = 32-63 in {
2050b57cec5SDimitry Andric  def VSX#Index : VSXReg<Index, "vs"#Index>;
2060b57cec5SDimitry Andric}
2070b57cec5SDimitry Andric
208e8d8bef9SDimitry Andriclet SubRegIndices = [sub_vsx0, sub_vsx1] in {
209e8d8bef9SDimitry Andric  // VSR pairs 0 - 15 (corresponding to VSRs 0 - 30 paired with 1 - 31).
210e8d8bef9SDimitry Andric  foreach Index = { 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30 } in {
211e8d8bef9SDimitry Andric    def VSRp#!srl(Index, 1) : VSRPair<!srl(Index, 1), "vsp"#Index,
212e8d8bef9SDimitry Andric                                      [!cast<VSRL>("VSL"#Index), !cast<VSRL>("VSL"#!add(Index, 1))]>,
21323408297SDimitry Andric                              DwarfRegNum<[-1, -1]>;
214e8d8bef9SDimitry Andric  }
215e8d8bef9SDimitry Andric
216e8d8bef9SDimitry Andric  // VSR pairs 16 - 31 (corresponding to VSRs 32 - 62 paired with 33 - 63).
217e8d8bef9SDimitry Andric  foreach Index = { 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30 } in {
218e8d8bef9SDimitry Andric    def VSRp#!add(!srl(Index, 1), 16) :
219e8d8bef9SDimitry Andric      VSRPair<!add(!srl(Index, 1), 16), "vsp"#!add(Index, 32),
220e8d8bef9SDimitry Andric              [!cast<VR>("V"#Index), !cast<VR>("V"#!add(Index, 1))]>,
2210fca6ea1SDimitry Andric              DwarfRegAlias<!cast<VR>("V"#Index)>;
222e8d8bef9SDimitry Andric  }
223e8d8bef9SDimitry Andric}
224e8d8bef9SDimitry Andric
225fe6060f1SDimitry Andric// 16 paired even-odd consecutive GP8s.
226fe6060f1SDimitry Andricforeach Index = { 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30 } in {
227fe6060f1SDimitry Andric  def G8p#!srl(Index, 1) : GP8Pair<"r"#Index, Index>;
228fe6060f1SDimitry Andric}
229fe6060f1SDimitry Andric
2305ffd83dbSDimitry Andric// The representation of r0 when treated as the constant 0.
231bdd1243dSDimitry Andriclet isConstant = true in {
2320b57cec5SDimitry Andricdef ZERO  : GPR<0, "0">,    DwarfRegAlias<R0>;
2330b57cec5SDimitry Andricdef ZERO8 : GP8<ZERO, "0">, DwarfRegAlias<X0>;
234bdd1243dSDimitry Andric} // isConstant = true
2350b57cec5SDimitry Andric
2360b57cec5SDimitry Andric// Representations of the frame pointer used by ISD::FRAMEADDR.
2370b57cec5SDimitry Andricdef FP   : GPR<0 /* arbitrary */, "**FRAME POINTER**">;
2380b57cec5SDimitry Andricdef FP8  : GP8<FP, "**FRAME POINTER**">;
2390b57cec5SDimitry Andric
2400b57cec5SDimitry Andric// Representations of the base pointer used by setjmp.
2410b57cec5SDimitry Andricdef BP   : GPR<0 /* arbitrary */, "**BASE POINTER**">;
2420b57cec5SDimitry Andricdef BP8  : GP8<BP, "**BASE POINTER**">;
2430b57cec5SDimitry Andric
2440b57cec5SDimitry Andric// Condition register bits
2450b57cec5SDimitry Andricdef CR0LT : CRBIT< 0, "0">;
2460b57cec5SDimitry Andricdef CR0GT : CRBIT< 1, "1">;
2470b57cec5SDimitry Andricdef CR0EQ : CRBIT< 2, "2">;
2480b57cec5SDimitry Andricdef CR0UN : CRBIT< 3, "3">;
2490b57cec5SDimitry Andricdef CR1LT : CRBIT< 4, "4">;
2500b57cec5SDimitry Andricdef CR1GT : CRBIT< 5, "5">;
2510b57cec5SDimitry Andricdef CR1EQ : CRBIT< 6, "6">;
2520b57cec5SDimitry Andricdef CR1UN : CRBIT< 7, "7">;
2530b57cec5SDimitry Andricdef CR2LT : CRBIT< 8, "8">;
2540b57cec5SDimitry Andricdef CR2GT : CRBIT< 9, "9">;
2550b57cec5SDimitry Andricdef CR2EQ : CRBIT<10, "10">;
2560b57cec5SDimitry Andricdef CR2UN : CRBIT<11, "11">;
2570b57cec5SDimitry Andricdef CR3LT : CRBIT<12, "12">;
2580b57cec5SDimitry Andricdef CR3GT : CRBIT<13, "13">;
2590b57cec5SDimitry Andricdef CR3EQ : CRBIT<14, "14">;
2600b57cec5SDimitry Andricdef CR3UN : CRBIT<15, "15">;
2610b57cec5SDimitry Andricdef CR4LT : CRBIT<16, "16">;
2620b57cec5SDimitry Andricdef CR4GT : CRBIT<17, "17">;
2630b57cec5SDimitry Andricdef CR4EQ : CRBIT<18, "18">;
2640b57cec5SDimitry Andricdef CR4UN : CRBIT<19, "19">;
2650b57cec5SDimitry Andricdef CR5LT : CRBIT<20, "20">;
2660b57cec5SDimitry Andricdef CR5GT : CRBIT<21, "21">;
2670b57cec5SDimitry Andricdef CR5EQ : CRBIT<22, "22">;
2680b57cec5SDimitry Andricdef CR5UN : CRBIT<23, "23">;
2690b57cec5SDimitry Andricdef CR6LT : CRBIT<24, "24">;
2700b57cec5SDimitry Andricdef CR6GT : CRBIT<25, "25">;
2710b57cec5SDimitry Andricdef CR6EQ : CRBIT<26, "26">;
2720b57cec5SDimitry Andricdef CR6UN : CRBIT<27, "27">;
2730b57cec5SDimitry Andricdef CR7LT : CRBIT<28, "28">;
2740b57cec5SDimitry Andricdef CR7GT : CRBIT<29, "29">;
2750b57cec5SDimitry Andricdef CR7EQ : CRBIT<30, "30">;
2760b57cec5SDimitry Andricdef CR7UN : CRBIT<31, "31">;
2770b57cec5SDimitry Andric
2780b57cec5SDimitry Andric// Condition registers
2790b57cec5SDimitry Andriclet SubRegIndices = [sub_lt, sub_gt, sub_eq, sub_un] in {
2800b57cec5SDimitry Andricdef CR0 : CR<0, "cr0", [CR0LT, CR0GT, CR0EQ, CR0UN]>, DwarfRegNum<[68, 68]>;
2810b57cec5SDimitry Andricdef CR1 : CR<1, "cr1", [CR1LT, CR1GT, CR1EQ, CR1UN]>, DwarfRegNum<[69, 69]>;
2820b57cec5SDimitry Andricdef CR2 : CR<2, "cr2", [CR2LT, CR2GT, CR2EQ, CR2UN]>, DwarfRegNum<[70, 70]>;
2830b57cec5SDimitry Andricdef CR3 : CR<3, "cr3", [CR3LT, CR3GT, CR3EQ, CR3UN]>, DwarfRegNum<[71, 71]>;
2840b57cec5SDimitry Andricdef CR4 : CR<4, "cr4", [CR4LT, CR4GT, CR4EQ, CR4UN]>, DwarfRegNum<[72, 72]>;
2850b57cec5SDimitry Andricdef CR5 : CR<5, "cr5", [CR5LT, CR5GT, CR5EQ, CR5UN]>, DwarfRegNum<[73, 73]>;
2860b57cec5SDimitry Andricdef CR6 : CR<6, "cr6", [CR6LT, CR6GT, CR6EQ, CR6UN]>, DwarfRegNum<[74, 74]>;
2870b57cec5SDimitry Andricdef CR7 : CR<7, "cr7", [CR7LT, CR7GT, CR7EQ, CR7UN]>, DwarfRegNum<[75, 75]>;
2880b57cec5SDimitry Andric}
2890b57cec5SDimitry Andric
2900b57cec5SDimitry Andric// Link register
2910b57cec5SDimitry Andricdef LR  : SPR<8, "lr">, DwarfRegNum<[-2, 65]>;
2921db9f3b2SDimitry Andricdef LR8 : SPR<8, "lr">, DwarfRegNum<[65, -2]> {
2931db9f3b2SDimitry Andric  let Aliases = [LR];
2941db9f3b2SDimitry Andric}
2950b57cec5SDimitry Andric
2960b57cec5SDimitry Andric// Count register
2970b57cec5SDimitry Andricdef CTR  : SPR<9, "ctr">, DwarfRegNum<[-2, 66]>;
2981db9f3b2SDimitry Andricdef CTR8 : SPR<9, "ctr">, DwarfRegNum<[66, -2]> {
2991db9f3b2SDimitry Andric  let Aliases = [CTR];
3001db9f3b2SDimitry Andric}
3010b57cec5SDimitry Andric
3020b57cec5SDimitry Andric// VRsave register
3030b57cec5SDimitry Andricdef VRSAVE: SPR<256, "vrsave">, DwarfRegNum<[109]>;
3040b57cec5SDimitry Andric
3050b57cec5SDimitry Andric// SPE extra registers
3060b57cec5SDimitry Andricdef SPEFSCR: SPR<512, "spefscr">, DwarfRegNum<[612, 112]>;
3070b57cec5SDimitry Andric
3080b57cec5SDimitry Andricdef XER: SPR<1, "xer">, DwarfRegNum<[76]>;
3090b57cec5SDimitry Andric
3100b57cec5SDimitry Andric// Carry bit.  In the architecture this is really bit 0 of the XER register
3110b57cec5SDimitry Andric// (which really is SPR register 1);  this is the only bit interesting to a
3120b57cec5SDimitry Andric// compiler.
3130b57cec5SDimitry Andricdef CARRY: SPR<1, "xer">, DwarfRegNum<[76]> {
3140b57cec5SDimitry Andric  let Aliases = [XER];
3150b57cec5SDimitry Andric}
3160b57cec5SDimitry Andric
3170b57cec5SDimitry Andric// FP rounding mode:  bits 30 and 31 of the FP status and control register
3180b57cec5SDimitry Andric// This is not allocated as a normal register; it appears only in
3190b57cec5SDimitry Andric// Uses and Defs.  The ABI says it needs to be preserved by a function,
3200b57cec5SDimitry Andric// but this is not achieved by saving and restoring it as with
3210b57cec5SDimitry Andric// most registers, it has to be done in code; to make this work all the
3220b57cec5SDimitry Andric// return and call instructions are described as Uses of RM, so instructions
3230b57cec5SDimitry Andric// that do nothing but change RM will not get deleted.
3240b57cec5SDimitry Andricdef RM: PPCReg<"**ROUNDING MODE**">;
3250b57cec5SDimitry Andric
32606c3fb27SDimitry Andriclet isAllocatable = 0 in
32706c3fb27SDimitry Andricdef GPRC32 : RegisterClass<"PPC", [i32,f32], 32, (add (sequence "H%u", 2, 12),
32806c3fb27SDimitry Andric                                                      (sequence "H%u", 30, 13),
32906c3fb27SDimitry Andric                                                      H31, H0, H1)>;
33006c3fb27SDimitry Andric
3310b57cec5SDimitry Andric/// Register classes
3320b57cec5SDimitry Andric// Allocate volatiles first
3330b57cec5SDimitry Andric// then nonvolatiles in reverse order since stmw/lmw save from rN to r31
3348bcb0991SDimitry Andricdef GPRC : RegisterClass<"PPC", [i32,f32], 32, (add (sequence "R%u", 2, 12),
3350b57cec5SDimitry Andric                                                    (sequence "R%u", 30, 13),
3360b57cec5SDimitry Andric                                                    R31, R0, R1, FP, BP)> {
3370b57cec5SDimitry Andric  // On non-Darwin PPC64 systems, R2 can be allocated, but must be restored, so
3380b57cec5SDimitry Andric  // put it at the end of the list.
339fe6060f1SDimitry Andric  // On AIX, CSRs are allocated starting from R31 according to:
340fe6060f1SDimitry Andric  // https://www.ibm.com/docs/en/ssw_aix_72/assembler/assembler_pdf.pdf.
341fe6060f1SDimitry Andric  // This also helps setting the correct `NumOfGPRsSaved' in traceback table.
342fe6060f1SDimitry Andric  let AltOrders = [(add (sub GPRC, R2), R2),
343fe6060f1SDimitry Andric                   (add (sequence "R%u", 2, 12),
344fe6060f1SDimitry Andric                        (sequence "R%u", 31, 13), R0, R1, FP, BP)];
3450b57cec5SDimitry Andric  let AltOrderSelect = [{
346fe6060f1SDimitry Andric    return MF.getSubtarget<PPCSubtarget>().getGPRAllocationOrderIdx();
3470b57cec5SDimitry Andric  }];
3480b57cec5SDimitry Andric}
3490b57cec5SDimitry Andric
3500b57cec5SDimitry Andricdef G8RC : RegisterClass<"PPC", [i64], 64, (add (sequence "X%u", 2, 12),
3510b57cec5SDimitry Andric                                                (sequence "X%u", 30, 14),
3520b57cec5SDimitry Andric                                                X31, X13, X0, X1, FP8, BP8)> {
3530b57cec5SDimitry Andric  // On non-Darwin PPC64 systems, R2 can be allocated, but must be restored, so
3540b57cec5SDimitry Andric  // put it at the end of the list.
355fe6060f1SDimitry Andric  let AltOrders = [(add (sub G8RC, X2), X2),
356fe6060f1SDimitry Andric                   (add (sequence "X%u", 2, 12),
357fe6060f1SDimitry Andric                        (sequence "X%u", 31, 13), X0, X1, FP8, BP8)];
3580b57cec5SDimitry Andric  let AltOrderSelect = [{
359fe6060f1SDimitry Andric    return MF.getSubtarget<PPCSubtarget>().getGPRAllocationOrderIdx();
3600b57cec5SDimitry Andric  }];
3610b57cec5SDimitry Andric}
3620b57cec5SDimitry Andric
3630b57cec5SDimitry Andric// For some instructions r0 is special (representing the value 0 instead of
3640b57cec5SDimitry Andric// the value in the r0 register), and we use these register subclasses to
3650b57cec5SDimitry Andric// prevent r0 from being allocated for use by those instructions.
3668bcb0991SDimitry Andricdef GPRC_NOR0 : RegisterClass<"PPC", [i32,f32], 32, (add (sub GPRC, R0), ZERO)> {
3670b57cec5SDimitry Andric  // On non-Darwin PPC64 systems, R2 can be allocated, but must be restored, so
3680b57cec5SDimitry Andric  // put it at the end of the list.
369fe6060f1SDimitry Andric  let AltOrders = [(add (sub GPRC_NOR0, R2), R2),
370fe6060f1SDimitry Andric                   (add (sequence "R%u", 2, 12),
371fe6060f1SDimitry Andric                        (sequence "R%u", 31, 13), R1, FP, BP, ZERO)];
3720b57cec5SDimitry Andric  let AltOrderSelect = [{
373fe6060f1SDimitry Andric    return MF.getSubtarget<PPCSubtarget>().getGPRAllocationOrderIdx();
3740b57cec5SDimitry Andric  }];
3750b57cec5SDimitry Andric}
3760b57cec5SDimitry Andric
3770b57cec5SDimitry Andricdef G8RC_NOX0 : RegisterClass<"PPC", [i64], 64, (add (sub G8RC, X0), ZERO8)> {
3780b57cec5SDimitry Andric  // On non-Darwin PPC64 systems, R2 can be allocated, but must be restored, so
3790b57cec5SDimitry Andric  // put it at the end of the list.
380fe6060f1SDimitry Andric  let AltOrders = [(add (sub G8RC_NOX0, X2), X2),
381fe6060f1SDimitry Andric                   (add (sequence "X%u", 2, 12),
382fe6060f1SDimitry Andric                        (sequence "X%u", 31, 13), X1, FP8, BP8, ZERO8)];
3830b57cec5SDimitry Andric  let AltOrderSelect = [{
384fe6060f1SDimitry Andric    return MF.getSubtarget<PPCSubtarget>().getGPRAllocationOrderIdx();
3850b57cec5SDimitry Andric  }];
3860b57cec5SDimitry Andric}
3870b57cec5SDimitry Andric
3880b57cec5SDimitry Andricdef SPERC : RegisterClass<"PPC", [f64], 64, (add (sequence "S%u", 2, 12),
3890b57cec5SDimitry Andric                                                (sequence "S%u", 30, 13),
3900b57cec5SDimitry Andric                                                S31, S0, S1)>;
3910b57cec5SDimitry Andric
3920b57cec5SDimitry Andric// Allocate volatiles first, then non-volatiles in reverse order. With the SVR4
3930b57cec5SDimitry Andric// ABI the size of the Floating-point register save area is determined by the
3940b57cec5SDimitry Andric// allocated non-volatile register with the lowest register number, as FP
3950b57cec5SDimitry Andric// register N is spilled to offset 8 * (32 - N) below the back chain word of the
3960b57cec5SDimitry Andric// previous stack frame. By allocating non-volatiles in reverse order we make
3970b57cec5SDimitry Andric// sure that the Floating-point register save area is always as small as
3980b57cec5SDimitry Andric// possible because there aren't any unused spill slots.
3990b57cec5SDimitry Andricdef F8RC : RegisterClass<"PPC", [f64], 64, (add (sequence "F%u", 0, 13),
4000b57cec5SDimitry Andric                                                (sequence "F%u", 31, 14))>;
4010b57cec5SDimitry Andricdef F4RC : RegisterClass<"PPC", [f32], 32, (add F8RC)>;
4020b57cec5SDimitry Andric
40306c3fb27SDimitry Andric// Floating point pair registers.
40406c3fb27SDimitry Andric// Note that the type used for this register class is ppcf128. This is not
40506c3fb27SDimitry Andric// completely correct. However, since we are not pattern matching any
40606c3fb27SDimitry Andric// instructions for these registers and we are not register allocating or
40706c3fb27SDimitry Andric// scheduling any of these instructions it should be safe to do this.
40806c3fb27SDimitry Andric// The reason we didn't use the correct type (Decimal Floating Point) is that
40906c3fb27SDimitry Andric// at the time of this implementation the correct type was not available.
41006c3fb27SDimitry Andricdef FpRC :
41106c3fb27SDimitry Andric  RegisterClass<"PPC", [ppcf128], 128,
41206c3fb27SDimitry Andric                (add Fpair0, Fpair2, Fpair4, Fpair6, Fpair8, Fpair10, Fpair12,
41306c3fb27SDimitry Andric                     Fpair14, Fpair16, Fpair18, Fpair20, Fpair22, Fpair24,
41406c3fb27SDimitry Andric                     Fpair26, Fpair28, Fpair30)> {
41506c3fb27SDimitry Andric  let Size = 128;
41606c3fb27SDimitry Andric}
41706c3fb27SDimitry Andric
4180b57cec5SDimitry Andricdef VRRC : RegisterClass<"PPC",
4190b57cec5SDimitry Andric                         [v16i8,v8i16,v4i32,v2i64,v1i128,v4f32,v2f64, f128],
4200b57cec5SDimitry Andric                         128,
4210b57cec5SDimitry Andric                         (add V2, V3, V4, V5, V0, V1, V6, V7, V8, V9, V10, V11,
4220b57cec5SDimitry Andric                             V12, V13, V14, V15, V16, V17, V18, V19, V31, V30,
4230b57cec5SDimitry Andric                             V29, V28, V27, V26, V25, V24, V23, V22, V21, V20)>;
4240b57cec5SDimitry Andric
4250b57cec5SDimitry Andric// VSX register classes (the allocation order mirrors that of the corresponding
4260b57cec5SDimitry Andric// subregister classes).
4270b57cec5SDimitry Andricdef VSLRC : RegisterClass<"PPC", [v4i32,v4f32,v2f64,v2i64], 128,
4280b57cec5SDimitry Andric                          (add (sequence "VSL%u", 0, 13),
4290b57cec5SDimitry Andric                               (sequence "VSL%u", 31, 14))>;
4300b57cec5SDimitry Andricdef VSRC  : RegisterClass<"PPC", [v4i32,v4f32,v2f64,v2i64], 128,
4310b57cec5SDimitry Andric                          (add VSLRC, VRRC)>;
4320b57cec5SDimitry Andric
4330b57cec5SDimitry Andric// Register classes for the 64-bit "scalar" VSX subregisters.
4340b57cec5SDimitry Andricdef VFRC :  RegisterClass<"PPC", [f64], 64,
4350b57cec5SDimitry Andric                          (add VF2, VF3, VF4, VF5, VF0, VF1, VF6, VF7,
4360b57cec5SDimitry Andric                               VF8, VF9, VF10, VF11, VF12, VF13, VF14,
4370b57cec5SDimitry Andric                               VF15, VF16, VF17, VF18, VF19, VF31, VF30,
4380b57cec5SDimitry Andric                               VF29, VF28, VF27, VF26, VF25, VF24, VF23,
4390b57cec5SDimitry Andric                               VF22, VF21, VF20)>;
4400b57cec5SDimitry Andricdef VSFRC : RegisterClass<"PPC", [f64], 64, (add F8RC, VFRC)>;
4410b57cec5SDimitry Andric
4420b57cec5SDimitry Andric// Allow spilling GPR's into caller-saved VSR's.
4430b57cec5SDimitry Andricdef SPILLTOVSRRC : RegisterClass<"PPC", [i64, f64], 64, (add G8RC, (sub VSFRC,
4440b57cec5SDimitry Andric				(sequence "VF%u", 31, 20),
4450b57cec5SDimitry Andric				(sequence "F%u", 31, 14)))>;
4460b57cec5SDimitry Andric
4470b57cec5SDimitry Andric// Register class for single precision scalars in VSX registers
4480b57cec5SDimitry Andricdef VSSRC : RegisterClass<"PPC", [f32], 32, (add VSFRC)>;
4490b57cec5SDimitry Andric
4500b57cec5SDimitry Andricdef CRBITRC : RegisterClass<"PPC", [i1], 32,
4510b57cec5SDimitry Andric  (add CR2LT, CR2GT, CR2EQ, CR2UN,
4520b57cec5SDimitry Andric       CR3LT, CR3GT, CR3EQ, CR3UN,
4530b57cec5SDimitry Andric       CR4LT, CR4GT, CR4EQ, CR4UN,
4540b57cec5SDimitry Andric       CR5LT, CR5GT, CR5EQ, CR5UN,
4550b57cec5SDimitry Andric       CR6LT, CR6GT, CR6EQ, CR6UN,
4560b57cec5SDimitry Andric       CR7LT, CR7GT, CR7EQ, CR7UN,
4570b57cec5SDimitry Andric       CR1LT, CR1GT, CR1EQ, CR1UN,
4580b57cec5SDimitry Andric       CR0LT, CR0GT, CR0EQ, CR0UN)> {
4590b57cec5SDimitry Andric  let Size = 32;
4605ffd83dbSDimitry Andric  let AltOrders = [(sub CRBITRC, CR2LT, CR2GT, CR2EQ, CR2UN, CR3LT, CR3GT,
4615ffd83dbSDimitry Andric                        CR3EQ, CR3UN, CR4LT, CR4GT, CR4EQ, CR4UN)];
4625ffd83dbSDimitry Andric  let AltOrderSelect = [{
4635ffd83dbSDimitry Andric    return MF.getSubtarget<PPCSubtarget>().isELFv2ABI() &&
4645ffd83dbSDimitry Andric           MF.getInfo<PPCFunctionInfo>()->isNonVolatileCRDisabled();
4655ffd83dbSDimitry Andric  }];
4660b57cec5SDimitry Andric}
4670b57cec5SDimitry Andric
4685ffd83dbSDimitry Andricdef CRRC : RegisterClass<"PPC", [i32], 32,
4695ffd83dbSDimitry Andric  (add CR0, CR1, CR5, CR6,
4705ffd83dbSDimitry Andric       CR7, CR2, CR3, CR4)> {
4715ffd83dbSDimitry Andric  let AltOrders = [(sub CRRC, CR2, CR3, CR4)];
4725ffd83dbSDimitry Andric  let AltOrderSelect = [{
4735ffd83dbSDimitry Andric    return MF.getSubtarget<PPCSubtarget>().isELFv2ABI() &&
4745ffd83dbSDimitry Andric           MF.getInfo<PPCFunctionInfo>()->isNonVolatileCRDisabled();
4755ffd83dbSDimitry Andric  }];
4765ffd83dbSDimitry Andric}
4770b57cec5SDimitry Andric// The CTR registers are not allocatable because they're used by the
4780b57cec5SDimitry Andric// decrement-and-branch instructions, and thus need to stay live across
4790b57cec5SDimitry Andric// multiple basic blocks.
4800b57cec5SDimitry Andricdef CTRRC : RegisterClass<"PPC", [i32], 32, (add CTR)> {
4810b57cec5SDimitry Andric  let isAllocatable = 0;
4820b57cec5SDimitry Andric}
4830b57cec5SDimitry Andricdef CTRRC8 : RegisterClass<"PPC", [i64], 64, (add CTR8)> {
4840b57cec5SDimitry Andric  let isAllocatable = 0;
4850b57cec5SDimitry Andric}
4860b57cec5SDimitry Andric
48723408297SDimitry Andricdef LRRC : RegisterClass<"PPC", [i32], 32, (add LR)> {
48823408297SDimitry Andric  let isAllocatable = 0;
48923408297SDimitry Andric}
49023408297SDimitry Andricdef LR8RC : RegisterClass<"PPC", [i64], 64, (add LR8)> {
49123408297SDimitry Andric  let isAllocatable = 0;
49223408297SDimitry Andric}
49323408297SDimitry Andric
4940b57cec5SDimitry Andricdef VRSAVERC : RegisterClass<"PPC", [i32], 32, (add VRSAVE)>;
4950b57cec5SDimitry Andricdef CARRYRC : RegisterClass<"PPC", [i32], 32, (add CARRY, XER)> {
4960b57cec5SDimitry Andric  let CopyCost = -1;
4970b57cec5SDimitry Andric}
4980b57cec5SDimitry Andric
499fe6060f1SDimitry Andric// Make AllocationOrder as similar as G8RC's to avoid potential spilling.
500fe6060f1SDimitry Andric// Similarly, we have an AltOrder for 64-bit ELF ABI which r2 is allocated
501fe6060f1SDimitry Andric// at last.
502fe6060f1SDimitry Andricdef G8pRC :
503fe6060f1SDimitry Andric  RegisterClass<"PPC", [i128], 128,
504fe6060f1SDimitry Andric                (add (sequence "G8p%u", 1, 5),
505fe6060f1SDimitry Andric                     (sequence "G8p%u", 14, 7),
506fe6060f1SDimitry Andric                     G8p15, G8p6, G8p0)> {
507fe6060f1SDimitry Andric  let AltOrders = [(add (sub G8pRC, G8p1), G8p1)];
508fe6060f1SDimitry Andric  let AltOrderSelect = [{
509fe6060f1SDimitry Andric    return MF.getSubtarget<PPCSubtarget>().is64BitELFABI();
510fe6060f1SDimitry Andric  }];
511fe6060f1SDimitry Andric  let Size = 128;
512fe6060f1SDimitry Andric}
51381ad6265SDimitry Andric
51481ad6265SDimitry Andricinclude "PPCRegisterInfoMMA.td"
515bdd1243dSDimitry Andricinclude "PPCRegisterInfoDMR.td"
51681ad6265SDimitry Andric
51781ad6265SDimitry Andric//===----------------------------------------------------------------------===//
51881ad6265SDimitry Andric// PowerPC Operand Definitions.
51981ad6265SDimitry Andric
52081ad6265SDimitry Andric// In the default PowerPC assembler syntax, registers are specified simply
52181ad6265SDimitry Andric// by number, so they cannot be distinguished from immediate values (without
52281ad6265SDimitry Andric// looking at the opcode).  This means that the default operand matching logic
52381ad6265SDimitry Andric// for the asm parser does not work, and we need to specify custom matchers.
52481ad6265SDimitry Andric// Since those can only be specified with RegisterOperand classes and not
52581ad6265SDimitry Andric// directly on the RegisterClass, all instructions patterns used by the asm
52681ad6265SDimitry Andric// parser need to use a RegisterOperand (instead of a RegisterClass) for
52781ad6265SDimitry Andric// all their register operands.
52881ad6265SDimitry Andric// For this purpose, we define one RegisterOperand for each RegisterClass,
52981ad6265SDimitry Andric// using the same name as the class, just in lower case.
53081ad6265SDimitry Andric
53181ad6265SDimitry Andricdef PPCRegGPRCAsmOperand : AsmOperandClass {
53281ad6265SDimitry Andric  let Name = "RegGPRC"; let PredicateMethod = "isRegNumber";
53381ad6265SDimitry Andric}
53481ad6265SDimitry Andricdef gprc : RegisterOperand<GPRC> {
53581ad6265SDimitry Andric  let ParserMatchClass = PPCRegGPRCAsmOperand;
53681ad6265SDimitry Andric}
53781ad6265SDimitry Andricdef PPCRegG8RCAsmOperand : AsmOperandClass {
53881ad6265SDimitry Andric  let Name = "RegG8RC"; let PredicateMethod = "isRegNumber";
53981ad6265SDimitry Andric}
54081ad6265SDimitry Andricdef g8rc : RegisterOperand<G8RC> {
54181ad6265SDimitry Andric  let ParserMatchClass = PPCRegG8RCAsmOperand;
54281ad6265SDimitry Andric}
54381ad6265SDimitry Andricdef PPCRegG8pRCAsmOperand : AsmOperandClass {
54481ad6265SDimitry Andric  let Name = "RegG8pRC"; let PredicateMethod = "isEvenRegNumber";
54581ad6265SDimitry Andric}
54681ad6265SDimitry Andricdef g8prc : RegisterOperand<G8pRC> {
54781ad6265SDimitry Andric  let ParserMatchClass = PPCRegG8pRCAsmOperand;
54881ad6265SDimitry Andric}
54981ad6265SDimitry Andricdef PPCRegGPRCNoR0AsmOperand : AsmOperandClass {
55081ad6265SDimitry Andric  let Name = "RegGPRCNoR0"; let PredicateMethod = "isRegNumber";
55181ad6265SDimitry Andric}
55281ad6265SDimitry Andricdef gprc_nor0 : RegisterOperand<GPRC_NOR0> {
55381ad6265SDimitry Andric  let ParserMatchClass = PPCRegGPRCNoR0AsmOperand;
55481ad6265SDimitry Andric}
55581ad6265SDimitry Andricdef PPCRegG8RCNoX0AsmOperand : AsmOperandClass {
55681ad6265SDimitry Andric  let Name = "RegG8RCNoX0"; let PredicateMethod = "isRegNumber";
55781ad6265SDimitry Andric}
55881ad6265SDimitry Andricdef g8rc_nox0 : RegisterOperand<G8RC_NOX0> {
55981ad6265SDimitry Andric  let ParserMatchClass = PPCRegG8RCNoX0AsmOperand;
56081ad6265SDimitry Andric}
56181ad6265SDimitry Andricdef PPCRegF8RCAsmOperand : AsmOperandClass {
56281ad6265SDimitry Andric  let Name = "RegF8RC"; let PredicateMethod = "isRegNumber";
56381ad6265SDimitry Andric}
56481ad6265SDimitry Andricdef f8rc : RegisterOperand<F8RC> {
56581ad6265SDimitry Andric  let ParserMatchClass = PPCRegF8RCAsmOperand;
56681ad6265SDimitry Andric}
56781ad6265SDimitry Andricdef PPCRegF4RCAsmOperand : AsmOperandClass {
56881ad6265SDimitry Andric  let Name = "RegF4RC"; let PredicateMethod = "isRegNumber";
56981ad6265SDimitry Andric}
57081ad6265SDimitry Andricdef f4rc : RegisterOperand<F4RC> {
57181ad6265SDimitry Andric  let ParserMatchClass = PPCRegF4RCAsmOperand;
57281ad6265SDimitry Andric}
57306c3fb27SDimitry Andricdef PPCRegFpRCAsmOperand : AsmOperandClass {
57406c3fb27SDimitry Andric  let Name = "RegFpRC"; let PredicateMethod = "isEvenRegNumber";
57506c3fb27SDimitry Andric}
57606c3fb27SDimitry Andricdef fpairrc : RegisterOperand<FpRC> {
57706c3fb27SDimitry Andric  let ParserMatchClass = PPCRegFpRCAsmOperand;
57806c3fb27SDimitry Andric}
57981ad6265SDimitry Andricdef PPCRegVRRCAsmOperand : AsmOperandClass {
58081ad6265SDimitry Andric  let Name = "RegVRRC"; let PredicateMethod = "isRegNumber";
58181ad6265SDimitry Andric}
58281ad6265SDimitry Andricdef vrrc : RegisterOperand<VRRC> {
58381ad6265SDimitry Andric  let ParserMatchClass = PPCRegVRRCAsmOperand;
58481ad6265SDimitry Andric}
58581ad6265SDimitry Andricdef PPCRegVFRCAsmOperand : AsmOperandClass {
58681ad6265SDimitry Andric  let Name = "RegVFRC"; let PredicateMethod = "isRegNumber";
58781ad6265SDimitry Andric}
58881ad6265SDimitry Andricdef vfrc : RegisterOperand<VFRC> {
58981ad6265SDimitry Andric  let ParserMatchClass = PPCRegVFRCAsmOperand;
59081ad6265SDimitry Andric}
59181ad6265SDimitry Andricdef PPCRegCRBITRCAsmOperand : AsmOperandClass {
59281ad6265SDimitry Andric  let Name = "RegCRBITRC"; let PredicateMethod = "isCRBitNumber";
59381ad6265SDimitry Andric}
59481ad6265SDimitry Andricdef crbitrc : RegisterOperand<CRBITRC> {
59581ad6265SDimitry Andric  let ParserMatchClass = PPCRegCRBITRCAsmOperand;
59681ad6265SDimitry Andric}
59781ad6265SDimitry Andricdef PPCRegCRRCAsmOperand : AsmOperandClass {
59881ad6265SDimitry Andric  let Name = "RegCRRC"; let PredicateMethod = "isCCRegNumber";
59981ad6265SDimitry Andric}
60081ad6265SDimitry Andricdef crrc : RegisterOperand<CRRC> {
60181ad6265SDimitry Andric  let ParserMatchClass = PPCRegCRRCAsmOperand;
60281ad6265SDimitry Andric}
60381ad6265SDimitry Andricdef PPCRegSPERCAsmOperand : AsmOperandClass {
60481ad6265SDimitry Andric  let Name = "RegSPERC"; let PredicateMethod = "isRegNumber";
60581ad6265SDimitry Andric}
60681ad6265SDimitry Andricdef sperc : RegisterOperand<SPERC> {
60781ad6265SDimitry Andric  let ParserMatchClass = PPCRegSPERCAsmOperand;
60881ad6265SDimitry Andric}
60981ad6265SDimitry Andricdef PPCRegSPE4RCAsmOperand : AsmOperandClass {
61081ad6265SDimitry Andric  let Name = "RegSPE4RC"; let PredicateMethod = "isRegNumber";
61181ad6265SDimitry Andric}
61281ad6265SDimitry Andricdef spe4rc : RegisterOperand<GPRC> {
61381ad6265SDimitry Andric  let ParserMatchClass = PPCRegSPE4RCAsmOperand;
61481ad6265SDimitry Andric}
61581ad6265SDimitry Andric
61681ad6265SDimitry Andricdef PPCU1ImmAsmOperand : AsmOperandClass {
61781ad6265SDimitry Andric  let Name = "U1Imm"; let PredicateMethod = "isU1Imm";
61881ad6265SDimitry Andric  let RenderMethod = "addImmOperands";
61981ad6265SDimitry Andric}
62081ad6265SDimitry Andricdef u1imm   : Operand<i32> {
62181ad6265SDimitry Andric  let PrintMethod = "printU1ImmOperand";
62281ad6265SDimitry Andric  let ParserMatchClass = PPCU1ImmAsmOperand;
62306c3fb27SDimitry Andric  let DecoderMethod = "decodeUImmOperand<1>";
62481ad6265SDimitry Andric  let OperandType = "OPERAND_IMMEDIATE";
62581ad6265SDimitry Andric}
62681ad6265SDimitry Andric
62781ad6265SDimitry Andricdef PPCU2ImmAsmOperand : AsmOperandClass {
62881ad6265SDimitry Andric  let Name = "U2Imm"; let PredicateMethod = "isU2Imm";
62981ad6265SDimitry Andric  let RenderMethod = "addImmOperands";
63081ad6265SDimitry Andric}
63181ad6265SDimitry Andricdef u2imm   : Operand<i32> {
63281ad6265SDimitry Andric  let PrintMethod = "printU2ImmOperand";
63381ad6265SDimitry Andric  let ParserMatchClass = PPCU2ImmAsmOperand;
63406c3fb27SDimitry Andric  let DecoderMethod = "decodeUImmOperand<2>";
63581ad6265SDimitry Andric  let OperandType = "OPERAND_IMMEDIATE";
63681ad6265SDimitry Andric}
63781ad6265SDimitry Andric
63881ad6265SDimitry Andricdef PPCATBitsAsHintAsmOperand : AsmOperandClass {
63981ad6265SDimitry Andric  let Name = "ATBitsAsHint"; let PredicateMethod = "isATBitsAsHint";
64081ad6265SDimitry Andric  let RenderMethod = "addImmOperands"; // Irrelevant, predicate always fails.
64181ad6265SDimitry Andric}
64281ad6265SDimitry Andricdef atimm   : Operand<i32> {
64381ad6265SDimitry Andric  let PrintMethod = "printATBitsAsHint";
64481ad6265SDimitry Andric  let ParserMatchClass = PPCATBitsAsHintAsmOperand;
64581ad6265SDimitry Andric  let OperandType = "OPERAND_IMMEDIATE";
64681ad6265SDimitry Andric}
64781ad6265SDimitry Andric
64881ad6265SDimitry Andricdef PPCU3ImmAsmOperand : AsmOperandClass {
64981ad6265SDimitry Andric  let Name = "U3Imm"; let PredicateMethod = "isU3Imm";
65081ad6265SDimitry Andric  let RenderMethod = "addImmOperands";
65181ad6265SDimitry Andric}
65281ad6265SDimitry Andricdef u3imm   : Operand<i32> {
65381ad6265SDimitry Andric  let PrintMethod = "printU3ImmOperand";
65481ad6265SDimitry Andric  let ParserMatchClass = PPCU3ImmAsmOperand;
65506c3fb27SDimitry Andric  let DecoderMethod = "decodeUImmOperand<3>";
65681ad6265SDimitry Andric  let OperandType = "OPERAND_IMMEDIATE";
65781ad6265SDimitry Andric}
65881ad6265SDimitry Andric
65981ad6265SDimitry Andricdef PPCU4ImmAsmOperand : AsmOperandClass {
66081ad6265SDimitry Andric  let Name = "U4Imm"; let PredicateMethod = "isU4Imm";
66181ad6265SDimitry Andric  let RenderMethod = "addImmOperands";
66281ad6265SDimitry Andric}
66381ad6265SDimitry Andricdef u4imm   : Operand<i32> {
66481ad6265SDimitry Andric  let PrintMethod = "printU4ImmOperand";
66581ad6265SDimitry Andric  let ParserMatchClass = PPCU4ImmAsmOperand;
66606c3fb27SDimitry Andric  let DecoderMethod = "decodeUImmOperand<4>";
66781ad6265SDimitry Andric  let OperandType = "OPERAND_IMMEDIATE";
66881ad6265SDimitry Andric}
66981ad6265SDimitry Andricdef PPCS5ImmAsmOperand : AsmOperandClass {
67081ad6265SDimitry Andric  let Name = "S5Imm"; let PredicateMethod = "isS5Imm";
67181ad6265SDimitry Andric  let RenderMethod = "addImmOperands";
67281ad6265SDimitry Andric}
67381ad6265SDimitry Andricdef s5imm   : Operand<i32> {
67481ad6265SDimitry Andric  let PrintMethod = "printS5ImmOperand";
67581ad6265SDimitry Andric  let ParserMatchClass = PPCS5ImmAsmOperand;
67681ad6265SDimitry Andric  let DecoderMethod = "decodeSImmOperand<5>";
67781ad6265SDimitry Andric  let OperandType = "OPERAND_IMMEDIATE";
67881ad6265SDimitry Andric}
67981ad6265SDimitry Andricdef PPCU5ImmAsmOperand : AsmOperandClass {
68081ad6265SDimitry Andric  let Name = "U5Imm"; let PredicateMethod = "isU5Imm";
68181ad6265SDimitry Andric  let RenderMethod = "addImmOperands";
68281ad6265SDimitry Andric}
68381ad6265SDimitry Andricdef u5imm   : Operand<i32> {
68481ad6265SDimitry Andric  let PrintMethod = "printU5ImmOperand";
68581ad6265SDimitry Andric  let ParserMatchClass = PPCU5ImmAsmOperand;
68681ad6265SDimitry Andric  let DecoderMethod = "decodeUImmOperand<5>";
68781ad6265SDimitry Andric  let OperandType = "OPERAND_IMMEDIATE";
68881ad6265SDimitry Andric}
68981ad6265SDimitry Andricdef PPCU6ImmAsmOperand : AsmOperandClass {
69081ad6265SDimitry Andric  let Name = "U6Imm"; let PredicateMethod = "isU6Imm";
69181ad6265SDimitry Andric  let RenderMethod = "addImmOperands";
69281ad6265SDimitry Andric}
69381ad6265SDimitry Andricdef u6imm   : Operand<i32> {
69481ad6265SDimitry Andric  let PrintMethod = "printU6ImmOperand";
69581ad6265SDimitry Andric  let ParserMatchClass = PPCU6ImmAsmOperand;
69681ad6265SDimitry Andric  let DecoderMethod = "decodeUImmOperand<6>";
69781ad6265SDimitry Andric  let OperandType = "OPERAND_IMMEDIATE";
69881ad6265SDimitry Andric}
69981ad6265SDimitry Andricdef PPCU7ImmAsmOperand : AsmOperandClass {
70081ad6265SDimitry Andric  let Name = "U7Imm"; let PredicateMethod = "isU7Imm";
70181ad6265SDimitry Andric  let RenderMethod = "addImmOperands";
70281ad6265SDimitry Andric}
70381ad6265SDimitry Andricdef u7imm   : Operand<i32> {
70481ad6265SDimitry Andric  let PrintMethod = "printU7ImmOperand";
70581ad6265SDimitry Andric  let ParserMatchClass = PPCU7ImmAsmOperand;
70681ad6265SDimitry Andric  let DecoderMethod = "decodeUImmOperand<7>";
70781ad6265SDimitry Andric  let OperandType = "OPERAND_IMMEDIATE";
70881ad6265SDimitry Andric}
70981ad6265SDimitry Andricdef PPCU8ImmAsmOperand : AsmOperandClass {
71081ad6265SDimitry Andric  let Name = "U8Imm"; let PredicateMethod = "isU8Imm";
71181ad6265SDimitry Andric  let RenderMethod = "addImmOperands";
71281ad6265SDimitry Andric}
71381ad6265SDimitry Andricdef u8imm   : Operand<i32> {
71481ad6265SDimitry Andric  let PrintMethod = "printU8ImmOperand";
71581ad6265SDimitry Andric  let ParserMatchClass = PPCU8ImmAsmOperand;
71681ad6265SDimitry Andric  let DecoderMethod = "decodeUImmOperand<8>";
71781ad6265SDimitry Andric  let OperandType = "OPERAND_IMMEDIATE";
71881ad6265SDimitry Andric}
71981ad6265SDimitry Andricdef PPCU10ImmAsmOperand : AsmOperandClass {
72081ad6265SDimitry Andric  let Name = "U10Imm"; let PredicateMethod = "isU10Imm";
72181ad6265SDimitry Andric  let RenderMethod = "addImmOperands";
72281ad6265SDimitry Andric}
72381ad6265SDimitry Andricdef u10imm  : Operand<i32> {
72481ad6265SDimitry Andric  let PrintMethod = "printU10ImmOperand";
72581ad6265SDimitry Andric  let ParserMatchClass = PPCU10ImmAsmOperand;
72681ad6265SDimitry Andric  let DecoderMethod = "decodeUImmOperand<10>";
72781ad6265SDimitry Andric  let OperandType = "OPERAND_IMMEDIATE";
72881ad6265SDimitry Andric}
72981ad6265SDimitry Andricdef PPCU12ImmAsmOperand : AsmOperandClass {
73081ad6265SDimitry Andric  let Name = "U12Imm"; let PredicateMethod = "isU12Imm";
73181ad6265SDimitry Andric  let RenderMethod = "addImmOperands";
73281ad6265SDimitry Andric}
73381ad6265SDimitry Andricdef u12imm  : Operand<i32> {
73481ad6265SDimitry Andric  let PrintMethod = "printU12ImmOperand";
73581ad6265SDimitry Andric  let ParserMatchClass = PPCU12ImmAsmOperand;
73681ad6265SDimitry Andric  let DecoderMethod = "decodeUImmOperand<12>";
73781ad6265SDimitry Andric  let OperandType = "OPERAND_IMMEDIATE";
73881ad6265SDimitry Andric}
73981ad6265SDimitry Andricdef PPCS16ImmAsmOperand : AsmOperandClass {
74081ad6265SDimitry Andric  let Name = "S16Imm"; let PredicateMethod = "isS16Imm";
74181ad6265SDimitry Andric  let RenderMethod = "addS16ImmOperands";
74281ad6265SDimitry Andric}
74381ad6265SDimitry Andricdef s16imm  : Operand<i32> {
74481ad6265SDimitry Andric  let PrintMethod = "printS16ImmOperand";
74581ad6265SDimitry Andric  let EncoderMethod = "getImm16Encoding";
74681ad6265SDimitry Andric  let ParserMatchClass = PPCS16ImmAsmOperand;
74781ad6265SDimitry Andric  let DecoderMethod = "decodeSImmOperand<16>";
74881ad6265SDimitry Andric  let OperandType = "OPERAND_IMMEDIATE";
74981ad6265SDimitry Andric}
75081ad6265SDimitry Andricdef PPCU16ImmAsmOperand : AsmOperandClass {
75181ad6265SDimitry Andric  let Name = "U16Imm"; let PredicateMethod = "isU16Imm";
75281ad6265SDimitry Andric  let RenderMethod = "addU16ImmOperands";
75381ad6265SDimitry Andric}
75481ad6265SDimitry Andricdef u16imm  : Operand<i32> {
75581ad6265SDimitry Andric  let PrintMethod = "printU16ImmOperand";
75681ad6265SDimitry Andric  let EncoderMethod = "getImm16Encoding";
75781ad6265SDimitry Andric  let ParserMatchClass = PPCU16ImmAsmOperand;
75881ad6265SDimitry Andric  let DecoderMethod = "decodeUImmOperand<16>";
75981ad6265SDimitry Andric  let OperandType = "OPERAND_IMMEDIATE";
76081ad6265SDimitry Andric}
76181ad6265SDimitry Andricdef PPCS17ImmAsmOperand : AsmOperandClass {
76281ad6265SDimitry Andric  let Name = "S17Imm"; let PredicateMethod = "isS17Imm";
76381ad6265SDimitry Andric  let RenderMethod = "addS16ImmOperands";
76481ad6265SDimitry Andric}
76581ad6265SDimitry Andricdef s17imm  : Operand<i32> {
76681ad6265SDimitry Andric  // This operand type is used for addis/lis to allow the assembler parser
76781ad6265SDimitry Andric  // to accept immediates in the range -65536..65535 for compatibility with
76881ad6265SDimitry Andric  // the GNU assembler.  The operand is treated as 16-bit otherwise.
76981ad6265SDimitry Andric  let PrintMethod = "printS16ImmOperand";
77081ad6265SDimitry Andric  let EncoderMethod = "getImm16Encoding";
77181ad6265SDimitry Andric  let ParserMatchClass = PPCS17ImmAsmOperand;
77281ad6265SDimitry Andric  let DecoderMethod = "decodeSImmOperand<16>";
77381ad6265SDimitry Andric  let OperandType = "OPERAND_IMMEDIATE";
77481ad6265SDimitry Andric}
77581ad6265SDimitry Andricdef PPCS34ImmAsmOperand : AsmOperandClass {
77681ad6265SDimitry Andric  let Name = "S34Imm";
77781ad6265SDimitry Andric  let PredicateMethod = "isS34Imm";
77881ad6265SDimitry Andric  let RenderMethod = "addImmOperands";
77981ad6265SDimitry Andric}
78081ad6265SDimitry Andricdef s34imm : Operand<i64> {
78181ad6265SDimitry Andric  let PrintMethod = "printS34ImmOperand";
78281ad6265SDimitry Andric  let EncoderMethod = "getImm34EncodingNoPCRel";
78381ad6265SDimitry Andric  let ParserMatchClass = PPCS34ImmAsmOperand;
78481ad6265SDimitry Andric  let DecoderMethod = "decodeSImmOperand<34>";
78581ad6265SDimitry Andric  let OperandType = "OPERAND_IMMEDIATE";
78681ad6265SDimitry Andric}
78781ad6265SDimitry Andricdef s34imm_pcrel : Operand<i64> {
78881ad6265SDimitry Andric  let PrintMethod = "printS34ImmOperand";
78981ad6265SDimitry Andric  let EncoderMethod = "getImm34EncodingPCRel";
79081ad6265SDimitry Andric  let ParserMatchClass = PPCS34ImmAsmOperand;
79181ad6265SDimitry Andric  let DecoderMethod = "decodeSImmOperand<34>";
79281ad6265SDimitry Andric  let OperandType = "OPERAND_IMMEDIATE";
79381ad6265SDimitry Andric}
79481ad6265SDimitry Andricdef PPCImmZeroAsmOperand : AsmOperandClass {
79581ad6265SDimitry Andric  let Name = "ImmZero";
79681ad6265SDimitry Andric  let PredicateMethod = "isImmZero";
79781ad6265SDimitry Andric  let RenderMethod = "addImmOperands";
79881ad6265SDimitry Andric}
79981ad6265SDimitry Andricdef immZero : Operand<i32> {
80081ad6265SDimitry Andric  let PrintMethod = "printImmZeroOperand";
80181ad6265SDimitry Andric  let ParserMatchClass = PPCImmZeroAsmOperand;
80281ad6265SDimitry Andric  let DecoderMethod = "decodeImmZeroOperand";
80381ad6265SDimitry Andric  let OperandType = "OPERAND_IMMEDIATE";
80481ad6265SDimitry Andric}
80581ad6265SDimitry Andric
80681ad6265SDimitry Andricdef fpimm0 : PatLeaf<(fpimm), [{ return N->isExactlyValue(+0.0); }]>;
807bdd1243dSDimitry Andricdef fpimm0neg : PatLeaf<(fpimm), [{return N->isExactlyValue(-0.0);}]>;
80881ad6265SDimitry Andric
80981ad6265SDimitry Andricdef PPCDirectBrAsmOperand : AsmOperandClass {
81081ad6265SDimitry Andric  let Name = "DirectBr"; let PredicateMethod = "isDirectBr";
81181ad6265SDimitry Andric  let RenderMethod = "addBranchTargetOperands";
81281ad6265SDimitry Andric}
81381ad6265SDimitry Andricdef directbrtarget : Operand<OtherVT> {
81481ad6265SDimitry Andric  let PrintMethod = "printBranchOperand";
81581ad6265SDimitry Andric  let EncoderMethod = "getDirectBrEncoding";
81681ad6265SDimitry Andric  let DecoderMethod = "decodeDirectBrTarget";
81781ad6265SDimitry Andric  let ParserMatchClass = PPCDirectBrAsmOperand;
81881ad6265SDimitry Andric  let OperandType = "OPERAND_PCREL";
81981ad6265SDimitry Andric}
82081ad6265SDimitry Andricdef absdirectbrtarget : Operand<OtherVT> {
82181ad6265SDimitry Andric  let PrintMethod = "printAbsBranchOperand";
82281ad6265SDimitry Andric  let EncoderMethod = "getAbsDirectBrEncoding";
8235f757f3fSDimitry Andric  let DecoderMethod = "decodeDirectBrTarget";
82481ad6265SDimitry Andric  let ParserMatchClass = PPCDirectBrAsmOperand;
82581ad6265SDimitry Andric}
82681ad6265SDimitry Andricdef PPCCondBrAsmOperand : AsmOperandClass {
82781ad6265SDimitry Andric  let Name = "CondBr"; let PredicateMethod = "isCondBr";
82881ad6265SDimitry Andric  let RenderMethod = "addBranchTargetOperands";
82981ad6265SDimitry Andric}
83081ad6265SDimitry Andricdef condbrtarget : Operand<OtherVT> {
83181ad6265SDimitry Andric  let PrintMethod = "printBranchOperand";
83281ad6265SDimitry Andric  let EncoderMethod = "getCondBrEncoding";
83381ad6265SDimitry Andric  let DecoderMethod = "decodeCondBrTarget";
83481ad6265SDimitry Andric  let ParserMatchClass = PPCCondBrAsmOperand;
83581ad6265SDimitry Andric  let OperandType = "OPERAND_PCREL";
83681ad6265SDimitry Andric}
83781ad6265SDimitry Andricdef abscondbrtarget : Operand<OtherVT> {
83881ad6265SDimitry Andric  let PrintMethod = "printAbsBranchOperand";
83981ad6265SDimitry Andric  let EncoderMethod = "getAbsCondBrEncoding";
8405f757f3fSDimitry Andric  let DecoderMethod = "decodeCondBrTarget";
84181ad6265SDimitry Andric  let ParserMatchClass = PPCCondBrAsmOperand;
84281ad6265SDimitry Andric}
84381ad6265SDimitry Andricdef calltarget : Operand<iPTR> {
84481ad6265SDimitry Andric  let PrintMethod = "printBranchOperand";
84581ad6265SDimitry Andric  let EncoderMethod = "getDirectBrEncoding";
84681ad6265SDimitry Andric  let DecoderMethod = "decodeDirectBrTarget";
84781ad6265SDimitry Andric  let ParserMatchClass = PPCDirectBrAsmOperand;
84881ad6265SDimitry Andric  let OperandType = "OPERAND_PCREL";
84981ad6265SDimitry Andric}
85081ad6265SDimitry Andricdef abscalltarget : Operand<iPTR> {
85181ad6265SDimitry Andric  let PrintMethod = "printAbsBranchOperand";
85281ad6265SDimitry Andric  let EncoderMethod = "getAbsDirectBrEncoding";
8535f757f3fSDimitry Andric  let DecoderMethod = "decodeDirectBrTarget";
85481ad6265SDimitry Andric  let ParserMatchClass = PPCDirectBrAsmOperand;
85581ad6265SDimitry Andric}
85681ad6265SDimitry Andricdef PPCCRBitMaskOperand : AsmOperandClass {
85781ad6265SDimitry Andric let Name = "CRBitMask"; let PredicateMethod = "isCRBitMask";
85881ad6265SDimitry Andric}
85981ad6265SDimitry Andricdef crbitm: Operand<i8> {
86081ad6265SDimitry Andric  let PrintMethod = "printcrbitm";
86181ad6265SDimitry Andric  let EncoderMethod = "get_crbitm_encoding";
86281ad6265SDimitry Andric  let DecoderMethod = "decodeCRBitMOperand";
86381ad6265SDimitry Andric  let ParserMatchClass = PPCCRBitMaskOperand;
86481ad6265SDimitry Andric}
86581ad6265SDimitry Andric// Address operands
86681ad6265SDimitry Andric// A version of ptr_rc which excludes R0 (or X0 in 64-bit mode).
86781ad6265SDimitry Andricdef PPCRegGxRCNoR0Operand : AsmOperandClass {
86881ad6265SDimitry Andric  let Name = "RegGxRCNoR0"; let PredicateMethod = "isRegNumber";
86981ad6265SDimitry Andric}
87081ad6265SDimitry Andricdef ptr_rc_nor0 : Operand<iPTR>, PointerLikeRegClass<1> {
87181ad6265SDimitry Andric  let ParserMatchClass = PPCRegGxRCNoR0Operand;
87281ad6265SDimitry Andric}
87381ad6265SDimitry Andric
87481ad6265SDimitry Andric// New addressing modes with 34 bit immediates.
87581ad6265SDimitry Andricdef PPCDispRI34Operand : AsmOperandClass {
87681ad6265SDimitry Andric  let Name = "DispRI34"; let PredicateMethod = "isS34Imm";
87781ad6265SDimitry Andric  let RenderMethod = "addImmOperands";
87881ad6265SDimitry Andric}
87981ad6265SDimitry Andricdef dispRI34 : Operand<iPTR> {
88081ad6265SDimitry Andric  let ParserMatchClass = PPCDispRI34Operand;
88106c3fb27SDimitry Andric  let EncoderMethod = "getDispRI34Encoding";
88206c3fb27SDimitry Andric  let DecoderMethod = "decodeSImmOperand<34>";
88306c3fb27SDimitry Andric}
88406c3fb27SDimitry Andricdef dispRI34_pcrel : Operand<iPTR> {
88506c3fb27SDimitry Andric  let ParserMatchClass = PPCDispRI34Operand;
88606c3fb27SDimitry Andric  let EncoderMethod = "getDispRI34PCRelEncoding";
88706c3fb27SDimitry Andric  let DecoderMethod = "decodeSImmOperand<34>";
88881ad6265SDimitry Andric}
88981ad6265SDimitry Andricdef memri34 : Operand<iPTR> { // memri, imm is a 34-bit value.
89081ad6265SDimitry Andric  let PrintMethod = "printMemRegImm34";
89181ad6265SDimitry Andric  let MIOperandInfo = (ops dispRI34:$imm, ptr_rc_nor0:$reg);
89281ad6265SDimitry Andric}
89381ad6265SDimitry Andric// memri, imm is a 34-bit value for pc-relative instructions where
89481ad6265SDimitry Andric// base register is set to zero.
89581ad6265SDimitry Andricdef memri34_pcrel : Operand<iPTR> { // memri, imm is a 34-bit value.
89681ad6265SDimitry Andric  let PrintMethod = "printMemRegImm34PCRel";
89706c3fb27SDimitry Andric  let MIOperandInfo = (ops dispRI34_pcrel:$imm, immZero:$reg);
89881ad6265SDimitry Andric}
89981ad6265SDimitry Andric
90081ad6265SDimitry Andric// A version of ptr_rc usable with the asm parser.
90181ad6265SDimitry Andricdef PPCRegGxRCOperand : AsmOperandClass {
90281ad6265SDimitry Andric  let Name = "RegGxRC"; let PredicateMethod = "isRegNumber";
90381ad6265SDimitry Andric}
90481ad6265SDimitry Andricdef ptr_rc_idx : Operand<iPTR>, PointerLikeRegClass<0> {
90581ad6265SDimitry Andric  let ParserMatchClass = PPCRegGxRCOperand;
90681ad6265SDimitry Andric}
90781ad6265SDimitry Andric
90881ad6265SDimitry Andricdef PPCDispRIOperand : AsmOperandClass {
90981ad6265SDimitry Andric let Name = "DispRI"; let PredicateMethod = "isS16Imm";
91081ad6265SDimitry Andric let RenderMethod = "addS16ImmOperands";
91181ad6265SDimitry Andric}
91281ad6265SDimitry Andricdef dispRI : Operand<iPTR> {
91381ad6265SDimitry Andric  let ParserMatchClass = PPCDispRIOperand;
91406c3fb27SDimitry Andric  let EncoderMethod = "getDispRIEncoding";
91581ad6265SDimitry Andric}
91681ad6265SDimitry Andricdef PPCDispRIXOperand : AsmOperandClass {
91781ad6265SDimitry Andric let Name = "DispRIX"; let PredicateMethod = "isS16ImmX4";
91881ad6265SDimitry Andric let RenderMethod = "addS16ImmOperands";
91981ad6265SDimitry Andric}
92081ad6265SDimitry Andricdef dispRIX : Operand<iPTR> {
92181ad6265SDimitry Andric  let ParserMatchClass = PPCDispRIXOperand;
92206c3fb27SDimitry Andric  let EncoderMethod = "getDispRIXEncoding";
92306c3fb27SDimitry Andric  let DecoderMethod = "decodeDispRIXOperand";
92481ad6265SDimitry Andric}
92581ad6265SDimitry Andricdef PPCDispRIHashOperand : AsmOperandClass {
92681ad6265SDimitry Andric  let Name = "DispRIHash"; let PredicateMethod = "isHashImmX8";
92781ad6265SDimitry Andric  let RenderMethod = "addImmOperands";
92881ad6265SDimitry Andric}
92981ad6265SDimitry Andricdef dispRIHash : Operand<iPTR> {
93081ad6265SDimitry Andric  let ParserMatchClass = PPCDispRIHashOperand;
93106c3fb27SDimitry Andric  let EncoderMethod = "getDispRIHashEncoding";
93206c3fb27SDimitry Andric  let DecoderMethod = "decodeDispRIHashOperand";
93381ad6265SDimitry Andric}
93481ad6265SDimitry Andricdef PPCDispRIX16Operand : AsmOperandClass {
93581ad6265SDimitry Andric let Name = "DispRIX16"; let PredicateMethod = "isS16ImmX16";
93681ad6265SDimitry Andric let RenderMethod = "addS16ImmOperands";
93781ad6265SDimitry Andric}
93881ad6265SDimitry Andricdef dispRIX16 : Operand<iPTR> {
93981ad6265SDimitry Andric  let ParserMatchClass = PPCDispRIX16Operand;
94006c3fb27SDimitry Andric  let EncoderMethod = "getDispRIX16Encoding";
94106c3fb27SDimitry Andric  let DecoderMethod = "decodeDispRIX16Operand";
94206c3fb27SDimitry Andric
94381ad6265SDimitry Andric}
94481ad6265SDimitry Andricdef PPCDispSPE8Operand : AsmOperandClass {
94581ad6265SDimitry Andric let Name = "DispSPE8"; let PredicateMethod = "isU8ImmX8";
94681ad6265SDimitry Andric let RenderMethod = "addImmOperands";
94781ad6265SDimitry Andric}
94881ad6265SDimitry Andricdef dispSPE8 : Operand<iPTR> {
94981ad6265SDimitry Andric  let ParserMatchClass = PPCDispSPE8Operand;
95006c3fb27SDimitry Andric  let DecoderMethod = "decodeDispSPE8Operand";
95106c3fb27SDimitry Andric  let EncoderMethod = "getDispSPE8Encoding";
95281ad6265SDimitry Andric}
95381ad6265SDimitry Andricdef PPCDispSPE4Operand : AsmOperandClass {
95481ad6265SDimitry Andric let Name = "DispSPE4"; let PredicateMethod = "isU7ImmX4";
95581ad6265SDimitry Andric let RenderMethod = "addImmOperands";
95681ad6265SDimitry Andric}
95781ad6265SDimitry Andricdef dispSPE4 : Operand<iPTR> {
95881ad6265SDimitry Andric  let ParserMatchClass = PPCDispSPE4Operand;
95906c3fb27SDimitry Andric  let DecoderMethod = "decodeDispSPE4Operand";
96006c3fb27SDimitry Andric  let EncoderMethod = "getDispSPE4Encoding";
96181ad6265SDimitry Andric}
96281ad6265SDimitry Andricdef PPCDispSPE2Operand : AsmOperandClass {
96381ad6265SDimitry Andric let Name = "DispSPE2"; let PredicateMethod = "isU6ImmX2";
96481ad6265SDimitry Andric let RenderMethod = "addImmOperands";
96581ad6265SDimitry Andric}
96681ad6265SDimitry Andricdef dispSPE2 : Operand<iPTR> {
96781ad6265SDimitry Andric  let ParserMatchClass = PPCDispSPE2Operand;
96806c3fb27SDimitry Andric  let DecoderMethod = "decodeDispSPE2Operand";
96906c3fb27SDimitry Andric  let EncoderMethod = "getDispSPE2Encoding";
97081ad6265SDimitry Andric}
97181ad6265SDimitry Andric
97281ad6265SDimitry Andricdef memri : Operand<iPTR> {
97381ad6265SDimitry Andric  let PrintMethod = "printMemRegImm";
97481ad6265SDimitry Andric  let MIOperandInfo = (ops dispRI:$imm, ptr_rc_nor0:$reg);
97581ad6265SDimitry Andric  let OperandType = "OPERAND_MEMORY";
97681ad6265SDimitry Andric}
97781ad6265SDimitry Andricdef memrr : Operand<iPTR> {
97881ad6265SDimitry Andric  let PrintMethod = "printMemRegReg";
97981ad6265SDimitry Andric  let MIOperandInfo = (ops ptr_rc_nor0:$ptrreg, ptr_rc_idx:$offreg);
98081ad6265SDimitry Andric  let OperandType = "OPERAND_MEMORY";
98181ad6265SDimitry Andric}
98281ad6265SDimitry Andricdef memrix : Operand<iPTR> {   // memri where the imm is 4-aligned.
98381ad6265SDimitry Andric  let PrintMethod = "printMemRegImm";
98481ad6265SDimitry Andric  let MIOperandInfo = (ops dispRIX:$imm, ptr_rc_nor0:$reg);
98581ad6265SDimitry Andric  let OperandType = "OPERAND_MEMORY";
98681ad6265SDimitry Andric}
98781ad6265SDimitry Andricdef memrihash : Operand<iPTR> {
98881ad6265SDimitry Andric  // memrihash 8-aligned for ROP Protection Instructions.
98981ad6265SDimitry Andric  let PrintMethod = "printMemRegImmHash";
99081ad6265SDimitry Andric  let MIOperandInfo = (ops dispRIHash:$imm, ptr_rc_nor0:$reg);
99181ad6265SDimitry Andric  let OperandType = "OPERAND_MEMORY";
99281ad6265SDimitry Andric}
99381ad6265SDimitry Andricdef memrix16 : Operand<iPTR> { // memri, imm is 16-aligned, 12-bit, Inst{16:27}
99481ad6265SDimitry Andric  let PrintMethod = "printMemRegImm";
99581ad6265SDimitry Andric  let MIOperandInfo = (ops dispRIX16:$imm, ptr_rc_nor0:$reg);
99681ad6265SDimitry Andric  let OperandType = "OPERAND_MEMORY";
99781ad6265SDimitry Andric}
99881ad6265SDimitry Andricdef spe8dis : Operand<iPTR> {   // SPE displacement where the imm is 8-aligned.
99981ad6265SDimitry Andric  let PrintMethod = "printMemRegImm";
100081ad6265SDimitry Andric  let MIOperandInfo = (ops dispSPE8:$imm, ptr_rc_nor0:$reg);
100181ad6265SDimitry Andric  let OperandType = "OPERAND_MEMORY";
100281ad6265SDimitry Andric}
100381ad6265SDimitry Andricdef spe4dis : Operand<iPTR> {   // SPE displacement where the imm is 4-aligned.
100481ad6265SDimitry Andric  let PrintMethod = "printMemRegImm";
100581ad6265SDimitry Andric  let MIOperandInfo = (ops dispSPE4:$imm, ptr_rc_nor0:$reg);
100681ad6265SDimitry Andric  let OperandType = "OPERAND_MEMORY";
100781ad6265SDimitry Andric}
100881ad6265SDimitry Andricdef spe2dis : Operand<iPTR> {   // SPE displacement where the imm is 2-aligned.
100981ad6265SDimitry Andric  let PrintMethod = "printMemRegImm";
101081ad6265SDimitry Andric  let MIOperandInfo = (ops dispSPE2:$imm, ptr_rc_nor0:$reg);
101181ad6265SDimitry Andric  let OperandType = "OPERAND_MEMORY";
101281ad6265SDimitry Andric}
101381ad6265SDimitry Andric
101481ad6265SDimitry Andric// A single-register address. This is used with the SjLj
101581ad6265SDimitry Andric// pseudo-instructions which translates to LD/LWZ.  These instructions requires
101681ad6265SDimitry Andric// G8RC_NOX0 registers.
101781ad6265SDimitry Andricdef memr : Operand<iPTR> {
101881ad6265SDimitry Andric  let MIOperandInfo = (ops ptr_rc_nor0:$ptrreg);
101981ad6265SDimitry Andric  let OperandType = "OPERAND_MEMORY";
102081ad6265SDimitry Andric}
102181ad6265SDimitry Andricdef PPCTLSRegOperand : AsmOperandClass {
102281ad6265SDimitry Andric  let Name = "TLSReg"; let PredicateMethod = "isTLSReg";
102381ad6265SDimitry Andric  let RenderMethod = "addTLSRegOperands";
102481ad6265SDimitry Andric}
102581ad6265SDimitry Andricdef tlsreg32 : Operand<i32> {
102681ad6265SDimitry Andric  let EncoderMethod = "getTLSRegEncoding";
102781ad6265SDimitry Andric  let ParserMatchClass = PPCTLSRegOperand;
102881ad6265SDimitry Andric}
102981ad6265SDimitry Andricdef tlsgd32 : Operand<i32> {}
103081ad6265SDimitry Andricdef tlscall32 : Operand<i32> {
103181ad6265SDimitry Andric  let PrintMethod = "printTLSCall";
103281ad6265SDimitry Andric  let MIOperandInfo = (ops calltarget:$func, tlsgd32:$sym);
103381ad6265SDimitry Andric  let EncoderMethod = "getTLSCallEncoding";
103481ad6265SDimitry Andric}
103581ad6265SDimitry Andric
103681ad6265SDimitry Andric// PowerPC Predicate operand.
103781ad6265SDimitry Andricdef pred : Operand<OtherVT> {
103881ad6265SDimitry Andric  let PrintMethod = "printPredicateOperand";
103981ad6265SDimitry Andric  let MIOperandInfo = (ops i32imm:$bibo, crrc:$reg);
104081ad6265SDimitry Andric}
104181ad6265SDimitry Andric
104281ad6265SDimitry Andricdef PPCRegVSRCAsmOperand : AsmOperandClass {
104381ad6265SDimitry Andric  let Name = "RegVSRC"; let PredicateMethod = "isVSRegNumber";
104481ad6265SDimitry Andric}
104581ad6265SDimitry Andricdef vsrc : RegisterOperand<VSRC> {
104681ad6265SDimitry Andric  let ParserMatchClass = PPCRegVSRCAsmOperand;
104781ad6265SDimitry Andric}
104881ad6265SDimitry Andric
104981ad6265SDimitry Andricdef PPCRegVSFRCAsmOperand : AsmOperandClass {
105081ad6265SDimitry Andric  let Name = "RegVSFRC"; let PredicateMethod = "isVSRegNumber";
105181ad6265SDimitry Andric}
105281ad6265SDimitry Andricdef vsfrc : RegisterOperand<VSFRC> {
105381ad6265SDimitry Andric  let ParserMatchClass = PPCRegVSFRCAsmOperand;
105481ad6265SDimitry Andric}
105581ad6265SDimitry Andric
105681ad6265SDimitry Andricdef PPCRegVSSRCAsmOperand : AsmOperandClass {
105781ad6265SDimitry Andric  let Name = "RegVSSRC"; let PredicateMethod = "isVSRegNumber";
105881ad6265SDimitry Andric}
105981ad6265SDimitry Andricdef vssrc : RegisterOperand<VSSRC> {
106081ad6265SDimitry Andric  let ParserMatchClass = PPCRegVSSRCAsmOperand;
106181ad6265SDimitry Andric}
106281ad6265SDimitry Andric
106381ad6265SDimitry Andricdef PPCRegSPILLTOVSRRCAsmOperand : AsmOperandClass {
106481ad6265SDimitry Andric  let Name = "RegSPILLTOVSRRC"; let PredicateMethod = "isVSRegNumber";
106581ad6265SDimitry Andric}
106681ad6265SDimitry Andric
106781ad6265SDimitry Andricdef spilltovsrrc : RegisterOperand<SPILLTOVSRRC> {
106881ad6265SDimitry Andric  let ParserMatchClass = PPCRegSPILLTOVSRRCAsmOperand;
106981ad6265SDimitry Andric}
107081ad6265SDimitry Andric
107181ad6265SDimitry Andricdef PPCRegVSRpRCAsmOperand : AsmOperandClass {
107281ad6265SDimitry Andric  let Name = "RegVSRpRC"; let PredicateMethod = "isVSRpEvenRegNumber";
107381ad6265SDimitry Andric}
107481ad6265SDimitry Andric
107581ad6265SDimitry Andricdef vsrprc : RegisterOperand<VSRpRC> {
107681ad6265SDimitry Andric  let ParserMatchClass = PPCRegVSRpRCAsmOperand;
107781ad6265SDimitry Andric}
107881ad6265SDimitry Andric
107981ad6265SDimitry Andricdef PPCRegVSRpEvenRCAsmOperand : AsmOperandClass {
108081ad6265SDimitry Andric  let Name = "RegVSRpEvenRC"; let PredicateMethod = "isVSRpEvenRegNumber";
108181ad6265SDimitry Andric}
108281ad6265SDimitry Andric
108381ad6265SDimitry Andricdef vsrpevenrc : RegisterOperand<VSRpRC> {
108481ad6265SDimitry Andric  let ParserMatchClass = PPCRegVSRpEvenRCAsmOperand;
108581ad6265SDimitry Andric  let EncoderMethod = "getVSRpEvenEncoding";
108681ad6265SDimitry Andric  let DecoderMethod = "decodeVSRpEvenOperands";
108781ad6265SDimitry Andric}
108881ad6265SDimitry Andric
108981ad6265SDimitry Andricdef PPCRegACCRCAsmOperand : AsmOperandClass {
109081ad6265SDimitry Andric  let Name = "RegACCRC"; let PredicateMethod = "isACCRegNumber";
109181ad6265SDimitry Andric}
109281ad6265SDimitry Andric
109381ad6265SDimitry Andricdef acc : RegisterOperand<ACCRC> {
109481ad6265SDimitry Andric  let ParserMatchClass = PPCRegACCRCAsmOperand;
109581ad6265SDimitry Andric}
109681ad6265SDimitry Andric
109781ad6265SDimitry Andricdef uacc : RegisterOperand<UACCRC> {
109881ad6265SDimitry Andric  let ParserMatchClass = PPCRegACCRCAsmOperand;
109981ad6265SDimitry Andric}
1100bdd1243dSDimitry Andric
1101bdd1243dSDimitry Andric// DMR Register Operands
1102bdd1243dSDimitry Andricdef PPCRegDMRROWRCAsmOperand : AsmOperandClass {
1103bdd1243dSDimitry Andric  let Name = "RegDMRROWRC";
1104bdd1243dSDimitry Andric  let PredicateMethod = "isDMRROWRegNumber";
1105bdd1243dSDimitry Andric}
1106bdd1243dSDimitry Andric
1107bdd1243dSDimitry Andricdef dmrrow : RegisterOperand<DMRROWRC> {
1108bdd1243dSDimitry Andric  let ParserMatchClass = PPCRegDMRROWRCAsmOperand;
1109bdd1243dSDimitry Andric}
1110bdd1243dSDimitry Andric
1111bdd1243dSDimitry Andricdef PPCRegDMRROWpRCAsmOperand : AsmOperandClass {
1112bdd1243dSDimitry Andric  let Name = "RegDMRROWpRC";
1113bdd1243dSDimitry Andric  let PredicateMethod = "isDMRROWpRegNumber";
1114bdd1243dSDimitry Andric}
1115bdd1243dSDimitry Andric
1116bdd1243dSDimitry Andricdef dmrrowp : RegisterOperand<DMRROWpRC> {
1117bdd1243dSDimitry Andric  let ParserMatchClass = PPCRegDMRROWpRCAsmOperand;
1118bdd1243dSDimitry Andric}
1119bdd1243dSDimitry Andric
1120bdd1243dSDimitry Andricdef wacc : RegisterOperand<WACCRC> {
1121bdd1243dSDimitry Andric  let ParserMatchClass = PPCRegACCRCAsmOperand;
1122bdd1243dSDimitry Andric}
1123bdd1243dSDimitry Andric
1124bdd1243dSDimitry Andricdef wacc_hi : RegisterOperand<WACC_HIRC> {
1125bdd1243dSDimitry Andric  let ParserMatchClass = PPCRegACCRCAsmOperand;
1126bdd1243dSDimitry Andric}
1127bdd1243dSDimitry Andric
1128bdd1243dSDimitry Andricdef PPCRegDMRRCAsmOperand : AsmOperandClass {
1129bdd1243dSDimitry Andric  let Name = "RegDMRRC";
1130bdd1243dSDimitry Andric  let PredicateMethod = "isDMRRegNumber";
1131bdd1243dSDimitry Andric}
1132bdd1243dSDimitry Andric
1133bdd1243dSDimitry Andricdef dmr : RegisterOperand<DMRRC> {
1134bdd1243dSDimitry Andric  let ParserMatchClass = PPCRegDMRRCAsmOperand;
1135bdd1243dSDimitry Andric}
1136bdd1243dSDimitry Andric
1137bdd1243dSDimitry Andricdef PPCRegDMRpRCAsmOperand : AsmOperandClass {
1138bdd1243dSDimitry Andric  let Name = "RegDMRpRC";
1139bdd1243dSDimitry Andric  let PredicateMethod = "isDMRpRegNumber";
1140bdd1243dSDimitry Andric}
1141bdd1243dSDimitry Andric
1142bdd1243dSDimitry Andricdef dmrp : RegisterOperand<DMRpRC> {
1143bdd1243dSDimitry Andric  let ParserMatchClass = PPCRegDMRpRCAsmOperand;
1144bdd1243dSDimitry Andric}
1145