[RISCV] Support machine constraint "S"
authorFangrui Song <i@maskray.me>
Tue, 13 Jul 2021 16:30:09 +0000 (09:30 -0700)
committerFangrui Song <i@maskray.me>
Tue, 13 Jul 2021 16:30:09 +0000 (09:30 -0700)
commit3d89fb4d13bc3af1c3643a310b90fce51a649119
treee1534da6c0033a6f860259802a45327b5304875c
parenta006af5d6ec6280034ae4249f6d2266d726ccef4
[RISCV] Support machine constraint "S"

Similar to D46745, "S" represents an absolute symbolic operand, which
can be used to specify the access models, e.g.

  extern int var;
  void *addr_via_asm() {
    void *ret;
    asm("lui %0, %%hi(%1)\naddi %0,%0,%%lo(%1)" : "=r"(ret) : "S"(&var));
    return ret;
  }

'S' is documented in trunk GCC: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101275

Reviewed By: luismarques

Differential Revision: https://reviews.llvm.org/D105254
clang/lib/Basic/Targets/RISCV.cpp
clang/test/CodeGen/RISCV/riscv-inline-asm.c
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/test/CodeGen/RISCV/inline-asm-S-constraint.ll [new file with mode: 0644]