xref: /dflybsd-src/contrib/gcc-4.7/gcc/addresses.h (revision 04febcfb30580676d3e95f58a16c5137ee478b32)
1*e4b17023SJohn Marino /* Inline functions to test validity of reg classes for addressing modes.
2*e4b17023SJohn Marino    Copyright (C) 2006, 2007, 2010 Free Software Foundation, Inc.
3*e4b17023SJohn Marino 
4*e4b17023SJohn Marino This file is part of GCC.
5*e4b17023SJohn Marino 
6*e4b17023SJohn Marino GCC is free software; you can redistribute it and/or modify it under
7*e4b17023SJohn Marino the terms of the GNU General Public License as published by the Free
8*e4b17023SJohn Marino Software Foundation; either version 3, or (at your option) any later
9*e4b17023SJohn Marino version.
10*e4b17023SJohn Marino 
11*e4b17023SJohn Marino GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12*e4b17023SJohn Marino WARRANTY; without even the implied warranty of MERCHANTABILITY or
13*e4b17023SJohn Marino FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14*e4b17023SJohn Marino for more details.
15*e4b17023SJohn Marino 
16*e4b17023SJohn Marino You should have received a copy of the GNU General Public License
17*e4b17023SJohn Marino along with GCC; see the file COPYING3.  If not see
18*e4b17023SJohn Marino <http://www.gnu.org/licenses/>.  */
19*e4b17023SJohn Marino 
20*e4b17023SJohn Marino /* Wrapper function to unify target macros MODE_CODE_BASE_REG_CLASS,
21*e4b17023SJohn Marino    MODE_BASE_REG_REG_CLASS, MODE_BASE_REG_CLASS and BASE_REG_CLASS.
22*e4b17023SJohn Marino    Arguments as for the MODE_CODE_BASE_REG_CLASS macro.  */
23*e4b17023SJohn Marino 
24*e4b17023SJohn Marino static inline enum reg_class
base_reg_class(enum machine_mode mode ATTRIBUTE_UNUSED,addr_space_t as ATTRIBUTE_UNUSED,enum rtx_code outer_code ATTRIBUTE_UNUSED,enum rtx_code index_code ATTRIBUTE_UNUSED)25*e4b17023SJohn Marino base_reg_class (enum machine_mode mode ATTRIBUTE_UNUSED,
26*e4b17023SJohn Marino 		addr_space_t as ATTRIBUTE_UNUSED,
27*e4b17023SJohn Marino 		enum rtx_code outer_code ATTRIBUTE_UNUSED,
28*e4b17023SJohn Marino 		enum rtx_code index_code ATTRIBUTE_UNUSED)
29*e4b17023SJohn Marino {
30*e4b17023SJohn Marino #ifdef MODE_CODE_BASE_REG_CLASS
31*e4b17023SJohn Marino   return MODE_CODE_BASE_REG_CLASS (mode, as, outer_code, index_code);
32*e4b17023SJohn Marino #else
33*e4b17023SJohn Marino #ifdef MODE_BASE_REG_REG_CLASS
34*e4b17023SJohn Marino   if (index_code == REG)
35*e4b17023SJohn Marino     return MODE_BASE_REG_REG_CLASS (mode);
36*e4b17023SJohn Marino #endif
37*e4b17023SJohn Marino #ifdef MODE_BASE_REG_CLASS
38*e4b17023SJohn Marino   return MODE_BASE_REG_CLASS (mode);
39*e4b17023SJohn Marino #else
40*e4b17023SJohn Marino   return BASE_REG_CLASS;
41*e4b17023SJohn Marino #endif
42*e4b17023SJohn Marino #endif
43*e4b17023SJohn Marino }
44*e4b17023SJohn Marino 
45*e4b17023SJohn Marino /* Wrapper function to unify target macros REGNO_MODE_CODE_OK_FOR_BASE_P,
46*e4b17023SJohn Marino    REGNO_MODE_OK_FOR_REG_BASE_P, REGNO_MODE_OK_FOR_BASE_P and
47*e4b17023SJohn Marino    REGNO_OK_FOR_BASE_P.
48*e4b17023SJohn Marino    Arguments as for the REGNO_MODE_CODE_OK_FOR_BASE_P macro.  */
49*e4b17023SJohn Marino 
50*e4b17023SJohn Marino static inline bool
ok_for_base_p_1(unsigned regno ATTRIBUTE_UNUSED,enum machine_mode mode ATTRIBUTE_UNUSED,addr_space_t as ATTRIBUTE_UNUSED,enum rtx_code outer_code ATTRIBUTE_UNUSED,enum rtx_code index_code ATTRIBUTE_UNUSED)51*e4b17023SJohn Marino ok_for_base_p_1 (unsigned regno ATTRIBUTE_UNUSED,
52*e4b17023SJohn Marino 		 enum machine_mode mode ATTRIBUTE_UNUSED,
53*e4b17023SJohn Marino 		 addr_space_t as ATTRIBUTE_UNUSED,
54*e4b17023SJohn Marino 		 enum rtx_code outer_code ATTRIBUTE_UNUSED,
55*e4b17023SJohn Marino 		 enum rtx_code index_code ATTRIBUTE_UNUSED)
56*e4b17023SJohn Marino {
57*e4b17023SJohn Marino #ifdef REGNO_MODE_CODE_OK_FOR_BASE_P
58*e4b17023SJohn Marino   return REGNO_MODE_CODE_OK_FOR_BASE_P (regno, mode, as,
59*e4b17023SJohn Marino 					outer_code, index_code);
60*e4b17023SJohn Marino #else
61*e4b17023SJohn Marino #ifdef REGNO_MODE_OK_FOR_REG_BASE_P
62*e4b17023SJohn Marino   if (index_code == REG)
63*e4b17023SJohn Marino     return REGNO_MODE_OK_FOR_REG_BASE_P (regno, mode);
64*e4b17023SJohn Marino #endif
65*e4b17023SJohn Marino #ifdef REGNO_MODE_OK_FOR_BASE_P
66*e4b17023SJohn Marino   return REGNO_MODE_OK_FOR_BASE_P (regno, mode);
67*e4b17023SJohn Marino #else
68*e4b17023SJohn Marino   return REGNO_OK_FOR_BASE_P (regno);
69*e4b17023SJohn Marino #endif
70*e4b17023SJohn Marino #endif
71*e4b17023SJohn Marino }
72*e4b17023SJohn Marino 
73*e4b17023SJohn Marino /* Wrapper around ok_for_base_p_1, for use after register allocation is
74*e4b17023SJohn Marino    complete.  Arguments as for the called function.  */
75*e4b17023SJohn Marino 
76*e4b17023SJohn Marino static inline bool
regno_ok_for_base_p(unsigned regno,enum machine_mode mode,addr_space_t as,enum rtx_code outer_code,enum rtx_code index_code)77*e4b17023SJohn Marino regno_ok_for_base_p (unsigned regno, enum machine_mode mode, addr_space_t as,
78*e4b17023SJohn Marino 		     enum rtx_code outer_code, enum rtx_code index_code)
79*e4b17023SJohn Marino {
80*e4b17023SJohn Marino   if (regno >= FIRST_PSEUDO_REGISTER && reg_renumber[regno] >= 0)
81*e4b17023SJohn Marino     regno = reg_renumber[regno];
82*e4b17023SJohn Marino 
83*e4b17023SJohn Marino   return ok_for_base_p_1 (regno, mode, as, outer_code, index_code);
84*e4b17023SJohn Marino }
85