aboutsummaryrefslogtreecommitdiff
path: root/gcc/recog.h
diff options
context:
space:
mode:
authorAlex Coplan <alex.coplan@arm.com>2023-12-15 09:31:28 +0000
committerAlex Coplan <alex.coplan@arm.com>2023-12-15 09:35:45 +0000
commitbac33a522bb51e30729191e935f25c2b0a63e225 (patch)
treec24f0468433e99b13bf8278159abd25bd1d982d8 /gcc/recog.h
parent91e9e8faea4086b3b8aef2355fc12c1559d425f6 (diff)
downloadgcc-bac33a522bb51e30729191e935f25c2b0a63e225.zip
gcc-bac33a522bb51e30729191e935f25c2b0a63e225.tar.gz
gcc-bac33a522bb51e30729191e935f25c2b0a63e225.tar.bz2
emit-rtl, lra: Move lra's emit_inc to emit-rtl.cc
In PR112906 we ICE because we try to use force_reg to reload an auto-increment address, but force_reg can't do this. With the aim of fixing the PR by supporting reloading arbitrary addresses in pre-RA splitters, this patch generalizes lra-constraints.cc:emit_inc and makes it available to the rest of the compiler by moving the generalized version to emit-rtl.cc. We observe that the separate IN parameter to LRA's emit_inc is redundant, since the function is static and is only (statically) called once in lra-constraints.cc, with in == value. As such, we drop the IN parameter and simplify the code accordingly. We wrap the emit_inc code in a virtual class to allow LRA to override how reload pseudos are created, thereby preserving the existing LRA behaviour as much as possible. We then add a second (higher-level) routine to emit-rtl.cc, force_reload_address, which can reload arbitrary addresses. This uses the generalized emit_inc code to handle the RTX_AUTOINC case. The second patch in this series uses force_reload_address to fix PR112906. Since we intend to call address_reload_context::emit_autoinc from within splitters, and the code lifted from LRA calls recog, we have to avoid clobbering recog_data. We do this by introducing a new RAII class for saving/restoring recog_data on the stack. gcc/ChangeLog: PR target/112906 * emit-rtl.cc (address_reload_context::emit_autoinc): New. (force_reload_address): New. * emit-rtl.h (struct address_reload_context): Declare. (force_reload_address): Declare. * lra-constraints.cc (class lra_autoinc_reload_context): New. (emit_inc): Drop IN parameter, invoke code moved to emit-rtl.cc:address_reload_context::emit_autoinc. (curr_insn_transform): Drop redundant IN parameter in call to emit_inc. * recog.h (class recog_data_saver): New.
Diffstat (limited to 'gcc/recog.h')
-rw-r--r--gcc/recog.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/recog.h b/gcc/recog.h
index 5c801e7..bf0b809 100644
--- a/gcc/recog.h
+++ b/gcc/recog.h
@@ -398,6 +398,16 @@ struct recog_data_d
extern struct recog_data_d recog_data;
+/* RAII class for saving/restoring recog_data. */
+
+class recog_data_saver
+{
+ recog_data_d m_saved_data;
+public:
+ recog_data_saver () : m_saved_data (recog_data) {}
+ ~recog_data_saver () { recog_data = m_saved_data; }
+};
+
#ifndef GENERATOR_FILE
extern const operand_alternative *recog_op_alt;