1*9a0e4156SSadaf Ebrahimi //===-- SystemZMCTargetDesc.cpp - SystemZ target descriptions -------------===//
2*9a0e4156SSadaf Ebrahimi //
3*9a0e4156SSadaf Ebrahimi // The LLVM Compiler Infrastructure
4*9a0e4156SSadaf Ebrahimi //
5*9a0e4156SSadaf Ebrahimi // This file is distributed under the University of Illinois Open Source
6*9a0e4156SSadaf Ebrahimi // License. See LICENSE.TXT for details.
7*9a0e4156SSadaf Ebrahimi //
8*9a0e4156SSadaf Ebrahimi //===----------------------------------------------------------------------===//
9*9a0e4156SSadaf Ebrahimi
10*9a0e4156SSadaf Ebrahimi /* Capstone Disassembly Engine */
11*9a0e4156SSadaf Ebrahimi /* By Nguyen Anh Quynh <[email protected]>, 2013-2015 */
12*9a0e4156SSadaf Ebrahimi
13*9a0e4156SSadaf Ebrahimi #ifdef CAPSTONE_HAS_SYSZ
14*9a0e4156SSadaf Ebrahimi
15*9a0e4156SSadaf Ebrahimi #include "SystemZMCTargetDesc.h"
16*9a0e4156SSadaf Ebrahimi
17*9a0e4156SSadaf Ebrahimi #define GET_REGINFO_ENUM
18*9a0e4156SSadaf Ebrahimi #include "SystemZGenRegisterInfo.inc"
19*9a0e4156SSadaf Ebrahimi
20*9a0e4156SSadaf Ebrahimi const unsigned SystemZMC_GR32Regs[16] = {
21*9a0e4156SSadaf Ebrahimi SystemZ_R0L, SystemZ_R1L, SystemZ_R2L, SystemZ_R3L,
22*9a0e4156SSadaf Ebrahimi SystemZ_R4L, SystemZ_R5L, SystemZ_R6L, SystemZ_R7L,
23*9a0e4156SSadaf Ebrahimi SystemZ_R8L, SystemZ_R9L, SystemZ_R10L, SystemZ_R11L,
24*9a0e4156SSadaf Ebrahimi SystemZ_R12L, SystemZ_R13L, SystemZ_R14L, SystemZ_R15L
25*9a0e4156SSadaf Ebrahimi };
26*9a0e4156SSadaf Ebrahimi
27*9a0e4156SSadaf Ebrahimi const unsigned SystemZMC_GRH32Regs[16] = {
28*9a0e4156SSadaf Ebrahimi SystemZ_R0H, SystemZ_R1H, SystemZ_R2H, SystemZ_R3H,
29*9a0e4156SSadaf Ebrahimi SystemZ_R4H, SystemZ_R5H, SystemZ_R6H, SystemZ_R7H,
30*9a0e4156SSadaf Ebrahimi SystemZ_R8H, SystemZ_R9H, SystemZ_R10H, SystemZ_R11H,
31*9a0e4156SSadaf Ebrahimi SystemZ_R12H, SystemZ_R13H, SystemZ_R14H, SystemZ_R15H
32*9a0e4156SSadaf Ebrahimi };
33*9a0e4156SSadaf Ebrahimi
34*9a0e4156SSadaf Ebrahimi const unsigned SystemZMC_GR64Regs[16] = {
35*9a0e4156SSadaf Ebrahimi SystemZ_R0D, SystemZ_R1D, SystemZ_R2D, SystemZ_R3D,
36*9a0e4156SSadaf Ebrahimi SystemZ_R4D, SystemZ_R5D, SystemZ_R6D, SystemZ_R7D,
37*9a0e4156SSadaf Ebrahimi SystemZ_R8D, SystemZ_R9D, SystemZ_R10D, SystemZ_R11D,
38*9a0e4156SSadaf Ebrahimi SystemZ_R12D, SystemZ_R13D, SystemZ_R14D, SystemZ_R15D
39*9a0e4156SSadaf Ebrahimi };
40*9a0e4156SSadaf Ebrahimi
41*9a0e4156SSadaf Ebrahimi const unsigned SystemZMC_GR128Regs[16] = {
42*9a0e4156SSadaf Ebrahimi SystemZ_R0Q, 0, SystemZ_R2Q, 0,
43*9a0e4156SSadaf Ebrahimi SystemZ_R4Q, 0, SystemZ_R6Q, 0,
44*9a0e4156SSadaf Ebrahimi SystemZ_R8Q, 0, SystemZ_R10Q, 0,
45*9a0e4156SSadaf Ebrahimi SystemZ_R12Q, 0, SystemZ_R14Q, 0
46*9a0e4156SSadaf Ebrahimi };
47*9a0e4156SSadaf Ebrahimi
48*9a0e4156SSadaf Ebrahimi const unsigned SystemZMC_FP32Regs[16] = {
49*9a0e4156SSadaf Ebrahimi SystemZ_F0S, SystemZ_F1S, SystemZ_F2S, SystemZ_F3S,
50*9a0e4156SSadaf Ebrahimi SystemZ_F4S, SystemZ_F5S, SystemZ_F6S, SystemZ_F7S,
51*9a0e4156SSadaf Ebrahimi SystemZ_F8S, SystemZ_F9S, SystemZ_F10S, SystemZ_F11S,
52*9a0e4156SSadaf Ebrahimi SystemZ_F12S, SystemZ_F13S, SystemZ_F14S, SystemZ_F15S
53*9a0e4156SSadaf Ebrahimi };
54*9a0e4156SSadaf Ebrahimi
55*9a0e4156SSadaf Ebrahimi const unsigned SystemZMC_FP64Regs[16] = {
56*9a0e4156SSadaf Ebrahimi SystemZ_F0D, SystemZ_F1D, SystemZ_F2D, SystemZ_F3D,
57*9a0e4156SSadaf Ebrahimi SystemZ_F4D, SystemZ_F5D, SystemZ_F6D, SystemZ_F7D,
58*9a0e4156SSadaf Ebrahimi SystemZ_F8D, SystemZ_F9D, SystemZ_F10D, SystemZ_F11D,
59*9a0e4156SSadaf Ebrahimi SystemZ_F12D, SystemZ_F13D, SystemZ_F14D, SystemZ_F15D
60*9a0e4156SSadaf Ebrahimi };
61*9a0e4156SSadaf Ebrahimi
62*9a0e4156SSadaf Ebrahimi const unsigned SystemZMC_FP128Regs[16] = {
63*9a0e4156SSadaf Ebrahimi SystemZ_F0Q, SystemZ_F1Q, 0, 0,
64*9a0e4156SSadaf Ebrahimi SystemZ_F4Q, SystemZ_F5Q, 0, 0,
65*9a0e4156SSadaf Ebrahimi SystemZ_F8Q, SystemZ_F9Q, 0, 0,
66*9a0e4156SSadaf Ebrahimi SystemZ_F12Q, SystemZ_F13Q, 0, 0
67*9a0e4156SSadaf Ebrahimi };
68*9a0e4156SSadaf Ebrahimi
69*9a0e4156SSadaf Ebrahimi const unsigned SystemZMC_VR32Regs[32] = {
70*9a0e4156SSadaf Ebrahimi SystemZ_F0S, SystemZ_F1S, SystemZ_F2S, SystemZ_F3S,
71*9a0e4156SSadaf Ebrahimi SystemZ_F4S, SystemZ_F5S, SystemZ_F6S, SystemZ_F7S,
72*9a0e4156SSadaf Ebrahimi SystemZ_F8S, SystemZ_F9S, SystemZ_F10S, SystemZ_F11S,
73*9a0e4156SSadaf Ebrahimi SystemZ_F12S, SystemZ_F13S, SystemZ_F14S, SystemZ_F15S,
74*9a0e4156SSadaf Ebrahimi SystemZ_F16S, SystemZ_F17S, SystemZ_F18S, SystemZ_F19S,
75*9a0e4156SSadaf Ebrahimi SystemZ_F20S, SystemZ_F21S, SystemZ_F22S, SystemZ_F23S,
76*9a0e4156SSadaf Ebrahimi SystemZ_F24S, SystemZ_F25S, SystemZ_F26S, SystemZ_F27S,
77*9a0e4156SSadaf Ebrahimi SystemZ_F28S, SystemZ_F29S, SystemZ_F30S, SystemZ_F31S
78*9a0e4156SSadaf Ebrahimi };
79*9a0e4156SSadaf Ebrahimi
80*9a0e4156SSadaf Ebrahimi const unsigned SystemZMC_VR64Regs[32] = {
81*9a0e4156SSadaf Ebrahimi SystemZ_F0D, SystemZ_F1D, SystemZ_F2D, SystemZ_F3D,
82*9a0e4156SSadaf Ebrahimi SystemZ_F4D, SystemZ_F5D, SystemZ_F6D, SystemZ_F7D,
83*9a0e4156SSadaf Ebrahimi SystemZ_F8D, SystemZ_F9D, SystemZ_F10D, SystemZ_F11D,
84*9a0e4156SSadaf Ebrahimi SystemZ_F12D, SystemZ_F13D, SystemZ_F14D, SystemZ_F15D,
85*9a0e4156SSadaf Ebrahimi SystemZ_F16D, SystemZ_F17D, SystemZ_F18D, SystemZ_F19D,
86*9a0e4156SSadaf Ebrahimi SystemZ_F20D, SystemZ_F21D, SystemZ_F22D, SystemZ_F23D,
87*9a0e4156SSadaf Ebrahimi SystemZ_F24D, SystemZ_F25D, SystemZ_F26D, SystemZ_F27D,
88*9a0e4156SSadaf Ebrahimi SystemZ_F28D, SystemZ_F29D, SystemZ_F30D, SystemZ_F31D
89*9a0e4156SSadaf Ebrahimi };
90*9a0e4156SSadaf Ebrahimi
91*9a0e4156SSadaf Ebrahimi const unsigned SystemZMC_VR128Regs[32] = {
92*9a0e4156SSadaf Ebrahimi SystemZ_V0, SystemZ_V1, SystemZ_V2, SystemZ_V3,
93*9a0e4156SSadaf Ebrahimi SystemZ_V4, SystemZ_V5, SystemZ_V6, SystemZ_V7,
94*9a0e4156SSadaf Ebrahimi SystemZ_V8, SystemZ_V9, SystemZ_V10, SystemZ_V11,
95*9a0e4156SSadaf Ebrahimi SystemZ_V12, SystemZ_V13, SystemZ_V14, SystemZ_V15,
96*9a0e4156SSadaf Ebrahimi SystemZ_V16, SystemZ_V17, SystemZ_V18, SystemZ_V19,
97*9a0e4156SSadaf Ebrahimi SystemZ_V20, SystemZ_V21, SystemZ_V22, SystemZ_V23,
98*9a0e4156SSadaf Ebrahimi SystemZ_V24, SystemZ_V25, SystemZ_V26, SystemZ_V27,
99*9a0e4156SSadaf Ebrahimi SystemZ_V28, SystemZ_V29, SystemZ_V30, SystemZ_V31
100*9a0e4156SSadaf Ebrahimi };
101*9a0e4156SSadaf Ebrahimi
102*9a0e4156SSadaf Ebrahimi const unsigned SystemZMC_AR32Regs[16] = {
103*9a0e4156SSadaf Ebrahimi SystemZ_A0, SystemZ_A1, SystemZ_A2, SystemZ_A3,
104*9a0e4156SSadaf Ebrahimi SystemZ_A4, SystemZ_A5, SystemZ_A6, SystemZ_A7,
105*9a0e4156SSadaf Ebrahimi SystemZ_A8, SystemZ_A9, SystemZ_A10, SystemZ_A11,
106*9a0e4156SSadaf Ebrahimi SystemZ_A12, SystemZ_A13, SystemZ_A14, SystemZ_A15
107*9a0e4156SSadaf Ebrahimi };
108*9a0e4156SSadaf Ebrahimi
109*9a0e4156SSadaf Ebrahimi const unsigned SystemZMC_CR64Regs[16] = {
110*9a0e4156SSadaf Ebrahimi SystemZ_C0, SystemZ_C1, SystemZ_C2, SystemZ_C3,
111*9a0e4156SSadaf Ebrahimi SystemZ_C4, SystemZ_C5, SystemZ_C6, SystemZ_C7,
112*9a0e4156SSadaf Ebrahimi SystemZ_C8, SystemZ_C9, SystemZ_C10, SystemZ_C11,
113*9a0e4156SSadaf Ebrahimi SystemZ_C12, SystemZ_C13, SystemZ_C14, SystemZ_C15
114*9a0e4156SSadaf Ebrahimi };
115*9a0e4156SSadaf Ebrahimi
SystemZMC_getFirstReg(unsigned Reg)116*9a0e4156SSadaf Ebrahimi unsigned SystemZMC_getFirstReg(unsigned Reg)
117*9a0e4156SSadaf Ebrahimi {
118*9a0e4156SSadaf Ebrahimi static unsigned Map[SystemZ_NUM_TARGET_REGS];
119*9a0e4156SSadaf Ebrahimi static int Initialized = 0;
120*9a0e4156SSadaf Ebrahimi unsigned I;
121*9a0e4156SSadaf Ebrahimi
122*9a0e4156SSadaf Ebrahimi if (!Initialized) {
123*9a0e4156SSadaf Ebrahimi Initialized = 1;
124*9a0e4156SSadaf Ebrahimi for (I = 0; I < 16; ++I) {
125*9a0e4156SSadaf Ebrahimi Map[SystemZMC_GR32Regs[I]] = I;
126*9a0e4156SSadaf Ebrahimi Map[SystemZMC_GRH32Regs[I]] = I;
127*9a0e4156SSadaf Ebrahimi Map[SystemZMC_GR64Regs[I]] = I;
128*9a0e4156SSadaf Ebrahimi Map[SystemZMC_GR128Regs[I]] = I;
129*9a0e4156SSadaf Ebrahimi Map[SystemZMC_FP32Regs[I]] = I;
130*9a0e4156SSadaf Ebrahimi Map[SystemZMC_FP64Regs[I]] = I;
131*9a0e4156SSadaf Ebrahimi Map[SystemZMC_FP128Regs[I]] = I;
132*9a0e4156SSadaf Ebrahimi Map[SystemZMC_VR32Regs[I]] = I;
133*9a0e4156SSadaf Ebrahimi Map[SystemZMC_VR64Regs[I]] = I;
134*9a0e4156SSadaf Ebrahimi Map[SystemZMC_VR128Regs[I]] = I;
135*9a0e4156SSadaf Ebrahimi Map[SystemZMC_AR32Regs[I]] = I;
136*9a0e4156SSadaf Ebrahimi Map[SystemZMC_CR64Regs[I]] = I;
137*9a0e4156SSadaf Ebrahimi }
138*9a0e4156SSadaf Ebrahimi }
139*9a0e4156SSadaf Ebrahimi
140*9a0e4156SSadaf Ebrahimi // assert(Reg < SystemZ_NUM_TARGET_REGS);
141*9a0e4156SSadaf Ebrahimi return Map[Reg];
142*9a0e4156SSadaf Ebrahimi }
143*9a0e4156SSadaf Ebrahimi
144*9a0e4156SSadaf Ebrahimi #endif
145