/src/capstonev5/arch/SystemZ/SystemZDisassembler.c
Line  | Count  | Source  | 
1  |  | //===------ SystemZDisassembler.cpp - Disassembler for PowerPC ------*- C++ -*-===//  | 
2  |  | //  | 
3  |  | //                     The LLVM Compiler Infrastructure  | 
4  |  | //  | 
5  |  | // This file is distributed under the University of Illinois Open Source  | 
6  |  | // License. See LICENSE.TXT for details.  | 
7  |  | //  | 
8  |  | //===----------------------------------------------------------------------===//  | 
9  |  |  | 
10  |  | /* Capstone Disassembly Engine */  | 
11  |  | /* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2015 */  | 
12  |  |  | 
13  |  | #ifdef CAPSTONE_HAS_SYSZ  | 
14  |  |  | 
15  |  | #include <stdio.h>  // DEBUG  | 
16  |  | #include <stdlib.h>  | 
17  |  | #include <string.h>  | 
18  |  |  | 
19  |  | #include "../../cs_priv.h"  | 
20  |  | #include "../../utils.h"  | 
21  |  |  | 
22  |  | #include "SystemZDisassembler.h"  | 
23  |  |  | 
24  |  | #include "../../MCInst.h"  | 
25  |  | #include "../../MCInstrDesc.h"  | 
26  |  | #include "../../MCFixedLenDisassembler.h"  | 
27  |  | #include "../../MCRegisterInfo.h"  | 
28  |  | #include "../../MCDisassembler.h"  | 
29  |  | #include "../../MathExtras.h"  | 
30  |  |  | 
31  |  | #include "SystemZMCTargetDesc.h"  | 
32  |  |  | 
33  |  | static uint64_t getFeatureBits(int mode)  | 
34  | 97.8k  | { | 
35  |  |   // support everything  | 
36  | 97.8k  |   return (uint64_t)-1;  | 
37  | 97.8k  | }  | 
38  |  |  | 
39  |  | static DecodeStatus decodeRegisterClass(MCInst *Inst, uint64_t RegNo, const unsigned *Regs)  | 
40  | 181k  | { | 
41  |  |   //assert(RegNo < 16 && "Invalid register");  | 
42  | 181k  |   RegNo = Regs[RegNo];  | 
43  | 181k  |   if (RegNo == 0)  | 
44  | 118  |     return MCDisassembler_Fail;  | 
45  |  |  | 
46  | 181k  |   MCOperand_CreateReg0(Inst, (unsigned)RegNo);  | 
47  | 181k  |   return MCDisassembler_Success;  | 
48  | 181k  | }  | 
49  |  |  | 
50  |  | static DecodeStatus DecodeGR32BitRegisterClass(MCInst *Inst, uint64_t RegNo,  | 
51  |  |     uint64_t Address, const void *Decoder)  | 
52  | 38.5k  | { | 
53  | 38.5k  |   return decodeRegisterClass(Inst, RegNo, SystemZMC_GR32Regs);  | 
54  | 38.5k  | }  | 
55  |  |  | 
56  |  | static DecodeStatus DecodeGRH32BitRegisterClass(MCInst *Inst, uint64_t RegNo,  | 
57  |  |     uint64_t Address, const void *Decoder)  | 
58  | 6.58k  | { | 
59  | 6.58k  |   return decodeRegisterClass(Inst, RegNo, SystemZMC_GRH32Regs);  | 
60  | 6.58k  | }  | 
61  |  |  | 
62  |  | static DecodeStatus DecodeGR64BitRegisterClass(MCInst *Inst, uint64_t RegNo,  | 
63  |  |     uint64_t Address, const void *Decoder)  | 
64  | 32.0k  | { | 
65  | 32.0k  |   return decodeRegisterClass(Inst, RegNo, SystemZMC_GR64Regs);  | 
66  | 32.0k  | }  | 
67  |  |  | 
68  |  | static DecodeStatus DecodeGR128BitRegisterClass(MCInst *Inst, uint64_t RegNo,  | 
69  |  |     uint64_t Address, const void *Decoder)  | 
70  | 12.1k  | { | 
71  | 12.1k  |   return decodeRegisterClass(Inst, RegNo, SystemZMC_GR128Regs);  | 
72  | 12.1k  | }  | 
73  |  |  | 
74  |  | static DecodeStatus DecodeADDR64BitRegisterClass(MCInst *Inst, uint64_t RegNo,  | 
75  |  |     uint64_t Address, const void *Decoder)  | 
76  | 1.90k  | { | 
77  | 1.90k  |   return decodeRegisterClass(Inst, RegNo, SystemZMC_GR64Regs);  | 
78  | 1.90k  | }  | 
79  |  |  | 
80  |  | static DecodeStatus DecodeFP32BitRegisterClass(MCInst *Inst, uint64_t RegNo,  | 
81  |  |     uint64_t Address, const void *Decoder)   | 
82  | 13.9k  | { | 
83  | 13.9k  |   return decodeRegisterClass(Inst, RegNo, SystemZMC_FP32Regs);  | 
84  | 13.9k  | }  | 
85  |  |  | 
86  |  | static DecodeStatus DecodeFP64BitRegisterClass(MCInst *Inst, uint64_t RegNo,  | 
87  |  |     uint64_t Address, const void *Decoder)  | 
88  | 33.5k  | { | 
89  | 33.5k  |   return decodeRegisterClass(Inst, RegNo, SystemZMC_FP64Regs);  | 
90  | 33.5k  | }  | 
91  |  |  | 
92  |  | static DecodeStatus DecodeFP128BitRegisterClass(MCInst *Inst, uint64_t RegNo,  | 
93  |  |     uint64_t Address, const void *Decoder)  | 
94  | 6.36k  | { | 
95  | 6.36k  |   return decodeRegisterClass(Inst, RegNo, SystemZMC_FP128Regs);  | 
96  | 6.36k  | }  | 
97  |  |  | 
98  |  | static DecodeStatus DecodeVR32BitRegisterClass(MCInst *Inst, uint64_t RegNo,  | 
99  |  |     uint64_t Address, const void *Decoder)  | 
100  | 3.90k  | { | 
101  | 3.90k  |   return decodeRegisterClass(Inst, RegNo, SystemZMC_VR32Regs);  | 
102  | 3.90k  | }  | 
103  |  |  | 
104  |  | static DecodeStatus DecodeVR64BitRegisterClass(MCInst *Inst, uint64_t RegNo,  | 
105  |  |     uint64_t Address, const void *Decoder)  | 
106  | 3.72k  | { | 
107  | 3.72k  |   return decodeRegisterClass(Inst, RegNo, SystemZMC_VR64Regs);  | 
108  | 3.72k  | }  | 
109  |  |  | 
110  |  | static DecodeStatus DecodeVR128BitRegisterClass(MCInst *Inst, uint64_t RegNo,  | 
111  |  |     uint64_t Address, const void *Decoder)  | 
112  | 26.7k  | { | 
113  | 26.7k  |   return decodeRegisterClass(Inst, RegNo, SystemZMC_VR128Regs);  | 
114  | 26.7k  | }  | 
115  |  |  | 
116  |  | static DecodeStatus DecodeAR32BitRegisterClass(MCInst *Inst, uint64_t RegNo,  | 
117  |  |     uint64_t Address, const void *Decoder)  | 
118  | 1.67k  | { | 
119  | 1.67k  |   return decodeRegisterClass(Inst, RegNo, SystemZMC_AR32Regs);  | 
120  | 1.67k  | }  | 
121  |  |  | 
122  |  | static DecodeStatus DecodeCR64BitRegisterClass(MCInst *Inst, uint64_t RegNo,  | 
123  |  |     uint64_t Address, const void *Decoder)  | 
124  | 686  | { | 
125  | 686  |   return decodeRegisterClass(Inst, RegNo, SystemZMC_CR64Regs);  | 
126  | 686  | }  | 
127  |  |  | 
128  |  | static DecodeStatus decodeUImmOperand(MCInst *Inst, uint64_t Imm)  | 
129  | 40.2k  | { | 
130  |  |   //assert(isUInt<N>(Imm) && "Invalid immediate");  | 
131  | 40.2k  |   MCOperand_CreateImm0(Inst, Imm);  | 
132  | 40.2k  |   return MCDisassembler_Success;  | 
133  | 40.2k  | }  | 
134  |  |  | 
135  |  | static DecodeStatus decodeSImmOperand(MCInst *Inst, uint64_t Imm, unsigned N)  | 
136  | 6.70k  | { | 
137  |  |   //assert(isUInt<N>(Imm) && "Invalid immediate");  | 
138  | 6.70k  |   MCOperand_CreateImm0(Inst, SignExtend64(Imm, N));  | 
139  | 6.70k  |   return MCDisassembler_Success;  | 
140  | 6.70k  | }  | 
141  |  |  | 
142  |  | static DecodeStatus decodeU1ImmOperand(MCInst *Inst, uint64_t Imm,  | 
143  |  |     uint64_t Address, const void *Decoder)  | 
144  | 573  | { | 
145  | 573  |   return decodeUImmOperand(Inst, Imm);  | 
146  | 573  | }  | 
147  |  |  | 
148  |  | static DecodeStatus decodeU2ImmOperand(MCInst *Inst, uint64_t Imm,  | 
149  |  |     uint64_t Address, const void *Decoder)  | 
150  | 993  | { | 
151  | 993  |   return decodeUImmOperand(Inst, Imm);  | 
152  | 993  | }  | 
153  |  |  | 
154  |  | static DecodeStatus decodeU3ImmOperand(MCInst *Inst, uint64_t Imm,  | 
155  |  |     uint64_t Address, const void *Decoder)  | 
156  | 170  | { | 
157  | 170  |   return decodeUImmOperand(Inst, Imm);  | 
158  | 170  | }  | 
159  |  |  | 
160  |  | static DecodeStatus decodeU4ImmOperand(MCInst *Inst, uint64_t Imm,  | 
161  |  |     uint64_t Address, const void *Decoder)  | 
162  | 28.3k  | { | 
163  | 28.3k  |   return decodeUImmOperand(Inst, Imm);  | 
164  | 28.3k  | }  | 
165  |  |  | 
166  |  | static DecodeStatus decodeU6ImmOperand(MCInst *Inst, uint64_t Imm,  | 
167  |  |     uint64_t Address, const void *Decoder)  | 
168  | 344  | { | 
169  | 344  |   return decodeUImmOperand(Inst, Imm);  | 
170  | 344  | }  | 
171  |  |  | 
172  |  | static DecodeStatus decodeU8ImmOperand(MCInst *Inst, uint64_t Imm,  | 
173  |  |     uint64_t Address, const void *Decoder)  | 
174  | 5.72k  | { | 
175  | 5.72k  |   return decodeUImmOperand(Inst, Imm);  | 
176  | 5.72k  | }  | 
177  |  |  | 
178  |  | static DecodeStatus decodeU12ImmOperand(MCInst *Inst, uint64_t Imm,  | 
179  |  |     uint64_t Address, const void *Decoder)  | 
180  | 370  | { | 
181  | 370  |   return decodeUImmOperand(Inst, Imm);  | 
182  | 370  | }  | 
183  |  |  | 
184  |  | static DecodeStatus decodeU16ImmOperand(MCInst *Inst, uint64_t Imm,  | 
185  |  |     uint64_t Address, const void *Decoder)  | 
186  | 2.67k  | { | 
187  | 2.67k  |   return decodeUImmOperand(Inst, Imm);  | 
188  | 2.67k  | }  | 
189  |  |  | 
190  |  | static DecodeStatus decodeU32ImmOperand(MCInst *Inst, uint64_t Imm,  | 
191  |  |     uint64_t Address, const void *Decoder)  | 
192  | 1.04k  | { | 
193  | 1.04k  |   return decodeUImmOperand(Inst, Imm);  | 
194  | 1.04k  | }  | 
195  |  |  | 
196  |  | static DecodeStatus decodeS8ImmOperand(MCInst *Inst, uint64_t Imm,  | 
197  |  |     uint64_t Address, const void *Decoder)  | 
198  | 1.96k  | { | 
199  | 1.96k  |   return decodeSImmOperand(Inst, Imm, 8);  | 
200  | 1.96k  | }  | 
201  |  |  | 
202  |  | static DecodeStatus decodeS16ImmOperand(MCInst *Inst, uint64_t Imm,  | 
203  |  |     uint64_t Address, const void *Decoder)   | 
204  | 3.50k  | { | 
205  | 3.50k  |   return decodeSImmOperand(Inst, Imm, 16);  | 
206  | 3.50k  | }  | 
207  |  |  | 
208  |  | static DecodeStatus decodeS32ImmOperand(MCInst *Inst, uint64_t Imm,  | 
209  |  |     uint64_t Address, const void *Decoder)  | 
210  | 1.23k  | { | 
211  | 1.23k  |   return decodeSImmOperand(Inst, Imm, 32);  | 
212  | 1.23k  | }  | 
213  |  |  | 
214  |  | static DecodeStatus decodePCDBLOperand(MCInst *Inst, uint64_t Imm,  | 
215  |  |     uint64_t Address, unsigned N)  | 
216  | 7.57k  | { | 
217  |  |   //assert(isUInt<N>(Imm) && "Invalid PC-relative offset");  | 
218  | 7.57k  |   MCOperand_CreateImm0(Inst, SignExtend64(Imm, N) * 2 + Address);  | 
219  | 7.57k  |   return MCDisassembler_Success;  | 
220  | 7.57k  | }  | 
221  |  |  | 
222  |  | static DecodeStatus decodePC12DBLBranchOperand(MCInst *Inst, uint64_t Imm,  | 
223  |  |     uint64_t Address,  | 
224  |  |     const void *Decoder)  | 
225  | 313  | { | 
226  | 313  |   return decodePCDBLOperand(Inst, Imm, Address, 12);  | 
227  | 313  | }  | 
228  |  |  | 
229  |  | static DecodeStatus decodePC16DBLBranchOperand(MCInst *Inst, uint64_t Imm,  | 
230  |  |     uint64_t Address,  | 
231  |  |     const void *Decoder)  | 
232  | 4.88k  | { | 
233  | 4.88k  |   return decodePCDBLOperand(Inst, Imm, Address, 16);  | 
234  | 4.88k  | }  | 
235  |  |  | 
236  |  | static DecodeStatus decodePC24DBLBranchOperand(MCInst *Inst, uint64_t Imm,  | 
237  |  |     uint64_t Address,  | 
238  |  |     const void *Decoder)  | 
239  | 313  | { | 
240  | 313  |   return decodePCDBLOperand(Inst, Imm, Address, 24);  | 
241  | 313  | }  | 
242  |  |  | 
243  |  | static DecodeStatus decodePC32DBLBranchOperand(MCInst *Inst, uint64_t Imm,  | 
244  |  |     uint64_t Address,  | 
245  |  |     const void *Decoder)  | 
246  | 789  | { | 
247  | 789  |   return decodePCDBLOperand(Inst, Imm, Address, 32);  | 
248  | 789  | }  | 
249  |  |  | 
250  |  | static DecodeStatus decodePC32DBLOperand(MCInst *Inst, uint64_t Imm,  | 
251  |  |     uint64_t Address,  | 
252  |  |     const void *Decoder)  | 
253  | 1.27k  | { | 
254  | 1.27k  |   return decodePCDBLOperand(Inst, Imm, Address, 32);  | 
255  | 1.27k  | }  | 
256  |  |  | 
257  |  | static DecodeStatus decodeBDAddr12Operand(MCInst *Inst, uint64_t Field,  | 
258  |  |     const unsigned *Regs)  | 
259  | 14.3k  | { | 
260  | 14.3k  |   uint64_t Base = Field >> 12;  | 
261  | 14.3k  |   uint64_t Disp = Field & 0xfff;  | 
262  |  |   //assert(Base < 16 && "Invalid BDAddr12");  | 
263  |  |  | 
264  | 14.3k  |   MCOperand_CreateReg0(Inst, Base == 0 ? 0 : Regs[Base]);  | 
265  | 14.3k  |   MCOperand_CreateImm0(Inst, Disp);  | 
266  |  |  | 
267  | 14.3k  |   return MCDisassembler_Success;  | 
268  | 14.3k  | }  | 
269  |  |  | 
270  |  | static DecodeStatus decodeBDAddr20Operand(MCInst *Inst, uint64_t Field,  | 
271  |  |     const unsigned *Regs)  | 
272  | 4.86k  | { | 
273  | 4.86k  |   uint64_t Base = Field >> 20;  | 
274  | 4.86k  |   uint64_t Disp = ((Field << 12) & 0xff000) | ((Field >> 8) & 0xfff);  | 
275  |  |   //assert(Base < 16 && "Invalid BDAddr20");  | 
276  |  |  | 
277  | 4.86k  |   MCOperand_CreateReg0(Inst, Base == 0 ? 0 : Regs[Base]);  | 
278  | 4.86k  |   MCOperand_CreateImm0(Inst, SignExtend64(Disp, 20));  | 
279  | 4.86k  |   return MCDisassembler_Success;  | 
280  | 4.86k  | }  | 
281  |  |  | 
282  |  | static DecodeStatus decodeBDXAddr12Operand(MCInst *Inst, uint64_t Field,  | 
283  |  |     const unsigned *Regs)  | 
284  | 15.6k  | { | 
285  | 15.6k  |   uint64_t Index = Field >> 16;  | 
286  | 15.6k  |   uint64_t Base = (Field >> 12) & 0xf;  | 
287  | 15.6k  |   uint64_t Disp = Field & 0xfff;  | 
288  |  |  | 
289  |  |   //assert(Index < 16 && "Invalid BDXAddr12");  | 
290  | 15.6k  |   MCOperand_CreateReg0(Inst, Base == 0 ? 0 : Regs[Base]);  | 
291  | 15.6k  |   MCOperand_CreateImm0(Inst, Disp);  | 
292  | 15.6k  |   MCOperand_CreateReg0(Inst, Index == 0 ? 0 : Regs[Index]);  | 
293  |  |  | 
294  | 15.6k  |   return MCDisassembler_Success;  | 
295  | 15.6k  | }  | 
296  |  |  | 
297  |  | static DecodeStatus decodeBDXAddr20Operand(MCInst *Inst, uint64_t Field,  | 
298  |  |     const unsigned *Regs)  | 
299  | 1.27k  | { | 
300  | 1.27k  |   uint64_t Index = Field >> 24;  | 
301  | 1.27k  |   uint64_t Base = (Field >> 20) & 0xf;  | 
302  | 1.27k  |   uint64_t Disp = ((Field & 0xfff00) >> 8) | ((Field & 0xff) << 12);  | 
303  |  |  | 
304  |  |   //assert(Index < 16 && "Invalid BDXAddr20");  | 
305  | 1.27k  |   MCOperand_CreateReg0(Inst, Base == 0 ? 0 : Regs[Base]);  | 
306  | 1.27k  |   MCOperand_CreateImm0(Inst, SignExtend64(Disp, 20));  | 
307  | 1.27k  |   MCOperand_CreateReg0(Inst, Index == 0 ? 0 : Regs[Index]);  | 
308  |  |  | 
309  | 1.27k  |   return MCDisassembler_Success;  | 
310  | 1.27k  | }  | 
311  |  |  | 
312  |  | static DecodeStatus decodeBDLAddr12Len8Operand(MCInst *Inst, uint64_t Field,  | 
313  |  |     const unsigned *Regs)  | 
314  | 7.92k  | { | 
315  | 7.92k  |   uint64_t Length = Field >> 16;  | 
316  | 7.92k  |   uint64_t Base = (Field >> 12) & 0xf;  | 
317  | 7.92k  |   uint64_t Disp = Field & 0xfff;  | 
318  |  |   //assert(Length < 256 && "Invalid BDLAddr12Len8");  | 
319  |  |  | 
320  | 7.92k  |   MCOperand_CreateReg0(Inst, Base == 0 ? 0 : Regs[Base]);  | 
321  | 7.92k  |   MCOperand_CreateImm0(Inst, Disp);  | 
322  | 7.92k  |   MCOperand_CreateImm0(Inst, Length + 1);  | 
323  |  |  | 
324  | 7.92k  |   return MCDisassembler_Success;  | 
325  | 7.92k  | }  | 
326  |  |  | 
327  |  | static DecodeStatus decodeBDRAddr12Operand(MCInst *Inst, uint64_t Field,  | 
328  |  |     const unsigned *Regs)  | 
329  | 888  | { | 
330  | 888  |   uint64_t Length = Field >> 16;  | 
331  | 888  |   uint64_t Base = (Field >> 12) & 0xf;  | 
332  | 888  |   uint64_t Disp = Field & 0xfff;  | 
333  |  |   //assert(Length < 16 && "Invalid BDRAddr12");  | 
334  |  |  | 
335  | 888  |   MCOperand_CreateReg0(Inst, Base == 0 ? 0 : Regs[Base]);  | 
336  | 888  |   MCOperand_CreateImm0(Inst, Disp);  | 
337  | 888  |   MCOperand_CreateReg0(Inst, Regs[Length]);  | 
338  |  |  | 
339  | 888  |   return MCDisassembler_Success;  | 
340  | 888  | }  | 
341  |  |  | 
342  |  | static DecodeStatus decodeBDVAddr12Operand(MCInst *Inst, uint64_t Field,  | 
343  |  |     const unsigned *Regs)  | 
344  | 1.07k  | { | 
345  | 1.07k  |   uint64_t Index = Field >> 16;  | 
346  | 1.07k  |   uint64_t Base = (Field >> 12) & 0xf;  | 
347  | 1.07k  |   uint64_t Disp = Field & 0xfff;  | 
348  |  |   //assert(Index < 32 && "Invalid BDVAddr12");  | 
349  |  |  | 
350  | 1.07k  |   MCOperand_CreateReg0(Inst, Base == 0 ? 0 : Regs[Base]);  | 
351  | 1.07k  |   MCOperand_CreateImm0(Inst, Disp);  | 
352  | 1.07k  |   MCOperand_CreateReg0(Inst, SystemZMC_VR128Regs[Index]);  | 
353  |  |  | 
354  | 1.07k  |   return MCDisassembler_Success;  | 
355  | 1.07k  | }  | 
356  |  |  | 
357  |  | static DecodeStatus decodeBDAddr32Disp12Operand(MCInst *Inst, uint64_t Field,  | 
358  |  |     uint64_t Address, const void *Decoder)  | 
359  | 2.38k  | { | 
360  | 2.38k  |   return decodeBDAddr12Operand(Inst, Field, SystemZMC_GR32Regs);  | 
361  | 2.38k  | }  | 
362  |  |  | 
363  |  | static DecodeStatus decodeBDAddr32Disp20Operand(MCInst *Inst, uint64_t Field,  | 
364  |  |     uint64_t Address, const void *Decoder)  | 
365  | 1.19k  | { | 
366  | 1.19k  |   return decodeBDAddr20Operand(Inst, Field, SystemZMC_GR32Regs);  | 
367  | 1.19k  | }  | 
368  |  |  | 
369  |  | static DecodeStatus decodeBDAddr64Disp12Operand(MCInst *Inst, uint64_t Field,  | 
370  |  |     uint64_t Address, const void *Decoder)  | 
371  | 12.0k  | { | 
372  | 12.0k  |   return decodeBDAddr12Operand(Inst, Field, SystemZMC_GR64Regs);  | 
373  | 12.0k  | }  | 
374  |  |  | 
375  |  | static DecodeStatus decodeBDAddr64Disp20Operand(MCInst *Inst, uint64_t Field,  | 
376  |  |     uint64_t Address, const void *Decoder)  | 
377  | 3.67k  | { | 
378  | 3.67k  |   return decodeBDAddr20Operand(Inst, Field, SystemZMC_GR64Regs);  | 
379  | 3.67k  | }  | 
380  |  |  | 
381  |  | static DecodeStatus decodeBDXAddr64Disp12Operand(MCInst *Inst, uint64_t Field,  | 
382  |  |     uint64_t Address, const void *Decoder)  | 
383  | 15.6k  | { | 
384  | 15.6k  |   return decodeBDXAddr12Operand(Inst, Field, SystemZMC_GR64Regs);  | 
385  | 15.6k  | }  | 
386  |  |  | 
387  |  | static DecodeStatus decodeBDXAddr64Disp20Operand(MCInst *Inst, uint64_t Field,  | 
388  |  |     uint64_t Address, const void *Decoder)  | 
389  | 1.27k  | { | 
390  | 1.27k  |   return decodeBDXAddr20Operand(Inst, Field, SystemZMC_GR64Regs);  | 
391  | 1.27k  | }  | 
392  |  |  | 
393  |  | static DecodeStatus decodeBDLAddr64Disp12Len4Operand(MCInst *Inst, uint64_t Field,  | 
394  |  |     uint64_t Address, const void *Decoder)  | 
395  | 4.58k  | { | 
396  | 4.58k  |   return decodeBDLAddr12Len8Operand(Inst, Field, SystemZMC_GR64Regs);  | 
397  | 4.58k  | }  | 
398  |  |  | 
399  |  | static DecodeStatus decodeBDLAddr64Disp12Len8Operand(MCInst *Inst, uint64_t Field,  | 
400  |  |     uint64_t Address, const void *Decoder)  | 
401  | 3.33k  | { | 
402  | 3.33k  |   return decodeBDLAddr12Len8Operand(Inst, Field, SystemZMC_GR64Regs);  | 
403  | 3.33k  | }  | 
404  |  |  | 
405  |  | static DecodeStatus decodeBDRAddr64Disp12Operand(MCInst *Inst, uint64_t Field,  | 
406  |  |     uint64_t Address, const void *Decoder)  | 
407  | 888  | { | 
408  | 888  |   return decodeBDRAddr12Operand(Inst, Field, SystemZMC_GR64Regs);  | 
409  | 888  | }  | 
410  |  |  | 
411  |  | static DecodeStatus decodeBDVAddr64Disp12Operand(MCInst *Inst, uint64_t Field,  | 
412  |  |     uint64_t Address, const void *Decoder)  | 
413  | 1.07k  | { | 
414  | 1.07k  |   return decodeBDVAddr12Operand(Inst, Field, SystemZMC_GR64Regs);  | 
415  | 1.07k  | }  | 
416  |  |  | 
417  |  |  | 
418  |  | #define GET_SUBTARGETINFO_ENUM  | 
419  |  | #include "SystemZGenSubtargetInfo.inc"  | 
420  |  | #include "SystemZGenDisassemblerTables.inc"  | 
421  |  | bool SystemZ_getInstruction(csh ud, const uint8_t *code, size_t code_len, MCInst *MI,  | 
422  |  |     uint16_t *size, uint64_t address, void *info)  | 
423  | 98.7k  | { | 
424  | 98.7k  |   uint64_t Inst;  | 
425  | 98.7k  |   const uint8_t *Table;  | 
426  | 98.7k  |   uint16_t I;   | 
427  |  |  | 
428  |  |   // The top 2 bits of the first byte specify the size.  | 
429  | 98.7k  |   if (*code < 0x40) { | 
430  | 19.0k  |     *size = 2;  | 
431  | 19.0k  |     Table = DecoderTable16;  | 
432  | 79.7k  |   } else if (*code < 0xc0) { | 
433  | 36.0k  |     *size = 4;  | 
434  | 36.0k  |     Table = DecoderTable32;  | 
435  | 43.6k  |   } else { | 
436  | 43.6k  |     *size = 6;  | 
437  | 43.6k  |     Table = DecoderTable48;  | 
438  | 43.6k  |   }  | 
439  |  |  | 
440  | 98.7k  |   if (code_len < *size)  | 
441  |  |     // short of input data  | 
442  | 883  |     return false;  | 
443  |  |  | 
444  | 97.8k  |   if (MI->flat_insn->detail) { | 
445  | 97.8k  |     memset(MI->flat_insn->detail, 0, offsetof(cs_detail, sysz)+sizeof(cs_sysz));  | 
446  | 97.8k  |   }  | 
447  |  |  | 
448  |  |   // Construct the instruction.  | 
449  | 97.8k  |   Inst = 0;  | 
450  | 538k  |   for (I = 0; I < *size; ++I)  | 
451  | 440k  |     Inst = (Inst << 8) | code[I];  | 
452  |  |  | 
453  | 97.8k  |   return decodeInstruction(Table, MI, Inst, address, info, 0);  | 
454  | 98.7k  | }  | 
455  |  |  | 
456  |  | #define GET_REGINFO_ENUM  | 
457  |  | #define GET_REGINFO_MC_DESC  | 
458  |  | #include "SystemZGenRegisterInfo.inc"  | 
459  |  | void SystemZ_init(MCRegisterInfo *MRI)  | 
460  | 3.33k  | { | 
461  |  |   /*  | 
462  |  |   InitMCRegisterInfo(SystemZRegDesc, 98, RA, PC,  | 
463  |  |       SystemZMCRegisterClasses, 12,  | 
464  |  |       SystemZRegUnitRoots,  | 
465  |  |       49,  | 
466  |  |       SystemZRegDiffLists,  | 
467  |  |       SystemZRegStrings,  | 
468  |  |       SystemZSubRegIdxLists,  | 
469  |  |       7,  | 
470  |  |       SystemZSubRegIdxRanges,  | 
471  |  |       SystemZRegEncodingTable);  | 
472  |  |   */  | 
473  |  |  | 
474  | 3.33k  |   MCRegisterInfo_InitMCRegisterInfo(MRI, SystemZRegDesc, 194,  | 
475  | 3.33k  |       0, 0,  | 
476  | 3.33k  |       SystemZMCRegisterClasses, 21,  | 
477  | 3.33k  |       0, 0,  | 
478  | 3.33k  |       SystemZRegDiffLists,  | 
479  | 3.33k  |       0,  | 
480  | 3.33k  |       SystemZSubRegIdxLists, 7,  | 
481  | 3.33k  |       0);  | 
482  | 3.33k  | }  | 
483  |  |  | 
484  |  | #endif  |