Tanya Lattner | cd0aa81 | 2004-11-06 21:40:51 +0000 | [diff] [blame^] | 1 | ; RUN: llvm-as < %s | llc |
| 2 | |
Misha Brukman | 5b160f1 | 2004-08-11 14:16:34 +0000 | [diff] [blame] | 3 | %a_fstr = internal constant [8 x sbyte] c"a = %f\0A\00" |
| 4 | %a_lstr = internal constant [10 x sbyte] c"a = %lld\0A\00" |
| 5 | %a_dstr = internal constant [8 x sbyte] c"a = %d\0A\00" |
| 6 | |
| 7 | %b_dstr = internal constant [8 x sbyte] c"b = %d\0A\00" |
| 8 | %b_fstr = internal constant [8 x sbyte] c"b = %f\0A\00" |
| 9 | |
| 10 | declare int %printf(sbyte*, ...) |
| 11 | %A = global double 2.0 |
| 12 | %B = global int 2 |
| 13 | |
| 14 | int %main() { |
| 15 | ;; A |
| 16 | %a = load double* %A |
| 17 | %a_fs = getelementptr [8 x sbyte]* %a_fstr, long 0, long 0 |
| 18 | call int (sbyte*, ...)* %printf(sbyte* %a_fs, double %a) |
| 19 | |
| 20 | ;; cast double to long |
| 21 | %a_d2l = cast double %a to long |
| 22 | %a_ls = getelementptr [10 x sbyte]* %a_lstr, long 0, long 0 |
| 23 | call int (sbyte*, ...)* %printf(sbyte* %a_ls, long %a_d2l) |
| 24 | |
| 25 | ;; cast double to int |
| 26 | %a_d2i = cast double %a to int |
| 27 | %a_ds = getelementptr [8 x sbyte]* %a_dstr, long 0, long 0 |
| 28 | call int (sbyte*, ...)* %printf(sbyte* %a_ds, int %a_d2i) |
| 29 | |
| 30 | ;; cast double to sbyte |
| 31 | %a_d2sb = cast double %a to sbyte |
| 32 | call int (sbyte*, ...)* %printf(sbyte* %a_ds, sbyte %a_d2sb) |
| 33 | |
| 34 | ;; cast int to sbyte |
| 35 | %a_d2i2sb = cast int %a_d2i to sbyte |
| 36 | call int (sbyte*, ...)* %printf(sbyte* %a_ds, sbyte %a_d2i2sb) |
| 37 | |
| 38 | ;; B |
| 39 | %b = load int* %B |
| 40 | %b_ds = getelementptr [8 x sbyte]* %b_dstr, long 0, long 0 |
| 41 | call int (sbyte*, ...)* %printf(sbyte* %b_ds, int %b) |
| 42 | |
| 43 | ;; cast int to double |
| 44 | %b_i2d = cast int %b to double |
| 45 | %b_fs = getelementptr [8 x sbyte]* %b_fstr, long 0, long 0 |
| 46 | call int (sbyte*, ...)* %printf(sbyte* %b_fs, double %b_i2d) |
| 47 | |
| 48 | ret int 0 |
| 49 | } |