summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorflorian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2>2018-08-19 15:26:44 +0000
committerflorian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2>2018-08-19 15:26:44 +0000
commit0c775d82d379ccd6eeb33d926c2da5abc96ec4d7 (patch)
treefe4b1dbf183919e62c37597a2999f68387c97fa3
parent7700a23409089e824dfa17f35313e21bc4a706ef (diff)
downloadfpc-0c775d82d379ccd6eeb33d926c2da5abc96ec4d7.tar.gz
* fix SetRoundingMode on RiscV64
git-svn-id: https://svn.freepascal.org/svn/fpc/branches/laksen@39646 3ad0048d-3df7-0310-abae-a5850022a9f2
-rw-r--r--riscv_new/rtl/riscv64/mathu.inc14
1 files changed, 8 insertions, 6 deletions
diff --git a/riscv_new/rtl/riscv64/mathu.inc b/riscv_new/rtl/riscv64/mathu.inc
index e76b595641..a831c6fa78 100644
--- a/riscv_new/rtl/riscv64/mathu.inc
+++ b/riscv_new/rtl/riscv64/mathu.inc
@@ -12,13 +12,15 @@
**********************************************************************}
-function getfpcr: dword; nostackframe; assembler;
+function getrm: dword; nostackframe; assembler;
asm
+ frrm a0
end;
-procedure setfpcr(val: dword); nostackframe; assembler;
+procedure setrm(val: dword); nostackframe; assembler;
asm
+ fsrm a0
end;
@@ -36,19 +38,19 @@ procedure setfflags(flags : dword); nostackframe; assembler;
function GetRoundMode: TFPURoundingMode;
const
- bits2rm: array[0..3] of TFPURoundingMode = (rmNearest,rmUp,rmDown,rmTruncate);
+ bits2rm: array[0..3] of TFPURoundingMode = (rmNearest,rmTruncate,rmDown,rmUp);
begin
- result:=TFPURoundingMode(bits2rm[(getfpcr shr 22) and 3])
+ result:=TFPURoundingMode(bits2rm[getrm])
end;
function SetRoundMode(const RoundMode: TFPURoundingMode): TFPURoundingMode;
const
- rm2bits: array[TFPURoundingMode] of byte = (0,2,1,3);
+ rm2bits : array[TFPURoundingMode] of byte = (0,2,3,1);
begin
softfloat_rounding_mode:=RoundMode;
SetRoundMode:=RoundMode;
- setfpcr((getfpcr and $ff3fffff) or (rm2bits[RoundMode] shl 22));
+ setrm(rm2bits[RoundMode]);
end;