root / hostregs_helper.h @ e6bb7d7e
History | View | Annotate | Download (2.1 kB)
1 | 1057eaa7 | pbrook | /*
|
---|---|---|---|
2 | 1057eaa7 | pbrook | * Save/restore host registrs.
|
3 | 1057eaa7 | pbrook | *
|
4 | 1057eaa7 | pbrook | * Copyright (c) 2007 CodeSourcery
|
5 | 1057eaa7 | pbrook | *
|
6 | 1057eaa7 | pbrook | * This library is free software; you can redistribute it and/or
|
7 | 1057eaa7 | pbrook | * modify it under the terms of the GNU Lesser General Public
|
8 | 1057eaa7 | pbrook | * License as published by the Free Software Foundation; either
|
9 | 1057eaa7 | pbrook | * version 2 of the License, or (at your option) any later version.
|
10 | 1057eaa7 | pbrook | *
|
11 | 1057eaa7 | pbrook | * This library is distributed in the hope that it will be useful,
|
12 | 1057eaa7 | pbrook | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | 1057eaa7 | pbrook | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | 1057eaa7 | pbrook | * Lesser General Public License for more details.
|
15 | 1057eaa7 | pbrook | *
|
16 | 1057eaa7 | pbrook | * You should have received a copy of the GNU Lesser General Public
|
17 | 1057eaa7 | pbrook | * License along with this library; if not, write to the Free Software
|
18 | 1057eaa7 | pbrook | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
19 | 1057eaa7 | pbrook | */
|
20 | 1057eaa7 | pbrook | |
21 | 1057eaa7 | pbrook | /* The GCC global register vairable extension is used to reserve some
|
22 | 1057eaa7 | pbrook | host registers for use by dyngen. However only the core parts of the
|
23 | 1057eaa7 | pbrook | translation engine are compiled with these settings. We must manually
|
24 | 1057eaa7 | pbrook | save/restore these registers when called from regular code.
|
25 | 1057eaa7 | pbrook | It is not sufficient to save/restore T0 et. al. as these may be declared
|
26 | 1057eaa7 | pbrook | with a datatype smaller than the actual register. */
|
27 | 1057eaa7 | pbrook | |
28 | 1057eaa7 | pbrook | #if defined(DECLARE_HOST_REGS)
|
29 | 1057eaa7 | pbrook | |
30 | 1057eaa7 | pbrook | #define DO_REG(REG) \
|
31 | 1057eaa7 | pbrook | register host_reg_t reg_AREG##REG asm(AREG##REG); \ |
32 | 1057eaa7 | pbrook | volatile host_reg_t saved_AREG##REG; |
33 | 1057eaa7 | pbrook | |
34 | 1057eaa7 | pbrook | #elif defined(SAVE_HOST_REGS)
|
35 | 1057eaa7 | pbrook | |
36 | 1057eaa7 | pbrook | #define DO_REG(REG) \
|
37 | 1057eaa7 | pbrook | __asm__ __volatile__ ("" : "=r" (reg_AREG##REG)); \ |
38 | 1057eaa7 | pbrook | saved_AREG##REG = reg_AREG##REG; |
39 | 1057eaa7 | pbrook | |
40 | 1057eaa7 | pbrook | #else
|
41 | 1057eaa7 | pbrook | |
42 | 1057eaa7 | pbrook | #define DO_REG(REG) \
|
43 | 1057eaa7 | pbrook | reg_AREG##REG = saved_AREG##REG; \ |
44 | 1057eaa7 | pbrook | __asm__ __volatile__ ("" : : "r" (reg_AREG##REG)); |
45 | 1057eaa7 | pbrook | |
46 | 1057eaa7 | pbrook | #endif
|
47 | 1057eaa7 | pbrook | |
48 | 1057eaa7 | pbrook | #ifdef AREG0
|
49 | 1057eaa7 | pbrook | DO_REG(0)
|
50 | 1057eaa7 | pbrook | #endif
|
51 | 1057eaa7 | pbrook | |
52 | 1057eaa7 | pbrook | #ifdef AREG1
|
53 | 1057eaa7 | pbrook | DO_REG(1)
|
54 | 1057eaa7 | pbrook | #endif
|
55 | 1057eaa7 | pbrook | |
56 | 1057eaa7 | pbrook | #ifdef AREG2
|
57 | 1057eaa7 | pbrook | DO_REG(2)
|
58 | 1057eaa7 | pbrook | #endif
|
59 | 1057eaa7 | pbrook | |
60 | 1057eaa7 | pbrook | #ifdef AREG3
|
61 | 1057eaa7 | pbrook | DO_REG(3)
|
62 | 1057eaa7 | pbrook | #endif
|
63 | 1057eaa7 | pbrook | |
64 | 1057eaa7 | pbrook | #ifdef AREG4
|
65 | 1057eaa7 | pbrook | DO_REG(4)
|
66 | 1057eaa7 | pbrook | #endif
|
67 | 1057eaa7 | pbrook | |
68 | 1057eaa7 | pbrook | #ifdef AREG5
|
69 | 1057eaa7 | pbrook | DO_REG(5)
|
70 | 1057eaa7 | pbrook | #endif
|
71 | 1057eaa7 | pbrook | |
72 | 1057eaa7 | pbrook | #ifdef AREG6
|
73 | 1057eaa7 | pbrook | DO_REG(6)
|
74 | 1057eaa7 | pbrook | #endif
|
75 | 1057eaa7 | pbrook | |
76 | 1057eaa7 | pbrook | #ifdef AREG7
|
77 | 1057eaa7 | pbrook | DO_REG(7)
|
78 | 1057eaa7 | pbrook | #endif
|
79 | 1057eaa7 | pbrook | |
80 | 1057eaa7 | pbrook | #ifdef AREG8
|
81 | 1057eaa7 | pbrook | DO_REG(8)
|
82 | 1057eaa7 | pbrook | #endif
|
83 | 1057eaa7 | pbrook | |
84 | 1057eaa7 | pbrook | #ifdef AREG9
|
85 | 1057eaa7 | pbrook | DO_REG(9)
|
86 | 1057eaa7 | pbrook | #endif
|
87 | 1057eaa7 | pbrook | |
88 | 1057eaa7 | pbrook | #ifdef AREG10
|
89 | 1057eaa7 | pbrook | DO_REG(10)
|
90 | 1057eaa7 | pbrook | #endif
|
91 | 1057eaa7 | pbrook | |
92 | 1057eaa7 | pbrook | #ifdef AREG11
|
93 | 1057eaa7 | pbrook | DO_REG(11)
|
94 | 1057eaa7 | pbrook | #endif
|
95 | 1057eaa7 | pbrook | |
96 | 1057eaa7 | pbrook | #undef SAVE_HOST_REGS
|
97 | 1057eaa7 | pbrook | #undef DECLARE_HOST_REGS
|
98 | 1057eaa7 | pbrook | #undef DO_REG |