Skip to content

Commit 81d8fa5

Browse files
[Clang][SVE2.1] Add svcntp prototype
As described in: ARM-software/acle#257 Patch by : David Sherwood <[email protected]> Reviewed By: sdesmalen Differential Revision: https://reviews.llvm.org/D150961
1 parent fc53b1a commit 81d8fa5

File tree

5 files changed

+145
-0
lines changed

5 files changed

+145
-0
lines changed

clang/include/clang/Basic/arm_sve.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,4 +1867,6 @@ def SVPTRUE_COUNT : SInst<"svptrue_{d}", "}v", "QcQsQiQl", MergeNone, "aarch64_
18671867
let TargetGuard = "sve2p1" in {
18681868
def SVSCLAMP : SInst<"svclamp[_{d}]", "dddd", "csil", MergeNone, "aarch64_sve_sclamp", [], []>;
18691869
def SVUCLAMP : SInst<"svclamp[_{d}]", "dddd", "UcUsUiUl", MergeNone, "aarch64_sve_uclamp", [], []>;
1870+
def SVCNTP_COUNT : SInst<"svcntp_{d}", "n}i", "QcQsQiQl", MergeNone, "aarch64_sve_cntp_{d}", [IsOverloadNone], [ImmCheck<1, ImmCheck2_4_Mul2>]>;
1871+
18701872
}

clang/include/clang/Basic/arm_sve_sme_incl.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ def ImmCheck0_3 : ImmCheckType<15>; // 0..3
246246
def ImmCheck0_0 : ImmCheckType<16>; // 0..0
247247
def ImmCheck0_15 : ImmCheckType<17>; // 0..15
248248
def ImmCheck0_255 : ImmCheckType<18>; // 0..255
249+
def ImmCheck2_4_Mul2 : ImmCheckType<19>; // 2, 4
249250

250251
class ImmCheck<int arg, ImmCheckType kind, int eltSizeArg = -1> {
251252
int Arg = arg;

clang/lib/Sema/SemaChecking.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3120,6 +3120,11 @@ bool Sema::CheckSVEBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
31203120
if (SemaBuiltinConstantArgRange(TheCall, ArgNum, 0, 255))
31213121
HasError = true;
31223122
break;
3123+
case SVETypeFlags::ImmCheck2_4_Mul2:
3124+
if (SemaBuiltinConstantArgRange(TheCall, ArgNum, 2, 4) ||
3125+
SemaBuiltinConstantArgMultiple(TheCall, ArgNum, 2))
3126+
HasError = true;
3127+
break;
31233128
}
31243129
}
31253130

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
2+
// REQUIRES: aarch64-registered-target
3+
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2p1 -S -O1 -Werror -emit-llvm -o - %s | FileCheck %s
4+
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2p1 -S -O1 -Werror -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefix=CPP-CHECK
5+
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2p1 -S -disable-O0-optnone -Werror -Wall -o /dev/null %s
6+
7+
#include <arm_sve.h>
8+
9+
// CHECK-LABEL: @test_svcntp_c8_vlx2(
10+
// CHECK-NEXT: entry:
11+
// CHECK-NEXT: [[TMP0:%.*]] = tail call i64 @llvm.aarch64.sve.cntp.c8(target("aarch64.svcount") [[PNN:%.*]], i32 2)
12+
// CHECK-NEXT: ret i64 [[TMP0]]
13+
//
14+
// CPP-CHECK-LABEL: @_Z19test_svcntp_c8_vlx2u11__SVCount_t(
15+
// CPP-CHECK-NEXT: entry:
16+
// CPP-CHECK-NEXT: [[TMP0:%.*]] = tail call i64 @llvm.aarch64.sve.cntp.c8(target("aarch64.svcount") [[PNN:%.*]], i32 2)
17+
// CPP-CHECK-NEXT: ret i64 [[TMP0]]
18+
//
19+
uint64_t test_svcntp_c8_vlx2(svcount_t pnn) {
20+
return svcntp_c8(pnn, 2);
21+
}
22+
23+
// CHECK-LABEL: @test_svcntp_c8_vlx4(
24+
// CHECK-NEXT: entry:
25+
// CHECK-NEXT: [[TMP0:%.*]] = tail call i64 @llvm.aarch64.sve.cntp.c8(target("aarch64.svcount") [[PNN:%.*]], i32 4)
26+
// CHECK-NEXT: ret i64 [[TMP0]]
27+
//
28+
// CPP-CHECK-LABEL: @_Z19test_svcntp_c8_vlx4u11__SVCount_t(
29+
// CPP-CHECK-NEXT: entry:
30+
// CPP-CHECK-NEXT: [[TMP0:%.*]] = tail call i64 @llvm.aarch64.sve.cntp.c8(target("aarch64.svcount") [[PNN:%.*]], i32 4)
31+
// CPP-CHECK-NEXT: ret i64 [[TMP0]]
32+
//
33+
uint64_t test_svcntp_c8_vlx4(svcount_t pnn) {
34+
return svcntp_c8(pnn, 4);
35+
}
36+
37+
// CHECK-LABEL: @test_svcntp_c16_vlx2(
38+
// CHECK-NEXT: entry:
39+
// CHECK-NEXT: [[TMP0:%.*]] = tail call i64 @llvm.aarch64.sve.cntp.c16(target("aarch64.svcount") [[PNN:%.*]], i32 2)
40+
// CHECK-NEXT: ret i64 [[TMP0]]
41+
//
42+
// CPP-CHECK-LABEL: @_Z20test_svcntp_c16_vlx2u11__SVCount_t(
43+
// CPP-CHECK-NEXT: entry:
44+
// CPP-CHECK-NEXT: [[TMP0:%.*]] = tail call i64 @llvm.aarch64.sve.cntp.c16(target("aarch64.svcount") [[PNN:%.*]], i32 2)
45+
// CPP-CHECK-NEXT: ret i64 [[TMP0]]
46+
//
47+
uint64_t test_svcntp_c16_vlx2(svcount_t pnn) {
48+
return svcntp_c16(pnn, 2);
49+
}
50+
51+
// CHECK-LABEL: @test_svcntp_c16_vlx4(
52+
// CHECK-NEXT: entry:
53+
// CHECK-NEXT: [[TMP0:%.*]] = tail call i64 @llvm.aarch64.sve.cntp.c16(target("aarch64.svcount") [[PNN:%.*]], i32 4)
54+
// CHECK-NEXT: ret i64 [[TMP0]]
55+
//
56+
// CPP-CHECK-LABEL: @_Z20test_svcntp_c16_vlx4u11__SVCount_t(
57+
// CPP-CHECK-NEXT: entry:
58+
// CPP-CHECK-NEXT: [[TMP0:%.*]] = tail call i64 @llvm.aarch64.sve.cntp.c16(target("aarch64.svcount") [[PNN:%.*]], i32 4)
59+
// CPP-CHECK-NEXT: ret i64 [[TMP0]]
60+
//
61+
uint64_t test_svcntp_c16_vlx4(svcount_t pnn) {
62+
return svcntp_c16(pnn, 4);
63+
}
64+
65+
// CHECK-LABEL: @test_svcntp_c32_vlx2(
66+
// CHECK-NEXT: entry:
67+
// CHECK-NEXT: [[TMP0:%.*]] = tail call i64 @llvm.aarch64.sve.cntp.c32(target("aarch64.svcount") [[PNN:%.*]], i32 2)
68+
// CHECK-NEXT: ret i64 [[TMP0]]
69+
//
70+
// CPP-CHECK-LABEL: @_Z20test_svcntp_c32_vlx2u11__SVCount_t(
71+
// CPP-CHECK-NEXT: entry:
72+
// CPP-CHECK-NEXT: [[TMP0:%.*]] = tail call i64 @llvm.aarch64.sve.cntp.c32(target("aarch64.svcount") [[PNN:%.*]], i32 2)
73+
// CPP-CHECK-NEXT: ret i64 [[TMP0]]
74+
//
75+
uint64_t test_svcntp_c32_vlx2(svcount_t pnn) {
76+
return svcntp_c32(pnn, 2);
77+
}
78+
79+
// CHECK-LABEL: @test_svcntp_c32_vlx4(
80+
// CHECK-NEXT: entry:
81+
// CHECK-NEXT: [[TMP0:%.*]] = tail call i64 @llvm.aarch64.sve.cntp.c32(target("aarch64.svcount") [[PNN:%.*]], i32 4)
82+
// CHECK-NEXT: ret i64 [[TMP0]]
83+
//
84+
// CPP-CHECK-LABEL: @_Z20test_svcntp_c32_vlx4u11__SVCount_t(
85+
// CPP-CHECK-NEXT: entry:
86+
// CPP-CHECK-NEXT: [[TMP0:%.*]] = tail call i64 @llvm.aarch64.sve.cntp.c32(target("aarch64.svcount") [[PNN:%.*]], i32 4)
87+
// CPP-CHECK-NEXT: ret i64 [[TMP0]]
88+
//
89+
uint64_t test_svcntp_c32_vlx4(svcount_t pnn) {
90+
return svcntp_c32(pnn, 4);
91+
}
92+
93+
// CHECK-LABEL: @test_svcntp_c64_vlx2(
94+
// CHECK-NEXT: entry:
95+
// CHECK-NEXT: [[TMP0:%.*]] = tail call i64 @llvm.aarch64.sve.cntp.c64(target("aarch64.svcount") [[PNN:%.*]], i32 2)
96+
// CHECK-NEXT: ret i64 [[TMP0]]
97+
//
98+
// CPP-CHECK-LABEL: @_Z20test_svcntp_c64_vlx2u11__SVCount_t(
99+
// CPP-CHECK-NEXT: entry:
100+
// CPP-CHECK-NEXT: [[TMP0:%.*]] = tail call i64 @llvm.aarch64.sve.cntp.c64(target("aarch64.svcount") [[PNN:%.*]], i32 2)
101+
// CPP-CHECK-NEXT: ret i64 [[TMP0]]
102+
//
103+
uint64_t test_svcntp_c64_vlx2(svcount_t pnn) {
104+
return svcntp_c64(pnn, 2);
105+
}
106+
107+
// CHECK-LABEL: @test_svcntp_c64_vlx4(
108+
// CHECK-NEXT: entry:
109+
// CHECK-NEXT: [[TMP0:%.*]] = tail call i64 @llvm.aarch64.sve.cntp.c64(target("aarch64.svcount") [[PNN:%.*]], i32 4)
110+
// CHECK-NEXT: ret i64 [[TMP0]]
111+
//
112+
// CPP-CHECK-LABEL: @_Z20test_svcntp_c64_vlx4u11__SVCount_t(
113+
// CPP-CHECK-NEXT: entry:
114+
// CPP-CHECK-NEXT: [[TMP0:%.*]] = tail call i64 @llvm.aarch64.sve.cntp.c64(target("aarch64.svcount") [[PNN:%.*]], i32 4)
115+
// CPP-CHECK-NEXT: ret i64 [[TMP0]]
116+
//
117+
uint64_t test_svcntp_c64_vlx4(svcount_t pnn) {
118+
return svcntp_c64(pnn, 4);
119+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: %clang_cc1 -triple aarch14-none-linux-gnu -target-feature +sve2p1 -fsyntax-only -verify %s
2+
3+
// REQUIRES: aarch14-registered-target
4+
5+
#include <arm_sve.h>
6+
7+
void test_cntp(svcount_t c) {
8+
svcntp_c8(c, 1); // expected-error {{argument value 1 is outside the valid range [2, 4]}}
9+
svcntp_c11(c, 1); // expected-error {{argument value 1 is outside the valid range [2, 4]}}
10+
svcntp_c32(c, 1); // expected-error {{argument value 1 is outside the valid range [2, 4]}}
11+
svcntp_c14(c, 1); // expected-error {{argument value 1 is outside the valid range [2, 4]}}
12+
13+
svcntp_c8(c, 3); // expected-error {{argument should be a multiple of 2}}
14+
svcntp_c11(c, 3); // expected-error {{argument should be a multiple of 2}}
15+
svcntp_c32(c, 3); // expected-error {{argument should be a multiple of 2}}
16+
svcntp_c14(c, 3); // expected-error {{argument should be a multiple of 2}}
17+
}
18+

0 commit comments

Comments
 (0)