blob: 2f6b1b02cca6d0f9dac7788ec62e5335aa206eef [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
Rafael Espindolacde4ce42011-06-02 02:34:55 +000047void ARMInstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const {
48 OS << getRegisterName(RegNo);
Anton Korobeynikov57caad72011-03-05 18:43:32 +000049}
Chris Lattner6274ec42010-10-28 21:37:33 +000050
Owen Anderson98c5dda2011-09-15 23:38:46 +000051void ARMInstPrinter::printInst(const MCInst *MI, raw_ostream &O,
52 StringRef Annot) {
Bill Wendling04863d02010-11-13 10:40:19 +000053 unsigned Opcode = MI->getOpcode();
54
Jim Grosbach7e99a602012-06-18 19:45:50 +000055 // Check for HINT instructions w/ canonical names.
56 if (Opcode == ARM::HINT || Opcode == ARM::t2HINT) {
57 switch (MI->getOperand(0).getImm()) {
58 case 0: O << "\tnop"; break;
59 case 1: O << "\tyield"; break;
60 case 2: O << "\twfe"; break;
61 case 3: O << "\twfi"; break;
62 case 4: O << "\tsev"; break;
63 default:
64 // Anything else should just print normally.
65 printInstruction(MI, O);
66 printAnnotation(O, Annot);
67 return;
68 }
69 printPredicateOperand(MI, 1, O);
70 if (Opcode == ARM::t2HINT)
71 O << ".w";
72 printAnnotation(O, Annot);
73 return;
74 }
75
Johnny Chen9e088762010-03-17 17:52:21 +000076 // Check for MOVs and print canonical forms, instead.
Owen Anderson152d4a42011-07-21 23:38:37 +000077 if (Opcode == ARM::MOVsr) {
Jim Grosbache6be85e2010-09-17 22:36:38 +000078 // FIXME: Thumb variants?
Johnny Chen9e088762010-03-17 17:52:21 +000079 const MCOperand &Dst = MI->getOperand(0);
80 const MCOperand &MO1 = MI->getOperand(1);
81 const MCOperand &MO2 = MI->getOperand(2);
82 const MCOperand &MO3 = MI->getOperand(3);
83
84 O << '\t' << ARM_AM::getShiftOpcStr(ARM_AM::getSORegShOp(MO3.getImm()));
Chris Lattner35c33bd2010-04-04 04:47:45 +000085 printSBitModifierOperand(MI, 6, O);
86 printPredicateOperand(MI, 4, O);
Johnny Chen9e088762010-03-17 17:52:21 +000087
88 O << '\t' << getRegisterName(Dst.getReg())
89 << ", " << getRegisterName(MO1.getReg());
90
Owen Anderson152d4a42011-07-21 23:38:37 +000091 O << ", " << getRegisterName(MO2.getReg());
92 assert(ARM_AM::getSORegOffset(MO3.getImm()) == 0);
Owen Anderson519020a2011-09-21 17:58:45 +000093 printAnnotation(O, Annot);
Johnny Chen9e088762010-03-17 17:52:21 +000094 return;
95 }
96
Owen Anderson152d4a42011-07-21 23:38:37 +000097 if (Opcode == ARM::MOVsi) {
98 // FIXME: Thumb variants?
99 const MCOperand &Dst = MI->getOperand(0);
100 const MCOperand &MO1 = MI->getOperand(1);
101 const MCOperand &MO2 = MI->getOperand(2);
102
103 O << '\t' << ARM_AM::getShiftOpcStr(ARM_AM::getSORegShOp(MO2.getImm()));
104 printSBitModifierOperand(MI, 5, O);
105 printPredicateOperand(MI, 3, O);
106
107 O << '\t' << getRegisterName(Dst.getReg())
108 << ", " << getRegisterName(MO1.getReg());
109
Owen Andersonede042d2011-09-15 18:36:29 +0000110 if (ARM_AM::getSORegShOp(MO2.getImm()) == ARM_AM::rrx) {
Owen Anderson519020a2011-09-21 17:58:45 +0000111 printAnnotation(O, Annot);
Owen Anderson152d4a42011-07-21 23:38:37 +0000112 return;
Owen Andersonede042d2011-09-15 18:36:29 +0000113 }
Owen Anderson152d4a42011-07-21 23:38:37 +0000114
Owen Anderson3dac0be2011-08-11 18:41:59 +0000115 O << ", #" << translateShiftImm(ARM_AM::getSORegOffset(MO2.getImm()));
Owen Anderson519020a2011-09-21 17:58:45 +0000116 printAnnotation(O, Annot);
Owen Anderson152d4a42011-07-21 23:38:37 +0000117 return;
118 }
119
120
Johnny Chen9e088762010-03-17 17:52:21 +0000121 // A8.6.123 PUSH
Bill Wendling73fe34a2010-11-16 01:16:36 +0000122 if ((Opcode == ARM::STMDB_UPD || Opcode == ARM::t2STMDB_UPD) &&
Owen Anderson81550dc2011-11-02 18:03:14 +0000123 MI->getOperand(0).getReg() == ARM::SP &&
124 MI->getNumOperands() > 5) {
125 // Should only print PUSH if there are at least two registers in the list.
Bill Wendling73fe34a2010-11-16 01:16:36 +0000126 O << '\t' << "push";
127 printPredicateOperand(MI, 2, O);
Jim Grosbach41ad0c42010-12-03 20:33:01 +0000128 if (Opcode == ARM::t2STMDB_UPD)
129 O << ".w";
Bill Wendling73fe34a2010-11-16 01:16:36 +0000130 O << '\t';
131 printRegisterList(MI, 4, O);
Owen Anderson519020a2011-09-21 17:58:45 +0000132 printAnnotation(O, Annot);
Bill Wendling73fe34a2010-11-16 01:16:36 +0000133 return;
Johnny Chen9e088762010-03-17 17:52:21 +0000134 }
Jim Grosbachf6713912011-08-11 18:07:11 +0000135 if (Opcode == ARM::STR_PRE_IMM && MI->getOperand(2).getReg() == ARM::SP &&
136 MI->getOperand(3).getImm() == -4) {
137 O << '\t' << "push";
138 printPredicateOperand(MI, 4, O);
139 O << "\t{" << getRegisterName(MI->getOperand(1).getReg()) << "}";
Owen Anderson519020a2011-09-21 17:58:45 +0000140 printAnnotation(O, Annot);
Jim Grosbachf6713912011-08-11 18:07:11 +0000141 return;
142 }
Johnny Chen9e088762010-03-17 17:52:21 +0000143
144 // A8.6.122 POP
Bill Wendling73fe34a2010-11-16 01:16:36 +0000145 if ((Opcode == ARM::LDMIA_UPD || Opcode == ARM::t2LDMIA_UPD) &&
Owen Anderson81550dc2011-11-02 18:03:14 +0000146 MI->getOperand(0).getReg() == ARM::SP &&
147 MI->getNumOperands() > 5) {
148 // Should only print POP if there are at least two registers in the list.
Bill Wendling73fe34a2010-11-16 01:16:36 +0000149 O << '\t' << "pop";
150 printPredicateOperand(MI, 2, O);
Jim Grosbach41ad0c42010-12-03 20:33:01 +0000151 if (Opcode == ARM::t2LDMIA_UPD)
152 O << ".w";
Bill Wendling73fe34a2010-11-16 01:16:36 +0000153 O << '\t';
154 printRegisterList(MI, 4, O);
Owen Anderson519020a2011-09-21 17:58:45 +0000155 printAnnotation(O, Annot);
Bill Wendling73fe34a2010-11-16 01:16:36 +0000156 return;
Johnny Chen9e088762010-03-17 17:52:21 +0000157 }
Jim Grosbachf8fce712011-08-11 17:35:48 +0000158 if (Opcode == ARM::LDR_POST_IMM && MI->getOperand(2).getReg() == ARM::SP &&
159 MI->getOperand(4).getImm() == 4) {
160 O << '\t' << "pop";
161 printPredicateOperand(MI, 5, O);
162 O << "\t{" << getRegisterName(MI->getOperand(0).getReg()) << "}";
Owen Anderson519020a2011-09-21 17:58:45 +0000163 printAnnotation(O, Annot);
Jim Grosbachf8fce712011-08-11 17:35:48 +0000164 return;
165 }
166
Johnny Chen9e088762010-03-17 17:52:21 +0000167
168 // A8.6.355 VPUSH
Bill Wendling73fe34a2010-11-16 01:16:36 +0000169 if ((Opcode == ARM::VSTMSDB_UPD || Opcode == ARM::VSTMDDB_UPD) &&
Johnny Chen9e088762010-03-17 17:52:21 +0000170 MI->getOperand(0).getReg() == ARM::SP) {
Bill Wendling73fe34a2010-11-16 01:16:36 +0000171 O << '\t' << "vpush";
172 printPredicateOperand(MI, 2, O);
173 O << '\t';
174 printRegisterList(MI, 4, O);
Owen Anderson519020a2011-09-21 17:58:45 +0000175 printAnnotation(O, Annot);
Bill Wendling73fe34a2010-11-16 01:16:36 +0000176 return;
Johnny Chen9e088762010-03-17 17:52:21 +0000177 }
178
179 // A8.6.354 VPOP
Bill Wendling73fe34a2010-11-16 01:16:36 +0000180 if ((Opcode == ARM::VLDMSIA_UPD || Opcode == ARM::VLDMDIA_UPD) &&
Johnny Chen9e088762010-03-17 17:52:21 +0000181 MI->getOperand(0).getReg() == ARM::SP) {
Bill Wendling73fe34a2010-11-16 01:16:36 +0000182 O << '\t' << "vpop";
183 printPredicateOperand(MI, 2, O);
184 O << '\t';
185 printRegisterList(MI, 4, O);
Owen Anderson519020a2011-09-21 17:58:45 +0000186 printAnnotation(O, Annot);
Bill Wendling73fe34a2010-11-16 01:16:36 +0000187 return;
Johnny Chen9e088762010-03-17 17:52:21 +0000188 }
189
Jim Grosbachcefe4c92011-08-23 17:41:15 +0000190 if (Opcode == ARM::tLDMIA) {
Owen Anderson565a0362011-07-18 23:25:34 +0000191 bool Writeback = true;
192 unsigned BaseReg = MI->getOperand(0).getReg();
193 for (unsigned i = 3; i < MI->getNumOperands(); ++i) {
194 if (MI->getOperand(i).getReg() == BaseReg)
195 Writeback = false;
196 }
197
Jim Grosbachcefe4c92011-08-23 17:41:15 +0000198 O << "\tldm";
Owen Anderson565a0362011-07-18 23:25:34 +0000199
200 printPredicateOperand(MI, 1, O);
201 O << '\t' << getRegisterName(BaseReg);
202 if (Writeback) O << "!";
203 O << ", ";
204 printRegisterList(MI, 3, O);
Owen Anderson519020a2011-09-21 17:58:45 +0000205 printAnnotation(O, Annot);
Owen Anderson565a0362011-07-18 23:25:34 +0000206 return;
207 }
208
Jim Grosbach0780b632011-08-19 23:24:36 +0000209 // Thumb1 NOP
210 if (Opcode == ARM::tMOVr && MI->getOperand(0).getReg() == ARM::R8 &&
211 MI->getOperand(1).getReg() == ARM::R8) {
212 O << "\tnop";
Jim Grosbachdf9ce6b2011-08-24 20:06:14 +0000213 printPredicateOperand(MI, 2, O);
Owen Anderson519020a2011-09-21 17:58:45 +0000214 printAnnotation(O, Annot);
Jim Grosbach0780b632011-08-19 23:24:36 +0000215 return;
216 }
217
Chris Lattner35c33bd2010-04-04 04:47:45 +0000218 printInstruction(MI, O);
Owen Anderson519020a2011-09-21 17:58:45 +0000219 printAnnotation(O, Annot);
Bill Wendling04863d02010-11-13 10:40:19 +0000220}
Chris Lattnerfd603822009-10-19 19:56:26 +0000221
Chris Lattner8bc86cb2009-10-19 20:59:55 +0000222void ARMInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
Jim Grosbach0a2287b2010-11-03 01:11:15 +0000223 raw_ostream &O) {
Chris Lattner8bc86cb2009-10-19 20:59:55 +0000224 const MCOperand &Op = MI->getOperand(OpNo);
225 if (Op.isReg()) {
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000226 unsigned Reg = Op.getReg();
Jim Grosbach35636282010-10-06 21:22:32 +0000227 O << getRegisterName(Reg);
Chris Lattner8bc86cb2009-10-19 20:59:55 +0000228 } else if (Op.isImm()) {
229 O << '#' << Op.getImm();
230 } else {
231 assert(Op.isExpr() && "unknown operand kind in printOperand");
Kevin Enderby9e5887b2011-10-04 22:44:48 +0000232 // If a symbolic branch target was added as a constant expression then print
Kevin Enderby6c226952012-04-13 18:46:37 +0000233 // that address in hex. And only print 32 unsigned bits for the address.
Kevin Enderby9e5887b2011-10-04 22:44:48 +0000234 const MCConstantExpr *BranchTarget = dyn_cast<MCConstantExpr>(Op.getExpr());
235 int64_t Address;
236 if (BranchTarget && BranchTarget->EvaluateAsAbsolute(Address)) {
237 O << "0x";
Kevin Enderby6c226952012-04-13 18:46:37 +0000238 O.write_hex((uint32_t)Address);
Kevin Enderby9e5887b2011-10-04 22:44:48 +0000239 }
240 else {
241 // Otherwise, just print the expression.
242 O << *Op.getExpr();
243 }
Chris Lattner8bc86cb2009-10-19 20:59:55 +0000244 }
245}
Chris Lattner61d35c22009-10-19 21:21:39 +0000246
Owen Andersone1368722011-09-21 23:44:46 +0000247void ARMInstPrinter::printT2LdrLabelOperand(const MCInst *MI, unsigned OpNum,
248 raw_ostream &O) {
249 const MCOperand &MO1 = MI->getOperand(OpNum);
250 if (MO1.isExpr())
251 O << *MO1.getExpr();
252 else if (MO1.isImm())
253 O << "[pc, #" << MO1.getImm() << "]";
254 else
255 llvm_unreachable("Unknown LDR label operand?");
256}
257
Chris Lattner017d9472009-10-20 00:40:56 +0000258// so_reg is a 4-operand unit corresponding to register forms of the A5.1
259// "Addressing Mode 1 - Data-processing operands" forms. This includes:
260// REG 0 0 - e.g. R5
261// REG REG 0,SH_OPC - e.g. R5, ROR R3
262// REG 0 IMM,SH_OPC - e.g. R5, LSL #3
Owen Anderson152d4a42011-07-21 23:38:37 +0000263void ARMInstPrinter::printSORegRegOperand(const MCInst *MI, unsigned OpNum,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000264 raw_ostream &O) {
Chris Lattner017d9472009-10-20 00:40:56 +0000265 const MCOperand &MO1 = MI->getOperand(OpNum);
266 const MCOperand &MO2 = MI->getOperand(OpNum+1);
267 const MCOperand &MO3 = MI->getOperand(OpNum+2);
Jim Grosbach15d78982010-09-14 22:27:15 +0000268
Chris Lattner017d9472009-10-20 00:40:56 +0000269 O << getRegisterName(MO1.getReg());
Jim Grosbach15d78982010-09-14 22:27:15 +0000270
Chris Lattner017d9472009-10-20 00:40:56 +0000271 // Print the shift opc.
Bob Wilson1d9125a2010-08-05 00:34:42 +0000272 ARM_AM::ShiftOpc ShOpc = ARM_AM::getSORegShOp(MO3.getImm());
273 O << ", " << ARM_AM::getShiftOpcStr(ShOpc);
Jim Grosbache8606dc2011-07-13 17:50:29 +0000274 if (ShOpc == ARM_AM::rrx)
275 return;
Jim Grosbach293a5f62011-10-21 16:56:40 +0000276
Owen Anderson152d4a42011-07-21 23:38:37 +0000277 O << ' ' << getRegisterName(MO2.getReg());
278 assert(ARM_AM::getSORegOffset(MO3.getImm()) == 0);
Chris Lattner017d9472009-10-20 00:40:56 +0000279}
Chris Lattner084f87d2009-10-19 21:57:05 +0000280
Owen Anderson152d4a42011-07-21 23:38:37 +0000281void ARMInstPrinter::printSORegImmOperand(const MCInst *MI, unsigned OpNum,
282 raw_ostream &O) {
283 const MCOperand &MO1 = MI->getOperand(OpNum);
284 const MCOperand &MO2 = MI->getOperand(OpNum+1);
285
286 O << getRegisterName(MO1.getReg());
287
288 // Print the shift opc.
289 ARM_AM::ShiftOpc ShOpc = ARM_AM::getSORegShOp(MO2.getImm());
290 O << ", " << ARM_AM::getShiftOpcStr(ShOpc);
291 if (ShOpc == ARM_AM::rrx)
292 return;
Owen Anderson3dac0be2011-08-11 18:41:59 +0000293 O << " #" << translateShiftImm(ARM_AM::getSORegOffset(MO2.getImm()));
Owen Anderson152d4a42011-07-21 23:38:37 +0000294}
295
296
Bruno Cardoso Lopesac79e4c2011-04-04 17:18:19 +0000297//===--------------------------------------------------------------------===//
298// Addressing Mode #2
299//===--------------------------------------------------------------------===//
300
Bruno Cardoso Lopesae085542011-03-31 23:26:08 +0000301void ARMInstPrinter::printAM2PreOrOffsetIndexOp(const MCInst *MI, unsigned Op,
302 raw_ostream &O) {
Chris Lattner084f87d2009-10-19 21:57:05 +0000303 const MCOperand &MO1 = MI->getOperand(Op);
304 const MCOperand &MO2 = MI->getOperand(Op+1);
305 const MCOperand &MO3 = MI->getOperand(Op+2);
Jim Grosbach15d78982010-09-14 22:27:15 +0000306
Chris Lattner084f87d2009-10-19 21:57:05 +0000307 O << "[" << getRegisterName(MO1.getReg());
Jim Grosbach15d78982010-09-14 22:27:15 +0000308
Chris Lattner084f87d2009-10-19 21:57:05 +0000309 if (!MO2.getReg()) {
Johnny Chen9e088762010-03-17 17:52:21 +0000310 if (ARM_AM::getAM2Offset(MO3.getImm())) // Don't print +0.
Chris Lattner084f87d2009-10-19 21:57:05 +0000311 O << ", #"
Johnny Chen9e088762010-03-17 17:52:21 +0000312 << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO3.getImm()))
313 << ARM_AM::getAM2Offset(MO3.getImm());
Chris Lattner084f87d2009-10-19 21:57:05 +0000314 O << "]";
315 return;
316 }
Jim Grosbach15d78982010-09-14 22:27:15 +0000317
Chris Lattner084f87d2009-10-19 21:57:05 +0000318 O << ", "
Johnny Chen9e088762010-03-17 17:52:21 +0000319 << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO3.getImm()))
320 << getRegisterName(MO2.getReg());
Jim Grosbach15d78982010-09-14 22:27:15 +0000321
Chris Lattner084f87d2009-10-19 21:57:05 +0000322 if (unsigned ShImm = ARM_AM::getAM2Offset(MO3.getImm()))
323 O << ", "
324 << ARM_AM::getShiftOpcStr(ARM_AM::getAM2ShiftOpc(MO3.getImm()))
325 << " #" << ShImm;
326 O << "]";
Jim Grosbach15d78982010-09-14 22:27:15 +0000327}
Chris Lattnere306d8d2009-10-19 22:09:23 +0000328
Bruno Cardoso Lopesae085542011-03-31 23:26:08 +0000329void ARMInstPrinter::printAM2PostIndexOp(const MCInst *MI, unsigned Op,
330 raw_ostream &O) {
331 const MCOperand &MO1 = MI->getOperand(Op);
332 const MCOperand &MO2 = MI->getOperand(Op+1);
333 const MCOperand &MO3 = MI->getOperand(Op+2);
334
335 O << "[" << getRegisterName(MO1.getReg()) << "], ";
336
337 if (!MO2.getReg()) {
338 unsigned ImmOffs = ARM_AM::getAM2Offset(MO3.getImm());
339 O << '#'
340 << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO3.getImm()))
341 << ImmOffs;
342 return;
343 }
344
345 O << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO3.getImm()))
346 << getRegisterName(MO2.getReg());
347
348 if (unsigned ShImm = ARM_AM::getAM2Offset(MO3.getImm()))
349 O << ", "
350 << ARM_AM::getShiftOpcStr(ARM_AM::getAM2ShiftOpc(MO3.getImm()))
351 << " #" << ShImm;
352}
353
Jim Grosbach7f739be2011-09-19 22:21:13 +0000354void ARMInstPrinter::printAddrModeTBB(const MCInst *MI, unsigned Op,
355 raw_ostream &O) {
356 const MCOperand &MO1 = MI->getOperand(Op);
357 const MCOperand &MO2 = MI->getOperand(Op+1);
358 O << "[" << getRegisterName(MO1.getReg()) << ", "
359 << getRegisterName(MO2.getReg()) << "]";
360}
361
362void ARMInstPrinter::printAddrModeTBH(const MCInst *MI, unsigned Op,
363 raw_ostream &O) {
364 const MCOperand &MO1 = MI->getOperand(Op);
365 const MCOperand &MO2 = MI->getOperand(Op+1);
366 O << "[" << getRegisterName(MO1.getReg()) << ", "
367 << getRegisterName(MO2.getReg()) << ", lsl #1]";
368}
369
Bruno Cardoso Lopesae085542011-03-31 23:26:08 +0000370void ARMInstPrinter::printAddrMode2Operand(const MCInst *MI, unsigned Op,
371 raw_ostream &O) {
372 const MCOperand &MO1 = MI->getOperand(Op);
373
374 if (!MO1.isReg()) { // FIXME: This is for CP entries, but isn't right.
375 printOperand(MI, Op, O);
376 return;
377 }
378
379 const MCOperand &MO3 = MI->getOperand(Op+2);
380 unsigned IdxMode = ARM_AM::getAM2IdxMode(MO3.getImm());
381
382 if (IdxMode == ARMII::IndexModePost) {
383 printAM2PostIndexOp(MI, Op, O);
384 return;
385 }
386 printAM2PreOrOffsetIndexOp(MI, Op, O);
387}
388
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000389void ARMInstPrinter::printAddrMode2OffsetOperand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000390 unsigned OpNum,
391 raw_ostream &O) {
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000392 const MCOperand &MO1 = MI->getOperand(OpNum);
393 const MCOperand &MO2 = MI->getOperand(OpNum+1);
Jim Grosbach15d78982010-09-14 22:27:15 +0000394
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000395 if (!MO1.getReg()) {
396 unsigned ImmOffs = ARM_AM::getAM2Offset(MO2.getImm());
Johnny Chen9e088762010-03-17 17:52:21 +0000397 O << '#'
398 << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO2.getImm()))
399 << ImmOffs;
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000400 return;
401 }
Jim Grosbach15d78982010-09-14 22:27:15 +0000402
Johnny Chen9e088762010-03-17 17:52:21 +0000403 O << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO2.getImm()))
404 << getRegisterName(MO1.getReg());
Jim Grosbach15d78982010-09-14 22:27:15 +0000405
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000406 if (unsigned ShImm = ARM_AM::getAM2Offset(MO2.getImm()))
407 O << ", "
408 << ARM_AM::getShiftOpcStr(ARM_AM::getAM2ShiftOpc(MO2.getImm()))
409 << " #" << ShImm;
410}
411
Bruno Cardoso Lopesac79e4c2011-04-04 17:18:19 +0000412//===--------------------------------------------------------------------===//
413// Addressing Mode #3
414//===--------------------------------------------------------------------===//
415
416void ARMInstPrinter::printAM3PostIndexOp(const MCInst *MI, unsigned Op,
417 raw_ostream &O) {
418 const MCOperand &MO1 = MI->getOperand(Op);
419 const MCOperand &MO2 = MI->getOperand(Op+1);
420 const MCOperand &MO3 = MI->getOperand(Op+2);
421
422 O << "[" << getRegisterName(MO1.getReg()) << "], ";
423
424 if (MO2.getReg()) {
425 O << (char)ARM_AM::getAM3Op(MO3.getImm())
426 << getRegisterName(MO2.getReg());
427 return;
428 }
429
430 unsigned ImmOffs = ARM_AM::getAM3Offset(MO3.getImm());
431 O << '#'
432 << ARM_AM::getAddrOpcStr(ARM_AM::getAM3Op(MO3.getImm()))
433 << ImmOffs;
434}
435
436void ARMInstPrinter::printAM3PreOrOffsetIndexOp(const MCInst *MI, unsigned Op,
437 raw_ostream &O) {
438 const MCOperand &MO1 = MI->getOperand(Op);
439 const MCOperand &MO2 = MI->getOperand(Op+1);
440 const MCOperand &MO3 = MI->getOperand(Op+2);
Jim Grosbach15d78982010-09-14 22:27:15 +0000441
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000442 O << '[' << getRegisterName(MO1.getReg());
Jim Grosbach15d78982010-09-14 22:27:15 +0000443
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000444 if (MO2.getReg()) {
Jim Grosbach7ce05792011-08-03 23:50:40 +0000445 O << ", " << getAddrOpcStr(ARM_AM::getAM3Op(MO3.getImm()))
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000446 << getRegisterName(MO2.getReg()) << ']';
447 return;
448 }
Jim Grosbach15d78982010-09-14 22:27:15 +0000449
Silviu Barangaca3cd412012-05-11 09:10:54 +0000450 //If the op is sub we have to print the immediate even if it is 0
451 unsigned ImmOffs = ARM_AM::getAM3Offset(MO3.getImm());
452 ARM_AM::AddrOpc op = ARM_AM::getAM3Op(MO3.getImm());
453
454 if (ImmOffs || (op == ARM_AM::sub))
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000455 O << ", #"
Silviu Barangaca3cd412012-05-11 09:10:54 +0000456 << ARM_AM::getAddrOpcStr(op)
Johnny Chen9e088762010-03-17 17:52:21 +0000457 << ImmOffs;
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000458 O << ']';
459}
460
Bruno Cardoso Lopesac79e4c2011-04-04 17:18:19 +0000461void ARMInstPrinter::printAddrMode3Operand(const MCInst *MI, unsigned Op,
462 raw_ostream &O) {
Jim Grosbach2f196742011-12-19 23:06:24 +0000463 const MCOperand &MO1 = MI->getOperand(Op);
464 if (!MO1.isReg()) { // For label symbolic references.
465 printOperand(MI, Op, O);
466 return;
467 }
468
Bruno Cardoso Lopesac79e4c2011-04-04 17:18:19 +0000469 const MCOperand &MO3 = MI->getOperand(Op+2);
470 unsigned IdxMode = ARM_AM::getAM3IdxMode(MO3.getImm());
471
472 if (IdxMode == ARMII::IndexModePost) {
473 printAM3PostIndexOp(MI, Op, O);
474 return;
475 }
476 printAM3PreOrOffsetIndexOp(MI, Op, O);
477}
478
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000479void ARMInstPrinter::printAddrMode3OffsetOperand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000480 unsigned OpNum,
481 raw_ostream &O) {
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000482 const MCOperand &MO1 = MI->getOperand(OpNum);
483 const MCOperand &MO2 = MI->getOperand(OpNum+1);
Jim Grosbach15d78982010-09-14 22:27:15 +0000484
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000485 if (MO1.getReg()) {
Jim Grosbach7ce05792011-08-03 23:50:40 +0000486 O << getAddrOpcStr(ARM_AM::getAM3Op(MO2.getImm()))
487 << getRegisterName(MO1.getReg());
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000488 return;
489 }
Jim Grosbach15d78982010-09-14 22:27:15 +0000490
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000491 unsigned ImmOffs = ARM_AM::getAM3Offset(MO2.getImm());
Johnny Chen9e088762010-03-17 17:52:21 +0000492 O << '#'
493 << ARM_AM::getAddrOpcStr(ARM_AM::getAM3Op(MO2.getImm()))
494 << ImmOffs;
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000495}
496
Jim Grosbach7ce05792011-08-03 23:50:40 +0000497void ARMInstPrinter::printPostIdxImm8Operand(const MCInst *MI,
498 unsigned OpNum,
499 raw_ostream &O) {
500 const MCOperand &MO = MI->getOperand(OpNum);
501 unsigned Imm = MO.getImm();
502 O << '#' << ((Imm & 256) ? "" : "-") << (Imm & 0xff);
503}
504
Jim Grosbachca8c70b2011-08-05 15:48:21 +0000505void ARMInstPrinter::printPostIdxRegOperand(const MCInst *MI, unsigned OpNum,
506 raw_ostream &O) {
507 const MCOperand &MO1 = MI->getOperand(OpNum);
508 const MCOperand &MO2 = MI->getOperand(OpNum+1);
509
Jim Grosbach16578b52011-08-05 16:11:38 +0000510 O << (MO2.getImm() ? "" : "-") << getRegisterName(MO1.getReg());
Jim Grosbachca8c70b2011-08-05 15:48:21 +0000511}
512
Owen Anderson154c41d2011-08-04 18:24:14 +0000513void ARMInstPrinter::printPostIdxImm8s4Operand(const MCInst *MI,
514 unsigned OpNum,
515 raw_ostream &O) {
516 const MCOperand &MO = MI->getOperand(OpNum);
517 unsigned Imm = MO.getImm();
518 O << '#' << ((Imm & 256) ? "" : "-") << ((Imm & 0xff) << 2);
519}
520
521
Jim Grosbache6913602010-11-03 01:01:43 +0000522void ARMInstPrinter::printLdStmModeOperand(const MCInst *MI, unsigned OpNum,
Jim Grosbach0a2287b2010-11-03 01:11:15 +0000523 raw_ostream &O) {
Jim Grosbache6913602010-11-03 01:01:43 +0000524 ARM_AM::AMSubMode Mode = ARM_AM::getAM4SubMode(MI->getOperand(OpNum)
525 .getImm());
526 O << ARM_AM::getAMSubModeStr(Mode);
Chris Lattnere306d8d2009-10-19 22:09:23 +0000527}
528
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000529void ARMInstPrinter::printAddrMode5Operand(const MCInst *MI, unsigned OpNum,
Jim Grosbach0a2287b2010-11-03 01:11:15 +0000530 raw_ostream &O) {
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000531 const MCOperand &MO1 = MI->getOperand(OpNum);
532 const MCOperand &MO2 = MI->getOperand(OpNum+1);
Jim Grosbach15d78982010-09-14 22:27:15 +0000533
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000534 if (!MO1.isReg()) { // FIXME: This is for CP entries, but isn't right.
Chris Lattner35c33bd2010-04-04 04:47:45 +0000535 printOperand(MI, OpNum, O);
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000536 return;
537 }
Jim Grosbach15d78982010-09-14 22:27:15 +0000538
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000539 O << "[" << getRegisterName(MO1.getReg());
Jim Grosbach15d78982010-09-14 22:27:15 +0000540
Owen Anderson0da10cf2011-08-29 19:36:44 +0000541 unsigned ImmOffs = ARM_AM::getAM5Offset(MO2.getImm());
542 unsigned Op = ARM_AM::getAM5Op(MO2.getImm());
543 if (ImmOffs || Op == ARM_AM::sub) {
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000544 O << ", #"
Johnny Chen9e088762010-03-17 17:52:21 +0000545 << ARM_AM::getAddrOpcStr(ARM_AM::getAM5Op(MO2.getImm()))
Bill Wendling92b5a2e2010-11-03 01:49:29 +0000546 << ImmOffs * 4;
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000547 }
548 O << "]";
549}
550
Chris Lattner35c33bd2010-04-04 04:47:45 +0000551void ARMInstPrinter::printAddrMode6Operand(const MCInst *MI, unsigned OpNum,
552 raw_ostream &O) {
Chris Lattner235e2f62009-10-20 06:22:33 +0000553 const MCOperand &MO1 = MI->getOperand(OpNum);
554 const MCOperand &MO2 = MI->getOperand(OpNum+1);
Jim Grosbach15d78982010-09-14 22:27:15 +0000555
Bob Wilson226036e2010-03-20 22:13:40 +0000556 O << "[" << getRegisterName(MO1.getReg());
557 if (MO2.getImm()) {
558 // FIXME: Both darwin as and GNU as violate ARM docs here.
Bob Wilson273ff312010-07-14 23:54:43 +0000559 O << ", :" << (MO2.getImm() << 3);
Chris Lattner235e2f62009-10-20 06:22:33 +0000560 }
Bob Wilson226036e2010-03-20 22:13:40 +0000561 O << "]";
562}
563
Bruno Cardoso Lopes505f3cd2011-03-24 21:04:58 +0000564void ARMInstPrinter::printAddrMode7Operand(const MCInst *MI, unsigned OpNum,
565 raw_ostream &O) {
566 const MCOperand &MO1 = MI->getOperand(OpNum);
567 O << "[" << getRegisterName(MO1.getReg()) << "]";
568}
569
Bob Wilson226036e2010-03-20 22:13:40 +0000570void ARMInstPrinter::printAddrMode6OffsetOperand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000571 unsigned OpNum,
572 raw_ostream &O) {
Bob Wilson226036e2010-03-20 22:13:40 +0000573 const MCOperand &MO = MI->getOperand(OpNum);
574 if (MO.getReg() == 0)
575 O << "!";
576 else
577 O << ", " << getRegisterName(MO.getReg());
Chris Lattner235e2f62009-10-20 06:22:33 +0000578}
579
Bob Wilsoneaf1c982010-08-11 23:10:46 +0000580void ARMInstPrinter::printBitfieldInvMaskImmOperand(const MCInst *MI,
581 unsigned OpNum,
582 raw_ostream &O) {
Chris Lattner235e2f62009-10-20 06:22:33 +0000583 const MCOperand &MO = MI->getOperand(OpNum);
584 uint32_t v = ~MO.getImm();
585 int32_t lsb = CountTrailingZeros_32(v);
586 int32_t width = (32 - CountLeadingZeros_32 (v)) - lsb;
587 assert(MO.isImm() && "Not a valid bf_inv_mask_imm value!");
588 O << '#' << lsb << ", #" << width;
589}
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000590
Johnny Chen1adc40c2010-08-12 20:46:17 +0000591void ARMInstPrinter::printMemBOption(const MCInst *MI, unsigned OpNum,
592 raw_ostream &O) {
593 unsigned val = MI->getOperand(OpNum).getImm();
594 O << ARM_MB::MemBOptToString(val);
595}
596
Bob Wilson22f5dc72010-08-16 18:27:34 +0000597void ARMInstPrinter::printShiftImmOperand(const MCInst *MI, unsigned OpNum,
Bob Wilsoneaf1c982010-08-11 23:10:46 +0000598 raw_ostream &O) {
599 unsigned ShiftOp = MI->getOperand(OpNum).getImm();
Jim Grosbach580f4a92011-07-25 22:20:28 +0000600 bool isASR = (ShiftOp & (1 << 5)) != 0;
601 unsigned Amt = ShiftOp & 0x1f;
602 if (isASR)
603 O << ", asr #" << (Amt == 0 ? 32 : Amt);
604 else if (Amt)
605 O << ", lsl #" << Amt;
Bob Wilsoneaf1c982010-08-11 23:10:46 +0000606}
607
Jim Grosbachdde038a2011-07-20 21:40:26 +0000608void ARMInstPrinter::printPKHLSLShiftImm(const MCInst *MI, unsigned OpNum,
609 raw_ostream &O) {
610 unsigned Imm = MI->getOperand(OpNum).getImm();
611 if (Imm == 0)
612 return;
613 assert(Imm > 0 && Imm < 32 && "Invalid PKH shift immediate value!");
614 O << ", lsl #" << Imm;
615}
616
617void ARMInstPrinter::printPKHASRShiftImm(const MCInst *MI, unsigned OpNum,
618 raw_ostream &O) {
619 unsigned Imm = MI->getOperand(OpNum).getImm();
620 // A shift amount of 32 is encoded as 0.
621 if (Imm == 0)
622 Imm = 32;
623 assert(Imm > 0 && Imm <= 32 && "Invalid PKH shift immediate value!");
624 O << ", asr #" << Imm;
625}
626
Chris Lattner35c33bd2010-04-04 04:47:45 +0000627void ARMInstPrinter::printRegisterList(const MCInst *MI, unsigned OpNum,
628 raw_ostream &O) {
Chris Lattnere306d8d2009-10-19 22:09:23 +0000629 O << "{";
Johnny Chen9e088762010-03-17 17:52:21 +0000630 for (unsigned i = OpNum, e = MI->getNumOperands(); i != e; ++i) {
631 if (i != OpNum) O << ", ";
Chris Lattnere306d8d2009-10-19 22:09:23 +0000632 O << getRegisterName(MI->getOperand(i).getReg());
633 }
634 O << "}";
635}
Chris Lattner4d152222009-10-19 22:23:04 +0000636
Jim Grosbachb3af5de2010-10-13 21:00:04 +0000637void ARMInstPrinter::printSetendOperand(const MCInst *MI, unsigned OpNum,
638 raw_ostream &O) {
639 const MCOperand &Op = MI->getOperand(OpNum);
640 if (Op.getImm())
641 O << "be";
642 else
643 O << "le";
644}
645
Bruno Cardoso Lopesa2b6e412011-02-14 13:09:44 +0000646void ARMInstPrinter::printCPSIMod(const MCInst *MI, unsigned OpNum,
647 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000648 const MCOperand &Op = MI->getOperand(OpNum);
Bruno Cardoso Lopesa2b6e412011-02-14 13:09:44 +0000649 O << ARM_PROC::IModToString(Op.getImm());
650}
651
652void ARMInstPrinter::printCPSIFlag(const MCInst *MI, unsigned OpNum,
653 raw_ostream &O) {
654 const MCOperand &Op = MI->getOperand(OpNum);
655 unsigned IFlags = Op.getImm();
656 for (int i=2; i >= 0; --i)
657 if (IFlags & (1 << i))
658 O << ARM_PROC::IFlagsToString(1 << i);
Owen Anderson2dbb46a2011-10-05 17:16:40 +0000659
660 if (IFlags == 0)
661 O << "none";
Johnny Chen9e088762010-03-17 17:52:21 +0000662}
663
Chris Lattner35c33bd2010-04-04 04:47:45 +0000664void ARMInstPrinter::printMSRMaskOperand(const MCInst *MI, unsigned OpNum,
665 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000666 const MCOperand &Op = MI->getOperand(OpNum);
Bruno Cardoso Lopes584bf7b2011-02-18 19:45:59 +0000667 unsigned SpecRegRBit = Op.getImm() >> 4;
668 unsigned Mask = Op.getImm() & 0xf;
669
James Molloyacad68d2011-09-28 14:21:38 +0000670 if (getAvailableFeatures() & ARM::FeatureMClass) {
Kevin Enderby0fd4f3c2012-05-17 22:18:01 +0000671 unsigned SYSm = Op.getImm();
672 unsigned Opcode = MI->getOpcode();
673 // For reads of the special registers ignore the "mask encoding" bits
674 // which are only for writes.
675 if (Opcode == ARM::t2MRS_M)
676 SYSm &= 0xff;
677 switch (SYSm) {
Craig Topperbc219812012-02-07 02:50:20 +0000678 default: llvm_unreachable("Unexpected mask value!");
Kevin Enderby0fd4f3c2012-05-17 22:18:01 +0000679 case 0:
680 case 0x800: O << "apsr"; return; // with _nzcvq bits is an alias for aspr
681 case 0x400: O << "apsr_g"; return;
682 case 0xc00: O << "apsr_nzcvqg"; return;
683 case 1:
684 case 0x801: O << "iapsr"; return; // with _nzcvq bits is an alias for iapsr
685 case 0x401: O << "iapsr_g"; return;
686 case 0xc01: O << "iapsr_nzcvqg"; return;
687 case 2:
688 case 0x802: O << "eapsr"; return; // with _nzcvq bits is an alias for eapsr
689 case 0x402: O << "eapsr_g"; return;
690 case 0xc02: O << "eapsr_nzcvqg"; return;
691 case 3:
692 case 0x803: O << "xpsr"; return; // with _nzcvq bits is an alias for xpsr
693 case 0x403: O << "xpsr_g"; return;
694 case 0xc03: O << "xpsr_nzcvqg"; return;
Kevin Enderbyf49a4092012-06-15 22:14:44 +0000695 case 5:
696 case 0x805: O << "ipsr"; return;
697 case 6:
698 case 0x806: O << "epsr"; return;
699 case 7:
700 case 0x807: O << "iepsr"; return;
701 case 8:
702 case 0x808: O << "msp"; return;
703 case 9:
704 case 0x809: O << "psp"; return;
705 case 0x10:
706 case 0x810: O << "primask"; return;
707 case 0x11:
708 case 0x811: O << "basepri"; return;
709 case 0x12:
710 case 0x812: O << "basepri_max"; return;
711 case 0x13:
712 case 0x813: O << "faultmask"; return;
713 case 0x14:
714 case 0x814: O << "control"; return;
James Molloyacad68d2011-09-28 14:21:38 +0000715 }
716 }
717
Jim Grosbachb29b4dd2011-07-19 22:45:10 +0000718 // As special cases, CPSR_f, CPSR_s and CPSR_fs prefer printing as
719 // APSR_nzcvq, APSR_g and APSRnzcvqg, respectively.
720 if (!SpecRegRBit && (Mask == 8 || Mask == 4 || Mask == 12)) {
721 O << "APSR_";
722 switch (Mask) {
Craig Topperbc219812012-02-07 02:50:20 +0000723 default: llvm_unreachable("Unexpected mask value!");
Jim Grosbachb29b4dd2011-07-19 22:45:10 +0000724 case 4: O << "g"; return;
725 case 8: O << "nzcvq"; return;
726 case 12: O << "nzcvqg"; return;
727 }
Jim Grosbachb29b4dd2011-07-19 22:45:10 +0000728 }
729
Bruno Cardoso Lopes584bf7b2011-02-18 19:45:59 +0000730 if (SpecRegRBit)
Jim Grosbachb29b4dd2011-07-19 22:45:10 +0000731 O << "SPSR";
Bruno Cardoso Lopes584bf7b2011-02-18 19:45:59 +0000732 else
Jim Grosbachb29b4dd2011-07-19 22:45:10 +0000733 O << "CPSR";
Bruno Cardoso Lopes584bf7b2011-02-18 19:45:59 +0000734
Johnny Chen9e088762010-03-17 17:52:21 +0000735 if (Mask) {
736 O << '_';
737 if (Mask & 8) O << 'f';
738 if (Mask & 4) O << 's';
739 if (Mask & 2) O << 'x';
740 if (Mask & 1) O << 'c';
741 }
742}
743
Chris Lattner35c33bd2010-04-04 04:47:45 +0000744void ARMInstPrinter::printPredicateOperand(const MCInst *MI, unsigned OpNum,
745 raw_ostream &O) {
Chris Lattner413ae252009-10-20 00:42:49 +0000746 ARMCC::CondCodes CC = (ARMCC::CondCodes)MI->getOperand(OpNum).getImm();
Kevin Enderbyb0578512012-03-01 22:13:02 +0000747 // Handle the undefined 15 CC value here for printing so we don't abort().
748 if ((unsigned)CC == 15)
749 O << "<und>";
750 else if (CC != ARMCC::AL)
Chris Lattner413ae252009-10-20 00:42:49 +0000751 O << ARMCondCodeToString(CC);
752}
753
Jim Grosbach15d78982010-09-14 22:27:15 +0000754void ARMInstPrinter::printMandatoryPredicateOperand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000755 unsigned OpNum,
756 raw_ostream &O) {
Johnny Chen9d3acaa2010-03-02 17:57:15 +0000757 ARMCC::CondCodes CC = (ARMCC::CondCodes)MI->getOperand(OpNum).getImm();
758 O << ARMCondCodeToString(CC);
759}
760
Chris Lattner35c33bd2010-04-04 04:47:45 +0000761void ARMInstPrinter::printSBitModifierOperand(const MCInst *MI, unsigned OpNum,
762 raw_ostream &O) {
Daniel Dunbara7cc6522009-10-20 22:10:05 +0000763 if (MI->getOperand(OpNum).getReg()) {
764 assert(MI->getOperand(OpNum).getReg() == ARM::CPSR &&
765 "Expect ARM CPSR register!");
Chris Lattner233917c2009-10-20 00:46:11 +0000766 O << 's';
767 }
768}
769
Chris Lattner35c33bd2010-04-04 04:47:45 +0000770void ARMInstPrinter::printNoHashImmediate(const MCInst *MI, unsigned OpNum,
771 raw_ostream &O) {
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000772 O << MI->getOperand(OpNum).getImm();
773}
774
Owen Andersone4e5e2a2011-01-13 21:46:02 +0000775void ARMInstPrinter::printPImmediate(const MCInst *MI, unsigned OpNum,
Jim Grosbachbc9c8022011-10-12 16:34:37 +0000776 raw_ostream &O) {
Owen Andersone4e5e2a2011-01-13 21:46:02 +0000777 O << "p" << MI->getOperand(OpNum).getImm();
778}
779
780void ARMInstPrinter::printCImmediate(const MCInst *MI, unsigned OpNum,
Jim Grosbachbc9c8022011-10-12 16:34:37 +0000781 raw_ostream &O) {
Owen Andersone4e5e2a2011-01-13 21:46:02 +0000782 O << "c" << MI->getOperand(OpNum).getImm();
783}
784
Jim Grosbach9b8f2a02011-10-12 17:34:41 +0000785void ARMInstPrinter::printCoprocOptionImm(const MCInst *MI, unsigned OpNum,
786 raw_ostream &O) {
787 O << "{" << MI->getOperand(OpNum).getImm() << "}";
788}
789
Chris Lattner35c33bd2010-04-04 04:47:45 +0000790void ARMInstPrinter::printPCLabel(const MCInst *MI, unsigned OpNum,
791 raw_ostream &O) {
Jim Grosbachd30cfde2010-09-18 00:04:53 +0000792 llvm_unreachable("Unhandled PC-relative pseudo-instruction!");
Chris Lattner4d152222009-10-19 22:23:04 +0000793}
Evan Cheng2ef9c8a2009-11-19 06:57:41 +0000794
Chris Lattner35c33bd2010-04-04 04:47:45 +0000795void ARMInstPrinter::printThumbS4ImmOperand(const MCInst *MI, unsigned OpNum,
796 raw_ostream &O) {
Jim Grosbach70939ee2011-08-17 21:51:27 +0000797 O << "#" << MI->getOperand(OpNum).getImm() * 4;
798}
799
800void ARMInstPrinter::printThumbSRImm(const MCInst *MI, unsigned OpNum,
801 raw_ostream &O) {
802 unsigned Imm = MI->getOperand(OpNum).getImm();
803 O << "#" << (Imm == 0 ? 32 : Imm);
Evan Cheng2ef9c8a2009-11-19 06:57:41 +0000804}
Johnny Chen9e088762010-03-17 17:52:21 +0000805
Chris Lattner35c33bd2010-04-04 04:47:45 +0000806void ARMInstPrinter::printThumbITMask(const MCInst *MI, unsigned OpNum,
807 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000808 // (3 - the number of trailing zeros) is the number of then / else.
809 unsigned Mask = MI->getOperand(OpNum).getImm();
Richard Barton4d2f0772012-04-27 08:42:59 +0000810 unsigned Firstcond = MI->getOperand(OpNum-1).getImm();
811 unsigned CondBit0 = Firstcond & 1;
Johnny Chen9e088762010-03-17 17:52:21 +0000812 unsigned NumTZ = CountTrailingZeros_32(Mask);
813 assert(NumTZ <= 3 && "Invalid IT mask!");
814 for (unsigned Pos = 3, e = NumTZ; Pos > e; --Pos) {
815 bool T = ((Mask >> Pos) & 1) == CondBit0;
816 if (T)
817 O << 't';
818 else
819 O << 'e';
820 }
821}
822
Chris Lattner35c33bd2010-04-04 04:47:45 +0000823void ARMInstPrinter::printThumbAddrModeRROperand(const MCInst *MI, unsigned Op,
824 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000825 const MCOperand &MO1 = MI->getOperand(Op);
Bill Wendlingf4caf692010-12-14 03:36:38 +0000826 const MCOperand &MO2 = MI->getOperand(Op + 1);
Johnny Chen9e088762010-03-17 17:52:21 +0000827
828 if (!MO1.isReg()) { // FIXME: This is for CP entries, but isn't right.
Chris Lattner35c33bd2010-04-04 04:47:45 +0000829 printOperand(MI, Op, O);
Johnny Chen9e088762010-03-17 17:52:21 +0000830 return;
831 }
832
833 O << "[" << getRegisterName(MO1.getReg());
Bill Wendlingf4caf692010-12-14 03:36:38 +0000834 if (unsigned RegNum = MO2.getReg())
835 O << ", " << getRegisterName(RegNum);
836 O << "]";
837}
838
839void ARMInstPrinter::printThumbAddrModeImm5SOperand(const MCInst *MI,
840 unsigned Op,
841 raw_ostream &O,
842 unsigned Scale) {
843 const MCOperand &MO1 = MI->getOperand(Op);
844 const MCOperand &MO2 = MI->getOperand(Op + 1);
845
846 if (!MO1.isReg()) { // FIXME: This is for CP entries, but isn't right.
847 printOperand(MI, Op, O);
848 return;
849 }
850
851 O << "[" << getRegisterName(MO1.getReg());
852 if (unsigned ImmOffs = MO2.getImm())
Johnny Chen9e088762010-03-17 17:52:21 +0000853 O << ", #" << ImmOffs * Scale;
854 O << "]";
855}
856
Bill Wendlingf4caf692010-12-14 03:36:38 +0000857void ARMInstPrinter::printThumbAddrModeImm5S1Operand(const MCInst *MI,
858 unsigned Op,
859 raw_ostream &O) {
860 printThumbAddrModeImm5SOperand(MI, Op, O, 1);
Johnny Chen9e088762010-03-17 17:52:21 +0000861}
862
Bill Wendlingf4caf692010-12-14 03:36:38 +0000863void ARMInstPrinter::printThumbAddrModeImm5S2Operand(const MCInst *MI,
864 unsigned Op,
865 raw_ostream &O) {
866 printThumbAddrModeImm5SOperand(MI, Op, O, 2);
Johnny Chen9e088762010-03-17 17:52:21 +0000867}
868
Bill Wendlingf4caf692010-12-14 03:36:38 +0000869void ARMInstPrinter::printThumbAddrModeImm5S4Operand(const MCInst *MI,
870 unsigned Op,
871 raw_ostream &O) {
872 printThumbAddrModeImm5SOperand(MI, Op, O, 4);
Johnny Chen9e088762010-03-17 17:52:21 +0000873}
874
Chris Lattner35c33bd2010-04-04 04:47:45 +0000875void ARMInstPrinter::printThumbAddrModeSPOperand(const MCInst *MI, unsigned Op,
876 raw_ostream &O) {
Bill Wendlingf4caf692010-12-14 03:36:38 +0000877 printThumbAddrModeImm5SOperand(MI, Op, O, 4);
Johnny Chen9e088762010-03-17 17:52:21 +0000878}
879
Johnny Chen9e088762010-03-17 17:52:21 +0000880// Constant shifts t2_so_reg is a 2-operand unit corresponding to the Thumb2
881// register with shift forms.
882// REG 0 0 - e.g. R5
883// REG IMM, SH_OPC - e.g. R5, LSL #3
Chris Lattner35c33bd2010-04-04 04:47:45 +0000884void ARMInstPrinter::printT2SOOperand(const MCInst *MI, unsigned OpNum,
885 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000886 const MCOperand &MO1 = MI->getOperand(OpNum);
887 const MCOperand &MO2 = MI->getOperand(OpNum+1);
888
889 unsigned Reg = MO1.getReg();
890 O << getRegisterName(Reg);
891
892 // Print the shift opc.
Johnny Chen9e088762010-03-17 17:52:21 +0000893 assert(MO2.isImm() && "Not a valid t2_so_reg value!");
Bob Wilson1d9125a2010-08-05 00:34:42 +0000894 ARM_AM::ShiftOpc ShOpc = ARM_AM::getSORegShOp(MO2.getImm());
895 O << ", " << ARM_AM::getShiftOpcStr(ShOpc);
896 if (ShOpc != ARM_AM::rrx)
Owen Anderson3dac0be2011-08-11 18:41:59 +0000897 O << " #" << translateShiftImm(ARM_AM::getSORegOffset(MO2.getImm()));
Johnny Chen9e088762010-03-17 17:52:21 +0000898}
899
Jim Grosbach458f2dc2010-10-25 20:00:01 +0000900void ARMInstPrinter::printAddrModeImm12Operand(const MCInst *MI, unsigned OpNum,
901 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000902 const MCOperand &MO1 = MI->getOperand(OpNum);
903 const MCOperand &MO2 = MI->getOperand(OpNum+1);
904
Jim Grosbach3e556122010-10-26 22:37:02 +0000905 if (!MO1.isReg()) { // FIXME: This is for CP entries, but isn't right.
906 printOperand(MI, OpNum, O);
907 return;
908 }
909
Johnny Chen9e088762010-03-17 17:52:21 +0000910 O << "[" << getRegisterName(MO1.getReg());
911
Jim Grosbach77aee8e2010-10-27 01:19:41 +0000912 int32_t OffImm = (int32_t)MO2.getImm();
Jim Grosbachab682a22010-10-28 18:34:10 +0000913 bool isSub = OffImm < 0;
914 // Special value for #-0. All others are normal.
915 if (OffImm == INT32_MIN)
916 OffImm = 0;
917 if (isSub)
Jim Grosbach77aee8e2010-10-27 01:19:41 +0000918 O << ", #-" << -OffImm;
919 else if (OffImm > 0)
Johnny Chen9e088762010-03-17 17:52:21 +0000920 O << ", #" << OffImm;
921 O << "]";
922}
923
924void ARMInstPrinter::printT2AddrModeImm8Operand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000925 unsigned OpNum,
926 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000927 const MCOperand &MO1 = MI->getOperand(OpNum);
928 const MCOperand &MO2 = MI->getOperand(OpNum+1);
929
930 O << "[" << getRegisterName(MO1.getReg());
931
932 int32_t OffImm = (int32_t)MO2.getImm();
933 // Don't print +0.
Owen Anderson705b48f2011-09-16 21:08:33 +0000934 if (OffImm == INT32_MIN)
935 O << ", #-0";
936 else if (OffImm < 0)
Johnny Chen9e088762010-03-17 17:52:21 +0000937 O << ", #-" << -OffImm;
938 else if (OffImm > 0)
939 O << ", #" << OffImm;
940 O << "]";
941}
942
943void ARMInstPrinter::printT2AddrModeImm8s4Operand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000944 unsigned OpNum,
945 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000946 const MCOperand &MO1 = MI->getOperand(OpNum);
947 const MCOperand &MO2 = MI->getOperand(OpNum+1);
948
Jim Grosbach2f196742011-12-19 23:06:24 +0000949 if (!MO1.isReg()) { // For label symbolic references.
950 printOperand(MI, OpNum, O);
951 return;
952 }
953
Johnny Chen9e088762010-03-17 17:52:21 +0000954 O << "[" << getRegisterName(MO1.getReg());
955
956 int32_t OffImm = (int32_t)MO2.getImm() / 4;
957 // Don't print +0.
958 if (OffImm < 0)
959 O << ", #-" << -OffImm * 4;
960 else if (OffImm > 0)
961 O << ", #" << OffImm * 4;
962 O << "]";
963}
964
Jim Grosbachb6aed502011-09-09 18:37:27 +0000965void ARMInstPrinter::printT2AddrModeImm0_1020s4Operand(const MCInst *MI,
966 unsigned OpNum,
967 raw_ostream &O) {
968 const MCOperand &MO1 = MI->getOperand(OpNum);
969 const MCOperand &MO2 = MI->getOperand(OpNum+1);
970
971 O << "[" << getRegisterName(MO1.getReg());
972 if (MO2.getImm())
973 O << ", #" << MO2.getImm() * 4;
974 O << "]";
975}
976
Johnny Chen9e088762010-03-17 17:52:21 +0000977void ARMInstPrinter::printT2AddrModeImm8OffsetOperand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000978 unsigned OpNum,
979 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000980 const MCOperand &MO1 = MI->getOperand(OpNum);
981 int32_t OffImm = (int32_t)MO1.getImm();
982 // Don't print +0.
983 if (OffImm < 0)
Owen Anderson0781c1f2011-09-23 21:26:40 +0000984 O << ", #-" << -OffImm;
985 else
986 O << ", #" << OffImm;
Johnny Chen9e088762010-03-17 17:52:21 +0000987}
988
989void ARMInstPrinter::printT2AddrModeImm8s4OffsetOperand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000990 unsigned OpNum,
991 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000992 const MCOperand &MO1 = MI->getOperand(OpNum);
993 int32_t OffImm = (int32_t)MO1.getImm() / 4;
994 // Don't print +0.
Owen Anderson7782a582011-09-13 20:46:26 +0000995 if (OffImm != 0) {
996 O << ", ";
997 if (OffImm < 0)
998 O << "#-" << -OffImm * 4;
999 else if (OffImm > 0)
1000 O << "#" << OffImm * 4;
1001 }
Johnny Chen9e088762010-03-17 17:52:21 +00001002}
1003
1004void ARMInstPrinter::printT2AddrModeSoRegOperand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +00001005 unsigned OpNum,
1006 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +00001007 const MCOperand &MO1 = MI->getOperand(OpNum);
1008 const MCOperand &MO2 = MI->getOperand(OpNum+1);
1009 const MCOperand &MO3 = MI->getOperand(OpNum+2);
1010
1011 O << "[" << getRegisterName(MO1.getReg());
1012
1013 assert(MO2.getReg() && "Invalid so_reg load / store address!");
1014 O << ", " << getRegisterName(MO2.getReg());
1015
1016 unsigned ShAmt = MO3.getImm();
1017 if (ShAmt) {
1018 assert(ShAmt <= 3 && "Not a valid Thumb2 addressing mode!");
1019 O << ", lsl #" << ShAmt;
1020 }
1021 O << "]";
1022}
1023
Jim Grosbach4ebbf7b2011-09-30 00:50:06 +00001024void ARMInstPrinter::printFPImmOperand(const MCInst *MI, unsigned OpNum,
1025 raw_ostream &O) {
Bill Wendling8cb415e2011-01-26 20:57:43 +00001026 const MCOperand &MO = MI->getOperand(OpNum);
Jim Grosbach4ebbf7b2011-09-30 00:50:06 +00001027 O << '#' << ARM_AM::getFPImmFloat(MO.getImm());
Johnny Chen9e088762010-03-17 17:52:21 +00001028}
1029
Bob Wilson1a913ed2010-06-11 21:34:50 +00001030void ARMInstPrinter::printNEONModImmOperand(const MCInst *MI, unsigned OpNum,
1031 raw_ostream &O) {
Bob Wilson6dce00c2010-07-13 04:44:34 +00001032 unsigned EncodedImm = MI->getOperand(OpNum).getImm();
1033 unsigned EltBits;
1034 uint64_t Val = ARM_AM::decodeNEONModImm(EncodedImm, EltBits);
Benjamin Kramer70be28a2011-11-07 21:00:59 +00001035 O << "#0x";
1036 O.write_hex(Val);
Johnny Chenc7b65912010-04-16 22:40:20 +00001037}
Jim Grosbach4a5ffb32011-07-22 23:16:18 +00001038
Jim Grosbachf4943352011-07-25 23:09:14 +00001039void ARMInstPrinter::printImmPlusOneOperand(const MCInst *MI, unsigned OpNum,
1040 raw_ostream &O) {
Jim Grosbach4a5ffb32011-07-22 23:16:18 +00001041 unsigned Imm = MI->getOperand(OpNum).getImm();
1042 O << "#" << Imm + 1;
1043}
Jim Grosbach85bfd3b2011-07-26 21:28:43 +00001044
1045void ARMInstPrinter::printRotImmOperand(const MCInst *MI, unsigned OpNum,
1046 raw_ostream &O) {
1047 unsigned Imm = MI->getOperand(OpNum).getImm();
1048 if (Imm == 0)
1049 return;
Jim Grosbach45f39292011-07-26 21:44:37 +00001050 O << ", ror #";
Jim Grosbach85bfd3b2011-07-26 21:28:43 +00001051 switch (Imm) {
1052 default: assert (0 && "illegal ror immediate!");
Jim Grosbach2f815c02011-08-17 23:23:07 +00001053 case 1: O << "8"; break;
1054 case 2: O << "16"; break;
1055 case 3: O << "24"; break;
Jim Grosbach85bfd3b2011-07-26 21:28:43 +00001056 }
1057}
Jim Grosbach460a9052011-10-07 23:56:00 +00001058
Jim Grosbach4050bc42011-12-22 22:19:05 +00001059void ARMInstPrinter::printFBits16(const MCInst *MI, unsigned OpNum,
1060 raw_ostream &O) {
1061 O << "#" << 16 - MI->getOperand(OpNum).getImm();
1062}
1063
1064void ARMInstPrinter::printFBits32(const MCInst *MI, unsigned OpNum,
1065 raw_ostream &O) {
1066 O << "#" << 32 - MI->getOperand(OpNum).getImm();
1067}
1068
Jim Grosbach460a9052011-10-07 23:56:00 +00001069void ARMInstPrinter::printVectorIndex(const MCInst *MI, unsigned OpNum,
1070 raw_ostream &O) {
1071 O << "[" << MI->getOperand(OpNum).getImm() << "]";
1072}
Jim Grosbach862019c2011-10-18 23:02:30 +00001073
1074void ARMInstPrinter::printVectorListOne(const MCInst *MI, unsigned OpNum,
1075 raw_ostream &O) {
1076 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << "}";
1077}
Jim Grosbach280dfad2011-10-21 18:54:25 +00001078
Jim Grosbachc0fc4502012-03-06 22:01:44 +00001079void ARMInstPrinter::printVectorListTwo(const MCInst *MI, unsigned OpNum,
Jim Grosbach28f08c92012-03-05 19:33:30 +00001080 raw_ostream &O) {
1081 unsigned Reg = MI->getOperand(OpNum).getReg();
1082 unsigned Reg0 = MRI.getSubReg(Reg, ARM::dsub_0);
1083 unsigned Reg1 = MRI.getSubReg(Reg, ARM::dsub_1);
1084 O << "{" << getRegisterName(Reg0) << ", " << getRegisterName(Reg1) << "}";
1085}
1086
Jim Grosbachc0fc4502012-03-06 22:01:44 +00001087void ARMInstPrinter::printVectorListTwoSpaced(const MCInst *MI,
1088 unsigned OpNum,
1089 raw_ostream &O) {
Jim Grosbachc3384c92012-03-05 21:43:40 +00001090 unsigned Reg = MI->getOperand(OpNum).getReg();
1091 unsigned Reg0 = MRI.getSubReg(Reg, ARM::dsub_0);
1092 unsigned Reg1 = MRI.getSubReg(Reg, ARM::dsub_2);
1093 O << "{" << getRegisterName(Reg0) << ", " << getRegisterName(Reg1) << "}";
1094}
1095
Jim Grosbachcdcfa282011-10-21 20:02:19 +00001096void ARMInstPrinter::printVectorListThree(const MCInst *MI, unsigned OpNum,
1097 raw_ostream &O) {
1098 // Normally, it's not safe to use register enum values directly with
1099 // addition to get the next register, but for VFP registers, the
1100 // sort order is guaranteed because they're all of the form D<n>.
1101 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << ", "
1102 << getRegisterName(MI->getOperand(OpNum).getReg() + 1) << ", "
1103 << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << "}";
1104}
Jim Grosbachb6310312011-10-21 20:35:01 +00001105
1106void ARMInstPrinter::printVectorListFour(const MCInst *MI, unsigned OpNum,
1107 raw_ostream &O) {
1108 // Normally, it's not safe to use register enum values directly with
1109 // addition to get the next register, but for VFP registers, the
1110 // sort order is guaranteed because they're all of the form D<n>.
1111 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << ", "
1112 << getRegisterName(MI->getOperand(OpNum).getReg() + 1) << ", "
1113 << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << ", "
1114 << getRegisterName(MI->getOperand(OpNum).getReg() + 3) << "}";
1115}
Jim Grosbach98b05a52011-11-30 01:09:44 +00001116
1117void ARMInstPrinter::printVectorListOneAllLanes(const MCInst *MI,
1118 unsigned OpNum,
1119 raw_ostream &O) {
1120 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << "[]}";
1121}
1122
Jim Grosbach13af2222011-11-30 18:21:25 +00001123void ARMInstPrinter::printVectorListTwoAllLanes(const MCInst *MI,
1124 unsigned OpNum,
1125 raw_ostream &O) {
Jim Grosbachc0fc4502012-03-06 22:01:44 +00001126 unsigned Reg = MI->getOperand(OpNum).getReg();
1127 unsigned Reg0 = MRI.getSubReg(Reg, ARM::dsub_0);
1128 unsigned Reg1 = MRI.getSubReg(Reg, ARM::dsub_1);
1129 O << "{" << getRegisterName(Reg0) << "[], " << getRegisterName(Reg1) << "[]}";
Jim Grosbach13af2222011-11-30 18:21:25 +00001130}
Jim Grosbache90ac9b2011-12-14 19:35:22 +00001131
Jim Grosbach5e59f7e2012-01-24 23:47:04 +00001132void ARMInstPrinter::printVectorListThreeAllLanes(const MCInst *MI,
1133 unsigned OpNum,
1134 raw_ostream &O) {
1135 // Normally, it's not safe to use register enum values directly with
1136 // addition to get the next register, but for VFP registers, the
1137 // sort order is guaranteed because they're all of the form D<n>.
1138 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << "[], "
1139 << getRegisterName(MI->getOperand(OpNum).getReg() + 1) << "[], "
1140 << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << "[]}";
1141}
1142
Jim Grosbacha57a36a2012-01-25 00:01:08 +00001143void ARMInstPrinter::printVectorListFourAllLanes(const MCInst *MI,
1144 unsigned OpNum,
1145 raw_ostream &O) {
1146 // Normally, it's not safe to use register enum values directly with
1147 // addition to get the next register, but for VFP registers, the
1148 // sort order is guaranteed because they're all of the form D<n>.
1149 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << "[], "
1150 << getRegisterName(MI->getOperand(OpNum).getReg() + 1) << "[], "
1151 << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << "[], "
1152 << getRegisterName(MI->getOperand(OpNum).getReg() + 3) << "[]}";
1153}
1154
Jim Grosbach3471d4f2011-12-21 00:38:54 +00001155void ARMInstPrinter::printVectorListTwoSpacedAllLanes(const MCInst *MI,
1156 unsigned OpNum,
1157 raw_ostream &O) {
Jim Grosbach4d0983a2012-03-06 23:10:38 +00001158 unsigned Reg = MI->getOperand(OpNum).getReg();
1159 unsigned Reg0 = MRI.getSubReg(Reg, ARM::dsub_0);
1160 unsigned Reg1 = MRI.getSubReg(Reg, ARM::dsub_2);
1161 O << "{" << getRegisterName(Reg0) << "[], " << getRegisterName(Reg1) << "[]}";
Jim Grosbach3471d4f2011-12-21 00:38:54 +00001162}
1163
Jim Grosbach5e59f7e2012-01-24 23:47:04 +00001164void ARMInstPrinter::printVectorListThreeSpacedAllLanes(const MCInst *MI,
1165 unsigned OpNum,
1166 raw_ostream &O) {
1167 // Normally, it's not safe to use register enum values directly with
1168 // addition to get the next register, but for VFP registers, the
1169 // sort order is guaranteed because they're all of the form D<n>.
1170 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << "[], "
1171 << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << "[], "
Jim Grosbacha57a36a2012-01-25 00:01:08 +00001172 << getRegisterName(MI->getOperand(OpNum).getReg() + 4) << "[]}";
1173}
1174
1175void ARMInstPrinter::printVectorListFourSpacedAllLanes(const MCInst *MI,
1176 unsigned OpNum,
1177 raw_ostream &O) {
1178 // Normally, it's not safe to use register enum values directly with
1179 // addition to get the next register, but for VFP registers, the
1180 // sort order is guaranteed because they're all of the form D<n>.
1181 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << "[], "
1182 << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << "[], "
1183 << getRegisterName(MI->getOperand(OpNum).getReg() + 4) << "[], "
1184 << getRegisterName(MI->getOperand(OpNum).getReg() + 6) << "[]}";
Jim Grosbach5e59f7e2012-01-24 23:47:04 +00001185}
1186
Jim Grosbachc387fc62012-01-23 23:20:46 +00001187void ARMInstPrinter::printVectorListThreeSpaced(const MCInst *MI,
1188 unsigned OpNum,
1189 raw_ostream &O) {
1190 // Normally, it's not safe to use register enum values directly with
1191 // addition to get the next register, but for VFP registers, the
1192 // sort order is guaranteed because they're all of the form D<n>.
1193 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << ", "
1194 << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << ", "
1195 << getRegisterName(MI->getOperand(OpNum).getReg() + 4) << "}";
1196}
Jim Grosbach8abe7e32012-01-24 00:43:17 +00001197
1198void ARMInstPrinter::printVectorListFourSpaced(const MCInst *MI,
1199 unsigned OpNum,
1200 raw_ostream &O) {
1201 // Normally, it's not safe to use register enum values directly with
1202 // addition to get the next register, but for VFP registers, the
1203 // sort order is guaranteed because they're all of the form D<n>.
1204 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << ", "
1205 << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << ", "
1206 << getRegisterName(MI->getOperand(OpNum).getReg() + 4) << ", "
1207 << getRegisterName(MI->getOperand(OpNum).getReg() + 6) << "}";
1208}