diff options
author | Maciej W. Rozycki <macro@wdc.com> | 2019-05-02 16:39:16 +0000 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gcc.gnu.org> | 2019-05-02 16:39:16 +0000 |
commit | e05a859cf63e361465d2dfb3f6347ba04cd22570 (patch) | |
tree | 450bbcf4dfb8d0964fa898dc6dddbde7a9b2e4b4 | |
parent | ad4952c887bdb351e31cffecda4f6c1b8a76ee5f (diff) | |
download | gcc-e05a859cf63e361465d2dfb3f6347ba04cd22570.zip gcc-e05a859cf63e361465d2dfb3f6347ba04cd22570.tar.gz gcc-e05a859cf63e361465d2dfb3f6347ba04cd22570.tar.bz2 |
libphobos: RISC-V: Fix soft-float build errors with IEEE exception flags
Fix assembly errors:
.../libphobos/src/std/math.d: Assembler messages:.../libphobos/src/std/math.d:4773: Error: unrecognized opcode `frflags a0'.../libphobos/src/std/math.d:4856: Error: unrecognized opcode `fsflags a5'.../libphobos/src/std/math.d:4856: Error: unrecognized opcode `fsflags a5'.../libphobos/src/std/math.d:4773: Error: unrecognized opcode `frflags a0'.../libphobos/src/std/math.d:5549: Error: unrecognized opcode `fscsr a5'.../libphobos/src/std/math.d:5456: Error: unrecognized opcode `frcsr a5'.../libphobos/src/std/math.d:5456: Error: unrecognized opcode `frcsr a5'.../libphobos/src/std/math.d:5549: Error: unrecognized opcode `fscsr a5'.../libphobos/src/std/math.d:5456: Error: unrecognized opcode `frcsr a5'.../libphobos/src/std/math.d:5549: Error: unrecognized opcode `fscsr a0'.../libphobos/src/std/math.d:5456: Error: unrecognized opcode `frcsr a0'.../libphobos/src/std/math.d:5456: Error: unrecognized opcode `frcsr a0'.../libphobos/src/std/math.d:5549: Error: unrecognized opcode `fscsr s2'make[8]: *** [Makefile:1119: std/math.lo] Error 1
triggered with the RISC-V lp64 multilib in a GCC build configured with
`--enable-multilib --enable-languages=all --target=riscv64-linux-gnu'.
This is due to unconditional explicit use of F extension instructions
within inline assembly, to access IEEE exception flags. The use of
these instructions is not allowed when building for a soft-float ABI.
Correct the problem by wrapping said inline assembly into a conditional
such that if `D_SoftFloat' is true, then reads from IEEE exception flags
return 0 and writes are ignored instead, complementing r270522
("libphobos: Add D support for RISC-V Linux"), which is an updated
version of <https://gcc.gnu.org/ml/gcc-patches/2019-04/msg00325.html>,
where the problematic code has originated from.
libphobos/ChangeLog:
2019-05-02 Maciej Rozycki <macro@wdc.com>
* std/math.d (IeeeFlags.getIeeeFlags): Handle RISC-V soft-float ABI.
(IeeeFlags.resetIeeeFlags): Likewise.
(FloatingPointControl.getControlState): Likewise.
(FloatingPointControl.setControlState): Likewise.
From-SVN: r270816
-rw-r--r-- | libphobos/ChangeLog | 7 | ||||
-rw-r--r-- | libphobos/src/std/math.d | 46 |
2 files changed, 40 insertions, 13 deletions
diff --git a/libphobos/ChangeLog b/libphobos/ChangeLog index 0d937e0..780e304 100644 --- a/libphobos/ChangeLog +++ b/libphobos/ChangeLog @@ -1,3 +1,10 @@ +2019-05-02 Maciej Rozycki <macro@wdc.com> + + * std/math.d (IeeeFlags.getIeeeFlags): Handle RISC-V soft-float ABI. + (IeeeFlags.resetIeeeFlags): Likewise. + (FloatingPointControl.getControlState): Likewise. + (FloatingPointControl.setControlState): Likewise. + 2019-04-25 Iain Buclaw <ibuclaw@gdcproject.org> PR d/90250 diff --git a/libphobos/src/std/math.d b/libphobos/src/std/math.d index 7bc9422..14868dd 100644 --- a/libphobos/src/std/math.d +++ b/libphobos/src/std/math.d @@ -4761,12 +4761,17 @@ private: } else version (RISCV_Any) { - uint result = void; - asm pure nothrow @nogc + version (D_SoftFloat) + return 0; + else { - "frflags %0" : "=r" result; + uint result = void; + asm pure nothrow @nogc + { + "frflags %0" : "=r" result; + } + return result; } - return result; } else assert(0, "Not yet supported"); @@ -4844,10 +4849,15 @@ private: } else version (RISCV_Any) { - uint newValues = 0x0; - asm pure nothrow @nogc + version (D_SoftFloat) + return; + else { - "fsflags %0" : : "r" newValues; + uint newValues = 0x0; + asm pure nothrow @nogc + { + "fsflags %0" : : "r" newValues; + } } } else @@ -5444,12 +5454,17 @@ private: } else version (RISCV_Any) { - ControlState cont; - asm pure nothrow @nogc + version (D_SoftFloat) + return 0; + else { - "frcsr %0" : "=r" cont; + ControlState cont; + asm pure nothrow @nogc + { + "frcsr %0" : "=r" cont; + } + return cont; } - return cont; } else assert(0, "Not yet supported"); @@ -5538,9 +5553,14 @@ private: } else version (RISCV_Any) { - asm pure nothrow @nogc + version (D_SoftFloat) + return; + else { - "fscsr %0" : : "r" (newState); + asm pure nothrow @nogc + { + "fscsr %0" : : "r" (newState); + } } } else |