/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- * vim: set ts=8 sts=2 et sw=2 tw=80:
*/ // Copyright 2011 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file.
// A Disassembler object is used to disassemble a block of code instruction by // instruction. The default implementation of the NameConverter object can be // overriden to modify register names or to do symbol lookup on addresses. // // The example below will disassemble a block of code and print it to stdout. // // disasm::NameConverter converter; // disasm::Disassembler d(converter); // for (uint8_t* pc = begin; pc < end;) { // disasm::EmbeddedVector<char, disasm::ReasonableBufferSize> buffer; // uint8_t* prev_pc = pc; // pc += d.InstructionDecode(buffer, pc); // printf("%p %08x %s\n", // prev_pc, *reinterpret_cast<int32_t*>(prev_pc), buffer); // } // // The Disassembler class also has a convenience method to disassemble a block // of code into a FILE*, meaning that the above functionality could also be // achieved by just calling Disassembler::Disassemble(stdout, begin, end);
#include"jit/arm/disasm/Disasm-arm.h"
#ifdef JS_DISASM_ARM
# include <stdarg.h> # include <stdio.h> # include <string.h>
# include "jit/arm/disasm/Constants-arm.h"
namespace js { namespace jit { namespace disasm {
// Helper function for printing to a Vector. staticint MOZ_FORMAT_PRINTF(2, 3)
SNPrintF(V8Vector<char> str, constchar* format, ...) {
va_list args;
va_start(args, format); int result = vsnprintf(str.start(), str.length(), format, args);
va_end(args); return result;
}
// Decoder decodes and disassembles instructions into an output buffer. // It uses the converter to convert register names and call destinations into // more informative description. class Decoder { public:
Decoder(const disasm::NameConverter& converter, V8Vector<char> out_buffer)
: converter_(converter), out_buffer_(out_buffer), out_buffer_pos_(0) {
out_buffer_[out_buffer_pos_] = '\0';
}
~Decoder() {}
// Writes one disassembled instruction into 'buffer' (0-terminated). // Returns the length of the disassembled machine instruction in bytes. int InstructionDecode(uint8_t* instruction);
// Handle formatting of instructions and their options. int FormatRegister(Instruction* instr, constchar* option); void FormatNeonList(int Vd, int type); void FormatNeonMemory(int Rn, int align, int Rm); int FormatOption(Instruction* instr, constchar* option); void Format(Instruction* instr, constchar* format); void Unknown(Instruction* instr);
// Each of these functions decodes one particular instruction type, a 3-bit // field in the instruction encoding. // Types 0 and 1 are combined as they are largely the same except for the way // they interpret the shifter operand. void DecodeType01(Instruction* instr); void DecodeType2(Instruction* instr); void DecodeType3(Instruction* instr); void DecodeType4(Instruction* instr); void DecodeType5(Instruction* instr); void DecodeType6(Instruction* instr); // Type 7 includes special Debugger instructions. int DecodeType7(Instruction* instr); // For VFP support. void DecodeTypeVFP(Instruction* instr); void DecodeType6CoprocessorIns(Instruction* instr);
// Support for assertions in the Decoder formatting functions. # define STRING_STARTS_WITH(string, compare_string) \
(strncmp(string, compare_string, strlen(compare_string)) == 0)
// Append the ch to the output buffer. void Decoder::PrintChar(constchar ch) { out_buffer_[out_buffer_pos_++] = ch; }
// Append the str to the output buffer. void Decoder::Print(constchar* str) { char cur = *str++; while (cur != '\0' && (out_buffer_pos_ < int(out_buffer_.length() - 1))) {
PrintChar(cur);
cur = *str++;
}
out_buffer_[out_buffer_pos_] = 0;
}
// These condition names are defined in a way to match the native disassembler // formatting. See for example the command "objdump -d <binary file>". staticconstchar* const cond_names[kNumberOfConditions] = { "eq", "ne", "cs", "cc", "mi", "pl", "vs", "vc", "hi", "ls", "ge", "lt", "gt", "le", "", "invalid",
};
// Print the condition guarding the instruction. void Decoder::PrintCondition(Instruction* instr) {
Print(cond_names[instr->ConditionValue()]);
}
// Print the register name according to the active name converter. void Decoder::PrintRegister(int reg) {
Print(converter_.NameOfCPURegister(reg));
}
// Print the VFP S register name according to the active name converter. void Decoder::PrintSRegister(int reg) { Print(VFPRegisters::Name(reg, false)); }
// Print the VFP D register name according to the active name converter. void Decoder::PrintDRegister(int reg) { Print(VFPRegisters::Name(reg, true)); }
// These shift names are defined in a way to match the native disassembler // formatting. See for example the command "objdump -d <binary file>". staticconstchar* const shift_names[kNumberOfShifts] = {"lsl", "lsr", "asr", "ror"};
// Print the register shift operands for the instruction. Generally used for // data processing instructions. void Decoder::PrintShiftRm(Instruction* instr) {
ShiftOp shift = instr->ShiftField(); int shift_index = instr->ShiftValue(); int shift_amount = instr->ShiftAmountValue(); int rm = instr->RmValue();
PrintRegister(rm);
if ((instr->RegShiftValue() == 0) && (shift == LSL) && (shift_amount == 0)) { // Special case for using rm only. return;
} if (instr->RegShiftValue() == 0) { // by immediate if ((shift == ROR) && (shift_amount == 0)) {
Print(", RRX"); return;
} elseif (((shift == LSR) || (shift == ASR)) && (shift_amount == 0)) {
shift_amount = 32;
}
out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, ", %s #%d",
shift_names[shift_index], shift_amount);
} else { // by register int rs = instr->RsValue();
out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, ", %s ",
shift_names[shift_index]);
PrintRegister(rs);
}
}
// Print the immediate operand for the instruction. Generally used for data // processing instructions. void Decoder::PrintShiftImm(Instruction* instr) { int rotate = instr->RotateValue() * 2; int immed8 = instr->Immed8Value(); int imm = RotateRight32(immed8, rotate);
out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "#%d", imm);
}
// Print the optional shift and immediate used by saturating instructions. void Decoder::PrintShiftSat(Instruction* instr) { int shift = instr->Bits(11, 7); if (shift > 0) {
out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_, ", %s #%d",
shift_names[instr->Bit(6) * 2], instr->Bits(11, 7));
}
}
// Print PU formatting to reduce complexity of FormatOption. void Decoder::PrintPU(Instruction* instr) { switch (instr->PUField()) { case da_x: {
Print("da"); break;
} case ia_x: {
Print("ia"); break;
} case db_x: {
Print("db"); break;
} case ib_x: {
Print("ib"); break;
} default: {
MOZ_CRASH(); break;
}
}
}
// Print SoftwareInterrupt codes. Factoring this out reduces the complexity of // the FormatOption method. void Decoder::PrintSoftwareInterrupt(SoftwareInterruptCodes svc) { switch (svc) { case kCallRtRedirected:
Print("call rt redirected"); return; case kBreakpoint:
Print("breakpoint"); return; default: if (svc >= kStopCode) {
out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d - 0x%x",
svc & kStopCodeMask, svc & kStopCodeMask);
} else {
out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", svc);
} return;
}
}
// Handle all register based formatting in this function to reduce the // complexity of FormatOption. int Decoder::FormatRegister(Instruction* instr, constchar* format) {
MOZ_ASSERT(format[0] == 'r'); if (format[1] == 'n') { // 'rn: Rn register int reg = instr->RnValue();
PrintRegister(reg); return 2;
} elseif (format[1] == 'd') { // 'rd: Rd register int reg = instr->RdValue();
PrintRegister(reg); return 2;
} elseif (format[1] == 's') { // 'rs: Rs register int reg = instr->RsValue();
PrintRegister(reg); return 2;
} elseif (format[1] == 'm') { // 'rm: Rm register int reg = instr->RmValue();
PrintRegister(reg); return 2;
} elseif (format[1] == 't') { // 'rt: Rt register int reg = instr->RtValue();
PrintRegister(reg); return 2;
} elseif (format[1] == 'l') { // 'rlist: register list for load and store multiple instructions
MOZ_ASSERT(STRING_STARTS_WITH(format, "rlist")); int rlist = instr->RlistValue(); int reg = 0;
Print("{"); // Print register list in ascending order, by scanning the bit mask. while (rlist != 0) { if ((rlist & 1) != 0) {
PrintRegister(reg); if ((rlist >> 1) != 0) {
Print(", ");
}
}
reg++;
rlist >>= 1;
}
Print("}"); return 5;
}
MOZ_CRASH(); return -1;
}
// Handle all VFP register based formatting in this function to reduce the // complexity of FormatOption. int Decoder::FormatVFPRegister(Instruction* instr, constchar* format) {
MOZ_ASSERT((format[0] == 'S') || (format[0] == 'D'));
out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d",
instr->Bits(width + lsb - 1, lsb)); return 8;
} case'l': { // 'l: branch and link if (instr->HasLink()) {
Print("l");
} return 1;
} case'm': { if (format[1] == 'w') { // 'mw: movt/movw instructions.
PrintMovwMovt(instr); return 2;
} if (format[1] == 'e') { // 'memop: load/store instructions.
MOZ_ASSERT(STRING_STARTS_WITH(format, "memop")); if (instr->HasL()) {
Print("ldr");
} else { if ((instr->Bits(27, 25) == 0) && (instr->Bit(20) == 0) &&
(instr->Bits(7, 6) == 3) && (instr->Bit(4) == 1)) { if (instr->Bit(5) == 1) {
Print("strd");
} else {
Print("ldrd");
} return 5;
}
Print("str");
} return 5;
} // 'msg: for simulator break instructions
MOZ_ASSERT(STRING_STARTS_WITH(format, "msg"));
uint8_t* str = reinterpret_cast<uint8_t*>(instr->InstructionBits() & 0x0fffffff);
out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%s",
converter_.NameInCode(str)); return 3;
} case'o': { if ((format[3] == '1') && (format[4] == '2')) { // 'off12: 12-bit offset for load and store instructions
MOZ_ASSERT(STRING_STARTS_WITH(format, "off12"));
out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d",
instr->Offset12Value()); return 5;
} elseif (format[3] == '0') { // 'off0to3and8to19 16-bit immediate encoded in bits 19-8 and 3-0.
MOZ_ASSERT(STRING_STARTS_WITH(format, "off0to3and8to19"));
out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_, "%d",
(instr->Bits(19, 8) << 4) + instr->Bits(3, 0)); return 15;
} // 'off8: 8-bit offset for extra load and store instructions
MOZ_ASSERT(STRING_STARTS_WITH(format, "off8")); int offs8 = (instr->ImmedHValue() << 4) | instr->ImmedLValue();
out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", offs8); return 4;
} case'p': { // 'pu: P and U bits for load and store instructions
MOZ_ASSERT(STRING_STARTS_WITH(format, "pu"));
PrintPU(instr); return 2;
} case'r': { return FormatRegister(instr, format);
} case's': { if (format[1] == 'h') { // 'shift_op or 'shift_rm or 'shift_sat. if (format[6] == 'o') { // 'shift_op
MOZ_ASSERT(STRING_STARTS_WITH(format, "shift_op")); if (instr->TypeValue() == 0) {
PrintShiftRm(instr);
} else {
MOZ_ASSERT(instr->TypeValue() == 1);
PrintShiftImm(instr);
} return 8;
} elseif (format[6] == 's') { // 'shift_sat.
MOZ_ASSERT(STRING_STARTS_WITH(format, "shift_sat"));
PrintShiftSat(instr); return 9;
} else { // 'shift_rm
MOZ_ASSERT(STRING_STARTS_WITH(format, "shift_rm"));
PrintShiftRm(instr); return 8;
}
} elseif (format[1] == 'v') { // 'svc
MOZ_ASSERT(STRING_STARTS_WITH(format, "svc"));
PrintSoftwareInterrupt(instr->SvcValue()); return 3;
} elseif (format[1] == 'i') { // 'sign: signed extra loads and stores
MOZ_ASSERT(STRING_STARTS_WITH(format, "sign")); if (instr->HasSign()) {
Print("s");
} return 4;
} // 's: S field of data processing instructions if (instr->HasS()) {
Print("s");
} return 1;
} case't': { // 'target: target of branch instructions
MOZ_ASSERT(STRING_STARTS_WITH(format, "target")); int off = (instr->SImmed24Value() << 2) + 8;
out_buffer_pos_ += SNPrintF(
out_buffer_ + out_buffer_pos_, "%+d -> %s", off,
converter_.NameOfAddress(reinterpret_cast<uint8_t*>(instr) + off)); return 6;
} case'u': { // 'u: signed or unsigned multiplies // The manual gets the meaning of bit 22 backwards in the multiply // instruction overview on page A3.16.2. The instructions that // exist in u and s variants are the following: // smull A4.1.87 // umull A4.1.129 // umlal A4.1.128 // smlal A4.1.76 // For these 0 means u and 1 means s. As can be seen on their individual // pages. The other 18 mul instructions have the bit set or unset in // arbitrary ways that are unrelated to the signedness of the instruction. // None of these 18 instructions exist in both a 'u' and an 's' variant.
if (instr->Bit(22) == 0) {
Print("u");
} else {
Print("s");
} return 1;
} case'v': { return FormatVFPinstruction(instr, format);
} case'S': case'D': { return FormatVFPRegister(instr, format);
} case'w': { // 'w: W field of load and store instructions if (instr->HasW()) {
Print("!");
} return 1;
} default: {
MOZ_CRASH(); break;
}
}
MOZ_CRASH(); return -1;
}
// Format takes a formatting string for a whole instruction and prints it into // the output buffer. All escaped options are handed to FormatOption to be // parsed further. void Decoder::Format(Instruction* instr, constchar* format) { char cur = *format++; while ((cur != 0) && (out_buffer_pos_ < (out_buffer_.length() - 1))) { if (cur == '\'') { // Single quote is used as the formatting escape.
format += FormatOption(instr, format);
} else {
out_buffer_[out_buffer_pos_++] = cur;
}
cur = *format++;
}
out_buffer_[out_buffer_pos_] = '\0';
}
// The disassembler may end up decoding data inlined in the code. We do not want // it to crash if the data does not ressemble any known instruction. # define VERIFY(condition) \ if (!(condition)) { \
Unknown(instr); \ return; \
}
// For currently unimplemented decodings the disassembler calls Unknown(instr) // which will just print "unknown" of the instruction bits. void Decoder::Unknown(Instruction* instr) { Format(instr, "unknown"); }
void Decoder::DecodeType01(Instruction* instr) { int type = instr->TypeValue(); if ((type == 0) && instr->IsSpecialType0()) { // multiply instruction or extra loads and stores if (instr->Bits(7, 4) == 9) { if (instr->Bit(24) == 0) { // multiply instructions if (instr->Bit(23) == 0) { if (instr->Bit(21) == 0) { // The MUL instruction description (A 4.1.33) refers to Rd as being // the destination for the operation, but it confusingly uses the // Rn field to encode it.
Format(instr, "mul'cond's 'rn, 'rm, 'rs");
} else { if (instr->Bit(22) == 0) { // The MLA instruction description (A 4.1.28) refers to the order // of registers as "Rd, Rm, Rs, Rn". But confusingly it uses the // Rn field to encode the Rd register and the Rd field to encode // the Rn register.
Format(instr, "mla'cond's 'rn, 'rm, 'rs, 'rd");
} else { // The MLS instruction description (A 4.1.29) refers to the order // of registers as "Rd, Rm, Rs, Rn". But confusingly it uses the // Rn field to encode the Rd register and the Rd field to encode // the Rn register.
Format(instr, "mls'cond's 'rn, 'rm, 'rs, 'rd");
}
}
} else { // The signed/long multiply instructions use the terms RdHi and RdLo // when referring to the target registers. They are mapped to the Rn // and Rd fields as follows: // RdLo == Rd field // RdHi == Rn field // The order of registers is: <RdLo>, <RdHi>, <Rm>, <Rs>
Format(instr, "'um'al'cond's 'rd, 'rn, 'rm, 'rs");
}
} else { if (instr->Bits(ExclusiveOpHi, ExclusiveOpLo) == ExclusiveOpcode) { if (instr->Bit(ExclusiveLoad) == 1) { switch (instr->Bits(ExclusiveSizeHi, ExclusiveSizeLo)) { case ExclusiveWord:
Format(instr, "ldrex'cond 'rt, ['rn]"); break; case ExclusiveDouble:
Format(instr, "ldrexd'cond 'rt, ['rn]"); break; case ExclusiveByte:
Format(instr, "ldrexb'cond 'rt, ['rn]"); break; case ExclusiveHalf:
Format(instr, "ldrexh'cond 'rt, ['rn]"); break;
}
} else { // The documentation names the low four bits of the // store-exclusive instructions "Rt" but canonically // for disassembly they are really "Rm". switch (instr->Bits(ExclusiveSizeHi, ExclusiveSizeLo)) { case ExclusiveWord:
Format(instr, "strex'cond 'rd, 'rm, ['rn]"); break; case ExclusiveDouble:
Format(instr, "strexd'cond 'rd, 'rm, ['rn]"); break; case ExclusiveByte:
Format(instr, "strexb'cond 'rd, 'rm, ['rn]"); break; case ExclusiveHalf:
Format(instr, "strexh'cond 'rd, 'rm, ['rn]"); break;
}
}
} else {
Unknown(instr);
}
}
} elseif ((instr->Bit(20) == 0) && ((instr->Bits(7, 4) & 0xd) == 0xd)) { // ldrd, strd switch (instr->PUField()) { case da_x: { if (instr->Bit(22) == 0) {
Format(instr, "'memop'cond's 'rd, ['rn], -'rm");
} else {
Format(instr, "'memop'cond's 'rd, ['rn], #-'off8");
} break;
} case ia_x: { if (instr->Bit(22) == 0) {
Format(instr, "'memop'cond's 'rd, ['rn], +'rm");
} else {
Format(instr, "'memop'cond's 'rd, ['rn], #+'off8");
} break;
} case db_x: { if (instr->Bit(22) == 0) {
Format(instr, "'memop'cond's 'rd, ['rn, -'rm]'w");
} else {
Format(instr, "'memop'cond's 'rd, ['rn, #-'off8]'w");
} break;
} case ib_x: { if (instr->Bit(22) == 0) {
Format(instr, "'memop'cond's 'rd, ['rn, +'rm]'w");
} else {
Format(instr, "'memop'cond's 'rd, ['rn, #+'off8]'w");
} break;
} default: { // The PU field is a 2-bit field.
MOZ_CRASH(); break;
}
}
} else { // extra load/store instructions switch (instr->PUField()) { case da_x: { if (instr->Bit(22) == 0) {
Format(instr, "'memop'cond'sign'h 'rd, ['rn], -'rm");
} else {
Format(instr, "'memop'cond'sign'h 'rd, ['rn], #-'off8");
} break;
} case ia_x: { if (instr->Bit(22) == 0) {
Format(instr, "'memop'cond'sign'h 'rd, ['rn], +'rm");
} else {
Format(instr, "'memop'cond'sign'h 'rd, ['rn], #+'off8");
} break;
} case db_x: { if (instr->Bit(22) == 0) {
Format(instr, "'memop'cond'sign'h 'rd, ['rn, -'rm]'w");
} else {
Format(instr, "'memop'cond'sign'h 'rd, ['rn, #-'off8]'w");
} break;
} case ib_x: { if (instr->Bit(22) == 0) {
Format(instr, "'memop'cond'sign'h 'rd, ['rn, +'rm]'w");
} else {
Format(instr, "'memop'cond'sign'h 'rd, ['rn, #+'off8]'w");
} break;
} default: { // The PU field is a 2-bit field.
MOZ_CRASH(); break;
}
} return;
}
} elseif ((type == 0) && instr->IsMiscType0()) { if (instr->Bits(22, 21) == 1) { switch (instr->BitField(7, 4)) { case BX:
Format(instr, "bx'cond 'rm"); break; case BLX:
Format(instr, "blx'cond 'rm"); break; case BKPT:
Format(instr, "bkpt 'off0to3and8to19"); break; default:
Unknown(instr); // not used by V8 break;
}
} elseif (instr->Bits(22, 21) == 3) { switch (instr->BitField(7, 4)) { case CLZ:
Format(instr, "clz'cond 'rd, 'rm"); break; default:
Unknown(instr); // not used by V8 break;
}
} else {
Unknown(instr); // not used by V8
}
} elseif ((type == 1) && instr->IsNopType1()) {
Format(instr, "nop'cond");
} elseif ((type == 1) && instr->IsYieldType1()) {
Format(instr, "yield'cond");
} elseif ((type == 1) && instr->IsCsdbType1()) {
Format(instr, "csdb'cond");
} else { switch (instr->OpcodeField()) { caseAND: {
Format(instr, "and'cond's 'rd, 'rn, 'shift_op"); break;
} case EOR: {
Format(instr, "eor'cond's 'rd, 'rn, 'shift_op"); break;
} case SUB: {
Format(instr, "sub'cond's 'rd, 'rn, 'shift_op"); break;
} case RSB: {
Format(instr, "rsb'cond's 'rd, 'rn, 'shift_op"); break;
} case ADD: {
Format(instr, "add'cond's 'rd, 'rn, 'shift_op"); break;
} case ADC: {
Format(instr, "adc'cond's 'rd, 'rn, 'shift_op"); break;
} case SBC: {
Format(instr, "sbc'cond's 'rd, 'rn, 'shift_op"); break;
} case RSC: {
Format(instr, "rsc'cond's 'rd, 'rn, 'shift_op"); break;
} case TST: { if (instr->HasS()) {
Format(instr, "tst'cond 'rn, 'shift_op");
} else {
Format(instr, "movw'cond 'mw");
} break;
} case TEQ: { if (instr->HasS()) {
Format(instr, "teq'cond 'rn, 'shift_op");
} else { // Other instructions matching this pattern are handled in the // miscellaneous instructions part above.
MOZ_CRASH();
} break;
} case CMP: { if (instr->HasS()) {
Format(instr, "cmp'cond 'rn, 'shift_op");
} else {
Format(instr, "movt'cond 'mw");
} break;
} case CMN: { if (instr->HasS()) {
Format(instr, "cmn'cond 'rn, 'shift_op");
} else { // Other instructions matching this pattern are handled in the // miscellaneous instructions part above.
MOZ_CRASH();
} break;
} case ORR: {
Format(instr, "orr'cond's 'rd, 'rn, 'shift_op"); break;
} case MOV: {
Format(instr, "mov'cond's 'rd, 'shift_op"); break;
} case BIC: {
Format(instr, "bic'cond's 'rd, 'rn, 'shift_op"); break;
} case MVN: {
Format(instr, "mvn'cond's 'rd, 'shift_op"); break;
} default: { // The Opcode field is a 4-bit field.
MOZ_CRASH(); break;
}
}
}
}
void Decoder::DecodeType2(Instruction* instr) { switch (instr->PUField()) { case da_x: { if (instr->HasW()) {
Unknown(instr); // not used in V8 return;
}
Format(instr, "'memop'cond'b 'rd, ['rn], #-'off12"); break;
} case ia_x: { if (instr->HasW()) {
Unknown(instr); // not used in V8 return;
}
Format(instr, "'memop'cond'b 'rd, ['rn], #+'off12"); break;
} case db_x: {
Format(instr, "'memop'cond'b 'rd, ['rn, #-'off12]'w"); break;
} case ib_x: {
Format(instr, "'memop'cond'b 'rd, ['rn, #+'off12]'w"); break;
} default: { // The PU field is a 2-bit field.
MOZ_CRASH(); break;
}
}
}
void Decoder::DecodeType3(Instruction* instr) { switch (instr->PUField()) { case da_x: {
VERIFY(!instr->HasW());
Format(instr, "'memop'cond'b 'rd, ['rn], -'shift_rm"); break;
} case ia_x: { if (instr->Bit(4) == 0) {
Format(instr, "'memop'cond'b 'rd, ['rn], +'shift_rm");
} else { if (instr->Bit(5) == 0) { switch (instr->Bits(22, 21)) { case 0: if (instr->Bit(20) == 0) { if (instr->Bit(6) == 0) {
Format(instr, "pkhbt'cond 'rd, 'rn, 'rm, lsl #'imm05@07");
} else { if (instr->Bits(11, 7) == 0) {
Format(instr, "pkhtb'cond 'rd, 'rn, 'rm, asr #32");
} else {
Format(instr, "pkhtb'cond 'rd, 'rn, 'rm, asr #'imm05@07");
}
}
} else {
MOZ_CRASH();
} break; case 1:
MOZ_CRASH(); break; case 2:
MOZ_CRASH(); break; case 3:
Format(instr, "usat 'rd, #'imm05@16, 'rm'shift_sat"); break;
}
} else { switch (instr->Bits(22, 21)) { case 0:
MOZ_CRASH(); break; case 1: if (instr->Bits(9, 6) == 1) { if (instr->Bit(20) == 0) { if (instr->Bits(19, 16) == 0xF) { switch (instr->Bits(11, 10)) { case 0:
Format(instr, "sxtb'cond 'rd, 'rm"); break; case 1:
Format(instr, "sxtb'cond 'rd, 'rm, ror #8"); break; case 2:
Format(instr, "sxtb'cond 'rd, 'rm, ror #16"); break; case 3:
Format(instr, "sxtb'cond 'rd, 'rm, ror #24"); break;
}
} else { switch (instr->Bits(11, 10)) { case 0:
Format(instr, "sxtab'cond 'rd, 'rn, 'rm"); break; case 1:
Format(instr, "sxtab'cond 'rd, 'rn, 'rm, ror #8"); break; case 2:
Format(instr, "sxtab'cond 'rd, 'rn, 'rm, ror #16"); break; case 3:
Format(instr, "sxtab'cond 'rd, 'rn, 'rm, ror #24"); break;
}
}
} else { if (instr->Bits(19, 16) == 0xF) { switch (instr->Bits(11, 10)) { case 0:
Format(instr, "sxth'cond 'rd, 'rm"); break; case 1:
Format(instr, "sxth'cond 'rd, 'rm, ror #8"); break; case 2:
Format(instr, "sxth'cond 'rd, 'rm, ror #16"); break; case 3:
Format(instr, "sxth'cond 'rd, 'rm, ror #24"); break;
}
} else { switch (instr->Bits(11, 10)) { case 0:
Format(instr, "sxtah'cond 'rd, 'rn, 'rm"); break; case 1:
Format(instr, "sxtah'cond 'rd, 'rn, 'rm, ror #8"); break; case 2:
Format(instr, "sxtah'cond 'rd, 'rn, 'rm, ror #16"); break; case 3:
Format(instr, "sxtah'cond 'rd, 'rn, 'rm, ror #24"); break;
}
}
}
} else {
MOZ_CRASH();
} break; case 2: if ((instr->Bit(20) == 0) && (instr->Bits(9, 6) == 1)) { if (instr->Bits(19, 16) == 0xF) { switch (instr->Bits(11, 10)) { case 0:
Format(instr, "uxtb16'cond 'rd, 'rm"); break; case 1:
Format(instr, "uxtb16'cond 'rd, 'rm, ror #8"); break; case 2:
Format(instr, "uxtb16'cond 'rd, 'rm, ror #16"); break; case 3:
Format(instr, "uxtb16'cond 'rd, 'rm, ror #24"); break;
}
} else {
MOZ_CRASH();
}
} else {
MOZ_CRASH();
} break; case 3: if ((instr->Bits(9, 6) == 1)) { if ((instr->Bit(20) == 0)) { if (instr->Bits(19, 16) == 0xF) { switch (instr->Bits(11, 10)) { case 0:
Format(instr, "uxtb'cond 'rd, 'rm"); break; case 1:
Format(instr, "uxtb'cond 'rd, 'rm, ror #8"); break; case 2:
Format(instr, "uxtb'cond 'rd, 'rm, ror #16"); break; case 3:
Format(instr, "uxtb'cond 'rd, 'rm, ror #24"); break;
}
} else { switch (instr->Bits(11, 10)) { case 0:
Format(instr, "uxtab'cond 'rd, 'rn, 'rm"); break; case 1:
Format(instr, "uxtab'cond 'rd, 'rn, 'rm, ror #8"); break; case 2:
Format(instr, "uxtab'cond 'rd, 'rn, 'rm, ror #16"); break; case 3:
Format(instr, "uxtab'cond 'rd, 'rn, 'rm, ror #24"); break;
}
}
} else { if (instr->Bits(19, 16) == 0xF) { switch (instr->Bits(11, 10)) { case 0:
Format(instr, "uxth'cond 'rd, 'rm"); break; case 1:
Format(instr, "uxth'cond 'rd, 'rm, ror #8"); break; case 2:
Format(instr, "uxth'cond 'rd, 'rm, ror #16"); break; case 3:
Format(instr, "uxth'cond 'rd, 'rm, ror #24"); break;
}
} else { switch (instr->Bits(11, 10)) { case 0:
Format(instr, "uxtah'cond 'rd, 'rn, 'rm"); break; case 1:
Format(instr, "uxtah'cond 'rd, 'rn, 'rm, ror #8"); break; case 2:
Format(instr, "uxtah'cond 'rd, 'rn, 'rm, ror #16"); break; case 3:
Format(instr, "uxtah'cond 'rd, 'rn, 'rm, ror #24"); break;
}
}
}
} else {
MOZ_CRASH();
} break;
}
}
} break;
} case db_x: { if (instr->Bits(22, 20) == 0x5) { if (instr->Bits(7, 4) == 0x1) { if (instr->Bits(15, 12) == 0xF) {
Format(instr, "smmul'cond 'rn, 'rm, 'rs");
} else { // SMMLA (in V8 notation matching ARM ISA format)
Format(instr, "smmla'cond 'rn, 'rm, 'rs, 'rd");
} break;
}
} bool FLAG_enable_sudiv = true; // Flag doesn't exist in our engine. if (FLAG_enable_sudiv) { if (instr->Bits(5, 4) == 0x1) { if ((instr->Bit(22) == 0x0) && (instr->Bit(20) == 0x1)) { if (instr->Bit(21) == 0x1) { // UDIV (in V8 notation matching ARM ISA format) rn = rm/rs
Format(instr, "udiv'cond'b 'rn, 'rm, 'rs");
} else { // SDIV (in V8 notation matching ARM ISA format) rn = rm/rs
Format(instr, "sdiv'cond'b 'rn, 'rm, 'rs");
} break;
}
}
}
Format(instr, "'memop'cond'b 'rd, ['rn, -'shift_rm]'w"); break;
} case ib_x: { if (instr->HasW() && (instr->Bits(6, 4) == 0x5)) {
uint32_t widthminus1 = static_cast<uint32_t>(instr->Bits(20, 16));
uint32_t lsbit = static_cast<uint32_t>(instr->Bits(11, 7));
uint32_t msbit = widthminus1 + lsbit; if (msbit <= 31) { if (instr->Bit(22)) {
Format(instr, "ubfx'cond 'rd, 'rm, 'f");
} else {
Format(instr, "sbfx'cond 'rd, 'rm, 'f");
}
} else {
MOZ_CRASH();
}
} elseif (!instr->HasW() && (instr->Bits(6, 4) == 0x1)) {
uint32_t lsbit = static_cast<uint32_t>(instr->Bits(11, 7));
uint32_t msbit = static_cast<uint32_t>(instr->Bits(20, 16)); if (msbit >= lsbit) { if (instr->RmValue() == 15) {
Format(instr, "bfc'cond 'rd, 'f");
} else {
Format(instr, "bfi'cond 'rd, 'rm, 'f");
}
} else {
MOZ_CRASH();
}
} else {
Format(instr, "'memop'cond'b 'rd, ['rn, +'shift_rm]'w");
} break;
} default: { // The PU field is a 2-bit field.
MOZ_CRASH(); break;
}
}
}
void Decoder::DecodeType4(Instruction* instr) { if (instr->Bit(22) != 0) { // Privileged mode currently not supported.
Unknown(instr);
} else { if (instr->HasL()) {
Format(instr, "ldm'cond'pu 'rn'w, 'rlist");
} else {
Format(instr, "stm'cond'pu 'rn'w, 'rlist");
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.