[ARM] Factor out CMSE register clearing code

Programming / Compilers / GCC - thopre01 [138bc75d-0d04-0410-961f-82ee72b054a4] - 22 November 2017 15:58 EST

Functions cmse_nonsecure_call_clear_caller_saved and cmse_nonsecure_entry_clear_before_return both contain very similar code to clear registers. What's worse, they differ slightly at times so if a bug is found in one careful thoughts is needed to decide whether the other function needs fixing too.

This commit addresses the situation by factoring the two pieces of code into a new function. In doing so the code generated to clear VFP registers in cmse_nonsecure_call now uses the same sequence as cmse_nonsecure_entry functions. Tests expectation are thus updated accordingly.

2017-11-22 Thomas Preud'homme

gcc/
- config/arm/arm.c (cmse_clear_registers): New function. (cmse_nonsecure_call_clear_caller_saved): Replace register clearing code by call to cmse_clear_registers. (cmse_nonsecure_entry_clear_before_return): Likewise.

gcc/testsuite/
- gcc.target/arm/cmse/mainline/hard-sp/cmse-13.c: Adapt expectations to vmov instructions now generated.
- gcc.target/arm/cmse/mainline/hard-sp/cmse-7.c: Likewise.
- gcc.target/arm/cmse/mainline/hard-sp/cmse-8.c: Likewise.
- gcc.target/arm/cmse/mainline/hard/cmse-13.c: Likewise.
- gcc.target/arm/cmse/mainline/hard/cmse-7.c: Likewise.
- gcc.target/arm/cmse/mainline/hard/cmse-8.c: Likewise.

9b5945c3f65 [ARM] Factor out CMSE register clearing code
gcc/ChangeLog | 7 +
gcc/config/arm/arm.c | 283 +++++++++++----------
gcc/testsuite/ChangeLog | 10 +
.../gcc.target/arm/cmse/mainline/hard-sp/cmse-13.c | 32 +--
.../gcc.target/arm/cmse/mainline/hard-sp/cmse-7.c | 32 +--
.../gcc.target/arm/cmse/mainline/hard-sp/cmse-8.c | 32 +--
.../gcc.target/arm/cmse/mainline/hard/cmse-13.c | 24 +-
.../gcc.target/arm/cmse/mainline/hard/cmse-7.c | 16 +-
.../gcc.target/arm/cmse/mainline/hard/cmse-8.c | 16 +-
9 files changed, 235 insertions(+), 217 deletions(-)

Upstream: gcc.gnu.org


  • Share