They are meant to exercise the hardware floating-point calling convention of the risc-v target.
Unified · Split
| @@ -10,6 +10,8 @@ type :st7 = { s, d } · 9 unmodified lines | ||
| 10 | 10 | type :st8 = { w 4 } |
| 11 | 11 | type :un9 = { { b } { s } } |
| 12 | 12 | type :st9 = { w, :un9 } |
| 13 | +type :sta = { b, s } | |
| 14 | +type :stb = { b, b, s } | |
| 13 | 15 | |
| 14 | 16 | data $fmt1 = { b "t1: %s\n", b 0 } |
| 15 | 17 | data $fmt2 = { b "t2: %d\n", b 0 } |
| @@ -20,6 +22,8 @@ data $fmt6 = { b "t6: %s\n", b 0 } · 4 unmodified lines | ||
| 20 | 22 | data $fmt7 = { b "t7: %f %f\n", b 0 } |
| 21 | 23 | data $fmt8 = { b "t8: %d %d %d %d\n", b 0 } |
| 22 | 24 | data $fmt9 = { b "t9: %d %f\n", b 0 } |
| 25 | +data $fmta = { b "ta: %d %f\n", b 0 } | |
| 26 | +data $fmtb = { b "tb: %d %d %f\n", b 0 } | |
| 23 | 27 | |
| 24 | 28 | export |
| 25 | 29 | function $test() { |
| @@ -78,12 +82,27 @@ function $test() { · 52 unmodified lines | ||
| 78 | 82 | %d9 =d exts %s9 |
| 79 | 83 | %i9 =w call $printf(l $fmt9, ..., w %w9, d %d9) |
| 80 | 84 | |
| 85 | + %ra =:sta call $ta() | |
| 86 | + %ra4 =l add 4, %ra | |
| 87 | + %wa =w loadsb %ra | |
| 88 | + %sa =s loads %ra4 | |
| 89 | + %da =d exts %sa | |
| 90 | + %ia =w call $printf(l $fmta, ..., w %wa, d %da) | |
| 91 | + | |
| 92 | + %rb =:stb call $tb() | |
| 93 | + %rb1 =l add 1, %rb | |
| 94 | + %rb4 =l add 4, %rb | |
| 95 | + %w0b =w loadsb %rb | |
| 96 | + %w1b =w loadsb %rb1 | |
| 97 | + %sb =s loads %rb4 | |
| 98 | + %db =d exts %sb | |
| 99 | + %ib =w call $printf(l $fmtb, ..., w %w0b, w %w1b, d %db) | |
| 100 | + | |
| 81 | 101 | ret |
| 82 | 102 | } |
| 83 | 103 | |
| 84 | 104 | |
| 85 | 105 | # >>> driver |
| 86 | −# #include <stdio.h> | |
| 87 | 106 | # typedef struct { char t[17]; } st1; |
| 88 | 107 | # typedef struct { int i; } st2; |
| 89 | 108 | # typedef struct { float f; int i; } st3; |
| @@ -93,6 +112,8 @@ function $test() { · 3 unmodified lines | ||
| 93 | 112 | # typedef struct { float f; double d; } st7; |
| 94 | 113 | # typedef struct { int i[4]; } st8; |
| 95 | 114 | # typedef struct { int i; union { char c; float f; } u; } st9; |
| 115 | +# typedef struct { char c; float f; } sta; | |
| 116 | +# typedef struct { char c0, c1; float f; } stb; | |
| 96 | 117 | # extern void test(void); |
| 97 | 118 | # st1 t1() { return (st1){"abcdefghijklmnop"}; } |
| 98 | 119 | # st2 t2() { return (st2){2}; } |
| @@ -103,6 +124,8 @@ function $test() { · 4 unmodified lines | ||
| 103 | 124 | # st7 t7() { return (st7){7.77,77.7}; } |
| 104 | 125 | # st8 t8() { return (st8){-8,88,-888,8888}; } |
| 105 | 126 | # st9 t9() { return (st9){9,{.f=9.9}}; } |
| 127 | +# sta ta() { return (sta){-10,10.1}; } | |
| 128 | +# stb tb() { return (stb){-1,11,11.11}; } | |
| 106 | 129 | # int main() { test(); return 0; } |
| 107 | 130 | # <<< |
| 108 | 131 | |
| @@ -116,4 +139,6 @@ function $test() { · 7 unmodified lines | ||
| 116 | 139 | # t7: 7.770000 77.700000 |
| 117 | 140 | # t8: -8 88 -888 8888 |
| 118 | 141 | # t9: 9 9.900000 |
| 142 | +# ta: -10 10.100000 | |
| 143 | +# tb: -1 11 11.110000 | |
| 119 | 144 | # <<< |