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