Skip to content

Commit

Permalink
RISC-V: Introduce the -mlong-double-{64,128} option
Browse files Browse the repository at this point in the history
Similarly to some other targets, this patch adds the ability to
change the size of long double.  This is to support the ABI deviation
permitting long double to be 64-bit wide.

Add a testcase checking that, whenever -mlong-double-64 is given,
64-bit double-precision instructions are used instead of calls to
libgcc's 128-bit softfloat functions.

FIXME: This patch is incomplete and unsafe until a mechanism is added
that would propagate this option to the assembler and linker to ensure
that 64-bit long double and 128-bit long double code can never be linked
together.

Signed-off-by: Artemiy Volkov <artemiy@synopsys.com>
  • Loading branch information
artemiy-volkov committed Aug 20, 2024
1 parent 2677e8b commit 15a88f9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gcc/config/riscv/riscv.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ ASM_MISA_SPEC

#define FLOAT_TYPE_SIZE 32
#define DOUBLE_TYPE_SIZE 64
#define LONG_DOUBLE_TYPE_SIZE 128
#define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_64 ? 64 : 128)

/* Allocation boundary (in *bits*) for storing arguments in argument list. */
#define PARM_BOUNDARY BITS_PER_WORD
Expand Down
8 changes: 8 additions & 0 deletions gcc/config/riscv/riscv.opt
Original file line number Diff line number Diff line change
Expand Up @@ -637,3 +637,11 @@ Enum(arcv_mpy_option) String(10c) Value(ARCV_MPY_OPTION_10C)
-param=arcv-mpy-option=
Target RejectNegative Joined Enum(arcv_mpy_option) Var(arcv_mpy_option) Init(ARCV_MPY_OPTION_2C)
The type of MPY unit used by the RMX-100 core (to be used in combination with -mtune=rmx100) (default: 2c).

mlong-double-64
Target RejectNegative Negative(mlong-double-128) Mask(LONG_DOUBLE_64)
Use 64-bit long double.

mlong-double-128
Target RejectNegative Negative(mlong-double-64) InverseMask(LONG_DOUBLE_64)
Use 128-bit long double.
17 changes: 17 additions & 0 deletions gcc/testsuite/gcc.target/riscv/arcv-long-double-64.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* { dg-do compile } */
/* { dg-require-effective-target rv32 } */
/* { dg-options "-march=rv32gc -mabi=ilp32d -mlong-double-64" } */

int __attribute__((noinline))
g (long double ld)
{
return (int)ld;
}

int
f (int x)
{
return (long double) 3.141592;
}

/* { dg-final { scan-assembler-times "__fixtfsi" 0 } } */

0 comments on commit 15a88f9

Please sign in to comment.