Browse Source

Merged revisions 7466,7469-7474,7476-7477 via svnmerge from
svn+ssh://[email protected]/FPC/svn/fpc/trunk

........
r7466 | jonas | 2007-05-25 10:49:07 +0200 (Fri, 25 May 2007) | 2 lines

* fixed a_load_ref_reg_unaligned in case reg is used in ref

........
r7469 | jonas | 2007-05-25 14:00:55 +0200 (Fri, 25 May 2007) | 3 lines

+ defined FPC_SUPPORTS_UNALIGNED if the compiler supports the
unaligned() expression

........
r7470 | jonas | 2007-05-25 14:01:28 +0200 (Fri, 25 May 2007) | 2 lines

* fixed get_caller_frame() and get_caller_addr() for nil addresses

........
r7471 | jonas | 2007-05-25 14:02:08 +0200 (Fri, 25 May 2007) | 3 lines

* fixed add_tail functionality for cpus which require natural
alignment

........
r7472 | jonas | 2007-05-25 14:30:14 +0200 (Fri, 25 May 2007) | 2 lines

- removed a comment which wasn't true anymore

........
r7473 | jonas | 2007-05-25 15:07:23 +0200 (Fri, 25 May 2007) | 3 lines

* fixed program exitcode after change of operatingsystem_result from
word to longint

........
r7474 | jonas | 2007-05-25 19:48:24 +0200 (Fri, 25 May 2007) | 2 lines

* exit -> exit_group to exit so unterminated threads are killed too

........
r7476 | jonas | 2007-05-25 21:02:19 +0200 (Fri, 25 May 2007) | 2 lines

* fixed multi-thread case of FPC_SYSCALL3 (all others were already correct)

........
r7477 | jonas | 2007-05-25 21:22:28 +0200 (Fri, 25 May 2007) | 3 lines

* fixed fpu rte code for invalid, inexact and "subscript out of range"
errors (216 -> 207) (same as for sparc/solaris in r7453)

........

git-svn-id: branches/fixes_2_2@7479 -

Jonas Maebe 18 years ago
parent
commit
8233244f05

+ 16 - 14
compiler/cgobj.pas

@@ -1873,7 +1873,8 @@ implementation
     procedure tcg.a_load_ref_reg_unaligned(list : TAsmList;fromsize,tosize : tcgsize;const ref : treference;register : tregister);
       var
         tmpref : treference;
-        tmpreg : tregister;
+        tmpreg,
+        tmpreg2 : tregister;
         i : longint;
       begin
         if ref.alignment<>0 then
@@ -1884,38 +1885,39 @@ implementation
             case FromSize of
               OS_16,OS_S16:
                 begin
+                  { first load in tmpreg, because the target register }
+                  { may be used in ref as well                        }
                   if target_info.endian=endian_little then
                     inc(tmpref.offset);
-                  register:=makeregsize(list,register,OS_8);
-                  a_load_ref_reg(list,OS_8,OS_8,tmpref,register);
-                  register:=makeregsize(list,register,OS_16);
-                  a_op_const_reg(list,OP_SHL,OS_16,8,register);
+                  tmpreg:=getintregister(list,OS_8);
+                  a_load_ref_reg(list,OS_8,OS_8,tmpref,tmpreg);
+                  tmpreg:=makeregsize(list,tmpreg,OS_16);
+                  a_op_const_reg(list,OP_SHL,OS_16,8,tmpreg);
                   if target_info.endian=endian_little then
                     dec(tmpref.offset)
                   else
                     inc(tmpref.offset);
-                  tmpreg:=getintregister(list,OS_16);
-                  a_load_ref_reg(list,OS_8,OS_16,tmpref,tmpreg);
+                  a_load_ref_reg(list,OS_8,OS_16,tmpref,register);
                   a_op_reg_reg(list,OP_OR,OS_16,tmpreg,register);
                 end;
               OS_32,OS_S32:
                 begin
                   if target_info.endian=endian_little then
                     inc(tmpref.offset,3);
-                  register:=makeregsize(list,register,OS_8);
-                  a_load_ref_reg(list,OS_8,OS_8,tmpref,register);
-                  register:=makeregsize(list,register,OS_32);
+                  tmpreg:=getintregister(list,OS_32);
+                  a_load_ref_reg(list,OS_8,OS_32,tmpref,tmpreg);
+                  tmpreg2:=getintregister(list,OS_32);
                   for i:=1 to 3 do
                     begin
-                      a_op_const_reg(list,OP_SHL,OS_32,8,register);
+                      a_op_const_reg(list,OP_SHL,OS_32,8,tmpreg);
                       if target_info.endian=endian_little then
                         dec(tmpref.offset)
                       else
                         inc(tmpref.offset);
-                      tmpreg:=getintregister(list,OS_32);
-                      a_load_ref_reg(list,OS_8,OS_32,tmpref,tmpreg);
-                      a_op_reg_reg(list,OP_OR,OS_32,tmpreg,register);
+                      a_load_ref_reg(list,OS_8,OS_32,tmpref,tmpreg2);
+                      a_op_reg_reg(list,OP_OR,OS_32,tmpreg2,tmpreg);
                     end;
+                  a_load_reg_reg(list,OS_32,OS_32,tmpreg,register);
                 end
               else
                 a_load_ref_reg(list,fromsize,tosize,tmpref,register);

+ 3 - 0
compiler/options.pas

@@ -1990,6 +1990,9 @@ begin
   def_system_macro('FPC_HAS_STR_CURRENCY');
   def_system_macro('FPC_REAL2REAL_FIXED');
   def_system_macro('FPC_STRTOCHARARRAYPROC');
+{$ifdef SUPPORT_UNALIGNED}
+  def_system_macro('FPC_SUPPORTS_UNALIGNED');
+{$endif SUPPORT_UNALIGNED}
 
 {$if defined(x86) or defined(arm)}
   def_system_macro('INTERNAL_BACKTRACE');

+ 0 - 3
compiler/ptconst.pas

@@ -128,9 +128,6 @@ implementation
         bitstowrite: longint;
         writeval : byte;
       begin
-        { these values have to be byte swapped when cross-compiling }
-        { from one endianess to another, but this will be done      }
-        { automatically by the assembler writer                     }
         if (bp.curbitoffset < AIntBits) then
           begin
             { forced flush -> write multiple of loadsize }

+ 8 - 0
rtl/inc/heaptrc.pp

@@ -410,7 +410,11 @@ begin
   if add_tail then
     begin
       pl:=pointer(pp)+allocsize-pp^.extra_info_size-sizeof(ptrint);
+{$ifdef FPC_SUPPORTS_UNALIGNED}
+      unaligned(pl^):=$DEADBEEF;
+{$else FPC_SUPPORTS_UNALIGNED}
       pl^:=$DEADBEEF;
+{$endif FPC_SUPPORTS_UNALIGNED}
     end;
   { clear the memory }
   fillchar(p^,size,#255);
@@ -733,7 +737,11 @@ begin
   if add_tail then
     begin
       pl:=pointer(pp)+allocsize-pp^.extra_info_size-sizeof(ptrint);
+{$ifdef FPC_SUPPORTS_UNALIGNED}
+      unaligned(pl^):=$DEADBEEF;
+{$else FPC_SUPPORTS_UNALIGNED}
       pl^:=$DEADBEEF;
+{$endif FPC_SUPPORTS_UNALIGNED}
     end;
   { adjust like a freemem and then a getmem, so you get correct
     results in the summary display }

+ 1 - 4
rtl/linux/sparc/cprt0.as

@@ -65,10 +65,7 @@ _start:
 								.globl  _haltproc
         .type   _haltproc,@function
         _haltproc:
-       	mov	1, %g1			/* "exit" system call */
-       	sethi	%hi(operatingsystem_result),%o0
-       	or	%o0,%lo(operatingsystem_result),%o0
-       	ldsh	[%o0], %o0			/* give exit status to parent process*/
+       	mov	188, %g1			/* "exit" system call */
        	ta	0x10			/* dot the system call */
        	nop				/* delay slot */
        	/* Die very horribly if exit returns.  */

+ 1 - 4
rtl/linux/sparc/gprt0.as

@@ -86,10 +86,7 @@ _start:
         .globl  _haltproc
         .type   _haltproc,@function
   _haltproc:
-        mov	1, %g1			/* "exit" system call */
-        sethi	%hi(operatingsystem_result),%o0
-        or	%o0,%lo(operatingsystem_result),%o0
-        ldsh	[%o0], %o0			/* give exit status to parent process*/
+        mov	188, %g1			/* "exit" system call */
         ta	0x10			/* dot the system call */
         nop				/* delay slot */
         /* Die very horribly if exit returns.  */

+ 1 - 4
rtl/linux/sparc/prt0.as

@@ -61,10 +61,7 @@ _start:
 .globl  _haltproc
 .type   _haltproc,@function
 _haltproc:
-	mov	1, %g1			/* "exit" system call */
-	sethi	%hi(operatingsystem_result),%o0
-	or	%o0,%lo(operatingsystem_result),%o0
-	ldsh	[%o0], %o0			/* give exit status to parent process*/
+	mov	188, %g1			/* "exit_group" system call */
 	ta	0x10			/* dot the system call */
 	nop				/* delay slot */
 	/* Die very horribly if exit returns.  */

+ 0 - 5
rtl/linux/sparc/sighnd.inc

@@ -26,7 +26,6 @@ begin
     SIGFPE :
         begin
           addr := siginfo^._sifields._sigfault._addr;
-          res := 207;
           case  siginfo^.si_code of
             FPE_INTDIV:
               res:=200;
@@ -38,10 +37,6 @@ begin
               res:=205;
             FPE_FLTUND:
               res:=206;
-            FPE_FLTRES,
-            FPE_FLTINV,
-            FPE_FLTSUB:
-              res:=216;
             else
               res:=207;
           end;

+ 5 - 6
rtl/linux/sparc/syscall.inc

@@ -183,17 +183,16 @@ asm
         subcc   %o3,%g0,%g0
         bne     .LThread
         nop
-        sethi   %hi(Errno+4),%o2
+        sethi   %hi(Errno+4),%o0
         ba      .LNoThread
-        or      %o2,%lo(Errno+4),%o2
+        or      %o0,%lo(Errno+4),%o0
 .LThread:
         sethi   %hi(Errno),%o0
-        ld      [%o3],%o1
         or      %o0,%lo(Errno),%o0
-        call    %o1
-        nop
+        call    %o3
+        ld      [%o0],%o0
 .LNoThread:
-        st      %o0,[%o2]
+        st      %l0,[%o0]
         mov     -1,%o0
 .LSyscOK:
         mov     %o0,%i0

+ 9 - 1
rtl/sparc/sparc.inc

@@ -73,21 +73,29 @@ function get_frame:pointer;assembler;nostackframe;
 function get_caller_addr(framebp:pointer):pointer;assembler;nostackframe;
   asm
     { framebp = %o0 }
+    subcc   %o0,0,%o0
+    be      .Lframezero
+    nop
     { flush register windows, so they are stored in the stack }
     ta      3
     ld [%o0+60],%o0
     { add 8 to skip jmpl and delay slot }
     add %o0,8,%o0
+.Lframezero:
   end;
 
 
 {$define FPC_SYSTEM_HAS_GET_CALLER_FRAME}
 function get_caller_frame(framebp:pointer):pointer;assembler;nostackframe;
   asm
+    { framebp = %o0 }
+    subcc   %o0,0,%o0
+    be      .Lframezero
+    nop
     { flush register windows, so they are stored in the stack }
     ta      3
-    { framebp = %o0 }
     ld [%o0+56],%o0
+.Lframezero:
   end;