blob: 2b994dfc4d46fb7d2700766f6c84a56d40402508 [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"
15#include "ARMInstPrinter.h"
Evan Chengbe740292011-07-23 00:00:19 +000016#include "MCTargetDesc/ARMBaseInfo.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"
Jim Grosbach28f08c92012-03-05 19:33:30 +000021#include "llvm/MC/MCRegisterInfo.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
Owen Anderson3dac0be2011-08-11 18:41:59 +000028/// translateShiftImm - Convert shift immediate from 0-31 to 1-32 for printing.
29///
Jim Grosbach01208d52011-10-12 16:36:01 +000030/// getSORegOffset returns an integer from 0-31, representing '32' as 0.
Owen Anderson3dac0be2011-08-11 18:41:59 +000031static unsigned translateShiftImm(unsigned imm) {
32 if (imm == 0)
33 return 32;
34 return imm;
35}
36
James Molloyb9505852011-09-07 17:24:38 +000037
38ARMInstPrinter::ARMInstPrinter(const MCAsmInfo &MAI,
Jim Grosbachc6449b62012-03-05 19:33:20 +000039 const MCRegisterInfo &MRI,
James Molloyb9505852011-09-07 17:24:38 +000040 const MCSubtargetInfo &STI) :
Jim Grosbachc6449b62012-03-05 19:33:20 +000041 MCInstPrinter(MAI, MRI) {
James Molloyb9505852011-09-07 17:24:38 +000042 // Initialize the set of available features.
43 setAvailableFeatures(STI.getFeatureBits());
44}
45
Chris Lattner6274ec42010-10-28 21:37:33 +000046StringRef ARMInstPrinter::getOpcodeName(unsigned Opcode) const {
47 return getInstructionName(Opcode);
48}
49
Rafael Espindolacde4ce42011-06-02 02:34:55 +000050void ARMInstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const {
51 OS << getRegisterName(RegNo);
Anton Korobeynikov57caad72011-03-05 18:43:32 +000052}
Chris Lattner6274ec42010-10-28 21:37:33 +000053
Owen Anderson98c5dda2011-09-15 23:38:46 +000054void ARMInstPrinter::printInst(const MCInst *MI, raw_ostream &O,
55 StringRef Annot) {
Bill Wendling04863d02010-11-13 10:40:19 +000056 unsigned Opcode = MI->getOpcode();
57
Johnny Chen9e088762010-03-17 17:52:21 +000058 // Check for MOVs and print canonical forms, instead.
Owen Anderson152d4a42011-07-21 23:38:37 +000059 if (Opcode == ARM::MOVsr) {
Jim Grosbache6be85e2010-09-17 22:36:38 +000060 // FIXME: Thumb variants?
Johnny Chen9e088762010-03-17 17:52:21 +000061 const MCOperand &Dst = MI->getOperand(0);
62 const MCOperand &MO1 = MI->getOperand(1);
63 const MCOperand &MO2 = MI->getOperand(2);
64 const MCOperand &MO3 = MI->getOperand(3);
65
66 O << '\t' << ARM_AM::getShiftOpcStr(ARM_AM::getSORegShOp(MO3.getImm()));
Chris Lattner35c33bd2010-04-04 04:47:45 +000067 printSBitModifierOperand(MI, 6, O);
68 printPredicateOperand(MI, 4, O);
Johnny Chen9e088762010-03-17 17:52:21 +000069
70 O << '\t' << getRegisterName(Dst.getReg())
71 << ", " << getRegisterName(MO1.getReg());
72
Owen Anderson152d4a42011-07-21 23:38:37 +000073 O << ", " << getRegisterName(MO2.getReg());
74 assert(ARM_AM::getSORegOffset(MO3.getImm()) == 0);
Owen Anderson519020a2011-09-21 17:58:45 +000075 printAnnotation(O, Annot);
Johnny Chen9e088762010-03-17 17:52:21 +000076 return;
77 }
78
Owen Anderson152d4a42011-07-21 23:38:37 +000079 if (Opcode == ARM::MOVsi) {
80 // FIXME: Thumb variants?
81 const MCOperand &Dst = MI->getOperand(0);
82 const MCOperand &MO1 = MI->getOperand(1);
83 const MCOperand &MO2 = MI->getOperand(2);
84
85 O << '\t' << ARM_AM::getShiftOpcStr(ARM_AM::getSORegShOp(MO2.getImm()));
86 printSBitModifierOperand(MI, 5, O);
87 printPredicateOperand(MI, 3, O);
88
89 O << '\t' << getRegisterName(Dst.getReg())
90 << ", " << getRegisterName(MO1.getReg());
91
Owen Andersonede042d2011-09-15 18:36:29 +000092 if (ARM_AM::getSORegShOp(MO2.getImm()) == ARM_AM::rrx) {
Owen Anderson519020a2011-09-21 17:58:45 +000093 printAnnotation(O, Annot);
Owen Anderson152d4a42011-07-21 23:38:37 +000094 return;
Owen Andersonede042d2011-09-15 18:36:29 +000095 }
Owen Anderson152d4a42011-07-21 23:38:37 +000096
Owen Anderson3dac0be2011-08-11 18:41:59 +000097 O << ", #" << translateShiftImm(ARM_AM::getSORegOffset(MO2.getImm()));
Owen Anderson519020a2011-09-21 17:58:45 +000098 printAnnotation(O, Annot);
Owen Anderson152d4a42011-07-21 23:38:37 +000099 return;
100 }
101
102
Johnny Chen9e088762010-03-17 17:52:21 +0000103 // A8.6.123 PUSH
Bill Wendling73fe34a2010-11-16 01:16:36 +0000104 if ((Opcode == ARM::STMDB_UPD || Opcode == ARM::t2STMDB_UPD) &&
Owen Anderson81550dc2011-11-02 18:03:14 +0000105 MI->getOperand(0).getReg() == ARM::SP &&
106 MI->getNumOperands() > 5) {
107 // Should only print PUSH if there are at least two registers in the list.
Bill Wendling73fe34a2010-11-16 01:16:36 +0000108 O << '\t' << "push";
109 printPredicateOperand(MI, 2, O);
Jim Grosbach41ad0c42010-12-03 20:33:01 +0000110 if (Opcode == ARM::t2STMDB_UPD)
111 O << ".w";
Bill Wendling73fe34a2010-11-16 01:16:36 +0000112 O << '\t';
113 printRegisterList(MI, 4, O);
Owen Anderson519020a2011-09-21 17:58:45 +0000114 printAnnotation(O, Annot);
Bill Wendling73fe34a2010-11-16 01:16:36 +0000115 return;
Johnny Chen9e088762010-03-17 17:52:21 +0000116 }
Jim Grosbachf6713912011-08-11 18:07:11 +0000117 if (Opcode == ARM::STR_PRE_IMM && MI->getOperand(2).getReg() == ARM::SP &&
118 MI->getOperand(3).getImm() == -4) {
119 O << '\t' << "push";
120 printPredicateOperand(MI, 4, O);
121 O << "\t{" << getRegisterName(MI->getOperand(1).getReg()) << "}";
Owen Anderson519020a2011-09-21 17:58:45 +0000122 printAnnotation(O, Annot);
Jim Grosbachf6713912011-08-11 18:07:11 +0000123 return;
124 }
Johnny Chen9e088762010-03-17 17:52:21 +0000125
126 // A8.6.122 POP
Bill Wendling73fe34a2010-11-16 01:16:36 +0000127 if ((Opcode == ARM::LDMIA_UPD || Opcode == ARM::t2LDMIA_UPD) &&
Owen Anderson81550dc2011-11-02 18:03:14 +0000128 MI->getOperand(0).getReg() == ARM::SP &&
129 MI->getNumOperands() > 5) {
130 // Should only print POP if there are at least two registers in the list.
Bill Wendling73fe34a2010-11-16 01:16:36 +0000131 O << '\t' << "pop";
132 printPredicateOperand(MI, 2, O);
Jim Grosbach41ad0c42010-12-03 20:33:01 +0000133 if (Opcode == ARM::t2LDMIA_UPD)
134 O << ".w";
Bill Wendling73fe34a2010-11-16 01:16:36 +0000135 O << '\t';
136 printRegisterList(MI, 4, O);
Owen Anderson519020a2011-09-21 17:58:45 +0000137 printAnnotation(O, Annot);
Bill Wendling73fe34a2010-11-16 01:16:36 +0000138 return;
Johnny Chen9e088762010-03-17 17:52:21 +0000139 }
Jim Grosbachf8fce712011-08-11 17:35:48 +0000140 if (Opcode == ARM::LDR_POST_IMM && MI->getOperand(2).getReg() == ARM::SP &&
141 MI->getOperand(4).getImm() == 4) {
142 O << '\t' << "pop";
143 printPredicateOperand(MI, 5, O);
144 O << "\t{" << getRegisterName(MI->getOperand(0).getReg()) << "}";
Owen Anderson519020a2011-09-21 17:58:45 +0000145 printAnnotation(O, Annot);
Jim Grosbachf8fce712011-08-11 17:35:48 +0000146 return;
147 }
148
Johnny Chen9e088762010-03-17 17:52:21 +0000149
150 // A8.6.355 VPUSH
Bill Wendling73fe34a2010-11-16 01:16:36 +0000151 if ((Opcode == ARM::VSTMSDB_UPD || Opcode == ARM::VSTMDDB_UPD) &&
Johnny Chen9e088762010-03-17 17:52:21 +0000152 MI->getOperand(0).getReg() == ARM::SP) {
Bill Wendling73fe34a2010-11-16 01:16:36 +0000153 O << '\t' << "vpush";
154 printPredicateOperand(MI, 2, O);
155 O << '\t';
156 printRegisterList(MI, 4, O);
Owen Anderson519020a2011-09-21 17:58:45 +0000157 printAnnotation(O, Annot);
Bill Wendling73fe34a2010-11-16 01:16:36 +0000158 return;
Johnny Chen9e088762010-03-17 17:52:21 +0000159 }
160
161 // A8.6.354 VPOP
Bill Wendling73fe34a2010-11-16 01:16:36 +0000162 if ((Opcode == ARM::VLDMSIA_UPD || Opcode == ARM::VLDMDIA_UPD) &&
Johnny Chen9e088762010-03-17 17:52:21 +0000163 MI->getOperand(0).getReg() == ARM::SP) {
Bill Wendling73fe34a2010-11-16 01:16:36 +0000164 O << '\t' << "vpop";
165 printPredicateOperand(MI, 2, O);
166 O << '\t';
167 printRegisterList(MI, 4, O);
Owen Anderson519020a2011-09-21 17:58:45 +0000168 printAnnotation(O, Annot);
Bill Wendling73fe34a2010-11-16 01:16:36 +0000169 return;
Johnny Chen9e088762010-03-17 17:52:21 +0000170 }
171
Jim Grosbachcefe4c92011-08-23 17:41:15 +0000172 if (Opcode == ARM::tLDMIA) {
Owen Anderson565a0362011-07-18 23:25:34 +0000173 bool Writeback = true;
174 unsigned BaseReg = MI->getOperand(0).getReg();
175 for (unsigned i = 3; i < MI->getNumOperands(); ++i) {
176 if (MI->getOperand(i).getReg() == BaseReg)
177 Writeback = false;
178 }
179
Jim Grosbachcefe4c92011-08-23 17:41:15 +0000180 O << "\tldm";
Owen Anderson565a0362011-07-18 23:25:34 +0000181
182 printPredicateOperand(MI, 1, O);
183 O << '\t' << getRegisterName(BaseReg);
184 if (Writeback) O << "!";
185 O << ", ";
186 printRegisterList(MI, 3, O);
Owen Anderson519020a2011-09-21 17:58:45 +0000187 printAnnotation(O, Annot);
Owen Anderson565a0362011-07-18 23:25:34 +0000188 return;
189 }
190
Jim Grosbach0780b632011-08-19 23:24:36 +0000191 // Thumb1 NOP
192 if (Opcode == ARM::tMOVr && MI->getOperand(0).getReg() == ARM::R8 &&
193 MI->getOperand(1).getReg() == ARM::R8) {
194 O << "\tnop";
Jim Grosbachdf9ce6b2011-08-24 20:06:14 +0000195 printPredicateOperand(MI, 2, O);
Owen Anderson519020a2011-09-21 17:58:45 +0000196 printAnnotation(O, Annot);
Jim Grosbach0780b632011-08-19 23:24:36 +0000197 return;
198 }
199
Chris Lattner35c33bd2010-04-04 04:47:45 +0000200 printInstruction(MI, O);
Owen Anderson519020a2011-09-21 17:58:45 +0000201 printAnnotation(O, Annot);
Bill Wendling04863d02010-11-13 10:40:19 +0000202}
Chris Lattnerfd603822009-10-19 19:56:26 +0000203
Chris Lattner8bc86cb2009-10-19 20:59:55 +0000204void ARMInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
Jim Grosbach0a2287b2010-11-03 01:11:15 +0000205 raw_ostream &O) {
Chris Lattner8bc86cb2009-10-19 20:59:55 +0000206 const MCOperand &Op = MI->getOperand(OpNo);
207 if (Op.isReg()) {
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000208 unsigned Reg = Op.getReg();
Jim Grosbach35636282010-10-06 21:22:32 +0000209 O << getRegisterName(Reg);
Chris Lattner8bc86cb2009-10-19 20:59:55 +0000210 } else if (Op.isImm()) {
211 O << '#' << Op.getImm();
212 } else {
213 assert(Op.isExpr() && "unknown operand kind in printOperand");
Kevin Enderby9e5887b2011-10-04 22:44:48 +0000214 // If a symbolic branch target was added as a constant expression then print
215 // that address in hex.
216 const MCConstantExpr *BranchTarget = dyn_cast<MCConstantExpr>(Op.getExpr());
217 int64_t Address;
218 if (BranchTarget && BranchTarget->EvaluateAsAbsolute(Address)) {
219 O << "0x";
220 O.write_hex(Address);
221 }
222 else {
223 // Otherwise, just print the expression.
224 O << *Op.getExpr();
225 }
Chris Lattner8bc86cb2009-10-19 20:59:55 +0000226 }
227}
Chris Lattner61d35c22009-10-19 21:21:39 +0000228
Owen Andersone1368722011-09-21 23:44:46 +0000229void ARMInstPrinter::printT2LdrLabelOperand(const MCInst *MI, unsigned OpNum,
230 raw_ostream &O) {
231 const MCOperand &MO1 = MI->getOperand(OpNum);
232 if (MO1.isExpr())
233 O << *MO1.getExpr();
234 else if (MO1.isImm())
235 O << "[pc, #" << MO1.getImm() << "]";
236 else
237 llvm_unreachable("Unknown LDR label operand?");
238}
239
Chris Lattner017d9472009-10-20 00:40:56 +0000240// so_reg is a 4-operand unit corresponding to register forms of the A5.1
241// "Addressing Mode 1 - Data-processing operands" forms. This includes:
242// REG 0 0 - e.g. R5
243// REG REG 0,SH_OPC - e.g. R5, ROR R3
244// REG 0 IMM,SH_OPC - e.g. R5, LSL #3
Owen Anderson152d4a42011-07-21 23:38:37 +0000245void ARMInstPrinter::printSORegRegOperand(const MCInst *MI, unsigned OpNum,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000246 raw_ostream &O) {
Chris Lattner017d9472009-10-20 00:40:56 +0000247 const MCOperand &MO1 = MI->getOperand(OpNum);
248 const MCOperand &MO2 = MI->getOperand(OpNum+1);
249 const MCOperand &MO3 = MI->getOperand(OpNum+2);
Jim Grosbach15d78982010-09-14 22:27:15 +0000250
Chris Lattner017d9472009-10-20 00:40:56 +0000251 O << getRegisterName(MO1.getReg());
Jim Grosbach15d78982010-09-14 22:27:15 +0000252
Chris Lattner017d9472009-10-20 00:40:56 +0000253 // Print the shift opc.
Bob Wilson1d9125a2010-08-05 00:34:42 +0000254 ARM_AM::ShiftOpc ShOpc = ARM_AM::getSORegShOp(MO3.getImm());
255 O << ", " << ARM_AM::getShiftOpcStr(ShOpc);
Jim Grosbache8606dc2011-07-13 17:50:29 +0000256 if (ShOpc == ARM_AM::rrx)
257 return;
Jim Grosbach293a5f62011-10-21 16:56:40 +0000258
Owen Anderson152d4a42011-07-21 23:38:37 +0000259 O << ' ' << getRegisterName(MO2.getReg());
260 assert(ARM_AM::getSORegOffset(MO3.getImm()) == 0);
Chris Lattner017d9472009-10-20 00:40:56 +0000261}
Chris Lattner084f87d2009-10-19 21:57:05 +0000262
Owen Anderson152d4a42011-07-21 23:38:37 +0000263void ARMInstPrinter::printSORegImmOperand(const MCInst *MI, unsigned OpNum,
264 raw_ostream &O) {
265 const MCOperand &MO1 = MI->getOperand(OpNum);
266 const MCOperand &MO2 = MI->getOperand(OpNum+1);
267
268 O << getRegisterName(MO1.getReg());
269
270 // Print the shift opc.
271 ARM_AM::ShiftOpc ShOpc = ARM_AM::getSORegShOp(MO2.getImm());
272 O << ", " << ARM_AM::getShiftOpcStr(ShOpc);
273 if (ShOpc == ARM_AM::rrx)
274 return;
Owen Anderson3dac0be2011-08-11 18:41:59 +0000275 O << " #" << translateShiftImm(ARM_AM::getSORegOffset(MO2.getImm()));
Owen Anderson152d4a42011-07-21 23:38:37 +0000276}
277
278
Bruno Cardoso Lopesac79e4c2011-04-04 17:18:19 +0000279//===--------------------------------------------------------------------===//
280// Addressing Mode #2
281//===--------------------------------------------------------------------===//
282
Bruno Cardoso Lopesae085542011-03-31 23:26:08 +0000283void ARMInstPrinter::printAM2PreOrOffsetIndexOp(const MCInst *MI, unsigned Op,
284 raw_ostream &O) {
Chris Lattner084f87d2009-10-19 21:57:05 +0000285 const MCOperand &MO1 = MI->getOperand(Op);
286 const MCOperand &MO2 = MI->getOperand(Op+1);
287 const MCOperand &MO3 = MI->getOperand(Op+2);
Jim Grosbach15d78982010-09-14 22:27:15 +0000288
Chris Lattner084f87d2009-10-19 21:57:05 +0000289 O << "[" << getRegisterName(MO1.getReg());
Jim Grosbach15d78982010-09-14 22:27:15 +0000290
Chris Lattner084f87d2009-10-19 21:57:05 +0000291 if (!MO2.getReg()) {
Johnny Chen9e088762010-03-17 17:52:21 +0000292 if (ARM_AM::getAM2Offset(MO3.getImm())) // Don't print +0.
Chris Lattner084f87d2009-10-19 21:57:05 +0000293 O << ", #"
Johnny Chen9e088762010-03-17 17:52:21 +0000294 << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO3.getImm()))
295 << ARM_AM::getAM2Offset(MO3.getImm());
Chris Lattner084f87d2009-10-19 21:57:05 +0000296 O << "]";
297 return;
298 }
Jim Grosbach15d78982010-09-14 22:27:15 +0000299
Chris Lattner084f87d2009-10-19 21:57:05 +0000300 O << ", "
Johnny Chen9e088762010-03-17 17:52:21 +0000301 << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO3.getImm()))
302 << getRegisterName(MO2.getReg());
Jim Grosbach15d78982010-09-14 22:27:15 +0000303
Chris Lattner084f87d2009-10-19 21:57:05 +0000304 if (unsigned ShImm = ARM_AM::getAM2Offset(MO3.getImm()))
305 O << ", "
306 << ARM_AM::getShiftOpcStr(ARM_AM::getAM2ShiftOpc(MO3.getImm()))
307 << " #" << ShImm;
308 O << "]";
Jim Grosbach15d78982010-09-14 22:27:15 +0000309}
Chris Lattnere306d8d2009-10-19 22:09:23 +0000310
Bruno Cardoso Lopesae085542011-03-31 23:26:08 +0000311void ARMInstPrinter::printAM2PostIndexOp(const MCInst *MI, unsigned Op,
312 raw_ostream &O) {
313 const MCOperand &MO1 = MI->getOperand(Op);
314 const MCOperand &MO2 = MI->getOperand(Op+1);
315 const MCOperand &MO3 = MI->getOperand(Op+2);
316
317 O << "[" << getRegisterName(MO1.getReg()) << "], ";
318
319 if (!MO2.getReg()) {
320 unsigned ImmOffs = ARM_AM::getAM2Offset(MO3.getImm());
321 O << '#'
322 << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO3.getImm()))
323 << ImmOffs;
324 return;
325 }
326
327 O << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO3.getImm()))
328 << getRegisterName(MO2.getReg());
329
330 if (unsigned ShImm = ARM_AM::getAM2Offset(MO3.getImm()))
331 O << ", "
332 << ARM_AM::getShiftOpcStr(ARM_AM::getAM2ShiftOpc(MO3.getImm()))
333 << " #" << ShImm;
334}
335
Jim Grosbach7f739be2011-09-19 22:21:13 +0000336void ARMInstPrinter::printAddrModeTBB(const MCInst *MI, unsigned Op,
337 raw_ostream &O) {
338 const MCOperand &MO1 = MI->getOperand(Op);
339 const MCOperand &MO2 = MI->getOperand(Op+1);
340 O << "[" << getRegisterName(MO1.getReg()) << ", "
341 << getRegisterName(MO2.getReg()) << "]";
342}
343
344void ARMInstPrinter::printAddrModeTBH(const MCInst *MI, unsigned Op,
345 raw_ostream &O) {
346 const MCOperand &MO1 = MI->getOperand(Op);
347 const MCOperand &MO2 = MI->getOperand(Op+1);
348 O << "[" << getRegisterName(MO1.getReg()) << ", "
349 << getRegisterName(MO2.getReg()) << ", lsl #1]";
350}
351
Bruno Cardoso Lopesae085542011-03-31 23:26:08 +0000352void ARMInstPrinter::printAddrMode2Operand(const MCInst *MI, unsigned Op,
353 raw_ostream &O) {
354 const MCOperand &MO1 = MI->getOperand(Op);
355
356 if (!MO1.isReg()) { // FIXME: This is for CP entries, but isn't right.
357 printOperand(MI, Op, O);
358 return;
359 }
360
361 const MCOperand &MO3 = MI->getOperand(Op+2);
362 unsigned IdxMode = ARM_AM::getAM2IdxMode(MO3.getImm());
363
364 if (IdxMode == ARMII::IndexModePost) {
365 printAM2PostIndexOp(MI, Op, O);
366 return;
367 }
368 printAM2PreOrOffsetIndexOp(MI, Op, O);
369}
370
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000371void ARMInstPrinter::printAddrMode2OffsetOperand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000372 unsigned OpNum,
373 raw_ostream &O) {
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000374 const MCOperand &MO1 = MI->getOperand(OpNum);
375 const MCOperand &MO2 = MI->getOperand(OpNum+1);
Jim Grosbach15d78982010-09-14 22:27:15 +0000376
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000377 if (!MO1.getReg()) {
378 unsigned ImmOffs = ARM_AM::getAM2Offset(MO2.getImm());
Johnny Chen9e088762010-03-17 17:52:21 +0000379 O << '#'
380 << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO2.getImm()))
381 << ImmOffs;
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000382 return;
383 }
Jim Grosbach15d78982010-09-14 22:27:15 +0000384
Johnny Chen9e088762010-03-17 17:52:21 +0000385 O << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO2.getImm()))
386 << getRegisterName(MO1.getReg());
Jim Grosbach15d78982010-09-14 22:27:15 +0000387
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000388 if (unsigned ShImm = ARM_AM::getAM2Offset(MO2.getImm()))
389 O << ", "
390 << ARM_AM::getShiftOpcStr(ARM_AM::getAM2ShiftOpc(MO2.getImm()))
391 << " #" << ShImm;
392}
393
Bruno Cardoso Lopesac79e4c2011-04-04 17:18:19 +0000394//===--------------------------------------------------------------------===//
395// Addressing Mode #3
396//===--------------------------------------------------------------------===//
397
398void ARMInstPrinter::printAM3PostIndexOp(const MCInst *MI, unsigned Op,
399 raw_ostream &O) {
400 const MCOperand &MO1 = MI->getOperand(Op);
401 const MCOperand &MO2 = MI->getOperand(Op+1);
402 const MCOperand &MO3 = MI->getOperand(Op+2);
403
404 O << "[" << getRegisterName(MO1.getReg()) << "], ";
405
406 if (MO2.getReg()) {
407 O << (char)ARM_AM::getAM3Op(MO3.getImm())
408 << getRegisterName(MO2.getReg());
409 return;
410 }
411
412 unsigned ImmOffs = ARM_AM::getAM3Offset(MO3.getImm());
413 O << '#'
414 << ARM_AM::getAddrOpcStr(ARM_AM::getAM3Op(MO3.getImm()))
415 << ImmOffs;
416}
417
418void ARMInstPrinter::printAM3PreOrOffsetIndexOp(const MCInst *MI, unsigned Op,
419 raw_ostream &O) {
420 const MCOperand &MO1 = MI->getOperand(Op);
421 const MCOperand &MO2 = MI->getOperand(Op+1);
422 const MCOperand &MO3 = MI->getOperand(Op+2);
Jim Grosbach15d78982010-09-14 22:27:15 +0000423
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000424 O << '[' << getRegisterName(MO1.getReg());
Jim Grosbach15d78982010-09-14 22:27:15 +0000425
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000426 if (MO2.getReg()) {
Jim Grosbach7ce05792011-08-03 23:50:40 +0000427 O << ", " << getAddrOpcStr(ARM_AM::getAM3Op(MO3.getImm()))
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000428 << getRegisterName(MO2.getReg()) << ']';
429 return;
430 }
Jim Grosbach15d78982010-09-14 22:27:15 +0000431
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000432 if (unsigned ImmOffs = ARM_AM::getAM3Offset(MO3.getImm()))
433 O << ", #"
Johnny Chen9e088762010-03-17 17:52:21 +0000434 << ARM_AM::getAddrOpcStr(ARM_AM::getAM3Op(MO3.getImm()))
435 << ImmOffs;
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000436 O << ']';
437}
438
Bruno Cardoso Lopesac79e4c2011-04-04 17:18:19 +0000439void ARMInstPrinter::printAddrMode3Operand(const MCInst *MI, unsigned Op,
440 raw_ostream &O) {
Jim Grosbach2f196742011-12-19 23:06:24 +0000441 const MCOperand &MO1 = MI->getOperand(Op);
442 if (!MO1.isReg()) { // For label symbolic references.
443 printOperand(MI, Op, O);
444 return;
445 }
446
Bruno Cardoso Lopesac79e4c2011-04-04 17:18:19 +0000447 const MCOperand &MO3 = MI->getOperand(Op+2);
448 unsigned IdxMode = ARM_AM::getAM3IdxMode(MO3.getImm());
449
450 if (IdxMode == ARMII::IndexModePost) {
451 printAM3PostIndexOp(MI, Op, O);
452 return;
453 }
454 printAM3PreOrOffsetIndexOp(MI, Op, O);
455}
456
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000457void ARMInstPrinter::printAddrMode3OffsetOperand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000458 unsigned OpNum,
459 raw_ostream &O) {
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000460 const MCOperand &MO1 = MI->getOperand(OpNum);
461 const MCOperand &MO2 = MI->getOperand(OpNum+1);
Jim Grosbach15d78982010-09-14 22:27:15 +0000462
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000463 if (MO1.getReg()) {
Jim Grosbach7ce05792011-08-03 23:50:40 +0000464 O << getAddrOpcStr(ARM_AM::getAM3Op(MO2.getImm()))
465 << getRegisterName(MO1.getReg());
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000466 return;
467 }
Jim Grosbach15d78982010-09-14 22:27:15 +0000468
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000469 unsigned ImmOffs = ARM_AM::getAM3Offset(MO2.getImm());
Johnny Chen9e088762010-03-17 17:52:21 +0000470 O << '#'
471 << ARM_AM::getAddrOpcStr(ARM_AM::getAM3Op(MO2.getImm()))
472 << ImmOffs;
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000473}
474
Jim Grosbach7ce05792011-08-03 23:50:40 +0000475void ARMInstPrinter::printPostIdxImm8Operand(const MCInst *MI,
476 unsigned OpNum,
477 raw_ostream &O) {
478 const MCOperand &MO = MI->getOperand(OpNum);
479 unsigned Imm = MO.getImm();
480 O << '#' << ((Imm & 256) ? "" : "-") << (Imm & 0xff);
481}
482
Jim Grosbachca8c70b2011-08-05 15:48:21 +0000483void ARMInstPrinter::printPostIdxRegOperand(const MCInst *MI, unsigned OpNum,
484 raw_ostream &O) {
485 const MCOperand &MO1 = MI->getOperand(OpNum);
486 const MCOperand &MO2 = MI->getOperand(OpNum+1);
487
Jim Grosbach16578b52011-08-05 16:11:38 +0000488 O << (MO2.getImm() ? "" : "-") << getRegisterName(MO1.getReg());
Jim Grosbachca8c70b2011-08-05 15:48:21 +0000489}
490
Owen Anderson154c41d2011-08-04 18:24:14 +0000491void ARMInstPrinter::printPostIdxImm8s4Operand(const MCInst *MI,
492 unsigned OpNum,
493 raw_ostream &O) {
494 const MCOperand &MO = MI->getOperand(OpNum);
495 unsigned Imm = MO.getImm();
496 O << '#' << ((Imm & 256) ? "" : "-") << ((Imm & 0xff) << 2);
497}
498
499
Jim Grosbache6913602010-11-03 01:01:43 +0000500void ARMInstPrinter::printLdStmModeOperand(const MCInst *MI, unsigned OpNum,
Jim Grosbach0a2287b2010-11-03 01:11:15 +0000501 raw_ostream &O) {
Jim Grosbache6913602010-11-03 01:01:43 +0000502 ARM_AM::AMSubMode Mode = ARM_AM::getAM4SubMode(MI->getOperand(OpNum)
503 .getImm());
504 O << ARM_AM::getAMSubModeStr(Mode);
Chris Lattnere306d8d2009-10-19 22:09:23 +0000505}
506
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000507void ARMInstPrinter::printAddrMode5Operand(const MCInst *MI, unsigned OpNum,
Jim Grosbach0a2287b2010-11-03 01:11:15 +0000508 raw_ostream &O) {
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000509 const MCOperand &MO1 = MI->getOperand(OpNum);
510 const MCOperand &MO2 = MI->getOperand(OpNum+1);
Jim Grosbach15d78982010-09-14 22:27:15 +0000511
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000512 if (!MO1.isReg()) { // FIXME: This is for CP entries, but isn't right.
Chris Lattner35c33bd2010-04-04 04:47:45 +0000513 printOperand(MI, OpNum, O);
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000514 return;
515 }
Jim Grosbach15d78982010-09-14 22:27:15 +0000516
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000517 O << "[" << getRegisterName(MO1.getReg());
Jim Grosbach15d78982010-09-14 22:27:15 +0000518
Owen Anderson0da10cf2011-08-29 19:36:44 +0000519 unsigned ImmOffs = ARM_AM::getAM5Offset(MO2.getImm());
520 unsigned Op = ARM_AM::getAM5Op(MO2.getImm());
521 if (ImmOffs || Op == ARM_AM::sub) {
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000522 O << ", #"
Johnny Chen9e088762010-03-17 17:52:21 +0000523 << ARM_AM::getAddrOpcStr(ARM_AM::getAM5Op(MO2.getImm()))
Bill Wendling92b5a2e2010-11-03 01:49:29 +0000524 << ImmOffs * 4;
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000525 }
526 O << "]";
527}
528
Chris Lattner35c33bd2010-04-04 04:47:45 +0000529void ARMInstPrinter::printAddrMode6Operand(const MCInst *MI, unsigned OpNum,
530 raw_ostream &O) {
Chris Lattner235e2f62009-10-20 06:22:33 +0000531 const MCOperand &MO1 = MI->getOperand(OpNum);
532 const MCOperand &MO2 = MI->getOperand(OpNum+1);
Jim Grosbach15d78982010-09-14 22:27:15 +0000533
Bob Wilson226036e2010-03-20 22:13:40 +0000534 O << "[" << getRegisterName(MO1.getReg());
535 if (MO2.getImm()) {
536 // FIXME: Both darwin as and GNU as violate ARM docs here.
Bob Wilson273ff312010-07-14 23:54:43 +0000537 O << ", :" << (MO2.getImm() << 3);
Chris Lattner235e2f62009-10-20 06:22:33 +0000538 }
Bob Wilson226036e2010-03-20 22:13:40 +0000539 O << "]";
540}
541
Bruno Cardoso Lopes505f3cd2011-03-24 21:04:58 +0000542void ARMInstPrinter::printAddrMode7Operand(const MCInst *MI, unsigned OpNum,
543 raw_ostream &O) {
544 const MCOperand &MO1 = MI->getOperand(OpNum);
545 O << "[" << getRegisterName(MO1.getReg()) << "]";
546}
547
Bob Wilson226036e2010-03-20 22:13:40 +0000548void ARMInstPrinter::printAddrMode6OffsetOperand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000549 unsigned OpNum,
550 raw_ostream &O) {
Bob Wilson226036e2010-03-20 22:13:40 +0000551 const MCOperand &MO = MI->getOperand(OpNum);
552 if (MO.getReg() == 0)
553 O << "!";
554 else
555 O << ", " << getRegisterName(MO.getReg());
Chris Lattner235e2f62009-10-20 06:22:33 +0000556}
557
Bob Wilsoneaf1c982010-08-11 23:10:46 +0000558void ARMInstPrinter::printBitfieldInvMaskImmOperand(const MCInst *MI,
559 unsigned OpNum,
560 raw_ostream &O) {
Chris Lattner235e2f62009-10-20 06:22:33 +0000561 const MCOperand &MO = MI->getOperand(OpNum);
562 uint32_t v = ~MO.getImm();
563 int32_t lsb = CountTrailingZeros_32(v);
564 int32_t width = (32 - CountLeadingZeros_32 (v)) - lsb;
565 assert(MO.isImm() && "Not a valid bf_inv_mask_imm value!");
566 O << '#' << lsb << ", #" << width;
567}
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000568
Johnny Chen1adc40c2010-08-12 20:46:17 +0000569void ARMInstPrinter::printMemBOption(const MCInst *MI, unsigned OpNum,
570 raw_ostream &O) {
571 unsigned val = MI->getOperand(OpNum).getImm();
572 O << ARM_MB::MemBOptToString(val);
573}
574
Bob Wilson22f5dc72010-08-16 18:27:34 +0000575void ARMInstPrinter::printShiftImmOperand(const MCInst *MI, unsigned OpNum,
Bob Wilsoneaf1c982010-08-11 23:10:46 +0000576 raw_ostream &O) {
577 unsigned ShiftOp = MI->getOperand(OpNum).getImm();
Jim Grosbach580f4a92011-07-25 22:20:28 +0000578 bool isASR = (ShiftOp & (1 << 5)) != 0;
579 unsigned Amt = ShiftOp & 0x1f;
580 if (isASR)
581 O << ", asr #" << (Amt == 0 ? 32 : Amt);
582 else if (Amt)
583 O << ", lsl #" << Amt;
Bob Wilsoneaf1c982010-08-11 23:10:46 +0000584}
585
Jim Grosbachdde038a2011-07-20 21:40:26 +0000586void ARMInstPrinter::printPKHLSLShiftImm(const MCInst *MI, unsigned OpNum,
587 raw_ostream &O) {
588 unsigned Imm = MI->getOperand(OpNum).getImm();
589 if (Imm == 0)
590 return;
591 assert(Imm > 0 && Imm < 32 && "Invalid PKH shift immediate value!");
592 O << ", lsl #" << Imm;
593}
594
595void ARMInstPrinter::printPKHASRShiftImm(const MCInst *MI, unsigned OpNum,
596 raw_ostream &O) {
597 unsigned Imm = MI->getOperand(OpNum).getImm();
598 // A shift amount of 32 is encoded as 0.
599 if (Imm == 0)
600 Imm = 32;
601 assert(Imm > 0 && Imm <= 32 && "Invalid PKH shift immediate value!");
602 O << ", asr #" << Imm;
603}
604
Chris Lattner35c33bd2010-04-04 04:47:45 +0000605void ARMInstPrinter::printRegisterList(const MCInst *MI, unsigned OpNum,
606 raw_ostream &O) {
Chris Lattnere306d8d2009-10-19 22:09:23 +0000607 O << "{";
Johnny Chen9e088762010-03-17 17:52:21 +0000608 for (unsigned i = OpNum, e = MI->getNumOperands(); i != e; ++i) {
609 if (i != OpNum) O << ", ";
Chris Lattnere306d8d2009-10-19 22:09:23 +0000610 O << getRegisterName(MI->getOperand(i).getReg());
611 }
612 O << "}";
613}
Chris Lattner4d152222009-10-19 22:23:04 +0000614
Jim Grosbachb3af5de2010-10-13 21:00:04 +0000615void ARMInstPrinter::printSetendOperand(const MCInst *MI, unsigned OpNum,
616 raw_ostream &O) {
617 const MCOperand &Op = MI->getOperand(OpNum);
618 if (Op.getImm())
619 O << "be";
620 else
621 O << "le";
622}
623
Bruno Cardoso Lopesa2b6e412011-02-14 13:09:44 +0000624void ARMInstPrinter::printCPSIMod(const MCInst *MI, unsigned OpNum,
625 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000626 const MCOperand &Op = MI->getOperand(OpNum);
Bruno Cardoso Lopesa2b6e412011-02-14 13:09:44 +0000627 O << ARM_PROC::IModToString(Op.getImm());
628}
629
630void ARMInstPrinter::printCPSIFlag(const MCInst *MI, unsigned OpNum,
631 raw_ostream &O) {
632 const MCOperand &Op = MI->getOperand(OpNum);
633 unsigned IFlags = Op.getImm();
634 for (int i=2; i >= 0; --i)
635 if (IFlags & (1 << i))
636 O << ARM_PROC::IFlagsToString(1 << i);
Owen Anderson2dbb46a2011-10-05 17:16:40 +0000637
638 if (IFlags == 0)
639 O << "none";
Johnny Chen9e088762010-03-17 17:52:21 +0000640}
641
Chris Lattner35c33bd2010-04-04 04:47:45 +0000642void ARMInstPrinter::printMSRMaskOperand(const MCInst *MI, unsigned OpNum,
643 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000644 const MCOperand &Op = MI->getOperand(OpNum);
Bruno Cardoso Lopes584bf7b2011-02-18 19:45:59 +0000645 unsigned SpecRegRBit = Op.getImm() >> 4;
646 unsigned Mask = Op.getImm() & 0xf;
647
James Molloyacad68d2011-09-28 14:21:38 +0000648 if (getAvailableFeatures() & ARM::FeatureMClass) {
649 switch (Op.getImm()) {
Craig Topperbc219812012-02-07 02:50:20 +0000650 default: llvm_unreachable("Unexpected mask value!");
James Molloyacad68d2011-09-28 14:21:38 +0000651 case 0: O << "apsr"; return;
652 case 1: O << "iapsr"; return;
653 case 2: O << "eapsr"; return;
654 case 3: O << "xpsr"; return;
655 case 5: O << "ipsr"; return;
656 case 6: O << "epsr"; return;
657 case 7: O << "iepsr"; return;
658 case 8: O << "msp"; return;
659 case 9: O << "psp"; return;
660 case 16: O << "primask"; return;
661 case 17: O << "basepri"; return;
662 case 18: O << "basepri_max"; return;
663 case 19: O << "faultmask"; return;
664 case 20: O << "control"; return;
665 }
666 }
667
Jim Grosbachb29b4dd2011-07-19 22:45:10 +0000668 // As special cases, CPSR_f, CPSR_s and CPSR_fs prefer printing as
669 // APSR_nzcvq, APSR_g and APSRnzcvqg, respectively.
670 if (!SpecRegRBit && (Mask == 8 || Mask == 4 || Mask == 12)) {
671 O << "APSR_";
672 switch (Mask) {
Craig Topperbc219812012-02-07 02:50:20 +0000673 default: llvm_unreachable("Unexpected mask value!");
Jim Grosbachb29b4dd2011-07-19 22:45:10 +0000674 case 4: O << "g"; return;
675 case 8: O << "nzcvq"; return;
676 case 12: O << "nzcvqg"; return;
677 }
Jim Grosbachb29b4dd2011-07-19 22:45:10 +0000678 }
679
Bruno Cardoso Lopes584bf7b2011-02-18 19:45:59 +0000680 if (SpecRegRBit)
Jim Grosbachb29b4dd2011-07-19 22:45:10 +0000681 O << "SPSR";
Bruno Cardoso Lopes584bf7b2011-02-18 19:45:59 +0000682 else
Jim Grosbachb29b4dd2011-07-19 22:45:10 +0000683 O << "CPSR";
Bruno Cardoso Lopes584bf7b2011-02-18 19:45:59 +0000684
Johnny Chen9e088762010-03-17 17:52:21 +0000685 if (Mask) {
686 O << '_';
687 if (Mask & 8) O << 'f';
688 if (Mask & 4) O << 's';
689 if (Mask & 2) O << 'x';
690 if (Mask & 1) O << 'c';
691 }
692}
693
Chris Lattner35c33bd2010-04-04 04:47:45 +0000694void ARMInstPrinter::printPredicateOperand(const MCInst *MI, unsigned OpNum,
695 raw_ostream &O) {
Chris Lattner413ae252009-10-20 00:42:49 +0000696 ARMCC::CondCodes CC = (ARMCC::CondCodes)MI->getOperand(OpNum).getImm();
Kevin Enderbyb0578512012-03-01 22:13:02 +0000697 // Handle the undefined 15 CC value here for printing so we don't abort().
698 if ((unsigned)CC == 15)
699 O << "<und>";
700 else if (CC != ARMCC::AL)
Chris Lattner413ae252009-10-20 00:42:49 +0000701 O << ARMCondCodeToString(CC);
702}
703
Jim Grosbach15d78982010-09-14 22:27:15 +0000704void ARMInstPrinter::printMandatoryPredicateOperand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000705 unsigned OpNum,
706 raw_ostream &O) {
Johnny Chen9d3acaa2010-03-02 17:57:15 +0000707 ARMCC::CondCodes CC = (ARMCC::CondCodes)MI->getOperand(OpNum).getImm();
708 O << ARMCondCodeToString(CC);
709}
710
Chris Lattner35c33bd2010-04-04 04:47:45 +0000711void ARMInstPrinter::printSBitModifierOperand(const MCInst *MI, unsigned OpNum,
712 raw_ostream &O) {
Daniel Dunbara7cc6522009-10-20 22:10:05 +0000713 if (MI->getOperand(OpNum).getReg()) {
714 assert(MI->getOperand(OpNum).getReg() == ARM::CPSR &&
715 "Expect ARM CPSR register!");
Chris Lattner233917c2009-10-20 00:46:11 +0000716 O << 's';
717 }
718}
719
Chris Lattner35c33bd2010-04-04 04:47:45 +0000720void ARMInstPrinter::printNoHashImmediate(const MCInst *MI, unsigned OpNum,
721 raw_ostream &O) {
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000722 O << MI->getOperand(OpNum).getImm();
723}
724
Owen Andersone4e5e2a2011-01-13 21:46:02 +0000725void ARMInstPrinter::printPImmediate(const MCInst *MI, unsigned OpNum,
Jim Grosbachbc9c8022011-10-12 16:34:37 +0000726 raw_ostream &O) {
Owen Andersone4e5e2a2011-01-13 21:46:02 +0000727 O << "p" << MI->getOperand(OpNum).getImm();
728}
729
730void ARMInstPrinter::printCImmediate(const MCInst *MI, unsigned OpNum,
Jim Grosbachbc9c8022011-10-12 16:34:37 +0000731 raw_ostream &O) {
Owen Andersone4e5e2a2011-01-13 21:46:02 +0000732 O << "c" << MI->getOperand(OpNum).getImm();
733}
734
Jim Grosbach9b8f2a02011-10-12 17:34:41 +0000735void ARMInstPrinter::printCoprocOptionImm(const MCInst *MI, unsigned OpNum,
736 raw_ostream &O) {
737 O << "{" << MI->getOperand(OpNum).getImm() << "}";
738}
739
Chris Lattner35c33bd2010-04-04 04:47:45 +0000740void ARMInstPrinter::printPCLabel(const MCInst *MI, unsigned OpNum,
741 raw_ostream &O) {
Jim Grosbachd30cfde2010-09-18 00:04:53 +0000742 llvm_unreachable("Unhandled PC-relative pseudo-instruction!");
Chris Lattner4d152222009-10-19 22:23:04 +0000743}
Evan Cheng2ef9c8a2009-11-19 06:57:41 +0000744
Chris Lattner35c33bd2010-04-04 04:47:45 +0000745void ARMInstPrinter::printThumbS4ImmOperand(const MCInst *MI, unsigned OpNum,
746 raw_ostream &O) {
Jim Grosbach70939ee2011-08-17 21:51:27 +0000747 O << "#" << MI->getOperand(OpNum).getImm() * 4;
748}
749
750void ARMInstPrinter::printThumbSRImm(const MCInst *MI, unsigned OpNum,
751 raw_ostream &O) {
752 unsigned Imm = MI->getOperand(OpNum).getImm();
753 O << "#" << (Imm == 0 ? 32 : Imm);
Evan Cheng2ef9c8a2009-11-19 06:57:41 +0000754}
Johnny Chen9e088762010-03-17 17:52:21 +0000755
Chris Lattner35c33bd2010-04-04 04:47:45 +0000756void ARMInstPrinter::printThumbITMask(const MCInst *MI, unsigned OpNum,
757 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000758 // (3 - the number of trailing zeros) is the number of then / else.
759 unsigned Mask = MI->getOperand(OpNum).getImm();
760 unsigned CondBit0 = Mask >> 4 & 1;
761 unsigned NumTZ = CountTrailingZeros_32(Mask);
762 assert(NumTZ <= 3 && "Invalid IT mask!");
763 for (unsigned Pos = 3, e = NumTZ; Pos > e; --Pos) {
764 bool T = ((Mask >> Pos) & 1) == CondBit0;
765 if (T)
766 O << 't';
767 else
768 O << 'e';
769 }
770}
771
Chris Lattner35c33bd2010-04-04 04:47:45 +0000772void ARMInstPrinter::printThumbAddrModeRROperand(const MCInst *MI, unsigned Op,
773 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000774 const MCOperand &MO1 = MI->getOperand(Op);
Bill Wendlingf4caf692010-12-14 03:36:38 +0000775 const MCOperand &MO2 = MI->getOperand(Op + 1);
Johnny Chen9e088762010-03-17 17:52:21 +0000776
777 if (!MO1.isReg()) { // FIXME: This is for CP entries, but isn't right.
Chris Lattner35c33bd2010-04-04 04:47:45 +0000778 printOperand(MI, Op, O);
Johnny Chen9e088762010-03-17 17:52:21 +0000779 return;
780 }
781
782 O << "[" << getRegisterName(MO1.getReg());
Bill Wendlingf4caf692010-12-14 03:36:38 +0000783 if (unsigned RegNum = MO2.getReg())
784 O << ", " << getRegisterName(RegNum);
785 O << "]";
786}
787
788void ARMInstPrinter::printThumbAddrModeImm5SOperand(const MCInst *MI,
789 unsigned Op,
790 raw_ostream &O,
791 unsigned Scale) {
792 const MCOperand &MO1 = MI->getOperand(Op);
793 const MCOperand &MO2 = MI->getOperand(Op + 1);
794
795 if (!MO1.isReg()) { // FIXME: This is for CP entries, but isn't right.
796 printOperand(MI, Op, O);
797 return;
798 }
799
800 O << "[" << getRegisterName(MO1.getReg());
801 if (unsigned ImmOffs = MO2.getImm())
Johnny Chen9e088762010-03-17 17:52:21 +0000802 O << ", #" << ImmOffs * Scale;
803 O << "]";
804}
805
Bill Wendlingf4caf692010-12-14 03:36:38 +0000806void ARMInstPrinter::printThumbAddrModeImm5S1Operand(const MCInst *MI,
807 unsigned Op,
808 raw_ostream &O) {
809 printThumbAddrModeImm5SOperand(MI, Op, O, 1);
Johnny Chen9e088762010-03-17 17:52:21 +0000810}
811
Bill Wendlingf4caf692010-12-14 03:36:38 +0000812void ARMInstPrinter::printThumbAddrModeImm5S2Operand(const MCInst *MI,
813 unsigned Op,
814 raw_ostream &O) {
815 printThumbAddrModeImm5SOperand(MI, Op, O, 2);
Johnny Chen9e088762010-03-17 17:52:21 +0000816}
817
Bill Wendlingf4caf692010-12-14 03:36:38 +0000818void ARMInstPrinter::printThumbAddrModeImm5S4Operand(const MCInst *MI,
819 unsigned Op,
820 raw_ostream &O) {
821 printThumbAddrModeImm5SOperand(MI, Op, O, 4);
Johnny Chen9e088762010-03-17 17:52:21 +0000822}
823
Chris Lattner35c33bd2010-04-04 04:47:45 +0000824void ARMInstPrinter::printThumbAddrModeSPOperand(const MCInst *MI, unsigned Op,
825 raw_ostream &O) {
Bill Wendlingf4caf692010-12-14 03:36:38 +0000826 printThumbAddrModeImm5SOperand(MI, Op, O, 4);
Johnny Chen9e088762010-03-17 17:52:21 +0000827}
828
Johnny Chen9e088762010-03-17 17:52:21 +0000829// Constant shifts t2_so_reg is a 2-operand unit corresponding to the Thumb2
830// register with shift forms.
831// REG 0 0 - e.g. R5
832// REG IMM, SH_OPC - e.g. R5, LSL #3
Chris Lattner35c33bd2010-04-04 04:47:45 +0000833void ARMInstPrinter::printT2SOOperand(const MCInst *MI, unsigned OpNum,
834 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000835 const MCOperand &MO1 = MI->getOperand(OpNum);
836 const MCOperand &MO2 = MI->getOperand(OpNum+1);
837
838 unsigned Reg = MO1.getReg();
839 O << getRegisterName(Reg);
840
841 // Print the shift opc.
Johnny Chen9e088762010-03-17 17:52:21 +0000842 assert(MO2.isImm() && "Not a valid t2_so_reg value!");
Bob Wilson1d9125a2010-08-05 00:34:42 +0000843 ARM_AM::ShiftOpc ShOpc = ARM_AM::getSORegShOp(MO2.getImm());
844 O << ", " << ARM_AM::getShiftOpcStr(ShOpc);
845 if (ShOpc != ARM_AM::rrx)
Owen Anderson3dac0be2011-08-11 18:41:59 +0000846 O << " #" << translateShiftImm(ARM_AM::getSORegOffset(MO2.getImm()));
Johnny Chen9e088762010-03-17 17:52:21 +0000847}
848
Jim Grosbach458f2dc2010-10-25 20:00:01 +0000849void ARMInstPrinter::printAddrModeImm12Operand(const MCInst *MI, unsigned OpNum,
850 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000851 const MCOperand &MO1 = MI->getOperand(OpNum);
852 const MCOperand &MO2 = MI->getOperand(OpNum+1);
853
Jim Grosbach3e556122010-10-26 22:37:02 +0000854 if (!MO1.isReg()) { // FIXME: This is for CP entries, but isn't right.
855 printOperand(MI, OpNum, O);
856 return;
857 }
858
Johnny Chen9e088762010-03-17 17:52:21 +0000859 O << "[" << getRegisterName(MO1.getReg());
860
Jim Grosbach77aee8e2010-10-27 01:19:41 +0000861 int32_t OffImm = (int32_t)MO2.getImm();
Jim Grosbachab682a22010-10-28 18:34:10 +0000862 bool isSub = OffImm < 0;
863 // Special value for #-0. All others are normal.
864 if (OffImm == INT32_MIN)
865 OffImm = 0;
866 if (isSub)
Jim Grosbach77aee8e2010-10-27 01:19:41 +0000867 O << ", #-" << -OffImm;
868 else if (OffImm > 0)
Johnny Chen9e088762010-03-17 17:52:21 +0000869 O << ", #" << OffImm;
870 O << "]";
871}
872
873void ARMInstPrinter::printT2AddrModeImm8Operand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000874 unsigned OpNum,
875 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000876 const MCOperand &MO1 = MI->getOperand(OpNum);
877 const MCOperand &MO2 = MI->getOperand(OpNum+1);
878
879 O << "[" << getRegisterName(MO1.getReg());
880
881 int32_t OffImm = (int32_t)MO2.getImm();
882 // Don't print +0.
Owen Anderson705b48f2011-09-16 21:08:33 +0000883 if (OffImm == INT32_MIN)
884 O << ", #-0";
885 else if (OffImm < 0)
Johnny Chen9e088762010-03-17 17:52:21 +0000886 O << ", #-" << -OffImm;
887 else if (OffImm > 0)
888 O << ", #" << OffImm;
889 O << "]";
890}
891
892void ARMInstPrinter::printT2AddrModeImm8s4Operand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000893 unsigned OpNum,
894 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000895 const MCOperand &MO1 = MI->getOperand(OpNum);
896 const MCOperand &MO2 = MI->getOperand(OpNum+1);
897
Jim Grosbach2f196742011-12-19 23:06:24 +0000898 if (!MO1.isReg()) { // For label symbolic references.
899 printOperand(MI, OpNum, O);
900 return;
901 }
902
Johnny Chen9e088762010-03-17 17:52:21 +0000903 O << "[" << getRegisterName(MO1.getReg());
904
905 int32_t OffImm = (int32_t)MO2.getImm() / 4;
906 // Don't print +0.
907 if (OffImm < 0)
908 O << ", #-" << -OffImm * 4;
909 else if (OffImm > 0)
910 O << ", #" << OffImm * 4;
911 O << "]";
912}
913
Jim Grosbachb6aed502011-09-09 18:37:27 +0000914void ARMInstPrinter::printT2AddrModeImm0_1020s4Operand(const MCInst *MI,
915 unsigned OpNum,
916 raw_ostream &O) {
917 const MCOperand &MO1 = MI->getOperand(OpNum);
918 const MCOperand &MO2 = MI->getOperand(OpNum+1);
919
920 O << "[" << getRegisterName(MO1.getReg());
921 if (MO2.getImm())
922 O << ", #" << MO2.getImm() * 4;
923 O << "]";
924}
925
Johnny Chen9e088762010-03-17 17:52:21 +0000926void ARMInstPrinter::printT2AddrModeImm8OffsetOperand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000927 unsigned OpNum,
928 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000929 const MCOperand &MO1 = MI->getOperand(OpNum);
930 int32_t OffImm = (int32_t)MO1.getImm();
931 // Don't print +0.
932 if (OffImm < 0)
Owen Anderson0781c1f2011-09-23 21:26:40 +0000933 O << ", #-" << -OffImm;
934 else
935 O << ", #" << OffImm;
Johnny Chen9e088762010-03-17 17:52:21 +0000936}
937
938void ARMInstPrinter::printT2AddrModeImm8s4OffsetOperand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000939 unsigned OpNum,
940 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000941 const MCOperand &MO1 = MI->getOperand(OpNum);
942 int32_t OffImm = (int32_t)MO1.getImm() / 4;
943 // Don't print +0.
Owen Anderson7782a582011-09-13 20:46:26 +0000944 if (OffImm != 0) {
945 O << ", ";
946 if (OffImm < 0)
947 O << "#-" << -OffImm * 4;
948 else if (OffImm > 0)
949 O << "#" << OffImm * 4;
950 }
Johnny Chen9e088762010-03-17 17:52:21 +0000951}
952
953void ARMInstPrinter::printT2AddrModeSoRegOperand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000954 unsigned OpNum,
955 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000956 const MCOperand &MO1 = MI->getOperand(OpNum);
957 const MCOperand &MO2 = MI->getOperand(OpNum+1);
958 const MCOperand &MO3 = MI->getOperand(OpNum+2);
959
960 O << "[" << getRegisterName(MO1.getReg());
961
962 assert(MO2.getReg() && "Invalid so_reg load / store address!");
963 O << ", " << getRegisterName(MO2.getReg());
964
965 unsigned ShAmt = MO3.getImm();
966 if (ShAmt) {
967 assert(ShAmt <= 3 && "Not a valid Thumb2 addressing mode!");
968 O << ", lsl #" << ShAmt;
969 }
970 O << "]";
971}
972
Jim Grosbach4ebbf7b2011-09-30 00:50:06 +0000973void ARMInstPrinter::printFPImmOperand(const MCInst *MI, unsigned OpNum,
974 raw_ostream &O) {
Bill Wendling8cb415e2011-01-26 20:57:43 +0000975 const MCOperand &MO = MI->getOperand(OpNum);
Jim Grosbach4ebbf7b2011-09-30 00:50:06 +0000976 O << '#' << ARM_AM::getFPImmFloat(MO.getImm());
Johnny Chen9e088762010-03-17 17:52:21 +0000977}
978
Bob Wilson1a913ed2010-06-11 21:34:50 +0000979void ARMInstPrinter::printNEONModImmOperand(const MCInst *MI, unsigned OpNum,
980 raw_ostream &O) {
Bob Wilson6dce00c2010-07-13 04:44:34 +0000981 unsigned EncodedImm = MI->getOperand(OpNum).getImm();
982 unsigned EltBits;
983 uint64_t Val = ARM_AM::decodeNEONModImm(EncodedImm, EltBits);
Benjamin Kramer70be28a2011-11-07 21:00:59 +0000984 O << "#0x";
985 O.write_hex(Val);
Johnny Chenc7b65912010-04-16 22:40:20 +0000986}
Jim Grosbach4a5ffb32011-07-22 23:16:18 +0000987
Jim Grosbachf4943352011-07-25 23:09:14 +0000988void ARMInstPrinter::printImmPlusOneOperand(const MCInst *MI, unsigned OpNum,
989 raw_ostream &O) {
Jim Grosbach4a5ffb32011-07-22 23:16:18 +0000990 unsigned Imm = MI->getOperand(OpNum).getImm();
991 O << "#" << Imm + 1;
992}
Jim Grosbach85bfd3b2011-07-26 21:28:43 +0000993
994void ARMInstPrinter::printRotImmOperand(const MCInst *MI, unsigned OpNum,
995 raw_ostream &O) {
996 unsigned Imm = MI->getOperand(OpNum).getImm();
997 if (Imm == 0)
998 return;
Jim Grosbach45f39292011-07-26 21:44:37 +0000999 O << ", ror #";
Jim Grosbach85bfd3b2011-07-26 21:28:43 +00001000 switch (Imm) {
1001 default: assert (0 && "illegal ror immediate!");
Jim Grosbach2f815c02011-08-17 23:23:07 +00001002 case 1: O << "8"; break;
1003 case 2: O << "16"; break;
1004 case 3: O << "24"; break;
Jim Grosbach85bfd3b2011-07-26 21:28:43 +00001005 }
1006}
Jim Grosbach460a9052011-10-07 23:56:00 +00001007
Jim Grosbach4050bc42011-12-22 22:19:05 +00001008void ARMInstPrinter::printFBits16(const MCInst *MI, unsigned OpNum,
1009 raw_ostream &O) {
1010 O << "#" << 16 - MI->getOperand(OpNum).getImm();
1011}
1012
1013void ARMInstPrinter::printFBits32(const MCInst *MI, unsigned OpNum,
1014 raw_ostream &O) {
1015 O << "#" << 32 - MI->getOperand(OpNum).getImm();
1016}
1017
Jim Grosbach460a9052011-10-07 23:56:00 +00001018void ARMInstPrinter::printVectorIndex(const MCInst *MI, unsigned OpNum,
1019 raw_ostream &O) {
1020 O << "[" << MI->getOperand(OpNum).getImm() << "]";
1021}
Jim Grosbach862019c2011-10-18 23:02:30 +00001022
1023void ARMInstPrinter::printVectorListOne(const MCInst *MI, unsigned OpNum,
1024 raw_ostream &O) {
1025 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << "}";
1026}
Jim Grosbach280dfad2011-10-21 18:54:25 +00001027
Jim Grosbachc0fc4502012-03-06 22:01:44 +00001028void ARMInstPrinter::printVectorListTwo(const MCInst *MI, unsigned OpNum,
Jim Grosbach28f08c92012-03-05 19:33:30 +00001029 raw_ostream &O) {
1030 unsigned Reg = MI->getOperand(OpNum).getReg();
1031 unsigned Reg0 = MRI.getSubReg(Reg, ARM::dsub_0);
1032 unsigned Reg1 = MRI.getSubReg(Reg, ARM::dsub_1);
1033 O << "{" << getRegisterName(Reg0) << ", " << getRegisterName(Reg1) << "}";
1034}
1035
Jim Grosbachc0fc4502012-03-06 22:01:44 +00001036void ARMInstPrinter::printVectorListTwoSpaced(const MCInst *MI,
1037 unsigned OpNum,
1038 raw_ostream &O) {
Jim Grosbachc3384c92012-03-05 21:43:40 +00001039 unsigned Reg = MI->getOperand(OpNum).getReg();
1040 unsigned Reg0 = MRI.getSubReg(Reg, ARM::dsub_0);
1041 unsigned Reg1 = MRI.getSubReg(Reg, ARM::dsub_2);
1042 O << "{" << getRegisterName(Reg0) << ", " << getRegisterName(Reg1) << "}";
1043}
1044
Jim Grosbachcdcfa282011-10-21 20:02:19 +00001045void ARMInstPrinter::printVectorListThree(const MCInst *MI, unsigned OpNum,
1046 raw_ostream &O) {
1047 // Normally, it's not safe to use register enum values directly with
1048 // addition to get the next register, but for VFP registers, the
1049 // sort order is guaranteed because they're all of the form D<n>.
1050 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << ", "
1051 << getRegisterName(MI->getOperand(OpNum).getReg() + 1) << ", "
1052 << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << "}";
1053}
Jim Grosbachb6310312011-10-21 20:35:01 +00001054
1055void ARMInstPrinter::printVectorListFour(const MCInst *MI, unsigned OpNum,
1056 raw_ostream &O) {
1057 // Normally, it's not safe to use register enum values directly with
1058 // addition to get the next register, but for VFP registers, the
1059 // sort order is guaranteed because they're all of the form D<n>.
1060 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << ", "
1061 << getRegisterName(MI->getOperand(OpNum).getReg() + 1) << ", "
1062 << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << ", "
1063 << getRegisterName(MI->getOperand(OpNum).getReg() + 3) << "}";
1064}
Jim Grosbach98b05a52011-11-30 01:09:44 +00001065
1066void ARMInstPrinter::printVectorListOneAllLanes(const MCInst *MI,
1067 unsigned OpNum,
1068 raw_ostream &O) {
1069 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << "[]}";
1070}
1071
Jim Grosbach13af2222011-11-30 18:21:25 +00001072void ARMInstPrinter::printVectorListTwoAllLanes(const MCInst *MI,
1073 unsigned OpNum,
1074 raw_ostream &O) {
Jim Grosbachc0fc4502012-03-06 22:01:44 +00001075 unsigned Reg = MI->getOperand(OpNum).getReg();
1076 unsigned Reg0 = MRI.getSubReg(Reg, ARM::dsub_0);
1077 unsigned Reg1 = MRI.getSubReg(Reg, ARM::dsub_1);
1078 O << "{" << getRegisterName(Reg0) << "[], " << getRegisterName(Reg1) << "[]}";
Jim Grosbach13af2222011-11-30 18:21:25 +00001079}
Jim Grosbache90ac9b2011-12-14 19:35:22 +00001080
Jim Grosbach5e59f7e2012-01-24 23:47:04 +00001081void ARMInstPrinter::printVectorListThreeAllLanes(const MCInst *MI,
1082 unsigned OpNum,
1083 raw_ostream &O) {
1084 // Normally, it's not safe to use register enum values directly with
1085 // addition to get the next register, but for VFP registers, the
1086 // sort order is guaranteed because they're all of the form D<n>.
1087 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << "[], "
1088 << getRegisterName(MI->getOperand(OpNum).getReg() + 1) << "[], "
1089 << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << "[]}";
1090}
1091
Jim Grosbacha57a36a2012-01-25 00:01:08 +00001092void ARMInstPrinter::printVectorListFourAllLanes(const MCInst *MI,
1093 unsigned OpNum,
1094 raw_ostream &O) {
1095 // Normally, it's not safe to use register enum values directly with
1096 // addition to get the next register, but for VFP registers, the
1097 // sort order is guaranteed because they're all of the form D<n>.
1098 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << "[], "
1099 << getRegisterName(MI->getOperand(OpNum).getReg() + 1) << "[], "
1100 << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << "[], "
1101 << getRegisterName(MI->getOperand(OpNum).getReg() + 3) << "[]}";
1102}
1103
Jim Grosbach3471d4f2011-12-21 00:38:54 +00001104void ARMInstPrinter::printVectorListTwoSpacedAllLanes(const MCInst *MI,
1105 unsigned OpNum,
1106 raw_ostream &O) {
Jim Grosbach4d0983a2012-03-06 23:10:38 +00001107 unsigned Reg = MI->getOperand(OpNum).getReg();
1108 unsigned Reg0 = MRI.getSubReg(Reg, ARM::dsub_0);
1109 unsigned Reg1 = MRI.getSubReg(Reg, ARM::dsub_2);
1110 O << "{" << getRegisterName(Reg0) << "[], " << getRegisterName(Reg1) << "[]}";
Jim Grosbach3471d4f2011-12-21 00:38:54 +00001111}
1112
Jim Grosbach5e59f7e2012-01-24 23:47:04 +00001113void ARMInstPrinter::printVectorListThreeSpacedAllLanes(const MCInst *MI,
1114 unsigned OpNum,
1115 raw_ostream &O) {
1116 // Normally, it's not safe to use register enum values directly with
1117 // addition to get the next register, but for VFP registers, the
1118 // sort order is guaranteed because they're all of the form D<n>.
1119 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << "[], "
1120 << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << "[], "
Jim Grosbacha57a36a2012-01-25 00:01:08 +00001121 << getRegisterName(MI->getOperand(OpNum).getReg() + 4) << "[]}";
1122}
1123
1124void ARMInstPrinter::printVectorListFourSpacedAllLanes(const MCInst *MI,
1125 unsigned OpNum,
1126 raw_ostream &O) {
1127 // Normally, it's not safe to use register enum values directly with
1128 // addition to get the next register, but for VFP registers, the
1129 // sort order is guaranteed because they're all of the form D<n>.
1130 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << "[], "
1131 << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << "[], "
1132 << getRegisterName(MI->getOperand(OpNum).getReg() + 4) << "[], "
1133 << getRegisterName(MI->getOperand(OpNum).getReg() + 6) << "[]}";
Jim Grosbach5e59f7e2012-01-24 23:47:04 +00001134}
1135
Jim Grosbachc387fc62012-01-23 23:20:46 +00001136void ARMInstPrinter::printVectorListThreeSpaced(const MCInst *MI,
1137 unsigned OpNum,
1138 raw_ostream &O) {
1139 // Normally, it's not safe to use register enum values directly with
1140 // addition to get the next register, but for VFP registers, the
1141 // sort order is guaranteed because they're all of the form D<n>.
1142 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << ", "
1143 << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << ", "
1144 << getRegisterName(MI->getOperand(OpNum).getReg() + 4) << "}";
1145}
Jim Grosbach8abe7e32012-01-24 00:43:17 +00001146
1147void ARMInstPrinter::printVectorListFourSpaced(const MCInst *MI,
1148 unsigned OpNum,
1149 raw_ostream &O) {
1150 // Normally, it's not safe to use register enum values directly with
1151 // addition to get the next register, but for VFP registers, the
1152 // sort order is guaranteed because they're all of the form D<n>.
1153 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << ", "
1154 << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << ", "
1155 << getRegisterName(MI->getOperand(OpNum).getReg() + 4) << ", "
1156 << getRegisterName(MI->getOperand(OpNum).getReg() + 6) << "}";
1157}