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