Debian Codegraph @

arch/Mips/MipsInstPrinter.c

raw symbols SCIP
1 //===-- MipsInstPrinter.cpp - Convert Mips MCInst to assembly syntax ------===//cxx . . $ `<file>/arch/Mips/MipsInstPrinter.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 // This class prints an Mips MCInst to a .s file.
11 //
12 //===----------------------------------------------------------------------===//
13
14 /* Capstone Disassembly Engine */
15 /* By Nguyen Anh Quynh <[email protected]>, 2013-2015 */
16
17 #ifdef CAPSTONE_HAS_MIPScxx . . $ `<built-in>:415:9`!
18
19 #include <capstone/platform.h>cxx . . $ `<file>/include/capstone/platform.h`/
20 #include <stdlib.h>
21 #include <stdio.h> // debug
22 #include <string.h>
23
24 #include "MipsInstPrinter.h"cxx . . $ `<file>/arch/Mips/MipsInstPrinter.h`/
25 #include "../../MCInst.h"cxx . . $ `<file>/MCInst.h`/
26 #include "../../utils.h"cxx . . $ `<file>/utils.h`/
27 #include "../../SStream.h"cxx . . $ `<file>/SStream.h`/
28 #include "../../MCRegisterInfo.h"cxx . . $ `<file>/MCRegisterInfo.h`/
29 #include "MipsMapping.h"cxx . . $ `<file>/arch/Mips/MipsMapping.h`/
30
31 #include "MipsInstPrinter.h"cxx . . $ `<file>/arch/Mips/MipsInstPrinter.h`/
32
33 static void printUnsignedImmcxx . . $ printUnsignedImm(3697f441d84167e5).(MCInstcxx . . $ MCInst# *MI, int opNum, SStreamcxx . . $ SStream# *O);
34 static char *printAliasInstrcxx . . $ printAliasInstr(880ad24b2950696a).(MCInstcxx . . $ MCInst# *MI, SStreamcxx . . $ SStream# *O, void *info);
35 static char *printAliascxx . . $ printAlias(557cb2fe98621455).(MCInstcxx . . $ MCInst# *MI, SStreamcxx . . $ SStream# *OS);
36
37 // These enumeration declarations were originally in MipsInstrInfo.h but
38 // had to be moved here to avoid circular dependencies between
39 // LLVMMipsCodeGen and LLVMMipsAsmPrinter.
40
41 // Mips Condition Codes
42 typedef enum Mips_CondCodecxx . . $ Mips_CondCode# {
43 // To be used with float branch True
44 Mips_FCOND_Fcxx . . $ Mips_FCOND_F.,
45 Mips_FCOND_UNcxx . . $ Mips_FCOND_UN.,
46 Mips_FCOND_OEQcxx . . $ Mips_FCOND_OEQ.,
47 Mips_FCOND_UEQcxx . . $ Mips_FCOND_UEQ.,
48 Mips_FCOND_OLTcxx . . $ Mips_FCOND_OLT.,
49 Mips_FCOND_ULTcxx . . $ Mips_FCOND_ULT.,
50 Mips_FCOND_OLEcxx . . $ Mips_FCOND_OLE.,
51 Mips_FCOND_ULEcxx . . $ Mips_FCOND_ULE.,
52 Mips_FCOND_SFcxx . . $ Mips_FCOND_SF.,
53 Mips_FCOND_NGLEcxx . . $ Mips_FCOND_NGLE.,
54 Mips_FCOND_SEQcxx . . $ Mips_FCOND_SEQ.,
55 Mips_FCOND_NGLcxx . . $ Mips_FCOND_NGL.,
56 Mips_FCOND_LTcxx . . $ Mips_FCOND_LT.,
57 Mips_FCOND_NGEcxx . . $ Mips_FCOND_NGE.,
58 Mips_FCOND_LEcxx . . $ Mips_FCOND_LE.,
59 Mips_FCOND_NGTcxx . . $ Mips_FCOND_NGT.,
60
61 // To be used with float branch False
62 // This conditions have the same mnemonic as the
63 // above ones, but are used with a branch False;
64 Mips_FCOND_Tcxx . . $ Mips_FCOND_T.,
65 Mips_FCOND_ORcxx . . $ Mips_FCOND_OR.,
66 Mips_FCOND_UNEcxx . . $ Mips_FCOND_UNE.,
67 Mips_FCOND_ONEcxx . . $ Mips_FCOND_ONE.,
68 Mips_FCOND_UGEcxx . . $ Mips_FCOND_UGE.,
69 Mips_FCOND_OGEcxx . . $ Mips_FCOND_OGE.,
70 Mips_FCOND_UGTcxx . . $ Mips_FCOND_UGT.,
71 Mips_FCOND_OGTcxx . . $ Mips_FCOND_OGT.,
72 Mips_FCOND_STcxx . . $ Mips_FCOND_ST.,
73 Mips_FCOND_GLEcxx . . $ Mips_FCOND_GLE.,
74 Mips_FCOND_SNEcxx . . $ Mips_FCOND_SNE.,
75 Mips_FCOND_GLcxx . . $ Mips_FCOND_GL.,
76 Mips_FCOND_NLTcxx . . $ Mips_FCOND_NLT.,
77 Mips_FCOND_GEcxx . . $ Mips_FCOND_GE.,
78 Mips_FCOND_NLEcxx . . $ Mips_FCOND_NLE.,
79 Mips_FCOND_GTcxx . . $ Mips_FCOND_GT.
80 } Mips_CondCodecxx . . $ Mips_CondCode#;
81
82 #define GET_INSTRINFO_ENUMcxx . . $ `arch/Mips/MipsInstPrinter.c:82:9`!
83 #include "MipsGenInstrInfo.inc"cxx . . $ `<file>/arch/Mips/MipsGenInstrInfo.inc`/
84
85 static const char *getRegisterNamecxx . . $ getRegisterName(81a3ae90da26a711).(unsigned RegNo);
86 static void printInstructioncxx . . $ printInstruction(379c3fc2e06d3201).(MCInstcxx . . $ MCInst# *MI, SStreamcxx . . $ SStream# *O, const MCRegisterInfocxx . . $ MCRegisterInfo# *MRI);
87
88 static void set_mem_accesscxx . . $ set_mem_access(512db92e0bcb52df).(MCInstcxx . . $ MCInst# *MI, boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! status)
89 {
90 MI->cshcxx . . $ MCInst#csh.->doing_memcxx . . $ cs_struct#doing_mem. = status;
91
92 if (MI->cshcxx . . $ MCInst#csh.->detailcxx . . $ cs_struct#detail. != CS_OPT_ONcxx . . $ CS_OPT_ON.)
93 return;
94
95 if (status) {
96 MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..operandscxx . . $ cs_mips#operands.[MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..op_countcxx . . $ cs_mips#op_count.].typecxx . . $ cs_mips_op#type. = MIPS_OP_MEMcxx . . $ MIPS_OP_MEM.;
97 MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..operandscxx . . $ cs_mips#operands.[MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..op_countcxx . . $ cs_mips#op_count.].memcxx . . $ cs_mips_op#$anonymous_type_0#mem..basecxx . . $ mips_op_mem#base. = MIPS_REG_INVALIDcxx . . $ MIPS_REG_INVALID.;
98 MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..operandscxx . . $ cs_mips#operands.[MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..op_countcxx . . $ cs_mips#op_count.].memcxx . . $ cs_mips_op#$anonymous_type_0#mem..dispcxx . . $ mips_op_mem#disp. = 0;
99 } else {
100 // done, create the next operand slot
101 MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..op_countcxx . . $ cs_mips#op_count.++;
102 }
103 }
104
105 static boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! isRegcxx . . $ isReg(9c693f20edc875b5).(MCInstcxx . . $ MCInst# *MI, unsigned OpNo, unsigned R)
106 {
107 return (MCOperand_isRegcxx . . $ MCOperand_isReg(8be14e8515538be0).(MCInst_getOperandcxx . . $ MCInst_getOperand(4687f87e75986a5b).(MI, OpNo)) &&
108 MCOperand_getRegcxx . . $ MCOperand_getReg(2f0d38ead81b409a).(MCInst_getOperandcxx . . $ MCInst_getOperand(4687f87e75986a5b).(MI, OpNo)) == R);
109 }
110
111 static const char* MipsFCCToStringcxx . . $ MipsFCCToString(683af83b0800c625).(Mips_CondCodecxx . . $ Mips_CondCode# CC)
112 {
113 switch (CC) {
114 default: return 0; // never reach
115 case Mips_FCOND_Fcxx . . $ Mips_FCOND_F.:
116 case Mips_FCOND_Tcxx . . $ Mips_FCOND_T.: return "f";
117 case Mips_FCOND_UNcxx . . $ Mips_FCOND_UN.:
118 case Mips_FCOND_ORcxx . . $ Mips_FCOND_OR.: return "un";
119 case Mips_FCOND_OEQcxx . . $ Mips_FCOND_OEQ.:
120 case Mips_FCOND_UNEcxx . . $ Mips_FCOND_UNE.: return "eq";
121 case Mips_FCOND_UEQcxx . . $ Mips_FCOND_UEQ.:
122 case Mips_FCOND_ONEcxx . . $ Mips_FCOND_ONE.: return "ueq";
123 case Mips_FCOND_OLTcxx . . $ Mips_FCOND_OLT.:
124 case Mips_FCOND_UGEcxx . . $ Mips_FCOND_UGE.: return "olt";
125 case Mips_FCOND_ULTcxx . . $ Mips_FCOND_ULT.:
126 case Mips_FCOND_OGEcxx . . $ Mips_FCOND_OGE.: return "ult";
127 case Mips_FCOND_OLEcxx . . $ Mips_FCOND_OLE.:
128 case Mips_FCOND_UGTcxx . . $ Mips_FCOND_UGT.: return "ole";
129 case Mips_FCOND_ULEcxx . . $ Mips_FCOND_ULE.:
130 case Mips_FCOND_OGTcxx . . $ Mips_FCOND_OGT.: return "ule";
131 case Mips_FCOND_SFcxx . . $ Mips_FCOND_SF.:
132 case Mips_FCOND_STcxx . . $ Mips_FCOND_ST.: return "sf";
133 case Mips_FCOND_NGLEcxx . . $ Mips_FCOND_NGLE.:
134 case Mips_FCOND_GLEcxx . . $ Mips_FCOND_GLE.: return "ngle";
135 case Mips_FCOND_SEQcxx . . $ Mips_FCOND_SEQ.:
136 case Mips_FCOND_SNEcxx . . $ Mips_FCOND_SNE.: return "seq";
137 case Mips_FCOND_NGLcxx . . $ Mips_FCOND_NGL.:
138 case Mips_FCOND_GLcxx . . $ Mips_FCOND_GL.: return "ngl";
139 case Mips_FCOND_LTcxx . . $ Mips_FCOND_LT.:
140 case Mips_FCOND_NLTcxx . . $ Mips_FCOND_NLT.: return "lt";
141 case Mips_FCOND_NGEcxx . . $ Mips_FCOND_NGE.:
142 case Mips_FCOND_GEcxx . . $ Mips_FCOND_GE.: return "nge";
143 case Mips_FCOND_LEcxx . . $ Mips_FCOND_LE.:
144 case Mips_FCOND_NLEcxx . . $ Mips_FCOND_NLE.: return "le";
145 case Mips_FCOND_NGTcxx . . $ Mips_FCOND_NGT.:
146 case Mips_FCOND_GTcxx . . $ Mips_FCOND_GT.: return "ngt";
147 }
148 }
149
150 static void printRegNamecxx . . $ printRegName(2cfdcacebbcb5657).(SStreamcxx . . $ SStream# *OS, unsigned RegNo)
151 {
152 SStream_concatcxx . . $ SStream_concat(72515e07697b04b4).(OS, "$%s", getRegisterNamecxx . . $ getRegisterName(81a3ae90da26a711).(RegNo));
153 }
154
155 void Mips_printInstcxx . . $ Mips_printInst(6238f66e5ea10f57).(MCInstcxx . . $ MCInst# *MI, SStreamcxx . . $ SStream# *O, void *info)
156 {
157 char *mnem;
158
159 switch (MCInst_getOpcodecxx . . $ MCInst_getOpcode(66549afbf0596d6c).(MI)) {
160 default: break;
161 case Mips_Save16cxx . . $ Mips_Save16.:
162 case Mips_SaveX16cxx . . $ Mips_SaveX16.:
163 case Mips_Restore16cxx . . $ Mips_Restore16.:
164 case Mips_RestoreX16cxx . . $ Mips_RestoreX16.:
165 return;
166 }
167
168 // Try to print any aliases first.
169 mnem = printAliasInstrcxx . . $ printAliasInstr(880ad24b2950696a).(MI, O, info);
170 if (!mnem) {
171 mnem = printAliascxx . . $ printAlias(557cb2fe98621455).(MI, O);
172 if (!mnem) {
173 printInstructioncxx . . $ printInstruction(379c3fc2e06d3201).(MI, O, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
174 }
175 }
176
177 if (mnem) {
178 // fixup instruction id due to the change in alias instruction
179 MCInst_setOpcodePubcxx . . $ MCInst_setOpcodePub(1d3fdd902ae43da2).(MI, Mips_map_insncxx . . $ Mips_map_insn(3a779733ad26660c).(mnem));
180 cs_mem_freecxx . . $ cs_mem_free.(mnem);
181 }
182 }
183
184 static void printOperandcxx . . $ printOperand(2c3fef4aec20445).(MCInstcxx . . $ MCInst# *MI, unsigned OpNo, SStreamcxx . . $ SStream# *O)
185 {
186 MCOperandcxx . . $ MCOperand# *Op;
187
188 if (OpNo >= MI->sizecxx . . $ MCInst#size.)
189 return;
190
191 Op = MCInst_getOperandcxx . . $ MCInst_getOperand(4687f87e75986a5b).(MI, OpNo);
192 if (MCOperand_isRegcxx . . $ MCOperand_isReg(8be14e8515538be0).(Op)) {
193 unsigned int reg = MCOperand_getRegcxx . . $ MCOperand_getReg(2f0d38ead81b409a).(Op);
194 printRegNamecxx . . $ printRegName(2cfdcacebbcb5657).(O, reg);
195 reg = Mips_map_registercxx . . $ Mips_map_register(204837ed41c32f7a).(reg);
196 if (MI->cshcxx . . $ MCInst#csh.->detailcxx . . $ cs_struct#detail.) {
197 if (MI->cshcxx . . $ MCInst#csh.->doing_memcxx . . $ cs_struct#doing_mem.) {
198 MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..operandscxx . . $ cs_mips#operands.[MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..op_countcxx . . $ cs_mips#op_count.].memcxx . . $ cs_mips_op#$anonymous_type_0#mem..basecxx . . $ mips_op_mem#base. = reg;
199 } else {
200 MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..operandscxx . . $ cs_mips#operands.[MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..op_countcxx . . $ cs_mips#op_count.].typecxx . . $ cs_mips_op#type. = MIPS_OP_REGcxx . . $ MIPS_OP_REG.;
201 MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..operandscxx . . $ cs_mips#operands.[MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..op_countcxx . . $ cs_mips#op_count.].regcxx . . $ cs_mips_op#$anonymous_type_0#reg. = reg;
202 MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..op_countcxx . . $ cs_mips#op_count.++;
203 }
204 }
205 } else if (MCOperand_isImmcxx . . $ MCOperand_isImm(8be14e8515538be0).(Op)) {
206 int64_tcxx . . $ int64_t# imm = MCOperand_getImmcxx . . $ MCOperand_getImm(e2e9552a97d88948).(Op);
207 if (MI->cshcxx . . $ MCInst#csh.->doing_memcxx . . $ cs_struct#doing_mem.) {
208 if (imm) { // only print Imm offset if it is not 0
209 printInt64cxx . . $ printInt64(d5b67dadd92627cf).(O, imm);
210 }
211 if (MI->cshcxx . . $ MCInst#csh.->detailcxx . . $ cs_struct#detail.)
212 MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..operandscxx . . $ cs_mips#operands.[MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..op_countcxx . . $ cs_mips#op_count.].memcxx . . $ cs_mips_op#$anonymous_type_0#mem..dispcxx . . $ mips_op_mem#disp. = imm;
213 } else {
214 printInt64cxx . . $ printInt64(d5b67dadd92627cf).(O, imm);
215
216 if (MI->cshcxx . . $ MCInst#csh.->detailcxx . . $ cs_struct#detail.) {
217 MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..operandscxx . . $ cs_mips#operands.[MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..op_countcxx . . $ cs_mips#op_count.].typecxx . . $ cs_mips_op#type. = MIPS_OP_IMMcxx . . $ MIPS_OP_IMM.;
218 MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..operandscxx . . $ cs_mips#operands.[MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..op_countcxx . . $ cs_mips#op_count.].immcxx . . $ cs_mips_op#$anonymous_type_0#imm. = imm;
219 MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..op_countcxx . . $ cs_mips#op_count.++;
220 }
221 }
222 }
223 }
224
225 static void printUnsignedImmcxx . . $ printUnsignedImm(3697f441d84167e5).(MCInstcxx . . $ MCInst# *MI, int opNum, SStreamcxx . . $ SStream# *O)
226 {
227 MCOperandcxx . . $ MCOperand# *MO = MCInst_getOperandcxx . . $ MCInst_getOperand(4687f87e75986a5b).(MI, opNum);
228 if (MCOperand_isImmcxx . . $ MCOperand_isImm(8be14e8515538be0).(MO)) {
229 int64_tcxx . . $ int64_t# imm = MCOperand_getImmcxx . . $ MCOperand_getImm(e2e9552a97d88948).(MO);
230 printInt64cxx . . $ printInt64(d5b67dadd92627cf).(O, imm);
231
232 if (MI->cshcxx . . $ MCInst#csh.->detailcxx . . $ cs_struct#detail.) {
233 MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..operandscxx . . $ cs_mips#operands.[MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..op_countcxx . . $ cs_mips#op_count.].typecxx . . $ cs_mips_op#type. = MIPS_OP_IMMcxx . . $ MIPS_OP_IMM.;
234 MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..operandscxx . . $ cs_mips#operands.[MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..op_countcxx . . $ cs_mips#op_count.].immcxx . . $ cs_mips_op#$anonymous_type_0#imm. = (unsigned short int)imm;
235 MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..op_countcxx . . $ cs_mips#op_count.++;
236 }
237 } else
238 printOperandcxx . . $ printOperand(2c3fef4aec20445).(MI, opNum, O);
239 }
240
241 static void printUnsignedImm8cxx . . $ printUnsignedImm8(3697f441d84167e5).(MCInstcxx . . $ MCInst# *MI, int opNum, SStreamcxx . . $ SStream# *O)
242 {
243 MCOperandcxx . . $ MCOperand# *MO = MCInst_getOperandcxx . . $ MCInst_getOperand(4687f87e75986a5b).(MI, opNum);
244 if (MCOperand_isImmcxx . . $ MCOperand_isImm(8be14e8515538be0).(MO)) {
245 uint8_tcxx . . $ uint8_t# imm = (uint8_tcxx . . $ uint8_t#)MCOperand_getImmcxx . . $ MCOperand_getImm(e2e9552a97d88948).(MO);
246 if (imm > HEX_THRESHOLDcxx . . $ `utils.h:17:9`!)
247 SStream_concatcxx . . $ SStream_concat(72515e07697b04b4).(O, "0x%x", imm);
248 else
249 SStream_concatcxx . . $ SStream_concat(72515e07697b04b4).(O, "%u", imm);
250 if (MI->cshcxx . . $ MCInst#csh.->detailcxx . . $ cs_struct#detail.) {
251 MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..operandscxx . . $ cs_mips#operands.[MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..op_countcxx . . $ cs_mips#op_count.].typecxx . . $ cs_mips_op#type. = MIPS_OP_IMMcxx . . $ MIPS_OP_IMM.;
252 MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..operandscxx . . $ cs_mips#operands.[MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..op_countcxx . . $ cs_mips#op_count.].immcxx . . $ cs_mips_op#$anonymous_type_0#imm. = imm;
253 MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..op_countcxx . . $ cs_mips#op_count.++;
254 }
255 } else
256 printOperandcxx . . $ printOperand(2c3fef4aec20445).(MI, opNum, O);
257 }
258
259 static void printMemOperandcxx . . $ printMemOperand(3697f441d84167e5).(MCInstcxx . . $ MCInst# *MI, int opNum, SStreamcxx . . $ SStream# *O)
260 {
261 // Load/Store memory operands -- imm($reg)
262 // If PIC target the target is loaded as the
263 // pattern lw $25,%call16($28)
264
265 // opNum can be invalid if instruction had reglist as operand.
266 // MemOperand is always last operand of instruction (base + offset).
267 switch (MCInst_getOpcodecxx . . $ MCInst_getOpcode(66549afbf0596d6c).(MI)) {
268 default:
269 break;
270 case Mips_SWM32_MMcxx . . $ Mips_SWM32_MM.:
271 case Mips_LWM32_MMcxx . . $ Mips_LWM32_MM.:
272 case Mips_SWM16_MMcxx . . $ Mips_SWM16_MM.:
273 case Mips_LWM16_MMcxx . . $ Mips_LWM16_MM.:
274 opNum = MCInst_getNumOperandscxx . . $ MCInst_getNumOperands(66549afbf0596d6c).(MI) - 2;
275 break;
276 }
277
278 set_mem_accesscxx . . $ set_mem_access(512db92e0bcb52df).(MI, truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!);
279 printOperandcxx . . $ printOperand(2c3fef4aec20445).(MI, opNum + 1, O);
280 SStream_concat0cxx . . $ SStream_concat0(a720692b9b1c0c27).(O, "(");
281 printOperandcxx . . $ printOperand(2c3fef4aec20445).(MI, opNum, O);
282 SStream_concat0cxx . . $ SStream_concat0(a720692b9b1c0c27).(O, ")");
283 set_mem_accesscxx . . $ set_mem_access(512db92e0bcb52df).(MI, falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!);
284 }
285
286 // TODO???
287 static void printMemOperandEAcxx . . $ printMemOperandEA(3697f441d84167e5).(MCInstcxx . . $ MCInst# *MI, int opNum, SStreamcxx . . $ SStream# *O)
288 {
289 // when using stack locations for not load/store instructions
290 // print the same way as all normal 3 operand instructions.
291 printOperandcxx . . $ printOperand(2c3fef4aec20445).(MI, opNum, O);
292 SStream_concat0cxx . . $ SStream_concat0(a720692b9b1c0c27).(O, ", ");
293 printOperandcxx . . $ printOperand(2c3fef4aec20445).(MI, opNum + 1, O);
294 return;
295 }
296
297 static void printFCCOperandcxx . . $ printFCCOperand(3697f441d84167e5).(MCInstcxx . . $ MCInst# *MI, int opNum, SStreamcxx . . $ SStream# *O)
298 {
299 MCOperandcxx . . $ MCOperand# *MO = MCInst_getOperandcxx . . $ MCInst_getOperand(4687f87e75986a5b).(MI, opNum);
300 SStream_concat0cxx . . $ SStream_concat0(a720692b9b1c0c27).(O, MipsFCCToStringcxx . . $ MipsFCCToString(683af83b0800c625).((Mips_CondCodecxx . . $ Mips_CondCode#)MCOperand_getImmcxx . . $ MCOperand_getImm(e2e9552a97d88948).(MO)));
301 }
302
303 static void printRegisterPaircxx . . $ printRegisterPair(3697f441d84167e5).(MCInstcxx . . $ MCInst# *MI, int opNum, SStreamcxx . . $ SStream# *O)
304 {
305 printRegNamecxx . . $ printRegName(2cfdcacebbcb5657).(O, MCOperand_getRegcxx . . $ MCOperand_getReg(2f0d38ead81b409a).(MCInst_getOperandcxx . . $ MCInst_getOperand(4687f87e75986a5b).(MI, opNum)));
306 }
307
308 static char *printAlias1cxx . . $ printAlias1(573485e88f482750).(const char *Str, MCInstcxx . . $ MCInst# *MI, unsigned OpNo, SStreamcxx . . $ SStream# *OS)
309 {
310 SStream_concatcxx . . $ SStream_concat(72515e07697b04b4).(OS, "%s\t", Str);
311 printOperandcxx . . $ printOperand(2c3fef4aec20445).(MI, OpNo, OS);
312 return cs_strdupcxx . . $ cs_strdup(a8b8e32347182212).(Str);
313 }
314
315 static char *printAlias2cxx . . $ printAlias2(a8a30d2240818f94).(const char *Str, MCInstcxx . . $ MCInst# *MI,
316 unsigned OpNo0, unsigned OpNo1, SStreamcxx . . $ SStream# *OS)
317 {
318 char *tmp;
319
320 tmp = printAlias1cxx . . $ printAlias1(573485e88f482750).(Str, MI, OpNo0, OS);
321 SStream_concat0cxx . . $ SStream_concat0(a720692b9b1c0c27).(OS, ", ");
322 printOperandcxx . . $ printOperand(2c3fef4aec20445).(MI, OpNo1, OS);
323
324 return tmp;
325 }
326
327 #define GET_REGINFO_ENUMcxx . . $ `arch/Mips/MipsInstPrinter.c:327:9`!
328 #include "MipsGenRegisterInfo.inc"cxx . . $ `<file>/arch/Mips/MipsGenRegisterInfo.inc`/
329
330 static char *printAliascxx . . $ printAlias(557cb2fe98621455).(MCInstcxx . . $ MCInst# *MI, SStreamcxx . . $ SStream# *OS)
331 {
332 switch (MCInst_getOpcodecxx . . $ MCInst_getOpcode(66549afbf0596d6c).(MI)) {
333 case Mips_BEQcxx . . $ Mips_BEQ.:
334 case Mips_BEQ_MMcxx . . $ Mips_BEQ_MM.:
335 // beq $zero, $zero, $L2 => b $L2
336 // beq $r0, $zero, $L2 => beqz $r0, $L2
337 if (isRegcxx . . $ isReg(9c693f20edc875b5).(MI, 0, Mips_ZEROcxx . . $ Mips_ZERO.) && isRegcxx . . $ isReg(9c693f20edc875b5).(MI, 1, Mips_ZEROcxx . . $ Mips_ZERO.))
338 return printAlias1cxx . . $ printAlias1(573485e88f482750).("b", MI, 2, OS);
339 if (isRegcxx . . $ isReg(9c693f20edc875b5).(MI, 1, Mips_ZEROcxx . . $ Mips_ZERO.))
340 return printAlias2cxx . . $ printAlias2(a8a30d2240818f94).("beqz", MI, 0, 2, OS);
341 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
342 case Mips_BEQ64cxx . . $ Mips_BEQ64.:
343 // beq $r0, $zero, $L2 => beqz $r0, $L2
344 if (isRegcxx . . $ isReg(9c693f20edc875b5).(MI, 1, Mips_ZERO_64cxx . . $ Mips_ZERO_64.))
345 return printAlias2cxx . . $ printAlias2(a8a30d2240818f94).("beqz", MI, 0, 2, OS);
346 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
347 case Mips_BNEcxx . . $ Mips_BNE.:
348 // bne $r0, $zero, $L2 => bnez $r0, $L2
349 if (isRegcxx . . $ isReg(9c693f20edc875b5).(MI, 1, Mips_ZEROcxx . . $ Mips_ZERO.))
350 return printAlias2cxx . . $ printAlias2(a8a30d2240818f94).("bnez", MI, 0, 2, OS);
351 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
352 case Mips_BNE64cxx . . $ Mips_BNE64.:
353 // bne $r0, $zero, $L2 => bnez $r0, $L2
354 if (isRegcxx . . $ isReg(9c693f20edc875b5).(MI, 1, Mips_ZERO_64cxx . . $ Mips_ZERO_64.))
355 return printAlias2cxx . . $ printAlias2(a8a30d2240818f94).("bnez", MI, 0, 2, OS);
356 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
357 case Mips_BGEZALcxx . . $ Mips_BGEZAL.:
358 // bgezal $zero, $L1 => bal $L1
359 if (isRegcxx . . $ isReg(9c693f20edc875b5).(MI, 0, Mips_ZEROcxx . . $ Mips_ZERO.))
360 return printAlias1cxx . . $ printAlias1(573485e88f482750).("bal", MI, 1, OS);
361 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
362 case Mips_BC1Tcxx . . $ Mips_BC1T.:
363 // bc1t $fcc0, $L1 => bc1t $L1
364 if (isRegcxx . . $ isReg(9c693f20edc875b5).(MI, 0, Mips_FCC0cxx . . $ Mips_FCC0.))
365 return printAlias1cxx . . $ printAlias1(573485e88f482750).("bc1t", MI, 1, OS);
366 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
367 case Mips_BC1Fcxx . . $ Mips_BC1F.:
368 // bc1f $fcc0, $L1 => bc1f $L1
369 if (isRegcxx . . $ isReg(9c693f20edc875b5).(MI, 0, Mips_FCC0cxx . . $ Mips_FCC0.))
370 return printAlias1cxx . . $ printAlias1(573485e88f482750).("bc1f", MI, 1, OS);
371 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
372 case Mips_JALRcxx . . $ Mips_JALR.:
373 // jalr $ra, $r1 => jalr $r1
374 if (isRegcxx . . $ isReg(9c693f20edc875b5).(MI, 0, Mips_RAcxx . . $ Mips_RA.))
375 return printAlias1cxx . . $ printAlias1(573485e88f482750).("jalr", MI, 1, OS);
376 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
377 case Mips_JALR64cxx . . $ Mips_JALR64.:
378 // jalr $ra, $r1 => jalr $r1
379 if (isRegcxx . . $ isReg(9c693f20edc875b5).(MI, 0, Mips_RA_64cxx . . $ Mips_RA_64.))
380 return printAlias1cxx . . $ printAlias1(573485e88f482750).("jalr", MI, 1, OS);
381 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
382 case Mips_NORcxx . . $ Mips_NOR.:
383 case Mips_NOR_MMcxx . . $ Mips_NOR_MM.:
384 // nor $r0, $r1, $zero => not $r0, $r1
385 if (isRegcxx . . $ isReg(9c693f20edc875b5).(MI, 2, Mips_ZEROcxx . . $ Mips_ZERO.))
386 return printAlias2cxx . . $ printAlias2(a8a30d2240818f94).("not", MI, 0, 1, OS);
387 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
388 case Mips_NOR64cxx . . $ Mips_NOR64.:
389 // nor $r0, $r1, $zero => not $r0, $r1
390 if (isRegcxx . . $ isReg(9c693f20edc875b5).(MI, 2, Mips_ZERO_64cxx . . $ Mips_ZERO_64.))
391 return printAlias2cxx . . $ printAlias2(a8a30d2240818f94).("not", MI, 0, 1, OS);
392 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
393 case Mips_ORcxx . . $ Mips_OR.:
394 // or $r0, $r1, $zero => move $r0, $r1
395 if (isRegcxx . . $ isReg(9c693f20edc875b5).(MI, 2, Mips_ZEROcxx . . $ Mips_ZERO.))
396 return printAlias2cxx . . $ printAlias2(a8a30d2240818f94).("move", MI, 0, 1, OS);
397 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
398 default: return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
399 }
400 }
401
402 static void printRegisterListcxx . . $ printRegisterList(3697f441d84167e5).(MCInstcxx . . $ MCInst# *MI, int opNum, SStreamcxx . . $ SStream# *O)
403 {
404 int i, e, reg;
405
406 // - 2 because register List is always first operand of instruction and it is
407 // always followed by memory operand (base + offset).
408 for (i = opNum, e = MCInst_getNumOperandscxx . . $ MCInst_getNumOperands(66549afbf0596d6c).(MI) - 2; i != e; ++i) {
409 if (i != opNum)
410 SStream_concat0cxx . . $ SStream_concat0(a720692b9b1c0c27).(O, ", ");
411 reg = MCOperand_getRegcxx . . $ MCOperand_getReg(2f0d38ead81b409a).(MCInst_getOperandcxx . . $ MCInst_getOperand(4687f87e75986a5b).(MI, i));
412 printRegNamecxx . . $ printRegName(2cfdcacebbcb5657).(O, reg);
413 if (MI->cshcxx . . $ MCInst#csh.->detailcxx . . $ cs_struct#detail.) {
414 MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..operandscxx . . $ cs_mips#operands.[MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..op_countcxx . . $ cs_mips#op_count.].typecxx . . $ cs_mips_op#type. = MIPS_OP_REGcxx . . $ MIPS_OP_REG.;
415 MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..operandscxx . . $ cs_mips#operands.[MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..op_countcxx . . $ cs_mips#op_count.].regcxx . . $ cs_mips_op#$anonymous_type_0#reg. = reg;
416 MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->mipscxx . . $ cs_detail#$anonymous_type_0#mips..op_countcxx . . $ cs_mips#op_count.++;
417 }
418 }
419 }
420
421 #define PRINT_ALIAS_INSTRcxx . . $ `arch/Mips/MipsInstPrinter.c:421:9`!
422 #include "MipsGenAsmWriter.inc"cxx . . $ `<file>/arch/Mips/MipsGenAsmWriter.inc`/
423
424 #endif