11cb0ef41Sopenharmony_ci// Copyright 2021 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#include <assert.h>
61cb0ef41Sopenharmony_ci#include <stdarg.h>
71cb0ef41Sopenharmony_ci#include <stdio.h>
81cb0ef41Sopenharmony_ci#include <string.h>
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_LOONG64
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_ci#include "src/base/platform/platform.h"
131cb0ef41Sopenharmony_ci#include "src/base/strings.h"
141cb0ef41Sopenharmony_ci#include "src/base/vector.h"
151cb0ef41Sopenharmony_ci#include "src/codegen/loong64/constants-loong64.h"
161cb0ef41Sopenharmony_ci#include "src/codegen/macro-assembler.h"
171cb0ef41Sopenharmony_ci#include "src/diagnostics/disasm.h"
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_cinamespace v8 {
201cb0ef41Sopenharmony_cinamespace internal {
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ci//------------------------------------------------------------------------------
231cb0ef41Sopenharmony_ci
241cb0ef41Sopenharmony_ci// Decoder decodes and disassembles instructions into an output buffer.
251cb0ef41Sopenharmony_ci// It uses the converter to convert register names and call destinations into
261cb0ef41Sopenharmony_ci// more informative description.
271cb0ef41Sopenharmony_ciclass Decoder {
281cb0ef41Sopenharmony_ci public:
291cb0ef41Sopenharmony_ci  Decoder(const disasm::NameConverter& converter,
301cb0ef41Sopenharmony_ci          v8::base::Vector<char> out_buffer)
311cb0ef41Sopenharmony_ci      : converter_(converter), out_buffer_(out_buffer), out_buffer_pos_(0) {
321cb0ef41Sopenharmony_ci    out_buffer_[out_buffer_pos_] = '\0';
331cb0ef41Sopenharmony_ci  }
341cb0ef41Sopenharmony_ci
351cb0ef41Sopenharmony_ci  ~Decoder() {}
361cb0ef41Sopenharmony_ci
371cb0ef41Sopenharmony_ci  Decoder(const Decoder&) = delete;
381cb0ef41Sopenharmony_ci  Decoder& operator=(const Decoder&) = delete;
391cb0ef41Sopenharmony_ci
401cb0ef41Sopenharmony_ci  // Writes one disassembled instruction into 'buffer' (0-terminated).
411cb0ef41Sopenharmony_ci  // Returns the length of the disassembled machine instruction in bytes.
421cb0ef41Sopenharmony_ci  int InstructionDecode(byte* instruction);
431cb0ef41Sopenharmony_ci
441cb0ef41Sopenharmony_ci private:
451cb0ef41Sopenharmony_ci  // Bottleneck functions to print into the out_buffer.
461cb0ef41Sopenharmony_ci  void PrintChar(const char ch);
471cb0ef41Sopenharmony_ci  void Print(const char* str);
481cb0ef41Sopenharmony_ci
491cb0ef41Sopenharmony_ci  // Printing of common values.
501cb0ef41Sopenharmony_ci  void PrintRegister(int reg);
511cb0ef41Sopenharmony_ci  void PrintFPURegister(int freg);
521cb0ef41Sopenharmony_ci  void PrintFPUStatusRegister(int freg);
531cb0ef41Sopenharmony_ci  void PrintRj(Instruction* instr);
541cb0ef41Sopenharmony_ci  void PrintRk(Instruction* instr);
551cb0ef41Sopenharmony_ci  void PrintRd(Instruction* instr);
561cb0ef41Sopenharmony_ci  void PrintFj(Instruction* instr);
571cb0ef41Sopenharmony_ci  void PrintFk(Instruction* instr);
581cb0ef41Sopenharmony_ci  void PrintFd(Instruction* instr);
591cb0ef41Sopenharmony_ci  void PrintFa(Instruction* instr);
601cb0ef41Sopenharmony_ci  void PrintSa2(Instruction* instr);
611cb0ef41Sopenharmony_ci  void PrintSa3(Instruction* instr);
621cb0ef41Sopenharmony_ci  void PrintUi5(Instruction* instr);
631cb0ef41Sopenharmony_ci  void PrintUi6(Instruction* instr);
641cb0ef41Sopenharmony_ci  void PrintUi12(Instruction* instr);
651cb0ef41Sopenharmony_ci  void PrintMsbw(Instruction* instr);
661cb0ef41Sopenharmony_ci  void PrintLsbw(Instruction* instr);
671cb0ef41Sopenharmony_ci  void PrintMsbd(Instruction* instr);
681cb0ef41Sopenharmony_ci  void PrintLsbd(Instruction* instr);
691cb0ef41Sopenharmony_ci  //  void PrintCond(Instruction* instr);
701cb0ef41Sopenharmony_ci  void PrintSi12(Instruction* instr);
711cb0ef41Sopenharmony_ci  void PrintSi14(Instruction* instr);
721cb0ef41Sopenharmony_ci  void PrintSi16(Instruction* instr);
731cb0ef41Sopenharmony_ci  void PrintSi20(Instruction* instr);
741cb0ef41Sopenharmony_ci  void PrintXi12(Instruction* instr);
751cb0ef41Sopenharmony_ci  void PrintXi20(Instruction* instr);
761cb0ef41Sopenharmony_ci  void PrintCj(Instruction* instr);
771cb0ef41Sopenharmony_ci  void PrintCd(Instruction* instr);
781cb0ef41Sopenharmony_ci  void PrintCa(Instruction* instr);
791cb0ef41Sopenharmony_ci  void PrintCode(Instruction* instr);
801cb0ef41Sopenharmony_ci  void PrintHint5(Instruction* instr);
811cb0ef41Sopenharmony_ci  void PrintHint15(Instruction* instr);
821cb0ef41Sopenharmony_ci  void PrintPCOffs16(Instruction* instr);
831cb0ef41Sopenharmony_ci  void PrintPCOffs21(Instruction* instr);
841cb0ef41Sopenharmony_ci  void PrintPCOffs26(Instruction* instr);
851cb0ef41Sopenharmony_ci  void PrintOffs16(Instruction* instr);
861cb0ef41Sopenharmony_ci  void PrintOffs21(Instruction* instr);
871cb0ef41Sopenharmony_ci  void PrintOffs26(Instruction* instr);
881cb0ef41Sopenharmony_ci
891cb0ef41Sopenharmony_ci  // Handle formatting of instructions and their options.
901cb0ef41Sopenharmony_ci  int FormatRegister(Instruction* instr, const char* option);
911cb0ef41Sopenharmony_ci  int FormatFPURegister(Instruction* instr, const char* option);
921cb0ef41Sopenharmony_ci  int FormatOption(Instruction* instr, const char* option);
931cb0ef41Sopenharmony_ci  void Format(Instruction* instr, const char* format);
941cb0ef41Sopenharmony_ci  void Unknown(Instruction* instr);
951cb0ef41Sopenharmony_ci  int DecodeBreakInstr(Instruction* instr);
961cb0ef41Sopenharmony_ci
971cb0ef41Sopenharmony_ci  // Each of these functions decodes one particular instruction type.
981cb0ef41Sopenharmony_ci  int InstructionDecode(Instruction* instr);
991cb0ef41Sopenharmony_ci  void DecodeTypekOp6(Instruction* instr);
1001cb0ef41Sopenharmony_ci  void DecodeTypekOp7(Instruction* instr);
1011cb0ef41Sopenharmony_ci  void DecodeTypekOp8(Instruction* instr);
1021cb0ef41Sopenharmony_ci  void DecodeTypekOp10(Instruction* instr);
1031cb0ef41Sopenharmony_ci  void DecodeTypekOp12(Instruction* instr);
1041cb0ef41Sopenharmony_ci  void DecodeTypekOp14(Instruction* instr);
1051cb0ef41Sopenharmony_ci  int DecodeTypekOp17(Instruction* instr);
1061cb0ef41Sopenharmony_ci  void DecodeTypekOp22(Instruction* instr);
1071cb0ef41Sopenharmony_ci
1081cb0ef41Sopenharmony_ci  const disasm::NameConverter& converter_;
1091cb0ef41Sopenharmony_ci  v8::base::Vector<char> out_buffer_;
1101cb0ef41Sopenharmony_ci  int out_buffer_pos_;
1111cb0ef41Sopenharmony_ci};
1121cb0ef41Sopenharmony_ci
1131cb0ef41Sopenharmony_ci// Support for assertions in the Decoder formatting functions.
1141cb0ef41Sopenharmony_ci#define STRING_STARTS_WITH(string, compare_string) \
1151cb0ef41Sopenharmony_ci  (strncmp(string, compare_string, strlen(compare_string)) == 0)
1161cb0ef41Sopenharmony_ci
1171cb0ef41Sopenharmony_ci// Append the ch to the output buffer.
1181cb0ef41Sopenharmony_civoid Decoder::PrintChar(const char ch) { out_buffer_[out_buffer_pos_++] = ch; }
1191cb0ef41Sopenharmony_ci
1201cb0ef41Sopenharmony_ci// Append the str to the output buffer.
1211cb0ef41Sopenharmony_civoid Decoder::Print(const char* str) {
1221cb0ef41Sopenharmony_ci  char cur = *str++;
1231cb0ef41Sopenharmony_ci  while (cur != '\0' && (out_buffer_pos_ < (out_buffer_.length() - 1))) {
1241cb0ef41Sopenharmony_ci    PrintChar(cur);
1251cb0ef41Sopenharmony_ci    cur = *str++;
1261cb0ef41Sopenharmony_ci  }
1271cb0ef41Sopenharmony_ci  out_buffer_[out_buffer_pos_] = 0;
1281cb0ef41Sopenharmony_ci}
1291cb0ef41Sopenharmony_ci
1301cb0ef41Sopenharmony_ci// Print the register name according to the active name converter.
1311cb0ef41Sopenharmony_civoid Decoder::PrintRegister(int reg) {
1321cb0ef41Sopenharmony_ci  Print(converter_.NameOfCPURegister(reg));
1331cb0ef41Sopenharmony_ci}
1341cb0ef41Sopenharmony_ci
1351cb0ef41Sopenharmony_civoid Decoder::PrintRj(Instruction* instr) {
1361cb0ef41Sopenharmony_ci  int reg = instr->RjValue();
1371cb0ef41Sopenharmony_ci  PrintRegister(reg);
1381cb0ef41Sopenharmony_ci}
1391cb0ef41Sopenharmony_ci
1401cb0ef41Sopenharmony_civoid Decoder::PrintRk(Instruction* instr) {
1411cb0ef41Sopenharmony_ci  int reg = instr->RkValue();
1421cb0ef41Sopenharmony_ci  PrintRegister(reg);
1431cb0ef41Sopenharmony_ci}
1441cb0ef41Sopenharmony_ci
1451cb0ef41Sopenharmony_civoid Decoder::PrintRd(Instruction* instr) {
1461cb0ef41Sopenharmony_ci  int reg = instr->RdValue();
1471cb0ef41Sopenharmony_ci  PrintRegister(reg);
1481cb0ef41Sopenharmony_ci}
1491cb0ef41Sopenharmony_ci
1501cb0ef41Sopenharmony_ci// Print the FPUregister name according to the active name converter.
1511cb0ef41Sopenharmony_civoid Decoder::PrintFPURegister(int freg) {
1521cb0ef41Sopenharmony_ci  Print(converter_.NameOfXMMRegister(freg));
1531cb0ef41Sopenharmony_ci}
1541cb0ef41Sopenharmony_ci
1551cb0ef41Sopenharmony_civoid Decoder::PrintFj(Instruction* instr) {
1561cb0ef41Sopenharmony_ci  int freg = instr->FjValue();
1571cb0ef41Sopenharmony_ci  PrintFPURegister(freg);
1581cb0ef41Sopenharmony_ci}
1591cb0ef41Sopenharmony_ci
1601cb0ef41Sopenharmony_civoid Decoder::PrintFk(Instruction* instr) {
1611cb0ef41Sopenharmony_ci  int freg = instr->FkValue();
1621cb0ef41Sopenharmony_ci  PrintFPURegister(freg);
1631cb0ef41Sopenharmony_ci}
1641cb0ef41Sopenharmony_ci
1651cb0ef41Sopenharmony_civoid Decoder::PrintFd(Instruction* instr) {
1661cb0ef41Sopenharmony_ci  int freg = instr->FdValue();
1671cb0ef41Sopenharmony_ci  PrintFPURegister(freg);
1681cb0ef41Sopenharmony_ci}
1691cb0ef41Sopenharmony_ci
1701cb0ef41Sopenharmony_civoid Decoder::PrintFa(Instruction* instr) {
1711cb0ef41Sopenharmony_ci  int freg = instr->FaValue();
1721cb0ef41Sopenharmony_ci  PrintFPURegister(freg);
1731cb0ef41Sopenharmony_ci}
1741cb0ef41Sopenharmony_ci
1751cb0ef41Sopenharmony_ci// Print the integer value of the sa field.
1761cb0ef41Sopenharmony_civoid Decoder::PrintSa2(Instruction* instr) {
1771cb0ef41Sopenharmony_ci  int sa = instr->Sa2Value();
1781cb0ef41Sopenharmony_ci  uint32_t opcode = (instr->InstructionBits() >> 18) << 18;
1791cb0ef41Sopenharmony_ci  if (opcode == ALSL || opcode == ALSL_D) {
1801cb0ef41Sopenharmony_ci    sa += 1;
1811cb0ef41Sopenharmony_ci  }
1821cb0ef41Sopenharmony_ci  out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "%d", sa);
1831cb0ef41Sopenharmony_ci}
1841cb0ef41Sopenharmony_ci
1851cb0ef41Sopenharmony_civoid Decoder::PrintSa3(Instruction* instr) {
1861cb0ef41Sopenharmony_ci  int sa = instr->Sa3Value();
1871cb0ef41Sopenharmony_ci  out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "%d", sa);
1881cb0ef41Sopenharmony_ci}
1891cb0ef41Sopenharmony_ci
1901cb0ef41Sopenharmony_civoid Decoder::PrintUi5(Instruction* instr) {
1911cb0ef41Sopenharmony_ci  int ui = instr->Ui5Value();
1921cb0ef41Sopenharmony_ci  out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "%u", ui);
1931cb0ef41Sopenharmony_ci}
1941cb0ef41Sopenharmony_ci
1951cb0ef41Sopenharmony_civoid Decoder::PrintUi6(Instruction* instr) {
1961cb0ef41Sopenharmony_ci  int ui = instr->Ui6Value();
1971cb0ef41Sopenharmony_ci  out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "%u", ui);
1981cb0ef41Sopenharmony_ci}
1991cb0ef41Sopenharmony_ci
2001cb0ef41Sopenharmony_civoid Decoder::PrintUi12(Instruction* instr) {
2011cb0ef41Sopenharmony_ci  int ui = instr->Ui12Value();
2021cb0ef41Sopenharmony_ci  out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "%u", ui);
2031cb0ef41Sopenharmony_ci}
2041cb0ef41Sopenharmony_ci
2051cb0ef41Sopenharmony_civoid Decoder::PrintXi12(Instruction* instr) {
2061cb0ef41Sopenharmony_ci  int xi = instr->Ui12Value();
2071cb0ef41Sopenharmony_ci  out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x", xi);
2081cb0ef41Sopenharmony_ci}
2091cb0ef41Sopenharmony_ci
2101cb0ef41Sopenharmony_civoid Decoder::PrintXi20(Instruction* instr) {
2111cb0ef41Sopenharmony_ci  int xi = instr->Si20Value();
2121cb0ef41Sopenharmony_ci  out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x", xi);
2131cb0ef41Sopenharmony_ci}
2141cb0ef41Sopenharmony_ci
2151cb0ef41Sopenharmony_civoid Decoder::PrintMsbd(Instruction* instr) {
2161cb0ef41Sopenharmony_ci  int msbd = instr->MsbdValue();
2171cb0ef41Sopenharmony_ci  out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "%u", msbd);
2181cb0ef41Sopenharmony_ci}
2191cb0ef41Sopenharmony_ci
2201cb0ef41Sopenharmony_civoid Decoder::PrintLsbd(Instruction* instr) {
2211cb0ef41Sopenharmony_ci  int lsbd = instr->LsbdValue();
2221cb0ef41Sopenharmony_ci  out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "%u", lsbd);
2231cb0ef41Sopenharmony_ci}
2241cb0ef41Sopenharmony_ci
2251cb0ef41Sopenharmony_civoid Decoder::PrintMsbw(Instruction* instr) {
2261cb0ef41Sopenharmony_ci  int msbw = instr->MsbwValue();
2271cb0ef41Sopenharmony_ci  out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "%u", msbw);
2281cb0ef41Sopenharmony_ci}
2291cb0ef41Sopenharmony_ci
2301cb0ef41Sopenharmony_civoid Decoder::PrintLsbw(Instruction* instr) {
2311cb0ef41Sopenharmony_ci  int lsbw = instr->LsbwValue();
2321cb0ef41Sopenharmony_ci  out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "%u", lsbw);
2331cb0ef41Sopenharmony_ci}
2341cb0ef41Sopenharmony_ci
2351cb0ef41Sopenharmony_civoid Decoder::PrintSi12(Instruction* instr) {
2361cb0ef41Sopenharmony_ci  int si = ((instr->Si12Value()) << (32 - kSi12Bits)) >> (32 - kSi12Bits);
2371cb0ef41Sopenharmony_ci  out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "%d(0x%x)",
2381cb0ef41Sopenharmony_ci                                    si, instr->Si12Value());
2391cb0ef41Sopenharmony_ci}
2401cb0ef41Sopenharmony_ci
2411cb0ef41Sopenharmony_civoid Decoder::PrintSi14(Instruction* instr) {
2421cb0ef41Sopenharmony_ci  int si = ((instr->Si14Value()) << (32 - kSi14Bits)) >> (32 - kSi14Bits);
2431cb0ef41Sopenharmony_ci  si <<= 2;
2441cb0ef41Sopenharmony_ci  out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "%d(0x%x)",
2451cb0ef41Sopenharmony_ci                                    si, instr->Si14Value() << 2);
2461cb0ef41Sopenharmony_ci}
2471cb0ef41Sopenharmony_ci
2481cb0ef41Sopenharmony_civoid Decoder::PrintSi16(Instruction* instr) {
2491cb0ef41Sopenharmony_ci  int si = ((instr->Si16Value()) << (32 - kSi16Bits)) >> (32 - kSi16Bits);
2501cb0ef41Sopenharmony_ci  out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "%d(0x%x)",
2511cb0ef41Sopenharmony_ci                                    si, instr->Si16Value());
2521cb0ef41Sopenharmony_ci}
2531cb0ef41Sopenharmony_ci
2541cb0ef41Sopenharmony_civoid Decoder::PrintSi20(Instruction* instr) {
2551cb0ef41Sopenharmony_ci  int si = ((instr->Si20Value()) << (32 - kSi20Bits)) >> (32 - kSi20Bits);
2561cb0ef41Sopenharmony_ci  out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "%d(0x%x)",
2571cb0ef41Sopenharmony_ci                                    si, instr->Si20Value());
2581cb0ef41Sopenharmony_ci}
2591cb0ef41Sopenharmony_ci
2601cb0ef41Sopenharmony_civoid Decoder::PrintCj(Instruction* instr) {
2611cb0ef41Sopenharmony_ci  int cj = instr->CjValue();
2621cb0ef41Sopenharmony_ci  out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "%u", cj);
2631cb0ef41Sopenharmony_ci}
2641cb0ef41Sopenharmony_ci
2651cb0ef41Sopenharmony_civoid Decoder::PrintCd(Instruction* instr) {
2661cb0ef41Sopenharmony_ci  int cd = instr->CdValue();
2671cb0ef41Sopenharmony_ci  out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "%u", cd);
2681cb0ef41Sopenharmony_ci}
2691cb0ef41Sopenharmony_ci
2701cb0ef41Sopenharmony_civoid Decoder::PrintCa(Instruction* instr) {
2711cb0ef41Sopenharmony_ci  int ca = instr->CaValue();
2721cb0ef41Sopenharmony_ci  out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "%u", ca);
2731cb0ef41Sopenharmony_ci}
2741cb0ef41Sopenharmony_ci
2751cb0ef41Sopenharmony_civoid Decoder::PrintCode(Instruction* instr) {
2761cb0ef41Sopenharmony_ci  int code = instr->CodeValue();
2771cb0ef41Sopenharmony_ci  out_buffer_pos_ +=
2781cb0ef41Sopenharmony_ci      base::SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x(%u)", code, code);
2791cb0ef41Sopenharmony_ci}
2801cb0ef41Sopenharmony_ci
2811cb0ef41Sopenharmony_civoid Decoder::PrintHint5(Instruction* instr) {
2821cb0ef41Sopenharmony_ci  int hint = instr->Hint5Value();
2831cb0ef41Sopenharmony_ci  out_buffer_pos_ +=
2841cb0ef41Sopenharmony_ci      base::SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x(%u)", hint, hint);
2851cb0ef41Sopenharmony_ci}
2861cb0ef41Sopenharmony_ci
2871cb0ef41Sopenharmony_civoid Decoder::PrintHint15(Instruction* instr) {
2881cb0ef41Sopenharmony_ci  int hint = instr->Hint15Value();
2891cb0ef41Sopenharmony_ci  out_buffer_pos_ +=
2901cb0ef41Sopenharmony_ci      base::SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x(%u)", hint, hint);
2911cb0ef41Sopenharmony_ci}
2921cb0ef41Sopenharmony_ci
2931cb0ef41Sopenharmony_civoid Decoder::PrintPCOffs16(Instruction* instr) {
2941cb0ef41Sopenharmony_ci  int n_bits = 2;
2951cb0ef41Sopenharmony_ci  int offs = instr->Offs16Value();
2961cb0ef41Sopenharmony_ci  int target = ((offs << n_bits) << (32 - kOffsLowBits - n_bits)) >>
2971cb0ef41Sopenharmony_ci               (32 - kOffsLowBits - n_bits);
2981cb0ef41Sopenharmony_ci  out_buffer_pos_ += base::SNPrintF(
2991cb0ef41Sopenharmony_ci      out_buffer_ + out_buffer_pos_, "%s",
3001cb0ef41Sopenharmony_ci      converter_.NameOfAddress(reinterpret_cast<byte*>(instr) + target));
3011cb0ef41Sopenharmony_ci}
3021cb0ef41Sopenharmony_ci
3031cb0ef41Sopenharmony_civoid Decoder::PrintPCOffs21(Instruction* instr) {
3041cb0ef41Sopenharmony_ci  int n_bits = 2;
3051cb0ef41Sopenharmony_ci  int offs = instr->Offs21Value();
3061cb0ef41Sopenharmony_ci  int target =
3071cb0ef41Sopenharmony_ci      ((offs << n_bits) << (32 - kOffsLowBits - kOffs21HighBits - n_bits)) >>
3081cb0ef41Sopenharmony_ci      (32 - kOffsLowBits - kOffs21HighBits - n_bits);
3091cb0ef41Sopenharmony_ci  out_buffer_pos_ += base::SNPrintF(
3101cb0ef41Sopenharmony_ci      out_buffer_ + out_buffer_pos_, "%s",
3111cb0ef41Sopenharmony_ci      converter_.NameOfAddress(reinterpret_cast<byte*>(instr) + target));
3121cb0ef41Sopenharmony_ci}
3131cb0ef41Sopenharmony_ci
3141cb0ef41Sopenharmony_civoid Decoder::PrintPCOffs26(Instruction* instr) {
3151cb0ef41Sopenharmony_ci  int n_bits = 2;
3161cb0ef41Sopenharmony_ci  int offs = instr->Offs26Value();
3171cb0ef41Sopenharmony_ci  int target =
3181cb0ef41Sopenharmony_ci      ((offs << n_bits) << (32 - kOffsLowBits - kOffs26HighBits - n_bits)) >>
3191cb0ef41Sopenharmony_ci      (32 - kOffsLowBits - kOffs26HighBits - n_bits);
3201cb0ef41Sopenharmony_ci  out_buffer_pos_ += base::SNPrintF(
3211cb0ef41Sopenharmony_ci      out_buffer_ + out_buffer_pos_, "%s",
3221cb0ef41Sopenharmony_ci      converter_.NameOfAddress(reinterpret_cast<byte*>(instr) + target));
3231cb0ef41Sopenharmony_ci}
3241cb0ef41Sopenharmony_ci
3251cb0ef41Sopenharmony_civoid Decoder::PrintOffs16(Instruction* instr) {
3261cb0ef41Sopenharmony_ci  int offs = instr->Offs16Value();
3271cb0ef41Sopenharmony_ci  out_buffer_pos_ +=
3281cb0ef41Sopenharmony_ci      base::SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x", offs << 2);
3291cb0ef41Sopenharmony_ci}
3301cb0ef41Sopenharmony_ci
3311cb0ef41Sopenharmony_civoid Decoder::PrintOffs21(Instruction* instr) {
3321cb0ef41Sopenharmony_ci  int offs = instr->Offs21Value();
3331cb0ef41Sopenharmony_ci  out_buffer_pos_ +=
3341cb0ef41Sopenharmony_ci      base::SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x", offs << 2);
3351cb0ef41Sopenharmony_ci}
3361cb0ef41Sopenharmony_ci
3371cb0ef41Sopenharmony_civoid Decoder::PrintOffs26(Instruction* instr) {
3381cb0ef41Sopenharmony_ci  int offs = instr->Offs26Value();
3391cb0ef41Sopenharmony_ci  out_buffer_pos_ +=
3401cb0ef41Sopenharmony_ci      base::SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x", offs << 2);
3411cb0ef41Sopenharmony_ci}
3421cb0ef41Sopenharmony_ci
3431cb0ef41Sopenharmony_ci// Handle all register based formatting in this function to reduce the
3441cb0ef41Sopenharmony_ci// complexity of FormatOption.
3451cb0ef41Sopenharmony_ciint Decoder::FormatRegister(Instruction* instr, const char* format) {
3461cb0ef41Sopenharmony_ci  DCHECK_EQ(format[0], 'r');
3471cb0ef41Sopenharmony_ci  if (format[1] == 'j') {  // 'rj: Rj register.
3481cb0ef41Sopenharmony_ci    int reg = instr->RjValue();
3491cb0ef41Sopenharmony_ci    PrintRegister(reg);
3501cb0ef41Sopenharmony_ci    return 2;
3511cb0ef41Sopenharmony_ci  } else if (format[1] == 'k') {  // 'rk: rk register.
3521cb0ef41Sopenharmony_ci    int reg = instr->RkValue();
3531cb0ef41Sopenharmony_ci    PrintRegister(reg);
3541cb0ef41Sopenharmony_ci    return 2;
3551cb0ef41Sopenharmony_ci  } else if (format[1] == 'd') {  // 'rd: rd register.
3561cb0ef41Sopenharmony_ci    int reg = instr->RdValue();
3571cb0ef41Sopenharmony_ci    PrintRegister(reg);
3581cb0ef41Sopenharmony_ci    return 2;
3591cb0ef41Sopenharmony_ci  }
3601cb0ef41Sopenharmony_ci  UNREACHABLE();
3611cb0ef41Sopenharmony_ci}
3621cb0ef41Sopenharmony_ci
3631cb0ef41Sopenharmony_ci// Handle all FPUregister based formatting in this function to reduce the
3641cb0ef41Sopenharmony_ci// complexity of FormatOption.
3651cb0ef41Sopenharmony_ciint Decoder::FormatFPURegister(Instruction* instr, const char* format) {
3661cb0ef41Sopenharmony_ci  DCHECK_EQ(format[0], 'f');
3671cb0ef41Sopenharmony_ci  if (format[1] == 'j') {  // 'fj: fj register.
3681cb0ef41Sopenharmony_ci    int reg = instr->FjValue();
3691cb0ef41Sopenharmony_ci    PrintFPURegister(reg);
3701cb0ef41Sopenharmony_ci    return 2;
3711cb0ef41Sopenharmony_ci  } else if (format[1] == 'k') {  // 'fk: fk register.
3721cb0ef41Sopenharmony_ci    int reg = instr->FkValue();
3731cb0ef41Sopenharmony_ci    PrintFPURegister(reg);
3741cb0ef41Sopenharmony_ci    return 2;
3751cb0ef41Sopenharmony_ci  } else if (format[1] == 'd') {  // 'fd: fd register.
3761cb0ef41Sopenharmony_ci    int reg = instr->FdValue();
3771cb0ef41Sopenharmony_ci    PrintFPURegister(reg);
3781cb0ef41Sopenharmony_ci    return 2;
3791cb0ef41Sopenharmony_ci  } else if (format[1] == 'a') {  // 'fa: fa register.
3801cb0ef41Sopenharmony_ci    int reg = instr->FaValue();
3811cb0ef41Sopenharmony_ci    PrintFPURegister(reg);
3821cb0ef41Sopenharmony_ci    return 2;
3831cb0ef41Sopenharmony_ci  }
3841cb0ef41Sopenharmony_ci  UNREACHABLE();
3851cb0ef41Sopenharmony_ci}
3861cb0ef41Sopenharmony_ci
3871cb0ef41Sopenharmony_ci// FormatOption takes a formatting string and interprets it based on
3881cb0ef41Sopenharmony_ci// the current instructions. The format string points to the first
3891cb0ef41Sopenharmony_ci// character of the option string (the option escape has already been
3901cb0ef41Sopenharmony_ci// consumed by the caller.)  FormatOption returns the number of
3911cb0ef41Sopenharmony_ci// characters that were consumed from the formatting string.
3921cb0ef41Sopenharmony_ciint Decoder::FormatOption(Instruction* instr, const char* format) {
3931cb0ef41Sopenharmony_ci  switch (format[0]) {
3941cb0ef41Sopenharmony_ci    case 'c': {
3951cb0ef41Sopenharmony_ci      switch (format[1]) {
3961cb0ef41Sopenharmony_ci        case 'a':
3971cb0ef41Sopenharmony_ci          DCHECK(STRING_STARTS_WITH(format, "ca"));
3981cb0ef41Sopenharmony_ci          PrintCa(instr);
3991cb0ef41Sopenharmony_ci          return 2;
4001cb0ef41Sopenharmony_ci        case 'd':
4011cb0ef41Sopenharmony_ci          DCHECK(STRING_STARTS_WITH(format, "cd"));
4021cb0ef41Sopenharmony_ci          PrintCd(instr);
4031cb0ef41Sopenharmony_ci          return 2;
4041cb0ef41Sopenharmony_ci        case 'j':
4051cb0ef41Sopenharmony_ci          DCHECK(STRING_STARTS_WITH(format, "cj"));
4061cb0ef41Sopenharmony_ci          PrintCj(instr);
4071cb0ef41Sopenharmony_ci          return 2;
4081cb0ef41Sopenharmony_ci        case 'o':
4091cb0ef41Sopenharmony_ci          DCHECK(STRING_STARTS_WITH(format, "code"));
4101cb0ef41Sopenharmony_ci          PrintCode(instr);
4111cb0ef41Sopenharmony_ci          return 4;
4121cb0ef41Sopenharmony_ci      }
4131cb0ef41Sopenharmony_ci    }
4141cb0ef41Sopenharmony_ci    case 'f': {
4151cb0ef41Sopenharmony_ci      return FormatFPURegister(instr, format);
4161cb0ef41Sopenharmony_ci    }
4171cb0ef41Sopenharmony_ci    case 'h': {
4181cb0ef41Sopenharmony_ci      if (format[4] == '5') {
4191cb0ef41Sopenharmony_ci        DCHECK(STRING_STARTS_WITH(format, "hint5"));
4201cb0ef41Sopenharmony_ci        PrintHint5(instr);
4211cb0ef41Sopenharmony_ci        return 5;
4221cb0ef41Sopenharmony_ci      } else if (format[4] == '1') {
4231cb0ef41Sopenharmony_ci        DCHECK(STRING_STARTS_WITH(format, "hint15"));
4241cb0ef41Sopenharmony_ci        PrintHint15(instr);
4251cb0ef41Sopenharmony_ci        return 6;
4261cb0ef41Sopenharmony_ci      }
4271cb0ef41Sopenharmony_ci      break;
4281cb0ef41Sopenharmony_ci    }
4291cb0ef41Sopenharmony_ci    case 'l': {
4301cb0ef41Sopenharmony_ci      switch (format[3]) {
4311cb0ef41Sopenharmony_ci        case 'w':
4321cb0ef41Sopenharmony_ci          DCHECK(STRING_STARTS_WITH(format, "lsbw"));
4331cb0ef41Sopenharmony_ci          PrintLsbw(instr);
4341cb0ef41Sopenharmony_ci          return 4;
4351cb0ef41Sopenharmony_ci        case 'd':
4361cb0ef41Sopenharmony_ci          DCHECK(STRING_STARTS_WITH(format, "lsbd"));
4371cb0ef41Sopenharmony_ci          PrintLsbd(instr);
4381cb0ef41Sopenharmony_ci          return 4;
4391cb0ef41Sopenharmony_ci        default:
4401cb0ef41Sopenharmony_ci          return 0;
4411cb0ef41Sopenharmony_ci      }
4421cb0ef41Sopenharmony_ci    }
4431cb0ef41Sopenharmony_ci    case 'm': {
4441cb0ef41Sopenharmony_ci      if (format[3] == 'w') {
4451cb0ef41Sopenharmony_ci        DCHECK(STRING_STARTS_WITH(format, "msbw"));
4461cb0ef41Sopenharmony_ci        PrintMsbw(instr);
4471cb0ef41Sopenharmony_ci      } else if (format[3] == 'd') {
4481cb0ef41Sopenharmony_ci        DCHECK(STRING_STARTS_WITH(format, "msbd"));
4491cb0ef41Sopenharmony_ci        PrintMsbd(instr);
4501cb0ef41Sopenharmony_ci      }
4511cb0ef41Sopenharmony_ci      return 4;
4521cb0ef41Sopenharmony_ci    }
4531cb0ef41Sopenharmony_ci    case 'o': {
4541cb0ef41Sopenharmony_ci      if (format[1] == 'f') {
4551cb0ef41Sopenharmony_ci        if (format[4] == '1') {
4561cb0ef41Sopenharmony_ci          DCHECK(STRING_STARTS_WITH(format, "offs16"));
4571cb0ef41Sopenharmony_ci          PrintOffs16(instr);
4581cb0ef41Sopenharmony_ci          return 6;
4591cb0ef41Sopenharmony_ci        } else if (format[4] == '2') {
4601cb0ef41Sopenharmony_ci          if (format[5] == '1') {
4611cb0ef41Sopenharmony_ci            DCHECK(STRING_STARTS_WITH(format, "offs21"));
4621cb0ef41Sopenharmony_ci            PrintOffs21(instr);
4631cb0ef41Sopenharmony_ci            return 6;
4641cb0ef41Sopenharmony_ci          } else if (format[5] == '6') {
4651cb0ef41Sopenharmony_ci            DCHECK(STRING_STARTS_WITH(format, "offs26"));
4661cb0ef41Sopenharmony_ci            PrintOffs26(instr);
4671cb0ef41Sopenharmony_ci            return 6;
4681cb0ef41Sopenharmony_ci          }
4691cb0ef41Sopenharmony_ci        }
4701cb0ef41Sopenharmony_ci      }
4711cb0ef41Sopenharmony_ci      break;
4721cb0ef41Sopenharmony_ci    }
4731cb0ef41Sopenharmony_ci    case 'p': {
4741cb0ef41Sopenharmony_ci      if (format[6] == '1') {
4751cb0ef41Sopenharmony_ci        DCHECK(STRING_STARTS_WITH(format, "pcoffs16"));
4761cb0ef41Sopenharmony_ci        PrintPCOffs16(instr);
4771cb0ef41Sopenharmony_ci        return 8;
4781cb0ef41Sopenharmony_ci      } else if (format[6] == '2') {
4791cb0ef41Sopenharmony_ci        if (format[7] == '1') {
4801cb0ef41Sopenharmony_ci          DCHECK(STRING_STARTS_WITH(format, "pcoffs21"));
4811cb0ef41Sopenharmony_ci          PrintPCOffs21(instr);
4821cb0ef41Sopenharmony_ci          return 8;
4831cb0ef41Sopenharmony_ci        } else if (format[7] == '6') {
4841cb0ef41Sopenharmony_ci          DCHECK(STRING_STARTS_WITH(format, "pcoffs26"));
4851cb0ef41Sopenharmony_ci          PrintPCOffs26(instr);
4861cb0ef41Sopenharmony_ci          return 8;
4871cb0ef41Sopenharmony_ci        }
4881cb0ef41Sopenharmony_ci      }
4891cb0ef41Sopenharmony_ci      break;
4901cb0ef41Sopenharmony_ci    }
4911cb0ef41Sopenharmony_ci    case 'r': {
4921cb0ef41Sopenharmony_ci      return FormatRegister(instr, format);
4931cb0ef41Sopenharmony_ci    }
4941cb0ef41Sopenharmony_ci    case 's': {
4951cb0ef41Sopenharmony_ci      switch (format[1]) {
4961cb0ef41Sopenharmony_ci        case 'a':
4971cb0ef41Sopenharmony_ci          if (format[2] == '2') {
4981cb0ef41Sopenharmony_ci            DCHECK(STRING_STARTS_WITH(format, "sa2"));
4991cb0ef41Sopenharmony_ci            PrintSa2(instr);
5001cb0ef41Sopenharmony_ci          } else if (format[2] == '3') {
5011cb0ef41Sopenharmony_ci            DCHECK(STRING_STARTS_WITH(format, "sa3"));
5021cb0ef41Sopenharmony_ci            PrintSa3(instr);
5031cb0ef41Sopenharmony_ci          }
5041cb0ef41Sopenharmony_ci          return 3;
5051cb0ef41Sopenharmony_ci        case 'i':
5061cb0ef41Sopenharmony_ci          if (format[2] == '2') {
5071cb0ef41Sopenharmony_ci            DCHECK(STRING_STARTS_WITH(format, "si20"));
5081cb0ef41Sopenharmony_ci            PrintSi20(instr);
5091cb0ef41Sopenharmony_ci            return 4;
5101cb0ef41Sopenharmony_ci          } else if (format[2] == '1') {
5111cb0ef41Sopenharmony_ci            switch (format[3]) {
5121cb0ef41Sopenharmony_ci              case '2':
5131cb0ef41Sopenharmony_ci                DCHECK(STRING_STARTS_WITH(format, "si12"));
5141cb0ef41Sopenharmony_ci                PrintSi12(instr);
5151cb0ef41Sopenharmony_ci                return 4;
5161cb0ef41Sopenharmony_ci              case '4':
5171cb0ef41Sopenharmony_ci                DCHECK(STRING_STARTS_WITH(format, "si14"));
5181cb0ef41Sopenharmony_ci                PrintSi14(instr);
5191cb0ef41Sopenharmony_ci                return 4;
5201cb0ef41Sopenharmony_ci              case '6':
5211cb0ef41Sopenharmony_ci                DCHECK(STRING_STARTS_WITH(format, "si16"));
5221cb0ef41Sopenharmony_ci                PrintSi16(instr);
5231cb0ef41Sopenharmony_ci                return 4;
5241cb0ef41Sopenharmony_ci              default:
5251cb0ef41Sopenharmony_ci                break;
5261cb0ef41Sopenharmony_ci            }
5271cb0ef41Sopenharmony_ci          }
5281cb0ef41Sopenharmony_ci          break;
5291cb0ef41Sopenharmony_ci        default:
5301cb0ef41Sopenharmony_ci          break;
5311cb0ef41Sopenharmony_ci      }
5321cb0ef41Sopenharmony_ci      break;
5331cb0ef41Sopenharmony_ci    }
5341cb0ef41Sopenharmony_ci    case 'u': {
5351cb0ef41Sopenharmony_ci      if (format[2] == '5') {
5361cb0ef41Sopenharmony_ci        DCHECK(STRING_STARTS_WITH(format, "ui5"));
5371cb0ef41Sopenharmony_ci        PrintUi5(instr);
5381cb0ef41Sopenharmony_ci        return 3;
5391cb0ef41Sopenharmony_ci      } else if (format[2] == '6') {
5401cb0ef41Sopenharmony_ci        DCHECK(STRING_STARTS_WITH(format, "ui6"));
5411cb0ef41Sopenharmony_ci        PrintUi6(instr);
5421cb0ef41Sopenharmony_ci        return 3;
5431cb0ef41Sopenharmony_ci      } else if (format[2] == '1') {
5441cb0ef41Sopenharmony_ci        DCHECK(STRING_STARTS_WITH(format, "ui12"));
5451cb0ef41Sopenharmony_ci        PrintUi12(instr);
5461cb0ef41Sopenharmony_ci        return 4;
5471cb0ef41Sopenharmony_ci      }
5481cb0ef41Sopenharmony_ci      break;
5491cb0ef41Sopenharmony_ci    }
5501cb0ef41Sopenharmony_ci    case 'x': {
5511cb0ef41Sopenharmony_ci      if (format[2] == '2') {
5521cb0ef41Sopenharmony_ci        DCHECK(STRING_STARTS_WITH(format, "xi20"));
5531cb0ef41Sopenharmony_ci        PrintXi20(instr);
5541cb0ef41Sopenharmony_ci        return 4;
5551cb0ef41Sopenharmony_ci      } else if (format[3] == '2') {
5561cb0ef41Sopenharmony_ci        DCHECK(STRING_STARTS_WITH(format, "xi12"));
5571cb0ef41Sopenharmony_ci        PrintXi12(instr);
5581cb0ef41Sopenharmony_ci        return 4;
5591cb0ef41Sopenharmony_ci      }
5601cb0ef41Sopenharmony_ci      break;
5611cb0ef41Sopenharmony_ci    }
5621cb0ef41Sopenharmony_ci    default:
5631cb0ef41Sopenharmony_ci      UNREACHABLE();
5641cb0ef41Sopenharmony_ci  }
5651cb0ef41Sopenharmony_ci  return 0;
5661cb0ef41Sopenharmony_ci}
5671cb0ef41Sopenharmony_ci
5681cb0ef41Sopenharmony_ci// Format takes a formatting string for a whole instruction and prints it into
5691cb0ef41Sopenharmony_ci// the output buffer. All escaped options are handed to FormatOption to be
5701cb0ef41Sopenharmony_ci// parsed further.
5711cb0ef41Sopenharmony_civoid Decoder::Format(Instruction* instr, const char* format) {
5721cb0ef41Sopenharmony_ci  char cur = *format++;
5731cb0ef41Sopenharmony_ci  while ((cur != 0) && (out_buffer_pos_ < (out_buffer_.length() - 1))) {
5741cb0ef41Sopenharmony_ci    if (cur == '\'') {  // Single quote is used as the formatting escape.
5751cb0ef41Sopenharmony_ci      format += FormatOption(instr, format);
5761cb0ef41Sopenharmony_ci    } else {
5771cb0ef41Sopenharmony_ci      out_buffer_[out_buffer_pos_++] = cur;
5781cb0ef41Sopenharmony_ci    }
5791cb0ef41Sopenharmony_ci    cur = *format++;
5801cb0ef41Sopenharmony_ci  }
5811cb0ef41Sopenharmony_ci  out_buffer_[out_buffer_pos_] = '\0';
5821cb0ef41Sopenharmony_ci}
5831cb0ef41Sopenharmony_ci
5841cb0ef41Sopenharmony_ci// For currently unimplemented decodings the disassembler calls Unknown(instr)
5851cb0ef41Sopenharmony_ci// which will just print "unknown" of the instruction bits.
5861cb0ef41Sopenharmony_civoid Decoder::Unknown(Instruction* instr) { Format(instr, "unknown"); }
5871cb0ef41Sopenharmony_ci
5881cb0ef41Sopenharmony_ciint Decoder::DecodeBreakInstr(Instruction* instr) {
5891cb0ef41Sopenharmony_ci  // This is already known to be BREAK instr, just extract the code.
5901cb0ef41Sopenharmony_ci  /*if (instr->Bits(14, 0) == static_cast<int>(kMaxStopCode)) {
5911cb0ef41Sopenharmony_ci    // This is stop(msg).
5921cb0ef41Sopenharmony_ci    Format(instr, "break, code: 'code");
5931cb0ef41Sopenharmony_ci    out_buffer_pos_ += SNPrintF(
5941cb0ef41Sopenharmony_ci        out_buffer_ + out_buffer_pos_, "\n%p       %08" PRIx64,
5951cb0ef41Sopenharmony_ci        static_cast<void*>(reinterpret_cast<int32_t*>(instr + kInstrSize)),
5961cb0ef41Sopenharmony_ci        reinterpret_cast<uint64_t>(
5971cb0ef41Sopenharmony_ci            *reinterpret_cast<char**>(instr + kInstrSize)));
5981cb0ef41Sopenharmony_ci    // Size 3: the break_ instr, plus embedded 64-bit char pointer.
5991cb0ef41Sopenharmony_ci    return 3 * kInstrSize;
6001cb0ef41Sopenharmony_ci  } else {
6011cb0ef41Sopenharmony_ci    Format(instr, "break, code: 'code");
6021cb0ef41Sopenharmony_ci    return kInstrSize;
6031cb0ef41Sopenharmony_ci  }*/
6041cb0ef41Sopenharmony_ci  Format(instr, "break        code: 'code");
6051cb0ef41Sopenharmony_ci  return kInstrSize;
6061cb0ef41Sopenharmony_ci}  //===================================================
6071cb0ef41Sopenharmony_ci
6081cb0ef41Sopenharmony_civoid Decoder::DecodeTypekOp6(Instruction* instr) {
6091cb0ef41Sopenharmony_ci  switch (instr->Bits(31, 26) << 26) {
6101cb0ef41Sopenharmony_ci    case ADDU16I_D:
6111cb0ef41Sopenharmony_ci      Format(instr, "addu16i.d    'rd, 'rj, 'si16");
6121cb0ef41Sopenharmony_ci      break;
6131cb0ef41Sopenharmony_ci    case BEQZ:
6141cb0ef41Sopenharmony_ci      Format(instr, "beqz         'rj, 'offs21 -> 'pcoffs21");
6151cb0ef41Sopenharmony_ci      break;
6161cb0ef41Sopenharmony_ci    case BNEZ:
6171cb0ef41Sopenharmony_ci      Format(instr, "bnez         'rj, 'offs21 -> 'pcoffs21");
6181cb0ef41Sopenharmony_ci      break;
6191cb0ef41Sopenharmony_ci    case BCZ:
6201cb0ef41Sopenharmony_ci      if (instr->Bit(8))
6211cb0ef41Sopenharmony_ci        Format(instr, "bcnez        fcc'cj, 'offs21 -> 'pcoffs21");
6221cb0ef41Sopenharmony_ci      else
6231cb0ef41Sopenharmony_ci        Format(instr, "bceqz        fcc'cj, 'offs21 -> 'pcoffs21");
6241cb0ef41Sopenharmony_ci      break;
6251cb0ef41Sopenharmony_ci    case JIRL:
6261cb0ef41Sopenharmony_ci      Format(instr, "jirl         'rd, 'rj, 'offs16");
6271cb0ef41Sopenharmony_ci      break;
6281cb0ef41Sopenharmony_ci    case B:
6291cb0ef41Sopenharmony_ci      Format(instr, "b            'offs26 -> 'pcoffs26");
6301cb0ef41Sopenharmony_ci      break;
6311cb0ef41Sopenharmony_ci    case BL:
6321cb0ef41Sopenharmony_ci      Format(instr, "bl           'offs26 -> 'pcoffs26");
6331cb0ef41Sopenharmony_ci      break;
6341cb0ef41Sopenharmony_ci    case BEQ:
6351cb0ef41Sopenharmony_ci      Format(instr, "beq          'rj, 'rd, 'offs16 -> 'pcoffs16");
6361cb0ef41Sopenharmony_ci      break;
6371cb0ef41Sopenharmony_ci    case BNE:
6381cb0ef41Sopenharmony_ci      Format(instr, "bne          'rj, 'rd, 'offs16 -> 'pcoffs16");
6391cb0ef41Sopenharmony_ci      break;
6401cb0ef41Sopenharmony_ci    case BLT:
6411cb0ef41Sopenharmony_ci      Format(instr, "blt          'rj, 'rd, 'offs16 -> 'pcoffs16");
6421cb0ef41Sopenharmony_ci      break;
6431cb0ef41Sopenharmony_ci    case BGE:
6441cb0ef41Sopenharmony_ci      Format(instr, "bge          'rj, 'rd, 'offs16 -> 'pcoffs16");
6451cb0ef41Sopenharmony_ci      break;
6461cb0ef41Sopenharmony_ci    case BLTU:
6471cb0ef41Sopenharmony_ci      Format(instr, "bltu         'rj, 'rd, 'offs16 -> 'pcoffs16");
6481cb0ef41Sopenharmony_ci      break;
6491cb0ef41Sopenharmony_ci    case BGEU:
6501cb0ef41Sopenharmony_ci      Format(instr, "bgeu         'rj, 'rd, 'offs16 -> 'pcoffs16");
6511cb0ef41Sopenharmony_ci      break;
6521cb0ef41Sopenharmony_ci    default:
6531cb0ef41Sopenharmony_ci      UNREACHABLE();
6541cb0ef41Sopenharmony_ci  }
6551cb0ef41Sopenharmony_ci}
6561cb0ef41Sopenharmony_ci
6571cb0ef41Sopenharmony_civoid Decoder::DecodeTypekOp7(Instruction* instr) {
6581cb0ef41Sopenharmony_ci  switch (instr->Bits(31, 25) << 25) {
6591cb0ef41Sopenharmony_ci    case LU12I_W:
6601cb0ef41Sopenharmony_ci      Format(instr, "lu12i.w      'rd, 'xi20");
6611cb0ef41Sopenharmony_ci      break;
6621cb0ef41Sopenharmony_ci    case LU32I_D:
6631cb0ef41Sopenharmony_ci      Format(instr, "lu32i.d      'rd, 'xi20");
6641cb0ef41Sopenharmony_ci      break;
6651cb0ef41Sopenharmony_ci    case PCADDI:
6661cb0ef41Sopenharmony_ci      Format(instr, "pcaddi       'rd, 'xi20");
6671cb0ef41Sopenharmony_ci      break;
6681cb0ef41Sopenharmony_ci    case PCALAU12I:
6691cb0ef41Sopenharmony_ci      Format(instr, "pcalau12i    'rd, 'xi20");
6701cb0ef41Sopenharmony_ci      break;
6711cb0ef41Sopenharmony_ci    case PCADDU12I:
6721cb0ef41Sopenharmony_ci      Format(instr, "pcaddu12i    'rd, 'xi20");
6731cb0ef41Sopenharmony_ci      break;
6741cb0ef41Sopenharmony_ci    case PCADDU18I:
6751cb0ef41Sopenharmony_ci      Format(instr, "pcaddu18i    'rd, 'xi20");
6761cb0ef41Sopenharmony_ci      break;
6771cb0ef41Sopenharmony_ci    default:
6781cb0ef41Sopenharmony_ci      UNREACHABLE();
6791cb0ef41Sopenharmony_ci  }
6801cb0ef41Sopenharmony_ci}
6811cb0ef41Sopenharmony_ci
6821cb0ef41Sopenharmony_civoid Decoder::DecodeTypekOp8(Instruction* instr) {
6831cb0ef41Sopenharmony_ci  switch (instr->Bits(31, 24) << 24) {
6841cb0ef41Sopenharmony_ci    case LDPTR_W:
6851cb0ef41Sopenharmony_ci      Format(instr, "ldptr.w      'rd, 'rj, 'si14");
6861cb0ef41Sopenharmony_ci      break;
6871cb0ef41Sopenharmony_ci    case STPTR_W:
6881cb0ef41Sopenharmony_ci      Format(instr, "stptr.w      'rd, 'rj, 'si14");
6891cb0ef41Sopenharmony_ci      break;
6901cb0ef41Sopenharmony_ci    case LDPTR_D:
6911cb0ef41Sopenharmony_ci      Format(instr, "ldptr.d      'rd, 'rj, 'si14");
6921cb0ef41Sopenharmony_ci      break;
6931cb0ef41Sopenharmony_ci    case STPTR_D:
6941cb0ef41Sopenharmony_ci      Format(instr, "stptr.d      'rd, 'rj, 'si14");
6951cb0ef41Sopenharmony_ci      break;
6961cb0ef41Sopenharmony_ci    case LL_W:
6971cb0ef41Sopenharmony_ci      Format(instr, "ll.w         'rd, 'rj, 'si14");
6981cb0ef41Sopenharmony_ci      break;
6991cb0ef41Sopenharmony_ci    case SC_W:
7001cb0ef41Sopenharmony_ci      Format(instr, "sc.w         'rd, 'rj, 'si14");
7011cb0ef41Sopenharmony_ci      break;
7021cb0ef41Sopenharmony_ci    case LL_D:
7031cb0ef41Sopenharmony_ci      Format(instr, "ll.d         'rd, 'rj, 'si14");
7041cb0ef41Sopenharmony_ci      break;
7051cb0ef41Sopenharmony_ci    case SC_D:
7061cb0ef41Sopenharmony_ci      Format(instr, "sc.d         'rd, 'rj, 'si14");
7071cb0ef41Sopenharmony_ci      break;
7081cb0ef41Sopenharmony_ci    default:
7091cb0ef41Sopenharmony_ci      UNREACHABLE();
7101cb0ef41Sopenharmony_ci  }
7111cb0ef41Sopenharmony_ci}
7121cb0ef41Sopenharmony_ci
7131cb0ef41Sopenharmony_civoid Decoder::DecodeTypekOp10(Instruction* instr) {
7141cb0ef41Sopenharmony_ci  switch (instr->Bits(31, 22) << 22) {
7151cb0ef41Sopenharmony_ci    case BSTR_W: {
7161cb0ef41Sopenharmony_ci      if (instr->Bit(21) != 0) {
7171cb0ef41Sopenharmony_ci        if (instr->Bit(15) == 0) {
7181cb0ef41Sopenharmony_ci          Format(instr, "bstrins.w    'rd, 'rj, 'msbw, 'lsbw");
7191cb0ef41Sopenharmony_ci        } else {
7201cb0ef41Sopenharmony_ci          Format(instr, "bstrpick.w   'rd, 'rj, 'msbw, 'lsbw");
7211cb0ef41Sopenharmony_ci        }
7221cb0ef41Sopenharmony_ci      }
7231cb0ef41Sopenharmony_ci      break;
7241cb0ef41Sopenharmony_ci    }
7251cb0ef41Sopenharmony_ci    case BSTRINS_D:
7261cb0ef41Sopenharmony_ci      Format(instr, "bstrins.d    'rd, 'rj, 'msbd, 'lsbd");
7271cb0ef41Sopenharmony_ci      break;
7281cb0ef41Sopenharmony_ci    case BSTRPICK_D:
7291cb0ef41Sopenharmony_ci      Format(instr, "bstrpick.d   'rd, 'rj, 'msbd, 'lsbd");
7301cb0ef41Sopenharmony_ci      break;
7311cb0ef41Sopenharmony_ci    case SLTI:
7321cb0ef41Sopenharmony_ci      Format(instr, "slti         'rd, 'rj, 'si12");
7331cb0ef41Sopenharmony_ci      break;
7341cb0ef41Sopenharmony_ci    case SLTUI:
7351cb0ef41Sopenharmony_ci      Format(instr, "sltui        'rd, 'rj, 'si12");
7361cb0ef41Sopenharmony_ci      break;
7371cb0ef41Sopenharmony_ci    case ADDI_W:
7381cb0ef41Sopenharmony_ci      Format(instr, "addi.w       'rd, 'rj, 'si12");
7391cb0ef41Sopenharmony_ci      break;
7401cb0ef41Sopenharmony_ci    case ADDI_D:
7411cb0ef41Sopenharmony_ci      Format(instr, "addi.d       'rd, 'rj, 'si12");
7421cb0ef41Sopenharmony_ci      break;
7431cb0ef41Sopenharmony_ci    case LU52I_D:
7441cb0ef41Sopenharmony_ci      Format(instr, "lu52i.d      'rd, 'rj, 'xi12");
7451cb0ef41Sopenharmony_ci      break;
7461cb0ef41Sopenharmony_ci    case ANDI:
7471cb0ef41Sopenharmony_ci      Format(instr, "andi         'rd, 'rj, 'xi12");
7481cb0ef41Sopenharmony_ci      break;
7491cb0ef41Sopenharmony_ci    case ORI:
7501cb0ef41Sopenharmony_ci      Format(instr, "ori          'rd, 'rj, 'xi12");
7511cb0ef41Sopenharmony_ci      break;
7521cb0ef41Sopenharmony_ci    case XORI:
7531cb0ef41Sopenharmony_ci      Format(instr, "xori         'rd, 'rj, 'xi12");
7541cb0ef41Sopenharmony_ci      break;
7551cb0ef41Sopenharmony_ci    case LD_B:
7561cb0ef41Sopenharmony_ci      Format(instr, "ld.b         'rd, 'rj, 'si12");
7571cb0ef41Sopenharmony_ci      break;
7581cb0ef41Sopenharmony_ci    case LD_H:
7591cb0ef41Sopenharmony_ci      Format(instr, "ld.h         'rd, 'rj, 'si12");
7601cb0ef41Sopenharmony_ci      break;
7611cb0ef41Sopenharmony_ci    case LD_W:
7621cb0ef41Sopenharmony_ci      Format(instr, "ld.w         'rd, 'rj, 'si12");
7631cb0ef41Sopenharmony_ci      break;
7641cb0ef41Sopenharmony_ci    case LD_D:
7651cb0ef41Sopenharmony_ci      Format(instr, "ld.d         'rd, 'rj, 'si12");
7661cb0ef41Sopenharmony_ci      break;
7671cb0ef41Sopenharmony_ci    case ST_B:
7681cb0ef41Sopenharmony_ci      Format(instr, "st.b         'rd, 'rj, 'si12");
7691cb0ef41Sopenharmony_ci      break;
7701cb0ef41Sopenharmony_ci    case ST_H:
7711cb0ef41Sopenharmony_ci      Format(instr, "st.h         'rd, 'rj, 'si12");
7721cb0ef41Sopenharmony_ci      break;
7731cb0ef41Sopenharmony_ci    case ST_W:
7741cb0ef41Sopenharmony_ci      Format(instr, "st.w         'rd, 'rj, 'si12");
7751cb0ef41Sopenharmony_ci      break;
7761cb0ef41Sopenharmony_ci    case ST_D:
7771cb0ef41Sopenharmony_ci      Format(instr, "st.d         'rd, 'rj, 'si12");
7781cb0ef41Sopenharmony_ci      break;
7791cb0ef41Sopenharmony_ci    case LD_BU:
7801cb0ef41Sopenharmony_ci      Format(instr, "ld.bu        'rd, 'rj, 'si12");
7811cb0ef41Sopenharmony_ci      break;
7821cb0ef41Sopenharmony_ci    case LD_HU:
7831cb0ef41Sopenharmony_ci      Format(instr, "ld.hu        'rd, 'rj, 'si12");
7841cb0ef41Sopenharmony_ci      break;
7851cb0ef41Sopenharmony_ci    case LD_WU:
7861cb0ef41Sopenharmony_ci      Format(instr, "ld.wu        'rd, 'rj, 'si12");
7871cb0ef41Sopenharmony_ci      break;
7881cb0ef41Sopenharmony_ci    case FLD_S:
7891cb0ef41Sopenharmony_ci      Format(instr, "fld.s        'fd, 'rj, 'si12");
7901cb0ef41Sopenharmony_ci      break;
7911cb0ef41Sopenharmony_ci    case FST_S:
7921cb0ef41Sopenharmony_ci      Format(instr, "fst.s        'fd, 'rj, 'si12");
7931cb0ef41Sopenharmony_ci      break;
7941cb0ef41Sopenharmony_ci    case FLD_D:
7951cb0ef41Sopenharmony_ci      Format(instr, "fld.d        'fd, 'rj, 'si12");
7961cb0ef41Sopenharmony_ci      break;
7971cb0ef41Sopenharmony_ci    case FST_D:
7981cb0ef41Sopenharmony_ci      Format(instr, "fst.d        'fd, 'rj, 'si12");
7991cb0ef41Sopenharmony_ci      break;
8001cb0ef41Sopenharmony_ci    default:
8011cb0ef41Sopenharmony_ci      UNREACHABLE();
8021cb0ef41Sopenharmony_ci  }
8031cb0ef41Sopenharmony_ci}
8041cb0ef41Sopenharmony_ci
8051cb0ef41Sopenharmony_civoid Decoder::DecodeTypekOp12(Instruction* instr) {
8061cb0ef41Sopenharmony_ci  switch (instr->Bits(31, 20) << 20) {
8071cb0ef41Sopenharmony_ci    case FMADD_S:
8081cb0ef41Sopenharmony_ci      Format(instr, "fmadd.s      'fd, 'fj, 'fk, 'fa");
8091cb0ef41Sopenharmony_ci      break;
8101cb0ef41Sopenharmony_ci    case FMADD_D:
8111cb0ef41Sopenharmony_ci      Format(instr, "fmadd.d      'fd, 'fj, 'fk, 'fa");
8121cb0ef41Sopenharmony_ci      break;
8131cb0ef41Sopenharmony_ci    case FMSUB_S:
8141cb0ef41Sopenharmony_ci      Format(instr, "fmsub.s      'fd, 'fj, 'fk, 'fa");
8151cb0ef41Sopenharmony_ci      break;
8161cb0ef41Sopenharmony_ci    case FMSUB_D:
8171cb0ef41Sopenharmony_ci      Format(instr, "fmsub.d      'fd, 'fj, 'fk, 'fa");
8181cb0ef41Sopenharmony_ci      break;
8191cb0ef41Sopenharmony_ci    case FNMADD_S:
8201cb0ef41Sopenharmony_ci      Format(instr, "fnmadd.s     'fd, 'fj, 'fk, 'fa");
8211cb0ef41Sopenharmony_ci      break;
8221cb0ef41Sopenharmony_ci    case FNMADD_D:
8231cb0ef41Sopenharmony_ci      Format(instr, "fnmadd.d     'fd, 'fj, 'fk, 'fa");
8241cb0ef41Sopenharmony_ci      break;
8251cb0ef41Sopenharmony_ci    case FNMSUB_S:
8261cb0ef41Sopenharmony_ci      Format(instr, "fnmsub.s     'fd, 'fj, 'fk, 'fa");
8271cb0ef41Sopenharmony_ci      break;
8281cb0ef41Sopenharmony_ci    case FNMSUB_D:
8291cb0ef41Sopenharmony_ci      Format(instr, "fnmsub.d     'fd, 'fj, 'fk, 'fa");
8301cb0ef41Sopenharmony_ci      break;
8311cb0ef41Sopenharmony_ci    case FCMP_COND_S:
8321cb0ef41Sopenharmony_ci      switch (instr->Bits(19, 15)) {
8331cb0ef41Sopenharmony_ci        case CAF:
8341cb0ef41Sopenharmony_ci          Format(instr, "fcmp.caf.s   fcc'cd, 'fj, 'fk");
8351cb0ef41Sopenharmony_ci          break;
8361cb0ef41Sopenharmony_ci        case SAF:
8371cb0ef41Sopenharmony_ci          Format(instr, "fcmp.saf.s   fcc'cd, 'fj, 'fk");
8381cb0ef41Sopenharmony_ci          break;
8391cb0ef41Sopenharmony_ci        case CLT:
8401cb0ef41Sopenharmony_ci          Format(instr, "fcmp.clt.s   fcc'cd, 'fj, 'fk");
8411cb0ef41Sopenharmony_ci          break;
8421cb0ef41Sopenharmony_ci        case CEQ:
8431cb0ef41Sopenharmony_ci          Format(instr, "fcmp.ceq.s   fcc'cd, 'fj, 'fk");
8441cb0ef41Sopenharmony_ci          break;
8451cb0ef41Sopenharmony_ci        case SEQ:
8461cb0ef41Sopenharmony_ci          Format(instr, "fcmp.seq.s   fcc'cd, 'fj, 'fk");
8471cb0ef41Sopenharmony_ci          break;
8481cb0ef41Sopenharmony_ci        case CLE:
8491cb0ef41Sopenharmony_ci          Format(instr, "fcmp.cle.s   fcc'cd, 'fj, 'fk");
8501cb0ef41Sopenharmony_ci          break;
8511cb0ef41Sopenharmony_ci        case SLE:
8521cb0ef41Sopenharmony_ci          Format(instr, "fcmp.sle.s   fcc'cd, 'fj, 'fk");
8531cb0ef41Sopenharmony_ci          break;
8541cb0ef41Sopenharmony_ci        case CUN:
8551cb0ef41Sopenharmony_ci          Format(instr, "fcmp.cun.s   fcc'cd, 'fj, 'fk");
8561cb0ef41Sopenharmony_ci          break;
8571cb0ef41Sopenharmony_ci        case SUN:
8581cb0ef41Sopenharmony_ci          Format(instr, "fcmp.sun.s   fcc'cd, 'fj, 'fk");
8591cb0ef41Sopenharmony_ci          break;
8601cb0ef41Sopenharmony_ci        case CULT:
8611cb0ef41Sopenharmony_ci          Format(instr, "fcmp.cult.s  fcc'cd, 'fj, 'fk");
8621cb0ef41Sopenharmony_ci          break;
8631cb0ef41Sopenharmony_ci        case SULT:
8641cb0ef41Sopenharmony_ci          Format(instr, "fcmp.sult.s  fcc'cd, 'fj, 'fk");
8651cb0ef41Sopenharmony_ci          break;
8661cb0ef41Sopenharmony_ci        case CUEQ:
8671cb0ef41Sopenharmony_ci          Format(instr, "fcmp.cueq.s  fcc'cd, 'fj, 'fk");
8681cb0ef41Sopenharmony_ci          break;
8691cb0ef41Sopenharmony_ci        case SUEQ:
8701cb0ef41Sopenharmony_ci          Format(instr, "fcmp.sueq.s  fcc'cd, 'fj, 'fk");
8711cb0ef41Sopenharmony_ci          break;
8721cb0ef41Sopenharmony_ci        case CULE:
8731cb0ef41Sopenharmony_ci          Format(instr, "fcmp.cule.s  fcc'cd, 'fj, 'fk");
8741cb0ef41Sopenharmony_ci          break;
8751cb0ef41Sopenharmony_ci        case SULE:
8761cb0ef41Sopenharmony_ci          Format(instr, "fcmp.sule.s  fcc'cd, 'fj, 'fk");
8771cb0ef41Sopenharmony_ci          break;
8781cb0ef41Sopenharmony_ci        case CNE:
8791cb0ef41Sopenharmony_ci          Format(instr, "fcmp.cne.s   fcc'cd, 'fj, 'fk");
8801cb0ef41Sopenharmony_ci          break;
8811cb0ef41Sopenharmony_ci        case SNE:
8821cb0ef41Sopenharmony_ci          Format(instr, "fcmp.sne.s   fcc'cd, 'fj, 'fk");
8831cb0ef41Sopenharmony_ci          break;
8841cb0ef41Sopenharmony_ci        case COR:
8851cb0ef41Sopenharmony_ci          Format(instr, "fcmp.cor.s   fcc'cd, 'fj, 'fk");
8861cb0ef41Sopenharmony_ci          break;
8871cb0ef41Sopenharmony_ci        case SOR:
8881cb0ef41Sopenharmony_ci          Format(instr, "fcmp.sor.s   fcc'cd, 'fj, 'fk");
8891cb0ef41Sopenharmony_ci          break;
8901cb0ef41Sopenharmony_ci        case CUNE:
8911cb0ef41Sopenharmony_ci          Format(instr, "fcmp.cune.s  fcc'cd, 'fj, 'fk");
8921cb0ef41Sopenharmony_ci          break;
8931cb0ef41Sopenharmony_ci        case SUNE:
8941cb0ef41Sopenharmony_ci          Format(instr, "fcmp.sune.s  fcc'cd, 'fj, 'fk");
8951cb0ef41Sopenharmony_ci          break;
8961cb0ef41Sopenharmony_ci        default:
8971cb0ef41Sopenharmony_ci          UNREACHABLE();
8981cb0ef41Sopenharmony_ci      }
8991cb0ef41Sopenharmony_ci      break;
9001cb0ef41Sopenharmony_ci    case FCMP_COND_D:
9011cb0ef41Sopenharmony_ci      switch (instr->Bits(19, 15)) {
9021cb0ef41Sopenharmony_ci        case CAF:
9031cb0ef41Sopenharmony_ci          Format(instr, "fcmp.caf.d   fcc'cd, 'fj, 'fk");
9041cb0ef41Sopenharmony_ci          break;
9051cb0ef41Sopenharmony_ci        case SAF:
9061cb0ef41Sopenharmony_ci          Format(instr, "fcmp.saf.d   fcc'cd, 'fj, 'fk");
9071cb0ef41Sopenharmony_ci          break;
9081cb0ef41Sopenharmony_ci        case CLT:
9091cb0ef41Sopenharmony_ci          Format(instr, "fcmp.clt.d   fcc'cd, 'fj, 'fk");
9101cb0ef41Sopenharmony_ci          break;
9111cb0ef41Sopenharmony_ci        case CEQ:
9121cb0ef41Sopenharmony_ci          Format(instr, "fcmp.ceq.d   fcc'cd, 'fj, 'fk");
9131cb0ef41Sopenharmony_ci          break;
9141cb0ef41Sopenharmony_ci        case SEQ:
9151cb0ef41Sopenharmony_ci          Format(instr, "fcmp.seq.d   fcc'cd, 'fj, 'fk");
9161cb0ef41Sopenharmony_ci          break;
9171cb0ef41Sopenharmony_ci        case CLE:
9181cb0ef41Sopenharmony_ci          Format(instr, "fcmp.cle.d   fcc'cd, 'fj, 'fk");
9191cb0ef41Sopenharmony_ci          break;
9201cb0ef41Sopenharmony_ci        case SLE:
9211cb0ef41Sopenharmony_ci          Format(instr, "fcmp.sle.d   fcc'cd, 'fj, 'fk");
9221cb0ef41Sopenharmony_ci          break;
9231cb0ef41Sopenharmony_ci        case CUN:
9241cb0ef41Sopenharmony_ci          Format(instr, "fcmp.cun.d   fcc'cd, 'fj, 'fk");
9251cb0ef41Sopenharmony_ci          break;
9261cb0ef41Sopenharmony_ci        case SUN:
9271cb0ef41Sopenharmony_ci          Format(instr, "fcmp.sun.d   fcc'cd, 'fj, 'fk");
9281cb0ef41Sopenharmony_ci          break;
9291cb0ef41Sopenharmony_ci        case CULT:
9301cb0ef41Sopenharmony_ci          Format(instr, "fcmp.cult.d  fcc'cd, 'fj, 'fk");
9311cb0ef41Sopenharmony_ci          break;
9321cb0ef41Sopenharmony_ci        case SULT:
9331cb0ef41Sopenharmony_ci          Format(instr, "fcmp.sult.d  fcc'cd, 'fj, 'fk");
9341cb0ef41Sopenharmony_ci          break;
9351cb0ef41Sopenharmony_ci        case CUEQ:
9361cb0ef41Sopenharmony_ci          Format(instr, "fcmp.cueq.d  fcc'cd, 'fj, 'fk");
9371cb0ef41Sopenharmony_ci          break;
9381cb0ef41Sopenharmony_ci        case SUEQ:
9391cb0ef41Sopenharmony_ci          Format(instr, "fcmp.sueq.d  fcc'cd, 'fj, 'fk");
9401cb0ef41Sopenharmony_ci          break;
9411cb0ef41Sopenharmony_ci        case CULE:
9421cb0ef41Sopenharmony_ci          Format(instr, "fcmp.cule.d  fcc'cd, 'fj, 'fk");
9431cb0ef41Sopenharmony_ci          break;
9441cb0ef41Sopenharmony_ci        case SULE:
9451cb0ef41Sopenharmony_ci          Format(instr, "fcmp.sule.d  fcc'cd, 'fj, 'fk");
9461cb0ef41Sopenharmony_ci          break;
9471cb0ef41Sopenharmony_ci        case CNE:
9481cb0ef41Sopenharmony_ci          Format(instr, "fcmp.cne.d   fcc'cd, 'fj, 'fk");
9491cb0ef41Sopenharmony_ci          break;
9501cb0ef41Sopenharmony_ci        case SNE:
9511cb0ef41Sopenharmony_ci          Format(instr, "fcmp.sne.d   fcc'cd, 'fj, 'fk");
9521cb0ef41Sopenharmony_ci          break;
9531cb0ef41Sopenharmony_ci        case COR:
9541cb0ef41Sopenharmony_ci          Format(instr, "fcmp.cor.d   fcc'cd, 'fj, 'fk");
9551cb0ef41Sopenharmony_ci          break;
9561cb0ef41Sopenharmony_ci        case SOR:
9571cb0ef41Sopenharmony_ci          Format(instr, "fcmp.sor.d   fcc'cd, 'fj, 'fk");
9581cb0ef41Sopenharmony_ci          break;
9591cb0ef41Sopenharmony_ci        case CUNE:
9601cb0ef41Sopenharmony_ci          Format(instr, "fcmp.cune.d  fcc'cd, 'fj, 'fk");
9611cb0ef41Sopenharmony_ci          break;
9621cb0ef41Sopenharmony_ci        case SUNE:
9631cb0ef41Sopenharmony_ci          Format(instr, "fcmp.sune.d  fcc'cd, 'fj, 'fk");
9641cb0ef41Sopenharmony_ci          break;
9651cb0ef41Sopenharmony_ci        default:
9661cb0ef41Sopenharmony_ci          UNREACHABLE();
9671cb0ef41Sopenharmony_ci      }
9681cb0ef41Sopenharmony_ci      break;
9691cb0ef41Sopenharmony_ci    case FSEL:
9701cb0ef41Sopenharmony_ci      Format(instr, "fsel         'fd, 'fj, 'fk, fcc'ca");
9711cb0ef41Sopenharmony_ci      break;
9721cb0ef41Sopenharmony_ci    default:
9731cb0ef41Sopenharmony_ci      UNREACHABLE();
9741cb0ef41Sopenharmony_ci  }
9751cb0ef41Sopenharmony_ci}
9761cb0ef41Sopenharmony_ci
9771cb0ef41Sopenharmony_civoid Decoder::DecodeTypekOp14(Instruction* instr) {
9781cb0ef41Sopenharmony_ci  switch (instr->Bits(31, 18) << 18) {
9791cb0ef41Sopenharmony_ci    case ALSL:
9801cb0ef41Sopenharmony_ci      if (instr->Bit(17))
9811cb0ef41Sopenharmony_ci        Format(instr, "alsl.wu      'rd, 'rj, 'rk, 'sa2");
9821cb0ef41Sopenharmony_ci      else
9831cb0ef41Sopenharmony_ci        Format(instr, "alsl.w       'rd, 'rj, 'rk, 'sa2");
9841cb0ef41Sopenharmony_ci      break;
9851cb0ef41Sopenharmony_ci    case BYTEPICK_W:
9861cb0ef41Sopenharmony_ci      Format(instr, "bytepick.w   'rd, 'rj, 'rk, 'sa2");
9871cb0ef41Sopenharmony_ci      break;
9881cb0ef41Sopenharmony_ci    case BYTEPICK_D:
9891cb0ef41Sopenharmony_ci      Format(instr, "bytepick.d   'rd, 'rj, 'rk, 'sa3");
9901cb0ef41Sopenharmony_ci      break;
9911cb0ef41Sopenharmony_ci    case ALSL_D:
9921cb0ef41Sopenharmony_ci      Format(instr, "alsl.d       'rd, 'rj, 'rk, 'sa2");
9931cb0ef41Sopenharmony_ci      break;
9941cb0ef41Sopenharmony_ci    case SLLI:
9951cb0ef41Sopenharmony_ci      if (instr->Bit(16))
9961cb0ef41Sopenharmony_ci        Format(instr, "slli.d       'rd, 'rj, 'ui6");
9971cb0ef41Sopenharmony_ci      else
9981cb0ef41Sopenharmony_ci        Format(instr, "slli.w       'rd, 'rj, 'ui5");
9991cb0ef41Sopenharmony_ci      break;
10001cb0ef41Sopenharmony_ci    case SRLI:
10011cb0ef41Sopenharmony_ci      if (instr->Bit(16))
10021cb0ef41Sopenharmony_ci        Format(instr, "srli.d       'rd, 'rj, 'ui6");
10031cb0ef41Sopenharmony_ci      else
10041cb0ef41Sopenharmony_ci        Format(instr, "srli.w       'rd, 'rj, 'ui5");
10051cb0ef41Sopenharmony_ci      break;
10061cb0ef41Sopenharmony_ci    case SRAI:
10071cb0ef41Sopenharmony_ci      if (instr->Bit(16))
10081cb0ef41Sopenharmony_ci        Format(instr, "srai.d       'rd, 'rj, 'ui6");
10091cb0ef41Sopenharmony_ci      else
10101cb0ef41Sopenharmony_ci        Format(instr, "srai.w       'rd, 'rj, 'ui5");
10111cb0ef41Sopenharmony_ci      break;
10121cb0ef41Sopenharmony_ci    case ROTRI:
10131cb0ef41Sopenharmony_ci      if (instr->Bit(16))
10141cb0ef41Sopenharmony_ci        Format(instr, "rotri.d      'rd, 'rj, 'ui6");
10151cb0ef41Sopenharmony_ci      else
10161cb0ef41Sopenharmony_ci        Format(instr, "rotri.w      'rd, 'rj, 'ui5");
10171cb0ef41Sopenharmony_ci      break;
10181cb0ef41Sopenharmony_ci    default:
10191cb0ef41Sopenharmony_ci      UNREACHABLE();
10201cb0ef41Sopenharmony_ci  }
10211cb0ef41Sopenharmony_ci}
10221cb0ef41Sopenharmony_ci
10231cb0ef41Sopenharmony_ciint Decoder::DecodeTypekOp17(Instruction* instr) {
10241cb0ef41Sopenharmony_ci  switch (instr->Bits(31, 15) << 15) {
10251cb0ef41Sopenharmony_ci    case ADD_W:
10261cb0ef41Sopenharmony_ci      Format(instr, "add.w        'rd, 'rj, 'rk");
10271cb0ef41Sopenharmony_ci      break;
10281cb0ef41Sopenharmony_ci    case ADD_D:
10291cb0ef41Sopenharmony_ci      Format(instr, "add.d        'rd, 'rj, 'rk");
10301cb0ef41Sopenharmony_ci      break;
10311cb0ef41Sopenharmony_ci    case SUB_W:
10321cb0ef41Sopenharmony_ci      Format(instr, "sub.w        'rd, 'rj, 'rk");
10331cb0ef41Sopenharmony_ci      break;
10341cb0ef41Sopenharmony_ci    case SUB_D:
10351cb0ef41Sopenharmony_ci      Format(instr, "sub.d        'rd, 'rj, 'rk");
10361cb0ef41Sopenharmony_ci      break;
10371cb0ef41Sopenharmony_ci    case SLT:
10381cb0ef41Sopenharmony_ci      Format(instr, "slt          'rd, 'rj, 'rk");
10391cb0ef41Sopenharmony_ci      break;
10401cb0ef41Sopenharmony_ci    case SLTU:
10411cb0ef41Sopenharmony_ci      Format(instr, "sltu         'rd, 'rj, 'rk");
10421cb0ef41Sopenharmony_ci      break;
10431cb0ef41Sopenharmony_ci    case MASKEQZ:
10441cb0ef41Sopenharmony_ci      Format(instr, "maskeqz      'rd, 'rj, 'rk");
10451cb0ef41Sopenharmony_ci      break;
10461cb0ef41Sopenharmony_ci    case MASKNEZ:
10471cb0ef41Sopenharmony_ci      Format(instr, "masknez      'rd, 'rj, 'rk");
10481cb0ef41Sopenharmony_ci      break;
10491cb0ef41Sopenharmony_ci    case NOR:
10501cb0ef41Sopenharmony_ci      Format(instr, "nor          'rd, 'rj, 'rk");
10511cb0ef41Sopenharmony_ci      break;
10521cb0ef41Sopenharmony_ci    case AND:
10531cb0ef41Sopenharmony_ci      Format(instr, "and          'rd, 'rj, 'rk");
10541cb0ef41Sopenharmony_ci      break;
10551cb0ef41Sopenharmony_ci    case OR:
10561cb0ef41Sopenharmony_ci      Format(instr, "or           'rd, 'rj, 'rk");
10571cb0ef41Sopenharmony_ci      break;
10581cb0ef41Sopenharmony_ci    case XOR:
10591cb0ef41Sopenharmony_ci      Format(instr, "xor          'rd, 'rj, 'rk");
10601cb0ef41Sopenharmony_ci      break;
10611cb0ef41Sopenharmony_ci    case ORN:
10621cb0ef41Sopenharmony_ci      Format(instr, "orn          'rd, 'rj, 'rk");
10631cb0ef41Sopenharmony_ci      break;
10641cb0ef41Sopenharmony_ci    case ANDN:
10651cb0ef41Sopenharmony_ci      Format(instr, "andn         'rd, 'rj, 'rk");
10661cb0ef41Sopenharmony_ci      break;
10671cb0ef41Sopenharmony_ci    case SLL_W:
10681cb0ef41Sopenharmony_ci      Format(instr, "sll.w        'rd, 'rj, 'rk");
10691cb0ef41Sopenharmony_ci      break;
10701cb0ef41Sopenharmony_ci    case SRL_W:
10711cb0ef41Sopenharmony_ci      Format(instr, "srl.w        'rd, 'rj, 'rk");
10721cb0ef41Sopenharmony_ci      break;
10731cb0ef41Sopenharmony_ci    case SRA_W:
10741cb0ef41Sopenharmony_ci      Format(instr, "sra.w        'rd, 'rj, 'rk");
10751cb0ef41Sopenharmony_ci      break;
10761cb0ef41Sopenharmony_ci    case SLL_D:
10771cb0ef41Sopenharmony_ci      Format(instr, "sll.d        'rd, 'rj, 'rk");
10781cb0ef41Sopenharmony_ci      break;
10791cb0ef41Sopenharmony_ci    case SRL_D:
10801cb0ef41Sopenharmony_ci      Format(instr, "srl.d        'rd, 'rj, 'rk");
10811cb0ef41Sopenharmony_ci      break;
10821cb0ef41Sopenharmony_ci    case SRA_D:
10831cb0ef41Sopenharmony_ci      Format(instr, "sra.d        'rd, 'rj, 'rk");
10841cb0ef41Sopenharmony_ci      break;
10851cb0ef41Sopenharmony_ci    case ROTR_D:
10861cb0ef41Sopenharmony_ci      Format(instr, "rotr.d       'rd, 'rj, 'rk");
10871cb0ef41Sopenharmony_ci      break;
10881cb0ef41Sopenharmony_ci    case ROTR_W:
10891cb0ef41Sopenharmony_ci      Format(instr, "rotr.w       'rd, 'rj, 'rk");
10901cb0ef41Sopenharmony_ci      break;
10911cb0ef41Sopenharmony_ci    case MUL_W:
10921cb0ef41Sopenharmony_ci      Format(instr, "mul.w        'rd, 'rj, 'rk");
10931cb0ef41Sopenharmony_ci      break;
10941cb0ef41Sopenharmony_ci    case MULH_W:
10951cb0ef41Sopenharmony_ci      Format(instr, "mulh.w       'rd, 'rj, 'rk");
10961cb0ef41Sopenharmony_ci      break;
10971cb0ef41Sopenharmony_ci    case MULH_WU:
10981cb0ef41Sopenharmony_ci      Format(instr, "mulh.wu      'rd, 'rj, 'rk");
10991cb0ef41Sopenharmony_ci      break;
11001cb0ef41Sopenharmony_ci    case MUL_D:
11011cb0ef41Sopenharmony_ci      Format(instr, "mul.d        'rd, 'rj, 'rk");
11021cb0ef41Sopenharmony_ci      break;
11031cb0ef41Sopenharmony_ci    case MULH_D:
11041cb0ef41Sopenharmony_ci      Format(instr, "mulh.d       'rd, 'rj, 'rk");
11051cb0ef41Sopenharmony_ci      break;
11061cb0ef41Sopenharmony_ci    case MULH_DU:
11071cb0ef41Sopenharmony_ci      Format(instr, "mulh.du      'rd, 'rj, 'rk");
11081cb0ef41Sopenharmony_ci      break;
11091cb0ef41Sopenharmony_ci    case MULW_D_W:
11101cb0ef41Sopenharmony_ci      Format(instr, "mulw.d.w     'rd, 'rj, 'rk");
11111cb0ef41Sopenharmony_ci      break;
11121cb0ef41Sopenharmony_ci    case MULW_D_WU:
11131cb0ef41Sopenharmony_ci      Format(instr, "mulw.d.wu    'rd, 'rj, 'rk");
11141cb0ef41Sopenharmony_ci      break;
11151cb0ef41Sopenharmony_ci    case DIV_W:
11161cb0ef41Sopenharmony_ci      Format(instr, "div.w        'rd, 'rj, 'rk");
11171cb0ef41Sopenharmony_ci      break;
11181cb0ef41Sopenharmony_ci    case MOD_W:
11191cb0ef41Sopenharmony_ci      Format(instr, "mod.w        'rd, 'rj, 'rk");
11201cb0ef41Sopenharmony_ci      break;
11211cb0ef41Sopenharmony_ci    case DIV_WU:
11221cb0ef41Sopenharmony_ci      Format(instr, "div.wu       'rd, 'rj, 'rk");
11231cb0ef41Sopenharmony_ci      break;
11241cb0ef41Sopenharmony_ci    case MOD_WU:
11251cb0ef41Sopenharmony_ci      Format(instr, "mod.wu       'rd, 'rj, 'rk");
11261cb0ef41Sopenharmony_ci      break;
11271cb0ef41Sopenharmony_ci    case DIV_D:
11281cb0ef41Sopenharmony_ci      Format(instr, "div.d        'rd, 'rj, 'rk");
11291cb0ef41Sopenharmony_ci      break;
11301cb0ef41Sopenharmony_ci    case MOD_D:
11311cb0ef41Sopenharmony_ci      Format(instr, "mod.d        'rd, 'rj, 'rk");
11321cb0ef41Sopenharmony_ci      break;
11331cb0ef41Sopenharmony_ci    case DIV_DU:
11341cb0ef41Sopenharmony_ci      Format(instr, "div.du       'rd, 'rj, 'rk");
11351cb0ef41Sopenharmony_ci      break;
11361cb0ef41Sopenharmony_ci    case MOD_DU:
11371cb0ef41Sopenharmony_ci      Format(instr, "mod.du       'rd, 'rj, 'rk");
11381cb0ef41Sopenharmony_ci      break;
11391cb0ef41Sopenharmony_ci    case BREAK:
11401cb0ef41Sopenharmony_ci      return DecodeBreakInstr(instr);
11411cb0ef41Sopenharmony_ci    case FADD_S:
11421cb0ef41Sopenharmony_ci      Format(instr, "fadd.s       'fd, 'fj, 'fk");
11431cb0ef41Sopenharmony_ci      break;
11441cb0ef41Sopenharmony_ci    case FADD_D:
11451cb0ef41Sopenharmony_ci      Format(instr, "fadd.d       'fd, 'fj, 'fk");
11461cb0ef41Sopenharmony_ci      break;
11471cb0ef41Sopenharmony_ci    case FSUB_S:
11481cb0ef41Sopenharmony_ci      Format(instr, "fsub.s       'fd, 'fj, 'fk");
11491cb0ef41Sopenharmony_ci      break;
11501cb0ef41Sopenharmony_ci    case FSUB_D:
11511cb0ef41Sopenharmony_ci      Format(instr, "fsub.d       'fd, 'fj, 'fk");
11521cb0ef41Sopenharmony_ci      break;
11531cb0ef41Sopenharmony_ci    case FMUL_S:
11541cb0ef41Sopenharmony_ci      Format(instr, "fmul.s       'fd, 'fj, 'fk");
11551cb0ef41Sopenharmony_ci      break;
11561cb0ef41Sopenharmony_ci    case FMUL_D:
11571cb0ef41Sopenharmony_ci      Format(instr, "fmul.d       'fd, 'fj, 'fk");
11581cb0ef41Sopenharmony_ci      break;
11591cb0ef41Sopenharmony_ci    case FDIV_S:
11601cb0ef41Sopenharmony_ci      Format(instr, "fdiv.s       'fd, 'fj, 'fk");
11611cb0ef41Sopenharmony_ci      break;
11621cb0ef41Sopenharmony_ci    case FDIV_D:
11631cb0ef41Sopenharmony_ci      Format(instr, "fdiv.d       'fd, 'fj, 'fk");
11641cb0ef41Sopenharmony_ci      break;
11651cb0ef41Sopenharmony_ci    case FMAX_S:
11661cb0ef41Sopenharmony_ci      Format(instr, "fmax.s       'fd, 'fj, 'fk");
11671cb0ef41Sopenharmony_ci      break;
11681cb0ef41Sopenharmony_ci    case FMAX_D:
11691cb0ef41Sopenharmony_ci      Format(instr, "fmax.d       'fd, 'fj, 'fk");
11701cb0ef41Sopenharmony_ci      break;
11711cb0ef41Sopenharmony_ci    case FMIN_S:
11721cb0ef41Sopenharmony_ci      Format(instr, "fmin.s       'fd, 'fj, 'fk");
11731cb0ef41Sopenharmony_ci      break;
11741cb0ef41Sopenharmony_ci    case FMIN_D:
11751cb0ef41Sopenharmony_ci      Format(instr, "fmin.d       'fd, 'fj, 'fk");
11761cb0ef41Sopenharmony_ci      break;
11771cb0ef41Sopenharmony_ci    case FMAXA_S:
11781cb0ef41Sopenharmony_ci      Format(instr, "fmaxa.s      'fd, 'fj, 'fk");
11791cb0ef41Sopenharmony_ci      break;
11801cb0ef41Sopenharmony_ci    case FMAXA_D:
11811cb0ef41Sopenharmony_ci      Format(instr, "fmaxa.d      'fd, 'fj, 'fk");
11821cb0ef41Sopenharmony_ci      break;
11831cb0ef41Sopenharmony_ci    case FMINA_S:
11841cb0ef41Sopenharmony_ci      Format(instr, "fmina.s      'fd, 'fj, 'fk");
11851cb0ef41Sopenharmony_ci      break;
11861cb0ef41Sopenharmony_ci    case FMINA_D:
11871cb0ef41Sopenharmony_ci      Format(instr, "fmina.d      'fd, 'fj, 'fk");
11881cb0ef41Sopenharmony_ci      break;
11891cb0ef41Sopenharmony_ci    case LDX_B:
11901cb0ef41Sopenharmony_ci      Format(instr, "ldx.b        'rd, 'rj, 'rk");
11911cb0ef41Sopenharmony_ci      break;
11921cb0ef41Sopenharmony_ci    case LDX_H:
11931cb0ef41Sopenharmony_ci      Format(instr, "ldx.h        'rd, 'rj, 'rk");
11941cb0ef41Sopenharmony_ci      break;
11951cb0ef41Sopenharmony_ci    case LDX_W:
11961cb0ef41Sopenharmony_ci      Format(instr, "ldx.w        'rd, 'rj, 'rk");
11971cb0ef41Sopenharmony_ci      break;
11981cb0ef41Sopenharmony_ci    case LDX_D:
11991cb0ef41Sopenharmony_ci      Format(instr, "ldx.d        'rd, 'rj, 'rk");
12001cb0ef41Sopenharmony_ci      break;
12011cb0ef41Sopenharmony_ci    case STX_B:
12021cb0ef41Sopenharmony_ci      Format(instr, "stx.b        'rd, 'rj, 'rk");
12031cb0ef41Sopenharmony_ci      break;
12041cb0ef41Sopenharmony_ci    case STX_H:
12051cb0ef41Sopenharmony_ci      Format(instr, "stx.h        'rd, 'rj, 'rk");
12061cb0ef41Sopenharmony_ci      break;
12071cb0ef41Sopenharmony_ci    case STX_W:
12081cb0ef41Sopenharmony_ci      Format(instr, "stx.w        'rd, 'rj, 'rk");
12091cb0ef41Sopenharmony_ci      break;
12101cb0ef41Sopenharmony_ci    case STX_D:
12111cb0ef41Sopenharmony_ci      Format(instr, "stx.d        'rd, 'rj, 'rk");
12121cb0ef41Sopenharmony_ci      break;
12131cb0ef41Sopenharmony_ci    case LDX_BU:
12141cb0ef41Sopenharmony_ci      Format(instr, "ldx.bu       'rd, 'rj, 'rk");
12151cb0ef41Sopenharmony_ci      break;
12161cb0ef41Sopenharmony_ci    case LDX_HU:
12171cb0ef41Sopenharmony_ci      Format(instr, "ldx.hu       'rd, 'rj, 'rk");
12181cb0ef41Sopenharmony_ci      break;
12191cb0ef41Sopenharmony_ci    case LDX_WU:
12201cb0ef41Sopenharmony_ci      Format(instr, "ldx.wu       'rd, 'rj, 'rk");
12211cb0ef41Sopenharmony_ci      break;
12221cb0ef41Sopenharmony_ci    case FLDX_S:
12231cb0ef41Sopenharmony_ci      Format(instr, "fldx.s       'fd, 'rj, 'rk");
12241cb0ef41Sopenharmony_ci      break;
12251cb0ef41Sopenharmony_ci    case FLDX_D:
12261cb0ef41Sopenharmony_ci      Format(instr, "fldx.d       'fd, 'rj, 'rk");
12271cb0ef41Sopenharmony_ci      break;
12281cb0ef41Sopenharmony_ci    case FSTX_S:
12291cb0ef41Sopenharmony_ci      Format(instr, "fstx.s       'fd, 'rj, 'rk");
12301cb0ef41Sopenharmony_ci      break;
12311cb0ef41Sopenharmony_ci    case FSTX_D:
12321cb0ef41Sopenharmony_ci      Format(instr, "fstx.d       'fd, 'rj, 'rk");
12331cb0ef41Sopenharmony_ci      break;
12341cb0ef41Sopenharmony_ci    case AMSWAP_W:
12351cb0ef41Sopenharmony_ci      Format(instr, "amswap.w     'rd, 'rk, 'rj");
12361cb0ef41Sopenharmony_ci      break;
12371cb0ef41Sopenharmony_ci    case AMSWAP_D:
12381cb0ef41Sopenharmony_ci      Format(instr, "amswap.d     'rd, 'rk, 'rj");
12391cb0ef41Sopenharmony_ci      break;
12401cb0ef41Sopenharmony_ci    case AMADD_W:
12411cb0ef41Sopenharmony_ci      Format(instr, "amadd.w      'rd, 'rk, 'rj");
12421cb0ef41Sopenharmony_ci      break;
12431cb0ef41Sopenharmony_ci    case AMADD_D:
12441cb0ef41Sopenharmony_ci      Format(instr, "amadd.d      'rd, 'rk, 'rj");
12451cb0ef41Sopenharmony_ci      break;
12461cb0ef41Sopenharmony_ci    case AMAND_W:
12471cb0ef41Sopenharmony_ci      Format(instr, "amand.w      'rd, 'rk, 'rj");
12481cb0ef41Sopenharmony_ci      break;
12491cb0ef41Sopenharmony_ci    case AMAND_D:
12501cb0ef41Sopenharmony_ci      Format(instr, "amand.d      'rd, 'rk, 'rj");
12511cb0ef41Sopenharmony_ci      break;
12521cb0ef41Sopenharmony_ci    case AMOR_W:
12531cb0ef41Sopenharmony_ci      Format(instr, "amor.w       'rd, 'rk, 'rj");
12541cb0ef41Sopenharmony_ci      break;
12551cb0ef41Sopenharmony_ci    case AMOR_D:
12561cb0ef41Sopenharmony_ci      Format(instr, "amor.d       'rd, 'rk, 'rj");
12571cb0ef41Sopenharmony_ci      break;
12581cb0ef41Sopenharmony_ci    case AMXOR_W:
12591cb0ef41Sopenharmony_ci      Format(instr, "amxor.w      'rd, 'rk, 'rj");
12601cb0ef41Sopenharmony_ci      break;
12611cb0ef41Sopenharmony_ci    case AMXOR_D:
12621cb0ef41Sopenharmony_ci      Format(instr, "amxor.d      'rd, 'rk, 'rj");
12631cb0ef41Sopenharmony_ci      break;
12641cb0ef41Sopenharmony_ci    case AMMAX_W:
12651cb0ef41Sopenharmony_ci      Format(instr, "ammax.w      'rd, 'rk, 'rj");
12661cb0ef41Sopenharmony_ci      break;
12671cb0ef41Sopenharmony_ci    case AMMAX_D:
12681cb0ef41Sopenharmony_ci      Format(instr, "ammax.d      'rd, 'rk, 'rj");
12691cb0ef41Sopenharmony_ci      break;
12701cb0ef41Sopenharmony_ci    case AMMIN_W:
12711cb0ef41Sopenharmony_ci      Format(instr, "ammin.w      'rd, 'rk, 'rj");
12721cb0ef41Sopenharmony_ci      break;
12731cb0ef41Sopenharmony_ci    case AMMIN_D:
12741cb0ef41Sopenharmony_ci      Format(instr, "ammin.d      'rd, 'rk, 'rj");
12751cb0ef41Sopenharmony_ci      break;
12761cb0ef41Sopenharmony_ci    case AMMAX_WU:
12771cb0ef41Sopenharmony_ci      Format(instr, "ammax.wu     'rd, 'rk, 'rj");
12781cb0ef41Sopenharmony_ci      break;
12791cb0ef41Sopenharmony_ci    case AMMAX_DU:
12801cb0ef41Sopenharmony_ci      Format(instr, "ammax.du     'rd, 'rk, 'rj");
12811cb0ef41Sopenharmony_ci      break;
12821cb0ef41Sopenharmony_ci    case AMMIN_WU:
12831cb0ef41Sopenharmony_ci      Format(instr, "ammin.wu     'rd, 'rk, 'rj");
12841cb0ef41Sopenharmony_ci      break;
12851cb0ef41Sopenharmony_ci    case AMMIN_DU:
12861cb0ef41Sopenharmony_ci      Format(instr, "ammin.du     'rd, 'rk, 'rj");
12871cb0ef41Sopenharmony_ci      break;
12881cb0ef41Sopenharmony_ci    case AMSWAP_DB_W:
12891cb0ef41Sopenharmony_ci      Format(instr, "amswap_db.w  'rd, 'rk, 'rj");
12901cb0ef41Sopenharmony_ci      break;
12911cb0ef41Sopenharmony_ci    case AMSWAP_DB_D:
12921cb0ef41Sopenharmony_ci      Format(instr, "amswap_db.d  'rd, 'rk, 'rj");
12931cb0ef41Sopenharmony_ci      break;
12941cb0ef41Sopenharmony_ci    case AMADD_DB_W:
12951cb0ef41Sopenharmony_ci      Format(instr, "amadd_db.w   'rd, 'rk, 'rj");
12961cb0ef41Sopenharmony_ci      break;
12971cb0ef41Sopenharmony_ci    case AMADD_DB_D:
12981cb0ef41Sopenharmony_ci      Format(instr, "amadd_db.d   'rd, 'rk, 'rj");
12991cb0ef41Sopenharmony_ci      break;
13001cb0ef41Sopenharmony_ci    case AMAND_DB_W:
13011cb0ef41Sopenharmony_ci      Format(instr, "amand_db.w   'rd, 'rk, 'rj");
13021cb0ef41Sopenharmony_ci      break;
13031cb0ef41Sopenharmony_ci    case AMAND_DB_D:
13041cb0ef41Sopenharmony_ci      Format(instr, "amand_db.d   'rd, 'rk, 'rj");
13051cb0ef41Sopenharmony_ci      break;
13061cb0ef41Sopenharmony_ci    case AMOR_DB_W:
13071cb0ef41Sopenharmony_ci      Format(instr, "amor_db.w    'rd, 'rk, 'rj");
13081cb0ef41Sopenharmony_ci      break;
13091cb0ef41Sopenharmony_ci    case AMOR_DB_D:
13101cb0ef41Sopenharmony_ci      Format(instr, "amor_db.d    'rd, 'rk, 'rj");
13111cb0ef41Sopenharmony_ci      break;
13121cb0ef41Sopenharmony_ci    case AMXOR_DB_W:
13131cb0ef41Sopenharmony_ci      Format(instr, "amxor_db.w   'rd, 'rk, 'rj");
13141cb0ef41Sopenharmony_ci      break;
13151cb0ef41Sopenharmony_ci    case AMXOR_DB_D:
13161cb0ef41Sopenharmony_ci      Format(instr, "amxor_db.d   'rd, 'rk, 'rj");
13171cb0ef41Sopenharmony_ci      break;
13181cb0ef41Sopenharmony_ci    case AMMAX_DB_W:
13191cb0ef41Sopenharmony_ci      Format(instr, "ammax_db.w   'rd, 'rk, 'rj");
13201cb0ef41Sopenharmony_ci      break;
13211cb0ef41Sopenharmony_ci    case AMMAX_DB_D:
13221cb0ef41Sopenharmony_ci      Format(instr, "ammax_db.d   'rd, 'rk, 'rj");
13231cb0ef41Sopenharmony_ci      break;
13241cb0ef41Sopenharmony_ci    case AMMIN_DB_W:
13251cb0ef41Sopenharmony_ci      Format(instr, "ammin_db.w   'rd, 'rk, 'rj");
13261cb0ef41Sopenharmony_ci      break;
13271cb0ef41Sopenharmony_ci    case AMMIN_DB_D:
13281cb0ef41Sopenharmony_ci      Format(instr, "ammin_db.d   'rd, 'rk, 'rj");
13291cb0ef41Sopenharmony_ci      break;
13301cb0ef41Sopenharmony_ci    case AMMAX_DB_WU:
13311cb0ef41Sopenharmony_ci      Format(instr, "ammax_db.wu  'rd, 'rk, 'rj");
13321cb0ef41Sopenharmony_ci      break;
13331cb0ef41Sopenharmony_ci    case AMMAX_DB_DU:
13341cb0ef41Sopenharmony_ci      Format(instr, "ammax_db.du  'rd, 'rk, 'rj");
13351cb0ef41Sopenharmony_ci      break;
13361cb0ef41Sopenharmony_ci    case AMMIN_DB_WU:
13371cb0ef41Sopenharmony_ci      Format(instr, "ammin_db.wu  'rd, 'rk, 'rj");
13381cb0ef41Sopenharmony_ci      break;
13391cb0ef41Sopenharmony_ci    case AMMIN_DB_DU:
13401cb0ef41Sopenharmony_ci      Format(instr, "ammin_db.du  'rd, 'rk, 'rj");
13411cb0ef41Sopenharmony_ci      break;
13421cb0ef41Sopenharmony_ci    case DBAR:
13431cb0ef41Sopenharmony_ci      Format(instr, "dbar         'hint15");
13441cb0ef41Sopenharmony_ci      break;
13451cb0ef41Sopenharmony_ci    case IBAR:
13461cb0ef41Sopenharmony_ci      Format(instr, "ibar         'hint15");
13471cb0ef41Sopenharmony_ci      break;
13481cb0ef41Sopenharmony_ci    case FSCALEB_S:
13491cb0ef41Sopenharmony_ci      Format(instr, "fscaleb.s    'fd, 'fj, 'fk");
13501cb0ef41Sopenharmony_ci      break;
13511cb0ef41Sopenharmony_ci    case FSCALEB_D:
13521cb0ef41Sopenharmony_ci      Format(instr, "fscaleb.d    'fd, 'fj, 'fk");
13531cb0ef41Sopenharmony_ci      break;
13541cb0ef41Sopenharmony_ci    case FCOPYSIGN_S:
13551cb0ef41Sopenharmony_ci      Format(instr, "fcopysign.s  'fd, 'fj, 'fk");
13561cb0ef41Sopenharmony_ci      break;
13571cb0ef41Sopenharmony_ci    case FCOPYSIGN_D:
13581cb0ef41Sopenharmony_ci      Format(instr, "fcopysign.d  'fd, 'fj, 'fk");
13591cb0ef41Sopenharmony_ci      break;
13601cb0ef41Sopenharmony_ci    default:
13611cb0ef41Sopenharmony_ci      UNREACHABLE();
13621cb0ef41Sopenharmony_ci  }
13631cb0ef41Sopenharmony_ci  return kInstrSize;
13641cb0ef41Sopenharmony_ci}
13651cb0ef41Sopenharmony_ci
13661cb0ef41Sopenharmony_civoid Decoder::DecodeTypekOp22(Instruction* instr) {
13671cb0ef41Sopenharmony_ci  switch (instr->Bits(31, 10) << 10) {
13681cb0ef41Sopenharmony_ci    case CLZ_W:
13691cb0ef41Sopenharmony_ci      Format(instr, "clz.w        'rd, 'rj");
13701cb0ef41Sopenharmony_ci      break;
13711cb0ef41Sopenharmony_ci    case CTZ_W:
13721cb0ef41Sopenharmony_ci      Format(instr, "ctz.w        'rd, 'rj");
13731cb0ef41Sopenharmony_ci      break;
13741cb0ef41Sopenharmony_ci    case CLZ_D:
13751cb0ef41Sopenharmony_ci      Format(instr, "clz.d        'rd, 'rj");
13761cb0ef41Sopenharmony_ci      break;
13771cb0ef41Sopenharmony_ci    case CTZ_D:
13781cb0ef41Sopenharmony_ci      Format(instr, "ctz.d        'rd, 'rj");
13791cb0ef41Sopenharmony_ci      break;
13801cb0ef41Sopenharmony_ci    case REVB_2H:
13811cb0ef41Sopenharmony_ci      Format(instr, "revb.2h      'rd, 'rj");
13821cb0ef41Sopenharmony_ci      break;
13831cb0ef41Sopenharmony_ci    case REVB_4H:
13841cb0ef41Sopenharmony_ci      Format(instr, "revb.4h      'rd, 'rj");
13851cb0ef41Sopenharmony_ci      break;
13861cb0ef41Sopenharmony_ci    case REVB_2W:
13871cb0ef41Sopenharmony_ci      Format(instr, "revb.2w      'rd, 'rj");
13881cb0ef41Sopenharmony_ci      break;
13891cb0ef41Sopenharmony_ci    case REVB_D:
13901cb0ef41Sopenharmony_ci      Format(instr, "revb.d       'rd, 'rj");
13911cb0ef41Sopenharmony_ci      break;
13921cb0ef41Sopenharmony_ci    case REVH_2W:
13931cb0ef41Sopenharmony_ci      Format(instr, "revh.2w      'rd, 'rj");
13941cb0ef41Sopenharmony_ci      break;
13951cb0ef41Sopenharmony_ci    case REVH_D:
13961cb0ef41Sopenharmony_ci      Format(instr, "revh.d       'rd, 'rj");
13971cb0ef41Sopenharmony_ci      break;
13981cb0ef41Sopenharmony_ci    case BITREV_4B:
13991cb0ef41Sopenharmony_ci      Format(instr, "bitrev.4b    'rd, 'rj");
14001cb0ef41Sopenharmony_ci      break;
14011cb0ef41Sopenharmony_ci    case BITREV_8B:
14021cb0ef41Sopenharmony_ci      Format(instr, "bitrev.8b    'rd, 'rj");
14031cb0ef41Sopenharmony_ci      break;
14041cb0ef41Sopenharmony_ci    case BITREV_W:
14051cb0ef41Sopenharmony_ci      Format(instr, "bitrev.w     'rd, 'rj");
14061cb0ef41Sopenharmony_ci      break;
14071cb0ef41Sopenharmony_ci    case BITREV_D:
14081cb0ef41Sopenharmony_ci      Format(instr, "bitrev.d     'rd, 'rj");
14091cb0ef41Sopenharmony_ci      break;
14101cb0ef41Sopenharmony_ci    case EXT_W_B:
14111cb0ef41Sopenharmony_ci      Format(instr, "ext.w.b      'rd, 'rj");
14121cb0ef41Sopenharmony_ci      break;
14131cb0ef41Sopenharmony_ci    case EXT_W_H:
14141cb0ef41Sopenharmony_ci      Format(instr, "ext.w.h      'rd, 'rj");
14151cb0ef41Sopenharmony_ci      break;
14161cb0ef41Sopenharmony_ci    case FABS_S:
14171cb0ef41Sopenharmony_ci      Format(instr, "fabs.s       'fd, 'fj");
14181cb0ef41Sopenharmony_ci      break;
14191cb0ef41Sopenharmony_ci    case FABS_D:
14201cb0ef41Sopenharmony_ci      Format(instr, "fabs.d       'fd, 'fj");
14211cb0ef41Sopenharmony_ci      break;
14221cb0ef41Sopenharmony_ci    case FNEG_S:
14231cb0ef41Sopenharmony_ci      Format(instr, "fneg.s       'fd, 'fj");
14241cb0ef41Sopenharmony_ci      break;
14251cb0ef41Sopenharmony_ci    case FNEG_D:
14261cb0ef41Sopenharmony_ci      Format(instr, "fneg.d       'fd, 'fj");
14271cb0ef41Sopenharmony_ci      break;
14281cb0ef41Sopenharmony_ci    case FSQRT_S:
14291cb0ef41Sopenharmony_ci      Format(instr, "fsqrt.s      'fd, 'fj");
14301cb0ef41Sopenharmony_ci      break;
14311cb0ef41Sopenharmony_ci    case FSQRT_D:
14321cb0ef41Sopenharmony_ci      Format(instr, "fsqrt.d      'fd, 'fj");
14331cb0ef41Sopenharmony_ci      break;
14341cb0ef41Sopenharmony_ci    case FMOV_S:
14351cb0ef41Sopenharmony_ci      Format(instr, "fmov.s       'fd, 'fj");
14361cb0ef41Sopenharmony_ci      break;
14371cb0ef41Sopenharmony_ci    case FMOV_D:
14381cb0ef41Sopenharmony_ci      Format(instr, "fmov.d       'fd, 'fj");
14391cb0ef41Sopenharmony_ci      break;
14401cb0ef41Sopenharmony_ci    case MOVGR2FR_W:
14411cb0ef41Sopenharmony_ci      Format(instr, "movgr2fr.w   'fd, 'rj");
14421cb0ef41Sopenharmony_ci      break;
14431cb0ef41Sopenharmony_ci    case MOVGR2FR_D:
14441cb0ef41Sopenharmony_ci      Format(instr, "movgr2fr.d   'fd, 'rj");
14451cb0ef41Sopenharmony_ci      break;
14461cb0ef41Sopenharmony_ci    case MOVGR2FRH_W:
14471cb0ef41Sopenharmony_ci      Format(instr, "movgr2frh.w  'fd, 'rj");
14481cb0ef41Sopenharmony_ci      break;
14491cb0ef41Sopenharmony_ci    case MOVFR2GR_S:
14501cb0ef41Sopenharmony_ci      Format(instr, "movfr2gr.s   'rd, 'fj");
14511cb0ef41Sopenharmony_ci      break;
14521cb0ef41Sopenharmony_ci    case MOVFR2GR_D:
14531cb0ef41Sopenharmony_ci      Format(instr, "movfr2gr.d   'rd, 'fj");
14541cb0ef41Sopenharmony_ci      break;
14551cb0ef41Sopenharmony_ci    case MOVFRH2GR_S:
14561cb0ef41Sopenharmony_ci      Format(instr, "movfrh2gr.s  'rd, 'fj");
14571cb0ef41Sopenharmony_ci      break;
14581cb0ef41Sopenharmony_ci    case MOVGR2FCSR:
14591cb0ef41Sopenharmony_ci      Format(instr, "movgr2fcsr   fcsr, 'rj");
14601cb0ef41Sopenharmony_ci      break;
14611cb0ef41Sopenharmony_ci    case MOVFCSR2GR:
14621cb0ef41Sopenharmony_ci      Format(instr, "movfcsr2gr   'rd, fcsr");
14631cb0ef41Sopenharmony_ci      break;
14641cb0ef41Sopenharmony_ci    case FCVT_S_D:
14651cb0ef41Sopenharmony_ci      Format(instr, "fcvt.s.d     'fd, 'fj");
14661cb0ef41Sopenharmony_ci      break;
14671cb0ef41Sopenharmony_ci    case FCVT_D_S:
14681cb0ef41Sopenharmony_ci      Format(instr, "fcvt.d.s     'fd, 'fj");
14691cb0ef41Sopenharmony_ci      break;
14701cb0ef41Sopenharmony_ci    case FTINTRM_W_S:
14711cb0ef41Sopenharmony_ci      Format(instr, "ftintrm.w.s  'fd, 'fj");
14721cb0ef41Sopenharmony_ci      break;
14731cb0ef41Sopenharmony_ci    case FTINTRM_W_D:
14741cb0ef41Sopenharmony_ci      Format(instr, "ftintrm.w.d  'fd, 'fj");
14751cb0ef41Sopenharmony_ci      break;
14761cb0ef41Sopenharmony_ci    case FTINTRM_L_S:
14771cb0ef41Sopenharmony_ci      Format(instr, "ftintrm.l.s  'fd, 'fj");
14781cb0ef41Sopenharmony_ci      break;
14791cb0ef41Sopenharmony_ci    case FTINTRM_L_D:
14801cb0ef41Sopenharmony_ci      Format(instr, "ftintrm.l.d  'fd, 'fj");
14811cb0ef41Sopenharmony_ci      break;
14821cb0ef41Sopenharmony_ci    case FTINTRP_W_S:
14831cb0ef41Sopenharmony_ci      Format(instr, "ftintrp.w.s  'fd, 'fj");
14841cb0ef41Sopenharmony_ci      break;
14851cb0ef41Sopenharmony_ci    case FTINTRP_W_D:
14861cb0ef41Sopenharmony_ci      Format(instr, "ftintrp.w.d  'fd, 'fj");
14871cb0ef41Sopenharmony_ci      break;
14881cb0ef41Sopenharmony_ci    case FTINTRP_L_S:
14891cb0ef41Sopenharmony_ci      Format(instr, "ftintrp.l.s  'fd, 'fj");
14901cb0ef41Sopenharmony_ci      break;
14911cb0ef41Sopenharmony_ci    case FTINTRP_L_D:
14921cb0ef41Sopenharmony_ci      Format(instr, "ftintrp.l.d  'fd, 'fj");
14931cb0ef41Sopenharmony_ci      break;
14941cb0ef41Sopenharmony_ci    case FTINTRZ_W_S:
14951cb0ef41Sopenharmony_ci      Format(instr, "ftintrz.w.s  'fd, 'fj");
14961cb0ef41Sopenharmony_ci      break;
14971cb0ef41Sopenharmony_ci    case FTINTRZ_W_D:
14981cb0ef41Sopenharmony_ci      Format(instr, "ftintrz.w.d  'fd, 'fj");
14991cb0ef41Sopenharmony_ci      break;
15001cb0ef41Sopenharmony_ci    case FTINTRZ_L_S:
15011cb0ef41Sopenharmony_ci      Format(instr, "ftintrz.l.s  'fd, 'fj");
15021cb0ef41Sopenharmony_ci      break;
15031cb0ef41Sopenharmony_ci    case FTINTRZ_L_D:
15041cb0ef41Sopenharmony_ci      Format(instr, "ftintrz.l.d  'fd, 'fj");
15051cb0ef41Sopenharmony_ci      break;
15061cb0ef41Sopenharmony_ci    case FTINTRNE_W_S:
15071cb0ef41Sopenharmony_ci      Format(instr, "ftintrne.w.s 'fd, 'fj");
15081cb0ef41Sopenharmony_ci      break;
15091cb0ef41Sopenharmony_ci    case FTINTRNE_W_D:
15101cb0ef41Sopenharmony_ci      Format(instr, "ftintrne.w.d 'fd, 'fj");
15111cb0ef41Sopenharmony_ci      break;
15121cb0ef41Sopenharmony_ci    case FTINTRNE_L_S:
15131cb0ef41Sopenharmony_ci      Format(instr, "ftintrne.l.s 'fd, 'fj");
15141cb0ef41Sopenharmony_ci      break;
15151cb0ef41Sopenharmony_ci    case FTINTRNE_L_D:
15161cb0ef41Sopenharmony_ci      Format(instr, "ftintrne.l.d 'fd, 'fj");
15171cb0ef41Sopenharmony_ci      break;
15181cb0ef41Sopenharmony_ci    case FTINT_W_S:
15191cb0ef41Sopenharmony_ci      Format(instr, "ftint.w.s    'fd, 'fj");
15201cb0ef41Sopenharmony_ci      break;
15211cb0ef41Sopenharmony_ci    case FTINT_W_D:
15221cb0ef41Sopenharmony_ci      Format(instr, "ftint.w.d    'fd, 'fj");
15231cb0ef41Sopenharmony_ci      break;
15241cb0ef41Sopenharmony_ci    case FTINT_L_S:
15251cb0ef41Sopenharmony_ci      Format(instr, "ftint.l.s    'fd, 'fj");
15261cb0ef41Sopenharmony_ci      break;
15271cb0ef41Sopenharmony_ci    case FTINT_L_D:
15281cb0ef41Sopenharmony_ci      Format(instr, "ftint.l.d    'fd, 'fj");
15291cb0ef41Sopenharmony_ci      break;
15301cb0ef41Sopenharmony_ci    case FFINT_S_W:
15311cb0ef41Sopenharmony_ci      Format(instr, "ffint.s.w    'fd, 'fj");
15321cb0ef41Sopenharmony_ci      break;
15331cb0ef41Sopenharmony_ci    case FFINT_S_L:
15341cb0ef41Sopenharmony_ci      Format(instr, "ffint.s.l    'fd, 'fj");
15351cb0ef41Sopenharmony_ci      break;
15361cb0ef41Sopenharmony_ci    case FFINT_D_W:
15371cb0ef41Sopenharmony_ci      Format(instr, "ffint.d.w    'fd, 'fj");
15381cb0ef41Sopenharmony_ci      break;
15391cb0ef41Sopenharmony_ci    case FFINT_D_L:
15401cb0ef41Sopenharmony_ci      Format(instr, "ffint.d.l    'fd, 'fj");
15411cb0ef41Sopenharmony_ci      break;
15421cb0ef41Sopenharmony_ci    case FRINT_S:
15431cb0ef41Sopenharmony_ci      Format(instr, "frint.s      'fd, 'fj");
15441cb0ef41Sopenharmony_ci      break;
15451cb0ef41Sopenharmony_ci    case FRINT_D:
15461cb0ef41Sopenharmony_ci      Format(instr, "frint.d      'fd, 'fj");
15471cb0ef41Sopenharmony_ci      break;
15481cb0ef41Sopenharmony_ci    case MOVFR2CF:
15491cb0ef41Sopenharmony_ci      Format(instr, "movfr2cf     fcc'cd, 'fj");
15501cb0ef41Sopenharmony_ci      break;
15511cb0ef41Sopenharmony_ci    case MOVCF2FR:
15521cb0ef41Sopenharmony_ci      Format(instr, "movcf2fr     'fd, fcc'cj");
15531cb0ef41Sopenharmony_ci      break;
15541cb0ef41Sopenharmony_ci    case MOVGR2CF:
15551cb0ef41Sopenharmony_ci      Format(instr, "movgr2cf     fcc'cd, 'rj");
15561cb0ef41Sopenharmony_ci      break;
15571cb0ef41Sopenharmony_ci    case MOVCF2GR:
15581cb0ef41Sopenharmony_ci      Format(instr, "movcf2gr     'rd, fcc'cj");
15591cb0ef41Sopenharmony_ci      break;
15601cb0ef41Sopenharmony_ci    case FRECIP_S:
15611cb0ef41Sopenharmony_ci      Format(instr, "frecip.s     'fd, 'fj");
15621cb0ef41Sopenharmony_ci      break;
15631cb0ef41Sopenharmony_ci    case FRECIP_D:
15641cb0ef41Sopenharmony_ci      Format(instr, "frecip.d     'fd, 'fj");
15651cb0ef41Sopenharmony_ci      break;
15661cb0ef41Sopenharmony_ci    case FRSQRT_S:
15671cb0ef41Sopenharmony_ci      Format(instr, "frsqrt.s     'fd, 'fj");
15681cb0ef41Sopenharmony_ci      break;
15691cb0ef41Sopenharmony_ci    case FRSQRT_D:
15701cb0ef41Sopenharmony_ci      Format(instr, "frsqrt.d     'fd, 'fj");
15711cb0ef41Sopenharmony_ci      break;
15721cb0ef41Sopenharmony_ci    case FCLASS_S:
15731cb0ef41Sopenharmony_ci      Format(instr, "fclass.s     'fd, 'fj");
15741cb0ef41Sopenharmony_ci      break;
15751cb0ef41Sopenharmony_ci    case FCLASS_D:
15761cb0ef41Sopenharmony_ci      Format(instr, "fclass.d     'fd, 'fj");
15771cb0ef41Sopenharmony_ci      break;
15781cb0ef41Sopenharmony_ci    case FLOGB_S:
15791cb0ef41Sopenharmony_ci      Format(instr, "flogb.s      'fd, 'fj");
15801cb0ef41Sopenharmony_ci      break;
15811cb0ef41Sopenharmony_ci    case FLOGB_D:
15821cb0ef41Sopenharmony_ci      Format(instr, "flogb.d      'fd, 'fj");
15831cb0ef41Sopenharmony_ci      break;
15841cb0ef41Sopenharmony_ci    case CLO_W:
15851cb0ef41Sopenharmony_ci      Format(instr, "clo.w        'rd, 'rj");
15861cb0ef41Sopenharmony_ci      break;
15871cb0ef41Sopenharmony_ci    case CTO_W:
15881cb0ef41Sopenharmony_ci      Format(instr, "cto.w        'rd, 'rj");
15891cb0ef41Sopenharmony_ci      break;
15901cb0ef41Sopenharmony_ci    case CLO_D:
15911cb0ef41Sopenharmony_ci      Format(instr, "clo.d        'rd, 'rj");
15921cb0ef41Sopenharmony_ci      break;
15931cb0ef41Sopenharmony_ci    case CTO_D:
15941cb0ef41Sopenharmony_ci      Format(instr, "cto.d        'rd, 'rj");
15951cb0ef41Sopenharmony_ci      break;
15961cb0ef41Sopenharmony_ci    default:
15971cb0ef41Sopenharmony_ci      UNREACHABLE();
15981cb0ef41Sopenharmony_ci  }
15991cb0ef41Sopenharmony_ci}
16001cb0ef41Sopenharmony_ci
16011cb0ef41Sopenharmony_ciint Decoder::InstructionDecode(byte* instr_ptr) {
16021cb0ef41Sopenharmony_ci  Instruction* instr = Instruction::At(instr_ptr);
16031cb0ef41Sopenharmony_ci  out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_,
16041cb0ef41Sopenharmony_ci                                    "%08x       ", instr->InstructionBits());
16051cb0ef41Sopenharmony_ci  switch (instr->InstructionType()) {
16061cb0ef41Sopenharmony_ci    case Instruction::kOp6Type: {
16071cb0ef41Sopenharmony_ci      DecodeTypekOp6(instr);
16081cb0ef41Sopenharmony_ci      break;
16091cb0ef41Sopenharmony_ci    }
16101cb0ef41Sopenharmony_ci    case Instruction::kOp7Type: {
16111cb0ef41Sopenharmony_ci      DecodeTypekOp7(instr);
16121cb0ef41Sopenharmony_ci      break;
16131cb0ef41Sopenharmony_ci    }
16141cb0ef41Sopenharmony_ci    case Instruction::kOp8Type: {
16151cb0ef41Sopenharmony_ci      DecodeTypekOp8(instr);
16161cb0ef41Sopenharmony_ci      break;
16171cb0ef41Sopenharmony_ci    }
16181cb0ef41Sopenharmony_ci    case Instruction::kOp10Type: {
16191cb0ef41Sopenharmony_ci      DecodeTypekOp10(instr);
16201cb0ef41Sopenharmony_ci      break;
16211cb0ef41Sopenharmony_ci    }
16221cb0ef41Sopenharmony_ci    case Instruction::kOp12Type: {
16231cb0ef41Sopenharmony_ci      DecodeTypekOp12(instr);
16241cb0ef41Sopenharmony_ci      break;
16251cb0ef41Sopenharmony_ci    }
16261cb0ef41Sopenharmony_ci    case Instruction::kOp14Type: {
16271cb0ef41Sopenharmony_ci      DecodeTypekOp14(instr);
16281cb0ef41Sopenharmony_ci      break;
16291cb0ef41Sopenharmony_ci    }
16301cb0ef41Sopenharmony_ci    case Instruction::kOp17Type: {
16311cb0ef41Sopenharmony_ci      return DecodeTypekOp17(instr);
16321cb0ef41Sopenharmony_ci    }
16331cb0ef41Sopenharmony_ci    case Instruction::kOp22Type: {
16341cb0ef41Sopenharmony_ci      DecodeTypekOp22(instr);
16351cb0ef41Sopenharmony_ci      break;
16361cb0ef41Sopenharmony_ci    }
16371cb0ef41Sopenharmony_ci    case Instruction::kUnsupported: {
16381cb0ef41Sopenharmony_ci      Format(instr, "UNSUPPORTED");
16391cb0ef41Sopenharmony_ci      break;
16401cb0ef41Sopenharmony_ci    }
16411cb0ef41Sopenharmony_ci    default: {
16421cb0ef41Sopenharmony_ci      Format(instr, "UNSUPPORTED");
16431cb0ef41Sopenharmony_ci      break;
16441cb0ef41Sopenharmony_ci    }
16451cb0ef41Sopenharmony_ci  }
16461cb0ef41Sopenharmony_ci  return kInstrSize;
16471cb0ef41Sopenharmony_ci}
16481cb0ef41Sopenharmony_ci
16491cb0ef41Sopenharmony_ci}  // namespace internal
16501cb0ef41Sopenharmony_ci}  // namespace v8
16511cb0ef41Sopenharmony_ci
16521cb0ef41Sopenharmony_ci//------------------------------------------------------------------------------
16531cb0ef41Sopenharmony_ci
16541cb0ef41Sopenharmony_cinamespace disasm {
16551cb0ef41Sopenharmony_ci
16561cb0ef41Sopenharmony_ciconst char* NameConverter::NameOfAddress(byte* addr) const {
16571cb0ef41Sopenharmony_ci  v8::base::SNPrintF(tmp_buffer_, "%p", static_cast<void*>(addr));
16581cb0ef41Sopenharmony_ci  return tmp_buffer_.begin();
16591cb0ef41Sopenharmony_ci}
16601cb0ef41Sopenharmony_ci
16611cb0ef41Sopenharmony_ciconst char* NameConverter::NameOfConstant(byte* addr) const {
16621cb0ef41Sopenharmony_ci  return NameOfAddress(addr);
16631cb0ef41Sopenharmony_ci}
16641cb0ef41Sopenharmony_ci
16651cb0ef41Sopenharmony_ciconst char* NameConverter::NameOfCPURegister(int reg) const {
16661cb0ef41Sopenharmony_ci  return v8::internal::Registers::Name(reg);
16671cb0ef41Sopenharmony_ci}
16681cb0ef41Sopenharmony_ci
16691cb0ef41Sopenharmony_ciconst char* NameConverter::NameOfXMMRegister(int reg) const {
16701cb0ef41Sopenharmony_ci  return v8::internal::FPURegisters::Name(reg);
16711cb0ef41Sopenharmony_ci}
16721cb0ef41Sopenharmony_ci
16731cb0ef41Sopenharmony_ciconst char* NameConverter::NameOfByteCPURegister(int reg) const {
16741cb0ef41Sopenharmony_ci  UNREACHABLE();
16751cb0ef41Sopenharmony_ci}
16761cb0ef41Sopenharmony_ci
16771cb0ef41Sopenharmony_ciconst char* NameConverter::NameInCode(byte* addr) const {
16781cb0ef41Sopenharmony_ci  // The default name converter is called for unknown code. So we will not try
16791cb0ef41Sopenharmony_ci  // to access any memory.
16801cb0ef41Sopenharmony_ci  return "";
16811cb0ef41Sopenharmony_ci}
16821cb0ef41Sopenharmony_ci
16831cb0ef41Sopenharmony_ci//------------------------------------------------------------------------------
16841cb0ef41Sopenharmony_ci
16851cb0ef41Sopenharmony_ciint Disassembler::InstructionDecode(v8::base::Vector<char> buffer,
16861cb0ef41Sopenharmony_ci                                    byte* instruction) {
16871cb0ef41Sopenharmony_ci  v8::internal::Decoder d(converter_, buffer);
16881cb0ef41Sopenharmony_ci  return d.InstructionDecode(instruction);
16891cb0ef41Sopenharmony_ci}
16901cb0ef41Sopenharmony_ci
16911cb0ef41Sopenharmony_ciint Disassembler::ConstantPoolSizeAt(byte* instruction) { return -1; }
16921cb0ef41Sopenharmony_ci
16931cb0ef41Sopenharmony_civoid Disassembler::Disassemble(FILE* f, byte* begin, byte* end,
16941cb0ef41Sopenharmony_ci                               UnimplementedOpcodeAction unimplemented_action) {
16951cb0ef41Sopenharmony_ci  NameConverter converter;
16961cb0ef41Sopenharmony_ci  Disassembler d(converter, unimplemented_action);
16971cb0ef41Sopenharmony_ci  for (byte* pc = begin; pc < end;) {
16981cb0ef41Sopenharmony_ci    v8::base::EmbeddedVector<char, 128> buffer;
16991cb0ef41Sopenharmony_ci    buffer[0] = '\0';
17001cb0ef41Sopenharmony_ci    byte* prev_pc = pc;
17011cb0ef41Sopenharmony_ci    pc += d.InstructionDecode(buffer, pc);
17021cb0ef41Sopenharmony_ci    v8::internal::PrintF(f, "%p    %08x      %s\n", static_cast<void*>(prev_pc),
17031cb0ef41Sopenharmony_ci                         *reinterpret_cast<int32_t*>(prev_pc), buffer.begin());
17041cb0ef41Sopenharmony_ci  }
17051cb0ef41Sopenharmony_ci}
17061cb0ef41Sopenharmony_ci
17071cb0ef41Sopenharmony_ci#undef STRING_STARTS_WITH
17081cb0ef41Sopenharmony_ci
17091cb0ef41Sopenharmony_ci}  // namespace disasm
17101cb0ef41Sopenharmony_ci
17111cb0ef41Sopenharmony_ci#endif  // V8_TARGET_ARCH_LOONG64
1712