ソースを参照

* sparc fixes

peter 22 年 前
コミット
1b633246b9

+ 18 - 13
compiler/ncgadd.pas

@@ -228,20 +228,18 @@ interface
     procedure tcgaddnode.release_reg_left_right;
       begin
         if (right.location.loc in [LOC_REGISTER,LOC_FPUREGISTER]) and
-           ((location.loc<>LOC_REGISTER) or
-            (
-             (location.register.enum <> right.location.register.enum) and
-             (location.register.number <> right.location.register.number)
-            )
-           ) then
+           not(
+               (location.loc=LOC_REGISTER) and
+               (location.register.enum=right.location.register.enum) and
+               (location.register.number=right.location.register.number)
+              ) then
           location_release(exprasmlist,right.location);
         if (left.location.loc in [LOC_REGISTER,LOC_FPUREGISTER]) and
-           ((location.loc<>LOC_REGISTER) or
-            (
-             (location.register.enum <> left.location.register.enum) and
-             (location.register.number <> left.location.register.number)
-            )
-           ) then
+           not(
+               (location.loc=LOC_REGISTER) and
+               (location.register.enum=left.location.register.enum) and
+               (location.register.number=left.location.register.number)
+              ) then
           location_release(exprasmlist,left.location);
       end;
 
@@ -568,6 +566,8 @@ interface
         { emit overflow check if enabled }
         if checkoverflow then
            cg.g_overflowcheck(exprasmlist,Location,ResultType.Def);
+
+        release_reg_left_right;
       end;
 
 
@@ -697,6 +697,8 @@ interface
         { emit overflow check if required }
         if checkoverflow then
           cg.g_overflowcheck(exprasmlist,Location,ResultType.Def);
+
+        release_reg_left_right;
       end;
 
 
@@ -752,7 +754,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.14  2003-07-06 17:44:12  peter
+  Revision 1.15  2003-07-08 21:24:59  peter
+    * sparc fixes
+
+  Revision 1.14  2003/07/06 17:44:12  peter
     * cleanup and first sparc implementation
 
   Revision 1.13  2003/06/12 16:43:07  peter

+ 35 - 21
compiler/ncgcal.pas

@@ -59,6 +59,7 @@ interface
           function  align_parasize:longint;virtual;
           procedure pop_parasize(pop_size:longint);virtual;
           procedure push_framepointer;virtual;
+          procedure free_pushed_framepointer;virtual;
           procedure extra_interrupt_code;virtual;
        public
           procedure pass_2;override;
@@ -390,6 +391,12 @@ implementation
       end;
 
 
+    procedure tcgcallnode.free_pushed_framepointer;
+      begin
+        paramanager.freeintparaloc(exprasmlist,1);
+      end;
+
+
     procedure tcgcallnode.handle_return_value;
       var
         cgsize : tcgsize;
@@ -651,7 +658,6 @@ implementation
       {$endif}
          pushedother : tpushedsavedother;
          oldpushedparasize : longint;
-         paraitem : tparaitem;
          { adress returned from an I/O-error }
          iolabel : tasmlabel;
          { help reference pointer }
@@ -664,6 +670,26 @@ implementation
 {$endif x86}
          vmtreg,vmtreg2 : tregister;
          oldaktcallnode : tcallnode;
+
+         procedure freeparas;
+         var
+           paraitem : tparaitem;
+         begin
+           { free the resources allocated for the parameters }
+           paraitem:=tparaitem(procdefinition.para.first);
+           while assigned(paraitem) do
+             begin
+               paramanager.freeparaloc(exprasmlist,paraitem.callerparaloc);
+               paraitem:=tparaitem(paraitem.next);
+             end;
+           { free pushed base pointer }
+           if (right=nil) and
+              (current_procinfo.procdef.parast.symtablelevel>=normal_function_level) and
+              assigned(tprocdef(procdefinition).parast) and
+              ((tprocdef(procdefinition).parast.symtablelevel)>normal_function_level) then
+             free_pushed_framepointer;
+         end;
+
       begin
          if not assigned(procdefinition) then
            internalerror(200305264);
@@ -920,12 +946,7 @@ implementation
                    cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,vmtreg,vmtreg2);
 {$endif newra}
                    { free the resources allocated for the parameters }
-                   paraitem:=tparaitem(procdefinition.para.first);
-                   while assigned(paraitem) do
-                     begin
-                       paramanager.freeparaloc(exprasmlist,paraitem.callerparaloc);
-                       paraitem:=tparaitem(paraitem.next);
-                     end;
+                   freeparas;
 
 {$ifdef newra}
                    rg.allocexplicitregistersint(exprasmlist,regs_to_alloc);
@@ -941,13 +962,8 @@ implementation
                 end
               else
                 begin
-                 { free the resources allocated for the parameters }
-                  paraitem:=tparaitem(procdefinition.para.first);
-                  while assigned(paraitem) do
-                    begin
-                      paramanager.freeparaloc(exprasmlist,paraitem.callerparaloc);
-                      paraitem:=tparaitem(paraitem.next);
-                    end;
+                  { free the resources allocated for the parameters }
+                  freeparas;
 
 {$ifdef newra}
                   rg.allocexplicitregistersint(exprasmlist,regs_to_alloc);
@@ -992,12 +1008,7 @@ implementation
 {$endif newra}
 
               { free the resources allocated for the parameters }
-              paraitem:=tparaitem(procdefinition.para.first);
-              while assigned(paraitem) do
-                begin
-                  paramanager.freeparaloc(exprasmlist,paraitem.callerparaloc);
-                  paraitem:=tparaitem(paraitem.next);
-                end;
+              freeparas;
 
 {$ifdef newra}
               rg.allocexplicitregistersint(exprasmlist,regs_to_alloc);
@@ -1518,7 +1529,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.100  2003-07-06 21:50:33  jonas
+  Revision 1.101  2003-07-08 21:24:59  peter
+    * sparc fixes
+
+  Revision 1.100  2003/07/06 21:50:33  jonas
     * fixed ppc compilation problems and changed VOLATILE_REGISTERS for x86
       so that it doesn't include ebp and esp anymore
 

+ 5 - 2
compiler/paramgr.pas

@@ -56,7 +56,7 @@ unit paramgr;
           { Returns true if a parameter needs to be copied on the stack, this
             is required for cdecl procedures
           }
-          function copy_value_on_stack(def : tdef;calloption : tproccalloption) : boolean;
+          function copy_value_on_stack(def : tdef;calloption : tproccalloption) : boolean;virtual;
           {# Returns a structure giving the information on
             the storage of the parameter (which must be
             an integer parameter). This is only used when calling
@@ -443,7 +443,10 @@ end.
 
 {
    $Log$
-   Revision 1.48  2003-07-05 20:11:41  jonas
+   Revision 1.49  2003-07-08 21:24:59  peter
+     * sparc fixes
+
+   Revision 1.48  2003/07/05 20:11:41  jonas
      * create_paraloc_info() is now called separately for the caller and
        callee info
      * fixed ppc cycle

+ 10 - 1
compiler/powerpc/nppccal.pas

@@ -33,6 +33,7 @@ interface
        tppccallnode = class(tcgcallnode)
           function pass_1 : tnode;override;
           procedure push_framepointer;override;
+          procedure free_pushed_framepointer;override;
        end;
 
 implementation
@@ -120,12 +121,20 @@ implementation
          internalerror(2002081303);
     end;
 
+
+  procedure tppccallnode.free_pushed_framepointer;
+    begin
+    end;
+
 begin
    ccallnode:=tppccallnode;
 end.
 {
   $Log$
-  Revision 1.19  2003-07-06 20:25:03  jonas
+  Revision 1.20  2003-07-08 21:24:59  peter
+    * sparc fixes
+
+  Revision 1.19  2003/07/06 20:25:03  jonas
     * fixed ppc compiler
 
   Revision 1.18  2003/06/13 21:19:32  peter

+ 6 - 1
compiler/pstatmnt.pas

@@ -1140,6 +1140,7 @@ implementation
          include(current_procinfo.flags,pi_is_assembler);
          p:=_asm_statement;
 
+{$ifndef sparc}
          { set the framepointer to esp for assembler functions when the
            following conditions are met:
            - if the are no local variables (except the allocated result)
@@ -1171,6 +1172,7 @@ implementation
                  then
                  OptimizeFramePointer(tasmnode(p));
             end;
+{$endif sparc}
 
         { Flag the result as assigned when it is returned in a
           register.
@@ -1189,7 +1191,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.105  2003-06-17 16:34:44  jonas
+  Revision 1.106  2003-07-08 21:24:59  peter
+    * sparc fixes
+
+  Revision 1.105  2003/06/17 16:34:44  jonas
     * lots of newra fixes (need getfuncretparaloc implementation for i386)!
     * renamed all_intregisters to volatile_intregisters and made it
       processor dependent

+ 10 - 5
compiler/sparc/cgcpu.pas

@@ -119,8 +119,8 @@ implementation
           InternalError(2002100804);
         result :=not(assigned(ref.symbol))and
                   (((ref.index.number = NR_NO) and
-                   (ref.offset >= low(smallint)) and
-                    (ref.offset <= high(smallint))) or
+                   (ref.offset >= simm13lo) and
+                    (ref.offset <= simm13hi)) or
                   ((ref.index.number <> NR_NO) and
                   (ref.offset = 0)));
       end;
@@ -1005,7 +1005,8 @@ implementation
          if not issimpleref(source) or
             (
               (source.index.number<>NR_NO) and
-              ((source.offset+longint(len))>high(smallint))
+              (((source.offset+longint(len))>simm13hi) or
+               ((source.offset+longint(len))<simm13lo))
             ) then
            begin
 {$ifdef newra}
@@ -1027,7 +1028,8 @@ implementation
         if not issimpleref(dest) or
            (
             (dest.index.number<>NR_NO) and
-            ((dest.offset + longint(len)) > high(smallint))
+            (((dest.offset + longint(len)) > simm13hi) or
+             ((dest.offset + longint(len)) < simm13lo))
            ) then
           begin
 {$ifdef newra}
@@ -1255,7 +1257,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.64  2003-07-06 22:10:13  peter
+  Revision 1.65  2003-07-08 21:24:59  peter
+    * sparc fixes
+
+  Revision 1.64  2003/07/06 22:10:13  peter
     * operand order of cmp fixed
 
   Revision 1.63  2003/07/06 17:58:22  peter

+ 9 - 5
compiler/sparc/cpugas.pas

@@ -48,11 +48,10 @@ unit cpugas;
           begin
             inc(offset,offsetfixup);
             offsetfixup:=0;
-            if assigned(symbol) then
+            if (base.number=NR_NO) and (index.number=NR_NO) then
               begin
-                 if (base.number<>NR_NO) or (index.number<>NR_NO) then
-                   internalerror(2003052601);
-                 GetReferenceString:=symbol.name;
+                 if assigned(symbol) then
+                   GetReferenceString:=symbol.name;
                  if offset>0 then
                    GetReferenceString:=GetReferenceString+'+'+ToStr(offset)
                  else if offset<0 then
@@ -66,6 +65,8 @@ unit cpugas;
               end
             else
               begin
+                if assigned(symbol) then
+                  internalerror(2003052601);
                 GetReferenceString:='[';
                 if base.number<>NR_NO then
                   GetReferenceString:=GetReferenceString+std_reg2str[base.enum];
@@ -204,7 +205,10 @@ begin
 end.
 {
     $Log$
-    Revision 1.20  2003-07-02 22:18:04  peter
+    Revision 1.21  2003-07-08 21:25:00  peter
+      * sparc fixes
+
+    Revision 1.20  2003/07/02 22:18:04  peter
       * paraloc splitted in callerparaloc,calleeparaloc
       * sparc calling convention updates
 

+ 35 - 2
compiler/sparc/cpupara.pas

@@ -26,11 +26,13 @@ interface
 
     uses
       cpubase,
-      aasmtai,
+      aasmtai,globtype,
       symconst,symbase,symtype,symdef,paramgr;
 
     type
       TSparcParaManager=class(TParaManager)
+        function copy_value_on_stack(def : tdef;calloption : tproccalloption) : boolean;override;
+        function push_addr_param(def : tdef;calloption : tproccalloption) : boolean;override;
         {Returns a structure giving the information on the storage of the parameter
         (which must be an integer parameter)
         @param(nr Parameter number of routine, starting from 1)}
@@ -54,6 +56,34 @@ implementation
       cpuinfo,cginfo,cgbase,
       defutil,rgobj;
 
+    function tsparcparamanager.copy_value_on_stack(def : tdef;calloption : tproccalloption) : boolean;
+      begin
+        result:=false;
+      end;
+
+
+    { true if a parameter is too large to copy and only the address is pushed }
+    function tsparcparamanager.push_addr_param(def : tdef;calloption : tproccalloption) : boolean;
+      begin
+        push_addr_param:=false;
+        case def.deftype of
+          recorddef,
+          arraydef,
+          variantdef,
+          formaldef :
+            push_addr_param:=true;
+          objectdef :
+            push_addr_param:=is_object(def);
+          stringdef :
+            push_addr_param:=(tstringdef(def).string_typ in [st_shortstring,st_longstring]);
+          procvardef :
+            push_addr_param:=(po_methodpointer in tprocvardef(def).procoptions);
+          setdef :
+            push_addr_param:=(tsetdef(def).settype<>smallset);
+        end;
+      end;
+
+
     function TSparcParaManager.GetIntParaLoc(List:TAasmOutput;nr:longint):TParaLocation;
       begin
         if nr<1 then
@@ -278,7 +308,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.25  2003-07-06 22:10:56  peter
+  Revision 1.26  2003-07-08 21:25:00  peter
+    * sparc fixes
+
+  Revision 1.25  2003/07/06 22:10:56  peter
     * big endian first allocates high
 
   Revision 1.24  2003/07/06 17:58:22  peter

+ 17 - 2
compiler/sparc/ncpuadd.pas

@@ -153,7 +153,9 @@ interface
           location.register:=right.location.register;
 
         exprasmlist.concat(taicpu.op_reg_reg_reg(op,
-           left.location.register,right.location.register,location.register))
+           left.location.register,right.location.register,location.register));
+
+        release_reg_left_right;
       end;
 
 
@@ -175,6 +177,8 @@ interface
            left.location.register,right.location.register));
         { Delay slot (can only contain integer operation) }
         exprasmlist.concat(taicpu.op_none(A_NOP));
+
+        release_reg_left_right;
       end;
 
 
@@ -195,6 +199,8 @@ interface
 
         location_reset(location,LOC_FLAGS,OS_NO);
         location.resflags:=getresflags(true);
+
+        release_reg_left_right;
       end;
 
 
@@ -215,6 +221,8 @@ interface
 
         location_reset(location,LOC_FLAGS,OS_NO);
         location.resflags:=getresflags(true);
+
+        release_reg_left_right;
       end;
 
 
@@ -228,6 +236,8 @@ interface
 
         location_reset(location,LOC_FLAGS,OS_NO);
         location.resflags:=getresflags(unsigned);
+
+        release_reg_left_right;
       end;
 
 
@@ -252,6 +262,8 @@ interface
 
         location_reset(location,LOC_FLAGS,OS_NO);
         location.resflags:=getresflags(unsigned);
+
+        release_reg_left_right;
       end;
 
 begin
@@ -259,7 +271,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.17  2003-07-06 22:09:50  peter
+  Revision 1.18  2003-07-08 21:25:00  peter
+    * sparc fixes
+
+  Revision 1.17  2003/07/06 22:09:50  peter
     * signed compare fixed
 
   Revision 1.16  2003/07/06 17:44:12  peter

+ 9 - 2
rtl/linux/systypes.inc

@@ -69,13 +69,17 @@ type
 {$ifdef powerpc}
   dev_t = cardinal;
 {$else powerpc}
+{$ifdef sparc}
+  dev_t = cardinal;
+{$else sparc}
 {$error dev_t unknown for this processor}
+{$endif sparc}
 {$endif powerpc}
 {$endif m68k}
 {$endif i386}
 
 { definition of stat record type }
-{$i stat.inc}  
+{$i stat.inc}
   PStat=^Stat;
   TStat=Stat;
 
@@ -126,7 +130,10 @@ type
 
 {
   $Log$
-  Revision 1.9  2003-07-08 14:18:40  peter
+  Revision 1.10  2003-07-08 21:23:24  peter
+    * sparc fixes
+
+  Revision 1.9  2003/07/08 14:18:40  peter
     * fdset changed to 1024 bits
 
   Revision 1.8  2003/05/15 22:50:50  jonas

+ 7 - 1
rtl/linux/unixsysc.inc

@@ -856,6 +856,8 @@ end;
       Port IO functions
 --------------------------------}
 
+{$ifdef i386}
+
 Function  IOperm (From,Num : Cardinal; Value : Longint) : boolean;
 {
   Set permissions on NUM ports starting with port FROM to VALUE
@@ -882,10 +884,14 @@ begin
   LinuxError:=Errno;
 end;
 
+{$endif i386}
 
 {
   $Log$
-  Revision 1.8  2002-12-18 16:43:26  marco
+  Revision 1.9  2003-07-08 21:23:24  peter
+    * sparc fixes
+
+  Revision 1.8  2002/12/18 16:43:26  marco
    * new unix rtl, linux part.....
 
   Revision 1.7  2002/09/07 16:01:20  peter

+ 9 - 6
rtl/unix/unix.pp

@@ -422,15 +422,15 @@ type
 function MMap(const m:tmmapargs):longint;
 function MUnMap (P : Pointer; Size : Longint) : Boolean;
 
-{**************************
-     Port IO functions
-***************************}
+{***********************************
+  Port IO functions (x86 specific)
+***********************************}
 
+{$ifdef i386}
 Function  IOperm (From,Num : Cardinal; Value : Longint) : boolean;
 {$ifndef BSD}
 Function  IoPL(Level : longint) : Boolean;
 {$endif}
-{$ifdef i386}
 Procedure WritePort (Port : Longint; Value : Byte);
 Procedure WritePort (Port : Longint; Value : Word);
 Procedure WritePort (Port : Longint; Value : Longint);
@@ -449,7 +449,7 @@ function  ReadPortL (Port : Longint): LongInt;
 Procedure ReadPortL (Port : Longint; Var Buf; Count: longint);
 Procedure ReadPortW (Port : Longint; Var Buf; Count: longint);
 Procedure ReadPortB (Port : Longint; Var Buf; Count: longint);
-{$endif}
+{$endif i386}
 
 {**************************
     Utility functions
@@ -3059,7 +3059,10 @@ End.
 
 {
   $Log$
-  Revision 1.29  2003-05-30 19:58:40  marco
+  Revision 1.30  2003-07-08 21:23:24  peter
+    * sparc fixes
+
+  Revision 1.29  2003/05/30 19:58:40  marco
    * Getting NetBSD/i386 to compile.
 
   Revision 1.28  2003/05/29 19:16:16  marco