Skip to content

Commit 768d8f2

Browse files
committed
RuntimeLibcalls: Add call entries for sincos sleef and armpl libcalls
These are the tested set of libcalls used for codegen of llvm.sincos and are needed to get the legalization to follow standard procedure.
1 parent 821d282 commit 768d8f2

File tree

4 files changed

+67
-9
lines changed

4 files changed

+67
-9
lines changed

llvm/include/llvm/IR/RuntimeLibcalls.td

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ foreach FPTy = ["F32", "F64", "F80", "F128", "PPCF128"] in {
183183
}
184184

185185
foreach VecTy = ["V4F32", "V2F64", "NXV4F32", "NXV2F64"] in {
186+
def SINCOS_#VecTy : RuntimeLibcall;
186187
def SINCOSPI_#VecTy : RuntimeLibcall;
187188
}
188189

@@ -1092,6 +1093,11 @@ def __security_check_cookie_arm64ec : RuntimeLibcallImpl<SECURITY_CHECK_COOKIE,
10921093
//===----------------------------------------------------------------------===//
10931094

10941095
defset list<RuntimeLibcallImpl> SleefLibcalls = {
1096+
def _ZGVnN2vl8l8_sincos : RuntimeLibcallImpl<SINCOS_V2F64>;
1097+
def _ZGVnN4vl4l4_sincosf : RuntimeLibcallImpl<SINCOS_V4F32>;
1098+
def _ZGVsNxvl8l8_sincos : RuntimeLibcallImpl<SINCOS_NXV2F64>;
1099+
def _ZGVsNxvl4l4_sincosf : RuntimeLibcallImpl<SINCOS_NXV4F32>;
1100+
10951101
def _ZGVnN4vl4l4_sincospif : RuntimeLibcallImpl<SINCOSPI_V4F32>;
10961102
def _ZGVnN2vl8l8_sincospi : RuntimeLibcallImpl<SINCOSPI_V2F64>;
10971103
def _ZGVsNxvl4l4_sincospif : RuntimeLibcallImpl<SINCOSPI_NXV4F32>;
@@ -1103,6 +1109,13 @@ defset list<RuntimeLibcallImpl> SleefLibcalls = {
11031109
//===----------------------------------------------------------------------===//
11041110

11051111
defset list<RuntimeLibcallImpl> ARMPLLibcalls = {
1112+
def armpl_vsincosq_f64
1113+
: RuntimeLibcallImpl<SINCOS_V2F64>; // CallingConv::AArch64_VectorCall
1114+
def armpl_vsincosq_f32
1115+
: RuntimeLibcallImpl<SINCOS_V4F32>; // CallingConv::AArch64_VectorCall
1116+
def armpl_svsincos_f64_x : RuntimeLibcallImpl<SINCOS_NXV2F64>;
1117+
def armpl_svsincos_f32_x : RuntimeLibcallImpl<SINCOS_NXV4F32>;
1118+
11061119
def armpl_vsincospiq_f32 : RuntimeLibcallImpl<SINCOSPI_V4F32>;
11071120
def armpl_vsincospiq_f64 : RuntimeLibcallImpl<SINCOSPI_V2F64>;
11081121
def armpl_svsincospi_f32_x : RuntimeLibcallImpl<SINCOSPI_NXV4F32>;

llvm/lib/IR/RuntimeLibcalls.cpp

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,26 @@ RuntimeLibcallsInfo::RuntimeLibcallsInfo(const Triple &TT,
4343
switch (ClVectorLibrary) {
4444
case VectorLibrary::SLEEFGNUABI:
4545
for (RTLIB::LibcallImpl Impl :
46-
{RTLIB::impl__ZGVnN4vl4l4_sincospif, RTLIB::impl__ZGVnN2vl8l8_sincospi,
46+
{RTLIB::impl__ZGVnN2vl8l8_sincos, RTLIB::impl__ZGVnN4vl4l4_sincosf,
47+
RTLIB::impl__ZGVsNxvl8l8_sincos, RTLIB::impl__ZGVsNxvl4l4_sincosf,
48+
RTLIB::impl__ZGVnN4vl4l4_sincospif, RTLIB::impl__ZGVnN2vl8l8_sincospi,
4749
RTLIB::impl__ZGVsNxvl4l4_sincospif,
4850
RTLIB::impl__ZGVsNxvl8l8_sincospi})
4951
setAvailable(Impl);
5052
break;
5153
case VectorLibrary::ArmPL:
5254
for (RTLIB::LibcallImpl Impl :
53-
{RTLIB::impl_armpl_vsincospiq_f32, RTLIB::impl_armpl_vsincospiq_f64,
55+
{RTLIB::impl_armpl_vsincosq_f64, RTLIB::impl_armpl_vsincosq_f32,
56+
RTLIB::impl_armpl_svsincos_f64_x, RTLIB::impl_armpl_svsincos_f32_x,
57+
RTLIB::impl_armpl_vsincospiq_f32, RTLIB::impl_armpl_vsincospiq_f64,
5458
RTLIB::impl_armpl_svsincospi_f32_x,
5559
RTLIB::impl_armpl_svsincospi_f64_x})
5660
setAvailable(Impl);
61+
62+
for (RTLIB::LibcallImpl Impl :
63+
{RTLIB::impl_armpl_vsincosq_f64, RTLIB::impl_armpl_vsincosq_f32})
64+
setLibcallImplCallingConv(Impl, CallingConv::AArch64_VectorCall);
65+
5766
break;
5867
default:
5968
break;
@@ -188,6 +197,14 @@ RuntimeLibcallsInfo::getFunctionTy(LLVMContext &Ctx, const Triple &TT,
188197
fcNegNormal));
189198
return {FuncTy, Attrs};
190199
}
200+
case RTLIB::impl__ZGVnN2vl8l8_sincos:
201+
case RTLIB::impl__ZGVnN4vl4l4_sincosf:
202+
case RTLIB::impl__ZGVsNxvl8l8_sincos:
203+
case RTLIB::impl__ZGVsNxvl4l4_sincosf:
204+
case RTLIB::impl_armpl_vsincosq_f64:
205+
case RTLIB::impl_armpl_vsincosq_f32:
206+
case RTLIB::impl_armpl_svsincos_f64_x:
207+
case RTLIB::impl_armpl_svsincos_f32_x:
191208
case RTLIB::impl__ZGVnN4vl4l4_sincospif:
192209
case RTLIB::impl__ZGVnN2vl8l8_sincospi:
193210
case RTLIB::impl__ZGVsNxvl4l4_sincospif:
@@ -201,11 +218,20 @@ RuntimeLibcallsInfo::getFunctionTy(LLVMContext &Ctx, const Triple &TT,
201218
bool IsF32 = LibcallImpl == RTLIB::impl__ZGVnN4vl4l4_sincospif ||
202219
LibcallImpl == RTLIB::impl__ZGVsNxvl4l4_sincospif ||
203220
LibcallImpl == RTLIB::impl_armpl_vsincospiq_f32 ||
204-
LibcallImpl == RTLIB::impl_armpl_svsincospi_f32_x;
221+
LibcallImpl == RTLIB::impl_armpl_svsincospi_f32_x ||
222+
LibcallImpl == RTLIB::impl__ZGVnN4vl4l4_sincosf ||
223+
LibcallImpl == RTLIB::impl__ZGVsNxvl4l4_sincosf ||
224+
LibcallImpl == RTLIB::impl_armpl_vsincosq_f32 ||
225+
LibcallImpl == RTLIB::impl_armpl_svsincos_f32_x;
226+
205227
Type *ScalarTy = IsF32 ? Type::getFloatTy(Ctx) : Type::getDoubleTy(Ctx);
206228
unsigned EC = IsF32 ? 4 : 2;
207229

208-
bool IsScalable = LibcallImpl == RTLIB::impl__ZGVsNxvl4l4_sincospif ||
230+
bool IsScalable = LibcallImpl == RTLIB::impl__ZGVsNxvl8l8_sincos ||
231+
LibcallImpl == RTLIB::impl__ZGVsNxvl4l4_sincosf ||
232+
LibcallImpl == RTLIB::impl_armpl_svsincos_f32_x ||
233+
LibcallImpl == RTLIB::impl_armpl_svsincos_f64_x ||
234+
LibcallImpl == RTLIB::impl__ZGVsNxvl4l4_sincospif ||
209235
LibcallImpl == RTLIB::impl__ZGVsNxvl8l8_sincospi ||
210236
LibcallImpl == RTLIB::impl_armpl_svsincospi_f32_x ||
211237
LibcallImpl == RTLIB::impl_armpl_svsincospi_f64_x;
@@ -245,6 +271,8 @@ bool RuntimeLibcallsInfo::hasVectorMaskArgument(RTLIB::LibcallImpl Impl) {
245271
/// FIXME: This should be generated by tablegen and support the argument at an
246272
/// arbitrary position
247273
switch (Impl) {
274+
case RTLIB::impl_armpl_svsincos_f32_x:
275+
case RTLIB::impl_armpl_svsincos_f64_x:
248276
case RTLIB::impl_armpl_svsincospi_f32_x:
249277
case RTLIB::impl_armpl_svsincospi_f64_x:
250278
return true;
Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
; REQUIRES: aarch64-registered-target
22
; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=aarch64-unknown-linux -mattr=+neon,+sve -vector-library=ArmPL < %s | FileCheck %s
33

4-
; CHECK: declare void @armpl_svsincospi_f32_x(<vscale x 4 x float>, ptr noalias nonnull writeonly align 16, ptr noalias nonnull writeonly align 16, <vscale x 4 x i1>) [[ATTRS:#[0-9]+]]
4+
; CHECK: declare void @armpl_svsincos_f32_x(<vscale x 4 x float>, ptr noalias nonnull writeonly align 16, ptr noalias nonnull writeonly align 16, <vscale x 4 x i1>) [[ATTRS:#[0-9]+]]
55

6-
; CHECK: declare void @armpl_svsincospi_f64_x(<vscale x 2 x double>, ptr noalias nonnull writeonly align 16, ptr noalias nonnull writeonly align 16, <vscale x 2 x i1>) [[ATTRS:#[0-9]+]]
6+
; CHECK: declare void @armpl_svsincos_f64_x(<vscale x 2 x double>, ptr noalias nonnull writeonly align 16, ptr noalias nonnull writeonly align 16, <vscale x 2 x i1>) [[ATTRS]]
7+
8+
; CHECK: declare void @armpl_svsincospi_f32_x(<vscale x 4 x float>, ptr noalias nonnull writeonly align 16, ptr noalias nonnull writeonly align 16, <vscale x 4 x i1>) [[ATTRS]]
9+
10+
; CHECK: declare void @armpl_svsincospi_f64_x(<vscale x 2 x double>, ptr noalias nonnull writeonly align 16, ptr noalias nonnull writeonly align 16, <vscale x 2 x i1>) [[ATTRS]]
711

812
; CHECK: declare void @armpl_vsincospiq_f32(<4 x float>, ptr noalias nonnull writeonly align 16, ptr noalias nonnull writeonly align 16) [[ATTRS]]
913

1014
; CHECK: declare void @armpl_vsincospiq_f64(<2 x double>, ptr noalias nonnull writeonly align 16, ptr noalias nonnull writeonly align 16) [[ATTRS]]
1115

16+
; CHECK: declare aarch64_vector_pcs void @armpl_vsincosq_f32(<4 x float>, ptr noalias nonnull writeonly align 16, ptr noalias nonnull writeonly align 16) [[ATTRS]]
17+
18+
; CHECK: declare aarch64_vector_pcs void @armpl_vsincosq_f64(<2 x double>, ptr noalias nonnull writeonly align 16, ptr noalias nonnull writeonly align 16) [[ATTRS]]
19+
20+
1221
; CHECK: attributes [[ATTRS]] = { nocallback nofree nosync nounwind willreturn memory(argmem: write) }
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
; REQUIRES: aarch64-registered-target
22
; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=aarch64-unknown-linux -mattr=+neon,+sve -vector-library=sleefgnuabi < %s | FileCheck %s
33

4-
; CHECK: declare void @_ZGVnN2vl8l8_sincospi(<2 x double>, ptr noalias nonnull writeonly align 16, ptr noalias nonnull writeonly align 16) [[ATTRS:#[0-9]+]]
4+
; CHECK: declare void @_ZGVnN2vl8l8_sincos(<2 x double>, ptr noalias nonnull writeonly align 16, ptr noalias nonnull writeonly align 16) [[ATTRS:#[0-9]+]]
5+
6+
; CHECK: declare void @_ZGVnN2vl8l8_sincospi(<2 x double>, ptr noalias nonnull writeonly align 16, ptr noalias nonnull writeonly align 16) [[ATTRS]]
7+
8+
; CHECK: declare void @_ZGVnN4vl4l4_sincosf(<4 x float>, ptr noalias nonnull writeonly align 16, ptr noalias nonnull writeonly align 16) [[ATTRS]]
59

610
; CHECK: declare void @_ZGVnN4vl4l4_sincospif(<4 x float>, ptr noalias nonnull writeonly align 16, ptr noalias nonnull writeonly align 16) [[ATTRS]]
711

8-
; CHECK: declare void @_ZGVsNxvl4l4_sincospif(<vscale x 4 x float>, ptr noalias nonnull writeonly align 16, ptr noalias nonnull writeonly align 16) [[ATTRS:#[0-9]+]]
12+
; CHECK: declare void @_ZGVsNxvl4l4_sincosf(<vscale x 4 x float>, ptr noalias nonnull writeonly align 16, ptr noalias nonnull writeonly align 16) [[ATTRS]]
13+
14+
; CHECK: declare void @_ZGVsNxvl4l4_sincospif(<vscale x 4 x float>, ptr noalias nonnull writeonly align 16, ptr noalias nonnull writeonly align 16) [[ATTRS]]
15+
16+
; CHECK: declare void @_ZGVsNxvl8l8_sincos(<vscale x 2 x double>, ptr noalias nonnull writeonly align 16, ptr noalias nonnull writeonly align 16) [[ATTRS]]
917

10-
; CHECK: declare void @_ZGVsNxvl8l8_sincospi(<vscale x 2 x double>, ptr noalias nonnull writeonly align 16, ptr noalias nonnull writeonly align 16) [[ATTRS:#[0-9]+]]
18+
; CHECK: declare void @_ZGVsNxvl8l8_sincospi(<vscale x 2 x double>, ptr noalias nonnull writeonly align 16, ptr noalias nonnull writeonly align 16) [[ATTRS]]
1119

1220
; CHECK: attributes [[ATTRS]] = { nocallback nofree nosync nounwind willreturn memory(argmem: write) }

0 commit comments

Comments
 (0)