[PowerPC] Initial VSX intrinsic support, with min/max for vector double
Now that we have initial support for VSX, we can begin adding
intrinsics for programmer access to VSX instructions. This patch
performs the necessary enablement in the front end, and tests it by
implementing intrinsics for minimum and maximum using the vector
double data type.
The main change in the front end is to no longer disallow "vector" and
"double" in the same declaration (lib/Sema/DeclSpec.cpp), but "vector"
and "long double" must still be disallowed. The new intrinsics are
accessed via vec_max and vec_min with changes in
lib/Headers/altivec.h. Note that for v4f32, we already access
corresponding VMX builtins, but with VSX enabled we should use the
forms that allow all 64 vector registers.
The new built-ins are defined in include/clang/Basic/BuiltinsPPC.def.
I've added a new test in test/CodeGen/builtins-ppc-vsx.c that is
similar to, but much smaller than, builtins-ppc-altivec.c. This
allows us to test VSX IR generation without duplicating CHECK lines
for the existing bazillion Altivec tests.
Since vector double is now legal when VSX is available, I've modified
the error message, and changed where we test for it and for vector
long double, since the target machine isn't visible in the old place.
This serendipitously removed a not-pertinent warning about 'long'
being deprecated when used with 'vector', when "vector long double" is
encountered and we just want to issue an error. The existing tests
test/Parser/altivec.c and test/Parser/cxx-altivec.cpp have been
updated accordingly, and I've added test/Parser/vsx.c to verify that
"vector double" is now legitimate with VSX enabled.
There is a companion patch for LLVM.
llvm-svn: 220989
2014-11-01 03:19:24 +08:00
|
|
|
// REQUIRES: powerpc-registered-target
|
|
|
|
// RUN: %clang_cc1 -faltivec -target-feature +vsx -triple powerpc64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
|
|
|
|
|
2014-11-14 21:10:13 +08:00
|
|
|
vector unsigned char vuc = { 8, 9, 10, 11, 12, 13, 14, 15,
|
|
|
|
0, 1, 2, 3, 4, 5, 6, 7};
|
[PowerPC] Initial VSX intrinsic support, with min/max for vector double
Now that we have initial support for VSX, we can begin adding
intrinsics for programmer access to VSX instructions. This patch
performs the necessary enablement in the front end, and tests it by
implementing intrinsics for minimum and maximum using the vector
double data type.
The main change in the front end is to no longer disallow "vector" and
"double" in the same declaration (lib/Sema/DeclSpec.cpp), but "vector"
and "long double" must still be disallowed. The new intrinsics are
accessed via vec_max and vec_min with changes in
lib/Headers/altivec.h. Note that for v4f32, we already access
corresponding VMX builtins, but with VSX enabled we should use the
forms that allow all 64 vector registers.
The new built-ins are defined in include/clang/Basic/BuiltinsPPC.def.
I've added a new test in test/CodeGen/builtins-ppc-vsx.c that is
similar to, but much smaller than, builtins-ppc-altivec.c. This
allows us to test VSX IR generation without duplicating CHECK lines
for the existing bazillion Altivec tests.
Since vector double is now legal when VSX is available, I've modified
the error message, and changed where we test for it and for vector
long double, since the target machine isn't visible in the old place.
This serendipitously removed a not-pertinent warning about 'long'
being deprecated when used with 'vector', when "vector long double" is
encountered and we just want to issue an error. The existing tests
test/Parser/altivec.c and test/Parser/cxx-altivec.cpp have been
updated accordingly, and I've added test/Parser/vsx.c to verify that
"vector double" is now legitimate with VSX enabled.
There is a companion patch for LLVM.
llvm-svn: 220989
2014-11-01 03:19:24 +08:00
|
|
|
vector float vf = { -1.5, 2.5, -3.5, 4.5 };
|
|
|
|
vector double vd = { 3.5, -7.5 };
|
2014-11-12 12:19:56 +08:00
|
|
|
vector signed int vsi = { -1, 2, -3, 4 };
|
|
|
|
vector unsigned int vui = { 0, 1, 2, 3 };
|
|
|
|
vector signed long long vsll = { 255LL, -937LL };
|
|
|
|
vector unsigned long long vull = { 1447LL, 2894LL };
|
[PowerPC] Initial VSX intrinsic support, with min/max for vector double
Now that we have initial support for VSX, we can begin adding
intrinsics for programmer access to VSX instructions. This patch
performs the necessary enablement in the front end, and tests it by
implementing intrinsics for minimum and maximum using the vector
double data type.
The main change in the front end is to no longer disallow "vector" and
"double" in the same declaration (lib/Sema/DeclSpec.cpp), but "vector"
and "long double" must still be disallowed. The new intrinsics are
accessed via vec_max and vec_min with changes in
lib/Headers/altivec.h. Note that for v4f32, we already access
corresponding VMX builtins, but with VSX enabled we should use the
forms that allow all 64 vector registers.
The new built-ins are defined in include/clang/Basic/BuiltinsPPC.def.
I've added a new test in test/CodeGen/builtins-ppc-vsx.c that is
similar to, but much smaller than, builtins-ppc-altivec.c. This
allows us to test VSX IR generation without duplicating CHECK lines
for the existing bazillion Altivec tests.
Since vector double is now legal when VSX is available, I've modified
the error message, and changed where we test for it and for vector
long double, since the target machine isn't visible in the old place.
This serendipitously removed a not-pertinent warning about 'long'
being deprecated when used with 'vector', when "vector long double" is
encountered and we just want to issue an error. The existing tests
test/Parser/altivec.c and test/Parser/cxx-altivec.cpp have been
updated accordingly, and I've added test/Parser/vsx.c to verify that
"vector double" is now legitimate with VSX enabled.
There is a companion patch for LLVM.
llvm-svn: 220989
2014-11-01 03:19:24 +08:00
|
|
|
double d = 23.4;
|
|
|
|
|
|
|
|
vector float res_vf;
|
|
|
|
vector double res_vd;
|
2014-11-12 12:19:56 +08:00
|
|
|
vector signed int res_vsi;
|
|
|
|
vector unsigned int res_vui;
|
|
|
|
vector signed long long res_vsll;
|
|
|
|
vector unsigned long long res_vull;
|
[PowerPC] Initial VSX intrinsic support, with min/max for vector double
Now that we have initial support for VSX, we can begin adding
intrinsics for programmer access to VSX instructions. This patch
performs the necessary enablement in the front end, and tests it by
implementing intrinsics for minimum and maximum using the vector
double data type.
The main change in the front end is to no longer disallow "vector" and
"double" in the same declaration (lib/Sema/DeclSpec.cpp), but "vector"
and "long double" must still be disallowed. The new intrinsics are
accessed via vec_max and vec_min with changes in
lib/Headers/altivec.h. Note that for v4f32, we already access
corresponding VMX builtins, but with VSX enabled we should use the
forms that allow all 64 vector registers.
The new built-ins are defined in include/clang/Basic/BuiltinsPPC.def.
I've added a new test in test/CodeGen/builtins-ppc-vsx.c that is
similar to, but much smaller than, builtins-ppc-altivec.c. This
allows us to test VSX IR generation without duplicating CHECK lines
for the existing bazillion Altivec tests.
Since vector double is now legal when VSX is available, I've modified
the error message, and changed where we test for it and for vector
long double, since the target machine isn't visible in the old place.
This serendipitously removed a not-pertinent warning about 'long'
being deprecated when used with 'vector', when "vector long double" is
encountered and we just want to issue an error. The existing tests
test/Parser/altivec.c and test/Parser/cxx-altivec.cpp have been
updated accordingly, and I've added test/Parser/vsx.c to verify that
"vector double" is now legitimate with VSX enabled.
There is a companion patch for LLVM.
llvm-svn: 220989
2014-11-01 03:19:24 +08:00
|
|
|
double res_d;
|
|
|
|
|
|
|
|
void test1() {
|
|
|
|
// CHECK-LABEL: define void @test1
|
|
|
|
|
2014-11-14 20:10:51 +08:00
|
|
|
/* vec_div */
|
|
|
|
res_vf = vec_div(vf, vf);
|
|
|
|
// CHECK: @llvm.ppc.vsx.xvdivsp
|
|
|
|
|
|
|
|
res_vd = vec_div(vd, vd);
|
|
|
|
// CHECK: @llvm.ppc.vsx.xvdivdp
|
|
|
|
|
[PowerPC] Initial VSX intrinsic support, with min/max for vector double
Now that we have initial support for VSX, we can begin adding
intrinsics for programmer access to VSX instructions. This patch
performs the necessary enablement in the front end, and tests it by
implementing intrinsics for minimum and maximum using the vector
double data type.
The main change in the front end is to no longer disallow "vector" and
"double" in the same declaration (lib/Sema/DeclSpec.cpp), but "vector"
and "long double" must still be disallowed. The new intrinsics are
accessed via vec_max and vec_min with changes in
lib/Headers/altivec.h. Note that for v4f32, we already access
corresponding VMX builtins, but with VSX enabled we should use the
forms that allow all 64 vector registers.
The new built-ins are defined in include/clang/Basic/BuiltinsPPC.def.
I've added a new test in test/CodeGen/builtins-ppc-vsx.c that is
similar to, but much smaller than, builtins-ppc-altivec.c. This
allows us to test VSX IR generation without duplicating CHECK lines
for the existing bazillion Altivec tests.
Since vector double is now legal when VSX is available, I've modified
the error message, and changed where we test for it and for vector
long double, since the target machine isn't visible in the old place.
This serendipitously removed a not-pertinent warning about 'long'
being deprecated when used with 'vector', when "vector long double" is
encountered and we just want to issue an error. The existing tests
test/Parser/altivec.c and test/Parser/cxx-altivec.cpp have been
updated accordingly, and I've added test/Parser/vsx.c to verify that
"vector double" is now legitimate with VSX enabled.
There is a companion patch for LLVM.
llvm-svn: 220989
2014-11-01 03:19:24 +08:00
|
|
|
/* vec_max */
|
|
|
|
res_vf = vec_max(vf, vf);
|
|
|
|
// CHECK: @llvm.ppc.vsx.xvmaxsp
|
|
|
|
|
|
|
|
res_vd = vec_max(vd, vd);
|
|
|
|
// CHECK: @llvm.ppc.vsx.xvmaxdp
|
|
|
|
|
|
|
|
res_vf = vec_vmaxfp(vf, vf);
|
|
|
|
// CHECK: @llvm.ppc.vsx.xvmaxsp
|
|
|
|
|
|
|
|
/* vec_min */
|
|
|
|
res_vf = vec_min(vf, vf);
|
|
|
|
// CHECK: @llvm.ppc.vsx.xvminsp
|
|
|
|
|
|
|
|
res_vd = vec_min(vd, vd);
|
|
|
|
// CHECK: @llvm.ppc.vsx.xvmindp
|
|
|
|
|
|
|
|
res_vf = vec_vminfp(vf, vf);
|
|
|
|
// CHECK: @llvm.ppc.vsx.xvminsp
|
|
|
|
|
|
|
|
res_d = __builtin_vsx_xsmaxdp(d, d);
|
|
|
|
// CHECK: @llvm.ppc.vsx.xsmaxdp
|
|
|
|
|
|
|
|
res_d = __builtin_vsx_xsmindp(d, d);
|
|
|
|
// CHECK: @llvm.ppc.vsx.xsmindp
|
2014-11-12 12:19:56 +08:00
|
|
|
|
2014-11-14 21:10:13 +08:00
|
|
|
/* vec_perm */
|
|
|
|
res_vsll = vec_perm(vsll, vsll, vuc);
|
|
|
|
// CHECK: @llvm.ppc.altivec.vperm
|
|
|
|
|
|
|
|
res_vull = vec_perm(vull, vull, vuc);
|
|
|
|
// CHECK: @llvm.ppc.altivec.vperm
|
|
|
|
|
|
|
|
res_vd = vec_perm(vd, vd, vuc);
|
|
|
|
// CHECK: @llvm.ppc.altivec.vperm
|
|
|
|
|
|
|
|
res_vsll = vec_vperm(vsll, vsll, vuc);
|
|
|
|
// CHECK: @llvm.ppc.altivec.vperm
|
|
|
|
|
|
|
|
res_vull = vec_vperm(vull, vull, vuc);
|
|
|
|
// CHECK: @llvm.ppc.altivec.vperm
|
|
|
|
|
|
|
|
res_vd = vec_vperm(vd, vd, vuc);
|
|
|
|
// CHECK: @llvm.ppc.altivec.vperm
|
|
|
|
|
2014-11-12 12:19:56 +08:00
|
|
|
/* vec_vsx_ld */
|
|
|
|
|
|
|
|
res_vsi = vec_vsx_ld(0, &vsi);
|
|
|
|
// CHECK: @llvm.ppc.vsx.lxvw4x
|
|
|
|
|
|
|
|
res_vui = vec_vsx_ld(0, &vui);
|
|
|
|
// CHECK: @llvm.ppc.vsx.lxvw4x
|
|
|
|
|
|
|
|
res_vf = vec_vsx_ld (0, &vf);
|
|
|
|
// CHECK: @llvm.ppc.vsx.lxvw4x
|
|
|
|
|
|
|
|
res_vsll = vec_vsx_ld(0, &vsll);
|
|
|
|
// CHECK: @llvm.ppc.vsx.lxvd2x
|
|
|
|
|
|
|
|
res_vull = vec_vsx_ld(0, &vull);
|
|
|
|
// CHECK: @llvm.ppc.vsx.lxvd2x
|
|
|
|
|
|
|
|
res_vd = vec_vsx_ld(0, &vd);
|
|
|
|
// CHECK: @llvm.ppc.vsx.lxvd2x
|
|
|
|
|
|
|
|
/* vec_vsx_st */
|
|
|
|
|
|
|
|
vec_vsx_st(vsi, 0, &res_vsi);
|
|
|
|
// CHECK: @llvm.ppc.vsx.stxvw4x
|
|
|
|
|
|
|
|
vec_vsx_st(vui, 0, &res_vui);
|
|
|
|
// CHECK: @llvm.ppc.vsx.stxvw4x
|
|
|
|
|
|
|
|
vec_vsx_st(vf, 0, &res_vf);
|
|
|
|
// CHECK: @llvm.ppc.vsx.stxvw4x
|
|
|
|
|
|
|
|
vec_vsx_st(vsll, 0, &res_vsll);
|
|
|
|
// CHECK: @llvm.ppc.vsx.stxvd2x
|
|
|
|
|
|
|
|
vec_vsx_st(vull, 0, &res_vull);
|
|
|
|
// CHECK: @llvm.ppc.vsx.stxvd2x
|
|
|
|
|
|
|
|
vec_vsx_st(vd, 0, &res_vd);
|
|
|
|
// CHECK: @llvm.ppc.vsx.stxvd2x
|
[PowerPC] Initial VSX intrinsic support, with min/max for vector double
Now that we have initial support for VSX, we can begin adding
intrinsics for programmer access to VSX instructions. This patch
performs the necessary enablement in the front end, and tests it by
implementing intrinsics for minimum and maximum using the vector
double data type.
The main change in the front end is to no longer disallow "vector" and
"double" in the same declaration (lib/Sema/DeclSpec.cpp), but "vector"
and "long double" must still be disallowed. The new intrinsics are
accessed via vec_max and vec_min with changes in
lib/Headers/altivec.h. Note that for v4f32, we already access
corresponding VMX builtins, but with VSX enabled we should use the
forms that allow all 64 vector registers.
The new built-ins are defined in include/clang/Basic/BuiltinsPPC.def.
I've added a new test in test/CodeGen/builtins-ppc-vsx.c that is
similar to, but much smaller than, builtins-ppc-altivec.c. This
allows us to test VSX IR generation without duplicating CHECK lines
for the existing bazillion Altivec tests.
Since vector double is now legal when VSX is available, I've modified
the error message, and changed where we test for it and for vector
long double, since the target machine isn't visible in the old place.
This serendipitously removed a not-pertinent warning about 'long'
being deprecated when used with 'vector', when "vector long double" is
encountered and we just want to issue an error. The existing tests
test/Parser/altivec.c and test/Parser/cxx-altivec.cpp have been
updated accordingly, and I've added test/Parser/vsx.c to verify that
"vector double" is now legitimate with VSX enabled.
There is a companion patch for LLVM.
llvm-svn: 220989
2014-11-01 03:19:24 +08:00
|
|
|
}
|