blob: fc12d46c237b384fb38b34700e20d86aa82c32f8 [file] [log] [blame]
Chris Lattnerfd603822009-10-19 19:56:26 +00001//===-- ARMInstPrinter.cpp - Convert ARM MCInst to assembly syntax --------===//
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 ARM MCInst to a .s file.
11//
12//===----------------------------------------------------------------------===//
13
14#define DEBUG_TYPE "asm-printer"
Jim Grosbachd8be4102010-09-15 19:27:50 +000015#include "ARMBaseInfo.h"
Chris Lattnerfd603822009-10-19 19:56:26 +000016#include "ARMInstPrinter.h"
Evan Chengee04a6d2011-07-20 23:34:39 +000017#include "MCTargetDesc/ARMAddressingModes.h"
Chris Lattnerfd603822009-10-19 19:56:26 +000018#include "llvm/MC/MCInst.h"
Chris Lattner61d35c22009-10-19 21:21:39 +000019#include "llvm/MC/MCAsmInfo.h"
Chris Lattner6f997762009-10-19 21:53:00 +000020#include "llvm/MC/MCExpr.h"
Johnny Chenc7b65912010-04-16 22:40:20 +000021#include "llvm/ADT/StringExtras.h"
Chris Lattner6f997762009-10-19 21:53:00 +000022#include "llvm/Support/raw_ostream.h"
Chris Lattnerfd603822009-10-19 19:56:26 +000023using namespace llvm;
24
Chris Lattner6274ec42010-10-28 21:37:33 +000025#define GET_INSTRUCTION_NAME
Chris Lattnerfd603822009-10-19 19:56:26 +000026#include "ARMGenAsmWriter.inc"
Chris Lattnerfd603822009-10-19 19:56:26 +000027
Chris Lattner6274ec42010-10-28 21:37:33 +000028StringRef ARMInstPrinter::getOpcodeName(unsigned Opcode) const {
29 return getInstructionName(Opcode);
30}
31
Rafael Espindolacde4ce42011-06-02 02:34:55 +000032void ARMInstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const {
33 OS << getRegisterName(RegNo);
Anton Korobeynikov57caad72011-03-05 18:43:32 +000034}
Chris Lattner6274ec42010-10-28 21:37:33 +000035
Chris Lattnerd3740872010-04-04 05:04:31 +000036void ARMInstPrinter::printInst(const MCInst *MI, raw_ostream &O) {
Bill Wendling04863d02010-11-13 10:40:19 +000037 unsigned Opcode = MI->getOpcode();
38
Johnny Chen9e088762010-03-17 17:52:21 +000039 // Check for MOVs and print canonical forms, instead.
Bill Wendling04863d02010-11-13 10:40:19 +000040 if (Opcode == ARM::MOVs) {
Jim Grosbache6be85e2010-09-17 22:36:38 +000041 // FIXME: Thumb variants?
Johnny Chen9e088762010-03-17 17:52:21 +000042 const MCOperand &Dst = MI->getOperand(0);
43 const MCOperand &MO1 = MI->getOperand(1);
44 const MCOperand &MO2 = MI->getOperand(2);
45 const MCOperand &MO3 = MI->getOperand(3);
46
47 O << '\t' << ARM_AM::getShiftOpcStr(ARM_AM::getSORegShOp(MO3.getImm()));
Chris Lattner35c33bd2010-04-04 04:47:45 +000048 printSBitModifierOperand(MI, 6, O);
49 printPredicateOperand(MI, 4, O);
Johnny Chen9e088762010-03-17 17:52:21 +000050
51 O << '\t' << getRegisterName(Dst.getReg())
52 << ", " << getRegisterName(MO1.getReg());
53
54 if (ARM_AM::getSORegShOp(MO3.getImm()) == ARM_AM::rrx)
55 return;
56
57 O << ", ";
58
59 if (MO2.getReg()) {
60 O << getRegisterName(MO2.getReg());
61 assert(ARM_AM::getSORegOffset(MO3.getImm()) == 0);
62 } else {
63 O << "#" << ARM_AM::getSORegOffset(MO3.getImm());
64 }
65 return;
66 }
67
68 // A8.6.123 PUSH
Bill Wendling73fe34a2010-11-16 01:16:36 +000069 if ((Opcode == ARM::STMDB_UPD || Opcode == ARM::t2STMDB_UPD) &&
Johnny Chen9e088762010-03-17 17:52:21 +000070 MI->getOperand(0).getReg() == ARM::SP) {
Bill Wendling73fe34a2010-11-16 01:16:36 +000071 O << '\t' << "push";
72 printPredicateOperand(MI, 2, O);
Jim Grosbach41ad0c42010-12-03 20:33:01 +000073 if (Opcode == ARM::t2STMDB_UPD)
74 O << ".w";
Bill Wendling73fe34a2010-11-16 01:16:36 +000075 O << '\t';
76 printRegisterList(MI, 4, O);
77 return;
Johnny Chen9e088762010-03-17 17:52:21 +000078 }
79
80 // A8.6.122 POP
Bill Wendling73fe34a2010-11-16 01:16:36 +000081 if ((Opcode == ARM::LDMIA_UPD || Opcode == ARM::t2LDMIA_UPD) &&
Johnny Chen9e088762010-03-17 17:52:21 +000082 MI->getOperand(0).getReg() == ARM::SP) {
Bill Wendling73fe34a2010-11-16 01:16:36 +000083 O << '\t' << "pop";
84 printPredicateOperand(MI, 2, O);
Jim Grosbach41ad0c42010-12-03 20:33:01 +000085 if (Opcode == ARM::t2LDMIA_UPD)
86 O << ".w";
Bill Wendling73fe34a2010-11-16 01:16:36 +000087 O << '\t';
88 printRegisterList(MI, 4, O);
89 return;
Johnny Chen9e088762010-03-17 17:52:21 +000090 }
91
92 // A8.6.355 VPUSH
Bill Wendling73fe34a2010-11-16 01:16:36 +000093 if ((Opcode == ARM::VSTMSDB_UPD || Opcode == ARM::VSTMDDB_UPD) &&
Johnny Chen9e088762010-03-17 17:52:21 +000094 MI->getOperand(0).getReg() == ARM::SP) {
Bill Wendling73fe34a2010-11-16 01:16:36 +000095 O << '\t' << "vpush";
96 printPredicateOperand(MI, 2, O);
97 O << '\t';
98 printRegisterList(MI, 4, O);
99 return;
Johnny Chen9e088762010-03-17 17:52:21 +0000100 }
101
102 // A8.6.354 VPOP
Bill Wendling73fe34a2010-11-16 01:16:36 +0000103 if ((Opcode == ARM::VLDMSIA_UPD || Opcode == ARM::VLDMDIA_UPD) &&
Johnny Chen9e088762010-03-17 17:52:21 +0000104 MI->getOperand(0).getReg() == ARM::SP) {
Bill Wendling73fe34a2010-11-16 01:16:36 +0000105 O << '\t' << "vpop";
106 printPredicateOperand(MI, 2, O);
107 O << '\t';
108 printRegisterList(MI, 4, O);
109 return;
Johnny Chen9e088762010-03-17 17:52:21 +0000110 }
111
Owen Anderson565a0362011-07-18 23:25:34 +0000112 if (Opcode == ARM::tLDMIA || Opcode == ARM::tSTMIA) {
113 bool Writeback = true;
114 unsigned BaseReg = MI->getOperand(0).getReg();
115 for (unsigned i = 3; i < MI->getNumOperands(); ++i) {
116 if (MI->getOperand(i).getReg() == BaseReg)
117 Writeback = false;
118 }
119
120 if (Opcode == ARM::tLDMIA)
121 O << "\tldmia";
122 else if (Opcode == ARM::tSTMIA)
123 O << "\tstmia";
124 else
125 llvm_unreachable("Unknown opcode!");
126
127 printPredicateOperand(MI, 1, O);
128 O << '\t' << getRegisterName(BaseReg);
129 if (Writeback) O << "!";
130 O << ", ";
131 printRegisterList(MI, 3, O);
132 return;
133 }
134
Chris Lattner35c33bd2010-04-04 04:47:45 +0000135 printInstruction(MI, O);
Bill Wendling04863d02010-11-13 10:40:19 +0000136}
Chris Lattnerfd603822009-10-19 19:56:26 +0000137
Chris Lattner8bc86cb2009-10-19 20:59:55 +0000138void ARMInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
Jim Grosbach0a2287b2010-11-03 01:11:15 +0000139 raw_ostream &O) {
Chris Lattner8bc86cb2009-10-19 20:59:55 +0000140 const MCOperand &Op = MI->getOperand(OpNo);
141 if (Op.isReg()) {
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000142 unsigned Reg = Op.getReg();
Jim Grosbach35636282010-10-06 21:22:32 +0000143 O << getRegisterName(Reg);
Chris Lattner8bc86cb2009-10-19 20:59:55 +0000144 } else if (Op.isImm()) {
145 O << '#' << Op.getImm();
146 } else {
147 assert(Op.isExpr() && "unknown operand kind in printOperand");
Chris Lattner8cb9a3b2010-01-18 00:37:40 +0000148 O << *Op.getExpr();
Chris Lattner8bc86cb2009-10-19 20:59:55 +0000149 }
150}
Chris Lattner61d35c22009-10-19 21:21:39 +0000151
Chris Lattner017d9472009-10-20 00:40:56 +0000152// so_reg is a 4-operand unit corresponding to register forms of the A5.1
153// "Addressing Mode 1 - Data-processing operands" forms. This includes:
154// REG 0 0 - e.g. R5
155// REG REG 0,SH_OPC - e.g. R5, ROR R3
156// REG 0 IMM,SH_OPC - e.g. R5, LSL #3
Chris Lattner35c33bd2010-04-04 04:47:45 +0000157void ARMInstPrinter::printSORegOperand(const MCInst *MI, unsigned OpNum,
158 raw_ostream &O) {
Chris Lattner017d9472009-10-20 00:40:56 +0000159 const MCOperand &MO1 = MI->getOperand(OpNum);
160 const MCOperand &MO2 = MI->getOperand(OpNum+1);
161 const MCOperand &MO3 = MI->getOperand(OpNum+2);
Jim Grosbach15d78982010-09-14 22:27:15 +0000162
Chris Lattner017d9472009-10-20 00:40:56 +0000163 O << getRegisterName(MO1.getReg());
Jim Grosbach15d78982010-09-14 22:27:15 +0000164
Chris Lattner017d9472009-10-20 00:40:56 +0000165 // Print the shift opc.
Bob Wilson1d9125a2010-08-05 00:34:42 +0000166 ARM_AM::ShiftOpc ShOpc = ARM_AM::getSORegShOp(MO3.getImm());
167 O << ", " << ARM_AM::getShiftOpcStr(ShOpc);
Jim Grosbache8606dc2011-07-13 17:50:29 +0000168 if (ShOpc == ARM_AM::rrx)
169 return;
Chris Lattner017d9472009-10-20 00:40:56 +0000170 if (MO2.getReg()) {
Bob Wilson1d9125a2010-08-05 00:34:42 +0000171 O << ' ' << getRegisterName(MO2.getReg());
Chris Lattner017d9472009-10-20 00:40:56 +0000172 assert(ARM_AM::getSORegOffset(MO3.getImm()) == 0);
Bob Wilson1d9125a2010-08-05 00:34:42 +0000173 } else if (ShOpc != ARM_AM::rrx) {
174 O << " #" << ARM_AM::getSORegOffset(MO3.getImm());
Chris Lattner017d9472009-10-20 00:40:56 +0000175 }
176}
Chris Lattner084f87d2009-10-19 21:57:05 +0000177
Bruno Cardoso Lopesac79e4c2011-04-04 17:18:19 +0000178//===--------------------------------------------------------------------===//
179// Addressing Mode #2
180//===--------------------------------------------------------------------===//
181
Bruno Cardoso Lopesae085542011-03-31 23:26:08 +0000182void ARMInstPrinter::printAM2PreOrOffsetIndexOp(const MCInst *MI, unsigned Op,
183 raw_ostream &O) {
Chris Lattner084f87d2009-10-19 21:57:05 +0000184 const MCOperand &MO1 = MI->getOperand(Op);
185 const MCOperand &MO2 = MI->getOperand(Op+1);
186 const MCOperand &MO3 = MI->getOperand(Op+2);
Jim Grosbach15d78982010-09-14 22:27:15 +0000187
Chris Lattner084f87d2009-10-19 21:57:05 +0000188 O << "[" << getRegisterName(MO1.getReg());
Jim Grosbach15d78982010-09-14 22:27:15 +0000189
Chris Lattner084f87d2009-10-19 21:57:05 +0000190 if (!MO2.getReg()) {
Johnny Chen9e088762010-03-17 17:52:21 +0000191 if (ARM_AM::getAM2Offset(MO3.getImm())) // Don't print +0.
Chris Lattner084f87d2009-10-19 21:57:05 +0000192 O << ", #"
Johnny Chen9e088762010-03-17 17:52:21 +0000193 << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO3.getImm()))
194 << ARM_AM::getAM2Offset(MO3.getImm());
Chris Lattner084f87d2009-10-19 21:57:05 +0000195 O << "]";
196 return;
197 }
Jim Grosbach15d78982010-09-14 22:27:15 +0000198
Chris Lattner084f87d2009-10-19 21:57:05 +0000199 O << ", "
Johnny Chen9e088762010-03-17 17:52:21 +0000200 << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO3.getImm()))
201 << getRegisterName(MO2.getReg());
Jim Grosbach15d78982010-09-14 22:27:15 +0000202
Chris Lattner084f87d2009-10-19 21:57:05 +0000203 if (unsigned ShImm = ARM_AM::getAM2Offset(MO3.getImm()))
204 O << ", "
205 << ARM_AM::getShiftOpcStr(ARM_AM::getAM2ShiftOpc(MO3.getImm()))
206 << " #" << ShImm;
207 O << "]";
Jim Grosbach15d78982010-09-14 22:27:15 +0000208}
Chris Lattnere306d8d2009-10-19 22:09:23 +0000209
Bruno Cardoso Lopesae085542011-03-31 23:26:08 +0000210void ARMInstPrinter::printAM2PostIndexOp(const MCInst *MI, unsigned Op,
211 raw_ostream &O) {
212 const MCOperand &MO1 = MI->getOperand(Op);
213 const MCOperand &MO2 = MI->getOperand(Op+1);
214 const MCOperand &MO3 = MI->getOperand(Op+2);
215
216 O << "[" << getRegisterName(MO1.getReg()) << "], ";
217
218 if (!MO2.getReg()) {
219 unsigned ImmOffs = ARM_AM::getAM2Offset(MO3.getImm());
220 O << '#'
221 << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO3.getImm()))
222 << ImmOffs;
223 return;
224 }
225
226 O << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO3.getImm()))
227 << getRegisterName(MO2.getReg());
228
229 if (unsigned ShImm = ARM_AM::getAM2Offset(MO3.getImm()))
230 O << ", "
231 << ARM_AM::getShiftOpcStr(ARM_AM::getAM2ShiftOpc(MO3.getImm()))
232 << " #" << ShImm;
233}
234
235void ARMInstPrinter::printAddrMode2Operand(const MCInst *MI, unsigned Op,
236 raw_ostream &O) {
237 const MCOperand &MO1 = MI->getOperand(Op);
238
239 if (!MO1.isReg()) { // FIXME: This is for CP entries, but isn't right.
240 printOperand(MI, Op, O);
241 return;
242 }
243
244 const MCOperand &MO3 = MI->getOperand(Op+2);
245 unsigned IdxMode = ARM_AM::getAM2IdxMode(MO3.getImm());
246
247 if (IdxMode == ARMII::IndexModePost) {
248 printAM2PostIndexOp(MI, Op, O);
249 return;
250 }
251 printAM2PreOrOffsetIndexOp(MI, Op, O);
252}
253
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000254void ARMInstPrinter::printAddrMode2OffsetOperand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000255 unsigned OpNum,
256 raw_ostream &O) {
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000257 const MCOperand &MO1 = MI->getOperand(OpNum);
258 const MCOperand &MO2 = MI->getOperand(OpNum+1);
Jim Grosbach15d78982010-09-14 22:27:15 +0000259
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000260 if (!MO1.getReg()) {
261 unsigned ImmOffs = ARM_AM::getAM2Offset(MO2.getImm());
Johnny Chen9e088762010-03-17 17:52:21 +0000262 O << '#'
263 << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO2.getImm()))
264 << ImmOffs;
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000265 return;
266 }
Jim Grosbach15d78982010-09-14 22:27:15 +0000267
Johnny Chen9e088762010-03-17 17:52:21 +0000268 O << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO2.getImm()))
269 << getRegisterName(MO1.getReg());
Jim Grosbach15d78982010-09-14 22:27:15 +0000270
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000271 if (unsigned ShImm = ARM_AM::getAM2Offset(MO2.getImm()))
272 O << ", "
273 << ARM_AM::getShiftOpcStr(ARM_AM::getAM2ShiftOpc(MO2.getImm()))
274 << " #" << ShImm;
275}
276
Bruno Cardoso Lopesac79e4c2011-04-04 17:18:19 +0000277//===--------------------------------------------------------------------===//
278// Addressing Mode #3
279//===--------------------------------------------------------------------===//
280
281void ARMInstPrinter::printAM3PostIndexOp(const MCInst *MI, unsigned Op,
282 raw_ostream &O) {
283 const MCOperand &MO1 = MI->getOperand(Op);
284 const MCOperand &MO2 = MI->getOperand(Op+1);
285 const MCOperand &MO3 = MI->getOperand(Op+2);
286
287 O << "[" << getRegisterName(MO1.getReg()) << "], ";
288
289 if (MO2.getReg()) {
290 O << (char)ARM_AM::getAM3Op(MO3.getImm())
291 << getRegisterName(MO2.getReg());
292 return;
293 }
294
295 unsigned ImmOffs = ARM_AM::getAM3Offset(MO3.getImm());
296 O << '#'
297 << ARM_AM::getAddrOpcStr(ARM_AM::getAM3Op(MO3.getImm()))
298 << ImmOffs;
299}
300
301void ARMInstPrinter::printAM3PreOrOffsetIndexOp(const MCInst *MI, unsigned Op,
302 raw_ostream &O) {
303 const MCOperand &MO1 = MI->getOperand(Op);
304 const MCOperand &MO2 = MI->getOperand(Op+1);
305 const MCOperand &MO3 = MI->getOperand(Op+2);
Jim Grosbach15d78982010-09-14 22:27:15 +0000306
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000307 O << '[' << getRegisterName(MO1.getReg());
Jim Grosbach15d78982010-09-14 22:27:15 +0000308
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000309 if (MO2.getReg()) {
310 O << ", " << (char)ARM_AM::getAM3Op(MO3.getImm())
311 << getRegisterName(MO2.getReg()) << ']';
312 return;
313 }
Jim Grosbach15d78982010-09-14 22:27:15 +0000314
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000315 if (unsigned ImmOffs = ARM_AM::getAM3Offset(MO3.getImm()))
316 O << ", #"
Johnny Chen9e088762010-03-17 17:52:21 +0000317 << ARM_AM::getAddrOpcStr(ARM_AM::getAM3Op(MO3.getImm()))
318 << ImmOffs;
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000319 O << ']';
320}
321
Bruno Cardoso Lopesac79e4c2011-04-04 17:18:19 +0000322void ARMInstPrinter::printAddrMode3Operand(const MCInst *MI, unsigned Op,
323 raw_ostream &O) {
324 const MCOperand &MO3 = MI->getOperand(Op+2);
325 unsigned IdxMode = ARM_AM::getAM3IdxMode(MO3.getImm());
326
327 if (IdxMode == ARMII::IndexModePost) {
328 printAM3PostIndexOp(MI, Op, O);
329 return;
330 }
331 printAM3PreOrOffsetIndexOp(MI, Op, O);
332}
333
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000334void ARMInstPrinter::printAddrMode3OffsetOperand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000335 unsigned OpNum,
336 raw_ostream &O) {
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000337 const MCOperand &MO1 = MI->getOperand(OpNum);
338 const MCOperand &MO2 = MI->getOperand(OpNum+1);
Jim Grosbach15d78982010-09-14 22:27:15 +0000339
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000340 if (MO1.getReg()) {
341 O << (char)ARM_AM::getAM3Op(MO2.getImm())
342 << getRegisterName(MO1.getReg());
343 return;
344 }
Jim Grosbach15d78982010-09-14 22:27:15 +0000345
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000346 unsigned ImmOffs = ARM_AM::getAM3Offset(MO2.getImm());
Johnny Chen9e088762010-03-17 17:52:21 +0000347 O << '#'
348 << ARM_AM::getAddrOpcStr(ARM_AM::getAM3Op(MO2.getImm()))
349 << ImmOffs;
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000350}
351
Jim Grosbache6913602010-11-03 01:01:43 +0000352void ARMInstPrinter::printLdStmModeOperand(const MCInst *MI, unsigned OpNum,
Jim Grosbach0a2287b2010-11-03 01:11:15 +0000353 raw_ostream &O) {
Jim Grosbache6913602010-11-03 01:01:43 +0000354 ARM_AM::AMSubMode Mode = ARM_AM::getAM4SubMode(MI->getOperand(OpNum)
355 .getImm());
356 O << ARM_AM::getAMSubModeStr(Mode);
Chris Lattnere306d8d2009-10-19 22:09:23 +0000357}
358
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000359void ARMInstPrinter::printAddrMode5Operand(const MCInst *MI, unsigned OpNum,
Jim Grosbach0a2287b2010-11-03 01:11:15 +0000360 raw_ostream &O) {
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000361 const MCOperand &MO1 = MI->getOperand(OpNum);
362 const MCOperand &MO2 = MI->getOperand(OpNum+1);
Jim Grosbach15d78982010-09-14 22:27:15 +0000363
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000364 if (!MO1.isReg()) { // FIXME: This is for CP entries, but isn't right.
Chris Lattner35c33bd2010-04-04 04:47:45 +0000365 printOperand(MI, OpNum, O);
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000366 return;
367 }
Jim Grosbach15d78982010-09-14 22:27:15 +0000368
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000369 O << "[" << getRegisterName(MO1.getReg());
Jim Grosbach15d78982010-09-14 22:27:15 +0000370
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000371 if (unsigned ImmOffs = ARM_AM::getAM5Offset(MO2.getImm())) {
372 O << ", #"
Johnny Chen9e088762010-03-17 17:52:21 +0000373 << ARM_AM::getAddrOpcStr(ARM_AM::getAM5Op(MO2.getImm()))
Bill Wendling92b5a2e2010-11-03 01:49:29 +0000374 << ImmOffs * 4;
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000375 }
376 O << "]";
377}
378
Chris Lattner35c33bd2010-04-04 04:47:45 +0000379void ARMInstPrinter::printAddrMode6Operand(const MCInst *MI, unsigned OpNum,
380 raw_ostream &O) {
Chris Lattner235e2f62009-10-20 06:22:33 +0000381 const MCOperand &MO1 = MI->getOperand(OpNum);
382 const MCOperand &MO2 = MI->getOperand(OpNum+1);
Jim Grosbach15d78982010-09-14 22:27:15 +0000383
Bob Wilson226036e2010-03-20 22:13:40 +0000384 O << "[" << getRegisterName(MO1.getReg());
385 if (MO2.getImm()) {
386 // FIXME: Both darwin as and GNU as violate ARM docs here.
Bob Wilson273ff312010-07-14 23:54:43 +0000387 O << ", :" << (MO2.getImm() << 3);
Chris Lattner235e2f62009-10-20 06:22:33 +0000388 }
Bob Wilson226036e2010-03-20 22:13:40 +0000389 O << "]";
390}
391
Bruno Cardoso Lopes505f3cd2011-03-24 21:04:58 +0000392void ARMInstPrinter::printAddrMode7Operand(const MCInst *MI, unsigned OpNum,
393 raw_ostream &O) {
394 const MCOperand &MO1 = MI->getOperand(OpNum);
395 O << "[" << getRegisterName(MO1.getReg()) << "]";
396}
397
Bob Wilson226036e2010-03-20 22:13:40 +0000398void ARMInstPrinter::printAddrMode6OffsetOperand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000399 unsigned OpNum,
400 raw_ostream &O) {
Bob Wilson226036e2010-03-20 22:13:40 +0000401 const MCOperand &MO = MI->getOperand(OpNum);
402 if (MO.getReg() == 0)
403 O << "!";
404 else
405 O << ", " << getRegisterName(MO.getReg());
Chris Lattner235e2f62009-10-20 06:22:33 +0000406}
407
Bob Wilsoneaf1c982010-08-11 23:10:46 +0000408void ARMInstPrinter::printBitfieldInvMaskImmOperand(const MCInst *MI,
409 unsigned OpNum,
410 raw_ostream &O) {
Chris Lattner235e2f62009-10-20 06:22:33 +0000411 const MCOperand &MO = MI->getOperand(OpNum);
412 uint32_t v = ~MO.getImm();
413 int32_t lsb = CountTrailingZeros_32(v);
414 int32_t width = (32 - CountLeadingZeros_32 (v)) - lsb;
415 assert(MO.isImm() && "Not a valid bf_inv_mask_imm value!");
416 O << '#' << lsb << ", #" << width;
417}
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000418
Johnny Chen1adc40c2010-08-12 20:46:17 +0000419void ARMInstPrinter::printMemBOption(const MCInst *MI, unsigned OpNum,
420 raw_ostream &O) {
421 unsigned val = MI->getOperand(OpNum).getImm();
422 O << ARM_MB::MemBOptToString(val);
423}
424
Bob Wilson22f5dc72010-08-16 18:27:34 +0000425void ARMInstPrinter::printShiftImmOperand(const MCInst *MI, unsigned OpNum,
Bob Wilsoneaf1c982010-08-11 23:10:46 +0000426 raw_ostream &O) {
427 unsigned ShiftOp = MI->getOperand(OpNum).getImm();
428 ARM_AM::ShiftOpc Opc = ARM_AM::getSORegShOp(ShiftOp);
429 switch (Opc) {
430 case ARM_AM::no_shift:
431 return;
432 case ARM_AM::lsl:
433 O << ", lsl #";
434 break;
435 case ARM_AM::asr:
436 O << ", asr #";
437 break;
438 default:
Bob Wilson22f5dc72010-08-16 18:27:34 +0000439 assert(0 && "unexpected shift opcode for shift immediate operand");
Bob Wilsoneaf1c982010-08-11 23:10:46 +0000440 }
441 O << ARM_AM::getSORegOffset(ShiftOp);
442}
443
Jim Grosbachdde038a2011-07-20 21:40:26 +0000444void ARMInstPrinter::printPKHLSLShiftImm(const MCInst *MI, unsigned OpNum,
445 raw_ostream &O) {
446 unsigned Imm = MI->getOperand(OpNum).getImm();
447 if (Imm == 0)
448 return;
449 assert(Imm > 0 && Imm < 32 && "Invalid PKH shift immediate value!");
450 O << ", lsl #" << Imm;
451}
452
453void ARMInstPrinter::printPKHASRShiftImm(const MCInst *MI, unsigned OpNum,
454 raw_ostream &O) {
455 unsigned Imm = MI->getOperand(OpNum).getImm();
456 // A shift amount of 32 is encoded as 0.
457 if (Imm == 0)
458 Imm = 32;
459 assert(Imm > 0 && Imm <= 32 && "Invalid PKH shift immediate value!");
460 O << ", asr #" << Imm;
461}
462
Chris Lattner35c33bd2010-04-04 04:47:45 +0000463void ARMInstPrinter::printRegisterList(const MCInst *MI, unsigned OpNum,
464 raw_ostream &O) {
Chris Lattnere306d8d2009-10-19 22:09:23 +0000465 O << "{";
Johnny Chen9e088762010-03-17 17:52:21 +0000466 for (unsigned i = OpNum, e = MI->getNumOperands(); i != e; ++i) {
467 if (i != OpNum) O << ", ";
Chris Lattnere306d8d2009-10-19 22:09:23 +0000468 O << getRegisterName(MI->getOperand(i).getReg());
469 }
470 O << "}";
471}
Chris Lattner4d152222009-10-19 22:23:04 +0000472
Jim Grosbachb3af5de2010-10-13 21:00:04 +0000473void ARMInstPrinter::printSetendOperand(const MCInst *MI, unsigned OpNum,
474 raw_ostream &O) {
475 const MCOperand &Op = MI->getOperand(OpNum);
476 if (Op.getImm())
477 O << "be";
478 else
479 O << "le";
480}
481
Bruno Cardoso Lopesa2b6e412011-02-14 13:09:44 +0000482void ARMInstPrinter::printCPSIMod(const MCInst *MI, unsigned OpNum,
483 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000484 const MCOperand &Op = MI->getOperand(OpNum);
Bruno Cardoso Lopesa2b6e412011-02-14 13:09:44 +0000485 O << ARM_PROC::IModToString(Op.getImm());
486}
487
488void ARMInstPrinter::printCPSIFlag(const MCInst *MI, unsigned OpNum,
489 raw_ostream &O) {
490 const MCOperand &Op = MI->getOperand(OpNum);
491 unsigned IFlags = Op.getImm();
492 for (int i=2; i >= 0; --i)
493 if (IFlags & (1 << i))
494 O << ARM_PROC::IFlagsToString(1 << i);
Johnny Chen9e088762010-03-17 17:52:21 +0000495}
496
Chris Lattner35c33bd2010-04-04 04:47:45 +0000497void ARMInstPrinter::printMSRMaskOperand(const MCInst *MI, unsigned OpNum,
498 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000499 const MCOperand &Op = MI->getOperand(OpNum);
Bruno Cardoso Lopes584bf7b2011-02-18 19:45:59 +0000500 unsigned SpecRegRBit = Op.getImm() >> 4;
501 unsigned Mask = Op.getImm() & 0xf;
502
Jim Grosbachb29b4dd2011-07-19 22:45:10 +0000503 // As special cases, CPSR_f, CPSR_s and CPSR_fs prefer printing as
504 // APSR_nzcvq, APSR_g and APSRnzcvqg, respectively.
505 if (!SpecRegRBit && (Mask == 8 || Mask == 4 || Mask == 12)) {
506 O << "APSR_";
507 switch (Mask) {
508 default: assert(0);
509 case 4: O << "g"; return;
510 case 8: O << "nzcvq"; return;
511 case 12: O << "nzcvqg"; return;
512 }
513 llvm_unreachable("Unexpected mask value!");
514 }
515
Bruno Cardoso Lopes584bf7b2011-02-18 19:45:59 +0000516 if (SpecRegRBit)
Jim Grosbachb29b4dd2011-07-19 22:45:10 +0000517 O << "SPSR";
Bruno Cardoso Lopes584bf7b2011-02-18 19:45:59 +0000518 else
Jim Grosbachb29b4dd2011-07-19 22:45:10 +0000519 O << "CPSR";
Bruno Cardoso Lopes584bf7b2011-02-18 19:45:59 +0000520
Johnny Chen9e088762010-03-17 17:52:21 +0000521 if (Mask) {
522 O << '_';
523 if (Mask & 8) O << 'f';
524 if (Mask & 4) O << 's';
525 if (Mask & 2) O << 'x';
526 if (Mask & 1) O << 'c';
527 }
528}
529
Chris Lattner35c33bd2010-04-04 04:47:45 +0000530void ARMInstPrinter::printPredicateOperand(const MCInst *MI, unsigned OpNum,
531 raw_ostream &O) {
Chris Lattner413ae252009-10-20 00:42:49 +0000532 ARMCC::CondCodes CC = (ARMCC::CondCodes)MI->getOperand(OpNum).getImm();
533 if (CC != ARMCC::AL)
534 O << ARMCondCodeToString(CC);
535}
536
Jim Grosbach15d78982010-09-14 22:27:15 +0000537void ARMInstPrinter::printMandatoryPredicateOperand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000538 unsigned OpNum,
539 raw_ostream &O) {
Johnny Chen9d3acaa2010-03-02 17:57:15 +0000540 ARMCC::CondCodes CC = (ARMCC::CondCodes)MI->getOperand(OpNum).getImm();
541 O << ARMCondCodeToString(CC);
542}
543
Chris Lattner35c33bd2010-04-04 04:47:45 +0000544void ARMInstPrinter::printSBitModifierOperand(const MCInst *MI, unsigned OpNum,
545 raw_ostream &O) {
Daniel Dunbara7cc6522009-10-20 22:10:05 +0000546 if (MI->getOperand(OpNum).getReg()) {
547 assert(MI->getOperand(OpNum).getReg() == ARM::CPSR &&
548 "Expect ARM CPSR register!");
Chris Lattner233917c2009-10-20 00:46:11 +0000549 O << 's';
550 }
551}
552
Chris Lattner35c33bd2010-04-04 04:47:45 +0000553void ARMInstPrinter::printNoHashImmediate(const MCInst *MI, unsigned OpNum,
554 raw_ostream &O) {
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000555 O << MI->getOperand(OpNum).getImm();
556}
557
Owen Andersone4e5e2a2011-01-13 21:46:02 +0000558void ARMInstPrinter::printPImmediate(const MCInst *MI, unsigned OpNum,
559 raw_ostream &O) {
560 O << "p" << MI->getOperand(OpNum).getImm();
561}
562
563void ARMInstPrinter::printCImmediate(const MCInst *MI, unsigned OpNum,
564 raw_ostream &O) {
565 O << "c" << MI->getOperand(OpNum).getImm();
566}
567
Chris Lattner35c33bd2010-04-04 04:47:45 +0000568void ARMInstPrinter::printPCLabel(const MCInst *MI, unsigned OpNum,
569 raw_ostream &O) {
Jim Grosbachd30cfde2010-09-18 00:04:53 +0000570 llvm_unreachable("Unhandled PC-relative pseudo-instruction!");
Chris Lattner4d152222009-10-19 22:23:04 +0000571}
Evan Cheng2ef9c8a2009-11-19 06:57:41 +0000572
Chris Lattner35c33bd2010-04-04 04:47:45 +0000573void ARMInstPrinter::printThumbS4ImmOperand(const MCInst *MI, unsigned OpNum,
574 raw_ostream &O) {
Johnny Chen541ba7d2010-01-25 22:13:10 +0000575 O << "#" << MI->getOperand(OpNum).getImm() * 4;
Evan Cheng2ef9c8a2009-11-19 06:57:41 +0000576}
Johnny Chen9e088762010-03-17 17:52:21 +0000577
Chris Lattner35c33bd2010-04-04 04:47:45 +0000578void ARMInstPrinter::printThumbITMask(const MCInst *MI, unsigned OpNum,
579 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000580 // (3 - the number of trailing zeros) is the number of then / else.
581 unsigned Mask = MI->getOperand(OpNum).getImm();
582 unsigned CondBit0 = Mask >> 4 & 1;
583 unsigned NumTZ = CountTrailingZeros_32(Mask);
584 assert(NumTZ <= 3 && "Invalid IT mask!");
585 for (unsigned Pos = 3, e = NumTZ; Pos > e; --Pos) {
586 bool T = ((Mask >> Pos) & 1) == CondBit0;
587 if (T)
588 O << 't';
589 else
590 O << 'e';
591 }
592}
593
Chris Lattner35c33bd2010-04-04 04:47:45 +0000594void ARMInstPrinter::printThumbAddrModeRROperand(const MCInst *MI, unsigned Op,
595 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000596 const MCOperand &MO1 = MI->getOperand(Op);
Bill Wendlingf4caf692010-12-14 03:36:38 +0000597 const MCOperand &MO2 = MI->getOperand(Op + 1);
Johnny Chen9e088762010-03-17 17:52:21 +0000598
599 if (!MO1.isReg()) { // FIXME: This is for CP entries, but isn't right.
Chris Lattner35c33bd2010-04-04 04:47:45 +0000600 printOperand(MI, Op, O);
Johnny Chen9e088762010-03-17 17:52:21 +0000601 return;
602 }
603
604 O << "[" << getRegisterName(MO1.getReg());
Bill Wendlingf4caf692010-12-14 03:36:38 +0000605 if (unsigned RegNum = MO2.getReg())
606 O << ", " << getRegisterName(RegNum);
607 O << "]";
608}
609
610void ARMInstPrinter::printThumbAddrModeImm5SOperand(const MCInst *MI,
611 unsigned Op,
612 raw_ostream &O,
613 unsigned Scale) {
614 const MCOperand &MO1 = MI->getOperand(Op);
615 const MCOperand &MO2 = MI->getOperand(Op + 1);
616
617 if (!MO1.isReg()) { // FIXME: This is for CP entries, but isn't right.
618 printOperand(MI, Op, O);
619 return;
620 }
621
622 O << "[" << getRegisterName(MO1.getReg());
623 if (unsigned ImmOffs = MO2.getImm())
Johnny Chen9e088762010-03-17 17:52:21 +0000624 O << ", #" << ImmOffs * Scale;
625 O << "]";
626}
627
Bill Wendlingf4caf692010-12-14 03:36:38 +0000628void ARMInstPrinter::printThumbAddrModeImm5S1Operand(const MCInst *MI,
629 unsigned Op,
630 raw_ostream &O) {
631 printThumbAddrModeImm5SOperand(MI, Op, O, 1);
Johnny Chen9e088762010-03-17 17:52:21 +0000632}
633
Bill Wendlingf4caf692010-12-14 03:36:38 +0000634void ARMInstPrinter::printThumbAddrModeImm5S2Operand(const MCInst *MI,
635 unsigned Op,
636 raw_ostream &O) {
637 printThumbAddrModeImm5SOperand(MI, Op, O, 2);
Johnny Chen9e088762010-03-17 17:52:21 +0000638}
639
Bill Wendlingf4caf692010-12-14 03:36:38 +0000640void ARMInstPrinter::printThumbAddrModeImm5S4Operand(const MCInst *MI,
641 unsigned Op,
642 raw_ostream &O) {
643 printThumbAddrModeImm5SOperand(MI, Op, O, 4);
Johnny Chen9e088762010-03-17 17:52:21 +0000644}
645
Chris Lattner35c33bd2010-04-04 04:47:45 +0000646void ARMInstPrinter::printThumbAddrModeSPOperand(const MCInst *MI, unsigned Op,
647 raw_ostream &O) {
Bill Wendlingf4caf692010-12-14 03:36:38 +0000648 printThumbAddrModeImm5SOperand(MI, Op, O, 4);
Johnny Chen9e088762010-03-17 17:52:21 +0000649}
650
Johnny Chen9e088762010-03-17 17:52:21 +0000651// Constant shifts t2_so_reg is a 2-operand unit corresponding to the Thumb2
652// register with shift forms.
653// REG 0 0 - e.g. R5
654// REG IMM, SH_OPC - e.g. R5, LSL #3
Chris Lattner35c33bd2010-04-04 04:47:45 +0000655void ARMInstPrinter::printT2SOOperand(const MCInst *MI, unsigned OpNum,
656 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000657 const MCOperand &MO1 = MI->getOperand(OpNum);
658 const MCOperand &MO2 = MI->getOperand(OpNum+1);
659
660 unsigned Reg = MO1.getReg();
661 O << getRegisterName(Reg);
662
663 // Print the shift opc.
Johnny Chen9e088762010-03-17 17:52:21 +0000664 assert(MO2.isImm() && "Not a valid t2_so_reg value!");
Bob Wilson1d9125a2010-08-05 00:34:42 +0000665 ARM_AM::ShiftOpc ShOpc = ARM_AM::getSORegShOp(MO2.getImm());
666 O << ", " << ARM_AM::getShiftOpcStr(ShOpc);
667 if (ShOpc != ARM_AM::rrx)
668 O << " #" << ARM_AM::getSORegOffset(MO2.getImm());
Johnny Chen9e088762010-03-17 17:52:21 +0000669}
670
Jim Grosbach458f2dc2010-10-25 20:00:01 +0000671void ARMInstPrinter::printAddrModeImm12Operand(const MCInst *MI, unsigned OpNum,
672 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000673 const MCOperand &MO1 = MI->getOperand(OpNum);
674 const MCOperand &MO2 = MI->getOperand(OpNum+1);
675
Jim Grosbach3e556122010-10-26 22:37:02 +0000676 if (!MO1.isReg()) { // FIXME: This is for CP entries, but isn't right.
677 printOperand(MI, OpNum, O);
678 return;
679 }
680
Johnny Chen9e088762010-03-17 17:52:21 +0000681 O << "[" << getRegisterName(MO1.getReg());
682
Jim Grosbach77aee8e2010-10-27 01:19:41 +0000683 int32_t OffImm = (int32_t)MO2.getImm();
Jim Grosbachab682a22010-10-28 18:34:10 +0000684 bool isSub = OffImm < 0;
685 // Special value for #-0. All others are normal.
686 if (OffImm == INT32_MIN)
687 OffImm = 0;
688 if (isSub)
Jim Grosbach77aee8e2010-10-27 01:19:41 +0000689 O << ", #-" << -OffImm;
690 else if (OffImm > 0)
Johnny Chen9e088762010-03-17 17:52:21 +0000691 O << ", #" << OffImm;
692 O << "]";
693}
694
695void ARMInstPrinter::printT2AddrModeImm8Operand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000696 unsigned OpNum,
697 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000698 const MCOperand &MO1 = MI->getOperand(OpNum);
699 const MCOperand &MO2 = MI->getOperand(OpNum+1);
700
701 O << "[" << getRegisterName(MO1.getReg());
702
703 int32_t OffImm = (int32_t)MO2.getImm();
704 // Don't print +0.
705 if (OffImm < 0)
706 O << ", #-" << -OffImm;
707 else if (OffImm > 0)
708 O << ", #" << OffImm;
709 O << "]";
710}
711
712void ARMInstPrinter::printT2AddrModeImm8s4Operand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000713 unsigned OpNum,
714 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000715 const MCOperand &MO1 = MI->getOperand(OpNum);
716 const MCOperand &MO2 = MI->getOperand(OpNum+1);
717
718 O << "[" << getRegisterName(MO1.getReg());
719
720 int32_t OffImm = (int32_t)MO2.getImm() / 4;
721 // Don't print +0.
722 if (OffImm < 0)
723 O << ", #-" << -OffImm * 4;
724 else if (OffImm > 0)
725 O << ", #" << OffImm * 4;
726 O << "]";
727}
728
729void ARMInstPrinter::printT2AddrModeImm8OffsetOperand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000730 unsigned OpNum,
731 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000732 const MCOperand &MO1 = MI->getOperand(OpNum);
733 int32_t OffImm = (int32_t)MO1.getImm();
734 // Don't print +0.
735 if (OffImm < 0)
736 O << "#-" << -OffImm;
737 else if (OffImm > 0)
738 O << "#" << OffImm;
739}
740
741void ARMInstPrinter::printT2AddrModeImm8s4OffsetOperand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000742 unsigned OpNum,
743 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000744 const MCOperand &MO1 = MI->getOperand(OpNum);
745 int32_t OffImm = (int32_t)MO1.getImm() / 4;
746 // Don't print +0.
747 if (OffImm < 0)
748 O << "#-" << -OffImm * 4;
749 else if (OffImm > 0)
750 O << "#" << OffImm * 4;
751}
752
753void ARMInstPrinter::printT2AddrModeSoRegOperand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000754 unsigned OpNum,
755 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000756 const MCOperand &MO1 = MI->getOperand(OpNum);
757 const MCOperand &MO2 = MI->getOperand(OpNum+1);
758 const MCOperand &MO3 = MI->getOperand(OpNum+2);
759
760 O << "[" << getRegisterName(MO1.getReg());
761
762 assert(MO2.getReg() && "Invalid so_reg load / store address!");
763 O << ", " << getRegisterName(MO2.getReg());
764
765 unsigned ShAmt = MO3.getImm();
766 if (ShAmt) {
767 assert(ShAmt <= 3 && "Not a valid Thumb2 addressing mode!");
768 O << ", lsl #" << ShAmt;
769 }
770 O << "]";
771}
772
Chris Lattner35c33bd2010-04-04 04:47:45 +0000773void ARMInstPrinter::printVFPf32ImmOperand(const MCInst *MI, unsigned OpNum,
774 raw_ostream &O) {
Bill Wendling8cb415e2011-01-26 20:57:43 +0000775 const MCOperand &MO = MI->getOperand(OpNum);
776 O << '#';
777 if (MO.isFPImm()) {
778 O << (float)MO.getFPImm();
779 } else {
780 union {
781 uint32_t I;
782 float F;
783 } FPUnion;
784
785 FPUnion.I = MO.getImm();
786 O << FPUnion.F;
787 }
Johnny Chen9e088762010-03-17 17:52:21 +0000788}
789
Chris Lattner35c33bd2010-04-04 04:47:45 +0000790void ARMInstPrinter::printVFPf64ImmOperand(const MCInst *MI, unsigned OpNum,
791 raw_ostream &O) {
Bill Wendling8cb415e2011-01-26 20:57:43 +0000792 const MCOperand &MO = MI->getOperand(OpNum);
793 O << '#';
794 if (MO.isFPImm()) {
795 O << MO.getFPImm();
796 } else {
797 // We expect the binary encoding of a floating point number here.
798 union {
799 uint64_t I;
800 double D;
801 } FPUnion;
802
803 FPUnion.I = MO.getImm();
804 O << FPUnion.D;
805 }
Johnny Chen9e088762010-03-17 17:52:21 +0000806}
807
Bob Wilson1a913ed2010-06-11 21:34:50 +0000808void ARMInstPrinter::printNEONModImmOperand(const MCInst *MI, unsigned OpNum,
809 raw_ostream &O) {
Bob Wilson6dce00c2010-07-13 04:44:34 +0000810 unsigned EncodedImm = MI->getOperand(OpNum).getImm();
811 unsigned EltBits;
812 uint64_t Val = ARM_AM::decodeNEONModImm(EncodedImm, EltBits);
Bob Wilson1a913ed2010-06-11 21:34:50 +0000813 O << "#0x" << utohexstr(Val);
Johnny Chenc7b65912010-04-16 22:40:20 +0000814}