summaryrefslogtreecommitdiffstats
path: root/test/CodeGen/builtins.c
diff options
context:
space:
mode:
authorrdivacky <rdivacky@FreeBSD.org>2010-03-03 17:28:16 +0000
committerrdivacky <rdivacky@FreeBSD.org>2010-03-03 17:28:16 +0000
commitdf90325d4c0a65ee64d2dae3ed9b5b34f7418533 (patch)
treee1a885aadfd80632f5bd70d4bd2d37e715e35a79 /test/CodeGen/builtins.c
parentfd035e6496665b1f1197868e21cb0a4594e8db6e (diff)
downloadFreeBSD-src-df90325d4c0a65ee64d2dae3ed9b5b34f7418533.zip
FreeBSD-src-df90325d4c0a65ee64d2dae3ed9b5b34f7418533.tar.gz
Update clang to 97654.
Diffstat (limited to 'test/CodeGen/builtins.c')
-rw-r--r--test/CodeGen/builtins.c45
1 files changed, 42 insertions, 3 deletions
diff --git a/test/CodeGen/builtins.c b/test/CodeGen/builtins.c
index 4fa4785..417ca7d 100644
--- a/test/CodeGen/builtins.c
+++ b/test/CodeGen/builtins.c
@@ -1,5 +1,6 @@
// RUN: %clang_cc1 -emit-llvm -o %t %s
// RUN: not grep __builtin %t
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-darwin-apple | FileCheck %s
int printf(const char *, ...);
@@ -9,11 +10,17 @@ void p(char *str, int x) {
void q(char *str, double x) {
printf("%s: %f\n", str, x);
}
+void r(char *str, void *ptr) {
+ printf("%s: %p\n", str, ptr);
+}
+
+int random(void);
int main() {
int N = random();
#define P(n,args) p(#n #args, __builtin_##n args)
#define Q(n,args) q(#n #args, __builtin_##n args)
+#define R(n,args) r(#n #args, __builtin_##n args)
#define V(n,args) p(#n #args, (__builtin_##n args, 0))
P(types_compatible_p, (int, float));
P(choose_expr, (0, 10, 20));
@@ -110,16 +117,48 @@ int main() {
// FIXME
// V(clear_cache, (&N, &N+1));
V(trap, ());
- P(extract_return_addr, (&N));
+ R(extract_return_addr, (&N));
return 0;
}
-void strcat() {}
-
void foo() {
__builtin_strcat(0, 0);
}
+// CHECK: define void @bar(
+void bar() {
+ float f;
+ double d;
+ long double ld;
+
+ // LLVM's hex representation of float constants is really unfortunate;
+ // basically it does a float-to-double "conversion" and then prints the
+ // hex form of that. That gives us wierd artifacts like exponents
+ // that aren't numerically similar to the original exponent and
+ // significand bit-patterns that are offset by three bits (because
+ // the exponent was expanded from 8 bits to 11).
+ //
+ // 0xAE98 == 1010111010011000
+ // 0x15D3 == 1010111010011
+
+ f = __builtin_huge_valf(); // CHECK: float 0x7FF0000000000000
+ d = __builtin_huge_val(); // CHECK: double 0x7FF0000000000000
+ ld = __builtin_huge_vall(); // CHECK: x86_fp80 0xK7FFF8000000000000000
+ f = __builtin_nanf(""); // CHECK: float 0x7FF8000000000000
+ d = __builtin_nan(""); // CHECK: double 0x7FF8000000000000
+ ld = __builtin_nanl(""); // CHECK: x86_fp80 0xK7FFFC000000000000000
+ f = __builtin_nanf("0xAE98"); // CHECK: float 0x7FF815D300000000
+ d = __builtin_nan("0xAE98"); // CHECK: double 0x7FF800000000AE98
+ ld = __builtin_nanl("0xAE98"); // CHECK: x86_fp80 0xK7FFFC00000000000AE98
+ f = __builtin_nansf(""); // CHECK: float 0x7FF4000000000000
+ d = __builtin_nans(""); // CHECK: double 0x7FF4000000000000
+ ld = __builtin_nansl(""); // CHECK: x86_fp80 0xK7FFFA000000000000000
+ f = __builtin_nansf("0xAE98"); // CHECK: float 0x7FF015D300000000
+ d = __builtin_nans("0xAE98"); // CHECK: double 0x7FF000000000AE98
+ ld = __builtin_nansl("0xAE98");// CHECK: x86_fp80 0xK7FFF800000000000AE98
+
+}
+// CHECK: }
OpenPOWER on IntegriCloud