<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hi Tim,<br>
    <br>
    There are at least a couple of library builtins that (kind of)
    qualify as precedents:<br>
    <br>
    <code>// Blocks runtime Builtin math library functions</code><code><br>
    </code><code>
      LIBBUILTIN(_Block_object_assign, "vv*vC*iC", "f", "Blocks.h",
      ALL_LANGUAGES)</code><code><br>
    </code><code>
      LIBBUILTIN(_Block_object_dispose, "vvC*iC", "f", "Blocks.h",
      ALL_LANGUAGES)</code><code><br>
    </code><code>
    </code><br>
    So the change seems harmless enough. Perhaps include a comment
    explaining why they've been added and keep the Apple-flavoured
    builtins close to each other.<br>
    <br>
    Meanwhile __exp10() function also seems to fall into this category
    -- man __exp10(3) says the variant exists because it "may be
    computed more efficiently than pow(10,x)". Want to go for that one
    too?<br>
    <br>
    Alp.<br>
    <br>
    <br>
    <div class="moz-cite-prefix">On 06/01/2014 15:18, Tim Northover
      wrote:<br>
    </div>
    <blockquote
cite="mid:differential-rev-PHID-DREV-5mg7hvvlocefbplsrxfw-req@llvm-reviews.chandlerc.com"
      type="cite">
      <pre wrap="">Hi,

OS X version 10.9 onwards has a bunch of functions for computing things like sin(PI * x) called, unimaginatively, __sinpi (etc). It also has a __sincospi function, which LLVM can optimise already, but obviously only if it knows the __sinpi and __cospi are builtin.

Currently Clang doesn't know this so I'd like to teach it. Adding OS-specific builtins seemed a little sketchy but they're in the '__' namespace so we're allowed to do what we want as a compiler. I'm hoping it'll be OK.

Can I commit?

Cheers.

Tim.

<a class="moz-txt-link-freetext" href="http://llvm-reviews.chandlerc.com/D2516">http://llvm-reviews.chandlerc.com/D2516</a>

Files:
  include/clang/Basic/Builtins.def
  test/CodeGen/libcall-declarations.c

Index: include/clang/Basic/Builtins.def
===================================================================
--- include/clang/Basic/Builtins.def
+++ include/clang/Basic/Builtins.def
@@ -1137,6 +1137,15 @@
 LIBBUILTIN(ctanhf, "XfXf", "fnc", "complex.h", ALL_LANGUAGES)
 LIBBUILTIN(ctanhl, "XLdXLd", "fnc", "complex.h", ALL_LANGUAGES)
 
+LIBBUILTIN(__sinpi, "dd", "fne", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(__sinpif, "ff", "fne", "math.h", ALL_LANGUAGES)
+
+LIBBUILTIN(__cospi, "dd", "fne", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(__cospif, "ff", "fne", "math.h", ALL_LANGUAGES)
+
+LIBBUILTIN(__tanpi, "dd", "fne", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(__tanpif, "ff", "fne", "math.h", ALL_LANGUAGES)
+
 // Blocks runtime Builtin math library functions
 LIBBUILTIN(_Block_object_assign, "vv*vC*iC", "f", "Blocks.h", ALL_LANGUAGES)
 LIBBUILTIN(_Block_object_dispose, "vvC*iC", "f", "Blocks.h", ALL_LANGUAGES)
Index: test/CodeGen/libcall-declarations.c
===================================================================
--- test/CodeGen/libcall-declarations.c
+++ test/CodeGen/libcall-declarations.c
@@ -244,6 +244,13 @@
 double _Complex ctanh(double _Complex);
 float _Complex ctanhf(float _Complex);
 long double _Complex ctanhl(long double _Complex);
+
+double __sinpi(double);
+float __sinpif(float);
+double __cospi(double);
+float __cospif(float);
+double __tanpi(double);
+float __tanpif(float);
 #ifdef __cplusplus
 }
 #endif
@@ -298,7 +305,8 @@
   F(crealf),     F(creall),     F(csin),       F(csinf),       F(csinl),
   F(csinh),      F(csinhf),     F(csinhl),     F(csqrt),       F(csqrtf),
   F(csqrtl),     F(ctan),       F(ctanf),      F(ctanl),       F(ctanh),
-  F(ctanhf),     F(ctanhl)
+  F(ctanhf),     F(ctanhl),     F(__sinpi),    F(__sinpif),    F(__cospi),
+  F(__cospif),   F(__tanpi),    F(__tanpif)
 };
 
 // CHECK-NOERRNO: declare double @atan2(double, double) [[NUW:#[0-9]+]]
@@ -510,6 +518,12 @@
 // CHECK-NOERRNO: declare <2 x float> @ctanf(<2 x float>) [[NUW]]
 // CHECK-NOERRNO: declare { double, double } @ctanh(double, double) [[NUW]]
 // CHECK-NOERRNO: declare <2 x float> @ctanhf(<2 x float>) [[NUW]]
+// CHECK-NOERRNO: declare double @__sinpi(double) [[NUW]]
+// CHECK-NOERRNO: declare float @__sinpif(float) [[NUW]]
+// CHECK-NOERRNO: declare double @__cospi(double) [[NUW]]
+// CHECK-NOERRNO: declare float @__cospif(float) [[NUW]]
+// CHECK-NOERRNO: declare double @__tanpi(double) [[NUW]]
+// CHECK-NOERRNO: declare float @__tanpif(float) [[NUW]]
 
 // CHECK-ERRNO: declare i32 @abs(i32) [[NUW:#[0-9]+]]
 // CHECK-ERRNO: declare i64 @labs(i64) [[NUW]]
</pre>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
cfe-commits mailing list
<a class="moz-txt-link-abbreviated" href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a>
</pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
<a class="moz-txt-link-freetext" href="http://www.nuanti.com">http://www.nuanti.com</a>
the browser experts
</pre>
  </body>
</html>