From 3de0a385c96fa94dd7ed3c1df8b10dd65cf738c8 Mon Sep 17 00:00:00 2001 From: Nemanja Ivanovic Date: Wed, 26 Oct 2016 19:27:11 +0000 Subject: [PATCH] [PowerPC] Implement vector_insert_exp builtins - clang portion This patch corresponds to review https://reviews.llvm.org/D25956. Committing on behalf of Zaara Syeda. llvm-svn: 285229 --- clang/include/clang/Basic/BuiltinsPPC.def | 3 +++ clang/lib/Headers/altivec.h | 20 ++++++++++++++++ clang/test/CodeGen/builtins-ppc-p9vector.c | 28 ++++++++++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/clang/include/clang/Basic/BuiltinsPPC.def b/clang/include/clang/Basic/BuiltinsPPC.def index 33ea512cce8d..14284155a032 100644 --- a/clang/include/clang/Basic/BuiltinsPPC.def +++ b/clang/include/clang/Basic/BuiltinsPPC.def @@ -362,6 +362,9 @@ BUILTIN(__builtin_vsx_xvcpsgnsp, "V4fV4fV4f", "") BUILTIN(__builtin_vsx_xvabssp, "V4fV4f", "") BUILTIN(__builtin_vsx_xvabsdp, "V2dV2d", "") +BUILTIN(__builtin_vsx_xviexpdp, "V2dV2ULLiV2ULLi", "") +BUILTIN(__builtin_vsx_xviexpsp, "V4fV4UiV4Ui", "") + // HTM builtins BUILTIN(__builtin_tbegin, "UiUIi", "") BUILTIN(__builtin_tend, "UiUIi", "") diff --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h index 5dd093a9efce..6deef6aabb8e 100644 --- a/clang/lib/Headers/altivec.h +++ b/clang/lib/Headers/altivec.h @@ -2497,6 +2497,26 @@ vec_first_mismatch_or_eos_index(vector unsigned int __a, return __res[0] >> 5; } +static __inline__ vector double __ATTRS_o_ai +vec_insert_exp(vector double __a, vector unsigned long long __b) { + return __builtin_vsx_xviexpdp((vector unsigned long long)__a,__b); +} + +static __inline__ vector double __ATTRS_o_ai +vec_insert_exp(vector unsigned long long __a, vector unsigned long long __b) { + return __builtin_vsx_xviexpdp(__a,__b); +} + +static __inline__ vector float __ATTRS_o_ai +vec_insert_exp(vector float __a, vector unsigned int __b) { + return __builtin_vsx_xviexpsp((vector unsigned int)__a,__b); +} + +static __inline__ vector float __ATTRS_o_ai +vec_insert_exp(vector unsigned int __a, vector unsigned int __b) { + return __builtin_vsx_xviexpsp(__a,__b); +} + #endif /* vec_cpsgn */ diff --git a/clang/test/CodeGen/builtins-ppc-p9vector.c b/clang/test/CodeGen/builtins-ppc-p9vector.c index 44562c519b0c..8f7f48cc5930 100644 --- a/clang/test/CodeGen/builtins-ppc-p9vector.c +++ b/clang/test/CodeGen/builtins-ppc-p9vector.c @@ -698,3 +698,31 @@ vector unsigned short test54(void) { // CHECK-NEXT: ret <8 x i16> return vec_popcnt (vusa); } +vector double test55(void) { +// CHECK-BE: @llvm.ppc.vsx.xviexpdp(<2 x i64> %{{.+}}, <2 x i64> +// CHECK-BE-NEXT: ret <2 x double> +// CHECK: @llvm.ppc.vsx.xviexpdp(<2 x i64> %{{.+}}, <2 x i64> +// CHECK-NEXT: ret <2 x double> + return vec_insert_exp (vda,vulb); +} +vector double test56(void) { +// CHECK-BE: @llvm.ppc.vsx.xviexpdp(<2 x i64> %{{.+}}, <2 x i64> +// CHECK-BE-NEXT: ret <2 x double> +// CHECK: @llvm.ppc.vsx.xviexpdp(<2 x i64> %{{.+}}, <2 x i64> +// CHECK-NEXT: ret <2 x double> + return vec_insert_exp (vula, vulb); +} +vector float test57(void) { +// CHECK-BE: @llvm.ppc.vsx.xviexpsp(<4 x i32> %{{.+}}, <4 x i32> +// CHECK-BE-NEXT: ret <4 x float> +// CHECK: @llvm.ppc.vsx.xviexpsp(<4 x i32> %{{.+}}, <4 x i32> +// CHECK-NEXT: ret <4 x float> + return vec_insert_exp (vfa,vuib); +} +vector float test58(void) { +// CHECK-BE: @llvm.ppc.vsx.xviexpsp(<4 x i32> %{{.+}}, <4 x i32> +// CHECK-BE-NEXT: ret <4 x float> +// CHECK: @llvm.ppc.vsx.xviexpsp(<4 x i32> %{{.+}}, <4 x i32> +// CHECK-NEXT: ret <4 x float> + return vec_insert_exp (vuia,vuib); +}