Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -emit-llvm %s -o %t |
Chris Lattner | 02b3c26 | 2007-08-27 05:23:45 +0000 | [diff] [blame] | 2 | |
| 3 | /* Sparc is not C99-compliant */ |
| 4 | #if defined(sparc) || defined(__sparc__) || defined(__sparcv9) |
| 5 | |
| 6 | int main() { return 0; } |
| 7 | |
| 8 | #else /* sparc */ |
| 9 | |
| 10 | #define ESCAPE 2 |
| 11 | #define IMAGE_WIDTH 150 |
| 12 | #define IMAGE_HEIGHT 50 |
| 13 | #if 1 |
| 14 | #define IMAGE_SIZE 60 |
| 15 | #else |
| 16 | #define IMAGE_SIZE 5000 |
| 17 | #endif |
| 18 | #define START_X -2.1 |
| 19 | #define END_X 1.0 |
| 20 | #define START_Y -1.25 |
| 21 | #define MAX_ITER 100 |
| 22 | |
| 23 | #define step_X ((END_X - START_X)/IMAGE_WIDTH) |
| 24 | #define step_Y ((-START_Y - START_Y)/IMAGE_HEIGHT) |
| 25 | |
| 26 | #define I 1.0iF |
| 27 | |
Daniel Dunbar | 23afaad | 2009-11-17 08:57:36 +0000 | [diff] [blame] | 28 | int putchar(char c); |
Chris Lattner | 02b3c26 | 2007-08-27 05:23:45 +0000 | [diff] [blame] | 29 | |
| 30 | volatile double __complex__ accum; |
| 31 | |
| 32 | void mandel() { |
| 33 | int x, y, n; |
| 34 | for (y = 0; y < IMAGE_HEIGHT; ++y) { |
| 35 | for (x = 0; x < IMAGE_WIDTH; ++x) { |
| 36 | double __complex__ c = (START_X+x*step_X) + (START_Y+y*step_Y) * I; |
| 37 | double __complex__ z = 0.0; |
| 38 | |
| 39 | for (n = 0; n < MAX_ITER; ++n) { |
| 40 | z = z * z + c; |
| 41 | if (hypot(__real__ z, __imag__ z) >= ESCAPE) |
| 42 | break; |
| 43 | } |
| 44 | |
| 45 | if (n == MAX_ITER) |
| 46 | putchar(' '); |
| 47 | else if (n > 6) |
| 48 | putchar('.'); |
| 49 | else if (n > 3) |
| 50 | putchar('+'); |
| 51 | else if (n > 2) |
| 52 | putchar('x'); |
| 53 | else |
| 54 | putchar('*'); |
| 55 | } |
| 56 | putchar('\n'); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | int main() { |
| 61 | mandel(); |
| 62 | return 0; |
| 63 | } |
| 64 | |
| 65 | #endif /* sparc */ |