aboutsummaryrefslogtreecommitdiff
path: root/gcc/cse.cc
diff options
context:
space:
mode:
authorUros Bizjak <ubizjak@gmail.com>2023-06-14 12:13:25 +0200
committerUros Bizjak <ubizjak@gmail.com>2023-06-18 17:05:17 +0200
commit47fa3cef59a031f1b0fdce309ff634fab717606d (patch)
tree80280aaa71b46492063b7a4e5abd472b2ff8e711 /gcc/cse.cc
parent8a96f240d71d367a2955ab9e0f0fef3a0b0e2a74 (diff)
downloadgcc-47fa3cef59a031f1b0fdce309ff634fab717606d.zip
gcc-47fa3cef59a031f1b0fdce309ff634fab717606d.tar.gz
gcc-47fa3cef59a031f1b0fdce309ff634fab717606d.tar.bz2
RTL: Merge rtx_equal_p and hash_rtx functions with their callback variants
Use default argument when callback function is not required to merge rtx_equal_p and hash_rtx functions with their callback variants. gcc/ChangeLog: * cse.cc (hash_rtx_cb): Rename to hash_rtx. (hash_rtx): Remove. * early-remat.cc (remat_candidate_hasher::equal): Update to call rtx_equal_p with rtx_equal_p_callback_function argument. * rtl.cc (rtx_equal_p_cb): Rename to rtx_equal_p. (rtx_equal_p): Remove. * rtl.h (rtx_equal_p): Add rtx_equal_p_callback_function argument with NULL default value. (rtx_equal_p_cb): Remove function declaration. (hash_rtx_cb): Ditto. (hash_rtx): Add hash_rtx_callback_function argument with NULL default value. * sel-sched-ir.cc (free_nop_pool): Update function comment. (skip_unspecs_callback): Ditto. (vinsn_init): Update to call hash_rtx with hash_rtx_callback_function argument. (vinsn_equal_p): Ditto.
Diffstat (limited to 'gcc/cse.cc')
-rw-r--r--gcc/cse.cc72
1 files changed, 32 insertions, 40 deletions
diff --git a/gcc/cse.cc b/gcc/cse.cc
index 2bb63ac..6f2e0d4 100644
--- a/gcc/cse.cc
+++ b/gcc/cse.cc
@@ -2208,13 +2208,26 @@ hash_rtx_string (const char *ps)
return hash;
}
-/* Same as hash_rtx, but call CB on each rtx if it is not NULL.
+/* Hash an rtx. We are careful to make sure the value is never negative.
+ Equivalent registers hash identically.
+ MODE is used in hashing for CONST_INTs only;
+ otherwise the mode of X is used.
+
+ Store 1 in DO_NOT_RECORD_P if any subexpression is volatile.
+
+ If HASH_ARG_IN_MEMORY_P is not NULL, store 1 in it if X contains
+ a MEM rtx which does not have the MEM_READONLY_P flag set.
+
+ Note that cse_insn knows that the hash code of a MEM expression
+ is just (int) MEM plus the hash code of the address.
+
+ Call CB on each rtx if CB is not NULL.
When the callback returns true, we continue with the new rtx. */
unsigned
-hash_rtx_cb (const_rtx x, machine_mode mode,
- int *do_not_record_p, int *hash_arg_in_memory_p,
- bool have_reg_qty, hash_rtx_callback_function cb)
+hash_rtx (const_rtx x, machine_mode mode,
+ int *do_not_record_p, int *hash_arg_in_memory_p,
+ bool have_reg_qty, hash_rtx_callback_function cb)
{
int i, j;
unsigned hash = 0;
@@ -2234,8 +2247,8 @@ hash_rtx_cb (const_rtx x, machine_mode mode,
if (cb != NULL
&& ((*cb) (x, mode, &newx, &newmode)))
{
- hash += hash_rtx_cb (newx, newmode, do_not_record_p,
- hash_arg_in_memory_p, have_reg_qty, cb);
+ hash += hash_rtx (newx, newmode, do_not_record_p,
+ hash_arg_in_memory_p, have_reg_qty, cb);
return hash;
}
@@ -2355,9 +2368,9 @@ hash_rtx_cb (const_rtx x, machine_mode mode,
for (i = 0; i < units; ++i)
{
elt = CONST_VECTOR_ENCODED_ELT (x, i);
- hash += hash_rtx_cb (elt, GET_MODE (elt),
- do_not_record_p, hash_arg_in_memory_p,
- have_reg_qty, cb);
+ hash += hash_rtx (elt, GET_MODE (elt),
+ do_not_record_p, hash_arg_in_memory_p,
+ have_reg_qty, cb);
}
return hash;
@@ -2463,10 +2476,10 @@ hash_rtx_cb (const_rtx x, machine_mode mode,
{
for (i = 1; i < ASM_OPERANDS_INPUT_LENGTH (x); i++)
{
- hash += (hash_rtx_cb (ASM_OPERANDS_INPUT (x, i),
- GET_MODE (ASM_OPERANDS_INPUT (x, i)),
- do_not_record_p, hash_arg_in_memory_p,
- have_reg_qty, cb)
+ hash += (hash_rtx (ASM_OPERANDS_INPUT (x, i),
+ GET_MODE (ASM_OPERANDS_INPUT (x, i)),
+ do_not_record_p, hash_arg_in_memory_p,
+ have_reg_qty, cb)
+ hash_rtx_string
(ASM_OPERANDS_INPUT_CONSTRAINT (x, i)));
}
@@ -2502,16 +2515,16 @@ hash_rtx_cb (const_rtx x, machine_mode mode,
goto repeat;
}
- hash += hash_rtx_cb (XEXP (x, i), VOIDmode, do_not_record_p,
- hash_arg_in_memory_p,
- have_reg_qty, cb);
+ hash += hash_rtx (XEXP (x, i), VOIDmode, do_not_record_p,
+ hash_arg_in_memory_p,
+ have_reg_qty, cb);
break;
case 'E':
for (j = 0; j < XVECLEN (x, i); j++)
- hash += hash_rtx_cb (XVECEXP (x, i, j), VOIDmode, do_not_record_p,
- hash_arg_in_memory_p,
- have_reg_qty, cb);
+ hash += hash_rtx (XVECEXP (x, i, j), VOIDmode, do_not_record_p,
+ hash_arg_in_memory_p,
+ have_reg_qty, cb);
break;
case 's':
@@ -2538,27 +2551,6 @@ hash_rtx_cb (const_rtx x, machine_mode mode,
return hash;
}
-/* Hash an rtx. We are careful to make sure the value is never negative.
- Equivalent registers hash identically.
- MODE is used in hashing for CONST_INTs only;
- otherwise the mode of X is used.
-
- Store 1 in DO_NOT_RECORD_P if any subexpression is volatile.
-
- If HASH_ARG_IN_MEMORY_P is not NULL, store 1 in it if X contains
- a MEM rtx which does not have the MEM_READONLY_P flag set.
-
- Note that cse_insn knows that the hash code of a MEM expression
- is just (int) MEM plus the hash code of the address. */
-
-unsigned
-hash_rtx (const_rtx x, machine_mode mode, int *do_not_record_p,
- int *hash_arg_in_memory_p, bool have_reg_qty)
-{
- return hash_rtx_cb (x, mode, do_not_record_p,
- hash_arg_in_memory_p, have_reg_qty, NULL);
-}
-
/* Hash an rtx X for cse via hash_rtx.
Stores 1 in do_not_record if any subexpression is volatile.
Stores 1 in hash_arg_in_memory if X contains a mem rtx which