aboutsummaryrefslogtreecommitdiff
path: root/llvm/docs/LangRef.rst
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2024-02-01 10:18:42 -0800
committerGitHub <noreply@github.com>2024-02-01 10:18:42 -0800
commit10a55caccf4e2d397f94c1455b93d774591be45f (patch)
tree390d47c551513f21d8c0fdfb71c237993534739d /llvm/docs/LangRef.rst
parent6a3fde6d600cccd2ffbede6dd54519036cc4089c (diff)
downloadllvm-10a55caccf4e2d397f94c1455b93d774591be45f.zip
llvm-10a55caccf4e2d397f94c1455b93d774591be45f.tar.gz
llvm-10a55caccf4e2d397f94c1455b93d774591be45f.tar.bz2
[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).
Diffstat (limited to 'llvm/docs/LangRef.rst')
-rw-r--r--llvm/docs/LangRef.rst3
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 7a7ddc5..3648ea2 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -5075,7 +5075,7 @@ Some constraint codes are typically supported by all targets:
- ``i``: An integer constant (of target-specific width). Allows either a simple
immediate, or a relocatable value.
- ``n``: An integer constant -- *not* including relocatable values.
-- ``s``: An integer constant, but allowing *only* relocatable values.
+- ``s``: A symbol or label reference with a constant offset.
- ``X``: Allows an operand of any kind, no constraint whatsoever. Typically
useful to pass a label for an asm branch or call.
@@ -5283,6 +5283,7 @@ RISC-V:
- ``f``: A 32- or 64-bit floating-point register (requires F or D extension).
- ``r``: A 32- or 64-bit general-purpose register (depending on the platform
``XLEN``).
+- ``S``: Alias for ``s``.
- ``vr``: A vector register. (requires V extension).
- ``vm``: A vector register for masking operand. (requires V extension).