Skip to content

Commit 4cf11d8

Browse files
committed
[Clang][SVE] Permit specific predicate-as-counter registers in inline assembly
This patch adds the predicate-as-counter registers pn0-pn15 to the list of supported registers used when writing inline assembly. Tests added to clang/test/CodeGen/aarch64-sve-inline-asm.c Differential Revision: https://reviews.llvm.org/D156115
1 parent 86da763 commit 4cf11d8

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

clang/lib/Basic/Targets/AArch64.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,11 @@ const char *const AArch64TargetInfo::GCCRegNames[] = {
11641164

11651165
// SVE predicate registers
11661166
"p0", "p1", "p2", "p3", "p4", "p5", "p6", "p7", "p8", "p9", "p10",
1167-
"p11", "p12", "p13", "p14", "p15"
1167+
"p11", "p12", "p13", "p14", "p15",
1168+
1169+
// SVE predicate-as-counter registers
1170+
"pn0", "pn1", "pn2", "pn3", "pn4", "pn5", "pn6", "pn7", "pn8",
1171+
"pn9", "pn10", "pn11", "pn12", "pn13", "pn14", "pn15"
11681172
};
11691173

11701174
ArrayRef<const char *> AArch64TargetInfo::getGCCRegNames() const {

clang/test/CodeGen/aarch64-sve-inline-asm.c

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK
1+
// REQUIRES: aarch64-registered-target
2+
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +sve2p1 \
3+
// RUN: -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK
4+
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +sve2p1 \
5+
// RUN: -S -o /dev/null
26

37
void test_sve_asm(void) {
48
asm volatile(
@@ -9,5 +13,16 @@ void test_sve_asm(void) {
913
:
1014
:
1115
: "z0", "z31", "p0", "p15");
16+
// CHECK-LABEL: @test_sve_asm
1217
// CHECK: "~{z0},~{z31},~{p0},~{p15}"
1318
}
19+
20+
void test_sve2p1_asm(void) {
21+
asm("pfalse pn0.b\n"
22+
"ptrue pn8.d\n"
23+
"ptrue pn15.b\n"
24+
"pext p3.b, pn8[1]\n"
25+
::: "pn0", "pn8", "pn15", "p3");
26+
// CHECK-LABEL: @test_sve2p1_asm
27+
// CHECK: "~{pn0},~{pn8},~{pn15},~{p3}"
28+
}

0 commit comments

Comments
 (0)