/src/capstonenext/arch/Mips/MipsInstPrinter.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* Capstone Disassembly Engine, http://www.capstone-engine.org */ |
2 | | /* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2022, */ |
3 | | /* Rot127 <unisono@quyllur.org> 2022-2023 */ |
4 | | /* Automatically translated source file from LLVM. */ |
5 | | |
6 | | /* LLVM-commit: <commit> */ |
7 | | /* LLVM-tag: <tag> */ |
8 | | |
9 | | /* Only small edits allowed. */ |
10 | | /* For multiple similar edits, please create a Patch for the translator. */ |
11 | | |
12 | | /* Capstone's C++ file translator: */ |
13 | | /* https://github.com/capstone-engine/capstone/tree/next/suite/auto-sync */ |
14 | | |
15 | | //===-- MipsInstPrinter.cpp - Convert Mips MCInst to assembly syntax ------===// |
16 | | // |
17 | | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
18 | | // See https://llvm.org/LICENSE.txt for license information. |
19 | | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
20 | | // |
21 | | //===----------------------------------------------------------------------===// |
22 | | // |
23 | | // This class prints an Mips MCInst to a .s file. |
24 | | // |
25 | | //===----------------------------------------------------------------------===// |
26 | | |
27 | | #include <stdio.h> |
28 | | #include <string.h> |
29 | | #include <stdlib.h> |
30 | | #include <capstone/platform.h> |
31 | | |
32 | | #include "MipsMapping.h" |
33 | | #include "MipsInstPrinter.h" |
34 | | |
35 | | #define GET_SUBTARGETINFO_ENUM |
36 | | #include "MipsGenSubtargetInfo.inc" |
37 | | |
38 | | #define GET_INSTRINFO_ENUM |
39 | | #include "MipsGenInstrInfo.inc" |
40 | | |
41 | | #define GET_REGINFO_ENUM |
42 | | #include "MipsGenRegisterInfo.inc" |
43 | | |
44 | 14.3k | #define CONCAT(a, b) CONCAT_(a, b) |
45 | 14.3k | #define CONCAT_(a, b) a##_##b |
46 | | |
47 | | #define DEBUG_TYPE "asm-printer" |
48 | | |
49 | | #define PRINT_ALIAS_INSTR |
50 | | #include "MipsGenAsmWriter.inc" |
51 | | |
52 | | static bool isReg(const MCInst *MI, unsigned OpNo, unsigned R) |
53 | 6.89k | { |
54 | 6.89k | return MCOperand_getReg(MCInst_getOperand((MCInst *)MI, (OpNo))) == R; |
55 | 6.89k | } |
56 | | |
57 | | static const char *MipsFCCToString(Mips_CondCode CC) |
58 | 0 | { |
59 | 0 | switch (CC) { |
60 | 0 | case Mips_FCOND_F: |
61 | 0 | case Mips_FCOND_T: |
62 | 0 | return "f"; |
63 | 0 | case Mips_FCOND_UN: |
64 | 0 | case Mips_FCOND_OR: |
65 | 0 | return "un"; |
66 | 0 | case Mips_FCOND_OEQ: |
67 | 0 | case Mips_FCOND_UNE: |
68 | 0 | return "eq"; |
69 | 0 | case Mips_FCOND_UEQ: |
70 | 0 | case Mips_FCOND_ONE: |
71 | 0 | return "ueq"; |
72 | 0 | case Mips_FCOND_OLT: |
73 | 0 | case Mips_FCOND_UGE: |
74 | 0 | return "olt"; |
75 | 0 | case Mips_FCOND_ULT: |
76 | 0 | case Mips_FCOND_OGE: |
77 | 0 | return "ult"; |
78 | 0 | case Mips_FCOND_OLE: |
79 | 0 | case Mips_FCOND_UGT: |
80 | 0 | return "ole"; |
81 | 0 | case Mips_FCOND_ULE: |
82 | 0 | case Mips_FCOND_OGT: |
83 | 0 | return "ule"; |
84 | 0 | case Mips_FCOND_SF: |
85 | 0 | case Mips_FCOND_ST: |
86 | 0 | return "sf"; |
87 | 0 | case Mips_FCOND_NGLE: |
88 | 0 | case Mips_FCOND_GLE: |
89 | 0 | return "ngle"; |
90 | 0 | case Mips_FCOND_SEQ: |
91 | 0 | case Mips_FCOND_SNE: |
92 | 0 | return "seq"; |
93 | 0 | case Mips_FCOND_NGL: |
94 | 0 | case Mips_FCOND_GL: |
95 | 0 | return "ngl"; |
96 | 0 | case Mips_FCOND_LT: |
97 | 0 | case Mips_FCOND_NLT: |
98 | 0 | return "lt"; |
99 | 0 | case Mips_FCOND_NGE: |
100 | 0 | case Mips_FCOND_GE: |
101 | 0 | return "nge"; |
102 | 0 | case Mips_FCOND_LE: |
103 | 0 | case Mips_FCOND_NLE: |
104 | 0 | return "le"; |
105 | 0 | case Mips_FCOND_NGT: |
106 | 0 | case Mips_FCOND_GT: |
107 | 0 | return "ngt"; |
108 | 0 | } |
109 | 0 | CS_ASSERT_RET_VAL(0 && "Impossible condition code!", NULL); |
110 | 0 | return ""; |
111 | 0 | } |
112 | | |
113 | | const char *Mips_LLVM_getRegisterName(unsigned RegNo, bool noRegName); |
114 | | |
115 | | static void printRegName(MCInst *MI, SStream *OS, MCRegister Reg) |
116 | 185k | { |
117 | 185k | int syntax_opt = MI->csh->syntax; |
118 | 185k | if (!(syntax_opt & CS_OPT_SYNTAX_NO_DOLLAR)) { |
119 | 185k | SStream_concat1(OS, '$'); |
120 | 185k | } |
121 | 185k | SStream_concat0(OS, Mips_LLVM_getRegisterName(Reg, syntax_opt & CS_OPT_SYNTAX_NOREGNAME)); |
122 | 185k | } |
123 | | |
124 | 102k | static void patch_cs_printer(MCInst *MI, SStream *O) { |
125 | | // replace '# 16 bit inst' to empty. |
126 | 102k | SStream_replc(O, '#', 0); |
127 | 102k | SStream_trimls(O); |
128 | | |
129 | 102k | if (MI->csh->syntax & CS_OPT_SYNTAX_NO_DOLLAR) { |
130 | 0 | char *dollar = strchr(O->buffer, '$'); |
131 | 0 | if (!dollar) { |
132 | 0 | return; |
133 | 0 | } |
134 | 0 | size_t dollar_len = strlen(dollar + 1); |
135 | | // to include `\0` |
136 | 0 | memmove(dollar, dollar + 1, dollar_len + 1); |
137 | 0 | } |
138 | 102k | } |
139 | | |
140 | 461 | static void patch_cs_detail_operand_reg(cs_mips_op *op, unsigned reg, unsigned access) { |
141 | 461 | op->type = MIPS_OP_REG; |
142 | 461 | op->reg = reg; |
143 | 461 | op->is_reglist = false; |
144 | 461 | op->access = access; |
145 | 461 | } |
146 | | |
147 | 102k | static void patch_cs_details(MCInst *MI) { |
148 | 102k | if (!detail_is_set(MI)) |
149 | 0 | return; |
150 | | |
151 | 102k | cs_mips_op *op0 = NULL, *op1 = NULL, *op2 = NULL; |
152 | 102k | unsigned opcode = MCInst_getOpcode(MI); |
153 | 102k | unsigned n_ops = MCInst_getNumOperands(MI); |
154 | | |
155 | 102k | switch(opcode) { |
156 | | /* mips r2 to r5 only 64bit */ |
157 | 38 | case Mips_DSDIV: /// ddiv $$zero, $rs, $rt |
158 | | /* fall-thru */ |
159 | 104 | case Mips_DUDIV: /// ddivu $$zero, $rs, $rt |
160 | 104 | if (n_ops != 2) { |
161 | 0 | return; |
162 | 0 | } |
163 | 104 | Mips_inc_op_count(MI); |
164 | 104 | op0 = Mips_get_detail_op(MI, -3); |
165 | 104 | op1 = Mips_get_detail_op(MI, -2); |
166 | 104 | op2 = Mips_get_detail_op(MI, -1); |
167 | | // move all details by one and add $zero reg |
168 | 104 | *op2 = *op1; |
169 | 104 | *op1 = *op0; |
170 | 104 | patch_cs_detail_operand_reg(op0, MIPS_REG_ZERO_64, CS_AC_WRITE); |
171 | 104 | return; |
172 | | |
173 | | /* mips r2 to r5 only */ |
174 | 18 | case Mips_SDIV: /// div $$zero, $rs, $rt |
175 | | /* fall-thru */ |
176 | 223 | case Mips_UDIV: /// divu $$zero, $rs, $rt |
177 | | /* fall-thru */ |
178 | | /* microMIPS only */ |
179 | 290 | case Mips_SDIV_MM: /// div $$zero, $rs, $rt |
180 | | /* fall-thru */ |
181 | 357 | case Mips_UDIV_MM: /// divu $$zero, $rs, $rt |
182 | | /* fall-thru */ |
183 | | |
184 | | /* MIPS16 only */ |
185 | 357 | case Mips_DivRxRy16: /// div $$zero, $rx, $ry |
186 | | /* fall-thru */ |
187 | 357 | case Mips_DivuRxRy16: /// divu $$zero, $rx, $ry |
188 | 357 | if (n_ops != 2) { |
189 | 0 | return; |
190 | 0 | } |
191 | 357 | Mips_inc_op_count(MI); |
192 | 357 | op0 = Mips_get_detail_op(MI, -3); |
193 | 357 | op1 = Mips_get_detail_op(MI, -2); |
194 | 357 | op2 = Mips_get_detail_op(MI, -1); |
195 | | // move all details by one and add $zero reg |
196 | 357 | *op2 = *op1; |
197 | 357 | *op1 = *op0; |
198 | 357 | patch_cs_detail_operand_reg(op0, MIPS_REG_ZERO, CS_AC_WRITE); |
199 | 357 | return; |
200 | 0 | case Mips_AddiuSpImm16: /// addiu $$sp, imm8 |
201 | | /* fall-thru */ |
202 | 0 | case Mips_AddiuSpImmX16: /// addiu $$sp, imm8 |
203 | 0 | if (n_ops != 1) { |
204 | 0 | return; |
205 | 0 | } |
206 | 0 | Mips_inc_op_count(MI); |
207 | 0 | op0 = Mips_get_detail_op(MI, -2); |
208 | 0 | op1 = Mips_get_detail_op(MI, -1); |
209 | | // move all details by one and add $sp reg |
210 | 0 | *op1 = *op0; |
211 | 0 | patch_cs_detail_operand_reg(op0, MIPS_REG_SP, CS_AC_READ_WRITE); |
212 | 0 | return; |
213 | 0 | case Mips_JrcRa16: /// jrc $ra |
214 | | /* fall-thru */ |
215 | 0 | case Mips_JrRa16: /// jr $ra |
216 | 0 | if (n_ops > 0) { |
217 | 0 | return; |
218 | 0 | } |
219 | 0 | Mips_inc_op_count(MI); |
220 | 0 | op0 = Mips_get_detail_op(MI, -1); |
221 | 0 | patch_cs_detail_operand_reg(op0, MIPS_REG_RA, CS_AC_READ); |
222 | 0 | return; |
223 | 102k | default: |
224 | 102k | return; |
225 | 102k | } |
226 | 102k | } |
227 | | |
228 | 102k | void Mips_LLVM_printInst(MCInst *MI, uint64_t Address, SStream *O) { |
229 | 102k | bool useAliasDetails = map_use_alias_details(MI); |
230 | 102k | if (!useAliasDetails) { |
231 | 0 | SStream_Close(O); |
232 | 0 | printInstruction(MI, Address, O); |
233 | 0 | SStream_Open(O); |
234 | 0 | map_set_fill_detail_ops(MI, false); |
235 | 0 | } |
236 | | |
237 | 102k | if (printAliasInstr(MI, Address, O) || |
238 | 102k | printAlias4(MI, Address, O)) { |
239 | 5.27k | MCInst_setIsAlias(MI, true); |
240 | 97.6k | } else { |
241 | 97.6k | printInstruction(MI, Address, O); |
242 | 97.6k | } |
243 | | |
244 | 102k | patch_cs_printer(MI, O); |
245 | 102k | patch_cs_details(MI); |
246 | | |
247 | 102k | if (!useAliasDetails) { |
248 | 0 | map_set_fill_detail_ops(MI, true); |
249 | 0 | } |
250 | 102k | } |
251 | | |
252 | | void printOperand(MCInst *MI, unsigned OpNo, SStream *O) |
253 | 226k | { |
254 | 226k | switch (MCInst_getOpcode(MI)) { |
255 | 226k | default: |
256 | 226k | break; |
257 | 226k | case Mips_AND16_NM: |
258 | 0 | case Mips_XOR16_NM: |
259 | 0 | case Mips_OR16_NM: |
260 | 0 | if (MCInst_getNumOperands(MI) == 2 && OpNo == 2) |
261 | 0 | OpNo = 0; // rt, rs -> rt, rs, rt |
262 | 0 | break; |
263 | 0 | case Mips_ADDu4x4_NM: |
264 | 0 | case Mips_MUL4x4_NM: |
265 | 0 | if (MCInst_getNumOperands(MI) == 2 && OpNo > 0) |
266 | 0 | OpNo = OpNo - 1; // rt, rs -> rt, rt, rs |
267 | 0 | break; |
268 | 226k | } |
269 | | |
270 | 226k | MCOperand *Op = MCInst_getOperand(MI, (OpNo)); |
271 | 226k | if (MCOperand_isReg(Op)) { |
272 | 180k | add_cs_detail(MI, Mips_OP_GROUP_Operand, OpNo); |
273 | 180k | printRegName(MI, O, MCOperand_getReg(Op)); |
274 | 180k | return; |
275 | 180k | } |
276 | | |
277 | | |
278 | 45.8k | if (MCOperand_isImm(Op)) { |
279 | 45.8k | switch (MCInst_getOpcode(MI)) { |
280 | 0 | case Mips_LI48_NM: |
281 | 0 | case Mips_ANDI16_NM: |
282 | 0 | case Mips_ANDI_NM: |
283 | 0 | case Mips_ORI_NM: |
284 | 0 | case Mips_XORI_NM: |
285 | 0 | case Mips_TEQ_NM: |
286 | 0 | case Mips_TNE_NM: |
287 | 0 | case Mips_SIGRIE_NM: |
288 | 0 | case Mips_SDBBP_NM: |
289 | 0 | case Mips_SDBBP16_NM: |
290 | 0 | case Mips_BREAK_NM: |
291 | 0 | case Mips_BREAK16_NM: |
292 | 0 | case Mips_SYSCALL_NM: |
293 | 0 | case Mips_SYSCALL16_NM: |
294 | 0 | case Mips_WAIT_NM: |
295 | 0 | CONCAT(printUImm, CONCAT(32, 0)) |
296 | 0 | (MI, OpNo, O); |
297 | 0 | break; |
298 | 45.8k | default: |
299 | 45.8k | add_cs_detail(MI, Mips_OP_GROUP_Operand, OpNo); |
300 | 45.8k | printInt64(O, MCOperand_getImm(Op)); |
301 | 45.8k | break; |
302 | 45.8k | } |
303 | 45.8k | return; |
304 | 45.8k | } |
305 | 45.8k | } |
306 | | |
307 | | static void printJumpOperand(MCInst *MI, unsigned OpNo, SStream *O) |
308 | 2.14k | { |
309 | 2.14k | add_cs_detail(MI, Mips_OP_GROUP_JumpOperand, OpNo); |
310 | 2.14k | MCOperand *Op = MCInst_getOperand(MI, (OpNo)); |
311 | 2.14k | if (MCOperand_isReg(Op)) |
312 | 0 | return printRegName(MI, O, MCOperand_getReg(Op)); |
313 | | |
314 | | // only the upper bits are needed. |
315 | 2.14k | uint64_t Base = MI->address & ~0x0fffffffull; |
316 | 2.14k | uint64_t Target = MCOperand_getImm(Op); |
317 | 2.14k | printInt64(O, Base | Target); |
318 | 2.14k | } |
319 | | |
320 | | static void printBranchOperand(MCInst *MI, uint64_t Address, unsigned OpNo, SStream *O) |
321 | 20.6k | { |
322 | 20.6k | add_cs_detail(MI, Mips_OP_GROUP_BranchOperand, OpNo); |
323 | 20.6k | MCOperand *Op = MCInst_getOperand(MI, (OpNo)); |
324 | 20.6k | if (MCOperand_isReg(Op)) |
325 | 531 | return printRegName(MI, O, MCOperand_getReg(Op)); |
326 | | |
327 | 20.0k | uint64_t Target = Address + MCOperand_getImm(Op); |
328 | 20.0k | printInt64(O, Target); |
329 | 20.0k | } |
330 | | |
331 | | #define DEFINE_printUImm(Bits) \ |
332 | | static void CONCAT(printUImm, CONCAT(Bits, 0))(MCInst * MI, int opNum, \ |
333 | | SStream *O) \ |
334 | 13.8k | { \ |
335 | 13.8k | add_cs_detail(MI, CONCAT(Mips_OP_GROUP_UImm, CONCAT(Bits, 0)), opNum); \ |
336 | 13.8k | MCOperand *MO = MCInst_getOperand(MI, (opNum)); \ |
337 | 13.8k | if (MCOperand_isImm(MO)) { \ |
338 | 13.8k | uint64_t Imm = MCOperand_getImm(MO); \ |
339 | 13.8k | Imm &= (((uint64_t)1) << Bits) - 1; \ |
340 | 13.8k | printUInt64(O, Imm); \ |
341 | 13.8k | return; \ |
342 | 13.8k | } \ |
343 | 13.8k | MCOperand *Op = MCInst_getOperand(MI, (opNum)); \ |
344 | 0 | printRegName(MI, O, MCOperand_getReg(Op)); \ |
345 | 0 | } MipsInstPrinter.c:printUImm_10_0 Line | Count | Source | 334 | 1.92k | { \ | 335 | 1.92k | add_cs_detail(MI, CONCAT(Mips_OP_GROUP_UImm, CONCAT(Bits, 0)), opNum); \ | 336 | 1.92k | MCOperand *MO = MCInst_getOperand(MI, (opNum)); \ | 337 | 1.92k | if (MCOperand_isImm(MO)) { \ | 338 | 1.92k | uint64_t Imm = MCOperand_getImm(MO); \ | 339 | 1.92k | Imm &= (((uint64_t)1) << Bits) - 1; \ | 340 | 1.92k | printUInt64(O, Imm); \ | 341 | 1.92k | return; \ | 342 | 1.92k | } \ | 343 | 1.92k | MCOperand *Op = MCInst_getOperand(MI, (opNum)); \ | 344 | 0 | printRegName(MI, O, MCOperand_getReg(Op)); \ | 345 | 0 | } |
MipsInstPrinter.c:printUImm_4_0 Line | Count | Source | 334 | 818 | { \ | 335 | 818 | add_cs_detail(MI, CONCAT(Mips_OP_GROUP_UImm, CONCAT(Bits, 0)), opNum); \ | 336 | 818 | MCOperand *MO = MCInst_getOperand(MI, (opNum)); \ | 337 | 818 | if (MCOperand_isImm(MO)) { \ | 338 | 818 | uint64_t Imm = MCOperand_getImm(MO); \ | 339 | 818 | Imm &= (((uint64_t)1) << Bits) - 1; \ | 340 | 818 | printUInt64(O, Imm); \ | 341 | 818 | return; \ | 342 | 818 | } \ | 343 | 818 | MCOperand *Op = MCInst_getOperand(MI, (opNum)); \ | 344 | 0 | printRegName(MI, O, MCOperand_getReg(Op)); \ | 345 | 0 | } |
MipsInstPrinter.c:printUImm_5_0 Line | Count | Source | 334 | 2.63k | { \ | 335 | 2.63k | add_cs_detail(MI, CONCAT(Mips_OP_GROUP_UImm, CONCAT(Bits, 0)), opNum); \ | 336 | 2.63k | MCOperand *MO = MCInst_getOperand(MI, (opNum)); \ | 337 | 2.63k | if (MCOperand_isImm(MO)) { \ | 338 | 2.63k | uint64_t Imm = MCOperand_getImm(MO); \ | 339 | 2.63k | Imm &= (((uint64_t)1) << Bits) - 1; \ | 340 | 2.63k | printUInt64(O, Imm); \ | 341 | 2.63k | return; \ | 342 | 2.63k | } \ | 343 | 2.63k | MCOperand *Op = MCInst_getOperand(MI, (opNum)); \ | 344 | 0 | printRegName(MI, O, MCOperand_getReg(Op)); \ | 345 | 0 | } |
Unexecuted instantiation: MipsInstPrinter.c:printUImm_26_0 MipsInstPrinter.c:printUImm_8_0 Line | Count | Source | 334 | 396 | { \ | 335 | 396 | add_cs_detail(MI, CONCAT(Mips_OP_GROUP_UImm, CONCAT(Bits, 0)), opNum); \ | 336 | 396 | MCOperand *MO = MCInst_getOperand(MI, (opNum)); \ | 337 | 396 | if (MCOperand_isImm(MO)) { \ | 338 | 396 | uint64_t Imm = MCOperand_getImm(MO); \ | 339 | 396 | Imm &= (((uint64_t)1) << Bits) - 1; \ | 340 | 396 | printUInt64(O, Imm); \ | 341 | 396 | return; \ | 342 | 396 | } \ | 343 | 396 | MCOperand *Op = MCInst_getOperand(MI, (opNum)); \ | 344 | 0 | printRegName(MI, O, MCOperand_getReg(Op)); \ | 345 | 0 | } |
Unexecuted instantiation: MipsInstPrinter.c:printUImm_12_0 MipsInstPrinter.c:printUImm_20_0 Line | Count | Source | 334 | 227 | { \ | 335 | 227 | add_cs_detail(MI, CONCAT(Mips_OP_GROUP_UImm, CONCAT(Bits, 0)), opNum); \ | 336 | 227 | MCOperand *MO = MCInst_getOperand(MI, (opNum)); \ | 337 | 227 | if (MCOperand_isImm(MO)) { \ | 338 | 227 | uint64_t Imm = MCOperand_getImm(MO); \ | 339 | 227 | Imm &= (((uint64_t)1) << Bits) - 1; \ | 340 | 227 | printUInt64(O, Imm); \ | 341 | 227 | return; \ | 342 | 227 | } \ | 343 | 227 | MCOperand *Op = MCInst_getOperand(MI, (opNum)); \ | 344 | 0 | printRegName(MI, O, MCOperand_getReg(Op)); \ | 345 | 0 | } |
MipsInstPrinter.c:printUImm_16_0 Line | Count | Source | 334 | 4.06k | { \ | 335 | 4.06k | add_cs_detail(MI, CONCAT(Mips_OP_GROUP_UImm, CONCAT(Bits, 0)), opNum); \ | 336 | 4.06k | MCOperand *MO = MCInst_getOperand(MI, (opNum)); \ | 337 | 4.06k | if (MCOperand_isImm(MO)) { \ | 338 | 4.06k | uint64_t Imm = MCOperand_getImm(MO); \ | 339 | 4.06k | Imm &= (((uint64_t)1) << Bits) - 1; \ | 340 | 4.06k | printUInt64(O, Imm); \ | 341 | 4.06k | return; \ | 342 | 4.06k | } \ | 343 | 4.06k | MCOperand *Op = MCInst_getOperand(MI, (opNum)); \ | 344 | 0 | printRegName(MI, O, MCOperand_getReg(Op)); \ | 345 | 0 | } |
Unexecuted instantiation: MipsInstPrinter.c:printUImm_32_0 MipsInstPrinter.c:printUImm_7_0 Line | Count | Source | 334 | 306 | { \ | 335 | 306 | add_cs_detail(MI, CONCAT(Mips_OP_GROUP_UImm, CONCAT(Bits, 0)), opNum); \ | 336 | 306 | MCOperand *MO = MCInst_getOperand(MI, (opNum)); \ | 337 | 306 | if (MCOperand_isImm(MO)) { \ | 338 | 306 | uint64_t Imm = MCOperand_getImm(MO); \ | 339 | 306 | Imm &= (((uint64_t)1) << Bits) - 1; \ | 340 | 306 | printUInt64(O, Imm); \ | 341 | 306 | return; \ | 342 | 306 | } \ | 343 | 306 | MCOperand *Op = MCInst_getOperand(MI, (opNum)); \ | 344 | 0 | printRegName(MI, O, MCOperand_getReg(Op)); \ | 345 | 0 | } |
MipsInstPrinter.c:printUImm_2_0 Line | Count | Source | 334 | 784 | { \ | 335 | 784 | add_cs_detail(MI, CONCAT(Mips_OP_GROUP_UImm, CONCAT(Bits, 0)), opNum); \ | 336 | 784 | MCOperand *MO = MCInst_getOperand(MI, (opNum)); \ | 337 | 784 | if (MCOperand_isImm(MO)) { \ | 338 | 784 | uint64_t Imm = MCOperand_getImm(MO); \ | 339 | 784 | Imm &= (((uint64_t)1) << Bits) - 1; \ | 340 | 784 | printUInt64(O, Imm); \ | 341 | 784 | return; \ | 342 | 784 | } \ | 343 | 784 | MCOperand *Op = MCInst_getOperand(MI, (opNum)); \ | 344 | 0 | printRegName(MI, O, MCOperand_getReg(Op)); \ | 345 | 0 | } |
MipsInstPrinter.c:printUImm_1_0 Line | Count | Source | 334 | 403 | { \ | 335 | 403 | add_cs_detail(MI, CONCAT(Mips_OP_GROUP_UImm, CONCAT(Bits, 0)), opNum); \ | 336 | 403 | MCOperand *MO = MCInst_getOperand(MI, (opNum)); \ | 337 | 403 | if (MCOperand_isImm(MO)) { \ | 338 | 403 | uint64_t Imm = MCOperand_getImm(MO); \ | 339 | 403 | Imm &= (((uint64_t)1) << Bits) - 1; \ | 340 | 403 | printUInt64(O, Imm); \ | 341 | 403 | return; \ | 342 | 403 | } \ | 343 | 403 | MCOperand *Op = MCInst_getOperand(MI, (opNum)); \ | 344 | 0 | printRegName(MI, O, MCOperand_getReg(Op)); \ | 345 | 0 | } |
MipsInstPrinter.c:printUImm_3_0 Line | Count | Source | 334 | 1.67k | { \ | 335 | 1.67k | add_cs_detail(MI, CONCAT(Mips_OP_GROUP_UImm, CONCAT(Bits, 0)), opNum); \ | 336 | 1.67k | MCOperand *MO = MCInst_getOperand(MI, (opNum)); \ | 337 | 1.67k | if (MCOperand_isImm(MO)) { \ | 338 | 1.67k | uint64_t Imm = MCOperand_getImm(MO); \ | 339 | 1.67k | Imm &= (((uint64_t)1) << Bits) - 1; \ | 340 | 1.67k | printUInt64(O, Imm); \ | 341 | 1.67k | return; \ | 342 | 1.67k | } \ | 343 | 1.67k | MCOperand *Op = MCInst_getOperand(MI, (opNum)); \ | 344 | 0 | printRegName(MI, O, MCOperand_getReg(Op)); \ | 345 | 0 | } |
MipsInstPrinter.c:printUImm_0_0 Line | Count | Source | 334 | 308 | { \ | 335 | 308 | add_cs_detail(MI, CONCAT(Mips_OP_GROUP_UImm, CONCAT(Bits, 0)), opNum); \ | 336 | 308 | MCOperand *MO = MCInst_getOperand(MI, (opNum)); \ | 337 | 308 | if (MCOperand_isImm(MO)) { \ | 338 | 308 | uint64_t Imm = MCOperand_getImm(MO); \ | 339 | 308 | Imm &= (((uint64_t)1) << Bits) - 1; \ | 340 | 308 | printUInt64(O, Imm); \ | 341 | 308 | return; \ | 342 | 308 | } \ | 343 | 308 | MCOperand *Op = MCInst_getOperand(MI, (opNum)); \ | 344 | 0 | printRegName(MI, O, MCOperand_getReg(Op)); \ | 345 | 0 | } |
MipsInstPrinter.c:printUImm_6_0 Line | Count | Source | 334 | 283 | { \ | 335 | 283 | add_cs_detail(MI, CONCAT(Mips_OP_GROUP_UImm, CONCAT(Bits, 0)), opNum); \ | 336 | 283 | MCOperand *MO = MCInst_getOperand(MI, (opNum)); \ | 337 | 283 | if (MCOperand_isImm(MO)) { \ | 338 | 283 | uint64_t Imm = MCOperand_getImm(MO); \ | 339 | 283 | Imm &= (((uint64_t)1) << Bits) - 1; \ | 340 | 283 | printUInt64(O, Imm); \ | 341 | 283 | return; \ | 342 | 283 | } \ | 343 | 283 | MCOperand *Op = MCInst_getOperand(MI, (opNum)); \ | 344 | 0 | printRegName(MI, O, MCOperand_getReg(Op)); \ | 345 | 0 | } |
|
346 | | |
347 | | #define DEFINE_printUImm_2(Bits, Offset) \ |
348 | | static void CONCAT(printUImm, CONCAT(Bits, Offset))(MCInst * MI, int opNum, \ |
349 | | SStream *O) \ |
350 | 555 | { \ |
351 | 555 | add_cs_detail(MI, CONCAT(Mips_OP_GROUP_UImm, CONCAT(Bits, Offset)), \ |
352 | 555 | opNum); \ |
353 | 555 | MCOperand *MO = MCInst_getOperand(MI, (opNum)); \ |
354 | 555 | if (MCOperand_isImm(MO)) { \ |
355 | 555 | uint64_t Imm = MCOperand_getImm(MO); \ |
356 | 555 | Imm -= Offset; \ |
357 | 555 | Imm &= (1 << Bits) - 1; \ |
358 | 555 | Imm += Offset; \ |
359 | 555 | printUInt64(O, Imm); \ |
360 | 555 | return; \ |
361 | 555 | } \ |
362 | 555 | MCOperand *Op = MCInst_getOperand(MI, (opNum)); \ |
363 | 0 | printRegName(MI, O, MCOperand_getReg(Op)); \ |
364 | 0 | } MipsInstPrinter.c:printUImm_2_1 Line | Count | Source | 350 | 203 | { \ | 351 | 203 | add_cs_detail(MI, CONCAT(Mips_OP_GROUP_UImm, CONCAT(Bits, Offset)), \ | 352 | 203 | opNum); \ | 353 | 203 | MCOperand *MO = MCInst_getOperand(MI, (opNum)); \ | 354 | 203 | if (MCOperand_isImm(MO)) { \ | 355 | 203 | uint64_t Imm = MCOperand_getImm(MO); \ | 356 | 203 | Imm -= Offset; \ | 357 | 203 | Imm &= (1 << Bits) - 1; \ | 358 | 203 | Imm += Offset; \ | 359 | 203 | printUInt64(O, Imm); \ | 360 | 203 | return; \ | 361 | 203 | } \ | 362 | 203 | MCOperand *Op = MCInst_getOperand(MI, (opNum)); \ | 363 | 0 | printRegName(MI, O, MCOperand_getReg(Op)); \ | 364 | 0 | } |
Unexecuted instantiation: MipsInstPrinter.c:printUImm_5_32 MipsInstPrinter.c:printUImm_5_1 Line | Count | Source | 350 | 352 | { \ | 351 | 352 | add_cs_detail(MI, CONCAT(Mips_OP_GROUP_UImm, CONCAT(Bits, Offset)), \ | 352 | 352 | opNum); \ | 353 | 352 | MCOperand *MO = MCInst_getOperand(MI, (opNum)); \ | 354 | 352 | if (MCOperand_isImm(MO)) { \ | 355 | 352 | uint64_t Imm = MCOperand_getImm(MO); \ | 356 | 352 | Imm -= Offset; \ | 357 | 352 | Imm &= (1 << Bits) - 1; \ | 358 | 352 | Imm += Offset; \ | 359 | 352 | printUInt64(O, Imm); \ | 360 | 352 | return; \ | 361 | 352 | } \ | 362 | 352 | MCOperand *Op = MCInst_getOperand(MI, (opNum)); \ | 363 | 0 | printRegName(MI, O, MCOperand_getReg(Op)); \ | 364 | 0 | } |
Unexecuted instantiation: MipsInstPrinter.c:printUImm_6_1 Unexecuted instantiation: MipsInstPrinter.c:printUImm_5_33 Unexecuted instantiation: MipsInstPrinter.c:printUImm_6_2 |
365 | | |
366 | | DEFINE_printUImm(0); |
367 | | DEFINE_printUImm(1); |
368 | | DEFINE_printUImm(10); |
369 | | DEFINE_printUImm(12); |
370 | | DEFINE_printUImm(16); |
371 | | DEFINE_printUImm(2); |
372 | | DEFINE_printUImm(20); |
373 | | DEFINE_printUImm(26); |
374 | | DEFINE_printUImm(3); |
375 | | DEFINE_printUImm(32); |
376 | | DEFINE_printUImm(4); |
377 | | DEFINE_printUImm(5); |
378 | | DEFINE_printUImm(6); |
379 | | DEFINE_printUImm(7); |
380 | | DEFINE_printUImm(8); |
381 | | DEFINE_printUImm_2(2, 1); |
382 | | DEFINE_printUImm_2(5, 1); |
383 | | DEFINE_printUImm_2(5, 32); |
384 | | DEFINE_printUImm_2(5, 33); |
385 | | DEFINE_printUImm_2(6, 1); |
386 | | DEFINE_printUImm_2(6, 2); |
387 | | |
388 | | static void printMemOperand(MCInst *MI, int opNum, SStream *O) |
389 | 30.2k | { |
390 | | // Load/Store memory operands -- imm($reg) |
391 | | // If PIC target the target is loaded as the |
392 | | // pattern lw $25,%call16($28) |
393 | | |
394 | | // opNum can be invalid if instruction had reglist as operand. |
395 | | // MemOperand is always last operand of instruction (base + offset). |
396 | 30.2k | switch (MCInst_getOpcode(MI)) { |
397 | 29.0k | default: |
398 | 29.0k | break; |
399 | 29.0k | case Mips_SWM32_MM: |
400 | 214 | case Mips_LWM32_MM: |
401 | 577 | case Mips_SWM16_MM: |
402 | 906 | case Mips_SWM16_MMR6: |
403 | 1.12k | case Mips_LWM16_MM: |
404 | 1.23k | case Mips_LWM16_MMR6: |
405 | 1.23k | opNum = MCInst_getNumOperands(MI) - 2; |
406 | 1.23k | break; |
407 | 30.2k | } |
408 | | |
409 | 30.2k | set_mem_access(MI, true); |
410 | | // Index register is encoded as immediate value |
411 | | // in case of nanoMIPS indexed instructions |
412 | 30.2k | switch (MCInst_getOpcode(MI)) { |
413 | | // No offset needed for paired LL/SC |
414 | 0 | case Mips_LLWP_NM: |
415 | 0 | case Mips_SCWP_NM: |
416 | 0 | break; |
417 | 0 | case Mips_LWX_NM: |
418 | 0 | case Mips_LWXS_NM: |
419 | 0 | case Mips_LWXS16_NM: |
420 | 0 | case Mips_LBX_NM: |
421 | 0 | case Mips_LBUX_NM: |
422 | 0 | case Mips_LHX_NM: |
423 | 0 | case Mips_LHUX_NM: |
424 | 0 | case Mips_LHXS_NM: |
425 | 0 | case Mips_LHUXS_NM: |
426 | 0 | case Mips_SWX_NM: |
427 | 0 | case Mips_SWXS_NM: |
428 | 0 | case Mips_SBX_NM: |
429 | 0 | case Mips_SHX_NM: |
430 | 0 | case Mips_SHXS_NM: |
431 | 0 | if (!MCOperand_isReg(MCInst_getOperand(MI, (opNum + 1)))) { |
432 | 0 | add_cs_detail(MI, Mips_OP_GROUP_MemOperand, (opNum + 1)); |
433 | 0 | printRegName(MI, O, MCOperand_getImm(MCInst_getOperand( |
434 | 0 | MI, (opNum + 1)))); |
435 | 0 | break; |
436 | 0 | } |
437 | | // Fall through |
438 | 30.2k | default: |
439 | 30.2k | printOperand((MCInst *)MI, opNum + 1, O); |
440 | 30.2k | break; |
441 | 30.2k | } |
442 | 30.2k | SStream_concat0(O, "("); |
443 | 30.2k | printOperand((MCInst *)MI, opNum, O); |
444 | 30.2k | SStream_concat0(O, ")"); |
445 | 30.2k | set_mem_access(MI, false); |
446 | 30.2k | } |
447 | | |
448 | | static void printMemOperandEA(MCInst *MI, int opNum, SStream *O) |
449 | 0 | { |
450 | | // when using stack locations for not load/store instructions |
451 | | // print the same way as all normal 3 operand instructions. |
452 | 0 | printOperand((MCInst *)MI, opNum, O); |
453 | 0 | SStream_concat0(O, ", "); |
454 | 0 | printOperand((MCInst *)MI, opNum + 1, O); |
455 | 0 | } |
456 | | |
457 | | static void printFCCOperand(MCInst *MI, int opNum, SStream *O) |
458 | 0 | { |
459 | 0 | MCOperand *MO = MCInst_getOperand(MI, (opNum)); |
460 | 0 | SStream_concat0(O, |
461 | 0 | MipsFCCToString((Mips_CondCode)MCOperand_getImm(MO))); |
462 | 0 | } |
463 | | |
464 | | static bool printAlias(const char *Str, const MCInst *MI, uint64_t Address, |
465 | | unsigned OpNo, SStream *OS, bool IsBranch) |
466 | 829 | { |
467 | 829 | SStream_concat(OS, "%s%s", "\t", Str); |
468 | 829 | SStream_concat0(OS, "\t"); |
469 | 829 | if (IsBranch) |
470 | 607 | printBranchOperand((MCInst *)MI, Address, OpNo, OS); |
471 | 222 | else |
472 | 222 | printOperand((MCInst *)MI, OpNo, OS); |
473 | 829 | return true; |
474 | 829 | } |
475 | | |
476 | | static bool printAlias2(const char *Str, const MCInst *MI, uint64_t Address, |
477 | | unsigned OpNo0, unsigned OpNo1, SStream *OS, bool IsBranch) |
478 | 683 | { |
479 | 683 | printAlias(Str, MI, Address, OpNo0, OS, IsBranch); |
480 | 683 | SStream_concat0(OS, ", "); |
481 | 683 | if (IsBranch) |
482 | 531 | printBranchOperand((MCInst *)MI, Address, OpNo1, OS); |
483 | 152 | else |
484 | 152 | printOperand((MCInst *)MI, OpNo1, OS); |
485 | 683 | return true; |
486 | 683 | } |
487 | | |
488 | | static bool printAlias3(const char *Str, const MCInst *MI, uint64_t Address, |
489 | | unsigned OpNo0, unsigned OpNo1, unsigned OpNo2, SStream *OS) |
490 | 0 | { |
491 | 0 | printAlias(Str, MI, Address, OpNo0, OS, false); |
492 | 0 | SStream_concat0(OS, ", "); |
493 | 0 | printOperand((MCInst *)MI, OpNo1, OS); |
494 | 0 | SStream_concat0(OS, ", "); |
495 | 0 | printOperand((MCInst *)MI, OpNo2, OS); |
496 | 0 | return true; |
497 | 0 | } |
498 | | |
499 | | static bool printAlias4(const MCInst *MI, uint64_t Address, SStream *OS) |
500 | 98.4k | { |
501 | 98.4k | switch (MCInst_getOpcode(MI)) { |
502 | 1.76k | case Mips_BEQ: |
503 | 2.00k | case Mips_BEQ_MM: |
504 | | // beq $zero, $zero, $L2 => b $L2 |
505 | | // beq $r0, $zero, $L2 => beqz $r0, $L2 |
506 | 2.00k | return (isReg(MI, 0, Mips_ZERO) && |
507 | 2.00k | isReg(MI, 1, Mips_ZERO) && |
508 | 2.00k | printAlias("b", MI, Address, 2, OS, true)) || |
509 | 2.00k | (isReg(MI, 1, Mips_ZERO) && |
510 | 1.92k | printAlias2("beqz", MI, Address, 0, 2, OS, true)); |
511 | 0 | case Mips_BEQ64: |
512 | | // beq $r0, $zero, $L2 => beqz $r0, $L2 |
513 | 0 | return isReg(MI, 1, Mips_ZERO_64) && |
514 | 0 | printAlias2("beqz", MI, Address, 0, 2, OS, true); |
515 | 836 | case Mips_BNE: |
516 | 1.06k | case Mips_BNE_MM: |
517 | | // bne $r0, $zero, $L2 => bnez $r0, $L2 |
518 | 1.06k | return isReg(MI, 1, Mips_ZERO) && |
519 | 1.06k | printAlias2("bnez", MI, Address, 0, 2, OS, true); |
520 | 0 | case Mips_BNE64: |
521 | | // bne $r0, $zero, $L2 => bnez $r0, $L2 |
522 | 0 | return isReg(MI, 1, Mips_ZERO_64) && |
523 | 0 | printAlias2("bnez", MI, Address, 0, 2, OS, true); |
524 | 439 | case Mips_BGEZAL: |
525 | | // bgezal $zero, $L1 => bal $L1 |
526 | 439 | return isReg(MI, 0, Mips_ZERO) && |
527 | 439 | printAlias("bal", MI, Address, 1, OS, true); |
528 | 203 | case Mips_BC1T: |
529 | | // bc1t $fcc0, $L1 => bc1t $L1 |
530 | 203 | return isReg(MI, 0, Mips_FCC0) && |
531 | 203 | printAlias("bc1t", MI, Address, 1, OS, true); |
532 | 203 | case Mips_BC1F: |
533 | | // bc1f $fcc0, $L1 => bc1f $L1 |
534 | 203 | return isReg(MI, 0, Mips_FCC0) && |
535 | 203 | printAlias("bc1f", MI, Address, 1, OS, true); |
536 | 148 | case Mips_JALR: |
537 | | // jalr $zero, $r1 => jr $r1 |
538 | | // jalr $ra, $r1 => jalr $r1 |
539 | 148 | return (isReg(MI, 0, Mips_ZERO) && |
540 | 148 | printAlias("jr", MI, Address, 1, OS, false)) || |
541 | 148 | (isReg(MI, 0, Mips_RA) && |
542 | 97 | printAlias("jalr", MI, Address, 1, OS, false)); |
543 | 0 | case Mips_JALR64: |
544 | | // jalr $zero, $r1 => jr $r1 |
545 | | // jalr $ra, $r1 => jalr $r1 |
546 | 0 | return (isReg(MI, 0, Mips_ZERO_64) && |
547 | 0 | printAlias("jr", MI, Address, 1, OS, false)) || |
548 | 0 | (isReg(MI, 0, Mips_RA_64) && |
549 | 0 | printAlias("jalr", MI, Address, 1, OS, false)); |
550 | 338 | case Mips_NOR: |
551 | 374 | case Mips_NOR_MM: |
552 | 408 | case Mips_NOR_MMR6: |
553 | | // nor $r0, $r1, $zero => not $r0, $r1 |
554 | 408 | return isReg(MI, 2, Mips_ZERO) && |
555 | 408 | printAlias2("not", MI, Address, 0, 1, OS, false); |
556 | 0 | case Mips_NOR64: |
557 | | // nor $r0, $r1, $zero => not $r0, $r1 |
558 | 0 | return isReg(MI, 2, Mips_ZERO_64) && |
559 | 0 | printAlias2("not", MI, Address, 0, 1, OS, false); |
560 | 66 | case Mips_OR: |
561 | 118 | case Mips_ADDu: |
562 | | // or $r0, $r1, $zero => move $r0, $r1 |
563 | | // addu $r0, $r1, $zero => move $r0, $r1 |
564 | 118 | return isReg(MI, 2, Mips_ZERO) && |
565 | 118 | printAlias2("move", MI, Address, 0, 1, OS, false); |
566 | 0 | case Mips_LI48_NM: |
567 | 0 | case Mips_LI16_NM: |
568 | | // li[16/48] $r0, imm => li $r0, imm |
569 | 0 | return printAlias2("li", MI, Address, 0, 1, OS, false); |
570 | 0 | case Mips_ADDIU_NM: |
571 | 0 | case Mips_ADDIUNEG_NM: |
572 | 0 | if (isReg(MI, 1, Mips_ZERO_NM)) |
573 | 0 | return printAlias2("li", MI, Address, 0, 2, OS, false); |
574 | 0 | else |
575 | 0 | return printAlias3("addiu", MI, Address, 0, 1, 2, OS); |
576 | 0 | case Mips_ADDIU48_NM: |
577 | 0 | case Mips_ADDIURS5_NM: |
578 | 0 | case Mips_ADDIUR1SP_NM: |
579 | 0 | case Mips_ADDIUR2_NM: |
580 | 0 | case Mips_ADDIUGPB_NM: |
581 | 0 | case Mips_ADDIUGPW_NM: |
582 | 0 | return printAlias3("addiu", MI, Address, 0, 1, 2, OS); |
583 | 0 | case Mips_ANDI16_NM: |
584 | 0 | case Mips_ANDI_NM: |
585 | | // andi[16/32] $r0, $r1, imm => andi $r0, $r1, imm |
586 | 0 | return printAlias3("andi", MI, Address, 0, 1, 2, OS); |
587 | 93.8k | default: |
588 | 93.8k | return false; |
589 | 98.4k | } |
590 | 98.4k | } |
591 | | |
592 | | static void printRegisterList(MCInst *MI, int opNum, SStream *O) |
593 | 1.23k | { |
594 | | // - 2 because register List is always first operand of instruction and it is |
595 | | // always followed by memory operand (base + offset). |
596 | 1.23k | add_cs_detail(MI, Mips_OP_GROUP_RegisterList, opNum); |
597 | 5.73k | for (int i = opNum, e = MCInst_getNumOperands(MI) - 2; i != e; ++i) { |
598 | 4.50k | if (i != opNum) |
599 | 3.27k | SStream_concat0(O, ", "); |
600 | 4.50k | printRegName(MI, O, MCOperand_getReg(MCInst_getOperand(MI, (i)))); |
601 | 4.50k | } |
602 | 1.23k | } |
603 | | |
604 | | static void printNanoMipsRegisterList(MCInst *MI, int OpNum, SStream *O) |
605 | 0 | { |
606 | 0 | add_cs_detail(MI, Mips_OP_GROUP_NanoMipsRegisterList, OpNum); |
607 | 0 | for (unsigned I = OpNum; I < MCInst_getNumOperands(MI); I++) { |
608 | 0 | SStream_concat0(O, ", "); |
609 | 0 | printRegName(MI, O, MCOperand_getReg(MCInst_getOperand(MI, (I)))); |
610 | 0 | } |
611 | 0 | } |
612 | | |
613 | | static void printHi20(MCInst *MI, int OpNum, SStream *O) |
614 | 0 | { |
615 | 0 | MCOperand *MO = MCInst_getOperand(MI, (OpNum)); |
616 | 0 | if (MCOperand_isImm(MO)) { |
617 | 0 | add_cs_detail(MI, Mips_OP_GROUP_Hi20, OpNum); |
618 | 0 | SStream_concat0(O, "%hi("); |
619 | 0 | printUInt64(O, MCOperand_getImm(MO)); |
620 | 0 | SStream_concat0(O, ")"); |
621 | 0 | } else |
622 | 0 | printOperand(MI, OpNum, O); |
623 | 0 | } |
624 | | |
625 | | static void printHi20PCRel(MCInst *MI, uint64_t Address, int OpNum, SStream *O) |
626 | 0 | { |
627 | 0 | MCOperand *MO = MCInst_getOperand(MI, (OpNum)); |
628 | 0 | if (MCOperand_isImm(MO)) { |
629 | 0 | add_cs_detail(MI, Mips_OP_GROUP_Hi20PCRel, OpNum); |
630 | 0 | SStream_concat0(O, "%pcrel_hi("); |
631 | 0 | printUInt64(O, MCOperand_getImm(MO) + Address); |
632 | 0 | SStream_concat0(O, ")"); |
633 | 0 | } else |
634 | 0 | printOperand(MI, OpNum, O); |
635 | 0 | } |
636 | | |
637 | | static void printPCRel(MCInst *MI, uint64_t Address, int OpNum, SStream *O) |
638 | 0 | { |
639 | 0 | MCOperand *MO = MCInst_getOperand(MI, (OpNum)); |
640 | 0 | if (MCOperand_isImm(MO)) { |
641 | 0 | add_cs_detail(MI, Mips_OP_GROUP_PCRel, OpNum); |
642 | 0 | printUInt64(O, MCOperand_getImm(MO) + Address); |
643 | 0 | } |
644 | 0 | else |
645 | 0 | printOperand(MI, OpNum, O); |
646 | 0 | } |
647 | | |
648 | | const char *Mips_LLVM_getRegisterName(unsigned RegNo, bool noRegName) |
649 | 210k | { |
650 | 210k | if (!RegNo || RegNo >= MIPS_REG_ENDING) { |
651 | 0 | return NULL; |
652 | 0 | } |
653 | 210k | if (noRegName) { |
654 | 0 | return getRegisterName(RegNo); |
655 | 0 | } |
656 | 210k | switch(RegNo) { |
657 | 21.6k | case MIPS_REG_AT: |
658 | 22.3k | case MIPS_REG_AT_64: |
659 | 22.3k | return "at"; |
660 | 6.15k | case MIPS_REG_A0: |
661 | 6.37k | case MIPS_REG_A0_64: |
662 | 6.37k | return "a0"; |
663 | 5.29k | case MIPS_REG_A1: |
664 | 5.60k | case MIPS_REG_A1_64: |
665 | 5.60k | return "a1"; |
666 | 10.2k | case MIPS_REG_A2: |
667 | 10.5k | case MIPS_REG_A2_64: |
668 | 10.5k | return "a2"; |
669 | 6.68k | case MIPS_REG_A3: |
670 | 7.09k | case MIPS_REG_A3_64: |
671 | 7.09k | return "a3"; |
672 | 2.03k | case MIPS_REG_K0: |
673 | 2.12k | case MIPS_REG_K0_64: |
674 | 2.12k | return "k0"; |
675 | 3.26k | case MIPS_REG_K1: |
676 | 3.82k | case MIPS_REG_K1_64: |
677 | 3.82k | return "k1"; |
678 | 12.6k | case MIPS_REG_S0: |
679 | 13.0k | case MIPS_REG_S0_64: |
680 | 13.0k | return "s0"; |
681 | 5.58k | case MIPS_REG_S1: |
682 | 5.86k | case MIPS_REG_S1_64: |
683 | 5.86k | return "s1"; |
684 | 2.98k | case MIPS_REG_S2: |
685 | 3.29k | case MIPS_REG_S2_64: |
686 | 3.29k | return "s2"; |
687 | 3.85k | case MIPS_REG_S3: |
688 | 4.53k | case MIPS_REG_S3_64: |
689 | 4.53k | return "s3"; |
690 | 2.67k | case MIPS_REG_S4: |
691 | 2.78k | case MIPS_REG_S4_64: |
692 | 2.78k | return "s4"; |
693 | 1.51k | case MIPS_REG_S5: |
694 | 1.66k | case MIPS_REG_S5_64: |
695 | 1.66k | return "s5"; |
696 | 2.91k | case MIPS_REG_S6: |
697 | 3.12k | case MIPS_REG_S6_64: |
698 | 3.12k | return "s6"; |
699 | 2.02k | case MIPS_REG_S7: |
700 | 2.13k | case MIPS_REG_S7_64: |
701 | 2.13k | return "s7"; |
702 | 3.11k | case MIPS_REG_T0: |
703 | 3.42k | case MIPS_REG_T0_64: |
704 | 3.42k | return "t0"; |
705 | 2.67k | case MIPS_REG_T1: |
706 | 2.94k | case MIPS_REG_T1_64: |
707 | 2.94k | return "t1"; |
708 | 3.16k | case MIPS_REG_T2: |
709 | 3.44k | case MIPS_REG_T2_64: |
710 | 3.44k | return "t2"; |
711 | 1.41k | case MIPS_REG_T3: |
712 | 2.08k | case MIPS_REG_T3_64: |
713 | 2.08k | return "t3"; |
714 | 1.67k | case MIPS_REG_T4: |
715 | 1.97k | case MIPS_REG_T4_64: |
716 | 1.97k | return "t4"; |
717 | 3.42k | case MIPS_REG_T5: |
718 | 3.76k | case MIPS_REG_T5_64: |
719 | 3.76k | return "t5"; |
720 | 1.29k | case MIPS_REG_T6: |
721 | 1.60k | case MIPS_REG_T6_64: |
722 | 1.60k | return "t6"; |
723 | 2.38k | case MIPS_REG_T7: |
724 | 2.74k | case MIPS_REG_T7_64: |
725 | 2.74k | return "t7"; |
726 | 4.05k | case MIPS_REG_T8: |
727 | 4.49k | case MIPS_REG_T8_64: |
728 | 4.49k | return "t8"; |
729 | 2.52k | case MIPS_REG_T9: |
730 | 2.66k | case MIPS_REG_T9_64: |
731 | 2.66k | return "t9"; |
732 | 7.23k | case MIPS_REG_V0: |
733 | 7.62k | case MIPS_REG_V0_64: |
734 | 7.62k | return "v0"; |
735 | 5.86k | case MIPS_REG_V1: |
736 | 6.35k | case MIPS_REG_V1_64: |
737 | 6.35k | return "v1"; |
738 | 73.1k | default: |
739 | 73.1k | return getRegisterName(RegNo); |
740 | 210k | } |
741 | 210k | } |