Răsfoiți Sursa

* powerpc64 port now (manually) cycles, most test programs in tests/test are fine too
* fixed bug in ncal.pas which in some circumstances treated the hidden length parameter for open arrays as 32 bit integer

git-svn-id: trunk@1303 -

tom_at_work 20 ani în urmă
părinte
comite
b2e1cf2610

+ 3 - 3
compiler/ncal.pas

@@ -366,7 +366,7 @@ type
                    begin
                    begin
                      maybe_load_para_in_temp(p);
                      maybe_load_para_in_temp(p);
                      hightree:=caddnode.create(subn,geninlinenode(in_length_x,false,p.getcopy),
                      hightree:=caddnode.create(subn,geninlinenode(in_length_x,false,p.getcopy),
-                                               cordconstnode.create(1,s32inttype,false));
+                                               cordconstnode.create(1,sinttype,false));
                      loadconst:=false;
                      loadconst:=false;
                    end;
                    end;
                end;
                end;
@@ -375,13 +375,13 @@ type
           len:=0;
           len:=0;
         end;
         end;
         if loadconst then
         if loadconst then
-          hightree:=cordconstnode.create(len,s32inttype,true)
+          hightree:=cordconstnode.create(len,sinttype,true)
         else
         else
           begin
           begin
             if not assigned(hightree) then
             if not assigned(hightree) then
               internalerror(200304071);
               internalerror(200304071);
             { Need to use explicit, because it can also be a enum }
             { Need to use explicit, because it can also be a enum }
-            hightree:=ctypeconvnode.create_internal(hightree,s32inttype);
+            hightree:=ctypeconvnode.create_internal(hightree,sinttype);
           end;
           end;
         result:=hightree;
         result:=hightree;
       end;
       end;

+ 0 - 1
compiler/powerpc64/cgcpu.pas

@@ -1040,7 +1040,6 @@ begin
       reference_reset_base(href, NR_STACK_POINTER_REG, -localsize);
       reference_reset_base(href, NR_STACK_POINTER_REG, -localsize);
       a_load_store(list, A_STDU, NR_STACK_POINTER_REG, href);
       a_load_store(list, A_STDU, NR_STACK_POINTER_REG, href);
     end else begin
     end else begin
-      writeln(localsize);
       reference_reset_base(href, NR_NO, -localsize);
       reference_reset_base(href, NR_NO, -localsize);
 
 
       // use R0 for loading the constant (which is definitely > 32k when entering
       // use R0 for loading the constant (which is definitely > 32k when entering

+ 17 - 14
compiler/powerpc64/nppcmat.pas

@@ -113,20 +113,23 @@ begin
     (right.nodetype = ordconstn) and
     (right.nodetype = ordconstn) and
     ispowerof2(tordconstnode(right).value, power) then
     ispowerof2(tordconstnode(right).value, power) then
   begin
   begin
-    { From "The PowerPC Compiler Writer's Guide":                   }
-    { This code uses the fact that, in the PowerPC architecture,    }
-    { the shift right algebraic instructions set the Carry bit if   }
-    { the source register contains a negative number and one or     }
-    { more 1-bits are shifted out. Otherwise, the carry bit is      }
-    { cleared. The addze instruction corrects the quotient, if      }
-    { necessary, when the dividend is negative. For example, if     }
-    { n = -13, (0xFFFF_FFF3), and k = 2, after executing the srawi  }
-    { instruction, q = -4 (0xFFFF_FFFC) and CA = 1. After executing }
-    { the addze instruction, q = -3, the correct quotient.          }
-    // ts: buggy....... sar also used in a unsigned division...
-    cg.a_op_const_reg_reg(exprasmlist, OP_SAR, OS_64, power,
-      numerator, resultreg);
-    exprasmlist.concat(taicpu.op_reg_reg(A_ADDZE, resultreg, resultreg));
+  	if (is_signed(right.resulttype.def)) then begin
+      { From "The PowerPC Compiler Writer's Guide":                   }
+      { This code uses the fact that, in the PowerPC architecture,    }
+      { the shift right algebraic instructions set the Carry bit if   }
+      { the source register contains a negative number and one or     }
+      { more 1-bits are shifted out. Otherwise, the carry bit is      }
+      { cleared. The addze instruction corrects the quotient, if      }
+      { necessary, when the dividend is negative. For example, if     }
+      { n = -13, (0xFFFF_FFF3), and k = 2, after executing the srawi  }
+      { instruction, q = -4 (0xFFFF_FFFC) and CA = 1. After executing }
+      { the addze instruction, q = -3, the correct quotient.          }
+      cg.a_op_const_reg_reg(exprasmlist, OP_SAR, OS_64, power,
+        numerator, resultreg);
+      exprasmlist.concat(taicpu.op_reg_reg(A_ADDZE, resultreg, resultreg));
+    end else begin
+      cg.a_op_const_reg_reg(exprasmlist, OP_SHR, OS_INT, power, numerator, resultreg);
+    end;
   end
   end
   else
   else
   begin
   begin

+ 1 - 1
compiler/psub.pas

@@ -1301,7 +1301,7 @@ implementation
                    begin
                    begin
                      s:=proc_get_importname(pd);
                      s:=proc_get_importname(pd);
                      if s<>'' then
                      if s<>'' then
-                       gen_external_stub(asmlist[al_procedures],pd,s);
+                       gen_external_stub(asmlist[al_procedures],pd,{$IFDEF POWERPC64}'.'+{$ENDIF}s);
                    end;
                    end;
 
 
                  { Import DLL specified? }
                  { Import DLL specified? }

+ 5 - 4
rtl/inc/objpash.inc

@@ -275,12 +275,13 @@
       PVarRec = ^TVarRec;
       PVarRec = ^TVarRec;
       TVarRec = record
       TVarRec = record
          case VType : Ptrint of
          case VType : Ptrint of
-           vtInteger    : (VInteger: Longint);
 {$ifdef ENDIAN_BIG}
 {$ifdef ENDIAN_BIG}
-           vtBoolean    : (booldummy1,booldummy2,booldummy3: byte; VBoolean: Boolean);
-           vtChar       : (chardummy1,chardummy2,chardummy3: byte; VChar: Char);
-           vtWideChar   : (wchardummy1,VWideChar: WideChar);
+           vtInteger    : ({$IFDEF CPU64}integerdummy1 : Longint;{$ENDIF CPU64}VInteger: Longint);
+           vtBoolean    : ({$IFDEF CPU64}booldummy : Longint;{$ENDIF CPU64}booldummy1,booldummy2,booldummy3: byte; VBoolean: Boolean);
+           vtChar       : ({$IFDEF CPU64}chardummy : Longint;{$ENDIF CPU64}chardummy1,chardummy2,chardummy3: byte; VChar: Char);
+           vtWideChar   : ({$IFDEF CPU64}widechardummy : Longint;{$ENDIF CPU64}wchardummy1,VWideChar: WideChar);
 {$else ENDIAN_BIG}
 {$else ENDIAN_BIG}
+           vtInteger    : (VInteger: Longint);
            vtBoolean    : (VBoolean: Boolean);
            vtBoolean    : (VBoolean: Boolean);
            vtChar       : (VChar: Char);
            vtChar       : (VChar: Char);
            vtWideChar   : (VWideChar: WideChar);
            vtWideChar   : (VWideChar: WideChar);

+ 0 - 145
rtl/linux/powerpc64/cprt0.as

@@ -1,5 +1,3 @@
-/*
-*/
 /* Startup code for programs linked with GNU libc.
 /* Startup code for programs linked with GNU libc.
    Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
    Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    This file is part of the GNU C Library.
@@ -136,147 +134,4 @@ ___fpc_brk_addr:
 	.comm operatingsystem_parameter_argc, 4
 	.comm operatingsystem_parameter_argc, 4
 	.comm operatingsystem_parameter_argv, 8
 	.comm operatingsystem_parameter_argv, 8
 	.comm operatingsystem_parameter_envp, 8
 	.comm operatingsystem_parameter_envp, 8
-	.comm operatingsystem_parameter_auxp, 8
-	.comm operatingsystem_parameter_exitp, 8
-
-/*
-*/
-/* Startup code for programs linked with GNU libc.
-   Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
-
-.macro LOAD_64BIT_VAL ra, value
-        addis           \ra, 0, \value@highest
-        ori             \ra,\ra,\value@higher
-        sldi            \ra,\ra,32
-        oris            \ra,\ra,\value@h
-        ori             \ra,\ra,\value@l
-.endm
-
-.macro FUNCTION_PROLOG fn
-        .section        ".text"
-        .align  2
-        .globl  \fn
-        .section        ".opd", "aw"
-        .align  3
-        \fn:
-        .quad   .\fn, .TOC.@tocbase, 0
-        .previous
-        .size   \fn, 24
-        .type   \fn, @function
-        .globl  .\fn
-.\fn:
-.endm
-
-.macro FUNCTION_EPILOG fn
-        .long   0
-        .byte   0, 12, 0, 0, 0, 0, 0, 0
-        .type   .\fn, @function
-        .size   .\fn,.-.\fn
-.endm
-
-.macro PRINTMSG msg len
-        lis     4, \msg@highest
-        ori     4, 4, \msg@higher
-        sldi    4, 4, 32
-        oris    4, 4, \msg@h
-        ori     4, 4, \msg@l
-        li      5, \len
-        li      0,4
-        li      3,1
-        sc
-.endm
-        /*
-        cprt0 pascal entry
-        */
-FUNCTION_PROLOG _start
-
-        mr      26, 1
-        /* Set up an initial stack frame, and clear the LR */
-        clrrdi  1, 1, 5       /* align r1 */
-        li      0, 0
-        stdu    1,-48(1)
-        mtlr    0
-        std     0, 0(1)       /* r1 = pointer to NULL value */
-
-        /* store argument count (= 0(r1) )*/
-        ld      3, 0(26)
-        LOAD_64BIT_VAL 10, operatingsystem_parameter_argc
-        stw     3, 0(10)
-        /* calculate argument vector address and store (= 8(r1) + 8 ) */
-        addi    4, 26, 8
-        LOAD_64BIT_VAL 10, operatingsystem_parameter_argv
-        std     4, 0(10)
-        /* store environment pointer (= argv + (argc+1)* 8 ) */
-        addi    5, 3, 1
-        sldi    5, 5, 3
-        add     5, 4, 5
-        LOAD_64BIT_VAL 10, operatingsystem_parameter_envp
-        std     5, 0(10)
-
-        bl      .__libc_init_first
-        nop
-
-        lis     3, _dl_fini@highest
-        ori     3, 3, _dl_fini@higher
-        sldi    3,3,32
-        oris    3, 3, _dl_fini@h
-        ori     3, 3, _dl_fini@l
-
-        bl      .PASCALMAIN
-        nop
-        ori     0, 0, 0
-
-        /* directly jump to exit procedure, not via the function pointer */
-        b       _haltproc
-
-        .align  3
-
-        .global ._haltproc
-        .section        ".opd", "aw"
-        .align 3
-._haltproc:
-        .quad   _haltproc, .TOC.@tocbase, 0
-        .previous
-        .size ._haltproc, 24
-        .global _haltproc
-
-_haltproc:
-        /* exit call */
-        li      0, 1
-        sc
-        b       _haltproc
-
-        /* Define a symbol for the first piece of initialized data.  */
-        .section ".data"
-        .globl  __data_start
-__data_start:
-data_start:
-        .globl  ___fpc_brk_addr /* heap management */
-        .type   ___fpc_brk_addr, @object
-        .size   ___fpc_brk_addr, 4
-___fpc_brk_addr:
-        .long   0
-
-.text
-        .comm operatingsystem_parameter_argc, 4
-        .comm operatingsystem_parameter_argv, 8
-        .comm operatingsystem_parameter_envp, 8
-        .comm operatingsystem_parameter_auxp, 8
-        .comm operatingsystem_parameter_exitp, 8
 
 

+ 0 - 4
rtl/linux/powerpc64/dllprt0.as

@@ -2,7 +2,3 @@
 */
 */
 
 
 /* empty */
 /* empty */
-/*
-*/
-
-/* empty */

+ 0 - 6
rtl/linux/powerpc64/gprt0.as

@@ -1,10 +1,4 @@
 /*
 /*
 */
 */
 
 
-
-/* empty */
-/*
-*/
-
-
 /* empty */
 /* empty */

+ 0 - 129
rtl/linux/powerpc64/prt0.as

@@ -127,132 +127,3 @@ ___fpc_brk_addr:
 	.comm operatingsystem_parameter_argv, 8
 	.comm operatingsystem_parameter_argv, 8
 	.comm operatingsystem_parameter_envp, 8
 	.comm operatingsystem_parameter_envp, 8
 
 
-/*
-*/
-/* Startup code for programs linked with GNU libc.
-   Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
-
-.macro LOAD_64BIT_VAL ra, value
-        lis             \ra,\value@highest
-        ori             \ra,\ra,\value@higher
-        sldi            \ra,\ra,32
-        oris            \ra,\ra,\value@h
-        ori             \ra,\ra,\value@l
-.endm
-
-.macro FUNCTION_PROLOG fn
-        .section        ".text"
-        .align  2
-        .globl  \fn
-        .section        ".opd", "aw"
-        .align  3
-        \fn:
-        .quad   .\fn, .TOC.@tocbase, 0
-        .previous
-        .size   \fn, 24
-        .type   \fn, @function
-        .globl  .\fn
-.\fn:
-.endm
-
-.macro FUNCTION_EPILOG fn
-        .long   0
-        .byte   0, 12, 0, 0, 0, 0, 0, 0
-        .type   .\fn, @function
-        .size   .\fn,.-.\fn
-.endm
-
-.macro PRINTMSG msg len
-        lis     4, \msg@highest
-        ori     4, 4, \msg@higher
-        sldi    4, 4, 32
-        oris    4, 4, \msg@h
-        ori     4, 4, \msg@l
-        li      5, \len
-        li      0,4
-        li      3,1
-        sc
-.endm
-        /*
-        Main Pascal entry point label (function)
-        */
-FUNCTION_PROLOG _start
-
-        mr      26, 1
-        /* Set up an initial stack frame, and clear the LR */
-        clrrdi  1, 1, 5       /* align r1 */
-        li      0, 0
-        stdu    1,-48(1)
-        mtlr    0
-        std     0, 0(1)       /* r1 = pointer to NULL value */
-
-        /* store argument count (= 0(r1) )*/
-        ld      3, 0(26)
-        LOAD_64BIT_VAL 10, operatingsystem_parameter_argc
-        stw     3, 0(10)
-        /* calculate argument vector address and store (= 8(r1) + 8 ) */
-        addi    4, 26, 8
-        LOAD_64BIT_VAL 10, operatingsystem_parameter_argv
-        std     4, 0(10)
-        /* store environment pointer (= argv + (argc+1)* 8 ) */
-        addi    5, 3, 1
-        sldi    5, 5, 3
-        add     5, 4, 5
-        LOAD_64BIT_VAL 10, operatingsystem_parameter_envp
-        std     5, 0(10)
-
-        bl      .PASCALMAIN
-        ori     0, 0, 0
-
-        /* directly jump to exit procedure, not via the function pointer */
-        b       ._haltproc
-
-        .align  3
-
-        .global _haltproc
-        .section        ".opd", "aw"
-        .align 3
-_haltproc:
-        .quad   ._haltproc, .TOC.@tocbase, 0
-        .previous
-        .size _haltproc, 24
-        .global ._haltproc
-
-._haltproc:
-        /* exit call */
-        li      0, 1
-        sc
-        b       ._haltproc
-
-        /* Define a symbol for the first piece of initialized data.  */
-        .section ".data"
-        .globl  __data_start
-__data_start:
-data_start:
-        .globl  ___fpc_brk_addr /* heap management */
-        .type   ___fpc_brk_addr, @object
-        .size   ___fpc_brk_addr, 4
-___fpc_brk_addr:
-        .long   0
-
-.text
-        .comm operatingsystem_parameter_argc, 4
-        .comm operatingsystem_parameter_argv, 8
-        .comm operatingsystem_parameter_envp, 8
-

+ 11 - 10
rtl/linux/powerpc64/sighndh.inc

@@ -18,7 +18,7 @@
 
 
 type
 type
   TPPC_Reg = QWord;
   TPPC_Reg = QWord;
-  { from include/ppc/ptrace.h }
+  { from include/asm-ppc64/ptrace.h }
   pptregs = ^tptregs;
   pptregs = ^tptregs;
   tptregs = record
   tptregs = record
     gpr: array[0..31] of TPPC_Reg;
     gpr: array[0..31] of TPPC_Reg;
@@ -29,38 +29,39 @@ type
     link: TPPC_Reg;
     link: TPPC_Reg;
     xer: TPPC_Reg;
     xer: TPPC_Reg;
     ccr: TPPC_Reg;
     ccr: TPPC_Reg;
-    mq: TPPC_Reg;        { 601 only (not used at present)  }
-                         { Used on APUS to hold IPL value. }
+    softe: TPPC_Reg;     { soft enabled/disabled  }
     trap: TPPC_Reg;      { Reason for being here }
     trap: TPPC_Reg;      { Reason for being here }
     dar: TPPC_Reg;       { Fault registers }
     dar: TPPC_Reg;       { Fault registers }
     dsisr: TPPC_Reg;
     dsisr: TPPC_Reg;
     result: TPPC_Reg;    { Result of a system call }
     result: TPPC_Reg;    { Result of a system call }
   end;
   end;
 
 
-  { from include/asm-ppc/signal.h }
+  { from include/asm-ppc64/signal.h }
   stack_t = record
   stack_t = record
     ss_sp: pointer;
     ss_sp: pointer;
     ss_flags: longint;
     ss_flags: longint;
     ss_size: size_t;
     ss_size: size_t;
   end;
   end;
 
 
-  { from include/asm-ppc/sigcontext.h }
+  { from include/asm-ppc64/sigcontext.h }
   tsigcontext_struct = record
   tsigcontext_struct = record
-    _unused: array[0..3] of PtrUInt;
+    _unused: array[0..3] of dword;
     signal: longint;
     signal: longint;
-    handler: PtrInt;
-    oldmask: PtrInt;
+    pad0 : longint;
+    handler: dword;
+    oldmask: dword;
     pt_regs: pptregs;
     pt_regs: pptregs;
   end;
   end;
 
 
-  { from include/asm-ppc/ucontext.h }
+  { from include/asm-ppc64/ucontext.h }
   pucontext = ^tucontext;
   pucontext = ^tucontext;
   tucontext = record
   tucontext = record
     uc_flags : dword;
     uc_flags : dword;
     uc_link : pucontext;
     uc_link : pucontext;
     uc_stack : stack_t;
     uc_stack : stack_t;
-    uc_mcontext : tsigcontext_struct;
     uc_sigmask : sigset_t;
     uc_sigmask : sigset_t;
+    __unused : array[0..14] of sigset_t;
+    uc_mcontext : tsigcontext_struct;
   end;
   end;
 
 
 
 

+ 4 - 0
rtl/linux/signal.inc

@@ -186,6 +186,10 @@ type
 {$define NEWSIGNAL}
 {$define NEWSIGNAL}
 {$endif CPUx86_64}
 {$endif CPUx86_64}
 
 
+{$ifdef CPUPOWERPC64}
+{$define NEWSIGNAL}
+{$endif CPUPOWERPC64}
+
   SigActionRec = packed record  // this is temporary for the migration
   SigActionRec = packed record  // this is temporary for the migration
     sa_handler : SigActionHandler;
     sa_handler : SigActionHandler;
    {$ifdef NEWSIGNAL}
    {$ifdef NEWSIGNAL}