[all-commits] [llvm/llvm-project] 10a55c: [RISCV] Support constraint "s" (#80201)

Fangrui Song via All-commits all-commits at lists.llvm.org
Thu Feb 1 10:18:53 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 10a55caccf4e2d397f94c1455b93d774591be45f
      https://github.com/llvm/llvm-project/commit/10a55caccf4e2d397f94c1455b93d774591be45f
  Author: Fangrui Song <i at maskray.me>
  Date:   2024-02-01 (Thu, 01 Feb 2024)

  Changed paths:
    M clang/lib/Basic/Targets/RISCV.cpp
    M clang/test/CodeGen/RISCV/riscv-inline-asm.c
    M clang/test/Sema/inline-asm-validate-riscv.c
    M llvm/docs/LangRef.rst
    M llvm/lib/Target/RISCV/RISCVISelLowering.cpp
    R llvm/test/CodeGen/RISCV/inline-asm-S-constraint.ll
    A llvm/test/CodeGen/RISCV/inline-asm-s-constraint-error.ll
    A llvm/test/CodeGen/RISCV/inline-asm-s-constraint.ll

  Log Message:
  -----------
  [RISCV] Support constraint "s" (#80201)

GCC has supported a generic constraint "s" for a long time (since at
least 1992), which references a symbol or label with an optional
constant offset. "i" is a superset that also supports a constant
integer.

GCC's RISC-V port also supports a machine-specific constraint "S",
which cannot be used with a preemptible symbol. (We don't bother to
check preemptibility.) In PIC code, an external symbol is preemptible by
default, making "S" less useful if you want to create an artificial
reference for linker garbage collection, or define sections to hold
symbol addresses:

```
void fun();
// error: impossible constraint in ‘asm’ for riscv64-linux-gnu-gcc -fpie/-fpic
void foo() { asm(".reloc ., BFD_RELOC_NONE, %0" :: "S"(fun)); }
// good even if -fpie/-fpic
void foo() { asm(".reloc ., BFD_RELOC_NONE, %0" :: "s"(fun)); }
```

This patch adds support for "s". Modify https://reviews.llvm.org/D105254
("S") to handle multi-depth GEPs (https://reviews.llvm.org/D61560).




More information about the All-commits mailing list