diff options
author | Zancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au> | 2012-09-24 09:58:17 +1000 |
---|---|---|
committer | Zancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au> | 2012-09-24 09:58:17 +1000 |
commit | 222e2a7620e6520ffaf4fc4e69d79c18da31542e (patch) | |
tree | 7bfbc05bfa3b41c8f9d2e56d53a0bc3e310df239 /clang/test/CodeGen/mandel.c | |
parent | 3d206f03985b50beacae843d880bccdc91a9f424 (diff) |
Add the clang library to the repo (with some of my changes, too).
Diffstat (limited to 'clang/test/CodeGen/mandel.c')
-rw-r--r-- | clang/test/CodeGen/mandel.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/clang/test/CodeGen/mandel.c b/clang/test/CodeGen/mandel.c new file mode 100644 index 0000000..8ecf8f2 --- /dev/null +++ b/clang/test/CodeGen/mandel.c @@ -0,0 +1,65 @@ +// RUN: %clang_cc1 -emit-llvm %s -o %t + +/* 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 + +int putchar(char c); + +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 */ |