xref: /dragonfly/contrib/gcc-4.7/gcc/targhooks.c (revision e4b17023)
1*e4b17023SJohn Marino /* Default target hook functions.
2*e4b17023SJohn Marino    Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
3*e4b17023SJohn Marino    Free Software Foundation, Inc.
4*e4b17023SJohn Marino 
5*e4b17023SJohn Marino This file is part of GCC.
6*e4b17023SJohn Marino 
7*e4b17023SJohn Marino GCC is free software; you can redistribute it and/or modify it under
8*e4b17023SJohn Marino the terms of the GNU General Public License as published by the Free
9*e4b17023SJohn Marino Software Foundation; either version 3, or (at your option) any later
10*e4b17023SJohn Marino version.
11*e4b17023SJohn Marino 
12*e4b17023SJohn Marino GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13*e4b17023SJohn Marino WARRANTY; without even the implied warranty of MERCHANTABILITY or
14*e4b17023SJohn Marino FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15*e4b17023SJohn Marino for more details.
16*e4b17023SJohn Marino 
17*e4b17023SJohn Marino You should have received a copy of the GNU General Public License
18*e4b17023SJohn Marino along with GCC; see the file COPYING3.  If not see
19*e4b17023SJohn Marino <http://www.gnu.org/licenses/>.  */
20*e4b17023SJohn Marino 
21*e4b17023SJohn Marino /* The migration of target macros to target hooks works as follows:
22*e4b17023SJohn Marino 
23*e4b17023SJohn Marino    1. Create a target hook that uses the existing target macros to
24*e4b17023SJohn Marino       implement the same functionality.
25*e4b17023SJohn Marino 
26*e4b17023SJohn Marino    2. Convert all the MI files to use the hook instead of the macro.
27*e4b17023SJohn Marino 
28*e4b17023SJohn Marino    3. Repeat for a majority of the remaining target macros.  This will
29*e4b17023SJohn Marino       take some time.
30*e4b17023SJohn Marino 
31*e4b17023SJohn Marino    4. Tell target maintainers to start migrating.
32*e4b17023SJohn Marino 
33*e4b17023SJohn Marino    5. Eventually convert the backends to override the hook instead of
34*e4b17023SJohn Marino       defining the macros.  This will take some time too.
35*e4b17023SJohn Marino 
36*e4b17023SJohn Marino    6. TBD when, poison the macros.  Unmigrated targets will break at
37*e4b17023SJohn Marino       this point.
38*e4b17023SJohn Marino 
39*e4b17023SJohn Marino    Note that we expect steps 1-3 to be done by the people that
40*e4b17023SJohn Marino    understand what the MI does with each macro, and step 5 to be done
41*e4b17023SJohn Marino    by the target maintainers for their respective targets.
42*e4b17023SJohn Marino 
43*e4b17023SJohn Marino    Note that steps 1 and 2 don't have to be done together, but no
44*e4b17023SJohn Marino    target can override the new hook until step 2 is complete for it.
45*e4b17023SJohn Marino 
46*e4b17023SJohn Marino    Once the macros are poisoned, we will revert to the old migration
47*e4b17023SJohn Marino    rules - migrate the macro, callers, and targets all at once.  This
48*e4b17023SJohn Marino    comment can thus be removed at that point.  */
49*e4b17023SJohn Marino 
50*e4b17023SJohn Marino #include "config.h"
51*e4b17023SJohn Marino #include "system.h"
52*e4b17023SJohn Marino #include "coretypes.h"
53*e4b17023SJohn Marino #include "tm.h"
54*e4b17023SJohn Marino #include "machmode.h"
55*e4b17023SJohn Marino #include "rtl.h"
56*e4b17023SJohn Marino #include "tree.h"
57*e4b17023SJohn Marino #include "expr.h"
58*e4b17023SJohn Marino #include "output.h"
59*e4b17023SJohn Marino #include "diagnostic-core.h"
60*e4b17023SJohn Marino #include "function.h"
61*e4b17023SJohn Marino #include "target.h"
62*e4b17023SJohn Marino #include "tm_p.h"
63*e4b17023SJohn Marino #include "target-def.h"
64*e4b17023SJohn Marino #include "ggc.h"
65*e4b17023SJohn Marino #include "hard-reg-set.h"
66*e4b17023SJohn Marino #include "regs.h"
67*e4b17023SJohn Marino #include "reload.h"
68*e4b17023SJohn Marino #include "optabs.h"
69*e4b17023SJohn Marino #include "recog.h"
70*e4b17023SJohn Marino #include "intl.h"
71*e4b17023SJohn Marino #include "opts.h"
72*e4b17023SJohn Marino #include "tree-flow.h"
73*e4b17023SJohn Marino #include "tree-ssa-alias.h"
74*e4b17023SJohn Marino 
75*e4b17023SJohn Marino 
76*e4b17023SJohn Marino bool
default_legitimate_address_p(enum machine_mode mode ATTRIBUTE_UNUSED,rtx addr ATTRIBUTE_UNUSED,bool strict ATTRIBUTE_UNUSED)77*e4b17023SJohn Marino default_legitimate_address_p (enum machine_mode mode ATTRIBUTE_UNUSED,
78*e4b17023SJohn Marino 			      rtx addr ATTRIBUTE_UNUSED,
79*e4b17023SJohn Marino 			      bool strict ATTRIBUTE_UNUSED)
80*e4b17023SJohn Marino {
81*e4b17023SJohn Marino #ifdef GO_IF_LEGITIMATE_ADDRESS
82*e4b17023SJohn Marino   /* Defer to the old implementation using a goto.  */
83*e4b17023SJohn Marino   if (strict)
84*e4b17023SJohn Marino     return strict_memory_address_p (mode, addr);
85*e4b17023SJohn Marino   else
86*e4b17023SJohn Marino     return memory_address_p (mode, addr);
87*e4b17023SJohn Marino #else
88*e4b17023SJohn Marino   gcc_unreachable ();
89*e4b17023SJohn Marino #endif
90*e4b17023SJohn Marino }
91*e4b17023SJohn Marino 
92*e4b17023SJohn Marino void
default_external_libcall(rtx fun ATTRIBUTE_UNUSED)93*e4b17023SJohn Marino default_external_libcall (rtx fun ATTRIBUTE_UNUSED)
94*e4b17023SJohn Marino {
95*e4b17023SJohn Marino #ifdef ASM_OUTPUT_EXTERNAL_LIBCALL
96*e4b17023SJohn Marino   ASM_OUTPUT_EXTERNAL_LIBCALL(asm_out_file, fun);
97*e4b17023SJohn Marino #endif
98*e4b17023SJohn Marino }
99*e4b17023SJohn Marino 
100*e4b17023SJohn Marino int
default_unspec_may_trap_p(const_rtx x,unsigned flags)101*e4b17023SJohn Marino default_unspec_may_trap_p (const_rtx x, unsigned flags)
102*e4b17023SJohn Marino {
103*e4b17023SJohn Marino   int i;
104*e4b17023SJohn Marino 
105*e4b17023SJohn Marino   if (GET_CODE (x) == UNSPEC_VOLATILE
106*e4b17023SJohn Marino       /* Any floating arithmetic may trap.  */
107*e4b17023SJohn Marino       || (SCALAR_FLOAT_MODE_P (GET_MODE (x))
108*e4b17023SJohn Marino 	  && flag_trapping_math))
109*e4b17023SJohn Marino     return 1;
110*e4b17023SJohn Marino 
111*e4b17023SJohn Marino   for (i = 0; i < XVECLEN (x, 0); ++i)
112*e4b17023SJohn Marino     {
113*e4b17023SJohn Marino       if (may_trap_p_1 (XVECEXP (x, 0, i), flags))
114*e4b17023SJohn Marino 	return 1;
115*e4b17023SJohn Marino     }
116*e4b17023SJohn Marino 
117*e4b17023SJohn Marino   return 0;
118*e4b17023SJohn Marino }
119*e4b17023SJohn Marino 
120*e4b17023SJohn Marino enum machine_mode
default_promote_function_mode(const_tree type ATTRIBUTE_UNUSED,enum machine_mode mode,int * punsignedp ATTRIBUTE_UNUSED,const_tree funtype ATTRIBUTE_UNUSED,int for_return ATTRIBUTE_UNUSED)121*e4b17023SJohn Marino default_promote_function_mode (const_tree type ATTRIBUTE_UNUSED,
122*e4b17023SJohn Marino 			       enum machine_mode mode,
123*e4b17023SJohn Marino 			       int *punsignedp ATTRIBUTE_UNUSED,
124*e4b17023SJohn Marino 			       const_tree funtype ATTRIBUTE_UNUSED,
125*e4b17023SJohn Marino 			       int for_return ATTRIBUTE_UNUSED)
126*e4b17023SJohn Marino {
127*e4b17023SJohn Marino   if (type != NULL_TREE && for_return == 2)
128*e4b17023SJohn Marino     return promote_mode (type, mode, punsignedp);
129*e4b17023SJohn Marino   return mode;
130*e4b17023SJohn Marino }
131*e4b17023SJohn Marino 
132*e4b17023SJohn Marino enum machine_mode
default_promote_function_mode_always_promote(const_tree type,enum machine_mode mode,int * punsignedp,const_tree funtype ATTRIBUTE_UNUSED,int for_return ATTRIBUTE_UNUSED)133*e4b17023SJohn Marino default_promote_function_mode_always_promote (const_tree type,
134*e4b17023SJohn Marino 					      enum machine_mode mode,
135*e4b17023SJohn Marino 					      int *punsignedp,
136*e4b17023SJohn Marino 					      const_tree funtype ATTRIBUTE_UNUSED,
137*e4b17023SJohn Marino 					      int for_return ATTRIBUTE_UNUSED)
138*e4b17023SJohn Marino {
139*e4b17023SJohn Marino   return promote_mode (type, mode, punsignedp);
140*e4b17023SJohn Marino }
141*e4b17023SJohn Marino 
142*e4b17023SJohn Marino 
143*e4b17023SJohn Marino enum machine_mode
default_cc_modes_compatible(enum machine_mode m1,enum machine_mode m2)144*e4b17023SJohn Marino default_cc_modes_compatible (enum machine_mode m1, enum machine_mode m2)
145*e4b17023SJohn Marino {
146*e4b17023SJohn Marino   if (m1 == m2)
147*e4b17023SJohn Marino     return m1;
148*e4b17023SJohn Marino   return VOIDmode;
149*e4b17023SJohn Marino }
150*e4b17023SJohn Marino 
151*e4b17023SJohn Marino bool
default_return_in_memory(const_tree type,const_tree fntype ATTRIBUTE_UNUSED)152*e4b17023SJohn Marino default_return_in_memory (const_tree type,
153*e4b17023SJohn Marino 			  const_tree fntype ATTRIBUTE_UNUSED)
154*e4b17023SJohn Marino {
155*e4b17023SJohn Marino   return (TYPE_MODE (type) == BLKmode);
156*e4b17023SJohn Marino }
157*e4b17023SJohn Marino 
158*e4b17023SJohn Marino rtx
default_legitimize_address(rtx x,rtx orig_x ATTRIBUTE_UNUSED,enum machine_mode mode ATTRIBUTE_UNUSED)159*e4b17023SJohn Marino default_legitimize_address (rtx x, rtx orig_x ATTRIBUTE_UNUSED,
160*e4b17023SJohn Marino 			    enum machine_mode mode ATTRIBUTE_UNUSED)
161*e4b17023SJohn Marino {
162*e4b17023SJohn Marino   return x;
163*e4b17023SJohn Marino }
164*e4b17023SJohn Marino 
165*e4b17023SJohn Marino rtx
default_expand_builtin_saveregs(void)166*e4b17023SJohn Marino default_expand_builtin_saveregs (void)
167*e4b17023SJohn Marino {
168*e4b17023SJohn Marino   error ("__builtin_saveregs not supported by this target");
169*e4b17023SJohn Marino   return const0_rtx;
170*e4b17023SJohn Marino }
171*e4b17023SJohn Marino 
172*e4b17023SJohn Marino void
default_setup_incoming_varargs(cumulative_args_t ca ATTRIBUTE_UNUSED,enum machine_mode mode ATTRIBUTE_UNUSED,tree type ATTRIBUTE_UNUSED,int * pretend_arg_size ATTRIBUTE_UNUSED,int second_time ATTRIBUTE_UNUSED)173*e4b17023SJohn Marino default_setup_incoming_varargs (cumulative_args_t ca ATTRIBUTE_UNUSED,
174*e4b17023SJohn Marino 				enum machine_mode mode ATTRIBUTE_UNUSED,
175*e4b17023SJohn Marino 				tree type ATTRIBUTE_UNUSED,
176*e4b17023SJohn Marino 				int *pretend_arg_size ATTRIBUTE_UNUSED,
177*e4b17023SJohn Marino 				int second_time ATTRIBUTE_UNUSED)
178*e4b17023SJohn Marino {
179*e4b17023SJohn Marino }
180*e4b17023SJohn Marino 
181*e4b17023SJohn Marino /* The default implementation of TARGET_BUILTIN_SETJMP_FRAME_VALUE.  */
182*e4b17023SJohn Marino 
183*e4b17023SJohn Marino rtx
default_builtin_setjmp_frame_value(void)184*e4b17023SJohn Marino default_builtin_setjmp_frame_value (void)
185*e4b17023SJohn Marino {
186*e4b17023SJohn Marino   return virtual_stack_vars_rtx;
187*e4b17023SJohn Marino }
188*e4b17023SJohn Marino 
189*e4b17023SJohn Marino /* Generic hook that takes a CUMULATIVE_ARGS pointer and returns false.  */
190*e4b17023SJohn Marino 
191*e4b17023SJohn Marino bool
hook_bool_CUMULATIVE_ARGS_false(cumulative_args_t ca ATTRIBUTE_UNUSED)192*e4b17023SJohn Marino hook_bool_CUMULATIVE_ARGS_false (cumulative_args_t ca ATTRIBUTE_UNUSED)
193*e4b17023SJohn Marino {
194*e4b17023SJohn Marino   return false;
195*e4b17023SJohn Marino }
196*e4b17023SJohn Marino 
197*e4b17023SJohn Marino bool
default_pretend_outgoing_varargs_named(cumulative_args_t ca ATTRIBUTE_UNUSED)198*e4b17023SJohn Marino default_pretend_outgoing_varargs_named (cumulative_args_t ca ATTRIBUTE_UNUSED)
199*e4b17023SJohn Marino {
200*e4b17023SJohn Marino   return (targetm.calls.setup_incoming_varargs
201*e4b17023SJohn Marino 	  != default_setup_incoming_varargs);
202*e4b17023SJohn Marino }
203*e4b17023SJohn Marino 
204*e4b17023SJohn Marino enum machine_mode
default_eh_return_filter_mode(void)205*e4b17023SJohn Marino default_eh_return_filter_mode (void)
206*e4b17023SJohn Marino {
207*e4b17023SJohn Marino   return targetm.unwind_word_mode ();
208*e4b17023SJohn Marino }
209*e4b17023SJohn Marino 
210*e4b17023SJohn Marino enum machine_mode
default_libgcc_cmp_return_mode(void)211*e4b17023SJohn Marino default_libgcc_cmp_return_mode (void)
212*e4b17023SJohn Marino {
213*e4b17023SJohn Marino   return word_mode;
214*e4b17023SJohn Marino }
215*e4b17023SJohn Marino 
216*e4b17023SJohn Marino enum machine_mode
default_libgcc_shift_count_mode(void)217*e4b17023SJohn Marino default_libgcc_shift_count_mode (void)
218*e4b17023SJohn Marino {
219*e4b17023SJohn Marino   return word_mode;
220*e4b17023SJohn Marino }
221*e4b17023SJohn Marino 
222*e4b17023SJohn Marino enum machine_mode
default_unwind_word_mode(void)223*e4b17023SJohn Marino default_unwind_word_mode (void)
224*e4b17023SJohn Marino {
225*e4b17023SJohn Marino   return word_mode;
226*e4b17023SJohn Marino }
227*e4b17023SJohn Marino 
228*e4b17023SJohn Marino /* The default implementation of TARGET_SHIFT_TRUNCATION_MASK.  */
229*e4b17023SJohn Marino 
230*e4b17023SJohn Marino unsigned HOST_WIDE_INT
default_shift_truncation_mask(enum machine_mode mode)231*e4b17023SJohn Marino default_shift_truncation_mask (enum machine_mode mode)
232*e4b17023SJohn Marino {
233*e4b17023SJohn Marino   return SHIFT_COUNT_TRUNCATED ? GET_MODE_BITSIZE (mode) - 1 : 0;
234*e4b17023SJohn Marino }
235*e4b17023SJohn Marino 
236*e4b17023SJohn Marino /* The default implementation of TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.  */
237*e4b17023SJohn Marino 
238*e4b17023SJohn Marino unsigned int
default_min_divisions_for_recip_mul(enum machine_mode mode ATTRIBUTE_UNUSED)239*e4b17023SJohn Marino default_min_divisions_for_recip_mul (enum machine_mode mode ATTRIBUTE_UNUSED)
240*e4b17023SJohn Marino {
241*e4b17023SJohn Marino   return have_insn_for (DIV, mode) ? 3 : 2;
242*e4b17023SJohn Marino }
243*e4b17023SJohn Marino 
244*e4b17023SJohn Marino /* The default implementation of TARGET_MODE_REP_EXTENDED.  */
245*e4b17023SJohn Marino 
246*e4b17023SJohn Marino int
default_mode_rep_extended(enum machine_mode mode ATTRIBUTE_UNUSED,enum machine_mode mode_rep ATTRIBUTE_UNUSED)247*e4b17023SJohn Marino default_mode_rep_extended (enum machine_mode mode ATTRIBUTE_UNUSED,
248*e4b17023SJohn Marino 			   enum machine_mode mode_rep ATTRIBUTE_UNUSED)
249*e4b17023SJohn Marino {
250*e4b17023SJohn Marino   return UNKNOWN;
251*e4b17023SJohn Marino }
252*e4b17023SJohn Marino 
253*e4b17023SJohn Marino /* Generic hook that takes a CUMULATIVE_ARGS pointer and returns true.  */
254*e4b17023SJohn Marino 
255*e4b17023SJohn Marino bool
hook_bool_CUMULATIVE_ARGS_true(cumulative_args_t a ATTRIBUTE_UNUSED)256*e4b17023SJohn Marino hook_bool_CUMULATIVE_ARGS_true (cumulative_args_t a ATTRIBUTE_UNUSED)
257*e4b17023SJohn Marino {
258*e4b17023SJohn Marino   return true;
259*e4b17023SJohn Marino }
260*e4b17023SJohn Marino 
261*e4b17023SJohn Marino /* Return machine mode for non-standard suffix
262*e4b17023SJohn Marino    or VOIDmode if non-standard suffixes are unsupported.  */
263*e4b17023SJohn Marino enum machine_mode
default_mode_for_suffix(char suffix ATTRIBUTE_UNUSED)264*e4b17023SJohn Marino default_mode_for_suffix (char suffix ATTRIBUTE_UNUSED)
265*e4b17023SJohn Marino {
266*e4b17023SJohn Marino   return VOIDmode;
267*e4b17023SJohn Marino }
268*e4b17023SJohn Marino 
269*e4b17023SJohn Marino /* The generic C++ ABI specifies this is a 64-bit value.  */
270*e4b17023SJohn Marino tree
default_cxx_guard_type(void)271*e4b17023SJohn Marino default_cxx_guard_type (void)
272*e4b17023SJohn Marino {
273*e4b17023SJohn Marino   return long_long_integer_type_node;
274*e4b17023SJohn Marino }
275*e4b17023SJohn Marino 
276*e4b17023SJohn Marino 
277*e4b17023SJohn Marino /* Returns the size of the cookie to use when allocating an array
278*e4b17023SJohn Marino    whose elements have the indicated TYPE.  Assumes that it is already
279*e4b17023SJohn Marino    known that a cookie is needed.  */
280*e4b17023SJohn Marino 
281*e4b17023SJohn Marino tree
default_cxx_get_cookie_size(tree type)282*e4b17023SJohn Marino default_cxx_get_cookie_size (tree type)
283*e4b17023SJohn Marino {
284*e4b17023SJohn Marino   tree cookie_size;
285*e4b17023SJohn Marino 
286*e4b17023SJohn Marino   /* We need to allocate an additional max (sizeof (size_t), alignof
287*e4b17023SJohn Marino      (true_type)) bytes.  */
288*e4b17023SJohn Marino   tree sizetype_size;
289*e4b17023SJohn Marino   tree type_align;
290*e4b17023SJohn Marino 
291*e4b17023SJohn Marino   sizetype_size = size_in_bytes (sizetype);
292*e4b17023SJohn Marino   type_align = size_int (TYPE_ALIGN_UNIT (type));
293*e4b17023SJohn Marino   if (INT_CST_LT_UNSIGNED (type_align, sizetype_size))
294*e4b17023SJohn Marino     cookie_size = sizetype_size;
295*e4b17023SJohn Marino   else
296*e4b17023SJohn Marino     cookie_size = type_align;
297*e4b17023SJohn Marino 
298*e4b17023SJohn Marino   return cookie_size;
299*e4b17023SJohn Marino }
300*e4b17023SJohn Marino 
301*e4b17023SJohn Marino /* Return true if a parameter must be passed by reference.  This version
302*e4b17023SJohn Marino    of the TARGET_PASS_BY_REFERENCE hook uses just MUST_PASS_IN_STACK.  */
303*e4b17023SJohn Marino 
304*e4b17023SJohn Marino bool
hook_pass_by_reference_must_pass_in_stack(cumulative_args_t c ATTRIBUTE_UNUSED,enum machine_mode mode ATTRIBUTE_UNUSED,const_tree type ATTRIBUTE_UNUSED,bool named_arg ATTRIBUTE_UNUSED)305*e4b17023SJohn Marino hook_pass_by_reference_must_pass_in_stack (cumulative_args_t c ATTRIBUTE_UNUSED,
306*e4b17023SJohn Marino 	enum machine_mode mode ATTRIBUTE_UNUSED, const_tree type ATTRIBUTE_UNUSED,
307*e4b17023SJohn Marino 	bool named_arg ATTRIBUTE_UNUSED)
308*e4b17023SJohn Marino {
309*e4b17023SJohn Marino   return targetm.calls.must_pass_in_stack (mode, type);
310*e4b17023SJohn Marino }
311*e4b17023SJohn Marino 
312*e4b17023SJohn Marino /* Return true if a parameter follows callee copies conventions.  This
313*e4b17023SJohn Marino    version of the hook is true for all named arguments.  */
314*e4b17023SJohn Marino 
315*e4b17023SJohn Marino bool
hook_callee_copies_named(cumulative_args_t ca ATTRIBUTE_UNUSED,enum machine_mode mode ATTRIBUTE_UNUSED,const_tree type ATTRIBUTE_UNUSED,bool named)316*e4b17023SJohn Marino hook_callee_copies_named (cumulative_args_t ca ATTRIBUTE_UNUSED,
317*e4b17023SJohn Marino 			  enum machine_mode mode ATTRIBUTE_UNUSED,
318*e4b17023SJohn Marino 			  const_tree type ATTRIBUTE_UNUSED, bool named)
319*e4b17023SJohn Marino {
320*e4b17023SJohn Marino   return named;
321*e4b17023SJohn Marino }
322*e4b17023SJohn Marino 
323*e4b17023SJohn Marino /* Emit to STREAM the assembler syntax for insn operand X.  */
324*e4b17023SJohn Marino 
325*e4b17023SJohn Marino void
default_print_operand(FILE * stream ATTRIBUTE_UNUSED,rtx x ATTRIBUTE_UNUSED,int code ATTRIBUTE_UNUSED)326*e4b17023SJohn Marino default_print_operand (FILE *stream ATTRIBUTE_UNUSED, rtx x ATTRIBUTE_UNUSED,
327*e4b17023SJohn Marino 		       int code ATTRIBUTE_UNUSED)
328*e4b17023SJohn Marino {
329*e4b17023SJohn Marino #ifdef PRINT_OPERAND
330*e4b17023SJohn Marino   PRINT_OPERAND (stream, x, code);
331*e4b17023SJohn Marino #else
332*e4b17023SJohn Marino   gcc_unreachable ();
333*e4b17023SJohn Marino #endif
334*e4b17023SJohn Marino }
335*e4b17023SJohn Marino 
336*e4b17023SJohn Marino /* Emit to STREAM the assembler syntax for an insn operand whose memory
337*e4b17023SJohn Marino    address is X.  */
338*e4b17023SJohn Marino 
339*e4b17023SJohn Marino void
default_print_operand_address(FILE * stream ATTRIBUTE_UNUSED,rtx x ATTRIBUTE_UNUSED)340*e4b17023SJohn Marino default_print_operand_address (FILE *stream ATTRIBUTE_UNUSED,
341*e4b17023SJohn Marino 			       rtx x ATTRIBUTE_UNUSED)
342*e4b17023SJohn Marino {
343*e4b17023SJohn Marino #ifdef PRINT_OPERAND_ADDRESS
344*e4b17023SJohn Marino   PRINT_OPERAND_ADDRESS (stream, x);
345*e4b17023SJohn Marino #else
346*e4b17023SJohn Marino   gcc_unreachable ();
347*e4b17023SJohn Marino #endif
348*e4b17023SJohn Marino }
349*e4b17023SJohn Marino 
350*e4b17023SJohn Marino /* Return true if CODE is a valid punctuation character for the
351*e4b17023SJohn Marino    `print_operand' hook.  */
352*e4b17023SJohn Marino 
353*e4b17023SJohn Marino bool
default_print_operand_punct_valid_p(unsigned char code ATTRIBUTE_UNUSED)354*e4b17023SJohn Marino default_print_operand_punct_valid_p (unsigned char code ATTRIBUTE_UNUSED)
355*e4b17023SJohn Marino {
356*e4b17023SJohn Marino #ifdef PRINT_OPERAND_PUNCT_VALID_P
357*e4b17023SJohn Marino   return PRINT_OPERAND_PUNCT_VALID_P (code);
358*e4b17023SJohn Marino #else
359*e4b17023SJohn Marino   return false;
360*e4b17023SJohn Marino #endif
361*e4b17023SJohn Marino }
362*e4b17023SJohn Marino 
363*e4b17023SJohn Marino /* The default implementation of TARGET_MANGLE_ASSEMBLER_NAME.  */
364*e4b17023SJohn Marino tree
default_mangle_assembler_name(const char * name ATTRIBUTE_UNUSED)365*e4b17023SJohn Marino default_mangle_assembler_name (const char *name ATTRIBUTE_UNUSED)
366*e4b17023SJohn Marino {
367*e4b17023SJohn Marino   const char *skipped = name + (*name == '*' ? 1 : 0);
368*e4b17023SJohn Marino   const char *stripped = targetm.strip_name_encoding (skipped);
369*e4b17023SJohn Marino   if (*name != '*' && user_label_prefix[0])
370*e4b17023SJohn Marino     stripped = ACONCAT ((user_label_prefix, stripped, NULL));
371*e4b17023SJohn Marino   return get_identifier (stripped);
372*e4b17023SJohn Marino }
373*e4b17023SJohn Marino 
374*e4b17023SJohn Marino /* True if MODE is valid for the target.  By "valid", we mean able to
375*e4b17023SJohn Marino    be manipulated in non-trivial ways.  In particular, this means all
376*e4b17023SJohn Marino    the arithmetic is supported.
377*e4b17023SJohn Marino 
378*e4b17023SJohn Marino    By default we guess this means that any C type is supported.  If
379*e4b17023SJohn Marino    we can't map the mode back to a type that would be available in C,
380*e4b17023SJohn Marino    then reject it.  Special case, here, is the double-word arithmetic
381*e4b17023SJohn Marino    supported by optabs.c.  */
382*e4b17023SJohn Marino 
383*e4b17023SJohn Marino bool
default_scalar_mode_supported_p(enum machine_mode mode)384*e4b17023SJohn Marino default_scalar_mode_supported_p (enum machine_mode mode)
385*e4b17023SJohn Marino {
386*e4b17023SJohn Marino   int precision = GET_MODE_PRECISION (mode);
387*e4b17023SJohn Marino 
388*e4b17023SJohn Marino   switch (GET_MODE_CLASS (mode))
389*e4b17023SJohn Marino     {
390*e4b17023SJohn Marino     case MODE_PARTIAL_INT:
391*e4b17023SJohn Marino     case MODE_INT:
392*e4b17023SJohn Marino       if (precision == CHAR_TYPE_SIZE)
393*e4b17023SJohn Marino 	return true;
394*e4b17023SJohn Marino       if (precision == SHORT_TYPE_SIZE)
395*e4b17023SJohn Marino 	return true;
396*e4b17023SJohn Marino       if (precision == INT_TYPE_SIZE)
397*e4b17023SJohn Marino 	return true;
398*e4b17023SJohn Marino       if (precision == LONG_TYPE_SIZE)
399*e4b17023SJohn Marino 	return true;
400*e4b17023SJohn Marino       if (precision == LONG_LONG_TYPE_SIZE)
401*e4b17023SJohn Marino 	return true;
402*e4b17023SJohn Marino       if (precision == 2 * BITS_PER_WORD)
403*e4b17023SJohn Marino 	return true;
404*e4b17023SJohn Marino       return false;
405*e4b17023SJohn Marino 
406*e4b17023SJohn Marino     case MODE_FLOAT:
407*e4b17023SJohn Marino       if (precision == FLOAT_TYPE_SIZE)
408*e4b17023SJohn Marino 	return true;
409*e4b17023SJohn Marino       if (precision == DOUBLE_TYPE_SIZE)
410*e4b17023SJohn Marino 	return true;
411*e4b17023SJohn Marino       if (precision == LONG_DOUBLE_TYPE_SIZE)
412*e4b17023SJohn Marino 	return true;
413*e4b17023SJohn Marino       return false;
414*e4b17023SJohn Marino 
415*e4b17023SJohn Marino     case MODE_DECIMAL_FLOAT:
416*e4b17023SJohn Marino     case MODE_FRACT:
417*e4b17023SJohn Marino     case MODE_UFRACT:
418*e4b17023SJohn Marino     case MODE_ACCUM:
419*e4b17023SJohn Marino     case MODE_UACCUM:
420*e4b17023SJohn Marino       return false;
421*e4b17023SJohn Marino 
422*e4b17023SJohn Marino     default:
423*e4b17023SJohn Marino       gcc_unreachable ();
424*e4b17023SJohn Marino     }
425*e4b17023SJohn Marino }
426*e4b17023SJohn Marino 
427*e4b17023SJohn Marino /* Make some target macros useable by target-independent code.  */
428*e4b17023SJohn Marino bool
targhook_words_big_endian(void)429*e4b17023SJohn Marino targhook_words_big_endian (void)
430*e4b17023SJohn Marino {
431*e4b17023SJohn Marino   return !!WORDS_BIG_ENDIAN;
432*e4b17023SJohn Marino }
433*e4b17023SJohn Marino 
434*e4b17023SJohn Marino bool
targhook_float_words_big_endian(void)435*e4b17023SJohn Marino targhook_float_words_big_endian (void)
436*e4b17023SJohn Marino {
437*e4b17023SJohn Marino   return !!FLOAT_WORDS_BIG_ENDIAN;
438*e4b17023SJohn Marino }
439*e4b17023SJohn Marino 
440*e4b17023SJohn Marino /* True if the target supports decimal floating point.  */
441*e4b17023SJohn Marino 
442*e4b17023SJohn Marino bool
default_decimal_float_supported_p(void)443*e4b17023SJohn Marino default_decimal_float_supported_p (void)
444*e4b17023SJohn Marino {
445*e4b17023SJohn Marino   return ENABLE_DECIMAL_FLOAT;
446*e4b17023SJohn Marino }
447*e4b17023SJohn Marino 
448*e4b17023SJohn Marino /* True if the target supports fixed-point arithmetic.  */
449*e4b17023SJohn Marino 
450*e4b17023SJohn Marino bool
default_fixed_point_supported_p(void)451*e4b17023SJohn Marino default_fixed_point_supported_p (void)
452*e4b17023SJohn Marino {
453*e4b17023SJohn Marino   return ENABLE_FIXED_POINT;
454*e4b17023SJohn Marino }
455*e4b17023SJohn Marino 
456*e4b17023SJohn Marino /* NULL if INSN insn is valid within a low-overhead loop, otherwise returns
457*e4b17023SJohn Marino    an error message.
458*e4b17023SJohn Marino 
459*e4b17023SJohn Marino    This function checks whether a given INSN is valid within a low-overhead
460*e4b17023SJohn Marino    loop.  If INSN is invalid it returns the reason for that, otherwise it
461*e4b17023SJohn Marino    returns NULL. A called function may clobber any special registers required
462*e4b17023SJohn Marino    for low-overhead looping. Additionally, some targets (eg, PPC) use the count
463*e4b17023SJohn Marino    register for branch on table instructions. We reject the doloop pattern in
464*e4b17023SJohn Marino    these cases.  */
465*e4b17023SJohn Marino 
466*e4b17023SJohn Marino const char *
default_invalid_within_doloop(const_rtx insn)467*e4b17023SJohn Marino default_invalid_within_doloop (const_rtx insn)
468*e4b17023SJohn Marino {
469*e4b17023SJohn Marino   if (CALL_P (insn))
470*e4b17023SJohn Marino     return "Function call in loop.";
471*e4b17023SJohn Marino 
472*e4b17023SJohn Marino   if (JUMP_TABLE_DATA_P (insn))
473*e4b17023SJohn Marino     return "Computed branch in the loop.";
474*e4b17023SJohn Marino 
475*e4b17023SJohn Marino   return NULL;
476*e4b17023SJohn Marino }
477*e4b17023SJohn Marino 
478*e4b17023SJohn Marino /* Mapping of builtin functions to vectorized variants.  */
479*e4b17023SJohn Marino 
480*e4b17023SJohn Marino tree
default_builtin_vectorized_function(tree fndecl ATTRIBUTE_UNUSED,tree type_out ATTRIBUTE_UNUSED,tree type_in ATTRIBUTE_UNUSED)481*e4b17023SJohn Marino default_builtin_vectorized_function (tree fndecl ATTRIBUTE_UNUSED,
482*e4b17023SJohn Marino 				     tree type_out ATTRIBUTE_UNUSED,
483*e4b17023SJohn Marino 				     tree type_in ATTRIBUTE_UNUSED)
484*e4b17023SJohn Marino {
485*e4b17023SJohn Marino   return NULL_TREE;
486*e4b17023SJohn Marino }
487*e4b17023SJohn Marino 
488*e4b17023SJohn Marino /* Vectorized conversion.  */
489*e4b17023SJohn Marino 
490*e4b17023SJohn Marino tree
default_builtin_vectorized_conversion(unsigned int code ATTRIBUTE_UNUSED,tree dest_type ATTRIBUTE_UNUSED,tree src_type ATTRIBUTE_UNUSED)491*e4b17023SJohn Marino default_builtin_vectorized_conversion (unsigned int code ATTRIBUTE_UNUSED,
492*e4b17023SJohn Marino 				       tree dest_type ATTRIBUTE_UNUSED,
493*e4b17023SJohn Marino 				       tree src_type ATTRIBUTE_UNUSED)
494*e4b17023SJohn Marino {
495*e4b17023SJohn Marino   return NULL_TREE;
496*e4b17023SJohn Marino }
497*e4b17023SJohn Marino 
498*e4b17023SJohn Marino /* Default vectorizer cost model values.  */
499*e4b17023SJohn Marino 
500*e4b17023SJohn Marino int
default_builtin_vectorization_cost(enum vect_cost_for_stmt type_of_cost,tree vectype ATTRIBUTE_UNUSED,int misalign ATTRIBUTE_UNUSED)501*e4b17023SJohn Marino default_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost,
502*e4b17023SJohn Marino                                     tree vectype ATTRIBUTE_UNUSED,
503*e4b17023SJohn Marino                                     int misalign ATTRIBUTE_UNUSED)
504*e4b17023SJohn Marino {
505*e4b17023SJohn Marino   switch (type_of_cost)
506*e4b17023SJohn Marino     {
507*e4b17023SJohn Marino       case scalar_stmt:
508*e4b17023SJohn Marino       case scalar_load:
509*e4b17023SJohn Marino       case scalar_store:
510*e4b17023SJohn Marino       case vector_stmt:
511*e4b17023SJohn Marino       case vector_load:
512*e4b17023SJohn Marino       case vector_store:
513*e4b17023SJohn Marino       case vec_to_scalar:
514*e4b17023SJohn Marino       case scalar_to_vec:
515*e4b17023SJohn Marino       case cond_branch_not_taken:
516*e4b17023SJohn Marino       case vec_perm:
517*e4b17023SJohn Marino       case vec_promote_demote:
518*e4b17023SJohn Marino         return 1;
519*e4b17023SJohn Marino 
520*e4b17023SJohn Marino       case unaligned_load:
521*e4b17023SJohn Marino       case unaligned_store:
522*e4b17023SJohn Marino         return 2;
523*e4b17023SJohn Marino 
524*e4b17023SJohn Marino       case cond_branch_taken:
525*e4b17023SJohn Marino         return 3;
526*e4b17023SJohn Marino 
527*e4b17023SJohn Marino       default:
528*e4b17023SJohn Marino         gcc_unreachable ();
529*e4b17023SJohn Marino     }
530*e4b17023SJohn Marino }
531*e4b17023SJohn Marino 
532*e4b17023SJohn Marino /* Reciprocal.  */
533*e4b17023SJohn Marino 
534*e4b17023SJohn Marino tree
default_builtin_reciprocal(unsigned int fn ATTRIBUTE_UNUSED,bool md_fn ATTRIBUTE_UNUSED,bool sqrt ATTRIBUTE_UNUSED)535*e4b17023SJohn Marino default_builtin_reciprocal (unsigned int fn ATTRIBUTE_UNUSED,
536*e4b17023SJohn Marino 			    bool md_fn ATTRIBUTE_UNUSED,
537*e4b17023SJohn Marino 			    bool sqrt ATTRIBUTE_UNUSED)
538*e4b17023SJohn Marino {
539*e4b17023SJohn Marino   return NULL_TREE;
540*e4b17023SJohn Marino }
541*e4b17023SJohn Marino 
542*e4b17023SJohn Marino bool
hook_bool_CUMULATIVE_ARGS_mode_tree_bool_false(cumulative_args_t ca ATTRIBUTE_UNUSED,enum machine_mode mode ATTRIBUTE_UNUSED,const_tree type ATTRIBUTE_UNUSED,bool named ATTRIBUTE_UNUSED)543*e4b17023SJohn Marino hook_bool_CUMULATIVE_ARGS_mode_tree_bool_false (
544*e4b17023SJohn Marino 	cumulative_args_t ca ATTRIBUTE_UNUSED,
545*e4b17023SJohn Marino 	enum machine_mode mode ATTRIBUTE_UNUSED,
546*e4b17023SJohn Marino 	const_tree type ATTRIBUTE_UNUSED, bool named ATTRIBUTE_UNUSED)
547*e4b17023SJohn Marino {
548*e4b17023SJohn Marino   return false;
549*e4b17023SJohn Marino }
550*e4b17023SJohn Marino 
551*e4b17023SJohn Marino bool
hook_bool_CUMULATIVE_ARGS_mode_tree_bool_true(cumulative_args_t ca ATTRIBUTE_UNUSED,enum machine_mode mode ATTRIBUTE_UNUSED,const_tree type ATTRIBUTE_UNUSED,bool named ATTRIBUTE_UNUSED)552*e4b17023SJohn Marino hook_bool_CUMULATIVE_ARGS_mode_tree_bool_true (
553*e4b17023SJohn Marino 	cumulative_args_t ca ATTRIBUTE_UNUSED,
554*e4b17023SJohn Marino 	enum machine_mode mode ATTRIBUTE_UNUSED,
555*e4b17023SJohn Marino 	const_tree type ATTRIBUTE_UNUSED, bool named ATTRIBUTE_UNUSED)
556*e4b17023SJohn Marino {
557*e4b17023SJohn Marino   return true;
558*e4b17023SJohn Marino }
559*e4b17023SJohn Marino 
560*e4b17023SJohn Marino int
hook_int_CUMULATIVE_ARGS_mode_tree_bool_0(cumulative_args_t ca ATTRIBUTE_UNUSED,enum machine_mode mode ATTRIBUTE_UNUSED,tree type ATTRIBUTE_UNUSED,bool named ATTRIBUTE_UNUSED)561*e4b17023SJohn Marino hook_int_CUMULATIVE_ARGS_mode_tree_bool_0 (
562*e4b17023SJohn Marino 	cumulative_args_t ca ATTRIBUTE_UNUSED,
563*e4b17023SJohn Marino 	enum machine_mode mode ATTRIBUTE_UNUSED,
564*e4b17023SJohn Marino 	tree type ATTRIBUTE_UNUSED, bool named ATTRIBUTE_UNUSED)
565*e4b17023SJohn Marino {
566*e4b17023SJohn Marino   return 0;
567*e4b17023SJohn Marino }
568*e4b17023SJohn Marino 
569*e4b17023SJohn Marino void
default_function_arg_advance(cumulative_args_t ca ATTRIBUTE_UNUSED,enum machine_mode mode ATTRIBUTE_UNUSED,const_tree type ATTRIBUTE_UNUSED,bool named ATTRIBUTE_UNUSED)570*e4b17023SJohn Marino default_function_arg_advance (cumulative_args_t ca ATTRIBUTE_UNUSED,
571*e4b17023SJohn Marino 			      enum machine_mode mode ATTRIBUTE_UNUSED,
572*e4b17023SJohn Marino 			      const_tree type ATTRIBUTE_UNUSED,
573*e4b17023SJohn Marino 			      bool named ATTRIBUTE_UNUSED)
574*e4b17023SJohn Marino {
575*e4b17023SJohn Marino   gcc_unreachable ();
576*e4b17023SJohn Marino }
577*e4b17023SJohn Marino 
578*e4b17023SJohn Marino rtx
default_function_arg(cumulative_args_t ca ATTRIBUTE_UNUSED,enum machine_mode mode ATTRIBUTE_UNUSED,const_tree type ATTRIBUTE_UNUSED,bool named ATTRIBUTE_UNUSED)579*e4b17023SJohn Marino default_function_arg (cumulative_args_t ca ATTRIBUTE_UNUSED,
580*e4b17023SJohn Marino 		      enum machine_mode mode ATTRIBUTE_UNUSED,
581*e4b17023SJohn Marino 		      const_tree type ATTRIBUTE_UNUSED,
582*e4b17023SJohn Marino 		      bool named ATTRIBUTE_UNUSED)
583*e4b17023SJohn Marino {
584*e4b17023SJohn Marino   gcc_unreachable ();
585*e4b17023SJohn Marino }
586*e4b17023SJohn Marino 
587*e4b17023SJohn Marino rtx
default_function_incoming_arg(cumulative_args_t ca ATTRIBUTE_UNUSED,enum machine_mode mode ATTRIBUTE_UNUSED,const_tree type ATTRIBUTE_UNUSED,bool named ATTRIBUTE_UNUSED)588*e4b17023SJohn Marino default_function_incoming_arg (cumulative_args_t ca ATTRIBUTE_UNUSED,
589*e4b17023SJohn Marino 			       enum machine_mode mode ATTRIBUTE_UNUSED,
590*e4b17023SJohn Marino 			       const_tree type ATTRIBUTE_UNUSED,
591*e4b17023SJohn Marino 			       bool named ATTRIBUTE_UNUSED)
592*e4b17023SJohn Marino {
593*e4b17023SJohn Marino   gcc_unreachable ();
594*e4b17023SJohn Marino }
595*e4b17023SJohn Marino 
596*e4b17023SJohn Marino unsigned int
default_function_arg_boundary(enum machine_mode mode ATTRIBUTE_UNUSED,const_tree type ATTRIBUTE_UNUSED)597*e4b17023SJohn Marino default_function_arg_boundary (enum machine_mode mode ATTRIBUTE_UNUSED,
598*e4b17023SJohn Marino 			       const_tree type ATTRIBUTE_UNUSED)
599*e4b17023SJohn Marino {
600*e4b17023SJohn Marino   return PARM_BOUNDARY;
601*e4b17023SJohn Marino }
602*e4b17023SJohn Marino 
603*e4b17023SJohn Marino unsigned int
default_function_arg_round_boundary(enum machine_mode mode ATTRIBUTE_UNUSED,const_tree type ATTRIBUTE_UNUSED)604*e4b17023SJohn Marino default_function_arg_round_boundary (enum machine_mode mode ATTRIBUTE_UNUSED,
605*e4b17023SJohn Marino 				     const_tree type ATTRIBUTE_UNUSED)
606*e4b17023SJohn Marino {
607*e4b17023SJohn Marino   return PARM_BOUNDARY;
608*e4b17023SJohn Marino }
609*e4b17023SJohn Marino 
610*e4b17023SJohn Marino void
hook_void_bitmap(bitmap regs ATTRIBUTE_UNUSED)611*e4b17023SJohn Marino hook_void_bitmap (bitmap regs ATTRIBUTE_UNUSED)
612*e4b17023SJohn Marino {
613*e4b17023SJohn Marino }
614*e4b17023SJohn Marino 
615*e4b17023SJohn Marino const char *
hook_invalid_arg_for_unprototyped_fn(const_tree typelist ATTRIBUTE_UNUSED,const_tree funcdecl ATTRIBUTE_UNUSED,const_tree val ATTRIBUTE_UNUSED)616*e4b17023SJohn Marino hook_invalid_arg_for_unprototyped_fn (
617*e4b17023SJohn Marino 	const_tree typelist ATTRIBUTE_UNUSED,
618*e4b17023SJohn Marino 	const_tree funcdecl ATTRIBUTE_UNUSED,
619*e4b17023SJohn Marino 	const_tree val ATTRIBUTE_UNUSED)
620*e4b17023SJohn Marino {
621*e4b17023SJohn Marino   return NULL;
622*e4b17023SJohn Marino }
623*e4b17023SJohn Marino 
624*e4b17023SJohn Marino /* Initialize the stack protection decls.  */
625*e4b17023SJohn Marino 
626*e4b17023SJohn Marino /* Stack protection related decls living in libgcc.  */
627*e4b17023SJohn Marino static GTY(()) tree stack_chk_guard_decl;
628*e4b17023SJohn Marino 
629*e4b17023SJohn Marino tree
default_stack_protect_guard(void)630*e4b17023SJohn Marino default_stack_protect_guard (void)
631*e4b17023SJohn Marino {
632*e4b17023SJohn Marino   tree t = stack_chk_guard_decl;
633*e4b17023SJohn Marino 
634*e4b17023SJohn Marino   if (t == NULL)
635*e4b17023SJohn Marino     {
636*e4b17023SJohn Marino       rtx x;
637*e4b17023SJohn Marino 
638*e4b17023SJohn Marino       t = build_decl (UNKNOWN_LOCATION,
639*e4b17023SJohn Marino 		      VAR_DECL, get_identifier ("__stack_chk_guard"),
640*e4b17023SJohn Marino 		      ptr_type_node);
641*e4b17023SJohn Marino       TREE_STATIC (t) = 1;
642*e4b17023SJohn Marino       TREE_PUBLIC (t) = 1;
643*e4b17023SJohn Marino       DECL_EXTERNAL (t) = 1;
644*e4b17023SJohn Marino       TREE_USED (t) = 1;
645*e4b17023SJohn Marino       TREE_THIS_VOLATILE (t) = 1;
646*e4b17023SJohn Marino       DECL_ARTIFICIAL (t) = 1;
647*e4b17023SJohn Marino       DECL_IGNORED_P (t) = 1;
648*e4b17023SJohn Marino 
649*e4b17023SJohn Marino       /* Do not share RTL as the declaration is visible outside of
650*e4b17023SJohn Marino 	 current function.  */
651*e4b17023SJohn Marino       x = DECL_RTL (t);
652*e4b17023SJohn Marino       RTX_FLAG (x, used) = 1;
653*e4b17023SJohn Marino 
654*e4b17023SJohn Marino       stack_chk_guard_decl = t;
655*e4b17023SJohn Marino     }
656*e4b17023SJohn Marino 
657*e4b17023SJohn Marino   return t;
658*e4b17023SJohn Marino }
659*e4b17023SJohn Marino 
660*e4b17023SJohn Marino static GTY(()) tree stack_chk_fail_decl;
661*e4b17023SJohn Marino 
662*e4b17023SJohn Marino tree
default_external_stack_protect_fail(void)663*e4b17023SJohn Marino default_external_stack_protect_fail (void)
664*e4b17023SJohn Marino {
665*e4b17023SJohn Marino   tree t = stack_chk_fail_decl;
666*e4b17023SJohn Marino 
667*e4b17023SJohn Marino   if (t == NULL_TREE)
668*e4b17023SJohn Marino     {
669*e4b17023SJohn Marino       t = build_function_type_list (void_type_node, NULL_TREE);
670*e4b17023SJohn Marino       t = build_decl (UNKNOWN_LOCATION,
671*e4b17023SJohn Marino 		      FUNCTION_DECL, get_identifier ("__stack_chk_fail"), t);
672*e4b17023SJohn Marino       TREE_STATIC (t) = 1;
673*e4b17023SJohn Marino       TREE_PUBLIC (t) = 1;
674*e4b17023SJohn Marino       DECL_EXTERNAL (t) = 1;
675*e4b17023SJohn Marino       TREE_USED (t) = 1;
676*e4b17023SJohn Marino       TREE_THIS_VOLATILE (t) = 1;
677*e4b17023SJohn Marino       TREE_NOTHROW (t) = 1;
678*e4b17023SJohn Marino       DECL_ARTIFICIAL (t) = 1;
679*e4b17023SJohn Marino       DECL_IGNORED_P (t) = 1;
680*e4b17023SJohn Marino       DECL_VISIBILITY (t) = VISIBILITY_DEFAULT;
681*e4b17023SJohn Marino       DECL_VISIBILITY_SPECIFIED (t) = 1;
682*e4b17023SJohn Marino 
683*e4b17023SJohn Marino       stack_chk_fail_decl = t;
684*e4b17023SJohn Marino     }
685*e4b17023SJohn Marino 
686*e4b17023SJohn Marino   return build_call_expr (t, 0);
687*e4b17023SJohn Marino }
688*e4b17023SJohn Marino 
689*e4b17023SJohn Marino tree
default_hidden_stack_protect_fail(void)690*e4b17023SJohn Marino default_hidden_stack_protect_fail (void)
691*e4b17023SJohn Marino {
692*e4b17023SJohn Marino #ifndef HAVE_GAS_HIDDEN
693*e4b17023SJohn Marino   return default_external_stack_protect_fail ();
694*e4b17023SJohn Marino #else
695*e4b17023SJohn Marino   tree t = stack_chk_fail_decl;
696*e4b17023SJohn Marino 
697*e4b17023SJohn Marino   if (!flag_pic)
698*e4b17023SJohn Marino     return default_external_stack_protect_fail ();
699*e4b17023SJohn Marino 
700*e4b17023SJohn Marino   if (t == NULL_TREE)
701*e4b17023SJohn Marino     {
702*e4b17023SJohn Marino       t = build_function_type_list (void_type_node, NULL_TREE);
703*e4b17023SJohn Marino       t = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL,
704*e4b17023SJohn Marino 		      get_identifier ("__stack_chk_fail_local"), t);
705*e4b17023SJohn Marino       TREE_STATIC (t) = 1;
706*e4b17023SJohn Marino       TREE_PUBLIC (t) = 1;
707*e4b17023SJohn Marino       DECL_EXTERNAL (t) = 1;
708*e4b17023SJohn Marino       TREE_USED (t) = 1;
709*e4b17023SJohn Marino       TREE_THIS_VOLATILE (t) = 1;
710*e4b17023SJohn Marino       TREE_NOTHROW (t) = 1;
711*e4b17023SJohn Marino       DECL_ARTIFICIAL (t) = 1;
712*e4b17023SJohn Marino       DECL_IGNORED_P (t) = 1;
713*e4b17023SJohn Marino       DECL_VISIBILITY_SPECIFIED (t) = 1;
714*e4b17023SJohn Marino       DECL_VISIBILITY (t) = VISIBILITY_HIDDEN;
715*e4b17023SJohn Marino 
716*e4b17023SJohn Marino       stack_chk_fail_decl = t;
717*e4b17023SJohn Marino     }
718*e4b17023SJohn Marino 
719*e4b17023SJohn Marino   return build_call_expr (t, 0);
720*e4b17023SJohn Marino #endif
721*e4b17023SJohn Marino }
722*e4b17023SJohn Marino 
723*e4b17023SJohn Marino bool
hook_bool_const_rtx_commutative_p(const_rtx x,int outer_code ATTRIBUTE_UNUSED)724*e4b17023SJohn Marino hook_bool_const_rtx_commutative_p (const_rtx x,
725*e4b17023SJohn Marino 				   int outer_code ATTRIBUTE_UNUSED)
726*e4b17023SJohn Marino {
727*e4b17023SJohn Marino   return COMMUTATIVE_P (x);
728*e4b17023SJohn Marino }
729*e4b17023SJohn Marino 
730*e4b17023SJohn Marino rtx
default_function_value(const_tree ret_type ATTRIBUTE_UNUSED,const_tree fn_decl_or_type,bool outgoing ATTRIBUTE_UNUSED)731*e4b17023SJohn Marino default_function_value (const_tree ret_type ATTRIBUTE_UNUSED,
732*e4b17023SJohn Marino 			const_tree fn_decl_or_type,
733*e4b17023SJohn Marino 			bool outgoing ATTRIBUTE_UNUSED)
734*e4b17023SJohn Marino {
735*e4b17023SJohn Marino   /* The old interface doesn't handle receiving the function type.  */
736*e4b17023SJohn Marino   if (fn_decl_or_type
737*e4b17023SJohn Marino       && !DECL_P (fn_decl_or_type))
738*e4b17023SJohn Marino     fn_decl_or_type = NULL;
739*e4b17023SJohn Marino 
740*e4b17023SJohn Marino #ifdef FUNCTION_VALUE
741*e4b17023SJohn Marino   return FUNCTION_VALUE (ret_type, fn_decl_or_type);
742*e4b17023SJohn Marino #else
743*e4b17023SJohn Marino   gcc_unreachable ();
744*e4b17023SJohn Marino #endif
745*e4b17023SJohn Marino }
746*e4b17023SJohn Marino 
747*e4b17023SJohn Marino rtx
default_libcall_value(enum machine_mode mode ATTRIBUTE_UNUSED,const_rtx fun ATTRIBUTE_UNUSED)748*e4b17023SJohn Marino default_libcall_value (enum machine_mode mode ATTRIBUTE_UNUSED,
749*e4b17023SJohn Marino 		       const_rtx fun ATTRIBUTE_UNUSED)
750*e4b17023SJohn Marino {
751*e4b17023SJohn Marino #ifdef LIBCALL_VALUE
752*e4b17023SJohn Marino   return LIBCALL_VALUE (mode);
753*e4b17023SJohn Marino #else
754*e4b17023SJohn Marino   gcc_unreachable ();
755*e4b17023SJohn Marino #endif
756*e4b17023SJohn Marino }
757*e4b17023SJohn Marino 
758*e4b17023SJohn Marino /* The default hook for TARGET_FUNCTION_VALUE_REGNO_P.  */
759*e4b17023SJohn Marino 
760*e4b17023SJohn Marino bool
default_function_value_regno_p(const unsigned int regno ATTRIBUTE_UNUSED)761*e4b17023SJohn Marino default_function_value_regno_p (const unsigned int regno ATTRIBUTE_UNUSED)
762*e4b17023SJohn Marino {
763*e4b17023SJohn Marino #ifdef FUNCTION_VALUE_REGNO_P
764*e4b17023SJohn Marino   return FUNCTION_VALUE_REGNO_P (regno);
765*e4b17023SJohn Marino #else
766*e4b17023SJohn Marino   gcc_unreachable ();
767*e4b17023SJohn Marino #endif
768*e4b17023SJohn Marino }
769*e4b17023SJohn Marino 
770*e4b17023SJohn Marino rtx
default_internal_arg_pointer(void)771*e4b17023SJohn Marino default_internal_arg_pointer (void)
772*e4b17023SJohn Marino {
773*e4b17023SJohn Marino   /* If the reg that the virtual arg pointer will be translated into is
774*e4b17023SJohn Marino      not a fixed reg or is the stack pointer, make a copy of the virtual
775*e4b17023SJohn Marino      arg pointer, and address parms via the copy.  The frame pointer is
776*e4b17023SJohn Marino      considered fixed even though it is not marked as such.  */
777*e4b17023SJohn Marino   if ((ARG_POINTER_REGNUM == STACK_POINTER_REGNUM
778*e4b17023SJohn Marino        || ! (fixed_regs[ARG_POINTER_REGNUM]
779*e4b17023SJohn Marino 	     || ARG_POINTER_REGNUM == FRAME_POINTER_REGNUM)))
780*e4b17023SJohn Marino     return copy_to_reg (virtual_incoming_args_rtx);
781*e4b17023SJohn Marino   else
782*e4b17023SJohn Marino     return virtual_incoming_args_rtx;
783*e4b17023SJohn Marino }
784*e4b17023SJohn Marino 
785*e4b17023SJohn Marino rtx
default_static_chain(const_tree fndecl,bool incoming_p)786*e4b17023SJohn Marino default_static_chain (const_tree fndecl, bool incoming_p)
787*e4b17023SJohn Marino {
788*e4b17023SJohn Marino   if (!DECL_STATIC_CHAIN (fndecl))
789*e4b17023SJohn Marino     return NULL;
790*e4b17023SJohn Marino 
791*e4b17023SJohn Marino   if (incoming_p)
792*e4b17023SJohn Marino     {
793*e4b17023SJohn Marino #ifdef STATIC_CHAIN_INCOMING_REGNUM
794*e4b17023SJohn Marino       return gen_rtx_REG (Pmode, STATIC_CHAIN_INCOMING_REGNUM);
795*e4b17023SJohn Marino #endif
796*e4b17023SJohn Marino     }
797*e4b17023SJohn Marino 
798*e4b17023SJohn Marino #ifdef STATIC_CHAIN_REGNUM
799*e4b17023SJohn Marino   return gen_rtx_REG (Pmode, STATIC_CHAIN_REGNUM);
800*e4b17023SJohn Marino #endif
801*e4b17023SJohn Marino 
802*e4b17023SJohn Marino   {
803*e4b17023SJohn Marino     static bool issued_error;
804*e4b17023SJohn Marino     if (!issued_error)
805*e4b17023SJohn Marino       {
806*e4b17023SJohn Marino 	issued_error = true;
807*e4b17023SJohn Marino 	sorry ("nested functions not supported on this target");
808*e4b17023SJohn Marino       }
809*e4b17023SJohn Marino 
810*e4b17023SJohn Marino     /* It really doesn't matter what we return here, so long at it
811*e4b17023SJohn Marino        doesn't cause the rest of the compiler to crash.  */
812*e4b17023SJohn Marino     return gen_rtx_MEM (Pmode, stack_pointer_rtx);
813*e4b17023SJohn Marino   }
814*e4b17023SJohn Marino }
815*e4b17023SJohn Marino 
816*e4b17023SJohn Marino void
default_trampoline_init(rtx ARG_UNUSED (m_tramp),tree ARG_UNUSED (t_func),rtx ARG_UNUSED (r_chain))817*e4b17023SJohn Marino default_trampoline_init (rtx ARG_UNUSED (m_tramp), tree ARG_UNUSED (t_func),
818*e4b17023SJohn Marino 			 rtx ARG_UNUSED (r_chain))
819*e4b17023SJohn Marino {
820*e4b17023SJohn Marino   sorry ("nested function trampolines not supported on this target");
821*e4b17023SJohn Marino }
822*e4b17023SJohn Marino 
823*e4b17023SJohn Marino int
default_return_pops_args(tree fundecl ATTRIBUTE_UNUSED,tree funtype ATTRIBUTE_UNUSED,int size ATTRIBUTE_UNUSED)824*e4b17023SJohn Marino default_return_pops_args (tree fundecl ATTRIBUTE_UNUSED,
825*e4b17023SJohn Marino 			  tree funtype ATTRIBUTE_UNUSED,
826*e4b17023SJohn Marino 			  int size ATTRIBUTE_UNUSED)
827*e4b17023SJohn Marino {
828*e4b17023SJohn Marino   return 0;
829*e4b17023SJohn Marino }
830*e4b17023SJohn Marino 
831*e4b17023SJohn Marino reg_class_t
default_branch_target_register_class(void)832*e4b17023SJohn Marino default_branch_target_register_class (void)
833*e4b17023SJohn Marino {
834*e4b17023SJohn Marino   return NO_REGS;
835*e4b17023SJohn Marino }
836*e4b17023SJohn Marino 
837*e4b17023SJohn Marino reg_class_t
default_secondary_reload(bool in_p ATTRIBUTE_UNUSED,rtx x ATTRIBUTE_UNUSED,reg_class_t reload_class_i ATTRIBUTE_UNUSED,enum machine_mode reload_mode ATTRIBUTE_UNUSED,secondary_reload_info * sri)838*e4b17023SJohn Marino default_secondary_reload (bool in_p ATTRIBUTE_UNUSED, rtx x ATTRIBUTE_UNUSED,
839*e4b17023SJohn Marino 			  reg_class_t reload_class_i ATTRIBUTE_UNUSED,
840*e4b17023SJohn Marino 			  enum machine_mode reload_mode ATTRIBUTE_UNUSED,
841*e4b17023SJohn Marino 			  secondary_reload_info *sri)
842*e4b17023SJohn Marino {
843*e4b17023SJohn Marino   enum reg_class rclass = NO_REGS;
844*e4b17023SJohn Marino   enum reg_class reload_class = (enum reg_class) reload_class_i;
845*e4b17023SJohn Marino 
846*e4b17023SJohn Marino   if (sri->prev_sri && sri->prev_sri->t_icode != CODE_FOR_nothing)
847*e4b17023SJohn Marino     {
848*e4b17023SJohn Marino       sri->icode = sri->prev_sri->t_icode;
849*e4b17023SJohn Marino       return NO_REGS;
850*e4b17023SJohn Marino     }
851*e4b17023SJohn Marino #ifdef SECONDARY_INPUT_RELOAD_CLASS
852*e4b17023SJohn Marino   if (in_p)
853*e4b17023SJohn Marino     rclass = SECONDARY_INPUT_RELOAD_CLASS (reload_class, reload_mode, x);
854*e4b17023SJohn Marino #endif
855*e4b17023SJohn Marino #ifdef SECONDARY_OUTPUT_RELOAD_CLASS
856*e4b17023SJohn Marino   if (! in_p)
857*e4b17023SJohn Marino     rclass = SECONDARY_OUTPUT_RELOAD_CLASS (reload_class, reload_mode, x);
858*e4b17023SJohn Marino #endif
859*e4b17023SJohn Marino   if (rclass != NO_REGS)
860*e4b17023SJohn Marino     {
861*e4b17023SJohn Marino       enum insn_code icode
862*e4b17023SJohn Marino 	= direct_optab_handler (in_p ? reload_in_optab : reload_out_optab,
863*e4b17023SJohn Marino 				reload_mode);
864*e4b17023SJohn Marino 
865*e4b17023SJohn Marino       if (icode != CODE_FOR_nothing
866*e4b17023SJohn Marino 	  && !insn_operand_matches (icode, in_p, x))
867*e4b17023SJohn Marino 	icode = CODE_FOR_nothing;
868*e4b17023SJohn Marino       else if (icode != CODE_FOR_nothing)
869*e4b17023SJohn Marino 	{
870*e4b17023SJohn Marino 	  const char *insn_constraint, *scratch_constraint;
871*e4b17023SJohn Marino 	  char insn_letter, scratch_letter;
872*e4b17023SJohn Marino 	  enum reg_class insn_class, scratch_class;
873*e4b17023SJohn Marino 
874*e4b17023SJohn Marino 	  gcc_assert (insn_data[(int) icode].n_operands == 3);
875*e4b17023SJohn Marino 	  insn_constraint = insn_data[(int) icode].operand[!in_p].constraint;
876*e4b17023SJohn Marino 	  if (!*insn_constraint)
877*e4b17023SJohn Marino 	    insn_class = ALL_REGS;
878*e4b17023SJohn Marino 	  else
879*e4b17023SJohn Marino 	    {
880*e4b17023SJohn Marino 	      if (in_p)
881*e4b17023SJohn Marino 		{
882*e4b17023SJohn Marino 		  gcc_assert (*insn_constraint == '=');
883*e4b17023SJohn Marino 		  insn_constraint++;
884*e4b17023SJohn Marino 		}
885*e4b17023SJohn Marino 	      insn_letter = *insn_constraint;
886*e4b17023SJohn Marino 	      insn_class
887*e4b17023SJohn Marino 		= (insn_letter == 'r' ? GENERAL_REGS
888*e4b17023SJohn Marino 		   : REG_CLASS_FROM_CONSTRAINT ((unsigned char) insn_letter,
889*e4b17023SJohn Marino 						insn_constraint));
890*e4b17023SJohn Marino 	      gcc_assert (insn_class != NO_REGS);
891*e4b17023SJohn Marino 	    }
892*e4b17023SJohn Marino 
893*e4b17023SJohn Marino 	  scratch_constraint = insn_data[(int) icode].operand[2].constraint;
894*e4b17023SJohn Marino 	  /* The scratch register's constraint must start with "=&",
895*e4b17023SJohn Marino 	     except for an input reload, where only "=" is necessary,
896*e4b17023SJohn Marino 	     and where it might be beneficial to re-use registers from
897*e4b17023SJohn Marino 	     the input.  */
898*e4b17023SJohn Marino 	  gcc_assert (scratch_constraint[0] == '='
899*e4b17023SJohn Marino 		      && (in_p || scratch_constraint[1] == '&'));
900*e4b17023SJohn Marino 	  scratch_constraint++;
901*e4b17023SJohn Marino 	  if (*scratch_constraint == '&')
902*e4b17023SJohn Marino 	    scratch_constraint++;
903*e4b17023SJohn Marino 	  scratch_letter = *scratch_constraint;
904*e4b17023SJohn Marino 	  scratch_class
905*e4b17023SJohn Marino 	    = (scratch_letter == 'r' ? GENERAL_REGS
906*e4b17023SJohn Marino 	       : REG_CLASS_FROM_CONSTRAINT ((unsigned char) scratch_letter,
907*e4b17023SJohn Marino 					    scratch_constraint));
908*e4b17023SJohn Marino 
909*e4b17023SJohn Marino 	  if (reg_class_subset_p (reload_class, insn_class))
910*e4b17023SJohn Marino 	    {
911*e4b17023SJohn Marino 	      gcc_assert (scratch_class == rclass);
912*e4b17023SJohn Marino 	      rclass = NO_REGS;
913*e4b17023SJohn Marino 	    }
914*e4b17023SJohn Marino 	  else
915*e4b17023SJohn Marino 	    rclass = insn_class;
916*e4b17023SJohn Marino 
917*e4b17023SJohn Marino         }
918*e4b17023SJohn Marino       if (rclass == NO_REGS)
919*e4b17023SJohn Marino 	sri->icode = icode;
920*e4b17023SJohn Marino       else
921*e4b17023SJohn Marino 	sri->t_icode = icode;
922*e4b17023SJohn Marino     }
923*e4b17023SJohn Marino   return rclass;
924*e4b17023SJohn Marino }
925*e4b17023SJohn Marino 
926*e4b17023SJohn Marino /* By default, if flag_pic is true, then neither local nor global relocs
927*e4b17023SJohn Marino    should be placed in readonly memory.  */
928*e4b17023SJohn Marino 
929*e4b17023SJohn Marino int
default_reloc_rw_mask(void)930*e4b17023SJohn Marino default_reloc_rw_mask (void)
931*e4b17023SJohn Marino {
932*e4b17023SJohn Marino   return flag_pic ? 3 : 0;
933*e4b17023SJohn Marino }
934*e4b17023SJohn Marino 
935*e4b17023SJohn Marino /* By default, do no modification. */
default_mangle_decl_assembler_name(tree decl ATTRIBUTE_UNUSED,tree id)936*e4b17023SJohn Marino tree default_mangle_decl_assembler_name (tree decl ATTRIBUTE_UNUSED,
937*e4b17023SJohn Marino 					 tree id)
938*e4b17023SJohn Marino {
939*e4b17023SJohn Marino    return id;
940*e4b17023SJohn Marino }
941*e4b17023SJohn Marino 
942*e4b17023SJohn Marino /* Default to natural alignment for vector types.  */
943*e4b17023SJohn Marino HOST_WIDE_INT
default_vector_alignment(const_tree type)944*e4b17023SJohn Marino default_vector_alignment (const_tree type)
945*e4b17023SJohn Marino {
946*e4b17023SJohn Marino   return tree_low_cst (TYPE_SIZE (type), 0);
947*e4b17023SJohn Marino }
948*e4b17023SJohn Marino 
949*e4b17023SJohn Marino bool
default_builtin_vector_alignment_reachable(const_tree type,bool is_packed)950*e4b17023SJohn Marino default_builtin_vector_alignment_reachable (const_tree type, bool is_packed)
951*e4b17023SJohn Marino {
952*e4b17023SJohn Marino   if (is_packed)
953*e4b17023SJohn Marino     return false;
954*e4b17023SJohn Marino 
955*e4b17023SJohn Marino   /* Assuming that types whose size is > pointer-size are not guaranteed to be
956*e4b17023SJohn Marino      naturally aligned.  */
957*e4b17023SJohn Marino   if (tree_int_cst_compare (TYPE_SIZE (type), bitsize_int (POINTER_SIZE)) > 0)
958*e4b17023SJohn Marino     return false;
959*e4b17023SJohn Marino 
960*e4b17023SJohn Marino   /* Assuming that types whose size is <= pointer-size
961*e4b17023SJohn Marino      are naturally aligned.  */
962*e4b17023SJohn Marino   return true;
963*e4b17023SJohn Marino }
964*e4b17023SJohn Marino 
965*e4b17023SJohn Marino /* By default, assume that a target supports any factor of misalignment
966*e4b17023SJohn Marino    memory access if it supports movmisalign patten.
967*e4b17023SJohn Marino    is_packed is true if the memory access is defined in a packed struct.  */
968*e4b17023SJohn Marino bool
default_builtin_support_vector_misalignment(enum machine_mode mode,const_tree type ATTRIBUTE_UNUSED,int misalignment ATTRIBUTE_UNUSED,bool is_packed ATTRIBUTE_UNUSED)969*e4b17023SJohn Marino default_builtin_support_vector_misalignment (enum machine_mode mode,
970*e4b17023SJohn Marino 					     const_tree type
971*e4b17023SJohn Marino 					     ATTRIBUTE_UNUSED,
972*e4b17023SJohn Marino 					     int misalignment
973*e4b17023SJohn Marino 					     ATTRIBUTE_UNUSED,
974*e4b17023SJohn Marino 					     bool is_packed
975*e4b17023SJohn Marino 					     ATTRIBUTE_UNUSED)
976*e4b17023SJohn Marino {
977*e4b17023SJohn Marino   if (optab_handler (movmisalign_optab, mode) != CODE_FOR_nothing)
978*e4b17023SJohn Marino     return true;
979*e4b17023SJohn Marino   return false;
980*e4b17023SJohn Marino }
981*e4b17023SJohn Marino 
982*e4b17023SJohn Marino /* By default, only attempt to parallelize bitwise operations, and
983*e4b17023SJohn Marino    possibly adds/subtracts using bit-twiddling.  */
984*e4b17023SJohn Marino 
985*e4b17023SJohn Marino enum machine_mode
default_preferred_simd_mode(enum machine_mode mode ATTRIBUTE_UNUSED)986*e4b17023SJohn Marino default_preferred_simd_mode (enum machine_mode mode ATTRIBUTE_UNUSED)
987*e4b17023SJohn Marino {
988*e4b17023SJohn Marino   return word_mode;
989*e4b17023SJohn Marino }
990*e4b17023SJohn Marino 
991*e4b17023SJohn Marino /* By default only the size derived from the preferred vector mode
992*e4b17023SJohn Marino    is tried.  */
993*e4b17023SJohn Marino 
994*e4b17023SJohn Marino unsigned int
default_autovectorize_vector_sizes(void)995*e4b17023SJohn Marino default_autovectorize_vector_sizes (void)
996*e4b17023SJohn Marino {
997*e4b17023SJohn Marino   return 0;
998*e4b17023SJohn Marino }
999*e4b17023SJohn Marino 
1000*e4b17023SJohn Marino /* Determine whether or not a pointer mode is valid. Assume defaults
1001*e4b17023SJohn Marino    of ptr_mode or Pmode - can be overridden.  */
1002*e4b17023SJohn Marino bool
default_valid_pointer_mode(enum machine_mode mode)1003*e4b17023SJohn Marino default_valid_pointer_mode (enum machine_mode mode)
1004*e4b17023SJohn Marino {
1005*e4b17023SJohn Marino   return (mode == ptr_mode || mode == Pmode);
1006*e4b17023SJohn Marino }
1007*e4b17023SJohn Marino 
1008*e4b17023SJohn Marino /* Determine whether the memory reference specified by REF may alias
1009*e4b17023SJohn Marino    the C libraries errno location.  */
1010*e4b17023SJohn Marino bool
default_ref_may_alias_errno(ao_ref * ref)1011*e4b17023SJohn Marino default_ref_may_alias_errno (ao_ref *ref)
1012*e4b17023SJohn Marino {
1013*e4b17023SJohn Marino   tree base = ao_ref_base (ref);
1014*e4b17023SJohn Marino   /* The default implementation assumes the errno location is
1015*e4b17023SJohn Marino      a declaration of type int or is always accessed via a
1016*e4b17023SJohn Marino      pointer to int.  We assume that accesses to errno are
1017*e4b17023SJohn Marino      not deliberately obfuscated (even in conforming ways).  */
1018*e4b17023SJohn Marino   if (TYPE_UNSIGNED (TREE_TYPE (base))
1019*e4b17023SJohn Marino       || TYPE_MODE (TREE_TYPE (base)) != TYPE_MODE (integer_type_node))
1020*e4b17023SJohn Marino     return false;
1021*e4b17023SJohn Marino   /* The default implementation assumes an errno location
1022*e4b17023SJohn Marino      declaration is never defined in the current compilation unit.  */
1023*e4b17023SJohn Marino   if (DECL_P (base)
1024*e4b17023SJohn Marino       && !TREE_STATIC (base))
1025*e4b17023SJohn Marino     return true;
1026*e4b17023SJohn Marino   else if (TREE_CODE (base) == MEM_REF
1027*e4b17023SJohn Marino 	   && TREE_CODE (TREE_OPERAND (base, 0)) == SSA_NAME)
1028*e4b17023SJohn Marino     {
1029*e4b17023SJohn Marino       struct ptr_info_def *pi = SSA_NAME_PTR_INFO (TREE_OPERAND (base, 0));
1030*e4b17023SJohn Marino       return !pi || pi->pt.anything || pi->pt.nonlocal;
1031*e4b17023SJohn Marino     }
1032*e4b17023SJohn Marino   return false;
1033*e4b17023SJohn Marino }
1034*e4b17023SJohn Marino 
1035*e4b17023SJohn Marino /* Return the mode for a pointer to a given ADDRSPACE, defaulting to ptr_mode
1036*e4b17023SJohn Marino    for the generic address space only.  */
1037*e4b17023SJohn Marino 
1038*e4b17023SJohn Marino enum machine_mode
default_addr_space_pointer_mode(addr_space_t addrspace ATTRIBUTE_UNUSED)1039*e4b17023SJohn Marino default_addr_space_pointer_mode (addr_space_t addrspace ATTRIBUTE_UNUSED)
1040*e4b17023SJohn Marino {
1041*e4b17023SJohn Marino   gcc_assert (ADDR_SPACE_GENERIC_P (addrspace));
1042*e4b17023SJohn Marino   return ptr_mode;
1043*e4b17023SJohn Marino }
1044*e4b17023SJohn Marino 
1045*e4b17023SJohn Marino /* Return the mode for an address in a given ADDRSPACE, defaulting to Pmode
1046*e4b17023SJohn Marino    for the generic address space only.  */
1047*e4b17023SJohn Marino 
1048*e4b17023SJohn Marino enum machine_mode
default_addr_space_address_mode(addr_space_t addrspace ATTRIBUTE_UNUSED)1049*e4b17023SJohn Marino default_addr_space_address_mode (addr_space_t addrspace ATTRIBUTE_UNUSED)
1050*e4b17023SJohn Marino {
1051*e4b17023SJohn Marino   gcc_assert (ADDR_SPACE_GENERIC_P (addrspace));
1052*e4b17023SJohn Marino   return Pmode;
1053*e4b17023SJohn Marino }
1054*e4b17023SJohn Marino 
1055*e4b17023SJohn Marino /* Named address space version of valid_pointer_mode.  */
1056*e4b17023SJohn Marino 
1057*e4b17023SJohn Marino bool
default_addr_space_valid_pointer_mode(enum machine_mode mode,addr_space_t as)1058*e4b17023SJohn Marino default_addr_space_valid_pointer_mode (enum machine_mode mode, addr_space_t as)
1059*e4b17023SJohn Marino {
1060*e4b17023SJohn Marino   if (!ADDR_SPACE_GENERIC_P (as))
1061*e4b17023SJohn Marino     return (mode == targetm.addr_space.pointer_mode (as)
1062*e4b17023SJohn Marino 	    || mode == targetm.addr_space.address_mode (as));
1063*e4b17023SJohn Marino 
1064*e4b17023SJohn Marino   return targetm.valid_pointer_mode (mode);
1065*e4b17023SJohn Marino }
1066*e4b17023SJohn Marino 
1067*e4b17023SJohn Marino /* Some places still assume that all pointer or address modes are the
1068*e4b17023SJohn Marino    standard Pmode and ptr_mode.  These optimizations become invalid if
1069*e4b17023SJohn Marino    the target actually supports multiple different modes.  For now,
1070*e4b17023SJohn Marino    we disable such optimizations on such targets, using this function.  */
1071*e4b17023SJohn Marino 
1072*e4b17023SJohn Marino bool
target_default_pointer_address_modes_p(void)1073*e4b17023SJohn Marino target_default_pointer_address_modes_p (void)
1074*e4b17023SJohn Marino {
1075*e4b17023SJohn Marino   if (targetm.addr_space.address_mode != default_addr_space_address_mode)
1076*e4b17023SJohn Marino     return false;
1077*e4b17023SJohn Marino   if (targetm.addr_space.pointer_mode != default_addr_space_pointer_mode)
1078*e4b17023SJohn Marino     return false;
1079*e4b17023SJohn Marino 
1080*e4b17023SJohn Marino   return true;
1081*e4b17023SJohn Marino }
1082*e4b17023SJohn Marino 
1083*e4b17023SJohn Marino /* Named address space version of legitimate_address_p.  */
1084*e4b17023SJohn Marino 
1085*e4b17023SJohn Marino bool
default_addr_space_legitimate_address_p(enum machine_mode mode,rtx mem,bool strict,addr_space_t as)1086*e4b17023SJohn Marino default_addr_space_legitimate_address_p (enum machine_mode mode, rtx mem,
1087*e4b17023SJohn Marino 					 bool strict, addr_space_t as)
1088*e4b17023SJohn Marino {
1089*e4b17023SJohn Marino   if (!ADDR_SPACE_GENERIC_P (as))
1090*e4b17023SJohn Marino     gcc_unreachable ();
1091*e4b17023SJohn Marino 
1092*e4b17023SJohn Marino   return targetm.legitimate_address_p (mode, mem, strict);
1093*e4b17023SJohn Marino }
1094*e4b17023SJohn Marino 
1095*e4b17023SJohn Marino /* Named address space version of LEGITIMIZE_ADDRESS.  */
1096*e4b17023SJohn Marino 
1097*e4b17023SJohn Marino rtx
default_addr_space_legitimize_address(rtx x,rtx oldx,enum machine_mode mode,addr_space_t as)1098*e4b17023SJohn Marino default_addr_space_legitimize_address (rtx x, rtx oldx,
1099*e4b17023SJohn Marino 				       enum machine_mode mode, addr_space_t as)
1100*e4b17023SJohn Marino {
1101*e4b17023SJohn Marino   if (!ADDR_SPACE_GENERIC_P (as))
1102*e4b17023SJohn Marino     return x;
1103*e4b17023SJohn Marino 
1104*e4b17023SJohn Marino   return targetm.legitimize_address (x, oldx, mode);
1105*e4b17023SJohn Marino }
1106*e4b17023SJohn Marino 
1107*e4b17023SJohn Marino /* The default hook for determining if one named address space is a subset of
1108*e4b17023SJohn Marino    another and to return which address space to use as the common address
1109*e4b17023SJohn Marino    space.  */
1110*e4b17023SJohn Marino 
1111*e4b17023SJohn Marino bool
default_addr_space_subset_p(addr_space_t subset,addr_space_t superset)1112*e4b17023SJohn Marino default_addr_space_subset_p (addr_space_t subset, addr_space_t superset)
1113*e4b17023SJohn Marino {
1114*e4b17023SJohn Marino   return (subset == superset);
1115*e4b17023SJohn Marino }
1116*e4b17023SJohn Marino 
1117*e4b17023SJohn Marino /* The default hook for TARGET_ADDR_SPACE_CONVERT. This hook should never be
1118*e4b17023SJohn Marino    called for targets with only a generic address space.  */
1119*e4b17023SJohn Marino 
1120*e4b17023SJohn Marino rtx
default_addr_space_convert(rtx op ATTRIBUTE_UNUSED,tree from_type ATTRIBUTE_UNUSED,tree to_type ATTRIBUTE_UNUSED)1121*e4b17023SJohn Marino default_addr_space_convert (rtx op ATTRIBUTE_UNUSED,
1122*e4b17023SJohn Marino 			    tree from_type ATTRIBUTE_UNUSED,
1123*e4b17023SJohn Marino 			    tree to_type ATTRIBUTE_UNUSED)
1124*e4b17023SJohn Marino {
1125*e4b17023SJohn Marino   gcc_unreachable ();
1126*e4b17023SJohn Marino }
1127*e4b17023SJohn Marino 
1128*e4b17023SJohn Marino bool
default_hard_regno_scratch_ok(unsigned int regno ATTRIBUTE_UNUSED)1129*e4b17023SJohn Marino default_hard_regno_scratch_ok (unsigned int regno ATTRIBUTE_UNUSED)
1130*e4b17023SJohn Marino {
1131*e4b17023SJohn Marino   return true;
1132*e4b17023SJohn Marino }
1133*e4b17023SJohn Marino 
1134*e4b17023SJohn Marino /* The default implementation of TARGET_MODE_DEPENDENT_ADDRESS_P.  */
1135*e4b17023SJohn Marino 
1136*e4b17023SJohn Marino bool
default_mode_dependent_address_p(const_rtx addr ATTRIBUTE_UNUSED)1137*e4b17023SJohn Marino default_mode_dependent_address_p (const_rtx addr ATTRIBUTE_UNUSED)
1138*e4b17023SJohn Marino {
1139*e4b17023SJohn Marino #ifdef GO_IF_MODE_DEPENDENT_ADDRESS
1140*e4b17023SJohn Marino 
1141*e4b17023SJohn Marino   GO_IF_MODE_DEPENDENT_ADDRESS (CONST_CAST_RTX (addr), win);
1142*e4b17023SJohn Marino   return false;
1143*e4b17023SJohn Marino   /* Label `win' might (not) be used via GO_IF_MODE_DEPENDENT_ADDRESS.  */
1144*e4b17023SJohn Marino  win: ATTRIBUTE_UNUSED_LABEL
1145*e4b17023SJohn Marino   return true;
1146*e4b17023SJohn Marino 
1147*e4b17023SJohn Marino #else
1148*e4b17023SJohn Marino 
1149*e4b17023SJohn Marino   return false;
1150*e4b17023SJohn Marino 
1151*e4b17023SJohn Marino #endif
1152*e4b17023SJohn Marino }
1153*e4b17023SJohn Marino 
1154*e4b17023SJohn Marino bool
default_target_option_valid_attribute_p(tree ARG_UNUSED (fndecl),tree ARG_UNUSED (name),tree ARG_UNUSED (args),int ARG_UNUSED (flags))1155*e4b17023SJohn Marino default_target_option_valid_attribute_p (tree ARG_UNUSED (fndecl),
1156*e4b17023SJohn Marino 					 tree ARG_UNUSED (name),
1157*e4b17023SJohn Marino 					 tree ARG_UNUSED (args),
1158*e4b17023SJohn Marino 					 int ARG_UNUSED (flags))
1159*e4b17023SJohn Marino {
1160*e4b17023SJohn Marino   warning (OPT_Wattributes,
1161*e4b17023SJohn Marino 	   "target attribute is not supported on this machine");
1162*e4b17023SJohn Marino 
1163*e4b17023SJohn Marino   return false;
1164*e4b17023SJohn Marino }
1165*e4b17023SJohn Marino 
1166*e4b17023SJohn Marino bool
default_target_option_pragma_parse(tree ARG_UNUSED (args),tree ARG_UNUSED (pop_target))1167*e4b17023SJohn Marino default_target_option_pragma_parse (tree ARG_UNUSED (args),
1168*e4b17023SJohn Marino 				    tree ARG_UNUSED (pop_target))
1169*e4b17023SJohn Marino {
1170*e4b17023SJohn Marino   warning (OPT_Wpragmas,
1171*e4b17023SJohn Marino 	   "#pragma GCC target is not supported for this machine");
1172*e4b17023SJohn Marino 
1173*e4b17023SJohn Marino   return false;
1174*e4b17023SJohn Marino }
1175*e4b17023SJohn Marino 
1176*e4b17023SJohn Marino bool
default_target_can_inline_p(tree caller,tree callee)1177*e4b17023SJohn Marino default_target_can_inline_p (tree caller, tree callee)
1178*e4b17023SJohn Marino {
1179*e4b17023SJohn Marino   bool ret = false;
1180*e4b17023SJohn Marino   tree callee_opts = DECL_FUNCTION_SPECIFIC_TARGET (callee);
1181*e4b17023SJohn Marino   tree caller_opts = DECL_FUNCTION_SPECIFIC_TARGET (caller);
1182*e4b17023SJohn Marino 
1183*e4b17023SJohn Marino   /* If callee has no option attributes, then it is ok to inline */
1184*e4b17023SJohn Marino   if (!callee_opts)
1185*e4b17023SJohn Marino     ret = true;
1186*e4b17023SJohn Marino 
1187*e4b17023SJohn Marino   /* If caller has no option attributes, but callee does then it is not ok to
1188*e4b17023SJohn Marino      inline */
1189*e4b17023SJohn Marino   else if (!caller_opts)
1190*e4b17023SJohn Marino     ret = false;
1191*e4b17023SJohn Marino 
1192*e4b17023SJohn Marino   /* If both caller and callee have attributes, assume that if the
1193*e4b17023SJohn Marino      pointer is different, the two functions have different target
1194*e4b17023SJohn Marino      options since build_target_option_node uses a hash table for the
1195*e4b17023SJohn Marino      options.  */
1196*e4b17023SJohn Marino   else
1197*e4b17023SJohn Marino     ret = (callee_opts == caller_opts);
1198*e4b17023SJohn Marino 
1199*e4b17023SJohn Marino   return ret;
1200*e4b17023SJohn Marino }
1201*e4b17023SJohn Marino 
1202*e4b17023SJohn Marino #ifndef HAVE_casesi
1203*e4b17023SJohn Marino # define HAVE_casesi 0
1204*e4b17023SJohn Marino #endif
1205*e4b17023SJohn Marino 
1206*e4b17023SJohn Marino /* If the machine does not have a case insn that compares the bounds,
1207*e4b17023SJohn Marino    this means extra overhead for dispatch tables, which raises the
1208*e4b17023SJohn Marino    threshold for using them.  */
1209*e4b17023SJohn Marino 
default_case_values_threshold(void)1210*e4b17023SJohn Marino unsigned int default_case_values_threshold (void)
1211*e4b17023SJohn Marino {
1212*e4b17023SJohn Marino   return (HAVE_casesi ? 4 : 5);
1213*e4b17023SJohn Marino }
1214*e4b17023SJohn Marino 
1215*e4b17023SJohn Marino bool
default_have_conditional_execution(void)1216*e4b17023SJohn Marino default_have_conditional_execution (void)
1217*e4b17023SJohn Marino {
1218*e4b17023SJohn Marino #ifdef HAVE_conditional_execution
1219*e4b17023SJohn Marino   return HAVE_conditional_execution;
1220*e4b17023SJohn Marino #else
1221*e4b17023SJohn Marino   return false;
1222*e4b17023SJohn Marino #endif
1223*e4b17023SJohn Marino }
1224*e4b17023SJohn Marino 
1225*e4b17023SJohn Marino tree
default_builtin_tm_load_store(tree ARG_UNUSED (type))1226*e4b17023SJohn Marino default_builtin_tm_load_store (tree ARG_UNUSED (type))
1227*e4b17023SJohn Marino {
1228*e4b17023SJohn Marino   return NULL_TREE;
1229*e4b17023SJohn Marino }
1230*e4b17023SJohn Marino 
1231*e4b17023SJohn Marino /* Compute cost of moving registers to/from memory.  */
1232*e4b17023SJohn Marino 
1233*e4b17023SJohn Marino int
default_memory_move_cost(enum machine_mode mode ATTRIBUTE_UNUSED,reg_class_t rclass ATTRIBUTE_UNUSED,bool in ATTRIBUTE_UNUSED)1234*e4b17023SJohn Marino default_memory_move_cost (enum machine_mode mode ATTRIBUTE_UNUSED,
1235*e4b17023SJohn Marino 			  reg_class_t rclass ATTRIBUTE_UNUSED,
1236*e4b17023SJohn Marino 			  bool in ATTRIBUTE_UNUSED)
1237*e4b17023SJohn Marino {
1238*e4b17023SJohn Marino #ifndef MEMORY_MOVE_COST
1239*e4b17023SJohn Marino     return (4 + memory_move_secondary_cost (mode, (enum reg_class) rclass, in));
1240*e4b17023SJohn Marino #else
1241*e4b17023SJohn Marino     return MEMORY_MOVE_COST (mode, (enum reg_class) rclass, in);
1242*e4b17023SJohn Marino #endif
1243*e4b17023SJohn Marino }
1244*e4b17023SJohn Marino 
1245*e4b17023SJohn Marino /* Compute cost of moving data from a register of class FROM to one of
1246*e4b17023SJohn Marino    TO, using MODE.  */
1247*e4b17023SJohn Marino 
1248*e4b17023SJohn Marino int
default_register_move_cost(enum machine_mode mode ATTRIBUTE_UNUSED,reg_class_t from ATTRIBUTE_UNUSED,reg_class_t to ATTRIBUTE_UNUSED)1249*e4b17023SJohn Marino default_register_move_cost (enum machine_mode mode ATTRIBUTE_UNUSED,
1250*e4b17023SJohn Marino                             reg_class_t from ATTRIBUTE_UNUSED,
1251*e4b17023SJohn Marino                             reg_class_t to ATTRIBUTE_UNUSED)
1252*e4b17023SJohn Marino {
1253*e4b17023SJohn Marino #ifndef REGISTER_MOVE_COST
1254*e4b17023SJohn Marino   return 2;
1255*e4b17023SJohn Marino #else
1256*e4b17023SJohn Marino   return REGISTER_MOVE_COST (mode, (enum reg_class) from, (enum reg_class) to);
1257*e4b17023SJohn Marino #endif
1258*e4b17023SJohn Marino }
1259*e4b17023SJohn Marino 
1260*e4b17023SJohn Marino bool
default_profile_before_prologue(void)1261*e4b17023SJohn Marino default_profile_before_prologue (void)
1262*e4b17023SJohn Marino {
1263*e4b17023SJohn Marino #ifdef PROFILE_BEFORE_PROLOGUE
1264*e4b17023SJohn Marino   return true;
1265*e4b17023SJohn Marino #else
1266*e4b17023SJohn Marino   return false;
1267*e4b17023SJohn Marino #endif
1268*e4b17023SJohn Marino }
1269*e4b17023SJohn Marino 
1270*e4b17023SJohn Marino /* The default implementation of TARGET_PREFERRED_RELOAD_CLASS.  */
1271*e4b17023SJohn Marino 
1272*e4b17023SJohn Marino reg_class_t
default_preferred_reload_class(rtx x ATTRIBUTE_UNUSED,reg_class_t rclass)1273*e4b17023SJohn Marino default_preferred_reload_class (rtx x ATTRIBUTE_UNUSED,
1274*e4b17023SJohn Marino 			        reg_class_t rclass)
1275*e4b17023SJohn Marino {
1276*e4b17023SJohn Marino #ifdef PREFERRED_RELOAD_CLASS
1277*e4b17023SJohn Marino   return (reg_class_t) PREFERRED_RELOAD_CLASS (x, (enum reg_class) rclass);
1278*e4b17023SJohn Marino #else
1279*e4b17023SJohn Marino   return rclass;
1280*e4b17023SJohn Marino #endif
1281*e4b17023SJohn Marino }
1282*e4b17023SJohn Marino 
1283*e4b17023SJohn Marino /* The default implementation of TARGET_OUTPUT_PREFERRED_RELOAD_CLASS.  */
1284*e4b17023SJohn Marino 
1285*e4b17023SJohn Marino reg_class_t
default_preferred_output_reload_class(rtx x ATTRIBUTE_UNUSED,reg_class_t rclass)1286*e4b17023SJohn Marino default_preferred_output_reload_class (rtx x ATTRIBUTE_UNUSED,
1287*e4b17023SJohn Marino 				       reg_class_t rclass)
1288*e4b17023SJohn Marino {
1289*e4b17023SJohn Marino   return rclass;
1290*e4b17023SJohn Marino }
1291*e4b17023SJohn Marino 
1292*e4b17023SJohn Marino /* The default implementation of TARGET_PREFERRED_RENAME_CLASS.  */
1293*e4b17023SJohn Marino reg_class_t
default_preferred_rename_class(reg_class_t rclass ATTRIBUTE_UNUSED)1294*e4b17023SJohn Marino default_preferred_rename_class (reg_class_t rclass ATTRIBUTE_UNUSED)
1295*e4b17023SJohn Marino {
1296*e4b17023SJohn Marino   return NO_REGS;
1297*e4b17023SJohn Marino }
1298*e4b17023SJohn Marino 
1299*e4b17023SJohn Marino /* The default implementation of TARGET_CLASS_LIKELY_SPILLED_P.  */
1300*e4b17023SJohn Marino 
1301*e4b17023SJohn Marino bool
default_class_likely_spilled_p(reg_class_t rclass)1302*e4b17023SJohn Marino default_class_likely_spilled_p (reg_class_t rclass)
1303*e4b17023SJohn Marino {
1304*e4b17023SJohn Marino   return (reg_class_size[(int) rclass] == 1);
1305*e4b17023SJohn Marino }
1306*e4b17023SJohn Marino 
1307*e4b17023SJohn Marino /* The default implementation of TARGET_CLASS_MAX_NREGS.  */
1308*e4b17023SJohn Marino 
1309*e4b17023SJohn Marino unsigned char
default_class_max_nregs(reg_class_t rclass ATTRIBUTE_UNUSED,enum machine_mode mode ATTRIBUTE_UNUSED)1310*e4b17023SJohn Marino default_class_max_nregs (reg_class_t rclass ATTRIBUTE_UNUSED,
1311*e4b17023SJohn Marino 			 enum machine_mode mode ATTRIBUTE_UNUSED)
1312*e4b17023SJohn Marino {
1313*e4b17023SJohn Marino #ifdef CLASS_MAX_NREGS
1314*e4b17023SJohn Marino   return (unsigned char) CLASS_MAX_NREGS ((enum reg_class) rclass, mode);
1315*e4b17023SJohn Marino #else
1316*e4b17023SJohn Marino   return ((GET_MODE_SIZE (mode) + UNITS_PER_WORD - 1) / UNITS_PER_WORD);
1317*e4b17023SJohn Marino #endif
1318*e4b17023SJohn Marino }
1319*e4b17023SJohn Marino 
1320*e4b17023SJohn Marino /* Determine the debugging unwind mechanism for the target.  */
1321*e4b17023SJohn Marino 
1322*e4b17023SJohn Marino enum unwind_info_type
default_debug_unwind_info(void)1323*e4b17023SJohn Marino default_debug_unwind_info (void)
1324*e4b17023SJohn Marino {
1325*e4b17023SJohn Marino   /* If the target wants to force the use of dwarf2 unwind info, let it.  */
1326*e4b17023SJohn Marino   /* ??? Change all users to the hook, then poison this.  */
1327*e4b17023SJohn Marino #ifdef DWARF2_FRAME_INFO
1328*e4b17023SJohn Marino   if (DWARF2_FRAME_INFO)
1329*e4b17023SJohn Marino     return UI_DWARF2;
1330*e4b17023SJohn Marino #endif
1331*e4b17023SJohn Marino 
1332*e4b17023SJohn Marino   /* Otherwise, only turn it on if dwarf2 debugging is enabled.  */
1333*e4b17023SJohn Marino #ifdef DWARF2_DEBUGGING_INFO
1334*e4b17023SJohn Marino   if (write_symbols == DWARF2_DEBUG || write_symbols == VMS_AND_DWARF2_DEBUG)
1335*e4b17023SJohn Marino     return UI_DWARF2;
1336*e4b17023SJohn Marino #endif
1337*e4b17023SJohn Marino 
1338*e4b17023SJohn Marino   return UI_NONE;
1339*e4b17023SJohn Marino }
1340*e4b17023SJohn Marino 
1341*e4b17023SJohn Marino /* To be used by targets where reg_raw_mode doesn't return the right
1342*e4b17023SJohn Marino    mode for registers used in apply_builtin_return and apply_builtin_arg.  */
1343*e4b17023SJohn Marino 
1344*e4b17023SJohn Marino enum machine_mode
default_get_reg_raw_mode(int regno)1345*e4b17023SJohn Marino default_get_reg_raw_mode(int regno)
1346*e4b17023SJohn Marino {
1347*e4b17023SJohn Marino   return reg_raw_mode[regno];
1348*e4b17023SJohn Marino }
1349*e4b17023SJohn Marino 
1350*e4b17023SJohn Marino /* Return true if the state of option OPTION should be stored in PCH files
1351*e4b17023SJohn Marino    and checked by default_pch_valid_p.  Store the option's current state
1352*e4b17023SJohn Marino    in STATE if so.  */
1353*e4b17023SJohn Marino 
1354*e4b17023SJohn Marino static inline bool
option_affects_pch_p(int option,struct cl_option_state * state)1355*e4b17023SJohn Marino option_affects_pch_p (int option, struct cl_option_state *state)
1356*e4b17023SJohn Marino {
1357*e4b17023SJohn Marino   if ((cl_options[option].flags & CL_TARGET) == 0)
1358*e4b17023SJohn Marino     return false;
1359*e4b17023SJohn Marino   if (option_flag_var (option, &global_options) == &target_flags)
1360*e4b17023SJohn Marino     if (targetm.check_pch_target_flags)
1361*e4b17023SJohn Marino       return false;
1362*e4b17023SJohn Marino   return get_option_state (&global_options, option, state);
1363*e4b17023SJohn Marino }
1364*e4b17023SJohn Marino 
1365*e4b17023SJohn Marino /* Default version of get_pch_validity.
1366*e4b17023SJohn Marino    By default, every flag difference is fatal; that will be mostly right for
1367*e4b17023SJohn Marino    most targets, but completely right for very few.  */
1368*e4b17023SJohn Marino 
1369*e4b17023SJohn Marino void *
default_get_pch_validity(size_t * sz)1370*e4b17023SJohn Marino default_get_pch_validity (size_t *sz)
1371*e4b17023SJohn Marino {
1372*e4b17023SJohn Marino   struct cl_option_state state;
1373*e4b17023SJohn Marino   size_t i;
1374*e4b17023SJohn Marino   char *result, *r;
1375*e4b17023SJohn Marino 
1376*e4b17023SJohn Marino   *sz = 2;
1377*e4b17023SJohn Marino   if (targetm.check_pch_target_flags)
1378*e4b17023SJohn Marino     *sz += sizeof (target_flags);
1379*e4b17023SJohn Marino   for (i = 0; i < cl_options_count; i++)
1380*e4b17023SJohn Marino     if (option_affects_pch_p (i, &state))
1381*e4b17023SJohn Marino       *sz += state.size;
1382*e4b17023SJohn Marino 
1383*e4b17023SJohn Marino   result = r = XNEWVEC (char, *sz);
1384*e4b17023SJohn Marino   r[0] = flag_pic;
1385*e4b17023SJohn Marino   r[1] = flag_pie;
1386*e4b17023SJohn Marino   r += 2;
1387*e4b17023SJohn Marino   if (targetm.check_pch_target_flags)
1388*e4b17023SJohn Marino     {
1389*e4b17023SJohn Marino       memcpy (r, &target_flags, sizeof (target_flags));
1390*e4b17023SJohn Marino       r += sizeof (target_flags);
1391*e4b17023SJohn Marino     }
1392*e4b17023SJohn Marino 
1393*e4b17023SJohn Marino   for (i = 0; i < cl_options_count; i++)
1394*e4b17023SJohn Marino     if (option_affects_pch_p (i, &state))
1395*e4b17023SJohn Marino       {
1396*e4b17023SJohn Marino 	memcpy (r, state.data, state.size);
1397*e4b17023SJohn Marino 	r += state.size;
1398*e4b17023SJohn Marino       }
1399*e4b17023SJohn Marino 
1400*e4b17023SJohn Marino   return result;
1401*e4b17023SJohn Marino }
1402*e4b17023SJohn Marino 
1403*e4b17023SJohn Marino /* Return a message which says that a PCH file was created with a different
1404*e4b17023SJohn Marino    setting of OPTION.  */
1405*e4b17023SJohn Marino 
1406*e4b17023SJohn Marino static const char *
pch_option_mismatch(const char * option)1407*e4b17023SJohn Marino pch_option_mismatch (const char *option)
1408*e4b17023SJohn Marino {
1409*e4b17023SJohn Marino   char *r;
1410*e4b17023SJohn Marino 
1411*e4b17023SJohn Marino   asprintf (&r, _("created and used with differing settings of '%s'"), option);
1412*e4b17023SJohn Marino   if (r == NULL)
1413*e4b17023SJohn Marino     return _("out of memory");
1414*e4b17023SJohn Marino   return r;
1415*e4b17023SJohn Marino }
1416*e4b17023SJohn Marino 
1417*e4b17023SJohn Marino /* Default version of pch_valid_p.  */
1418*e4b17023SJohn Marino 
1419*e4b17023SJohn Marino const char *
default_pch_valid_p(const void * data_p,size_t len)1420*e4b17023SJohn Marino default_pch_valid_p (const void *data_p, size_t len)
1421*e4b17023SJohn Marino {
1422*e4b17023SJohn Marino   struct cl_option_state state;
1423*e4b17023SJohn Marino   const char *data = (const char *)data_p;
1424*e4b17023SJohn Marino   size_t i;
1425*e4b17023SJohn Marino 
1426*e4b17023SJohn Marino   /* -fpic and -fpie also usually make a PCH invalid.  */
1427*e4b17023SJohn Marino   if (data[0] != flag_pic)
1428*e4b17023SJohn Marino     return _("created and used with different settings of -fpic");
1429*e4b17023SJohn Marino   if (data[1] != flag_pie)
1430*e4b17023SJohn Marino     return _("created and used with different settings of -fpie");
1431*e4b17023SJohn Marino   data += 2;
1432*e4b17023SJohn Marino 
1433*e4b17023SJohn Marino   /* Check target_flags.  */
1434*e4b17023SJohn Marino   if (targetm.check_pch_target_flags)
1435*e4b17023SJohn Marino     {
1436*e4b17023SJohn Marino       int tf;
1437*e4b17023SJohn Marino       const char *r;
1438*e4b17023SJohn Marino 
1439*e4b17023SJohn Marino       memcpy (&tf, data, sizeof (target_flags));
1440*e4b17023SJohn Marino       data += sizeof (target_flags);
1441*e4b17023SJohn Marino       len -= sizeof (target_flags);
1442*e4b17023SJohn Marino       r = targetm.check_pch_target_flags (tf);
1443*e4b17023SJohn Marino       if (r != NULL)
1444*e4b17023SJohn Marino 	return r;
1445*e4b17023SJohn Marino     }
1446*e4b17023SJohn Marino 
1447*e4b17023SJohn Marino   for (i = 0; i < cl_options_count; i++)
1448*e4b17023SJohn Marino     if (option_affects_pch_p (i, &state))
1449*e4b17023SJohn Marino       {
1450*e4b17023SJohn Marino 	if (memcmp (data, state.data, state.size) != 0)
1451*e4b17023SJohn Marino 	  return pch_option_mismatch (cl_options[i].opt_text);
1452*e4b17023SJohn Marino 	data += state.size;
1453*e4b17023SJohn Marino 	len -= state.size;
1454*e4b17023SJohn Marino       }
1455*e4b17023SJohn Marino 
1456*e4b17023SJohn Marino   return NULL;
1457*e4b17023SJohn Marino }
1458*e4b17023SJohn Marino 
1459*e4b17023SJohn Marino #include "gt-targhooks.h"
1460