summaryrefslogtreecommitdiff
path: root/test/CodeGen/mandel.c
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-08-27 05:23:45 +0000
committerChris Lattner <sabre@nondot.org>2007-08-27 05:23:45 +0000
commit02b3c26e71a551064e9a60a7d28dfd7cd631e3c5 (patch)
tree2e409cab49d2ea7d3bfb50d6a70125c1be1eeca6 /test/CodeGen/mandel.c
parentc30ebfbf23d6a471146e3c68c2cf7f170b7e55dc (diff)
downloadclang-02b3c26e71a551064e9a60a7d28dfd7cd631e3c5.tar.gz
testcase that doesn't work quite yet
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41478 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/mandel.c')
-rw-r--r--test/CodeGen/mandel.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/test/CodeGen/mandel.c b/test/CodeGen/mandel.c
new file mode 100644
index 0000000000..f9b5972216
--- /dev/null
+++ b/test/CodeGen/mandel.c
@@ -0,0 +1,73 @@
+// RUN: clang -emit-llvm %s
+
+/* Sparc is not C99-compliant */
+#if defined(sparc) || defined(__sparc__) || defined(__sparcv9)
+
+int main() { return 0; }
+
+#else /* sparc */
+
+#define ESCAPE 2
+#define IMAGE_WIDTH 150
+#define IMAGE_HEIGHT 50
+#if 1
+#define IMAGE_SIZE 60
+#else
+#define IMAGE_SIZE 5000
+#endif
+#define START_X -2.1
+#define END_X 1.0
+#define START_Y -1.25
+#define MAX_ITER 100
+
+#define step_X ((END_X - START_X)/IMAGE_WIDTH)
+#define step_Y ((-START_Y - START_Y)/IMAGE_HEIGHT)
+
+#define I 1.0iF
+
+#if defined(__FreeBSD__) || defined(__OpenBSD__)
+#include <complex.h>
+#elif defined(__APPLE__)
+#include <math.h>
+#else
+#include <tgmath.h>
+#endif
+
+#include <stdio.h>
+
+volatile double __complex__ accum;
+
+void mandel() {
+ int x, y, n;
+ for (y = 0; y < IMAGE_HEIGHT; ++y) {
+ for (x = 0; x < IMAGE_WIDTH; ++x) {
+ double __complex__ c = (START_X+x*step_X) + (START_Y+y*step_Y) * I;
+ double __complex__ z = 0.0;
+
+ for (n = 0; n < MAX_ITER; ++n) {
+ z = z * z + c;
+ if (hypot(__real__ z, __imag__ z) >= ESCAPE)
+ break;
+ }
+
+ if (n == MAX_ITER)
+ putchar(' ');
+ else if (n > 6)
+ putchar('.');
+ else if (n > 3)
+ putchar('+');
+ else if (n > 2)
+ putchar('x');
+ else
+ putchar('*');
+ }
+ putchar('\n');
+ }
+}
+
+int main() {
+ mandel();
+ return 0;
+}
+
+#endif /* sparc */