| 1 |
#include <stdarg.h> |
| 2 |
|
| 3 |
typedef unsigned _BitInt(63) BI __attribute__((aligned(ALIGN))); |
| 4 |
|
| 5 |
#ifndef EXTRA |
| 6 |
#define EXTRA unsigned long long x; |
| 7 |
#endif |
| 8 |
|
| 9 |
struct S1 { __attribute__((aligned(1))) BI i : 1; EXTRA }; |
| 10 |
struct S8 { __attribute__((aligned(8))) BI i : 1; EXTRA }; |
| 11 |
struct S16 { __attribute__((aligned(16))) BI i : 1; EXTRA }; |
| 12 |
|
| 13 |
struct Sp { BI i : 1; EXTRA }__attribute__((packed)); |
| 14 |
struct S1p { __attribute__((packed, aligned(1))) BI i : 1; EXTRA }; |
| 15 |
struct S8p { __attribute__((packed, aligned(8))) BI i : 1; EXTRA }; |
| 16 |
struct S16p { __attribute__((packed, aligned(16))) BI i : 1; EXTRA }; |
| 17 |
|
| 18 |
/* Bitfield in registers. */ |
| 19 |
#define PARAMS(xx) int a0, struct S##xx s, BI a1 |
| 20 |
/* Bitfield passed by the stack. */ |
| 21 |
#define PARAMS_STACK(xx) int a0, BI a1, BI a2, BI a3, BI a4, BI a5, BI a6, BI a7, BI a8, struct S##xx t |
| 22 |
/* Bitfield passed via stdarg. */ |
| 23 |
#define PARAMS_STDARG(xx) int a0, ... |
| 24 |
|
| 25 |
#define CODE(xx) \ |
| 26 |
return s.i; |
| 27 |
|
| 28 |
#define CODE_STACK(xx) \ |
| 29 |
return t.i; |
| 30 |
|
| 31 |
#define CODE_STDARG(xx) \ |
| 32 |
va_list ap; \ |
| 33 |
struct S##xx arg; \ |
| 34 |
__builtin_va_start(ap,a0); \ |
| 35 |
arg = __builtin_va_arg(ap, struct S##xx); \ |
| 36 |
return arg.i; |
| 37 |
|
| 38 |
#define ARGS(xx) y, (struct S##xx) { x }, x |
| 39 |
#define ARGS_STACK(xx) y, y, y, y, y, y, y, y, y, (struct S##xx) { x } |
| 40 |
#define ARGS_STDARG(xx) y, (struct S##xx) { x } |
| 41 |
|
| 42 |
/* Bitfield in registers. */ |
| 43 |
_BitInt(63) __attribute__ ((noipa)) f1 (PARAMS(1)) { CODE(1) } |
| 44 |
_BitInt(63) __attribute__ ((noipa)) f8 (PARAMS(8)) { CODE(8) } |
| 45 |
_BitInt(63) __attribute__ ((noipa)) f16(PARAMS(16)) { CODE(16) } |
| 46 |
|
| 47 |
_BitInt(63) __attribute__ ((noipa)) fp (PARAMS(p)) { CODE(p) } |
| 48 |
_BitInt(63) __attribute__ ((noipa)) f1p (PARAMS(1p)) { CODE(1p) } |
| 49 |
_BitInt(63) __attribute__ ((noipa)) f8p (PARAMS(8p)) { CODE(8p) } |
| 50 |
_BitInt(63) __attribute__ ((noipa)) f16p(PARAMS(16p)) { CODE(16p) } |
| 51 |
|
| 52 |
_BitInt(63) g1 (_BitInt(63) x, int y) { return f1 (ARGS(1)); } |
| 53 |
_BitInt(63) g8 (_BitInt(63) x, int y) { return f8 (ARGS(8)); } |
| 54 |
_BitInt(63) g16(_BitInt(63) x, int y) { return f16 (ARGS(16)); } |
| 55 |
|
| 56 |
_BitInt(63) gp (_BitInt(63) x, int y) { return fp (ARGS(p)); } |
| 57 |
_BitInt(63) g1p (_BitInt(63) x, int y) { return f1p (ARGS(1p)); } |
| 58 |
_BitInt(63) g8p (_BitInt(63) x, int y) { return f8p (ARGS(8p)); } |
| 59 |
_BitInt(63) g16p(_BitInt(63) x, int y) { return f16p (ARGS(16p)); } |
| 60 |
|
| 61 |
/* Bitfield in the stack. */ |
| 62 |
_BitInt(63) __attribute__ ((noipa)) f1_stack (PARAMS_STACK(1)) { CODE_STACK(1) } |
| 63 |
_BitInt(63) __attribute__ ((noipa)) f8_stack (PARAMS_STACK(8)) { CODE_STACK(8) } |
| 64 |
_BitInt(63) __attribute__ ((noipa)) f16_stack(PARAMS_STACK(16)) { CODE_STACK(16) } |
| 65 |
|
| 66 |
_BitInt(63) __attribute__ ((noipa)) fp_stack (PARAMS_STACK(p)) { CODE_STACK(p) } |
| 67 |
_BitInt(63) __attribute__ ((noipa)) f1p_stack (PARAMS_STACK(1p)) { CODE_STACK(1p) } |
| 68 |
_BitInt(63) __attribute__ ((noipa)) f8p_stack (PARAMS_STACK(8p)) { CODE_STACK(8p) } |
| 69 |
_BitInt(63) __attribute__ ((noipa)) f16p_stack(PARAMS_STACK(16p)) { CODE_STACK(16p) } |
| 70 |
|
| 71 |
|
| 72 |
_BitInt(63) g1_stack (_BitInt(63) x, int y) { return f1_stack (ARGS_STACK(1)); } |
| 73 |
_BitInt(63) g8_stack (_BitInt(63) x, int y) { return f8_stack (ARGS_STACK(8)); } |
| 74 |
_BitInt(63) g16_stack(_BitInt(63) x, int y) { return f16_stack (ARGS_STACK(16)); } |
| 75 |
|
| 76 |
_BitInt(63) gp_stack (_BitInt(63) x, int y) { return fp_stack (ARGS_STACK(p)); } |
| 77 |
_BitInt(63) g1p_stack (_BitInt(63) x, int y) { return f1p_stack (ARGS_STACK(1p)); } |
| 78 |
_BitInt(63) g8p_stack (_BitInt(63) x, int y) { return f8p_stack (ARGS_STACK(8p)); } |
| 79 |
_BitInt(63) g16p_stack(_BitInt(63) x, int y) { return f16p_stack (ARGS_STACK(16p)); } |
| 80 |
|
| 81 |
|
| 82 |
/* Bitfield via stdarg. */ |
| 83 |
_BitInt(63) __attribute__ ((noipa)) f1_stdarg (PARAMS_STDARG(1)) { CODE_STDARG(1) } |
| 84 |
_BitInt(63) __attribute__ ((noipa)) f8_stdarg (PARAMS_STDARG(8)) { CODE_STDARG(8) } |
| 85 |
_BitInt(63) __attribute__ ((noipa)) f16_stdarg(PARAMS_STDARG(16)) { CODE_STDARG(16) } |
| 86 |
|
| 87 |
_BitInt(63) __attribute__ ((noipa)) fp_stdarg (PARAMS_STDARG(p)) { CODE_STDARG(p) } |
| 88 |
_BitInt(63) __attribute__ ((noipa)) f1p_stdarg (PARAMS_STDARG(1p)) { CODE_STDARG(1p) } |
| 89 |
_BitInt(63) __attribute__ ((noipa)) f8p_stdarg (PARAMS_STDARG(8p)) { CODE_STDARG(8p) } |
| 90 |
_BitInt(63) __attribute__ ((noipa)) f16p_stdarg(PARAMS_STDARG(16p)) { CODE_STDARG(16p) } |
| 91 |
|
| 92 |
_BitInt(63) g1_stdarg (_BitInt(63) x, int y) { return f1_stdarg (ARGS_STDARG(1)); } |
| 93 |
_BitInt(63) g8_stdarg (_BitInt(63) x, int y) { return f8_stdarg (ARGS_STDARG(8)); } |
| 94 |
_BitInt(63) g16_stdarg(_BitInt(63) x, int y) { return f16_stdarg (ARGS_STDARG(16)); } |
| 95 |
|
| 96 |
_BitInt(63) gp_stdarg (_BitInt(63) x, int y) { return fp_stdarg (ARGS_STDARG(p)); } |
| 97 |
_BitInt(63) g1p_stdarg (_BitInt(63) x, int y) { return f1p_stdarg (ARGS_STDARG(1p)); } |
| 98 |
_BitInt(63) g8p_stdarg (_BitInt(63) x, int y) { return f8p_stdarg (ARGS_STDARG(8p)); } |
| 99 |
_BitInt(63) g16p_stdarg(_BitInt(63) x, int y) { return f16p_stdarg (ARGS_STDARG(16p)); } |
| 100 |
|
| 101 |
|