1132718Skan/* Default target hook functions.
2169689Skan   Copyright (C) 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
3132718Skan
4132718SkanThis file is part of GCC.
5132718Skan
6132718SkanGCC is free software; you can redistribute it and/or modify it under
7132718Skanthe terms of the GNU General Public License as published by the Free
8132718SkanSoftware Foundation; either version 2, or (at your option) any later
9132718Skanversion.
10132718Skan
11132718SkanGCC is distributed in the hope that it will be useful, but WITHOUT ANY
12132718SkanWARRANTY; without even the implied warranty of MERCHANTABILITY or
13132718SkanFITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14132718Skanfor more details.
15132718Skan
16132718SkanYou should have received a copy of the GNU General Public License
17132718Skanalong with GCC; see the file COPYING.  If not, write to the Free
18169689SkanSoftware Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
19169689Skan02110-1301, USA.  */
20132718Skan
21132718Skan/* The migration of target macros to target hooks works as follows:
22132718Skan
23132718Skan   1. Create a target hook that uses the existing target macros to
24132718Skan      implement the same functionality.
25132718Skan
26132718Skan   2. Convert all the MI files to use the hook instead of the macro.
27132718Skan
28132718Skan   3. Repeat for a majority of the remaining target macros.  This will
29132718Skan      take some time.
30132718Skan
31132718Skan   4. Tell target maintainers to start migrating.
32132718Skan
33132718Skan   5. Eventually convert the backends to override the hook instead of
34132718Skan      defining the macros.  This will take some time too.
35132718Skan
36132718Skan   6. TBD when, poison the macros.  Unmigrated targets will break at
37132718Skan      this point.
38132718Skan
39132718Skan   Note that we expect steps 1-3 to be done by the people that
40132718Skan   understand what the MI does with each macro, and step 5 to be done
41132718Skan   by the target maintainers for their respective targets.
42132718Skan
43132718Skan   Note that steps 1 and 2 don't have to be done together, but no
44132718Skan   target can override the new hook until step 2 is complete for it.
45132718Skan
46132718Skan   Once the macros are poisoned, we will revert to the old migration
47132718Skan   rules - migrate the macro, callers, and targets all at once.  This
48132718Skan   comment can thus be removed at that point.  */
49132718Skan
50132718Skan#include "config.h"
51132718Skan#include "system.h"
52132718Skan#include "coretypes.h"
53132718Skan#include "tm.h"
54132718Skan#include "machmode.h"
55132718Skan#include "rtl.h"
56132718Skan#include "tree.h"
57132718Skan#include "expr.h"
58132718Skan#include "output.h"
59132718Skan#include "toplev.h"
60132718Skan#include "function.h"
61132718Skan#include "target.h"
62132718Skan#include "tm_p.h"
63132718Skan#include "target-def.h"
64169689Skan#include "ggc.h"
65169689Skan#include "hard-reg-set.h"
66169689Skan#include "reload.h"
67169689Skan#include "optabs.h"
68169689Skan#include "recog.h"
69132718Skan
70169689Skan
71132718Skanvoid
72132718Skandefault_external_libcall (rtx fun ATTRIBUTE_UNUSED)
73132718Skan{
74132718Skan#ifdef ASM_OUTPUT_EXTERNAL_LIBCALL
75132718Skan  ASM_OUTPUT_EXTERNAL_LIBCALL(asm_out_file, fun);
76132718Skan#endif
77132718Skan}
78132718Skan
79132718Skanenum machine_mode
80132718Skandefault_cc_modes_compatible (enum machine_mode m1, enum machine_mode m2)
81132718Skan{
82132718Skan  if (m1 == m2)
83132718Skan    return m1;
84132718Skan  return VOIDmode;
85132718Skan}
86132718Skan
87132718Skanbool
88169689Skandefault_return_in_memory (tree type,
89169689Skan			  tree fntype ATTRIBUTE_UNUSED)
90132718Skan{
91169689Skan#ifndef RETURN_IN_MEMORY
92169689Skan  return (TYPE_MODE (type) == BLKmode);
93132718Skan#else
94169689Skan  return RETURN_IN_MEMORY (type);
95132718Skan#endif
96132718Skan}
97132718Skan
98261188Spfg/* APPLE LOCAL begin radar 4781080 */
99261188Spfgbool
100261188Spfgdefault_objc_fpreturn_msgcall (tree type, bool no_long_double)
101261188Spfg{
102261188Spfg#ifndef OBJC_FPRETURN_MSGCALL
103261188Spfg  return type == NULL_TREE && no_long_double;
104261188Spfg#else
105261188Spfg  return OBJC_FPRETURN_MSGCALL (type, no_long_double);
106261188Spfg#endif
107261188Spfg}
108261188Spfg/* APPLE LOCAL end radar 4781080 */
109261188Spfg
110169689Skanrtx
111169689Skandefault_expand_builtin_saveregs (void)
112169689Skan{
113169689Skan  error ("__builtin_saveregs not supported by this target");
114169689Skan  return const0_rtx;
115169689Skan}
116169689Skan
117169689Skanvoid
118169689Skandefault_setup_incoming_varargs (CUMULATIVE_ARGS *ca ATTRIBUTE_UNUSED,
119169689Skan				enum machine_mode mode ATTRIBUTE_UNUSED,
120169689Skan				tree type ATTRIBUTE_UNUSED,
121169689Skan				int *pretend_arg_size ATTRIBUTE_UNUSED,
122169689Skan				int second_time ATTRIBUTE_UNUSED)
123169689Skan{
124169689Skan}
125169689Skan
126169689Skan/* The default implementation of TARGET_BUILTIN_SETJMP_FRAME_VALUE.  */
127169689Skan
128169689Skanrtx
129169689Skandefault_builtin_setjmp_frame_value (void)
130169689Skan{
131169689Skan  return virtual_stack_vars_rtx;
132169689Skan}
133169689Skan
134169689Skan/* Generic hook that takes a CUMULATIVE_ARGS pointer and returns false.  */
135169689Skan
136132718Skanbool
137169689Skanhook_bool_CUMULATIVE_ARGS_false (CUMULATIVE_ARGS *ca ATTRIBUTE_UNUSED)
138132718Skan{
139132718Skan  return false;
140132718Skan}
141132718Skan
142132718Skanbool
143169689Skandefault_pretend_outgoing_varargs_named (CUMULATIVE_ARGS *ca ATTRIBUTE_UNUSED)
144132718Skan{
145169689Skan  return (targetm.calls.setup_incoming_varargs
146169689Skan	  != default_setup_incoming_varargs);
147169689Skan}
148169689Skan
149169689Skanenum machine_mode
150169689Skandefault_eh_return_filter_mode (void)
151169689Skan{
152169689Skan  return word_mode;
153169689Skan}
154169689Skan
155169689Skan/* The default implementation of TARGET_SHIFT_TRUNCATION_MASK.  */
156169689Skan
157169689Skanunsigned HOST_WIDE_INT
158169689Skandefault_shift_truncation_mask (enum machine_mode mode)
159169689Skan{
160169689Skan  return SHIFT_COUNT_TRUNCATED ? GET_MODE_BITSIZE (mode) - 1 : 0;
161169689Skan}
162169689Skan
163169689Skan/* The default implementation of TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.  */
164169689Skan
165169689Skanunsigned int
166169689Skandefault_min_divisions_for_recip_mul (enum machine_mode mode ATTRIBUTE_UNUSED)
167169689Skan{
168169689Skan  return have_insn_for (DIV, mode) ? 3 : 2;
169169689Skan}
170169689Skan
171169689Skan/* The default implementation of TARGET_MODE_REP_EXTENDED.  */
172169689Skan
173169689Skanint
174169689Skandefault_mode_rep_extended (enum machine_mode mode ATTRIBUTE_UNUSED,
175169689Skan			   enum machine_mode mode_rep ATTRIBUTE_UNUSED)
176169689Skan{
177169689Skan  return UNKNOWN;
178169689Skan}
179169689Skan
180169689Skan/* Generic hook that takes a CUMULATIVE_ARGS pointer and returns true.  */
181169689Skan
182169689Skanbool
183169689Skanhook_bool_CUMULATIVE_ARGS_true (CUMULATIVE_ARGS * a ATTRIBUTE_UNUSED)
184169689Skan{
185169689Skan  return true;
186169689Skan}
187169689Skan
188169689Skan
189169689Skan/* The generic C++ ABI specifies this is a 64-bit value.  */
190169689Skantree
191169689Skandefault_cxx_guard_type (void)
192169689Skan{
193169689Skan  return long_long_integer_type_node;
194169689Skan}
195169689Skan
196169689Skan
197169689Skan/* Returns the size of the cookie to use when allocating an array
198169689Skan   whose elements have the indicated TYPE.  Assumes that it is already
199169689Skan   known that a cookie is needed.  */
200169689Skan
201169689Skantree
202169689Skandefault_cxx_get_cookie_size (tree type)
203169689Skan{
204169689Skan  tree cookie_size;
205169689Skan
206169689Skan  /* We need to allocate an additional max (sizeof (size_t), alignof
207169689Skan     (true_type)) bytes.  */
208169689Skan  tree sizetype_size;
209169689Skan  tree type_align;
210169689Skan
211169689Skan  sizetype_size = size_in_bytes (sizetype);
212169689Skan  type_align = size_int (TYPE_ALIGN_UNIT (type));
213169689Skan  if (INT_CST_LT_UNSIGNED (type_align, sizetype_size))
214169689Skan    cookie_size = sizetype_size;
215132718Skan  else
216169689Skan    cookie_size = type_align;
217169689Skan
218169689Skan  return cookie_size;
219132718Skan}
220132718Skan
221169689Skan/* Return true if a parameter must be passed by reference.  This version
222169689Skan   of the TARGET_PASS_BY_REFERENCE hook uses just MUST_PASS_IN_STACK.  */
223169689Skan
224169689Skanbool
225169689Skanhook_pass_by_reference_must_pass_in_stack (CUMULATIVE_ARGS *c ATTRIBUTE_UNUSED,
226169689Skan	enum machine_mode mode ATTRIBUTE_UNUSED, tree type ATTRIBUTE_UNUSED,
227169689Skan	bool named_arg ATTRIBUTE_UNUSED)
228132718Skan{
229169689Skan  return targetm.calls.must_pass_in_stack (mode, type);
230169689Skan}
231169689Skan
232169689Skan/* Return true if a parameter follows callee copies conventions.  This
233169689Skan   version of the hook is true for all named arguments.  */
234169689Skan
235169689Skanbool
236169689Skanhook_callee_copies_named (CUMULATIVE_ARGS *ca ATTRIBUTE_UNUSED,
237169689Skan			  enum machine_mode mode ATTRIBUTE_UNUSED,
238169689Skan			  tree type ATTRIBUTE_UNUSED, bool named)
239169689Skan{
240169689Skan  return named;
241169689Skan}
242169689Skan
243169689Skan/* Emit any directives required to unwind this instruction.  */
244169689Skan
245169689Skanvoid
246169689Skandefault_unwind_emit (FILE * stream ATTRIBUTE_UNUSED,
247169689Skan		     rtx insn ATTRIBUTE_UNUSED)
248169689Skan{
249169689Skan  /* Should never happen.  */
250169689Skan  gcc_unreachable ();
251169689Skan}
252169689Skan
253169689Skan/* True if MODE is valid for the target.  By "valid", we mean able to
254169689Skan   be manipulated in non-trivial ways.  In particular, this means all
255169689Skan   the arithmetic is supported.
256169689Skan
257169689Skan   By default we guess this means that any C type is supported.  If
258169689Skan   we can't map the mode back to a type that would be available in C,
259169689Skan   then reject it.  Special case, here, is the double-word arithmetic
260169689Skan   supported by optabs.c.  */
261169689Skan
262169689Skanbool
263169689Skandefault_scalar_mode_supported_p (enum machine_mode mode)
264169689Skan{
265169689Skan  int precision = GET_MODE_PRECISION (mode);
266169689Skan
267169689Skan  switch (GET_MODE_CLASS (mode))
268132718Skan    {
269169689Skan    case MODE_PARTIAL_INT:
270169689Skan    case MODE_INT:
271169689Skan      if (precision == CHAR_TYPE_SIZE)
272169689Skan	return true;
273169689Skan      if (precision == SHORT_TYPE_SIZE)
274169689Skan	return true;
275169689Skan      if (precision == INT_TYPE_SIZE)
276169689Skan	return true;
277169689Skan      if (precision == LONG_TYPE_SIZE)
278169689Skan	return true;
279169689Skan      if (precision == LONG_LONG_TYPE_SIZE)
280169689Skan	return true;
281169689Skan      if (precision == 2 * BITS_PER_WORD)
282169689Skan	return true;
283169689Skan      return false;
284169689Skan
285169689Skan    case MODE_FLOAT:
286169689Skan      if (precision == FLOAT_TYPE_SIZE)
287169689Skan	return true;
288169689Skan      if (precision == DOUBLE_TYPE_SIZE)
289169689Skan	return true;
290169689Skan      if (precision == LONG_DOUBLE_TYPE_SIZE)
291169689Skan	return true;
292169689Skan      return false;
293169689Skan
294169689Skan    case MODE_DECIMAL_FLOAT:
295169689Skan      return false;
296169689Skan
297169689Skan    default:
298169689Skan      gcc_unreachable ();
299132718Skan    }
300132718Skan}
301132718Skan
302169689Skan/* True if the target supports decimal floating point.  */
303169689Skan
304132718Skanbool
305169689Skandefault_decimal_float_supported_p (void)
306132718Skan{
307169689Skan  return ENABLE_DECIMAL_FLOAT;
308132718Skan}
309132718Skan
310169689Skan/* NULL if INSN insn is valid within a low-overhead loop, otherwise returns
311169689Skan   an error message.
312169689Skan
313169689Skan   This function checks whether a given INSN is valid within a low-overhead
314169689Skan   loop.  If INSN is invalid it returns the reason for that, otherwise it
315169689Skan   returns NULL. A called function may clobber any special registers required
316169689Skan   for low-overhead looping. Additionally, some targets (eg, PPC) use the count
317169689Skan   register for branch on table instructions. We reject the doloop pattern in
318169689Skan   these cases.  */
319169689Skan
320169689Skanconst char *
321169689Skandefault_invalid_within_doloop (rtx insn)
322132718Skan{
323169689Skan  if (CALL_P (insn))
324169689Skan    return "Function call in loop.";
325169689Skan
326169689Skan  if (JUMP_P (insn)
327169689Skan      && (GET_CODE (PATTERN (insn)) == ADDR_DIFF_VEC
328169689Skan	  || GET_CODE (PATTERN (insn)) == ADDR_VEC))
329169689Skan    return "Computed branch in the loop.";
330169689Skan
331169689Skan  return NULL;
332132718Skan}
333132718Skan
334169689Skanbool
335169689Skanhook_bool_CUMULATIVE_ARGS_mode_tree_bool_false (
336169689Skan	CUMULATIVE_ARGS *ca ATTRIBUTE_UNUSED,
337169689Skan	enum machine_mode mode ATTRIBUTE_UNUSED,
338169689Skan	tree type ATTRIBUTE_UNUSED, bool named ATTRIBUTE_UNUSED)
339132718Skan{
340169689Skan  return false;
341132718Skan}
342132718Skan
343132718Skanbool
344169689Skanhook_bool_CUMULATIVE_ARGS_mode_tree_bool_true (
345169689Skan	CUMULATIVE_ARGS *ca ATTRIBUTE_UNUSED,
346169689Skan	enum machine_mode mode ATTRIBUTE_UNUSED,
347169689Skan	tree type ATTRIBUTE_UNUSED, bool named ATTRIBUTE_UNUSED)
348132718Skan{
349169689Skan  return true;
350169689Skan}
351169689Skan
352169689Skanint
353169689Skanhook_int_CUMULATIVE_ARGS_mode_tree_bool_0 (
354169689Skan	CUMULATIVE_ARGS *ca ATTRIBUTE_UNUSED,
355169689Skan	enum machine_mode mode ATTRIBUTE_UNUSED,
356169689Skan	tree type ATTRIBUTE_UNUSED, bool named ATTRIBUTE_UNUSED)
357169689Skan{
358169689Skan  return 0;
359169689Skan}
360169689Skan
361169689Skanvoid
362169689Skanhook_void_bitmap (bitmap regs ATTRIBUTE_UNUSED)
363169689Skan{
364169689Skan}
365169689Skan
366169689Skanconst char *
367169689Skanhook_invalid_arg_for_unprototyped_fn (
368169689Skan	tree typelist ATTRIBUTE_UNUSED,
369169689Skan	tree funcdecl ATTRIBUTE_UNUSED,
370169689Skan	tree val ATTRIBUTE_UNUSED)
371169689Skan{
372169689Skan  return NULL;
373169689Skan}
374169689Skan
375169689Skan/* Initialize the stack protection decls.  */
376169689Skan
377169689Skan/* Stack protection related decls living in libgcc.  */
378169689Skanstatic GTY(()) tree stack_chk_guard_decl;
379169689Skan
380169689Skantree
381169689Skandefault_stack_protect_guard (void)
382169689Skan{
383169689Skan  tree t = stack_chk_guard_decl;
384169689Skan
385169689Skan  if (t == NULL)
386169689Skan    {
387169689Skan      t = build_decl (VAR_DECL, get_identifier ("__stack_chk_guard"),
388169689Skan		      ptr_type_node);
389169689Skan      TREE_STATIC (t) = 1;
390169689Skan      TREE_PUBLIC (t) = 1;
391169689Skan      DECL_EXTERNAL (t) = 1;
392169689Skan      TREE_USED (t) = 1;
393169689Skan      TREE_THIS_VOLATILE (t) = 1;
394169689Skan      DECL_ARTIFICIAL (t) = 1;
395169689Skan      DECL_IGNORED_P (t) = 1;
396169689Skan
397169689Skan      stack_chk_guard_decl = t;
398169689Skan    }
399169689Skan
400169689Skan  return t;
401169689Skan}
402169689Skan
403169689Skanstatic GTY(()) tree stack_chk_fail_decl;
404169689Skan
405169689Skantree
406169689Skandefault_external_stack_protect_fail (void)
407169689Skan{
408169689Skan  tree t = stack_chk_fail_decl;
409169689Skan
410169689Skan  if (t == NULL_TREE)
411169689Skan    {
412169689Skan      t = build_function_type_list (void_type_node, NULL_TREE);
413169689Skan      t = build_decl (FUNCTION_DECL, get_identifier ("__stack_chk_fail"), t);
414169689Skan      TREE_STATIC (t) = 1;
415169689Skan      TREE_PUBLIC (t) = 1;
416169689Skan      DECL_EXTERNAL (t) = 1;
417169689Skan      TREE_USED (t) = 1;
418169689Skan      TREE_THIS_VOLATILE (t) = 1;
419169689Skan      TREE_NOTHROW (t) = 1;
420169689Skan      DECL_ARTIFICIAL (t) = 1;
421169689Skan      DECL_IGNORED_P (t) = 1;
422169689Skan      DECL_VISIBILITY (t) = VISIBILITY_DEFAULT;
423169689Skan      DECL_VISIBILITY_SPECIFIED (t) = 1;
424169689Skan
425169689Skan      stack_chk_fail_decl = t;
426169689Skan    }
427169689Skan
428169689Skan  return build_function_call_expr (t, NULL_TREE);
429169689Skan}
430169689Skan
431169689Skantree
432169689Skandefault_hidden_stack_protect_fail (void)
433169689Skan{
434169689Skan#ifndef HAVE_GAS_HIDDEN
435169689Skan  return default_external_stack_protect_fail ();
436132718Skan#else
437169689Skan  tree t = stack_chk_fail_decl;
438169689Skan
439169689Skan  if (!flag_pic)
440169689Skan    return default_external_stack_protect_fail ();
441169689Skan
442169689Skan  if (t == NULL_TREE)
443169689Skan    {
444169689Skan      t = build_function_type_list (void_type_node, NULL_TREE);
445169689Skan      t = build_decl (FUNCTION_DECL,
446169689Skan		      get_identifier ("__stack_chk_fail_local"), t);
447169689Skan      TREE_STATIC (t) = 1;
448169689Skan      TREE_PUBLIC (t) = 1;
449169689Skan      DECL_EXTERNAL (t) = 1;
450169689Skan      TREE_USED (t) = 1;
451169689Skan      TREE_THIS_VOLATILE (t) = 1;
452169689Skan      TREE_NOTHROW (t) = 1;
453169689Skan      DECL_ARTIFICIAL (t) = 1;
454169689Skan      DECL_IGNORED_P (t) = 1;
455169689Skan      DECL_VISIBILITY_SPECIFIED (t) = 1;
456169689Skan      DECL_VISIBILITY (t) = VISIBILITY_HIDDEN;
457169689Skan
458169689Skan      stack_chk_fail_decl = t;
459169689Skan    }
460169689Skan
461169689Skan  return build_function_call_expr (t, NULL_TREE);
462132718Skan#endif
463132718Skan}
464132718Skan
465132718Skanbool
466169689Skanhook_bool_rtx_commutative_p (rtx x, int outer_code ATTRIBUTE_UNUSED)
467132718Skan{
468169689Skan  return COMMUTATIVE_P (x);
469169689Skan}
470169689Skan
471169689Skanrtx
472169689Skandefault_function_value (tree ret_type ATTRIBUTE_UNUSED,
473169689Skan			tree fn_decl_or_type,
474169689Skan			bool outgoing ATTRIBUTE_UNUSED)
475169689Skan{
476169689Skan  /* The old interface doesn't handle receiving the function type.  */
477169689Skan  if (fn_decl_or_type
478169689Skan      && !DECL_P (fn_decl_or_type))
479169689Skan    fn_decl_or_type = NULL;
480169689Skan
481169689Skan#ifdef FUNCTION_OUTGOING_VALUE
482169689Skan  if (outgoing)
483169689Skan    return FUNCTION_OUTGOING_VALUE (ret_type, fn_decl_or_type);
484169689Skan#endif
485169689Skan
486169689Skan#ifdef FUNCTION_VALUE
487169689Skan  return FUNCTION_VALUE (ret_type, fn_decl_or_type);
488132718Skan#else
489169689Skan  return NULL_RTX;
490132718Skan#endif
491132718Skan}
492132718Skan
493169689Skanrtx
494169689Skandefault_internal_arg_pointer (void)
495169689Skan{
496169689Skan  /* If the reg that the virtual arg pointer will be translated into is
497169689Skan     not a fixed reg or is the stack pointer, make a copy of the virtual
498169689Skan     arg pointer, and address parms via the copy.  The frame pointer is
499169689Skan     considered fixed even though it is not marked as such.  */
500169689Skan  if ((ARG_POINTER_REGNUM == STACK_POINTER_REGNUM
501169689Skan       || ! (fixed_regs[ARG_POINTER_REGNUM]
502169689Skan	     || ARG_POINTER_REGNUM == FRAME_POINTER_REGNUM)))
503169689Skan    return copy_to_reg (virtual_incoming_args_rtx);
504169689Skan  else
505169689Skan    return virtual_incoming_args_rtx;
506169689Skan}
507132718Skan
508169689Skanenum reg_class
509169689Skandefault_secondary_reload (bool in_p ATTRIBUTE_UNUSED, rtx x ATTRIBUTE_UNUSED,
510169689Skan			  enum reg_class reload_class ATTRIBUTE_UNUSED,
511169689Skan			  enum machine_mode reload_mode ATTRIBUTE_UNUSED,
512169689Skan			  secondary_reload_info *sri)
513132718Skan{
514169689Skan  enum reg_class class = NO_REGS;
515169689Skan
516169689Skan  if (sri->prev_sri && sri->prev_sri->t_icode != CODE_FOR_nothing)
517169689Skan    {
518169689Skan      sri->icode = sri->prev_sri->t_icode;
519169689Skan      return NO_REGS;
520169689Skan    }
521169689Skan#ifdef SECONDARY_INPUT_RELOAD_CLASS
522169689Skan  if (in_p)
523169689Skan    class = SECONDARY_INPUT_RELOAD_CLASS (reload_class, reload_mode, x);
524169689Skan#endif
525169689Skan#ifdef SECONDARY_OUTPUT_RELOAD_CLASS
526169689Skan  if (! in_p)
527169689Skan    class = SECONDARY_OUTPUT_RELOAD_CLASS (reload_class, reload_mode, x);
528169689Skan#endif
529169689Skan  if (class != NO_REGS)
530169689Skan    {
531169689Skan      enum insn_code icode = (in_p ? reload_in_optab[(int) reload_mode]
532169689Skan			      : reload_out_optab[(int) reload_mode]);
533169689Skan
534169689Skan      if (icode != CODE_FOR_nothing
535169689Skan	  && insn_data[(int) icode].operand[in_p].predicate
536169689Skan	  && ! insn_data[(int) icode].operand[in_p].predicate (x, reload_mode))
537169689Skan	icode = CODE_FOR_nothing;
538169689Skan      else if (icode != CODE_FOR_nothing)
539169689Skan	{
540169689Skan	  const char *insn_constraint, *scratch_constraint;
541169689Skan	  char insn_letter, scratch_letter;
542169689Skan	  enum reg_class insn_class, scratch_class;
543169689Skan
544169689Skan	  gcc_assert (insn_data[(int) icode].n_operands == 3);
545169689Skan	  insn_constraint = insn_data[(int) icode].operand[!in_p].constraint;
546169689Skan	  if (!*insn_constraint)
547169689Skan	    insn_class = ALL_REGS;
548169689Skan	  else
549169689Skan	    {
550169689Skan	      if (in_p)
551169689Skan		{
552169689Skan		  gcc_assert (*insn_constraint == '=');
553169689Skan		  insn_constraint++;
554169689Skan		}
555169689Skan	      insn_letter = *insn_constraint;
556169689Skan	      insn_class
557169689Skan		= (insn_letter == 'r' ? GENERAL_REGS
558169689Skan		   : REG_CLASS_FROM_CONSTRAINT ((unsigned char) insn_letter,
559169689Skan						insn_constraint));
560169689Skan	      gcc_assert (insn_class != NO_REGS);
561169689Skan	    }
562169689Skan
563169689Skan	  scratch_constraint = insn_data[(int) icode].operand[2].constraint;
564169689Skan	  /* The scratch register's constraint must start with "=&",
565169689Skan	     except for an input reload, where only "=" is necessary,
566169689Skan	     and where it might be beneficial to re-use registers from
567169689Skan	     the input.  */
568169689Skan	  gcc_assert (scratch_constraint[0] == '='
569169689Skan		      && (in_p || scratch_constraint[1] == '&'));
570169689Skan	  scratch_constraint++;
571169689Skan	  if (*scratch_constraint == '&')
572169689Skan	    scratch_constraint++;
573169689Skan	  scratch_letter = *scratch_constraint;
574169689Skan	  scratch_class
575169689Skan	    = (scratch_letter == 'r' ? GENERAL_REGS
576169689Skan	       : REG_CLASS_FROM_CONSTRAINT ((unsigned char) scratch_letter,
577169689Skan					    scratch_constraint));
578169689Skan
579169689Skan	  if (reg_class_subset_p (reload_class, insn_class))
580169689Skan	    {
581169689Skan	      gcc_assert (scratch_class == class);
582169689Skan	      class = NO_REGS;
583169689Skan	    }
584169689Skan	  else
585169689Skan	    class = insn_class;
586169689Skan
587169689Skan        }
588169689Skan      if (class == NO_REGS)
589169689Skan	sri->icode = icode;
590169689Skan      else
591169689Skan	sri->t_icode = icode;
592169689Skan    }
593169689Skan  return class;
594132718Skan}
595132718Skan
596132718Skan
597169689Skan/* If STRICT_ALIGNMENT is true we use the container type for accessing
598169689Skan   volatile bitfields.  This is generally the preferred behavior for memory
599169689Skan   mapped peripherals on RISC architectures.
600169689Skan   If STRICT_ALIGNMENT is false we use the narrowest type possible.  This
601169689Skan   is typically used to avoid spurious page faults and extra memory accesses
602169689Skan   due to unaligned accesses on CISC architectures.  */
603169689Skan
604132718Skanbool
605169689Skandefault_narrow_bitfield (void)
606132718Skan{
607169689Skan  return !STRICT_ALIGNMENT;
608132718Skan}
609169689Skan
610169689Skan/* By default, if flag_pic is true, then neither local nor global relocs
611169689Skan   should be placed in readonly memory.  */
612169689Skan
613169689Skanint
614169689Skandefault_reloc_rw_mask (void)
615169689Skan{
616169689Skan  return flag_pic ? 3 : 0;
617169689Skan}
618169689Skan
619220150Smmbool
620220150Smmdefault_builtin_vector_alignment_reachable (tree type, bool is_packed)
621220150Smm{
622220150Smm  if (is_packed)
623220150Smm    return false;
624220150Smm
625220150Smm  /* Assuming that types whose size is > pointer-size are not guaranteed to be
626220150Smm     naturally aligned.  */
627220150Smm  if (tree_int_cst_compare (TYPE_SIZE (type), bitsize_int (POINTER_SIZE)) > 0)
628220150Smm    return false;
629220150Smm
630220150Smm  /* Assuming that types whose size is <= pointer-size
631220150Smm     are naturally aligned.  */
632220150Smm  return true;
633220150Smm}
634220150Smm
635169689Skan#include "gt-targhooks.h"
636