root / hostregs_helper.h @ 94909d9f
History | View | Annotate | Download (1.8 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 | fad6cb1a | aurel32 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA
|
19 | 1057eaa7 | pbrook | */
|
20 | 1057eaa7 | pbrook | |
21 | 54604f74 | aurel32 | /* The GCC global register variable extension is used to reserve some
|
22 | 54604f74 | aurel32 | host registers for use by generated code. However only the core parts of
|
23 | 54604f74 | aurel32 | the 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 | #undef SAVE_HOST_REGS
|
61 | 1057eaa7 | pbrook | #undef DECLARE_HOST_REGS
|
62 | 1057eaa7 | pbrook | #undef DO_REG |