Skip to content

Commit 74ed1f2

Browse files
committed
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 ------------------------------------------------------------------------ llvm-svn: 369649
1 parent f3a5f23 commit 74ed1f2

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

clang/lib/Basic/Targets/RISCV.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ bool RISCVTargetInfo::validateAsmConstraint(
6060
// A floating-point register.
6161
Info.setAllowsRegister();
6262
return true;
63+
case 'A':
64+
// An address that is held in a general-purpose register.
65+
Info.setAllowsMemory();
66+
return true;
6367
}
6468
}
6569

clang/test/CodeGen/riscv-inline-asm.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,9 @@ void test_f() {
3838
// CHECK: call void asm sideeffect "", "f"(double [[FLT_ARG]])
3939
asm volatile ("" :: "f"(d));
4040
}
41+
42+
void test_A(int *p) {
43+
// CHECK-LABEL: define void @test_A(i32* %p)
44+
// CHECK: call void asm sideeffect "", "*A"(i32* %p)
45+
asm volatile("" :: "A"(*p));
46+
}

0 commit comments

Comments
 (0)