[PATCH, GCC/ARM, 3/10] Save/restore FPCXTNS in nsentry functions
authorMihail Ionescu <mihail.ionescu@arm.com>
Wed, 15 Jan 2020 10:33:52 +0000 (10:33 +0000)
committerMihail Ionescu <mihail.ionescu@arm.com>
Thu, 16 Jan 2020 15:11:15 +0000 (15:11 +0000)
commite0e4be48a9892195f11d1b608793c3a30b640f54
treec76fd00b5769275e5ef1d80ce7f812d711acf098
parente27cf2e372651997c3b46a5662dd4d47c53dd13b
[PATCH, GCC/ARM, 3/10] Save/restore FPCXTNS in nsentry functions

This patch consists mainly of creating 2 new instruction patterns to
push and pop special FP registers via vldm and vstr and using them in
prologue and epilogue. The patterns are defined as push/pop with an
unspecified operation on the memory accessed, with an unspecified
constant indicating what special FP register is being saved/restored.

Other aspects of the patch include:
  * defining the set of special registers that can be saved/restored and
    their name
  * reserving space in the stack frames for these push/pop
  * preventing return via pop
  * guarding the clearing of FPSCR to target architecture not having
    Armv8.1-M Mainline instructions.

*** gcc/ChangeLog ***

2020-01-16  Mihail-Calin Ionescu  <mihail.ionescu@arm.com>
2020-01-16  Thomas Preud'homme  <thomas.preudhomme@arm.com>

* config/arm/arm.c (fp_sysreg_names): Declare and define.
(use_return_insn): Also return false for Armv8.1-M Mainline.
(output_return_instruction): Skip FPSCR clearing if Armv8.1-M
Mainline instructions are available.
(arm_compute_frame_layout): Allocate space in frame for FPCXTNS
when targeting Armv8.1-M Mainline Security Extensions.
(arm_expand_prologue): Save FPCXTNS if this is an Armv8.1-M
Mainline entry function.
(cmse_nonsecure_entry_clear_before_return): Clear IP and r4 if
targeting Armv8.1-M Mainline or successor.
(arm_expand_epilogue): Fix indentation of caller-saved register
clearing.  Restore FPCXTNS if this is an Armv8.1-M Mainline
entry function.
* config/arm/arm.h (TARGET_HAVE_FP_CMSE): New macro.
(FP_SYSREGS): Likewise.
(enum vfp_sysregs_encoding): Define enum.
(fp_sysreg_names): Declare.
* config/arm/unspecs.md (VUNSPEC_VSTR_VLDR): New volatile unspec.
* config/arm/vfp.md (push_fpsysreg_insn): New define_insn.
(pop_fpsysreg_insn): Likewise.

*** gcc/testsuite/Changelog ***

2020-01-16  Mihail-Calin Ionescu  <mihail.ionescu@arm.com>
2020-01-16  Thomas Preud'homme  <thomas.preudhomme@arm.com>

* gcc.target/arm/cmse/bitfield-1.c: add checks for VSTR and VLDR.
* gcc.target/arm/cmse/bitfield-2.c: Likewise.
* gcc.target/arm/cmse/bitfield-3.c: Likewise.
* gcc.target/arm/cmse/cmse-1.c: Likewise.
* gcc.target/arm/cmse/struct-1.c: Likewise.
* gcc.target/arm/cmse/cmse.exp: Run existing Armv8-M Mainline tests
from mainline/8m subdirectory and new Armv8.1-M Mainline tests from
mainline/8_1m subdirectory.
* gcc.target/arm/cmse/mainline/bitfield-4.c: Move into ...
* gcc.target/arm/cmse/mainline/8m/bitfield-4.c: This.
* gcc.target/arm/cmse/mainline/bitfield-5.c: Move into ...
* gcc.target/arm/cmse/mainline/8m/bitfield-5.c: This.
* gcc.target/arm/cmse/mainline/bitfield-6.c: Move into ...
* gcc.target/arm/cmse/mainline/8m/bitfield-6.c: This.
* gcc.target/arm/cmse/mainline/bitfield-7.c: Move into ...
* gcc.target/arm/cmse/mainline/8m/bitfield-7.c: This.
* gcc.target/arm/cmse/mainline/bitfield-8.c: Move into ...
* gcc.target/arm/cmse/mainline/8m/bitfield-8.c: This.
* gcc.target/arm/cmse/mainline/bitfield-9.c: Move into ...
* gcc.target/arm/cmse/mainline/8m/bitfield-9.c: This.
* gcc.target/arm/cmse/mainline/bitfield-and-union-1.c: Move and rename
into ...
* gcc.target/arm/cmse/mainline/8m/bitfield-and-union.c: This.
* gcc.target/arm/cmse/mainline/hard-sp/cmse-13.c: Move into ...
* gcc.target/arm/cmse/mainline/8m/hard-sp/cmse-13.c: This.  Clean up
dg-skip-if directive for float ABI.
* gcc.target/arm/cmse/mainline/hard-sp/cmse-5.c: Move into ...
* gcc.target/arm/cmse/mainline/8m/hard-sp/cmse-5.c: This.  Clean up
dg-skip-if directive for float ABI.
* gcc.target/arm/cmse/mainline/hard-sp/cmse-7.c: Move into ...
* gcc.target/arm/cmse/mainline/8m/hard-sp/cmse-7.c: This.  Clean up
dg-skip-if directive for float ABI.
* gcc.target/arm/cmse/mainline/hard-sp/cmse-8.c: Move into ...
* gcc.target/arm/cmse/mainline/8m/hard-sp/cmse-8.c: This.  Clean up
dg-skip-if directive for float ABI.
* gcc.target/arm/cmse/mainline/hard/cmse-13.c: Move into ...
* gcc.target/arm/cmse/mainline/8m/hard/cmse-13.c: This.  Clean up
dg-skip-if directive for float ABI.
* gcc.target/arm/cmse/mainline/hard/cmse-5.c: Move into ...
* gcc.target/arm/cmse/mainline/8m/hard/cmse-5.c: This.  Clean up
dg-skip-if directive for float ABI.
* gcc.target/arm/cmse/mainline/hard/cmse-7.c: Move into ...
* gcc.target/arm/cmse/mainline/8m/hard/cmse-7.c: This.  Clean up
dg-skip-if directive for float ABI.
* gcc.target/arm/cmse/mainline/hard/cmse-8.c: Move into ...
* gcc.target/arm/cmse/mainline/8m/hard/cmse-8.c: This.  Clean up
dg-skip-if directive for float ABI.
* gcc.target/arm/cmse/mainline/soft/cmse-13.c: Move into ...
* gcc.target/arm/cmse/mainline/8m/soft/cmse-13.c: This.  Clean up
dg-skip-if directive for float ABI.
* gcc.target/arm/cmse/mainline/soft/cmse-5.c: Move into ...
* gcc.target/arm/cmse/mainline/8m/soft/cmse-5.c: This.  Clean up
dg-skip-if directive for float ABI.
* gcc.target/arm/cmse/mainline/soft/cmse-7.c: Move into ...
* gcc.target/arm/cmse/mainline/8m/soft/cmse-7.c: This.  Clean up
dg-skip-if directive for float ABI.
* gcc.target/arm/cmse/mainline/soft/cmse-8.c: Move into ...
* gcc.target/arm/cmse/mainline/8m/soft/cmse-8.c: This.  Clean up
dg-skip-if directive for float ABI.
* gcc.target/arm/cmse/mainline/softfp-sp/cmse-5.c: Move into ...
* gcc.target/arm/cmse/mainline/8m/softfp-sp/cmse-5.c: This.  Clean up
dg-skip-if directive for float ABI.
* gcc.target/arm/cmse/mainline/softfp-sp/cmse-7.c: Move into ...
* gcc.target/arm/cmse/mainline/8m/softfp-sp/cmse-7.c: This.  Clean up
dg-skip-if directive for float ABI.
* gcc.target/arm/cmse/mainline/softfp-sp/cmse-8.c: Move into ...
* gcc.target/arm/cmse/mainline/8m/softfp-sp/cmse-8.c: This.  Clean up
dg-skip-if directive for float ABI.
* gcc.target/arm/cmse/mainline/softfp/cmse-13.c: Move into ...
* gcc.target/arm/cmse/mainline/8m/softfp/cmse-13.c: This.  Clean up
dg-skip-if directive for float ABI.
* gcc.target/arm/cmse/mainline/softfp/cmse-5.c: Move into ...
* gcc.target/arm/cmse/mainline/8m/softfp/cmse-5.c: This.  Clean up
dg-skip-if directive for float ABI.
* gcc.target/arm/cmse/mainline/softfp/cmse-7.c: Move into ...
* gcc.target/arm/cmse/mainline/8m/softfp/cmse-7.c: This.  Clean up
dg-skip-if directive for float ABI.
* gcc.target/arm/cmse/mainline/softfp/cmse-8.c: Move into ...
* gcc.target/arm/cmse/mainline/8m/softfp/cmse-8.c: This.  Clean up
dg-skip-if directive for float ABI.
* gcc.target/arm/cmse/mainline/union-1.c: Move into ...
* gcc.target/arm/cmse/mainline/8m/union-1.c: This.
* gcc.target/arm/cmse/mainline/union-2.c: Move into ...
* gcc.target/arm/cmse/mainline/8m/union-2.c: This.
* gcc.target/arm/cmse/mainline/8_1m/bitfield-4.c: New file.
* gcc.target/arm/cmse/mainline/8_1m/bitfield-5.c: New file.
* gcc.target/arm/cmse/mainline/8_1m/bitfield-6.c: New file.
* gcc.target/arm/cmse/mainline/8_1m/bitfield-7.c: New file.
* gcc.target/arm/cmse/mainline/8_1m/bitfield-8.c: New file.
* gcc.target/arm/cmse/mainline/8_1m/bitfield-9.c: New file.
* gcc.target/arm/cmse/mainline/8_1m/bitfield-and-union.c: New file.
* gcc.target/arm/cmse/mainline/8_1m/hard-sp/cmse-13.c: New file.
* gcc.target/arm/cmse/mainline/8_1m/hard-sp/cmse-5.c: New file.
* gcc.target/arm/cmse/mainline/8_1m/hard-sp/cmse-7.c: New file.
* gcc.target/arm/cmse/mainline/8_1m/hard-sp/cmse-8.c: New file.
* gcc.target/arm/cmse/mainline/8_1m/hard/cmse-13.c: New file.
* gcc.target/arm/cmse/mainline/8_1m/hard/cmse-5.c: New file.
* gcc.target/arm/cmse/mainline/8_1m/hard/cmse-7.c: New file.
* gcc.target/arm/cmse/mainline/8_1m/hard/cmse-8.c: New file.
* gcc.target/arm/cmse/mainline/8_1m/soft/cmse-13.c: New file.
* gcc.target/arm/cmse/mainline/8_1m/soft/cmse-5.c: New file.
* gcc.target/arm/cmse/mainline/8_1m/soft/cmse-7.c: New file.
* gcc.target/arm/cmse/mainline/8_1m/soft/cmse-8.c: New file.
* gcc.target/arm/cmse/mainline/8_1m/softfp-sp/cmse-5.c: New file.
* gcc.target/arm/cmse/mainline/8_1m/softfp-sp/cmse-7.c: New file.
* gcc.target/arm/cmse/mainline/8_1m/softfp-sp/cmse-8.c: New file.
* gcc.target/arm/cmse/mainline/8_1m/softfp/cmse-13.c: New file.
* gcc.target/arm/cmse/mainline/8_1m/softfp/cmse-5.c: New file.
* gcc.target/arm/cmse/mainline/8_1m/softfp/cmse-7.c: New file.
* gcc.target/arm/cmse/mainline/8_1m/softfp/cmse-8.c: New file.
* gcc.target/arm/cmse/mainline/8_1m/union-1.c: New file.
* gcc.target/arm/cmse/mainline/8_1m/union-2.c: New file.
* lib/target-supports.exp (check_effective_target_arm_cmse_clear_ok):
New procedure.
97 files changed:
gcc/ChangeLog
gcc/config/arm/arm.c
gcc/config/arm/arm.h
gcc/config/arm/unspecs.md
gcc/config/arm/vfp.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/arm/cmse/bitfield-1.c
gcc/testsuite/gcc.target/arm/cmse/bitfield-2.c
gcc/testsuite/gcc.target/arm/cmse/bitfield-3.c
gcc/testsuite/gcc.target/arm/cmse/cmse-1.c
gcc/testsuite/gcc.target/arm/cmse/cmse.exp
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/bitfield-4.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/bitfield-5.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/bitfield-6.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/bitfield-7.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/bitfield-8.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/bitfield-9.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/bitfield-and-union.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/hard-sp/cmse-13.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/hard-sp/cmse-5.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/hard-sp/cmse-7.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/hard-sp/cmse-8.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/hard/cmse-13.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/hard/cmse-5.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/hard/cmse-7.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/hard/cmse-8.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/soft/cmse-13.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/soft/cmse-5.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/soft/cmse-7.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/soft/cmse-8.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/softfp-sp/cmse-5.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/softfp-sp/cmse-7.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/softfp-sp/cmse-8.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/softfp/cmse-13.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/softfp/cmse-5.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/softfp/cmse-7.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/softfp/cmse-8.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/union-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/union-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8m/bitfield-4.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8m/bitfield-5.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8m/bitfield-6.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8m/bitfield-7.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8m/bitfield-8.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8m/bitfield-9.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8m/bitfield-and-union.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8m/hard-sp/cmse-13.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8m/hard-sp/cmse-5.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8m/hard-sp/cmse-7.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8m/hard-sp/cmse-8.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8m/hard/cmse-13.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8m/hard/cmse-5.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8m/hard/cmse-7.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8m/hard/cmse-8.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8m/soft/cmse-13.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8m/soft/cmse-5.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8m/soft/cmse-7.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8m/soft/cmse-8.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8m/softfp-sp/cmse-5.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8m/softfp-sp/cmse-7.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8m/softfp-sp/cmse-8.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8m/softfp/cmse-13.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8m/softfp/cmse-5.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8m/softfp/cmse-7.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8m/softfp/cmse-8.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8m/union-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/8m/union-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/cmse/mainline/bitfield-4.c [deleted file]
gcc/testsuite/gcc.target/arm/cmse/mainline/bitfield-5.c [deleted file]
gcc/testsuite/gcc.target/arm/cmse/mainline/bitfield-6.c [deleted file]
gcc/testsuite/gcc.target/arm/cmse/mainline/bitfield-7.c [deleted file]
gcc/testsuite/gcc.target/arm/cmse/mainline/bitfield-8.c [deleted file]
gcc/testsuite/gcc.target/arm/cmse/mainline/bitfield-9.c [deleted file]
gcc/testsuite/gcc.target/arm/cmse/mainline/bitfield-and-union.c [deleted file]
gcc/testsuite/gcc.target/arm/cmse/mainline/hard-sp/cmse-13.c [deleted file]
gcc/testsuite/gcc.target/arm/cmse/mainline/hard-sp/cmse-5.c [deleted file]
gcc/testsuite/gcc.target/arm/cmse/mainline/hard-sp/cmse-7.c [deleted file]
gcc/testsuite/gcc.target/arm/cmse/mainline/hard-sp/cmse-8.c [deleted file]
gcc/testsuite/gcc.target/arm/cmse/mainline/hard/cmse-13.c [deleted file]
gcc/testsuite/gcc.target/arm/cmse/mainline/hard/cmse-5.c [deleted file]
gcc/testsuite/gcc.target/arm/cmse/mainline/hard/cmse-7.c [deleted file]
gcc/testsuite/gcc.target/arm/cmse/mainline/hard/cmse-8.c [deleted file]
gcc/testsuite/gcc.target/arm/cmse/mainline/soft/cmse-13.c [deleted file]
gcc/testsuite/gcc.target/arm/cmse/mainline/soft/cmse-5.c [deleted file]
gcc/testsuite/gcc.target/arm/cmse/mainline/soft/cmse-7.c [deleted file]
gcc/testsuite/gcc.target/arm/cmse/mainline/soft/cmse-8.c [deleted file]
gcc/testsuite/gcc.target/arm/cmse/mainline/softfp-sp/cmse-5.c [deleted file]
gcc/testsuite/gcc.target/arm/cmse/mainline/softfp-sp/cmse-7.c [deleted file]
gcc/testsuite/gcc.target/arm/cmse/mainline/softfp-sp/cmse-8.c [deleted file]
gcc/testsuite/gcc.target/arm/cmse/mainline/softfp/cmse-13.c [deleted file]
gcc/testsuite/gcc.target/arm/cmse/mainline/softfp/cmse-5.c [deleted file]
gcc/testsuite/gcc.target/arm/cmse/mainline/softfp/cmse-7.c [deleted file]
gcc/testsuite/gcc.target/arm/cmse/mainline/softfp/cmse-8.c [deleted file]
gcc/testsuite/gcc.target/arm/cmse/mainline/union-1.c [deleted file]
gcc/testsuite/gcc.target/arm/cmse/mainline/union-2.c [deleted file]
gcc/testsuite/gcc.target/arm/cmse/struct-1.c
gcc/testsuite/lib/target-supports.exp