
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).
15 lines
476 B
LLVM
15 lines
476 B
LLVM
; RUN: not llc -mtriple=riscv64 < %s 2>&1 | FileCheck %s
|
|
|
|
@a = external global [4 x i32], align 16
|
|
|
|
; CHECK-COUNT-2: error: invalid operand for inline asm constraint 's'
|
|
; CHECK-NOT: error:
|
|
define void @test(i64 %i) {
|
|
entry:
|
|
%x = alloca i32, align 4
|
|
%ai = getelementptr inbounds [4 x i32], ptr @a, i64 0, i64 %i
|
|
call void asm sideeffect "", "s,~{dirflag},~{fpsr},~{flags}"(ptr %x)
|
|
call void asm sideeffect "", "s,~{dirflag},~{fpsr},~{flags}"(ptr %ai)
|
|
ret void
|
|
}
|