From 4c7c8b9c3a83c10fcb424d7bb94bbcbd401b71e9 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Sat, 10 Jan 2004 00:16:20 +0000 Subject: [PATCH] * fixed mtfsb0 instruction for assembler reader/writer * fixed initialisation of fpscr register to avoid spurious SIGPFE's (uses mtfsb0 instruction, so added extra define in options.pas to avoid requiring to start with a cross compiler) --- compiler/options.pas | 9 ++++++++- compiler/powerpc/cpubase.pas | 10 ++++++++-- compiler/powerpc/itcpugas.pas | 10 ++++++++-- rtl/darwin/powerpc/sighnd.inc | 25 ++++++++++++------------- rtl/powerpc/powerpc.inc | 21 ++++++++++++++------- 5 files changed, 50 insertions(+), 25 deletions(-) diff --git a/compiler/options.pas b/compiler/options.pas index 735e1b883b..1830d3c5bd 100644 --- a/compiler/options.pas +++ b/compiler/options.pas @@ -1672,6 +1672,7 @@ begin {$ifdef powerpc} def_symbol('HASINTF'); def_symbol('HASVARIANT'); + def_symbol('FPC_MTFSB0_CORRECTED'); {$endif powerpc} def_symbol('INTERNSETLENGTH'); def_symbol('INTERNLENGTH'); @@ -1993,7 +1994,13 @@ finalization end. { $Log$ - Revision 1.119 2004-01-02 17:19:04 jonas + Revision 1.120 2004-01-10 00:16:21 jonas + * fixed mtfsb0 instruction for assembler reader/writer + * fixed initialisation of fpscr register to avoid spurious SIGPFE's + (uses mtfsb0 instruction, so added extra define in options.pas to avoid + requiring to start with a cross compiler) + + Revision 1.119 2004/01/02 17:19:04 jonas * if currency = int64, FPC_CURRENCY_IS_INT64 is defined + round and trunc for currency and comp if FPC_CURRENCY_IS_INT64 is defined diff --git a/compiler/powerpc/cpubase.pas b/compiler/powerpc/cpubase.pas index 30dfdd8e33..66d8f81166 100644 --- a/compiler/powerpc/cpubase.pas +++ b/compiler/powerpc/cpubase.pas @@ -61,7 +61,7 @@ uses a_lhau, a_lhaux, a_lhax, a_hbrx, a_lhz, a_lhzu, a_lhzux, a_lhzx, a_lmw, a_lswi, a_lswx, a_lwarx, a_lwbrx, a_lwz, a_lwzu, a_lwzux, a_lwzx, a_mcrf, a_mcrfs, a_mcrxr, a_lcrxe, a_mfcr, a_mffs, a_maffs_, a_mfmsr, a_mfspr, a_mfsr, - a_mfsrin, a_mftb, a_mtcrf, a_a_mtfd0, a_mtfsb1, a_mtfsf, a_mtfsf_, + a_mfsrin, a_mftb, a_mtcrf, a_mtfsb0, a_mtfsb1, a_mtfsf, a_mtfsf_, a_mtfsfi, a_mtfsfi_, a_mtmsr, a_mtspr, a_mtsr, a_mtsrin, a_mulhw, a_mulhw_, a_mulhwu, a_mulhwu_, a_mulli, a_mullw, a_mullw_, a_mullwo, a_mullwo_, a_nand, a_nand_, a_neg, a_neg_, a_nego, a_nego_, a_nor, a_nor_, @@ -694,7 +694,13 @@ implementation end. { $Log$ - Revision 1.81 2003-12-16 21:49:47 florian + Revision 1.82 2004-01-10 00:16:21 jonas + * fixed mtfsb0 instruction for assembler reader/writer + * fixed initialisation of fpscr register to avoid spurious SIGPFE's + (uses mtfsb0 instruction, so added extra define in options.pas to avoid + requiring to start with a cross compiler) + + Revision 1.81 2003/12/16 21:49:47 florian * fixed ppc compilation Revision 1.80 2003/12/09 20:39:43 jonas diff --git a/compiler/powerpc/itcpugas.pas b/compiler/powerpc/itcpugas.pas index 32790fdc29..d47bd8d06b 100644 --- a/compiler/powerpc/itcpugas.pas +++ b/compiler/powerpc/itcpugas.pas @@ -53,7 +53,7 @@ interface 'lhau','lhaux','lhax','hbrx','lhz','lhzu','lhzux','lhzx','lmw', 'lswi','lswx','lwarx','lwbrx','lwz','lwzu','lwzux','lwzx','mcrf', 'mcrfs','mcrxr','lcrxe','mfcr','mffs','maffs.','mfmsr','mfspr','mfsr', - 'mfsrin','mftb','mtcrf','mtfd0','mtfsb1','mtfsf','mtfsf.', + 'mfsrin','mftb','mtcrf','mtfsb0','mtfsb1','mtfsf','mtfsf.', 'mtfsfi','mtfsfi.','mtmsr','mtspr','mtsr','mtsrin','mulhw', 'mulhw.','mulhwu','mulhwu.','mulli','mullw','mullw.','mullwo', 'mullwo.','nand','nand.','neg','neg.','nego','nego.','nor','nor.', @@ -144,7 +144,13 @@ implementation end. { $Log$ - Revision 1.4 2004-01-04 21:18:10 jonas + Revision 1.5 2004-01-10 00:16:21 jonas + * fixed mtfsb0 instruction for assembler reader/writer + * fixed initialisation of fpscr register to avoid spurious SIGPFE's + (uses mtfsb0 instruction, so added extra define in options.pas to avoid + requiring to start with a cross compiler) + + Revision 1.4 2004/01/04 21:18:10 jonas + as_darwin assembler type (labels start with L) * never generate register->number mappings for Darwin * always use real register names for Darwin diff --git a/rtl/darwin/powerpc/sighnd.inc b/rtl/darwin/powerpc/sighnd.inc index c3580d2263..649be15258 100644 --- a/rtl/darwin/powerpc/sighnd.inc +++ b/rtl/darwin/powerpc/sighnd.inc @@ -14,13 +14,6 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. } -procedure darwin_signal_trampoline(pc,r1: pointer; res: longint); -begin -{ give runtime error at the position where the signal was raised } - HandleErrorAddrFrame(res,pc,r1); -end; - - procedure SignalToRunerror(Sig: cint; var info : tsiginfo_t;Var SigContext:SigContextRec); cdecl; var @@ -45,7 +38,7 @@ begin { enabled by executing a sigreturn, however then the exception is triggered } { triggered again immediately if we don't turn off the "exception occurred" } { flags in fpscr } - SigContext.uc_mcontext^.fs.fpscr := SigContext.uc_mcontext^.fs.fpscr and not($fffc0000); + SigContext.uc_mcontext^.fs.fpscr := SigContext.uc_mcontext^.fs.fpscr and not($fffe0700); end; SIGILL, SIGBUS, @@ -59,16 +52,22 @@ begin { return to trampoline } if res <> 0 then begin - SigContext.uc_mcontext^.ss.r3 := SigContext.uc_mcontext^.ss.srr0; - SigContext.uc_mcontext^.ss.r4 := SigContext.uc_mcontext^.ss.r1; - SigContext.uc_mcontext^.ss.r5 := res; - pointer(SigContext.uc_mcontext^.ss.srr0) := @darwin_signal_trampoline; + SigContext.uc_mcontext^.ss.r3 := res; + SigContext.uc_mcontext^.ss.r4 := SigContext.uc_mcontext^.ss.srr0; + SigContext.uc_mcontext^.ss.r5 := SigContext.uc_mcontext^.ss.r1; + pointer(SigContext.uc_mcontext^.ss.srr0) := @HandleErrorAddrFrame; end; end; { $Log$ - Revision 1.2 2004-01-08 21:52:34 jonas + Revision 1.3 2004-01-10 00:16:21 jonas + * fixed mtfsb0 instruction for assembler reader/writer + * fixed initialisation of fpscr register to avoid spurious SIGPFE's + (uses mtfsb0 instruction, so added extra define in options.pas to avoid + requiring to start with a cross compiler) + + Revision 1.2 2004/01/08 21:52:34 jonas * fixed signal handling under 10.3.2, still have to verify whether it's backwards compatible diff --git a/rtl/powerpc/powerpc.inc b/rtl/powerpc/powerpc.inc index 2bc46374c4..3ad9f7e123 100644 --- a/rtl/powerpc/powerpc.inc +++ b/rtl/powerpc/powerpc.inc @@ -38,6 +38,13 @@ asm { clear all "exception happened" flags we care about} mtfsfi 0,0 mtfsfi 1,0 + mtfsfi 2,0 + mtfsfi 3,0 +{$ifdef fpc_mtfsb0_corrected} + mtfsb0 21 + mtfsb0 22 + mtfsb0 23 +{$endif fpc_mtfsb0_corrected} { enable invalid operations and division by zero exceptions. } { No overflow/underflow, since those give some spurious } @@ -51,12 +58,7 @@ begin fpc_enable_ppc_fpu_exceptions; end; -{ -doesn't work, at least not on linux, because there after an exception -fpscr is set to 0 (JM) -} -(* function fpc_get_ppc_fpscr: cardinal; assembler; var @@ -73,7 +75,6 @@ asm a_mtfsf f0 } end; -*) { This function is never called directly, it's a dummy to hold the register save/ load subroutines @@ -1060,7 +1061,13 @@ end; { $Log$ - Revision 1.63 2004-01-03 19:46:29 jonas + Revision 1.64 2004-01-10 00:16:20 jonas + * fixed mtfsb0 instruction for assembler reader/writer + * fixed initialisation of fpscr register to avoid spurious SIGPFE's + (uses mtfsb0 instruction, so added extra define in options.pas to avoid + requiring to start with a cross compiler) + + Revision 1.63 2004/01/03 19:46:29 jonas * fixed syntax error caught by Mac OS X' as :) Revision 1.62 2004/01/02 17:21:50 jonas