blob: b654a75a2ebf1f0c8ef53f72f8f1ede8c766190e [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"
Craig Topper7c0b3c12012-04-02 07:01:04 +000021#include "llvm/MC/MCInstrInfo.h"
Jim Grosbach28f08c92012-03-05 19:33:30 +000022#include "llvm/MC/MCRegisterInfo.h"
Chris Lattner6f997762009-10-19 21:53:00 +000023#include "llvm/Support/raw_ostream.h"
Chris Lattnerfd603822009-10-19 19:56:26 +000024using namespace llvm;
25
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,
Craig Topper17463b32012-04-02 06:09:36 +000039 const MCInstrInfo &MII,
Jim Grosbachc6449b62012-03-05 19:33:20 +000040 const MCRegisterInfo &MRI,
James Molloyb9505852011-09-07 17:24:38 +000041 const MCSubtargetInfo &STI) :
Craig Topper17463b32012-04-02 06:09:36 +000042 MCInstPrinter(MAI, MII, MRI) {
James Molloyb9505852011-09-07 17:24:38 +000043 // Initialize the set of available features.
44 setAvailableFeatures(STI.getFeatureBits());
45}
46
Chris Lattner6274ec42010-10-28 21:37:33 +000047StringRef ARMInstPrinter::getOpcodeName(unsigned Opcode) const {
Craig Topper7c0b3c12012-04-02 07:01:04 +000048 return MII.getName(Opcode);
Chris Lattner6274ec42010-10-28 21:37:33 +000049}
50
Rafael Espindolacde4ce42011-06-02 02:34:55 +000051void ARMInstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const {
52 OS << getRegisterName(RegNo);
Anton Korobeynikov57caad72011-03-05 18:43:32 +000053}
Chris Lattner6274ec42010-10-28 21:37:33 +000054
Owen Anderson98c5dda2011-09-15 23:38:46 +000055void ARMInstPrinter::printInst(const MCInst *MI, raw_ostream &O,
56 StringRef Annot) {
Bill Wendling04863d02010-11-13 10:40:19 +000057 unsigned Opcode = MI->getOpcode();
58
Johnny Chen9e088762010-03-17 17:52:21 +000059 // Check for MOVs and print canonical forms, instead.
Owen Anderson152d4a42011-07-21 23:38:37 +000060 if (Opcode == ARM::MOVsr) {
Jim Grosbache6be85e2010-09-17 22:36:38 +000061 // FIXME: Thumb variants?
Johnny Chen9e088762010-03-17 17:52:21 +000062 const MCOperand &Dst = MI->getOperand(0);
63 const MCOperand &MO1 = MI->getOperand(1);
64 const MCOperand &MO2 = MI->getOperand(2);
65 const MCOperand &MO3 = MI->getOperand(3);
66
67 O << '\t' << ARM_AM::getShiftOpcStr(ARM_AM::getSORegShOp(MO3.getImm()));
Chris Lattner35c33bd2010-04-04 04:47:45 +000068 printSBitModifierOperand(MI, 6, O);
69 printPredicateOperand(MI, 4, O);
Johnny Chen9e088762010-03-17 17:52:21 +000070
71 O << '\t' << getRegisterName(Dst.getReg())
72 << ", " << getRegisterName(MO1.getReg());
73
Owen Anderson152d4a42011-07-21 23:38:37 +000074 O << ", " << getRegisterName(MO2.getReg());
75 assert(ARM_AM::getSORegOffset(MO3.getImm()) == 0);
Owen Anderson519020a2011-09-21 17:58:45 +000076 printAnnotation(O, Annot);
Johnny Chen9e088762010-03-17 17:52:21 +000077 return;
78 }
79
Owen Anderson152d4a42011-07-21 23:38:37 +000080 if (Opcode == ARM::MOVsi) {
81 // FIXME: Thumb variants?
82 const MCOperand &Dst = MI->getOperand(0);
83 const MCOperand &MO1 = MI->getOperand(1);
84 const MCOperand &MO2 = MI->getOperand(2);
85
86 O << '\t' << ARM_AM::getShiftOpcStr(ARM_AM::getSORegShOp(MO2.getImm()));
87 printSBitModifierOperand(MI, 5, O);
88 printPredicateOperand(MI, 3, O);
89
90 O << '\t' << getRegisterName(Dst.getReg())
91 << ", " << getRegisterName(MO1.getReg());
92
Owen Andersonede042d2011-09-15 18:36:29 +000093 if (ARM_AM::getSORegShOp(MO2.getImm()) == ARM_AM::rrx) {
Owen Anderson519020a2011-09-21 17:58:45 +000094 printAnnotation(O, Annot);
Owen Anderson152d4a42011-07-21 23:38:37 +000095 return;
Owen Andersonede042d2011-09-15 18:36:29 +000096 }
Owen Anderson152d4a42011-07-21 23:38:37 +000097
Owen Anderson3dac0be2011-08-11 18:41:59 +000098 O << ", #" << translateShiftImm(ARM_AM::getSORegOffset(MO2.getImm()));
Owen Anderson519020a2011-09-21 17:58:45 +000099 printAnnotation(O, Annot);
Owen Anderson152d4a42011-07-21 23:38:37 +0000100 return;
101 }
102
103
Johnny Chen9e088762010-03-17 17:52:21 +0000104 // A8.6.123 PUSH
Bill Wendling73fe34a2010-11-16 01:16:36 +0000105 if ((Opcode == ARM::STMDB_UPD || Opcode == ARM::t2STMDB_UPD) &&
Owen Anderson81550dc2011-11-02 18:03:14 +0000106 MI->getOperand(0).getReg() == ARM::SP &&
107 MI->getNumOperands() > 5) {
108 // Should only print PUSH if there are at least two registers in the list.
Bill Wendling73fe34a2010-11-16 01:16:36 +0000109 O << '\t' << "push";
110 printPredicateOperand(MI, 2, O);
Jim Grosbach41ad0c42010-12-03 20:33:01 +0000111 if (Opcode == ARM::t2STMDB_UPD)
112 O << ".w";
Bill Wendling73fe34a2010-11-16 01:16:36 +0000113 O << '\t';
114 printRegisterList(MI, 4, O);
Owen Anderson519020a2011-09-21 17:58:45 +0000115 printAnnotation(O, Annot);
Bill Wendling73fe34a2010-11-16 01:16:36 +0000116 return;
Johnny Chen9e088762010-03-17 17:52:21 +0000117 }
Jim Grosbachf6713912011-08-11 18:07:11 +0000118 if (Opcode == ARM::STR_PRE_IMM && MI->getOperand(2).getReg() == ARM::SP &&
119 MI->getOperand(3).getImm() == -4) {
120 O << '\t' << "push";
121 printPredicateOperand(MI, 4, O);
122 O << "\t{" << getRegisterName(MI->getOperand(1).getReg()) << "}";
Owen Anderson519020a2011-09-21 17:58:45 +0000123 printAnnotation(O, Annot);
Jim Grosbachf6713912011-08-11 18:07:11 +0000124 return;
125 }
Johnny Chen9e088762010-03-17 17:52:21 +0000126
127 // A8.6.122 POP
Bill Wendling73fe34a2010-11-16 01:16:36 +0000128 if ((Opcode == ARM::LDMIA_UPD || Opcode == ARM::t2LDMIA_UPD) &&
Owen Anderson81550dc2011-11-02 18:03:14 +0000129 MI->getOperand(0).getReg() == ARM::SP &&
130 MI->getNumOperands() > 5) {
131 // Should only print POP if there are at least two registers in the list.
Bill Wendling73fe34a2010-11-16 01:16:36 +0000132 O << '\t' << "pop";
133 printPredicateOperand(MI, 2, O);
Jim Grosbach41ad0c42010-12-03 20:33:01 +0000134 if (Opcode == ARM::t2LDMIA_UPD)
135 O << ".w";
Bill Wendling73fe34a2010-11-16 01:16:36 +0000136 O << '\t';
137 printRegisterList(MI, 4, O);
Owen Anderson519020a2011-09-21 17:58:45 +0000138 printAnnotation(O, Annot);
Bill Wendling73fe34a2010-11-16 01:16:36 +0000139 return;
Johnny Chen9e088762010-03-17 17:52:21 +0000140 }
Jim Grosbachf8fce712011-08-11 17:35:48 +0000141 if (Opcode == ARM::LDR_POST_IMM && MI->getOperand(2).getReg() == ARM::SP &&
142 MI->getOperand(4).getImm() == 4) {
143 O << '\t' << "pop";
144 printPredicateOperand(MI, 5, O);
145 O << "\t{" << getRegisterName(MI->getOperand(0).getReg()) << "}";
Owen Anderson519020a2011-09-21 17:58:45 +0000146 printAnnotation(O, Annot);
Jim Grosbachf8fce712011-08-11 17:35:48 +0000147 return;
148 }
149
Johnny Chen9e088762010-03-17 17:52:21 +0000150
151 // A8.6.355 VPUSH
Bill Wendling73fe34a2010-11-16 01:16:36 +0000152 if ((Opcode == ARM::VSTMSDB_UPD || Opcode == ARM::VSTMDDB_UPD) &&
Johnny Chen9e088762010-03-17 17:52:21 +0000153 MI->getOperand(0).getReg() == ARM::SP) {
Bill Wendling73fe34a2010-11-16 01:16:36 +0000154 O << '\t' << "vpush";
155 printPredicateOperand(MI, 2, O);
156 O << '\t';
157 printRegisterList(MI, 4, O);
Owen Anderson519020a2011-09-21 17:58:45 +0000158 printAnnotation(O, Annot);
Bill Wendling73fe34a2010-11-16 01:16:36 +0000159 return;
Johnny Chen9e088762010-03-17 17:52:21 +0000160 }
161
162 // A8.6.354 VPOP
Bill Wendling73fe34a2010-11-16 01:16:36 +0000163 if ((Opcode == ARM::VLDMSIA_UPD || Opcode == ARM::VLDMDIA_UPD) &&
Johnny Chen9e088762010-03-17 17:52:21 +0000164 MI->getOperand(0).getReg() == ARM::SP) {
Bill Wendling73fe34a2010-11-16 01:16:36 +0000165 O << '\t' << "vpop";
166 printPredicateOperand(MI, 2, O);
167 O << '\t';
168 printRegisterList(MI, 4, O);
Owen Anderson519020a2011-09-21 17:58:45 +0000169 printAnnotation(O, Annot);
Bill Wendling73fe34a2010-11-16 01:16:36 +0000170 return;
Johnny Chen9e088762010-03-17 17:52:21 +0000171 }
172
Jim Grosbachcefe4c92011-08-23 17:41:15 +0000173 if (Opcode == ARM::tLDMIA) {
Owen Anderson565a0362011-07-18 23:25:34 +0000174 bool Writeback = true;
175 unsigned BaseReg = MI->getOperand(0).getReg();
176 for (unsigned i = 3; i < MI->getNumOperands(); ++i) {
177 if (MI->getOperand(i).getReg() == BaseReg)
178 Writeback = false;
179 }
180
Jim Grosbachcefe4c92011-08-23 17:41:15 +0000181 O << "\tldm";
Owen Anderson565a0362011-07-18 23:25:34 +0000182
183 printPredicateOperand(MI, 1, O);
184 O << '\t' << getRegisterName(BaseReg);
185 if (Writeback) O << "!";
186 O << ", ";
187 printRegisterList(MI, 3, O);
Owen Anderson519020a2011-09-21 17:58:45 +0000188 printAnnotation(O, Annot);
Owen Anderson565a0362011-07-18 23:25:34 +0000189 return;
190 }
191
Jim Grosbach0780b632011-08-19 23:24:36 +0000192 // Thumb1 NOP
193 if (Opcode == ARM::tMOVr && MI->getOperand(0).getReg() == ARM::R8 &&
194 MI->getOperand(1).getReg() == ARM::R8) {
195 O << "\tnop";
Jim Grosbachdf9ce6b2011-08-24 20:06:14 +0000196 printPredicateOperand(MI, 2, O);
Owen Anderson519020a2011-09-21 17:58:45 +0000197 printAnnotation(O, Annot);
Jim Grosbach0780b632011-08-19 23:24:36 +0000198 return;
199 }
200
Chris Lattner35c33bd2010-04-04 04:47:45 +0000201 printInstruction(MI, O);
Owen Anderson519020a2011-09-21 17:58:45 +0000202 printAnnotation(O, Annot);
Bill Wendling04863d02010-11-13 10:40:19 +0000203}
Chris Lattnerfd603822009-10-19 19:56:26 +0000204
Chris Lattner8bc86cb2009-10-19 20:59:55 +0000205void ARMInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
Jim Grosbach0a2287b2010-11-03 01:11:15 +0000206 raw_ostream &O) {
Chris Lattner8bc86cb2009-10-19 20:59:55 +0000207 const MCOperand &Op = MI->getOperand(OpNo);
208 if (Op.isReg()) {
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000209 unsigned Reg = Op.getReg();
Jim Grosbach35636282010-10-06 21:22:32 +0000210 O << getRegisterName(Reg);
Chris Lattner8bc86cb2009-10-19 20:59:55 +0000211 } else if (Op.isImm()) {
212 O << '#' << Op.getImm();
213 } else {
214 assert(Op.isExpr() && "unknown operand kind in printOperand");
Kevin Enderby9e5887b2011-10-04 22:44:48 +0000215 // If a symbolic branch target was added as a constant expression then print
216 // that address in hex.
217 const MCConstantExpr *BranchTarget = dyn_cast<MCConstantExpr>(Op.getExpr());
218 int64_t Address;
219 if (BranchTarget && BranchTarget->EvaluateAsAbsolute(Address)) {
220 O << "0x";
221 O.write_hex(Address);
222 }
223 else {
224 // Otherwise, just print the expression.
225 O << *Op.getExpr();
226 }
Chris Lattner8bc86cb2009-10-19 20:59:55 +0000227 }
228}
Chris Lattner61d35c22009-10-19 21:21:39 +0000229
Owen Andersone1368722011-09-21 23:44:46 +0000230void ARMInstPrinter::printT2LdrLabelOperand(const MCInst *MI, unsigned OpNum,
231 raw_ostream &O) {
232 const MCOperand &MO1 = MI->getOperand(OpNum);
233 if (MO1.isExpr())
234 O << *MO1.getExpr();
235 else if (MO1.isImm())
236 O << "[pc, #" << MO1.getImm() << "]";
237 else
238 llvm_unreachable("Unknown LDR label operand?");
239}
240
Chris Lattner017d9472009-10-20 00:40:56 +0000241// so_reg is a 4-operand unit corresponding to register forms of the A5.1
242// "Addressing Mode 1 - Data-processing operands" forms. This includes:
243// REG 0 0 - e.g. R5
244// REG REG 0,SH_OPC - e.g. R5, ROR R3
245// REG 0 IMM,SH_OPC - e.g. R5, LSL #3
Owen Anderson152d4a42011-07-21 23:38:37 +0000246void ARMInstPrinter::printSORegRegOperand(const MCInst *MI, unsigned OpNum,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000247 raw_ostream &O) {
Chris Lattner017d9472009-10-20 00:40:56 +0000248 const MCOperand &MO1 = MI->getOperand(OpNum);
249 const MCOperand &MO2 = MI->getOperand(OpNum+1);
250 const MCOperand &MO3 = MI->getOperand(OpNum+2);
Jim Grosbach15d78982010-09-14 22:27:15 +0000251
Chris Lattner017d9472009-10-20 00:40:56 +0000252 O << getRegisterName(MO1.getReg());
Jim Grosbach15d78982010-09-14 22:27:15 +0000253
Chris Lattner017d9472009-10-20 00:40:56 +0000254 // Print the shift opc.
Bob Wilson1d9125a2010-08-05 00:34:42 +0000255 ARM_AM::ShiftOpc ShOpc = ARM_AM::getSORegShOp(MO3.getImm());
256 O << ", " << ARM_AM::getShiftOpcStr(ShOpc);
Jim Grosbache8606dc2011-07-13 17:50:29 +0000257 if (ShOpc == ARM_AM::rrx)
258 return;
Jim Grosbach293a5f62011-10-21 16:56:40 +0000259
Owen Anderson152d4a42011-07-21 23:38:37 +0000260 O << ' ' << getRegisterName(MO2.getReg());
261 assert(ARM_AM::getSORegOffset(MO3.getImm()) == 0);
Chris Lattner017d9472009-10-20 00:40:56 +0000262}
Chris Lattner084f87d2009-10-19 21:57:05 +0000263
Owen Anderson152d4a42011-07-21 23:38:37 +0000264void ARMInstPrinter::printSORegImmOperand(const MCInst *MI, unsigned OpNum,
265 raw_ostream &O) {
266 const MCOperand &MO1 = MI->getOperand(OpNum);
267 const MCOperand &MO2 = MI->getOperand(OpNum+1);
268
269 O << getRegisterName(MO1.getReg());
270
271 // Print the shift opc.
272 ARM_AM::ShiftOpc ShOpc = ARM_AM::getSORegShOp(MO2.getImm());
273 O << ", " << ARM_AM::getShiftOpcStr(ShOpc);
274 if (ShOpc == ARM_AM::rrx)
275 return;
Owen Anderson3dac0be2011-08-11 18:41:59 +0000276 O << " #" << translateShiftImm(ARM_AM::getSORegOffset(MO2.getImm()));
Owen Anderson152d4a42011-07-21 23:38:37 +0000277}
278
279
Bruno Cardoso Lopesac79e4c2011-04-04 17:18:19 +0000280//===--------------------------------------------------------------------===//
281// Addressing Mode #2
282//===--------------------------------------------------------------------===//
283
Bruno Cardoso Lopesae085542011-03-31 23:26:08 +0000284void ARMInstPrinter::printAM2PreOrOffsetIndexOp(const MCInst *MI, unsigned Op,
285 raw_ostream &O) {
Chris Lattner084f87d2009-10-19 21:57:05 +0000286 const MCOperand &MO1 = MI->getOperand(Op);
287 const MCOperand &MO2 = MI->getOperand(Op+1);
288 const MCOperand &MO3 = MI->getOperand(Op+2);
Jim Grosbach15d78982010-09-14 22:27:15 +0000289
Chris Lattner084f87d2009-10-19 21:57:05 +0000290 O << "[" << getRegisterName(MO1.getReg());
Jim Grosbach15d78982010-09-14 22:27:15 +0000291
Chris Lattner084f87d2009-10-19 21:57:05 +0000292 if (!MO2.getReg()) {
Johnny Chen9e088762010-03-17 17:52:21 +0000293 if (ARM_AM::getAM2Offset(MO3.getImm())) // Don't print +0.
Chris Lattner084f87d2009-10-19 21:57:05 +0000294 O << ", #"
Johnny Chen9e088762010-03-17 17:52:21 +0000295 << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO3.getImm()))
296 << ARM_AM::getAM2Offset(MO3.getImm());
Chris Lattner084f87d2009-10-19 21:57:05 +0000297 O << "]";
298 return;
299 }
Jim Grosbach15d78982010-09-14 22:27:15 +0000300
Chris Lattner084f87d2009-10-19 21:57:05 +0000301 O << ", "
Johnny Chen9e088762010-03-17 17:52:21 +0000302 << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO3.getImm()))
303 << getRegisterName(MO2.getReg());
Jim Grosbach15d78982010-09-14 22:27:15 +0000304
Chris Lattner084f87d2009-10-19 21:57:05 +0000305 if (unsigned ShImm = ARM_AM::getAM2Offset(MO3.getImm()))
306 O << ", "
307 << ARM_AM::getShiftOpcStr(ARM_AM::getAM2ShiftOpc(MO3.getImm()))
308 << " #" << ShImm;
309 O << "]";
Jim Grosbach15d78982010-09-14 22:27:15 +0000310}
Chris Lattnere306d8d2009-10-19 22:09:23 +0000311
Bruno Cardoso Lopesae085542011-03-31 23:26:08 +0000312void ARMInstPrinter::printAM2PostIndexOp(const MCInst *MI, unsigned Op,
313 raw_ostream &O) {
314 const MCOperand &MO1 = MI->getOperand(Op);
315 const MCOperand &MO2 = MI->getOperand(Op+1);
316 const MCOperand &MO3 = MI->getOperand(Op+2);
317
318 O << "[" << getRegisterName(MO1.getReg()) << "], ";
319
320 if (!MO2.getReg()) {
321 unsigned ImmOffs = ARM_AM::getAM2Offset(MO3.getImm());
322 O << '#'
323 << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO3.getImm()))
324 << ImmOffs;
325 return;
326 }
327
328 O << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO3.getImm()))
329 << getRegisterName(MO2.getReg());
330
331 if (unsigned ShImm = ARM_AM::getAM2Offset(MO3.getImm()))
332 O << ", "
333 << ARM_AM::getShiftOpcStr(ARM_AM::getAM2ShiftOpc(MO3.getImm()))
334 << " #" << ShImm;
335}
336
Jim Grosbach7f739be2011-09-19 22:21:13 +0000337void ARMInstPrinter::printAddrModeTBB(const MCInst *MI, unsigned Op,
338 raw_ostream &O) {
339 const MCOperand &MO1 = MI->getOperand(Op);
340 const MCOperand &MO2 = MI->getOperand(Op+1);
341 O << "[" << getRegisterName(MO1.getReg()) << ", "
342 << getRegisterName(MO2.getReg()) << "]";
343}
344
345void ARMInstPrinter::printAddrModeTBH(const MCInst *MI, unsigned Op,
346 raw_ostream &O) {
347 const MCOperand &MO1 = MI->getOperand(Op);
348 const MCOperand &MO2 = MI->getOperand(Op+1);
349 O << "[" << getRegisterName(MO1.getReg()) << ", "
350 << getRegisterName(MO2.getReg()) << ", lsl #1]";
351}
352
Bruno Cardoso Lopesae085542011-03-31 23:26:08 +0000353void ARMInstPrinter::printAddrMode2Operand(const MCInst *MI, unsigned Op,
354 raw_ostream &O) {
355 const MCOperand &MO1 = MI->getOperand(Op);
356
357 if (!MO1.isReg()) { // FIXME: This is for CP entries, but isn't right.
358 printOperand(MI, Op, O);
359 return;
360 }
361
362 const MCOperand &MO3 = MI->getOperand(Op+2);
363 unsigned IdxMode = ARM_AM::getAM2IdxMode(MO3.getImm());
364
365 if (IdxMode == ARMII::IndexModePost) {
366 printAM2PostIndexOp(MI, Op, O);
367 return;
368 }
369 printAM2PreOrOffsetIndexOp(MI, Op, O);
370}
371
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000372void ARMInstPrinter::printAddrMode2OffsetOperand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000373 unsigned OpNum,
374 raw_ostream &O) {
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000375 const MCOperand &MO1 = MI->getOperand(OpNum);
376 const MCOperand &MO2 = MI->getOperand(OpNum+1);
Jim Grosbach15d78982010-09-14 22:27:15 +0000377
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000378 if (!MO1.getReg()) {
379 unsigned ImmOffs = ARM_AM::getAM2Offset(MO2.getImm());
Johnny Chen9e088762010-03-17 17:52:21 +0000380 O << '#'
381 << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO2.getImm()))
382 << ImmOffs;
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000383 return;
384 }
Jim Grosbach15d78982010-09-14 22:27:15 +0000385
Johnny Chen9e088762010-03-17 17:52:21 +0000386 O << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO2.getImm()))
387 << getRegisterName(MO1.getReg());
Jim Grosbach15d78982010-09-14 22:27:15 +0000388
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000389 if (unsigned ShImm = ARM_AM::getAM2Offset(MO2.getImm()))
390 O << ", "
391 << ARM_AM::getShiftOpcStr(ARM_AM::getAM2ShiftOpc(MO2.getImm()))
392 << " #" << ShImm;
393}
394
Bruno Cardoso Lopesac79e4c2011-04-04 17:18:19 +0000395//===--------------------------------------------------------------------===//
396// Addressing Mode #3
397//===--------------------------------------------------------------------===//
398
399void ARMInstPrinter::printAM3PostIndexOp(const MCInst *MI, unsigned Op,
400 raw_ostream &O) {
401 const MCOperand &MO1 = MI->getOperand(Op);
402 const MCOperand &MO2 = MI->getOperand(Op+1);
403 const MCOperand &MO3 = MI->getOperand(Op+2);
404
405 O << "[" << getRegisterName(MO1.getReg()) << "], ";
406
407 if (MO2.getReg()) {
408 O << (char)ARM_AM::getAM3Op(MO3.getImm())
409 << getRegisterName(MO2.getReg());
410 return;
411 }
412
413 unsigned ImmOffs = ARM_AM::getAM3Offset(MO3.getImm());
414 O << '#'
415 << ARM_AM::getAddrOpcStr(ARM_AM::getAM3Op(MO3.getImm()))
416 << ImmOffs;
417}
418
419void ARMInstPrinter::printAM3PreOrOffsetIndexOp(const MCInst *MI, unsigned Op,
420 raw_ostream &O) {
421 const MCOperand &MO1 = MI->getOperand(Op);
422 const MCOperand &MO2 = MI->getOperand(Op+1);
423 const MCOperand &MO3 = MI->getOperand(Op+2);
Jim Grosbach15d78982010-09-14 22:27:15 +0000424
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000425 O << '[' << getRegisterName(MO1.getReg());
Jim Grosbach15d78982010-09-14 22:27:15 +0000426
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000427 if (MO2.getReg()) {
Jim Grosbach7ce05792011-08-03 23:50:40 +0000428 O << ", " << getAddrOpcStr(ARM_AM::getAM3Op(MO3.getImm()))
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000429 << getRegisterName(MO2.getReg()) << ']';
430 return;
431 }
Jim Grosbach15d78982010-09-14 22:27:15 +0000432
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000433 if (unsigned ImmOffs = ARM_AM::getAM3Offset(MO3.getImm()))
434 O << ", #"
Johnny Chen9e088762010-03-17 17:52:21 +0000435 << ARM_AM::getAddrOpcStr(ARM_AM::getAM3Op(MO3.getImm()))
436 << ImmOffs;
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000437 O << ']';
438}
439
Bruno Cardoso Lopesac79e4c2011-04-04 17:18:19 +0000440void ARMInstPrinter::printAddrMode3Operand(const MCInst *MI, unsigned Op,
441 raw_ostream &O) {
Jim Grosbach2f196742011-12-19 23:06:24 +0000442 const MCOperand &MO1 = MI->getOperand(Op);
443 if (!MO1.isReg()) { // For label symbolic references.
444 printOperand(MI, Op, O);
445 return;
446 }
447
Bruno Cardoso Lopesac79e4c2011-04-04 17:18:19 +0000448 const MCOperand &MO3 = MI->getOperand(Op+2);
449 unsigned IdxMode = ARM_AM::getAM3IdxMode(MO3.getImm());
450
451 if (IdxMode == ARMII::IndexModePost) {
452 printAM3PostIndexOp(MI, Op, O);
453 return;
454 }
455 printAM3PreOrOffsetIndexOp(MI, Op, O);
456}
457
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000458void ARMInstPrinter::printAddrMode3OffsetOperand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000459 unsigned OpNum,
460 raw_ostream &O) {
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000461 const MCOperand &MO1 = MI->getOperand(OpNum);
462 const MCOperand &MO2 = MI->getOperand(OpNum+1);
Jim Grosbach15d78982010-09-14 22:27:15 +0000463
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000464 if (MO1.getReg()) {
Jim Grosbach7ce05792011-08-03 23:50:40 +0000465 O << getAddrOpcStr(ARM_AM::getAM3Op(MO2.getImm()))
466 << getRegisterName(MO1.getReg());
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000467 return;
468 }
Jim Grosbach15d78982010-09-14 22:27:15 +0000469
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000470 unsigned ImmOffs = ARM_AM::getAM3Offset(MO2.getImm());
Johnny Chen9e088762010-03-17 17:52:21 +0000471 O << '#'
472 << ARM_AM::getAddrOpcStr(ARM_AM::getAM3Op(MO2.getImm()))
473 << ImmOffs;
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000474}
475
Jim Grosbach7ce05792011-08-03 23:50:40 +0000476void ARMInstPrinter::printPostIdxImm8Operand(const MCInst *MI,
477 unsigned OpNum,
478 raw_ostream &O) {
479 const MCOperand &MO = MI->getOperand(OpNum);
480 unsigned Imm = MO.getImm();
481 O << '#' << ((Imm & 256) ? "" : "-") << (Imm & 0xff);
482}
483
Jim Grosbachca8c70b2011-08-05 15:48:21 +0000484void ARMInstPrinter::printPostIdxRegOperand(const MCInst *MI, unsigned OpNum,
485 raw_ostream &O) {
486 const MCOperand &MO1 = MI->getOperand(OpNum);
487 const MCOperand &MO2 = MI->getOperand(OpNum+1);
488
Jim Grosbach16578b52011-08-05 16:11:38 +0000489 O << (MO2.getImm() ? "" : "-") << getRegisterName(MO1.getReg());
Jim Grosbachca8c70b2011-08-05 15:48:21 +0000490}
491
Owen Anderson154c41d2011-08-04 18:24:14 +0000492void ARMInstPrinter::printPostIdxImm8s4Operand(const MCInst *MI,
493 unsigned OpNum,
494 raw_ostream &O) {
495 const MCOperand &MO = MI->getOperand(OpNum);
496 unsigned Imm = MO.getImm();
497 O << '#' << ((Imm & 256) ? "" : "-") << ((Imm & 0xff) << 2);
498}
499
500
Jim Grosbache6913602010-11-03 01:01:43 +0000501void ARMInstPrinter::printLdStmModeOperand(const MCInst *MI, unsigned OpNum,
Jim Grosbach0a2287b2010-11-03 01:11:15 +0000502 raw_ostream &O) {
Jim Grosbache6913602010-11-03 01:01:43 +0000503 ARM_AM::AMSubMode Mode = ARM_AM::getAM4SubMode(MI->getOperand(OpNum)
504 .getImm());
505 O << ARM_AM::getAMSubModeStr(Mode);
Chris Lattnere306d8d2009-10-19 22:09:23 +0000506}
507
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000508void ARMInstPrinter::printAddrMode5Operand(const MCInst *MI, unsigned OpNum,
Jim Grosbach0a2287b2010-11-03 01:11:15 +0000509 raw_ostream &O) {
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000510 const MCOperand &MO1 = MI->getOperand(OpNum);
511 const MCOperand &MO2 = MI->getOperand(OpNum+1);
Jim Grosbach15d78982010-09-14 22:27:15 +0000512
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000513 if (!MO1.isReg()) { // FIXME: This is for CP entries, but isn't right.
Chris Lattner35c33bd2010-04-04 04:47:45 +0000514 printOperand(MI, OpNum, O);
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000515 return;
516 }
Jim Grosbach15d78982010-09-14 22:27:15 +0000517
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000518 O << "[" << getRegisterName(MO1.getReg());
Jim Grosbach15d78982010-09-14 22:27:15 +0000519
Owen Anderson0da10cf2011-08-29 19:36:44 +0000520 unsigned ImmOffs = ARM_AM::getAM5Offset(MO2.getImm());
521 unsigned Op = ARM_AM::getAM5Op(MO2.getImm());
522 if (ImmOffs || Op == ARM_AM::sub) {
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000523 O << ", #"
Johnny Chen9e088762010-03-17 17:52:21 +0000524 << ARM_AM::getAddrOpcStr(ARM_AM::getAM5Op(MO2.getImm()))
Bill Wendling92b5a2e2010-11-03 01:49:29 +0000525 << ImmOffs * 4;
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000526 }
527 O << "]";
528}
529
Chris Lattner35c33bd2010-04-04 04:47:45 +0000530void ARMInstPrinter::printAddrMode6Operand(const MCInst *MI, unsigned OpNum,
531 raw_ostream &O) {
Chris Lattner235e2f62009-10-20 06:22:33 +0000532 const MCOperand &MO1 = MI->getOperand(OpNum);
533 const MCOperand &MO2 = MI->getOperand(OpNum+1);
Jim Grosbach15d78982010-09-14 22:27:15 +0000534
Bob Wilson226036e2010-03-20 22:13:40 +0000535 O << "[" << getRegisterName(MO1.getReg());
536 if (MO2.getImm()) {
537 // FIXME: Both darwin as and GNU as violate ARM docs here.
Bob Wilson273ff312010-07-14 23:54:43 +0000538 O << ", :" << (MO2.getImm() << 3);
Chris Lattner235e2f62009-10-20 06:22:33 +0000539 }
Bob Wilson226036e2010-03-20 22:13:40 +0000540 O << "]";
541}
542
Bruno Cardoso Lopes505f3cd2011-03-24 21:04:58 +0000543void ARMInstPrinter::printAddrMode7Operand(const MCInst *MI, unsigned OpNum,
544 raw_ostream &O) {
545 const MCOperand &MO1 = MI->getOperand(OpNum);
546 O << "[" << getRegisterName(MO1.getReg()) << "]";
547}
548
Bob Wilson226036e2010-03-20 22:13:40 +0000549void ARMInstPrinter::printAddrMode6OffsetOperand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000550 unsigned OpNum,
551 raw_ostream &O) {
Bob Wilson226036e2010-03-20 22:13:40 +0000552 const MCOperand &MO = MI->getOperand(OpNum);
553 if (MO.getReg() == 0)
554 O << "!";
555 else
556 O << ", " << getRegisterName(MO.getReg());
Chris Lattner235e2f62009-10-20 06:22:33 +0000557}
558
Bob Wilsoneaf1c982010-08-11 23:10:46 +0000559void ARMInstPrinter::printBitfieldInvMaskImmOperand(const MCInst *MI,
560 unsigned OpNum,
561 raw_ostream &O) {
Chris Lattner235e2f62009-10-20 06:22:33 +0000562 const MCOperand &MO = MI->getOperand(OpNum);
563 uint32_t v = ~MO.getImm();
564 int32_t lsb = CountTrailingZeros_32(v);
565 int32_t width = (32 - CountLeadingZeros_32 (v)) - lsb;
566 assert(MO.isImm() && "Not a valid bf_inv_mask_imm value!");
567 O << '#' << lsb << ", #" << width;
568}
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000569
Johnny Chen1adc40c2010-08-12 20:46:17 +0000570void ARMInstPrinter::printMemBOption(const MCInst *MI, unsigned OpNum,
571 raw_ostream &O) {
572 unsigned val = MI->getOperand(OpNum).getImm();
573 O << ARM_MB::MemBOptToString(val);
574}
575
Bob Wilson22f5dc72010-08-16 18:27:34 +0000576void ARMInstPrinter::printShiftImmOperand(const MCInst *MI, unsigned OpNum,
Bob Wilsoneaf1c982010-08-11 23:10:46 +0000577 raw_ostream &O) {
578 unsigned ShiftOp = MI->getOperand(OpNum).getImm();
Jim Grosbach580f4a92011-07-25 22:20:28 +0000579 bool isASR = (ShiftOp & (1 << 5)) != 0;
580 unsigned Amt = ShiftOp & 0x1f;
581 if (isASR)
582 O << ", asr #" << (Amt == 0 ? 32 : Amt);
583 else if (Amt)
584 O << ", lsl #" << Amt;
Bob Wilsoneaf1c982010-08-11 23:10:46 +0000585}
586
Jim Grosbachdde038a2011-07-20 21:40:26 +0000587void ARMInstPrinter::printPKHLSLShiftImm(const MCInst *MI, unsigned OpNum,
588 raw_ostream &O) {
589 unsigned Imm = MI->getOperand(OpNum).getImm();
590 if (Imm == 0)
591 return;
592 assert(Imm > 0 && Imm < 32 && "Invalid PKH shift immediate value!");
593 O << ", lsl #" << Imm;
594}
595
596void ARMInstPrinter::printPKHASRShiftImm(const MCInst *MI, unsigned OpNum,
597 raw_ostream &O) {
598 unsigned Imm = MI->getOperand(OpNum).getImm();
599 // A shift amount of 32 is encoded as 0.
600 if (Imm == 0)
601 Imm = 32;
602 assert(Imm > 0 && Imm <= 32 && "Invalid PKH shift immediate value!");
603 O << ", asr #" << Imm;
604}
605
Chris Lattner35c33bd2010-04-04 04:47:45 +0000606void ARMInstPrinter::printRegisterList(const MCInst *MI, unsigned OpNum,
607 raw_ostream &O) {
Chris Lattnere306d8d2009-10-19 22:09:23 +0000608 O << "{";
Johnny Chen9e088762010-03-17 17:52:21 +0000609 for (unsigned i = OpNum, e = MI->getNumOperands(); i != e; ++i) {
610 if (i != OpNum) O << ", ";
Chris Lattnere306d8d2009-10-19 22:09:23 +0000611 O << getRegisterName(MI->getOperand(i).getReg());
612 }
613 O << "}";
614}
Chris Lattner4d152222009-10-19 22:23:04 +0000615
Jim Grosbachb3af5de2010-10-13 21:00:04 +0000616void ARMInstPrinter::printSetendOperand(const MCInst *MI, unsigned OpNum,
617 raw_ostream &O) {
618 const MCOperand &Op = MI->getOperand(OpNum);
619 if (Op.getImm())
620 O << "be";
621 else
622 O << "le";
623}
624
Bruno Cardoso Lopesa2b6e412011-02-14 13:09:44 +0000625void ARMInstPrinter::printCPSIMod(const MCInst *MI, unsigned OpNum,
626 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000627 const MCOperand &Op = MI->getOperand(OpNum);
Bruno Cardoso Lopesa2b6e412011-02-14 13:09:44 +0000628 O << ARM_PROC::IModToString(Op.getImm());
629}
630
631void ARMInstPrinter::printCPSIFlag(const MCInst *MI, unsigned OpNum,
632 raw_ostream &O) {
633 const MCOperand &Op = MI->getOperand(OpNum);
634 unsigned IFlags = Op.getImm();
635 for (int i=2; i >= 0; --i)
636 if (IFlags & (1 << i))
637 O << ARM_PROC::IFlagsToString(1 << i);
Owen Anderson2dbb46a2011-10-05 17:16:40 +0000638
639 if (IFlags == 0)
640 O << "none";
Johnny Chen9e088762010-03-17 17:52:21 +0000641}
642
Chris Lattner35c33bd2010-04-04 04:47:45 +0000643void ARMInstPrinter::printMSRMaskOperand(const MCInst *MI, unsigned OpNum,
644 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000645 const MCOperand &Op = MI->getOperand(OpNum);
Bruno Cardoso Lopes584bf7b2011-02-18 19:45:59 +0000646 unsigned SpecRegRBit = Op.getImm() >> 4;
647 unsigned Mask = Op.getImm() & 0xf;
648
James Molloyacad68d2011-09-28 14:21:38 +0000649 if (getAvailableFeatures() & ARM::FeatureMClass) {
650 switch (Op.getImm()) {
Craig Topperbc219812012-02-07 02:50:20 +0000651 default: llvm_unreachable("Unexpected mask value!");
James Molloyacad68d2011-09-28 14:21:38 +0000652 case 0: O << "apsr"; return;
653 case 1: O << "iapsr"; return;
654 case 2: O << "eapsr"; return;
655 case 3: O << "xpsr"; return;
656 case 5: O << "ipsr"; return;
657 case 6: O << "epsr"; return;
658 case 7: O << "iepsr"; return;
659 case 8: O << "msp"; return;
660 case 9: O << "psp"; return;
661 case 16: O << "primask"; return;
662 case 17: O << "basepri"; return;
663 case 18: O << "basepri_max"; return;
664 case 19: O << "faultmask"; return;
665 case 20: O << "control"; return;
666 }
667 }
668
Jim Grosbachb29b4dd2011-07-19 22:45:10 +0000669 // As special cases, CPSR_f, CPSR_s and CPSR_fs prefer printing as
670 // APSR_nzcvq, APSR_g and APSRnzcvqg, respectively.
671 if (!SpecRegRBit && (Mask == 8 || Mask == 4 || Mask == 12)) {
672 O << "APSR_";
673 switch (Mask) {
Craig Topperbc219812012-02-07 02:50:20 +0000674 default: llvm_unreachable("Unexpected mask value!");
Jim Grosbachb29b4dd2011-07-19 22:45:10 +0000675 case 4: O << "g"; return;
676 case 8: O << "nzcvq"; return;
677 case 12: O << "nzcvqg"; return;
678 }
Jim Grosbachb29b4dd2011-07-19 22:45:10 +0000679 }
680
Bruno Cardoso Lopes584bf7b2011-02-18 19:45:59 +0000681 if (SpecRegRBit)
Jim Grosbachb29b4dd2011-07-19 22:45:10 +0000682 O << "SPSR";
Bruno Cardoso Lopes584bf7b2011-02-18 19:45:59 +0000683 else
Jim Grosbachb29b4dd2011-07-19 22:45:10 +0000684 O << "CPSR";
Bruno Cardoso Lopes584bf7b2011-02-18 19:45:59 +0000685
Johnny Chen9e088762010-03-17 17:52:21 +0000686 if (Mask) {
687 O << '_';
688 if (Mask & 8) O << 'f';
689 if (Mask & 4) O << 's';
690 if (Mask & 2) O << 'x';
691 if (Mask & 1) O << 'c';
692 }
693}
694
Chris Lattner35c33bd2010-04-04 04:47:45 +0000695void ARMInstPrinter::printPredicateOperand(const MCInst *MI, unsigned OpNum,
696 raw_ostream &O) {
Chris Lattner413ae252009-10-20 00:42:49 +0000697 ARMCC::CondCodes CC = (ARMCC::CondCodes)MI->getOperand(OpNum).getImm();
Kevin Enderbyb0578512012-03-01 22:13:02 +0000698 // Handle the undefined 15 CC value here for printing so we don't abort().
699 if ((unsigned)CC == 15)
700 O << "<und>";
701 else if (CC != ARMCC::AL)
Chris Lattner413ae252009-10-20 00:42:49 +0000702 O << ARMCondCodeToString(CC);
703}
704
Jim Grosbach15d78982010-09-14 22:27:15 +0000705void ARMInstPrinter::printMandatoryPredicateOperand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000706 unsigned OpNum,
707 raw_ostream &O) {
Johnny Chen9d3acaa2010-03-02 17:57:15 +0000708 ARMCC::CondCodes CC = (ARMCC::CondCodes)MI->getOperand(OpNum).getImm();
709 O << ARMCondCodeToString(CC);
710}
711
Chris Lattner35c33bd2010-04-04 04:47:45 +0000712void ARMInstPrinter::printSBitModifierOperand(const MCInst *MI, unsigned OpNum,
713 raw_ostream &O) {
Daniel Dunbara7cc6522009-10-20 22:10:05 +0000714 if (MI->getOperand(OpNum).getReg()) {
715 assert(MI->getOperand(OpNum).getReg() == ARM::CPSR &&
716 "Expect ARM CPSR register!");
Chris Lattner233917c2009-10-20 00:46:11 +0000717 O << 's';
718 }
719}
720
Chris Lattner35c33bd2010-04-04 04:47:45 +0000721void ARMInstPrinter::printNoHashImmediate(const MCInst *MI, unsigned OpNum,
722 raw_ostream &O) {
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000723 O << MI->getOperand(OpNum).getImm();
724}
725
Owen Andersone4e5e2a2011-01-13 21:46:02 +0000726void ARMInstPrinter::printPImmediate(const MCInst *MI, unsigned OpNum,
Jim Grosbachbc9c8022011-10-12 16:34:37 +0000727 raw_ostream &O) {
Owen Andersone4e5e2a2011-01-13 21:46:02 +0000728 O << "p" << MI->getOperand(OpNum).getImm();
729}
730
731void ARMInstPrinter::printCImmediate(const MCInst *MI, unsigned OpNum,
Jim Grosbachbc9c8022011-10-12 16:34:37 +0000732 raw_ostream &O) {
Owen Andersone4e5e2a2011-01-13 21:46:02 +0000733 O << "c" << MI->getOperand(OpNum).getImm();
734}
735
Jim Grosbach9b8f2a02011-10-12 17:34:41 +0000736void ARMInstPrinter::printCoprocOptionImm(const MCInst *MI, unsigned OpNum,
737 raw_ostream &O) {
738 O << "{" << MI->getOperand(OpNum).getImm() << "}";
739}
740
Chris Lattner35c33bd2010-04-04 04:47:45 +0000741void ARMInstPrinter::printPCLabel(const MCInst *MI, unsigned OpNum,
742 raw_ostream &O) {
Jim Grosbachd30cfde2010-09-18 00:04:53 +0000743 llvm_unreachable("Unhandled PC-relative pseudo-instruction!");
Chris Lattner4d152222009-10-19 22:23:04 +0000744}
Evan Cheng2ef9c8a2009-11-19 06:57:41 +0000745
Chris Lattner35c33bd2010-04-04 04:47:45 +0000746void ARMInstPrinter::printThumbS4ImmOperand(const MCInst *MI, unsigned OpNum,
747 raw_ostream &O) {
Jim Grosbach70939ee2011-08-17 21:51:27 +0000748 O << "#" << MI->getOperand(OpNum).getImm() * 4;
749}
750
751void ARMInstPrinter::printThumbSRImm(const MCInst *MI, unsigned OpNum,
752 raw_ostream &O) {
753 unsigned Imm = MI->getOperand(OpNum).getImm();
754 O << "#" << (Imm == 0 ? 32 : Imm);
Evan Cheng2ef9c8a2009-11-19 06:57:41 +0000755}
Johnny Chen9e088762010-03-17 17:52:21 +0000756
Chris Lattner35c33bd2010-04-04 04:47:45 +0000757void ARMInstPrinter::printThumbITMask(const MCInst *MI, unsigned OpNum,
758 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000759 // (3 - the number of trailing zeros) is the number of then / else.
760 unsigned Mask = MI->getOperand(OpNum).getImm();
761 unsigned CondBit0 = Mask >> 4 & 1;
762 unsigned NumTZ = CountTrailingZeros_32(Mask);
763 assert(NumTZ <= 3 && "Invalid IT mask!");
764 for (unsigned Pos = 3, e = NumTZ; Pos > e; --Pos) {
765 bool T = ((Mask >> Pos) & 1) == CondBit0;
766 if (T)
767 O << 't';
768 else
769 O << 'e';
770 }
771}
772
Chris Lattner35c33bd2010-04-04 04:47:45 +0000773void ARMInstPrinter::printThumbAddrModeRROperand(const MCInst *MI, unsigned Op,
774 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000775 const MCOperand &MO1 = MI->getOperand(Op);
Bill Wendlingf4caf692010-12-14 03:36:38 +0000776 const MCOperand &MO2 = MI->getOperand(Op + 1);
Johnny Chen9e088762010-03-17 17:52:21 +0000777
778 if (!MO1.isReg()) { // FIXME: This is for CP entries, but isn't right.
Chris Lattner35c33bd2010-04-04 04:47:45 +0000779 printOperand(MI, Op, O);
Johnny Chen9e088762010-03-17 17:52:21 +0000780 return;
781 }
782
783 O << "[" << getRegisterName(MO1.getReg());
Bill Wendlingf4caf692010-12-14 03:36:38 +0000784 if (unsigned RegNum = MO2.getReg())
785 O << ", " << getRegisterName(RegNum);
786 O << "]";
787}
788
789void ARMInstPrinter::printThumbAddrModeImm5SOperand(const MCInst *MI,
790 unsigned Op,
791 raw_ostream &O,
792 unsigned Scale) {
793 const MCOperand &MO1 = MI->getOperand(Op);
794 const MCOperand &MO2 = MI->getOperand(Op + 1);
795
796 if (!MO1.isReg()) { // FIXME: This is for CP entries, but isn't right.
797 printOperand(MI, Op, O);
798 return;
799 }
800
801 O << "[" << getRegisterName(MO1.getReg());
802 if (unsigned ImmOffs = MO2.getImm())
Johnny Chen9e088762010-03-17 17:52:21 +0000803 O << ", #" << ImmOffs * Scale;
804 O << "]";
805}
806
Bill Wendlingf4caf692010-12-14 03:36:38 +0000807void ARMInstPrinter::printThumbAddrModeImm5S1Operand(const MCInst *MI,
808 unsigned Op,
809 raw_ostream &O) {
810 printThumbAddrModeImm5SOperand(MI, Op, O, 1);
Johnny Chen9e088762010-03-17 17:52:21 +0000811}
812
Bill Wendlingf4caf692010-12-14 03:36:38 +0000813void ARMInstPrinter::printThumbAddrModeImm5S2Operand(const MCInst *MI,
814 unsigned Op,
815 raw_ostream &O) {
816 printThumbAddrModeImm5SOperand(MI, Op, O, 2);
Johnny Chen9e088762010-03-17 17:52:21 +0000817}
818
Bill Wendlingf4caf692010-12-14 03:36:38 +0000819void ARMInstPrinter::printThumbAddrModeImm5S4Operand(const MCInst *MI,
820 unsigned Op,
821 raw_ostream &O) {
822 printThumbAddrModeImm5SOperand(MI, Op, O, 4);
Johnny Chen9e088762010-03-17 17:52:21 +0000823}
824
Chris Lattner35c33bd2010-04-04 04:47:45 +0000825void ARMInstPrinter::printThumbAddrModeSPOperand(const MCInst *MI, unsigned Op,
826 raw_ostream &O) {
Bill Wendlingf4caf692010-12-14 03:36:38 +0000827 printThumbAddrModeImm5SOperand(MI, Op, O, 4);
Johnny Chen9e088762010-03-17 17:52:21 +0000828}
829
Johnny Chen9e088762010-03-17 17:52:21 +0000830// Constant shifts t2_so_reg is a 2-operand unit corresponding to the Thumb2
831// register with shift forms.
832// REG 0 0 - e.g. R5
833// REG IMM, SH_OPC - e.g. R5, LSL #3
Chris Lattner35c33bd2010-04-04 04:47:45 +0000834void ARMInstPrinter::printT2SOOperand(const MCInst *MI, unsigned OpNum,
835 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000836 const MCOperand &MO1 = MI->getOperand(OpNum);
837 const MCOperand &MO2 = MI->getOperand(OpNum+1);
838
839 unsigned Reg = MO1.getReg();
840 O << getRegisterName(Reg);
841
842 // Print the shift opc.
Johnny Chen9e088762010-03-17 17:52:21 +0000843 assert(MO2.isImm() && "Not a valid t2_so_reg value!");
Bob Wilson1d9125a2010-08-05 00:34:42 +0000844 ARM_AM::ShiftOpc ShOpc = ARM_AM::getSORegShOp(MO2.getImm());
845 O << ", " << ARM_AM::getShiftOpcStr(ShOpc);
846 if (ShOpc != ARM_AM::rrx)
Owen Anderson3dac0be2011-08-11 18:41:59 +0000847 O << " #" << translateShiftImm(ARM_AM::getSORegOffset(MO2.getImm()));
Johnny Chen9e088762010-03-17 17:52:21 +0000848}
849
Jim Grosbach458f2dc2010-10-25 20:00:01 +0000850void ARMInstPrinter::printAddrModeImm12Operand(const MCInst *MI, unsigned OpNum,
851 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000852 const MCOperand &MO1 = MI->getOperand(OpNum);
853 const MCOperand &MO2 = MI->getOperand(OpNum+1);
854
Jim Grosbach3e556122010-10-26 22:37:02 +0000855 if (!MO1.isReg()) { // FIXME: This is for CP entries, but isn't right.
856 printOperand(MI, OpNum, O);
857 return;
858 }
859
Johnny Chen9e088762010-03-17 17:52:21 +0000860 O << "[" << getRegisterName(MO1.getReg());
861
Jim Grosbach77aee8e2010-10-27 01:19:41 +0000862 int32_t OffImm = (int32_t)MO2.getImm();
Jim Grosbachab682a22010-10-28 18:34:10 +0000863 bool isSub = OffImm < 0;
864 // Special value for #-0. All others are normal.
865 if (OffImm == INT32_MIN)
866 OffImm = 0;
867 if (isSub)
Jim Grosbach77aee8e2010-10-27 01:19:41 +0000868 O << ", #-" << -OffImm;
869 else if (OffImm > 0)
Johnny Chen9e088762010-03-17 17:52:21 +0000870 O << ", #" << OffImm;
871 O << "]";
872}
873
874void ARMInstPrinter::printT2AddrModeImm8Operand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000875 unsigned OpNum,
876 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000877 const MCOperand &MO1 = MI->getOperand(OpNum);
878 const MCOperand &MO2 = MI->getOperand(OpNum+1);
879
880 O << "[" << getRegisterName(MO1.getReg());
881
882 int32_t OffImm = (int32_t)MO2.getImm();
883 // Don't print +0.
Owen Anderson705b48f2011-09-16 21:08:33 +0000884 if (OffImm == INT32_MIN)
885 O << ", #-0";
886 else if (OffImm < 0)
Johnny Chen9e088762010-03-17 17:52:21 +0000887 O << ", #-" << -OffImm;
888 else if (OffImm > 0)
889 O << ", #" << OffImm;
890 O << "]";
891}
892
893void ARMInstPrinter::printT2AddrModeImm8s4Operand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000894 unsigned OpNum,
895 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000896 const MCOperand &MO1 = MI->getOperand(OpNum);
897 const MCOperand &MO2 = MI->getOperand(OpNum+1);
898
Jim Grosbach2f196742011-12-19 23:06:24 +0000899 if (!MO1.isReg()) { // For label symbolic references.
900 printOperand(MI, OpNum, O);
901 return;
902 }
903
Johnny Chen9e088762010-03-17 17:52:21 +0000904 O << "[" << getRegisterName(MO1.getReg());
905
906 int32_t OffImm = (int32_t)MO2.getImm() / 4;
907 // Don't print +0.
908 if (OffImm < 0)
909 O << ", #-" << -OffImm * 4;
910 else if (OffImm > 0)
911 O << ", #" << OffImm * 4;
912 O << "]";
913}
914
Jim Grosbachb6aed502011-09-09 18:37:27 +0000915void ARMInstPrinter::printT2AddrModeImm0_1020s4Operand(const MCInst *MI,
916 unsigned OpNum,
917 raw_ostream &O) {
918 const MCOperand &MO1 = MI->getOperand(OpNum);
919 const MCOperand &MO2 = MI->getOperand(OpNum+1);
920
921 O << "[" << getRegisterName(MO1.getReg());
922 if (MO2.getImm())
923 O << ", #" << MO2.getImm() * 4;
924 O << "]";
925}
926
Johnny Chen9e088762010-03-17 17:52:21 +0000927void ARMInstPrinter::printT2AddrModeImm8OffsetOperand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000928 unsigned OpNum,
929 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000930 const MCOperand &MO1 = MI->getOperand(OpNum);
931 int32_t OffImm = (int32_t)MO1.getImm();
932 // Don't print +0.
933 if (OffImm < 0)
Owen Anderson0781c1f2011-09-23 21:26:40 +0000934 O << ", #-" << -OffImm;
935 else
936 O << ", #" << OffImm;
Johnny Chen9e088762010-03-17 17:52:21 +0000937}
938
939void ARMInstPrinter::printT2AddrModeImm8s4OffsetOperand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000940 unsigned OpNum,
941 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000942 const MCOperand &MO1 = MI->getOperand(OpNum);
943 int32_t OffImm = (int32_t)MO1.getImm() / 4;
944 // Don't print +0.
Owen Anderson7782a582011-09-13 20:46:26 +0000945 if (OffImm != 0) {
946 O << ", ";
947 if (OffImm < 0)
948 O << "#-" << -OffImm * 4;
949 else if (OffImm > 0)
950 O << "#" << OffImm * 4;
951 }
Johnny Chen9e088762010-03-17 17:52:21 +0000952}
953
954void ARMInstPrinter::printT2AddrModeSoRegOperand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000955 unsigned OpNum,
956 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000957 const MCOperand &MO1 = MI->getOperand(OpNum);
958 const MCOperand &MO2 = MI->getOperand(OpNum+1);
959 const MCOperand &MO3 = MI->getOperand(OpNum+2);
960
961 O << "[" << getRegisterName(MO1.getReg());
962
963 assert(MO2.getReg() && "Invalid so_reg load / store address!");
964 O << ", " << getRegisterName(MO2.getReg());
965
966 unsigned ShAmt = MO3.getImm();
967 if (ShAmt) {
968 assert(ShAmt <= 3 && "Not a valid Thumb2 addressing mode!");
969 O << ", lsl #" << ShAmt;
970 }
971 O << "]";
972}
973
Jim Grosbach4ebbf7b2011-09-30 00:50:06 +0000974void ARMInstPrinter::printFPImmOperand(const MCInst *MI, unsigned OpNum,
975 raw_ostream &O) {
Bill Wendling8cb415e2011-01-26 20:57:43 +0000976 const MCOperand &MO = MI->getOperand(OpNum);
Jim Grosbach4ebbf7b2011-09-30 00:50:06 +0000977 O << '#' << ARM_AM::getFPImmFloat(MO.getImm());
Johnny Chen9e088762010-03-17 17:52:21 +0000978}
979
Bob Wilson1a913ed2010-06-11 21:34:50 +0000980void ARMInstPrinter::printNEONModImmOperand(const MCInst *MI, unsigned OpNum,
981 raw_ostream &O) {
Bob Wilson6dce00c2010-07-13 04:44:34 +0000982 unsigned EncodedImm = MI->getOperand(OpNum).getImm();
983 unsigned EltBits;
984 uint64_t Val = ARM_AM::decodeNEONModImm(EncodedImm, EltBits);
Benjamin Kramer70be28a2011-11-07 21:00:59 +0000985 O << "#0x";
986 O.write_hex(Val);
Johnny Chenc7b65912010-04-16 22:40:20 +0000987}
Jim Grosbach4a5ffb32011-07-22 23:16:18 +0000988
Jim Grosbachf4943352011-07-25 23:09:14 +0000989void ARMInstPrinter::printImmPlusOneOperand(const MCInst *MI, unsigned OpNum,
990 raw_ostream &O) {
Jim Grosbach4a5ffb32011-07-22 23:16:18 +0000991 unsigned Imm = MI->getOperand(OpNum).getImm();
992 O << "#" << Imm + 1;
993}
Jim Grosbach85bfd3b2011-07-26 21:28:43 +0000994
995void ARMInstPrinter::printRotImmOperand(const MCInst *MI, unsigned OpNum,
996 raw_ostream &O) {
997 unsigned Imm = MI->getOperand(OpNum).getImm();
998 if (Imm == 0)
999 return;
Jim Grosbach45f39292011-07-26 21:44:37 +00001000 O << ", ror #";
Jim Grosbach85bfd3b2011-07-26 21:28:43 +00001001 switch (Imm) {
1002 default: assert (0 && "illegal ror immediate!");
Jim Grosbach2f815c02011-08-17 23:23:07 +00001003 case 1: O << "8"; break;
1004 case 2: O << "16"; break;
1005 case 3: O << "24"; break;
Jim Grosbach85bfd3b2011-07-26 21:28:43 +00001006 }
1007}
Jim Grosbach460a9052011-10-07 23:56:00 +00001008
Jim Grosbach4050bc42011-12-22 22:19:05 +00001009void ARMInstPrinter::printFBits16(const MCInst *MI, unsigned OpNum,
1010 raw_ostream &O) {
1011 O << "#" << 16 - MI->getOperand(OpNum).getImm();
1012}
1013
1014void ARMInstPrinter::printFBits32(const MCInst *MI, unsigned OpNum,
1015 raw_ostream &O) {
1016 O << "#" << 32 - MI->getOperand(OpNum).getImm();
1017}
1018
Jim Grosbach460a9052011-10-07 23:56:00 +00001019void ARMInstPrinter::printVectorIndex(const MCInst *MI, unsigned OpNum,
1020 raw_ostream &O) {
1021 O << "[" << MI->getOperand(OpNum).getImm() << "]";
1022}
Jim Grosbach862019c2011-10-18 23:02:30 +00001023
1024void ARMInstPrinter::printVectorListOne(const MCInst *MI, unsigned OpNum,
1025 raw_ostream &O) {
1026 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << "}";
1027}
Jim Grosbach280dfad2011-10-21 18:54:25 +00001028
Jim Grosbachc0fc4502012-03-06 22:01:44 +00001029void ARMInstPrinter::printVectorListTwo(const MCInst *MI, unsigned OpNum,
Jim Grosbach28f08c92012-03-05 19:33:30 +00001030 raw_ostream &O) {
1031 unsigned Reg = MI->getOperand(OpNum).getReg();
1032 unsigned Reg0 = MRI.getSubReg(Reg, ARM::dsub_0);
1033 unsigned Reg1 = MRI.getSubReg(Reg, ARM::dsub_1);
1034 O << "{" << getRegisterName(Reg0) << ", " << getRegisterName(Reg1) << "}";
1035}
1036
Jim Grosbachc0fc4502012-03-06 22:01:44 +00001037void ARMInstPrinter::printVectorListTwoSpaced(const MCInst *MI,
1038 unsigned OpNum,
1039 raw_ostream &O) {
Jim Grosbachc3384c92012-03-05 21:43:40 +00001040 unsigned Reg = MI->getOperand(OpNum).getReg();
1041 unsigned Reg0 = MRI.getSubReg(Reg, ARM::dsub_0);
1042 unsigned Reg1 = MRI.getSubReg(Reg, ARM::dsub_2);
1043 O << "{" << getRegisterName(Reg0) << ", " << getRegisterName(Reg1) << "}";
1044}
1045
Jim Grosbachcdcfa282011-10-21 20:02:19 +00001046void ARMInstPrinter::printVectorListThree(const MCInst *MI, unsigned OpNum,
1047 raw_ostream &O) {
1048 // Normally, it's not safe to use register enum values directly with
1049 // addition to get the next register, but for VFP registers, the
1050 // sort order is guaranteed because they're all of the form D<n>.
1051 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << ", "
1052 << getRegisterName(MI->getOperand(OpNum).getReg() + 1) << ", "
1053 << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << "}";
1054}
Jim Grosbachb6310312011-10-21 20:35:01 +00001055
1056void ARMInstPrinter::printVectorListFour(const MCInst *MI, unsigned OpNum,
1057 raw_ostream &O) {
1058 // Normally, it's not safe to use register enum values directly with
1059 // addition to get the next register, but for VFP registers, the
1060 // sort order is guaranteed because they're all of the form D<n>.
1061 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << ", "
1062 << getRegisterName(MI->getOperand(OpNum).getReg() + 1) << ", "
1063 << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << ", "
1064 << getRegisterName(MI->getOperand(OpNum).getReg() + 3) << "}";
1065}
Jim Grosbach98b05a52011-11-30 01:09:44 +00001066
1067void ARMInstPrinter::printVectorListOneAllLanes(const MCInst *MI,
1068 unsigned OpNum,
1069 raw_ostream &O) {
1070 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << "[]}";
1071}
1072
Jim Grosbach13af2222011-11-30 18:21:25 +00001073void ARMInstPrinter::printVectorListTwoAllLanes(const MCInst *MI,
1074 unsigned OpNum,
1075 raw_ostream &O) {
Jim Grosbachc0fc4502012-03-06 22:01:44 +00001076 unsigned Reg = MI->getOperand(OpNum).getReg();
1077 unsigned Reg0 = MRI.getSubReg(Reg, ARM::dsub_0);
1078 unsigned Reg1 = MRI.getSubReg(Reg, ARM::dsub_1);
1079 O << "{" << getRegisterName(Reg0) << "[], " << getRegisterName(Reg1) << "[]}";
Jim Grosbach13af2222011-11-30 18:21:25 +00001080}
Jim Grosbache90ac9b2011-12-14 19:35:22 +00001081
Jim Grosbach5e59f7e2012-01-24 23:47:04 +00001082void ARMInstPrinter::printVectorListThreeAllLanes(const MCInst *MI,
1083 unsigned OpNum,
1084 raw_ostream &O) {
1085 // Normally, it's not safe to use register enum values directly with
1086 // addition to get the next register, but for VFP registers, the
1087 // sort order is guaranteed because they're all of the form D<n>.
1088 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << "[], "
1089 << getRegisterName(MI->getOperand(OpNum).getReg() + 1) << "[], "
1090 << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << "[]}";
1091}
1092
Jim Grosbacha57a36a2012-01-25 00:01:08 +00001093void ARMInstPrinter::printVectorListFourAllLanes(const MCInst *MI,
1094 unsigned OpNum,
1095 raw_ostream &O) {
1096 // Normally, it's not safe to use register enum values directly with
1097 // addition to get the next register, but for VFP registers, the
1098 // sort order is guaranteed because they're all of the form D<n>.
1099 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << "[], "
1100 << getRegisterName(MI->getOperand(OpNum).getReg() + 1) << "[], "
1101 << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << "[], "
1102 << getRegisterName(MI->getOperand(OpNum).getReg() + 3) << "[]}";
1103}
1104
Jim Grosbach3471d4f2011-12-21 00:38:54 +00001105void ARMInstPrinter::printVectorListTwoSpacedAllLanes(const MCInst *MI,
1106 unsigned OpNum,
1107 raw_ostream &O) {
Jim Grosbach4d0983a2012-03-06 23:10:38 +00001108 unsigned Reg = MI->getOperand(OpNum).getReg();
1109 unsigned Reg0 = MRI.getSubReg(Reg, ARM::dsub_0);
1110 unsigned Reg1 = MRI.getSubReg(Reg, ARM::dsub_2);
1111 O << "{" << getRegisterName(Reg0) << "[], " << getRegisterName(Reg1) << "[]}";
Jim Grosbach3471d4f2011-12-21 00:38:54 +00001112}
1113
Jim Grosbach5e59f7e2012-01-24 23:47:04 +00001114void ARMInstPrinter::printVectorListThreeSpacedAllLanes(const MCInst *MI,
1115 unsigned OpNum,
1116 raw_ostream &O) {
1117 // Normally, it's not safe to use register enum values directly with
1118 // addition to get the next register, but for VFP registers, the
1119 // sort order is guaranteed because they're all of the form D<n>.
1120 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << "[], "
1121 << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << "[], "
Jim Grosbacha57a36a2012-01-25 00:01:08 +00001122 << getRegisterName(MI->getOperand(OpNum).getReg() + 4) << "[]}";
1123}
1124
1125void ARMInstPrinter::printVectorListFourSpacedAllLanes(const MCInst *MI,
1126 unsigned OpNum,
1127 raw_ostream &O) {
1128 // Normally, it's not safe to use register enum values directly with
1129 // addition to get the next register, but for VFP registers, the
1130 // sort order is guaranteed because they're all of the form D<n>.
1131 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << "[], "
1132 << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << "[], "
1133 << getRegisterName(MI->getOperand(OpNum).getReg() + 4) << "[], "
1134 << getRegisterName(MI->getOperand(OpNum).getReg() + 6) << "[]}";
Jim Grosbach5e59f7e2012-01-24 23:47:04 +00001135}
1136
Jim Grosbachc387fc62012-01-23 23:20:46 +00001137void ARMInstPrinter::printVectorListThreeSpaced(const MCInst *MI,
1138 unsigned OpNum,
1139 raw_ostream &O) {
1140 // Normally, it's not safe to use register enum values directly with
1141 // addition to get the next register, but for VFP registers, the
1142 // sort order is guaranteed because they're all of the form D<n>.
1143 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << ", "
1144 << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << ", "
1145 << getRegisterName(MI->getOperand(OpNum).getReg() + 4) << "}";
1146}
Jim Grosbach8abe7e32012-01-24 00:43:17 +00001147
1148void ARMInstPrinter::printVectorListFourSpaced(const MCInst *MI,
1149 unsigned OpNum,
1150 raw_ostream &O) {
1151 // Normally, it's not safe to use register enum values directly with
1152 // addition to get the next register, but for VFP registers, the
1153 // sort order is guaranteed because they're all of the form D<n>.
1154 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << ", "
1155 << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << ", "
1156 << getRegisterName(MI->getOperand(OpNum).getReg() + 4) << ", "
1157 << getRegisterName(MI->getOperand(OpNum).getReg() + 6) << "}";
1158}