| 1 |
#include <stdarg.h> |
| 2 |
|
| 3 |
typedef unsigned long long ull __attribute__((aligned(ALIGN))); |
| 4 |
|
| 5 |
#ifndef EXTRA |
| 6 |
#define EXTRA unsigned long long x; |
| 7 |
#endif |
| 8 |
|
| 9 |
struct S1 { __attribute__((aligned(1))) ull i : 1; EXTRA }; |
| 10 |
struct S2 { __attribute__((aligned(2))) ull i : 1; EXTRA }; |
| 11 |
struct S4 { __attribute__((aligned(4))) ull i : 1; EXTRA }; |
| 12 |
struct S8 { __attribute__((aligned(8))) ull i : 1; EXTRA }; |
| 13 |
struct S16 { __attribute__((aligned(16))) ull i : 1; EXTRA }; |
| 14 |
|
| 15 |
struct Sp { ull i : 1; EXTRA }__attribute__((packed)); |
| 16 |
struct S1p { __attribute__((packed, aligned(1))) ull i : 1; EXTRA }; |
| 17 |
struct S2p { __attribute__((packed, aligned(2))) ull i : 1; EXTRA }; |
| 18 |
struct S4p { __attribute__((packed, aligned(4))) ull i : 1; EXTRA }; |
| 19 |
struct S8p { __attribute__((packed, aligned(8))) ull i : 1; EXTRA }; |
| 20 |
struct S16p { __attribute__((packed, aligned(16))) ull i : 1; EXTRA }; |
| 21 |
|
| 22 |
/* Bitfield in registers. */ |
| 23 |
#define PARAMS(xx) int a0, struct S##xx s, ull a1 |
| 24 |
/* Bitfield passed by the stack. */ |
| 25 |
#define PARAMS_STACK(xx) int a0, ull a1, ull a2, ull a3, ull a4, ull a5, ull a6, ull a7, ull a8, struct S##xx t |
| 26 |
/* Bitfield passed via stdarg. */ |
| 27 |
#define PARAMS_STDARG(xx) int a0, ... |
| 28 |
|
| 29 |
#define CODE(xx) \ |
| 30 |
return s.i; |
| 31 |
|
| 32 |
#define CODE_STACK(xx) \ |
| 33 |
return t.i; |
| 34 |
|
| 35 |
#define CODE_STDARG(xx) \ |
| 36 |
va_list ap; \ |
| 37 |
struct S##xx arg; \ |
| 38 |
__builtin_va_start(ap,a0); \ |
| 39 |
arg = __builtin_va_arg(ap, struct S##xx); \ |
| 40 |
return arg.i; |
| 41 |
|
| 42 |
#define ARGS(xx) x, (struct S##xx) { x }, x |
| 43 |
#define ARGS_STACK(xx) x, x, x, x, x, x, x, x, x, (struct S##xx) { x } |
| 44 |
#define ARGS_STDARG(xx) x, (struct S##xx) { x } |
| 45 |
|
| 46 |
/* Bitfield in registers. */ |
| 47 |
int __attribute__ ((noipa)) f1 (PARAMS(1)) { CODE(1) } |
| 48 |
int __attribute__ ((noipa)) f2 (PARAMS(2)) { CODE(2) } |
| 49 |
int __attribute__ ((noipa)) f4 (PARAMS(4)) { CODE(4) } |
| 50 |
int __attribute__ ((noipa)) f8 (PARAMS(8)) { CODE(8) } |
| 51 |
int __attribute__ ((noipa)) f16(PARAMS(16)) { CODE(16) } |
| 52 |
|
| 53 |
int __attribute__ ((noipa)) fp (PARAMS(p)) { CODE(p) } |
| 54 |
int __attribute__ ((noipa)) f1p (PARAMS(1p)) { CODE(1p) } |
| 55 |
int __attribute__ ((noipa)) f2p (PARAMS(2p)) { CODE(2p) } |
| 56 |
int __attribute__ ((noipa)) f4p (PARAMS(4p)) { CODE(4p) } |
| 57 |
int __attribute__ ((noipa)) f8p (PARAMS(8p)) { CODE(8p) } |
| 58 |
int __attribute__ ((noipa)) f16p(PARAMS(16p)) { CODE(16p) } |
| 59 |
|
| 60 |
int g1 (int x) { return f1 (ARGS(1)); } |
| 61 |
int g2 (int x) { return f2 (ARGS(2)); } |
| 62 |
int g4 (int x) { return f4 (ARGS(4)); } |
| 63 |
int g8 (int x) { return f8 (ARGS(8)); } |
| 64 |
int g16(int x) { return f16 (ARGS(16)); } |
| 65 |
|
| 66 |
int gp (int x) { return fp (ARGS(p)); } |
| 67 |
int g1p (int x) { return f1p (ARGS(1p)); } |
| 68 |
int g2p (int x) { return f2p (ARGS(2p)); } |
| 69 |
int g4p (int x) { return f4p (ARGS(4p)); } |
| 70 |
int g8p (int x) { return f8p (ARGS(8p)); } |
| 71 |
int g16p(int x) { return f16p (ARGS(16p)); } |
| 72 |
|
| 73 |
/* Bitfield in the stack. */ |
| 74 |
int __attribute__ ((noipa)) f1_stack (PARAMS_STACK(1)) { CODE_STACK(1) } |
| 75 |
int __attribute__ ((noipa)) f2_stack (PARAMS_STACK(2)) { CODE_STACK(2) } |
| 76 |
int __attribute__ ((noipa)) f4_stack (PARAMS_STACK(4)) { CODE_STACK(4) } |
| 77 |
int __attribute__ ((noipa)) f8_stack (PARAMS_STACK(8)) { CODE_STACK(8) } |
| 78 |
int __attribute__ ((noipa)) f16_stack(PARAMS_STACK(16)) { CODE_STACK(16) } |
| 79 |
|
| 80 |
int __attribute__ ((noipa)) fp_stack (PARAMS_STACK(p)) { CODE_STACK(p) } |
| 81 |
int __attribute__ ((noipa)) f1p_stack (PARAMS_STACK(1p)) { CODE_STACK(1p) } |
| 82 |
int __attribute__ ((noipa)) f2p_stack (PARAMS_STACK(2p)) { CODE_STACK(2p) } |
| 83 |
int __attribute__ ((noipa)) f4p_stack (PARAMS_STACK(4p)) { CODE_STACK(4p) } |
| 84 |
int __attribute__ ((noipa)) f8p_stack (PARAMS_STACK(8p)) { CODE_STACK(8p) } |
| 85 |
int __attribute__ ((noipa)) f16p_stack(PARAMS_STACK(16p)) { CODE_STACK(16p) } |
| 86 |
|
| 87 |
int g1_stack (int x) { return f1_stack (ARGS_STACK(1)); } |
| 88 |
int g2_stack (int x) { return f2_stack (ARGS_STACK(2)); } |
| 89 |
int g4_stack (int x) { return f4_stack (ARGS_STACK(4)); } |
| 90 |
int g8_stack (int x) { return f8_stack (ARGS_STACK(8)); } |
| 91 |
int g16_stack(int x) { return f16_stack (ARGS_STACK(16)); } |
| 92 |
|
| 93 |
int gp_stack (int x) { return fp_stack (ARGS_STACK(p)); } |
| 94 |
int g1p_stack (int x) { return f1p_stack (ARGS_STACK(1p)); } |
| 95 |
int g2p_stack (int x) { return f2p_stack (ARGS_STACK(2p)); } |
| 96 |
int g4p_stack (int x) { return f4p_stack (ARGS_STACK(4p)); } |
| 97 |
int g8p_stack (int x) { return f8p_stack (ARGS_STACK(8p)); } |
| 98 |
int g16p_stack(int x) { return f16p_stack (ARGS_STACK(16p)); } |
| 99 |
|
| 100 |
/* Bitfield via stdarg. */ |
| 101 |
int __attribute__ ((noipa)) f1_stdarg (PARAMS_STDARG(1)) { CODE_STDARG(1) } |
| 102 |
int __attribute__ ((noipa)) f2_stdarg (PARAMS_STDARG(2)) { CODE_STDARG(2) } |
| 103 |
int __attribute__ ((noipa)) f4_stdarg (PARAMS_STDARG(4)) { CODE_STDARG(4) } |
| 104 |
int __attribute__ ((noipa)) f8_stdarg (PARAMS_STDARG(8)) { CODE_STDARG(8) } |
| 105 |
int __attribute__ ((noipa)) f16_stdarg(PARAMS_STDARG(16)) { CODE_STDARG(16) } |
| 106 |
|
| 107 |
int __attribute__ ((noipa)) fp_stdarg (PARAMS_STDARG(p)) { CODE_STDARG(p) } |
| 108 |
int __attribute__ ((noipa)) f1p_stdarg (PARAMS_STDARG(1p)) { CODE_STDARG(1p) } |
| 109 |
int __attribute__ ((noipa)) f2p_stdarg (PARAMS_STDARG(2p)) { CODE_STDARG(2p) } |
| 110 |
int __attribute__ ((noipa)) f4p_stdarg (PARAMS_STDARG(4p)) { CODE_STDARG(4p) } |
| 111 |
int __attribute__ ((noipa)) f8p_stdarg (PARAMS_STDARG(8p)) { CODE_STDARG(8p) } |
| 112 |
int __attribute__ ((noipa)) f16p_stdarg(PARAMS_STDARG(16p)) { CODE_STDARG(16p) } |
| 113 |
|
| 114 |
int g1_stdarg (int x) { return f1_stdarg (ARGS_STDARG(1)); } |
| 115 |
int g2_stdarg (int x) { return f2_stdarg (ARGS_STDARG(2)); } |
| 116 |
int g4_stdarg (int x) { return f4_stdarg (ARGS_STDARG(4)); } |
| 117 |
int g8_stdarg (int x) { return f8_stdarg (ARGS_STDARG(8)); } |
| 118 |
int g16_stdarg(int x) { return f16_stdarg (ARGS_STDARG(16)); } |
| 119 |
|
| 120 |
int gp_stdarg (int x) { return fp_stdarg (ARGS_STDARG(p)); } |
| 121 |
int g1p_stdarg (int x) { return f1p_stdarg (ARGS_STDARG(1p)); } |
| 122 |
int g2p_stdarg (int x) { return f2p_stdarg (ARGS_STDARG(2p)); } |
| 123 |
int g4p_stdarg (int x) { return f4p_stdarg (ARGS_STDARG(4p)); } |
| 124 |
int g8p_stdarg (int x) { return f8p_stdarg (ARGS_STDARG(8p)); } |
| 125 |
int g16p_stdarg(int x) { return f16p_stdarg (ARGS_STDARG(16p)); } |