RISC-V: Add -mstrict-align option
authorAndrew Waterman <andrew@sifive.com>
Fri, 5 May 2017 20:24:46 +0000 (20:24 +0000)
committerPalmer Dabbelt <palmer@gcc.gnu.org>
Fri, 5 May 2017 20:24:46 +0000 (20:24 +0000)
commit822856928407e34bc10f2aa7d00bc6149b43d7f8
tree74d82a779503a679e790d959716e3be28758d974
parent248710c431b94c250e8356211df6f82c753d7b34
RISC-V: Add -mstrict-align option

The RISC-V user ISA permits misaligned accesses, but they may trap
and be emulated.  That emulation software needs to be compiled assuming
strict alignment.

Even when strict alignment is not required, set SLOW_UNALIGNED_ACCESS
based upon -mtune to avoid a performance pitfall.

gcc/ChangeLog:

2017-05-04  Andrew Waterman  <andrew@sifive.com>

* config/riscv/riscv.opt (mstrict-align): New option.
* config/riscv/riscv.h (STRICT_ALIGNMENT): Use it.  Update comment.
(SLOW_UNALIGNED_ACCESS): Define.
(riscv_slow_unaligned_access): Declare.
* config/riscv/riscv.c (riscv_tune_info): Add slow_unaligned_access
field.
(riscv_slow_unaligned_access): New variable.
(rocket_tune_info): Set slow_unaligned_access to true.
(optimize_size_tune_info): Set slow_unaligned_access to false.
(riscv_cpu_info_table): Add entry for optimize_size_tune_info.
(riscv_valid_lo_sum_p): Use TARGET_STRICT_ALIGN.
(riscv_option_override): Set riscv_slow_unaligned_access.
        * doc/invoke.texi: Add -mstrict-align to RISC-V.

From-SVN: r247659
gcc/ChangeLog
gcc/config/riscv/riscv.c
gcc/config/riscv/riscv.h
gcc/config/riscv/riscv.opt
gcc/doc/invoke.texi