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

Ilia Diachkov ilia.diachkov@optimitech.com
Wed Jun 26 22:34:00 GMT 2019


>> 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.
> 
> It's actually worse: in RISC-V "word" always means 32-bit 
> (BITS_PER_WORD is a
> GCC name).  "natural" seems like a good term for the "align to the size 
> of the
> type".  The RISC-V term for "the width of an integer register" is 
> "xlen", so I
> think that's a good bet for the other 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 and Palmer. I have updated the patch (see attached) by 
new option values "natural" and "xlen". Also I have added macro 
RISCV_EXPAND_ALIGNMENT similar to one implemented in ARM.

> Additionally, has this been tested with "-mstrict-align"?  The 
> generated code
> can be awful, but if it's not correct then we should throw an error on 
> that
> combination.

I have tested the new option with -mstrict-align and found no influence 
on each other. Indeed, -malign-data=xlen with -mstrict-align works in 
the same way as you run the current gcc with -mstrict-align. What about 
-malign-data=natural with -mstrict-align, I have tested it by dejagnu 
with modified target_board which additionally passes 
-malign-data=natural (the first run) and -malign-data=natural with 
-mstrict-align (the second run). Both runs shown the same result.

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 (RISCV_EXPAND_ALIGNMENT): Added.
	(DATA_ALIGNMENT): Use RISCV_EXPAND_ALIGNMENT.
	(LOCAL_ALIGNMENT): Use RISCV_EXPAND_ALIGNMENT.
	* config/riscv/riscv.opt (malign-data): New.
	* doc/invoke.texi (RISC-V Options): Document -malign-data=.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-RISC-V-Add-malign-data-option.patch
Type: text/x-diff
Size: 5186 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20190626/07d882c0/attachment.bin>


More information about the Gcc-patches mailing list