From a45f18948811483f1725b0125bb2f96bb50813c7 Mon Sep 17 00:00:00 2001 From: Kito Cheng Date: Wed, 15 Nov 2017 23:55:50 +0800 Subject: [PATCH] Add -mabi=ilp32e --- gcc/config.gcc | 6 ++++-- gcc/config/riscv/riscv-c.c | 1 + gcc/config/riscv/riscv-opts.h | 1 + gcc/config/riscv/riscv.c | 17 +++++++++++------ gcc/config/riscv/riscv.h | 8 +++++--- gcc/config/riscv/riscv.opt | 3 +++ 6 files changed, 25 insertions(+), 11 deletions(-) diff --git a/gcc/config.gcc b/gcc/config.gcc index 32d517554965..46e61a43f998 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -4041,6 +4041,7 @@ case "${target}" in "") # Infer XLEN, but otherwise assume GC. case "${with_abi}" in + ilp32e) with_arch="rv32e" ;; ilp32 | ilp32f | ilp32d) with_arch="rv32gc" ;; lp64 | lp64f | lp64d) with_arch="rv64gc" ;; *) with_arch="rv${xlen}gc" ;; @@ -4056,11 +4057,12 @@ case "${target}" in # pick a default based on the ISA, preferring soft-float # unless the D extension is present. case "${with_abi}" in - ilp32 | ilp32f | ilp32d | lp64 | lp64f | lp64d) + ilp32 | ilp32f | ilp32d | lp64 | lp64f | lp64d | lp64q) ;; "") case "${with_arch}" in rv32*d* | rv32g*) with_abi=ilp32d ;; + rv32e*) with_abi=ilp32e ;; rv32*) with_abi=ilp32 ;; rv64*d* | rv64g*) with_abi=lp64d ;; rv64*) with_abi=lp64 ;; @@ -4074,7 +4076,7 @@ case "${target}" in # Make sure ABI and ISA are compatible. case "${with_abi},${with_arch}" in - ilp32,rv32* \ + ilp32,rv32* | ilp32e,rv32e* \ | ilp32f,rv32*f* | ilp32f,rv32g* \ | ilp32d,rv32*d* | ilp32d,rv32g* \ | lp64,rv64* \ diff --git a/gcc/config/riscv/riscv-c.c b/gcc/config/riscv/riscv-c.c index 8bcc6b4e96b2..368b9a984553 100644 --- a/gcc/config/riscv/riscv-c.c +++ b/gcc/config/riscv/riscv-c.c @@ -63,6 +63,7 @@ riscv_cpu_cpp_builtins (cpp_reader *pfile) switch (riscv_abi) { case ABI_ILP32: + case ABI_ILP32E: case ABI_LP64: builtin_define ("__riscv_float_abi_soft"); break; diff --git a/gcc/config/riscv/riscv-opts.h b/gcc/config/riscv/riscv-opts.h index 2b19233379c0..b779e8bc23e5 100644 --- a/gcc/config/riscv/riscv-opts.h +++ b/gcc/config/riscv/riscv-opts.h @@ -23,6 +23,7 @@ along with GCC; see the file COPYING3. If not see enum riscv_abi_type { ABI_ILP32, + ABI_ILP32E, ABI_ILP32F, ABI_ILP32D, ABI_LP64, diff --git a/gcc/config/riscv/riscv.c b/gcc/config/riscv/riscv.c index 920afd7fb96f..73b8fad8c976 100644 --- a/gcc/config/riscv/riscv.c +++ b/gcc/config/riscv/riscv.c @@ -3998,6 +3998,9 @@ riscv_option_override (void) error ("requested ABI requires -march to subsume the %qc extension", UNITS_PER_FP_ARG > 8 ? 'Q' : (UNITS_PER_FP_ARG > 4 ? 'D' : 'F')); + if (TARGET_RVE && riscv_abi != ABI_ILP32E) + error ("rv32e requires ilp32e ABI"); + /* We do not yet support ILP32 on RV64. */ if (BITS_PER_WORD != POINTER_SIZE) error ("ABI requires -march=rv%d", POINTER_SIZE); @@ -4025,12 +4028,14 @@ riscv_conditional_register_usage (void) /* We have only x0~x15 on RV32E. */ if (TARGET_RVE) { - int r; - for (r = 16; r <= 31; r++) - { - fixed_regs[r] = 1; - call_used_regs[r] = call_really_used_regs[r] = 1; - } + for (int r = 16; r <= 31; r++) + fixed_regs[r] = 1; + } + + if (riscv_abi == ABI_ILP32E) + { + for (int r = 16; r <= 31; r++) + call_used_regs[r] = 1; } if (!TARGET_HARD_FLOAT) diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h index 192ddc090a23..6ec9a55e7c32 100644 --- a/gcc/config/riscv/riscv.h +++ b/gcc/config/riscv/riscv.h @@ -102,9 +102,11 @@ along with GCC; see the file COPYING3. If not see #define UNITS_PER_FP_REG (TARGET_DOUBLE_FLOAT ? 8 : 4) /* The largest type that can be passed in floating-point registers. */ -#define UNITS_PER_FP_ARG \ - (riscv_abi == ABI_ILP32 || riscv_abi == ABI_LP64 ? 0 : \ - riscv_abi == ABI_ILP32F || riscv_abi == ABI_LP64F ? 4 : 8) \ +#define UNITS_PER_FP_ARG \ + ((riscv_abi == ABI_ILP32 || riscv_abi == ABI_ILP32E \ + || riscv_abi == ABI_LP64) \ + ? 0 \ + : ((riscv_abi == ABI_ILP32F || riscv_abi == ABI_LP64F) ? 4 : 8)) /* Set the sizes of the core types. */ #define SHORT_TYPE_SIZE 16 diff --git a/gcc/config/riscv/riscv.opt b/gcc/config/riscv/riscv.opt index 5cb7ada8b510..00773c21c5b2 100644 --- a/gcc/config/riscv/riscv.opt +++ b/gcc/config/riscv/riscv.opt @@ -44,6 +44,9 @@ Supported ABIs (for use with the -mabi= option): EnumValue Enum(abi_type) String(ilp32) Value(ABI_ILP32) +EnumValue +Enum(abi_type) String(ilp32e) Value(ABI_ILP32E) + EnumValue Enum(abi_type) String(ilp32f) Value(ABI_ILP32F)