diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6453b26584b..d4d61a0cdba 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2018-03-01 Palmer Dabbelt + + * config/riscv/riscv.opt (mrelax): New option. + * config/riscv/riscv.c (riscv_file_start): Emit ".option + "norelax" when riscv_mrelax is disabled. + * doc/invoke.texi (RISC-V): Document "-mrelax" and "-mno-relax". + 2018-03-13 Aaron Sawdey PR target/84743 diff --git a/gcc/config/riscv/riscv.c b/gcc/config/riscv/riscv.c index c38f6c394d5..3e81874de23 100644 --- a/gcc/config/riscv/riscv.c +++ b/gcc/config/riscv/riscv.c @@ -3979,6 +3979,11 @@ riscv_file_start (void) /* Instruct GAS to generate position-[in]dependent code. */ fprintf (asm_out_file, "\t.option %spic\n", (flag_pic ? "" : "no")); + + /* If the user specifies "-mno-relax" on the command line then disable linker + relaxation in the assembler. */ + if (! riscv_mrelax) + fprintf (asm_out_file, "\t.option norelax\n"); } /* Implement TARGET_ASM_OUTPUT_MI_THUNK. Generate rtl rather than asm text diff --git a/gcc/config/riscv/riscv.opt b/gcc/config/riscv/riscv.opt index 581a26bb5c1..b37ac75d9bb 100644 --- a/gcc/config/riscv/riscv.opt +++ b/gcc/config/riscv/riscv.opt @@ -106,6 +106,11 @@ mexplicit-relocs Target Report Mask(EXPLICIT_RELOCS) Use %reloc() operators, rather than assembly macros, to load addresses. +mrelax +Target Bool Var(riscv_mrelax) Init(1) +Take advantage of linker relaxations to reduce the number of instructions +required to materialize symbol addresses. + Mask(64BIT) Mask(MUL) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 5d383509797..4d543008f53 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -1042,7 +1042,8 @@ See RS/6000 and PowerPC Options. -msave-restore -mno-save-restore @gol -mstrict-align -mno-strict-align @gol -mcmodel=medlow -mcmodel=medany @gol --mexplicit-relocs -mno-explicit-relocs @gol} +-mexplicit-relocs -mno-explicit-relocs @gol +-mrelax -mno-relax @gol} @emph{RL78 Options} @gccoptlist{-msim -mmul=none -mmul=g13 -mmul=g14 -mallregs @gol @@ -23102,6 +23103,12 @@ Use or do not use assembler relocation operators when dealing with symbolic addresses. The alternative is to use assembler macros instead, which may limit optimization. +@item -mrelax +@itemx -mno-relax +Take advantage of linker relaxations to reduce the number of instructions +required to materialize symbol addresses. The default is to take advantage of +linker relaxations. + @end table @node RL78 Options