2 * Save/restore host registrs.
4 * Copyright (c) 2007 CodeSourcery
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA
21 /* The GCC global register variable extension is used to reserve some
22 host registers for use by generated code. However only the core parts of
23 the translation engine are compiled with these settings. We must manually
24 save/restore these registers when called from regular code.
25 It is not sufficient to save/restore T0 et. al. as these may be declared
26 with a datatype smaller than the actual register. */
28 #if defined(DECLARE_HOST_REGS)
31 register host_reg_t reg_AREG##REG asm(AREG##REG); \
32 volatile host_reg_t saved_AREG##REG;
34 #elif defined(SAVE_HOST_REGS)
37 __asm__ __volatile__ ("" : "=r" (reg_AREG##REG)); \
38 saved_AREG##REG = reg_AREG##REG;
43 reg_AREG##REG = saved_AREG##REG; \
44 __asm__ __volatile__ ("" : : "r" (reg_AREG##REG));
61 #undef DECLARE_HOST_REGS