Chris Lattner | fd60382 | 2009-10-19 19:56:26 +0000 | [diff] [blame] | 1 | //===-- 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 Cheng | be74029 | 2011-07-23 00:00:19 +0000 | [diff] [blame] | 16 | #include "MCTargetDesc/ARMBaseInfo.h" |
Evan Cheng | ee04a6d | 2011-07-20 23:34:39 +0000 | [diff] [blame] | 17 | #include "MCTargetDesc/ARMAddressingModes.h" |
Chris Lattner | fd60382 | 2009-10-19 19:56:26 +0000 | [diff] [blame] | 18 | #include "llvm/MC/MCInst.h" |
Chris Lattner | 61d35c2 | 2009-10-19 21:21:39 +0000 | [diff] [blame] | 19 | #include "llvm/MC/MCAsmInfo.h" |
Chris Lattner | 6f99776 | 2009-10-19 21:53:00 +0000 | [diff] [blame] | 20 | #include "llvm/MC/MCExpr.h" |
Jim Grosbach | 28f08c9 | 2012-03-05 19:33:30 +0000 | [diff] [blame] | 21 | #include "llvm/MC/MCRegisterInfo.h" |
Chris Lattner | 6f99776 | 2009-10-19 21:53:00 +0000 | [diff] [blame] | 22 | #include "llvm/Support/raw_ostream.h" |
Chris Lattner | fd60382 | 2009-10-19 19:56:26 +0000 | [diff] [blame] | 23 | using namespace llvm; |
| 24 | |
Chris Lattner | 6274ec4 | 2010-10-28 21:37:33 +0000 | [diff] [blame] | 25 | #define GET_INSTRUCTION_NAME |
Chris Lattner | fd60382 | 2009-10-19 19:56:26 +0000 | [diff] [blame] | 26 | #include "ARMGenAsmWriter.inc" |
Chris Lattner | fd60382 | 2009-10-19 19:56:26 +0000 | [diff] [blame] | 27 | |
Owen Anderson | 3dac0be | 2011-08-11 18:41:59 +0000 | [diff] [blame] | 28 | /// translateShiftImm - Convert shift immediate from 0-31 to 1-32 for printing. |
| 29 | /// |
Jim Grosbach | 01208d5 | 2011-10-12 16:36:01 +0000 | [diff] [blame] | 30 | /// getSORegOffset returns an integer from 0-31, representing '32' as 0. |
Owen Anderson | 3dac0be | 2011-08-11 18:41:59 +0000 | [diff] [blame] | 31 | static unsigned translateShiftImm(unsigned imm) { |
| 32 | if (imm == 0) |
| 33 | return 32; |
| 34 | return imm; |
| 35 | } |
| 36 | |
James Molloy | b950585 | 2011-09-07 17:24:38 +0000 | [diff] [blame] | 37 | |
| 38 | ARMInstPrinter::ARMInstPrinter(const MCAsmInfo &MAI, |
Jim Grosbach | c6449b6 | 2012-03-05 19:33:20 +0000 | [diff] [blame] | 39 | const MCRegisterInfo &MRI, |
James Molloy | b950585 | 2011-09-07 17:24:38 +0000 | [diff] [blame] | 40 | const MCSubtargetInfo &STI) : |
Jim Grosbach | c6449b6 | 2012-03-05 19:33:20 +0000 | [diff] [blame] | 41 | MCInstPrinter(MAI, MRI) { |
James Molloy | b950585 | 2011-09-07 17:24:38 +0000 | [diff] [blame] | 42 | // Initialize the set of available features. |
| 43 | setAvailableFeatures(STI.getFeatureBits()); |
| 44 | } |
| 45 | |
Chris Lattner | 6274ec4 | 2010-10-28 21:37:33 +0000 | [diff] [blame] | 46 | StringRef ARMInstPrinter::getOpcodeName(unsigned Opcode) const { |
| 47 | return getInstructionName(Opcode); |
| 48 | } |
| 49 | |
Rafael Espindola | cde4ce4 | 2011-06-02 02:34:55 +0000 | [diff] [blame] | 50 | void ARMInstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const { |
| 51 | OS << getRegisterName(RegNo); |
Anton Korobeynikov | 57caad7 | 2011-03-05 18:43:32 +0000 | [diff] [blame] | 52 | } |
Chris Lattner | 6274ec4 | 2010-10-28 21:37:33 +0000 | [diff] [blame] | 53 | |
Owen Anderson | 98c5dda | 2011-09-15 23:38:46 +0000 | [diff] [blame] | 54 | void ARMInstPrinter::printInst(const MCInst *MI, raw_ostream &O, |
| 55 | StringRef Annot) { |
Bill Wendling | 04863d0 | 2010-11-13 10:40:19 +0000 | [diff] [blame] | 56 | unsigned Opcode = MI->getOpcode(); |
| 57 | |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 58 | // Check for MOVs and print canonical forms, instead. |
Owen Anderson | 152d4a4 | 2011-07-21 23:38:37 +0000 | [diff] [blame] | 59 | if (Opcode == ARM::MOVsr) { |
Jim Grosbach | e6be85e | 2010-09-17 22:36:38 +0000 | [diff] [blame] | 60 | // FIXME: Thumb variants? |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 61 | const MCOperand &Dst = MI->getOperand(0); |
| 62 | const MCOperand &MO1 = MI->getOperand(1); |
| 63 | const MCOperand &MO2 = MI->getOperand(2); |
| 64 | const MCOperand &MO3 = MI->getOperand(3); |
| 65 | |
| 66 | O << '\t' << ARM_AM::getShiftOpcStr(ARM_AM::getSORegShOp(MO3.getImm())); |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 67 | printSBitModifierOperand(MI, 6, O); |
| 68 | printPredicateOperand(MI, 4, O); |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 69 | |
| 70 | O << '\t' << getRegisterName(Dst.getReg()) |
| 71 | << ", " << getRegisterName(MO1.getReg()); |
| 72 | |
Owen Anderson | 152d4a4 | 2011-07-21 23:38:37 +0000 | [diff] [blame] | 73 | O << ", " << getRegisterName(MO2.getReg()); |
| 74 | assert(ARM_AM::getSORegOffset(MO3.getImm()) == 0); |
Owen Anderson | 519020a | 2011-09-21 17:58:45 +0000 | [diff] [blame] | 75 | printAnnotation(O, Annot); |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 76 | return; |
| 77 | } |
| 78 | |
Owen Anderson | 152d4a4 | 2011-07-21 23:38:37 +0000 | [diff] [blame] | 79 | if (Opcode == ARM::MOVsi) { |
| 80 | // FIXME: Thumb variants? |
| 81 | const MCOperand &Dst = MI->getOperand(0); |
| 82 | const MCOperand &MO1 = MI->getOperand(1); |
| 83 | const MCOperand &MO2 = MI->getOperand(2); |
| 84 | |
| 85 | O << '\t' << ARM_AM::getShiftOpcStr(ARM_AM::getSORegShOp(MO2.getImm())); |
| 86 | printSBitModifierOperand(MI, 5, O); |
| 87 | printPredicateOperand(MI, 3, O); |
| 88 | |
| 89 | O << '\t' << getRegisterName(Dst.getReg()) |
| 90 | << ", " << getRegisterName(MO1.getReg()); |
| 91 | |
Owen Anderson | ede042d | 2011-09-15 18:36:29 +0000 | [diff] [blame] | 92 | if (ARM_AM::getSORegShOp(MO2.getImm()) == ARM_AM::rrx) { |
Owen Anderson | 519020a | 2011-09-21 17:58:45 +0000 | [diff] [blame] | 93 | printAnnotation(O, Annot); |
Owen Anderson | 152d4a4 | 2011-07-21 23:38:37 +0000 | [diff] [blame] | 94 | return; |
Owen Anderson | ede042d | 2011-09-15 18:36:29 +0000 | [diff] [blame] | 95 | } |
Owen Anderson | 152d4a4 | 2011-07-21 23:38:37 +0000 | [diff] [blame] | 96 | |
Owen Anderson | 3dac0be | 2011-08-11 18:41:59 +0000 | [diff] [blame] | 97 | O << ", #" << translateShiftImm(ARM_AM::getSORegOffset(MO2.getImm())); |
Owen Anderson | 519020a | 2011-09-21 17:58:45 +0000 | [diff] [blame] | 98 | printAnnotation(O, Annot); |
Owen Anderson | 152d4a4 | 2011-07-21 23:38:37 +0000 | [diff] [blame] | 99 | return; |
| 100 | } |
| 101 | |
| 102 | |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 103 | // A8.6.123 PUSH |
Bill Wendling | 73fe34a | 2010-11-16 01:16:36 +0000 | [diff] [blame] | 104 | if ((Opcode == ARM::STMDB_UPD || Opcode == ARM::t2STMDB_UPD) && |
Owen Anderson | 81550dc | 2011-11-02 18:03:14 +0000 | [diff] [blame] | 105 | MI->getOperand(0).getReg() == ARM::SP && |
| 106 | MI->getNumOperands() > 5) { |
| 107 | // Should only print PUSH if there are at least two registers in the list. |
Bill Wendling | 73fe34a | 2010-11-16 01:16:36 +0000 | [diff] [blame] | 108 | O << '\t' << "push"; |
| 109 | printPredicateOperand(MI, 2, O); |
Jim Grosbach | 41ad0c4 | 2010-12-03 20:33:01 +0000 | [diff] [blame] | 110 | if (Opcode == ARM::t2STMDB_UPD) |
| 111 | O << ".w"; |
Bill Wendling | 73fe34a | 2010-11-16 01:16:36 +0000 | [diff] [blame] | 112 | O << '\t'; |
| 113 | printRegisterList(MI, 4, O); |
Owen Anderson | 519020a | 2011-09-21 17:58:45 +0000 | [diff] [blame] | 114 | printAnnotation(O, Annot); |
Bill Wendling | 73fe34a | 2010-11-16 01:16:36 +0000 | [diff] [blame] | 115 | return; |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 116 | } |
Jim Grosbach | f671391 | 2011-08-11 18:07:11 +0000 | [diff] [blame] | 117 | if (Opcode == ARM::STR_PRE_IMM && MI->getOperand(2).getReg() == ARM::SP && |
| 118 | MI->getOperand(3).getImm() == -4) { |
| 119 | O << '\t' << "push"; |
| 120 | printPredicateOperand(MI, 4, O); |
| 121 | O << "\t{" << getRegisterName(MI->getOperand(1).getReg()) << "}"; |
Owen Anderson | 519020a | 2011-09-21 17:58:45 +0000 | [diff] [blame] | 122 | printAnnotation(O, Annot); |
Jim Grosbach | f671391 | 2011-08-11 18:07:11 +0000 | [diff] [blame] | 123 | return; |
| 124 | } |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 125 | |
| 126 | // A8.6.122 POP |
Bill Wendling | 73fe34a | 2010-11-16 01:16:36 +0000 | [diff] [blame] | 127 | if ((Opcode == ARM::LDMIA_UPD || Opcode == ARM::t2LDMIA_UPD) && |
Owen Anderson | 81550dc | 2011-11-02 18:03:14 +0000 | [diff] [blame] | 128 | MI->getOperand(0).getReg() == ARM::SP && |
| 129 | MI->getNumOperands() > 5) { |
| 130 | // Should only print POP if there are at least two registers in the list. |
Bill Wendling | 73fe34a | 2010-11-16 01:16:36 +0000 | [diff] [blame] | 131 | O << '\t' << "pop"; |
| 132 | printPredicateOperand(MI, 2, O); |
Jim Grosbach | 41ad0c4 | 2010-12-03 20:33:01 +0000 | [diff] [blame] | 133 | if (Opcode == ARM::t2LDMIA_UPD) |
| 134 | O << ".w"; |
Bill Wendling | 73fe34a | 2010-11-16 01:16:36 +0000 | [diff] [blame] | 135 | O << '\t'; |
| 136 | printRegisterList(MI, 4, O); |
Owen Anderson | 519020a | 2011-09-21 17:58:45 +0000 | [diff] [blame] | 137 | printAnnotation(O, Annot); |
Bill Wendling | 73fe34a | 2010-11-16 01:16:36 +0000 | [diff] [blame] | 138 | return; |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 139 | } |
Jim Grosbach | f8fce71 | 2011-08-11 17:35:48 +0000 | [diff] [blame] | 140 | if (Opcode == ARM::LDR_POST_IMM && MI->getOperand(2).getReg() == ARM::SP && |
| 141 | MI->getOperand(4).getImm() == 4) { |
| 142 | O << '\t' << "pop"; |
| 143 | printPredicateOperand(MI, 5, O); |
| 144 | O << "\t{" << getRegisterName(MI->getOperand(0).getReg()) << "}"; |
Owen Anderson | 519020a | 2011-09-21 17:58:45 +0000 | [diff] [blame] | 145 | printAnnotation(O, Annot); |
Jim Grosbach | f8fce71 | 2011-08-11 17:35:48 +0000 | [diff] [blame] | 146 | return; |
| 147 | } |
| 148 | |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 149 | |
| 150 | // A8.6.355 VPUSH |
Bill Wendling | 73fe34a | 2010-11-16 01:16:36 +0000 | [diff] [blame] | 151 | if ((Opcode == ARM::VSTMSDB_UPD || Opcode == ARM::VSTMDDB_UPD) && |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 152 | MI->getOperand(0).getReg() == ARM::SP) { |
Bill Wendling | 73fe34a | 2010-11-16 01:16:36 +0000 | [diff] [blame] | 153 | O << '\t' << "vpush"; |
| 154 | printPredicateOperand(MI, 2, O); |
| 155 | O << '\t'; |
| 156 | printRegisterList(MI, 4, O); |
Owen Anderson | 519020a | 2011-09-21 17:58:45 +0000 | [diff] [blame] | 157 | printAnnotation(O, Annot); |
Bill Wendling | 73fe34a | 2010-11-16 01:16:36 +0000 | [diff] [blame] | 158 | return; |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | // A8.6.354 VPOP |
Bill Wendling | 73fe34a | 2010-11-16 01:16:36 +0000 | [diff] [blame] | 162 | if ((Opcode == ARM::VLDMSIA_UPD || Opcode == ARM::VLDMDIA_UPD) && |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 163 | MI->getOperand(0).getReg() == ARM::SP) { |
Bill Wendling | 73fe34a | 2010-11-16 01:16:36 +0000 | [diff] [blame] | 164 | O << '\t' << "vpop"; |
| 165 | printPredicateOperand(MI, 2, O); |
| 166 | O << '\t'; |
| 167 | printRegisterList(MI, 4, O); |
Owen Anderson | 519020a | 2011-09-21 17:58:45 +0000 | [diff] [blame] | 168 | printAnnotation(O, Annot); |
Bill Wendling | 73fe34a | 2010-11-16 01:16:36 +0000 | [diff] [blame] | 169 | return; |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 170 | } |
| 171 | |
Jim Grosbach | cefe4c9 | 2011-08-23 17:41:15 +0000 | [diff] [blame] | 172 | if (Opcode == ARM::tLDMIA) { |
Owen Anderson | 565a036 | 2011-07-18 23:25:34 +0000 | [diff] [blame] | 173 | bool Writeback = true; |
| 174 | unsigned BaseReg = MI->getOperand(0).getReg(); |
| 175 | for (unsigned i = 3; i < MI->getNumOperands(); ++i) { |
| 176 | if (MI->getOperand(i).getReg() == BaseReg) |
| 177 | Writeback = false; |
| 178 | } |
| 179 | |
Jim Grosbach | cefe4c9 | 2011-08-23 17:41:15 +0000 | [diff] [blame] | 180 | O << "\tldm"; |
Owen Anderson | 565a036 | 2011-07-18 23:25:34 +0000 | [diff] [blame] | 181 | |
| 182 | printPredicateOperand(MI, 1, O); |
| 183 | O << '\t' << getRegisterName(BaseReg); |
| 184 | if (Writeback) O << "!"; |
| 185 | O << ", "; |
| 186 | printRegisterList(MI, 3, O); |
Owen Anderson | 519020a | 2011-09-21 17:58:45 +0000 | [diff] [blame] | 187 | printAnnotation(O, Annot); |
Owen Anderson | 565a036 | 2011-07-18 23:25:34 +0000 | [diff] [blame] | 188 | return; |
| 189 | } |
| 190 | |
Jim Grosbach | 0780b63 | 2011-08-19 23:24:36 +0000 | [diff] [blame] | 191 | // Thumb1 NOP |
| 192 | if (Opcode == ARM::tMOVr && MI->getOperand(0).getReg() == ARM::R8 && |
| 193 | MI->getOperand(1).getReg() == ARM::R8) { |
| 194 | O << "\tnop"; |
Jim Grosbach | df9ce6b | 2011-08-24 20:06:14 +0000 | [diff] [blame] | 195 | printPredicateOperand(MI, 2, O); |
Owen Anderson | 519020a | 2011-09-21 17:58:45 +0000 | [diff] [blame] | 196 | printAnnotation(O, Annot); |
Jim Grosbach | 0780b63 | 2011-08-19 23:24:36 +0000 | [diff] [blame] | 197 | return; |
| 198 | } |
| 199 | |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 200 | printInstruction(MI, O); |
Owen Anderson | 519020a | 2011-09-21 17:58:45 +0000 | [diff] [blame] | 201 | printAnnotation(O, Annot); |
Bill Wendling | 04863d0 | 2010-11-13 10:40:19 +0000 | [diff] [blame] | 202 | } |
Chris Lattner | fd60382 | 2009-10-19 19:56:26 +0000 | [diff] [blame] | 203 | |
Chris Lattner | 8bc86cb | 2009-10-19 20:59:55 +0000 | [diff] [blame] | 204 | void ARMInstPrinter::printOperand(const MCInst *MI, unsigned OpNo, |
Jim Grosbach | 0a2287b | 2010-11-03 01:11:15 +0000 | [diff] [blame] | 205 | raw_ostream &O) { |
Chris Lattner | 8bc86cb | 2009-10-19 20:59:55 +0000 | [diff] [blame] | 206 | const MCOperand &Op = MI->getOperand(OpNo); |
| 207 | if (Op.isReg()) { |
Chris Lattner | bf16faa | 2009-10-20 06:15:28 +0000 | [diff] [blame] | 208 | unsigned Reg = Op.getReg(); |
Jim Grosbach | 3563628 | 2010-10-06 21:22:32 +0000 | [diff] [blame] | 209 | O << getRegisterName(Reg); |
Chris Lattner | 8bc86cb | 2009-10-19 20:59:55 +0000 | [diff] [blame] | 210 | } else if (Op.isImm()) { |
| 211 | O << '#' << Op.getImm(); |
| 212 | } else { |
| 213 | assert(Op.isExpr() && "unknown operand kind in printOperand"); |
Kevin Enderby | 9e5887b | 2011-10-04 22:44:48 +0000 | [diff] [blame] | 214 | // If a symbolic branch target was added as a constant expression then print |
| 215 | // that address in hex. |
| 216 | const MCConstantExpr *BranchTarget = dyn_cast<MCConstantExpr>(Op.getExpr()); |
| 217 | int64_t Address; |
| 218 | if (BranchTarget && BranchTarget->EvaluateAsAbsolute(Address)) { |
| 219 | O << "0x"; |
| 220 | O.write_hex(Address); |
| 221 | } |
| 222 | else { |
| 223 | // Otherwise, just print the expression. |
| 224 | O << *Op.getExpr(); |
| 225 | } |
Chris Lattner | 8bc86cb | 2009-10-19 20:59:55 +0000 | [diff] [blame] | 226 | } |
| 227 | } |
Chris Lattner | 61d35c2 | 2009-10-19 21:21:39 +0000 | [diff] [blame] | 228 | |
Owen Anderson | e136872 | 2011-09-21 23:44:46 +0000 | [diff] [blame] | 229 | void ARMInstPrinter::printT2LdrLabelOperand(const MCInst *MI, unsigned OpNum, |
| 230 | raw_ostream &O) { |
| 231 | const MCOperand &MO1 = MI->getOperand(OpNum); |
| 232 | if (MO1.isExpr()) |
| 233 | O << *MO1.getExpr(); |
| 234 | else if (MO1.isImm()) |
| 235 | O << "[pc, #" << MO1.getImm() << "]"; |
| 236 | else |
| 237 | llvm_unreachable("Unknown LDR label operand?"); |
| 238 | } |
| 239 | |
Chris Lattner | 017d947 | 2009-10-20 00:40:56 +0000 | [diff] [blame] | 240 | // so_reg is a 4-operand unit corresponding to register forms of the A5.1 |
| 241 | // "Addressing Mode 1 - Data-processing operands" forms. This includes: |
| 242 | // REG 0 0 - e.g. R5 |
| 243 | // REG REG 0,SH_OPC - e.g. R5, ROR R3 |
| 244 | // REG 0 IMM,SH_OPC - e.g. R5, LSL #3 |
Owen Anderson | 152d4a4 | 2011-07-21 23:38:37 +0000 | [diff] [blame] | 245 | void ARMInstPrinter::printSORegRegOperand(const MCInst *MI, unsigned OpNum, |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 246 | raw_ostream &O) { |
Chris Lattner | 017d947 | 2009-10-20 00:40:56 +0000 | [diff] [blame] | 247 | const MCOperand &MO1 = MI->getOperand(OpNum); |
| 248 | const MCOperand &MO2 = MI->getOperand(OpNum+1); |
| 249 | const MCOperand &MO3 = MI->getOperand(OpNum+2); |
Jim Grosbach | 15d7898 | 2010-09-14 22:27:15 +0000 | [diff] [blame] | 250 | |
Chris Lattner | 017d947 | 2009-10-20 00:40:56 +0000 | [diff] [blame] | 251 | O << getRegisterName(MO1.getReg()); |
Jim Grosbach | 15d7898 | 2010-09-14 22:27:15 +0000 | [diff] [blame] | 252 | |
Chris Lattner | 017d947 | 2009-10-20 00:40:56 +0000 | [diff] [blame] | 253 | // Print the shift opc. |
Bob Wilson | 1d9125a | 2010-08-05 00:34:42 +0000 | [diff] [blame] | 254 | ARM_AM::ShiftOpc ShOpc = ARM_AM::getSORegShOp(MO3.getImm()); |
| 255 | O << ", " << ARM_AM::getShiftOpcStr(ShOpc); |
Jim Grosbach | e8606dc | 2011-07-13 17:50:29 +0000 | [diff] [blame] | 256 | if (ShOpc == ARM_AM::rrx) |
| 257 | return; |
Jim Grosbach | 293a5f6 | 2011-10-21 16:56:40 +0000 | [diff] [blame] | 258 | |
Owen Anderson | 152d4a4 | 2011-07-21 23:38:37 +0000 | [diff] [blame] | 259 | O << ' ' << getRegisterName(MO2.getReg()); |
| 260 | assert(ARM_AM::getSORegOffset(MO3.getImm()) == 0); |
Chris Lattner | 017d947 | 2009-10-20 00:40:56 +0000 | [diff] [blame] | 261 | } |
Chris Lattner | 084f87d | 2009-10-19 21:57:05 +0000 | [diff] [blame] | 262 | |
Owen Anderson | 152d4a4 | 2011-07-21 23:38:37 +0000 | [diff] [blame] | 263 | void ARMInstPrinter::printSORegImmOperand(const MCInst *MI, unsigned OpNum, |
| 264 | raw_ostream &O) { |
| 265 | const MCOperand &MO1 = MI->getOperand(OpNum); |
| 266 | const MCOperand &MO2 = MI->getOperand(OpNum+1); |
| 267 | |
| 268 | O << getRegisterName(MO1.getReg()); |
| 269 | |
| 270 | // Print the shift opc. |
| 271 | ARM_AM::ShiftOpc ShOpc = ARM_AM::getSORegShOp(MO2.getImm()); |
| 272 | O << ", " << ARM_AM::getShiftOpcStr(ShOpc); |
| 273 | if (ShOpc == ARM_AM::rrx) |
| 274 | return; |
Owen Anderson | 3dac0be | 2011-08-11 18:41:59 +0000 | [diff] [blame] | 275 | O << " #" << translateShiftImm(ARM_AM::getSORegOffset(MO2.getImm())); |
Owen Anderson | 152d4a4 | 2011-07-21 23:38:37 +0000 | [diff] [blame] | 276 | } |
| 277 | |
| 278 | |
Bruno Cardoso Lopes | ac79e4c | 2011-04-04 17:18:19 +0000 | [diff] [blame] | 279 | //===--------------------------------------------------------------------===// |
| 280 | // Addressing Mode #2 |
| 281 | //===--------------------------------------------------------------------===// |
| 282 | |
Bruno Cardoso Lopes | ae08554 | 2011-03-31 23:26:08 +0000 | [diff] [blame] | 283 | void ARMInstPrinter::printAM2PreOrOffsetIndexOp(const MCInst *MI, unsigned Op, |
| 284 | raw_ostream &O) { |
Chris Lattner | 084f87d | 2009-10-19 21:57:05 +0000 | [diff] [blame] | 285 | const MCOperand &MO1 = MI->getOperand(Op); |
| 286 | const MCOperand &MO2 = MI->getOperand(Op+1); |
| 287 | const MCOperand &MO3 = MI->getOperand(Op+2); |
Jim Grosbach | 15d7898 | 2010-09-14 22:27:15 +0000 | [diff] [blame] | 288 | |
Chris Lattner | 084f87d | 2009-10-19 21:57:05 +0000 | [diff] [blame] | 289 | O << "[" << getRegisterName(MO1.getReg()); |
Jim Grosbach | 15d7898 | 2010-09-14 22:27:15 +0000 | [diff] [blame] | 290 | |
Chris Lattner | 084f87d | 2009-10-19 21:57:05 +0000 | [diff] [blame] | 291 | if (!MO2.getReg()) { |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 292 | if (ARM_AM::getAM2Offset(MO3.getImm())) // Don't print +0. |
Chris Lattner | 084f87d | 2009-10-19 21:57:05 +0000 | [diff] [blame] | 293 | O << ", #" |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 294 | << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO3.getImm())) |
| 295 | << ARM_AM::getAM2Offset(MO3.getImm()); |
Chris Lattner | 084f87d | 2009-10-19 21:57:05 +0000 | [diff] [blame] | 296 | O << "]"; |
| 297 | return; |
| 298 | } |
Jim Grosbach | 15d7898 | 2010-09-14 22:27:15 +0000 | [diff] [blame] | 299 | |
Chris Lattner | 084f87d | 2009-10-19 21:57:05 +0000 | [diff] [blame] | 300 | O << ", " |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 301 | << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO3.getImm())) |
| 302 | << getRegisterName(MO2.getReg()); |
Jim Grosbach | 15d7898 | 2010-09-14 22:27:15 +0000 | [diff] [blame] | 303 | |
Chris Lattner | 084f87d | 2009-10-19 21:57:05 +0000 | [diff] [blame] | 304 | if (unsigned ShImm = ARM_AM::getAM2Offset(MO3.getImm())) |
| 305 | O << ", " |
| 306 | << ARM_AM::getShiftOpcStr(ARM_AM::getAM2ShiftOpc(MO3.getImm())) |
| 307 | << " #" << ShImm; |
| 308 | O << "]"; |
Jim Grosbach | 15d7898 | 2010-09-14 22:27:15 +0000 | [diff] [blame] | 309 | } |
Chris Lattner | e306d8d | 2009-10-19 22:09:23 +0000 | [diff] [blame] | 310 | |
Bruno Cardoso Lopes | ae08554 | 2011-03-31 23:26:08 +0000 | [diff] [blame] | 311 | void ARMInstPrinter::printAM2PostIndexOp(const MCInst *MI, unsigned Op, |
| 312 | raw_ostream &O) { |
| 313 | const MCOperand &MO1 = MI->getOperand(Op); |
| 314 | const MCOperand &MO2 = MI->getOperand(Op+1); |
| 315 | const MCOperand &MO3 = MI->getOperand(Op+2); |
| 316 | |
| 317 | O << "[" << getRegisterName(MO1.getReg()) << "], "; |
| 318 | |
| 319 | if (!MO2.getReg()) { |
| 320 | unsigned ImmOffs = ARM_AM::getAM2Offset(MO3.getImm()); |
| 321 | O << '#' |
| 322 | << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO3.getImm())) |
| 323 | << ImmOffs; |
| 324 | return; |
| 325 | } |
| 326 | |
| 327 | O << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO3.getImm())) |
| 328 | << getRegisterName(MO2.getReg()); |
| 329 | |
| 330 | if (unsigned ShImm = ARM_AM::getAM2Offset(MO3.getImm())) |
| 331 | O << ", " |
| 332 | << ARM_AM::getShiftOpcStr(ARM_AM::getAM2ShiftOpc(MO3.getImm())) |
| 333 | << " #" << ShImm; |
| 334 | } |
| 335 | |
Jim Grosbach | 7f739be | 2011-09-19 22:21:13 +0000 | [diff] [blame] | 336 | void ARMInstPrinter::printAddrModeTBB(const MCInst *MI, unsigned Op, |
| 337 | raw_ostream &O) { |
| 338 | const MCOperand &MO1 = MI->getOperand(Op); |
| 339 | const MCOperand &MO2 = MI->getOperand(Op+1); |
| 340 | O << "[" << getRegisterName(MO1.getReg()) << ", " |
| 341 | << getRegisterName(MO2.getReg()) << "]"; |
| 342 | } |
| 343 | |
| 344 | void ARMInstPrinter::printAddrModeTBH(const MCInst *MI, unsigned Op, |
| 345 | raw_ostream &O) { |
| 346 | const MCOperand &MO1 = MI->getOperand(Op); |
| 347 | const MCOperand &MO2 = MI->getOperand(Op+1); |
| 348 | O << "[" << getRegisterName(MO1.getReg()) << ", " |
| 349 | << getRegisterName(MO2.getReg()) << ", lsl #1]"; |
| 350 | } |
| 351 | |
Bruno Cardoso Lopes | ae08554 | 2011-03-31 23:26:08 +0000 | [diff] [blame] | 352 | void ARMInstPrinter::printAddrMode2Operand(const MCInst *MI, unsigned Op, |
| 353 | raw_ostream &O) { |
| 354 | const MCOperand &MO1 = MI->getOperand(Op); |
| 355 | |
| 356 | if (!MO1.isReg()) { // FIXME: This is for CP entries, but isn't right. |
| 357 | printOperand(MI, Op, O); |
| 358 | return; |
| 359 | } |
| 360 | |
| 361 | const MCOperand &MO3 = MI->getOperand(Op+2); |
| 362 | unsigned IdxMode = ARM_AM::getAM2IdxMode(MO3.getImm()); |
| 363 | |
| 364 | if (IdxMode == ARMII::IndexModePost) { |
| 365 | printAM2PostIndexOp(MI, Op, O); |
| 366 | return; |
| 367 | } |
| 368 | printAM2PreOrOffsetIndexOp(MI, Op, O); |
| 369 | } |
| 370 | |
Chris Lattner | bf16faa | 2009-10-20 06:15:28 +0000 | [diff] [blame] | 371 | void ARMInstPrinter::printAddrMode2OffsetOperand(const MCInst *MI, |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 372 | unsigned OpNum, |
| 373 | raw_ostream &O) { |
Chris Lattner | bf16faa | 2009-10-20 06:15:28 +0000 | [diff] [blame] | 374 | const MCOperand &MO1 = MI->getOperand(OpNum); |
| 375 | const MCOperand &MO2 = MI->getOperand(OpNum+1); |
Jim Grosbach | 15d7898 | 2010-09-14 22:27:15 +0000 | [diff] [blame] | 376 | |
Chris Lattner | bf16faa | 2009-10-20 06:15:28 +0000 | [diff] [blame] | 377 | if (!MO1.getReg()) { |
| 378 | unsigned ImmOffs = ARM_AM::getAM2Offset(MO2.getImm()); |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 379 | O << '#' |
| 380 | << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO2.getImm())) |
| 381 | << ImmOffs; |
Chris Lattner | bf16faa | 2009-10-20 06:15:28 +0000 | [diff] [blame] | 382 | return; |
| 383 | } |
Jim Grosbach | 15d7898 | 2010-09-14 22:27:15 +0000 | [diff] [blame] | 384 | |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 385 | O << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO2.getImm())) |
| 386 | << getRegisterName(MO1.getReg()); |
Jim Grosbach | 15d7898 | 2010-09-14 22:27:15 +0000 | [diff] [blame] | 387 | |
Chris Lattner | bf16faa | 2009-10-20 06:15:28 +0000 | [diff] [blame] | 388 | if (unsigned ShImm = ARM_AM::getAM2Offset(MO2.getImm())) |
| 389 | O << ", " |
| 390 | << ARM_AM::getShiftOpcStr(ARM_AM::getAM2ShiftOpc(MO2.getImm())) |
| 391 | << " #" << ShImm; |
| 392 | } |
| 393 | |
Bruno Cardoso Lopes | ac79e4c | 2011-04-04 17:18:19 +0000 | [diff] [blame] | 394 | //===--------------------------------------------------------------------===// |
| 395 | // Addressing Mode #3 |
| 396 | //===--------------------------------------------------------------------===// |
| 397 | |
| 398 | void ARMInstPrinter::printAM3PostIndexOp(const MCInst *MI, unsigned Op, |
| 399 | raw_ostream &O) { |
| 400 | const MCOperand &MO1 = MI->getOperand(Op); |
| 401 | const MCOperand &MO2 = MI->getOperand(Op+1); |
| 402 | const MCOperand &MO3 = MI->getOperand(Op+2); |
| 403 | |
| 404 | O << "[" << getRegisterName(MO1.getReg()) << "], "; |
| 405 | |
| 406 | if (MO2.getReg()) { |
| 407 | O << (char)ARM_AM::getAM3Op(MO3.getImm()) |
| 408 | << getRegisterName(MO2.getReg()); |
| 409 | return; |
| 410 | } |
| 411 | |
| 412 | unsigned ImmOffs = ARM_AM::getAM3Offset(MO3.getImm()); |
| 413 | O << '#' |
| 414 | << ARM_AM::getAddrOpcStr(ARM_AM::getAM3Op(MO3.getImm())) |
| 415 | << ImmOffs; |
| 416 | } |
| 417 | |
| 418 | void ARMInstPrinter::printAM3PreOrOffsetIndexOp(const MCInst *MI, unsigned Op, |
| 419 | raw_ostream &O) { |
| 420 | const MCOperand &MO1 = MI->getOperand(Op); |
| 421 | const MCOperand &MO2 = MI->getOperand(Op+1); |
| 422 | const MCOperand &MO3 = MI->getOperand(Op+2); |
Jim Grosbach | 15d7898 | 2010-09-14 22:27:15 +0000 | [diff] [blame] | 423 | |
Chris Lattner | bf16faa | 2009-10-20 06:15:28 +0000 | [diff] [blame] | 424 | O << '[' << getRegisterName(MO1.getReg()); |
Jim Grosbach | 15d7898 | 2010-09-14 22:27:15 +0000 | [diff] [blame] | 425 | |
Chris Lattner | bf16faa | 2009-10-20 06:15:28 +0000 | [diff] [blame] | 426 | if (MO2.getReg()) { |
Jim Grosbach | 7ce0579 | 2011-08-03 23:50:40 +0000 | [diff] [blame] | 427 | O << ", " << getAddrOpcStr(ARM_AM::getAM3Op(MO3.getImm())) |
Chris Lattner | bf16faa | 2009-10-20 06:15:28 +0000 | [diff] [blame] | 428 | << getRegisterName(MO2.getReg()) << ']'; |
| 429 | return; |
| 430 | } |
Jim Grosbach | 15d7898 | 2010-09-14 22:27:15 +0000 | [diff] [blame] | 431 | |
Chris Lattner | bf16faa | 2009-10-20 06:15:28 +0000 | [diff] [blame] | 432 | if (unsigned ImmOffs = ARM_AM::getAM3Offset(MO3.getImm())) |
| 433 | O << ", #" |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 434 | << ARM_AM::getAddrOpcStr(ARM_AM::getAM3Op(MO3.getImm())) |
| 435 | << ImmOffs; |
Chris Lattner | bf16faa | 2009-10-20 06:15:28 +0000 | [diff] [blame] | 436 | O << ']'; |
| 437 | } |
| 438 | |
Bruno Cardoso Lopes | ac79e4c | 2011-04-04 17:18:19 +0000 | [diff] [blame] | 439 | void ARMInstPrinter::printAddrMode3Operand(const MCInst *MI, unsigned Op, |
| 440 | raw_ostream &O) { |
Jim Grosbach | 2f19674 | 2011-12-19 23:06:24 +0000 | [diff] [blame] | 441 | const MCOperand &MO1 = MI->getOperand(Op); |
| 442 | if (!MO1.isReg()) { // For label symbolic references. |
| 443 | printOperand(MI, Op, O); |
| 444 | return; |
| 445 | } |
| 446 | |
Bruno Cardoso Lopes | ac79e4c | 2011-04-04 17:18:19 +0000 | [diff] [blame] | 447 | const MCOperand &MO3 = MI->getOperand(Op+2); |
| 448 | unsigned IdxMode = ARM_AM::getAM3IdxMode(MO3.getImm()); |
| 449 | |
| 450 | if (IdxMode == ARMII::IndexModePost) { |
| 451 | printAM3PostIndexOp(MI, Op, O); |
| 452 | return; |
| 453 | } |
| 454 | printAM3PreOrOffsetIndexOp(MI, Op, O); |
| 455 | } |
| 456 | |
Chris Lattner | bf16faa | 2009-10-20 06:15:28 +0000 | [diff] [blame] | 457 | void ARMInstPrinter::printAddrMode3OffsetOperand(const MCInst *MI, |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 458 | unsigned OpNum, |
| 459 | raw_ostream &O) { |
Chris Lattner | bf16faa | 2009-10-20 06:15:28 +0000 | [diff] [blame] | 460 | const MCOperand &MO1 = MI->getOperand(OpNum); |
| 461 | const MCOperand &MO2 = MI->getOperand(OpNum+1); |
Jim Grosbach | 15d7898 | 2010-09-14 22:27:15 +0000 | [diff] [blame] | 462 | |
Chris Lattner | bf16faa | 2009-10-20 06:15:28 +0000 | [diff] [blame] | 463 | if (MO1.getReg()) { |
Jim Grosbach | 7ce0579 | 2011-08-03 23:50:40 +0000 | [diff] [blame] | 464 | O << getAddrOpcStr(ARM_AM::getAM3Op(MO2.getImm())) |
| 465 | << getRegisterName(MO1.getReg()); |
Chris Lattner | bf16faa | 2009-10-20 06:15:28 +0000 | [diff] [blame] | 466 | return; |
| 467 | } |
Jim Grosbach | 15d7898 | 2010-09-14 22:27:15 +0000 | [diff] [blame] | 468 | |
Chris Lattner | bf16faa | 2009-10-20 06:15:28 +0000 | [diff] [blame] | 469 | unsigned ImmOffs = ARM_AM::getAM3Offset(MO2.getImm()); |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 470 | O << '#' |
| 471 | << ARM_AM::getAddrOpcStr(ARM_AM::getAM3Op(MO2.getImm())) |
| 472 | << ImmOffs; |
Chris Lattner | bf16faa | 2009-10-20 06:15:28 +0000 | [diff] [blame] | 473 | } |
| 474 | |
Jim Grosbach | 7ce0579 | 2011-08-03 23:50:40 +0000 | [diff] [blame] | 475 | void ARMInstPrinter::printPostIdxImm8Operand(const MCInst *MI, |
| 476 | unsigned OpNum, |
| 477 | raw_ostream &O) { |
| 478 | const MCOperand &MO = MI->getOperand(OpNum); |
| 479 | unsigned Imm = MO.getImm(); |
| 480 | O << '#' << ((Imm & 256) ? "" : "-") << (Imm & 0xff); |
| 481 | } |
| 482 | |
Jim Grosbach | ca8c70b | 2011-08-05 15:48:21 +0000 | [diff] [blame] | 483 | void ARMInstPrinter::printPostIdxRegOperand(const MCInst *MI, unsigned OpNum, |
| 484 | raw_ostream &O) { |
| 485 | const MCOperand &MO1 = MI->getOperand(OpNum); |
| 486 | const MCOperand &MO2 = MI->getOperand(OpNum+1); |
| 487 | |
Jim Grosbach | 16578b5 | 2011-08-05 16:11:38 +0000 | [diff] [blame] | 488 | O << (MO2.getImm() ? "" : "-") << getRegisterName(MO1.getReg()); |
Jim Grosbach | ca8c70b | 2011-08-05 15:48:21 +0000 | [diff] [blame] | 489 | } |
| 490 | |
Owen Anderson | 154c41d | 2011-08-04 18:24:14 +0000 | [diff] [blame] | 491 | void ARMInstPrinter::printPostIdxImm8s4Operand(const MCInst *MI, |
| 492 | unsigned OpNum, |
| 493 | raw_ostream &O) { |
| 494 | const MCOperand &MO = MI->getOperand(OpNum); |
| 495 | unsigned Imm = MO.getImm(); |
| 496 | O << '#' << ((Imm & 256) ? "" : "-") << ((Imm & 0xff) << 2); |
| 497 | } |
| 498 | |
| 499 | |
Jim Grosbach | e691360 | 2010-11-03 01:01:43 +0000 | [diff] [blame] | 500 | void ARMInstPrinter::printLdStmModeOperand(const MCInst *MI, unsigned OpNum, |
Jim Grosbach | 0a2287b | 2010-11-03 01:11:15 +0000 | [diff] [blame] | 501 | raw_ostream &O) { |
Jim Grosbach | e691360 | 2010-11-03 01:01:43 +0000 | [diff] [blame] | 502 | ARM_AM::AMSubMode Mode = ARM_AM::getAM4SubMode(MI->getOperand(OpNum) |
| 503 | .getImm()); |
| 504 | O << ARM_AM::getAMSubModeStr(Mode); |
Chris Lattner | e306d8d | 2009-10-19 22:09:23 +0000 | [diff] [blame] | 505 | } |
| 506 | |
Chris Lattner | bf16faa | 2009-10-20 06:15:28 +0000 | [diff] [blame] | 507 | void ARMInstPrinter::printAddrMode5Operand(const MCInst *MI, unsigned OpNum, |
Jim Grosbach | 0a2287b | 2010-11-03 01:11:15 +0000 | [diff] [blame] | 508 | raw_ostream &O) { |
Chris Lattner | bf16faa | 2009-10-20 06:15:28 +0000 | [diff] [blame] | 509 | const MCOperand &MO1 = MI->getOperand(OpNum); |
| 510 | const MCOperand &MO2 = MI->getOperand(OpNum+1); |
Jim Grosbach | 15d7898 | 2010-09-14 22:27:15 +0000 | [diff] [blame] | 511 | |
Chris Lattner | bf16faa | 2009-10-20 06:15:28 +0000 | [diff] [blame] | 512 | if (!MO1.isReg()) { // FIXME: This is for CP entries, but isn't right. |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 513 | printOperand(MI, OpNum, O); |
Chris Lattner | bf16faa | 2009-10-20 06:15:28 +0000 | [diff] [blame] | 514 | return; |
| 515 | } |
Jim Grosbach | 15d7898 | 2010-09-14 22:27:15 +0000 | [diff] [blame] | 516 | |
Chris Lattner | bf16faa | 2009-10-20 06:15:28 +0000 | [diff] [blame] | 517 | O << "[" << getRegisterName(MO1.getReg()); |
Jim Grosbach | 15d7898 | 2010-09-14 22:27:15 +0000 | [diff] [blame] | 518 | |
Owen Anderson | 0da10cf | 2011-08-29 19:36:44 +0000 | [diff] [blame] | 519 | unsigned ImmOffs = ARM_AM::getAM5Offset(MO2.getImm()); |
| 520 | unsigned Op = ARM_AM::getAM5Op(MO2.getImm()); |
| 521 | if (ImmOffs || Op == ARM_AM::sub) { |
Chris Lattner | bf16faa | 2009-10-20 06:15:28 +0000 | [diff] [blame] | 522 | O << ", #" |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 523 | << ARM_AM::getAddrOpcStr(ARM_AM::getAM5Op(MO2.getImm())) |
Bill Wendling | 92b5a2e | 2010-11-03 01:49:29 +0000 | [diff] [blame] | 524 | << ImmOffs * 4; |
Chris Lattner | bf16faa | 2009-10-20 06:15:28 +0000 | [diff] [blame] | 525 | } |
| 526 | O << "]"; |
| 527 | } |
| 528 | |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 529 | void ARMInstPrinter::printAddrMode6Operand(const MCInst *MI, unsigned OpNum, |
| 530 | raw_ostream &O) { |
Chris Lattner | 235e2f6 | 2009-10-20 06:22:33 +0000 | [diff] [blame] | 531 | const MCOperand &MO1 = MI->getOperand(OpNum); |
| 532 | const MCOperand &MO2 = MI->getOperand(OpNum+1); |
Jim Grosbach | 15d7898 | 2010-09-14 22:27:15 +0000 | [diff] [blame] | 533 | |
Bob Wilson | 226036e | 2010-03-20 22:13:40 +0000 | [diff] [blame] | 534 | O << "[" << getRegisterName(MO1.getReg()); |
| 535 | if (MO2.getImm()) { |
| 536 | // FIXME: Both darwin as and GNU as violate ARM docs here. |
Bob Wilson | 273ff31 | 2010-07-14 23:54:43 +0000 | [diff] [blame] | 537 | O << ", :" << (MO2.getImm() << 3); |
Chris Lattner | 235e2f6 | 2009-10-20 06:22:33 +0000 | [diff] [blame] | 538 | } |
Bob Wilson | 226036e | 2010-03-20 22:13:40 +0000 | [diff] [blame] | 539 | O << "]"; |
| 540 | } |
| 541 | |
Bruno Cardoso Lopes | 505f3cd | 2011-03-24 21:04:58 +0000 | [diff] [blame] | 542 | void ARMInstPrinter::printAddrMode7Operand(const MCInst *MI, unsigned OpNum, |
| 543 | raw_ostream &O) { |
| 544 | const MCOperand &MO1 = MI->getOperand(OpNum); |
| 545 | O << "[" << getRegisterName(MO1.getReg()) << "]"; |
| 546 | } |
| 547 | |
Bob Wilson | 226036e | 2010-03-20 22:13:40 +0000 | [diff] [blame] | 548 | void ARMInstPrinter::printAddrMode6OffsetOperand(const MCInst *MI, |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 549 | unsigned OpNum, |
| 550 | raw_ostream &O) { |
Bob Wilson | 226036e | 2010-03-20 22:13:40 +0000 | [diff] [blame] | 551 | const MCOperand &MO = MI->getOperand(OpNum); |
| 552 | if (MO.getReg() == 0) |
| 553 | O << "!"; |
| 554 | else |
| 555 | O << ", " << getRegisterName(MO.getReg()); |
Chris Lattner | 235e2f6 | 2009-10-20 06:22:33 +0000 | [diff] [blame] | 556 | } |
| 557 | |
Bob Wilson | eaf1c98 | 2010-08-11 23:10:46 +0000 | [diff] [blame] | 558 | void ARMInstPrinter::printBitfieldInvMaskImmOperand(const MCInst *MI, |
| 559 | unsigned OpNum, |
| 560 | raw_ostream &O) { |
Chris Lattner | 235e2f6 | 2009-10-20 06:22:33 +0000 | [diff] [blame] | 561 | const MCOperand &MO = MI->getOperand(OpNum); |
| 562 | uint32_t v = ~MO.getImm(); |
| 563 | int32_t lsb = CountTrailingZeros_32(v); |
| 564 | int32_t width = (32 - CountLeadingZeros_32 (v)) - lsb; |
| 565 | assert(MO.isImm() && "Not a valid bf_inv_mask_imm value!"); |
| 566 | O << '#' << lsb << ", #" << width; |
| 567 | } |
Chris Lattner | bf16faa | 2009-10-20 06:15:28 +0000 | [diff] [blame] | 568 | |
Johnny Chen | 1adc40c | 2010-08-12 20:46:17 +0000 | [diff] [blame] | 569 | void ARMInstPrinter::printMemBOption(const MCInst *MI, unsigned OpNum, |
| 570 | raw_ostream &O) { |
| 571 | unsigned val = MI->getOperand(OpNum).getImm(); |
| 572 | O << ARM_MB::MemBOptToString(val); |
| 573 | } |
| 574 | |
Bob Wilson | 22f5dc7 | 2010-08-16 18:27:34 +0000 | [diff] [blame] | 575 | void ARMInstPrinter::printShiftImmOperand(const MCInst *MI, unsigned OpNum, |
Bob Wilson | eaf1c98 | 2010-08-11 23:10:46 +0000 | [diff] [blame] | 576 | raw_ostream &O) { |
| 577 | unsigned ShiftOp = MI->getOperand(OpNum).getImm(); |
Jim Grosbach | 580f4a9 | 2011-07-25 22:20:28 +0000 | [diff] [blame] | 578 | bool isASR = (ShiftOp & (1 << 5)) != 0; |
| 579 | unsigned Amt = ShiftOp & 0x1f; |
| 580 | if (isASR) |
| 581 | O << ", asr #" << (Amt == 0 ? 32 : Amt); |
| 582 | else if (Amt) |
| 583 | O << ", lsl #" << Amt; |
Bob Wilson | eaf1c98 | 2010-08-11 23:10:46 +0000 | [diff] [blame] | 584 | } |
| 585 | |
Jim Grosbach | dde038a | 2011-07-20 21:40:26 +0000 | [diff] [blame] | 586 | void ARMInstPrinter::printPKHLSLShiftImm(const MCInst *MI, unsigned OpNum, |
| 587 | raw_ostream &O) { |
| 588 | unsigned Imm = MI->getOperand(OpNum).getImm(); |
| 589 | if (Imm == 0) |
| 590 | return; |
| 591 | assert(Imm > 0 && Imm < 32 && "Invalid PKH shift immediate value!"); |
| 592 | O << ", lsl #" << Imm; |
| 593 | } |
| 594 | |
| 595 | void ARMInstPrinter::printPKHASRShiftImm(const MCInst *MI, unsigned OpNum, |
| 596 | raw_ostream &O) { |
| 597 | unsigned Imm = MI->getOperand(OpNum).getImm(); |
| 598 | // A shift amount of 32 is encoded as 0. |
| 599 | if (Imm == 0) |
| 600 | Imm = 32; |
| 601 | assert(Imm > 0 && Imm <= 32 && "Invalid PKH shift immediate value!"); |
| 602 | O << ", asr #" << Imm; |
| 603 | } |
| 604 | |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 605 | void ARMInstPrinter::printRegisterList(const MCInst *MI, unsigned OpNum, |
| 606 | raw_ostream &O) { |
Chris Lattner | e306d8d | 2009-10-19 22:09:23 +0000 | [diff] [blame] | 607 | O << "{"; |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 608 | for (unsigned i = OpNum, e = MI->getNumOperands(); i != e; ++i) { |
| 609 | if (i != OpNum) O << ", "; |
Chris Lattner | e306d8d | 2009-10-19 22:09:23 +0000 | [diff] [blame] | 610 | O << getRegisterName(MI->getOperand(i).getReg()); |
| 611 | } |
| 612 | O << "}"; |
| 613 | } |
Chris Lattner | 4d15222 | 2009-10-19 22:23:04 +0000 | [diff] [blame] | 614 | |
Jim Grosbach | b3af5de | 2010-10-13 21:00:04 +0000 | [diff] [blame] | 615 | void ARMInstPrinter::printSetendOperand(const MCInst *MI, unsigned OpNum, |
| 616 | raw_ostream &O) { |
| 617 | const MCOperand &Op = MI->getOperand(OpNum); |
| 618 | if (Op.getImm()) |
| 619 | O << "be"; |
| 620 | else |
| 621 | O << "le"; |
| 622 | } |
| 623 | |
Bruno Cardoso Lopes | a2b6e41 | 2011-02-14 13:09:44 +0000 | [diff] [blame] | 624 | void ARMInstPrinter::printCPSIMod(const MCInst *MI, unsigned OpNum, |
| 625 | raw_ostream &O) { |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 626 | const MCOperand &Op = MI->getOperand(OpNum); |
Bruno Cardoso Lopes | a2b6e41 | 2011-02-14 13:09:44 +0000 | [diff] [blame] | 627 | O << ARM_PROC::IModToString(Op.getImm()); |
| 628 | } |
| 629 | |
| 630 | void ARMInstPrinter::printCPSIFlag(const MCInst *MI, unsigned OpNum, |
| 631 | raw_ostream &O) { |
| 632 | const MCOperand &Op = MI->getOperand(OpNum); |
| 633 | unsigned IFlags = Op.getImm(); |
| 634 | for (int i=2; i >= 0; --i) |
| 635 | if (IFlags & (1 << i)) |
| 636 | O << ARM_PROC::IFlagsToString(1 << i); |
Owen Anderson | 2dbb46a | 2011-10-05 17:16:40 +0000 | [diff] [blame] | 637 | |
| 638 | if (IFlags == 0) |
| 639 | O << "none"; |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 640 | } |
| 641 | |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 642 | void ARMInstPrinter::printMSRMaskOperand(const MCInst *MI, unsigned OpNum, |
| 643 | raw_ostream &O) { |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 644 | const MCOperand &Op = MI->getOperand(OpNum); |
Bruno Cardoso Lopes | 584bf7b | 2011-02-18 19:45:59 +0000 | [diff] [blame] | 645 | unsigned SpecRegRBit = Op.getImm() >> 4; |
| 646 | unsigned Mask = Op.getImm() & 0xf; |
| 647 | |
James Molloy | acad68d | 2011-09-28 14:21:38 +0000 | [diff] [blame] | 648 | if (getAvailableFeatures() & ARM::FeatureMClass) { |
| 649 | switch (Op.getImm()) { |
Craig Topper | bc21981 | 2012-02-07 02:50:20 +0000 | [diff] [blame] | 650 | default: llvm_unreachable("Unexpected mask value!"); |
James Molloy | acad68d | 2011-09-28 14:21:38 +0000 | [diff] [blame] | 651 | case 0: O << "apsr"; return; |
| 652 | case 1: O << "iapsr"; return; |
| 653 | case 2: O << "eapsr"; return; |
| 654 | case 3: O << "xpsr"; return; |
| 655 | case 5: O << "ipsr"; return; |
| 656 | case 6: O << "epsr"; return; |
| 657 | case 7: O << "iepsr"; return; |
| 658 | case 8: O << "msp"; return; |
| 659 | case 9: O << "psp"; return; |
| 660 | case 16: O << "primask"; return; |
| 661 | case 17: O << "basepri"; return; |
| 662 | case 18: O << "basepri_max"; return; |
| 663 | case 19: O << "faultmask"; return; |
| 664 | case 20: O << "control"; return; |
| 665 | } |
| 666 | } |
| 667 | |
Jim Grosbach | b29b4dd | 2011-07-19 22:45:10 +0000 | [diff] [blame] | 668 | // As special cases, CPSR_f, CPSR_s and CPSR_fs prefer printing as |
| 669 | // APSR_nzcvq, APSR_g and APSRnzcvqg, respectively. |
| 670 | if (!SpecRegRBit && (Mask == 8 || Mask == 4 || Mask == 12)) { |
| 671 | O << "APSR_"; |
| 672 | switch (Mask) { |
Craig Topper | bc21981 | 2012-02-07 02:50:20 +0000 | [diff] [blame] | 673 | default: llvm_unreachable("Unexpected mask value!"); |
Jim Grosbach | b29b4dd | 2011-07-19 22:45:10 +0000 | [diff] [blame] | 674 | case 4: O << "g"; return; |
| 675 | case 8: O << "nzcvq"; return; |
| 676 | case 12: O << "nzcvqg"; return; |
| 677 | } |
Jim Grosbach | b29b4dd | 2011-07-19 22:45:10 +0000 | [diff] [blame] | 678 | } |
| 679 | |
Bruno Cardoso Lopes | 584bf7b | 2011-02-18 19:45:59 +0000 | [diff] [blame] | 680 | if (SpecRegRBit) |
Jim Grosbach | b29b4dd | 2011-07-19 22:45:10 +0000 | [diff] [blame] | 681 | O << "SPSR"; |
Bruno Cardoso Lopes | 584bf7b | 2011-02-18 19:45:59 +0000 | [diff] [blame] | 682 | else |
Jim Grosbach | b29b4dd | 2011-07-19 22:45:10 +0000 | [diff] [blame] | 683 | O << "CPSR"; |
Bruno Cardoso Lopes | 584bf7b | 2011-02-18 19:45:59 +0000 | [diff] [blame] | 684 | |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 685 | if (Mask) { |
| 686 | O << '_'; |
| 687 | if (Mask & 8) O << 'f'; |
| 688 | if (Mask & 4) O << 's'; |
| 689 | if (Mask & 2) O << 'x'; |
| 690 | if (Mask & 1) O << 'c'; |
| 691 | } |
| 692 | } |
| 693 | |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 694 | void ARMInstPrinter::printPredicateOperand(const MCInst *MI, unsigned OpNum, |
| 695 | raw_ostream &O) { |
Chris Lattner | 413ae25 | 2009-10-20 00:42:49 +0000 | [diff] [blame] | 696 | ARMCC::CondCodes CC = (ARMCC::CondCodes)MI->getOperand(OpNum).getImm(); |
Kevin Enderby | b057851 | 2012-03-01 22:13:02 +0000 | [diff] [blame] | 697 | // Handle the undefined 15 CC value here for printing so we don't abort(). |
| 698 | if ((unsigned)CC == 15) |
| 699 | O << "<und>"; |
| 700 | else if (CC != ARMCC::AL) |
Chris Lattner | 413ae25 | 2009-10-20 00:42:49 +0000 | [diff] [blame] | 701 | O << ARMCondCodeToString(CC); |
| 702 | } |
| 703 | |
Jim Grosbach | 15d7898 | 2010-09-14 22:27:15 +0000 | [diff] [blame] | 704 | void ARMInstPrinter::printMandatoryPredicateOperand(const MCInst *MI, |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 705 | unsigned OpNum, |
| 706 | raw_ostream &O) { |
Johnny Chen | 9d3acaa | 2010-03-02 17:57:15 +0000 | [diff] [blame] | 707 | ARMCC::CondCodes CC = (ARMCC::CondCodes)MI->getOperand(OpNum).getImm(); |
| 708 | O << ARMCondCodeToString(CC); |
| 709 | } |
| 710 | |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 711 | void ARMInstPrinter::printSBitModifierOperand(const MCInst *MI, unsigned OpNum, |
| 712 | raw_ostream &O) { |
Daniel Dunbar | a7cc652 | 2009-10-20 22:10:05 +0000 | [diff] [blame] | 713 | if (MI->getOperand(OpNum).getReg()) { |
| 714 | assert(MI->getOperand(OpNum).getReg() == ARM::CPSR && |
| 715 | "Expect ARM CPSR register!"); |
Chris Lattner | 233917c | 2009-10-20 00:46:11 +0000 | [diff] [blame] | 716 | O << 's'; |
| 717 | } |
| 718 | } |
| 719 | |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 720 | void ARMInstPrinter::printNoHashImmediate(const MCInst *MI, unsigned OpNum, |
| 721 | raw_ostream &O) { |
Chris Lattner | bf16faa | 2009-10-20 06:15:28 +0000 | [diff] [blame] | 722 | O << MI->getOperand(OpNum).getImm(); |
| 723 | } |
| 724 | |
Owen Anderson | e4e5e2a | 2011-01-13 21:46:02 +0000 | [diff] [blame] | 725 | void ARMInstPrinter::printPImmediate(const MCInst *MI, unsigned OpNum, |
Jim Grosbach | bc9c802 | 2011-10-12 16:34:37 +0000 | [diff] [blame] | 726 | raw_ostream &O) { |
Owen Anderson | e4e5e2a | 2011-01-13 21:46:02 +0000 | [diff] [blame] | 727 | O << "p" << MI->getOperand(OpNum).getImm(); |
| 728 | } |
| 729 | |
| 730 | void ARMInstPrinter::printCImmediate(const MCInst *MI, unsigned OpNum, |
Jim Grosbach | bc9c802 | 2011-10-12 16:34:37 +0000 | [diff] [blame] | 731 | raw_ostream &O) { |
Owen Anderson | e4e5e2a | 2011-01-13 21:46:02 +0000 | [diff] [blame] | 732 | O << "c" << MI->getOperand(OpNum).getImm(); |
| 733 | } |
| 734 | |
Jim Grosbach | 9b8f2a0 | 2011-10-12 17:34:41 +0000 | [diff] [blame] | 735 | void ARMInstPrinter::printCoprocOptionImm(const MCInst *MI, unsigned OpNum, |
| 736 | raw_ostream &O) { |
| 737 | O << "{" << MI->getOperand(OpNum).getImm() << "}"; |
| 738 | } |
| 739 | |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 740 | void ARMInstPrinter::printPCLabel(const MCInst *MI, unsigned OpNum, |
| 741 | raw_ostream &O) { |
Jim Grosbach | d30cfde | 2010-09-18 00:04:53 +0000 | [diff] [blame] | 742 | llvm_unreachable("Unhandled PC-relative pseudo-instruction!"); |
Chris Lattner | 4d15222 | 2009-10-19 22:23:04 +0000 | [diff] [blame] | 743 | } |
Evan Cheng | 2ef9c8a | 2009-11-19 06:57:41 +0000 | [diff] [blame] | 744 | |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 745 | void ARMInstPrinter::printThumbS4ImmOperand(const MCInst *MI, unsigned OpNum, |
| 746 | raw_ostream &O) { |
Jim Grosbach | 70939ee | 2011-08-17 21:51:27 +0000 | [diff] [blame] | 747 | O << "#" << MI->getOperand(OpNum).getImm() * 4; |
| 748 | } |
| 749 | |
| 750 | void ARMInstPrinter::printThumbSRImm(const MCInst *MI, unsigned OpNum, |
| 751 | raw_ostream &O) { |
| 752 | unsigned Imm = MI->getOperand(OpNum).getImm(); |
| 753 | O << "#" << (Imm == 0 ? 32 : Imm); |
Evan Cheng | 2ef9c8a | 2009-11-19 06:57:41 +0000 | [diff] [blame] | 754 | } |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 755 | |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 756 | void ARMInstPrinter::printThumbITMask(const MCInst *MI, unsigned OpNum, |
| 757 | raw_ostream &O) { |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 758 | // (3 - the number of trailing zeros) is the number of then / else. |
| 759 | unsigned Mask = MI->getOperand(OpNum).getImm(); |
| 760 | unsigned CondBit0 = Mask >> 4 & 1; |
| 761 | unsigned NumTZ = CountTrailingZeros_32(Mask); |
| 762 | assert(NumTZ <= 3 && "Invalid IT mask!"); |
| 763 | for (unsigned Pos = 3, e = NumTZ; Pos > e; --Pos) { |
| 764 | bool T = ((Mask >> Pos) & 1) == CondBit0; |
| 765 | if (T) |
| 766 | O << 't'; |
| 767 | else |
| 768 | O << 'e'; |
| 769 | } |
| 770 | } |
| 771 | |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 772 | void ARMInstPrinter::printThumbAddrModeRROperand(const MCInst *MI, unsigned Op, |
| 773 | raw_ostream &O) { |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 774 | const MCOperand &MO1 = MI->getOperand(Op); |
Bill Wendling | f4caf69 | 2010-12-14 03:36:38 +0000 | [diff] [blame] | 775 | const MCOperand &MO2 = MI->getOperand(Op + 1); |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 776 | |
| 777 | if (!MO1.isReg()) { // FIXME: This is for CP entries, but isn't right. |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 778 | printOperand(MI, Op, O); |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 779 | return; |
| 780 | } |
| 781 | |
| 782 | O << "[" << getRegisterName(MO1.getReg()); |
Bill Wendling | f4caf69 | 2010-12-14 03:36:38 +0000 | [diff] [blame] | 783 | if (unsigned RegNum = MO2.getReg()) |
| 784 | O << ", " << getRegisterName(RegNum); |
| 785 | O << "]"; |
| 786 | } |
| 787 | |
| 788 | void ARMInstPrinter::printThumbAddrModeImm5SOperand(const MCInst *MI, |
| 789 | unsigned Op, |
| 790 | raw_ostream &O, |
| 791 | unsigned Scale) { |
| 792 | const MCOperand &MO1 = MI->getOperand(Op); |
| 793 | const MCOperand &MO2 = MI->getOperand(Op + 1); |
| 794 | |
| 795 | if (!MO1.isReg()) { // FIXME: This is for CP entries, but isn't right. |
| 796 | printOperand(MI, Op, O); |
| 797 | return; |
| 798 | } |
| 799 | |
| 800 | O << "[" << getRegisterName(MO1.getReg()); |
| 801 | if (unsigned ImmOffs = MO2.getImm()) |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 802 | O << ", #" << ImmOffs * Scale; |
| 803 | O << "]"; |
| 804 | } |
| 805 | |
Bill Wendling | f4caf69 | 2010-12-14 03:36:38 +0000 | [diff] [blame] | 806 | void ARMInstPrinter::printThumbAddrModeImm5S1Operand(const MCInst *MI, |
| 807 | unsigned Op, |
| 808 | raw_ostream &O) { |
| 809 | printThumbAddrModeImm5SOperand(MI, Op, O, 1); |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 810 | } |
| 811 | |
Bill Wendling | f4caf69 | 2010-12-14 03:36:38 +0000 | [diff] [blame] | 812 | void ARMInstPrinter::printThumbAddrModeImm5S2Operand(const MCInst *MI, |
| 813 | unsigned Op, |
| 814 | raw_ostream &O) { |
| 815 | printThumbAddrModeImm5SOperand(MI, Op, O, 2); |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 816 | } |
| 817 | |
Bill Wendling | f4caf69 | 2010-12-14 03:36:38 +0000 | [diff] [blame] | 818 | void ARMInstPrinter::printThumbAddrModeImm5S4Operand(const MCInst *MI, |
| 819 | unsigned Op, |
| 820 | raw_ostream &O) { |
| 821 | printThumbAddrModeImm5SOperand(MI, Op, O, 4); |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 822 | } |
| 823 | |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 824 | void ARMInstPrinter::printThumbAddrModeSPOperand(const MCInst *MI, unsigned Op, |
| 825 | raw_ostream &O) { |
Bill Wendling | f4caf69 | 2010-12-14 03:36:38 +0000 | [diff] [blame] | 826 | printThumbAddrModeImm5SOperand(MI, Op, O, 4); |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 827 | } |
| 828 | |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 829 | // Constant shifts t2_so_reg is a 2-operand unit corresponding to the Thumb2 |
| 830 | // register with shift forms. |
| 831 | // REG 0 0 - e.g. R5 |
| 832 | // REG IMM, SH_OPC - e.g. R5, LSL #3 |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 833 | void ARMInstPrinter::printT2SOOperand(const MCInst *MI, unsigned OpNum, |
| 834 | raw_ostream &O) { |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 835 | const MCOperand &MO1 = MI->getOperand(OpNum); |
| 836 | const MCOperand &MO2 = MI->getOperand(OpNum+1); |
| 837 | |
| 838 | unsigned Reg = MO1.getReg(); |
| 839 | O << getRegisterName(Reg); |
| 840 | |
| 841 | // Print the shift opc. |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 842 | assert(MO2.isImm() && "Not a valid t2_so_reg value!"); |
Bob Wilson | 1d9125a | 2010-08-05 00:34:42 +0000 | [diff] [blame] | 843 | ARM_AM::ShiftOpc ShOpc = ARM_AM::getSORegShOp(MO2.getImm()); |
| 844 | O << ", " << ARM_AM::getShiftOpcStr(ShOpc); |
| 845 | if (ShOpc != ARM_AM::rrx) |
Owen Anderson | 3dac0be | 2011-08-11 18:41:59 +0000 | [diff] [blame] | 846 | O << " #" << translateShiftImm(ARM_AM::getSORegOffset(MO2.getImm())); |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 847 | } |
| 848 | |
Jim Grosbach | 458f2dc | 2010-10-25 20:00:01 +0000 | [diff] [blame] | 849 | void ARMInstPrinter::printAddrModeImm12Operand(const MCInst *MI, unsigned OpNum, |
| 850 | raw_ostream &O) { |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 851 | const MCOperand &MO1 = MI->getOperand(OpNum); |
| 852 | const MCOperand &MO2 = MI->getOperand(OpNum+1); |
| 853 | |
Jim Grosbach | 3e55612 | 2010-10-26 22:37:02 +0000 | [diff] [blame] | 854 | if (!MO1.isReg()) { // FIXME: This is for CP entries, but isn't right. |
| 855 | printOperand(MI, OpNum, O); |
| 856 | return; |
| 857 | } |
| 858 | |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 859 | O << "[" << getRegisterName(MO1.getReg()); |
| 860 | |
Jim Grosbach | 77aee8e | 2010-10-27 01:19:41 +0000 | [diff] [blame] | 861 | int32_t OffImm = (int32_t)MO2.getImm(); |
Jim Grosbach | ab682a2 | 2010-10-28 18:34:10 +0000 | [diff] [blame] | 862 | bool isSub = OffImm < 0; |
| 863 | // Special value for #-0. All others are normal. |
| 864 | if (OffImm == INT32_MIN) |
| 865 | OffImm = 0; |
| 866 | if (isSub) |
Jim Grosbach | 77aee8e | 2010-10-27 01:19:41 +0000 | [diff] [blame] | 867 | O << ", #-" << -OffImm; |
| 868 | else if (OffImm > 0) |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 869 | O << ", #" << OffImm; |
| 870 | O << "]"; |
| 871 | } |
| 872 | |
| 873 | void ARMInstPrinter::printT2AddrModeImm8Operand(const MCInst *MI, |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 874 | unsigned OpNum, |
| 875 | raw_ostream &O) { |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 876 | const MCOperand &MO1 = MI->getOperand(OpNum); |
| 877 | const MCOperand &MO2 = MI->getOperand(OpNum+1); |
| 878 | |
| 879 | O << "[" << getRegisterName(MO1.getReg()); |
| 880 | |
| 881 | int32_t OffImm = (int32_t)MO2.getImm(); |
| 882 | // Don't print +0. |
Owen Anderson | 705b48f | 2011-09-16 21:08:33 +0000 | [diff] [blame] | 883 | if (OffImm == INT32_MIN) |
| 884 | O << ", #-0"; |
| 885 | else if (OffImm < 0) |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 886 | O << ", #-" << -OffImm; |
| 887 | else if (OffImm > 0) |
| 888 | O << ", #" << OffImm; |
| 889 | O << "]"; |
| 890 | } |
| 891 | |
| 892 | void ARMInstPrinter::printT2AddrModeImm8s4Operand(const MCInst *MI, |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 893 | unsigned OpNum, |
| 894 | raw_ostream &O) { |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 895 | const MCOperand &MO1 = MI->getOperand(OpNum); |
| 896 | const MCOperand &MO2 = MI->getOperand(OpNum+1); |
| 897 | |
Jim Grosbach | 2f19674 | 2011-12-19 23:06:24 +0000 | [diff] [blame] | 898 | if (!MO1.isReg()) { // For label symbolic references. |
| 899 | printOperand(MI, OpNum, O); |
| 900 | return; |
| 901 | } |
| 902 | |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 903 | O << "[" << getRegisterName(MO1.getReg()); |
| 904 | |
| 905 | int32_t OffImm = (int32_t)MO2.getImm() / 4; |
| 906 | // Don't print +0. |
| 907 | if (OffImm < 0) |
| 908 | O << ", #-" << -OffImm * 4; |
| 909 | else if (OffImm > 0) |
| 910 | O << ", #" << OffImm * 4; |
| 911 | O << "]"; |
| 912 | } |
| 913 | |
Jim Grosbach | b6aed50 | 2011-09-09 18:37:27 +0000 | [diff] [blame] | 914 | void ARMInstPrinter::printT2AddrModeImm0_1020s4Operand(const MCInst *MI, |
| 915 | unsigned OpNum, |
| 916 | raw_ostream &O) { |
| 917 | const MCOperand &MO1 = MI->getOperand(OpNum); |
| 918 | const MCOperand &MO2 = MI->getOperand(OpNum+1); |
| 919 | |
| 920 | O << "[" << getRegisterName(MO1.getReg()); |
| 921 | if (MO2.getImm()) |
| 922 | O << ", #" << MO2.getImm() * 4; |
| 923 | O << "]"; |
| 924 | } |
| 925 | |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 926 | void ARMInstPrinter::printT2AddrModeImm8OffsetOperand(const MCInst *MI, |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 927 | unsigned OpNum, |
| 928 | raw_ostream &O) { |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 929 | const MCOperand &MO1 = MI->getOperand(OpNum); |
| 930 | int32_t OffImm = (int32_t)MO1.getImm(); |
| 931 | // Don't print +0. |
| 932 | if (OffImm < 0) |
Owen Anderson | 0781c1f | 2011-09-23 21:26:40 +0000 | [diff] [blame] | 933 | O << ", #-" << -OffImm; |
| 934 | else |
| 935 | O << ", #" << OffImm; |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 936 | } |
| 937 | |
| 938 | void ARMInstPrinter::printT2AddrModeImm8s4OffsetOperand(const MCInst *MI, |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 939 | unsigned OpNum, |
| 940 | raw_ostream &O) { |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 941 | const MCOperand &MO1 = MI->getOperand(OpNum); |
| 942 | int32_t OffImm = (int32_t)MO1.getImm() / 4; |
| 943 | // Don't print +0. |
Owen Anderson | 7782a58 | 2011-09-13 20:46:26 +0000 | [diff] [blame] | 944 | if (OffImm != 0) { |
| 945 | O << ", "; |
| 946 | if (OffImm < 0) |
| 947 | O << "#-" << -OffImm * 4; |
| 948 | else if (OffImm > 0) |
| 949 | O << "#" << OffImm * 4; |
| 950 | } |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 951 | } |
| 952 | |
| 953 | void ARMInstPrinter::printT2AddrModeSoRegOperand(const MCInst *MI, |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 954 | unsigned OpNum, |
| 955 | raw_ostream &O) { |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 956 | const MCOperand &MO1 = MI->getOperand(OpNum); |
| 957 | const MCOperand &MO2 = MI->getOperand(OpNum+1); |
| 958 | const MCOperand &MO3 = MI->getOperand(OpNum+2); |
| 959 | |
| 960 | O << "[" << getRegisterName(MO1.getReg()); |
| 961 | |
| 962 | assert(MO2.getReg() && "Invalid so_reg load / store address!"); |
| 963 | O << ", " << getRegisterName(MO2.getReg()); |
| 964 | |
| 965 | unsigned ShAmt = MO3.getImm(); |
| 966 | if (ShAmt) { |
| 967 | assert(ShAmt <= 3 && "Not a valid Thumb2 addressing mode!"); |
| 968 | O << ", lsl #" << ShAmt; |
| 969 | } |
| 970 | O << "]"; |
| 971 | } |
| 972 | |
Jim Grosbach | 4ebbf7b | 2011-09-30 00:50:06 +0000 | [diff] [blame] | 973 | void ARMInstPrinter::printFPImmOperand(const MCInst *MI, unsigned OpNum, |
| 974 | raw_ostream &O) { |
Bill Wendling | 8cb415e | 2011-01-26 20:57:43 +0000 | [diff] [blame] | 975 | const MCOperand &MO = MI->getOperand(OpNum); |
Jim Grosbach | 4ebbf7b | 2011-09-30 00:50:06 +0000 | [diff] [blame] | 976 | O << '#' << ARM_AM::getFPImmFloat(MO.getImm()); |
Johnny Chen | 9e08876 | 2010-03-17 17:52:21 +0000 | [diff] [blame] | 977 | } |
| 978 | |
Bob Wilson | 1a913ed | 2010-06-11 21:34:50 +0000 | [diff] [blame] | 979 | void ARMInstPrinter::printNEONModImmOperand(const MCInst *MI, unsigned OpNum, |
| 980 | raw_ostream &O) { |
Bob Wilson | 6dce00c | 2010-07-13 04:44:34 +0000 | [diff] [blame] | 981 | unsigned EncodedImm = MI->getOperand(OpNum).getImm(); |
| 982 | unsigned EltBits; |
| 983 | uint64_t Val = ARM_AM::decodeNEONModImm(EncodedImm, EltBits); |
Benjamin Kramer | 70be28a | 2011-11-07 21:00:59 +0000 | [diff] [blame] | 984 | O << "#0x"; |
| 985 | O.write_hex(Val); |
Johnny Chen | c7b6591 | 2010-04-16 22:40:20 +0000 | [diff] [blame] | 986 | } |
Jim Grosbach | 4a5ffb3 | 2011-07-22 23:16:18 +0000 | [diff] [blame] | 987 | |
Jim Grosbach | f494335 | 2011-07-25 23:09:14 +0000 | [diff] [blame] | 988 | void ARMInstPrinter::printImmPlusOneOperand(const MCInst *MI, unsigned OpNum, |
| 989 | raw_ostream &O) { |
Jim Grosbach | 4a5ffb3 | 2011-07-22 23:16:18 +0000 | [diff] [blame] | 990 | unsigned Imm = MI->getOperand(OpNum).getImm(); |
| 991 | O << "#" << Imm + 1; |
| 992 | } |
Jim Grosbach | 85bfd3b | 2011-07-26 21:28:43 +0000 | [diff] [blame] | 993 | |
| 994 | void ARMInstPrinter::printRotImmOperand(const MCInst *MI, unsigned OpNum, |
| 995 | raw_ostream &O) { |
| 996 | unsigned Imm = MI->getOperand(OpNum).getImm(); |
| 997 | if (Imm == 0) |
| 998 | return; |
Jim Grosbach | 45f3929 | 2011-07-26 21:44:37 +0000 | [diff] [blame] | 999 | O << ", ror #"; |
Jim Grosbach | 85bfd3b | 2011-07-26 21:28:43 +0000 | [diff] [blame] | 1000 | switch (Imm) { |
| 1001 | default: assert (0 && "illegal ror immediate!"); |
Jim Grosbach | 2f815c0 | 2011-08-17 23:23:07 +0000 | [diff] [blame] | 1002 | case 1: O << "8"; break; |
| 1003 | case 2: O << "16"; break; |
| 1004 | case 3: O << "24"; break; |
Jim Grosbach | 85bfd3b | 2011-07-26 21:28:43 +0000 | [diff] [blame] | 1005 | } |
| 1006 | } |
Jim Grosbach | 460a905 | 2011-10-07 23:56:00 +0000 | [diff] [blame] | 1007 | |
Jim Grosbach | 4050bc4 | 2011-12-22 22:19:05 +0000 | [diff] [blame] | 1008 | void ARMInstPrinter::printFBits16(const MCInst *MI, unsigned OpNum, |
| 1009 | raw_ostream &O) { |
| 1010 | O << "#" << 16 - MI->getOperand(OpNum).getImm(); |
| 1011 | } |
| 1012 | |
| 1013 | void ARMInstPrinter::printFBits32(const MCInst *MI, unsigned OpNum, |
| 1014 | raw_ostream &O) { |
| 1015 | O << "#" << 32 - MI->getOperand(OpNum).getImm(); |
| 1016 | } |
| 1017 | |
Jim Grosbach | 460a905 | 2011-10-07 23:56:00 +0000 | [diff] [blame] | 1018 | void ARMInstPrinter::printVectorIndex(const MCInst *MI, unsigned OpNum, |
| 1019 | raw_ostream &O) { |
| 1020 | O << "[" << MI->getOperand(OpNum).getImm() << "]"; |
| 1021 | } |
Jim Grosbach | 862019c | 2011-10-18 23:02:30 +0000 | [diff] [blame] | 1022 | |
| 1023 | void ARMInstPrinter::printVectorListOne(const MCInst *MI, unsigned OpNum, |
| 1024 | raw_ostream &O) { |
| 1025 | O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << "}"; |
| 1026 | } |
Jim Grosbach | 280dfad | 2011-10-21 18:54:25 +0000 | [diff] [blame] | 1027 | |
Jim Grosbach | c0fc450 | 2012-03-06 22:01:44 +0000 | [diff] [blame] | 1028 | void ARMInstPrinter::printVectorListTwo(const MCInst *MI, unsigned OpNum, |
Jim Grosbach | 28f08c9 | 2012-03-05 19:33:30 +0000 | [diff] [blame] | 1029 | raw_ostream &O) { |
| 1030 | unsigned Reg = MI->getOperand(OpNum).getReg(); |
| 1031 | unsigned Reg0 = MRI.getSubReg(Reg, ARM::dsub_0); |
| 1032 | unsigned Reg1 = MRI.getSubReg(Reg, ARM::dsub_1); |
| 1033 | O << "{" << getRegisterName(Reg0) << ", " << getRegisterName(Reg1) << "}"; |
| 1034 | } |
| 1035 | |
Jim Grosbach | c0fc450 | 2012-03-06 22:01:44 +0000 | [diff] [blame] | 1036 | void ARMInstPrinter::printVectorListTwoSpaced(const MCInst *MI, |
| 1037 | unsigned OpNum, |
| 1038 | raw_ostream &O) { |
Jim Grosbach | c3384c9 | 2012-03-05 21:43:40 +0000 | [diff] [blame] | 1039 | unsigned Reg = MI->getOperand(OpNum).getReg(); |
| 1040 | unsigned Reg0 = MRI.getSubReg(Reg, ARM::dsub_0); |
| 1041 | unsigned Reg1 = MRI.getSubReg(Reg, ARM::dsub_2); |
| 1042 | O << "{" << getRegisterName(Reg0) << ", " << getRegisterName(Reg1) << "}"; |
| 1043 | } |
| 1044 | |
Jim Grosbach | cdcfa28 | 2011-10-21 20:02:19 +0000 | [diff] [blame] | 1045 | void ARMInstPrinter::printVectorListThree(const MCInst *MI, unsigned OpNum, |
| 1046 | raw_ostream &O) { |
| 1047 | // Normally, it's not safe to use register enum values directly with |
| 1048 | // addition to get the next register, but for VFP registers, the |
| 1049 | // sort order is guaranteed because they're all of the form D<n>. |
| 1050 | O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << ", " |
| 1051 | << getRegisterName(MI->getOperand(OpNum).getReg() + 1) << ", " |
| 1052 | << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << "}"; |
| 1053 | } |
Jim Grosbach | b631031 | 2011-10-21 20:35:01 +0000 | [diff] [blame] | 1054 | |
| 1055 | void ARMInstPrinter::printVectorListFour(const MCInst *MI, unsigned OpNum, |
| 1056 | raw_ostream &O) { |
| 1057 | // Normally, it's not safe to use register enum values directly with |
| 1058 | // addition to get the next register, but for VFP registers, the |
| 1059 | // sort order is guaranteed because they're all of the form D<n>. |
| 1060 | O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << ", " |
| 1061 | << getRegisterName(MI->getOperand(OpNum).getReg() + 1) << ", " |
| 1062 | << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << ", " |
| 1063 | << getRegisterName(MI->getOperand(OpNum).getReg() + 3) << "}"; |
| 1064 | } |
Jim Grosbach | 98b05a5 | 2011-11-30 01:09:44 +0000 | [diff] [blame] | 1065 | |
| 1066 | void ARMInstPrinter::printVectorListOneAllLanes(const MCInst *MI, |
| 1067 | unsigned OpNum, |
| 1068 | raw_ostream &O) { |
| 1069 | O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << "[]}"; |
| 1070 | } |
| 1071 | |
Jim Grosbach | 13af222 | 2011-11-30 18:21:25 +0000 | [diff] [blame] | 1072 | void ARMInstPrinter::printVectorListTwoAllLanes(const MCInst *MI, |
| 1073 | unsigned OpNum, |
| 1074 | raw_ostream &O) { |
Jim Grosbach | c0fc450 | 2012-03-06 22:01:44 +0000 | [diff] [blame] | 1075 | unsigned Reg = MI->getOperand(OpNum).getReg(); |
| 1076 | unsigned Reg0 = MRI.getSubReg(Reg, ARM::dsub_0); |
| 1077 | unsigned Reg1 = MRI.getSubReg(Reg, ARM::dsub_1); |
| 1078 | O << "{" << getRegisterName(Reg0) << "[], " << getRegisterName(Reg1) << "[]}"; |
Jim Grosbach | 13af222 | 2011-11-30 18:21:25 +0000 | [diff] [blame] | 1079 | } |
Jim Grosbach | e90ac9b | 2011-12-14 19:35:22 +0000 | [diff] [blame] | 1080 | |
Jim Grosbach | 5e59f7e | 2012-01-24 23:47:04 +0000 | [diff] [blame] | 1081 | void ARMInstPrinter::printVectorListThreeAllLanes(const MCInst *MI, |
| 1082 | unsigned OpNum, |
| 1083 | raw_ostream &O) { |
| 1084 | // Normally, it's not safe to use register enum values directly with |
| 1085 | // addition to get the next register, but for VFP registers, the |
| 1086 | // sort order is guaranteed because they're all of the form D<n>. |
| 1087 | O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << "[], " |
| 1088 | << getRegisterName(MI->getOperand(OpNum).getReg() + 1) << "[], " |
| 1089 | << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << "[]}"; |
| 1090 | } |
| 1091 | |
Jim Grosbach | a57a36a | 2012-01-25 00:01:08 +0000 | [diff] [blame] | 1092 | void ARMInstPrinter::printVectorListFourAllLanes(const MCInst *MI, |
| 1093 | unsigned OpNum, |
| 1094 | raw_ostream &O) { |
| 1095 | // Normally, it's not safe to use register enum values directly with |
| 1096 | // addition to get the next register, but for VFP registers, the |
| 1097 | // sort order is guaranteed because they're all of the form D<n>. |
| 1098 | O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << "[], " |
| 1099 | << getRegisterName(MI->getOperand(OpNum).getReg() + 1) << "[], " |
| 1100 | << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << "[], " |
| 1101 | << getRegisterName(MI->getOperand(OpNum).getReg() + 3) << "[]}"; |
| 1102 | } |
| 1103 | |
Jim Grosbach | 3471d4f | 2011-12-21 00:38:54 +0000 | [diff] [blame] | 1104 | void ARMInstPrinter::printVectorListTwoSpacedAllLanes(const MCInst *MI, |
| 1105 | unsigned OpNum, |
| 1106 | raw_ostream &O) { |
Jim Grosbach | 4d0983a | 2012-03-06 23:10:38 +0000 | [diff] [blame^] | 1107 | unsigned Reg = MI->getOperand(OpNum).getReg(); |
| 1108 | unsigned Reg0 = MRI.getSubReg(Reg, ARM::dsub_0); |
| 1109 | unsigned Reg1 = MRI.getSubReg(Reg, ARM::dsub_2); |
| 1110 | O << "{" << getRegisterName(Reg0) << "[], " << getRegisterName(Reg1) << "[]}"; |
Jim Grosbach | 3471d4f | 2011-12-21 00:38:54 +0000 | [diff] [blame] | 1111 | } |
| 1112 | |
Jim Grosbach | 5e59f7e | 2012-01-24 23:47:04 +0000 | [diff] [blame] | 1113 | void ARMInstPrinter::printVectorListThreeSpacedAllLanes(const MCInst *MI, |
| 1114 | unsigned OpNum, |
| 1115 | raw_ostream &O) { |
| 1116 | // Normally, it's not safe to use register enum values directly with |
| 1117 | // addition to get the next register, but for VFP registers, the |
| 1118 | // sort order is guaranteed because they're all of the form D<n>. |
| 1119 | O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << "[], " |
| 1120 | << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << "[], " |
Jim Grosbach | a57a36a | 2012-01-25 00:01:08 +0000 | [diff] [blame] | 1121 | << getRegisterName(MI->getOperand(OpNum).getReg() + 4) << "[]}"; |
| 1122 | } |
| 1123 | |
| 1124 | void ARMInstPrinter::printVectorListFourSpacedAllLanes(const MCInst *MI, |
| 1125 | unsigned OpNum, |
| 1126 | raw_ostream &O) { |
| 1127 | // Normally, it's not safe to use register enum values directly with |
| 1128 | // addition to get the next register, but for VFP registers, the |
| 1129 | // sort order is guaranteed because they're all of the form D<n>. |
| 1130 | O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << "[], " |
| 1131 | << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << "[], " |
| 1132 | << getRegisterName(MI->getOperand(OpNum).getReg() + 4) << "[], " |
| 1133 | << getRegisterName(MI->getOperand(OpNum).getReg() + 6) << "[]}"; |
Jim Grosbach | 5e59f7e | 2012-01-24 23:47:04 +0000 | [diff] [blame] | 1134 | } |
| 1135 | |
Jim Grosbach | c387fc6 | 2012-01-23 23:20:46 +0000 | [diff] [blame] | 1136 | void ARMInstPrinter::printVectorListThreeSpaced(const MCInst *MI, |
| 1137 | unsigned OpNum, |
| 1138 | raw_ostream &O) { |
| 1139 | // Normally, it's not safe to use register enum values directly with |
| 1140 | // addition to get the next register, but for VFP registers, the |
| 1141 | // sort order is guaranteed because they're all of the form D<n>. |
| 1142 | O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << ", " |
| 1143 | << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << ", " |
| 1144 | << getRegisterName(MI->getOperand(OpNum).getReg() + 4) << "}"; |
| 1145 | } |
Jim Grosbach | 8abe7e3 | 2012-01-24 00:43:17 +0000 | [diff] [blame] | 1146 | |
| 1147 | void ARMInstPrinter::printVectorListFourSpaced(const MCInst *MI, |
| 1148 | unsigned OpNum, |
| 1149 | raw_ostream &O) { |
| 1150 | // Normally, it's not safe to use register enum values directly with |
| 1151 | // addition to get the next register, but for VFP registers, the |
| 1152 | // sort order is guaranteed because they're all of the form D<n>. |
| 1153 | O << "{" << getRegisterName(MI->getOperand(OpNum).getReg()) << ", " |
| 1154 | << getRegisterName(MI->getOperand(OpNum).getReg() + 2) << ", " |
| 1155 | << getRegisterName(MI->getOperand(OpNum).getReg() + 4) << ", " |
| 1156 | << getRegisterName(MI->getOperand(OpNum).getReg() + 6) << "}"; |
| 1157 | } |