diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2023-12-05 09:28:46 +0000 |
---|---|---|
committer | Richard Sandiford <richard.sandiford@arm.com> | 2023-12-05 09:28:46 +0000 |
commit | e9d2ae6b9816e61a6148040149c63faa83f54702 (patch) | |
tree | 11bc5ccc60085aacb63ff083613fa697ed43ca27 /gcc/function.cc | |
parent | f542df026cd24e604eb40426a83ce072ef34e15a (diff) | |
download | gcc-e9d2ae6b9816e61a6148040149c63faa83f54702.zip gcc-e9d2ae6b9816e61a6148040149c63faa83f54702.tar.gz gcc-e9d2ae6b9816e61a6148040149c63faa83f54702.tar.bz2 |
Allow prologues and epilogues to be inserted later
Arm's SME adds a new processor mode called streaming mode.
This mode enables some new (matrix-oriented) instructions and
disables several existing groups of instructions, such as most
Advanced SIMD vector instructions and a much smaller set of SVE
instructions. It can also change the current vector length.
There are instructions to switch in and out of streaming mode.
However, their effect on the ISA and vector length can't be represented
directly in RTL, so they need to be emitted late in the pass pipeline,
close to md_reorg.
It's sometimes the responsibility of the prologue and epilogue to
switch modes, which means we need to emit the prologue and epilogue
sequences late as well. (This loses shrink-wrapping and scheduling
opportunities, but that's a price worth paying.)
This patch therefore adds a target hook for forcing prologue
and epilogue insertion to happen later in the pipeline.
gcc/
* target.def (use_late_prologue_epilogue): New hook.
* doc/tm.texi.in: Add TARGET_USE_LATE_PROLOGUE_EPILOGUE.
* doc/tm.texi: Regenerate.
* passes.def (pass_late_thread_prologue_and_epilogue): New pass.
* tree-pass.h (make_pass_late_thread_prologue_and_epilogue): Declare.
* function.cc (pass_thread_prologue_and_epilogue::gate): New function.
(pass_data_late_thread_prologue_and_epilogue): New pass variable.
(pass_late_thread_prologue_and_epilogue): New pass class.
(make_pass_late_thread_prologue_and_epilogue): New function.
Diffstat (limited to 'gcc/function.cc')
-rw-r--r-- | gcc/function.cc | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/gcc/function.cc b/gcc/function.cc index 527ea48..7049301 100644 --- a/gcc/function.cc +++ b/gcc/function.cc @@ -84,6 +84,7 @@ along with GCC; see the file COPYING3. If not see #include "function-abi.h" #include "value-range.h" #include "gimple-range.h" +#include "insn-attr.h" /* So we can assign to cfun in this file. */ #undef cfun @@ -6629,6 +6630,11 @@ public: {} /* opt_pass methods: */ + bool gate (function *) final override + { + return !targetm.use_late_prologue_epilogue (); + } + unsigned int execute (function * fun) final override { rest_of_handle_thread_prologue_and_epilogue (fun); @@ -6637,6 +6643,44 @@ public: }; // class pass_thread_prologue_and_epilogue +const pass_data pass_data_late_thread_prologue_and_epilogue = +{ + RTL_PASS, /* type */ + "late_pro_and_epilogue", /* name */ + OPTGROUP_NONE, /* optinfo_flags */ + TV_THREAD_PROLOGUE_AND_EPILOGUE, /* tv_id */ + 0, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + ( TODO_df_verify | TODO_df_finish ), /* todo_flags_finish */ +}; + +class pass_late_thread_prologue_and_epilogue : public rtl_opt_pass +{ +public: + pass_late_thread_prologue_and_epilogue (gcc::context *ctxt) + : rtl_opt_pass (pass_data_late_thread_prologue_and_epilogue, ctxt) + {} + + /* opt_pass methods: */ + bool gate (function *) final override + { + return targetm.use_late_prologue_epilogue (); + } + + unsigned int execute (function *fn) final override + { + /* It's not currently possible to have both delay slots and + late prologue/epilogue, since the latter has to run before + the former, and the former won't honor whatever restrictions + the latter is trying to enforce. */ + gcc_assert (!DELAY_SLOTS); + rest_of_handle_thread_prologue_and_epilogue (fn); + return 0; + } +}; // class pass_late_thread_prologue_and_epilogue + } // anon namespace rtl_opt_pass * @@ -6645,6 +6689,12 @@ make_pass_thread_prologue_and_epilogue (gcc::context *ctxt) return new pass_thread_prologue_and_epilogue (ctxt); } +rtl_opt_pass * +make_pass_late_thread_prologue_and_epilogue (gcc::context *ctxt) +{ + return new pass_late_thread_prologue_and_epilogue (ctxt); +} + namespace { const pass_data pass_data_zero_call_used_regs = |