From f7e811b756b92a3636e1a4e940df4817a212e321 Mon Sep 17 00:00:00 2001 From: Lixuanwang Date: Mon, 21 Jul 2025 14:44:48 +0800 Subject: [PATCH] =?UTF-8?q?[backend]=E8=A7=A3=E5=86=B3=E4=BA=86=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E6=89=93=E5=8D=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/RISCv64AsmPrinter.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/RISCv64AsmPrinter.cpp b/src/RISCv64AsmPrinter.cpp index 0ad1c81..47e9773 100644 --- a/src/RISCv64AsmPrinter.cpp +++ b/src/RISCv64AsmPrinter.cpp @@ -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: