Browse Source

* nmem compiles again (at least for powerpc)

Jonas Maebe 25 years ago
parent
commit
3e11694e49
3 changed files with 151 additions and 109 deletions
  1. 5 2
      compiler/new/cgobj.pas
  2. 139 105
      compiler/new/nmem.pas
  3. 7 2
      compiler/new/powerpc/cpubase.pas

+ 5 - 2
compiler/new/cgobj.pas

@@ -126,6 +126,7 @@ unit cgobj;
 
           { move instructions }
           procedure a_load_const_reg(list : paasmoutput;size : tcgsize;a : aword;register : tregister);virtual;
+          procedure a_load_const_ref(list : paasmoutput;size : tcgsize;a : aword;const ref : treference);virtual;
           procedure a_load_reg_ref(list : paasmoutput;size : tcgsize;register : tregister;const ref : treference);virtual;
           procedure a_load_ref_reg(list : paasmoutput;size : tcgsize;const ref : treference;register : tregister);virtual;
           procedure a_load_reg_reg(list : paasmoutput;size : tcgsize;reg1,reg2 : tregister);virtual;
@@ -166,7 +167,6 @@ unit cgobj;
           procedure g_profilecode(list : paasmoutput);virtual;
           procedure g_stackcheck(list : paasmoutput;stackframesize : longint);virtual;
 
-          procedure a_load_const_ref(list : paasmoutput;size : tcgsize;a : aword;const ref : treference);virtual;
           procedure g_maybe_loadself(list : paasmoutput);virtual;
           { copies len bytes from the source to destination, if }
           { loadref is true, it assumes that it first must load }
@@ -1329,7 +1329,10 @@ unit cgobj;
 end.
 {
   $Log$
-  Revision 1.37  2000-04-22 14:25:03  jonas
+  Revision 1.38  2000-04-29 09:01:06  jonas
+    * nmem compiles again (at least for powerpc)
+
+  Revision 1.37  2000/04/22 14:25:03  jonas
     * aasm.pas: pai_align instead of pai_align_abstract if cpu <> i386
     + systems.pas: info for macos/ppc
     * new/cgobj.pas: compiles again without newst define

+ 139 - 105
compiler/new/nmem.pas

@@ -310,102 +310,58 @@ unit nmem;
                             TASSIGNMENTNODE
  ****************************************************************************}
 
-    constructor tassignmentnode.init(l,r : pnode);
+    procedure loadansistring;
 
       begin
-         inherited init(l,r);
-         concat_string:=false;
-         assigntyp:=at_normal;
+        { !!! }
       end;
 
-    destructor tassignmentnode.done;
+    procedure loadansi2short(right,left: pnode);
 
       begin
-         inherited done;
+        { !!! }
       end;
 
-    procedure tassignmentnode.det_temp;
+    procedure loadshortstring;
 
       begin
+        { !!! }
       end;
 
-    procedure tassignmentnode.det_resulttype;
+    constructor tassignmentnode.init(l,r : pnode);
 
       begin
-         inherited det_resulttype;
-         resulttype:=voiddef;
-         { assignements to open arrays aren't allowed }
-         if is_open_array(left^.resulttype) then
-           CGMessage(type_e_mismatch);
+         inherited init(l,r);
+{         concat_string:=false; }
+         assigntyp:=at_normal;
       end;
 
-    { updated from old cg on 29.2.00 by FK }
-    procedure generic_p2_stringassignment(p : passignmentnode);
+    destructor tassignmentnode.done;
 
       begin
-         if is_ansistring(left^.resulttype) then
-           begin
-             { the source and destinations are released
-               in loadansistring, because an ansi string can
-               also be in a register
-             }
-             loadansistring;
-           end
-         else
-         if is_shortstring(left^.resulttype) then
-           begin
-             if is_ansistring(right^.resulttype) then
-               begin
-                 if (right^.treetype=stringconstn) and
-                    (pstringconstnode(right)^.length=0) then
-                   begin
-                      cg^.a_load_const_ref(list,OS_8,0,left^.location.reference);
-                      tg.del_reference(left^.location.reference);
-                   end
-                 else
-                   loadansi2short(right,left);
-               end
-             else
-               begin
-                  { we do not need destination anymore }
-                  tg.del_reference(left^.location.reference);
-                  { tg.del_reference(right^.location.reference);
-                    done in loadshortstring }
-                  loadshortstring;
-                  tg.ungetiftemp(right^.location.reference);
-               end;
-           end
-         else if is_longstring(left^.resulttype) then
-           begin
-              abstract;
-           end
-         else
-           begin
-             { its the only thing we have to do }
-             tg.del_reference(right^.location.reference);
-           end
+         inherited done;
       end;
 
-    procedure generic_p2_assignment_int64_reg(p : passignmentnode);
+    procedure tassignmentnode.det_temp;
 
       begin
-         { we don't know it better here }
-         generic_p2_assignment(p);
       end;
 
-    { updated from old cg on 29.2.00 by FK }
-    procedure generic_p2_assignment_flags(p : passignmentnode);
+    procedure tassignmentnode.det_resulttype;
 
       begin
-         { for example the alpha doesn't have flags }
-         abstract;
+         inherited det_resulttype;
+         resulttype:=voiddef;
+         { assignements to open arrays aren't allowed }
+         if is_open_array(left^.resulttype) then
+           CGMessage(type_e_mismatch);
       end;
 
     { updated from old cg on 29.2.00 by FK }
     procedure generic_p2_assignment(p : passignmentnode);
 
       var
-         opsize : topsize;
+         opsize : tcgsize;
          otlabel,hlabel,oflabel : pasmlabel;
          fputyp : tfloattype;
          loc : tloc;
@@ -414,8 +370,8 @@ unit nmem;
          op : tasmop;
 
       begin
-         loc:=left^.location.loc;
-         case right^.location.loc of
+         loc:= p^.left^.location.loc;
+         case p^.right^.location.loc of
             LOC_REFERENCE,
             LOC_MEM : begin
                          { extra handling for ordinal constants }
@@ -430,10 +386,10 @@ unit nmem;
                               end;
                               if loc=LOC_CREGISTER then
                                 begin
-                                  emit_ref_reg(A_MOV,opsize,
-                                    newreference(p^.right^.location.reference),
+                                  cg^.a_load_ref_reg(p^.list,opsize,
+                                    p^.right^.location.reference,
                                     p^.left^.location.register);
-
+{$ifdef dummy}
                          !!!!!!!!!!!! only 32 bit cpus
                                   if is_64bitint(p^.right^.resulttype) then
                                     begin
@@ -442,14 +398,16 @@ unit nmem;
                                        emit_ref_reg(A_MOV,opsize,r,
                                          p^.left^.location.registerhigh);
                                     end;
-                                  tg.del_reference(right^.location.reference);
+{$endif dummy}
+                                  tg.del_reference(p^.right^.location.reference);
                                 end
                               else
                                 begin
-                                  emit_const_ref(A_MOV,opsize,
+                                  cg^.a_load_const_ref(p^.list,opsize,
                                     p^.right^.location.reference.offset,
-                                    newreference(p^.left^.location.reference));
+                                    p^.left^.location.reference);
 
+{$ifdef dummy}
                          !!!!!!!!!!!! only 32 bit cpus
                                   if is_64bitint(p^.right^.resulttype) then
                                     begin
@@ -458,11 +416,13 @@ unit nmem;
                                        emit_const_ref(A_MOV,opsize,
                                          0,r);
                                     end;
-                                  del_reference(left^.location.reference);
+{$endif dummy}
+                                  tg.del_reference(p^.left^.location.reference);
                                 end;
 
                            end
 
+{$ifdef i386}
                          !!!!!!!!!!!! only 386
                          else if loc=LOC_CFPUREGISTER then
                            begin
@@ -472,11 +432,13 @@ unit nmem;
                               emit_reg(A_FSTP,S_NO,
                                 correct_fpuregister(p^.left^.location.register,fpuvaroffset+1));
                            end
+{$endif i386}
                          else
                            begin
-                              if (right^.resulttype^.needs_inittable) and
-                                ((right^.resulttype^.deftype<>objectdef) or
-                                  not(pobjectdef(right^.resulttype)^.is_class)) then
+{$ifdef dummy}
+                              if (p^.right^.resulttype^.needs_inittable) and
+                                ((p^.right^.resulttype^.deftype<>objectdef) or
+                                  not(pobjectdef(p^.right^.resulttype)^.is_class)) then
                                 begin
                                    { this would be a problem }
                                    if not(left^.resulttype^.needs_inittable) then
@@ -498,15 +460,15 @@ unit nmem;
                                    emitpushreferenceaddr(p^.left^.location.reference);
                                    emitcall('FPC_DECREF');
                                 end;
-
+{$endif dummy}
 {$ifdef regallocfix}
-                              concatcopy(p^.right^.location.reference,
+                              cg^.concatcopy(p^.list,p^.right^.location.reference,
                                 p^.left^.location.reference,p^.left^.resulttype^.size,true,false);
                               ungetiftemp(p^.right^.location.reference);
 {$Else regallocfix}
-                              concatcopy(p^.right^.location.reference,
-                                p^.left^.location.reference,p^.left^.resulttype^.size,false,false);
-                              ungetiftemp(p^.right^.location.reference);
+                              cg^.g_concatcopy(p^.list,p^.right^.location.reference,
+                                p^.left^.location.reference,p^.left^.resulttype^.size,false);
+                              tg.ungetiftemp(p^.right^.location.reference);
 {$endif regallocfix}
                            end;
                       end;
@@ -533,19 +495,21 @@ unit nmem;
                               { simplified with op_reg_loc       }
                               if loc=LOC_CREGISTER then
                                 begin
-                                  emit_reg_reg(A_MOV,opsize,
+                                  cg^.a_load_reg_reg(p^.list,opsize,
                                     p^.right^.location.register,
                                     p^.left^.location.register);
-                                 ungetregister(p^.right^.location.register);
+                                 tg.ungetregister(p^.right^.location.register);
                                 end
                               else
                                 Begin
-                                  emit_reg_ref(A_MOV,opsize,
+                                  cg^.a_load_reg_ref(p^.list,opsize,
                                     p^.right^.location.register,
-                                    newreference(p^.left^.location.reference));
-                                  ungetregister(p^.right^.location.register);
-                                  del_reference(p^.left^.location.reference);
+                                    p^.left^.location.reference);
+                                  tg.ungetregister(p^.right^.location.register);
+                                  tg.del_reference(p^.left^.location.reference);
                                 end;
+{$ifdef dummy}
+                              !!!! only for 32bit processors
                               if is_64bitint(p^.right^.resulttype) then
                                 begin
                                    { simplified with op_reg_loc  }
@@ -561,7 +525,9 @@ unit nmem;
                                           p^.right^.location.registerhigh,r);
                                      end;
                                 end;
+{$endif dummy}
                            end;
+{$ifdef dummy}
             LOC_FPU : begin
                               if (p^.left^.resulttype^.deftype=floatdef) then
                                fputyp:=pfloatdef(p^.left^.resulttype)^.typ
@@ -587,7 +553,7 @@ unit nmem;
                                    internalerror(48991);
                               end;
                            end;
-
+{$ifdef i386}
                          !!!!!!!!!!!! only 386
             LOC_CFPUREGISTER: begin
                               if (p^.left^.resulttype^.deftype=floatdef) then
@@ -617,6 +583,8 @@ unit nmem;
                                    internalerror(48992);
                               end;
                            end;
+{$endif i386}
+{$endif dummy}
             LOC_JUMP     : begin
                               { support every type of boolean here }
                               case p^.right^.resulttype^.size of
@@ -628,26 +596,26 @@ unit nmem;
                                  8 : opsize:=OS_64;
                               end;
                               getlabel(hlabel);
-                              a_label(p^.list,p^.truelabel);
+                              cg^.a_label(p^.list,p^.truelabel);
                               if loc=LOC_CREGISTER then
-                                a_load_const_reg(p^.list,opsize,1,
+                                cg^.a_load_const_reg(p^.list,opsize,1,
                                   p^.left^.location.register)
                               else
-                                a_load_const_ref(p^.list,opsize,1,
-                                  newreference(p^.left^.location.reference));
-                              a_jmp_cond(p^.list,C_None,hlabel);
-                              a_label(p^.list,p^.falselabel);
+                                cg^.a_load_const_ref(p^.list,opsize,1,
+                                  p^.left^.location.reference);
+                              cg^.a_jmp_cond(p^.list,OC_None,hlabel);
+                              cg^.a_label(p^.list,p^.falselabel);
 
                               if loc=LOC_CREGISTER then
-                                a_load_const_reg(p^.list,opsize,0,
-                                  p^.left^.location.register);
+                                cg^.a_load_const_reg(p^.list,opsize,0,
+                                  p^.left^.location.register)
                               else
                                 begin
-                                  a_load_const_ref(p^.list,opsize,0,
-                                    newreference(p^.left^.location.reference));
+                                  cg^.a_load_const_ref(p^.list,opsize,0,
+                                    p^.left^.location.reference);
                                   tg.del_reference(p^.left^.location.reference);
                                  end;
-                              a_label(p^.list,hlabel);
+                              cg^.a_label(p^.list,hlabel);
                            end;
             LOC_FLAGS:
               p2_assignment_flags(p);
@@ -655,6 +623,70 @@ unit nmem;
       end;
 
 
+
+    { updated from old cg on 29.2.00 by FK }
+    procedure generic_p2_assignment_string(p : passignmentnode);
+
+      begin
+        with p^ do
+         if is_ansistring(left^.resulttype) then
+           begin
+             { the source and destinations are released
+               in loadansistring, because an ansi string can
+               also be in a register
+             }
+             loadansistring;
+           end
+         else
+         if is_shortstring(left^.resulttype) then
+           begin
+             if is_ansistring(right^.resulttype) then
+               begin
+                 if (right^.treetype=stringconstn) and
+                    (pstringconstnode(right)^.length=0) then
+                   begin
+                      cg^.a_load_const_ref(list,OS_8,0,left^.location.reference);
+                      tg.del_reference(left^.location.reference);
+                   end
+                 else
+                   loadansi2short(right,left);
+               end
+             else
+               begin
+                  { we do not need destination anymore }
+                  tg.del_reference(left^.location.reference);
+                  { tg.del_reference(right^.location.reference);
+                    done in loadshortstring }
+                  loadshortstring;
+                  tg.ungetiftemp(right^.location.reference);
+               end;
+           end
+         else if is_longstring(left^.resulttype) then
+           begin
+              abstract;
+           end
+         else
+           begin
+             { its the only thing we have to do }
+             tg.del_reference(right^.location.reference);
+           end
+      end;
+
+    procedure generic_p2_assignment_int64_reg(p : passignmentnode);
+
+      begin
+         { we don't know it better here }
+         generic_p2_assignment(p);
+      end;
+
+    { updated from old cg on 29.2.00 by FK }
+    procedure generic_p2_assignment_flags(p : passignmentnode);
+
+      begin
+         { for example the alpha doesn't have flags }
+         abstract;
+      end;
+
     procedure tassignmentnode.secondpass;
 
       var
@@ -668,14 +700,13 @@ unit nmem;
               exit;
            end;
          if left^.resulttype^.deftype=stringdef then
-           p2_assignment_string(@self);
+           p2_assignment_string(@self)
          { if is an int64 which has to do with registers, we
            need to call probably a procedure for 32 bit processors
          }
          else if is_64bitint(left^.resulttype) and
-           ((left^.location in [LOC_REGISGTER,LOC_CREGISTER) or
-            (left^.location in [LOC_REGISGTER,LOC_CREGISTER)) then
-         else
+           ((left^.location.loc in [LOC_REGISTER,LOC_CREGISTER]) or
+            (left^.location.loc in [LOC_REGISTER,LOC_CREGISTER])) then
            p2_assignment_int64_reg(@self)
          else
            p2_assignment(@self);
@@ -683,13 +714,16 @@ unit nmem;
 
 begin
    p2_assignment:=@generic_p2_assignment;
-   p2_assignment_flags:=p2_assignment_flags;
+   p2_assignment_flags:=@generic_p2_assignment_flags;
    p2_assignment_string:=@generic_p2_assignment_string;
    p2_assignment_int64_reg:=@generic_p2_assignment_int64_reg;
 end.
 {
   $Log$
-  Revision 1.17  2000-03-01 15:36:13  florian
+  Revision 1.18  2000-04-29 09:01:06  jonas
+    * nmem compiles again (at least for powerpc)
+
+  Revision 1.17  2000/03/01 15:36:13  florian
     * some new stuff for the new cg
 
   Revision 1.16  2000/01/07 01:14:53  peter

+ 7 - 2
compiler/new/powerpc/cpubase.pas

@@ -150,7 +150,6 @@ type
 
   reg2strtable = array[tregister] of string[5];
 
-
 Const
    R_SPR1 = R_XER;
    R_SPR8 = R_LR;
@@ -363,6 +362,9 @@ const
   availabletempregsfpu = [R_F14..R_F31];
   availabletempregsmm  = [R_M0..R_M31];
 
+  lvaluelocations = [LOC_REFERENCE, LOC_CREGISTER, LOC_CFPUREGISTER,
+                     LOC_CMMREGISTER];
+
   c_countusableregsint = 21;
   c_countusableregsfpu = 32;
   c_countusableregsmm  = 32;
@@ -565,7 +567,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.13  2000-03-26 16:38:06  jonas
+  Revision 1.14  2000-04-29 09:01:06  jonas
+    * nmem compiles again (at least for powerpc)
+
+  Revision 1.13  2000/03/26 16:38:06  jonas
     * frame_pointer = stackpointer instead of R_NO
 
   Revision 1.12  2000/01/07 01:14:58  peter