diff options
author | rsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-11-18 16:00:55 +0000 |
---|---|---|
committer | rsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-11-18 16:00:55 +0000 |
commit | 81c6af2dc6f960f98ef064146de297755d6b0894 (patch) | |
tree | 6caa7792f45dc14f92d076c6b3fe85c28f7de3d0 /gcc/expr.c | |
parent | a342dbb23c12ed61e824661be2dd672f6dceea4c (diff) | |
parent | aa59f000a84f3f0016bcb959a077047090c8d91c (diff) | |
download | gcc-81c6af2dc6f960f98ef064146de297755d6b0894.tar.gz |
Merge from trunk.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/wide-int@204969 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/expr.c')
-rw-r--r-- | gcc/expr.c | 95 |
1 files changed, 79 insertions, 16 deletions
diff --git a/gcc/expr.c b/gcc/expr.c index 52044ae37eb..f48a88d24e5 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -57,6 +57,7 @@ along with GCC; see the file COPYING3. If not see #include "target-globals.h" #include "params.h" #include "tree-ssa-address.h" +#include "cfgexpand.h" /* Decide whether a function's arguments should be processed from first to last or from last to first. @@ -127,7 +128,8 @@ struct store_by_pieces_d static void move_by_pieces_1 (insn_gen_fn, machine_mode, struct move_by_pieces_d *); static bool block_move_libcall_safe_for_call_parm (void); -static bool emit_block_move_via_movmem (rtx, rtx, rtx, unsigned, unsigned, HOST_WIDE_INT); +static bool emit_block_move_via_movmem (rtx, rtx, rtx, unsigned, unsigned, HOST_WIDE_INT, + unsigned HOST_WIDE_INT, unsigned HOST_WIDE_INT); static tree emit_block_move_libcall_fn (int); static void emit_block_move_via_loop (rtx, rtx, rtx, unsigned); static rtx clear_by_pieces_1 (void *, HOST_WIDE_INT, enum machine_mode); @@ -1087,13 +1089,18 @@ move_by_pieces_1 (insn_gen_fn genfun, machine_mode mode, SIZE is an rtx that says how long they are. ALIGN is the maximum alignment we can assume they have. METHOD describes what kind of copy this is, and what mechanisms may be used. + MIN_SIZE is the minimal size of block to move + MAX_SIZE is the maximal size of block to move, if it can not be represented + in unsigned HOST_WIDE_INT, than it is mask of all ones. Return the address of the new block, if memcpy is called and returns it, 0 otherwise. */ rtx emit_block_move_hints (rtx x, rtx y, rtx size, enum block_op_methods method, - unsigned int expected_align, HOST_WIDE_INT expected_size) + unsigned int expected_align, HOST_WIDE_INT expected_size, + unsigned HOST_WIDE_INT min_size, + unsigned HOST_WIDE_INT max_size) { bool may_use_call; rtx retval = 0; @@ -1149,7 +1156,8 @@ emit_block_move_hints (rtx x, rtx y, rtx size, enum block_op_methods method, if (CONST_INT_P (size) && MOVE_BY_PIECES_P (INTVAL (size), align)) move_by_pieces (x, y, INTVAL (size), align, 0); else if (emit_block_move_via_movmem (x, y, size, align, - expected_align, expected_size)) + expected_align, expected_size, + min_size, max_size)) ; else if (may_use_call && ADDR_SPACE_GENERIC_P (MEM_ADDR_SPACE (x)) @@ -1179,7 +1187,13 @@ emit_block_move_hints (rtx x, rtx y, rtx size, enum block_op_methods method, rtx emit_block_move (rtx x, rtx y, rtx size, enum block_op_methods method) { - return emit_block_move_hints (x, y, size, method, 0, -1); + unsigned HOST_WIDE_INT max, min = 0; + if (GET_CODE (size) == CONST_INT) + min = max = UINTVAL (size); + else + max = GET_MODE_MASK (GET_MODE (size)); + return emit_block_move_hints (x, y, size, method, 0, -1, + min, max); } /* A subroutine of emit_block_move. Returns true if calling the @@ -1242,13 +1256,22 @@ block_move_libcall_safe_for_call_parm (void) static bool emit_block_move_via_movmem (rtx x, rtx y, rtx size, unsigned int align, - unsigned int expected_align, HOST_WIDE_INT expected_size) + unsigned int expected_align, HOST_WIDE_INT expected_size, + unsigned HOST_WIDE_INT min_size, + unsigned HOST_WIDE_INT max_size) { int save_volatile_ok = volatile_ok; enum machine_mode mode; if (expected_align < align) expected_align = align; + if (expected_size != -1) + { + if ((unsigned HOST_WIDE_INT)expected_size > max_size) + expected_size = max_size; + if ((unsigned HOST_WIDE_INT)expected_size < min_size) + expected_size = min_size; + } /* Since this is a move insn, we don't care about volatility. */ volatile_ok = 1; @@ -1271,9 +1294,10 @@ emit_block_move_via_movmem (rtx x, rtx y, rtx size, unsigned int align, && ((CONST_INT_P (size) && ((unsigned HOST_WIDE_INT) INTVAL (size) <= (GET_MODE_MASK (mode) >> 1))) + || max_size <= (GET_MODE_MASK (mode) >> 1) || GET_MODE_BITSIZE (mode) >= GET_MODE_BITSIZE (Pmode))) { - struct expand_operand ops[6]; + struct expand_operand ops[8]; unsigned int nops; /* ??? When called via emit_block_move_for_call, it'd be @@ -1281,18 +1305,28 @@ emit_block_move_via_movmem (rtx x, rtx y, rtx size, unsigned int align, that it doesn't fail the expansion because it thinks emitting the libcall would be more efficient. */ nops = insn_data[(int) code].n_generator_args; - gcc_assert (nops == 4 || nops == 6); + gcc_assert (nops == 4 || nops == 6 || nops == 8); create_fixed_operand (&ops[0], x); create_fixed_operand (&ops[1], y); /* The check above guarantees that this size conversion is valid. */ create_convert_operand_to (&ops[2], size, mode, true); create_integer_operand (&ops[3], align / BITS_PER_UNIT); - if (nops == 6) + if (nops >= 6) { create_integer_operand (&ops[4], expected_align / BITS_PER_UNIT); create_integer_operand (&ops[5], expected_size); } + if (nops == 8) + { + create_integer_operand (&ops[6], min_size); + /* If we can not represent the maximal size, + make parameter NULL. */ + if ((HOST_WIDE_INT) max_size != -1) + create_integer_operand (&ops[7], max_size); + else + create_fixed_operand (&ops[7], NULL); + } if (maybe_expand_insn (code, nops, ops)) { volatile_ok = save_volatile_ok; @@ -2681,7 +2715,9 @@ store_by_pieces_2 (insn_gen_fn genfun, machine_mode mode, rtx clear_storage_hints (rtx object, rtx size, enum block_op_methods method, - unsigned int expected_align, HOST_WIDE_INT expected_size) + unsigned int expected_align, HOST_WIDE_INT expected_size, + unsigned HOST_WIDE_INT min_size, + unsigned HOST_WIDE_INT max_size) { enum machine_mode mode = GET_MODE (object); unsigned int align; @@ -2722,7 +2758,8 @@ clear_storage_hints (rtx object, rtx size, enum block_op_methods method, && CLEAR_BY_PIECES_P (INTVAL (size), align)) clear_by_pieces (object, INTVAL (size), align); else if (set_storage_via_setmem (object, size, const0_rtx, align, - expected_align, expected_size)) + expected_align, expected_size, + min_size, max_size)) ; else if (ADDR_SPACE_GENERIC_P (MEM_ADDR_SPACE (object))) return set_storage_via_libcall (object, size, const0_rtx, @@ -2736,7 +2773,12 @@ clear_storage_hints (rtx object, rtx size, enum block_op_methods method, rtx clear_storage (rtx object, rtx size, enum block_op_methods method) { - return clear_storage_hints (object, size, method, 0, -1); + unsigned HOST_WIDE_INT max, min = 0; + if (GET_CODE (size) == CONST_INT) + min = max = UINTVAL (size); + else + max = GET_MODE_MASK (GET_MODE (size)); + return clear_storage_hints (object, size, method, 0, -1, min, max); } @@ -2833,7 +2875,9 @@ clear_storage_libcall_fn (int for_call) bool set_storage_via_setmem (rtx object, rtx size, rtx val, unsigned int align, - unsigned int expected_align, HOST_WIDE_INT expected_size) + unsigned int expected_align, HOST_WIDE_INT expected_size, + unsigned HOST_WIDE_INT min_size, + unsigned HOST_WIDE_INT max_size) { /* Try the most limited insn first, because there's no point including more than one in the machine description unless @@ -2843,6 +2887,13 @@ set_storage_via_setmem (rtx object, rtx size, rtx val, unsigned int align, if (expected_align < align) expected_align = align; + if (expected_size != -1) + { + if ((unsigned HOST_WIDE_INT)expected_size > max_size) + expected_size = max_size; + if ((unsigned HOST_WIDE_INT)expected_size < min_size) + expected_size = min_size; + } for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT); mode != VOIDmode; mode = GET_MODE_WIDER_MODE (mode)) @@ -2858,24 +2909,35 @@ set_storage_via_setmem (rtx object, rtx size, rtx val, unsigned int align, && ((CONST_INT_P (size) && ((unsigned HOST_WIDE_INT) INTVAL (size) <= (GET_MODE_MASK (mode) >> 1))) + || max_size <= (GET_MODE_MASK (mode) >> 1) || GET_MODE_BITSIZE (mode) >= GET_MODE_BITSIZE (Pmode))) { - struct expand_operand ops[6]; + struct expand_operand ops[8]; unsigned int nops; nops = insn_data[(int) code].n_generator_args; - gcc_assert (nops == 4 || nops == 6); + gcc_assert (nops == 4 || nops == 6 || nops == 8); create_fixed_operand (&ops[0], object); /* The check above guarantees that this size conversion is valid. */ create_convert_operand_to (&ops[1], size, mode, true); create_convert_operand_from (&ops[2], val, byte_mode, true); create_integer_operand (&ops[3], align / BITS_PER_UNIT); - if (nops == 6) + if (nops >= 6) { create_integer_operand (&ops[4], expected_align / BITS_PER_UNIT); create_integer_operand (&ops[5], expected_size); } + if (nops == 8) + { + create_integer_operand (&ops[6], min_size); + /* If we can not represent the maximal size, + make parameter NULL. */ + if ((HOST_WIDE_INT) max_size != -1) + create_integer_operand (&ops[7], max_size); + else + create_fixed_operand (&ops[7], NULL); + } if (maybe_expand_insn (code, nops, ops)) return true; } @@ -8463,7 +8525,8 @@ expand_expr_real_2 (sepops ops, rtx target, enum machine_mode tmode, op0 = copy_to_mode_reg (mode, op0); return REDUCE_BIT_FIELD (gen_rtx_MULT (mode, op0, - gen_int_mode (tree_to_shwi (exp1), TYPE_MODE (TREE_TYPE (exp1))))); + gen_int_mode (tree_to_shwi (exp1), + TYPE_MODE (TREE_TYPE (exp1))))); } if (modifier == EXPAND_STACK_PARM) |