Commit c21438ab authored by Liu Yu's avatar Liu Yu Committed by V8 LUCI CQ

[loong64] Adjust the disassembler instruction format

Change-Id: I1148508825b7bdff3dae0634aed5318a605ba4da
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3153355Reviewed-by: 's avatarZhao Jiazhong <zhaojiazhong-hf@loongson.cn>
Commit-Queue: Zhao Jiazhong <zhaojiazhong-hf@loongson.cn>
Auto-Submit: Liu yu <liuyu@loongson.cn>
Cr-Commit-Position: refs/heads/main@{#76762}
parent b728cd9c
...@@ -62,7 +62,6 @@ class Decoder { ...@@ -62,7 +62,6 @@ class Decoder {
void PrintUi5(Instruction* instr); void PrintUi5(Instruction* instr);
void PrintUi6(Instruction* instr); void PrintUi6(Instruction* instr);
void PrintUi12(Instruction* instr); void PrintUi12(Instruction* instr);
void PrintXi12(Instruction* instr);
void PrintMsbw(Instruction* instr); void PrintMsbw(Instruction* instr);
void PrintLsbw(Instruction* instr); void PrintLsbw(Instruction* instr);
void PrintMsbd(Instruction* instr); void PrintMsbd(Instruction* instr);
...@@ -72,6 +71,8 @@ class Decoder { ...@@ -72,6 +71,8 @@ class Decoder {
void PrintSi14(Instruction* instr); void PrintSi14(Instruction* instr);
void PrintSi16(Instruction* instr); void PrintSi16(Instruction* instr);
void PrintSi20(Instruction* instr); void PrintSi20(Instruction* instr);
void PrintXi12(Instruction* instr);
void PrintXi20(Instruction* instr);
void PrintCj(Instruction* instr); void PrintCj(Instruction* instr);
void PrintCd(Instruction* instr); void PrintCd(Instruction* instr);
void PrintCa(Instruction* instr); void PrintCa(Instruction* instr);
...@@ -206,6 +207,11 @@ void Decoder::PrintXi12(Instruction* instr) { ...@@ -206,6 +207,11 @@ void Decoder::PrintXi12(Instruction* instr) {
out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x", xi); out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x", xi);
} }
void Decoder::PrintXi20(Instruction* instr) {
int xi = instr->Si20Value();
out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x", xi);
}
void Decoder::PrintMsbd(Instruction* instr) { void Decoder::PrintMsbd(Instruction* instr) {
int msbd = instr->MsbdValue(); int msbd = instr->MsbdValue();
out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "%u", msbd); out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "%u", msbd);
...@@ -228,23 +234,27 @@ void Decoder::PrintLsbw(Instruction* instr) { ...@@ -228,23 +234,27 @@ void Decoder::PrintLsbw(Instruction* instr) {
void Decoder::PrintSi12(Instruction* instr) { void Decoder::PrintSi12(Instruction* instr) {
int si = ((instr->Si12Value()) << (32 - kSi12Bits)) >> (32 - kSi12Bits); int si = ((instr->Si12Value()) << (32 - kSi12Bits)) >> (32 - kSi12Bits);
out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "%d", si); out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "%d(0x%x)",
si, instr->Si12Value());
} }
void Decoder::PrintSi14(Instruction* instr) { void Decoder::PrintSi14(Instruction* instr) {
int si = ((instr->Si14Value()) << (32 - kSi14Bits)) >> (32 - kSi14Bits); int si = ((instr->Si14Value()) << (32 - kSi14Bits)) >> (32 - kSi14Bits);
si <<= 2; si <<= 2;
out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "%d", si); out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "%d(0x%x)",
si, instr->Si14Value() << 2);
} }
void Decoder::PrintSi16(Instruction* instr) { void Decoder::PrintSi16(Instruction* instr) {
int si = ((instr->Si16Value()) << (32 - kSi16Bits)) >> (32 - kSi16Bits); int si = ((instr->Si16Value()) << (32 - kSi16Bits)) >> (32 - kSi16Bits);
out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "%d", si); out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "%d(0x%x)",
si, instr->Si16Value());
} }
void Decoder::PrintSi20(Instruction* instr) { void Decoder::PrintSi20(Instruction* instr) {
int si = ((instr->Si20Value()) << (32 - kSi20Bits)) >> (32 - kSi20Bits); int si = ((instr->Si20Value()) << (32 - kSi20Bits)) >> (32 - kSi20Bits);
out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "%d", si); out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "%d(0x%x)",
si, instr->Si20Value());
} }
void Decoder::PrintCj(Instruction* instr) { void Decoder::PrintCj(Instruction* instr) {
...@@ -314,23 +324,20 @@ void Decoder::PrintPCOffs26(Instruction* instr) { ...@@ -314,23 +324,20 @@ void Decoder::PrintPCOffs26(Instruction* instr) {
void Decoder::PrintOffs16(Instruction* instr) { void Decoder::PrintOffs16(Instruction* instr) {
int offs = instr->Offs16Value(); int offs = instr->Offs16Value();
offs <<= (32 - kOffsLowBits); out_buffer_pos_ +=
offs >>= (32 - kOffsLowBits); base::SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x", offs << 2);
out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "%d", offs);
} }
void Decoder::PrintOffs21(Instruction* instr) { void Decoder::PrintOffs21(Instruction* instr) {
int offs = instr->Offs21Value(); int offs = instr->Offs21Value();
offs <<= (32 - kOffsLowBits - kOffs21HighBits); out_buffer_pos_ +=
offs >>= (32 - kOffsLowBits - kOffs21HighBits); base::SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x", offs << 2);
out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "%d", offs);
} }
void Decoder::PrintOffs26(Instruction* instr) { void Decoder::PrintOffs26(Instruction* instr) {
int offs = instr->Offs26Value(); int offs = instr->Offs26Value();
offs <<= (32 - kOffsLowBits - kOffs26HighBits); out_buffer_pos_ +=
offs >>= (32 - kOffsLowBits - kOffs26HighBits); base::SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x", offs << 2);
out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "%d", offs);
} }
// Handle all register based formatting in this function to reduce the // Handle all register based formatting in this function to reduce the
...@@ -541,10 +548,17 @@ int Decoder::FormatOption(Instruction* instr, const char* format) { ...@@ -541,10 +548,17 @@ int Decoder::FormatOption(Instruction* instr, const char* format) {
break; break;
} }
case 'x': { case 'x': {
if (format[2] == '2') {
DCHECK(STRING_STARTS_WITH(format, "xi20"));
PrintXi20(instr);
return 4;
} else if (format[3] == '2') {
DCHECK(STRING_STARTS_WITH(format, "xi12")); DCHECK(STRING_STARTS_WITH(format, "xi12"));
PrintXi12(instr); PrintXi12(instr);
return 4; return 4;
} }
break;
}
default: default:
UNREACHABLE(); UNREACHABLE();
} }
...@@ -643,22 +657,22 @@ void Decoder::DecodeTypekOp6(Instruction* instr) { ...@@ -643,22 +657,22 @@ void Decoder::DecodeTypekOp6(Instruction* instr) {
void Decoder::DecodeTypekOp7(Instruction* instr) { void Decoder::DecodeTypekOp7(Instruction* instr) {
switch (instr->Bits(31, 25) << 25) { switch (instr->Bits(31, 25) << 25) {
case LU12I_W: case LU12I_W:
Format(instr, "lu12i.w 'rd, 'si20"); Format(instr, "lu12i.w 'rd, 'xi20");
break; break;
case LU32I_D: case LU32I_D:
Format(instr, "lu32i.d 'rd, 'si20"); Format(instr, "lu32i.d 'rd, 'xi20");
break; break;
case PCADDI: case PCADDI:
Format(instr, "pcaddi 'rd, 'si20"); Format(instr, "pcaddi 'rd, 'xi20");
break; break;
case PCALAU12I: case PCALAU12I:
Format(instr, "pcalau12i 'rd, 'si20"); Format(instr, "pcalau12i 'rd, 'xi20");
break; break;
case PCADDU12I: case PCADDU12I:
Format(instr, "pcaddu12i 'rd, 'si20"); Format(instr, "pcaddu12i 'rd, 'xi20");
break; break;
case PCADDU18I: case PCADDU18I:
Format(instr, "pcaddu18i 'rd, 'si20"); Format(instr, "pcaddu18i 'rd, 'xi20");
break; break;
default: default:
UNREACHABLE(); UNREACHABLE();
...@@ -727,7 +741,7 @@ void Decoder::DecodeTypekOp10(Instruction* instr) { ...@@ -727,7 +741,7 @@ void Decoder::DecodeTypekOp10(Instruction* instr) {
Format(instr, "addi.d 'rd, 'rj, 'si12"); Format(instr, "addi.d 'rd, 'rj, 'si12");
break; break;
case LU52I_D: case LU52I_D:
Format(instr, "lu52i.d 'rd, 'rj, 'si12"); Format(instr, "lu52i.d 'rd, 'rj, 'xi12");
break; break;
case ANDI: case ANDI:
Format(instr, "andi 'rd, 'rj, 'xi12"); Format(instr, "andi 'rd, 'rj, 'xi12");
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment