comparison gcc/explow.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
1 /* Subroutines for manipulating rtx's in semantically interesting ways. 1 /* Subroutines for manipulating rtx's in semantically interesting ways.
2 Copyright (C) 1987-2018 Free Software Foundation, Inc. 2 Copyright (C) 1987-2020 Free Software Foundation, Inc.
3 3
4 This file is part of GCC. 4 This file is part of GCC.
5 5
6 GCC is free software; you can redistribute it and/or modify it under 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 7 the terms of the GNU General Public License as published by the Free
36 #include "stor-layout.h" 36 #include "stor-layout.h"
37 #include "except.h" 37 #include "except.h"
38 #include "dojump.h" 38 #include "dojump.h"
39 #include "explow.h" 39 #include "explow.h"
40 #include "expr.h" 40 #include "expr.h"
41 #include "stringpool.h"
41 #include "common/common-target.h" 42 #include "common/common-target.h"
42 #include "output.h" 43 #include "output.h"
43 #include "params.h"
44 44
45 static rtx break_out_memory_refs (rtx); 45 static rtx break_out_memory_refs (rtx);
46 static void anti_adjust_stack_and_probe_stack_clash (rtx); 46 static void anti_adjust_stack_and_probe_stack_clash (rtx);
47 47
48 48
890 return mode; 890 return mode;
891 } 891 }
892 892
893 tree type = TREE_TYPE (name); 893 tree type = TREE_TYPE (name);
894 int unsignedp = TYPE_UNSIGNED (type); 894 int unsignedp = TYPE_UNSIGNED (type);
895 machine_mode mode = TYPE_MODE (type); 895 machine_mode pmode = promote_mode (type, TYPE_MODE (type), &unsignedp);
896
897 /* Bypass TYPE_MODE when it maps vector modes to BLKmode. */
898 if (mode == BLKmode)
899 {
900 gcc_assert (VECTOR_TYPE_P (type));
901 mode = type->type_common.mode;
902 }
903
904 machine_mode pmode = promote_mode (type, mode, &unsignedp);
905 if (punsignedp) 896 if (punsignedp)
906 *punsignedp = unsignedp; 897 *punsignedp = unsignedp;
907 898
908 return pmode; 899 return pmode;
909 } 900 }
1174 1165
1175 /* Record the new stack level for SJLJ exceptions. */ 1166 /* Record the new stack level for SJLJ exceptions. */
1176 if (targetm_common.except_unwind_info (&global_options) == UI_SJLJ) 1167 if (targetm_common.except_unwind_info (&global_options) == UI_SJLJ)
1177 update_sjlj_context (); 1168 update_sjlj_context ();
1178 } 1169 }
1179 1170
1180 /* Return an rtx doing runtime alignment to REQUIRED_ALIGN on TARGET. */ 1171 /* Return an rtx doing runtime alignment to REQUIRED_ALIGN on TARGET. */
1181 static rtx 1172
1173 rtx
1182 align_dynamic_address (rtx target, unsigned required_align) 1174 align_dynamic_address (rtx target, unsigned required_align)
1183 { 1175 {
1184 /* CEIL_DIV_EXPR needs to worry about the addition overflowing, 1176 /* CEIL_DIV_EXPR needs to worry about the addition overflowing,
1185 but we know it can't. So add ourselves and then do 1177 but we know it can't. So add ourselves and then do
1186 TRUNC_DIV_EXPR. */ 1178 TRUNC_DIV_EXPR. */
1495 /* Perform the required allocation from the stack. Some systems do 1487 /* Perform the required allocation from the stack. Some systems do
1496 this differently than simply incrementing/decrementing from the 1488 this differently than simply incrementing/decrementing from the
1497 stack pointer, such as acquiring the space by calling malloc(). */ 1489 stack pointer, such as acquiring the space by calling malloc(). */
1498 if (targetm.have_allocate_stack ()) 1490 if (targetm.have_allocate_stack ())
1499 { 1491 {
1500 struct expand_operand ops[2]; 1492 class expand_operand ops[2];
1501 /* We don't have to check against the predicate for operand 0 since 1493 /* We don't have to check against the predicate for operand 0 since
1502 TARGET is known to be a pseudo of the proper mode, which must 1494 TARGET is known to be a pseudo of the proper mode, which must
1503 be valid for the operand. */ 1495 be valid for the operand. */
1504 create_fixed_operand (&ops[0], target); 1496 create_fixed_operand (&ops[0], target);
1505 create_convert_operand_to (&ops[1], size, STACK_SIZE_MODE, true); 1497 create_convert_operand_to (&ops[1], size, STACK_SIZE_MODE, true);
1617 void 1609 void
1618 set_stack_check_libfunc (const char *libfunc_name) 1610 set_stack_check_libfunc (const char *libfunc_name)
1619 { 1611 {
1620 gcc_assert (stack_check_libfunc == NULL_RTX); 1612 gcc_assert (stack_check_libfunc == NULL_RTX);
1621 stack_check_libfunc = gen_rtx_SYMBOL_REF (Pmode, libfunc_name); 1613 stack_check_libfunc = gen_rtx_SYMBOL_REF (Pmode, libfunc_name);
1614 tree decl = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL,
1615 get_identifier (libfunc_name), void_type_node);
1616 DECL_EXTERNAL (decl) = 1;
1617 SET_SYMBOL_REF_DECL (stack_check_libfunc, decl);
1622 } 1618 }
1623 1619
1624 /* Emit one stack probe at ADDRESS, an address within the stack. */ 1620 /* Emit one stack probe at ADDRESS, an address within the stack. */
1625 1621
1626 void 1622 void
1627 emit_stack_probe (rtx address) 1623 emit_stack_probe (rtx address)
1628 { 1624 {
1629 if (targetm.have_probe_stack_address ()) 1625 if (targetm.have_probe_stack_address ())
1630 { 1626 {
1631 struct expand_operand ops[1]; 1627 class expand_operand ops[1];
1632 insn_code icode = targetm.code_for_probe_stack_address; 1628 insn_code icode = targetm.code_for_probe_stack_address;
1633 create_address_operand (ops, address); 1629 create_address_operand (ops, address);
1634 maybe_legitimize_operands (icode, 0, 1, ops); 1630 maybe_legitimize_operands (icode, 0, 1, ops);
1635 expand_insn (icode, 1, ops); 1631 expand_insn (icode, 1, ops);
1636 } 1632 }
1686 } 1682 }
1687 1683
1688 /* Next see if we have an insn to check the stack. */ 1684 /* Next see if we have an insn to check the stack. */
1689 else if (targetm.have_check_stack ()) 1685 else if (targetm.have_check_stack ())
1690 { 1686 {
1691 struct expand_operand ops[1]; 1687 class expand_operand ops[1];
1692 rtx addr = memory_address (Pmode, 1688 rtx addr = memory_address (Pmode,
1693 gen_rtx_fmt_ee (STACK_GROW_OP, Pmode, 1689 gen_rtx_fmt_ee (STACK_GROW_OP, Pmode,
1694 stack_pointer_rtx, 1690 stack_pointer_rtx,
1695 plus_constant (Pmode, 1691 plus_constant (Pmode,
1696 size, first))); 1692 size, first)));
1838 HOST_WIDE_INT *probe_interval, 1834 HOST_WIDE_INT *probe_interval,
1839 rtx size) 1835 rtx size)
1840 { 1836 {
1841 /* Round SIZE down to STACK_CLASH_PROTECTION_PROBE_INTERVAL */ 1837 /* Round SIZE down to STACK_CLASH_PROTECTION_PROBE_INTERVAL */
1842 *probe_interval 1838 *probe_interval
1843 = 1 << PARAM_VALUE (PARAM_STACK_CLASH_PROTECTION_PROBE_INTERVAL); 1839 = 1 << param_stack_clash_protection_probe_interval;
1844 *rounded_size = simplify_gen_binary (AND, Pmode, size, 1840 *rounded_size = simplify_gen_binary (AND, Pmode, size,
1845 GEN_INT (-*probe_interval)); 1841 GEN_INT (-*probe_interval));
1846 1842
1847 /* Compute the value of the stack pointer for the last iteration. 1843 /* Compute the value of the stack pointer for the last iteration.
1848 It's just SP + ROUNDED_SIZE. */ 1844 It's just SP + ROUNDED_SIZE. */