11cb0ef41Sopenharmony_ci// Copyright 2014 the V8 project authors. All rights reserved. 21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be 31cb0ef41Sopenharmony_ci// found in the LICENSE file. 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci// A Disassembler object is used to disassemble a block of code instruction by 61cb0ef41Sopenharmony_ci// instruction. The default implementation of the NameConverter object can be 71cb0ef41Sopenharmony_ci// overriden to modify register names or to do symbol lookup on addresses. 81cb0ef41Sopenharmony_ci// 91cb0ef41Sopenharmony_ci// The example below will disassemble a block of code and print it to stdout. 101cb0ef41Sopenharmony_ci// 111cb0ef41Sopenharmony_ci// NameConverter converter; 121cb0ef41Sopenharmony_ci// Disassembler d(converter); 131cb0ef41Sopenharmony_ci// for (byte* pc = begin; pc < end;) { 141cb0ef41Sopenharmony_ci// v8::base::EmbeddedVector<char, 256> buffer; 151cb0ef41Sopenharmony_ci// byte* prev_pc = pc; 161cb0ef41Sopenharmony_ci// pc += d.InstructionDecode(buffer, pc); 171cb0ef41Sopenharmony_ci// printf("%p %08x %s\n", 181cb0ef41Sopenharmony_ci// prev_pc, *reinterpret_cast<int32_t*>(prev_pc), buffer); 191cb0ef41Sopenharmony_ci// } 201cb0ef41Sopenharmony_ci// 211cb0ef41Sopenharmony_ci// The Disassembler class also has a convenience method to disassemble a block 221cb0ef41Sopenharmony_ci// of code into a FILE*, meaning that the above functionality could also be 231cb0ef41Sopenharmony_ci// achieved by just calling Disassembler::Disassemble(stdout, begin, end); 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_ci#include <assert.h> 261cb0ef41Sopenharmony_ci#include <stdarg.h> 271cb0ef41Sopenharmony_ci#include <stdio.h> 281cb0ef41Sopenharmony_ci#include <string.h> 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64 311cb0ef41Sopenharmony_ci 321cb0ef41Sopenharmony_ci#include "src/base/platform/platform.h" 331cb0ef41Sopenharmony_ci#include "src/base/strings.h" 341cb0ef41Sopenharmony_ci#include "src/base/vector.h" 351cb0ef41Sopenharmony_ci#include "src/codegen/macro-assembler.h" 361cb0ef41Sopenharmony_ci#include "src/codegen/ppc/constants-ppc.h" 371cb0ef41Sopenharmony_ci#include "src/codegen/register-configuration.h" 381cb0ef41Sopenharmony_ci#include "src/diagnostics/disasm.h" 391cb0ef41Sopenharmony_ci 401cb0ef41Sopenharmony_cinamespace v8 { 411cb0ef41Sopenharmony_cinamespace internal { 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_ci//------------------------------------------------------------------------------ 441cb0ef41Sopenharmony_ci 451cb0ef41Sopenharmony_ci// Decoder decodes and disassembles instructions into an output buffer. 461cb0ef41Sopenharmony_ci// It uses the converter to convert register names and call destinations into 471cb0ef41Sopenharmony_ci// more informative description. 481cb0ef41Sopenharmony_ciclass Decoder { 491cb0ef41Sopenharmony_ci public: 501cb0ef41Sopenharmony_ci Decoder(const disasm::NameConverter& converter, base::Vector<char> out_buffer) 511cb0ef41Sopenharmony_ci : converter_(converter), out_buffer_(out_buffer), out_buffer_pos_(0) { 521cb0ef41Sopenharmony_ci out_buffer_[out_buffer_pos_] = '\0'; 531cb0ef41Sopenharmony_ci } 541cb0ef41Sopenharmony_ci 551cb0ef41Sopenharmony_ci ~Decoder() {} 561cb0ef41Sopenharmony_ci 571cb0ef41Sopenharmony_ci Decoder(const Decoder&) = delete; 581cb0ef41Sopenharmony_ci Decoder& operator=(const Decoder&) = delete; 591cb0ef41Sopenharmony_ci 601cb0ef41Sopenharmony_ci // Writes one disassembled instruction into 'buffer' (0-terminated). 611cb0ef41Sopenharmony_ci // Returns the length of the disassembled machine instruction in bytes. 621cb0ef41Sopenharmony_ci int InstructionDecode(byte* instruction); 631cb0ef41Sopenharmony_ci 641cb0ef41Sopenharmony_ci // Prefixed instructions. 651cb0ef41Sopenharmony_ci enum PrefixType { not_prefixed, is_prefixed }; 661cb0ef41Sopenharmony_ci // static is used to retain values even with new instances. 671cb0ef41Sopenharmony_ci static PrefixType PrefixStatus; 681cb0ef41Sopenharmony_ci static uint64_t PrefixValue; 691cb0ef41Sopenharmony_ci uint64_t GetPrefixValue(); 701cb0ef41Sopenharmony_ci void SetAsPrefixed(uint64_t v); 711cb0ef41Sopenharmony_ci void ResetPrefix(); 721cb0ef41Sopenharmony_ci bool IsPrefixed(); 731cb0ef41Sopenharmony_ci 741cb0ef41Sopenharmony_ci private: 751cb0ef41Sopenharmony_ci // Bottleneck functions to print into the out_buffer. 761cb0ef41Sopenharmony_ci void PrintChar(const char ch); 771cb0ef41Sopenharmony_ci void Print(const char* str); 781cb0ef41Sopenharmony_ci 791cb0ef41Sopenharmony_ci // Printing of common values. 801cb0ef41Sopenharmony_ci void PrintRegister(int reg); 811cb0ef41Sopenharmony_ci void PrintDRegister(int reg); 821cb0ef41Sopenharmony_ci void PrintVectorRegister(int reg); 831cb0ef41Sopenharmony_ci int FormatFPRegister(Instruction* instr, const char* format); 841cb0ef41Sopenharmony_ci int FormatVectorRegister(Instruction* instr, const char* format); 851cb0ef41Sopenharmony_ci void PrintSoftwareInterrupt(SoftwareInterruptCodes svc); 861cb0ef41Sopenharmony_ci const char* NameOfVectorRegister(int reg) const; 871cb0ef41Sopenharmony_ci 881cb0ef41Sopenharmony_ci // Handle formatting of instructions and their options. 891cb0ef41Sopenharmony_ci int FormatRegister(Instruction* instr, const char* option); 901cb0ef41Sopenharmony_ci int FormatOption(Instruction* instr, const char* option); 911cb0ef41Sopenharmony_ci void Format(Instruction* instr, const char* format); 921cb0ef41Sopenharmony_ci void Unknown(Instruction* instr); 931cb0ef41Sopenharmony_ci void UnknownFormat(Instruction* instr, const char* opcname); 941cb0ef41Sopenharmony_ci 951cb0ef41Sopenharmony_ci void DecodeExtP(Instruction* instr); 961cb0ef41Sopenharmony_ci void DecodeExt0(Instruction* instr); 971cb0ef41Sopenharmony_ci void DecodeExt1(Instruction* instr); 981cb0ef41Sopenharmony_ci void DecodeExt2(Instruction* instr); 991cb0ef41Sopenharmony_ci void DecodeExt3(Instruction* instr); 1001cb0ef41Sopenharmony_ci void DecodeExt4(Instruction* instr); 1011cb0ef41Sopenharmony_ci void DecodeExt5(Instruction* instr); 1021cb0ef41Sopenharmony_ci void DecodeExt6(Instruction* instr); 1031cb0ef41Sopenharmony_ci 1041cb0ef41Sopenharmony_ci const disasm::NameConverter& converter_; 1051cb0ef41Sopenharmony_ci base::Vector<char> out_buffer_; 1061cb0ef41Sopenharmony_ci int out_buffer_pos_; 1071cb0ef41Sopenharmony_ci}; 1081cb0ef41Sopenharmony_ci 1091cb0ef41Sopenharmony_ci// Define Prefix functions and values. 1101cb0ef41Sopenharmony_ci// static 1111cb0ef41Sopenharmony_ciDecoder::PrefixType Decoder::PrefixStatus = not_prefixed; 1121cb0ef41Sopenharmony_ciuint64_t Decoder::PrefixValue = 0; 1131cb0ef41Sopenharmony_ci 1141cb0ef41Sopenharmony_ciuint64_t Decoder::GetPrefixValue() { return PrefixValue; } 1151cb0ef41Sopenharmony_ci 1161cb0ef41Sopenharmony_civoid Decoder::SetAsPrefixed(uint64_t v) { 1171cb0ef41Sopenharmony_ci PrefixStatus = is_prefixed; 1181cb0ef41Sopenharmony_ci PrefixValue = v; 1191cb0ef41Sopenharmony_ci} 1201cb0ef41Sopenharmony_ci 1211cb0ef41Sopenharmony_civoid Decoder::ResetPrefix() { 1221cb0ef41Sopenharmony_ci PrefixStatus = not_prefixed; 1231cb0ef41Sopenharmony_ci PrefixValue = 0; 1241cb0ef41Sopenharmony_ci} 1251cb0ef41Sopenharmony_ci 1261cb0ef41Sopenharmony_cibool Decoder::IsPrefixed() { return PrefixStatus == is_prefixed; } 1271cb0ef41Sopenharmony_ci 1281cb0ef41Sopenharmony_ci// Support for assertions in the Decoder formatting functions. 1291cb0ef41Sopenharmony_ci#define STRING_STARTS_WITH(string, compare_string) \ 1301cb0ef41Sopenharmony_ci (strncmp(string, compare_string, strlen(compare_string)) == 0) 1311cb0ef41Sopenharmony_ci 1321cb0ef41Sopenharmony_ci// Append the ch to the output buffer. 1331cb0ef41Sopenharmony_civoid Decoder::PrintChar(const char ch) { out_buffer_[out_buffer_pos_++] = ch; } 1341cb0ef41Sopenharmony_ci 1351cb0ef41Sopenharmony_ci// Append the str to the output buffer. 1361cb0ef41Sopenharmony_civoid Decoder::Print(const char* str) { 1371cb0ef41Sopenharmony_ci char cur = *str++; 1381cb0ef41Sopenharmony_ci while (cur != '\0' && (out_buffer_pos_ < (out_buffer_.length() - 1))) { 1391cb0ef41Sopenharmony_ci PrintChar(cur); 1401cb0ef41Sopenharmony_ci cur = *str++; 1411cb0ef41Sopenharmony_ci } 1421cb0ef41Sopenharmony_ci out_buffer_[out_buffer_pos_] = 0; 1431cb0ef41Sopenharmony_ci} 1441cb0ef41Sopenharmony_ci 1451cb0ef41Sopenharmony_ci// Print the register name according to the active name converter. 1461cb0ef41Sopenharmony_civoid Decoder::PrintRegister(int reg) { 1471cb0ef41Sopenharmony_ci Print(converter_.NameOfCPURegister(reg)); 1481cb0ef41Sopenharmony_ci} 1491cb0ef41Sopenharmony_ci 1501cb0ef41Sopenharmony_ci// Print the double FP register name according to the active name converter. 1511cb0ef41Sopenharmony_civoid Decoder::PrintDRegister(int reg) { 1521cb0ef41Sopenharmony_ci Print(RegisterName(DoubleRegister::from_code(reg))); 1531cb0ef41Sopenharmony_ci} 1541cb0ef41Sopenharmony_ci 1551cb0ef41Sopenharmony_ci// Print the Simd128 register name according to the active name converter. 1561cb0ef41Sopenharmony_civoid Decoder::PrintVectorRegister(int reg) { 1571cb0ef41Sopenharmony_ci Print(RegisterName(Simd128Register::from_code(reg))); 1581cb0ef41Sopenharmony_ci} 1591cb0ef41Sopenharmony_ci 1601cb0ef41Sopenharmony_ci// Print SoftwareInterrupt codes. Factoring this out reduces the complexity of 1611cb0ef41Sopenharmony_ci// the FormatOption method. 1621cb0ef41Sopenharmony_civoid Decoder::PrintSoftwareInterrupt(SoftwareInterruptCodes svc) { 1631cb0ef41Sopenharmony_ci switch (svc) { 1641cb0ef41Sopenharmony_ci case kCallRtRedirected: 1651cb0ef41Sopenharmony_ci Print("call rt redirected"); 1661cb0ef41Sopenharmony_ci return; 1671cb0ef41Sopenharmony_ci case kBreakpoint: 1681cb0ef41Sopenharmony_ci Print("breakpoint"); 1691cb0ef41Sopenharmony_ci return; 1701cb0ef41Sopenharmony_ci default: 1711cb0ef41Sopenharmony_ci if (svc >= kStopCode) { 1721cb0ef41Sopenharmony_ci out_buffer_pos_ += 1731cb0ef41Sopenharmony_ci base::SNPrintF(out_buffer_ + out_buffer_pos_, "%d - 0x%x", 1741cb0ef41Sopenharmony_ci svc & kStopCodeMask, svc & kStopCodeMask); 1751cb0ef41Sopenharmony_ci } else { 1761cb0ef41Sopenharmony_ci out_buffer_pos_ += 1771cb0ef41Sopenharmony_ci base::SNPrintF(out_buffer_ + out_buffer_pos_, "%d", svc); 1781cb0ef41Sopenharmony_ci } 1791cb0ef41Sopenharmony_ci return; 1801cb0ef41Sopenharmony_ci } 1811cb0ef41Sopenharmony_ci} 1821cb0ef41Sopenharmony_ci 1831cb0ef41Sopenharmony_ci// Handle all register based formatting in this function to reduce the 1841cb0ef41Sopenharmony_ci// complexity of FormatOption. 1851cb0ef41Sopenharmony_ciint Decoder::FormatRegister(Instruction* instr, const char* format) { 1861cb0ef41Sopenharmony_ci DCHECK_EQ(format[0], 'r'); 1871cb0ef41Sopenharmony_ci 1881cb0ef41Sopenharmony_ci if ((format[1] == 't') || (format[1] == 's')) { // 'rt & 'rs register 1891cb0ef41Sopenharmony_ci int reg = instr->RTValue(); 1901cb0ef41Sopenharmony_ci PrintRegister(reg); 1911cb0ef41Sopenharmony_ci return 2; 1921cb0ef41Sopenharmony_ci } else if (format[1] == 'a') { // 'ra: RA register 1931cb0ef41Sopenharmony_ci int reg = instr->RAValue(); 1941cb0ef41Sopenharmony_ci PrintRegister(reg); 1951cb0ef41Sopenharmony_ci return 2; 1961cb0ef41Sopenharmony_ci } else if (format[1] == 'b') { // 'rb: RB register 1971cb0ef41Sopenharmony_ci int reg = instr->RBValue(); 1981cb0ef41Sopenharmony_ci PrintRegister(reg); 1991cb0ef41Sopenharmony_ci return 2; 2001cb0ef41Sopenharmony_ci } 2011cb0ef41Sopenharmony_ci 2021cb0ef41Sopenharmony_ci UNREACHABLE(); 2031cb0ef41Sopenharmony_ci} 2041cb0ef41Sopenharmony_ci 2051cb0ef41Sopenharmony_ci// Handle all FP register based formatting in this function to reduce the 2061cb0ef41Sopenharmony_ci// complexity of FormatOption. 2071cb0ef41Sopenharmony_ciint Decoder::FormatFPRegister(Instruction* instr, const char* format) { 2081cb0ef41Sopenharmony_ci DCHECK(format[0] == 'D' || format[0] == 'X'); 2091cb0ef41Sopenharmony_ci 2101cb0ef41Sopenharmony_ci int retval = 2; 2111cb0ef41Sopenharmony_ci int reg = -1; 2121cb0ef41Sopenharmony_ci if (format[1] == 't' || format[1] == 's') { 2131cb0ef41Sopenharmony_ci reg = instr->RTValue(); 2141cb0ef41Sopenharmony_ci } else if (format[1] == 'a') { 2151cb0ef41Sopenharmony_ci reg = instr->RAValue(); 2161cb0ef41Sopenharmony_ci } else if (format[1] == 'b') { 2171cb0ef41Sopenharmony_ci reg = instr->RBValue(); 2181cb0ef41Sopenharmony_ci } else if (format[1] == 'c') { 2191cb0ef41Sopenharmony_ci reg = instr->RCValue(); 2201cb0ef41Sopenharmony_ci } else { 2211cb0ef41Sopenharmony_ci UNREACHABLE(); 2221cb0ef41Sopenharmony_ci } 2231cb0ef41Sopenharmony_ci 2241cb0ef41Sopenharmony_ci PrintDRegister(reg); 2251cb0ef41Sopenharmony_ci 2261cb0ef41Sopenharmony_ci return retval; 2271cb0ef41Sopenharmony_ci} 2281cb0ef41Sopenharmony_ci 2291cb0ef41Sopenharmony_ciint Decoder::FormatVectorRegister(Instruction* instr, const char* format) { 2301cb0ef41Sopenharmony_ci int retval = 2; 2311cb0ef41Sopenharmony_ci int reg = -1; 2321cb0ef41Sopenharmony_ci if (format[1] == 't' || format[1] == 's') { 2331cb0ef41Sopenharmony_ci reg = instr->RTValue(); 2341cb0ef41Sopenharmony_ci } else if (format[1] == 'a') { 2351cb0ef41Sopenharmony_ci reg = instr->RAValue(); 2361cb0ef41Sopenharmony_ci } else if (format[1] == 'b') { 2371cb0ef41Sopenharmony_ci reg = instr->RBValue(); 2381cb0ef41Sopenharmony_ci } else if (format[1] == 'c') { 2391cb0ef41Sopenharmony_ci reg = instr->RCValue(); 2401cb0ef41Sopenharmony_ci } else { 2411cb0ef41Sopenharmony_ci UNREACHABLE(); 2421cb0ef41Sopenharmony_ci } 2431cb0ef41Sopenharmony_ci 2441cb0ef41Sopenharmony_ci PrintVectorRegister(reg); 2451cb0ef41Sopenharmony_ci 2461cb0ef41Sopenharmony_ci return retval; 2471cb0ef41Sopenharmony_ci} 2481cb0ef41Sopenharmony_ci 2491cb0ef41Sopenharmony_ci// FormatOption takes a formatting string and interprets it based on 2501cb0ef41Sopenharmony_ci// the current instructions. The format string points to the first 2511cb0ef41Sopenharmony_ci// character of the option string (the option escape has already been 2521cb0ef41Sopenharmony_ci// consumed by the caller.) FormatOption returns the number of 2531cb0ef41Sopenharmony_ci// characters that were consumed from the formatting string. 2541cb0ef41Sopenharmony_ciint Decoder::FormatOption(Instruction* instr, const char* format) { 2551cb0ef41Sopenharmony_ci switch (format[0]) { 2561cb0ef41Sopenharmony_ci case 'o': { 2571cb0ef41Sopenharmony_ci if (instr->Bit(10) == 1) { 2581cb0ef41Sopenharmony_ci Print("o"); 2591cb0ef41Sopenharmony_ci } 2601cb0ef41Sopenharmony_ci return 1; 2611cb0ef41Sopenharmony_ci } 2621cb0ef41Sopenharmony_ci case '.': { 2631cb0ef41Sopenharmony_ci if (instr->Bit(0) == 1) { 2641cb0ef41Sopenharmony_ci Print("."); 2651cb0ef41Sopenharmony_ci } else { 2661cb0ef41Sopenharmony_ci Print(" "); // ensure consistent spacing 2671cb0ef41Sopenharmony_ci } 2681cb0ef41Sopenharmony_ci return 1; 2691cb0ef41Sopenharmony_ci } 2701cb0ef41Sopenharmony_ci case 'r': { 2711cb0ef41Sopenharmony_ci return FormatRegister(instr, format); 2721cb0ef41Sopenharmony_ci } 2731cb0ef41Sopenharmony_ci case 'D': { 2741cb0ef41Sopenharmony_ci return FormatFPRegister(instr, format); 2751cb0ef41Sopenharmony_ci } 2761cb0ef41Sopenharmony_ci case 'X': { 2771cb0ef41Sopenharmony_ci // Check the TX/SX value, if set then it's a Vector register. 2781cb0ef41Sopenharmony_ci if (instr->Bit(0) == 1) { 2791cb0ef41Sopenharmony_ci return FormatVectorRegister(instr, format); 2801cb0ef41Sopenharmony_ci } 2811cb0ef41Sopenharmony_ci // Double (VSX) register. 2821cb0ef41Sopenharmony_ci return FormatFPRegister(instr, format); 2831cb0ef41Sopenharmony_ci } 2841cb0ef41Sopenharmony_ci case 'V': { 2851cb0ef41Sopenharmony_ci return FormatVectorRegister(instr, format); 2861cb0ef41Sopenharmony_ci } 2871cb0ef41Sopenharmony_ci case 'i': { // int16 2881cb0ef41Sopenharmony_ci int64_t value; 2891cb0ef41Sopenharmony_ci uint32_t imm_value = instr->Bits(15, 0); 2901cb0ef41Sopenharmony_ci if (IsPrefixed()) { 2911cb0ef41Sopenharmony_ci uint64_t prefix_value = GetPrefixValue(); 2921cb0ef41Sopenharmony_ci value = SIGN_EXT_IMM34((prefix_value << 16) | imm_value); 2931cb0ef41Sopenharmony_ci } else { 2941cb0ef41Sopenharmony_ci value = (static_cast<int64_t>(imm_value) << 48) >> 48; 2951cb0ef41Sopenharmony_ci } 2961cb0ef41Sopenharmony_ci out_buffer_pos_ += 2971cb0ef41Sopenharmony_ci base::SNPrintF(out_buffer_ + out_buffer_pos_, "%ld", value); 2981cb0ef41Sopenharmony_ci return 5; 2991cb0ef41Sopenharmony_ci } 3001cb0ef41Sopenharmony_ci case 'I': { // IMM8 3011cb0ef41Sopenharmony_ci int8_t value = instr->Bits(18, 11); 3021cb0ef41Sopenharmony_ci out_buffer_pos_ += 3031cb0ef41Sopenharmony_ci base::SNPrintF(out_buffer_ + out_buffer_pos_, "%d", value); 3041cb0ef41Sopenharmony_ci return 4; 3051cb0ef41Sopenharmony_ci } 3061cb0ef41Sopenharmony_ci case 'u': { // uint16 3071cb0ef41Sopenharmony_ci int32_t value = instr->Bits(15, 0); 3081cb0ef41Sopenharmony_ci out_buffer_pos_ += 3091cb0ef41Sopenharmony_ci base::SNPrintF(out_buffer_ + out_buffer_pos_, "%d", value); 3101cb0ef41Sopenharmony_ci return 6; 3111cb0ef41Sopenharmony_ci } 3121cb0ef41Sopenharmony_ci case 'F': { // FXM 3131cb0ef41Sopenharmony_ci uint8_t value = instr->Bits(19, 12); 3141cb0ef41Sopenharmony_ci out_buffer_pos_ += 3151cb0ef41Sopenharmony_ci base::SNPrintF(out_buffer_ + out_buffer_pos_, "%d", value); 3161cb0ef41Sopenharmony_ci return 3; 3171cb0ef41Sopenharmony_ci } 3181cb0ef41Sopenharmony_ci case 'S': { // SIM 3191cb0ef41Sopenharmony_ci int32_t value = static_cast<int32_t>(SIGN_EXT_IMM5(instr->Bits(20, 16))); 3201cb0ef41Sopenharmony_ci out_buffer_pos_ += 3211cb0ef41Sopenharmony_ci base::SNPrintF(out_buffer_ + out_buffer_pos_, "%d", value); 3221cb0ef41Sopenharmony_ci return 3; 3231cb0ef41Sopenharmony_ci } 3241cb0ef41Sopenharmony_ci case 'U': { // UIM 3251cb0ef41Sopenharmony_ci uint8_t value = instr->Bits(19, 16); 3261cb0ef41Sopenharmony_ci out_buffer_pos_ += 3271cb0ef41Sopenharmony_ci base::SNPrintF(out_buffer_ + out_buffer_pos_, "%d", value); 3281cb0ef41Sopenharmony_ci return 3; 3291cb0ef41Sopenharmony_ci } 3301cb0ef41Sopenharmony_ci case 'l': { 3311cb0ef41Sopenharmony_ci // Link (LK) Bit 0 3321cb0ef41Sopenharmony_ci if (instr->Bit(0) == 1) { 3331cb0ef41Sopenharmony_ci Print("l"); 3341cb0ef41Sopenharmony_ci } 3351cb0ef41Sopenharmony_ci return 1; 3361cb0ef41Sopenharmony_ci } 3371cb0ef41Sopenharmony_ci case 'a': { 3381cb0ef41Sopenharmony_ci // Absolute Address Bit 1 3391cb0ef41Sopenharmony_ci if (instr->Bit(1) == 1) { 3401cb0ef41Sopenharmony_ci Print("a"); 3411cb0ef41Sopenharmony_ci } 3421cb0ef41Sopenharmony_ci return 1; 3431cb0ef41Sopenharmony_ci } 3441cb0ef41Sopenharmony_ci case 'c': { // 'cr: condition register of branch instruction 3451cb0ef41Sopenharmony_ci int code = instr->Bits(20, 18); 3461cb0ef41Sopenharmony_ci if (code != 7) { 3471cb0ef41Sopenharmony_ci out_buffer_pos_ += 3481cb0ef41Sopenharmony_ci base::SNPrintF(out_buffer_ + out_buffer_pos_, " cr%d", code); 3491cb0ef41Sopenharmony_ci } 3501cb0ef41Sopenharmony_ci return 2; 3511cb0ef41Sopenharmony_ci } 3521cb0ef41Sopenharmony_ci case 't': { // 'target: target of branch instructions 3531cb0ef41Sopenharmony_ci // target26 or target16 3541cb0ef41Sopenharmony_ci DCHECK(STRING_STARTS_WITH(format, "target")); 3551cb0ef41Sopenharmony_ci if ((format[6] == '2') && (format[7] == '6')) { 3561cb0ef41Sopenharmony_ci int off = ((instr->Bits(25, 2)) << 8) >> 6; 3571cb0ef41Sopenharmony_ci out_buffer_pos_ += base::SNPrintF( 3581cb0ef41Sopenharmony_ci out_buffer_ + out_buffer_pos_, "%+d -> %s", off, 3591cb0ef41Sopenharmony_ci converter_.NameOfAddress(reinterpret_cast<byte*>(instr) + off)); 3601cb0ef41Sopenharmony_ci return 8; 3611cb0ef41Sopenharmony_ci } else if ((format[6] == '1') && (format[7] == '6')) { 3621cb0ef41Sopenharmony_ci int off = ((instr->Bits(15, 2)) << 18) >> 16; 3631cb0ef41Sopenharmony_ci out_buffer_pos_ += base::SNPrintF( 3641cb0ef41Sopenharmony_ci out_buffer_ + out_buffer_pos_, "%+d -> %s", off, 3651cb0ef41Sopenharmony_ci converter_.NameOfAddress(reinterpret_cast<byte*>(instr) + off)); 3661cb0ef41Sopenharmony_ci return 8; 3671cb0ef41Sopenharmony_ci } 3681cb0ef41Sopenharmony_ci break; 3691cb0ef41Sopenharmony_ci case 's': { 3701cb0ef41Sopenharmony_ci DCHECK_EQ(format[1], 'h'); 3711cb0ef41Sopenharmony_ci int32_t value = 0; 3721cb0ef41Sopenharmony_ci int32_t opcode = instr->OpcodeValue() << 26; 3731cb0ef41Sopenharmony_ci int32_t sh = instr->Bits(15, 11); 3741cb0ef41Sopenharmony_ci if (opcode == EXT5 || 3751cb0ef41Sopenharmony_ci (opcode == EXT2 && instr->Bits(10, 2) << 2 == SRADIX)) { 3761cb0ef41Sopenharmony_ci // SH Bits 1 and 15-11 (split field) 3771cb0ef41Sopenharmony_ci value = (sh | (instr->Bit(1) << 5)); 3781cb0ef41Sopenharmony_ci } else { 3791cb0ef41Sopenharmony_ci // SH Bits 15-11 3801cb0ef41Sopenharmony_ci value = (sh << 26) >> 26; 3811cb0ef41Sopenharmony_ci } 3821cb0ef41Sopenharmony_ci out_buffer_pos_ += 3831cb0ef41Sopenharmony_ci base::SNPrintF(out_buffer_ + out_buffer_pos_, "%d", value); 3841cb0ef41Sopenharmony_ci return 2; 3851cb0ef41Sopenharmony_ci } 3861cb0ef41Sopenharmony_ci case 'm': { 3871cb0ef41Sopenharmony_ci int32_t value = 0; 3881cb0ef41Sopenharmony_ci if (format[1] == 'e') { 3891cb0ef41Sopenharmony_ci if (instr->OpcodeValue() << 26 != EXT5) { 3901cb0ef41Sopenharmony_ci // ME Bits 10-6 3911cb0ef41Sopenharmony_ci value = (instr->Bits(10, 6) << 26) >> 26; 3921cb0ef41Sopenharmony_ci } else { 3931cb0ef41Sopenharmony_ci // ME Bits 5 and 10-6 (split field) 3941cb0ef41Sopenharmony_ci value = (instr->Bits(10, 6) | (instr->Bit(5) << 5)); 3951cb0ef41Sopenharmony_ci } 3961cb0ef41Sopenharmony_ci } else if (format[1] == 'b') { 3971cb0ef41Sopenharmony_ci if (instr->OpcodeValue() << 26 != EXT5) { 3981cb0ef41Sopenharmony_ci // MB Bits 5-1 3991cb0ef41Sopenharmony_ci value = (instr->Bits(5, 1) << 26) >> 26; 4001cb0ef41Sopenharmony_ci } else { 4011cb0ef41Sopenharmony_ci // MB Bits 5 and 10-6 (split field) 4021cb0ef41Sopenharmony_ci value = (instr->Bits(10, 6) | (instr->Bit(5) << 5)); 4031cb0ef41Sopenharmony_ci } 4041cb0ef41Sopenharmony_ci } else { 4051cb0ef41Sopenharmony_ci UNREACHABLE(); // bad format 4061cb0ef41Sopenharmony_ci } 4071cb0ef41Sopenharmony_ci out_buffer_pos_ += 4081cb0ef41Sopenharmony_ci base::SNPrintF(out_buffer_ + out_buffer_pos_, "%d", value); 4091cb0ef41Sopenharmony_ci return 2; 4101cb0ef41Sopenharmony_ci } 4111cb0ef41Sopenharmony_ci } 4121cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_PPC64 4131cb0ef41Sopenharmony_ci case 'd': { // ds value for offset 4141cb0ef41Sopenharmony_ci int32_t value = SIGN_EXT_IMM16(instr->Bits(15, 0) & ~3); 4151cb0ef41Sopenharmony_ci out_buffer_pos_ += 4161cb0ef41Sopenharmony_ci base::SNPrintF(out_buffer_ + out_buffer_pos_, "%d", value); 4171cb0ef41Sopenharmony_ci return 1; 4181cb0ef41Sopenharmony_ci } 4191cb0ef41Sopenharmony_ci#endif 4201cb0ef41Sopenharmony_ci default: { 4211cb0ef41Sopenharmony_ci UNREACHABLE(); 4221cb0ef41Sopenharmony_ci } 4231cb0ef41Sopenharmony_ci } 4241cb0ef41Sopenharmony_ci 4251cb0ef41Sopenharmony_ci UNREACHABLE(); 4261cb0ef41Sopenharmony_ci} 4271cb0ef41Sopenharmony_ci 4281cb0ef41Sopenharmony_ci// Format takes a formatting string for a whole instruction and prints it into 4291cb0ef41Sopenharmony_ci// the output buffer. All escaped options are handed to FormatOption to be 4301cb0ef41Sopenharmony_ci// parsed further. 4311cb0ef41Sopenharmony_civoid Decoder::Format(Instruction* instr, const char* format) { 4321cb0ef41Sopenharmony_ci char cur = *format++; 4331cb0ef41Sopenharmony_ci while ((cur != 0) && (out_buffer_pos_ < (out_buffer_.length() - 1))) { 4341cb0ef41Sopenharmony_ci if (cur == '\'') { // Single quote is used as the formatting escape. 4351cb0ef41Sopenharmony_ci format += FormatOption(instr, format); 4361cb0ef41Sopenharmony_ci } else { 4371cb0ef41Sopenharmony_ci out_buffer_[out_buffer_pos_++] = cur; 4381cb0ef41Sopenharmony_ci } 4391cb0ef41Sopenharmony_ci cur = *format++; 4401cb0ef41Sopenharmony_ci } 4411cb0ef41Sopenharmony_ci out_buffer_[out_buffer_pos_] = '\0'; 4421cb0ef41Sopenharmony_ci} 4431cb0ef41Sopenharmony_ci 4441cb0ef41Sopenharmony_ci// The disassembler may end up decoding data inlined in the code. We do not want 4451cb0ef41Sopenharmony_ci// it to crash if the data does not resemble any known instruction. 4461cb0ef41Sopenharmony_ci#define VERIFY(condition) \ 4471cb0ef41Sopenharmony_ci if (!(condition)) { \ 4481cb0ef41Sopenharmony_ci Unknown(instr); \ 4491cb0ef41Sopenharmony_ci return; \ 4501cb0ef41Sopenharmony_ci } 4511cb0ef41Sopenharmony_ci 4521cb0ef41Sopenharmony_ci// For currently unimplemented decodings the disassembler calls Unknown(instr) 4531cb0ef41Sopenharmony_ci// which will just print "unknown" of the instruction bits. 4541cb0ef41Sopenharmony_civoid Decoder::Unknown(Instruction* instr) { Format(instr, "unknown"); } 4551cb0ef41Sopenharmony_ci 4561cb0ef41Sopenharmony_ci// For currently unimplemented decodings the disassembler calls 4571cb0ef41Sopenharmony_ci// UnknownFormat(instr) which will just print opcode name of the 4581cb0ef41Sopenharmony_ci// instruction bits. 4591cb0ef41Sopenharmony_civoid Decoder::UnknownFormat(Instruction* instr, const char* name) { 4601cb0ef41Sopenharmony_ci char buffer[100]; 4611cb0ef41Sopenharmony_ci snprintf(buffer, sizeof(buffer), "%s (unknown-format)", name); 4621cb0ef41Sopenharmony_ci Format(instr, buffer); 4631cb0ef41Sopenharmony_ci} 4641cb0ef41Sopenharmony_ci 4651cb0ef41Sopenharmony_civoid Decoder::DecodeExtP(Instruction* instr) { 4661cb0ef41Sopenharmony_ci switch (EXTP | (instr->BitField(25, 25))) { 4671cb0ef41Sopenharmony_ci case PLOAD_STORE_8LS: 4681cb0ef41Sopenharmony_ci case PLOAD_STORE_MLS: { 4691cb0ef41Sopenharmony_ci // TODO(miladfarca): Decode the R bit. 4701cb0ef41Sopenharmony_ci DCHECK_NE(instr->Bit(20), 1); 4711cb0ef41Sopenharmony_ci // Read prefix. 4721cb0ef41Sopenharmony_ci SetAsPrefixed(instr->Bits(17, 0)); 4731cb0ef41Sopenharmony_ci // Read suffix (next instruction). 4741cb0ef41Sopenharmony_ci Instruction* next_instr = 4751cb0ef41Sopenharmony_ci bit_cast<Instruction*>(bit_cast<intptr_t>(instr) + kInstrSize); 4761cb0ef41Sopenharmony_ci switch (next_instr->OpcodeBase()) { 4771cb0ef41Sopenharmony_ci // Prefixed ADDI. 4781cb0ef41Sopenharmony_ci case (ADDI): { 4791cb0ef41Sopenharmony_ci if (next_instr->RAValue() == 0) { 4801cb0ef41Sopenharmony_ci // This is load immediate prefixed. 4811cb0ef41Sopenharmony_ci Format(instr, "pli"); 4821cb0ef41Sopenharmony_ci Format(next_instr, " 'rt, "); 4831cb0ef41Sopenharmony_ci } else { 4841cb0ef41Sopenharmony_ci Format(instr, "paddi"); 4851cb0ef41Sopenharmony_ci Format(next_instr, " 'rt, 'ra, "); 4861cb0ef41Sopenharmony_ci } 4871cb0ef41Sopenharmony_ci Format(next_instr, "'int34"); 4881cb0ef41Sopenharmony_ci break; 4891cb0ef41Sopenharmony_ci } 4901cb0ef41Sopenharmony_ci // Prefixed LBZ. 4911cb0ef41Sopenharmony_ci case LBZ: { 4921cb0ef41Sopenharmony_ci Format(next_instr, "plbz 'rt, 'int34('ra)"); 4931cb0ef41Sopenharmony_ci break; 4941cb0ef41Sopenharmony_ci } 4951cb0ef41Sopenharmony_ci // Prefixed LHZ. 4961cb0ef41Sopenharmony_ci case LHZ: { 4971cb0ef41Sopenharmony_ci Format(next_instr, "plhz 'rt, 'int34('ra)"); 4981cb0ef41Sopenharmony_ci break; 4991cb0ef41Sopenharmony_ci } 5001cb0ef41Sopenharmony_ci // Prefixed LHA. 5011cb0ef41Sopenharmony_ci case LHA: { 5021cb0ef41Sopenharmony_ci Format(next_instr, "plha 'rt, 'int34('ra)"); 5031cb0ef41Sopenharmony_ci break; 5041cb0ef41Sopenharmony_ci } 5051cb0ef41Sopenharmony_ci // Prefixed LWZ. 5061cb0ef41Sopenharmony_ci case LWZ: { 5071cb0ef41Sopenharmony_ci Format(next_instr, "plwz 'rt, 'int34('ra)"); 5081cb0ef41Sopenharmony_ci break; 5091cb0ef41Sopenharmony_ci } 5101cb0ef41Sopenharmony_ci // Prefixed LWA. 5111cb0ef41Sopenharmony_ci case PPLWA: { 5121cb0ef41Sopenharmony_ci Format(next_instr, "plwa 'rt, 'int34('ra)"); 5131cb0ef41Sopenharmony_ci break; 5141cb0ef41Sopenharmony_ci } 5151cb0ef41Sopenharmony_ci // Prefixed LD. 5161cb0ef41Sopenharmony_ci case PPLD: { 5171cb0ef41Sopenharmony_ci Format(next_instr, "pld 'rt, 'int34('ra)"); 5181cb0ef41Sopenharmony_ci break; 5191cb0ef41Sopenharmony_ci } 5201cb0ef41Sopenharmony_ci // Prefixed LFS. 5211cb0ef41Sopenharmony_ci case LFS: { 5221cb0ef41Sopenharmony_ci Format(next_instr, "plfs 'Dt, 'int34('ra)"); 5231cb0ef41Sopenharmony_ci break; 5241cb0ef41Sopenharmony_ci } 5251cb0ef41Sopenharmony_ci // Prefixed LFD. 5261cb0ef41Sopenharmony_ci case LFD: { 5271cb0ef41Sopenharmony_ci Format(next_instr, "plfd 'Dt, 'int34('ra)"); 5281cb0ef41Sopenharmony_ci break; 5291cb0ef41Sopenharmony_ci } 5301cb0ef41Sopenharmony_ci default: { 5311cb0ef41Sopenharmony_ci Unknown(instr); 5321cb0ef41Sopenharmony_ci } 5331cb0ef41Sopenharmony_ci } 5341cb0ef41Sopenharmony_ci break; 5351cb0ef41Sopenharmony_ci } 5361cb0ef41Sopenharmony_ci default: { 5371cb0ef41Sopenharmony_ci Unknown(instr); 5381cb0ef41Sopenharmony_ci } 5391cb0ef41Sopenharmony_ci } 5401cb0ef41Sopenharmony_ci} 5411cb0ef41Sopenharmony_ci 5421cb0ef41Sopenharmony_civoid Decoder::DecodeExt0(Instruction* instr) { 5431cb0ef41Sopenharmony_ci // Some encodings have integers hard coded in the middle, handle those first. 5441cb0ef41Sopenharmony_ci switch (EXT0 | (instr->BitField(20, 16)) | (instr->BitField(10, 0))) { 5451cb0ef41Sopenharmony_ci#define DECODE_VX_D_FORM__INSTRUCTIONS(name, opcode_name, opcode_value) \ 5461cb0ef41Sopenharmony_ci case opcode_name: { \ 5471cb0ef41Sopenharmony_ci Format(instr, #name " 'Vt, 'Vb"); \ 5481cb0ef41Sopenharmony_ci return; \ 5491cb0ef41Sopenharmony_ci } 5501cb0ef41Sopenharmony_ci PPC_VX_OPCODE_D_FORM_LIST(DECODE_VX_D_FORM__INSTRUCTIONS) 5511cb0ef41Sopenharmony_ci#undef DECODE_VX_D_FORM__INSTRUCTIONS 5521cb0ef41Sopenharmony_ci#define DECODE_VX_F_FORM__INSTRUCTIONS(name, opcode_name, opcode_value) \ 5531cb0ef41Sopenharmony_ci case opcode_name: { \ 5541cb0ef41Sopenharmony_ci Format(instr, #name " 'rt, 'Vb"); \ 5551cb0ef41Sopenharmony_ci return; \ 5561cb0ef41Sopenharmony_ci } 5571cb0ef41Sopenharmony_ci PPC_VX_OPCODE_F_FORM_LIST(DECODE_VX_F_FORM__INSTRUCTIONS) 5581cb0ef41Sopenharmony_ci#undef DECODE_VX_F_FORM__INSTRUCTIONS 5591cb0ef41Sopenharmony_ci } 5601cb0ef41Sopenharmony_ci // Some encodings are 5-0 bits, handle those first 5611cb0ef41Sopenharmony_ci switch (EXT0 | (instr->BitField(5, 0))) { 5621cb0ef41Sopenharmony_ci#define DECODE_VA_A_FORM__INSTRUCTIONS(name, opcode_name, opcode_value) \ 5631cb0ef41Sopenharmony_ci case opcode_name: { \ 5641cb0ef41Sopenharmony_ci Format(instr, #name " 'Vt, 'Va, 'Vb, 'Vc"); \ 5651cb0ef41Sopenharmony_ci return; \ 5661cb0ef41Sopenharmony_ci } 5671cb0ef41Sopenharmony_ci PPC_VA_OPCODE_A_FORM_LIST(DECODE_VA_A_FORM__INSTRUCTIONS) 5681cb0ef41Sopenharmony_ci#undef DECODE_VA_A_FORM__INSTRUCTIONS 5691cb0ef41Sopenharmony_ci } 5701cb0ef41Sopenharmony_ci switch (EXT0 | (instr->BitField(9, 0))) { 5711cb0ef41Sopenharmony_ci// TODO(miladfarca): Fix RC indicator. 5721cb0ef41Sopenharmony_ci#define DECODE_VC_FORM__INSTRUCTIONS(name, opcode_name, opcode_value) \ 5731cb0ef41Sopenharmony_ci case opcode_name: { \ 5741cb0ef41Sopenharmony_ci Format(instr, #name " 'Vt, 'Va, 'Vb"); \ 5751cb0ef41Sopenharmony_ci return; \ 5761cb0ef41Sopenharmony_ci } 5771cb0ef41Sopenharmony_ci PPC_VC_OPCODE_LIST(DECODE_VC_FORM__INSTRUCTIONS) 5781cb0ef41Sopenharmony_ci#undef DECODE_VC_FORM__INSTRUCTIONS 5791cb0ef41Sopenharmony_ci } 5801cb0ef41Sopenharmony_ci switch (EXT0 | (instr->BitField(10, 0))) { 5811cb0ef41Sopenharmony_ci#define DECODE_VX_A_FORM__INSTRUCTIONS(name, opcode_name, opcode_value) \ 5821cb0ef41Sopenharmony_ci case opcode_name: { \ 5831cb0ef41Sopenharmony_ci Format(instr, #name " 'Vt, 'Vb, 'UIM"); \ 5841cb0ef41Sopenharmony_ci return; \ 5851cb0ef41Sopenharmony_ci } 5861cb0ef41Sopenharmony_ci PPC_VX_OPCODE_A_FORM_LIST(DECODE_VX_A_FORM__INSTRUCTIONS) 5871cb0ef41Sopenharmony_ci#undef DECODE_VX_A_FORM__INSTRUCTIONS 5881cb0ef41Sopenharmony_ci#define DECODE_VX_B_FORM__INSTRUCTIONS(name, opcode_name, opcode_value) \ 5891cb0ef41Sopenharmony_ci case opcode_name: { \ 5901cb0ef41Sopenharmony_ci Format(instr, #name " 'Vt, 'Va, 'Vb"); \ 5911cb0ef41Sopenharmony_ci return; \ 5921cb0ef41Sopenharmony_ci } 5931cb0ef41Sopenharmony_ci PPC_VX_OPCODE_B_FORM_LIST(DECODE_VX_B_FORM__INSTRUCTIONS) 5941cb0ef41Sopenharmony_ci#undef DECODE_VX_B_FORM__INSTRUCTIONS 5951cb0ef41Sopenharmony_ci#define DECODE_VX_C_FORM__INSTRUCTIONS(name, opcode_name, opcode_value) \ 5961cb0ef41Sopenharmony_ci case opcode_name: { \ 5971cb0ef41Sopenharmony_ci Format(instr, #name " 'Vt, 'Vb"); \ 5981cb0ef41Sopenharmony_ci return; \ 5991cb0ef41Sopenharmony_ci } 6001cb0ef41Sopenharmony_ci PPC_VX_OPCODE_C_FORM_LIST(DECODE_VX_C_FORM__INSTRUCTIONS) 6011cb0ef41Sopenharmony_ci#undef DECODE_VX_C_FORM__INSTRUCTIONS 6021cb0ef41Sopenharmony_ci#define DECODE_VX_E_FORM__INSTRUCTIONS(name, opcode_name, opcode_value) \ 6031cb0ef41Sopenharmony_ci case opcode_name: { \ 6041cb0ef41Sopenharmony_ci Format(instr, #name " 'Vt, 'SIM"); \ 6051cb0ef41Sopenharmony_ci return; \ 6061cb0ef41Sopenharmony_ci } 6071cb0ef41Sopenharmony_ci PPC_VX_OPCODE_E_FORM_LIST(DECODE_VX_E_FORM__INSTRUCTIONS) 6081cb0ef41Sopenharmony_ci#undef DECODE_VX_E_FORM__INSTRUCTIONS 6091cb0ef41Sopenharmony_ci#define DECODE_VX_G_FORM__INSTRUCTIONS(name, opcode_name, opcode_value) \ 6101cb0ef41Sopenharmony_ci case opcode_name: { \ 6111cb0ef41Sopenharmony_ci Format(instr, #name " 'Vt, 'rb, 'UIM"); \ 6121cb0ef41Sopenharmony_ci return; \ 6131cb0ef41Sopenharmony_ci } 6141cb0ef41Sopenharmony_ci PPC_VX_OPCODE_G_FORM_LIST(DECODE_VX_G_FORM__INSTRUCTIONS) 6151cb0ef41Sopenharmony_ci#undef DECODE_VX_G_FORM__INSTRUCTIONS 6161cb0ef41Sopenharmony_ci } 6171cb0ef41Sopenharmony_ci} 6181cb0ef41Sopenharmony_ci 6191cb0ef41Sopenharmony_civoid Decoder::DecodeExt1(Instruction* instr) { 6201cb0ef41Sopenharmony_ci switch (EXT1 | (instr->BitField(10, 1))) { 6211cb0ef41Sopenharmony_ci case MCRF: { 6221cb0ef41Sopenharmony_ci UnknownFormat(instr, "mcrf"); // not used by V8 6231cb0ef41Sopenharmony_ci break; 6241cb0ef41Sopenharmony_ci } 6251cb0ef41Sopenharmony_ci case BCLRX: { 6261cb0ef41Sopenharmony_ci int bo = instr->BitField(25, 21); 6271cb0ef41Sopenharmony_ci int bi = instr->Bits(20, 16); 6281cb0ef41Sopenharmony_ci CRBit cond = static_cast<CRBit>(bi & (CRWIDTH - 1)); 6291cb0ef41Sopenharmony_ci switch (bo) { 6301cb0ef41Sopenharmony_ci case DCBNZF: { 6311cb0ef41Sopenharmony_ci UnknownFormat(instr, "bclrx-dcbnzf"); 6321cb0ef41Sopenharmony_ci break; 6331cb0ef41Sopenharmony_ci } 6341cb0ef41Sopenharmony_ci case DCBEZF: { 6351cb0ef41Sopenharmony_ci UnknownFormat(instr, "bclrx-dcbezf"); 6361cb0ef41Sopenharmony_ci break; 6371cb0ef41Sopenharmony_ci } 6381cb0ef41Sopenharmony_ci case BF: { 6391cb0ef41Sopenharmony_ci switch (cond) { 6401cb0ef41Sopenharmony_ci case CR_EQ: 6411cb0ef41Sopenharmony_ci Format(instr, "bnelr'l'cr"); 6421cb0ef41Sopenharmony_ci break; 6431cb0ef41Sopenharmony_ci case CR_GT: 6441cb0ef41Sopenharmony_ci Format(instr, "blelr'l'cr"); 6451cb0ef41Sopenharmony_ci break; 6461cb0ef41Sopenharmony_ci case CR_LT: 6471cb0ef41Sopenharmony_ci Format(instr, "bgelr'l'cr"); 6481cb0ef41Sopenharmony_ci break; 6491cb0ef41Sopenharmony_ci case CR_SO: 6501cb0ef41Sopenharmony_ci Format(instr, "bnsolr'l'cr"); 6511cb0ef41Sopenharmony_ci break; 6521cb0ef41Sopenharmony_ci } 6531cb0ef41Sopenharmony_ci break; 6541cb0ef41Sopenharmony_ci } 6551cb0ef41Sopenharmony_ci case DCBNZT: { 6561cb0ef41Sopenharmony_ci UnknownFormat(instr, "bclrx-dcbbzt"); 6571cb0ef41Sopenharmony_ci break; 6581cb0ef41Sopenharmony_ci } 6591cb0ef41Sopenharmony_ci case DCBEZT: { 6601cb0ef41Sopenharmony_ci UnknownFormat(instr, "bclrx-dcbnezt"); 6611cb0ef41Sopenharmony_ci break; 6621cb0ef41Sopenharmony_ci } 6631cb0ef41Sopenharmony_ci case BT: { 6641cb0ef41Sopenharmony_ci switch (cond) { 6651cb0ef41Sopenharmony_ci case CR_EQ: 6661cb0ef41Sopenharmony_ci Format(instr, "beqlr'l'cr"); 6671cb0ef41Sopenharmony_ci break; 6681cb0ef41Sopenharmony_ci case CR_GT: 6691cb0ef41Sopenharmony_ci Format(instr, "bgtlr'l'cr"); 6701cb0ef41Sopenharmony_ci break; 6711cb0ef41Sopenharmony_ci case CR_LT: 6721cb0ef41Sopenharmony_ci Format(instr, "bltlr'l'cr"); 6731cb0ef41Sopenharmony_ci break; 6741cb0ef41Sopenharmony_ci case CR_SO: 6751cb0ef41Sopenharmony_ci Format(instr, "bsolr'l'cr"); 6761cb0ef41Sopenharmony_ci break; 6771cb0ef41Sopenharmony_ci } 6781cb0ef41Sopenharmony_ci break; 6791cb0ef41Sopenharmony_ci } 6801cb0ef41Sopenharmony_ci case DCBNZ: { 6811cb0ef41Sopenharmony_ci UnknownFormat(instr, "bclrx-dcbnz"); 6821cb0ef41Sopenharmony_ci break; 6831cb0ef41Sopenharmony_ci } 6841cb0ef41Sopenharmony_ci case DCBEZ: { 6851cb0ef41Sopenharmony_ci UnknownFormat(instr, "bclrx-dcbez"); // not used by V8 6861cb0ef41Sopenharmony_ci break; 6871cb0ef41Sopenharmony_ci } 6881cb0ef41Sopenharmony_ci case BA: { 6891cb0ef41Sopenharmony_ci Format(instr, "blr'l"); 6901cb0ef41Sopenharmony_ci break; 6911cb0ef41Sopenharmony_ci } 6921cb0ef41Sopenharmony_ci } 6931cb0ef41Sopenharmony_ci break; 6941cb0ef41Sopenharmony_ci } 6951cb0ef41Sopenharmony_ci case BCCTRX: { 6961cb0ef41Sopenharmony_ci switch (instr->BitField(25, 21)) { 6971cb0ef41Sopenharmony_ci case DCBNZF: { 6981cb0ef41Sopenharmony_ci UnknownFormat(instr, "bcctrx-dcbnzf"); 6991cb0ef41Sopenharmony_ci break; 7001cb0ef41Sopenharmony_ci } 7011cb0ef41Sopenharmony_ci case DCBEZF: { 7021cb0ef41Sopenharmony_ci UnknownFormat(instr, "bcctrx-dcbezf"); 7031cb0ef41Sopenharmony_ci break; 7041cb0ef41Sopenharmony_ci } 7051cb0ef41Sopenharmony_ci case BF: { 7061cb0ef41Sopenharmony_ci UnknownFormat(instr, "bcctrx-bf"); 7071cb0ef41Sopenharmony_ci break; 7081cb0ef41Sopenharmony_ci } 7091cb0ef41Sopenharmony_ci case DCBNZT: { 7101cb0ef41Sopenharmony_ci UnknownFormat(instr, "bcctrx-dcbnzt"); 7111cb0ef41Sopenharmony_ci break; 7121cb0ef41Sopenharmony_ci } 7131cb0ef41Sopenharmony_ci case DCBEZT: { 7141cb0ef41Sopenharmony_ci UnknownFormat(instr, "bcctrx-dcbezf"); 7151cb0ef41Sopenharmony_ci break; 7161cb0ef41Sopenharmony_ci } 7171cb0ef41Sopenharmony_ci case BT: { 7181cb0ef41Sopenharmony_ci UnknownFormat(instr, "bcctrx-bt"); 7191cb0ef41Sopenharmony_ci break; 7201cb0ef41Sopenharmony_ci } 7211cb0ef41Sopenharmony_ci case DCBNZ: { 7221cb0ef41Sopenharmony_ci UnknownFormat(instr, "bcctrx-dcbnz"); 7231cb0ef41Sopenharmony_ci break; 7241cb0ef41Sopenharmony_ci } 7251cb0ef41Sopenharmony_ci case DCBEZ: { 7261cb0ef41Sopenharmony_ci UnknownFormat(instr, "bcctrx-dcbez"); 7271cb0ef41Sopenharmony_ci break; 7281cb0ef41Sopenharmony_ci } 7291cb0ef41Sopenharmony_ci case BA: { 7301cb0ef41Sopenharmony_ci if (instr->Bit(0) == 1) { 7311cb0ef41Sopenharmony_ci Format(instr, "bctrl"); 7321cb0ef41Sopenharmony_ci } else { 7331cb0ef41Sopenharmony_ci Format(instr, "bctr"); 7341cb0ef41Sopenharmony_ci } 7351cb0ef41Sopenharmony_ci break; 7361cb0ef41Sopenharmony_ci } 7371cb0ef41Sopenharmony_ci default: { 7381cb0ef41Sopenharmony_ci UNREACHABLE(); 7391cb0ef41Sopenharmony_ci } 7401cb0ef41Sopenharmony_ci } 7411cb0ef41Sopenharmony_ci break; 7421cb0ef41Sopenharmony_ci } 7431cb0ef41Sopenharmony_ci case CRNOR: { 7441cb0ef41Sopenharmony_ci Format(instr, "crnor (stuff)"); 7451cb0ef41Sopenharmony_ci break; 7461cb0ef41Sopenharmony_ci } 7471cb0ef41Sopenharmony_ci case RFI: { 7481cb0ef41Sopenharmony_ci Format(instr, "rfi (stuff)"); 7491cb0ef41Sopenharmony_ci break; 7501cb0ef41Sopenharmony_ci } 7511cb0ef41Sopenharmony_ci case CRANDC: { 7521cb0ef41Sopenharmony_ci Format(instr, "crandc (stuff)"); 7531cb0ef41Sopenharmony_ci break; 7541cb0ef41Sopenharmony_ci } 7551cb0ef41Sopenharmony_ci case ISYNC: { 7561cb0ef41Sopenharmony_ci Format(instr, "isync (stuff)"); 7571cb0ef41Sopenharmony_ci break; 7581cb0ef41Sopenharmony_ci } 7591cb0ef41Sopenharmony_ci case CRXOR: { 7601cb0ef41Sopenharmony_ci Format(instr, "crxor (stuff)"); 7611cb0ef41Sopenharmony_ci break; 7621cb0ef41Sopenharmony_ci } 7631cb0ef41Sopenharmony_ci case CRNAND: { 7641cb0ef41Sopenharmony_ci UnknownFormat(instr, "crnand"); 7651cb0ef41Sopenharmony_ci break; 7661cb0ef41Sopenharmony_ci } 7671cb0ef41Sopenharmony_ci case CRAND: { 7681cb0ef41Sopenharmony_ci UnknownFormat(instr, "crand"); 7691cb0ef41Sopenharmony_ci break; 7701cb0ef41Sopenharmony_ci } 7711cb0ef41Sopenharmony_ci case CREQV: { 7721cb0ef41Sopenharmony_ci UnknownFormat(instr, "creqv"); 7731cb0ef41Sopenharmony_ci break; 7741cb0ef41Sopenharmony_ci } 7751cb0ef41Sopenharmony_ci case CRORC: { 7761cb0ef41Sopenharmony_ci UnknownFormat(instr, "crorc"); 7771cb0ef41Sopenharmony_ci break; 7781cb0ef41Sopenharmony_ci } 7791cb0ef41Sopenharmony_ci case CROR: { 7801cb0ef41Sopenharmony_ci UnknownFormat(instr, "cror"); 7811cb0ef41Sopenharmony_ci break; 7821cb0ef41Sopenharmony_ci } 7831cb0ef41Sopenharmony_ci default: { 7841cb0ef41Sopenharmony_ci Unknown(instr); // not used by V8 7851cb0ef41Sopenharmony_ci } 7861cb0ef41Sopenharmony_ci } 7871cb0ef41Sopenharmony_ci} 7881cb0ef41Sopenharmony_ci 7891cb0ef41Sopenharmony_civoid Decoder::DecodeExt2(Instruction* instr) { 7901cb0ef41Sopenharmony_ci // Some encodings are 10-1 bits, handle those first 7911cb0ef41Sopenharmony_ci switch (EXT2 | (instr->BitField(10, 1))) { 7921cb0ef41Sopenharmony_ci case LVX: { 7931cb0ef41Sopenharmony_ci Format(instr, "lvx 'Vt, 'ra, 'rb"); 7941cb0ef41Sopenharmony_ci return; 7951cb0ef41Sopenharmony_ci } 7961cb0ef41Sopenharmony_ci case STVX: { 7971cb0ef41Sopenharmony_ci Format(instr, "stvx 'Vs, 'ra, 'rb"); 7981cb0ef41Sopenharmony_ci return; 7991cb0ef41Sopenharmony_ci } 8001cb0ef41Sopenharmony_ci case LXVD: { 8011cb0ef41Sopenharmony_ci Format(instr, "lxvd 'Xt, 'ra, 'rb"); 8021cb0ef41Sopenharmony_ci return; 8031cb0ef41Sopenharmony_ci } 8041cb0ef41Sopenharmony_ci case LXVX: { 8051cb0ef41Sopenharmony_ci Format(instr, "lxvx 'Xt, 'ra, 'rb"); 8061cb0ef41Sopenharmony_ci return; 8071cb0ef41Sopenharmony_ci } 8081cb0ef41Sopenharmony_ci case LXSDX: { 8091cb0ef41Sopenharmony_ci Format(instr, "lxsdx 'Xt, 'ra, 'rb"); 8101cb0ef41Sopenharmony_ci return; 8111cb0ef41Sopenharmony_ci } 8121cb0ef41Sopenharmony_ci case LXSIBZX: { 8131cb0ef41Sopenharmony_ci Format(instr, "lxsibzx 'Xt, 'ra, 'rb"); 8141cb0ef41Sopenharmony_ci return; 8151cb0ef41Sopenharmony_ci } 8161cb0ef41Sopenharmony_ci case LXSIHZX: { 8171cb0ef41Sopenharmony_ci Format(instr, "lxsihzx 'Xt, 'ra, 'rb"); 8181cb0ef41Sopenharmony_ci return; 8191cb0ef41Sopenharmony_ci } 8201cb0ef41Sopenharmony_ci case LXSIWZX: { 8211cb0ef41Sopenharmony_ci Format(instr, "lxsiwzx 'Xt, 'ra, 'rb"); 8221cb0ef41Sopenharmony_ci return; 8231cb0ef41Sopenharmony_ci } 8241cb0ef41Sopenharmony_ci case STXVD: { 8251cb0ef41Sopenharmony_ci Format(instr, "stxvd 'Xs, 'ra, 'rb"); 8261cb0ef41Sopenharmony_ci return; 8271cb0ef41Sopenharmony_ci } 8281cb0ef41Sopenharmony_ci case STXVX: { 8291cb0ef41Sopenharmony_ci Format(instr, "stxvx 'Xs, 'ra, 'rb"); 8301cb0ef41Sopenharmony_ci return; 8311cb0ef41Sopenharmony_ci } 8321cb0ef41Sopenharmony_ci case STXSDX: { 8331cb0ef41Sopenharmony_ci Format(instr, "stxsdx 'Xs, 'ra, 'rb"); 8341cb0ef41Sopenharmony_ci return; 8351cb0ef41Sopenharmony_ci } 8361cb0ef41Sopenharmony_ci case STXSIBX: { 8371cb0ef41Sopenharmony_ci Format(instr, "stxsibx 'Xs, 'ra, 'rb"); 8381cb0ef41Sopenharmony_ci return; 8391cb0ef41Sopenharmony_ci } 8401cb0ef41Sopenharmony_ci case STXSIHX: { 8411cb0ef41Sopenharmony_ci Format(instr, "stxsihx 'Xs, 'ra, 'rb"); 8421cb0ef41Sopenharmony_ci return; 8431cb0ef41Sopenharmony_ci } 8441cb0ef41Sopenharmony_ci case STXSIWX: { 8451cb0ef41Sopenharmony_ci Format(instr, "stxsiwx 'Xs, 'ra, 'rb"); 8461cb0ef41Sopenharmony_ci return; 8471cb0ef41Sopenharmony_ci } 8481cb0ef41Sopenharmony_ci case SRWX: { 8491cb0ef41Sopenharmony_ci Format(instr, "srw'. 'ra, 'rs, 'rb"); 8501cb0ef41Sopenharmony_ci return; 8511cb0ef41Sopenharmony_ci } 8521cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_PPC64 8531cb0ef41Sopenharmony_ci case SRDX: { 8541cb0ef41Sopenharmony_ci Format(instr, "srd'. 'ra, 'rs, 'rb"); 8551cb0ef41Sopenharmony_ci return; 8561cb0ef41Sopenharmony_ci } 8571cb0ef41Sopenharmony_ci#endif 8581cb0ef41Sopenharmony_ci case SRAW: { 8591cb0ef41Sopenharmony_ci Format(instr, "sraw'. 'ra, 'rs, 'rb"); 8601cb0ef41Sopenharmony_ci return; 8611cb0ef41Sopenharmony_ci } 8621cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_PPC64 8631cb0ef41Sopenharmony_ci case SRAD: { 8641cb0ef41Sopenharmony_ci Format(instr, "srad'. 'ra, 'rs, 'rb"); 8651cb0ef41Sopenharmony_ci return; 8661cb0ef41Sopenharmony_ci } 8671cb0ef41Sopenharmony_ci#endif 8681cb0ef41Sopenharmony_ci case SYNC: { 8691cb0ef41Sopenharmony_ci Format(instr, "sync"); 8701cb0ef41Sopenharmony_ci return; 8711cb0ef41Sopenharmony_ci } 8721cb0ef41Sopenharmony_ci case MODSW: { 8731cb0ef41Sopenharmony_ci Format(instr, "modsw 'rt, 'ra, 'rb"); 8741cb0ef41Sopenharmony_ci return; 8751cb0ef41Sopenharmony_ci } 8761cb0ef41Sopenharmony_ci case MODUW: { 8771cb0ef41Sopenharmony_ci Format(instr, "moduw 'rt, 'ra, 'rb"); 8781cb0ef41Sopenharmony_ci return; 8791cb0ef41Sopenharmony_ci } 8801cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_PPC64 8811cb0ef41Sopenharmony_ci case MODSD: { 8821cb0ef41Sopenharmony_ci Format(instr, "modsd 'rt, 'ra, 'rb"); 8831cb0ef41Sopenharmony_ci return; 8841cb0ef41Sopenharmony_ci } 8851cb0ef41Sopenharmony_ci case MODUD: { 8861cb0ef41Sopenharmony_ci Format(instr, "modud 'rt, 'ra, 'rb"); 8871cb0ef41Sopenharmony_ci return; 8881cb0ef41Sopenharmony_ci } 8891cb0ef41Sopenharmony_ci#endif 8901cb0ef41Sopenharmony_ci case SRAWIX: { 8911cb0ef41Sopenharmony_ci Format(instr, "srawi'. 'ra,'rs,'sh"); 8921cb0ef41Sopenharmony_ci return; 8931cb0ef41Sopenharmony_ci } 8941cb0ef41Sopenharmony_ci case EXTSH: { 8951cb0ef41Sopenharmony_ci Format(instr, "extsh'. 'ra, 'rs"); 8961cb0ef41Sopenharmony_ci return; 8971cb0ef41Sopenharmony_ci } 8981cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_PPC64 8991cb0ef41Sopenharmony_ci case EXTSW: { 9001cb0ef41Sopenharmony_ci Format(instr, "extsw'. 'ra, 'rs"); 9011cb0ef41Sopenharmony_ci return; 9021cb0ef41Sopenharmony_ci } 9031cb0ef41Sopenharmony_ci#endif 9041cb0ef41Sopenharmony_ci case EXTSB: { 9051cb0ef41Sopenharmony_ci Format(instr, "extsb'. 'ra, 'rs"); 9061cb0ef41Sopenharmony_ci return; 9071cb0ef41Sopenharmony_ci } 9081cb0ef41Sopenharmony_ci case LFSX: { 9091cb0ef41Sopenharmony_ci Format(instr, "lfsx 'Dt, 'ra, 'rb"); 9101cb0ef41Sopenharmony_ci return; 9111cb0ef41Sopenharmony_ci } 9121cb0ef41Sopenharmony_ci case LFSUX: { 9131cb0ef41Sopenharmony_ci Format(instr, "lfsux 'Dt, 'ra, 'rb"); 9141cb0ef41Sopenharmony_ci return; 9151cb0ef41Sopenharmony_ci } 9161cb0ef41Sopenharmony_ci case LFDX: { 9171cb0ef41Sopenharmony_ci Format(instr, "lfdx 'Dt, 'ra, 'rb"); 9181cb0ef41Sopenharmony_ci return; 9191cb0ef41Sopenharmony_ci } 9201cb0ef41Sopenharmony_ci case LFDUX: { 9211cb0ef41Sopenharmony_ci Format(instr, "lfdux 'Dt, 'ra, 'rb"); 9221cb0ef41Sopenharmony_ci return; 9231cb0ef41Sopenharmony_ci } 9241cb0ef41Sopenharmony_ci case STFSX: { 9251cb0ef41Sopenharmony_ci Format(instr, "stfsx 'rs, 'ra, 'rb"); 9261cb0ef41Sopenharmony_ci return; 9271cb0ef41Sopenharmony_ci } 9281cb0ef41Sopenharmony_ci case STFSUX: { 9291cb0ef41Sopenharmony_ci Format(instr, "stfsux 'rs, 'ra, 'rb"); 9301cb0ef41Sopenharmony_ci return; 9311cb0ef41Sopenharmony_ci } 9321cb0ef41Sopenharmony_ci case STFDX: { 9331cb0ef41Sopenharmony_ci Format(instr, "stfdx 'rs, 'ra, 'rb"); 9341cb0ef41Sopenharmony_ci return; 9351cb0ef41Sopenharmony_ci } 9361cb0ef41Sopenharmony_ci case STFDUX: { 9371cb0ef41Sopenharmony_ci Format(instr, "stfdux 'rs, 'ra, 'rb"); 9381cb0ef41Sopenharmony_ci return; 9391cb0ef41Sopenharmony_ci } 9401cb0ef41Sopenharmony_ci case POPCNTW: { 9411cb0ef41Sopenharmony_ci Format(instr, "popcntw 'ra, 'rs"); 9421cb0ef41Sopenharmony_ci return; 9431cb0ef41Sopenharmony_ci } 9441cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_PPC64 9451cb0ef41Sopenharmony_ci case POPCNTD: { 9461cb0ef41Sopenharmony_ci Format(instr, "popcntd 'ra, 'rs"); 9471cb0ef41Sopenharmony_ci return; 9481cb0ef41Sopenharmony_ci } 9491cb0ef41Sopenharmony_ci#endif 9501cb0ef41Sopenharmony_ci } 9511cb0ef41Sopenharmony_ci 9521cb0ef41Sopenharmony_ci switch (EXT2 | (instr->BitField(10, 2))) { 9531cb0ef41Sopenharmony_ci case SRADIX: { 9541cb0ef41Sopenharmony_ci Format(instr, "sradi'. 'ra,'rs,'sh"); 9551cb0ef41Sopenharmony_ci return; 9561cb0ef41Sopenharmony_ci } 9571cb0ef41Sopenharmony_ci } 9581cb0ef41Sopenharmony_ci 9591cb0ef41Sopenharmony_ci switch (EXT2 | (instr->BitField(10, 0))) { 9601cb0ef41Sopenharmony_ci case STBCX: { 9611cb0ef41Sopenharmony_ci Format(instr, "stbcx 'rs, 'ra, 'rb"); 9621cb0ef41Sopenharmony_ci return; 9631cb0ef41Sopenharmony_ci } 9641cb0ef41Sopenharmony_ci case STHCX: { 9651cb0ef41Sopenharmony_ci Format(instr, "sthcx 'rs, 'ra, 'rb"); 9661cb0ef41Sopenharmony_ci return; 9671cb0ef41Sopenharmony_ci } 9681cb0ef41Sopenharmony_ci case STWCX: { 9691cb0ef41Sopenharmony_ci Format(instr, "stwcx 'rs, 'ra, 'rb"); 9701cb0ef41Sopenharmony_ci return; 9711cb0ef41Sopenharmony_ci } 9721cb0ef41Sopenharmony_ci case STDCX: { 9731cb0ef41Sopenharmony_ci Format(instr, "stdcx 'rs, 'ra, 'rb"); 9741cb0ef41Sopenharmony_ci return; 9751cb0ef41Sopenharmony_ci } 9761cb0ef41Sopenharmony_ci } 9771cb0ef41Sopenharmony_ci 9781cb0ef41Sopenharmony_ci // ?? are all of these xo_form? 9791cb0ef41Sopenharmony_ci switch (EXT2 | (instr->BitField(10, 1))) { 9801cb0ef41Sopenharmony_ci case CMP: { 9811cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_PPC64 9821cb0ef41Sopenharmony_ci if (instr->Bit(21)) { 9831cb0ef41Sopenharmony_ci#endif 9841cb0ef41Sopenharmony_ci Format(instr, "cmp 'ra, 'rb"); 9851cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_PPC64 9861cb0ef41Sopenharmony_ci } else { 9871cb0ef41Sopenharmony_ci Format(instr, "cmpw 'ra, 'rb"); 9881cb0ef41Sopenharmony_ci } 9891cb0ef41Sopenharmony_ci#endif 9901cb0ef41Sopenharmony_ci return; 9911cb0ef41Sopenharmony_ci } 9921cb0ef41Sopenharmony_ci case SLWX: { 9931cb0ef41Sopenharmony_ci Format(instr, "slw'. 'ra, 'rs, 'rb"); 9941cb0ef41Sopenharmony_ci return; 9951cb0ef41Sopenharmony_ci } 9961cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_PPC64 9971cb0ef41Sopenharmony_ci case SLDX: { 9981cb0ef41Sopenharmony_ci Format(instr, "sld'. 'ra, 'rs, 'rb"); 9991cb0ef41Sopenharmony_ci return; 10001cb0ef41Sopenharmony_ci } 10011cb0ef41Sopenharmony_ci#endif 10021cb0ef41Sopenharmony_ci case SUBFCX: { 10031cb0ef41Sopenharmony_ci Format(instr, "subfc'. 'rt, 'ra, 'rb"); 10041cb0ef41Sopenharmony_ci return; 10051cb0ef41Sopenharmony_ci } 10061cb0ef41Sopenharmony_ci case SUBFEX: { 10071cb0ef41Sopenharmony_ci Format(instr, "subfe'. 'rt, 'ra, 'rb"); 10081cb0ef41Sopenharmony_ci return; 10091cb0ef41Sopenharmony_ci } 10101cb0ef41Sopenharmony_ci case ADDCX: { 10111cb0ef41Sopenharmony_ci Format(instr, "addc'. 'rt, 'ra, 'rb"); 10121cb0ef41Sopenharmony_ci return; 10131cb0ef41Sopenharmony_ci } 10141cb0ef41Sopenharmony_ci case ADDEX: { 10151cb0ef41Sopenharmony_ci Format(instr, "adde'. 'rt, 'ra, 'rb"); 10161cb0ef41Sopenharmony_ci return; 10171cb0ef41Sopenharmony_ci } 10181cb0ef41Sopenharmony_ci case CNTLZWX: { 10191cb0ef41Sopenharmony_ci Format(instr, "cntlzw'. 'ra, 'rs"); 10201cb0ef41Sopenharmony_ci return; 10211cb0ef41Sopenharmony_ci } 10221cb0ef41Sopenharmony_ci case CNTLZDX: { 10231cb0ef41Sopenharmony_ci Format(instr, "cntlzd'. 'ra, 'rs"); 10241cb0ef41Sopenharmony_ci return; 10251cb0ef41Sopenharmony_ci } 10261cb0ef41Sopenharmony_ci case CNTTZWX: { 10271cb0ef41Sopenharmony_ci Format(instr, "cnttzw'. 'ra, 'rs"); 10281cb0ef41Sopenharmony_ci return; 10291cb0ef41Sopenharmony_ci } 10301cb0ef41Sopenharmony_ci case CNTTZDX: { 10311cb0ef41Sopenharmony_ci Format(instr, "cnttzd'. 'ra, 'rs"); 10321cb0ef41Sopenharmony_ci return; 10331cb0ef41Sopenharmony_ci } 10341cb0ef41Sopenharmony_ci case BRH: { 10351cb0ef41Sopenharmony_ci Format(instr, "brh 'ra, 'rs"); 10361cb0ef41Sopenharmony_ci return; 10371cb0ef41Sopenharmony_ci } 10381cb0ef41Sopenharmony_ci case BRW: { 10391cb0ef41Sopenharmony_ci Format(instr, "brw 'ra, 'rs"); 10401cb0ef41Sopenharmony_ci return; 10411cb0ef41Sopenharmony_ci } 10421cb0ef41Sopenharmony_ci case BRD: { 10431cb0ef41Sopenharmony_ci Format(instr, "brd 'ra, 'rs"); 10441cb0ef41Sopenharmony_ci return; 10451cb0ef41Sopenharmony_ci } 10461cb0ef41Sopenharmony_ci case ANDX: { 10471cb0ef41Sopenharmony_ci Format(instr, "and'. 'ra, 'rs, 'rb"); 10481cb0ef41Sopenharmony_ci return; 10491cb0ef41Sopenharmony_ci } 10501cb0ef41Sopenharmony_ci case ANDCX: { 10511cb0ef41Sopenharmony_ci Format(instr, "andc'. 'ra, 'rs, 'rb"); 10521cb0ef41Sopenharmony_ci return; 10531cb0ef41Sopenharmony_ci } 10541cb0ef41Sopenharmony_ci case CMPL: { 10551cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_PPC64 10561cb0ef41Sopenharmony_ci if (instr->Bit(21)) { 10571cb0ef41Sopenharmony_ci#endif 10581cb0ef41Sopenharmony_ci Format(instr, "cmpl 'ra, 'rb"); 10591cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_PPC64 10601cb0ef41Sopenharmony_ci } else { 10611cb0ef41Sopenharmony_ci Format(instr, "cmplw 'ra, 'rb"); 10621cb0ef41Sopenharmony_ci } 10631cb0ef41Sopenharmony_ci#endif 10641cb0ef41Sopenharmony_ci return; 10651cb0ef41Sopenharmony_ci } 10661cb0ef41Sopenharmony_ci case NEGX: { 10671cb0ef41Sopenharmony_ci Format(instr, "neg'. 'rt, 'ra"); 10681cb0ef41Sopenharmony_ci return; 10691cb0ef41Sopenharmony_ci } 10701cb0ef41Sopenharmony_ci case NORX: { 10711cb0ef41Sopenharmony_ci Format(instr, "nor'. 'rt, 'ra, 'rb"); 10721cb0ef41Sopenharmony_ci return; 10731cb0ef41Sopenharmony_ci } 10741cb0ef41Sopenharmony_ci case SUBFX: { 10751cb0ef41Sopenharmony_ci Format(instr, "subf'. 'rt, 'ra, 'rb"); 10761cb0ef41Sopenharmony_ci return; 10771cb0ef41Sopenharmony_ci } 10781cb0ef41Sopenharmony_ci case MULHWX: { 10791cb0ef41Sopenharmony_ci Format(instr, "mulhw'o'. 'rt, 'ra, 'rb"); 10801cb0ef41Sopenharmony_ci return; 10811cb0ef41Sopenharmony_ci } 10821cb0ef41Sopenharmony_ci case ADDZEX: { 10831cb0ef41Sopenharmony_ci Format(instr, "addze'. 'rt, 'ra"); 10841cb0ef41Sopenharmony_ci return; 10851cb0ef41Sopenharmony_ci } 10861cb0ef41Sopenharmony_ci case MULLW: { 10871cb0ef41Sopenharmony_ci Format(instr, "mullw'o'. 'rt, 'ra, 'rb"); 10881cb0ef41Sopenharmony_ci return; 10891cb0ef41Sopenharmony_ci } 10901cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_PPC64 10911cb0ef41Sopenharmony_ci case MULLD: { 10921cb0ef41Sopenharmony_ci Format(instr, "mulld'o'. 'rt, 'ra, 'rb"); 10931cb0ef41Sopenharmony_ci return; 10941cb0ef41Sopenharmony_ci } 10951cb0ef41Sopenharmony_ci#endif 10961cb0ef41Sopenharmony_ci case DIVW: { 10971cb0ef41Sopenharmony_ci Format(instr, "divw'o'. 'rt, 'ra, 'rb"); 10981cb0ef41Sopenharmony_ci return; 10991cb0ef41Sopenharmony_ci } 11001cb0ef41Sopenharmony_ci case DIVWU: { 11011cb0ef41Sopenharmony_ci Format(instr, "divwu'o'. 'rt, 'ra, 'rb"); 11021cb0ef41Sopenharmony_ci return; 11031cb0ef41Sopenharmony_ci } 11041cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_PPC64 11051cb0ef41Sopenharmony_ci case DIVD: { 11061cb0ef41Sopenharmony_ci Format(instr, "divd'o'. 'rt, 'ra, 'rb"); 11071cb0ef41Sopenharmony_ci return; 11081cb0ef41Sopenharmony_ci } 11091cb0ef41Sopenharmony_ci#endif 11101cb0ef41Sopenharmony_ci case ADDX: { 11111cb0ef41Sopenharmony_ci Format(instr, "add'o 'rt, 'ra, 'rb"); 11121cb0ef41Sopenharmony_ci return; 11131cb0ef41Sopenharmony_ci } 11141cb0ef41Sopenharmony_ci case XORX: { 11151cb0ef41Sopenharmony_ci Format(instr, "xor'. 'ra, 'rs, 'rb"); 11161cb0ef41Sopenharmony_ci return; 11171cb0ef41Sopenharmony_ci } 11181cb0ef41Sopenharmony_ci case ORX: { 11191cb0ef41Sopenharmony_ci if (instr->RTValue() == instr->RBValue()) { 11201cb0ef41Sopenharmony_ci Format(instr, "mr 'ra, 'rb"); 11211cb0ef41Sopenharmony_ci } else { 11221cb0ef41Sopenharmony_ci Format(instr, "or 'ra, 'rs, 'rb"); 11231cb0ef41Sopenharmony_ci } 11241cb0ef41Sopenharmony_ci return; 11251cb0ef41Sopenharmony_ci } 11261cb0ef41Sopenharmony_ci case MFSPR: { 11271cb0ef41Sopenharmony_ci int spr = instr->Bits(20, 11); 11281cb0ef41Sopenharmony_ci if (256 == spr) { 11291cb0ef41Sopenharmony_ci Format(instr, "mflr 'rt"); 11301cb0ef41Sopenharmony_ci } else { 11311cb0ef41Sopenharmony_ci Format(instr, "mfspr 'rt ??"); 11321cb0ef41Sopenharmony_ci } 11331cb0ef41Sopenharmony_ci return; 11341cb0ef41Sopenharmony_ci } 11351cb0ef41Sopenharmony_ci case MTSPR: { 11361cb0ef41Sopenharmony_ci int spr = instr->Bits(20, 11); 11371cb0ef41Sopenharmony_ci if (256 == spr) { 11381cb0ef41Sopenharmony_ci Format(instr, "mtlr 'rt"); 11391cb0ef41Sopenharmony_ci } else if (288 == spr) { 11401cb0ef41Sopenharmony_ci Format(instr, "mtctr 'rt"); 11411cb0ef41Sopenharmony_ci } else { 11421cb0ef41Sopenharmony_ci Format(instr, "mtspr 'rt ??"); 11431cb0ef41Sopenharmony_ci } 11441cb0ef41Sopenharmony_ci return; 11451cb0ef41Sopenharmony_ci } 11461cb0ef41Sopenharmony_ci case MFCR: { 11471cb0ef41Sopenharmony_ci Format(instr, "mfcr 'rt"); 11481cb0ef41Sopenharmony_ci return; 11491cb0ef41Sopenharmony_ci } 11501cb0ef41Sopenharmony_ci case STWX: { 11511cb0ef41Sopenharmony_ci Format(instr, "stwx 'rs, 'ra, 'rb"); 11521cb0ef41Sopenharmony_ci return; 11531cb0ef41Sopenharmony_ci } 11541cb0ef41Sopenharmony_ci case STWUX: { 11551cb0ef41Sopenharmony_ci Format(instr, "stwux 'rs, 'ra, 'rb"); 11561cb0ef41Sopenharmony_ci return; 11571cb0ef41Sopenharmony_ci } 11581cb0ef41Sopenharmony_ci case STBX: { 11591cb0ef41Sopenharmony_ci Format(instr, "stbx 'rs, 'ra, 'rb"); 11601cb0ef41Sopenharmony_ci return; 11611cb0ef41Sopenharmony_ci } 11621cb0ef41Sopenharmony_ci case STBUX: { 11631cb0ef41Sopenharmony_ci Format(instr, "stbux 'rs, 'ra, 'rb"); 11641cb0ef41Sopenharmony_ci return; 11651cb0ef41Sopenharmony_ci } 11661cb0ef41Sopenharmony_ci case STHX: { 11671cb0ef41Sopenharmony_ci Format(instr, "sthx 'rs, 'ra, 'rb"); 11681cb0ef41Sopenharmony_ci return; 11691cb0ef41Sopenharmony_ci } 11701cb0ef41Sopenharmony_ci case STHUX: { 11711cb0ef41Sopenharmony_ci Format(instr, "sthux 'rs, 'ra, 'rb"); 11721cb0ef41Sopenharmony_ci return; 11731cb0ef41Sopenharmony_ci } 11741cb0ef41Sopenharmony_ci case LWZX: { 11751cb0ef41Sopenharmony_ci Format(instr, "lwzx 'rt, 'ra, 'rb"); 11761cb0ef41Sopenharmony_ci return; 11771cb0ef41Sopenharmony_ci } 11781cb0ef41Sopenharmony_ci case LWZUX: { 11791cb0ef41Sopenharmony_ci Format(instr, "lwzux 'rt, 'ra, 'rb"); 11801cb0ef41Sopenharmony_ci return; 11811cb0ef41Sopenharmony_ci } 11821cb0ef41Sopenharmony_ci case LWAX: { 11831cb0ef41Sopenharmony_ci Format(instr, "lwax 'rt, 'ra, 'rb"); 11841cb0ef41Sopenharmony_ci return; 11851cb0ef41Sopenharmony_ci } 11861cb0ef41Sopenharmony_ci case LBZX: { 11871cb0ef41Sopenharmony_ci Format(instr, "lbzx 'rt, 'ra, 'rb"); 11881cb0ef41Sopenharmony_ci return; 11891cb0ef41Sopenharmony_ci } 11901cb0ef41Sopenharmony_ci case LBZUX: { 11911cb0ef41Sopenharmony_ci Format(instr, "lbzux 'rt, 'ra, 'rb"); 11921cb0ef41Sopenharmony_ci return; 11931cb0ef41Sopenharmony_ci } 11941cb0ef41Sopenharmony_ci case LHZX: { 11951cb0ef41Sopenharmony_ci Format(instr, "lhzx 'rt, 'ra, 'rb"); 11961cb0ef41Sopenharmony_ci return; 11971cb0ef41Sopenharmony_ci } 11981cb0ef41Sopenharmony_ci case LHZUX: { 11991cb0ef41Sopenharmony_ci Format(instr, "lhzux 'rt, 'ra, 'rb"); 12001cb0ef41Sopenharmony_ci return; 12011cb0ef41Sopenharmony_ci } 12021cb0ef41Sopenharmony_ci case LHAX: { 12031cb0ef41Sopenharmony_ci Format(instr, "lhax 'rt, 'ra, 'rb"); 12041cb0ef41Sopenharmony_ci return; 12051cb0ef41Sopenharmony_ci } 12061cb0ef41Sopenharmony_ci case LBARX: { 12071cb0ef41Sopenharmony_ci Format(instr, "lbarx 'rt, 'ra, 'rb"); 12081cb0ef41Sopenharmony_ci return; 12091cb0ef41Sopenharmony_ci } 12101cb0ef41Sopenharmony_ci case LHARX: { 12111cb0ef41Sopenharmony_ci Format(instr, "lharx 'rt, 'ra, 'rb"); 12121cb0ef41Sopenharmony_ci return; 12131cb0ef41Sopenharmony_ci } 12141cb0ef41Sopenharmony_ci case LWARX: { 12151cb0ef41Sopenharmony_ci Format(instr, "lwarx 'rt, 'ra, 'rb"); 12161cb0ef41Sopenharmony_ci return; 12171cb0ef41Sopenharmony_ci } 12181cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_PPC64 12191cb0ef41Sopenharmony_ci case LDX: { 12201cb0ef41Sopenharmony_ci Format(instr, "ldx 'rt, 'ra, 'rb"); 12211cb0ef41Sopenharmony_ci return; 12221cb0ef41Sopenharmony_ci } 12231cb0ef41Sopenharmony_ci case LDUX: { 12241cb0ef41Sopenharmony_ci Format(instr, "ldux 'rt, 'ra, 'rb"); 12251cb0ef41Sopenharmony_ci return; 12261cb0ef41Sopenharmony_ci } 12271cb0ef41Sopenharmony_ci case LDARX: { 12281cb0ef41Sopenharmony_ci Format(instr, "ldarx 'rt, 'ra, 'rb"); 12291cb0ef41Sopenharmony_ci return; 12301cb0ef41Sopenharmony_ci } 12311cb0ef41Sopenharmony_ci case STDX: { 12321cb0ef41Sopenharmony_ci Format(instr, "stdx 'rt, 'ra, 'rb"); 12331cb0ef41Sopenharmony_ci return; 12341cb0ef41Sopenharmony_ci } 12351cb0ef41Sopenharmony_ci case STDUX: { 12361cb0ef41Sopenharmony_ci Format(instr, "stdux 'rt, 'ra, 'rb"); 12371cb0ef41Sopenharmony_ci return; 12381cb0ef41Sopenharmony_ci } 12391cb0ef41Sopenharmony_ci case MFVSRD: { 12401cb0ef41Sopenharmony_ci Format(instr, "mfvsrd 'ra, 'Xs"); 12411cb0ef41Sopenharmony_ci return; 12421cb0ef41Sopenharmony_ci } 12431cb0ef41Sopenharmony_ci case MFVSRWZ: { 12441cb0ef41Sopenharmony_ci Format(instr, "mffprwz 'ra, 'Dt"); 12451cb0ef41Sopenharmony_ci return; 12461cb0ef41Sopenharmony_ci } 12471cb0ef41Sopenharmony_ci case MTVSRD: { 12481cb0ef41Sopenharmony_ci Format(instr, "mtvsrd 'Xt, 'ra"); 12491cb0ef41Sopenharmony_ci return; 12501cb0ef41Sopenharmony_ci } 12511cb0ef41Sopenharmony_ci case MTVSRWA: { 12521cb0ef41Sopenharmony_ci Format(instr, "mtfprwa 'Dt, 'ra"); 12531cb0ef41Sopenharmony_ci return; 12541cb0ef41Sopenharmony_ci } 12551cb0ef41Sopenharmony_ci case MTVSRWZ: { 12561cb0ef41Sopenharmony_ci Format(instr, "mtfprwz 'Dt, 'ra"); 12571cb0ef41Sopenharmony_ci return; 12581cb0ef41Sopenharmony_ci } 12591cb0ef41Sopenharmony_ci case MTVSRDD: { 12601cb0ef41Sopenharmony_ci Format(instr, "mtvsrdd 'Xt, 'ra, 'rb"); 12611cb0ef41Sopenharmony_ci return; 12621cb0ef41Sopenharmony_ci } 12631cb0ef41Sopenharmony_ci case LDBRX: { 12641cb0ef41Sopenharmony_ci Format(instr, "ldbrx 'rt, 'ra, 'rb"); 12651cb0ef41Sopenharmony_ci return; 12661cb0ef41Sopenharmony_ci } 12671cb0ef41Sopenharmony_ci case LHBRX: { 12681cb0ef41Sopenharmony_ci Format(instr, "lhbrx 'rt, 'ra, 'rb"); 12691cb0ef41Sopenharmony_ci return; 12701cb0ef41Sopenharmony_ci } 12711cb0ef41Sopenharmony_ci case LWBRX: { 12721cb0ef41Sopenharmony_ci Format(instr, "lwbrx 'rt, 'ra, 'rb"); 12731cb0ef41Sopenharmony_ci return; 12741cb0ef41Sopenharmony_ci } 12751cb0ef41Sopenharmony_ci case STDBRX: { 12761cb0ef41Sopenharmony_ci Format(instr, "stdbrx 'rs, 'ra, 'rb"); 12771cb0ef41Sopenharmony_ci return; 12781cb0ef41Sopenharmony_ci } 12791cb0ef41Sopenharmony_ci case STWBRX: { 12801cb0ef41Sopenharmony_ci Format(instr, "stwbrx 'rs, 'ra, 'rb"); 12811cb0ef41Sopenharmony_ci return; 12821cb0ef41Sopenharmony_ci } 12831cb0ef41Sopenharmony_ci case STHBRX: { 12841cb0ef41Sopenharmony_ci Format(instr, "sthbrx 'rs, 'ra, 'rb"); 12851cb0ef41Sopenharmony_ci return; 12861cb0ef41Sopenharmony_ci } 12871cb0ef41Sopenharmony_ci case MTCRF: { 12881cb0ef41Sopenharmony_ci Format(instr, "mtcrf 'FXM, 'rs"); 12891cb0ef41Sopenharmony_ci return; 12901cb0ef41Sopenharmony_ci } 12911cb0ef41Sopenharmony_ci#endif 12921cb0ef41Sopenharmony_ci } 12931cb0ef41Sopenharmony_ci 12941cb0ef41Sopenharmony_ci switch (EXT2 | (instr->BitField(5, 1))) { 12951cb0ef41Sopenharmony_ci case ISEL: { 12961cb0ef41Sopenharmony_ci Format(instr, "isel 'rt, 'ra, 'rb"); 12971cb0ef41Sopenharmony_ci return; 12981cb0ef41Sopenharmony_ci } 12991cb0ef41Sopenharmony_ci default: { 13001cb0ef41Sopenharmony_ci Unknown(instr); // not used by V8 13011cb0ef41Sopenharmony_ci } 13021cb0ef41Sopenharmony_ci } 13031cb0ef41Sopenharmony_ci} 13041cb0ef41Sopenharmony_ci 13051cb0ef41Sopenharmony_civoid Decoder::DecodeExt3(Instruction* instr) { 13061cb0ef41Sopenharmony_ci switch (EXT3 | (instr->BitField(10, 1))) { 13071cb0ef41Sopenharmony_ci case FCFID: { 13081cb0ef41Sopenharmony_ci Format(instr, "fcfids'. 'Dt, 'Db"); 13091cb0ef41Sopenharmony_ci break; 13101cb0ef41Sopenharmony_ci } 13111cb0ef41Sopenharmony_ci case FCFIDU: { 13121cb0ef41Sopenharmony_ci Format(instr, "fcfidus'.'Dt, 'Db"); 13131cb0ef41Sopenharmony_ci break; 13141cb0ef41Sopenharmony_ci } 13151cb0ef41Sopenharmony_ci default: { 13161cb0ef41Sopenharmony_ci Unknown(instr); // not used by V8 13171cb0ef41Sopenharmony_ci } 13181cb0ef41Sopenharmony_ci } 13191cb0ef41Sopenharmony_ci} 13201cb0ef41Sopenharmony_ci 13211cb0ef41Sopenharmony_civoid Decoder::DecodeExt4(Instruction* instr) { 13221cb0ef41Sopenharmony_ci switch (EXT4 | (instr->BitField(5, 1))) { 13231cb0ef41Sopenharmony_ci case FDIV: { 13241cb0ef41Sopenharmony_ci Format(instr, "fdiv'. 'Dt, 'Da, 'Db"); 13251cb0ef41Sopenharmony_ci return; 13261cb0ef41Sopenharmony_ci } 13271cb0ef41Sopenharmony_ci case FSUB: { 13281cb0ef41Sopenharmony_ci Format(instr, "fsub'. 'Dt, 'Da, 'Db"); 13291cb0ef41Sopenharmony_ci return; 13301cb0ef41Sopenharmony_ci } 13311cb0ef41Sopenharmony_ci case FADD: { 13321cb0ef41Sopenharmony_ci Format(instr, "fadd'. 'Dt, 'Da, 'Db"); 13331cb0ef41Sopenharmony_ci return; 13341cb0ef41Sopenharmony_ci } 13351cb0ef41Sopenharmony_ci case FSQRT: { 13361cb0ef41Sopenharmony_ci Format(instr, "fsqrt'. 'Dt, 'Db"); 13371cb0ef41Sopenharmony_ci return; 13381cb0ef41Sopenharmony_ci } 13391cb0ef41Sopenharmony_ci case FSEL: { 13401cb0ef41Sopenharmony_ci Format(instr, "fsel'. 'Dt, 'Da, 'Dc, 'Db"); 13411cb0ef41Sopenharmony_ci return; 13421cb0ef41Sopenharmony_ci } 13431cb0ef41Sopenharmony_ci case FMUL: { 13441cb0ef41Sopenharmony_ci Format(instr, "fmul'. 'Dt, 'Da, 'Dc"); 13451cb0ef41Sopenharmony_ci return; 13461cb0ef41Sopenharmony_ci } 13471cb0ef41Sopenharmony_ci case FMSUB: { 13481cb0ef41Sopenharmony_ci Format(instr, "fmsub'. 'Dt, 'Da, 'Dc, 'Db"); 13491cb0ef41Sopenharmony_ci return; 13501cb0ef41Sopenharmony_ci } 13511cb0ef41Sopenharmony_ci case FMADD: { 13521cb0ef41Sopenharmony_ci Format(instr, "fmadd'. 'Dt, 'Da, 'Dc, 'Db"); 13531cb0ef41Sopenharmony_ci return; 13541cb0ef41Sopenharmony_ci } 13551cb0ef41Sopenharmony_ci } 13561cb0ef41Sopenharmony_ci 13571cb0ef41Sopenharmony_ci switch (EXT4 | (instr->BitField(10, 1))) { 13581cb0ef41Sopenharmony_ci case FCMPU: { 13591cb0ef41Sopenharmony_ci Format(instr, "fcmpu 'Da, 'Db"); 13601cb0ef41Sopenharmony_ci break; 13611cb0ef41Sopenharmony_ci } 13621cb0ef41Sopenharmony_ci case FRSP: { 13631cb0ef41Sopenharmony_ci Format(instr, "frsp'. 'Dt, 'Db"); 13641cb0ef41Sopenharmony_ci break; 13651cb0ef41Sopenharmony_ci } 13661cb0ef41Sopenharmony_ci case FCFID: { 13671cb0ef41Sopenharmony_ci Format(instr, "fcfid'. 'Dt, 'Db"); 13681cb0ef41Sopenharmony_ci break; 13691cb0ef41Sopenharmony_ci } 13701cb0ef41Sopenharmony_ci case FCFIDU: { 13711cb0ef41Sopenharmony_ci Format(instr, "fcfidu'. 'Dt, 'Db"); 13721cb0ef41Sopenharmony_ci break; 13731cb0ef41Sopenharmony_ci } 13741cb0ef41Sopenharmony_ci case FCTID: { 13751cb0ef41Sopenharmony_ci Format(instr, "fctid 'Dt, 'Db"); 13761cb0ef41Sopenharmony_ci break; 13771cb0ef41Sopenharmony_ci } 13781cb0ef41Sopenharmony_ci case FCTIDZ: { 13791cb0ef41Sopenharmony_ci Format(instr, "fctidz 'Dt, 'Db"); 13801cb0ef41Sopenharmony_ci break; 13811cb0ef41Sopenharmony_ci } 13821cb0ef41Sopenharmony_ci case FCTIDU: { 13831cb0ef41Sopenharmony_ci Format(instr, "fctidu 'Dt, 'Db"); 13841cb0ef41Sopenharmony_ci break; 13851cb0ef41Sopenharmony_ci } 13861cb0ef41Sopenharmony_ci case FCTIDUZ: { 13871cb0ef41Sopenharmony_ci Format(instr, "fctiduz 'Dt, 'Db"); 13881cb0ef41Sopenharmony_ci break; 13891cb0ef41Sopenharmony_ci } 13901cb0ef41Sopenharmony_ci case FCTIW: { 13911cb0ef41Sopenharmony_ci Format(instr, "fctiw'. 'Dt, 'Db"); 13921cb0ef41Sopenharmony_ci break; 13931cb0ef41Sopenharmony_ci } 13941cb0ef41Sopenharmony_ci case FCTIWZ: { 13951cb0ef41Sopenharmony_ci Format(instr, "fctiwz'. 'Dt, 'Db"); 13961cb0ef41Sopenharmony_ci break; 13971cb0ef41Sopenharmony_ci } 13981cb0ef41Sopenharmony_ci case FCTIWUZ: { 13991cb0ef41Sopenharmony_ci Format(instr, "fctiwuz 'Dt, 'Db"); 14001cb0ef41Sopenharmony_ci break; 14011cb0ef41Sopenharmony_ci } 14021cb0ef41Sopenharmony_ci case FMR: { 14031cb0ef41Sopenharmony_ci Format(instr, "fmr'. 'Dt, 'Db"); 14041cb0ef41Sopenharmony_ci break; 14051cb0ef41Sopenharmony_ci } 14061cb0ef41Sopenharmony_ci case MTFSFI: { 14071cb0ef41Sopenharmony_ci Format(instr, "mtfsfi'. ?,?"); 14081cb0ef41Sopenharmony_ci break; 14091cb0ef41Sopenharmony_ci } 14101cb0ef41Sopenharmony_ci case MFFS: { 14111cb0ef41Sopenharmony_ci Format(instr, "mffs'. 'Dt"); 14121cb0ef41Sopenharmony_ci break; 14131cb0ef41Sopenharmony_ci } 14141cb0ef41Sopenharmony_ci case MTFSF: { 14151cb0ef41Sopenharmony_ci Format(instr, "mtfsf'. 'Db ?,?,?"); 14161cb0ef41Sopenharmony_ci break; 14171cb0ef41Sopenharmony_ci } 14181cb0ef41Sopenharmony_ci case FABS: { 14191cb0ef41Sopenharmony_ci Format(instr, "fabs'. 'Dt, 'Db"); 14201cb0ef41Sopenharmony_ci break; 14211cb0ef41Sopenharmony_ci } 14221cb0ef41Sopenharmony_ci case FRIN: { 14231cb0ef41Sopenharmony_ci Format(instr, "frin. 'Dt, 'Db"); 14241cb0ef41Sopenharmony_ci break; 14251cb0ef41Sopenharmony_ci } 14261cb0ef41Sopenharmony_ci case FRIZ: { 14271cb0ef41Sopenharmony_ci Format(instr, "friz. 'Dt, 'Db"); 14281cb0ef41Sopenharmony_ci break; 14291cb0ef41Sopenharmony_ci } 14301cb0ef41Sopenharmony_ci case FRIP: { 14311cb0ef41Sopenharmony_ci Format(instr, "frip. 'Dt, 'Db"); 14321cb0ef41Sopenharmony_ci break; 14331cb0ef41Sopenharmony_ci } 14341cb0ef41Sopenharmony_ci case FRIM: { 14351cb0ef41Sopenharmony_ci Format(instr, "frim. 'Dt, 'Db"); 14361cb0ef41Sopenharmony_ci break; 14371cb0ef41Sopenharmony_ci } 14381cb0ef41Sopenharmony_ci case FNEG: { 14391cb0ef41Sopenharmony_ci Format(instr, "fneg'. 'Dt, 'Db"); 14401cb0ef41Sopenharmony_ci break; 14411cb0ef41Sopenharmony_ci } 14421cb0ef41Sopenharmony_ci case FCPSGN: { 14431cb0ef41Sopenharmony_ci Format(instr, "fcpsgn'. 'Dt, 'Da, 'Db"); 14441cb0ef41Sopenharmony_ci break; 14451cb0ef41Sopenharmony_ci } 14461cb0ef41Sopenharmony_ci case MCRFS: { 14471cb0ef41Sopenharmony_ci Format(instr, "mcrfs ?,?"); 14481cb0ef41Sopenharmony_ci break; 14491cb0ef41Sopenharmony_ci } 14501cb0ef41Sopenharmony_ci case MTFSB0: { 14511cb0ef41Sopenharmony_ci Format(instr, "mtfsb0'. ?"); 14521cb0ef41Sopenharmony_ci break; 14531cb0ef41Sopenharmony_ci } 14541cb0ef41Sopenharmony_ci case MTFSB1: { 14551cb0ef41Sopenharmony_ci Format(instr, "mtfsb1'. ?"); 14561cb0ef41Sopenharmony_ci break; 14571cb0ef41Sopenharmony_ci } 14581cb0ef41Sopenharmony_ci default: { 14591cb0ef41Sopenharmony_ci Unknown(instr); // not used by V8 14601cb0ef41Sopenharmony_ci } 14611cb0ef41Sopenharmony_ci } 14621cb0ef41Sopenharmony_ci} 14631cb0ef41Sopenharmony_ci 14641cb0ef41Sopenharmony_civoid Decoder::DecodeExt5(Instruction* instr) { 14651cb0ef41Sopenharmony_ci switch (EXT5 | (instr->BitField(4, 2))) { 14661cb0ef41Sopenharmony_ci case RLDICL: { 14671cb0ef41Sopenharmony_ci Format(instr, "rldicl'. 'ra, 'rs, 'sh, 'mb"); 14681cb0ef41Sopenharmony_ci return; 14691cb0ef41Sopenharmony_ci } 14701cb0ef41Sopenharmony_ci case RLDICR: { 14711cb0ef41Sopenharmony_ci Format(instr, "rldicr'. 'ra, 'rs, 'sh, 'me"); 14721cb0ef41Sopenharmony_ci return; 14731cb0ef41Sopenharmony_ci } 14741cb0ef41Sopenharmony_ci case RLDIC: { 14751cb0ef41Sopenharmony_ci Format(instr, "rldic'. 'ra, 'rs, 'sh, 'mb"); 14761cb0ef41Sopenharmony_ci return; 14771cb0ef41Sopenharmony_ci } 14781cb0ef41Sopenharmony_ci case RLDIMI: { 14791cb0ef41Sopenharmony_ci Format(instr, "rldimi'. 'ra, 'rs, 'sh, 'mb"); 14801cb0ef41Sopenharmony_ci return; 14811cb0ef41Sopenharmony_ci } 14821cb0ef41Sopenharmony_ci } 14831cb0ef41Sopenharmony_ci switch (EXT5 | (instr->BitField(4, 1))) { 14841cb0ef41Sopenharmony_ci case RLDCL: { 14851cb0ef41Sopenharmony_ci Format(instr, "rldcl'. 'ra, 'rs, 'sb, 'mb"); 14861cb0ef41Sopenharmony_ci return; 14871cb0ef41Sopenharmony_ci } 14881cb0ef41Sopenharmony_ci } 14891cb0ef41Sopenharmony_ci Unknown(instr); // not used by V8 14901cb0ef41Sopenharmony_ci} 14911cb0ef41Sopenharmony_ci 14921cb0ef41Sopenharmony_civoid Decoder::DecodeExt6(Instruction* instr) { 14931cb0ef41Sopenharmony_ci switch (EXT6 | (instr->BitField(10, 1))) { 14941cb0ef41Sopenharmony_ci case XXSPLTIB: { 14951cb0ef41Sopenharmony_ci Format(instr, "xxspltib 'Xt, 'IMM8"); 14961cb0ef41Sopenharmony_ci return; 14971cb0ef41Sopenharmony_ci } 14981cb0ef41Sopenharmony_ci } 14991cb0ef41Sopenharmony_ci switch (EXT6 | (instr->BitField(10, 3))) { 15001cb0ef41Sopenharmony_ci#define DECODE_XX3_VECTOR_INSTRUCTIONS(name, opcode_name, opcode_value) \ 15011cb0ef41Sopenharmony_ci case opcode_name: { \ 15021cb0ef41Sopenharmony_ci Format(instr, #name " 'Xt, 'Xa, 'Xb"); \ 15031cb0ef41Sopenharmony_ci return; \ 15041cb0ef41Sopenharmony_ci } 15051cb0ef41Sopenharmony_ci PPC_XX3_OPCODE_VECTOR_LIST(DECODE_XX3_VECTOR_INSTRUCTIONS) 15061cb0ef41Sopenharmony_ci#undef DECODE_XX3_VECTOR_INSTRUCTIONS 15071cb0ef41Sopenharmony_ci#define DECODE_XX3_SCALAR_INSTRUCTIONS(name, opcode_name, opcode_value) \ 15081cb0ef41Sopenharmony_ci case opcode_name: { \ 15091cb0ef41Sopenharmony_ci Format(instr, #name " 'Dt, 'Da, 'Db"); \ 15101cb0ef41Sopenharmony_ci return; \ 15111cb0ef41Sopenharmony_ci } 15121cb0ef41Sopenharmony_ci PPC_XX3_OPCODE_SCALAR_LIST(DECODE_XX3_SCALAR_INSTRUCTIONS) 15131cb0ef41Sopenharmony_ci#undef DECODE_XX3_SCALAR_INSTRUCTIONS 15141cb0ef41Sopenharmony_ci } 15151cb0ef41Sopenharmony_ci // Some encodings have integers hard coded in the middle, handle those first. 15161cb0ef41Sopenharmony_ci switch (EXT6 | (instr->BitField(20, 16)) | (instr->BitField(10, 2))) { 15171cb0ef41Sopenharmony_ci#define DECODE_XX2_B_INSTRUCTIONS(name, opcode_name, opcode_value) \ 15181cb0ef41Sopenharmony_ci case opcode_name: { \ 15191cb0ef41Sopenharmony_ci Format(instr, #name " 'Xt, 'Xb"); \ 15201cb0ef41Sopenharmony_ci return; \ 15211cb0ef41Sopenharmony_ci } 15221cb0ef41Sopenharmony_ci PPC_XX2_OPCODE_B_FORM_LIST(DECODE_XX2_B_INSTRUCTIONS) 15231cb0ef41Sopenharmony_ci#undef DECODE_XX2_B_INSTRUCTIONS 15241cb0ef41Sopenharmony_ci } 15251cb0ef41Sopenharmony_ci switch (EXT6 | (instr->BitField(10, 2))) { 15261cb0ef41Sopenharmony_ci#define DECODE_XX2_VECTOR_A_INSTRUCTIONS(name, opcode_name, opcode_value) \ 15271cb0ef41Sopenharmony_ci case opcode_name: { \ 15281cb0ef41Sopenharmony_ci Format(instr, #name " 'Xt, 'Xb"); \ 15291cb0ef41Sopenharmony_ci return; \ 15301cb0ef41Sopenharmony_ci } 15311cb0ef41Sopenharmony_ci PPC_XX2_OPCODE_VECTOR_A_FORM_LIST(DECODE_XX2_VECTOR_A_INSTRUCTIONS) 15321cb0ef41Sopenharmony_ci#undef DECODE_XX2_VECTOR_A_INSTRUCTIONS 15331cb0ef41Sopenharmony_ci#define DECODE_XX2_SCALAR_A_INSTRUCTIONS(name, opcode_name, opcode_value) \ 15341cb0ef41Sopenharmony_ci case opcode_name: { \ 15351cb0ef41Sopenharmony_ci Format(instr, #name " 'Dt, 'Db"); \ 15361cb0ef41Sopenharmony_ci return; \ 15371cb0ef41Sopenharmony_ci } 15381cb0ef41Sopenharmony_ci PPC_XX2_OPCODE_SCALAR_A_FORM_LIST(DECODE_XX2_SCALAR_A_INSTRUCTIONS) 15391cb0ef41Sopenharmony_ci#undef DECODE_XX2_SCALAR_A_INSTRUCTIONS 15401cb0ef41Sopenharmony_ci } 15411cb0ef41Sopenharmony_ci Unknown(instr); // not used by V8 15421cb0ef41Sopenharmony_ci} 15431cb0ef41Sopenharmony_ci 15441cb0ef41Sopenharmony_ci#undef VERIFY 15451cb0ef41Sopenharmony_ci 15461cb0ef41Sopenharmony_ci// Disassemble the instruction at *instr_ptr into the output buffer. 15471cb0ef41Sopenharmony_ciint Decoder::InstructionDecode(byte* instr_ptr) { 15481cb0ef41Sopenharmony_ci Instruction* instr = Instruction::At(instr_ptr); 15491cb0ef41Sopenharmony_ci 15501cb0ef41Sopenharmony_ci uint32_t opcode = instr->OpcodeValue() << 26; 15511cb0ef41Sopenharmony_ci // Print raw instruction bytes. 15521cb0ef41Sopenharmony_ci if (opcode != EXTP) { 15531cb0ef41Sopenharmony_ci out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, 15541cb0ef41Sopenharmony_ci "%08x ", instr->InstructionBits()); 15551cb0ef41Sopenharmony_ci } else { 15561cb0ef41Sopenharmony_ci // Prefixed instructions have a 4-byte prefix and a 4-byte suffix. Print 15571cb0ef41Sopenharmony_ci // both on the same line. 15581cb0ef41Sopenharmony_ci Instruction* next_instr = 15591cb0ef41Sopenharmony_ci bit_cast<Instruction*>(bit_cast<intptr_t>(instr) + kInstrSize); 15601cb0ef41Sopenharmony_ci out_buffer_pos_ += 15611cb0ef41Sopenharmony_ci base::SNPrintF(out_buffer_ + out_buffer_pos_, "%08x|%08x ", 15621cb0ef41Sopenharmony_ci instr->InstructionBits(), next_instr->InstructionBits()); 15631cb0ef41Sopenharmony_ci } 15641cb0ef41Sopenharmony_ci 15651cb0ef41Sopenharmony_ci if (ABI_USES_FUNCTION_DESCRIPTORS && instr->InstructionBits() == 0) { 15661cb0ef41Sopenharmony_ci // The first field will be identified as a jump table entry. We 15671cb0ef41Sopenharmony_ci // emit the rest of the structure as zero, so just skip past them. 15681cb0ef41Sopenharmony_ci Format(instr, "constant"); 15691cb0ef41Sopenharmony_ci return kInstrSize; 15701cb0ef41Sopenharmony_ci } 15711cb0ef41Sopenharmony_ci 15721cb0ef41Sopenharmony_ci switch (opcode) { 15731cb0ef41Sopenharmony_ci case TWI: { 15741cb0ef41Sopenharmony_ci PrintSoftwareInterrupt(instr->SvcValue()); 15751cb0ef41Sopenharmony_ci break; 15761cb0ef41Sopenharmony_ci } 15771cb0ef41Sopenharmony_ci case MULLI: { 15781cb0ef41Sopenharmony_ci UnknownFormat(instr, "mulli"); 15791cb0ef41Sopenharmony_ci break; 15801cb0ef41Sopenharmony_ci } 15811cb0ef41Sopenharmony_ci case SUBFIC: { 15821cb0ef41Sopenharmony_ci Format(instr, "subfic 'rt, 'ra, 'int16"); 15831cb0ef41Sopenharmony_ci break; 15841cb0ef41Sopenharmony_ci } 15851cb0ef41Sopenharmony_ci case CMPLI: { 15861cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_PPC64 15871cb0ef41Sopenharmony_ci if (instr->Bit(21)) { 15881cb0ef41Sopenharmony_ci#endif 15891cb0ef41Sopenharmony_ci Format(instr, "cmpli 'ra, 'uint16"); 15901cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_PPC64 15911cb0ef41Sopenharmony_ci } else { 15921cb0ef41Sopenharmony_ci Format(instr, "cmplwi 'ra, 'uint16"); 15931cb0ef41Sopenharmony_ci } 15941cb0ef41Sopenharmony_ci#endif 15951cb0ef41Sopenharmony_ci break; 15961cb0ef41Sopenharmony_ci } 15971cb0ef41Sopenharmony_ci case CMPI: { 15981cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_PPC64 15991cb0ef41Sopenharmony_ci if (instr->Bit(21)) { 16001cb0ef41Sopenharmony_ci#endif 16011cb0ef41Sopenharmony_ci Format(instr, "cmpi 'ra, 'int16"); 16021cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_PPC64 16031cb0ef41Sopenharmony_ci } else { 16041cb0ef41Sopenharmony_ci Format(instr, "cmpwi 'ra, 'int16"); 16051cb0ef41Sopenharmony_ci } 16061cb0ef41Sopenharmony_ci#endif 16071cb0ef41Sopenharmony_ci break; 16081cb0ef41Sopenharmony_ci } 16091cb0ef41Sopenharmony_ci case ADDIC: { 16101cb0ef41Sopenharmony_ci Format(instr, "addic 'rt, 'ra, 'int16"); 16111cb0ef41Sopenharmony_ci break; 16121cb0ef41Sopenharmony_ci } 16131cb0ef41Sopenharmony_ci case ADDICx: { 16141cb0ef41Sopenharmony_ci UnknownFormat(instr, "addicx"); 16151cb0ef41Sopenharmony_ci break; 16161cb0ef41Sopenharmony_ci } 16171cb0ef41Sopenharmony_ci case ADDI: { 16181cb0ef41Sopenharmony_ci if (instr->RAValue() == 0) { 16191cb0ef41Sopenharmony_ci // this is load immediate 16201cb0ef41Sopenharmony_ci Format(instr, "li 'rt, 'int16"); 16211cb0ef41Sopenharmony_ci } else { 16221cb0ef41Sopenharmony_ci Format(instr, "addi 'rt, 'ra, 'int16"); 16231cb0ef41Sopenharmony_ci } 16241cb0ef41Sopenharmony_ci break; 16251cb0ef41Sopenharmony_ci } 16261cb0ef41Sopenharmony_ci case ADDIS: { 16271cb0ef41Sopenharmony_ci if (instr->RAValue() == 0) { 16281cb0ef41Sopenharmony_ci Format(instr, "lis 'rt, 'int16"); 16291cb0ef41Sopenharmony_ci } else { 16301cb0ef41Sopenharmony_ci Format(instr, "addis 'rt, 'ra, 'int16"); 16311cb0ef41Sopenharmony_ci } 16321cb0ef41Sopenharmony_ci break; 16331cb0ef41Sopenharmony_ci } 16341cb0ef41Sopenharmony_ci case BCX: { 16351cb0ef41Sopenharmony_ci int bo = instr->Bits(25, 21) << 21; 16361cb0ef41Sopenharmony_ci int bi = instr->Bits(20, 16); 16371cb0ef41Sopenharmony_ci CRBit cond = static_cast<CRBit>(bi & (CRWIDTH - 1)); 16381cb0ef41Sopenharmony_ci switch (bo) { 16391cb0ef41Sopenharmony_ci case BT: { // Branch if condition true 16401cb0ef41Sopenharmony_ci switch (cond) { 16411cb0ef41Sopenharmony_ci case CR_EQ: 16421cb0ef41Sopenharmony_ci Format(instr, "beq'l'a'cr 'target16"); 16431cb0ef41Sopenharmony_ci break; 16441cb0ef41Sopenharmony_ci case CR_GT: 16451cb0ef41Sopenharmony_ci Format(instr, "bgt'l'a'cr 'target16"); 16461cb0ef41Sopenharmony_ci break; 16471cb0ef41Sopenharmony_ci case CR_LT: 16481cb0ef41Sopenharmony_ci Format(instr, "blt'l'a'cr 'target16"); 16491cb0ef41Sopenharmony_ci break; 16501cb0ef41Sopenharmony_ci case CR_SO: 16511cb0ef41Sopenharmony_ci Format(instr, "bso'l'a'cr 'target16"); 16521cb0ef41Sopenharmony_ci break; 16531cb0ef41Sopenharmony_ci } 16541cb0ef41Sopenharmony_ci break; 16551cb0ef41Sopenharmony_ci } 16561cb0ef41Sopenharmony_ci case BF: { // Branch if condition false 16571cb0ef41Sopenharmony_ci switch (cond) { 16581cb0ef41Sopenharmony_ci case CR_EQ: 16591cb0ef41Sopenharmony_ci Format(instr, "bne'l'a'cr 'target16"); 16601cb0ef41Sopenharmony_ci break; 16611cb0ef41Sopenharmony_ci case CR_GT: 16621cb0ef41Sopenharmony_ci Format(instr, "ble'l'a'cr 'target16"); 16631cb0ef41Sopenharmony_ci break; 16641cb0ef41Sopenharmony_ci case CR_LT: 16651cb0ef41Sopenharmony_ci Format(instr, "bge'l'a'cr 'target16"); 16661cb0ef41Sopenharmony_ci break; 16671cb0ef41Sopenharmony_ci case CR_SO: 16681cb0ef41Sopenharmony_ci Format(instr, "bnso'l'a'cr 'target16"); 16691cb0ef41Sopenharmony_ci break; 16701cb0ef41Sopenharmony_ci } 16711cb0ef41Sopenharmony_ci break; 16721cb0ef41Sopenharmony_ci } 16731cb0ef41Sopenharmony_ci case DCBNZ: { // Decrement CTR; branch if CTR != 0 16741cb0ef41Sopenharmony_ci Format(instr, "bdnz'l'a 'target16"); 16751cb0ef41Sopenharmony_ci break; 16761cb0ef41Sopenharmony_ci } 16771cb0ef41Sopenharmony_ci default: 16781cb0ef41Sopenharmony_ci Format(instr, "bc'l'a'cr 'target16"); 16791cb0ef41Sopenharmony_ci break; 16801cb0ef41Sopenharmony_ci } 16811cb0ef41Sopenharmony_ci break; 16821cb0ef41Sopenharmony_ci } 16831cb0ef41Sopenharmony_ci case SC: { 16841cb0ef41Sopenharmony_ci UnknownFormat(instr, "sc"); 16851cb0ef41Sopenharmony_ci break; 16861cb0ef41Sopenharmony_ci } 16871cb0ef41Sopenharmony_ci case BX: { 16881cb0ef41Sopenharmony_ci Format(instr, "b'l'a 'target26"); 16891cb0ef41Sopenharmony_ci break; 16901cb0ef41Sopenharmony_ci } 16911cb0ef41Sopenharmony_ci case EXTP: { 16921cb0ef41Sopenharmony_ci DecodeExtP(instr); 16931cb0ef41Sopenharmony_ci break; 16941cb0ef41Sopenharmony_ci } 16951cb0ef41Sopenharmony_ci case EXT0: { 16961cb0ef41Sopenharmony_ci DecodeExt0(instr); 16971cb0ef41Sopenharmony_ci break; 16981cb0ef41Sopenharmony_ci } 16991cb0ef41Sopenharmony_ci case EXT1: { 17001cb0ef41Sopenharmony_ci DecodeExt1(instr); 17011cb0ef41Sopenharmony_ci break; 17021cb0ef41Sopenharmony_ci } 17031cb0ef41Sopenharmony_ci case RLWIMIX: { 17041cb0ef41Sopenharmony_ci Format(instr, "rlwimi'. 'ra, 'rs, 'sh, 'me, 'mb"); 17051cb0ef41Sopenharmony_ci break; 17061cb0ef41Sopenharmony_ci } 17071cb0ef41Sopenharmony_ci case RLWINMX: { 17081cb0ef41Sopenharmony_ci Format(instr, "rlwinm'. 'ra, 'rs, 'sh, 'me, 'mb"); 17091cb0ef41Sopenharmony_ci break; 17101cb0ef41Sopenharmony_ci } 17111cb0ef41Sopenharmony_ci case RLWNMX: { 17121cb0ef41Sopenharmony_ci Format(instr, "rlwnm'. 'ra, 'rs, 'rb, 'me, 'mb"); 17131cb0ef41Sopenharmony_ci break; 17141cb0ef41Sopenharmony_ci } 17151cb0ef41Sopenharmony_ci case ORI: { 17161cb0ef41Sopenharmony_ci Format(instr, "ori 'ra, 'rs, 'uint16"); 17171cb0ef41Sopenharmony_ci break; 17181cb0ef41Sopenharmony_ci } 17191cb0ef41Sopenharmony_ci case ORIS: { 17201cb0ef41Sopenharmony_ci Format(instr, "oris 'ra, 'rs, 'uint16"); 17211cb0ef41Sopenharmony_ci break; 17221cb0ef41Sopenharmony_ci } 17231cb0ef41Sopenharmony_ci case XORI: { 17241cb0ef41Sopenharmony_ci Format(instr, "xori 'ra, 'rs, 'uint16"); 17251cb0ef41Sopenharmony_ci break; 17261cb0ef41Sopenharmony_ci } 17271cb0ef41Sopenharmony_ci case XORIS: { 17281cb0ef41Sopenharmony_ci Format(instr, "xoris 'ra, 'rs, 'uint16"); 17291cb0ef41Sopenharmony_ci break; 17301cb0ef41Sopenharmony_ci } 17311cb0ef41Sopenharmony_ci case ANDIx: { 17321cb0ef41Sopenharmony_ci Format(instr, "andi. 'ra, 'rs, 'uint16"); 17331cb0ef41Sopenharmony_ci break; 17341cb0ef41Sopenharmony_ci } 17351cb0ef41Sopenharmony_ci case ANDISx: { 17361cb0ef41Sopenharmony_ci Format(instr, "andis. 'ra, 'rs, 'uint16"); 17371cb0ef41Sopenharmony_ci break; 17381cb0ef41Sopenharmony_ci } 17391cb0ef41Sopenharmony_ci case EXT2: { 17401cb0ef41Sopenharmony_ci DecodeExt2(instr); 17411cb0ef41Sopenharmony_ci break; 17421cb0ef41Sopenharmony_ci } 17431cb0ef41Sopenharmony_ci case LWZ: { 17441cb0ef41Sopenharmony_ci Format(instr, "lwz 'rt, 'int16('ra)"); 17451cb0ef41Sopenharmony_ci break; 17461cb0ef41Sopenharmony_ci } 17471cb0ef41Sopenharmony_ci case LWZU: { 17481cb0ef41Sopenharmony_ci Format(instr, "lwzu 'rt, 'int16('ra)"); 17491cb0ef41Sopenharmony_ci break; 17501cb0ef41Sopenharmony_ci } 17511cb0ef41Sopenharmony_ci case LBZ: { 17521cb0ef41Sopenharmony_ci Format(instr, "lbz 'rt, 'int16('ra)"); 17531cb0ef41Sopenharmony_ci break; 17541cb0ef41Sopenharmony_ci } 17551cb0ef41Sopenharmony_ci case LBZU: { 17561cb0ef41Sopenharmony_ci Format(instr, "lbzu 'rt, 'int16('ra)"); 17571cb0ef41Sopenharmony_ci break; 17581cb0ef41Sopenharmony_ci } 17591cb0ef41Sopenharmony_ci case STW: { 17601cb0ef41Sopenharmony_ci Format(instr, "stw 'rs, 'int16('ra)"); 17611cb0ef41Sopenharmony_ci break; 17621cb0ef41Sopenharmony_ci } 17631cb0ef41Sopenharmony_ci case STWU: { 17641cb0ef41Sopenharmony_ci Format(instr, "stwu 'rs, 'int16('ra)"); 17651cb0ef41Sopenharmony_ci break; 17661cb0ef41Sopenharmony_ci } 17671cb0ef41Sopenharmony_ci case STB: { 17681cb0ef41Sopenharmony_ci Format(instr, "stb 'rs, 'int16('ra)"); 17691cb0ef41Sopenharmony_ci break; 17701cb0ef41Sopenharmony_ci } 17711cb0ef41Sopenharmony_ci case STBU: { 17721cb0ef41Sopenharmony_ci Format(instr, "stbu 'rs, 'int16('ra)"); 17731cb0ef41Sopenharmony_ci break; 17741cb0ef41Sopenharmony_ci } 17751cb0ef41Sopenharmony_ci case LHZ: { 17761cb0ef41Sopenharmony_ci Format(instr, "lhz 'rt, 'int16('ra)"); 17771cb0ef41Sopenharmony_ci break; 17781cb0ef41Sopenharmony_ci } 17791cb0ef41Sopenharmony_ci case LHZU: { 17801cb0ef41Sopenharmony_ci Format(instr, "lhzu 'rt, 'int16('ra)"); 17811cb0ef41Sopenharmony_ci break; 17821cb0ef41Sopenharmony_ci } 17831cb0ef41Sopenharmony_ci case LHA: { 17841cb0ef41Sopenharmony_ci Format(instr, "lha 'rt, 'int16('ra)"); 17851cb0ef41Sopenharmony_ci break; 17861cb0ef41Sopenharmony_ci } 17871cb0ef41Sopenharmony_ci case LHAU: { 17881cb0ef41Sopenharmony_ci Format(instr, "lhau 'rt, 'int16('ra)"); 17891cb0ef41Sopenharmony_ci break; 17901cb0ef41Sopenharmony_ci } 17911cb0ef41Sopenharmony_ci case STH: { 17921cb0ef41Sopenharmony_ci Format(instr, "sth 'rs, 'int16('ra)"); 17931cb0ef41Sopenharmony_ci break; 17941cb0ef41Sopenharmony_ci } 17951cb0ef41Sopenharmony_ci case STHU: { 17961cb0ef41Sopenharmony_ci Format(instr, "sthu 'rs, 'int16('ra)"); 17971cb0ef41Sopenharmony_ci break; 17981cb0ef41Sopenharmony_ci } 17991cb0ef41Sopenharmony_ci case LMW: { 18001cb0ef41Sopenharmony_ci UnknownFormat(instr, "lmw"); 18011cb0ef41Sopenharmony_ci break; 18021cb0ef41Sopenharmony_ci } 18031cb0ef41Sopenharmony_ci case STMW: { 18041cb0ef41Sopenharmony_ci UnknownFormat(instr, "stmw"); 18051cb0ef41Sopenharmony_ci break; 18061cb0ef41Sopenharmony_ci } 18071cb0ef41Sopenharmony_ci case LFS: { 18081cb0ef41Sopenharmony_ci Format(instr, "lfs 'Dt, 'int16('ra)"); 18091cb0ef41Sopenharmony_ci break; 18101cb0ef41Sopenharmony_ci } 18111cb0ef41Sopenharmony_ci case LFSU: { 18121cb0ef41Sopenharmony_ci Format(instr, "lfsu 'Dt, 'int16('ra)"); 18131cb0ef41Sopenharmony_ci break; 18141cb0ef41Sopenharmony_ci } 18151cb0ef41Sopenharmony_ci case LFD: { 18161cb0ef41Sopenharmony_ci Format(instr, "lfd 'Dt, 'int16('ra)"); 18171cb0ef41Sopenharmony_ci break; 18181cb0ef41Sopenharmony_ci } 18191cb0ef41Sopenharmony_ci case LFDU: { 18201cb0ef41Sopenharmony_ci Format(instr, "lfdu 'Dt, 'int16('ra)"); 18211cb0ef41Sopenharmony_ci break; 18221cb0ef41Sopenharmony_ci } 18231cb0ef41Sopenharmony_ci case STFS: { 18241cb0ef41Sopenharmony_ci Format(instr, "stfs 'Dt, 'int16('ra)"); 18251cb0ef41Sopenharmony_ci break; 18261cb0ef41Sopenharmony_ci } 18271cb0ef41Sopenharmony_ci case STFSU: { 18281cb0ef41Sopenharmony_ci Format(instr, "stfsu 'Dt, 'int16('ra)"); 18291cb0ef41Sopenharmony_ci break; 18301cb0ef41Sopenharmony_ci } 18311cb0ef41Sopenharmony_ci case STFD: { 18321cb0ef41Sopenharmony_ci Format(instr, "stfd 'Dt, 'int16('ra)"); 18331cb0ef41Sopenharmony_ci break; 18341cb0ef41Sopenharmony_ci } 18351cb0ef41Sopenharmony_ci case STFDU: { 18361cb0ef41Sopenharmony_ci Format(instr, "stfdu 'Dt, 'int16('ra)"); 18371cb0ef41Sopenharmony_ci break; 18381cb0ef41Sopenharmony_ci } 18391cb0ef41Sopenharmony_ci case EXT3: { 18401cb0ef41Sopenharmony_ci DecodeExt3(instr); 18411cb0ef41Sopenharmony_ci break; 18421cb0ef41Sopenharmony_ci } 18431cb0ef41Sopenharmony_ci case EXT4: { 18441cb0ef41Sopenharmony_ci DecodeExt4(instr); 18451cb0ef41Sopenharmony_ci break; 18461cb0ef41Sopenharmony_ci } 18471cb0ef41Sopenharmony_ci case EXT5: { 18481cb0ef41Sopenharmony_ci DecodeExt5(instr); 18491cb0ef41Sopenharmony_ci break; 18501cb0ef41Sopenharmony_ci } 18511cb0ef41Sopenharmony_ci case EXT6: { 18521cb0ef41Sopenharmony_ci DecodeExt6(instr); 18531cb0ef41Sopenharmony_ci break; 18541cb0ef41Sopenharmony_ci } 18551cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_PPC64 18561cb0ef41Sopenharmony_ci case LD: { 18571cb0ef41Sopenharmony_ci switch (instr->Bits(1, 0)) { 18581cb0ef41Sopenharmony_ci case 0: 18591cb0ef41Sopenharmony_ci Format(instr, "ld 'rt, 'd('ra)"); 18601cb0ef41Sopenharmony_ci break; 18611cb0ef41Sopenharmony_ci case 1: 18621cb0ef41Sopenharmony_ci Format(instr, "ldu 'rt, 'd('ra)"); 18631cb0ef41Sopenharmony_ci break; 18641cb0ef41Sopenharmony_ci case 2: 18651cb0ef41Sopenharmony_ci Format(instr, "lwa 'rt, 'd('ra)"); 18661cb0ef41Sopenharmony_ci break; 18671cb0ef41Sopenharmony_ci } 18681cb0ef41Sopenharmony_ci break; 18691cb0ef41Sopenharmony_ci } 18701cb0ef41Sopenharmony_ci case STD: { // could be STD or STDU 18711cb0ef41Sopenharmony_ci if (instr->Bit(0) == 0) { 18721cb0ef41Sopenharmony_ci Format(instr, "std 'rs, 'd('ra)"); 18731cb0ef41Sopenharmony_ci } else { 18741cb0ef41Sopenharmony_ci Format(instr, "stdu 'rs, 'd('ra)"); 18751cb0ef41Sopenharmony_ci } 18761cb0ef41Sopenharmony_ci break; 18771cb0ef41Sopenharmony_ci } 18781cb0ef41Sopenharmony_ci#endif 18791cb0ef41Sopenharmony_ci default: { 18801cb0ef41Sopenharmony_ci Unknown(instr); 18811cb0ef41Sopenharmony_ci break; 18821cb0ef41Sopenharmony_ci } 18831cb0ef41Sopenharmony_ci } 18841cb0ef41Sopenharmony_ci 18851cb0ef41Sopenharmony_ci if (IsPrefixed()) { 18861cb0ef41Sopenharmony_ci // The next instruction (suffix) should have already been decoded as part of 18871cb0ef41Sopenharmony_ci // prefix decoding. 18881cb0ef41Sopenharmony_ci ResetPrefix(); 18891cb0ef41Sopenharmony_ci return 2 * kInstrSize; 18901cb0ef41Sopenharmony_ci } 18911cb0ef41Sopenharmony_ci 18921cb0ef41Sopenharmony_ci return kInstrSize; 18931cb0ef41Sopenharmony_ci} 18941cb0ef41Sopenharmony_ci} // namespace internal 18951cb0ef41Sopenharmony_ci} // namespace v8 18961cb0ef41Sopenharmony_ci 18971cb0ef41Sopenharmony_ci//------------------------------------------------------------------------------ 18981cb0ef41Sopenharmony_ci 18991cb0ef41Sopenharmony_cinamespace disasm { 19001cb0ef41Sopenharmony_ci 19011cb0ef41Sopenharmony_ciconst char* NameConverter::NameOfAddress(byte* addr) const { 19021cb0ef41Sopenharmony_ci v8::base::SNPrintF(tmp_buffer_, "%p", static_cast<void*>(addr)); 19031cb0ef41Sopenharmony_ci return tmp_buffer_.begin(); 19041cb0ef41Sopenharmony_ci} 19051cb0ef41Sopenharmony_ci 19061cb0ef41Sopenharmony_ciconst char* NameConverter::NameOfConstant(byte* addr) const { 19071cb0ef41Sopenharmony_ci return NameOfAddress(addr); 19081cb0ef41Sopenharmony_ci} 19091cb0ef41Sopenharmony_ci 19101cb0ef41Sopenharmony_ciconst char* NameConverter::NameOfCPURegister(int reg) const { 19111cb0ef41Sopenharmony_ci return RegisterName(i::Register::from_code(reg)); 19121cb0ef41Sopenharmony_ci} 19131cb0ef41Sopenharmony_ci 19141cb0ef41Sopenharmony_ciconst char* NameConverter::NameOfByteCPURegister(int reg) const { 19151cb0ef41Sopenharmony_ci UNREACHABLE(); // PPC does not have the concept of a byte register 19161cb0ef41Sopenharmony_ci} 19171cb0ef41Sopenharmony_ci 19181cb0ef41Sopenharmony_ciconst char* NameConverter::NameOfXMMRegister(int reg) const { 19191cb0ef41Sopenharmony_ci UNREACHABLE(); // PPC does not have any XMM registers 19201cb0ef41Sopenharmony_ci} 19211cb0ef41Sopenharmony_ci 19221cb0ef41Sopenharmony_ciconst char* NameConverter::NameInCode(byte* addr) const { 19231cb0ef41Sopenharmony_ci // The default name converter is called for unknown code. So we will not try 19241cb0ef41Sopenharmony_ci // to access any memory. 19251cb0ef41Sopenharmony_ci return ""; 19261cb0ef41Sopenharmony_ci} 19271cb0ef41Sopenharmony_ci 19281cb0ef41Sopenharmony_ci//------------------------------------------------------------------------------ 19291cb0ef41Sopenharmony_ci 19301cb0ef41Sopenharmony_ciint Disassembler::InstructionDecode(v8::base::Vector<char> buffer, 19311cb0ef41Sopenharmony_ci byte* instruction) { 19321cb0ef41Sopenharmony_ci v8::internal::Decoder d(converter_, buffer); 19331cb0ef41Sopenharmony_ci return d.InstructionDecode(instruction); 19341cb0ef41Sopenharmony_ci} 19351cb0ef41Sopenharmony_ci 19361cb0ef41Sopenharmony_ci// The PPC assembler does not currently use constant pools. 19371cb0ef41Sopenharmony_ciint Disassembler::ConstantPoolSizeAt(byte* instruction) { return -1; } 19381cb0ef41Sopenharmony_ci 19391cb0ef41Sopenharmony_civoid Disassembler::Disassemble(FILE* f, byte* begin, byte* end, 19401cb0ef41Sopenharmony_ci UnimplementedOpcodeAction unimplemented_action) { 19411cb0ef41Sopenharmony_ci NameConverter converter; 19421cb0ef41Sopenharmony_ci Disassembler d(converter, unimplemented_action); 19431cb0ef41Sopenharmony_ci for (byte* pc = begin; pc < end;) { 19441cb0ef41Sopenharmony_ci v8::base::EmbeddedVector<char, 128> buffer; 19451cb0ef41Sopenharmony_ci buffer[0] = '\0'; 19461cb0ef41Sopenharmony_ci byte* prev_pc = pc; 19471cb0ef41Sopenharmony_ci pc += d.InstructionDecode(buffer, pc); 19481cb0ef41Sopenharmony_ci v8::internal::PrintF(f, "%p %08x %s\n", static_cast<void*>(prev_pc), 19491cb0ef41Sopenharmony_ci *reinterpret_cast<int32_t*>(prev_pc), buffer.begin()); 19501cb0ef41Sopenharmony_ci } 19511cb0ef41Sopenharmony_ci} 19521cb0ef41Sopenharmony_ci 19531cb0ef41Sopenharmony_ci#undef STRING_STARTS_WITH 19541cb0ef41Sopenharmony_ci 19551cb0ef41Sopenharmony_ci} // namespace disasm 19561cb0ef41Sopenharmony_ci 19571cb0ef41Sopenharmony_ci#endif // V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64 1958