[PATCH] RISC-V: Add -malign-data= option.

Andrew Pinski pinskia@gmail.com
Tue Jun 25 22:59:00 GMT 2019


On Tue, Jun 25, 2019 at 3:46 PM Ilia Diachkov
<ilia.diachkov@optimitech.com> wrote:
>
> Hello,
>
> This patch adds new machine specific option -malign-data={word,abi} to
> RISC-V port. The option switches alignment of  global variables and
> constants of array/record/union types. The default value
> (-malign-data=word) keeps existing way of alignment computation. Another
> option value (-malign-data=abi) makes data natural alignment. It avoids
> extra spaces between data to reduce code size. The measured code size
> reduction is about 0.4% at -Os on EEMBC automotive 1.1 tests and
> SPEC2006 C/C++ benchmarks. The patch was tested in riscv-gnu-toolchain
> by dejagnu.
>
> Please check the patch into the trunk.

Hmm, may I suggest use "natural" rather than "abi" and 32bit or 64bit
rather than "word"; it is not obvious what abi means and it is not
obvious what word means here; it could be either 32bit or 64bit
depending on the option.
Also my other suggestion is create a new macro where you pass
riscv_align_data_type == riscv_align_data_type_word for the "(ALIGN) <
BITS_PER_WORD) " check to reduce the code duplication.

Thanks,
Andrew Pinski

>
> Best regards,
> Ilia.
>
> gcc/
>         * config/riscv/riscv-opts.h (struct riscv_align_data): Added.
>         * config/riscv/riscv.c (riscv_constant_alignment): Use
> riscv_align_data_type.
>         * config/riscv/riscv.h (DATA_ALIGNMENT): Use riscv_align_data_type.
>         (LOCAL_ALIGNMENT): Set to old DATA_ALIGNMENT value.
>         * config/riscv/riscv.opt (malign-data): New.
>         * doc/invoke.texi (RISC-V Options): Document -malign-data=.



More information about the Gcc-patches mailing list