Skip to content

Commit ba47bc7

Browse files
[Clang][SVE2.1] Add pfalse builtin
As described in: ARM-software/acle#257 Patch by : Sander de Smalen<[email protected]> Reviewed By: dtemirbulatov Differential Revision: https://reviews.llvm.org/D151199
1 parent c122b97 commit ba47bc7

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

clang/include/clang/Basic/arm_sve.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1862,6 +1862,7 @@ def SVBGRP_N : SInst<"svbgrp[_n_{d}]", "dda", "UcUsUiUl", MergeNone, "aarch64_sv
18621862
let TargetGuard = "sve2p1" in {
18631863
def SVFCLAMP : SInst<"svclamp[_{d}]", "dddd", "hfd", MergeNone, "aarch64_sve_fclamp", [], []>;
18641864
def SVPTRUE_COUNT : SInst<"svptrue_{d}", "}v", "QcQsQiQl", MergeNone, "aarch64_sve_ptrue_{d}", [IsOverloadNone], []>;
1865+
def SVPFALSE_COUNT_ALIAS : SInst<"svpfalse_c", "}v", "", MergeNone, "", [IsOverloadNone]>;
18651866

18661867
def SVPEXT_SINGLE : SInst<"svpext_lane_{d}", "P}i", "QcQsQiQl", MergeNone, "aarch64_sve_pext", [], [ImmCheck<1, ImmCheck0_3>]>;
18671868
def SVPEXT_X2 : SInst<"svpext_lane_{d}_x2", "2.P}i", "QcQsQiQl", MergeNone, "aarch64_sve_pext_x2", [], [ImmCheck<1, ImmCheck0_1>]>;

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10160,6 +10160,13 @@ Value *CodeGenFunction::EmitAArch64SVEBuiltinExpr(unsigned BuiltinID,
1016010160
case SVE::BI__builtin_sve_svpfalse_b:
1016110161
return ConstantInt::getFalse(Ty);
1016210162

10163+
case SVE::BI__builtin_sve_svpfalse_c: {
10164+
auto SVBoolTy = ScalableVectorType::get(Builder.getInt1Ty(), 16);
10165+
Function *CastToSVCountF =
10166+
CGM.getIntrinsic(Intrinsic::aarch64_sve_convert_from_svbool, Ty);
10167+
return Builder.CreateCall(CastToSVCountF, ConstantInt::getFalse(SVBoolTy));
10168+
}
10169+
1016310170
case SVE::BI__builtin_sve_svlen_bf16:
1016410171
case SVE::BI__builtin_sve_svlen_f16:
1016510172
case SVE::BI__builtin_sve_svlen_f32:
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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 -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -passes=mem2reg,tailcallelim | FileCheck %s
4+
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2p1 -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - -x c++ %s | opt -S -passes=mem2reg,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK
5+
// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve2p1 -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -passes=mem2reg,tailcallelim | FileCheck %s
6+
// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve2p1 -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - -x c++ %s | opt -S -passes=mem2reg,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK
7+
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2p1 -S -disable-O0-optnone -Werror -Wall -o /dev/null %s
8+
#include <arm_sve.h>
9+
10+
#ifdef SVE_OVERLOADED_FORMS
11+
// A simple used,unused... macro, long enough to represent any SVE builtin.
12+
#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
13+
#else
14+
#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
15+
#endif
16+
17+
// CHECK-LABEL: @test_svpfalse_c(
18+
// CHECK-NEXT: entry:
19+
// CHECK-NEXT: [[TMP0:%.*]] = tail call target("aarch64.svcount") @llvm.aarch64.sve.convert.from.svbool.taarch64.svcountt(<vscale x 16 x i1> zeroinitializer)
20+
// CHECK-NEXT: ret target("aarch64.svcount") [[TMP0]]
21+
//
22+
// CPP-CHECK-LABEL: @_Z15test_svpfalse_cv(
23+
// CPP-CHECK-NEXT: entry:
24+
// CPP-CHECK-NEXT: [[TMP0:%.*]] = tail call target("aarch64.svcount") @llvm.aarch64.sve.convert.from.svbool.taarch64.svcountt(<vscale x 16 x i1> zeroinitializer)
25+
// CPP-CHECK-NEXT: ret target("aarch64.svcount") [[TMP0]]
26+
//
27+
svcount_t test_svpfalse_c()
28+
{
29+
return SVE_ACLE_FUNC(svpfalse_c,,,)();
30+
}

0 commit comments

Comments
 (0)