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 {
void PrintUi5(Instruction* instr);
void PrintUi6(Instruction* instr);
void PrintUi12(Instruction* instr);
void PrintXi12(Instruction* instr);
void PrintMsbw(Instruction* instr);
void PrintLsbw(Instruction* instr);
void PrintMsbd(Instruction* instr);
......@@ -72,6 +71,8 @@ class Decoder {
void PrintSi14(Instruction* instr);
void PrintSi16(Instruction* instr);
void PrintSi20(Instruction* instr);
void PrintXi12(Instruction* instr);
void PrintXi20(Instruction* instr);
void PrintCj(Instruction* instr);
void PrintCd(Instruction* instr);
void PrintCa(Instruction* instr);
......@@ -206,6 +207,11 @@ void Decoder::PrintXi12(Instruction* instr) {
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) {
int msbd = instr->MsbdValue();
out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "%u", msbd);
......@@ -228,23 +234,27 @@ void Decoder::PrintLsbw(Instruction* instr) {
void Decoder::PrintSi12(Instruction* instr) {
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) {
int si = ((instr->Si14Value()) << (32 - kSi14Bits)) >> (32 - kSi14Bits);
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) {
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) {
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) {
......@@ -314,23 +324,20 @@ void Decoder::PrintPCOffs26(Instruction* instr) {
void Decoder::PrintOffs16(Instruction* instr) {
int offs = instr->Offs16Value();
offs <<= (32 - kOffsLowBits);
offs >>= (32 - kOffsLowBits);
out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "%d", offs);
out_buffer_pos_ +=
base::SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x", offs << 2);
}
void Decoder::PrintOffs21(Instruction* instr) {
int offs = instr->Offs21Value();
offs <<= (32 - kOffsLowBits - kOffs21HighBits);
offs >>= (32 - kOffsLowBits - kOffs21HighBits);
out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "%d", offs);
out_buffer_pos_ +=
base::SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x", offs << 2);
}
void Decoder::PrintOffs26(Instruction* instr) {
int offs = instr->Offs26Value();
offs <<= (32 - kOffsLowBits - kOffs26HighBits);
offs >>= (32 - kOffsLowBits - kOffs26HighBits);
out_buffer_pos_ += base::SNPrintF(out_buffer_ + out_buffer_pos_, "%d", offs);
out_buffer_pos_ +=
base::SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x", offs << 2);
}
// Handle all register based formatting in this function to reduce the
......@@ -541,10 +548,17 @@ int Decoder::FormatOption(Instruction* instr, const char* format) {
break;
}
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"));
PrintXi12(instr);
return 4;
}
break;
}
default:
UNREACHABLE();
}
......@@ -643,22 +657,22 @@ void Decoder::DecodeTypekOp6(Instruction* instr) {
void Decoder::DecodeTypekOp7(Instruction* instr) {
switch (instr->Bits(31, 25) << 25) {
case LU12I_W:
Format(instr, "lu12i.w 'rd, 'si20");
Format(instr, "lu12i.w 'rd, 'xi20");
break;
case LU32I_D:
Format(instr, "lu32i.d 'rd, 'si20");
Format(instr, "lu32i.d 'rd, 'xi20");
break;
case PCADDI:
Format(instr, "pcaddi 'rd, 'si20");
Format(instr, "pcaddi 'rd, 'xi20");
break;
case PCALAU12I:
Format(instr, "pcalau12i 'rd, 'si20");
Format(instr, "pcalau12i 'rd, 'xi20");
break;
case PCADDU12I:
Format(instr, "pcaddu12i 'rd, 'si20");
Format(instr, "pcaddu12i 'rd, 'xi20");
break;
case PCADDU18I:
Format(instr, "pcaddu18i 'rd, 'si20");
Format(instr, "pcaddu18i 'rd, 'xi20");
break;
default:
UNREACHABLE();
......@@ -727,7 +741,7 @@ void Decoder::DecodeTypekOp10(Instruction* instr) {
Format(instr, "addi.d 'rd, 'rj, 'si12");
break;
case LU52I_D:
Format(instr, "lu52i.d 'rd, 'rj, 'si12");
Format(instr, "lu52i.d 'rd, 'rj, 'xi12");
break;
case ANDI:
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