|
15 | 15 | /** |
16 | 16 | * @file |
17 | 17 | * |
18 | | - * ABI-related register definitions helpful when writing assembly code. |
| 18 | + * ABI-related register definitions. |
19 | 19 | */ |
20 | 20 |
|
21 | 21 | #ifndef __ARCH_ABI_H__ |
22 | | -#define __ARCH_ABI_H__ |
23 | 22 |
|
24 | | -#include <arch/chip.h> |
| 23 | +#if !defined __need_int_reg_t && !defined __DOXYGEN__ |
| 24 | +# define __ARCH_ABI_H__ |
| 25 | +# include <arch/chip.h> |
| 26 | +#endif |
| 27 | + |
| 28 | +/* Provide the basic machine types. */ |
| 29 | +#ifndef __INT_REG_BITS |
| 30 | + |
| 31 | +/** Number of bits in a register. */ |
| 32 | +#if defined __tilegx__ |
| 33 | +# define __INT_REG_BITS 64 |
| 34 | +#elif defined __tilepro__ |
| 35 | +# define __INT_REG_BITS 32 |
| 36 | +#elif !defined __need_int_reg_t |
| 37 | +# include <arch/chip.h> |
| 38 | +# define __INT_REG_BITS CHIP_WORD_SIZE() |
| 39 | +#else |
| 40 | +# error Unrecognized architecture with __need_int_reg_t |
| 41 | +#endif |
| 42 | + |
| 43 | +#if __INT_REG_BITS == 64 |
| 44 | + |
| 45 | +#ifndef __ASSEMBLER__ |
| 46 | +/** Unsigned type that can hold a register. */ |
| 47 | +typedef unsigned long long __uint_reg_t; |
| 48 | + |
| 49 | +/** Signed type that can hold a register. */ |
| 50 | +typedef long long __int_reg_t; |
| 51 | +#endif |
| 52 | + |
| 53 | +/** String prefix to use for printf(). */ |
| 54 | +#define __INT_REG_FMT "ll" |
| 55 | + |
| 56 | +#else |
| 57 | + |
| 58 | +#ifndef __ASSEMBLER__ |
| 59 | +/** Unsigned type that can hold a register. */ |
| 60 | +typedef unsigned long __uint_reg_t; |
| 61 | + |
| 62 | +/** Signed type that can hold a register. */ |
| 63 | +typedef long __int_reg_t; |
| 64 | +#endif |
| 65 | + |
| 66 | +/** String prefix to use for printf(). */ |
| 67 | +#define __INT_REG_FMT "l" |
| 68 | + |
| 69 | +#endif |
| 70 | +#endif /* __INT_REG_BITS */ |
| 71 | + |
| 72 | + |
| 73 | +#ifndef __need_int_reg_t |
| 74 | + |
| 75 | + |
| 76 | +#ifndef __ASSEMBLER__ |
| 77 | +/** Unsigned type that can hold a register. */ |
| 78 | +typedef __uint_reg_t uint_reg_t; |
| 79 | + |
| 80 | +/** Signed type that can hold a register. */ |
| 81 | +typedef __int_reg_t int_reg_t; |
| 82 | +#endif |
| 83 | + |
| 84 | +/** String prefix to use for printf(). */ |
| 85 | +#define INT_REG_FMT __INT_REG_FMT |
| 86 | + |
| 87 | +/** Number of bits in a register. */ |
| 88 | +#define INT_REG_BITS __INT_REG_BITS |
| 89 | + |
25 | 90 |
|
26 | 91 | /* Registers 0 - 55 are "normal", but some perform special roles. */ |
27 | 92 |
|
|
59 | 124 | * The ABI requires callers to allocate a caller state save area of |
60 | 125 | * this many bytes at the bottom of each stack frame. |
61 | 126 | */ |
62 | | -#define C_ABI_SAVE_AREA_SIZE (2 * (CHIP_WORD_SIZE() / 8)) |
| 127 | +#define C_ABI_SAVE_AREA_SIZE (2 * (INT_REG_BITS / 8)) |
63 | 128 |
|
64 | 129 | /** |
65 | 130 | * The operand to an 'info' opcode directing the backtracer to not |
66 | 131 | * try to find the calling frame. |
67 | 132 | */ |
68 | 133 | #define INFO_OP_CANNOT_BACKTRACE 2 |
69 | 134 |
|
70 | | -#ifndef __ASSEMBLER__ |
71 | | -#if CHIP_WORD_SIZE() > 32 |
72 | 135 |
|
73 | | -/** Unsigned type that can hold a register. */ |
74 | | -typedef unsigned long long uint_reg_t; |
| 136 | +#endif /* !__need_int_reg_t */ |
75 | 137 |
|
76 | | -/** Signed type that can hold a register. */ |
77 | | -typedef long long int_reg_t; |
78 | | - |
79 | | -/** String prefix to use for printf(). */ |
80 | | -#define INT_REG_FMT "ll" |
81 | | - |
82 | | -#elif !defined(__LP64__) /* avoid confusion with LP64 cross-build tools */ |
83 | | - |
84 | | -/** Unsigned type that can hold a register. */ |
85 | | -typedef unsigned long uint_reg_t; |
86 | | - |
87 | | -/** Signed type that can hold a register. */ |
88 | | -typedef long int_reg_t; |
89 | | - |
90 | | -/** String prefix to use for printf(). */ |
91 | | -#define INT_REG_FMT "l" |
92 | | - |
93 | | -#endif |
94 | | -#endif /* __ASSEMBLER__ */ |
| 138 | +/* Make sure we later can get all the definitions and declarations. */ |
| 139 | +#undef __need_int_reg_t |
95 | 140 |
|
96 | 141 | #endif /* !__ARCH_ABI_H__ */ |
0 commit comments