Explorar o código

+ generic FPC_CHECKPOINTER
+ first parameter offset in stack now portable
* rename some constants
+ move some cpu stuff to other units
- remove unused constents
* fix stacksize for some targets
* fix generic size problems which depend now on EXTEND_SIZE constant

carl %!s(int64=23) %!d(string=hai) anos
pai
achega
87aa88e9b7

+ 17 - 8
compiler/aoptcs.pas

@@ -99,10 +99,10 @@ End;
 Procedure TRegInfo.Clear;
 Begin
   RegsLoadedForRef   := [];
-  NewRegsEncountered := [ProcInfo.FramePointer, stack_pointer];
-  OldRegsEncountered := [ProcInfo.FramePointer, stack_pointer];
+  NewRegsEncountered := [ProcInfo.FramePointer, STACK_POINTER_REG];
+  OldRegsEncountered := [ProcInfo.FramePointer, STACK_POINTER_REG];
   New2OldReg[ProcInfo.FramePointer] := ProcInfo.FramePointer;
-  New2OldReg[stack_pointer] := stack_pointer;
+  New2OldReg[STACK_POINTER_REG] := STACK_POINTER_REG;
 End;
 
 Procedure TRegInfo.AddReg(OldReg, NewReg: TRegister);
@@ -250,11 +250,11 @@ Begin
               Begin
                 With PInstr(NewP)^.oper[LoadSrc].ref^ Do
                   Begin
-                    If Not(Base in [ProcInfo.FramePointer, R_NO, stack_pointer])
+                    If Not(Base in [ProcInfo.FramePointer, R_NO, STACK_POINTER_REG])
 { it won't do any harm if the register is already in RegsLoadedForRef }
                       Then RegsLoadedForRef := RegsLoadedForRef + [Base];
 {$ifdef RefsHaveIndexReg}
-                    If Not(Index in [ProcInfo.FramePointer, R_NO, stack_pointer])
+                    If Not(Index in [ProcInfo.FramePointer, R_NO, STACK_POINTER_REG])
                       Then RegsLoadedForRef := RegsLoadedForRef + [Index];
 {$endif RefsHaveIndexReg}
                   End;
@@ -282,7 +282,7 @@ Begin
               Begin
                 If Not(Base in [ProcInfo.FramePointer,
                                 RegMaxSize(PInstr(NewP)^.oper[LoadDst].reg),
-                                R_NO,stack_pointer])
+                                R_NO,STACK_POINTER_REG])
 { It won't do any harm if the register is already in RegsLoadedForRef }
                   Then
                     Begin
@@ -309,7 +309,7 @@ Begin
 { RegsLoadedForReg, since if it's loaded with a new value, it certainly     }
 { will still be used later on                                               }
             If Not(RegMaxSize(PInstr(NewP)^.oper[LoadDst].reg) In
-                [ProcInfo.FramePointer,R_NO,stack_pointer])
+                [ProcInfo.FramePointer,R_NO,STACK_POINTER_REG])
               Then
                 Begin
                   RegsLoadedForRef := RegsLoadedForRef -
@@ -850,7 +850,16 @@ End.
 
 {
   $Log$
-  Revision 1.3  2002-04-15 18:55:39  carl
+  Revision 1.4  2002-04-20 21:32:23  carl
+  + generic FPC_CHECKPOINTER
+  + first parameter offset in stack now portable
+  * rename some constants
+  + move some cpu stuff to other units
+  - remove unused constents
+  * fix stacksize for some targets
+  * fix generic size problems which depend now on EXTEND_SIZE constant
+
+  Revision 1.3  2002/04/15 18:55:39  carl
   + change reg2str array use
 
   Revision 1.2  2002/04/14 16:49:30  carl

+ 11 - 2
compiler/cgbase.pas

@@ -41,7 +41,7 @@ unit cgbase;
     const
        tcgsize2size: Array[tcgsize] of longint = (0,
           8,16,32,64,8,16,32,64,
-          32,64,80,64,
+          32,64,EXTENDED_SIZE*8,64,
           8,16,32,64,128,8,16,32,64,128);
 
        tfloat2tcgsize: array[tfloattype] of tcgsize =
@@ -529,7 +529,16 @@ begin
 end.
 {
   $Log$
-  Revision 1.10  2002-04-07 09:13:39  carl
+  Revision 1.11  2002-04-20 21:32:23  carl
+  + generic FPC_CHECKPOINTER
+  + first parameter offset in stack now portable
+  * rename some constants
+  + move some cpu stuff to other units
+  - remove unused constents
+  * fix stacksize for some targets
+  * fix generic size problems which depend now on EXTEND_SIZE constant
+
+  Revision 1.10  2002/04/07 09:13:39  carl
   + documentation
   - remove unused variables
 

+ 16 - 2
compiler/cginfo.pas

@@ -26,6 +26,8 @@ unit cginfo;
 
 interface
 
+  uses cpuinfo;
+
     type
        TOpCg = (OP_NONE,
                 OP_ADD,OP_AND,OP_DIV,OP_IDIV,OP_IMUL,OP_MUL,OP_NEG,OP_NOT,
@@ -85,8 +87,11 @@ interface
 
     const
       TCGSize2Size : Array[tcgsize] of integer =
+         { integer values }
         (0,1,2,4,8,1,2,4,8,
-         4,8,10,8,
+         { floating point values } 
+         4,8,EXTENDED_SIZE,8,
+         { multimedia values }
          1,2,4,8,16,1,2,4,8,16);
 
 
@@ -95,7 +100,16 @@ implementation
 end.
 {
   $Log$
-  Revision 1.2  2002-04-19 15:46:01  peter
+  Revision 1.3  2002-04-20 21:32:23  carl
+  + generic FPC_CHECKPOINTER
+  + first parameter offset in stack now portable
+  * rename some constants
+  + move some cpu stuff to other units
+  - remove unused constents
+  * fix stacksize for some targets
+  * fix generic size problems which depend now on EXTEND_SIZE constant
+
+  Revision 1.2  2002/04/19 15:46:01  peter
     * mangledname rewrite, tprocdef.mangledname is now created dynamicly
       in most cases and not written to the ppu
     * add mangeledname_prefix() routine to generate the prefix of

+ 14 - 5
compiler/cgobj.pas

@@ -842,7 +842,7 @@ unit cgobj;
            end;
         { omit stack frame ? }
         if not inlined then
-          if procinfo^.framepointer=stack_pointer then
+          if procinfo^.framepointer=STACK_POINTER_REG then
             begin
                CGMessage(cg_d_stackframe_omited);
                nostackframe:=true;
@@ -1025,7 +1025,7 @@ unit cgobj;
                        reset_reference(hr);
                        hr.symbol:=procinfo^._class^.get_inittable_label;
                        a_paramaddr_ref(list,hr,2);
-                       a_param_reg(list,OS_ADDR,self_pointer,1);
+                       a_param_reg(list,OS_ADDR,self_pointer_reg,1);
                        a_call_name(list,'FPC_FINALIZE',0);
                        a_label(list,nofinal);
                     end;
@@ -1090,8 +1090,8 @@ unit cgobj;
                   { return self in EAX }
                   a_label(list,quickexitlabel);
                   a_reg_alloc(list,accumulator);
-                  a_load_reg_reg(list,OS_ADDR,self_pointer,accumulator);
-                  a_reg_dealloc(list,self_pointer);
+                  a_load_reg_reg(list,OS_ADDR,self_pointer_reg,accumulator);
+                  a_reg_dealloc(list,self_pointer_reg);
                   a_label(list,quickexitlabel);
                   { we can't clear the zero flag because the Alpha     }
                   { for example doesn't have flags, we have to compare }
@@ -1660,7 +1660,16 @@ finalization
 end.
 {
   $Log$
-  Revision 1.14  2002-04-15 19:44:18  peter
+  Revision 1.15  2002-04-20 21:32:23  carl
+  + generic FPC_CHECKPOINTER
+  + first parameter offset in stack now portable
+  * rename some constants
+  + move some cpu stuff to other units
+  - remove unused constents
+  * fix stacksize for some targets
+  * fix generic size problems which depend now on EXTEND_SIZE constant
+
+  Revision 1.14  2002/04/15 19:44:18  peter
     * fixed stackcheck that would be called recursively when a stack
       error was found
     * generic changeregsize(reg,size) for i386 register resizing

+ 11 - 4
compiler/globals.pas

@@ -86,7 +86,7 @@ interface
        end;
 
 
-   { the ordinal type used when evaluating constant integer expressions }
+   {# the ordinal type used when evaluating constant integer expressions }
    TConstExprInt = int64;
    { ... the same unsigned }
    TConstExprUInt = {$ifdef fpc}qword{$else}int64{$endif};
@@ -191,7 +191,6 @@ interface
 
      { Memory sizes }
        heapsize,
-       maxheapsize,
        stacksize    : longint;
 
 {$Ifdef EXTDEBUG}
@@ -1441,7 +1440,6 @@ implementation
         in options or init_parser }
         stacksize:=0;
         heapsize:=0;
-        maxheapsize:=0;
 
       { compile state }
         in_args:=false;
@@ -1462,7 +1460,16 @@ begin
 end.
 {
   $Log$
-  Revision 1.54  2002-04-07 13:24:30  carl
+  Revision 1.55  2002-04-20 21:32:23  carl
+  + generic FPC_CHECKPOINTER
+  + first parameter offset in stack now portable
+  * rename some constants
+  + move some cpu stuff to other units
+  - remove unused constents
+  * fix stacksize for some targets
+  * fix generic size problems which depend now on EXTEND_SIZE constant
+
+  Revision 1.54  2002/04/07 13:24:30  carl
   + moved constant from cpuinfo, these are NOT cpu specific
     constant, but more related to compiler functionality.
 

+ 14 - 5
compiler/ncal.pas

@@ -119,7 +119,7 @@ implementation
       cutils,globtype,systems,
       verbose,globals,
       symconst,types,
-      htypechk,pass_1,cpubase,
+      htypechk,pass_1,cpuinfo,cpubase,
       ncnv,nld,ninl,nadd,ncon,
       rgobj,cgbase
       ;
@@ -1773,11 +1773,11 @@ implementation
       begin
          inherited create(procinlinen);
          inlineprocdef:=tcallnode(callp).symtableprocentry.defs^.def;
-         retoffset:=-pointer_size; { less dangerous as zero (PM) }
+         retoffset:=-POINTER_SIZE; { less dangerous as zero (PM) }
          para_offset:=0;
          para_size:=inlineprocdef.para_size(target_info.alignment.paraalign);
          if ret_in_param(inlineprocdef.rettype.def) then
-           inc(para_size,pointer_size);
+           inc(para_size,POINTER_SIZE);
          { copy args }
          if assigned(code) then
            inlinetree:=code.getcopy
@@ -1844,7 +1844,16 @@ begin
 end.
 {
   $Log$
-  Revision 1.70  2002-04-16 16:09:08  peter
+  Revision 1.71  2002-04-20 21:32:23  carl
+  + generic FPC_CHECKPOINTER
+  + first parameter offset in stack now portable
+  * rename some constants
+  + move some cpu stuff to other units
+  - remove unused constents
+  * fix stacksize for some targets
+  * fix generic size problems which depend now on EXTEND_SIZE constant
+
+  Revision 1.70  2002/04/16 16:09:08  peter
     * allow passing the address of a procedure to a formal parameter
       in delphi mode
 
@@ -1857,7 +1866,7 @@ end.
     * fixed default stacksize of linux and go32v2, 8kb was a bit small :-)
 
   Revision 1.68  2002/04/15 18:57:22  carl
-  + target_info.size_of_pointer -> pointer_Size
+  + target_info.size_of_pointer -> POINTER_SIZE
 
   Revision 1.67  2002/04/02 17:11:28  peter
     * tlocation,treference update

+ 20 - 6
compiler/ncgmem.pas

@@ -75,7 +75,7 @@ implementation
       symconst,symdef,symsym,aasm,
       cginfo,cgbase,pass_2,
       nld,ncon,nadd,
-      cpubase,cgobj,cgcpu,
+      cpuinfo,cpubase,cgobj,cgcpu,
       tgobj,rgobj
 {$ifdef GDB}
   {$ifdef delphi}
@@ -237,7 +237,12 @@ implementation
                  cg.a_load_loc_reg(exprasmlist,left.location,location.reference.base);
               end;
          end;
-         { still needs generic checkpointer() support! }
+         if (cs_gdb_heaptrc in aktglobalswitches) and
+            (cs_checkpointer in aktglobalswitches) then
+              begin
+                 cg.a_param_reg(exprasmlist, OS_ADDR,location.reference.base,1);
+                 cg.a_call_name(exprasmlist,'FPC_CHECKPOINTER',0);
+              end;
       end;
 
 
@@ -297,17 +302,17 @@ implementation
 
     procedure tcgselfnode.pass_2;
       begin
-         rg.getexplicitregisterint(exprasmlist,SELF_POINTER);
+         rg.getexplicitregisterint(exprasmlist,SELF_POINTER_REG);
          if (resulttype.def.deftype=classrefdef) or
             is_class(resulttype.def) then
           begin
             location_reset(location,LOC_CREGISTER,OS_ADDR);
-            location.register:=SELF_POINTER;
+            location.register:=SELF_POINTER_REG;
           end
          else
            begin
              location_reset(location,LOC_CREFERENCE,OS_ADDR);
-             location.reference.base:=SELF_POINTER;
+             location.reference.base:=SELF_POINTER_REG;
            end;
       end;
 
@@ -450,7 +455,16 @@ begin
 end.
 {
   $Log$
-  Revision 1.7  2002-04-15 18:58:47  carl
+  Revision 1.8  2002-04-20 21:32:23  carl
+  + generic FPC_CHECKPOINTER
+  + first parameter offset in stack now portable
+  * rename some constants
+  + move some cpu stuff to other units
+  - remove unused constents
+  * fix stacksize for some targets
+  * fix generic size problems which depend now on EXTEND_SIZE constant
+
+  Revision 1.7  2002/04/15 18:58:47  carl
   + target_info.size_of_pointer -> pointer_Size
 
   Revision 1.6  2002/04/04 19:05:57  peter

+ 21 - 12
compiler/nmem.pas

@@ -256,18 +256,18 @@ implementation
                     ccallparanode.create(cordconstnode.create
                        (tpointerdef(resulttype.def).pointertype.def.size,s32bittype),nil));
             newstatement.left := cstatementnode.create(nil,cassignmentnode.create(
-              ctemprefnode.create(tempcode),
-              ccallnode.createintern('fpc_initialize',sizepara)));
+            ctemprefnode.create(tempcode),
+            ccallnode.createintern('fpc_initialize',sizepara)));
             newstatement := tstatementnode(newstatement.left);
-                   new(r);
-                   reset_reference(r^);
-                   r^.symbol:=tstoreddef(tpointerdef(resulttype.def).pointertype.def).get_rtti_label(initrtti);
-                   emitpushreferenceaddr(r^);
-                   dispose(r);
-                   { push pointer we just allocated, we need to initialize the
-                     data located at that pointer not the pointer self (PFV) }
-                   emit_push_loc(location);
-                   emitcall('FPC_INITIALIZE');
+            new(r);
+            reset_reference(r^);
+            r^.symbol:=tstoreddef(tpointerdef(resulttype.def).pointertype.def).get_rtti_label(initrtti);
+            emitpushreferenceaddr(r^);
+            dispose(r);
+            { push pointer we just allocated, we need to initialize the
+              data located at that pointer not the pointer self (PFV) }
+            emit_push_loc(location);
+            emitcall('FPC_INITIALIZE');
           end;
 
          { and return it }
@@ -1040,7 +1040,16 @@ begin
 end.
 {
   $Log$
-  Revision 1.27  2002-04-02 17:11:29  peter
+  Revision 1.28  2002-04-20 21:32:23  carl
+  + generic FPC_CHECKPOINTER
+  + first parameter offset in stack now portable
+  * rename some constants
+  + move some cpu stuff to other units
+  - remove unused constents
+  * fix stacksize for some targets
+  * fix generic size problems which depend now on EXTEND_SIZE constant
+
+  Revision 1.27  2002/04/02 17:11:29  peter
     * tlocation,treference update
     * LOC_CONSTANT added for better constant handling
     * secondadd splitted in multiple routines

+ 11 - 2
compiler/nobj.pas

@@ -140,7 +140,7 @@ implementation
 {$ifdef GDB}
        gdb,
 {$endif GDB}
-       cpubase
+       cpuinfo,cpubase
        ;
 
 
@@ -1270,7 +1270,16 @@ initialization
 end.
 {
   $Log$
-  Revision 1.15  2002-04-19 15:46:01  peter
+  Revision 1.16  2002-04-20 21:32:24  carl
+  + generic FPC_CHECKPOINTER
+  + first parameter offset in stack now portable
+  * rename some constants
+  + move some cpu stuff to other units
+  - remove unused constents
+  * fix stacksize for some targets
+  * fix generic size problems which depend now on EXTEND_SIZE constant
+
+  Revision 1.15  2002/04/19 15:46:01  peter
     * mangledname rewrite, tprocdef.mangledname is now created dynamicly
       in most cases and not written to the ppu
     * add mangeledname_prefix() routine to generate the prefix of

+ 16 - 7
compiler/options.pas

@@ -1349,30 +1349,30 @@ begin
 
   { some stuff for TP compatibility }
   case target_info.cpu of
-   i386:
+   cpu_i386:
         begin
          def_symbol('CPU86');
          def_symbol('CPU87');
          def_symbol('CPUI386');
         end;
-   m68k:
+   cpu_m68k:
         begin
           def_symbol('CPU68');
           def_symbol('CPU68K');
         end;
-   alpha:
+   cpu_alpha:
         begin
           def_symbol('CPUALPHA');
         end;
-   powerpc:
+   cpu_powerpc:
         begin
           def_symbol('CPUPOWERPC');
         end;
-   sparc:
+   cpu_sparc:
         begin
           def_symbol('CPUSPARC');
         end;
-   vm:
+   cpu_vm:
         begin
           def_symbol('CPUVIS');
         end;
@@ -1656,7 +1656,16 @@ finalization
 end.
 {
   $Log$
-  Revision 1.67  2002-04-07 10:22:35  carl
+  Revision 1.68  2002-04-20 21:32:24  carl
+  + generic FPC_CHECKPOINTER
+  + first parameter offset in stack now portable
+  * rename some constants
+  + move some cpu stuff to other units
+  - remove unused constents
+  * fix stacksize for some targets
+  * fix generic size problems which depend now on EXTEND_SIZE constant
+
+  Revision 1.67  2002/04/07 10:22:35  carl
   + CPU defines now depends on current target
 
   Revision 1.66  2002/04/04 19:05:58  peter

+ 10 - 3
compiler/parser.pas

@@ -93,8 +93,6 @@ implementation
          { memory sizes }
          if heapsize=0 then
           heapsize:=target_info.heapsize;
-         if maxheapsize=0 then
-          maxheapsize:=target_info.maxheapsize;
          if stacksize=0 then
           stacksize:=target_info.stacksize;
 
@@ -627,7 +625,16 @@ implementation
 end.
 {
   $Log$
-  Revision 1.28  2002-04-19 15:46:02  peter
+  Revision 1.29  2002-04-20 21:32:24  carl
+  + generic FPC_CHECKPOINTER
+  + first parameter offset in stack now portable
+  * rename some constants
+  + move some cpu stuff to other units
+  - remove unused constents
+  * fix stacksize for some targets
+  * fix generic size problems which depend now on EXTEND_SIZE constant
+
+  Revision 1.28  2002/04/19 15:46:02  peter
     * mangledname rewrite, tprocdef.mangledname is now created dynamicly
       in most cases and not written to the ppu
     * add mangeledname_prefix() routine to generate the prefix of

+ 11 - 2
compiler/pass_2.pas

@@ -279,7 +279,7 @@ implementation
                                           (lexlevel>=normal_function_level) then
                                          begin
                                           { use ESP as frame pointer }
-                                           procinfo^.framepointer:=stack_pointer;
+                                           procinfo^.framepointer:=STACK_POINTER_REG;
                                            use_esp_stackframe:=true;
 
                                           { calc parameter distance new }
@@ -320,7 +320,16 @@ implementation
 end.
 {
   $Log$
-  Revision 1.24  2002-04-07 13:30:13  carl
+  Revision 1.25  2002-04-20 21:32:24  carl
+  + generic FPC_CHECKPOINTER
+  + first parameter offset in stack now portable
+  * rename some constants
+  + move some cpu stuff to other units
+  - remove unused constents
+  * fix stacksize for some targets
+  * fix generic size problems which depend now on EXTEND_SIZE constant
+
+  Revision 1.24  2002/04/07 13:30:13  carl
   - removed unused variable
 
   Revision 1.23  2002/04/02 17:11:29  peter

+ 16 - 7
compiler/pdecsub.pas

@@ -81,7 +81,7 @@ implementation
        { linking }
        import,gendef,
        { codegen }
-       cgbase
+       cpuinfo,cgbase
        ;
 
 
@@ -552,7 +552,7 @@ implementation
         aktprocdef.proctypeoption:=options;
 
         { calculate the offset of the parameters }
-        paramoffset:=8;
+        paramoffset:=target_info.first_parm_offset;
 
         { calculate frame pointer offset }
         if lexlevel>normal_function_level then
@@ -1487,7 +1487,7 @@ const
                  { do not copy on local !! }
                  tprocdef(def).parast.foreach_static({$ifdef FPCPROCVAR}@{$endif}resetvaluepara);
                  { Adjust positions of args for cdecl or stdcall }
-                 tparasymtable(tprocdef(def).parast).set_alignment(target_info.size_of_longint);
+                 tparasymtable(tprocdef(def).parast).set_alignment(std_param_align);
                end;
             end;
           pocall_cppdecl :
@@ -1507,7 +1507,7 @@ const
                  { do not copy on local !! }
                  tprocdef(def).parast.foreach_static({$ifdef FPCPROCVAR}@{$endif}resetvaluepara);
                  { Adjust positions of args for cdecl or stdcall }
-                 tparasymtable(tprocdef(def).parast).set_alignment(target_info.size_of_longint);
+                 tparasymtable(tprocdef(def).parast).set_alignment(std_param_align);
                end;
             end;
           pocall_stdcall :
@@ -1517,7 +1517,7 @@ const
                  assigned(tprocdef(def).parast) then
                begin
                  { Adjust positions of args for cdecl or stdcall }
-                 tparasymtable(tprocdef(def).parast).set_alignment(target_info.size_of_longint);
+                 tparasymtable(tprocdef(def).parast).set_alignment(std_param_align);
                end;
             end;
           pocall_safecall :
@@ -1585,7 +1585,7 @@ const
                  { do not copy on local !! }
                  tprocdef(def).parast.foreach_static({$ifdef FPCPROCVAR}@{$endif}resetvaluepara);
                  { Adjust positions of args for cdecl or stdcall }
-                 tparasymtable(tprocdef(def).parast).set_alignment(target_info.size_of_longint);
+                 tparasymtable(tprocdef(def).parast).set_alignment(std_param_align);
                end;
             end;
           pocall_inline :
@@ -1932,7 +1932,16 @@ const
 end.
 {
   $Log$
-  Revision 1.51  2002-04-20 15:27:05  carl
+  Revision 1.52  2002-04-20 21:32:24  carl
+  + generic FPC_CHECKPOINTER
+  + first parameter offset in stack now portable
+  * rename some constants
+  + move some cpu stuff to other units
+  - remove unused constents
+  * fix stacksize for some targets
+  * fix generic size problems which depend now on EXTEND_SIZE constant
+
+  Revision 1.51  2002/04/20 15:27:05  carl
   - remove ifdef i386 define
 
   Revision 1.50  2002/04/19 15:46:02  peter

+ 12 - 3
compiler/pmodules.pas

@@ -639,8 +639,8 @@ implementation
         with procinfo^ do
          begin
            _class:=nil;
-           para_offset:=8;
-           framepointer:=frame_pointer;
+           para_offset:=target_info.first_parm_offset;
+           framepointer:=FRAME_POINTER_REG;
            flags:=0;
            procdef:=aktprocdef;
          end;
@@ -1388,7 +1388,16 @@ implementation
 end.
 {
   $Log$
-  Revision 1.61  2002-04-19 15:46:02  peter
+  Revision 1.62  2002-04-20 21:32:24  carl
+  + generic FPC_CHECKPOINTER
+  + first parameter offset in stack now portable
+  * rename some constants
+  + move some cpu stuff to other units
+  - remove unused constents
+  * fix stacksize for some targets
+  * fix generic size problems which depend now on EXTEND_SIZE constant
+
+  Revision 1.61  2002/04/19 15:46:02  peter
     * mangledname rewrite, tprocdef.mangledname is now created dynamicly
       in most cases and not written to the ppu
     * add mangeledname_prefix() routine to generate the prefix of

+ 25 - 5
compiler/pstatmnt.pas

@@ -1068,6 +1068,13 @@ implementation
 
     function assembler_block : tnode;
 
+      {# Optimize the assembler block by removing all references
+         which are via the frame pointer by replacing them with
+         references via the stack pointer.
+         
+         This is only available to certain cpu targets where
+         the frame pointer saving must be done explicitly.
+      }
       procedure OptimizeFramePointer(p:tasmnode);
       var
         hp : tai;
@@ -1075,7 +1082,7 @@ implementation
         i : longint;
       begin
         { replace framepointer with stackpointer }
-        procinfo^.framepointer:=stack_pointer;
+        procinfo^.framepointer:=STACK_POINTER_REG;
         { set the right value for parameters }
         dec(aktprocdef.parast.address_fixup,pointer_size);
         dec(procinfo^.para_offset,pointer_size);
@@ -1099,7 +1106,7 @@ implementation
                        ref_parafixup :
                          begin
                            ref^.offsetfixup:=parafixup;
-                           ref^.base:=stack_pointer;
+                           ref^.base:=STACK_POINTER_REG;
                          end;
                      end;
                    end;
@@ -1171,14 +1178,18 @@ implementation
            following conditions are met:
            - if the are no local variables
            - no reference to the result variable (refcount<=1)
-           - result is not stored as parameter }
+           - result is not stored as parameter 
+           - target processor has optional frame pointer save 
+             (vm, i386, vm only currently)
+         }
          if (po_assembler in aktprocdef.procoptions) and
             (not haslocals) and
             (not hasparas) and
             (aktprocdef.owner.symtabletype<>objectsymtable) and
             (not assigned(aktprocdef.funcretsym) or
              (tfuncretsym(aktprocdef.funcretsym).refcount<=1)) and
-            not(ret_in_param(aktprocdef.rettype.def))
+            not(ret_in_param(aktprocdef.rettype.def)) and
+            (target_cpu in [cpu_i386,cpu_m68k,cpu_vm])
 {$ifdef CHECKFORPUSH}
             and not(UsesPush(tasmnode(p)))
 {$endif CHECKFORPUSH}
@@ -1202,7 +1213,16 @@ implementation
 end.
 {
   $Log$
-  Revision 1.52  2002-04-16 16:11:17  peter
+  Revision 1.53  2002-04-20 21:32:24  carl
+  + generic FPC_CHECKPOINTER
+  + first parameter offset in stack now portable
+  * rename some constants
+  + move some cpu stuff to other units
+  - remove unused constents
+  * fix stacksize for some targets
+  * fix generic size problems which depend now on EXTEND_SIZE constant
+
+  Revision 1.52  2002/04/16 16:11:17  peter
     * using inherited; without a parent having the same function
       will do nothing like delphi
 

+ 11 - 2
compiler/psub.pas

@@ -520,7 +520,7 @@ implementation
           { clear flags }
             flags:=0;
           { standard frame pointer }
-            framepointer:=frame_pointer;
+            framepointer:=frame_pointer_reg;
           { is this a nested function of a method ? }
             if assigned(oldprocinfo) then
               _class:=oldprocinfo^._class;
@@ -811,7 +811,16 @@ implementation
 end.
 {
   $Log$
-  Revision 1.48  2002-04-19 15:46:02  peter
+  Revision 1.49  2002-04-20 21:32:24  carl
+  + generic FPC_CHECKPOINTER
+  + first parameter offset in stack now portable
+  * rename some constants
+  + move some cpu stuff to other units
+  - remove unused constents
+  * fix stacksize for some targets
+  * fix generic size problems which depend now on EXTEND_SIZE constant
+
+  Revision 1.48  2002/04/19 15:46:02  peter
     * mangledname rewrite, tprocdef.mangledname is now created dynamicly
       in most cases and not written to the ppu
     * add mangeledname_prefix() routine to generate the prefix of

+ 11 - 2
compiler/ptconst.pas

@@ -50,7 +50,7 @@ implementation
        { parser specific stuff }
        pbase,pexpr,
        { codegen }
-       cgbase
+       cpuinfo,cgbase
        ;
 
 {$ifdef fpc}
@@ -970,7 +970,16 @@ implementation
 end.
 {
   $Log$
-  Revision 1.43  2002-04-15 19:01:53  carl
+  Revision 1.44  2002-04-20 21:32:24  carl
+  + generic FPC_CHECKPOINTER
+  + first parameter offset in stack now portable
+  * rename some constants
+  + move some cpu stuff to other units
+  - remove unused constents
+  * fix stacksize for some targets
+  * fix generic size problems which depend now on EXTEND_SIZE constant
+
+  Revision 1.43  2002/04/15 19:01:53  carl
   + target_info.size_of_pointer -> pointer_Size
 
   Revision 1.42  2002/04/04 19:06:03  peter

+ 12 - 3
compiler/rautils.pas

@@ -218,7 +218,7 @@ uses
 {$endif}
   types,systems,verbose,globals,
   symsym,symtable,cpuasm,
-  cgbase;
+  cpuinfo,cgbase;
 
 {*************************************************************************
                               TExprParse
@@ -819,7 +819,7 @@ Begin
                 that %esi is valid there }
               else
                 begin
-                  opr.ref.base:=self_pointer;
+                  opr.ref.base:=SELF_POINTER_REG;
                   opr.ref.offset:=tvarsym(sym).address;
                 end;
               hasvar:=true;
@@ -1585,7 +1585,16 @@ end;
 end.
 {
   $Log$
-  Revision 1.29  2002-04-15 19:02:35  carl
+  Revision 1.30  2002-04-20 21:32:24  carl
+  + generic FPC_CHECKPOINTER
+  + first parameter offset in stack now portable
+  * rename some constants
+  + move some cpu stuff to other units
+  - remove unused constents
+  * fix stacksize for some targets
+  * fix generic size problems which depend now on EXTEND_SIZE constant
+
+  Revision 1.29  2002/04/15 19:02:35  carl
   + target_info.size_of_pointer -> pointer_Size
 
   Revision 1.28  2002/04/02 17:11:29  peter

+ 13 - 4
compiler/rgobj.pas

@@ -520,7 +520,7 @@ unit rgobj;
             begin
               if saved[r].ofs <> reg_not_saved then
                 begin
-                  reference_reset_base(hr,frame_pointer,saved[r].ofs);
+                  reference_reset_base(hr,FRAME_POINTER_REG,saved[r].ofs);
                   cg.a_reg_alloc(list,r);
                   cg.a_loadmm_ref_reg(list,hr,r);
                   if not (r in unusedregsmm) then
@@ -542,7 +542,7 @@ unit rgobj;
             begin
               if saved[r].ofs <> reg_not_saved then
                 begin
-                  reference_reset_base(hr,frame_pointer,saved[r].ofs);
+                  reference_reset_base(hr,FRAME_POINTER_REG,saved[r].ofs);
                   cg.a_reg_alloc(list,r);
                   cg.a_loadfpu_ref_reg(list,OS_FLOAT,hr,r);
                   if not (r in unusedregsfpu) then
@@ -563,7 +563,7 @@ unit rgobj;
           begin
             if saved[r].ofs <> reg_not_saved then
               begin
-                reference_reset_base(hr,frame_pointer,saved[r].ofs);
+                reference_reset_base(hr,FRAME_POINTER_REG,saved[r].ofs);
                 cg.a_reg_alloc(list,r);
                 cg.a_load_ref_reg(list,OS_INT,hr,r);
                 if not (r in unusedregsint) then
@@ -842,7 +842,16 @@ end.
 
 {
   $Log$
-  Revision 1.6  2002-04-15 19:03:31  carl
+  Revision 1.7  2002-04-20 21:32:25  carl
+  + generic FPC_CHECKPOINTER
+  + first parameter offset in stack now portable
+  * rename some constants
+  + move some cpu stuff to other units
+  - remove unused constents
+  * fix stacksize for some targets
+  * fix generic size problems which depend now on EXTEND_SIZE constant
+
+  Revision 1.6  2002/04/15 19:03:31  carl
   + reg2str -> std_reg2str()
 
   Revision 1.5  2002/04/06 18:13:01  jonas

+ 12 - 5
compiler/scanner.pas

@@ -746,11 +746,9 @@ implementation
            found:=findincludefile(path,name,ext,foundfile);
            if (ext='') then
             begin
-              { try default extensions .pp and .pas }
+              { try default with .inc extension }
               if (not found) then
-               found:=findincludefile(path,name,target_info.sourceext,foundfile);
-              if (not found) then
-               found:=findincludefile(path,name,target_info.pasext,foundfile);
+               found:=findincludefile(path,name,'.inc',foundfile);
             end;
          { save old postion and decrease linebreak }
            if c=newline then
@@ -2756,7 +2754,16 @@ exit_label:
 end.
 {
   $Log$
-  Revision 1.32  2002-04-19 15:42:11  peter
+  Revision 1.33  2002-04-20 21:32:25  carl
+  + generic FPC_CHECKPOINTER
+  + first parameter offset in stack now portable
+  * rename some constants
+  + move some cpu stuff to other units
+  - remove unused constents
+  * fix stacksize for some targets
+  * fix generic size problems which depend now on EXTEND_SIZE constant
+
+  Revision 1.32  2002/04/19 15:42:11  peter
     * default extension checking for include files
 
   Revision 1.31  2002/03/01 14:39:44  peter

+ 38 - 29
compiler/symdef.pas

@@ -1193,7 +1193,7 @@ implementation
          string_typ:=st_longstring;
          deftype:=stringdef;
          len:=l;
-         savesize:=pointer_size;
+         savesize:=POINTER_SIZE;
       end;
 
 
@@ -1203,7 +1203,7 @@ implementation
          deftype:=stringdef;
          string_typ:=st_longstring;
          len:=ppufile.getlongint;
-         savesize:=pointer_size;
+         savesize:=POINTER_SIZE;
       end;
 
 
@@ -1213,7 +1213,7 @@ implementation
          string_typ:=st_ansistring;
          deftype:=stringdef;
          len:=l;
-         savesize:=pointer_size;
+         savesize:=POINTER_SIZE;
       end;
 
 
@@ -1223,7 +1223,7 @@ implementation
          deftype:=stringdef;
          string_typ:=st_ansistring;
          len:=ppufile.getlongint;
-         savesize:=pointer_size;
+         savesize:=POINTER_SIZE;
       end;
 
 
@@ -1233,7 +1233,7 @@ implementation
          string_typ:=st_widestring;
          deftype:=stringdef;
          len:=l;
-         savesize:=pointer_size;
+         savesize:=POINTER_SIZE;
       end;
 
 
@@ -1243,7 +1243,7 @@ implementation
          deftype:=stringdef;
          string_typ:=st_widestring;
          len:=ppufile.getlongint;
-         savesize:=pointer_size;
+         savesize:=POINTER_SIZE;
       end;
 
 
@@ -1554,7 +1554,7 @@ implementation
         memsize := memsizeinc;
         getmem(st,memsize);
         { we can specify the size with @s<size>; prefix PM }
-        if savesize <> target_info.size_of_longint then
+        if savesize <> std_param_align then
           strpcopy(st,'@s'+tostr(savesize*8)+';e')
         else
           strpcopy(st,'e');
@@ -2193,7 +2193,7 @@ implementation
         deftype:=pointerdef;
         pointertype:=tt;
         is_far:=false;
-        savesize:=pointer_size;
+        savesize:=POINTER_SIZE;
       end;
 
 
@@ -2203,7 +2203,7 @@ implementation
         deftype:=pointerdef;
         pointertype:=tt;
         is_far:=true;
-        savesize:=pointer_size;
+        savesize:=POINTER_SIZE;
       end;
 
 
@@ -2213,7 +2213,7 @@ implementation
          deftype:=pointerdef;
          ppufile.gettype(pointertype);
          is_far:=(ppufile.getbyte<>0);
-         savesize:=pointer_size;
+         savesize:=POINTER_SIZE;
       end;
 
 
@@ -2321,7 +2321,7 @@ implementation
          deftype:=classrefdef;
          ppufile.gettype(pointertype);
          is_far:=false;
-         savesize:=pointer_size;
+         savesize:=POINTER_SIZE;
       end;
 
 
@@ -2523,7 +2523,7 @@ implementation
               tsymtable(current_module.localsymtable).registerdef(self)
             else if assigned(current_module.globalsymtable) then
               tsymtable(current_module.globalsymtable).registerdef(self);
-         savesize:=pointer_size;
+         savesize:=POINTER_SIZE;
       end;
 
 
@@ -2531,7 +2531,7 @@ implementation
       begin
          inherited loaddef(ppufile);
          deftype:=formaldef;
-         savesize:=pointer_size;
+         savesize:=POINTER_SIZE;
       end;
 
 
@@ -2688,7 +2688,7 @@ implementation
       begin
         if IsDynamicArray then
           begin
-            size:=pointer_size;
+            size:=POINTER_SIZE;
             exit;
           end;
         {Tarraydef.size may never be called for an open array!}
@@ -3064,7 +3064,7 @@ implementation
          rettype:=voidtype;
          symtablelevel:=0;
          fpu_used:=0;
-         savesize:=pointer_size;
+         savesize:=POINTER_SIZE;
       end;
 
 
@@ -3139,7 +3139,7 @@ implementation
          proccalloption:=tproccalloption(ppufile.getbyte);
          ppufile.getsmallset(procoptions);
          count:=ppufile.getword;
-         savesize:=pointer_size;
+         savesize:=POINTER_SIZE;
          for i:=1 to count do
           begin
             hp:=TParaItem.Create;
@@ -3197,10 +3197,10 @@ implementation
           begin
             case pdc.paratyp of
               vs_out,
-              vs_var   : inc(l,pointer_size);
+              vs_var   : inc(l,POINTER_SIZE);
               vs_value,
               vs_const : if push_addr_param(pdc.paratype.def) then
-                          inc(l,pointer_size)
+                          inc(l,POINTER_SIZE)
                          else
                           inc(l,pdc.paratype.def.size);
             end;
@@ -3920,9 +3920,9 @@ implementation
     function tprocvardef.size : longint;
       begin
          if (po_methodpointer in procoptions) then
-           size:=2*pointer_size
+           size:=2*POINTER_SIZE
          else
-           size:=pointer_size;
+           size:=POINTER_SIZE;
       end;
 
 
@@ -4253,7 +4253,7 @@ implementation
                   inc(symtable.datasize,c.symtable.datasize);
                   if (oo_has_vmt in objectoptions) and
                      (oo_has_vmt in c.objectoptions) then
-                    dec(symtable.datasize,pointer_size);
+                    dec(symtable.datasize,POINTER_SIZE);
                   { if parent has a vmt field then
                     the offset is the same for the child PM }
                   if (oo_has_vmt in c.objectoptions) or is_class(self) then
@@ -4277,7 +4277,7 @@ implementation
           begin
              symtable.datasize:=align(symtable.datasize,symtable.dataalignment);
              vmt_offset:=symtable.datasize;
-             inc(symtable.datasize,pointer_size);
+             inc(symtable.datasize,POINTER_SIZE);
              include(objectoptions,oo_has_vmt);
           end;
      end;
@@ -4364,7 +4364,7 @@ implementation
     function tobjectdef.size : longint;
       begin
         if objecttype in [odt_class,odt_interfacecom,odt_interfacecorba] then
-          size:=pointer_size
+          size:=POINTER_SIZE
         else
           size:=symtable.datasize;
       end;
@@ -4381,14 +4381,14 @@ implementation
         { for offset of methods for classes, see rtl/inc/objpash.inc }
         case objecttype of
         odt_class:
-          vmtmethodoffset:=(index+12)*pointer_size;
+          vmtmethodoffset:=(index+12)*POINTER_SIZE;
         odt_interfacecom,odt_interfacecorba:
-          vmtmethodoffset:=index*pointer_size;
+          vmtmethodoffset:=index*POINTER_SIZE;
         else
 {$ifdef WITHDMT}
-          vmtmethodoffset:=(index+4)*pointer_size;
+          vmtmethodoffset:=(index+4)*POINTER_SIZE;
 {$else WITHDMT}
-          vmtmethodoffset:=(index+3)*pointer_size;
+          vmtmethodoffset:=(index+3)*POINTER_SIZE;
 {$endif WITHDMT}
         end;
       end;
@@ -5468,7 +5468,16 @@ implementation
 end.
 {
   $Log$
-  Revision 1.71  2002-04-19 15:46:03  peter
+  Revision 1.72  2002-04-20 21:32:25  carl
+  + generic FPC_CHECKPOINTER
+  + first parameter offset in stack now portable
+  * rename some constants
+  + move some cpu stuff to other units
+  - remove unused constents
+  * fix stacksize for some targets
+  * fix generic size problems which depend now on EXTEND_SIZE constant
+
+  Revision 1.71  2002/04/19 15:46:03  peter
     * mangledname rewrite, tprocdef.mangledname is now created dynamicly
       in most cases and not written to the ppu
     * add mangeledname_prefix() routine to generate the prefix of
@@ -5539,7 +5548,7 @@ end.
     * torddef low/high range changed to int64
 
   Revision 1.58  2001/11/30 15:01:51  jonas
-    * tarraydef.size returns pointer_size instead of 4 for
+    * tarraydef.size returns POINTER_SIZE instead of 4 for
       dynamic arrays
 
   Revision 1.57  2001/11/18 18:43:14  peter

+ 25 - 11
compiler/systems.pas

@@ -40,13 +40,13 @@ interface
      }
        ttargetcpu=
        (
-             no_cpu,                   { 0 }
-             i386,                     { 1 }
-             m68k,                     { 2 }
-             alpha,                    { 3 }
-             powerpc,                  { 4 }
-             sparc,                    { 5 }
-             vm                        { 6 }
+             cpu_no,                       { 0 }
+             cpu_i386,                     { 1 }
+             cpu_m68k,                     { 2 }
+             cpu_alpha,                    { 3 }
+             cpu_powerpc,                  { 4 }
+             cpu_sparc,                    { 5 }
+             cpu_vm                        { 6 }
        );
 
        tprocessors = (no_processor
@@ -191,7 +191,7 @@ interface
        end;
 
        ttargetflags = (tf_none,
-            tf_under_development,tf_supports_stack_checking,
+            tf_under_development,
             tf_need_export,tf_needs_isconsole
 {$ifdef m68k}
             ,tf_code_small,tf_static_a5_based
@@ -240,9 +240,14 @@ interface
           script       : tscripttype;
           endian       : tendian;
           alignment    : talignmentinfo;
-          size_of_longint : byte;
+          { 
+            Offset from the argument pointer register to the first 
+            argument's address. On some machines it may depend on 
+            the data type of the function. 
+            (see also FIRST_PARM_OFFSET in GCC source)
+          }
+          first_parm_offset : longint;
           heapsize,
-          maxheapsize,
           stacksize       : longint;
           DllScanSupported : boolean;
           use_bound_instruction : boolean;
@@ -679,7 +684,16 @@ finalization
 end.
 {
   $Log$
-  Revision 1.39  2002-04-15 19:08:22  carl
+  Revision 1.40  2002-04-20 21:32:26  carl
+  + generic FPC_CHECKPOINTER
+  + first parameter offset in stack now portable
+  * rename some constants
+  + move some cpu stuff to other units
+  - remove unused constents
+  * fix stacksize for some targets
+  * fix generic size problems which depend now on EXTEND_SIZE constant
+
+  Revision 1.39  2002/04/15 19:08:22  carl
   + target_info.size_of_pointer -> pointer_size
   + some cleanup of unused types/variables