r221984 - [PowerPC] Add VSX builtins for vec_div

Bill Schmidt wschmidt at linux.vnet.ibm.com
Fri Nov 14 04:10:51 PST 2014


Author: wschmidt
Date: Fri Nov 14 06:10:51 2014
New Revision: 221984

URL: http://llvm.org/viewvc/llvm-project?rev=221984&view=rev
Log:
[PowerPC] Add VSX builtins for vec_div

This patch adds builtin support for xvdivdp and xvdivsp, along with a
new test case.  The builtins are accessed using vec_div in altivec.h.
Builtins are listed (mostly) alphabetically there, so inserting these
changed the line numbers for deprecation warnings tested in
test/Headers/altivec-intrin.c.

There is a companion patch for LLVM.

Modified:
    cfe/trunk/include/clang/Basic/BuiltinsPPC.def
    cfe/trunk/lib/Headers/altivec.h
    cfe/trunk/test/CodeGen/builtins-ppc-vsx.c
    cfe/trunk/test/Headers/altivec-intrin.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsPPC.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsPPC.def?rev=221984&r1=221983&r2=221984&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/BuiltinsPPC.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsPPC.def Fri Nov 14 06:10:51 2014
@@ -220,6 +220,9 @@ BUILTIN(__builtin_vsx_xvmindp, "V2dV2dV2
 BUILTIN(__builtin_vsx_xvminsp, "V4fV4fV4f", "")
 BUILTIN(__builtin_vsx_xsmindp, "ddd", "")
 
+BUILTIN(__builtin_vsx_xvdivdp, "V2dV2dV2d", "")
+BUILTIN(__builtin_vsx_xvdivsp, "V4fV4fV4f", "")
+
 // FIXME: Obviously incomplete.
 
 #undef BUILTIN

Modified: cfe/trunk/lib/Headers/altivec.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/altivec.h?rev=221984&r1=221983&r2=221984&view=diff
==============================================================================
--- cfe/trunk/lib/Headers/altivec.h (original)
+++ cfe/trunk/lib/Headers/altivec.h Fri Nov 14 06:10:51 2014
@@ -1623,6 +1623,21 @@ vec_vctuxs(vector float __a, int __b)
   return __builtin_altivec_vctuxs(__a, __b);
 }
 
+/* vec_div */
+#ifdef __VSX__
+static vector float __ATTRS_o_ai
+vec_div(vector float __a, vector float __b)
+{
+  return __builtin_vsx_xvdivsp(__a, __b);
+}
+
+static vector double __ATTRS_o_ai
+vec_div(vector double __a, vector double __b)
+{
+  return __builtin_vsx_xvdivdp(__a, __b);
+}
+#endif
+
 /* vec_dss */
 
 static void __attribute__((__always_inline__))

Modified: cfe/trunk/test/CodeGen/builtins-ppc-vsx.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-ppc-vsx.c?rev=221984&r1=221983&r2=221984&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/builtins-ppc-vsx.c (original)
+++ cfe/trunk/test/CodeGen/builtins-ppc-vsx.c Fri Nov 14 06:10:51 2014
@@ -20,6 +20,13 @@ double res_d;
 void test1() {
 // CHECK-LABEL: define void @test1
 
+  /* vec_div */
+  res_vf = vec_div(vf, vf);
+// CHECK: @llvm.ppc.vsx.xvdivsp
+
+  res_vd = vec_div(vd, vd);
+// CHECK: @llvm.ppc.vsx.xvdivdp
+
   /* vec_max */
   res_vf = vec_max(vf, vf);
 // CHECK: @llvm.ppc.vsx.xvmaxsp

Modified: cfe/trunk/test/Headers/altivec-intrin.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/altivec-intrin.c?rev=221984&r1=221983&r2=221984&view=diff
==============================================================================
--- cfe/trunk/test/Headers/altivec-intrin.c (original)
+++ cfe/trunk/test/Headers/altivec-intrin.c Fri Nov 14 06:10:51 2014
@@ -14,5 +14,5 @@ int main()
 }
 // FIXME: As noted in ms-intrin.cpp, it would be nice if we didn't have to
 // hard-code the line number from altivec.h here.
-// expected-note at altivec.h:2374 {{deprecated here}}
-// expected-note at altivec.h:2509 {{deprecated here}}
+// expected-note at altivec.h:2389 {{deprecated here}}
+// expected-note at altivec.h:2524 {{deprecated here}}





More information about the cfe-commits mailing list