Browse Source

* fixed regallocator for m68k

git-svn-id: trunk@2395 -
florian 19 years ago
parent
commit
2c1e796f1f
4 changed files with 26 additions and 23 deletions
  1. 8 9
      compiler/m68k/aasmcpu.pas
  2. 1 1
      compiler/m68k/cgcpu.pas
  3. 6 5
      compiler/m68k/cpubase.pas
  4. 11 8
      compiler/m68k/cpupara.pas

+ 8 - 9
compiler/m68k/aasmcpu.pas

@@ -508,7 +508,7 @@ type
         case opcode of
           A_MOVE, A_MOVEQ, A_ADD, A_ADDQ, A_ADDX, A_SUB, A_SUBQ,
           A_AND, A_LSR, A_LSL, A_ASR, A_ASL, A_EOR, A_EORI:
-            if opnr=0 then begin
+            if opnr=1 then begin
 //              writeln('move/etc write');
               result:=operand_write;
             end else begin
@@ -517,7 +517,7 @@ type
             end;
           A_TST,A_CMP,A_CMPI:
             result:=operand_read;
-          A_CLR,A_NEG:
+          A_CLR,A_NEG,A_SXX:
             result:=operand_write;
         else
           writeln('other opcode: ',gas_op2str[opcode],' (faked value returned)',opnr);
@@ -534,10 +534,10 @@ type
         case getregtype(r) of
           R_INTREGISTER :
             result:=taicpu.op_ref_reg(A_MOVE,S_L,ref,r);
-          R_FPUREGISTER : begin 
-            // is this correct?
-	    result:=taicpu.op_ref_reg(A_FMOVE,S_L,ref,r);          
-            end;
+          R_FPUREGISTER :
+	    result:=taicpu.op_ref_reg(A_FMOVE,S_L,ref,r);
+          R_ADDRESSREGISTER :
+            result:=taicpu.op_ref_reg(A_MOVE,S_L,ref,r);
         end;
 {
         case getregtype(r) of
@@ -563,14 +563,13 @@ type
 
     function spilling_create_store(r:tregister; const ref:treference): tai;
       begin
-//        writeln('spilling_create_store');
 	case getregtype(r) of
 	  R_INTREGISTER :
 	    result:=taicpu.op_reg_ref(A_MOVE,S_L,r,ref);
+	  R_ADDRESSREGISTER :
+	    result:=taicpu.op_reg_ref(A_MOVE,S_L,r,ref);
 	  R_FPUREGISTER :
-	    begin
 	    result:=taicpu.op_reg_ref(A_FMOVE,S_L,r,ref);
-	    end;
 	end;
         {case getregtype(r) of
           R_INTREGISTER :

+ 1 - 1
compiler/m68k/cgcpu.pas

@@ -883,7 +883,7 @@ unit cgcpu;
          { this should never occur }
          if len > 65535 then
            internalerror(0);
-	   
+	
          hregister := getintregister(list,OS_INT);
 //         if delsource then
 //            reference_release(list,source);

+ 6 - 5
compiler/m68k/cpubase.pas

@@ -144,8 +144,9 @@ unit cpubase;
       );
 
       { registers which may be destroyed by calls }
-      VOLATILE_INTREGISTERS = [];
+      VOLATILE_INTREGISTERS = [RS_D0,RS_D1];
       VOLATILE_FPUREGISTERS = [];
+      VOLATILE_ADDRESSREGISTER = [RS_A0,RS_A1];
 
     type
       totherregisterset = set of tregisterindex;
@@ -407,7 +408,7 @@ implementation
 {$WARNING FIX ME!!! results in bad code generation}
             cgsize2subreg:=R_SUBWHOLE;
             end;
-            
+
           OS_8,OS_S8:
             cgsize2subreg:=R_SUBWHOLE;
           OS_16,OS_S16:
@@ -418,14 +419,14 @@ implementation
             begin
              writeln('64bit regsize?');
              cgsize2subreg:=R_SUBWHOLE;
-            end;    
+            end;
           else begin
             writeln('hmm!?');
-    // this supposed to be debug         
+    // this supposed to be debug
     //        p:=nil; dword(p^):=0;
     //        internalerror(200301231);
             cgsize2subreg:=R_SUBWHOLE;
-          end;    
+          end;
         end;
       end;
 

+ 11 - 8
compiler/m68k/cpupara.pas

@@ -47,7 +47,7 @@ unit cpupara;
          private
            procedure init_values(var curintreg, curfloatreg: tsuperregister; var cur_stack_offset: aword);
            function create_paraloc_info_intern(p : tabstractprocdef; side: tcallercallee; paras: tparalist;
-                                               var curintreg, curfloatreg: tsuperregister; var cur_stack_offset: aword):longint;   
+                                               var curintreg, curfloatreg: tsuperregister; var cur_stack_offset: aword):longint;
            function parseparaloc(p : tparavarsym;const s : string) : boolean;override;
            function parsefuncretloc(p : tabstractprocdef; const s : string) : boolean;override;
        end;
@@ -193,7 +193,7 @@ unit cpupara;
         location_reset(p.funcretloc[side],LOC_INVALID,OS_NO);
 
         { explicit paraloc specified? }
-        if po_explicitparaloc in p.procoptions then 
+        if po_explicitparaloc in p.procoptions then
          begin
            p.funcretloc[side].loc:=LOC_REGISTER;
            p.funcretloc[side].register:=p.exp_funcretloc;
@@ -289,7 +289,7 @@ unit cpupara;
           begin
             hp:=tparavarsym(paras[i]);
 	    paradef:=hp.vartype.def;
-	    
+	
 	    { syscall for AmigaOS can have already a paraloc set }
             if (vo_has_explicit_paraloc in hp.varoptions) then
               begin
@@ -298,7 +298,7 @@ unit cpupara;
                 continue;
               end;
             hp.paraloc[side].reset;
-	    
+	
             { currently only support C-style array of const }
             if (p.proccalloption in [pocall_cdecl,pocall_cppdecl]) and
                is_array_of_const(paradef) then
@@ -353,8 +353,10 @@ unit cpupara;
             while (paralen > 0) do
               begin
                 paraloc:=hp.paraloc[side].add_location;
+                {
+                  by default, the m68k doesn't know any register parameters  (FK)
                 if (loc = LOC_REGISTER) and
-                   (nextintreg <= RS_D7) then
+                   (nextintreg <= RS_D2) then
                   begin
 		    //writeln('loc register');
                     paraloc^.loc := loc;
@@ -370,7 +372,7 @@ unit cpupara;
                     dec(paralen,tcgsize2size[paraloc^.size]);
                   end
                 else if (loc = LOC_FPUREGISTER) and
-                        (nextfloatreg <= RS_FP7) then
+                        (nextfloatreg <= RS_FP2) then
                   begin
 		    writeln('loc fpuregister');
                     paraloc^.loc:=loc;
@@ -380,6 +382,7 @@ unit cpupara;
                     dec(paralen,tcgsize2size[paraloc^.size]);
                   end
                 else { LOC_REFERENCE }
+}
                   begin
 		    writeln('loc reference');
                     paraloc^.loc:=LOC_REFERENCE;
@@ -466,12 +469,12 @@ unit cpupara;
               { 'A7' is the stack pointer on 68k, can't be overwritten by API calls }
               else
                 p.exp_funcretloc:=NR_NO;
-                
+
               if p.exp_funcretloc<>NR_NO then result:=true;
             end;
           else
             internalerror(2005121801);
-        end;    
+        end;
       end;