[RISCV] Support global address as inline asm memory operand of `m`
authorwangpc <wangpengcheng.pp@bytedance.com>
Mon, 21 Aug 2023 10:56:18 +0000 (18:56 +0800)
committerTobias Hieta <tobias@hieta.se>
Tue, 22 Aug 2023 05:49:21 +0000 (07:49 +0200)
commit8918f6911b7cf73e3fd51d29f73782c1e147088c
treefd788783abdf7a320ba337b52d8756417dac1972
parent8890f0fafc61d192f8773221b55697d2b15a8cbe
[RISCV] Support global address as inline asm memory operand of `m`

In D146245, we have supported lowering inline asm `m` with offset
to `register+imm`, but we didn't handle the case that the offset
is the low part of global address.

This patch will emit `%lo(g)` when `g` is a global address.

Fixes #64656

Reviewed By: asb

Differential Revision: https://reviews.llvm.org/D157839

(cherry picked from commit dc60003ec8b2faf595b528a39f64b697a589da06)
llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
llvm/test/CodeGen/RISCV/inline-asm-mem-constraint.ll