forked from OSchip/llvm-project
[Clang,Driver] Add -fveclib=Darwin_libsystem_m support.
Support for Darwin's libsystem_m's vector functions has been added to
LLVM in 93a9a8a8d9
.
This patch adds support for -fveclib=Darwin_libsystem_m to Clang.
Reviewed By: arphaman
Differential Revision: https://reviews.llvm.org/D102489
This commit is contained in:
parent
5e289cc597
commit
187a14e1f3
|
@ -55,11 +55,12 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
enum VectorLibrary {
|
enum VectorLibrary {
|
||||||
NoLibrary, // Don't use any vector library.
|
NoLibrary, // Don't use any vector library.
|
||||||
Accelerate, // Use the Accelerate framework.
|
Accelerate, // Use the Accelerate framework.
|
||||||
LIBMVEC, // GLIBC vector math library.
|
LIBMVEC, // GLIBC vector math library.
|
||||||
MASSV, // IBM MASS vector library.
|
MASSV, // IBM MASS vector library.
|
||||||
SVML // Intel short vector math library.
|
SVML, // Intel short vector math library.
|
||||||
|
Darwin_libsystem_m // Use Darwin's libsytem_m vector functions.
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ObjCDispatchMethodKind {
|
enum ObjCDispatchMethodKind {
|
||||||
|
|
|
@ -2171,9 +2171,10 @@ def fno_experimental_isel : Flag<["-"], "fno-experimental-isel">, Group<f_clang_
|
||||||
Alias<fno_global_isel>;
|
Alias<fno_global_isel>;
|
||||||
def fveclib : Joined<["-"], "fveclib=">, Group<f_Group>, Flags<[CC1Option]>,
|
def fveclib : Joined<["-"], "fveclib=">, Group<f_Group>, Flags<[CC1Option]>,
|
||||||
HelpText<"Use the given vector functions library">,
|
HelpText<"Use the given vector functions library">,
|
||||||
Values<"Accelerate,libmvec,MASSV,SVML,none">,
|
Values<"Accelerate,libmvec,MASSV,SVML,Darwin_libsystem_m,none">,
|
||||||
NormalizedValuesScope<"CodeGenOptions">,
|
NormalizedValuesScope<"CodeGenOptions">,
|
||||||
NormalizedValues<["Accelerate", "LIBMVEC", "MASSV", "SVML", "NoLibrary"]>,
|
NormalizedValues<["Accelerate", "LIBMVEC", "MASSV", "SVML",
|
||||||
|
"Darwin_libsystem_m", "NoLibrary"]>,
|
||||||
MarshallingInfoEnum<CodeGenOpts<"VecLib">, "NoLibrary">;
|
MarshallingInfoEnum<CodeGenOpts<"VecLib">, "NoLibrary">;
|
||||||
def fno_lax_vector_conversions : Flag<["-"], "fno-lax-vector-conversions">, Group<f_Group>,
|
def fno_lax_vector_conversions : Flag<["-"], "fno-lax-vector-conversions">, Group<f_Group>,
|
||||||
Alias<flax_vector_conversions_EQ>, AliasArgs<["none"]>;
|
Alias<flax_vector_conversions_EQ>, AliasArgs<["none"]>;
|
||||||
|
|
|
@ -402,6 +402,10 @@ static TargetLibraryInfoImpl *createTLII(llvm::Triple &TargetTriple,
|
||||||
case CodeGenOptions::SVML:
|
case CodeGenOptions::SVML:
|
||||||
TLII->addVectorizableFunctionsFromVecLib(TargetLibraryInfoImpl::SVML);
|
TLII->addVectorizableFunctionsFromVecLib(TargetLibraryInfoImpl::SVML);
|
||||||
break;
|
break;
|
||||||
|
case CodeGenOptions::Darwin_libsystem_m:
|
||||||
|
TLII->addVectorizableFunctionsFromVecLib(
|
||||||
|
TargetLibraryInfoImpl::DarwinLibSystemM);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
// RUN: %clang_cc1 -fveclib=Darwin_libsystem_m -triple arm64-apple-darwin %s -target-cpu apple-a7 -vectorize-loops -emit-llvm -O3 -o - | FileCheck %s
|
||||||
|
|
||||||
|
// Make sure -fveclib=Darwin_libsystem_m gets passed through to LLVM as
|
||||||
|
// expected: a call to _simd_sin_f4 should be generated.
|
||||||
|
|
||||||
|
extern float sinf(float);
|
||||||
|
|
||||||
|
// CHECK-LABEL: define{{.*}}@apply_sin
|
||||||
|
// CHECK: call <4 x float> @_simd_sin_f4(
|
||||||
|
//
|
||||||
|
void apply_sin(float *A, float *B, float *C, unsigned N) {
|
||||||
|
for (unsigned i = 0; i < N; i++)
|
||||||
|
C[i] = sinf(A[i]) + sinf(B[i]);
|
||||||
|
}
|
|
@ -76,6 +76,7 @@
|
||||||
// FLTOALL-NEXT: thin
|
// FLTOALL-NEXT: thin
|
||||||
// RUN: %clang --autocomplete=-fveclib= | FileCheck %s -check-prefix=FVECLIBALL
|
// RUN: %clang --autocomplete=-fveclib= | FileCheck %s -check-prefix=FVECLIBALL
|
||||||
// FVECLIBALL: Accelerate
|
// FVECLIBALL: Accelerate
|
||||||
|
// FVECLIBALL-NEXT: Darwin_libsystem_m
|
||||||
// FVECLIBALL-NEXT: libmvec
|
// FVECLIBALL-NEXT: libmvec
|
||||||
// FVECLIBALL-NEXT: MASSV
|
// FVECLIBALL-NEXT: MASSV
|
||||||
// FVECLIBALL-NEXT: none
|
// FVECLIBALL-NEXT: none
|
||||||
|
|
|
@ -2,12 +2,14 @@
|
||||||
// RUN: %clang -### -c -fveclib=Accelerate %s 2>&1 | FileCheck -check-prefix CHECK-ACCELERATE %s
|
// RUN: %clang -### -c -fveclib=Accelerate %s 2>&1 | FileCheck -check-prefix CHECK-ACCELERATE %s
|
||||||
// RUN: %clang -### -c -fveclib=libmvec %s 2>&1 | FileCheck -check-prefix CHECK-libmvec %s
|
// RUN: %clang -### -c -fveclib=libmvec %s 2>&1 | FileCheck -check-prefix CHECK-libmvec %s
|
||||||
// RUN: %clang -### -c -fveclib=MASSV %s 2>&1 | FileCheck -check-prefix CHECK-MASSV %s
|
// RUN: %clang -### -c -fveclib=MASSV %s 2>&1 | FileCheck -check-prefix CHECK-MASSV %s
|
||||||
|
// RUN: %clang -### -c -fveclib=Darwin_libsystem_m %s 2>&1 | FileCheck -check-prefix CHECK-DARWIN_LIBSYSTEM_M %s
|
||||||
// RUN: not %clang -c -fveclib=something %s 2>&1 | FileCheck -check-prefix CHECK-INVALID %s
|
// RUN: not %clang -c -fveclib=something %s 2>&1 | FileCheck -check-prefix CHECK-INVALID %s
|
||||||
|
|
||||||
// CHECK-NOLIB: "-fveclib=none"
|
// CHECK-NOLIB: "-fveclib=none"
|
||||||
// CHECK-ACCELERATE: "-fveclib=Accelerate"
|
// CHECK-ACCELERATE: "-fveclib=Accelerate"
|
||||||
// CHECK-libmvec: "-fveclib=libmvec"
|
// CHECK-libmvec: "-fveclib=libmvec"
|
||||||
// CHECK-MASSV: "-fveclib=MASSV"
|
// CHECK-MASSV: "-fveclib=MASSV"
|
||||||
|
// CHECK-DARWIN_LIBSYSTEM_M: "-fveclib=Darwin_libsystem_m"
|
||||||
|
|
||||||
// CHECK-INVALID: error: invalid value 'something' in '-fveclib=something'
|
// CHECK-INVALID: error: invalid value 'something' in '-fveclib=something'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue