Commit 1770f169 by Maciej W. Rozycki Committed by Iain Buclaw

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 W. 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: r270815
parent 8c6a71e4
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> 2019-04-25 Iain Buclaw <ibuclaw@gdcproject.org>
PR d/90250 PR d/90250
......
...@@ -4767,6 +4767,10 @@ private: ...@@ -4767,6 +4767,10 @@ private:
} }
else version (RISCV_Any) else version (RISCV_Any)
{ {
version (D_SoftFloat)
return 0;
else
{
uint result = void; uint result = void;
asm pure nothrow @nogc asm pure nothrow @nogc
{ {
...@@ -4774,6 +4778,7 @@ private: ...@@ -4774,6 +4778,7 @@ private:
} }
return result; return result;
} }
}
else else
assert(0, "Not yet supported"); assert(0, "Not yet supported");
} }
...@@ -4850,12 +4855,17 @@ private: ...@@ -4850,12 +4855,17 @@ private:
} }
else version (RISCV_Any) else version (RISCV_Any)
{ {
version (D_SoftFloat)
return;
else
{
uint newValues = 0x0; uint newValues = 0x0;
asm pure nothrow @nogc asm pure nothrow @nogc
{ {
"fsflags %0" : : "r" newValues; "fsflags %0" : : "r" newValues;
} }
} }
}
else else
assert(0, "Not yet supported"); assert(0, "Not yet supported");
} }
...@@ -5450,6 +5460,10 @@ private: ...@@ -5450,6 +5460,10 @@ private:
} }
else version (RISCV_Any) else version (RISCV_Any)
{ {
version (D_SoftFloat)
return 0;
else
{
ControlState cont; ControlState cont;
asm pure nothrow @nogc asm pure nothrow @nogc
{ {
...@@ -5457,6 +5471,7 @@ private: ...@@ -5457,6 +5471,7 @@ private:
} }
return cont; return cont;
} }
}
else else
assert(0, "Not yet supported"); assert(0, "Not yet supported");
} }
...@@ -5544,11 +5559,16 @@ private: ...@@ -5544,11 +5559,16 @@ private:
} }
else version (RISCV_Any) else version (RISCV_Any)
{ {
version (D_SoftFloat)
return;
else
{
asm pure nothrow @nogc asm pure nothrow @nogc
{ {
"fscsr %0" : : "r" (newState); "fscsr %0" : : "r" (newState);
} }
} }
}
else else
assert(0, "Not yet supported"); assert(0, "Not yet supported");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment