Browse Source

* some small problems fixed

florian 26 years ago
parent
commit
e6c1b96cff

+ 12 - 2
compiler/cg386ld.pas

@@ -166,8 +166,15 @@ implementation
                                 begin
                                 begin
                                    p^.location.reference.base:=procinfo.framepointer;
                                    p^.location.reference.base:=procinfo.framepointer;
                                    p^.location.reference.offset:=pvarsym(p^.symtableentry)^.address+p^.symtable^.address_fixup;
                                    p^.location.reference.offset:=pvarsym(p^.symtableentry)^.address+p^.symtable^.address_fixup;
+
                                    if (symtabletype in [localsymtable,inlinelocalsymtable]) then
                                    if (symtabletype in [localsymtable,inlinelocalsymtable]) then
-                                     p^.location.reference.offset:=-p^.location.reference.offset;
+                                     begin
+                                        if use_esp_stackframe then
+                                          dec(p^.location.reference.offset,
+                                            pvarsym(p^.symtableentry)^.getsize)
+                                        else
+                                          p^.location.reference.offset:=-p^.location.reference.offset;
+                                     end;
                                    if (lexlevel>(p^.symtable^.symtablelevel)) then
                                    if (lexlevel>(p^.symtable^.symtablelevel)) then
                                      begin
                                      begin
                                         hregister:=getregister32;
                                         hregister:=getregister32;
@@ -929,7 +936,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.70  1999-08-04 13:45:22  florian
+  Revision 1.71  1999-08-07 14:20:55  florian
+    * some small problems fixed
+
+  Revision 1.70  1999/08/04 13:45:22  florian
     + floating point register variables !!
     + floating point register variables !!
     * pairegalloc is now generated for register variables
     * pairegalloc is now generated for register variables
 
 

+ 18 - 3
compiler/cgai386.pas

@@ -2710,6 +2710,9 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
                 parasize:=0
                 parasize:=0
               else
               else
                 parasize:=aktprocsym^.definition^.parast^.datasize+procinfo.call_offset-4;
                 parasize:=aktprocsym^.definition^.parast^.datasize+procinfo.call_offset-4;
+              if stackframe<>0 then
+                exprasmlist^.insert(new(pai386,
+                  op_const_reg(A_SUB,S_L,gettempsize,R_ESP)));
           end
           end
       else
       else
           begin
           begin
@@ -3079,9 +3082,18 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
         begin
         begin
           exprasmlist^.concat(new(pai386,op_none(A_POPA,S_L)));
           exprasmlist^.concat(new(pai386,op_none(A_POPA,S_L)));
         end;
         end;
+      if not(nostackframe) then
+        begin
+          if not inlined then
+            exprasmlist^.concat(new(pai386,op_none(A_LEAVE,S_NO)));
+        end
+      else
+        begin
+          if (gettempsize<>0) and not inlined then
+            exprasmlist^.insert(new(pai386,
+              op_const_reg(A_ADD,S_L,gettempsize,R_ESP)));
+        end;
 
 
-      if not(nostackframe) and not inlined then
-          exprasmlist^.concat(new(pai386,op_none(A_LEAVE,S_NO)));
       { parameters are limited to 65535 bytes because }
       { parameters are limited to 65535 bytes because }
       { ret allows only imm16                    }
       { ret allows only imm16                    }
       if (parasize>65535) and not(pocall_clearstack in aktprocsym^.definition^.proccalloptions) then
       if (parasize>65535) and not(pocall_clearstack in aktprocsym^.definition^.proccalloptions) then
@@ -3176,7 +3188,10 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.27  1999-08-05 23:45:09  peter
+  Revision 1.28  1999-08-07 14:20:57  florian
+    * some small problems fixed
+
+  Revision 1.27  1999/08/05 23:45:09  peter
     * saveregister is now working and used for assert and iocheck (which has
     * saveregister is now working and used for assert and iocheck (which has
       been moved to system.inc because it's now system independent)
       been moved to system.inc because it's now system independent)
 
 

+ 6 - 7
compiler/cpubase.pas

@@ -694,14 +694,10 @@ type
         );
         );
   end;
   end;
 
 
-
 {*****************************************************************************
 {*****************************************************************************
                                  Constants
                                  Constants
 *****************************************************************************}
 *****************************************************************************}
 
 
-type
-  tcpuflags = (cf_registers64);
-
 const
 const
   general_registers = [R_EAX,R_EBX,R_ECX,R_EDX];
   general_registers = [R_EAX,R_EBX,R_ECX,R_EDX];
 
 
@@ -716,9 +712,9 @@ const
   frame_pointer = R_EBP;
   frame_pointer = R_EBP;
   self_pointer  = R_ESI;
   self_pointer  = R_ESI;
   accumulator   = R_EAX;
   accumulator   = R_EAX;
-  scratchregister = R_EDI;
+  scratch_register = R_EDI;
 
 
-  cpuflags : set of tcpuflags = [];
+  cpuflags = [];
 
 
   { sizes }
   { sizes }
   pointersize   = 4;
   pointersize   = 4;
@@ -1011,7 +1007,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.3  1999-08-05 14:58:09  florian
+  Revision 1.4  1999-08-07 14:20:58  florian
+    * some small problems fixed
+
+  Revision 1.3  1999/08/05 14:58:09  florian
     * some fixes for the floating point registers
     * some fixes for the floating point registers
     * more things for the new code generator
     * more things for the new code generator
 
 

+ 10 - 3
compiler/new/cgobj.pas

@@ -31,10 +31,14 @@ unit cgobj;
     type
     type
        qword = comp;
        qword = comp;
 
 
+       talignment = (AM_NATURAL,AM_NONE,AM_2BYTE,AM_4BYTE,AM_8BYTE);
+
        pcg = ^tcg;
        pcg = ^tcg;
        tcg = object
        tcg = object
           scratch_register_array_pointer : aword;
           scratch_register_array_pointer : aword;
           unusedscratchregisters : tregisterset;
           unusedscratchregisters : tregisterset;
+
+          alignment : talignment
           {************************************************}
           {************************************************}
           {                 basic routines                 }
           {                 basic routines                 }
           constructor init;
           constructor init;
@@ -159,7 +163,7 @@ unit cgobj;
           { loadref is true, it assumes that it first must load }
           { loadref is true, it assumes that it first must load }
           { the source address from the memory location where   }
           { the source address from the memory location where   }
           { source points to					}
           { source points to					}
-          procedure g_concatcopy(const source,dest : treference;len : aword;loadref : boolean);virtual;
+          procedure g_concatcopy(list : paasmoutput;const source,dest : treference;len : aword;loadref : boolean);virtual;
 
 
           { uses the addr of ref as param, was emitpushreferenceaddr }
           { uses the addr of ref as param, was emitpushreferenceaddr }
           procedure a_param_ref_addr(list : paasmoutput;r : treference;nr : longint);virtual;
           procedure a_param_ref_addr(list : paasmoutput;r : treference;nr : longint);virtual;
@@ -323,7 +327,7 @@ unit cgobj;
       end;
       end;
 
 
 
 
-    procedure tcg.g_concatcopy(const source,dest : treference;len : aword;loadref : boolean);
+    procedure tcg.g_concatcopy(list : paasmoutput;const source,dest : treference;len : aword;loadref : boolean);
 
 
       begin
       begin
          abstract;
          abstract;
@@ -994,7 +998,10 @@ unit cgobj;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.20  1999-08-06 18:05:52  florian
+  Revision 1.21  1999-08-07 14:21:08  florian
+    * some small problems fixed
+
+  Revision 1.20  1999/08/06 18:05:52  florian
     * implemented some stuff for assignments
     * implemented some stuff for assignments
 
 
   Revision 1.19  1999/08/06 17:00:54  florian
   Revision 1.19  1999/08/06 17:00:54  florian

+ 9 - 1
compiler/pass_2.pas

@@ -425,6 +425,10 @@ implementation
                      3. no call to other procedures
                      3. no call to other procedures
                      4. no interrupt handler
                      4. no interrupt handler
                    }
                    }
+                   {!!!!!! this doesn work yet, because of problems with
+                     with linux and windows
+                   }
+                   (*
                    if assigned(aktprocsym) then
                    if assigned(aktprocsym) then
                      begin
                      begin
                        if not(aktprocsym^.definition^.proctypeoption in [potype_constructor,potype_destructor]) and
                        if not(aktprocsym^.definition^.proctypeoption in [potype_constructor,potype_destructor]) and
@@ -450,6 +454,7 @@ implementation
                          aktprocsym^.definition^.parast^.address_fixup:=procinfo.call_offset;
                          aktprocsym^.definition^.parast^.address_fixup:=procinfo.call_offset;
                        end;
                        end;
                      end;
                      end;
+                   *)
                    if (p^.registers32<4) then
                    if (p^.registers32<4) then
                      begin
                      begin
                         for i:=1 to maxvarregs do
                         for i:=1 to maxvarregs do
@@ -648,7 +653,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.30  1999-08-04 14:21:07  florian
+  Revision 1.31  1999-08-07 14:20:59  florian
+    * some small problems fixed
+
+  Revision 1.30  1999/08/04 14:21:07  florian
     * now every available fpu register is used for
     * now every available fpu register is used for
       fpu register variables
       fpu register variables
 
 

+ 31 - 1
compiler/symdef.inc

@@ -475,6 +475,33 @@
       end;
       end;
 
 
 
 
+   function tdef.is_intregable : boolean;
+
+     begin
+        is_intregable:=false;
+        case deftype of
+          pointerdef,
+          enumdef,
+          procvardef :
+            is_intregable:=true;
+          orddef :
+            case porddef(@self)^.typ of
+              bool8bit,bool16bit,bool32bit,
+              u8bit,u16bit,u32bit,
+              s8bit,s16bit,s32bit:
+                is_intregable:=true;
+            end;
+          setdef:
+            is_intregable:=is_smallset(@self);
+        end;
+     end;
+
+   function tdef.is_fpuregable : boolean;
+
+     begin
+        is_fpuregable:=not(pfloatdef(@self)^.typ in [f32bit,f16bit]);
+     end;
+
 {****************************************************************************
 {****************************************************************************
                                TSTRINGDEF
                                TSTRINGDEF
 ****************************************************************************}
 ****************************************************************************}
@@ -3590,7 +3617,10 @@ Const local_symtable_index : longint = $8001;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.145  1999-08-07 13:36:54  daniel
+  Revision 1.146  1999-08-07 14:21:00  florian
+    * some small problems fixed
+
+  Revision 1.145  1999/08/07 13:36:54  daniel
   * Recommitted the arraydef overflow bugfix.
   * Recommitted the arraydef overflow bugfix.
 
 
   Revision 1.143  1999/08/06 11:13:30  peter
   Revision 1.143  1999/08/06 11:13:30  peter

+ 6 - 1
compiler/symdefh.inc

@@ -86,6 +86,8 @@
           procedure generate_rtti;virtual;
           procedure generate_rtti;virtual;
           procedure write_rtti_data;virtual;
           procedure write_rtti_data;virtual;
           procedure write_child_rtti_data;virtual;
           procedure write_child_rtti_data;virtual;
+          function is_intregable : boolean;
+          function is_fpuregable : boolean;
        private
        private
           savesize  : longint;
           savesize  : longint;
        end;
        end;
@@ -517,7 +519,10 @@
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.38  1999-08-05 16:53:15  peter
+  Revision 1.39  1999-08-07 14:21:02  florian
+    * some small problems fixed
+
+  Revision 1.38  1999/08/05 16:53:15  peter
     * V_Fatal=1, all other V_ are also increased
     * V_Fatal=1, all other V_ are also increased
     * Check for local procedure when assigning procvar
     * Check for local procedure when assigning procvar
     * fixed comment parsing because directives
     * fixed comment parsing because directives

+ 18 - 36
compiler/symsym.inc

@@ -872,53 +872,32 @@
          varstate:=vs_used;
          varstate:=vs_used;
          varoptions:=[];
          varoptions:=[];
          { can we load the value into a register ? }
          { can we load the value into a register ? }
-         case p^.deftype of
-           pointerdef,
-           enumdef,
-           procvardef :
-{$ifdef INCLUDEOK}
-             include(varoptions,vo_regable);
-{$else}
-             varoptions:=varoptions+[vo_regable];
-{$endif}
-           orddef :
-             case porddef(p)^.typ of
-               bool8bit,bool16bit,bool32bit,
-               u8bit,u16bit,u32bit,
-               s8bit,s16bit,s32bit :
-{$ifdef INCLUDEOK}
-                 include(varoptions,vo_regable);
-{$else}
-                 varoptions:=varoptions+[vo_regable];
-{$endif}
-               else
+         if p^.is_intregable then
+
 {$ifdef INCLUDEOK}
 {$ifdef INCLUDEOK}
-                 exclude(varoptions,vo_regable);
+           include(varoptions,vo_regable)
 {$else}
 {$else}
-                 varoptions:=varoptions-[vo_regable];
+           varoptions:=varoptions+[vo_regable]
 {$endif}
 {$endif}
-             end;
-           setdef:
-             if psetdef(p)^.settype=smallset then
+         else
 {$ifdef INCLUDEOK}
 {$ifdef INCLUDEOK}
-                 include(varoptions,vo_regable);
+           exclude(varoptions,vo_regable);
 {$else}
 {$else}
-                 varoptions:=varoptions+[vo_regable];
+           varoptions:=varoptions-[vo_regable];
 {$endif}
 {$endif}
-           floatdef:
-             if not(pfloatdef(p)^.typ in [f32bit,f16bit]) then
+
+         if p^.is_fpuregable then
 {$ifdef INCLUDEOK}
 {$ifdef INCLUDEOK}
-               include(varoptions,vo_fpuregable);
+           include(varoptions,vo_fpuregable)
 {$else}
 {$else}
-               varoptions:=varoptions+[vo_fpuregable];
+           varoptions:=varoptions+[vo_fpuregable]
 {$endif}
 {$endif}
-           else
+         else
 {$ifdef INCLUDEOK}
 {$ifdef INCLUDEOK}
-             exclude(varoptions,vo_regable);
+           exclude(varoptions,vo_regable);
 {$else}
 {$else}
-             varoptions:=varoptions-[vo_regable];
+           varoptions:=varoptions-[vo_fpuregable];
 {$endif}
 {$endif}
-         end;
          reg:=R_NO;
          reg:=R_NO;
       end;
       end;
 
 
@@ -2118,7 +2097,10 @@
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.109  1999-08-07 13:24:34  daniel
+  Revision 1.110  1999-08-07 14:21:03  florian
+    * some small problems fixed
+
+  Revision 1.109  1999/08/07 13:24:34  daniel
   * Fixed open arrays
   * Fixed open arrays
 
 
   Revision 1.108  1999/08/05 16:53:17  peter
   Revision 1.108  1999/08/05 16:53:17  peter

+ 9 - 1
compiler/tccnv.pas

@@ -709,8 +709,13 @@ implementation
             end;
             end;
            if p^.explizit then
            if p^.explizit then
             begin
             begin
+              { check if the result could be in a register }
+              if not(p^.resulttype^.is_intregable) and
+                not(p^.resulttype^.is_fpuregable) then
+                make_not_regable(p^.left);
               { boolean to byte are special because the
               { boolean to byte are special because the
                 location can be different }
                 location can be different }
+
               if is_integer(p^.resulttype) and
               if is_integer(p^.resulttype) and
                  is_boolean(p^.left^.resulttype) then
                  is_boolean(p^.left^.resulttype) then
                begin
                begin
@@ -919,7 +924,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.44  1999-08-04 13:03:14  jonas
+  Revision 1.45  1999-08-07 14:21:04  florian
+    * some small problems fixed
+
+  Revision 1.44  1999/08/04 13:03:14  jonas
     * all tokens now start with an underscore
     * all tokens now start with an underscore
     * PowerPC compiles!!
     * PowerPC compiles!!
 
 

+ 4 - 2
compiler/types.pas

@@ -163,7 +163,6 @@ interface
     { returns the mmx type }
     { returns the mmx type }
     function mmx_type(p : pdef) : tmmxtype;
     function mmx_type(p : pdef) : tmmxtype;
 
 
-
 implementation
 implementation
 
 
     uses
     uses
@@ -975,7 +974,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.82  1999-08-07 13:36:56  daniel
+  Revision 1.83  1999-08-07 14:21:06  florian
+    * some small problems fixed
+
+  Revision 1.82  1999/08/07 13:36:56  daniel
   * Recommitted the arraydef overflow bugfix.
   * Recommitted the arraydef overflow bugfix.
 
 
   Revision 1.80  1999/08/05 22:42:49  daniel
   Revision 1.80  1999/08/05 22:42:49  daniel