mirror of
				https://gitlab.com/freepascal.org/fpc/source.git
				synced 2025-10-31 03:11:39 +01:00 
			
		
		
		
	+ fpc_cpuinit procedure to allow cpu/fpu initialisation before any unit
initialises
  + fpu exceptions for invalid operations and division by zero enabled for
    ppc
			
			
This commit is contained in:
		
							parent
							
								
									2af569745c
								
							
						
					
					
						commit
						6bd3eccdac
					
				| @ -21,6 +21,10 @@ | |||||||
|                                Primitives |                                Primitives | ||||||
| ****************************************************************************} | ****************************************************************************} | ||||||
| 
 | 
 | ||||||
|  | procedure fpc_cpuinit; | ||||||
|  | begin | ||||||
|  | end; | ||||||
|  | 
 | ||||||
| function geteipasebx : pointer;assembler;[public,alias:'FPC_GETEIPINEBX']; | function geteipasebx : pointer;assembler;[public,alias:'FPC_GETEIPINEBX']; | ||||||
| asm | asm | ||||||
|   movl (%esp),%ebx |   movl (%esp),%ebx | ||||||
| @ -1414,7 +1418,13 @@ end; | |||||||
| 
 | 
 | ||||||
| { | { | ||||||
|   $Log$ |   $Log$ | ||||||
|   Revision 1.56  2003-12-24 23:07:28  peter |   Revision 1.57  2004-01-02 17:22:14  jonas | ||||||
|  |     + fpc_cpuinit procedure to allow cpu/fpu initialisation before any unit | ||||||
|  |       initialises | ||||||
|  |     + fpu exceptions for invalid operations and division by zero enabled for | ||||||
|  |       ppc | ||||||
|  | 
 | ||||||
|  |   Revision 1.56  2003/12/24 23:07:28  peter | ||||||
|     * fixed indexbyte for regcall |     * fixed indexbyte for regcall | ||||||
| 
 | 
 | ||||||
|   Revision 1.55  2003/12/04 21:44:39  peter |   Revision 1.55  2003/12/04 21:44:39  peter | ||||||
|  | |||||||
| @ -598,6 +598,8 @@ procedure fpc_InitializeUnits;[public,alias:'FPC_INITIALIZEUNITS']; {$ifdef hasc | |||||||
| var | var | ||||||
|   i : longint; |   i : longint; | ||||||
| begin | begin | ||||||
|  |   { call cpu/fpu initialisation routine } | ||||||
|  |   fpc_cpuinit; | ||||||
|   with InitFinalTable do |   with InitFinalTable do | ||||||
|    begin |    begin | ||||||
|      for i:=1to TableCount do |      for i:=1to TableCount do | ||||||
| @ -857,7 +859,13 @@ end; | |||||||
| 
 | 
 | ||||||
| { | { | ||||||
|   $Log$ |   $Log$ | ||||||
|   Revision 1.48  2004-01-01 17:58:16  jonas |   Revision 1.49  2004-01-02 17:21:50  jonas | ||||||
|  |     + fpc_cpuinit procedure to allow cpu/fpu initialisation before any unit | ||||||
|  |       initialises | ||||||
|  |     + fpu exceptions for invalid operations and division by zero enabled for | ||||||
|  |       ppc | ||||||
|  | 
 | ||||||
|  |   Revision 1.48  2004/01/01 17:58:16  jonas | ||||||
|     + integer division-by-zero detection support for ppc |     + integer division-by-zero detection support for ppc | ||||||
|     + compilerproc FPC_DIVBYZERO |     + compilerproc FPC_DIVBYZERO | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -30,6 +30,10 @@ | |||||||
| {****************************************************************************} | {****************************************************************************} | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | procedure fpc_cpuinit; | ||||||
|  | begin | ||||||
|  | end; | ||||||
|  | 
 | ||||||
|     { Don't call the following routines directly. } |     { Don't call the following routines directly. } | ||||||
|  Procedure Hlt;[public,alias: 'FPC_HALT_ERROR']; |  Procedure Hlt;[public,alias: 'FPC_HALT_ERROR']; | ||||||
|  { called by code generator on run-time errors. } |  { called by code generator on run-time errors. } | ||||||
| @ -688,7 +692,13 @@ end; | |||||||
| 
 | 
 | ||||||
| { | { | ||||||
|   $Log$ |   $Log$ | ||||||
|   Revision 1.3  2002-09-07 16:01:20  peter |   Revision 1.4  2004-01-02 17:22:14  jonas | ||||||
|  |     + fpc_cpuinit procedure to allow cpu/fpu initialisation before any unit | ||||||
|  |       initialises | ||||||
|  |     + fpu exceptions for invalid operations and division by zero enabled for | ||||||
|  |       ppc | ||||||
|  | 
 | ||||||
|  |   Revision 1.3  2002/09/07 16:01:20  peter | ||||||
|     * old logs removed and tabs fixed |     * old logs removed and tabs fixed | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | |||||||
| @ -22,6 +22,58 @@ | |||||||
| {**************************************************************************** | {**************************************************************************** | ||||||
|                            PowerPC specific stuff |                            PowerPC specific stuff | ||||||
| ****************************************************************************} | ****************************************************************************} | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  | const | ||||||
|  |   ppc_fpu_overflow     = (1 shl (32-3)); | ||||||
|  |   ppc_fpu_underflow    = (1 shl (32-4)); | ||||||
|  |   ppc_fpu_divbyzero    = (1 shl (32-5)); | ||||||
|  |   ppc_fpu_inexact      = (1 shl (32-6)); | ||||||
|  |   ppc_fpu_invalid_snan = (1 shl (32-7)); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | procedure fpc_enable_ppc_fpu_exceptions; | ||||||
|  | assembler; | ||||||
|  | asm | ||||||
|  |   { clear all "exception happened" flags we care about} | ||||||
|  |   mtfsfi 0,0 | ||||||
|  |   mtfsfi 1,0 | ||||||
|  | 
 | ||||||
|  |   { enable invalid operations and division by zero exceptions. } | ||||||
|  |   { No overflow/underflow, since those give some spurious      } | ||||||
|  |   { exceptions                                                 } | ||||||
|  |   mtfsfi 6,9 | ||||||
|  | end; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | procedure fpc_cpuinit; | ||||||
|  | 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 | ||||||
|  |   temp: record a,b:longint; end; | ||||||
|  | asm | ||||||
|  |   mffs f0 | ||||||
|  |   stfd f0,temp | ||||||
|  |   lwz  r3,temp.b | ||||||
|  |   { clear all exception flags } | ||||||
|  | { | ||||||
|  |   rlwinm r4,r3,0,16,31 | ||||||
|  |   stw  r4,temp.b | ||||||
|  |   lfd  f0,temp | ||||||
|  |   a_mtfsf f0 | ||||||
|  | } | ||||||
|  | end; | ||||||
|  | *) | ||||||
| 
 | 
 | ||||||
| { This function is never called directly, it's a dummy to hold the register save/ | { This function is never called directly, it's a dummy to hold the register save/ | ||||||
|   load subroutines |   load subroutines | ||||||
| @ -584,6 +636,7 @@ asm | |||||||
|                 { r3 still contains -1 here } |                 { r3 still contains -1 here } | ||||||
|                 bne     .LIndexWordDone |                 bne     .LIndexWordDone | ||||||
|                 sub     r3,r10,r0 |                 sub     r3,r10,r0 | ||||||
|  |                 srawi   r3,r3,1 | ||||||
| .LIndexWordDone: | .LIndexWordDone: | ||||||
| end; | end; | ||||||
| 
 | 
 | ||||||
| @ -609,6 +662,7 @@ asm | |||||||
|                 { r3 still contains -1 here } |                 { r3 still contains -1 here } | ||||||
|                 bne     .LIndexDWordDone |                 bne     .LIndexDWordDone | ||||||
|                 sub     r3,r10,r0 |                 sub     r3,r10,r0 | ||||||
|  |                 srawi   r3,r3,2 | ||||||
| .LIndexDWordDone: | .LIndexDWordDone: | ||||||
| end; | end; | ||||||
| 
 | 
 | ||||||
| @ -1006,7 +1060,13 @@ end; | |||||||
| 
 | 
 | ||||||
| { | { | ||||||
|   $Log$ |   $Log$ | ||||||
|   Revision 1.61  2003-12-28 21:06:56  jonas |   Revision 1.62  2004-01-02 17:21:50  jonas | ||||||
|  |     + fpc_cpuinit procedure to allow cpu/fpu initialisation before any unit | ||||||
|  |       initialises | ||||||
|  |     + fpu exceptions for invalid operations and division by zero enabled for | ||||||
|  |       ppc | ||||||
|  | 
 | ||||||
|  |   Revision 1.61  2003/12/28 21:06:56  jonas | ||||||
|     * fixed fillchar for SYSV abi |     * fixed fillchar for SYSV abi | ||||||
| 
 | 
 | ||||||
|   Revision 1.60  2003/12/21 21:23:09  florian |   Revision 1.60  2003/12/21 21:23:09  florian | ||||||
|  | |||||||
| @ -1,3 +1,7 @@ | |||||||
|  | procedure fpc_cpuinit; | ||||||
|  | begin | ||||||
|  | end; | ||||||
|  | 
 | ||||||
| {$define FPC_SYSTEM_HAS_GET_FRAME} | {$define FPC_SYSTEM_HAS_GET_FRAME} | ||||||
| function get_frame:pointer;{assembler;} | function get_frame:pointer;{assembler;} | ||||||
| begin{asm} | begin{asm} | ||||||
| @ -31,7 +35,13 @@ begin{asm} | |||||||
| end; | end; | ||||||
| { | { | ||||||
|   $Log$ |   $Log$ | ||||||
|   Revision 1.4  2003-12-04 21:42:07  peter |   Revision 1.5  2004-01-02 17:22:14  jonas | ||||||
|  |     + fpc_cpuinit procedure to allow cpu/fpu initialisation before any unit | ||||||
|  |       initialises | ||||||
|  |     + fpu exceptions for invalid operations and division by zero enabled for | ||||||
|  |       ppc | ||||||
|  | 
 | ||||||
|  |   Revision 1.4  2003/12/04 21:42:07  peter | ||||||
|     * register calling updates |     * register calling updates | ||||||
| 
 | 
 | ||||||
|   Revision 1.3  2003/03/17 14:30:11  peter |   Revision 1.3  2003/03/17 14:30:11  peter | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Jonas Maebe
						Jonas Maebe