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