[backend]解决了标签打印问题

This commit is contained in:
Lixuanwang
2025-07-21 14:44:48 +08:00
parent 80dee78f04
commit f7e811b756

View File

@@ -87,10 +87,17 @@ void RISCv64AsmPrinter::printInstruction(MachineInstr* instr) {
if (opcode == RVOpcodes::RET) {
printEpilogue();
}
if (opcode != RVOpcodes::LABEL) {
*OS << " ";
if (opcode == RVOpcodes::LABEL) {
// 标签直接打印,不加缩进
printOperand(instr->getOperands()[0].get());
*OS << ":\n";
return; // 处理完毕,直接返回
}
// 对于所有非标签指令,先打印缩进
*OS << " ";
switch (opcode) {
case RVOpcodes::ADD: *OS << "add "; break; case RVOpcodes::ADDI: *OS << "addi "; break;
case RVOpcodes::ADDW: *OS << "addw "; break; case RVOpcodes::ADDIW: *OS << "addiw "; break;
@@ -126,8 +133,8 @@ void RISCv64AsmPrinter::printInstruction(MachineInstr* instr) {
case RVOpcodes::SNEZ: *OS << "snez "; break;
case RVOpcodes::CALL: *OS << "call "; break;
case RVOpcodes::LABEL:
printOperand(instr->getOperands()[0].get());
*OS << ":";
// printOperand(instr->getOperands()[0].get());
// *OS << ":";
break;
case RVOpcodes::FRAME_LOAD:
case RVOpcodes::FRAME_STORE: