1 |
+ |
/* Define usage of "reserved" registers */ |
2 |
+ |
#if defined(__linux__) |
3 |
+ |
#define SYSTEM_CLOBBERS_R2 1 /* Pointer to Thread Local Storage */ |
4 |
+ |
#define SYSTEM_CLOBBERS_R13 1 /* Pointer to .sdata section */ |
5 |
+ |
#endif |
6 |
+ |
|
7 |
+ |
#ifdef __ASSEMBLY__ |
8 |
+ |
/* Helper macros */ |
9 |
+ |
#ifdef SYSTEM_CLOBBERS_R2 |
10 |
+ |
#define RESTORE_SYSTEM_R2 lwz r2,XLM_TOC(0) |
11 |
+ |
#define SAVE_SYSTEM_R2 stw r2,XLM_TOC(0) |
12 |
+ |
#else |
13 |
+ |
#define RESTORE_SYSTEM_R2 |
14 |
+ |
#define SAVE_SYSTEM_R2 |
15 |
+ |
#endif |
16 |
+ |
#ifdef SYSTEM_CLOBBERS_R13 |
17 |
+ |
#define RESTORE_SYSTEM_R13 lwz r13,XLM_R13(0) |
18 |
+ |
#define SAVE_SYSTEM_R13 stw r13,XLM_R13(0) |
19 |
+ |
#else |
20 |
+ |
#define RESTORE_SYSTEM_R13 |
21 |
+ |
#define SAVE_SYSTEM_R13 |
22 |
+ |
#endif |
23 |
+ |
|
24 |
+ |
/* Helper macros */ |
25 |
+ |
#define xglue(x, y) x ## y |
26 |
+ |
#define glue(x, y) xglue(x, y) |
27 |
+ |
|
28 |
+ |
/* Apple assembler perticularities */ |
29 |
+ |
#if (defined(__APPLE__) && defined(__MACH__)) |
30 |
+ |
#define C_SYMBOL_NAME(NAME) glue(_, NAME) |
31 |
+ |
#define ASM_TYPE(NAME, TYPE) /* nothing */ |
32 |
+ |
#define ASM_ALIGN_2(EXP) EXP |
33 |
+ |
#define ASM_HA16(VAR) ha16(VAR) |
34 |
+ |
#define ASM_LO16(VAR) lo16(VAR) |
35 |
+ |
#define ASM_MACRO_END .endmacro |
36 |
+ |
#define ASM_MACRO_ARG_SEP , |
37 |
+ |
#define ASM_MACRO_ARG0_DEF /* nothing! */ |
38 |
+ |
#define ASM_MACRO_ARG0 $0 |
39 |
+ |
#define ASM_MACRO_ARG1_DEF /* nothing! */ |
40 |
+ |
#define ASM_MACRO_ARG1 $1 |
41 |
+ |
#define ASM_MACRO_ARG2_DEF /* nothing! */ |
42 |
+ |
#define ASM_MACRO_ARG2 $2 |
43 |
+ |
#define ASM_MACRO_ARG3_DEF /* nothing! */ |
44 |
+ |
#define ASM_MACRO_ARG3 $3 |
45 |
+ |
#endif |
46 |
+ |
|
47 |
+ |
/* Defaults for GNU assembler */ |
48 |
+ |
#ifndef ASM_TYPE |
49 |
+ |
#define ASM_TYPE(NAME, TYPE) .type NAME, TYPE |
50 |
+ |
#endif |
51 |
+ |
#ifndef ASM_ALIGN_2 |
52 |
+ |
#define ASM_ALIGN_2(EXP) (1 << (EXP)) |
53 |
+ |
#endif |
54 |
+ |
#ifndef ASM_HA16 |
55 |
+ |
#define ASM_HA16(VAR) VAR@ha |
56 |
+ |
#endif |
57 |
+ |
#ifndef ASM_LO16 |
58 |
+ |
#define ASM_LO16(VAR) VAR@l |
59 |
+ |
#endif |
60 |
+ |
#ifndef ASM_MACRO_START |
61 |
+ |
#define ASM_MACRO_START .macro |
62 |
+ |
#endif |
63 |
+ |
#ifndef ASM_MACRO_END |
64 |
+ |
#define ASM_MACRO_END .endm |
65 |
+ |
#endif |
66 |
+ |
#ifndef ASM_MACRO_ARG_SEP |
67 |
+ |
#define ASM_MACRO_ARG_SEP |
68 |
+ |
#endif |
69 |
+ |
#ifndef ASM_MACRO_ARG0_DEF |
70 |
+ |
#define ASM_MACRO_ARG0_DEF __asm_macro_arg0 |
71 |
+ |
#define ASM_MACRO_ARG0 \__asm_macro_arg0 |
72 |
+ |
#define ASM_MACRO_ARG1_DEF , __asm_macro_arg1 |
73 |
+ |
#define ASM_MACRO_ARG1 \__asm_macro_arg1 |
74 |
+ |
#define ASM_MACRO_ARG2_DEF , __asm_macro_arg2 |
75 |
+ |
#define ASM_MACRO_ARG2 \__asm_macro_arg2 |
76 |
+ |
#define ASM_MACRO_ARG3_DEF , __asm_macro_arg3 |
77 |
+ |
#define ASM_MACRO_ARG3 \__asm_macro_arg3 |
78 |
+ |
#endif |
79 |
+ |
#ifndef C_SYMBOL_NAME |
80 |
+ |
#define C_SYMBOL_NAME(NAME) NAME |
81 |
+ |
#endif |
82 |
+ |
#ifndef ASM_GLOBAL_DIRECTIVE |
83 |
+ |
#define ASM_GLOBAL_DIRECTIVE .globl |
84 |
+ |
#endif |
85 |
+ |
|
86 |
|
/* Register names */ |
87 |
+ |
#if defined(__linux__) || defined(__NetBSD__) |
88 |
|
#define r0 0 |
89 |
|
#define r1 1 |
90 |
|
#define r2 2 |
117 |
|
#define r29 29 |
118 |
|
#define r30 30 |
119 |
|
#define r31 31 |
120 |
+ |
#endif |
121 |
|
|
122 |
+ |
#if defined(__linux__) || defined(__NetBSD__) |
123 |
|
#define f0 0 |
124 |
|
#define f1 1 |
125 |
|
#define f2 2 |
152 |
|
#define f29 29 |
153 |
|
#define f30 30 |
154 |
|
#define f31 31 |
155 |
+ |
#endif |
156 |
+ |
#endif |