Jia Liu | b22310f | 2012-02-18 12:03:15 +0000 | [diff] [blame] | 1 | //===-- X86Disassembler.cpp - Disassembler for x86 and x86_64 -------------===// |
Daniel Dunbar | 900f2ce | 2009-11-25 06:53:08 +0000 | [diff] [blame] | 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 | //===----------------------------------------------------------------------===// |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 9 | // |
| 10 | // This file is part of the X86 Disassembler. |
| 11 | // It contains code to translate the data produced by the decoder into |
| 12 | // MCInsts. |
| 13 | // Documentation for the disassembler can be found in X86Disassembler.h. |
| 14 | // |
| 15 | //===----------------------------------------------------------------------===// |
| 16 | |
| 17 | #include "X86Disassembler.h" |
| 18 | #include "X86DisassemblerDecoder.h" |
Kevin Enderby | 6fbcd8d | 2012-02-23 18:18:17 +0000 | [diff] [blame] | 19 | #include "llvm/MC/MCContext.h" |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 20 | #include "llvm/MC/MCDisassembler.h" |
Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 21 | #include "llvm/MC/MCExpr.h" |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 22 | #include "llvm/MC/MCInst.h" |
Benjamin Kramer | 478e8de | 2012-02-11 14:50:54 +0000 | [diff] [blame] | 23 | #include "llvm/MC/MCInstrInfo.h" |
James Molloy | 4c493e8 | 2011-09-07 17:24:38 +0000 | [diff] [blame] | 24 | #include "llvm/MC/MCSubtargetInfo.h" |
Sean Callanan | 010b373 | 2010-04-02 21:23:51 +0000 | [diff] [blame] | 25 | #include "llvm/Support/Debug.h" |
Evan Cheng | 2bb4035 | 2011-08-24 18:08:43 +0000 | [diff] [blame] | 26 | #include "llvm/Support/TargetRegistry.h" |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 27 | #include "llvm/Support/raw_ostream.h" |
Sean Callanan | 5c8f4cd | 2009-12-22 01:11:26 +0000 | [diff] [blame] | 28 | |
Chandler Carruth | d174b72 | 2014-04-22 02:03:14 +0000 | [diff] [blame] | 29 | using namespace llvm; |
| 30 | using namespace llvm::X86Disassembler; |
| 31 | |
| 32 | #define DEBUG_TYPE "x86-disassembler" |
| 33 | |
Evan Cheng | d9997ac | 2011-06-27 18:32:37 +0000 | [diff] [blame] | 34 | #define GET_REGINFO_ENUM |
| 35 | #include "X86GenRegisterInfo.inc" |
Kevin Enderby | 5b03f72 | 2011-09-02 20:01:23 +0000 | [diff] [blame] | 36 | #define GET_INSTRINFO_ENUM |
| 37 | #include "X86GenInstrInfo.inc" |
David Woodhouse | 7dd2182 | 2014-01-20 12:02:31 +0000 | [diff] [blame] | 38 | #define GET_SUBTARGETINFO_ENUM |
| 39 | #include "X86GenSubtargetInfo.inc" |
Sean Callanan | 5c8f4cd | 2009-12-22 01:11:26 +0000 | [diff] [blame] | 40 | |
Richard Smith | 89ee75d | 2014-04-20 21:07:34 +0000 | [diff] [blame] | 41 | void llvm::X86Disassembler::Debug(const char *file, unsigned line, |
| 42 | const char *s) { |
Sean Callanan | 010b373 | 2010-04-02 21:23:51 +0000 | [diff] [blame] | 43 | dbgs() << file << ":" << line << ": " << s; |
| 44 | } |
| 45 | |
Richard Smith | 89ee75d | 2014-04-20 21:07:34 +0000 | [diff] [blame] | 46 | const char *llvm::X86Disassembler::GetInstrName(unsigned Opcode, |
| 47 | const void *mii) { |
Benjamin Kramer | 478e8de | 2012-02-11 14:50:54 +0000 | [diff] [blame] | 48 | const MCInstrInfo *MII = static_cast<const MCInstrInfo *>(mii); |
| 49 | return MII->getName(Opcode); |
| 50 | } |
| 51 | |
Richard Smith | 89ee75d | 2014-04-20 21:07:34 +0000 | [diff] [blame] | 52 | #define debug(s) DEBUG(Debug(__FILE__, __LINE__, s)); |
Sean Callanan | 010b373 | 2010-04-02 21:23:51 +0000 | [diff] [blame] | 53 | |
Michael Liao | 5bf9578 | 2014-12-04 05:20:33 +0000 | [diff] [blame] | 54 | namespace llvm { |
| 55 | |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 56 | // Fill-ins to make the compiler happy. These constants are never actually |
| 57 | // assigned; they are just filler to make an automatically-generated switch |
| 58 | // statement work. |
| 59 | namespace X86 { |
| 60 | enum { |
| 61 | BX_SI = 500, |
| 62 | BX_DI = 501, |
| 63 | BP_SI = 502, |
| 64 | BP_DI = 503, |
| 65 | sib = 504, |
| 66 | sib64 = 505 |
| 67 | }; |
| 68 | } |
| 69 | |
Sean Callanan | 5c8f4cd | 2009-12-22 01:11:26 +0000 | [diff] [blame] | 70 | extern Target TheX86_32Target, TheX86_64Target; |
| 71 | |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 72 | } |
| 73 | |
Sean Callanan | 010b373 | 2010-04-02 21:23:51 +0000 | [diff] [blame] | 74 | static bool translateInstruction(MCInst &target, |
Kevin Enderby | 6fbcd8d | 2012-02-23 18:18:17 +0000 | [diff] [blame] | 75 | InternalInstruction &source, |
| 76 | const MCDisassembler *Dis); |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 77 | |
Lang Hames | 0563ca1 | 2014-04-13 04:09:16 +0000 | [diff] [blame] | 78 | X86GenericDisassembler::X86GenericDisassembler( |
| 79 | const MCSubtargetInfo &STI, |
Lang Hames | a1bc0f5 | 2014-04-15 04:40:56 +0000 | [diff] [blame] | 80 | MCContext &Ctx, |
Lang Hames | 0563ca1 | 2014-04-13 04:09:16 +0000 | [diff] [blame] | 81 | std::unique_ptr<const MCInstrInfo> MII) |
Lang Hames | a1bc0f5 | 2014-04-15 04:40:56 +0000 | [diff] [blame] | 82 | : MCDisassembler(STI, Ctx), MII(std::move(MII)) { |
David Woodhouse | 7dd2182 | 2014-01-20 12:02:31 +0000 | [diff] [blame] | 83 | switch (STI.getFeatureBits() & |
| 84 | (X86::Mode16Bit | X86::Mode32Bit | X86::Mode64Bit)) { |
| 85 | case X86::Mode16Bit: |
| 86 | fMode = MODE_16BIT; |
| 87 | break; |
| 88 | case X86::Mode32Bit: |
| 89 | fMode = MODE_32BIT; |
| 90 | break; |
| 91 | case X86::Mode64Bit: |
| 92 | fMode = MODE_64BIT; |
| 93 | break; |
| 94 | default: |
| 95 | llvm_unreachable("Invalid CPU mode"); |
| 96 | } |
| 97 | } |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 98 | |
Rafael Espindola | 7fc5b87 | 2014-11-12 02:04:27 +0000 | [diff] [blame] | 99 | struct Region { |
| 100 | ArrayRef<uint8_t> Bytes; |
| 101 | uint64_t Base; |
| 102 | Region(ArrayRef<uint8_t> Bytes, uint64_t Base) : Bytes(Bytes), Base(Base) {} |
| 103 | }; |
| 104 | |
| 105 | /// A callback function that wraps the readByte method from Region. |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 106 | /// |
Rafael Espindola | 4aa6bea | 2014-11-10 18:11:10 +0000 | [diff] [blame] | 107 | /// @param Arg - The generic callback parameter. In this case, this should |
Rafael Espindola | 7fc5b87 | 2014-11-12 02:04:27 +0000 | [diff] [blame] | 108 | /// be a pointer to a Region. |
Rafael Espindola | 4aa6bea | 2014-11-10 18:11:10 +0000 | [diff] [blame] | 109 | /// @param Byte - A pointer to the byte to be read. |
| 110 | /// @param Address - The address to be read. |
| 111 | static int regionReader(const void *Arg, uint8_t *Byte, uint64_t Address) { |
Rafael Espindola | 7fc5b87 | 2014-11-12 02:04:27 +0000 | [diff] [blame] | 112 | auto *R = static_cast<const Region *>(Arg); |
| 113 | ArrayRef<uint8_t> Bytes = R->Bytes; |
| 114 | unsigned Index = Address - R->Base; |
| 115 | if (Bytes.size() <= Index) |
| 116 | return -1; |
| 117 | *Byte = Bytes[Index]; |
| 118 | return 0; |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | /// logger - a callback function that wraps the operator<< method from |
| 122 | /// raw_ostream. |
| 123 | /// |
| 124 | /// @param arg - The generic callback parameter. This should be a pointe |
| 125 | /// to a raw_ostream. |
| 126 | /// @param log - A string to be logged. logger() adds a newline. |
| 127 | static void logger(void* arg, const char* log) { |
| 128 | if (!arg) |
| 129 | return; |
Michael Liao | 5bf9578 | 2014-12-04 05:20:33 +0000 | [diff] [blame] | 130 | |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 131 | raw_ostream &vStream = *(static_cast<raw_ostream*>(arg)); |
| 132 | vStream << log << "\n"; |
Michael Liao | 5bf9578 | 2014-12-04 05:20:33 +0000 | [diff] [blame] | 133 | } |
| 134 | |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 135 | // |
| 136 | // Public interface for the disassembler |
| 137 | // |
| 138 | |
Rafael Espindola | 4aa6bea | 2014-11-10 18:11:10 +0000 | [diff] [blame] | 139 | MCDisassembler::DecodeStatus X86GenericDisassembler::getInstruction( |
Rafael Espindola | 7fc5b87 | 2014-11-12 02:04:27 +0000 | [diff] [blame] | 140 | MCInst &Instr, uint64_t &Size, ArrayRef<uint8_t> Bytes, uint64_t Address, |
Rafael Espindola | 4aa6bea | 2014-11-10 18:11:10 +0000 | [diff] [blame] | 141 | raw_ostream &VStream, raw_ostream &CStream) const { |
| 142 | CommentStream = &CStream; |
Kevin Enderby | 6fbcd8d | 2012-02-23 18:18:17 +0000 | [diff] [blame] | 143 | |
Rafael Espindola | 4aa6bea | 2014-11-10 18:11:10 +0000 | [diff] [blame] | 144 | InternalInstruction InternalInstr; |
Benjamin Kramer | e5e189f | 2011-09-21 21:47:35 +0000 | [diff] [blame] | 145 | |
Rafael Espindola | 4aa6bea | 2014-11-10 18:11:10 +0000 | [diff] [blame] | 146 | dlog_t LoggerFn = logger; |
| 147 | if (&VStream == &nulls()) |
| 148 | LoggerFn = nullptr; // Disable logging completely if it's going to nulls(). |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 149 | |
Rafael Espindola | 7fc5b87 | 2014-11-12 02:04:27 +0000 | [diff] [blame] | 150 | Region R(Bytes, Address); |
| 151 | |
| 152 | int Ret = decodeInstruction(&InternalInstr, regionReader, (const void *)&R, |
| 153 | LoggerFn, (void *)&VStream, |
Rafael Espindola | 4aa6bea | 2014-11-10 18:11:10 +0000 | [diff] [blame] | 154 | (const void *)MII.get(), Address, fMode); |
| 155 | |
| 156 | if (Ret) { |
| 157 | Size = InternalInstr.readerCursor - Address; |
Owen Anderson | a4043c4 | 2011-08-17 17:44:15 +0000 | [diff] [blame] | 158 | return Fail; |
Rafael Espindola | 4aa6bea | 2014-11-10 18:11:10 +0000 | [diff] [blame] | 159 | } else { |
| 160 | Size = InternalInstr.length; |
| 161 | return (!translateInstruction(Instr, InternalInstr, this)) ? Success : Fail; |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 162 | } |
| 163 | } |
| 164 | |
| 165 | // |
| 166 | // Private code that translates from struct InternalInstructions to MCInsts. |
| 167 | // |
| 168 | |
| 169 | /// translateRegister - Translates an internal register to the appropriate LLVM |
| 170 | /// register, and appends it as an operand to an MCInst. |
| 171 | /// |
| 172 | /// @param mcInst - The MCInst to append to. |
| 173 | /// @param reg - The Reg to append. |
| 174 | static void translateRegister(MCInst &mcInst, Reg reg) { |
| 175 | #define ENTRY(x) X86::x, |
| 176 | uint8_t llvmRegnums[] = { |
| 177 | ALL_REGS |
| 178 | 0 |
| 179 | }; |
| 180 | #undef ENTRY |
| 181 | |
| 182 | uint8_t llvmRegnum = llvmRegnums[reg]; |
| 183 | mcInst.addOperand(MCOperand::CreateReg(llvmRegnum)); |
| 184 | } |
| 185 | |
Kevin Enderby | 6fbcd8d | 2012-02-23 18:18:17 +0000 | [diff] [blame] | 186 | /// tryAddingSymbolicOperand - trys to add a symbolic operand in place of the |
Michael Liao | 5bf9578 | 2014-12-04 05:20:33 +0000 | [diff] [blame] | 187 | /// immediate Value in the MCInst. |
Kevin Enderby | 6fbcd8d | 2012-02-23 18:18:17 +0000 | [diff] [blame] | 188 | /// |
| 189 | /// @param Value - The immediate Value, has had any PC adjustment made by |
| 190 | /// the caller. |
| 191 | /// @param isBranch - If the instruction is a branch instruction |
| 192 | /// @param Address - The starting address of the instruction |
| 193 | /// @param Offset - The byte offset to this immediate in the instruction |
| 194 | /// @param Width - The byte width of this immediate in the instruction |
| 195 | /// |
| 196 | /// If the getOpInfo() function was set when setupForSymbolicDisassembly() was |
| 197 | /// called then that function is called to get any symbolic information for the |
| 198 | /// immediate in the instruction using the Address, Offset and Width. If that |
Michael Liao | 5bf9578 | 2014-12-04 05:20:33 +0000 | [diff] [blame] | 199 | /// returns non-zero then the symbolic information it returns is used to create |
Kevin Enderby | 6fbcd8d | 2012-02-23 18:18:17 +0000 | [diff] [blame] | 200 | /// an MCExpr and that is added as an operand to the MCInst. If getOpInfo() |
| 201 | /// returns zero and isBranch is true then a symbol look up for immediate Value |
| 202 | /// is done and if a symbol is found an MCExpr is created with that, else |
| 203 | /// an MCExpr with the immediate Value is created. This function returns true |
| 204 | /// if it adds an operand to the MCInst and false otherwise. |
| 205 | static bool tryAddingSymbolicOperand(int64_t Value, bool isBranch, |
| 206 | uint64_t Address, uint64_t Offset, |
Michael Liao | 5bf9578 | 2014-12-04 05:20:33 +0000 | [diff] [blame] | 207 | uint64_t Width, MCInst &MI, |
| 208 | const MCDisassembler *Dis) { |
Ahmed Bougacha | ad1084d | 2013-05-24 00:39:57 +0000 | [diff] [blame] | 209 | return Dis->tryAddingSymbolicOperand(MI, Value, Address, isBranch, |
| 210 | Offset, Width); |
Kevin Enderby | 6fbcd8d | 2012-02-23 18:18:17 +0000 | [diff] [blame] | 211 | } |
| 212 | |
Kevin Enderby | b119c08 | 2012-02-29 22:58:34 +0000 | [diff] [blame] | 213 | /// tryAddingPcLoadReferenceComment - trys to add a comment as to what is being |
| 214 | /// referenced by a load instruction with the base register that is the rip. |
| 215 | /// These can often be addresses in a literal pool. The Address of the |
| 216 | /// instruction and its immediate Value are used to determine the address |
| 217 | /// being referenced in the literal pool entry. The SymbolLookUp call back will |
Michael Liao | 5bf9578 | 2014-12-04 05:20:33 +0000 | [diff] [blame] | 218 | /// return a pointer to a literal 'C' string if the referenced address is an |
Kevin Enderby | b119c08 | 2012-02-29 22:58:34 +0000 | [diff] [blame] | 219 | /// address into a section with 'C' string literals. |
| 220 | static void tryAddingPcLoadReferenceComment(uint64_t Address, uint64_t Value, |
| 221 | const void *Decoder) { |
| 222 | const MCDisassembler *Dis = static_cast<const MCDisassembler*>(Decoder); |
Ahmed Bougacha | ad1084d | 2013-05-24 00:39:57 +0000 | [diff] [blame] | 223 | Dis->tryAddingPcLoadReferenceComment(Value, Address); |
Kevin Enderby | b119c08 | 2012-02-29 22:58:34 +0000 | [diff] [blame] | 224 | } |
| 225 | |
Craig Topper | 35da3d1 | 2014-01-16 07:36:58 +0000 | [diff] [blame] | 226 | static const uint8_t segmentRegnums[SEG_OVERRIDE_max] = { |
| 227 | 0, // SEG_OVERRIDE_NONE |
| 228 | X86::CS, |
| 229 | X86::SS, |
| 230 | X86::DS, |
| 231 | X86::ES, |
| 232 | X86::FS, |
| 233 | X86::GS |
| 234 | }; |
| 235 | |
David Woodhouse | 2ef8d9c | 2014-01-22 15:08:08 +0000 | [diff] [blame] | 236 | /// translateSrcIndex - Appends a source index operand to an MCInst. |
| 237 | /// |
| 238 | /// @param mcInst - The MCInst to append to. |
David Woodhouse | 2ef8d9c | 2014-01-22 15:08:08 +0000 | [diff] [blame] | 239 | /// @param insn - The internal instruction. |
| 240 | static bool translateSrcIndex(MCInst &mcInst, InternalInstruction &insn) { |
| 241 | unsigned baseRegNo; |
| 242 | |
| 243 | if (insn.mode == MODE_64BIT) |
| 244 | baseRegNo = insn.prefixPresent[0x67] ? X86::ESI : X86::RSI; |
| 245 | else if (insn.mode == MODE_32BIT) |
| 246 | baseRegNo = insn.prefixPresent[0x67] ? X86::SI : X86::ESI; |
David Woodhouse | fee418c | 2014-01-22 15:31:29 +0000 | [diff] [blame] | 247 | else { |
| 248 | assert(insn.mode == MODE_16BIT); |
David Woodhouse | 2ef8d9c | 2014-01-22 15:08:08 +0000 | [diff] [blame] | 249 | baseRegNo = insn.prefixPresent[0x67] ? X86::ESI : X86::SI; |
David Woodhouse | fee418c | 2014-01-22 15:31:29 +0000 | [diff] [blame] | 250 | } |
David Woodhouse | 2ef8d9c | 2014-01-22 15:08:08 +0000 | [diff] [blame] | 251 | MCOperand baseReg = MCOperand::CreateReg(baseRegNo); |
| 252 | mcInst.addOperand(baseReg); |
| 253 | |
| 254 | MCOperand segmentReg; |
| 255 | segmentReg = MCOperand::CreateReg(segmentRegnums[insn.segmentOverride]); |
| 256 | mcInst.addOperand(segmentReg); |
| 257 | return false; |
| 258 | } |
| 259 | |
David Woodhouse | b33c2ef | 2014-01-22 15:08:21 +0000 | [diff] [blame] | 260 | /// translateDstIndex - Appends a destination index operand to an MCInst. |
| 261 | /// |
| 262 | /// @param mcInst - The MCInst to append to. |
David Woodhouse | b33c2ef | 2014-01-22 15:08:21 +0000 | [diff] [blame] | 263 | /// @param insn - The internal instruction. |
| 264 | |
| 265 | static bool translateDstIndex(MCInst &mcInst, InternalInstruction &insn) { |
| 266 | unsigned baseRegNo; |
| 267 | |
| 268 | if (insn.mode == MODE_64BIT) |
| 269 | baseRegNo = insn.prefixPresent[0x67] ? X86::EDI : X86::RDI; |
| 270 | else if (insn.mode == MODE_32BIT) |
| 271 | baseRegNo = insn.prefixPresent[0x67] ? X86::DI : X86::EDI; |
David Woodhouse | fee418c | 2014-01-22 15:31:29 +0000 | [diff] [blame] | 272 | else { |
| 273 | assert(insn.mode == MODE_16BIT); |
David Woodhouse | b33c2ef | 2014-01-22 15:08:21 +0000 | [diff] [blame] | 274 | baseRegNo = insn.prefixPresent[0x67] ? X86::EDI : X86::DI; |
David Woodhouse | fee418c | 2014-01-22 15:31:29 +0000 | [diff] [blame] | 275 | } |
David Woodhouse | b33c2ef | 2014-01-22 15:08:21 +0000 | [diff] [blame] | 276 | MCOperand baseReg = MCOperand::CreateReg(baseRegNo); |
| 277 | mcInst.addOperand(baseReg); |
| 278 | return false; |
| 279 | } |
| 280 | |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 281 | /// translateImmediate - Appends an immediate operand to an MCInst. |
| 282 | /// |
| 283 | /// @param mcInst - The MCInst to append to. |
| 284 | /// @param immediate - The immediate value to append. |
Sean Callanan | 4cd930f | 2010-05-05 22:47:27 +0000 | [diff] [blame] | 285 | /// @param operand - The operand, as stored in the descriptor table. |
| 286 | /// @param insn - The internal instruction. |
Benjamin Kramer | de0a4fb | 2010-10-23 09:10:44 +0000 | [diff] [blame] | 287 | static void translateImmediate(MCInst &mcInst, uint64_t immediate, |
| 288 | const OperandSpecifier &operand, |
Kevin Enderby | 6fbcd8d | 2012-02-23 18:18:17 +0000 | [diff] [blame] | 289 | InternalInstruction &insn, |
Michael Liao | 5bf9578 | 2014-12-04 05:20:33 +0000 | [diff] [blame] | 290 | const MCDisassembler *Dis) { |
Sean Callanan | 4cd930f | 2010-05-05 22:47:27 +0000 | [diff] [blame] | 291 | // Sign-extend the immediate if necessary. |
| 292 | |
Craig Topper | 6dedbae | 2012-03-04 02:16:41 +0000 | [diff] [blame] | 293 | OperandType type = (OperandType)operand.type; |
Sean Callanan | 4cd930f | 2010-05-05 22:47:27 +0000 | [diff] [blame] | 294 | |
Kevin Enderby | ec4bd31 | 2012-04-18 23:12:11 +0000 | [diff] [blame] | 295 | bool isBranch = false; |
| 296 | uint64_t pcrel = 0; |
Sean Callanan | 4cd930f | 2010-05-05 22:47:27 +0000 | [diff] [blame] | 297 | if (type == TYPE_RELv) { |
Kevin Enderby | ec4bd31 | 2012-04-18 23:12:11 +0000 | [diff] [blame] | 298 | isBranch = true; |
| 299 | pcrel = insn.startLocation + |
Kevin Enderby | 216ac31 | 2012-07-24 21:40:01 +0000 | [diff] [blame] | 300 | insn.immediateOffset + insn.immediateSize; |
Sean Callanan | 4cd930f | 2010-05-05 22:47:27 +0000 | [diff] [blame] | 301 | switch (insn.displacementSize) { |
| 302 | default: |
| 303 | break; |
Sean Callanan | 5e8603d | 2011-02-21 21:55:05 +0000 | [diff] [blame] | 304 | case 1: |
Craig Topper | 1885417 | 2013-08-25 22:23:38 +0000 | [diff] [blame] | 305 | if(immediate & 0x80) |
| 306 | immediate |= ~(0xffull); |
Sean Callanan | 4cd930f | 2010-05-05 22:47:27 +0000 | [diff] [blame] | 307 | break; |
Sean Callanan | 5e8603d | 2011-02-21 21:55:05 +0000 | [diff] [blame] | 308 | case 2: |
Craig Topper | 1885417 | 2013-08-25 22:23:38 +0000 | [diff] [blame] | 309 | if(immediate & 0x8000) |
| 310 | immediate |= ~(0xffffull); |
Sean Callanan | 4cd930f | 2010-05-05 22:47:27 +0000 | [diff] [blame] | 311 | break; |
Sean Callanan | 5e8603d | 2011-02-21 21:55:05 +0000 | [diff] [blame] | 312 | case 4: |
Craig Topper | 1885417 | 2013-08-25 22:23:38 +0000 | [diff] [blame] | 313 | if(immediate & 0x80000000) |
| 314 | immediate |= ~(0xffffffffull); |
Sean Callanan | 4cd930f | 2010-05-05 22:47:27 +0000 | [diff] [blame] | 315 | break; |
Sean Callanan | 5e8603d | 2011-02-21 21:55:05 +0000 | [diff] [blame] | 316 | case 8: |
Sean Callanan | 4cd930f | 2010-05-05 22:47:27 +0000 | [diff] [blame] | 317 | break; |
| 318 | } |
| 319 | } |
Kevin Enderby | 5b03f72 | 2011-09-02 20:01:23 +0000 | [diff] [blame] | 320 | // By default sign-extend all X86 immediates based on their encoding. |
| 321 | else if (type == TYPE_IMM8 || type == TYPE_IMM16 || type == TYPE_IMM32 || |
Elena Demikhovsky | 8ac0bf9 | 2014-04-23 07:21:04 +0000 | [diff] [blame] | 322 | type == TYPE_IMM64 || type == TYPE_IMMv) { |
Kevin Enderby | 5b03f72 | 2011-09-02 20:01:23 +0000 | [diff] [blame] | 323 | switch (operand.encoding) { |
| 324 | default: |
| 325 | break; |
| 326 | case ENCODING_IB: |
Craig Topper | 620b50c | 2015-01-21 08:15:54 +0000 | [diff] [blame^] | 327 | if(immediate & 0x80) |
| 328 | immediate |= ~(0xffull); |
Kevin Enderby | 5b03f72 | 2011-09-02 20:01:23 +0000 | [diff] [blame] | 329 | break; |
| 330 | case ENCODING_IW: |
Craig Topper | 1885417 | 2013-08-25 22:23:38 +0000 | [diff] [blame] | 331 | if(immediate & 0x8000) |
| 332 | immediate |= ~(0xffffull); |
Kevin Enderby | 5b03f72 | 2011-09-02 20:01:23 +0000 | [diff] [blame] | 333 | break; |
| 334 | case ENCODING_ID: |
Craig Topper | 1885417 | 2013-08-25 22:23:38 +0000 | [diff] [blame] | 335 | if(immediate & 0x80000000) |
| 336 | immediate |= ~(0xffffffffull); |
Kevin Enderby | 5b03f72 | 2011-09-02 20:01:23 +0000 | [diff] [blame] | 337 | break; |
| 338 | case ENCODING_IO: |
Kevin Enderby | 5b03f72 | 2011-09-02 20:01:23 +0000 | [diff] [blame] | 339 | break; |
| 340 | } |
Craig Topper | ee9eef2 | 2014-12-26 06:36:28 +0000 | [diff] [blame] | 341 | } else if (type == TYPE_IMM3) { |
| 342 | // Check for immediates that printSSECC can't handle. |
| 343 | if (immediate >= 8) { |
| 344 | unsigned NewOpc; |
| 345 | switch (mcInst.getOpcode()) { |
| 346 | default: llvm_unreachable("unexpected opcode"); |
| 347 | case X86::CMPPDrmi: NewOpc = X86::CMPPDrmi_alt; break; |
| 348 | case X86::CMPPDrri: NewOpc = X86::CMPPDrri_alt; break; |
| 349 | case X86::CMPPSrmi: NewOpc = X86::CMPPSrmi_alt; break; |
| 350 | case X86::CMPPSrri: NewOpc = X86::CMPPSrri_alt; break; |
| 351 | case X86::CMPSDrm: NewOpc = X86::CMPSDrm_alt; break; |
| 352 | case X86::CMPSDrr: NewOpc = X86::CMPSDrr_alt; break; |
| 353 | case X86::CMPSSrm: NewOpc = X86::CMPSSrm_alt; break; |
| 354 | case X86::CMPSSrr: NewOpc = X86::CMPSSrr_alt; break; |
| 355 | } |
| 356 | // Switch opcode to the one that doesn't get special printing. |
| 357 | mcInst.setOpcode(NewOpc); |
| 358 | } |
| 359 | } else if (type == TYPE_IMM5) { |
| 360 | // Check for immediates that printAVXCC can't handle. |
| 361 | if (immediate >= 32) { |
| 362 | unsigned NewOpc; |
| 363 | switch (mcInst.getOpcode()) { |
| 364 | default: llvm_unreachable("unexpected opcode"); |
| 365 | case X86::VCMPPDrmi: NewOpc = X86::VCMPPDrmi_alt; break; |
| 366 | case X86::VCMPPDrri: NewOpc = X86::VCMPPDrri_alt; break; |
| 367 | case X86::VCMPPSrmi: NewOpc = X86::VCMPPSrmi_alt; break; |
| 368 | case X86::VCMPPSrri: NewOpc = X86::VCMPPSrri_alt; break; |
| 369 | case X86::VCMPSDrm: NewOpc = X86::VCMPSDrm_alt; break; |
| 370 | case X86::VCMPSDrr: NewOpc = X86::VCMPSDrr_alt; break; |
| 371 | case X86::VCMPSSrm: NewOpc = X86::VCMPSSrm_alt; break; |
| 372 | case X86::VCMPSSrr: NewOpc = X86::VCMPSSrr_alt; break; |
| 373 | case X86::VCMPPDYrmi: NewOpc = X86::VCMPPDYrmi_alt; break; |
| 374 | case X86::VCMPPDYrri: NewOpc = X86::VCMPPDYrri_alt; break; |
| 375 | case X86::VCMPPSYrmi: NewOpc = X86::VCMPPSYrmi_alt; break; |
| 376 | case X86::VCMPPSYrri: NewOpc = X86::VCMPPSYrri_alt; break; |
| 377 | case X86::VCMPPDZrmi: NewOpc = X86::VCMPPDZrmi_alt; break; |
| 378 | case X86::VCMPPDZrri: NewOpc = X86::VCMPPDZrri_alt; break; |
| 379 | case X86::VCMPPSZrmi: NewOpc = X86::VCMPPSZrmi_alt; break; |
| 380 | case X86::VCMPPSZrri: NewOpc = X86::VCMPPSZrri_alt; break; |
| 381 | case X86::VCMPSDZrm: NewOpc = X86::VCMPSDZrmi_alt; break; |
| 382 | case X86::VCMPSDZrr: NewOpc = X86::VCMPSDZrri_alt; break; |
| 383 | case X86::VCMPSSZrm: NewOpc = X86::VCMPSSZrmi_alt; break; |
| 384 | case X86::VCMPSSZrr: NewOpc = X86::VCMPSSZrri_alt; break; |
| 385 | } |
| 386 | // Switch opcode to the one that doesn't get special printing. |
| 387 | mcInst.setOpcode(NewOpc); |
| 388 | } |
Kevin Enderby | 5b03f72 | 2011-09-02 20:01:23 +0000 | [diff] [blame] | 389 | } |
Sean Callanan | 4cd930f | 2010-05-05 22:47:27 +0000 | [diff] [blame] | 390 | |
| 391 | switch (type) { |
Craig Topper | c30fdbc | 2012-08-31 15:40:30 +0000 | [diff] [blame] | 392 | case TYPE_XMM32: |
| 393 | case TYPE_XMM64: |
Craig Topper | 96e00e5 | 2011-09-14 05:55:28 +0000 | [diff] [blame] | 394 | case TYPE_XMM128: |
| 395 | mcInst.addOperand(MCOperand::CreateReg(X86::XMM0 + (immediate >> 4))); |
| 396 | return; |
| 397 | case TYPE_XMM256: |
| 398 | mcInst.addOperand(MCOperand::CreateReg(X86::YMM0 + (immediate >> 4))); |
| 399 | return; |
Elena Demikhovsky | 003e7d7 | 2013-07-28 08:28:38 +0000 | [diff] [blame] | 400 | case TYPE_XMM512: |
| 401 | mcInst.addOperand(MCOperand::CreateReg(X86::ZMM0 + (immediate >> 4))); |
| 402 | return; |
Sean Callanan | 4cd930f | 2010-05-05 22:47:27 +0000 | [diff] [blame] | 403 | case TYPE_REL8: |
Kevin Enderby | 6fbcd8d | 2012-02-23 18:18:17 +0000 | [diff] [blame] | 404 | isBranch = true; |
| 405 | pcrel = insn.startLocation + insn.immediateOffset + insn.immediateSize; |
Sean Callanan | 4cd930f | 2010-05-05 22:47:27 +0000 | [diff] [blame] | 406 | if(immediate & 0x80) |
| 407 | immediate |= ~(0xffull); |
| 408 | break; |
Sean Callanan | 4cd930f | 2010-05-05 22:47:27 +0000 | [diff] [blame] | 409 | case TYPE_REL32: |
| 410 | case TYPE_REL64: |
Kevin Enderby | 6fbcd8d | 2012-02-23 18:18:17 +0000 | [diff] [blame] | 411 | isBranch = true; |
| 412 | pcrel = insn.startLocation + insn.immediateOffset + insn.immediateSize; |
Sean Callanan | 4cd930f | 2010-05-05 22:47:27 +0000 | [diff] [blame] | 413 | if(immediate & 0x80000000) |
| 414 | immediate |= ~(0xffffffffull); |
| 415 | break; |
Sean Callanan | 4cd930f | 2010-05-05 22:47:27 +0000 | [diff] [blame] | 416 | default: |
| 417 | // operand is 64 bits wide. Do nothing. |
| 418 | break; |
| 419 | } |
Craig Topper | 092e2fe | 2013-08-24 19:50:11 +0000 | [diff] [blame] | 420 | |
Kevin Enderby | 6fbcd8d | 2012-02-23 18:18:17 +0000 | [diff] [blame] | 421 | if(!tryAddingSymbolicOperand(immediate + pcrel, isBranch, insn.startLocation, |
| 422 | insn.immediateOffset, insn.immediateSize, |
| 423 | mcInst, Dis)) |
| 424 | mcInst.addOperand(MCOperand::CreateImm(immediate)); |
Craig Topper | 35da3d1 | 2014-01-16 07:36:58 +0000 | [diff] [blame] | 425 | |
| 426 | if (type == TYPE_MOFFS8 || type == TYPE_MOFFS16 || |
| 427 | type == TYPE_MOFFS32 || type == TYPE_MOFFS64) { |
| 428 | MCOperand segmentReg; |
| 429 | segmentReg = MCOperand::CreateReg(segmentRegnums[insn.segmentOverride]); |
| 430 | mcInst.addOperand(segmentReg); |
| 431 | } |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 432 | } |
| 433 | |
| 434 | /// translateRMRegister - Translates a register stored in the R/M field of the |
| 435 | /// ModR/M byte to its LLVM equivalent and appends it to an MCInst. |
| 436 | /// @param mcInst - The MCInst to append to. |
| 437 | /// @param insn - The internal instruction to extract the R/M field |
| 438 | /// from. |
Sean Callanan | 010b373 | 2010-04-02 21:23:51 +0000 | [diff] [blame] | 439 | /// @return - 0 on success; -1 otherwise |
| 440 | static bool translateRMRegister(MCInst &mcInst, |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 441 | InternalInstruction &insn) { |
Sean Callanan | 010b373 | 2010-04-02 21:23:51 +0000 | [diff] [blame] | 442 | if (insn.eaBase == EA_BASE_sib || insn.eaBase == EA_BASE_sib64) { |
| 443 | debug("A R/M register operand may not have a SIB byte"); |
| 444 | return true; |
| 445 | } |
Michael Liao | 5bf9578 | 2014-12-04 05:20:33 +0000 | [diff] [blame] | 446 | |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 447 | switch (insn.eaBase) { |
Sean Callanan | 010b373 | 2010-04-02 21:23:51 +0000 | [diff] [blame] | 448 | default: |
| 449 | debug("Unexpected EA base register"); |
| 450 | return true; |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 451 | case EA_BASE_NONE: |
Sean Callanan | 010b373 | 2010-04-02 21:23:51 +0000 | [diff] [blame] | 452 | debug("EA_BASE_NONE for ModR/M base"); |
| 453 | return true; |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 454 | #define ENTRY(x) case EA_BASE_##x: |
| 455 | ALL_EA_BASES |
| 456 | #undef ENTRY |
Sean Callanan | 010b373 | 2010-04-02 21:23:51 +0000 | [diff] [blame] | 457 | debug("A R/M register operand may not have a base; " |
| 458 | "the operand must be a register."); |
| 459 | return true; |
| 460 | #define ENTRY(x) \ |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 461 | case EA_REG_##x: \ |
| 462 | mcInst.addOperand(MCOperand::CreateReg(X86::x)); break; |
| 463 | ALL_REGS |
| 464 | #undef ENTRY |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 465 | } |
Michael Liao | 5bf9578 | 2014-12-04 05:20:33 +0000 | [diff] [blame] | 466 | |
Sean Callanan | 010b373 | 2010-04-02 21:23:51 +0000 | [diff] [blame] | 467 | return false; |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 468 | } |
| 469 | |
| 470 | /// translateRMMemory - Translates a memory operand stored in the Mod and R/M |
| 471 | /// fields of an internal instruction (and possibly its SIB byte) to a memory |
| 472 | /// operand in LLVM's format, and appends it to an MCInst. |
| 473 | /// |
| 474 | /// @param mcInst - The MCInst to append to. |
| 475 | /// @param insn - The instruction to extract Mod, R/M, and SIB fields |
| 476 | /// from. |
Sean Callanan | 010b373 | 2010-04-02 21:23:51 +0000 | [diff] [blame] | 477 | /// @return - 0 on success; nonzero otherwise |
Kevin Enderby | 6fbcd8d | 2012-02-23 18:18:17 +0000 | [diff] [blame] | 478 | static bool translateRMMemory(MCInst &mcInst, InternalInstruction &insn, |
Michael Liao | 5bf9578 | 2014-12-04 05:20:33 +0000 | [diff] [blame] | 479 | const MCDisassembler *Dis) { |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 480 | // Addresses in an MCInst are represented as five operands: |
Michael Liao | 5bf9578 | 2014-12-04 05:20:33 +0000 | [diff] [blame] | 481 | // 1. basereg (register) The R/M base, or (if there is a SIB) the |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 482 | // SIB base |
Michael Liao | 5bf9578 | 2014-12-04 05:20:33 +0000 | [diff] [blame] | 483 | // 2. scaleamount (immediate) 1, or (if there is a SIB) the specified |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 484 | // scale amount |
| 485 | // 3. indexreg (register) x86_registerNONE, or (if there is a SIB) |
Michael Liao | 5bf9578 | 2014-12-04 05:20:33 +0000 | [diff] [blame] | 486 | // the index (which is multiplied by the |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 487 | // scale amount) |
| 488 | // 4. displacement (immediate) 0, or the displacement if there is one |
| 489 | // 5. segmentreg (register) x86_registerNONE for now, but could be set |
| 490 | // if we have segment overrides |
Michael Liao | 5bf9578 | 2014-12-04 05:20:33 +0000 | [diff] [blame] | 491 | |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 492 | MCOperand baseReg; |
| 493 | MCOperand scaleAmount; |
| 494 | MCOperand indexReg; |
| 495 | MCOperand displacement; |
| 496 | MCOperand segmentReg; |
Kevin Enderby | 6fbcd8d | 2012-02-23 18:18:17 +0000 | [diff] [blame] | 497 | uint64_t pcrel = 0; |
Michael Liao | 5bf9578 | 2014-12-04 05:20:33 +0000 | [diff] [blame] | 498 | |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 499 | if (insn.eaBase == EA_BASE_sib || insn.eaBase == EA_BASE_sib64) { |
| 500 | if (insn.sibBase != SIB_BASE_NONE) { |
| 501 | switch (insn.sibBase) { |
| 502 | default: |
Sean Callanan | 010b373 | 2010-04-02 21:23:51 +0000 | [diff] [blame] | 503 | debug("Unexpected sibBase"); |
| 504 | return true; |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 505 | #define ENTRY(x) \ |
Sean Callanan | 36eab80 | 2009-12-22 21:12:55 +0000 | [diff] [blame] | 506 | case SIB_BASE_##x: \ |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 507 | baseReg = MCOperand::CreateReg(X86::x); break; |
| 508 | ALL_SIB_BASES |
| 509 | #undef ENTRY |
| 510 | } |
| 511 | } else { |
| 512 | baseReg = MCOperand::CreateReg(0); |
| 513 | } |
Manman Ren | a098204 | 2012-06-26 19:47:59 +0000 | [diff] [blame] | 514 | |
| 515 | // Check whether we are handling VSIB addressing mode for GATHER. |
| 516 | // If sibIndex was set to SIB_INDEX_NONE, index offset is 4 and |
| 517 | // we should use SIB_INDEX_XMM4|YMM4 for VSIB. |
| 518 | // I don't see a way to get the correct IndexReg in readSIB: |
| 519 | // We can tell whether it is VSIB or SIB after instruction ID is decoded, |
| 520 | // but instruction ID may not be decoded yet when calling readSIB. |
| 521 | uint32_t Opcode = mcInst.getOpcode(); |
Manman Ren | 98a5bf2 | 2012-06-29 00:54:20 +0000 | [diff] [blame] | 522 | bool IndexIs128 = (Opcode == X86::VGATHERDPDrm || |
| 523 | Opcode == X86::VGATHERDPDYrm || |
| 524 | Opcode == X86::VGATHERQPDrm || |
| 525 | Opcode == X86::VGATHERDPSrm || |
| 526 | Opcode == X86::VGATHERQPSrm || |
| 527 | Opcode == X86::VPGATHERDQrm || |
| 528 | Opcode == X86::VPGATHERDQYrm || |
| 529 | Opcode == X86::VPGATHERQQrm || |
| 530 | Opcode == X86::VPGATHERDDrm || |
| 531 | Opcode == X86::VPGATHERQDrm); |
| 532 | bool IndexIs256 = (Opcode == X86::VGATHERQPDYrm || |
| 533 | Opcode == X86::VGATHERDPSYrm || |
| 534 | Opcode == X86::VGATHERQPSYrm || |
Elena Demikhovsky | 371e363 | 2013-12-25 11:40:51 +0000 | [diff] [blame] | 535 | Opcode == X86::VGATHERDPDZrm || |
| 536 | Opcode == X86::VPGATHERDQZrm || |
Manman Ren | 98a5bf2 | 2012-06-29 00:54:20 +0000 | [diff] [blame] | 537 | Opcode == X86::VPGATHERQQYrm || |
| 538 | Opcode == X86::VPGATHERDDYrm || |
| 539 | Opcode == X86::VPGATHERQDYrm); |
Elena Demikhovsky | 371e363 | 2013-12-25 11:40:51 +0000 | [diff] [blame] | 540 | bool IndexIs512 = (Opcode == X86::VGATHERQPDZrm || |
| 541 | Opcode == X86::VGATHERDPSZrm || |
| 542 | Opcode == X86::VGATHERQPSZrm || |
| 543 | Opcode == X86::VPGATHERQQZrm || |
| 544 | Opcode == X86::VPGATHERDDZrm || |
| 545 | Opcode == X86::VPGATHERQDZrm); |
| 546 | if (IndexIs128 || IndexIs256 || IndexIs512) { |
Manman Ren | a098204 | 2012-06-26 19:47:59 +0000 | [diff] [blame] | 547 | unsigned IndexOffset = insn.sibIndex - |
| 548 | (insn.addressSize == 8 ? SIB_INDEX_RAX:SIB_INDEX_EAX); |
Elena Demikhovsky | 371e363 | 2013-12-25 11:40:51 +0000 | [diff] [blame] | 549 | SIBIndex IndexBase = IndexIs512 ? SIB_INDEX_ZMM0 : |
| 550 | IndexIs256 ? SIB_INDEX_YMM0 : SIB_INDEX_XMM0; |
Michael Liao | 5bf9578 | 2014-12-04 05:20:33 +0000 | [diff] [blame] | 551 | insn.sibIndex = (SIBIndex)(IndexBase + |
Manman Ren | a098204 | 2012-06-26 19:47:59 +0000 | [diff] [blame] | 552 | (insn.sibIndex == SIB_INDEX_NONE ? 4 : IndexOffset)); |
| 553 | } |
| 554 | |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 555 | if (insn.sibIndex != SIB_INDEX_NONE) { |
| 556 | switch (insn.sibIndex) { |
| 557 | default: |
Sean Callanan | 010b373 | 2010-04-02 21:23:51 +0000 | [diff] [blame] | 558 | debug("Unexpected sibIndex"); |
| 559 | return true; |
Sean Callanan | 36eab80 | 2009-12-22 21:12:55 +0000 | [diff] [blame] | 560 | #define ENTRY(x) \ |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 561 | case SIB_INDEX_##x: \ |
| 562 | indexReg = MCOperand::CreateReg(X86::x); break; |
| 563 | EA_BASES_32BIT |
| 564 | EA_BASES_64BIT |
Manman Ren | a098204 | 2012-06-26 19:47:59 +0000 | [diff] [blame] | 565 | REGS_XMM |
| 566 | REGS_YMM |
Elena Demikhovsky | 003e7d7 | 2013-07-28 08:28:38 +0000 | [diff] [blame] | 567 | REGS_ZMM |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 568 | #undef ENTRY |
| 569 | } |
| 570 | } else { |
| 571 | indexReg = MCOperand::CreateReg(0); |
| 572 | } |
Michael Liao | 5bf9578 | 2014-12-04 05:20:33 +0000 | [diff] [blame] | 573 | |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 574 | scaleAmount = MCOperand::CreateImm(insn.sibScale); |
| 575 | } else { |
| 576 | switch (insn.eaBase) { |
| 577 | case EA_BASE_NONE: |
Sean Callanan | 010b373 | 2010-04-02 21:23:51 +0000 | [diff] [blame] | 578 | if (insn.eaDisplacement == EA_DISP_NONE) { |
| 579 | debug("EA_BASE_NONE and EA_DISP_NONE for ModR/M base"); |
| 580 | return true; |
| 581 | } |
Kevin Enderby | 6fbcd8d | 2012-02-23 18:18:17 +0000 | [diff] [blame] | 582 | if (insn.mode == MODE_64BIT){ |
| 583 | pcrel = insn.startLocation + |
| 584 | insn.displacementOffset + insn.displacementSize; |
Kevin Enderby | b119c08 | 2012-02-29 22:58:34 +0000 | [diff] [blame] | 585 | tryAddingPcLoadReferenceComment(insn.startLocation + |
| 586 | insn.displacementOffset, |
| 587 | insn.displacement + pcrel, Dis); |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 588 | baseReg = MCOperand::CreateReg(X86::RIP); // Section 2.2.1.6 |
Kevin Enderby | 6fbcd8d | 2012-02-23 18:18:17 +0000 | [diff] [blame] | 589 | } |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 590 | else |
| 591 | baseReg = MCOperand::CreateReg(0); |
Michael Liao | 5bf9578 | 2014-12-04 05:20:33 +0000 | [diff] [blame] | 592 | |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 593 | indexReg = MCOperand::CreateReg(0); |
| 594 | break; |
| 595 | case EA_BASE_BX_SI: |
| 596 | baseReg = MCOperand::CreateReg(X86::BX); |
| 597 | indexReg = MCOperand::CreateReg(X86::SI); |
| 598 | break; |
| 599 | case EA_BASE_BX_DI: |
| 600 | baseReg = MCOperand::CreateReg(X86::BX); |
| 601 | indexReg = MCOperand::CreateReg(X86::DI); |
| 602 | break; |
| 603 | case EA_BASE_BP_SI: |
| 604 | baseReg = MCOperand::CreateReg(X86::BP); |
| 605 | indexReg = MCOperand::CreateReg(X86::SI); |
| 606 | break; |
| 607 | case EA_BASE_BP_DI: |
| 608 | baseReg = MCOperand::CreateReg(X86::BP); |
| 609 | indexReg = MCOperand::CreateReg(X86::DI); |
| 610 | break; |
| 611 | default: |
| 612 | indexReg = MCOperand::CreateReg(0); |
| 613 | switch (insn.eaBase) { |
| 614 | default: |
Sean Callanan | 010b373 | 2010-04-02 21:23:51 +0000 | [diff] [blame] | 615 | debug("Unexpected eaBase"); |
| 616 | return true; |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 617 | // Here, we will use the fill-ins defined above. However, |
| 618 | // BX_SI, BX_DI, BP_SI, and BP_DI are all handled above and |
| 619 | // sib and sib64 were handled in the top-level if, so they're only |
| 620 | // placeholders to keep the compiler happy. |
| 621 | #define ENTRY(x) \ |
| 622 | case EA_BASE_##x: \ |
Michael Liao | 5bf9578 | 2014-12-04 05:20:33 +0000 | [diff] [blame] | 623 | baseReg = MCOperand::CreateReg(X86::x); break; |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 624 | ALL_EA_BASES |
| 625 | #undef ENTRY |
| 626 | #define ENTRY(x) case EA_REG_##x: |
| 627 | ALL_REGS |
| 628 | #undef ENTRY |
Sean Callanan | 010b373 | 2010-04-02 21:23:51 +0000 | [diff] [blame] | 629 | debug("A R/M memory operand may not be a register; " |
| 630 | "the base field must be a base."); |
| 631 | return true; |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 632 | } |
| 633 | } |
Michael Liao | 5bf9578 | 2014-12-04 05:20:33 +0000 | [diff] [blame] | 634 | |
Sean Callanan | 36eab80 | 2009-12-22 21:12:55 +0000 | [diff] [blame] | 635 | scaleAmount = MCOperand::CreateImm(1); |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 636 | } |
Michael Liao | 5bf9578 | 2014-12-04 05:20:33 +0000 | [diff] [blame] | 637 | |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 638 | displacement = MCOperand::CreateImm(insn.displacement); |
Craig Topper | 35da3d1 | 2014-01-16 07:36:58 +0000 | [diff] [blame] | 639 | |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 640 | segmentReg = MCOperand::CreateReg(segmentRegnums[insn.segmentOverride]); |
Michael Liao | 5bf9578 | 2014-12-04 05:20:33 +0000 | [diff] [blame] | 641 | |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 642 | mcInst.addOperand(baseReg); |
| 643 | mcInst.addOperand(scaleAmount); |
| 644 | mcInst.addOperand(indexReg); |
Kevin Enderby | 6fbcd8d | 2012-02-23 18:18:17 +0000 | [diff] [blame] | 645 | if(!tryAddingSymbolicOperand(insn.displacement + pcrel, false, |
| 646 | insn.startLocation, insn.displacementOffset, |
| 647 | insn.displacementSize, mcInst, Dis)) |
| 648 | mcInst.addOperand(displacement); |
Chris Lattner | 55595fb | 2010-07-13 04:23:55 +0000 | [diff] [blame] | 649 | mcInst.addOperand(segmentReg); |
Sean Callanan | 010b373 | 2010-04-02 21:23:51 +0000 | [diff] [blame] | 650 | return false; |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 651 | } |
| 652 | |
| 653 | /// translateRM - Translates an operand stored in the R/M (and possibly SIB) |
| 654 | /// byte of an instruction to LLVM form, and appends it to an MCInst. |
| 655 | /// |
| 656 | /// @param mcInst - The MCInst to append to. |
| 657 | /// @param operand - The operand, as stored in the descriptor table. |
| 658 | /// @param insn - The instruction to extract Mod, R/M, and SIB fields |
| 659 | /// from. |
Sean Callanan | 010b373 | 2010-04-02 21:23:51 +0000 | [diff] [blame] | 660 | /// @return - 0 on success; nonzero otherwise |
Benjamin Kramer | de0a4fb | 2010-10-23 09:10:44 +0000 | [diff] [blame] | 661 | static bool translateRM(MCInst &mcInst, const OperandSpecifier &operand, |
Michael Liao | 5bf9578 | 2014-12-04 05:20:33 +0000 | [diff] [blame] | 662 | InternalInstruction &insn, const MCDisassembler *Dis) { |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 663 | switch (operand.type) { |
| 664 | default: |
Sean Callanan | 010b373 | 2010-04-02 21:23:51 +0000 | [diff] [blame] | 665 | debug("Unexpected type for a R/M operand"); |
| 666 | return true; |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 667 | case TYPE_R8: |
| 668 | case TYPE_R16: |
| 669 | case TYPE_R32: |
| 670 | case TYPE_R64: |
| 671 | case TYPE_Rv: |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 672 | case TYPE_MM64: |
| 673 | case TYPE_XMM: |
| 674 | case TYPE_XMM32: |
| 675 | case TYPE_XMM64: |
| 676 | case TYPE_XMM128: |
Sean Callanan | c3fd523 | 2011-03-15 01:23:15 +0000 | [diff] [blame] | 677 | case TYPE_XMM256: |
Elena Demikhovsky | 003e7d7 | 2013-07-28 08:28:38 +0000 | [diff] [blame] | 678 | case TYPE_XMM512: |
Elena Demikhovsky | 371e363 | 2013-12-25 11:40:51 +0000 | [diff] [blame] | 679 | case TYPE_VK1: |
| 680 | case TYPE_VK8: |
| 681 | case TYPE_VK16: |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 682 | case TYPE_DEBUGREG: |
Sean Callanan | e7e1cf9 | 2010-05-06 20:59:00 +0000 | [diff] [blame] | 683 | case TYPE_CONTROLREG: |
Sean Callanan | 010b373 | 2010-04-02 21:23:51 +0000 | [diff] [blame] | 684 | return translateRMRegister(mcInst, insn); |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 685 | case TYPE_M: |
| 686 | case TYPE_M8: |
| 687 | case TYPE_M16: |
| 688 | case TYPE_M32: |
| 689 | case TYPE_M64: |
| 690 | case TYPE_M128: |
Sean Callanan | c3fd523 | 2011-03-15 01:23:15 +0000 | [diff] [blame] | 691 | case TYPE_M256: |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 692 | case TYPE_M512: |
| 693 | case TYPE_Mv: |
| 694 | case TYPE_M32FP: |
| 695 | case TYPE_M64FP: |
| 696 | case TYPE_M80FP: |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 697 | case TYPE_M1616: |
| 698 | case TYPE_M1632: |
| 699 | case TYPE_M1664: |
Sean Callanan | 36eab80 | 2009-12-22 21:12:55 +0000 | [diff] [blame] | 700 | case TYPE_LEA: |
Kevin Enderby | 6fbcd8d | 2012-02-23 18:18:17 +0000 | [diff] [blame] | 701 | return translateRMMemory(mcInst, insn, Dis); |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 702 | } |
| 703 | } |
Michael Liao | 5bf9578 | 2014-12-04 05:20:33 +0000 | [diff] [blame] | 704 | |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 705 | /// translateFPRegister - Translates a stack position on the FPU stack to its |
| 706 | /// LLVM form, and appends it to an MCInst. |
| 707 | /// |
| 708 | /// @param mcInst - The MCInst to append to. |
| 709 | /// @param stackPos - The stack position to translate. |
Craig Topper | 9155118 | 2014-01-01 15:29:32 +0000 | [diff] [blame] | 710 | static void translateFPRegister(MCInst &mcInst, |
| 711 | uint8_t stackPos) { |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 712 | mcInst.addOperand(MCOperand::CreateReg(X86::ST0 + stackPos)); |
| 713 | } |
| 714 | |
Elena Demikhovsky | 371e363 | 2013-12-25 11:40:51 +0000 | [diff] [blame] | 715 | /// translateMaskRegister - Translates a 3-bit mask register number to |
| 716 | /// LLVM form, and appends it to an MCInst. |
| 717 | /// |
| 718 | /// @param mcInst - The MCInst to append to. |
| 719 | /// @param maskRegNum - Number of mask register from 0 to 7. |
| 720 | /// @return - false on success; true otherwise. |
| 721 | static bool translateMaskRegister(MCInst &mcInst, |
| 722 | uint8_t maskRegNum) { |
| 723 | if (maskRegNum >= 8) { |
| 724 | debug("Invalid mask register number"); |
| 725 | return true; |
| 726 | } |
| 727 | |
| 728 | mcInst.addOperand(MCOperand::CreateReg(X86::K0 + maskRegNum)); |
| 729 | return false; |
| 730 | } |
| 731 | |
Michael Liao | 5bf9578 | 2014-12-04 05:20:33 +0000 | [diff] [blame] | 732 | /// translateOperand - Translates an operand stored in an internal instruction |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 733 | /// to LLVM's format and appends it to an MCInst. |
| 734 | /// |
| 735 | /// @param mcInst - The MCInst to append to. |
| 736 | /// @param operand - The operand, as stored in the descriptor table. |
| 737 | /// @param insn - The internal instruction. |
Sean Callanan | 010b373 | 2010-04-02 21:23:51 +0000 | [diff] [blame] | 738 | /// @return - false on success; true otherwise. |
Benjamin Kramer | de0a4fb | 2010-10-23 09:10:44 +0000 | [diff] [blame] | 739 | static bool translateOperand(MCInst &mcInst, const OperandSpecifier &operand, |
Kevin Enderby | 6fbcd8d | 2012-02-23 18:18:17 +0000 | [diff] [blame] | 740 | InternalInstruction &insn, |
Michael Liao | 5bf9578 | 2014-12-04 05:20:33 +0000 | [diff] [blame] | 741 | const MCDisassembler *Dis) { |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 742 | switch (operand.encoding) { |
| 743 | default: |
Sean Callanan | 010b373 | 2010-04-02 21:23:51 +0000 | [diff] [blame] | 744 | debug("Unhandled operand encoding during translation"); |
| 745 | return true; |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 746 | case ENCODING_REG: |
| 747 | translateRegister(mcInst, insn.reg); |
Sean Callanan | 010b373 | 2010-04-02 21:23:51 +0000 | [diff] [blame] | 748 | return false; |
Elena Demikhovsky | 371e363 | 2013-12-25 11:40:51 +0000 | [diff] [blame] | 749 | case ENCODING_WRITEMASK: |
| 750 | return translateMaskRegister(mcInst, insn.writemask); |
Adam Nemet | 5933c2f | 2014-07-17 17:04:56 +0000 | [diff] [blame] | 751 | CASE_ENCODING_RM: |
Kevin Enderby | 6fbcd8d | 2012-02-23 18:18:17 +0000 | [diff] [blame] | 752 | return translateRM(mcInst, operand, insn, Dis); |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 753 | case ENCODING_CB: |
| 754 | case ENCODING_CW: |
| 755 | case ENCODING_CD: |
| 756 | case ENCODING_CP: |
| 757 | case ENCODING_CO: |
| 758 | case ENCODING_CT: |
Sean Callanan | 010b373 | 2010-04-02 21:23:51 +0000 | [diff] [blame] | 759 | debug("Translation of code offsets isn't supported."); |
| 760 | return true; |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 761 | case ENCODING_IB: |
| 762 | case ENCODING_IW: |
| 763 | case ENCODING_ID: |
| 764 | case ENCODING_IO: |
| 765 | case ENCODING_Iv: |
| 766 | case ENCODING_Ia: |
Sean Callanan | 4cd930f | 2010-05-05 22:47:27 +0000 | [diff] [blame] | 767 | translateImmediate(mcInst, |
| 768 | insn.immediates[insn.numImmediatesTranslated++], |
| 769 | operand, |
Kevin Enderby | 6fbcd8d | 2012-02-23 18:18:17 +0000 | [diff] [blame] | 770 | insn, |
| 771 | Dis); |
Sean Callanan | 010b373 | 2010-04-02 21:23:51 +0000 | [diff] [blame] | 772 | return false; |
David Woodhouse | 2ef8d9c | 2014-01-22 15:08:08 +0000 | [diff] [blame] | 773 | case ENCODING_SI: |
| 774 | return translateSrcIndex(mcInst, insn); |
David Woodhouse | b33c2ef | 2014-01-22 15:08:21 +0000 | [diff] [blame] | 775 | case ENCODING_DI: |
| 776 | return translateDstIndex(mcInst, insn); |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 777 | case ENCODING_RB: |
| 778 | case ENCODING_RW: |
| 779 | case ENCODING_RD: |
| 780 | case ENCODING_RO: |
Craig Topper | 9155118 | 2014-01-01 15:29:32 +0000 | [diff] [blame] | 781 | case ENCODING_Rv: |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 782 | translateRegister(mcInst, insn.opcodeRegister); |
Sean Callanan | 010b373 | 2010-04-02 21:23:51 +0000 | [diff] [blame] | 783 | return false; |
Craig Topper | 623b0d6 | 2014-01-01 14:22:37 +0000 | [diff] [blame] | 784 | case ENCODING_FP: |
Craig Topper | 9155118 | 2014-01-01 15:29:32 +0000 | [diff] [blame] | 785 | translateFPRegister(mcInst, insn.modRM & 7); |
Sean Callanan | 010b373 | 2010-04-02 21:23:51 +0000 | [diff] [blame] | 786 | return false; |
Sean Callanan | c3fd523 | 2011-03-15 01:23:15 +0000 | [diff] [blame] | 787 | case ENCODING_VVVV: |
| 788 | translateRegister(mcInst, insn.vvvv); |
| 789 | return false; |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 790 | case ENCODING_DUP: |
Craig Topper | b8aec08 | 2012-08-01 07:39:18 +0000 | [diff] [blame] | 791 | return translateOperand(mcInst, insn.operands[operand.type - TYPE_DUP0], |
Kevin Enderby | 6fbcd8d | 2012-02-23 18:18:17 +0000 | [diff] [blame] | 792 | insn, Dis); |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 793 | } |
| 794 | } |
Michael Liao | 5bf9578 | 2014-12-04 05:20:33 +0000 | [diff] [blame] | 795 | |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 796 | /// translateInstruction - Translates an internal instruction and all its |
| 797 | /// operands to an MCInst. |
| 798 | /// |
| 799 | /// @param mcInst - The MCInst to populate with the instruction's data. |
| 800 | /// @param insn - The internal instruction. |
Sean Callanan | 010b373 | 2010-04-02 21:23:51 +0000 | [diff] [blame] | 801 | /// @return - false on success; true otherwise. |
| 802 | static bool translateInstruction(MCInst &mcInst, |
Kevin Enderby | 6fbcd8d | 2012-02-23 18:18:17 +0000 | [diff] [blame] | 803 | InternalInstruction &insn, |
Michael Liao | 5bf9578 | 2014-12-04 05:20:33 +0000 | [diff] [blame] | 804 | const MCDisassembler *Dis) { |
Sean Callanan | 010b373 | 2010-04-02 21:23:51 +0000 | [diff] [blame] | 805 | if (!insn.spec) { |
| 806 | debug("Instruction has no specification"); |
| 807 | return true; |
| 808 | } |
Michael Liao | 5bf9578 | 2014-12-04 05:20:33 +0000 | [diff] [blame] | 809 | |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 810 | mcInst.setOpcode(insn.instructionID); |
Kevin Enderby | 35fd792 | 2013-06-20 22:32:18 +0000 | [diff] [blame] | 811 | // If when reading the prefix bytes we determined the overlapping 0xf2 or 0xf3 |
| 812 | // prefix bytes should be disassembled as xrelease and xacquire then set the |
| 813 | // opcode to those instead of the rep and repne opcodes. |
| 814 | if (insn.xAcquireRelease) { |
| 815 | if(mcInst.getOpcode() == X86::REP_PREFIX) |
| 816 | mcInst.setOpcode(X86::XRELEASE_PREFIX); |
| 817 | else if(mcInst.getOpcode() == X86::REPNE_PREFIX) |
| 818 | mcInst.setOpcode(X86::XACQUIRE_PREFIX); |
| 819 | } |
Michael Liao | 5bf9578 | 2014-12-04 05:20:33 +0000 | [diff] [blame] | 820 | |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 821 | insn.numImmediatesTranslated = 0; |
Michael Liao | 5bf9578 | 2014-12-04 05:20:33 +0000 | [diff] [blame] | 822 | |
Patrik Hagglund | 3199838 | 2014-04-28 12:12:27 +0000 | [diff] [blame] | 823 | for (const auto &Op : insn.operands) { |
| 824 | if (Op.encoding != ENCODING_NONE) { |
| 825 | if (translateOperand(mcInst, Op, insn, Dis)) { |
Sean Callanan | 010b373 | 2010-04-02 21:23:51 +0000 | [diff] [blame] | 826 | return true; |
| 827 | } |
| 828 | } |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 829 | } |
Michael Liao | 5bf9578 | 2014-12-04 05:20:33 +0000 | [diff] [blame] | 830 | |
Sean Callanan | 010b373 | 2010-04-02 21:23:51 +0000 | [diff] [blame] | 831 | return false; |
Sean Callanan | 04cc307 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 832 | } |
Daniel Dunbar | 900f2ce | 2009-11-25 06:53:08 +0000 | [diff] [blame] | 833 | |
David Woodhouse | 7dd2182 | 2014-01-20 12:02:31 +0000 | [diff] [blame] | 834 | static MCDisassembler *createX86Disassembler(const Target &T, |
Lang Hames | a1bc0f5 | 2014-04-15 04:40:56 +0000 | [diff] [blame] | 835 | const MCSubtargetInfo &STI, |
| 836 | MCContext &Ctx) { |
Lang Hames | 0563ca1 | 2014-04-13 04:09:16 +0000 | [diff] [blame] | 837 | std::unique_ptr<const MCInstrInfo> MII(T.createMCInstrInfo()); |
Lang Hames | a1bc0f5 | 2014-04-15 04:40:56 +0000 | [diff] [blame] | 838 | return new X86Disassembler::X86GenericDisassembler(STI, Ctx, std::move(MII)); |
Daniel Dunbar | 900f2ce | 2009-11-25 06:53:08 +0000 | [diff] [blame] | 839 | } |
| 840 | |
Michael Liao | 5bf9578 | 2014-12-04 05:20:33 +0000 | [diff] [blame] | 841 | extern "C" void LLVMInitializeX86Disassembler() { |
Daniel Dunbar | 900f2ce | 2009-11-25 06:53:08 +0000 | [diff] [blame] | 842 | // Register the disassembler. |
Michael Liao | 5bf9578 | 2014-12-04 05:20:33 +0000 | [diff] [blame] | 843 | TargetRegistry::RegisterMCDisassembler(TheX86_32Target, |
David Woodhouse | 7dd2182 | 2014-01-20 12:02:31 +0000 | [diff] [blame] | 844 | createX86Disassembler); |
Daniel Dunbar | 900f2ce | 2009-11-25 06:53:08 +0000 | [diff] [blame] | 845 | TargetRegistry::RegisterMCDisassembler(TheX86_64Target, |
David Woodhouse | 7dd2182 | 2014-01-20 12:02:31 +0000 | [diff] [blame] | 846 | createX86Disassembler); |
Daniel Dunbar | 900f2ce | 2009-11-25 06:53:08 +0000 | [diff] [blame] | 847 | } |