]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/targhooks.c
Add an "early rematerialisation" pass
[thirdparty/gcc.git] / gcc / targhooks.c
1 /* Default target hook functions.
2 Copyright (C) 2003-2018 Free Software Foundation, Inc.
3
4 This file is part of GCC.
5
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
9 version.
10
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
19
20 /* The migration of target macros to target hooks works as follows:
21
22 1. Create a target hook that uses the existing target macros to
23 implement the same functionality.
24
25 2. Convert all the MI files to use the hook instead of the macro.
26
27 3. Repeat for a majority of the remaining target macros. This will
28 take some time.
29
30 4. Tell target maintainers to start migrating.
31
32 5. Eventually convert the backends to override the hook instead of
33 defining the macros. This will take some time too.
34
35 6. TBD when, poison the macros. Unmigrated targets will break at
36 this point.
37
38 Note that we expect steps 1-3 to be done by the people that
39 understand what the MI does with each macro, and step 5 to be done
40 by the target maintainers for their respective targets.
41
42 Note that steps 1 and 2 don't have to be done together, but no
43 target can override the new hook until step 2 is complete for it.
44
45 Once the macros are poisoned, we will revert to the old migration
46 rules - migrate the macro, callers, and targets all at once. This
47 comment can thus be removed at that point. */
48
49 #include "config.h"
50 #include "system.h"
51 #include "coretypes.h"
52 #include "target.h"
53 #include "function.h"
54 #include "rtl.h"
55 #include "tree.h"
56 #include "tree-ssa-alias.h"
57 #include "gimple-expr.h"
58 #include "memmodel.h"
59 #include "tm_p.h"
60 #include "stringpool.h"
61 #include "tree-vrp.h"
62 #include "tree-ssanames.h"
63 #include "profile-count.h"
64 #include "optabs.h"
65 #include "regs.h"
66 #include "recog.h"
67 #include "diagnostic-core.h"
68 #include "fold-const.h"
69 #include "stor-layout.h"
70 #include "varasm.h"
71 #include "flags.h"
72 #include "explow.h"
73 #include "calls.h"
74 #include "expr.h"
75 #include "output.h"
76 #include "common/common-target.h"
77 #include "reload.h"
78 #include "intl.h"
79 #include "opts.h"
80 #include "gimplify.h"
81 #include "predict.h"
82 #include "params.h"
83 #include "real.h"
84 #include "langhooks.h"
85 #include "sbitmap.h"
86
87 bool
88 default_legitimate_address_p (machine_mode mode ATTRIBUTE_UNUSED,
89 rtx addr ATTRIBUTE_UNUSED,
90 bool strict ATTRIBUTE_UNUSED)
91 {
92 #ifdef GO_IF_LEGITIMATE_ADDRESS
93 /* Defer to the old implementation using a goto. */
94 if (strict)
95 return strict_memory_address_p (mode, addr);
96 else
97 return memory_address_p (mode, addr);
98 #else
99 gcc_unreachable ();
100 #endif
101 }
102
103 void
104 default_external_libcall (rtx fun ATTRIBUTE_UNUSED)
105 {
106 #ifdef ASM_OUTPUT_EXTERNAL_LIBCALL
107 ASM_OUTPUT_EXTERNAL_LIBCALL (asm_out_file, fun);
108 #endif
109 }
110
111 int
112 default_unspec_may_trap_p (const_rtx x, unsigned flags)
113 {
114 int i;
115
116 /* Any floating arithmetic may trap. */
117 if ((SCALAR_FLOAT_MODE_P (GET_MODE (x)) && flag_trapping_math))
118 return 1;
119
120 for (i = 0; i < XVECLEN (x, 0); ++i)
121 {
122 if (may_trap_p_1 (XVECEXP (x, 0, i), flags))
123 return 1;
124 }
125
126 return 0;
127 }
128
129 machine_mode
130 default_promote_function_mode (const_tree type ATTRIBUTE_UNUSED,
131 machine_mode mode,
132 int *punsignedp ATTRIBUTE_UNUSED,
133 const_tree funtype ATTRIBUTE_UNUSED,
134 int for_return ATTRIBUTE_UNUSED)
135 {
136 if (type != NULL_TREE && for_return == 2)
137 return promote_mode (type, mode, punsignedp);
138 return mode;
139 }
140
141 machine_mode
142 default_promote_function_mode_always_promote (const_tree type,
143 machine_mode mode,
144 int *punsignedp,
145 const_tree funtype ATTRIBUTE_UNUSED,
146 int for_return ATTRIBUTE_UNUSED)
147 {
148 return promote_mode (type, mode, punsignedp);
149 }
150
151 machine_mode
152 default_cc_modes_compatible (machine_mode m1, machine_mode m2)
153 {
154 if (m1 == m2)
155 return m1;
156 return VOIDmode;
157 }
158
159 bool
160 default_return_in_memory (const_tree type,
161 const_tree fntype ATTRIBUTE_UNUSED)
162 {
163 return (TYPE_MODE (type) == BLKmode);
164 }
165
166 rtx
167 default_legitimize_address (rtx x, rtx orig_x ATTRIBUTE_UNUSED,
168 machine_mode mode ATTRIBUTE_UNUSED)
169 {
170 return x;
171 }
172
173 bool
174 default_legitimize_address_displacement (rtx *disp ATTRIBUTE_UNUSED,
175 rtx *offset ATTRIBUTE_UNUSED,
176 machine_mode mode ATTRIBUTE_UNUSED)
177 {
178 return false;
179 }
180
181 bool
182 default_const_not_ok_for_debug_p (rtx x)
183 {
184 if (GET_CODE (x) == UNSPEC)
185 return true;
186 return false;
187 }
188
189 rtx
190 default_expand_builtin_saveregs (void)
191 {
192 error ("__builtin_saveregs not supported by this target");
193 return const0_rtx;
194 }
195
196 void
197 default_setup_incoming_varargs (cumulative_args_t ca ATTRIBUTE_UNUSED,
198 machine_mode mode ATTRIBUTE_UNUSED,
199 tree type ATTRIBUTE_UNUSED,
200 int *pretend_arg_size ATTRIBUTE_UNUSED,
201 int second_time ATTRIBUTE_UNUSED)
202 {
203 }
204
205 /* The default implementation of TARGET_BUILTIN_SETJMP_FRAME_VALUE. */
206
207 rtx
208 default_builtin_setjmp_frame_value (void)
209 {
210 return virtual_stack_vars_rtx;
211 }
212
213 /* Generic hook that takes a CUMULATIVE_ARGS pointer and returns false. */
214
215 bool
216 hook_bool_CUMULATIVE_ARGS_false (cumulative_args_t ca ATTRIBUTE_UNUSED)
217 {
218 return false;
219 }
220
221 bool
222 default_pretend_outgoing_varargs_named (cumulative_args_t ca ATTRIBUTE_UNUSED)
223 {
224 return (targetm.calls.setup_incoming_varargs
225 != default_setup_incoming_varargs);
226 }
227
228 scalar_int_mode
229 default_eh_return_filter_mode (void)
230 {
231 return targetm.unwind_word_mode ();
232 }
233
234 scalar_int_mode
235 default_libgcc_cmp_return_mode (void)
236 {
237 return word_mode;
238 }
239
240 scalar_int_mode
241 default_libgcc_shift_count_mode (void)
242 {
243 return word_mode;
244 }
245
246 scalar_int_mode
247 default_unwind_word_mode (void)
248 {
249 return word_mode;
250 }
251
252 /* The default implementation of TARGET_SHIFT_TRUNCATION_MASK. */
253
254 unsigned HOST_WIDE_INT
255 default_shift_truncation_mask (machine_mode mode)
256 {
257 return SHIFT_COUNT_TRUNCATED ? GET_MODE_UNIT_BITSIZE (mode) - 1 : 0;
258 }
259
260 /* The default implementation of TARGET_MIN_DIVISIONS_FOR_RECIP_MUL. */
261
262 unsigned int
263 default_min_divisions_for_recip_mul (machine_mode mode ATTRIBUTE_UNUSED)
264 {
265 return have_insn_for (DIV, mode) ? 3 : 2;
266 }
267
268 /* The default implementation of TARGET_MODE_REP_EXTENDED. */
269
270 int
271 default_mode_rep_extended (scalar_int_mode, scalar_int_mode)
272 {
273 return UNKNOWN;
274 }
275
276 /* Generic hook that takes a CUMULATIVE_ARGS pointer and returns true. */
277
278 bool
279 hook_bool_CUMULATIVE_ARGS_true (cumulative_args_t a ATTRIBUTE_UNUSED)
280 {
281 return true;
282 }
283
284 /* Return machine mode for non-standard suffix
285 or VOIDmode if non-standard suffixes are unsupported. */
286 machine_mode
287 default_mode_for_suffix (char suffix ATTRIBUTE_UNUSED)
288 {
289 return VOIDmode;
290 }
291
292 /* The generic C++ ABI specifies this is a 64-bit value. */
293 tree
294 default_cxx_guard_type (void)
295 {
296 return long_long_integer_type_node;
297 }
298
299 /* Returns the size of the cookie to use when allocating an array
300 whose elements have the indicated TYPE. Assumes that it is already
301 known that a cookie is needed. */
302
303 tree
304 default_cxx_get_cookie_size (tree type)
305 {
306 tree cookie_size;
307
308 /* We need to allocate an additional max (sizeof (size_t), alignof
309 (true_type)) bytes. */
310 tree sizetype_size;
311 tree type_align;
312
313 sizetype_size = size_in_bytes (sizetype);
314 type_align = size_int (TYPE_ALIGN_UNIT (type));
315 if (tree_int_cst_lt (type_align, sizetype_size))
316 cookie_size = sizetype_size;
317 else
318 cookie_size = type_align;
319
320 return cookie_size;
321 }
322
323 /* Return true if a parameter must be passed by reference. This version
324 of the TARGET_PASS_BY_REFERENCE hook uses just MUST_PASS_IN_STACK. */
325
326 bool
327 hook_pass_by_reference_must_pass_in_stack (cumulative_args_t c ATTRIBUTE_UNUSED,
328 machine_mode mode ATTRIBUTE_UNUSED, const_tree type ATTRIBUTE_UNUSED,
329 bool named_arg ATTRIBUTE_UNUSED)
330 {
331 return targetm.calls.must_pass_in_stack (mode, type);
332 }
333
334 /* Return true if a parameter follows callee copies conventions. This
335 version of the hook is true for all named arguments. */
336
337 bool
338 hook_callee_copies_named (cumulative_args_t ca ATTRIBUTE_UNUSED,
339 machine_mode mode ATTRIBUTE_UNUSED,
340 const_tree type ATTRIBUTE_UNUSED, bool named)
341 {
342 return named;
343 }
344
345 /* Emit to STREAM the assembler syntax for insn operand X. */
346
347 void
348 default_print_operand (FILE *stream ATTRIBUTE_UNUSED, rtx x ATTRIBUTE_UNUSED,
349 int code ATTRIBUTE_UNUSED)
350 {
351 #ifdef PRINT_OPERAND
352 PRINT_OPERAND (stream, x, code);
353 #else
354 gcc_unreachable ();
355 #endif
356 }
357
358 /* Emit to STREAM the assembler syntax for an insn operand whose memory
359 address is X. */
360
361 void
362 default_print_operand_address (FILE *stream ATTRIBUTE_UNUSED,
363 machine_mode /*mode*/,
364 rtx x ATTRIBUTE_UNUSED)
365 {
366 #ifdef PRINT_OPERAND_ADDRESS
367 PRINT_OPERAND_ADDRESS (stream, x);
368 #else
369 gcc_unreachable ();
370 #endif
371 }
372
373 /* Return true if CODE is a valid punctuation character for the
374 `print_operand' hook. */
375
376 bool
377 default_print_operand_punct_valid_p (unsigned char code ATTRIBUTE_UNUSED)
378 {
379 #ifdef PRINT_OPERAND_PUNCT_VALID_P
380 return PRINT_OPERAND_PUNCT_VALID_P (code);
381 #else
382 return false;
383 #endif
384 }
385
386 /* The default implementation of TARGET_MANGLE_ASSEMBLER_NAME. */
387 tree
388 default_mangle_assembler_name (const char *name ATTRIBUTE_UNUSED)
389 {
390 const char *skipped = name + (*name == '*' ? 1 : 0);
391 const char *stripped = targetm.strip_name_encoding (skipped);
392 if (*name != '*' && user_label_prefix[0])
393 stripped = ACONCAT ((user_label_prefix, stripped, NULL));
394 return get_identifier (stripped);
395 }
396
397 /* True if MODE is valid for the target. By "valid", we mean able to
398 be manipulated in non-trivial ways. In particular, this means all
399 the arithmetic is supported.
400
401 By default we guess this means that any C type is supported. If
402 we can't map the mode back to a type that would be available in C,
403 then reject it. Special case, here, is the double-word arithmetic
404 supported by optabs.c. */
405
406 bool
407 default_scalar_mode_supported_p (scalar_mode mode)
408 {
409 int precision = GET_MODE_PRECISION (mode);
410
411 switch (GET_MODE_CLASS (mode))
412 {
413 case MODE_PARTIAL_INT:
414 case MODE_INT:
415 if (precision == CHAR_TYPE_SIZE)
416 return true;
417 if (precision == SHORT_TYPE_SIZE)
418 return true;
419 if (precision == INT_TYPE_SIZE)
420 return true;
421 if (precision == LONG_TYPE_SIZE)
422 return true;
423 if (precision == LONG_LONG_TYPE_SIZE)
424 return true;
425 if (precision == 2 * BITS_PER_WORD)
426 return true;
427 return false;
428
429 case MODE_FLOAT:
430 if (precision == FLOAT_TYPE_SIZE)
431 return true;
432 if (precision == DOUBLE_TYPE_SIZE)
433 return true;
434 if (precision == LONG_DOUBLE_TYPE_SIZE)
435 return true;
436 return false;
437
438 case MODE_DECIMAL_FLOAT:
439 case MODE_FRACT:
440 case MODE_UFRACT:
441 case MODE_ACCUM:
442 case MODE_UACCUM:
443 return false;
444
445 default:
446 gcc_unreachable ();
447 }
448 }
449
450 /* Return true if libgcc supports floating-point mode MODE (known to
451 be supported as a scalar mode). */
452
453 bool
454 default_libgcc_floating_mode_supported_p (scalar_float_mode mode)
455 {
456 switch (mode)
457 {
458 #ifdef HAVE_SFmode
459 case E_SFmode:
460 #endif
461 #ifdef HAVE_DFmode
462 case E_DFmode:
463 #endif
464 #ifdef HAVE_XFmode
465 case E_XFmode:
466 #endif
467 #ifdef HAVE_TFmode
468 case E_TFmode:
469 #endif
470 return true;
471
472 default:
473 return false;
474 }
475 }
476
477 /* Return the machine mode to use for the type _FloatN, if EXTENDED is
478 false, or _FloatNx, if EXTENDED is true, or VOIDmode if not
479 supported. */
480 opt_scalar_float_mode
481 default_floatn_mode (int n, bool extended)
482 {
483 if (extended)
484 {
485 opt_scalar_float_mode cand1, cand2;
486 scalar_float_mode mode;
487 switch (n)
488 {
489 case 32:
490 #ifdef HAVE_DFmode
491 cand1 = DFmode;
492 #endif
493 break;
494
495 case 64:
496 #ifdef HAVE_XFmode
497 cand1 = XFmode;
498 #endif
499 #ifdef HAVE_TFmode
500 cand2 = TFmode;
501 #endif
502 break;
503
504 case 128:
505 break;
506
507 default:
508 /* Those are the only valid _FloatNx types. */
509 gcc_unreachable ();
510 }
511 if (cand1.exists (&mode)
512 && REAL_MODE_FORMAT (mode)->ieee_bits > n
513 && targetm.scalar_mode_supported_p (mode)
514 && targetm.libgcc_floating_mode_supported_p (mode))
515 return cand1;
516 if (cand2.exists (&mode)
517 && REAL_MODE_FORMAT (mode)->ieee_bits > n
518 && targetm.scalar_mode_supported_p (mode)
519 && targetm.libgcc_floating_mode_supported_p (mode))
520 return cand2;
521 }
522 else
523 {
524 opt_scalar_float_mode cand;
525 scalar_float_mode mode;
526 switch (n)
527 {
528 case 16:
529 /* Always enable _Float16 if we have basic support for the mode.
530 Targets can control the range and precision of operations on
531 the _Float16 type using TARGET_C_EXCESS_PRECISION. */
532 #ifdef HAVE_HFmode
533 cand = HFmode;
534 #endif
535 break;
536
537 case 32:
538 #ifdef HAVE_SFmode
539 cand = SFmode;
540 #endif
541 break;
542
543 case 64:
544 #ifdef HAVE_DFmode
545 cand = DFmode;
546 #endif
547 break;
548
549 case 128:
550 #ifdef HAVE_TFmode
551 cand = TFmode;
552 #endif
553 break;
554
555 default:
556 break;
557 }
558 if (cand.exists (&mode)
559 && REAL_MODE_FORMAT (mode)->ieee_bits == n
560 && targetm.scalar_mode_supported_p (mode)
561 && targetm.libgcc_floating_mode_supported_p (mode))
562 return cand;
563 }
564 return opt_scalar_float_mode ();
565 }
566
567 /* Define this to return true if the _Floatn and _Floatnx built-in functions
568 should implicitly enable the built-in function without the __builtin_ prefix
569 in addition to the normal built-in function with the __builtin_ prefix. The
570 default is to only enable built-in functions without the __builtin_ prefix
571 for the GNU C langauge. The argument FUNC is the enum builtin_in_function
572 id of the function to be enabled. */
573
574 bool
575 default_floatn_builtin_p (int func ATTRIBUTE_UNUSED)
576 {
577 static bool first_time_p = true;
578 static bool c_or_objective_c;
579
580 if (first_time_p)
581 {
582 first_time_p = false;
583 c_or_objective_c = lang_GNU_C () || lang_GNU_OBJC ();
584 }
585
586 return c_or_objective_c;
587 }
588
589 /* Make some target macros useable by target-independent code. */
590 bool
591 targhook_words_big_endian (void)
592 {
593 return !!WORDS_BIG_ENDIAN;
594 }
595
596 bool
597 targhook_float_words_big_endian (void)
598 {
599 return !!FLOAT_WORDS_BIG_ENDIAN;
600 }
601
602 /* True if the target supports floating-point exceptions and rounding
603 modes. */
604
605 bool
606 default_float_exceptions_rounding_supported_p (void)
607 {
608 #ifdef HAVE_adddf3
609 return HAVE_adddf3;
610 #else
611 return false;
612 #endif
613 }
614
615 /* True if the target supports decimal floating point. */
616
617 bool
618 default_decimal_float_supported_p (void)
619 {
620 return ENABLE_DECIMAL_FLOAT;
621 }
622
623 /* True if the target supports fixed-point arithmetic. */
624
625 bool
626 default_fixed_point_supported_p (void)
627 {
628 return ENABLE_FIXED_POINT;
629 }
630
631 /* True if the target supports GNU indirect functions. */
632
633 bool
634 default_has_ifunc_p (void)
635 {
636 return HAVE_GNU_INDIRECT_FUNCTION;
637 }
638
639 /* NULL if INSN insn is valid within a low-overhead loop, otherwise returns
640 an error message.
641
642 This function checks whether a given INSN is valid within a low-overhead
643 loop. If INSN is invalid it returns the reason for that, otherwise it
644 returns NULL. A called function may clobber any special registers required
645 for low-overhead looping. Additionally, some targets (eg, PPC) use the count
646 register for branch on table instructions. We reject the doloop pattern in
647 these cases. */
648
649 const char *
650 default_invalid_within_doloop (const rtx_insn *insn)
651 {
652 if (CALL_P (insn))
653 return "Function call in loop.";
654
655 if (tablejump_p (insn, NULL, NULL) || computed_jump_p (insn))
656 return "Computed branch in the loop.";
657
658 return NULL;
659 }
660
661 /* Mapping of builtin functions to vectorized variants. */
662
663 tree
664 default_builtin_vectorized_function (unsigned int, tree, tree)
665 {
666 return NULL_TREE;
667 }
668
669 /* Mapping of target builtin functions to vectorized variants. */
670
671 tree
672 default_builtin_md_vectorized_function (tree, tree, tree)
673 {
674 return NULL_TREE;
675 }
676
677 /* Vectorized conversion. */
678
679 tree
680 default_builtin_vectorized_conversion (unsigned int code ATTRIBUTE_UNUSED,
681 tree dest_type ATTRIBUTE_UNUSED,
682 tree src_type ATTRIBUTE_UNUSED)
683 {
684 return NULL_TREE;
685 }
686
687 /* Default vectorizer cost model values. */
688
689 int
690 default_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost,
691 tree vectype,
692 int misalign ATTRIBUTE_UNUSED)
693 {
694 switch (type_of_cost)
695 {
696 case scalar_stmt:
697 case scalar_load:
698 case scalar_store:
699 case vector_stmt:
700 case vector_load:
701 case vector_store:
702 case vec_to_scalar:
703 case scalar_to_vec:
704 case cond_branch_not_taken:
705 case vec_perm:
706 case vec_promote_demote:
707 return 1;
708
709 case unaligned_load:
710 case unaligned_store:
711 return 2;
712
713 case cond_branch_taken:
714 return 3;
715
716 case vec_construct:
717 return estimated_poly_value (TYPE_VECTOR_SUBPARTS (vectype)) - 1;
718
719 default:
720 gcc_unreachable ();
721 }
722 }
723
724 /* Reciprocal. */
725
726 tree
727 default_builtin_reciprocal (tree)
728 {
729 return NULL_TREE;
730 }
731
732 bool
733 hook_bool_CUMULATIVE_ARGS_mode_tree_bool_false (
734 cumulative_args_t ca ATTRIBUTE_UNUSED,
735 machine_mode mode ATTRIBUTE_UNUSED,
736 const_tree type ATTRIBUTE_UNUSED, bool named ATTRIBUTE_UNUSED)
737 {
738 return false;
739 }
740
741 bool
742 hook_bool_CUMULATIVE_ARGS_mode_tree_bool_true (
743 cumulative_args_t ca ATTRIBUTE_UNUSED,
744 machine_mode mode ATTRIBUTE_UNUSED,
745 const_tree type ATTRIBUTE_UNUSED, bool named ATTRIBUTE_UNUSED)
746 {
747 return true;
748 }
749
750 int
751 hook_int_CUMULATIVE_ARGS_mode_tree_bool_0 (
752 cumulative_args_t ca ATTRIBUTE_UNUSED,
753 machine_mode mode ATTRIBUTE_UNUSED,
754 tree type ATTRIBUTE_UNUSED, bool named ATTRIBUTE_UNUSED)
755 {
756 return 0;
757 }
758
759 void
760 hook_void_CUMULATIVE_ARGS_tree (cumulative_args_t ca ATTRIBUTE_UNUSED,
761 tree ATTRIBUTE_UNUSED)
762 {
763 }
764
765 void
766 default_function_arg_advance (cumulative_args_t ca ATTRIBUTE_UNUSED,
767 machine_mode mode ATTRIBUTE_UNUSED,
768 const_tree type ATTRIBUTE_UNUSED,
769 bool named ATTRIBUTE_UNUSED)
770 {
771 gcc_unreachable ();
772 }
773
774 /* Default implementation of TARGET_FUNCTION_ARG_OFFSET. */
775
776 HOST_WIDE_INT
777 default_function_arg_offset (machine_mode, const_tree)
778 {
779 return 0;
780 }
781
782 /* Default implementation of TARGET_FUNCTION_ARG_PADDING: usually pad
783 upward, but pad short args downward on big-endian machines. */
784
785 pad_direction
786 default_function_arg_padding (machine_mode mode, const_tree type)
787 {
788 if (!BYTES_BIG_ENDIAN)
789 return PAD_UPWARD;
790
791 unsigned HOST_WIDE_INT size;
792 if (mode == BLKmode)
793 {
794 if (!type || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
795 return PAD_UPWARD;
796 size = int_size_in_bytes (type);
797 }
798 else
799 /* Targets with variable-sized modes must override this hook
800 and handle variable-sized modes explicitly. */
801 size = GET_MODE_SIZE (mode).to_constant ();
802
803 if (size < (PARM_BOUNDARY / BITS_PER_UNIT))
804 return PAD_DOWNWARD;
805
806 return PAD_UPWARD;
807 }
808
809 rtx
810 default_function_arg (cumulative_args_t ca ATTRIBUTE_UNUSED,
811 machine_mode mode ATTRIBUTE_UNUSED,
812 const_tree type ATTRIBUTE_UNUSED,
813 bool named ATTRIBUTE_UNUSED)
814 {
815 gcc_unreachable ();
816 }
817
818 rtx
819 default_function_incoming_arg (cumulative_args_t ca ATTRIBUTE_UNUSED,
820 machine_mode mode ATTRIBUTE_UNUSED,
821 const_tree type ATTRIBUTE_UNUSED,
822 bool named ATTRIBUTE_UNUSED)
823 {
824 gcc_unreachable ();
825 }
826
827 unsigned int
828 default_function_arg_boundary (machine_mode mode ATTRIBUTE_UNUSED,
829 const_tree type ATTRIBUTE_UNUSED)
830 {
831 return PARM_BOUNDARY;
832 }
833
834 unsigned int
835 default_function_arg_round_boundary (machine_mode mode ATTRIBUTE_UNUSED,
836 const_tree type ATTRIBUTE_UNUSED)
837 {
838 return PARM_BOUNDARY;
839 }
840
841 void
842 hook_void_bitmap (bitmap regs ATTRIBUTE_UNUSED)
843 {
844 }
845
846 const char *
847 hook_invalid_arg_for_unprototyped_fn (
848 const_tree typelist ATTRIBUTE_UNUSED,
849 const_tree funcdecl ATTRIBUTE_UNUSED,
850 const_tree val ATTRIBUTE_UNUSED)
851 {
852 return NULL;
853 }
854
855 /* Initialize the stack protection decls. */
856
857 /* Stack protection related decls living in libgcc. */
858 static GTY(()) tree stack_chk_guard_decl;
859
860 tree
861 default_stack_protect_guard (void)
862 {
863 tree t = stack_chk_guard_decl;
864
865 if (t == NULL)
866 {
867 rtx x;
868
869 t = build_decl (UNKNOWN_LOCATION,
870 VAR_DECL, get_identifier ("__stack_chk_guard"),
871 ptr_type_node);
872 TREE_STATIC (t) = 1;
873 TREE_PUBLIC (t) = 1;
874 DECL_EXTERNAL (t) = 1;
875 TREE_USED (t) = 1;
876 TREE_THIS_VOLATILE (t) = 1;
877 DECL_ARTIFICIAL (t) = 1;
878 DECL_IGNORED_P (t) = 1;
879
880 /* Do not share RTL as the declaration is visible outside of
881 current function. */
882 x = DECL_RTL (t);
883 RTX_FLAG (x, used) = 1;
884
885 stack_chk_guard_decl = t;
886 }
887
888 return t;
889 }
890
891 static GTY(()) tree stack_chk_fail_decl;
892
893 tree
894 default_external_stack_protect_fail (void)
895 {
896 tree t = stack_chk_fail_decl;
897
898 if (t == NULL_TREE)
899 {
900 t = build_function_type_list (void_type_node, NULL_TREE);
901 t = build_decl (UNKNOWN_LOCATION,
902 FUNCTION_DECL, get_identifier ("__stack_chk_fail"), t);
903 TREE_STATIC (t) = 1;
904 TREE_PUBLIC (t) = 1;
905 DECL_EXTERNAL (t) = 1;
906 TREE_USED (t) = 1;
907 TREE_THIS_VOLATILE (t) = 1;
908 TREE_NOTHROW (t) = 1;
909 DECL_ARTIFICIAL (t) = 1;
910 DECL_IGNORED_P (t) = 1;
911 DECL_VISIBILITY (t) = VISIBILITY_DEFAULT;
912 DECL_VISIBILITY_SPECIFIED (t) = 1;
913
914 stack_chk_fail_decl = t;
915 }
916
917 return build_call_expr (t, 0);
918 }
919
920 tree
921 default_hidden_stack_protect_fail (void)
922 {
923 #ifndef HAVE_GAS_HIDDEN
924 return default_external_stack_protect_fail ();
925 #else
926 tree t = stack_chk_fail_decl;
927
928 if (!flag_pic)
929 return default_external_stack_protect_fail ();
930
931 if (t == NULL_TREE)
932 {
933 t = build_function_type_list (void_type_node, NULL_TREE);
934 t = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL,
935 get_identifier ("__stack_chk_fail_local"), t);
936 TREE_STATIC (t) = 1;
937 TREE_PUBLIC (t) = 1;
938 DECL_EXTERNAL (t) = 1;
939 TREE_USED (t) = 1;
940 TREE_THIS_VOLATILE (t) = 1;
941 TREE_NOTHROW (t) = 1;
942 DECL_ARTIFICIAL (t) = 1;
943 DECL_IGNORED_P (t) = 1;
944 DECL_VISIBILITY_SPECIFIED (t) = 1;
945 DECL_VISIBILITY (t) = VISIBILITY_HIDDEN;
946
947 stack_chk_fail_decl = t;
948 }
949
950 return build_call_expr (t, 0);
951 #endif
952 }
953
954 bool
955 hook_bool_const_rtx_commutative_p (const_rtx x,
956 int outer_code ATTRIBUTE_UNUSED)
957 {
958 return COMMUTATIVE_P (x);
959 }
960
961 rtx
962 default_function_value (const_tree ret_type ATTRIBUTE_UNUSED,
963 const_tree fn_decl_or_type,
964 bool outgoing ATTRIBUTE_UNUSED)
965 {
966 /* The old interface doesn't handle receiving the function type. */
967 if (fn_decl_or_type
968 && !DECL_P (fn_decl_or_type))
969 fn_decl_or_type = NULL;
970
971 #ifdef FUNCTION_VALUE
972 return FUNCTION_VALUE (ret_type, fn_decl_or_type);
973 #else
974 gcc_unreachable ();
975 #endif
976 }
977
978 rtx
979 default_libcall_value (machine_mode mode ATTRIBUTE_UNUSED,
980 const_rtx fun ATTRIBUTE_UNUSED)
981 {
982 #ifdef LIBCALL_VALUE
983 return LIBCALL_VALUE (MACRO_MODE (mode));
984 #else
985 gcc_unreachable ();
986 #endif
987 }
988
989 /* The default hook for TARGET_FUNCTION_VALUE_REGNO_P. */
990
991 bool
992 default_function_value_regno_p (const unsigned int regno ATTRIBUTE_UNUSED)
993 {
994 #ifdef FUNCTION_VALUE_REGNO_P
995 return FUNCTION_VALUE_REGNO_P (regno);
996 #else
997 gcc_unreachable ();
998 #endif
999 }
1000
1001 rtx
1002 default_internal_arg_pointer (void)
1003 {
1004 /* If the reg that the virtual arg pointer will be translated into is
1005 not a fixed reg or is the stack pointer, make a copy of the virtual
1006 arg pointer, and address parms via the copy. The frame pointer is
1007 considered fixed even though it is not marked as such. */
1008 if ((ARG_POINTER_REGNUM == STACK_POINTER_REGNUM
1009 || ! (fixed_regs[ARG_POINTER_REGNUM]
1010 || ARG_POINTER_REGNUM == FRAME_POINTER_REGNUM)))
1011 return copy_to_reg (virtual_incoming_args_rtx);
1012 else
1013 return virtual_incoming_args_rtx;
1014 }
1015
1016 rtx
1017 default_static_chain (const_tree ARG_UNUSED (fndecl_or_type), bool incoming_p)
1018 {
1019 if (incoming_p)
1020 {
1021 #ifdef STATIC_CHAIN_INCOMING_REGNUM
1022 return gen_rtx_REG (Pmode, STATIC_CHAIN_INCOMING_REGNUM);
1023 #endif
1024 }
1025
1026 #ifdef STATIC_CHAIN_REGNUM
1027 return gen_rtx_REG (Pmode, STATIC_CHAIN_REGNUM);
1028 #endif
1029
1030 {
1031 static bool issued_error;
1032 if (!issued_error)
1033 {
1034 issued_error = true;
1035 sorry ("nested functions not supported on this target");
1036 }
1037
1038 /* It really doesn't matter what we return here, so long at it
1039 doesn't cause the rest of the compiler to crash. */
1040 return gen_rtx_MEM (Pmode, stack_pointer_rtx);
1041 }
1042 }
1043
1044 void
1045 default_trampoline_init (rtx ARG_UNUSED (m_tramp), tree ARG_UNUSED (t_func),
1046 rtx ARG_UNUSED (r_chain))
1047 {
1048 sorry ("nested function trampolines not supported on this target");
1049 }
1050
1051 poly_int64
1052 default_return_pops_args (tree, tree, poly_int64)
1053 {
1054 return 0;
1055 }
1056
1057 reg_class_t
1058 default_branch_target_register_class (void)
1059 {
1060 return NO_REGS;
1061 }
1062
1063 reg_class_t
1064 default_ira_change_pseudo_allocno_class (int regno ATTRIBUTE_UNUSED,
1065 reg_class_t cl,
1066 reg_class_t best_cl ATTRIBUTE_UNUSED)
1067 {
1068 return cl;
1069 }
1070
1071 extern bool
1072 default_lra_p (void)
1073 {
1074 return true;
1075 }
1076
1077 int
1078 default_register_priority (int hard_regno ATTRIBUTE_UNUSED)
1079 {
1080 return 0;
1081 }
1082
1083 extern bool
1084 default_register_usage_leveling_p (void)
1085 {
1086 return false;
1087 }
1088
1089 extern bool
1090 default_different_addr_displacement_p (void)
1091 {
1092 return false;
1093 }
1094
1095 reg_class_t
1096 default_secondary_reload (bool in_p ATTRIBUTE_UNUSED, rtx x ATTRIBUTE_UNUSED,
1097 reg_class_t reload_class_i ATTRIBUTE_UNUSED,
1098 machine_mode reload_mode ATTRIBUTE_UNUSED,
1099 secondary_reload_info *sri)
1100 {
1101 enum reg_class rclass = NO_REGS;
1102 enum reg_class reload_class = (enum reg_class) reload_class_i;
1103
1104 if (sri->prev_sri && sri->prev_sri->t_icode != CODE_FOR_nothing)
1105 {
1106 sri->icode = sri->prev_sri->t_icode;
1107 return NO_REGS;
1108 }
1109 #ifdef SECONDARY_INPUT_RELOAD_CLASS
1110 if (in_p)
1111 rclass = SECONDARY_INPUT_RELOAD_CLASS (reload_class,
1112 MACRO_MODE (reload_mode), x);
1113 #endif
1114 #ifdef SECONDARY_OUTPUT_RELOAD_CLASS
1115 if (! in_p)
1116 rclass = SECONDARY_OUTPUT_RELOAD_CLASS (reload_class,
1117 MACRO_MODE (reload_mode), x);
1118 #endif
1119 if (rclass != NO_REGS)
1120 {
1121 enum insn_code icode
1122 = direct_optab_handler (in_p ? reload_in_optab : reload_out_optab,
1123 reload_mode);
1124
1125 if (icode != CODE_FOR_nothing
1126 && !insn_operand_matches (icode, in_p, x))
1127 icode = CODE_FOR_nothing;
1128 else if (icode != CODE_FOR_nothing)
1129 {
1130 const char *insn_constraint, *scratch_constraint;
1131 enum reg_class insn_class, scratch_class;
1132
1133 gcc_assert (insn_data[(int) icode].n_operands == 3);
1134 insn_constraint = insn_data[(int) icode].operand[!in_p].constraint;
1135 if (!*insn_constraint)
1136 insn_class = ALL_REGS;
1137 else
1138 {
1139 if (in_p)
1140 {
1141 gcc_assert (*insn_constraint == '=');
1142 insn_constraint++;
1143 }
1144 insn_class = (reg_class_for_constraint
1145 (lookup_constraint (insn_constraint)));
1146 gcc_assert (insn_class != NO_REGS);
1147 }
1148
1149 scratch_constraint = insn_data[(int) icode].operand[2].constraint;
1150 /* The scratch register's constraint must start with "=&",
1151 except for an input reload, where only "=" is necessary,
1152 and where it might be beneficial to re-use registers from
1153 the input. */
1154 gcc_assert (scratch_constraint[0] == '='
1155 && (in_p || scratch_constraint[1] == '&'));
1156 scratch_constraint++;
1157 if (*scratch_constraint == '&')
1158 scratch_constraint++;
1159 scratch_class = (reg_class_for_constraint
1160 (lookup_constraint (scratch_constraint)));
1161
1162 if (reg_class_subset_p (reload_class, insn_class))
1163 {
1164 gcc_assert (scratch_class == rclass);
1165 rclass = NO_REGS;
1166 }
1167 else
1168 rclass = insn_class;
1169
1170 }
1171 if (rclass == NO_REGS)
1172 sri->icode = icode;
1173 else
1174 sri->t_icode = icode;
1175 }
1176 return rclass;
1177 }
1178
1179 /* The default implementation of TARGET_SECONDARY_MEMORY_NEEDED_MODE. */
1180
1181 machine_mode
1182 default_secondary_memory_needed_mode (machine_mode mode)
1183 {
1184 if (!targetm.lra_p ()
1185 && known_lt (GET_MODE_BITSIZE (mode), BITS_PER_WORD)
1186 && INTEGRAL_MODE_P (mode))
1187 return mode_for_size (BITS_PER_WORD, GET_MODE_CLASS (mode), 0).require ();
1188 return mode;
1189 }
1190
1191 /* By default, if flag_pic is true, then neither local nor global relocs
1192 should be placed in readonly memory. */
1193
1194 int
1195 default_reloc_rw_mask (void)
1196 {
1197 return flag_pic ? 3 : 0;
1198 }
1199
1200 /* By default, do no modification. */
1201 tree default_mangle_decl_assembler_name (tree decl ATTRIBUTE_UNUSED,
1202 tree id)
1203 {
1204 return id;
1205 }
1206
1207 /* The default implementation of TARGET_STATIC_RTX_ALIGNMENT. */
1208
1209 HOST_WIDE_INT
1210 default_static_rtx_alignment (machine_mode mode)
1211 {
1212 return GET_MODE_ALIGNMENT (mode);
1213 }
1214
1215 /* The default implementation of TARGET_CONSTANT_ALIGNMENT. */
1216
1217 HOST_WIDE_INT
1218 default_constant_alignment (const_tree, HOST_WIDE_INT align)
1219 {
1220 return align;
1221 }
1222
1223 /* An implementation of TARGET_CONSTANT_ALIGNMENT that aligns strings
1224 to at least BITS_PER_WORD but otherwise makes no changes. */
1225
1226 HOST_WIDE_INT
1227 constant_alignment_word_strings (const_tree exp, HOST_WIDE_INT align)
1228 {
1229 if (TREE_CODE (exp) == STRING_CST)
1230 return MAX (align, BITS_PER_WORD);
1231 return align;
1232 }
1233
1234 /* Default to natural alignment for vector types. */
1235 HOST_WIDE_INT
1236 default_vector_alignment (const_tree type)
1237 {
1238 HOST_WIDE_INT align = tree_to_shwi (TYPE_SIZE (type));
1239 if (align > MAX_OFILE_ALIGNMENT)
1240 align = MAX_OFILE_ALIGNMENT;
1241 return align;
1242 }
1243
1244 /* The default implementation of
1245 TARGET_VECTORIZE_PREFERRED_VECTOR_ALIGNMENT. */
1246
1247 HOST_WIDE_INT
1248 default_preferred_vector_alignment (const_tree type)
1249 {
1250 return TYPE_ALIGN (type);
1251 }
1252
1253 /* By default assume vectors of element TYPE require a multiple of the natural
1254 alignment of TYPE. TYPE is naturally aligned if IS_PACKED is false. */
1255 bool
1256 default_builtin_vector_alignment_reachable (const_tree /*type*/, bool is_packed)
1257 {
1258 return ! is_packed;
1259 }
1260
1261 /* By default, assume that a target supports any factor of misalignment
1262 memory access if it supports movmisalign patten.
1263 is_packed is true if the memory access is defined in a packed struct. */
1264 bool
1265 default_builtin_support_vector_misalignment (machine_mode mode,
1266 const_tree type
1267 ATTRIBUTE_UNUSED,
1268 int misalignment
1269 ATTRIBUTE_UNUSED,
1270 bool is_packed
1271 ATTRIBUTE_UNUSED)
1272 {
1273 if (optab_handler (movmisalign_optab, mode) != CODE_FOR_nothing)
1274 return true;
1275 return false;
1276 }
1277
1278 /* By default, only attempt to parallelize bitwise operations, and
1279 possibly adds/subtracts using bit-twiddling. */
1280
1281 machine_mode
1282 default_preferred_simd_mode (scalar_mode)
1283 {
1284 return word_mode;
1285 }
1286
1287 /* By default do not split reductions further. */
1288
1289 machine_mode
1290 default_split_reduction (machine_mode mode)
1291 {
1292 return mode;
1293 }
1294
1295 /* By default only the size derived from the preferred vector mode
1296 is tried. */
1297
1298 void
1299 default_autovectorize_vector_sizes (vector_sizes *)
1300 {
1301 }
1302
1303 /* By default a vector of integers is used as a mask. */
1304
1305 opt_machine_mode
1306 default_get_mask_mode (poly_uint64 nunits, poly_uint64 vector_size)
1307 {
1308 unsigned int elem_size = vector_element_size (vector_size, nunits);
1309 scalar_int_mode elem_mode
1310 = smallest_int_mode_for_size (elem_size * BITS_PER_UNIT);
1311 machine_mode vector_mode;
1312
1313 gcc_assert (known_eq (elem_size * nunits, vector_size));
1314
1315 if (mode_for_vector (elem_mode, nunits).exists (&vector_mode)
1316 && VECTOR_MODE_P (vector_mode)
1317 && targetm.vector_mode_supported_p (vector_mode))
1318 return vector_mode;
1319
1320 return opt_machine_mode ();
1321 }
1322
1323 /* By default consider masked stores to be expensive. */
1324
1325 bool
1326 default_empty_mask_is_expensive (unsigned ifn)
1327 {
1328 return ifn == IFN_MASK_STORE;
1329 }
1330
1331 /* By default, the cost model accumulates three separate costs (prologue,
1332 loop body, and epilogue) for a vectorized loop or block. So allocate an
1333 array of three unsigned ints, set it to zero, and return its address. */
1334
1335 void *
1336 default_init_cost (struct loop *loop_info ATTRIBUTE_UNUSED)
1337 {
1338 unsigned *cost = XNEWVEC (unsigned, 3);
1339 cost[vect_prologue] = cost[vect_body] = cost[vect_epilogue] = 0;
1340 return cost;
1341 }
1342
1343 /* By default, the cost model looks up the cost of the given statement
1344 kind and mode, multiplies it by the occurrence count, accumulates
1345 it into the cost specified by WHERE, and returns the cost added. */
1346
1347 unsigned
1348 default_add_stmt_cost (void *data, int count, enum vect_cost_for_stmt kind,
1349 struct _stmt_vec_info *stmt_info, int misalign,
1350 enum vect_cost_model_location where)
1351 {
1352 unsigned *cost = (unsigned *) data;
1353 unsigned retval = 0;
1354
1355 tree vectype = stmt_info ? stmt_vectype (stmt_info) : NULL_TREE;
1356 int stmt_cost = targetm.vectorize.builtin_vectorization_cost (kind, vectype,
1357 misalign);
1358 /* Statements in an inner loop relative to the loop being
1359 vectorized are weighted more heavily. The value here is
1360 arbitrary and could potentially be improved with analysis. */
1361 if (where == vect_body && stmt_info && stmt_in_inner_loop_p (stmt_info))
1362 count *= 50; /* FIXME. */
1363
1364 retval = (unsigned) (count * stmt_cost);
1365 cost[where] += retval;
1366
1367 return retval;
1368 }
1369
1370 /* By default, the cost model just returns the accumulated costs. */
1371
1372 void
1373 default_finish_cost (void *data, unsigned *prologue_cost,
1374 unsigned *body_cost, unsigned *epilogue_cost)
1375 {
1376 unsigned *cost = (unsigned *) data;
1377 *prologue_cost = cost[vect_prologue];
1378 *body_cost = cost[vect_body];
1379 *epilogue_cost = cost[vect_epilogue];
1380 }
1381
1382 /* Free the cost data. */
1383
1384 void
1385 default_destroy_cost_data (void *data)
1386 {
1387 free (data);
1388 }
1389
1390 /* Determine whether or not a pointer mode is valid. Assume defaults
1391 of ptr_mode or Pmode - can be overridden. */
1392 bool
1393 default_valid_pointer_mode (scalar_int_mode mode)
1394 {
1395 return (mode == ptr_mode || mode == Pmode);
1396 }
1397
1398 /* Determine whether the memory reference specified by REF may alias
1399 the C libraries errno location. */
1400 bool
1401 default_ref_may_alias_errno (ao_ref *ref)
1402 {
1403 tree base = ao_ref_base (ref);
1404 /* The default implementation assumes the errno location is
1405 a declaration of type int or is always accessed via a
1406 pointer to int. We assume that accesses to errno are
1407 not deliberately obfuscated (even in conforming ways). */
1408 if (TYPE_UNSIGNED (TREE_TYPE (base))
1409 || TYPE_MODE (TREE_TYPE (base)) != TYPE_MODE (integer_type_node))
1410 return false;
1411 /* The default implementation assumes an errno location
1412 declaration is never defined in the current compilation unit. */
1413 if (DECL_P (base)
1414 && !TREE_STATIC (base))
1415 return true;
1416 else if (TREE_CODE (base) == MEM_REF
1417 && TREE_CODE (TREE_OPERAND (base, 0)) == SSA_NAME)
1418 {
1419 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (TREE_OPERAND (base, 0));
1420 return !pi || pi->pt.anything || pi->pt.nonlocal;
1421 }
1422 return false;
1423 }
1424
1425 /* Return the mode for a pointer to a given ADDRSPACE,
1426 defaulting to ptr_mode for all address spaces. */
1427
1428 scalar_int_mode
1429 default_addr_space_pointer_mode (addr_space_t addrspace ATTRIBUTE_UNUSED)
1430 {
1431 return ptr_mode;
1432 }
1433
1434 /* Return the mode for an address in a given ADDRSPACE,
1435 defaulting to Pmode for all address spaces. */
1436
1437 scalar_int_mode
1438 default_addr_space_address_mode (addr_space_t addrspace ATTRIBUTE_UNUSED)
1439 {
1440 return Pmode;
1441 }
1442
1443 /* Named address space version of valid_pointer_mode.
1444 To match the above, the same modes apply to all address spaces. */
1445
1446 bool
1447 default_addr_space_valid_pointer_mode (scalar_int_mode mode,
1448 addr_space_t as ATTRIBUTE_UNUSED)
1449 {
1450 return targetm.valid_pointer_mode (mode);
1451 }
1452
1453 /* Some places still assume that all pointer or address modes are the
1454 standard Pmode and ptr_mode. These optimizations become invalid if
1455 the target actually supports multiple different modes. For now,
1456 we disable such optimizations on such targets, using this function. */
1457
1458 bool
1459 target_default_pointer_address_modes_p (void)
1460 {
1461 if (targetm.addr_space.address_mode != default_addr_space_address_mode)
1462 return false;
1463 if (targetm.addr_space.pointer_mode != default_addr_space_pointer_mode)
1464 return false;
1465
1466 return true;
1467 }
1468
1469 /* Named address space version of legitimate_address_p.
1470 By default, all address spaces have the same form. */
1471
1472 bool
1473 default_addr_space_legitimate_address_p (machine_mode mode, rtx mem,
1474 bool strict,
1475 addr_space_t as ATTRIBUTE_UNUSED)
1476 {
1477 return targetm.legitimate_address_p (mode, mem, strict);
1478 }
1479
1480 /* Named address space version of LEGITIMIZE_ADDRESS.
1481 By default, all address spaces have the same form. */
1482
1483 rtx
1484 default_addr_space_legitimize_address (rtx x, rtx oldx, machine_mode mode,
1485 addr_space_t as ATTRIBUTE_UNUSED)
1486 {
1487 return targetm.legitimize_address (x, oldx, mode);
1488 }
1489
1490 /* The default hook for determining if one named address space is a subset of
1491 another and to return which address space to use as the common address
1492 space. */
1493
1494 bool
1495 default_addr_space_subset_p (addr_space_t subset, addr_space_t superset)
1496 {
1497 return (subset == superset);
1498 }
1499
1500 /* The default hook for determining if 0 within a named address
1501 space is a valid address. */
1502
1503 bool
1504 default_addr_space_zero_address_valid (addr_space_t as ATTRIBUTE_UNUSED)
1505 {
1506 return false;
1507 }
1508
1509 /* The default hook for debugging the address space is to return the
1510 address space number to indicate DW_AT_address_class. */
1511 int
1512 default_addr_space_debug (addr_space_t as)
1513 {
1514 return as;
1515 }
1516
1517 /* The default hook implementation for TARGET_ADDR_SPACE_DIAGNOSE_USAGE.
1518 Don't complain about any address space. */
1519
1520 void
1521 default_addr_space_diagnose_usage (addr_space_t, location_t)
1522 {
1523 }
1524
1525
1526 /* The default hook for TARGET_ADDR_SPACE_CONVERT. This hook should never be
1527 called for targets with only a generic address space. */
1528
1529 rtx
1530 default_addr_space_convert (rtx op ATTRIBUTE_UNUSED,
1531 tree from_type ATTRIBUTE_UNUSED,
1532 tree to_type ATTRIBUTE_UNUSED)
1533 {
1534 gcc_unreachable ();
1535 }
1536
1537 /* The defualt implementation of TARGET_HARD_REGNO_NREGS. */
1538
1539 unsigned int
1540 default_hard_regno_nregs (unsigned int, machine_mode mode)
1541 {
1542 /* Targets with variable-sized modes must provide their own definition
1543 of this hook. */
1544 return CEIL (GET_MODE_SIZE (mode).to_constant (), UNITS_PER_WORD);
1545 }
1546
1547 bool
1548 default_hard_regno_scratch_ok (unsigned int regno ATTRIBUTE_UNUSED)
1549 {
1550 return true;
1551 }
1552
1553 /* The default implementation of TARGET_MODE_DEPENDENT_ADDRESS_P. */
1554
1555 bool
1556 default_mode_dependent_address_p (const_rtx addr ATTRIBUTE_UNUSED,
1557 addr_space_t addrspace ATTRIBUTE_UNUSED)
1558 {
1559 return false;
1560 }
1561
1562 bool
1563 default_target_option_valid_attribute_p (tree ARG_UNUSED (fndecl),
1564 tree ARG_UNUSED (name),
1565 tree ARG_UNUSED (args),
1566 int ARG_UNUSED (flags))
1567 {
1568 warning (OPT_Wattributes,
1569 "target attribute is not supported on this machine");
1570
1571 return false;
1572 }
1573
1574 bool
1575 default_target_option_pragma_parse (tree ARG_UNUSED (args),
1576 tree ARG_UNUSED (pop_target))
1577 {
1578 /* If args is NULL the caller is handle_pragma_pop_options (). In that case,
1579 emit no warning because "#pragma GCC pop_target" is valid on targets that
1580 do not have the "target" pragma. */
1581 if (args)
1582 warning (OPT_Wpragmas,
1583 "#pragma GCC target is not supported for this machine");
1584
1585 return false;
1586 }
1587
1588 bool
1589 default_target_can_inline_p (tree caller, tree callee)
1590 {
1591 tree callee_opts = DECL_FUNCTION_SPECIFIC_TARGET (callee);
1592 tree caller_opts = DECL_FUNCTION_SPECIFIC_TARGET (caller);
1593 if (! callee_opts)
1594 callee_opts = target_option_default_node;
1595 if (! caller_opts)
1596 caller_opts = target_option_default_node;
1597
1598 /* If both caller and callee have attributes, assume that if the
1599 pointer is different, the two functions have different target
1600 options since build_target_option_node uses a hash table for the
1601 options. */
1602 return callee_opts == caller_opts;
1603 }
1604
1605 /* If the machine does not have a case insn that compares the bounds,
1606 this means extra overhead for dispatch tables, which raises the
1607 threshold for using them. */
1608
1609 unsigned int
1610 default_case_values_threshold (void)
1611 {
1612 return (targetm.have_casesi () ? 4 : 5);
1613 }
1614
1615 bool
1616 default_have_conditional_execution (void)
1617 {
1618 return HAVE_conditional_execution;
1619 }
1620
1621 /* By default we assume that c99 functions are present at the runtime,
1622 but sincos is not. */
1623 bool
1624 default_libc_has_function (enum function_class fn_class)
1625 {
1626 if (fn_class == function_c94
1627 || fn_class == function_c99_misc
1628 || fn_class == function_c99_math_complex)
1629 return true;
1630
1631 return false;
1632 }
1633
1634 bool
1635 gnu_libc_has_function (enum function_class fn_class ATTRIBUTE_UNUSED)
1636 {
1637 return true;
1638 }
1639
1640 bool
1641 no_c99_libc_has_function (enum function_class fn_class ATTRIBUTE_UNUSED)
1642 {
1643 return false;
1644 }
1645
1646 tree
1647 default_builtin_tm_load_store (tree ARG_UNUSED (type))
1648 {
1649 return NULL_TREE;
1650 }
1651
1652 /* Compute cost of moving registers to/from memory. */
1653
1654 int
1655 default_memory_move_cost (machine_mode mode ATTRIBUTE_UNUSED,
1656 reg_class_t rclass ATTRIBUTE_UNUSED,
1657 bool in ATTRIBUTE_UNUSED)
1658 {
1659 #ifndef MEMORY_MOVE_COST
1660 return (4 + memory_move_secondary_cost (mode, (enum reg_class) rclass, in));
1661 #else
1662 return MEMORY_MOVE_COST (MACRO_MODE (mode), (enum reg_class) rclass, in);
1663 #endif
1664 }
1665
1666 /* Compute cost of moving data from a register of class FROM to one of
1667 TO, using MODE. */
1668
1669 int
1670 default_register_move_cost (machine_mode mode ATTRIBUTE_UNUSED,
1671 reg_class_t from ATTRIBUTE_UNUSED,
1672 reg_class_t to ATTRIBUTE_UNUSED)
1673 {
1674 #ifndef REGISTER_MOVE_COST
1675 return 2;
1676 #else
1677 return REGISTER_MOVE_COST (MACRO_MODE (mode),
1678 (enum reg_class) from, (enum reg_class) to);
1679 #endif
1680 }
1681
1682 /* The default implementation of TARGET_SLOW_UNALIGNED_ACCESS. */
1683
1684 bool
1685 default_slow_unaligned_access (machine_mode, unsigned int)
1686 {
1687 return STRICT_ALIGNMENT;
1688 }
1689
1690 /* The default implementation of TARGET_ESTIMATED_POLY_VALUE. */
1691
1692 HOST_WIDE_INT
1693 default_estimated_poly_value (poly_int64 x)
1694 {
1695 return x.coeffs[0];
1696 }
1697
1698 /* For hooks which use the MOVE_RATIO macro, this gives the legacy default
1699 behavior. SPEED_P is true if we are compiling for speed. */
1700
1701 unsigned int
1702 get_move_ratio (bool speed_p ATTRIBUTE_UNUSED)
1703 {
1704 unsigned int move_ratio;
1705 #ifdef MOVE_RATIO
1706 move_ratio = (unsigned int) MOVE_RATIO (speed_p);
1707 #else
1708 #if defined (HAVE_movmemqi) || defined (HAVE_movmemhi) || defined (HAVE_movmemsi) || defined (HAVE_movmemdi) || defined (HAVE_movmemti)
1709 move_ratio = 2;
1710 #else /* No movmem patterns, pick a default. */
1711 move_ratio = ((speed_p) ? 15 : 3);
1712 #endif
1713 #endif
1714 return move_ratio;
1715 }
1716
1717 /* Return TRUE if the move_by_pieces/set_by_pieces infrastructure should be
1718 used; return FALSE if the movmem/setmem optab should be expanded, or
1719 a call to memcpy emitted. */
1720
1721 bool
1722 default_use_by_pieces_infrastructure_p (unsigned HOST_WIDE_INT size,
1723 unsigned int alignment,
1724 enum by_pieces_operation op,
1725 bool speed_p)
1726 {
1727 unsigned int max_size = 0;
1728 unsigned int ratio = 0;
1729
1730 switch (op)
1731 {
1732 case CLEAR_BY_PIECES:
1733 max_size = STORE_MAX_PIECES;
1734 ratio = CLEAR_RATIO (speed_p);
1735 break;
1736 case MOVE_BY_PIECES:
1737 max_size = MOVE_MAX_PIECES;
1738 ratio = get_move_ratio (speed_p);
1739 break;
1740 case SET_BY_PIECES:
1741 max_size = STORE_MAX_PIECES;
1742 ratio = SET_RATIO (speed_p);
1743 break;
1744 case STORE_BY_PIECES:
1745 max_size = STORE_MAX_PIECES;
1746 ratio = get_move_ratio (speed_p);
1747 break;
1748 case COMPARE_BY_PIECES:
1749 max_size = COMPARE_MAX_PIECES;
1750 /* Pick a likely default, just as in get_move_ratio. */
1751 ratio = speed_p ? 15 : 3;
1752 break;
1753 }
1754
1755 return by_pieces_ninsns (size, alignment, max_size + 1, op) < ratio;
1756 }
1757
1758 /* This hook controls code generation for expanding a memcmp operation by
1759 pieces. Return 1 for the normal pattern of compare/jump after each pair
1760 of loads, or a higher number to reduce the number of branches. */
1761
1762 int
1763 default_compare_by_pieces_branch_ratio (machine_mode)
1764 {
1765 return 1;
1766 }
1767
1768 /* Write PATCH_AREA_SIZE NOPs into the asm outfile FILE around a function
1769 entry. If RECORD_P is true and the target supports named sections,
1770 the location of the NOPs will be recorded in a special object section
1771 called "__patchable_function_entries". This routine may be called
1772 twice per function to put NOPs before and after the function
1773 entry. */
1774
1775 void
1776 default_print_patchable_function_entry (FILE *file,
1777 unsigned HOST_WIDE_INT patch_area_size,
1778 bool record_p)
1779 {
1780 const char *nop_templ = 0;
1781 int code_num;
1782 rtx_insn *my_nop = make_insn_raw (gen_nop ());
1783
1784 /* We use the template alone, relying on the (currently sane) assumption
1785 that the NOP template does not have variable operands. */
1786 code_num = recog_memoized (my_nop);
1787 nop_templ = get_insn_template (code_num, my_nop);
1788
1789 if (record_p && targetm_common.have_named_sections)
1790 {
1791 char buf[256];
1792 static int patch_area_number;
1793 section *previous_section = in_section;
1794
1795 patch_area_number++;
1796 ASM_GENERATE_INTERNAL_LABEL (buf, "LPFE", patch_area_number);
1797
1798 switch_to_section (get_section ("__patchable_function_entries",
1799 0, NULL));
1800 fputs (integer_asm_op (POINTER_SIZE_UNITS, false), file);
1801 assemble_name_raw (file, buf);
1802 fputc ('\n', file);
1803
1804 switch_to_section (previous_section);
1805 ASM_OUTPUT_LABEL (file, buf);
1806 }
1807
1808 unsigned i;
1809 for (i = 0; i < patch_area_size; ++i)
1810 fprintf (file, "\t%s\n", nop_templ);
1811 }
1812
1813 bool
1814 default_profile_before_prologue (void)
1815 {
1816 #ifdef PROFILE_BEFORE_PROLOGUE
1817 return true;
1818 #else
1819 return false;
1820 #endif
1821 }
1822
1823 /* The default implementation of TARGET_PREFERRED_RELOAD_CLASS. */
1824
1825 reg_class_t
1826 default_preferred_reload_class (rtx x ATTRIBUTE_UNUSED,
1827 reg_class_t rclass)
1828 {
1829 #ifdef PREFERRED_RELOAD_CLASS
1830 return (reg_class_t) PREFERRED_RELOAD_CLASS (x, (enum reg_class) rclass);
1831 #else
1832 return rclass;
1833 #endif
1834 }
1835
1836 /* The default implementation of TARGET_OUTPUT_PREFERRED_RELOAD_CLASS. */
1837
1838 reg_class_t
1839 default_preferred_output_reload_class (rtx x ATTRIBUTE_UNUSED,
1840 reg_class_t rclass)
1841 {
1842 return rclass;
1843 }
1844
1845 /* The default implementation of TARGET_PREFERRED_RENAME_CLASS. */
1846 reg_class_t
1847 default_preferred_rename_class (reg_class_t rclass ATTRIBUTE_UNUSED)
1848 {
1849 return NO_REGS;
1850 }
1851
1852 /* The default implementation of TARGET_CLASS_LIKELY_SPILLED_P. */
1853
1854 bool
1855 default_class_likely_spilled_p (reg_class_t rclass)
1856 {
1857 return (reg_class_size[(int) rclass] == 1);
1858 }
1859
1860 /* The default implementation of TARGET_CLASS_MAX_NREGS. */
1861
1862 unsigned char
1863 default_class_max_nregs (reg_class_t rclass ATTRIBUTE_UNUSED,
1864 machine_mode mode ATTRIBUTE_UNUSED)
1865 {
1866 #ifdef CLASS_MAX_NREGS
1867 return (unsigned char) CLASS_MAX_NREGS ((enum reg_class) rclass,
1868 MACRO_MODE (mode));
1869 #else
1870 /* Targets with variable-sized modes must provide their own definition
1871 of this hook. */
1872 unsigned int size = GET_MODE_SIZE (mode).to_constant ();
1873 return (size + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
1874 #endif
1875 }
1876
1877 /* Determine the debugging unwind mechanism for the target. */
1878
1879 enum unwind_info_type
1880 default_debug_unwind_info (void)
1881 {
1882 /* If the target wants to force the use of dwarf2 unwind info, let it. */
1883 /* ??? Change all users to the hook, then poison this. */
1884 #ifdef DWARF2_FRAME_INFO
1885 if (DWARF2_FRAME_INFO)
1886 return UI_DWARF2;
1887 #endif
1888
1889 /* Otherwise, only turn it on if dwarf2 debugging is enabled. */
1890 #ifdef DWARF2_DEBUGGING_INFO
1891 if (write_symbols == DWARF2_DEBUG || write_symbols == VMS_AND_DWARF2_DEBUG)
1892 return UI_DWARF2;
1893 #endif
1894
1895 return UI_NONE;
1896 }
1897
1898 /* Targets that set NUM_POLY_INT_COEFFS to something greater than 1
1899 must define this hook. */
1900
1901 unsigned int
1902 default_dwarf_poly_indeterminate_value (unsigned int, unsigned int *, int *)
1903 {
1904 gcc_unreachable ();
1905 }
1906
1907 /* Determine the correct mode for a Dwarf frame register that represents
1908 register REGNO. */
1909
1910 machine_mode
1911 default_dwarf_frame_reg_mode (int regno)
1912 {
1913 machine_mode save_mode = reg_raw_mode[regno];
1914
1915 if (targetm.hard_regno_call_part_clobbered (regno, save_mode))
1916 save_mode = choose_hard_reg_mode (regno, 1, true);
1917 return save_mode;
1918 }
1919
1920 /* To be used by targets where reg_raw_mode doesn't return the right
1921 mode for registers used in apply_builtin_return and apply_builtin_arg. */
1922
1923 fixed_size_mode
1924 default_get_reg_raw_mode (int regno)
1925 {
1926 /* Targets must override this hook if the underlying register is
1927 variable-sized. */
1928 return as_a <fixed_size_mode> (reg_raw_mode[regno]);
1929 }
1930
1931 /* Return true if a leaf function should stay leaf even with profiling
1932 enabled. */
1933
1934 bool
1935 default_keep_leaf_when_profiled ()
1936 {
1937 return false;
1938 }
1939
1940 /* Return true if the state of option OPTION should be stored in PCH files
1941 and checked by default_pch_valid_p. Store the option's current state
1942 in STATE if so. */
1943
1944 static inline bool
1945 option_affects_pch_p (int option, struct cl_option_state *state)
1946 {
1947 if ((cl_options[option].flags & CL_TARGET) == 0)
1948 return false;
1949 if ((cl_options[option].flags & CL_PCH_IGNORE) != 0)
1950 return false;
1951 if (option_flag_var (option, &global_options) == &target_flags)
1952 if (targetm.check_pch_target_flags)
1953 return false;
1954 return get_option_state (&global_options, option, state);
1955 }
1956
1957 /* Default version of get_pch_validity.
1958 By default, every flag difference is fatal; that will be mostly right for
1959 most targets, but completely right for very few. */
1960
1961 void *
1962 default_get_pch_validity (size_t *sz)
1963 {
1964 struct cl_option_state state;
1965 size_t i;
1966 char *result, *r;
1967
1968 *sz = 2;
1969 if (targetm.check_pch_target_flags)
1970 *sz += sizeof (target_flags);
1971 for (i = 0; i < cl_options_count; i++)
1972 if (option_affects_pch_p (i, &state))
1973 *sz += state.size;
1974
1975 result = r = XNEWVEC (char, *sz);
1976 r[0] = flag_pic;
1977 r[1] = flag_pie;
1978 r += 2;
1979 if (targetm.check_pch_target_flags)
1980 {
1981 memcpy (r, &target_flags, sizeof (target_flags));
1982 r += sizeof (target_flags);
1983 }
1984
1985 for (i = 0; i < cl_options_count; i++)
1986 if (option_affects_pch_p (i, &state))
1987 {
1988 memcpy (r, state.data, state.size);
1989 r += state.size;
1990 }
1991
1992 return result;
1993 }
1994
1995 /* Return a message which says that a PCH file was created with a different
1996 setting of OPTION. */
1997
1998 static const char *
1999 pch_option_mismatch (const char *option)
2000 {
2001 return xasprintf (_("created and used with differing settings of '%s'"),
2002 option);
2003 }
2004
2005 /* Default version of pch_valid_p. */
2006
2007 const char *
2008 default_pch_valid_p (const void *data_p, size_t len)
2009 {
2010 struct cl_option_state state;
2011 const char *data = (const char *)data_p;
2012 size_t i;
2013
2014 /* -fpic and -fpie also usually make a PCH invalid. */
2015 if (data[0] != flag_pic)
2016 return _("created and used with different settings of -fpic");
2017 if (data[1] != flag_pie)
2018 return _("created and used with different settings of -fpie");
2019 data += 2;
2020
2021 /* Check target_flags. */
2022 if (targetm.check_pch_target_flags)
2023 {
2024 int tf;
2025 const char *r;
2026
2027 memcpy (&tf, data, sizeof (target_flags));
2028 data += sizeof (target_flags);
2029 len -= sizeof (target_flags);
2030 r = targetm.check_pch_target_flags (tf);
2031 if (r != NULL)
2032 return r;
2033 }
2034
2035 for (i = 0; i < cl_options_count; i++)
2036 if (option_affects_pch_p (i, &state))
2037 {
2038 if (memcmp (data, state.data, state.size) != 0)
2039 return pch_option_mismatch (cl_options[i].opt_text);
2040 data += state.size;
2041 len -= state.size;
2042 }
2043
2044 return NULL;
2045 }
2046
2047 /* Default version of cstore_mode. */
2048
2049 scalar_int_mode
2050 default_cstore_mode (enum insn_code icode)
2051 {
2052 return as_a <scalar_int_mode> (insn_data[(int) icode].operand[0].mode);
2053 }
2054
2055 /* Default version of member_type_forces_blk. */
2056
2057 bool
2058 default_member_type_forces_blk (const_tree, machine_mode)
2059 {
2060 return false;
2061 }
2062
2063 rtx
2064 default_load_bounds_for_arg (rtx addr ATTRIBUTE_UNUSED,
2065 rtx ptr ATTRIBUTE_UNUSED,
2066 rtx bnd ATTRIBUTE_UNUSED)
2067 {
2068 gcc_unreachable ();
2069 }
2070
2071 void
2072 default_store_bounds_for_arg (rtx val ATTRIBUTE_UNUSED,
2073 rtx addr ATTRIBUTE_UNUSED,
2074 rtx bounds ATTRIBUTE_UNUSED,
2075 rtx to ATTRIBUTE_UNUSED)
2076 {
2077 gcc_unreachable ();
2078 }
2079
2080 rtx
2081 default_load_returned_bounds (rtx slot ATTRIBUTE_UNUSED)
2082 {
2083 gcc_unreachable ();
2084 }
2085
2086 void
2087 default_store_returned_bounds (rtx slot ATTRIBUTE_UNUSED,
2088 rtx bounds ATTRIBUTE_UNUSED)
2089 {
2090 gcc_unreachable ();
2091 }
2092
2093 /* Default version of canonicalize_comparison. */
2094
2095 void
2096 default_canonicalize_comparison (int *, rtx *, rtx *, bool)
2097 {
2098 }
2099
2100 /* Default implementation of TARGET_ATOMIC_ASSIGN_EXPAND_FENV. */
2101
2102 void
2103 default_atomic_assign_expand_fenv (tree *, tree *, tree *)
2104 {
2105 }
2106
2107 #ifndef PAD_VARARGS_DOWN
2108 #define PAD_VARARGS_DOWN BYTES_BIG_ENDIAN
2109 #endif
2110
2111 /* Build an indirect-ref expression over the given TREE, which represents a
2112 piece of a va_arg() expansion. */
2113 tree
2114 build_va_arg_indirect_ref (tree addr)
2115 {
2116 addr = build_simple_mem_ref_loc (EXPR_LOCATION (addr), addr);
2117 return addr;
2118 }
2119
2120 /* The "standard" implementation of va_arg: read the value from the
2121 current (padded) address and increment by the (padded) size. */
2122
2123 tree
2124 std_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p,
2125 gimple_seq *post_p)
2126 {
2127 tree addr, t, type_size, rounded_size, valist_tmp;
2128 unsigned HOST_WIDE_INT align, boundary;
2129 bool indirect;
2130
2131 /* All of the alignment and movement below is for args-grow-up machines.
2132 As of 2004, there are only 3 ARGS_GROW_DOWNWARD targets, and they all
2133 implement their own specialized gimplify_va_arg_expr routines. */
2134 if (ARGS_GROW_DOWNWARD)
2135 gcc_unreachable ();
2136
2137 indirect = pass_by_reference (NULL, TYPE_MODE (type), type, false);
2138 if (indirect)
2139 type = build_pointer_type (type);
2140
2141 align = PARM_BOUNDARY / BITS_PER_UNIT;
2142 boundary = targetm.calls.function_arg_boundary (TYPE_MODE (type), type);
2143
2144 /* When we align parameter on stack for caller, if the parameter
2145 alignment is beyond MAX_SUPPORTED_STACK_ALIGNMENT, it will be
2146 aligned at MAX_SUPPORTED_STACK_ALIGNMENT. We will match callee
2147 here with caller. */
2148 if (boundary > MAX_SUPPORTED_STACK_ALIGNMENT)
2149 boundary = MAX_SUPPORTED_STACK_ALIGNMENT;
2150
2151 boundary /= BITS_PER_UNIT;
2152
2153 /* Hoist the valist value into a temporary for the moment. */
2154 valist_tmp = get_initialized_tmp_var (valist, pre_p, NULL);
2155
2156 /* va_list pointer is aligned to PARM_BOUNDARY. If argument actually
2157 requires greater alignment, we must perform dynamic alignment. */
2158 if (boundary > align
2159 && !TYPE_EMPTY_P (type)
2160 && !integer_zerop (TYPE_SIZE (type)))
2161 {
2162 t = build2 (MODIFY_EXPR, TREE_TYPE (valist), valist_tmp,
2163 fold_build_pointer_plus_hwi (valist_tmp, boundary - 1));
2164 gimplify_and_add (t, pre_p);
2165
2166 t = build2 (MODIFY_EXPR, TREE_TYPE (valist), valist_tmp,
2167 fold_build2 (BIT_AND_EXPR, TREE_TYPE (valist),
2168 valist_tmp,
2169 build_int_cst (TREE_TYPE (valist), -boundary)));
2170 gimplify_and_add (t, pre_p);
2171 }
2172 else
2173 boundary = align;
2174
2175 /* If the actual alignment is less than the alignment of the type,
2176 adjust the type accordingly so that we don't assume strict alignment
2177 when dereferencing the pointer. */
2178 boundary *= BITS_PER_UNIT;
2179 if (boundary < TYPE_ALIGN (type))
2180 {
2181 type = build_variant_type_copy (type);
2182 SET_TYPE_ALIGN (type, boundary);
2183 }
2184
2185 /* Compute the rounded size of the type. */
2186 type_size = arg_size_in_bytes (type);
2187 rounded_size = round_up (type_size, align);
2188
2189 /* Reduce rounded_size so it's sharable with the postqueue. */
2190 gimplify_expr (&rounded_size, pre_p, post_p, is_gimple_val, fb_rvalue);
2191
2192 /* Get AP. */
2193 addr = valist_tmp;
2194 if (PAD_VARARGS_DOWN && !integer_zerop (rounded_size))
2195 {
2196 /* Small args are padded downward. */
2197 t = fold_build2_loc (input_location, GT_EXPR, sizetype,
2198 rounded_size, size_int (align));
2199 t = fold_build3 (COND_EXPR, sizetype, t, size_zero_node,
2200 size_binop (MINUS_EXPR, rounded_size, type_size));
2201 addr = fold_build_pointer_plus (addr, t);
2202 }
2203
2204 /* Compute new value for AP. */
2205 t = fold_build_pointer_plus (valist_tmp, rounded_size);
2206 t = build2 (MODIFY_EXPR, TREE_TYPE (valist), valist, t);
2207 gimplify_and_add (t, pre_p);
2208
2209 addr = fold_convert (build_pointer_type (type), addr);
2210
2211 if (indirect)
2212 addr = build_va_arg_indirect_ref (addr);
2213
2214 return build_va_arg_indirect_ref (addr);
2215 }
2216
2217 tree
2218 default_chkp_bound_type (void)
2219 {
2220 tree res = make_node (POINTER_BOUNDS_TYPE);
2221 TYPE_PRECISION (res) = TYPE_PRECISION (size_type_node) * 2;
2222 TYPE_NAME (res) = get_identifier ("__bounds_type");
2223 SET_TYPE_MODE (res, targetm.chkp_bound_mode ());
2224 layout_type (res);
2225 return res;
2226 }
2227
2228 machine_mode
2229 default_chkp_bound_mode (void)
2230 {
2231 return VOIDmode;
2232 }
2233
2234 tree
2235 default_builtin_chkp_function (unsigned int fcode ATTRIBUTE_UNUSED)
2236 {
2237 return NULL_TREE;
2238 }
2239
2240 rtx
2241 default_chkp_function_value_bounds (const_tree ret_type ATTRIBUTE_UNUSED,
2242 const_tree fn_decl_or_type ATTRIBUTE_UNUSED,
2243 bool outgoing ATTRIBUTE_UNUSED)
2244 {
2245 gcc_unreachable ();
2246 }
2247
2248 tree
2249 default_chkp_make_bounds_constant (HOST_WIDE_INT lb ATTRIBUTE_UNUSED,
2250 HOST_WIDE_INT ub ATTRIBUTE_UNUSED)
2251 {
2252 return NULL_TREE;
2253 }
2254
2255 int
2256 default_chkp_initialize_bounds (tree var ATTRIBUTE_UNUSED,
2257 tree lb ATTRIBUTE_UNUSED,
2258 tree ub ATTRIBUTE_UNUSED,
2259 tree *stmts ATTRIBUTE_UNUSED)
2260 {
2261 return 0;
2262 }
2263
2264 void
2265 default_setup_incoming_vararg_bounds (cumulative_args_t ca ATTRIBUTE_UNUSED,
2266 machine_mode mode ATTRIBUTE_UNUSED,
2267 tree type ATTRIBUTE_UNUSED,
2268 int *pretend_arg_size ATTRIBUTE_UNUSED,
2269 int second_time ATTRIBUTE_UNUSED)
2270 {
2271 }
2272
2273 /* An implementation of TARGET_CAN_USE_DOLOOP_P for targets that do
2274 not support nested low-overhead loops. */
2275
2276 bool
2277 can_use_doloop_if_innermost (const widest_int &, const widest_int &,
2278 unsigned int loop_depth, bool)
2279 {
2280 return loop_depth == 1;
2281 }
2282
2283 /* Default implementation of TARGET_OPTAB_SUPPORTED_P. */
2284
2285 bool
2286 default_optab_supported_p (int, machine_mode, machine_mode, optimization_type)
2287 {
2288 return true;
2289 }
2290
2291 /* Default implementation of TARGET_MAX_NOCE_IFCVT_SEQ_COST. */
2292
2293 unsigned int
2294 default_max_noce_ifcvt_seq_cost (edge e)
2295 {
2296 bool predictable_p = predictable_edge_p (e);
2297
2298 enum compiler_param param
2299 = (predictable_p
2300 ? PARAM_MAX_RTL_IF_CONVERSION_PREDICTABLE_COST
2301 : PARAM_MAX_RTL_IF_CONVERSION_UNPREDICTABLE_COST);
2302
2303 /* If we have a parameter set, use that, otherwise take a guess using
2304 BRANCH_COST. */
2305 if (global_options_set.x_param_values[param])
2306 return PARAM_VALUE (param);
2307 else
2308 return BRANCH_COST (true, predictable_p) * COSTS_N_INSNS (3);
2309 }
2310
2311 /* Default implementation of TARGET_MIN_ARITHMETIC_PRECISION. */
2312
2313 unsigned int
2314 default_min_arithmetic_precision (void)
2315 {
2316 return WORD_REGISTER_OPERATIONS ? BITS_PER_WORD : BITS_PER_UNIT;
2317 }
2318
2319 /* Default implementation of TARGET_C_EXCESS_PRECISION. */
2320
2321 enum flt_eval_method
2322 default_excess_precision (enum excess_precision_type ATTRIBUTE_UNUSED)
2323 {
2324 return FLT_EVAL_METHOD_PROMOTE_TO_FLOAT;
2325 }
2326
2327 bool
2328 default_stack_clash_protection_final_dynamic_probe (rtx residual ATTRIBUTE_UNUSED)
2329 {
2330 return 0;
2331 }
2332
2333 /* The default implementation of TARGET_EARLY_REMAT_MODES. */
2334
2335 void
2336 default_select_early_remat_modes (sbitmap)
2337 {
2338 }
2339
2340 #include "gt-targhooks.h"