]> granicus.if.org Git - clang/commitdiff
[RISCV] Add inline asm constraint A for RISC-V
authorLewis Revill <lewis.revill@embecosm.com>
Fri, 16 Aug 2019 10:23:56 +0000 (10:23 +0000)
committerLewis Revill <lewis.revill@embecosm.com>
Fri, 16 Aug 2019 10:23:56 +0000 (10:23 +0000)
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/trunk@369093 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/Targets/RISCV.cpp
test/CodeGen/riscv-inline-asm.c

index a634ba69f3cd3b342a6550b08993b5efc751d6cd..d1166d90df482a7f663be390b21495f6762db641 100644 (file)
@@ -75,6 +75,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;
   }
 }
 
index f79527337bdfb4520f2c7cead3f621b7260a1912..2c92d15ca90acfe22771a758ccb912257f421bf5 100644 (file)
@@ -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));
+}