Could you document -mbig-endian and -mlittle-endian in gcc/doc/invoke.texi?
On Tue, Jan 26, 2021 at 2:16 AM Marcus Comstedt <mar...@mc.pp.se> wrote: > > gcc/ > * config/riscv/elf.h (LINK_SPEC): Pass linker endianness flag. > * config/riscv/freebsd.h (LINK_SPEC): Likewise. > * config/riscv/linux.h (LINK_SPEC): Likewise. > * config/riscv/riscv.h (ASM_SPEC): Pass -mbig-endian and > -mlittle-endian. > (BYTES_BIG_ENDIAN): Handle big endian. > (WORDS_BIG_ENDIAN): Define to BYTES_BIG_ENDIAN. > * config/riscv/riscv.opt (-mbig-endian, -mlittle-endian): New > options. > --- > gcc/config/riscv/elf.h | 2 ++ > gcc/config/riscv/freebsd.h | 2 ++ > gcc/config/riscv/linux.h | 2 ++ > gcc/config/riscv/riscv.h | 6 ++++-- > gcc/config/riscv/riscv.opt | 8 ++++++++ > 5 files changed, 18 insertions(+), 2 deletions(-) > > diff --git a/gcc/config/riscv/elf.h b/gcc/config/riscv/elf.h > index d136d46e4fa..973efdaed7b 100644 > --- a/gcc/config/riscv/elf.h > +++ b/gcc/config/riscv/elf.h > @@ -20,6 +20,8 @@ along with GCC; see the file COPYING3. If not see > #define LINK_SPEC "\ > -melf" XLEN_SPEC "lriscv \ > %{mno-relax:--no-relax} \ > +%{mbig-endian:-EB} \ > +%{mlittle-endian:-EL} \ > %{shared}" > > /* Link against Newlib libraries, because the ELF backend assumes Newlib. > diff --git a/gcc/config/riscv/freebsd.h b/gcc/config/riscv/freebsd.h > index a48bf9bffe4..f3aca9f7673 100644 > --- a/gcc/config/riscv/freebsd.h > +++ b/gcc/config/riscv/freebsd.h > @@ -44,6 +44,8 @@ along with GCC; see the file COPYING3. If not see > %{p:%nconsider using `-pg' instead of `-p' with gprof (1)} \ > %{v:-V} \ > %{assert*} %{R*} %{rpath*} %{defsym*} \ > + %{mbig-endian:-EB} \ > + %{mlittle-endian:-EL} \ > %{shared:-Bshareable %{h*} %{soname*}} \ > %{symbolic:-Bsymbolic} \ > %{static:-Bstatic} \ > diff --git a/gcc/config/riscv/linux.h b/gcc/config/riscv/linux.h > index 9238de5bc92..e74f5d3f914 100644 > --- a/gcc/config/riscv/linux.h > +++ b/gcc/config/riscv/linux.h > @@ -60,6 +60,8 @@ along with GCC; see the file COPYING3. If not see > #define LINK_SPEC "\ > -melf" XLEN_SPEC "lriscv" LD_EMUL_SUFFIX " \ > %{mno-relax:--no-relax} \ > +%{mbig-endian:-EB} \ > +%{mlittle-endian:-EL} \ > %{shared} \ > %{!shared: \ > %{!static: \ > diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h > index c6f8bee07ef..0b667d2e8b9 100644 > --- a/gcc/config/riscv/riscv.h > +++ b/gcc/config/riscv/riscv.h > @@ -91,6 +91,8 @@ extern const char *riscv_default_mtune (int argc, const > char **argv); > %{" FPIE_OR_FPIC_SPEC ":-fpic} \ > %{march=*} \ > %{mabi=*} \ > +%{mbig-endian} \ > +%{mlittle-endian} \ > %(subtarget_asm_spec)" \ > ASM_MISA_SPEC > > @@ -126,8 +128,8 @@ ASM_MISA_SPEC > /* Target machine storage layout */ > > #define BITS_BIG_ENDIAN 0 > -#define BYTES_BIG_ENDIAN 0 > -#define WORDS_BIG_ENDIAN 0 > +#define BYTES_BIG_ENDIAN (TARGET_BIG_ENDIAN != 0) > +#define WORDS_BIG_ENDIAN (BYTES_BIG_ENDIAN) > > #define MAX_BITS_PER_WORD 64 > > diff --git a/gcc/config/riscv/riscv.opt b/gcc/config/riscv/riscv.opt > index 761a09d18c3..e294e223151 100644 > --- a/gcc/config/riscv/riscv.opt > +++ b/gcc/config/riscv/riscv.opt > @@ -21,6 +21,14 @@ > HeaderInclude > config/riscv/riscv-opts.h > > +mbig-endian > +Target RejectNegative Mask(BIG_ENDIAN) > +Assume target CPU is configured as big endian. > + > +mlittle-endian > +Target RejectNegative InverseMask(BIG_ENDIAN) > +Assume target CPU is configured as little endian. > + > mbranch-cost= > Target RejectNegative Joined UInteger Var(riscv_branch_cost) > -mbranch-cost=N Set the cost of branches to roughly N instructions. > -- > 2.26.2 >