Skip to content

Commit 3017545

Browse files
authored
[RISCV] Fix inline asm error for block address (#66640)
After commit cedf2ea, `RISCVMergeBaseOffset` can handle `BlockAddress` currently. But we didn't handle it in `PrintAsmMemoryOperand` so we get `invalid operand in inline asm` error. This patch fixes the error.
1 parent 6a1cf54 commit 3017545

File tree

2 files changed

+418
-98
lines changed

2 files changed

+418
-98
lines changed

llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ bool RISCVAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
236236
// RISCVDAGToDAGISel::SelectInlineAsmMemoryOperand).
237237
if (!AddrReg.isReg())
238238
return true;
239-
if (!Offset.isImm() && !Offset.isGlobal())
239+
if (!Offset.isImm() && !Offset.isGlobal() && !Offset.isBlockAddress())
240240
return true;
241241

242242
MCOperand MCO;
@@ -245,7 +245,7 @@ bool RISCVAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
245245

246246
if (Offset.isImm())
247247
OS << MCO.getImm();
248-
else if (Offset.isGlobal())
248+
else if (Offset.isGlobal() || Offset.isBlockAddress())
249249
OS << *MCO.getExpr();
250250
OS << "(" << RISCVInstPrinter::getRegisterName(AddrReg.getReg()) << ")";
251251
return false;

0 commit comments

Comments
 (0)