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