aboutsummaryrefslogtreecommitdiff
path: root/gcc/expr.c
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2018-11-27 13:30:59 +0100
committerMartin Liska <marxin@gcc.gnu.org>2018-11-27 12:30:59 +0000
commit2ff5ffb623e17b6bb81532394cb1f42fe7b354c8 (patch)
tree82fc40305d36ff9ce012e68a6947467161e0a015 /gcc/expr.c
parentda193a2713d34358d564c9fd5b5347d7bc2cc150 (diff)
downloadgcc-2ff5ffb623e17b6bb81532394cb1f42fe7b354c8.zip
gcc-2ff5ffb623e17b6bb81532394cb1f42fe7b354c8.tar.gz
gcc-2ff5ffb623e17b6bb81532394cb1f42fe7b354c8.tar.bz2
Come up with memop_ret enum instead of int endp for memory operations.
2018-11-27 Martin Liska <mliska@suse.cz> * asan.c (asan_emit_stack_protection): Use new enum values instead of int constants. * builtins.c (expand_builtin_memory_copy_args): Replace int type with memop_ret enum type. (expand_builtin_mempcpy_args): Likewise. (expand_builtin_memcpy): Use new enum values instead of int constants. Likewise. (expand_builtin_mempcpy): Likewise. (expand_movstr): Likewise. (expand_builtin_strcpy_args): Likewise. (expand_builtin_stpcpy_1): Likewise. (expand_builtin_strncpy): Likewise. (expand_builtin_memset_args): Likewise. * expr.c (move_by_pieces_d::finish_endp): Rename to ... (move_by_pieces_d::finish_retmode): ... this. (move_by_pieces): Change last argument type to memop_ret. (store_by_pieces): Use new enum values instead of int constants. (emit_block_move_hints): Likewise. (emit_push_insn): Likewise. (store_expr): Likewise. * expr.h (store_by_pieces): Change int to newly added enum type. * rtl.h (enum memop_ret): Define. (move_by_pieces): Use the enum type. From-SVN: r266508
Diffstat (limited to 'gcc/expr.c')
-rw-r--r--gcc/expr.c53
1 files changed, 25 insertions, 28 deletions
diff --git a/gcc/expr.c b/gcc/expr.c
index ef29ec5..85b7847 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -1146,7 +1146,7 @@ class move_by_pieces_d : public op_by_pieces_d
: op_by_pieces_d (to, false, from, true, NULL, NULL, len, align)
{
}
- rtx finish_endp (int);
+ rtx finish_retmode (memop_ret);
};
/* Return true if MODE can be used for a set of copies, given an
@@ -1182,15 +1182,14 @@ move_by_pieces_d::generate (rtx op0, rtx op1,
}
/* Perform the final adjustment at the end of a string to obtain the
- correct return value for the block operation. If ENDP is 1 return
- memory at the end ala mempcpy, and if ENDP is 2 return memory the
- end minus one byte ala stpcpy. */
+ correct return value for the block operation.
+ Return value is based on RETMODE argument. */
rtx
-move_by_pieces_d::finish_endp (int endp)
+move_by_pieces_d::finish_retmode (memop_ret retmode)
{
gcc_assert (!m_reverse);
- if (endp == 2)
+ if (retmode == RETURN_END_MINUS_ONE)
{
m_to.maybe_postinc (-1);
--m_offset;
@@ -1206,13 +1205,11 @@ move_by_pieces_d::finish_endp (int endp)
ALIGN is maximum stack alignment we can assume.
- If ENDP is 0 return to, if ENDP is 1 return memory at the end ala
- mempcpy, and if ENDP is 2 return memory the end minus one byte ala
- stpcpy. */
+ Return value is based on RETMODE argument. */
rtx
move_by_pieces (rtx to, rtx from, unsigned HOST_WIDE_INT len,
- unsigned int align, int endp)
+ unsigned int align, memop_ret retmode)
{
#ifndef PUSH_ROUNDING
if (to == NULL)
@@ -1223,8 +1220,8 @@ move_by_pieces (rtx to, rtx from, unsigned HOST_WIDE_INT len,
data.run ();
- if (endp)
- return data.finish_endp (endp);
+ if (retmode)
+ return data.finish_retmode (retmode);
else
return to;
}
@@ -1244,7 +1241,7 @@ class store_by_pieces_d : public op_by_pieces_d
: op_by_pieces_d (to, false, NULL_RTX, true, cfn, cfn_data, len, align)
{
}
- rtx finish_endp (int);
+ rtx finish_retmode (memop_ret);
};
/* Return true if MODE can be used for a set of stores, given an
@@ -1272,15 +1269,14 @@ store_by_pieces_d::generate (rtx op0, rtx op1, machine_mode)
}
/* Perform the final adjustment at the end of a string to obtain the
- correct return value for the block operation. If ENDP is 1 return
- memory at the end ala mempcpy, and if ENDP is 2 return memory the
- end minus one byte ala stpcpy. */
+ correct return value for the block operation.
+ Return value is based on RETMODE argument. */
rtx
-store_by_pieces_d::finish_endp (int endp)
+store_by_pieces_d::finish_retmode (memop_ret retmode)
{
gcc_assert (!m_reverse);
- if (endp == 2)
+ if (retmode == RETURN_END_MINUS_ONE)
{
m_to.maybe_postinc (-1);
--m_offset;
@@ -1370,18 +1366,17 @@ can_store_by_pieces (unsigned HOST_WIDE_INT len,
pointer which will be passed as argument in every CONSTFUN call.
ALIGN is maximum alignment we can assume. MEMSETP is true if this is
a memset operation and false if it's a copy of a constant string.
- If ENDP is 0 return to, if ENDP is 1 return memory at the end ala
- mempcpy, and if ENDP is 2 return memory the end minus one byte ala
- stpcpy. */
+ Return value is based on RETMODE argument. */
rtx
store_by_pieces (rtx to, unsigned HOST_WIDE_INT len,
rtx (*constfun) (void *, HOST_WIDE_INT, scalar_int_mode),
- void *constfundata, unsigned int align, bool memsetp, int endp)
+ void *constfundata, unsigned int align, bool memsetp,
+ memop_ret retmode)
{
if (len == 0)
{
- gcc_assert (endp != 2);
+ gcc_assert (retmode != RETURN_END_MINUS_ONE);
return to;
}
@@ -1393,8 +1388,8 @@ store_by_pieces (rtx to, unsigned HOST_WIDE_INT len,
store_by_pieces_d data (to, constfun, constfundata, len, align);
data.run ();
- if (endp)
- return data.finish_endp (endp);
+ if (retmode)
+ return data.finish_retmode (retmode);
else
return to;
}
@@ -1624,7 +1619,7 @@ emit_block_move_hints (rtx x, rtx y, rtx size, enum block_op_methods method,
}
if (CONST_INT_P (size) && can_move_by_pieces (INTVAL (size), align))
- move_by_pieces (x, y, INTVAL (size), align, 0);
+ move_by_pieces (x, y, INTVAL (size), align, RETURN_BEGIN);
else if (emit_block_move_via_movmem (x, y, size, align,
expected_align, expected_size,
min_size, max_size, probable_max_size))
@@ -4421,7 +4416,8 @@ emit_push_insn (rtx x, machine_mode mode, tree type, rtx size,
&& where_pad != stack_direction)
anti_adjust_stack (gen_int_mode (extra, Pmode));
- move_by_pieces (NULL, xinner, INTVAL (size) - used, align, 0);
+ move_by_pieces (NULL, xinner, INTVAL (size) - used, align,
+ RETURN_BEGIN);
}
else
#endif /* PUSH_ROUNDING */
@@ -5618,7 +5614,8 @@ store_expr (tree exp, rtx target, int call_param_p,
CONST_CAST (char *,
TREE_STRING_POINTER (str)),
MEM_ALIGN (target), false,
- exp_len > str_copy_len ? 1 : 0);
+ (exp_len > str_copy_len ? RETURN_END :
+ RETURN_BEGIN));
if (exp_len > str_copy_len)
clear_storage (adjust_address (dest_mem, BLKmode, 0),
GEN_INT (exp_len - str_copy_len),