From: Hans Wennborg Date: Thu, 22 Aug 2019 13:42:47 +0000 (+0000) Subject: Merging r369093: X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f5f572092ba9b9ac944aebc4000f8bcae0448b71;p=clang Merging r369093: ------------------------------------------------------------------------ r369093 | lewis-revill | 2019-08-16 12:23:56 +0200 (Fri, 16 Aug 2019) | 11 lines [RISCV] Add inline asm constraint A for RISC-V This allows the constraint A to be used in inline asm for RISC-V, which allows an address held in a register to be used. This patch adds the minimal amount of code required to get operands with the right constraints to compile. Differential Revision: https://reviews.llvm.org/D54295 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_90@369649 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Basic/Targets/RISCV.cpp b/lib/Basic/Targets/RISCV.cpp index 939ac46d67..930b825e94 100644 --- a/lib/Basic/Targets/RISCV.cpp +++ b/lib/Basic/Targets/RISCV.cpp @@ -60,6 +60,10 @@ bool RISCVTargetInfo::validateAsmConstraint( // A floating-point register. Info.setAllowsRegister(); return true; + case 'A': + // An address that is held in a general-purpose register. + Info.setAllowsMemory(); + return true; } } diff --git a/test/CodeGen/riscv-inline-asm.c b/test/CodeGen/riscv-inline-asm.c index f79527337b..2c92d15ca9 100644 --- a/test/CodeGen/riscv-inline-asm.c +++ b/test/CodeGen/riscv-inline-asm.c @@ -38,3 +38,9 @@ void test_f() { // CHECK: call void asm sideeffect "", "f"(double [[FLT_ARG]]) asm volatile ("" :: "f"(d)); } + +void test_A(int *p) { +// CHECK-LABEL: define void @test_A(i32* %p) +// CHECK: call void asm sideeffect "", "*A"(i32* %p) + asm volatile("" :: "A"(*p)); +}