blob: be7e098b55fd65e193623dd357ae70a4345233ff [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
Johnny Chen9e088762010-03-17 17:52:21 +000055 // Check for MOVs and print canonical forms, instead.
Owen Anderson152d4a42011-07-21 23:38:37 +000056 if (Opcode == ARM::MOVsr) {
Jim Grosbache6be85e2010-09-17 22:36:38 +000057 // FIXME: Thumb variants?
Johnny Chen9e088762010-03-17 17:52:21 +000058 const MCOperand &Dst = MI->getOperand(0);
59 const MCOperand &MO1 = MI->getOperand(1);
60 const MCOperand &MO2 = MI->getOperand(2);
61 const MCOperand &MO3 = MI->getOperand(3);
62
63 O << '\t' << ARM_AM::getShiftOpcStr(ARM_AM::getSORegShOp(MO3.getImm()));
Chris Lattner35c33bd2010-04-04 04:47:45 +000064 printSBitModifierOperand(MI, 6, O);
65 printPredicateOperand(MI, 4, O);
Johnny Chen9e088762010-03-17 17:52:21 +000066
67 O << '\t' << getRegisterName(Dst.getReg())
68 << ", " << getRegisterName(MO1.getReg());
69
Owen Anderson152d4a42011-07-21 23:38:37 +000070 O << ", " << getRegisterName(MO2.getReg());
71 assert(ARM_AM::getSORegOffset(MO3.getImm()) == 0);
Owen Anderson519020a2011-09-21 17:58:45 +000072 printAnnotation(O, Annot);
Johnny Chen9e088762010-03-17 17:52:21 +000073 return;
74 }
75
Owen Anderson152d4a42011-07-21 23:38:37 +000076 if (Opcode == ARM::MOVsi) {
77 // FIXME: Thumb variants?
78 const MCOperand &Dst = MI->getOperand(0);
79 const MCOperand &MO1 = MI->getOperand(1);
80 const MCOperand &MO2 = MI->getOperand(2);
81
82 O << '\t' << ARM_AM::getShiftOpcStr(ARM_AM::getSORegShOp(MO2.getImm()));
83 printSBitModifierOperand(MI, 5, O);
84 printPredicateOperand(MI, 3, O);
85
86 O << '\t' << getRegisterName(Dst.getReg())
87 << ", " << getRegisterName(MO1.getReg());
88
Owen Andersonede042d2011-09-15 18:36:29 +000089 if (ARM_AM::getSORegShOp(MO2.getImm()) == ARM_AM::rrx) {
Owen Anderson519020a2011-09-21 17:58:45 +000090 printAnnotation(O, Annot);
Owen Anderson152d4a42011-07-21 23:38:37 +000091 return;
Owen Andersonede042d2011-09-15 18:36:29 +000092 }
Owen Anderson152d4a42011-07-21 23:38:37 +000093
Owen Anderson3dac0be2011-08-11 18:41:59 +000094 O << ", #" << translateShiftImm(ARM_AM::getSORegOffset(MO2.getImm()));
Owen Anderson519020a2011-09-21 17:58:45 +000095 printAnnotation(O, Annot);
Owen Anderson152d4a42011-07-21 23:38:37 +000096 return;
97 }
98
99
Johnny Chen9e088762010-03-17 17:52:21 +0000100 // A8.6.123 PUSH
Bill Wendling73fe34a2010-11-16 01:16:36 +0000101 if ((Opcode == ARM::STMDB_UPD || Opcode == ARM::t2STMDB_UPD) &&
Owen Anderson81550dc2011-11-02 18:03:14 +0000102 MI->getOperand(0).getReg() == ARM::SP &&
103 MI->getNumOperands() > 5) {
104 // Should only print PUSH if there are at least two registers in the list.
Bill Wendling73fe34a2010-11-16 01:16:36 +0000105 O << '\t' << "push";
106 printPredicateOperand(MI, 2, O);
Jim Grosbach41ad0c42010-12-03 20:33:01 +0000107 if (Opcode == ARM::t2STMDB_UPD)
108 O << ".w";
Bill Wendling73fe34a2010-11-16 01:16:36 +0000109 O << '\t';
110 printRegisterList(MI, 4, O);
Owen Anderson519020a2011-09-21 17:58:45 +0000111 printAnnotation(O, Annot);
Bill Wendling73fe34a2010-11-16 01:16:36 +0000112 return;
Johnny Chen9e088762010-03-17 17:52:21 +0000113 }
Jim Grosbachf6713912011-08-11 18:07:11 +0000114 if (Opcode == ARM::STR_PRE_IMM && MI->getOperand(2).getReg() == ARM::SP &&
115 MI->getOperand(3).getImm() == -4) {
116 O << '\t' << "push";
117 printPredicateOperand(MI, 4, O);
118 O << "\t{" << getRegisterName(MI->getOperand(1).getReg()) << "}";
Owen Anderson519020a2011-09-21 17:58:45 +0000119 printAnnotation(O, Annot);
Jim Grosbachf6713912011-08-11 18:07:11 +0000120 return;
121 }
Johnny Chen9e088762010-03-17 17:52:21 +0000122
123 // A8.6.122 POP
Bill Wendling73fe34a2010-11-16 01:16:36 +0000124 if ((Opcode == ARM::LDMIA_UPD || Opcode == ARM::t2LDMIA_UPD) &&
Owen Anderson81550dc2011-11-02 18:03:14 +0000125 MI->getOperand(0).getReg() == ARM::SP &&
126 MI->getNumOperands() > 5) {
127 // Should only print POP if there are at least two registers in the list.
Bill Wendling73fe34a2010-11-16 01:16:36 +0000128 O << '\t' << "pop";
129 printPredicateOperand(MI, 2, O);
Jim Grosbach41ad0c42010-12-03 20:33:01 +0000130 if (Opcode == ARM::t2LDMIA_UPD)
131 O << ".w";
Bill Wendling73fe34a2010-11-16 01:16:36 +0000132 O << '\t';
133 printRegisterList(MI, 4, O);
Owen Anderson519020a2011-09-21 17:58:45 +0000134 printAnnotation(O, Annot);
Bill Wendling73fe34a2010-11-16 01:16:36 +0000135 return;
Johnny Chen9e088762010-03-17 17:52:21 +0000136 }
Jim Grosbachf8fce712011-08-11 17:35:48 +0000137 if (Opcode == ARM::LDR_POST_IMM && MI->getOperand(2).getReg() == ARM::SP &&
138 MI->getOperand(4).getImm() == 4) {
139 O << '\t' << "pop";
140 printPredicateOperand(MI, 5, O);
141 O << "\t{" << getRegisterName(MI->getOperand(0).getReg()) << "}";
Owen Anderson519020a2011-09-21 17:58:45 +0000142 printAnnotation(O, Annot);
Jim Grosbachf8fce712011-08-11 17:35:48 +0000143 return;
144 }
145
Johnny Chen9e088762010-03-17 17:52:21 +0000146
147 // A8.6.355 VPUSH
Bill Wendling73fe34a2010-11-16 01:16:36 +0000148 if ((Opcode == ARM::VSTMSDB_UPD || Opcode == ARM::VSTMDDB_UPD) &&
Johnny Chen9e088762010-03-17 17:52:21 +0000149 MI->getOperand(0).getReg() == ARM::SP) {
Bill Wendling73fe34a2010-11-16 01:16:36 +0000150 O << '\t' << "vpush";
151 printPredicateOperand(MI, 2, O);
152 O << '\t';
153 printRegisterList(MI, 4, O);
Owen Anderson519020a2011-09-21 17:58:45 +0000154 printAnnotation(O, Annot);
Bill Wendling73fe34a2010-11-16 01:16:36 +0000155 return;
Johnny Chen9e088762010-03-17 17:52:21 +0000156 }
157
158 // A8.6.354 VPOP
Bill Wendling73fe34a2010-11-16 01:16:36 +0000159 if ((Opcode == ARM::VLDMSIA_UPD || Opcode == ARM::VLDMDIA_UPD) &&
Johnny Chen9e088762010-03-17 17:52:21 +0000160 MI->getOperand(0).getReg() == ARM::SP) {
Bill Wendling73fe34a2010-11-16 01:16:36 +0000161 O << '\t' << "vpop";
162 printPredicateOperand(MI, 2, O);
163 O << '\t';
164 printRegisterList(MI, 4, O);
Owen Anderson519020a2011-09-21 17:58:45 +0000165 printAnnotation(O, Annot);
Bill Wendling73fe34a2010-11-16 01:16:36 +0000166 return;
Johnny Chen9e088762010-03-17 17:52:21 +0000167 }
168
Jim Grosbachcefe4c92011-08-23 17:41:15 +0000169 if (Opcode == ARM::tLDMIA) {
Owen Anderson565a0362011-07-18 23:25:34 +0000170 bool Writeback = true;
171 unsigned BaseReg = MI->getOperand(0).getReg();
172 for (unsigned i = 3; i < MI->getNumOperands(); ++i) {
173 if (MI->getOperand(i).getReg() == BaseReg)
174 Writeback = false;
175 }
176
Jim Grosbachcefe4c92011-08-23 17:41:15 +0000177 O << "\tldm";
Owen Anderson565a0362011-07-18 23:25:34 +0000178
179 printPredicateOperand(MI, 1, O);
180 O << '\t' << getRegisterName(BaseReg);
181 if (Writeback) O << "!";
182 O << ", ";
183 printRegisterList(MI, 3, O);
Owen Anderson519020a2011-09-21 17:58:45 +0000184 printAnnotation(O, Annot);
Owen Anderson565a0362011-07-18 23:25:34 +0000185 return;
186 }
187
Jim Grosbach0780b632011-08-19 23:24:36 +0000188 // Thumb1 NOP
189 if (Opcode == ARM::tMOVr && MI->getOperand(0).getReg() == ARM::R8 &&
190 MI->getOperand(1).getReg() == ARM::R8) {
191 O << "\tnop";
Jim Grosbachdf9ce6b2011-08-24 20:06:14 +0000192 printPredicateOperand(MI, 2, O);
Owen Anderson519020a2011-09-21 17:58:45 +0000193 printAnnotation(O, Annot);
Jim Grosbach0780b632011-08-19 23:24:36 +0000194 return;
195 }
196
Chris Lattner35c33bd2010-04-04 04:47:45 +0000197 printInstruction(MI, O);
Owen Anderson519020a2011-09-21 17:58:45 +0000198 printAnnotation(O, Annot);
Bill Wendling04863d02010-11-13 10:40:19 +0000199}
Chris Lattnerfd603822009-10-19 19:56:26 +0000200
Chris Lattner8bc86cb2009-10-19 20:59:55 +0000201void ARMInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
Jim Grosbach0a2287b2010-11-03 01:11:15 +0000202 raw_ostream &O) {
Chris Lattner8bc86cb2009-10-19 20:59:55 +0000203 const MCOperand &Op = MI->getOperand(OpNo);
204 if (Op.isReg()) {
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000205 unsigned Reg = Op.getReg();
Jim Grosbach35636282010-10-06 21:22:32 +0000206 O << getRegisterName(Reg);
Chris Lattner8bc86cb2009-10-19 20:59:55 +0000207 } else if (Op.isImm()) {
208 O << '#' << Op.getImm();
209 } else {
210 assert(Op.isExpr() && "unknown operand kind in printOperand");
Kevin Enderby9e5887b2011-10-04 22:44:48 +0000211 // If a symbolic branch target was added as a constant expression then print
Kevin Enderby6c226952012-04-13 18:46:37 +0000212 // that address in hex. And only print 32 unsigned bits for the address.
Kevin Enderby9e5887b2011-10-04 22:44:48 +0000213 const MCConstantExpr *BranchTarget = dyn_cast<MCConstantExpr>(Op.getExpr());
214 int64_t Address;
215 if (BranchTarget && BranchTarget->EvaluateAsAbsolute(Address)) {
216 O << "0x";
Kevin Enderby6c226952012-04-13 18:46:37 +0000217 O.write_hex((uint32_t)Address);
Kevin Enderby9e5887b2011-10-04 22:44:48 +0000218 }
219 else {
220 // Otherwise, just print the expression.
221 O << *Op.getExpr();
222 }
Chris Lattner8bc86cb2009-10-19 20:59:55 +0000223 }
224}
Chris Lattner61d35c22009-10-19 21:21:39 +0000225
Owen Andersone1368722011-09-21 23:44:46 +0000226void ARMInstPrinter::printT2LdrLabelOperand(const MCInst *MI, unsigned OpNum,
227 raw_ostream &O) {
228 const MCOperand &MO1 = MI->getOperand(OpNum);
229 if (MO1.isExpr())
230 O << *MO1.getExpr();
231 else if (MO1.isImm())
232 O << "[pc, #" << MO1.getImm() << "]";
233 else
234 llvm_unreachable("Unknown LDR label operand?");
235}
236
Chris Lattner017d9472009-10-20 00:40:56 +0000237// so_reg is a 4-operand unit corresponding to register forms of the A5.1
238// "Addressing Mode 1 - Data-processing operands" forms. This includes:
239// REG 0 0 - e.g. R5
240// REG REG 0,SH_OPC - e.g. R5, ROR R3
241// REG 0 IMM,SH_OPC - e.g. R5, LSL #3
Owen Anderson152d4a42011-07-21 23:38:37 +0000242void ARMInstPrinter::printSORegRegOperand(const MCInst *MI, unsigned OpNum,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000243 raw_ostream &O) {
Chris Lattner017d9472009-10-20 00:40:56 +0000244 const MCOperand &MO1 = MI->getOperand(OpNum);
245 const MCOperand &MO2 = MI->getOperand(OpNum+1);
246 const MCOperand &MO3 = MI->getOperand(OpNum+2);
Jim Grosbach15d78982010-09-14 22:27:15 +0000247
Chris Lattner017d9472009-10-20 00:40:56 +0000248 O << getRegisterName(MO1.getReg());
Jim Grosbach15d78982010-09-14 22:27:15 +0000249
Chris Lattner017d9472009-10-20 00:40:56 +0000250 // Print the shift opc.
Bob Wilson1d9125a2010-08-05 00:34:42 +0000251 ARM_AM::ShiftOpc ShOpc = ARM_AM::getSORegShOp(MO3.getImm());
252 O << ", " << ARM_AM::getShiftOpcStr(ShOpc);
Jim Grosbache8606dc2011-07-13 17:50:29 +0000253 if (ShOpc == ARM_AM::rrx)
254 return;
Jim Grosbach293a5f62011-10-21 16:56:40 +0000255
Owen Anderson152d4a42011-07-21 23:38:37 +0000256 O << ' ' << getRegisterName(MO2.getReg());
257 assert(ARM_AM::getSORegOffset(MO3.getImm()) == 0);
Chris Lattner017d9472009-10-20 00:40:56 +0000258}
Chris Lattner084f87d2009-10-19 21:57:05 +0000259
Owen Anderson152d4a42011-07-21 23:38:37 +0000260void ARMInstPrinter::printSORegImmOperand(const MCInst *MI, unsigned OpNum,
261 raw_ostream &O) {
262 const MCOperand &MO1 = MI->getOperand(OpNum);
263 const MCOperand &MO2 = MI->getOperand(OpNum+1);
264
265 O << getRegisterName(MO1.getReg());
266
267 // Print the shift opc.
268 ARM_AM::ShiftOpc ShOpc = ARM_AM::getSORegShOp(MO2.getImm());
269 O << ", " << ARM_AM::getShiftOpcStr(ShOpc);
270 if (ShOpc == ARM_AM::rrx)
271 return;
Owen Anderson3dac0be2011-08-11 18:41:59 +0000272 O << " #" << translateShiftImm(ARM_AM::getSORegOffset(MO2.getImm()));
Owen Anderson152d4a42011-07-21 23:38:37 +0000273}
274
275
Bruno Cardoso Lopesac79e4c2011-04-04 17:18:19 +0000276//===--------------------------------------------------------------------===//
277// Addressing Mode #2
278//===--------------------------------------------------------------------===//
279
Bruno Cardoso Lopesae085542011-03-31 23:26:08 +0000280void ARMInstPrinter::printAM2PreOrOffsetIndexOp(const MCInst *MI, unsigned Op,
281 raw_ostream &O) {
Chris Lattner084f87d2009-10-19 21:57:05 +0000282 const MCOperand &MO1 = MI->getOperand(Op);
283 const MCOperand &MO2 = MI->getOperand(Op+1);
284 const MCOperand &MO3 = MI->getOperand(Op+2);
Jim Grosbach15d78982010-09-14 22:27:15 +0000285
Chris Lattner084f87d2009-10-19 21:57:05 +0000286 O << "[" << getRegisterName(MO1.getReg());
Jim Grosbach15d78982010-09-14 22:27:15 +0000287
Chris Lattner084f87d2009-10-19 21:57:05 +0000288 if (!MO2.getReg()) {
Johnny Chen9e088762010-03-17 17:52:21 +0000289 if (ARM_AM::getAM2Offset(MO3.getImm())) // Don't print +0.
Chris Lattner084f87d2009-10-19 21:57:05 +0000290 O << ", #"
Johnny Chen9e088762010-03-17 17:52:21 +0000291 << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO3.getImm()))
292 << ARM_AM::getAM2Offset(MO3.getImm());
Chris Lattner084f87d2009-10-19 21:57:05 +0000293 O << "]";
294 return;
295 }
Jim Grosbach15d78982010-09-14 22:27:15 +0000296
Chris Lattner084f87d2009-10-19 21:57:05 +0000297 O << ", "
Johnny Chen9e088762010-03-17 17:52:21 +0000298 << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO3.getImm()))
299 << getRegisterName(MO2.getReg());
Jim Grosbach15d78982010-09-14 22:27:15 +0000300
Chris Lattner084f87d2009-10-19 21:57:05 +0000301 if (unsigned ShImm = ARM_AM::getAM2Offset(MO3.getImm()))
302 O << ", "
303 << ARM_AM::getShiftOpcStr(ARM_AM::getAM2ShiftOpc(MO3.getImm()))
304 << " #" << ShImm;
305 O << "]";
Jim Grosbach15d78982010-09-14 22:27:15 +0000306}
Chris Lattnere306d8d2009-10-19 22:09:23 +0000307
Bruno Cardoso Lopesae085542011-03-31 23:26:08 +0000308void ARMInstPrinter::printAM2PostIndexOp(const MCInst *MI, unsigned Op,
309 raw_ostream &O) {
310 const MCOperand &MO1 = MI->getOperand(Op);
311 const MCOperand &MO2 = MI->getOperand(Op+1);
312 const MCOperand &MO3 = MI->getOperand(Op+2);
313
314 O << "[" << getRegisterName(MO1.getReg()) << "], ";
315
316 if (!MO2.getReg()) {
317 unsigned ImmOffs = ARM_AM::getAM2Offset(MO3.getImm());
318 O << '#'
319 << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO3.getImm()))
320 << ImmOffs;
321 return;
322 }
323
324 O << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO3.getImm()))
325 << getRegisterName(MO2.getReg());
326
327 if (unsigned ShImm = ARM_AM::getAM2Offset(MO3.getImm()))
328 O << ", "
329 << ARM_AM::getShiftOpcStr(ARM_AM::getAM2ShiftOpc(MO3.getImm()))
330 << " #" << ShImm;
331}
332
Jim Grosbach7f739be2011-09-19 22:21:13 +0000333void ARMInstPrinter::printAddrModeTBB(const MCInst *MI, unsigned Op,
334 raw_ostream &O) {
335 const MCOperand &MO1 = MI->getOperand(Op);
336 const MCOperand &MO2 = MI->getOperand(Op+1);
337 O << "[" << getRegisterName(MO1.getReg()) << ", "
338 << getRegisterName(MO2.getReg()) << "]";
339}
340
341void ARMInstPrinter::printAddrModeTBH(const MCInst *MI, unsigned Op,
342 raw_ostream &O) {
343 const MCOperand &MO1 = MI->getOperand(Op);
344 const MCOperand &MO2 = MI->getOperand(Op+1);
345 O << "[" << getRegisterName(MO1.getReg()) << ", "
346 << getRegisterName(MO2.getReg()) << ", lsl #1]";
347}
348
Bruno Cardoso Lopesae085542011-03-31 23:26:08 +0000349void ARMInstPrinter::printAddrMode2Operand(const MCInst *MI, unsigned Op,
350 raw_ostream &O) {
351 const MCOperand &MO1 = MI->getOperand(Op);
352
353 if (!MO1.isReg()) { // FIXME: This is for CP entries, but isn't right.
354 printOperand(MI, Op, O);
355 return;
356 }
357
358 const MCOperand &MO3 = MI->getOperand(Op+2);
359 unsigned IdxMode = ARM_AM::getAM2IdxMode(MO3.getImm());
360
361 if (IdxMode == ARMII::IndexModePost) {
362 printAM2PostIndexOp(MI, Op, O);
363 return;
364 }
365 printAM2PreOrOffsetIndexOp(MI, Op, O);
366}
367
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000368void ARMInstPrinter::printAddrMode2OffsetOperand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000369 unsigned OpNum,
370 raw_ostream &O) {
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000371 const MCOperand &MO1 = MI->getOperand(OpNum);
372 const MCOperand &MO2 = MI->getOperand(OpNum+1);
Jim Grosbach15d78982010-09-14 22:27:15 +0000373
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000374 if (!MO1.getReg()) {
375 unsigned ImmOffs = ARM_AM::getAM2Offset(MO2.getImm());
Johnny Chen9e088762010-03-17 17:52:21 +0000376 O << '#'
377 << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO2.getImm()))
378 << ImmOffs;
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000379 return;
380 }
Jim Grosbach15d78982010-09-14 22:27:15 +0000381
Johnny Chen9e088762010-03-17 17:52:21 +0000382 O << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO2.getImm()))
383 << getRegisterName(MO1.getReg());
Jim Grosbach15d78982010-09-14 22:27:15 +0000384
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000385 if (unsigned ShImm = ARM_AM::getAM2Offset(MO2.getImm()))
386 O << ", "
387 << ARM_AM::getShiftOpcStr(ARM_AM::getAM2ShiftOpc(MO2.getImm()))
388 << " #" << ShImm;
389}
390
Bruno Cardoso Lopesac79e4c2011-04-04 17:18:19 +0000391//===--------------------------------------------------------------------===//
392// Addressing Mode #3
393//===--------------------------------------------------------------------===//
394
395void ARMInstPrinter::printAM3PostIndexOp(const MCInst *MI, unsigned Op,
396 raw_ostream &O) {
397 const MCOperand &MO1 = MI->getOperand(Op);
398 const MCOperand &MO2 = MI->getOperand(Op+1);
399 const MCOperand &MO3 = MI->getOperand(Op+2);
400
401 O << "[" << getRegisterName(MO1.getReg()) << "], ";
402
403 if (MO2.getReg()) {
404 O << (char)ARM_AM::getAM3Op(MO3.getImm())
405 << getRegisterName(MO2.getReg());
406 return;
407 }
408
409 unsigned ImmOffs = ARM_AM::getAM3Offset(MO3.getImm());
410 O << '#'
411 << ARM_AM::getAddrOpcStr(ARM_AM::getAM3Op(MO3.getImm()))
412 << ImmOffs;
413}
414
415void ARMInstPrinter::printAM3PreOrOffsetIndexOp(const MCInst *MI, unsigned Op,
416 raw_ostream &O) {
417 const MCOperand &MO1 = MI->getOperand(Op);
418 const MCOperand &MO2 = MI->getOperand(Op+1);
419 const MCOperand &MO3 = MI->getOperand(Op+2);
Jim Grosbach15d78982010-09-14 22:27:15 +0000420
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000421 O << '[' << getRegisterName(MO1.getReg());
Jim Grosbach15d78982010-09-14 22:27:15 +0000422
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000423 if (MO2.getReg()) {
Jim Grosbach7ce05792011-08-03 23:50:40 +0000424 O << ", " << getAddrOpcStr(ARM_AM::getAM3Op(MO3.getImm()))
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000425 << getRegisterName(MO2.getReg()) << ']';
426 return;
427 }
Jim Grosbach15d78982010-09-14 22:27:15 +0000428
Silviu Barangaca3cd412012-05-11 09:10:54 +0000429 //If the op is sub we have to print the immediate even if it is 0
430 unsigned ImmOffs = ARM_AM::getAM3Offset(MO3.getImm());
431 ARM_AM::AddrOpc op = ARM_AM::getAM3Op(MO3.getImm());
432
433 if (ImmOffs || (op == ARM_AM::sub))
Chris Lattnerbf16faa2009-10-20 06:15:28 +0000434 O << ", #"
Silviu Barangaca3cd412012-05-11 09:10:54 +0000435 << ARM_AM::getAddrOpcStr(op)
Johnny Chen9e088762010-03-17 17:52:21 +0000436 << 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();
Richard Barton4d2f0772012-04-27 08:42:59 +0000761 unsigned Firstcond = MI->getOperand(OpNum-1).getImm();
762 unsigned CondBit0 = Firstcond & 1;
Johnny Chen9e088762010-03-17 17:52:21 +0000763 unsigned NumTZ = CountTrailingZeros_32(Mask);
764 assert(NumTZ <= 3 && "Invalid IT mask!");
765 for (unsigned Pos = 3, e = NumTZ; Pos > e; --Pos) {
766 bool T = ((Mask >> Pos) & 1) == CondBit0;
767 if (T)
768 O << 't';
769 else
770 O << 'e';
771 }
772}
773
Chris Lattner35c33bd2010-04-04 04:47:45 +0000774void ARMInstPrinter::printThumbAddrModeRROperand(const MCInst *MI, unsigned Op,
775 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000776 const MCOperand &MO1 = MI->getOperand(Op);
Bill Wendlingf4caf692010-12-14 03:36:38 +0000777 const MCOperand &MO2 = MI->getOperand(Op + 1);
Johnny Chen9e088762010-03-17 17:52:21 +0000778
779 if (!MO1.isReg()) { // FIXME: This is for CP entries, but isn't right.
Chris Lattner35c33bd2010-04-04 04:47:45 +0000780 printOperand(MI, Op, O);
Johnny Chen9e088762010-03-17 17:52:21 +0000781 return;
782 }
783
784 O << "[" << getRegisterName(MO1.getReg());
Bill Wendlingf4caf692010-12-14 03:36:38 +0000785 if (unsigned RegNum = MO2.getReg())
786 O << ", " << getRegisterName(RegNum);
787 O << "]";
788}
789
790void ARMInstPrinter::printThumbAddrModeImm5SOperand(const MCInst *MI,
791 unsigned Op,
792 raw_ostream &O,
793 unsigned Scale) {
794 const MCOperand &MO1 = MI->getOperand(Op);
795 const MCOperand &MO2 = MI->getOperand(Op + 1);
796
797 if (!MO1.isReg()) { // FIXME: This is for CP entries, but isn't right.
798 printOperand(MI, Op, O);
799 return;
800 }
801
802 O << "[" << getRegisterName(MO1.getReg());
803 if (unsigned ImmOffs = MO2.getImm())
Johnny Chen9e088762010-03-17 17:52:21 +0000804 O << ", #" << ImmOffs * Scale;
805 O << "]";
806}
807
Bill Wendlingf4caf692010-12-14 03:36:38 +0000808void ARMInstPrinter::printThumbAddrModeImm5S1Operand(const MCInst *MI,
809 unsigned Op,
810 raw_ostream &O) {
811 printThumbAddrModeImm5SOperand(MI, Op, O, 1);
Johnny Chen9e088762010-03-17 17:52:21 +0000812}
813
Bill Wendlingf4caf692010-12-14 03:36:38 +0000814void ARMInstPrinter::printThumbAddrModeImm5S2Operand(const MCInst *MI,
815 unsigned Op,
816 raw_ostream &O) {
817 printThumbAddrModeImm5SOperand(MI, Op, O, 2);
Johnny Chen9e088762010-03-17 17:52:21 +0000818}
819
Bill Wendlingf4caf692010-12-14 03:36:38 +0000820void ARMInstPrinter::printThumbAddrModeImm5S4Operand(const MCInst *MI,
821 unsigned Op,
822 raw_ostream &O) {
823 printThumbAddrModeImm5SOperand(MI, Op, O, 4);
Johnny Chen9e088762010-03-17 17:52:21 +0000824}
825
Chris Lattner35c33bd2010-04-04 04:47:45 +0000826void ARMInstPrinter::printThumbAddrModeSPOperand(const MCInst *MI, unsigned Op,
827 raw_ostream &O) {
Bill Wendlingf4caf692010-12-14 03:36:38 +0000828 printThumbAddrModeImm5SOperand(MI, Op, O, 4);
Johnny Chen9e088762010-03-17 17:52:21 +0000829}
830
Johnny Chen9e088762010-03-17 17:52:21 +0000831// Constant shifts t2_so_reg is a 2-operand unit corresponding to the Thumb2
832// register with shift forms.
833// REG 0 0 - e.g. R5
834// REG IMM, SH_OPC - e.g. R5, LSL #3
Chris Lattner35c33bd2010-04-04 04:47:45 +0000835void ARMInstPrinter::printT2SOOperand(const MCInst *MI, unsigned OpNum,
836 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000837 const MCOperand &MO1 = MI->getOperand(OpNum);
838 const MCOperand &MO2 = MI->getOperand(OpNum+1);
839
840 unsigned Reg = MO1.getReg();
841 O << getRegisterName(Reg);
842
843 // Print the shift opc.
Johnny Chen9e088762010-03-17 17:52:21 +0000844 assert(MO2.isImm() && "Not a valid t2_so_reg value!");
Bob Wilson1d9125a2010-08-05 00:34:42 +0000845 ARM_AM::ShiftOpc ShOpc = ARM_AM::getSORegShOp(MO2.getImm());
846 O << ", " << ARM_AM::getShiftOpcStr(ShOpc);
847 if (ShOpc != ARM_AM::rrx)
Owen Anderson3dac0be2011-08-11 18:41:59 +0000848 O << " #" << translateShiftImm(ARM_AM::getSORegOffset(MO2.getImm()));
Johnny Chen9e088762010-03-17 17:52:21 +0000849}
850
Jim Grosbach458f2dc2010-10-25 20:00:01 +0000851void ARMInstPrinter::printAddrModeImm12Operand(const MCInst *MI, unsigned OpNum,
852 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000853 const MCOperand &MO1 = MI->getOperand(OpNum);
854 const MCOperand &MO2 = MI->getOperand(OpNum+1);
855
Jim Grosbach3e556122010-10-26 22:37:02 +0000856 if (!MO1.isReg()) { // FIXME: This is for CP entries, but isn't right.
857 printOperand(MI, OpNum, O);
858 return;
859 }
860
Johnny Chen9e088762010-03-17 17:52:21 +0000861 O << "[" << getRegisterName(MO1.getReg());
862
Jim Grosbach77aee8e2010-10-27 01:19:41 +0000863 int32_t OffImm = (int32_t)MO2.getImm();
Jim Grosbachab682a22010-10-28 18:34:10 +0000864 bool isSub = OffImm < 0;
865 // Special value for #-0. All others are normal.
866 if (OffImm == INT32_MIN)
867 OffImm = 0;
868 if (isSub)
Jim Grosbach77aee8e2010-10-27 01:19:41 +0000869 O << ", #-" << -OffImm;
870 else if (OffImm > 0)
Johnny Chen9e088762010-03-17 17:52:21 +0000871 O << ", #" << OffImm;
872 O << "]";
873}
874
875void ARMInstPrinter::printT2AddrModeImm8Operand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000876 unsigned OpNum,
877 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000878 const MCOperand &MO1 = MI->getOperand(OpNum);
879 const MCOperand &MO2 = MI->getOperand(OpNum+1);
880
881 O << "[" << getRegisterName(MO1.getReg());
882
883 int32_t OffImm = (int32_t)MO2.getImm();
884 // Don't print +0.
Owen Anderson705b48f2011-09-16 21:08:33 +0000885 if (OffImm == INT32_MIN)
886 O << ", #-0";
887 else if (OffImm < 0)
Johnny Chen9e088762010-03-17 17:52:21 +0000888 O << ", #-" << -OffImm;
889 else if (OffImm > 0)
890 O << ", #" << OffImm;
891 O << "]";
892}
893
894void ARMInstPrinter::printT2AddrModeImm8s4Operand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000895 unsigned OpNum,
896 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000897 const MCOperand &MO1 = MI->getOperand(OpNum);
898 const MCOperand &MO2 = MI->getOperand(OpNum+1);
899
Jim Grosbach2f196742011-12-19 23:06:24 +0000900 if (!MO1.isReg()) { // For label symbolic references.
901 printOperand(MI, OpNum, O);
902 return;
903 }
904
Johnny Chen9e088762010-03-17 17:52:21 +0000905 O << "[" << getRegisterName(MO1.getReg());
906
907 int32_t OffImm = (int32_t)MO2.getImm() / 4;
908 // Don't print +0.
909 if (OffImm < 0)
910 O << ", #-" << -OffImm * 4;
911 else if (OffImm > 0)
912 O << ", #" << OffImm * 4;
913 O << "]";
914}
915
Jim Grosbachb6aed502011-09-09 18:37:27 +0000916void ARMInstPrinter::printT2AddrModeImm0_1020s4Operand(const MCInst *MI,
917 unsigned OpNum,
918 raw_ostream &O) {
919 const MCOperand &MO1 = MI->getOperand(OpNum);
920 const MCOperand &MO2 = MI->getOperand(OpNum+1);
921
922 O << "[" << getRegisterName(MO1.getReg());
923 if (MO2.getImm())
924 O << ", #" << MO2.getImm() * 4;
925 O << "]";
926}
927
Johnny Chen9e088762010-03-17 17:52:21 +0000928void ARMInstPrinter::printT2AddrModeImm8OffsetOperand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000929 unsigned OpNum,
930 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000931 const MCOperand &MO1 = MI->getOperand(OpNum);
932 int32_t OffImm = (int32_t)MO1.getImm();
933 // Don't print +0.
934 if (OffImm < 0)
Owen Anderson0781c1f2011-09-23 21:26:40 +0000935 O << ", #-" << -OffImm;
936 else
937 O << ", #" << OffImm;
Johnny Chen9e088762010-03-17 17:52:21 +0000938}
939
940void ARMInstPrinter::printT2AddrModeImm8s4OffsetOperand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000941 unsigned OpNum,
942 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000943 const MCOperand &MO1 = MI->getOperand(OpNum);
944 int32_t OffImm = (int32_t)MO1.getImm() / 4;
945 // Don't print +0.
Owen Anderson7782a582011-09-13 20:46:26 +0000946 if (OffImm != 0) {
947 O << ", ";
948 if (OffImm < 0)
949 O << "#-" << -OffImm * 4;
950 else if (OffImm > 0)
951 O << "#" << OffImm * 4;
952 }
Johnny Chen9e088762010-03-17 17:52:21 +0000953}
954
955void ARMInstPrinter::printT2AddrModeSoRegOperand(const MCInst *MI,
Chris Lattner35c33bd2010-04-04 04:47:45 +0000956 unsigned OpNum,
957 raw_ostream &O) {
Johnny Chen9e088762010-03-17 17:52:21 +0000958 const MCOperand &MO1 = MI->getOperand(OpNum);
959 const MCOperand &MO2 = MI->getOperand(OpNum+1);
960 const MCOperand &MO3 = MI->getOperand(OpNum+2);
961
962 O << "[" << getRegisterName(MO1.getReg());
963
964 assert(MO2.getReg() && "Invalid so_reg load / store address!");
965 O << ", " << getRegisterName(MO2.getReg());
966
967 unsigned ShAmt = MO3.getImm();
968 if (ShAmt) {
969 assert(ShAmt <= 3 && "Not a valid Thumb2 addressing mode!");
970 O << ", lsl #" << ShAmt;
971 }
972 O << "]";
973}
974
Jim Grosbach4ebbf7b2011-09-30 00:50:06 +0000975void ARMInstPrinter::printFPImmOperand(const MCInst *MI, unsigned OpNum,
976 raw_ostream &O) {
Bill Wendling8cb415e2011-01-26 20:57:43 +0000977 const MCOperand &MO = MI->getOperand(OpNum);
Jim Grosbach4ebbf7b2011-09-30 00:50:06 +0000978 O << '#' << ARM_AM::getFPImmFloat(MO.getImm());
Johnny Chen9e088762010-03-17 17:52:21 +0000979}
980
Bob Wilson1a913ed2010-06-11 21:34:50 +0000981void ARMInstPrinter::printNEONModImmOperand(const MCInst *MI, unsigned OpNum,
982 raw_ostream &O) {
Bob Wilson6dce00c2010-07-13 04:44:34 +0000983 unsigned EncodedImm = MI->getOperand(OpNum).getImm();
984 unsigned EltBits;
985 uint64_t Val = ARM_AM::decodeNEONModImm(EncodedImm, EltBits);
Benjamin Kramer70be28a2011-11-07 21:00:59 +0000986 O << "#0x";
987 O.write_hex(Val);
Johnny Chenc7b65912010-04-16 22:40:20 +0000988}
Jim Grosbach4a5ffb32011-07-22 23:16:18 +0000989
Jim Grosbachf4943352011-07-25 23:09:14 +0000990void ARMInstPrinter::printImmPlusOneOperand(const MCInst *MI, unsigned OpNum,
991 raw_ostream &O) {
Jim Grosbach4a5ffb32011-07-22 23:16:18 +0000992 unsigned Imm = MI->getOperand(OpNum).getImm();
993 O << "#" << Imm + 1;
994}
Jim Grosbach85bfd3b2011-07-26 21:28:43 +0000995
996void ARMInstPrinter::printRotImmOperand(const MCInst *MI, unsigned OpNum,
997 raw_ostream &O) {
998 unsigned Imm = MI->getOperand(OpNum).getImm();
999 if (Imm == 0)
1000 return;
Jim Grosbach45f39292011-07-26 21:44:37 +00001001 O << ", ror #";
Jim Grosbach85bfd3b2011-07-26 21:28:43 +00001002 switch (Imm) {
1003 default: assert (0 && "illegal ror immediate!");
Jim Grosbach2f815c02011-08-17 23:23:07 +00001004 case 1: O << "8"; break;
1005 case 2: O << "16"; break;
1006 case 3: O << "24"; break;
Jim Grosbach85bfd3b2011-07-26 21:28:43 +00001007 }
1008}
Jim Grosbach460a9052011-10-07 23:56:00 +00001009
Jim Grosbach4050bc42011-12-22 22:19:05 +00001010void ARMInstPrinter::printFBits16(const MCInst *MI, unsigned OpNum,
1011 raw_ostream &O) {
1012 O << "#" << 16 - MI->getOperand(OpNum).getImm();
1013}
1014
1015void ARMInstPrinter::printFBits32(const MCInst *MI, unsigned OpNum,
1016 raw_ostream &O) {
1017 O << "#" << 32 - MI->getOperand(OpNum).getImm();
1018}
1019
Jim Grosbach460a9052011-10-07 23:56:00 +00001020void ARMInstPrinter::printVectorIndex(const MCInst *MI, unsigned OpNum,
1021 raw_ostream &O) {
1022 O << "[" << MI->getOperand(OpNum).getImm() << "]";
1023}
Jim Grosbach862019c2011-10-18 23:02:30 +00001024
1025void ARMInstPrinter::printVectorListOne(const MCInst *MI, unsigned OpNum,
1026 raw_ostream &O) {
1027 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << "}";
1028}
Jim Grosbach280dfad2011-10-21 18:54:25 +00001029
Jim Grosbachc0fc4502012-03-06 22:01:44 +00001030void ARMInstPrinter::printVectorListTwo(const MCInst *MI, unsigned OpNum,
Jim Grosbach28f08c92012-03-05 19:33:30 +00001031 raw_ostream &O) {
1032 unsigned Reg = MI->getOperand(OpNum).getReg();
1033 unsigned Reg0 = MRI.getSubReg(Reg, ARM::dsub_0);
1034 unsigned Reg1 = MRI.getSubReg(Reg, ARM::dsub_1);
1035 O << "{" << getRegisterName(Reg0) << ", " << getRegisterName(Reg1) << "}";
1036}
1037
Jim Grosbachc0fc4502012-03-06 22:01:44 +00001038void ARMInstPrinter::printVectorListTwoSpaced(const MCInst *MI,
1039 unsigned OpNum,
1040 raw_ostream &O) {
Jim Grosbachc3384c92012-03-05 21:43:40 +00001041 unsigned Reg = MI->getOperand(OpNum).getReg();
1042 unsigned Reg0 = MRI.getSubReg(Reg, ARM::dsub_0);
1043 unsigned Reg1 = MRI.getSubReg(Reg, ARM::dsub_2);
1044 O << "{" << getRegisterName(Reg0) << ", " << getRegisterName(Reg1) << "}";
1045}
1046
Jim Grosbachcdcfa282011-10-21 20:02:19 +00001047void ARMInstPrinter::printVectorListThree(const MCInst *MI, unsigned OpNum,
1048 raw_ostream &O) {
1049 // Normally, it's not safe to use register enum values directly with
1050 // addition to get the next register, but for VFP registers, the
1051 // sort order is guaranteed because they're all of the form D<n>.
1052 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << ", "
1053 << getRegisterName(MI->getOperand(OpNum).getReg() + 1) << ", "
1054 << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << "}";
1055}
Jim Grosbachb6310312011-10-21 20:35:01 +00001056
1057void ARMInstPrinter::printVectorListFour(const MCInst *MI, unsigned OpNum,
1058 raw_ostream &O) {
1059 // Normally, it's not safe to use register enum values directly with
1060 // addition to get the next register, but for VFP registers, the
1061 // sort order is guaranteed because they're all of the form D<n>.
1062 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << ", "
1063 << getRegisterName(MI->getOperand(OpNum).getReg() + 1) << ", "
1064 << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << ", "
1065 << getRegisterName(MI->getOperand(OpNum).getReg() + 3) << "}";
1066}
Jim Grosbach98b05a52011-11-30 01:09:44 +00001067
1068void ARMInstPrinter::printVectorListOneAllLanes(const MCInst *MI,
1069 unsigned OpNum,
1070 raw_ostream &O) {
1071 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << "[]}";
1072}
1073
Jim Grosbach13af2222011-11-30 18:21:25 +00001074void ARMInstPrinter::printVectorListTwoAllLanes(const MCInst *MI,
1075 unsigned OpNum,
1076 raw_ostream &O) {
Jim Grosbachc0fc4502012-03-06 22:01:44 +00001077 unsigned Reg = MI->getOperand(OpNum).getReg();
1078 unsigned Reg0 = MRI.getSubReg(Reg, ARM::dsub_0);
1079 unsigned Reg1 = MRI.getSubReg(Reg, ARM::dsub_1);
1080 O << "{" << getRegisterName(Reg0) << "[], " << getRegisterName(Reg1) << "[]}";
Jim Grosbach13af2222011-11-30 18:21:25 +00001081}
Jim Grosbache90ac9b2011-12-14 19:35:22 +00001082
Jim Grosbach5e59f7e2012-01-24 23:47:04 +00001083void ARMInstPrinter::printVectorListThreeAllLanes(const MCInst *MI,
1084 unsigned OpNum,
1085 raw_ostream &O) {
1086 // Normally, it's not safe to use register enum values directly with
1087 // addition to get the next register, but for VFP registers, the
1088 // sort order is guaranteed because they're all of the form D<n>.
1089 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << "[], "
1090 << getRegisterName(MI->getOperand(OpNum).getReg() + 1) << "[], "
1091 << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << "[]}";
1092}
1093
Jim Grosbacha57a36a2012-01-25 00:01:08 +00001094void ARMInstPrinter::printVectorListFourAllLanes(const MCInst *MI,
1095 unsigned OpNum,
1096 raw_ostream &O) {
1097 // Normally, it's not safe to use register enum values directly with
1098 // addition to get the next register, but for VFP registers, the
1099 // sort order is guaranteed because they're all of the form D<n>.
1100 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << "[], "
1101 << getRegisterName(MI->getOperand(OpNum).getReg() + 1) << "[], "
1102 << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << "[], "
1103 << getRegisterName(MI->getOperand(OpNum).getReg() + 3) << "[]}";
1104}
1105
Jim Grosbach3471d4f2011-12-21 00:38:54 +00001106void ARMInstPrinter::printVectorListTwoSpacedAllLanes(const MCInst *MI,
1107 unsigned OpNum,
1108 raw_ostream &O) {
Jim Grosbach4d0983a2012-03-06 23:10:38 +00001109 unsigned Reg = MI->getOperand(OpNum).getReg();
1110 unsigned Reg0 = MRI.getSubReg(Reg, ARM::dsub_0);
1111 unsigned Reg1 = MRI.getSubReg(Reg, ARM::dsub_2);
1112 O << "{" << getRegisterName(Reg0) << "[], " << getRegisterName(Reg1) << "[]}";
Jim Grosbach3471d4f2011-12-21 00:38:54 +00001113}
1114
Jim Grosbach5e59f7e2012-01-24 23:47:04 +00001115void ARMInstPrinter::printVectorListThreeSpacedAllLanes(const MCInst *MI,
1116 unsigned OpNum,
1117 raw_ostream &O) {
1118 // Normally, it's not safe to use register enum values directly with
1119 // addition to get the next register, but for VFP registers, the
1120 // sort order is guaranteed because they're all of the form D<n>.
1121 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << "[], "
1122 << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << "[], "
Jim Grosbacha57a36a2012-01-25 00:01:08 +00001123 << getRegisterName(MI->getOperand(OpNum).getReg() + 4) << "[]}";
1124}
1125
1126void ARMInstPrinter::printVectorListFourSpacedAllLanes(const MCInst *MI,
1127 unsigned OpNum,
1128 raw_ostream &O) {
1129 // Normally, it's not safe to use register enum values directly with
1130 // addition to get the next register, but for VFP registers, the
1131 // sort order is guaranteed because they're all of the form D<n>.
1132 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << "[], "
1133 << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << "[], "
1134 << getRegisterName(MI->getOperand(OpNum).getReg() + 4) << "[], "
1135 << getRegisterName(MI->getOperand(OpNum).getReg() + 6) << "[]}";
Jim Grosbach5e59f7e2012-01-24 23:47:04 +00001136}
1137
Jim Grosbachc387fc62012-01-23 23:20:46 +00001138void ARMInstPrinter::printVectorListThreeSpaced(const MCInst *MI,
1139 unsigned OpNum,
1140 raw_ostream &O) {
1141 // Normally, it's not safe to use register enum values directly with
1142 // addition to get the next register, but for VFP registers, the
1143 // sort order is guaranteed because they're all of the form D<n>.
1144 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << ", "
1145 << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << ", "
1146 << getRegisterName(MI->getOperand(OpNum).getReg() + 4) << "}";
1147}
Jim Grosbach8abe7e32012-01-24 00:43:17 +00001148
1149void ARMInstPrinter::printVectorListFourSpaced(const MCInst *MI,
1150 unsigned OpNum,
1151 raw_ostream &O) {
1152 // Normally, it's not safe to use register enum values directly with
1153 // addition to get the next register, but for VFP registers, the
1154 // sort order is guaranteed because they're all of the form D<n>.
1155 O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << ", "
1156 << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << ", "
1157 << getRegisterName(MI->getOperand(OpNum).getReg() + 4) << ", "
1158 << getRegisterName(MI->getOperand(OpNum).getReg() + 6) << "}";
1159}