Browse Source

+ implemented initilizing of data for the new code generator
so it should compile now simple programs

florian 26 years ago
parent
commit
c512d38256
4 changed files with 120 additions and 21 deletions
  1. 13 1
      compiler/link.pas
  2. 96 10
      compiler/new/cgobj.pas
  3. 6 2
      compiler/new/nmem.pas
  4. 5 8
      compiler/new/powerpc/cgcpu.pas

+ 13 - 1
compiler/link.pas

@@ -755,6 +755,14 @@ begin
     target_i386_Go32v2 :
       linker:=new(plinkergo32v2,Init);
 {$endif i386}
+{$ifdef alpha}
+    target_alpha_linux:
+      linker:=new(plinker,Init);
+{$endif i386}
+{$ifdef powerpc}
+    target_powerpc_linux:
+      linker:=new(plinker,Init);
+{$endif powerpc}
     else
       linker:=new(plinker,Init);
   end;
@@ -771,7 +779,11 @@ end;
 end.
 {
   $Log$
-  Revision 1.67  1999-08-16 15:35:23  pierre
+  Revision 1.68  1999-08-18 17:05:53  florian
+    + implemented initilizing of data for the new code generator
+      so it should compile now simple programs
+
+  Revision 1.67  1999/08/16 15:35:23  pierre
     * fix for DLL relocation problems
     * external bss vars had wrong stabs for pecoff
     + -WB11000000 to specify default image base, allows to

+ 96 - 10
compiler/new/cgobj.pas

@@ -38,7 +38,7 @@ unit cgobj;
           scratch_register_array_pointer : aword;
           unusedscratchregisters : tregisterset;
 
-          alignment : talignment
+          alignment : talignment;
           {************************************************}
           {                 basic routines                 }
           constructor init;
@@ -59,6 +59,16 @@ unit cgobj;
           {************************************************}
           { code generation for subroutine entry/exit code }
 
+          { initilizes data of type t                           }
+          { if is_already_ref is true then the routines assumes }
+          { that r points to the data to initialize             }
+          procedure g_initialize(list : paasmoutput;t : pdef;const ref : treference;is_already_ref : boolean);
+
+          { finalizes data of type t                            }
+          { if is_already_ref is true then the routines assumes }
+          { that r points to the data to finalizes              }
+          procedure g_finalize(list : paasmoutput;t : pdef;const ref : treference;is_already_ref : boolean);
+
           { helper routines }
           procedure g_initialize_data(list : paasmoutput;p : psym);
           procedure g_incr_data(list : paasmoutput;p : psym);
@@ -66,11 +76,6 @@ unit cgobj;
           procedure g_copyvalueparas(list : paasmoutput;p : pnamedindexobject);
           procedure g_finalizetempansistrings(list : paasmoutput);
 
-          { finalizes data of type t                            }
-          { if is_already_ref is true then the routines assumes }
-          { that r points to the data to finalizes              }
-          procedure g_finalize(list : paasmoutput;t : pdef;const ref : treference;is_already_ref : boolean);
-
           procedure g_entrycode(list : paasmoutput;
             const proc_names : tstringcontainer;make_global : boolean;
             stackframe : longint;var parasize : longint;
@@ -381,6 +386,31 @@ unit cgobj;
                   Code generation for subroutine entry- and exit code
  *****************************************************************************}
 
+    { initilizes data of type t                           }
+    { if is_already_ref is true then the routines assumes }
+    { that r points to the data to initialize             }
+    procedure tcg.g_initialize(list : paasmoutput;t : pdef;const ref : treference;is_already_ref : boolean);
+
+      var
+         hr : treference;
+
+      begin
+         if is_ansistring(t) or
+           is_widestring(t) then
+           a_load_const_ref(list,OS_8,0,ref)
+         else
+           begin
+              reset_reference(hr);
+              hr.symbol:=t^.get_inittable_label;
+              a_param_ref_addr(list,hr,2);
+              if is_already_ref then
+                a_param_ref(list,OS_ADDR,ref,1)
+              else
+                a_param_ref_addr(list,ref,1);
+              a_call_name(list,'FPC_INITIALIZE',0);
+           end;
+      end;
+
     procedure tcg.g_finalize(list : paasmoutput;t : pdef;const ref : treference;is_already_ref : boolean);
 
       var
@@ -405,12 +435,32 @@ unit cgobj;
            end;
       end;
 
-
     { generates the code for initialisation of local data }
     procedure tcg.g_initialize_data(list : paasmoutput;p : psym);
 
+      var
+         hr : treference;
+
       begin
-         runerror(255);
+         if (psym(p)^.typ=varsym) and
+            assigned(pvarsym(p)^.definition) and
+            not((pvarsym(p)^.definition^.deftype=objectdef) and
+              pobjectdef(pvarsym(p)^.definition)^.is_class) and
+            pvarsym(p)^.definition^.needs_inittable then
+           begin
+              procinfo.flags:=procinfo.flags or pi_needs_implicit_finally;
+              reset_reference(hr);
+              if psym(p)^.owner^.symtabletype=localsymtable then
+                begin
+                   hr.base:=procinfo.framepointer;
+                   hr.offset:=-pvarsym(p)^.address;
+                end
+              else
+                begin
+                   hr.symbol:=newasmsymbol(pvarsym(p)^.mangledname);
+                end;
+              g_initialize(list,pvarsym(p)^.definition,hr,false);
+           end;
       end;
 
 
@@ -444,8 +494,40 @@ unit cgobj;
     { generates the code for finalisation of local data }
     procedure tcg.g_finalize_data(list : paasmoutput;p : pnamedindexobject);
 
+      var
+         hr : treference;
+
       begin
-         runerror(255);
+         if (psym(p)^.typ=varsym) and
+            assigned(pvarsym(p)^.definition) and
+            not((pvarsym(p)^.definition^.deftype=objectdef) and
+            pobjectdef(pvarsym(p)^.definition)^.is_class) and
+            pvarsym(p)^.definition^.needs_inittable then
+           begin
+              { not all kind of parameters need to be finalized  }
+              if (psym(p)^.owner^.symtabletype=parasymtable) and
+                ((pvarsym(p)^.varspez=vs_var)  or
+                 (pvarsym(p)^.varspez=vs_const) { and
+                 (dont_copy_const_param(pvarsym(p)^.definition)) } ) then
+                exit;
+              procinfo.flags:=procinfo.flags or pi_needs_implicit_finally;
+              reset_reference(hr);
+              case psym(p)^.owner^.symtabletype of
+                 localsymtable:
+                   begin
+                      hr.base:=procinfo.framepointer;
+                      hr.offset:=-pvarsym(p)^.address;
+                   end;
+                 parasymtable:
+                   begin
+                      hr.base:=procinfo.framepointer;
+                      hr.offset:=pvarsym(p)^.address+procinfo.call_offset;
+                   end;
+                 else
+                   hr.symbol:=newasmsymbol(pvarsym(p)^.mangledname);
+              end;
+              g_finalize(list,pvarsym(p)^.definition,hr,false);
+           end;
       end;
 
 
@@ -998,7 +1080,11 @@ unit cgobj;
 end.
 {
   $Log$
-  Revision 1.21  1999-08-07 14:21:08  florian
+  Revision 1.22  1999-08-18 17:05:55  florian
+    + implemented initilizing of data for the new code generator
+      so it should compile now simple programs
+
+  Revision 1.21  1999/08/07 14:21:08  florian
     * some small problems fixed
 
   Revision 1.20  1999/08/06 18:05:52  florian

+ 6 - 2
compiler/new/nmem.pas

@@ -540,7 +540,7 @@ unit nmem;
                                    cg^.a_param_ref_addr(list,left^.location.reference,1);
                                    cg^.a_call_name(list,'FPC_DECREF',0)
                                 end;
-                              cg^.g_concatcopy(right^.location.reference,
+                              cg^.g_concatcopy(list,right^.location.reference,
                                 left^.location.reference,left^.resulttype^.size,false);
                               tg.ungetiftemp(right^.location.reference);
                            end;
@@ -709,7 +709,11 @@ unit nmem;
 end.
 {
   $Log$
-  Revision 1.9  1999-08-06 18:05:54  florian
+  Revision 1.10  1999-08-18 17:05:56  florian
+    + implemented initilizing of data for the new code generator
+      so it should compile now simple programs
+
+  Revision 1.9  1999/08/06 18:05:54  florian
     * implemented some stuff for assignments
 
   Revision 1.8  1999/08/06 15:53:51  florian

+ 5 - 8
compiler/new/powerpc/cgcpu.pas

@@ -31,7 +31,6 @@ unit cgcpu;
        pcgppc = ^tcgppc;
 
        tcgppc = object(tcg)
-          procedure a_push_reg(list : paasmoutput;r : tregister);virtual;
           procedure a_call_name(list : paasmoutput;const s : string;
             offset : longint);virtual;
 
@@ -81,12 +80,6 @@ const
     uses
        globtype,globals,verbose;
 
-     procedure tcgppc.a_push_reg(list : paasmoutput;r : tregister);
-       begin
- { no in-procedure register pushing on the PowerPC                          }
-         internalerror(68995);
-       end;
-
     procedure tcgppc.a_call_name(list : paasmoutput;const s : string;
       offset : longint);
 
@@ -373,7 +366,11 @@ const
 end.
 {
   $Log$
-  Revision 1.1  1999-08-06 16:41:11  jonas
+  Revision 1.2  1999-08-18 17:05:57  florian
+    + implemented initilizing of data for the new code generator
+      so it should compile now simple programs
+
+  Revision 1.1  1999/08/06 16:41:11  jonas
     * PowerPC compiles again, several routines implemented in cgcpu.pas
     * added constant to cpubase of alpha and powerpc for maximum
       number of operands