[331] | 1 | // This program is designed to test some arm64-specific things, such as the
|
---|
| 2 | // calling convention, but should give the same results on any architecture.
|
---|
| 3 |
|
---|
| 4 | #include <stdarg.h>
|
---|
| 5 | #include <stdint.h>
|
---|
| 6 | #include <stdio.h>
|
---|
| 7 |
|
---|
| 8 | struct s1 { char x[1]; } s1 = { "0" };
|
---|
| 9 | struct s2 { char x[2]; } s2 = { "12" };
|
---|
| 10 | struct s3 { char x[3]; } s3 = { "345" };
|
---|
| 11 | struct s4 { char x[4]; } s4 = { "6789" };
|
---|
| 12 | struct s5 { char x[5]; } s5 = { "abcde" };
|
---|
| 13 | struct s6 { char x[6]; } s6 = { "fghijk" };
|
---|
| 14 | struct s7 { char x[7]; } s7 = { "lmnopqr" };
|
---|
| 15 | struct s8 { char x[8]; } s8 = { "stuvwxyz" };
|
---|
| 16 | struct s9 { char x[9]; } s9 = { "ABCDEFGHI" };
|
---|
| 17 | struct s10 { char x[10]; } s10 = { "JKLMNOPQRS" };
|
---|
| 18 | struct s11 { char x[11]; } s11 = { "TUVWXYZ0123" };
|
---|
| 19 | struct s12 { char x[12]; } s12 = { "456789abcdef" };
|
---|
| 20 | struct s13 { char x[13]; } s13 = { "ghijklmnopqrs" };
|
---|
| 21 | struct s14 { char x[14]; } s14 = { "tuvwxyzABCDEFG" };
|
---|
| 22 | struct s15 { char x[15]; } s15 = { "HIJKLMNOPQRSTUV" };
|
---|
| 23 | struct s16 { char x[16]; } s16 = { "WXYZ0123456789ab" };
|
---|
| 24 | struct s17 { char x[17]; } s17 = { "cdefghijklmnopqrs" };
|
---|
| 25 |
|
---|
| 26 | struct hfa11 { float a; } hfa11 = { 11.1 };
|
---|
| 27 | struct hfa12 { float a, b; } hfa12 = { 12.1, 12.2 };
|
---|
| 28 | struct hfa13 { float a, b, c; } hfa13 = { 13.1, 13.2, 13.3 };
|
---|
| 29 | struct hfa14 { float a, b, c, d; } hfa14 = { 14.1, 14.2, 14.3, 14.4 };
|
---|
| 30 |
|
---|
| 31 | struct hfa21 { double a; } hfa21 = { 21.1 };
|
---|
| 32 | struct hfa22 { double a, b; } hfa22 = { 22.1, 22.2 };
|
---|
| 33 | struct hfa23 { double a, b, c; } hfa23 = { 23.1, 23.2, 23.3 };
|
---|
| 34 | struct hfa24 { double a, b, c, d; } hfa24 = { 24.1, 24.2, 24.3, 24.4 };
|
---|
| 35 |
|
---|
| 36 | struct hfa31 { long double a; } hfa31 = { 31.1 };
|
---|
| 37 | struct hfa32 { long double a, b; } hfa32 = { 32.1, 32.2 };
|
---|
| 38 | struct hfa33 { long double a, b, c; } hfa33 = { 33.1, 33.2, 33.3 };
|
---|
| 39 | struct hfa34 { long double a, b, c, d; } hfa34 = { 34.1, 34.2, 34.3, 34.4 };
|
---|
| 40 |
|
---|
| 41 | void fa_s1(struct s1 a) { printf("%.1s\n", a.x); }
|
---|
| 42 | void fa_s2(struct s2 a) { printf("%.2s\n", a.x); }
|
---|
| 43 | void fa_s3(struct s3 a) { printf("%.3s\n", a.x); }
|
---|
| 44 | void fa_s4(struct s4 a) { printf("%.4s\n", a.x); }
|
---|
| 45 | void fa_s5(struct s5 a) { printf("%.5s\n", a.x); }
|
---|
| 46 | void fa_s6(struct s6 a) { printf("%.6s\n", a.x); }
|
---|
| 47 | void fa_s7(struct s7 a) { printf("%.7s\n", a.x); }
|
---|
| 48 | void fa_s8(struct s8 a) { printf("%.8s\n", a.x); }
|
---|
| 49 | void fa_s9(struct s9 a) { printf("%.9s\n", a.x); }
|
---|
| 50 | void fa_s10(struct s10 a) { printf("%.10s\n", a.x); }
|
---|
| 51 | void fa_s11(struct s11 a) { printf("%.11s\n", a.x); }
|
---|
| 52 | void fa_s12(struct s12 a) { printf("%.12s\n", a.x); }
|
---|
| 53 | void fa_s13(struct s13 a) { printf("%.13s\n", a.x); }
|
---|
| 54 | void fa_s14(struct s14 a) { printf("%.14s\n", a.x); }
|
---|
| 55 | void fa_s15(struct s15 a) { printf("%.15s\n", a.x); }
|
---|
| 56 | void fa_s16(struct s16 a) { printf("%.16s\n", a.x); }
|
---|
| 57 | void fa_s17(struct s17 a) { printf("%.17s\n", a.x); }
|
---|
| 58 |
|
---|
| 59 | void fa_hfa11(struct hfa11 a)
|
---|
| 60 | { printf("%.1f\n", a.a); }
|
---|
| 61 | void fa_hfa12(struct hfa12 a)
|
---|
| 62 | { printf("%.1f %.1f\n", a.a, a.a); }
|
---|
| 63 | void fa_hfa13(struct hfa13 a)
|
---|
| 64 | { printf("%.1f %.1f %.1f\n", a.a, a.b, a.c); }
|
---|
| 65 | void fa_hfa14(struct hfa14 a)
|
---|
| 66 | { printf("%.1f %.1f %.1f %.1f\n", a.a, a.b, a.c, a.d); }
|
---|
| 67 |
|
---|
| 68 | void fa_hfa21(struct hfa21 a)
|
---|
| 69 | { printf("%.1f\n", a.a); }
|
---|
| 70 | void fa_hfa22(struct hfa22 a)
|
---|
| 71 | { printf("%.1f %.1f\n", a.a, a.a); }
|
---|
| 72 | void fa_hfa23(struct hfa23 a)
|
---|
| 73 | { printf("%.1f %.1f %.1f\n", a.a, a.b, a.c); }
|
---|
| 74 | void fa_hfa24(struct hfa24 a)
|
---|
| 75 | { printf("%.1f %.1f %.1f %.1f\n", a.a, a.b, a.c, a.d); }
|
---|
| 76 |
|
---|
| 77 | void fa_hfa31(struct hfa31 a)
|
---|
| 78 | { printf("%.1Lf\n", a.a); }
|
---|
| 79 | void fa_hfa32(struct hfa32 a)
|
---|
| 80 | { printf("%.1Lf %.1Lf\n", a.a, a.a); }
|
---|
| 81 | void fa_hfa33(struct hfa33 a)
|
---|
| 82 | { printf("%.1Lf %.1Lf %.1Lf\n", a.a, a.b, a.c); }
|
---|
| 83 | void fa_hfa34(struct hfa34 a)
|
---|
| 84 | { printf("%.1Lf %.1Lf %.1Lf %.1Lf\n", a.a, a.b, a.c, a.d); }
|
---|
| 85 |
|
---|
| 86 | void fa1(struct s8 a, struct s9 b, struct s10 c, struct s11 d,
|
---|
| 87 | struct s12 e, struct s13 f)
|
---|
| 88 | {
|
---|
| 89 | printf("%.3s %.3s %.3s %.3s %.3s %.3s\n", a.x, b.x, c.x, d.x, e.x, f.x);
|
---|
| 90 | }
|
---|
| 91 |
|
---|
| 92 | void fa2(struct s9 a, struct s10 b, struct s11 c, struct s12 d,
|
---|
| 93 | struct s13 e, struct s14 f)
|
---|
| 94 | {
|
---|
| 95 | printf("%.3s %.3s %.3s %.3s %.3s %.3s\n", a.x, b.x, c.x, d.x, e.x, f.x);
|
---|
| 96 | }
|
---|
| 97 |
|
---|
| 98 | void fa3(struct hfa14 a, struct hfa23 b, struct hfa32 c)
|
---|
| 99 | {
|
---|
| 100 | printf("%.1f %.1f %.1f %.1f %.1Lf %.1Lf\n",
|
---|
| 101 | a.a, a.d, b.a, b.c, c.a, c.b);
|
---|
| 102 | }
|
---|
| 103 |
|
---|
| 104 | void fa4(struct s1 a, struct hfa14 b, struct s2 c, struct hfa24 d,
|
---|
| 105 | struct s3 e, struct hfa34 f)
|
---|
| 106 | {
|
---|
| 107 | printf("%.1s %.1f %.1f %.2s %.1f %.1f %.3s %.1Lf %.1Lf\n",
|
---|
| 108 | a.x, b.a, b.d, c.x, d.a, d.d, e.x, f.a, f.d);
|
---|
| 109 | }
|
---|
| 110 |
|
---|
| 111 | void arg(void)
|
---|
| 112 | {
|
---|
| 113 | printf("Arguments:\n");
|
---|
| 114 | fa_s1(s1);
|
---|
| 115 | fa_s2(s2);
|
---|
| 116 | fa_s3(s3);
|
---|
| 117 | fa_s4(s4);
|
---|
| 118 | fa_s5(s5);
|
---|
| 119 | fa_s6(s6);
|
---|
| 120 | fa_s7(s7);
|
---|
| 121 | fa_s8(s8);
|
---|
| 122 | fa_s9(s9);
|
---|
| 123 | fa_s10(s10);
|
---|
| 124 | fa_s11(s11);
|
---|
| 125 | fa_s12(s12);
|
---|
| 126 | fa_s13(s13);
|
---|
| 127 | fa_s14(s14);
|
---|
| 128 | fa_s15(s15);
|
---|
| 129 | fa_s16(s16);
|
---|
| 130 | fa_s17(s17);
|
---|
| 131 | fa_hfa11(hfa11);
|
---|
| 132 | fa_hfa12(hfa12);
|
---|
| 133 | fa_hfa13(hfa13);
|
---|
| 134 | fa_hfa14(hfa14);
|
---|
| 135 | fa_hfa21(hfa21);
|
---|
| 136 | fa_hfa22(hfa22);
|
---|
| 137 | fa_hfa23(hfa23);
|
---|
| 138 | fa_hfa24(hfa24);
|
---|
| 139 | fa_hfa31(hfa31);
|
---|
| 140 | fa_hfa32(hfa32);
|
---|
| 141 | fa_hfa33(hfa33);
|
---|
| 142 | fa_hfa34(hfa34);
|
---|
| 143 | fa1(s8, s9, s10, s11, s12, s13);
|
---|
| 144 | fa2(s9, s10, s11, s12, s13, s14);
|
---|
| 145 | fa3(hfa14, hfa23, hfa32);
|
---|
| 146 | fa4(s1, hfa14, s2, hfa24, s3, hfa34);
|
---|
| 147 | }
|
---|
| 148 |
|
---|
| 149 | struct s1 fr_s1(void) { return s1; }
|
---|
| 150 | struct s2 fr_s2(void) { return s2; }
|
---|
| 151 | struct s3 fr_s3(void) { return s3; }
|
---|
| 152 | struct s4 fr_s4(void) { return s4; }
|
---|
| 153 | struct s5 fr_s5(void) { return s5; }
|
---|
| 154 | struct s6 fr_s6(void) { return s6; }
|
---|
| 155 | struct s7 fr_s7(void) { return s7; }
|
---|
| 156 | struct s8 fr_s8(void) { return s8; }
|
---|
| 157 | struct s9 fr_s9(void) { return s9; }
|
---|
| 158 | struct s10 fr_s10(void) { return s10; }
|
---|
| 159 | struct s11 fr_s11(void) { return s11; }
|
---|
| 160 | struct s12 fr_s12(void) { return s12; }
|
---|
| 161 | struct s13 fr_s13(void) { return s13; }
|
---|
| 162 | struct s14 fr_s14(void) { return s14; }
|
---|
| 163 | struct s15 fr_s15(void) { return s15; }
|
---|
| 164 | struct s16 fr_s16(void) { return s16; }
|
---|
| 165 | struct s17 fr_s17(void) { return s17; }
|
---|
| 166 |
|
---|
| 167 | struct hfa11 fr_hfa11(void) { return hfa11; }
|
---|
| 168 | struct hfa12 fr_hfa12(void) { return hfa12; }
|
---|
| 169 | struct hfa13 fr_hfa13(void) { return hfa13; }
|
---|
| 170 | struct hfa14 fr_hfa14(void) { return hfa14; }
|
---|
| 171 |
|
---|
| 172 | struct hfa21 fr_hfa21(void) { return hfa21; }
|
---|
| 173 | struct hfa22 fr_hfa22(void) { return hfa22; }
|
---|
| 174 | struct hfa23 fr_hfa23(void) { return hfa23; }
|
---|
| 175 | struct hfa24 fr_hfa24(void) { return hfa24; }
|
---|
| 176 |
|
---|
| 177 | struct hfa31 fr_hfa31(void) { return hfa31; }
|
---|
| 178 | struct hfa32 fr_hfa32(void) { return hfa32; }
|
---|
| 179 | struct hfa33 fr_hfa33(void) { return hfa33; }
|
---|
| 180 | struct hfa34 fr_hfa34(void) { return hfa34; }
|
---|
| 181 |
|
---|
| 182 | void ret(void)
|
---|
| 183 | {
|
---|
| 184 | struct s1 t1 = fr_s1();
|
---|
| 185 | struct s2 t2 = fr_s2();
|
---|
| 186 | struct s3 t3 = fr_s3();
|
---|
| 187 | struct s4 t4 = fr_s4();
|
---|
| 188 | struct s5 t5 = fr_s5();
|
---|
| 189 | struct s6 t6 = fr_s6();
|
---|
| 190 | struct s7 t7 = fr_s7();
|
---|
| 191 | struct s8 t8 = fr_s8();
|
---|
| 192 | struct s9 t9 = fr_s9();
|
---|
| 193 | struct s10 t10 = fr_s10();
|
---|
| 194 | struct s11 t11 = fr_s11();
|
---|
| 195 | struct s12 t12 = fr_s12();
|
---|
| 196 | struct s13 t13 = fr_s13();
|
---|
| 197 | struct s14 t14 = fr_s14();
|
---|
| 198 | struct s15 t15 = fr_s15();
|
---|
| 199 | struct s16 t16 = fr_s16();
|
---|
| 200 | struct s17 t17 = fr_s17();
|
---|
| 201 | printf("Return values:\n");
|
---|
| 202 | printf("%.1s\n", t1.x);
|
---|
| 203 | printf("%.2s\n", t2.x);
|
---|
| 204 | printf("%.3s\n", t3.x);
|
---|
| 205 | printf("%.4s\n", t4.x);
|
---|
| 206 | printf("%.5s\n", t5.x);
|
---|
| 207 | printf("%.6s\n", t6.x);
|
---|
| 208 | printf("%.7s\n", t7.x);
|
---|
| 209 | printf("%.8s\n", t8.x);
|
---|
| 210 | printf("%.9s\n", t9.x);
|
---|
| 211 | printf("%.10s\n", t10.x);
|
---|
| 212 | printf("%.11s\n", t11.x);
|
---|
| 213 | printf("%.12s\n", t12.x);
|
---|
| 214 | printf("%.13s\n", t13.x);
|
---|
| 215 | printf("%.14s\n", t14.x);
|
---|
| 216 | printf("%.15s\n", t15.x);
|
---|
| 217 | printf("%.16s\n", t16.x);
|
---|
| 218 | printf("%.17s\n", t17.x);
|
---|
| 219 | printf("%.1f\n", fr_hfa11().a);
|
---|
| 220 | printf("%.1f %.1f\n", fr_hfa12().a, fr_hfa12().b);
|
---|
| 221 | printf("%.1f %.1f\n", fr_hfa13().a, fr_hfa13().c);
|
---|
| 222 | printf("%.1f %.1f\n", fr_hfa14().a, fr_hfa14().d);
|
---|
| 223 | printf("%.1f\n", fr_hfa21().a);
|
---|
| 224 | printf("%.1f %.1f\n", fr_hfa22().a, fr_hfa22().b);
|
---|
| 225 | printf("%.1f %.1f\n", fr_hfa23().a, fr_hfa23().c);
|
---|
| 226 | printf("%.1f %.1f\n", fr_hfa24().a, fr_hfa24().d);
|
---|
| 227 | printf("%.1Lf\n", fr_hfa31().a);
|
---|
| 228 | printf("%.1Lf %.1Lf\n", fr_hfa32().a, fr_hfa32().b);
|
---|
| 229 | printf("%.1Lf %.1Lf\n", fr_hfa33().a, fr_hfa33().c);
|
---|
| 230 | printf("%.1Lf %.1Lf\n", fr_hfa34().a, fr_hfa34().d);
|
---|
| 231 | }
|
---|
| 232 |
|
---|
| 233 | int match(const char **s, const char *f)
|
---|
| 234 | {
|
---|
| 235 | const char *p = *s;
|
---|
| 236 | for (p = *s; *f && *f == *p; f++, p++)
|
---|
| 237 | ;
|
---|
| 238 | if (!*f) {
|
---|
| 239 | *s = p - 1;
|
---|
| 240 | return 1;
|
---|
| 241 | }
|
---|
| 242 | return 0;
|
---|
| 243 | }
|
---|
| 244 |
|
---|
| 245 | void myprintf(const char *format, ...)
|
---|
| 246 | {
|
---|
| 247 | const char *s;
|
---|
| 248 | va_list ap;
|
---|
| 249 | va_start(ap, format);
|
---|
| 250 | for (s = format; *s; s++) {
|
---|
| 251 | if (match(&s, "%7s")) {
|
---|
| 252 | struct s7 t7 = va_arg(ap, struct s7);
|
---|
| 253 | printf("%.7s", t7.x);
|
---|
| 254 | }
|
---|
| 255 | else if (match(&s, "%9s")) {
|
---|
| 256 | struct s9 t9 = va_arg(ap, struct s9);
|
---|
| 257 | printf("%.9s", t9.x);
|
---|
| 258 | }
|
---|
| 259 | else if (match(&s, "%hfa11")) {
|
---|
| 260 | struct hfa11 x = va_arg(ap, struct hfa11);
|
---|
| 261 | printf("%.1f,%.1f", x.a, x.a);
|
---|
| 262 | }
|
---|
| 263 | else if (match(&s, "%hfa12")) {
|
---|
| 264 | struct hfa12 x = va_arg(ap, struct hfa12);
|
---|
| 265 | printf("%.1f,%.1f", x.a, x.b);
|
---|
| 266 | }
|
---|
| 267 | else if (match(&s, "%hfa13")) {
|
---|
| 268 | struct hfa13 x = va_arg(ap, struct hfa13);
|
---|
| 269 | printf("%.1f,%.1f", x.a, x.c);
|
---|
| 270 | }
|
---|
| 271 | else if (match(&s, "%hfa14")) {
|
---|
| 272 | struct hfa14 x = va_arg(ap, struct hfa14);
|
---|
| 273 | printf("%.1f,%.1f", x.a, x.d);
|
---|
| 274 | }
|
---|
| 275 | else if (match(&s, "%hfa21")) {
|
---|
| 276 | struct hfa21 x = va_arg(ap, struct hfa21);
|
---|
| 277 | printf("%.1f,%.1f", x.a, x.a);
|
---|
| 278 | }
|
---|
| 279 | else if (match(&s, "%hfa22")) {
|
---|
| 280 | struct hfa22 x = va_arg(ap, struct hfa22);
|
---|
| 281 | printf("%.1f,%.1f", x.a, x.b);
|
---|
| 282 | }
|
---|
| 283 | else if (match(&s, "%hfa23")) {
|
---|
| 284 | struct hfa23 x = va_arg(ap, struct hfa23);
|
---|
| 285 | printf("%.1f,%.1f", x.a, x.c);
|
---|
| 286 | }
|
---|
| 287 | else if (match(&s, "%hfa24")) {
|
---|
| 288 | struct hfa24 x = va_arg(ap, struct hfa24);
|
---|
| 289 | printf("%.1f,%.1f", x.a, x.d);
|
---|
| 290 | }
|
---|
| 291 | else if (match(&s, "%hfa31")) {
|
---|
| 292 | struct hfa31 x = va_arg(ap, struct hfa31);
|
---|
| 293 | printf("%.1Lf,%.1Lf", x.a, x.a);
|
---|
| 294 | }
|
---|
| 295 | else if (match(&s, "%hfa32")) {
|
---|
| 296 | struct hfa32 x = va_arg(ap, struct hfa32);
|
---|
| 297 | printf("%.1Lf,%.1Lf", x.a, x.b);
|
---|
| 298 | }
|
---|
| 299 | else if (match(&s, "%hfa33")) {
|
---|
| 300 | struct hfa33 x = va_arg(ap, struct hfa33);
|
---|
| 301 | printf("%.1Lf,%.1Lf", x.a, x.c);
|
---|
| 302 | }
|
---|
| 303 | else if (match(&s, "%hfa34")) {
|
---|
| 304 | struct hfa34 x = va_arg(ap, struct hfa34);
|
---|
| 305 | printf("%.1Lf,%.1Lf", x.a, x.d);
|
---|
| 306 | }
|
---|
| 307 | else
|
---|
| 308 | putchar(*s);
|
---|
| 309 | }
|
---|
| 310 | putchar('\n');
|
---|
| 311 | }
|
---|
| 312 |
|
---|
| 313 | void stdarg(void)
|
---|
| 314 | {
|
---|
| 315 | printf("stdarg:\n");
|
---|
| 316 | myprintf("%9s %9s %9s %9s %9s %9s", s9, s9, s9, s9, s9, s9);
|
---|
| 317 | myprintf("%7s %9s %9s %9s %9s %9s", s7, s9, s9, s9, s9, s9);
|
---|
| 318 |
|
---|
| 319 | myprintf("HFA long double:");
|
---|
| 320 | myprintf("%hfa34 %hfa34 %hfa34 %hfa34", hfa34, hfa34, hfa34, hfa34);
|
---|
| 321 | myprintf("%hfa33 %hfa34 %hfa34 %hfa34", hfa33, hfa34, hfa34, hfa34);
|
---|
| 322 | myprintf("%hfa32 %hfa34 %hfa34 %hfa34", hfa32, hfa34, hfa34, hfa34);
|
---|
| 323 | myprintf("%hfa31 %hfa34 %hfa34 %hfa34", hfa31, hfa34, hfa34, hfa34);
|
---|
| 324 |
|
---|
| 325 | myprintf("%hfa32 %hfa33 %hfa33 %hfa33 %hfa33",
|
---|
| 326 | hfa32, hfa33, hfa33, hfa33, hfa33);
|
---|
| 327 | myprintf("%hfa31 %hfa33 %hfa33 %hfa33 %hfa33",
|
---|
| 328 | hfa31, hfa33, hfa33, hfa33, hfa33);
|
---|
| 329 | myprintf("%hfa33 %hfa33 %hfa33 %hfa33",
|
---|
| 330 | hfa33, hfa33, hfa33, hfa33);
|
---|
| 331 |
|
---|
| 332 | myprintf("%hfa34 %hfa32 %hfa32 %hfa32 %hfa32",
|
---|
| 333 | hfa34, hfa32, hfa32, hfa32, hfa32);
|
---|
| 334 | myprintf("%hfa33 %hfa32 %hfa32 %hfa32 %hfa32",
|
---|
| 335 | hfa33, hfa32, hfa32, hfa32, hfa32);
|
---|
| 336 |
|
---|
| 337 | myprintf("%hfa34 %hfa32 %hfa31 %hfa31 %hfa31 %hfa31",
|
---|
| 338 | hfa34, hfa32, hfa31, hfa31, hfa31, hfa31);
|
---|
| 339 |
|
---|
| 340 | myprintf("HFA double:");
|
---|
| 341 | myprintf("%hfa24 %hfa24 %hfa24 %hfa24", hfa24, hfa24, hfa24, hfa24);
|
---|
| 342 | myprintf("%hfa23 %hfa24 %hfa24 %hfa24", hfa23, hfa24, hfa24, hfa24);
|
---|
| 343 | myprintf("%hfa22 %hfa24 %hfa24 %hfa24", hfa22, hfa24, hfa24, hfa24);
|
---|
| 344 | myprintf("%hfa21 %hfa24 %hfa24 %hfa24", hfa21, hfa24, hfa24, hfa24);
|
---|
| 345 |
|
---|
| 346 | myprintf("%hfa22 %hfa23 %hfa23 %hfa23 %hfa23",
|
---|
| 347 | hfa22, hfa23, hfa23, hfa23, hfa23);
|
---|
| 348 | myprintf("%hfa21 %hfa23 %hfa23 %hfa23 %hfa23",
|
---|
| 349 | hfa21, hfa23, hfa23, hfa23, hfa23);
|
---|
| 350 | myprintf("%hfa23 %hfa23 %hfa23 %hfa23",
|
---|
| 351 | hfa23, hfa23, hfa23, hfa23);
|
---|
| 352 |
|
---|
| 353 | myprintf("%hfa24 %hfa22 %hfa22 %hfa22 %hfa22",
|
---|
| 354 | hfa24, hfa22, hfa22, hfa22, hfa22);
|
---|
| 355 | myprintf("%hfa23 %hfa22 %hfa22 %hfa22 %hfa22",
|
---|
| 356 | hfa23, hfa22, hfa22, hfa22, hfa22);
|
---|
| 357 |
|
---|
| 358 | myprintf("%hfa24 %hfa22 %hfa21 %hfa21 %hfa21 %hfa21",
|
---|
| 359 | hfa24, hfa22, hfa21, hfa21, hfa21, hfa21);
|
---|
| 360 |
|
---|
| 361 | myprintf("HFA float:");
|
---|
| 362 | myprintf("%hfa14 %hfa14 %hfa14 %hfa14", hfa14, hfa14, hfa14, hfa14);
|
---|
| 363 | myprintf("%hfa13 %hfa14 %hfa14 %hfa14", hfa13, hfa14, hfa14, hfa14);
|
---|
| 364 | myprintf("%hfa12 %hfa14 %hfa14 %hfa14", hfa12, hfa14, hfa14, hfa14);
|
---|
| 365 | myprintf("%hfa11 %hfa14 %hfa14 %hfa14", hfa11, hfa14, hfa14, hfa14);
|
---|
| 366 |
|
---|
| 367 | myprintf("%hfa12 %hfa13 %hfa13 %hfa13 %hfa13",
|
---|
| 368 | hfa12, hfa13, hfa13, hfa13, hfa13);
|
---|
| 369 | myprintf("%hfa11 %hfa13 %hfa13 %hfa13 %hfa13",
|
---|
| 370 | hfa11, hfa13, hfa13, hfa13, hfa13);
|
---|
| 371 | myprintf("%hfa13 %hfa13 %hfa13 %hfa13",
|
---|
| 372 | hfa13, hfa13, hfa13, hfa13);
|
---|
| 373 |
|
---|
| 374 | myprintf("%hfa14 %hfa12 %hfa12 %hfa12 %hfa12",
|
---|
| 375 | hfa14, hfa12, hfa12, hfa12, hfa12);
|
---|
| 376 | myprintf("%hfa13 %hfa12 %hfa12 %hfa12 %hfa12",
|
---|
| 377 | hfa13, hfa12, hfa12, hfa12, hfa12);
|
---|
| 378 |
|
---|
| 379 | myprintf("%hfa14 %hfa12 %hfa11 %hfa11 %hfa11 %hfa11",
|
---|
| 380 | hfa14, hfa12, hfa11, hfa11, hfa11, hfa11);
|
---|
| 381 | }
|
---|
| 382 |
|
---|
| 383 | void pll(unsigned long long x)
|
---|
| 384 | {
|
---|
| 385 | printf("%llx\n", x);
|
---|
| 386 | }
|
---|
| 387 |
|
---|
| 388 | void movi(void)
|
---|
| 389 | {
|
---|
| 390 | printf("MOVI:\n");
|
---|
| 391 | pll(0);
|
---|
| 392 | pll(0xabcd);
|
---|
| 393 | pll(0xabcd0000);
|
---|
| 394 | pll(0xabcd00000000);
|
---|
| 395 | pll(0xabcd000000000000);
|
---|
| 396 | pll(0xffffabcd);
|
---|
| 397 | pll(0xabcdffff);
|
---|
| 398 | pll(0xffffffffffffabcd);
|
---|
| 399 | pll(0xffffffffabcdffff);
|
---|
| 400 | pll(0xffffabcdffffffff);
|
---|
| 401 | pll(0xabcdffffffffffff);
|
---|
| 402 | pll(0xaaaaaaaa);
|
---|
| 403 | pll(0x5555555555555555);
|
---|
| 404 | pll(0x77777777);
|
---|
| 405 | pll(0x3333333333333333);
|
---|
| 406 | pll(0xf8f8f8f8);
|
---|
| 407 | pll(0x1e1e1e1e1e1e1e1e);
|
---|
| 408 | pll(0x3f803f80);
|
---|
| 409 | pll(0x01ff01ff01ff01ff);
|
---|
| 410 | pll(0x007fffc0);
|
---|
| 411 | pll(0x03fff80003fff800);
|
---|
| 412 | pll(0x0007fffffffffe00);
|
---|
| 413 |
|
---|
| 414 | pll(0xabcd1234);
|
---|
| 415 | pll(0xabcd00001234);
|
---|
| 416 | pll(0xabcd000000001234);
|
---|
| 417 | pll(0xabcd12340000);
|
---|
| 418 | pll(0xabcd000012340000);
|
---|
| 419 | pll(0xabcd123400000000);
|
---|
| 420 | pll(0xffffffffabcd1234);
|
---|
| 421 | pll(0xffffabcdffff1234);
|
---|
| 422 | pll(0xabcdffffffff1234);
|
---|
| 423 | pll(0xffffabcd1234ffff);
|
---|
| 424 | pll(0xabcdffff1234ffff);
|
---|
| 425 | pll(0xabcd1234ffffffff);
|
---|
| 426 |
|
---|
| 427 | pll(0xffffef0123456789);
|
---|
| 428 | pll(0xabcdef012345ffff);
|
---|
| 429 |
|
---|
| 430 | pll(0xabcdef0123456789);
|
---|
| 431 | }
|
---|
| 432 |
|
---|
| 433 | static uint32_t addip0(uint32_t x) { return x + 0; }
|
---|
| 434 | static uint64_t sublp0(uint64_t x) { return x - 0; }
|
---|
| 435 | static uint32_t addip123(uint32_t x) { return x + 123; }
|
---|
| 436 | static uint64_t addlm123(uint64_t x) { return x + -123; }
|
---|
| 437 | static uint64_t sublp4095(uint64_t x) { return x - 4095; }
|
---|
| 438 | static uint32_t subim503808(uint32_t x) { return x - -503808; }
|
---|
| 439 | static uint64_t addp12345(uint64_t x) { return x + 12345; }
|
---|
| 440 | static uint32_t subp12345(uint32_t x) { return x - 12345; }
|
---|
| 441 |
|
---|
| 442 | static uint32_t mvni(uint32_t x) { return 0xffffffff - x; }
|
---|
| 443 | static uint64_t negl(uint64_t x) { return 0 - x; }
|
---|
| 444 | static uint32_t rsbi123(uint32_t x) { return 123 - x; }
|
---|
| 445 | static uint64_t rsbl123(uint64_t x) { return 123 - x; }
|
---|
| 446 |
|
---|
| 447 | static uint32_t andi0(uint32_t x) { return x & 0; }
|
---|
| 448 | static uint64_t andlm1(uint64_t x) { return x & -1; }
|
---|
| 449 | static uint64_t orrl0(uint64_t x) { return x | 0; }
|
---|
| 450 | static uint32_t orrim1(uint32_t x) { return x | -1; }
|
---|
| 451 | static uint32_t eori0(uint32_t x) { return x ^ 0; }
|
---|
| 452 | static uint64_t eorlm1(uint64_t x) { return x ^ -1; }
|
---|
| 453 | static uint32_t and0xf0(uint32_t x) { return x & 0xf0; }
|
---|
| 454 | static uint64_t orr0xf0(uint64_t x) { return x | 0xf0; }
|
---|
| 455 | static uint64_t eor0xf0(uint64_t x) { return x ^ 0xf0; }
|
---|
| 456 |
|
---|
| 457 | static uint32_t lsli0(uint32_t x) { return x << 0; }
|
---|
| 458 | static uint32_t lsri0(uint32_t x) { return x >> 0; }
|
---|
| 459 | static int64_t asrl0(int64_t x) { return x >> 0; }
|
---|
| 460 | static uint32_t lsli1(uint32_t x) { return x << 1; }
|
---|
| 461 | static uint32_t lsli31(uint32_t x) { return x << 31; }
|
---|
| 462 | static uint64_t lsll1(uint64_t x) { return x << 1; }
|
---|
| 463 | static uint64_t lsll63(uint64_t x) { return x << 63; }
|
---|
| 464 | static uint32_t lsri1(uint32_t x) { return x >> 1; }
|
---|
| 465 | static uint32_t lsri31(uint32_t x) { return x >> 31; }
|
---|
| 466 | static uint64_t lsrl1(uint64_t x) { return x >> 1; }
|
---|
| 467 | static uint64_t lsrl63(uint64_t x) { return x >> 63; }
|
---|
| 468 | static int32_t asri1(int32_t x) { return x >> 1; }
|
---|
| 469 | static int32_t asri31(int32_t x) { return x >> 31; }
|
---|
| 470 | static int64_t asrl1(int64_t x) { return x >> 1; }
|
---|
| 471 | static int64_t asrl63(int64_t x) { return x >> 63; }
|
---|
| 472 |
|
---|
| 473 | void opi(void)
|
---|
| 474 | {
|
---|
| 475 | int x = 1000;
|
---|
| 476 | pll(addip0(x));
|
---|
| 477 | pll(sublp0(x));
|
---|
| 478 | pll(addip123(x));
|
---|
| 479 | pll(addlm123(x));
|
---|
| 480 | pll(sublp4095(x));
|
---|
| 481 | pll(subim503808(x));
|
---|
| 482 | pll(addp12345(x));
|
---|
| 483 | pll(subp12345(x));
|
---|
| 484 | pll(mvni(x));
|
---|
| 485 | pll(negl(x));
|
---|
| 486 | pll(rsbi123(x));
|
---|
| 487 | pll(rsbl123(x));
|
---|
| 488 | pll(andi0(x));
|
---|
| 489 | pll(andlm1(x));
|
---|
| 490 | pll(orrl0(x));
|
---|
| 491 | pll(orrim1(x));
|
---|
| 492 | pll(eori0(x));
|
---|
| 493 | pll(eorlm1(x));
|
---|
| 494 | pll(and0xf0(x));
|
---|
| 495 | pll(orr0xf0(x));
|
---|
| 496 | pll(eor0xf0(x));
|
---|
| 497 | pll(lsli0(x));
|
---|
| 498 | pll(lsri0(x));
|
---|
| 499 | pll(asrl0(x));
|
---|
| 500 | pll(lsli1(x));
|
---|
| 501 | pll(lsli31(x));
|
---|
| 502 | pll(lsll1(x));
|
---|
| 503 | pll(lsll63(x));
|
---|
| 504 | pll(lsri1(x));
|
---|
| 505 | pll(lsri31(x));
|
---|
| 506 | pll(lsrl1(x));
|
---|
| 507 | pll(lsrl63(x));
|
---|
| 508 | pll(asri1(x));
|
---|
| 509 | pll(asri31(x));
|
---|
| 510 | pll(asrl1(x));
|
---|
| 511 | pll(asrl63(x));
|
---|
| 512 | }
|
---|
| 513 |
|
---|
| 514 | void pcs(void)
|
---|
| 515 | {
|
---|
| 516 | arg();
|
---|
| 517 | ret();
|
---|
| 518 | stdarg();
|
---|
| 519 | movi();
|
---|
| 520 | opi();
|
---|
| 521 | }
|
---|
| 522 |
|
---|
| 523 | int main()
|
---|
| 524 | {
|
---|
| 525 | pcs();
|
---|
| 526 | return 0;
|
---|
| 527 | }
|
---|