2
0
Эх сурвалжийг харах

* ppc compiles with -dnewra, haven't tried to compile anything with it
yet though

Jonas Maebe 22 жил өмнө
parent
commit
642d0f923b

+ 44 - 1
compiler/powerpc/aasmcpu.pas

@@ -78,6 +78,18 @@ uses
          constructor op_sym_ofs_ref(op : tasmop;_op1 : tasmsymbol;_op1ofs:longint;const _op2 : treference);
          constructor op_sym_ofs_ref(op : tasmop;_op1 : tasmsymbol;_op1ofs:longint;const _op2 : treference);
 
 
          procedure loadbool(opidx:longint;_b:boolean);
          procedure loadbool(opidx:longint;_b:boolean);
+
+
+         function is_nop: boolean; override;
+         function is_move:boolean; override;
+         function spill_registers(list:Taasmoutput;
+                                  rgget:Trggetproc;
+                                  rgunget:Trgungetproc;
+                                  r:Tsupregset;
+                                  var unusedregsint:Tsupregset;
+                                  const spilltemplist:Tspill_temp_list):boolean; override;
+
+
       end;
       end;
 
 
       tai_align = class(tai_align_abstract)
       tai_align = class(tai_align_abstract)
@@ -397,6 +409,33 @@ implementation
       end;
       end;
 
 
 
 
+{ ****************************** newra stuff *************************** }
+
+    function taicpu.is_nop: boolean;
+      begin
+        { we don't insert any more nops than necessary }
+        is_nop := false;
+      end;
+
+
+    function taicpu.is_move:boolean;
+      begin
+        is_move := opcode = A_MR;
+      end;
+
+
+    function taicpu.spill_registers(list:Taasmoutput; 
+                             rgget:Trggetproc; 
+                             rgunget:Trgungetproc; 
+                             r:Tsupregset; 
+                             var unusedregsint:Tsupregset; 
+                              const spilltemplist:Tspill_temp_list): boolean;
+      begin
+        internalerror(211);
+      end;
+
+
+
     procedure InitAsm;
     procedure InitAsm;
       begin
       begin
       end;
       end;
@@ -409,7 +448,11 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.7  2003-06-14 14:53:50  jonas
+  Revision 1.8  2003-06-14 22:32:43  jonas
+    * ppc compiles with -dnewra, haven't tried to compile anything with it
+      yet though
+
+  Revision 1.7  2003/06/14 14:53:50  jonas
     * fixed newra cycle for x86
     * fixed newra cycle for x86
     * added constants for indicating source and destination operands of the
     * added constants for indicating source and destination operands of the
       "move reg,reg" instruction to aasmcpu (and use those in rgobj)
       "move reg,reg" instruction to aasmcpu (and use those in rgobj)

+ 189 - 7
compiler/powerpc/cgcpu.pas

@@ -195,10 +195,18 @@ const
                reference_reset(ref);
                reference_reset(ref);
                ref.base:=locpara.reference.index;
                ref.base:=locpara.reference.index;
                ref.offset:=locpara.reference.offset;
                ref.offset:=locpara.reference.offset;
+{$ifndef newra}
                tmpreg := get_scratch_reg_int(list,size);
                tmpreg := get_scratch_reg_int(list,size);
+{$else newra}
+               tmpreg := rg.getregisterint(list,size);
+{$endif newra}
                a_load_ref_reg(list,size,size,r,tmpreg);
                a_load_ref_reg(list,size,size,r,tmpreg);
                a_load_reg_ref(list,size,size,tmpreg,ref);
                a_load_reg_ref(list,size,size,tmpreg,ref);
+{$ifndef newra}
                free_scratch_reg(list,tmpreg);
                free_scratch_reg(list,tmpreg);
+{$else newra}
+               rg.ungetregisterint(list,tmpreg); 
+{$endif newra}
             end;
             end;
           LOC_FPUREGISTER,LOC_CFPUREGISTER:
           LOC_FPUREGISTER,LOC_CFPUREGISTER:
             case size of
             case size of
@@ -216,7 +224,6 @@ const
 
 
 
 
     procedure tcgppc.a_paramaddr_ref(list : taasmoutput;const r : treference;const locpara : tparalocation);
     procedure tcgppc.a_paramaddr_ref(list : taasmoutput;const r : treference;const locpara : tparalocation);
-
       var
       var
         ref: treference;
         ref: treference;
         tmpreg: tregister;
         tmpreg: tregister;
@@ -230,10 +237,18 @@ const
                 reference_reset(ref);
                 reference_reset(ref);
                 ref.base := locpara.reference.index;
                 ref.base := locpara.reference.index;
                 ref.offset := locpara.reference.offset;
                 ref.offset := locpara.reference.offset;
+{$ifndef newra}
                 tmpreg := get_scratch_reg_address(list);
                 tmpreg := get_scratch_reg_address(list);
+{$else newra}
+                tmpreg := rg.getregisterint(list,OS_ADDR);
+{$endif newra}
                 a_loadaddr_ref_reg(list,r,tmpreg);
                 a_loadaddr_ref_reg(list,r,tmpreg);
                 a_load_reg_ref(list,OS_ADDR,OS_ADDR,tmpreg,ref);
                 a_load_reg_ref(list,OS_ADDR,OS_ADDR,tmpreg,ref);
+{$ifndef newra}
                 free_scratch_reg(list,tmpreg);
                 free_scratch_reg(list,tmpreg);
+{$else newra}
+                rg.ungetregisterint(list,tmpreg);
+{$endif newra}
               end;
               end;
             else
             else
               internalerror(2002080701);
               internalerror(2002080701);
@@ -269,14 +284,22 @@ const
             {Generate instruction to load the procedure address from
             {Generate instruction to load the procedure address from
             the transition vector.}
             the transition vector.}
             //TODO: Support cross-TOC calls.
             //TODO: Support cross-TOC calls.
+{$ifndef newra}
             tmpreg := get_scratch_reg_int(list,OS_INT);
             tmpreg := get_scratch_reg_int(list,OS_INT);
+{$else newra}
+            tmpreg := rg.getregisterint(list,OS_INT);
+{$endif newra}
             reference_reset(tmpref);
             reference_reset(tmpref);
             tmpref.offset := 0;
             tmpref.offset := 0;
             //tmpref.symaddr := refs_full;
             //tmpref.symaddr := refs_full;
             tmpref.base:= reg;
             tmpref.base:= reg;
             list.concat(taicpu.op_reg_ref(A_LWZ,tmpreg,tmpref));
             list.concat(taicpu.op_reg_ref(A_LWZ,tmpreg,tmpref));
             list.concat(taicpu.op_reg(A_MTCTR,tmpreg));
             list.concat(taicpu.op_reg(A_MTCTR,tmpreg));
+{$ifndef newra}
             free_scratch_reg(list,tmpreg);
             free_scratch_reg(list,tmpreg);
+{$else newra}            
+            rg.ungetregisterint(list,tmpreg);
+{$endif newra}            
           end
           end
         else
         else
           list.concat(taicpu.op_reg(A_MTCTR,reg));
           list.concat(taicpu.op_reg(A_MTCTR,reg));
@@ -298,7 +321,11 @@ const
         tmpref : treference;
         tmpref : treference;
 
 
       begin
       begin
+{$ifndef newra}
         tmpreg := get_scratch_reg_int(list,OS_ADDR);
         tmpreg := get_scratch_reg_int(list,OS_ADDR);
+{$else newra}            
+        tmpreg := rg.getregisterint(list,OS_ADDR);
+{$endif newra}            
         a_load_ref_reg(list,OS_ADDR,OS_ADDR,ref,tmpreg);
         a_load_ref_reg(list,OS_ADDR,OS_ADDR,ref,tmpreg);
         if target_info.system=system_powerpc_macos then
         if target_info.system=system_powerpc_macos then
           begin
           begin
@@ -312,7 +339,11 @@ const
             list.concat(taicpu.op_reg_ref(A_LWZ,tmpreg,tmpref));
             list.concat(taicpu.op_reg_ref(A_LWZ,tmpreg,tmpref));
           end;
           end;
         list.concat(taicpu.op_reg(A_MTCTR,tmpreg));
         list.concat(taicpu.op_reg(A_MTCTR,tmpreg));
+{$ifndef newra}
         free_scratch_reg(list,tmpreg);
         free_scratch_reg(list,tmpreg);
+{$else newra}
+        rg.ungetregisterint(list,tmpreg);
+{$endif newra} 
         list.concat(taicpu.op_none(A_BCTRL));
         list.concat(taicpu.op_none(A_BCTRL));
         //if target_info.system=system_powerpc_macos then
         //if target_info.system=system_powerpc_macos then
         //  //NOP is not needed here.
         //  //NOP is not needed here.
@@ -369,7 +400,11 @@ const
          op := storeinstr[tcgsize2unsigned[tosize],ref2.index.number<>NR_NO,false];
          op := storeinstr[tcgsize2unsigned[tosize],ref2.index.number<>NR_NO,false];
          a_load_store(list,op,reg,ref2);
          a_load_store(list,op,reg,ref2);
          if freereg then
          if freereg then
+{$ifndef newra}
            cg.free_scratch_reg(list,ref2.base);
            cg.free_scratch_reg(list,ref2.base);
+{$else newra}
+            rg.ungetregisterint(list,ref2.base);
+{$endif newra}
        End;
        End;
 
 
 
 
@@ -403,7 +438,11 @@ const
           op := loadinstr[fromsize,ref2.index.number<>NR_NO,false];
           op := loadinstr[fromsize,ref2.index.number<>NR_NO,false];
           a_load_store(list,op,reg,ref2);
           a_load_store(list,op,reg,ref2);
           if freereg then
           if freereg then
+{$ifndef newra}
             free_scratch_reg(list,ref2.base);
             free_scratch_reg(list,ref2.base);
+{$else newra}
+            rg.ungetregisterint(list,ref2.base);
+{$endif newra}
           { sign extend shortint if necessary, since there is no }
           { sign extend shortint if necessary, since there is no }
           { load instruction that does that automatically (JM)   }
           { load instruction that does that automatically (JM)   }
           if fromsize = OS_S8 then
           if fromsize = OS_S8 then
@@ -478,7 +517,11 @@ const
          op := fpuloadinstr[size,ref2.index.number <> NR_NO,false];
          op := fpuloadinstr[size,ref2.index.number <> NR_NO,false];
          a_load_store(list,op,reg,ref2);
          a_load_store(list,op,reg,ref2);
          if freereg then
          if freereg then
+{$ifndef newra}
            cg.free_scratch_reg(list,ref2.base);
            cg.free_scratch_reg(list,ref2.base);
+{$else newra}
+           rg.ungetregisterint(list,ref2.base);
+{$endif newra}
        end;
        end;
 
 
 
 
@@ -502,15 +545,16 @@ const
          op := fpustoreinstr[size,ref2.index.number <> NR_NO,false];
          op := fpustoreinstr[size,ref2.index.number <> NR_NO,false];
          a_load_store(list,op,reg,ref2);
          a_load_store(list,op,reg,ref2);
          if freereg then
          if freereg then
+{$ifndef newra}
            cg.free_scratch_reg(list,ref2.base);
            cg.free_scratch_reg(list,ref2.base);
+{$else newra}
+           rg.ungetregisterint(list,ref2.base);
+{$endif newra}
        end;
        end;
 
 
 
 
      procedure tcgppc.a_op_const_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; a: AWord; reg: TRegister);
      procedure tcgppc.a_op_const_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; a: AWord; reg: TRegister);
 
 
-       var
-         scratch_register: TRegister;
-
        begin
        begin
          a_op_const_reg_reg(list,op,OS_32,a,reg,reg);
          a_op_const_reg_reg(list,op,OS_32,a,reg,reg);
        end;
        end;
@@ -663,11 +707,19 @@ const
             if gotrlwi and
             if gotrlwi and
                (src.number = dst.number) then
                (src.number = dst.number) then
               begin
               begin
+{$ifndef newra}
                 scratchreg := get_scratch_reg_int(list,OS_INT);
                 scratchreg := get_scratch_reg_int(list,OS_INT);
+{$else newra}
+                scratchreg := rg.getregisterint(list,OS_INT);
+{$endif newra}
                 list.concat(taicpu.op_reg_const(A_LI,scratchreg,-1));
                 list.concat(taicpu.op_reg_const(A_LI,scratchreg,-1));
                 list.concat(taicpu.op_reg_reg_const_const_const(A_RLWIMI,dst,
                 list.concat(taicpu.op_reg_reg_const_const_const(A_RLWIMI,dst,
                   scratchreg,0,l1,l2));
                   scratchreg,0,l1,l2));
+{$ifndef newra}
                 free_scratch_reg(list,scratchreg);
                 free_scratch_reg(list,scratchreg);
+{$else newra}
+                rg.ungetregisterint(list,scratchreg);
+{$endif newra}
               end
               end
             else
             else
               do_lo_hi;
               do_lo_hi;
@@ -697,10 +749,18 @@ const
         { perform the operation                                        }
         { perform the operation                                        }
         if useReg then
         if useReg then
           begin
           begin
+{$ifndef newra}
             scratchreg := get_scratch_reg_int(list,OS_INT);
             scratchreg := get_scratch_reg_int(list,OS_INT);
+{$else newra}
+            scratchreg := rg.getregisterint(list,OS_INT);
+{$endif newra}
             a_load_const_reg(list,OS_32,a,scratchreg);
             a_load_const_reg(list,OS_32,a,scratchreg);
             a_op_reg_reg_reg(list,op,OS_32,scratchreg,src,dst);
             a_op_reg_reg_reg(list,op,OS_32,scratchreg,src,dst);
+{$ifndef newra}
             free_scratch_reg(list,scratchreg);
             free_scratch_reg(list,scratchreg);
+{$else newra}
+            rg.ungetregisterint(list,scratchreg);
+{$endif newra}
           end;
           end;
       end;
       end;
 
 
@@ -747,20 +807,36 @@ const
               list.concat(taicpu.op_reg_reg_const(A_CMPWI,r,reg,longint(a)))
               list.concat(taicpu.op_reg_reg_const(A_CMPWI,r,reg,longint(a)))
             else
             else
               begin
               begin
+{$ifndef newra}
                 scratch_register := get_scratch_reg_int(list,OS_INT);
                 scratch_register := get_scratch_reg_int(list,OS_INT);
+{$else newra}
+                scratch_register := rg.getregisterint(list,OS_INT);        
+{$endif newra}
                 a_load_const_reg(list,OS_32,a,scratch_register);
                 a_load_const_reg(list,OS_32,a,scratch_register);
                 list.concat(taicpu.op_reg_reg_reg(A_CMPW,r,reg,scratch_register));
                 list.concat(taicpu.op_reg_reg_reg(A_CMPW,r,reg,scratch_register));
+{$ifndef newra}
                 free_scratch_reg(list,scratch_register);
                 free_scratch_reg(list,scratch_register);
+{$else newra}
+                rg.ungetregisterint(list,scratch_register);        
+{$endif newra}
               end
               end
           else
           else
             if (a <= $ffff) then
             if (a <= $ffff) then
               list.concat(taicpu.op_reg_reg_const(A_CMPLWI,r,reg,a))
               list.concat(taicpu.op_reg_reg_const(A_CMPLWI,r,reg,a))
             else
             else
               begin
               begin
+{$ifndef newra}
                 scratch_register := get_scratch_reg_int(list,OS_32);
                 scratch_register := get_scratch_reg_int(list,OS_32);
+{$else newra}
+                scratch_register := rg.getregisterint(list,OS_INT);
+{$endif newra}
                 a_load_const_reg(list,OS_32,a,scratch_register);
                 a_load_const_reg(list,OS_32,a,scratch_register);
                 list.concat(taicpu.op_reg_reg_reg(A_CMPLW,r,reg,scratch_register));
                 list.concat(taicpu.op_reg_reg_reg(A_CMPLW,r,reg,scratch_register));
+{$ifndef newra}
                 free_scratch_reg(list,scratch_register);
                 free_scratch_reg(list,scratch_register);
+{$else newra}
+                rg.ungetregisterint(list,scratch_register);
+{$endif newra}
               end;
               end;
           a_jmp(list,A_BC,TOpCmp2AsmCond[cmp_op],0,l);
           a_jmp(list,A_BC,TOpCmp2AsmCond[cmp_op],0,l);
         end;
         end;
@@ -1075,10 +1151,18 @@ const
             else
             else
               begin
               begin
                 reference_reset_base(href,r,0);
                 reference_reset_base(href,r,0);
+{$ifndef newra}
                 href.index := get_scratch_reg_int(list,OS_32);
                 href.index := get_scratch_reg_int(list,OS_32);
+{$else newra}
+                href.index := rg.getregisterint(list,OS_32);
+{$endif newra}
                 a_load_const_reg(list,OS_S32,-localsize,href.index);
                 a_load_const_reg(list,OS_S32,-localsize,href.index);
                 a_load_store(list,A_STWUX,r,href);
                 a_load_store(list,A_STWUX,r,href);
+{$ifndef newra}
                 free_scratch_reg(list,href.index);
                 free_scratch_reg(list,href.index);
+{$else newra}
+                rg.ungetregisterint(list,href.index);
+{$endif newra}
               end;
               end;
           end;
           end;
 
 
@@ -1588,10 +1672,18 @@ const
             else
             else
               begin
               begin
                 reference_reset_base(href,r,0);
                 reference_reset_base(href,r,0);
+{$ifndef newra}
                 href.index := get_scratch_reg_int(list,OS_32);
                 href.index := get_scratch_reg_int(list,OS_32);
+{$else newra}
+                href.index := rg.getregisterint(list,OS_ADDR);
+{$endif newra}
                 a_load_const_reg(list,OS_S32,-localsize,href.index);
                 a_load_const_reg(list,OS_S32,-localsize,href.index);
                 a_load_store(list,A_STWUX,r,href);
                 a_load_store(list,A_STWUX,r,href);
+{$ifndef newra}
                 free_scratch_reg(list,href.index);
                 free_scratch_reg(list,href.index);
+{$else newra}
+                rg.ungetregisterint(list,href.index);
+{$endif newra}
               end;
               end;
           end;
           end;
       end;
       end;
@@ -1737,7 +1829,11 @@ const
                        ref2.base,tmpref));
                        ref2.base,tmpref));
                      if freereg then
                      if freereg then
                        begin
                        begin
+{$ifndef newra}
                          cg.free_scratch_reg(list,ref2.base);
                          cg.free_scratch_reg(list,ref2.base);
+{$else newra}
+                         rg.ungetregisterint(list,ref2.base);
+{$endif newra}
                          freereg := false;
                          freereg := false;
                        end;
                        end;
                    end
                    end
@@ -1763,7 +1859,11 @@ const
                  (r.number <> ref2.base.number) then
                  (r.number <> ref2.base.number) then
            list.concat(taicpu.op_reg_reg(A_MR,r,ref2.base));
            list.concat(taicpu.op_reg_reg(A_MR,r,ref2.base));
          if freereg then
          if freereg then
+{$ifndef newra}
            cg.free_scratch_reg(list,ref2.base);
            cg.free_scratch_reg(list,ref2.base);
+{$else newra}                         
+           rg.ungetregisterint(list,ref2.base);
+{$endif newra}                         
        end;
        end;
 
 
 { ************* concatcopy ************ }
 { ************* concatcopy ************ }
@@ -1831,7 +1931,11 @@ const
         { load the address of source into src.base }
         { load the address of source into src.base }
         if loadref then
         if loadref then
           begin
           begin
+{$ifndef newra}
             src.base := get_scratch_reg_address(list);
             src.base := get_scratch_reg_address(list);
+{$else newra}
+           src.base := rg.getregisterint(list,OS_ADDR);
+{$endif newra}
             a_load_ref_reg(list,OS_32,OS_32,source,src.base);
             a_load_ref_reg(list,OS_32,OS_32,source,src.base);
             orgsrc := false;
             orgsrc := false;
           end
           end
@@ -1840,7 +1944,11 @@ const
                 ((source.index.number <> NR_NO) and
                 ((source.index.number <> NR_NO) and
                  ((source.offset + longint(len)) > high(smallint))) then
                  ((source.offset + longint(len)) > high(smallint))) then
           begin
           begin
+{$ifndef newra}
             src.base := get_scratch_reg_address(list);
             src.base := get_scratch_reg_address(list);
+{$else newra}
+            src.base := rg.getregisterint(list,OS_ADDR);
+{$endif newra}
             a_loadaddr_ref_reg(list,source,src.base);
             a_loadaddr_ref_reg(list,source,src.base);
             orgsrc := false;
             orgsrc := false;
           end
           end
@@ -1857,7 +1965,11 @@ const
            ((dest.index.number <> NR_NO) and
            ((dest.index.number <> NR_NO) and
             ((dest.offset + longint(len)) > high(smallint))) then
             ((dest.offset + longint(len)) > high(smallint))) then
           begin
           begin
+{$ifndef newra}
             dst.base := get_scratch_reg_address(list);
             dst.base := get_scratch_reg_address(list);
+{$else newra}                                                
+            dst.base := rg.getregisterint(list,OS_ADDR);
+{$endif newra}      
             a_loadaddr_ref_reg(list,dest,dst.base);
             a_loadaddr_ref_reg(list,dest,dst.base);
             orgdst := false;
             orgdst := false;
           end
           end
@@ -1879,7 +1991,11 @@ const
             inc(src.offset,8);
             inc(src.offset,8);
             list.concat(taicpu.op_reg_reg_const(A_SUBI,src.base,src.base,8));
             list.concat(taicpu.op_reg_reg_const(A_SUBI,src.base,src.base,8));
             list.concat(taicpu.op_reg_reg_const(A_SUBI,dst.base,dst.base,8));
             list.concat(taicpu.op_reg_reg_const(A_SUBI,dst.base,dst.base,8));
+{$ifndef newra}
             countreg := get_scratch_reg_int(list,OS_INT);
             countreg := get_scratch_reg_int(list,OS_INT);
+{$else newra}                                                
+            countreg := rg.getregisterint(list,OS_INT);                         
+{$endif newra}                                                
             a_load_const_reg(list,OS_32,count,countreg);
             a_load_const_reg(list,OS_32,count,countreg);
             { explicitely allocate R_0 since it can be used safely here }
             { explicitely allocate R_0 since it can be used safely here }
             { (for holding date that's being copied)                    }
             { (for holding date that's being copied)                    }
@@ -1892,7 +2008,11 @@ const
             list.concat(taicpu.op_reg_ref(A_LFDU,r,src));
             list.concat(taicpu.op_reg_ref(A_LFDU,r,src));
             list.concat(taicpu.op_reg_ref(A_STFDU,r,dst));
             list.concat(taicpu.op_reg_ref(A_STFDU,r,dst));
             a_jmp(list,A_BC,C_NE,0,lab);
             a_jmp(list,A_BC,C_NE,0,lab);
+{$ifndef newra}
             free_scratch_reg(list,countreg);
             free_scratch_reg(list,countreg);
+{$else newra}                                                
+           rg.ungetregisterint(list,countreg);                         
+{$endif newra}                                                
             a_reg_dealloc(list,r);
             a_reg_dealloc(list,r);
             len := len mod 8;
             len := len mod 8;
           end;
           end;
@@ -1937,7 +2057,11 @@ const
             inc(src.offset,4);
             inc(src.offset,4);
             list.concat(taicpu.op_reg_reg_const(A_SUBI,src.base,src.base,4));
             list.concat(taicpu.op_reg_reg_const(A_SUBI,src.base,src.base,4));
             list.concat(taicpu.op_reg_reg_const(A_SUBI,dst.base,dst.base,4));
             list.concat(taicpu.op_reg_reg_const(A_SUBI,dst.base,dst.base,4));
+{$ifndef newra}
             countreg := get_scratch_reg_int(list,OS_INT);
             countreg := get_scratch_reg_int(list,OS_INT);
+{$else newra}                                                
+            countreg := rg.getregisterint(list,OS_INT);                         
+{$endif newra}                                                
             a_load_const_reg(list,OS_32,count,countreg);
             a_load_const_reg(list,OS_32,count,countreg);
             { explicitely allocate R_0 since it can be used safely here }
             { explicitely allocate R_0 since it can be used safely here }
             { (for holding date that's being copied)                    }
             { (for holding date that's being copied)                    }
@@ -1950,7 +2074,11 @@ const
             list.concat(taicpu.op_reg_ref(A_LWZU,r,src));
             list.concat(taicpu.op_reg_ref(A_LWZU,r,src));
             list.concat(taicpu.op_reg_ref(A_STWU,r,dst));
             list.concat(taicpu.op_reg_ref(A_STWU,r,dst));
             a_jmp(list,A_BC,C_NE,0,lab);
             a_jmp(list,A_BC,C_NE,0,lab);
+{$ifndef newra}
             free_scratch_reg(list,countreg);
             free_scratch_reg(list,countreg);
+{$else newra}                                                
+           rg.ungetregisterint(list,countreg);                         
+{$endif newra}                                                
             a_reg_dealloc(list,r);
             a_reg_dealloc(list,r);
             len := len mod 4;
             len := len mod 4;
           end;
           end;
@@ -2000,9 +2128,17 @@ const
              reference_release(list,source);
              reference_release(list,source);
          end
          end
        else
        else
+{$ifndef newra}
          free_scratch_reg(list,src.base);
          free_scratch_reg(list,src.base);
+{$else newra}                                                
+         rg.ungetregisterint(list,src.base);                         
+{$endif newra}                                                
        if not orgdst then
        if not orgdst then
+{$ifndef newra}
          free_scratch_reg(list,dst.base);
          free_scratch_reg(list,dst.base);
+{$else newra}                                                
+         rg.ungetregisterint(list,dest.base);                         
+{$endif newra}                                                
        if delsource then
        if delsource then
          tg.ungetiftemp(list,source);
          tg.ungetiftemp(list,source);
       end;
       end;
@@ -2190,7 +2326,11 @@ const
                 ((ref.offset <> 0) or assigned(ref.symbol)) then
                 ((ref.offset <> 0) or assigned(ref.symbol)) then
                begin
                begin
                  result := true;
                  result := true;
+{$ifndef newra}
                  tmpreg := cg.get_scratch_reg_int(list,OS_INT);
                  tmpreg := cg.get_scratch_reg_int(list,OS_INT);
+{$else newra}                                                
+                 tmpreg := rg.getregisterint(list,OS_INT);                         
+{$endif newra}                                                
                  if not assigned(ref.symbol) and
                  if not assigned(ref.symbol) and
                     (cardinal(ref.offset-low(smallint)) <=
                     (cardinal(ref.offset-low(smallint)) <=
                       high(smallint)-low(smallint)) then
                       high(smallint)-low(smallint)) then
@@ -2311,7 +2451,11 @@ const
                           op    reg, tempreg
                           op    reg, tempreg
                         but which saves one instruction.}
                         but which saves one instruction.}
 
 
+{$ifndef newra}
                         tmpreg := get_scratch_reg_address(list);
                         tmpreg := get_scratch_reg_address(list);
+{$else newra}                                                
+                        tmpreg := rg.getregisterint(list,OS_ADDR);                         
+{$endif newra}                                                
                         reference_reset(tmpref);
                         reference_reset(tmpref);
                         tmpref.symbol := ref.symbol;
                         tmpref.symbol := ref.symbol;
                         tmpref.offset := ref.offset;
                         tmpref.offset := ref.offset;
@@ -2326,7 +2470,11 @@ const
                       end
                       end
                     else
                     else
                       begin
                       begin
+{$ifndef newra}
                         tmpreg := get_scratch_reg_address(list);
                         tmpreg := get_scratch_reg_address(list);
+{$else newra}                                                
+                        tmpreg := rg.getregisterint(list,OS_ADDR);                         
+{$endif newra}                                                
                         reference_reset(tmpref);
                         reference_reset(tmpref);
                         tmpref.symbol := ref.symbol;
                         tmpref.symbol := ref.symbol;
                         tmpref.offset := ref.offset;
                         tmpref.offset := ref.offset;
@@ -2361,7 +2509,11 @@ const
                       end
                       end
                     else
                     else
                       begin
                       begin
+{$ifndef newra}
                         tmpreg := get_scratch_reg_address(list);
                         tmpreg := get_scratch_reg_address(list);
+{$else newra}                                                
+                        tmpreg := rg.getregisterint(list,OS_ADDR);                         
+{$endif newra}                                                
                         reference_reset(tmpref);
                         reference_reset(tmpref);
                         tmpref.symbol := ref.symbol;
                         tmpref.symbol := ref.symbol;
                         tmpref.offset := ref.offset;
                         tmpref.offset := ref.offset;
@@ -2382,7 +2534,11 @@ const
               end
               end
             else
             else
               begin
               begin
+{$ifndef newra}
                 tmpreg := get_scratch_reg_address(list);
                 tmpreg := get_scratch_reg_address(list);
+{$else newra}
+                tmpreg := rg.getregisterint(list,OS_ADDR);
+{$endif newra}
                 reference_reset(tmpref);
                 reference_reset(tmpref);
                 tmpref.symbol := ref.symbol;
                 tmpref.symbol := ref.symbol;
                 tmpref.offset := ref.offset;
                 tmpref.offset := ref.offset;
@@ -2400,7 +2556,11 @@ const
         else
         else
           list.concat(taicpu.op_reg_ref(op,reg,ref));
           list.concat(taicpu.op_reg_ref(op,reg,ref));
         if (tmpreg.number <> NR_NO) then
         if (tmpreg.number <> NR_NO) then
+{$ifndef newra}
           free_scratch_reg(list,tmpreg);
           free_scratch_reg(list,tmpreg);
+{$else newra}                                                                   
+          rg.ungetregisterint(list,tmpreg);
+{$endif newra}                                                                  
       end;
       end;
 
 
 
 
@@ -2495,22 +2655,40 @@ const
                     end
                     end
                   else if ((value shr 32) = 0) then
                   else if ((value shr 32) = 0) then
                     begin
                     begin
+{$ifndef newra}
                       tmpreg := cg.get_scratch_reg_int(list,OS_32);
                       tmpreg := cg.get_scratch_reg_int(list,OS_32);
+{$else newra}                                                                   
+                      tmpreg := rg.getregisterint(list,OS_32);
+{$endif newra}                                                                  
                       cg.a_load_const_reg(list,OS_32,cardinal(value),tmpreg);
                       cg.a_load_const_reg(list,OS_32,cardinal(value),tmpreg);
                       list.concat(taicpu.op_reg_reg_reg(ops[issub,2],
                       list.concat(taicpu.op_reg_reg_reg(ops[issub,2],
                         regdst.reglo,regsrc.reglo,tmpreg));
                         regdst.reglo,regsrc.reglo,tmpreg));
+{$ifndef newra}
                       cg.free_scratch_reg(list,tmpreg);
                       cg.free_scratch_reg(list,tmpreg);
+{$else newra}                                                                   
+                      rg.ungetregisterint(list,tmpreg);
+{$endif newra}                                                                  
                       list.concat(taicpu.op_reg_reg(ops[issub,3],
                       list.concat(taicpu.op_reg_reg(ops[issub,3],
                         regdst.reghi,regsrc.reghi));
                         regdst.reghi,regsrc.reghi));
                     end
                     end
                   else
                   else
                     begin
                     begin
-                      tmpreg64.reglo := cg.get_scratch_reg_int(list,OS_INT);
-                      tmpreg64.reghi := cg.get_scratch_reg_int(list,OS_INT);
+{$ifndef newra}
+                      tmpreg64.reglo := cg.get_scratch_reg_int(list,OS_32);
+                      tmpreg64.reghi := cg.get_scratch_reg_int(list,OS_32);
+{$else newra}                                                                   
+                      tmpreg64.reglo := rg.getregisterint(list,OS_32);
+                      tmpreg64.reghi := rg.getregisterint(list,OS_32);
+{$endif newra}                                                                  
                       a_load64_const_reg(list,value,tmpreg64);
                       a_load64_const_reg(list,value,tmpreg64);
                       a_op64_reg_reg_reg(list,op,tmpreg64,regsrc,regdst);
                       a_op64_reg_reg_reg(list,op,tmpreg64,regsrc,regdst);
+{$ifndef newra}
                       cg.free_scratch_reg(list,tmpreg64.reghi);
                       cg.free_scratch_reg(list,tmpreg64.reghi);
                       cg.free_scratch_reg(list,tmpreg64.reglo);
                       cg.free_scratch_reg(list,tmpreg64.reglo);
+{$else newra}
+                      rg.ungetregisterint(list,tmpreg64.reglo);
+                      rg.ungetregisterint(list,tmpreg64.reghi);  
+{$endif newra}
                     end
                     end
                 end
                 end
               else
               else
@@ -2532,7 +2710,11 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.108  2003-06-13 21:19:31  peter
+  Revision 1.109  2003-06-14 22:32:43  jonas
+    * ppc compiles with -dnewra, haven't tried to compile anything with it
+      yet though
+
+  Revision 1.108  2003/06/13 21:19:31  peter
     * current_procdef removed, use current_procinfo.procdef instead
     * current_procdef removed, use current_procinfo.procdef instead
 
 
   Revision 1.107  2003/06/09 14:54:26  jonas
   Revision 1.107  2003/06/09 14:54:26  jonas

+ 7 - 1
compiler/powerpc/cpubase.pas

@@ -555,11 +555,13 @@ uses
       param_regs_mm: Array[1..max_param_regs_mm] of Toldregister =
       param_regs_mm: Array[1..max_param_regs_mm] of Toldregister =
         (R_M1,R_M2,R_M3,R_M4,R_M5,R_M6,R_M7,R_M8,R_M9,R_M10,R_M11,R_M12,R_M13);
         (R_M1,R_M2,R_M3,R_M4,R_M5,R_M6,R_M7,R_M8,R_M9,R_M10,R_M11,R_M12,R_M13);
 
 
+{$ifndef newra}
       {# Registers which are defined as scratch and no need to save across
       {# Registers which are defined as scratch and no need to save across
          routine calls or in assembler blocks.
          routine calls or in assembler blocks.
       }
       }
       max_scratch_regs = 3;
       max_scratch_regs = 3;
       scratch_regs: Array[1..max_scratch_regs] of Tsuperregister = (RS_R29,RS_R30,RS_R31);
       scratch_regs: Array[1..max_scratch_regs] of Tsuperregister = (RS_R29,RS_R30,RS_R31);
+{$endif newra}
 
 
 {*****************************************************************************
 {*****************************************************************************
                           Default generic sizes
                           Default generic sizes
@@ -875,7 +877,11 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.57  2003-06-13 17:44:44  jonas
+  Revision 1.58  2003-06-14 22:32:43  jonas
+    * ppc compiles with -dnewra, haven't tried to compile anything with it
+      yet though
+
+  Revision 1.57  2003/06/13 17:44:44  jonas
     + added supreg_name function
     + added supreg_name function
 
 
   Revision 1.56  2003/06/12 19:11:34  jonas
   Revision 1.56  2003/06/12 19:11:34  jonas

+ 78 - 5
compiler/powerpc/nppcadd.pas

@@ -101,13 +101,17 @@ interface
         secondpass(left);
         secondpass(left);
 
 
         { are too few registers free? }
         { are too few registers free? }
+{$ifndef newra}
         maybe_save(exprasmlist,right.registers32,left.location,pushedregs);
         maybe_save(exprasmlist,right.registers32,left.location,pushedregs);
+{$endif newra}
         if location.loc=LOC_FPUREGISTER then
         if location.loc=LOC_FPUREGISTER then
           pushedfpu:=maybe_pushfpu(exprasmlist,right.registersfpu,left.location)
           pushedfpu:=maybe_pushfpu(exprasmlist,right.registersfpu,left.location)
         else
         else
           pushedfpu:=false;
           pushedfpu:=false;
         secondpass(right);
         secondpass(right);
+{$ifndef newra}
         maybe_restore(exprasmlist,left.location,pushedregs);
         maybe_restore(exprasmlist,left.location,pushedregs);
+{$endif newra}
         if pushedfpu then
         if pushedfpu then
           begin
           begin
             tmpreg := rg.getregisterfpu(exprasmlist,left.location.size);
             tmpreg := rg.getregisterfpu(exprasmlist,left.location.size);
@@ -262,7 +266,11 @@ interface
             else
             else
               begin
               begin
                 useconst := false;
                 useconst := false;
+{$ifndef newra}
                 tmpreg := cg.get_scratch_reg_int(exprasmlist,OS_INT);
                 tmpreg := cg.get_scratch_reg_int(exprasmlist,OS_INT);
+{$else newra}
+                tmpreg := rg.getregisterint(exprasmlist,OS_INT);
+{$endif newra}
                 cg.a_load_const_reg(exprasmlist,OS_INT,
                 cg.a_load_const_reg(exprasmlist,OS_INT,
                   aword(right.location.value),tmpreg);
                   aword(right.location.value),tmpreg);
                end
                end
@@ -290,7 +298,11 @@ interface
             begin
             begin
               exprasmlist.concat(taicpu.op_reg_reg(op,
               exprasmlist.concat(taicpu.op_reg_reg(op,
                 left.location.register,tmpreg));
                 left.location.register,tmpreg));
+{$ifndef newra}
               cg.free_scratch_reg(exprasmlist,tmpreg);
               cg.free_scratch_reg(exprasmlist,tmpreg);
+{$else newra}
+              rg.ungetregisterint(exprasmlist,tmpreg);
+{$endif newra}
             end
             end
         else
         else
           exprasmlist.concat(taicpu.op_reg_reg(op,
           exprasmlist.concat(taicpu.op_reg_reg(op,
@@ -348,7 +360,9 @@ interface
                falselabel:=ofl;
                falselabel:=ofl;
              end;
              end;
 
 
+{$ifndef newra}
             maybe_save(exprasmlist,right.registers32,left.location,pushedregs);
             maybe_save(exprasmlist,right.registers32,left.location,pushedregs);
+{$endif newra}
             isjump:=(right.location.loc=LOC_JUMP);
             isjump:=(right.location.loc=LOC_JUMP);
             if isjump then
             if isjump then
               begin
               begin
@@ -358,7 +372,9 @@ interface
                  objectlibrary.getlabel(falselabel);
                  objectlibrary.getlabel(falselabel);
               end;
               end;
             secondpass(right);
             secondpass(right);
+{$ifndef newra}
             maybe_restore(exprasmlist,left.location,pushedregs);
             maybe_restore(exprasmlist,left.location,pushedregs);
+{$endif newra}
             if right.location.loc in [LOC_FLAGS,LOC_JUMP] then
             if right.location.loc in [LOC_FLAGS,LOC_JUMP] then
              location_force_reg(exprasmlist,right.location,cgsize,false);
              location_force_reg(exprasmlist,right.location,cgsize,false);
             if isjump then
             if isjump then
@@ -585,7 +601,11 @@ interface
                       left.location.register,location.register)
                       left.location.register,location.register)
                   else
                   else
                     begin
                     begin
+{$ifndef newra}
                       tmpreg := cg.get_scratch_reg_int(exprasmlist,OS_INT);
                       tmpreg := cg.get_scratch_reg_int(exprasmlist,OS_INT);
+{$else newra}
+                      tmpreg := rg.getregisterint(exprasmlist,OS_INT);
+{$endif newra}
                       cg.a_load_const_reg(exprasmlist,OS_INT,1,tmpreg);
                       cg.a_load_const_reg(exprasmlist,OS_INT,1,tmpreg);
                       cg.a_op_reg_reg(exprasmlist,OP_SHL,OS_INT,
                       cg.a_op_reg_reg(exprasmlist,OP_SHL,OS_INT,
                         right.location.register,tmpreg);
                         right.location.register,tmpreg);
@@ -595,7 +615,11 @@ interface
                       else
                       else
                         cg.a_op_const_reg_reg(exprasmlist,OP_OR,OS_INT,
                         cg.a_op_const_reg_reg(exprasmlist,OP_OR,OS_INT,
                           aword(left.location.value),tmpreg,location.register);
                           aword(left.location.value),tmpreg,location.register);
+{$ifndef newra}
                       cg.free_scratch_reg(exprasmlist,tmpreg);
                       cg.free_scratch_reg(exprasmlist,tmpreg);
+{$else newra}
+                      rg.ungetregisterint(exprasmlist,tmpreg);
+{$endif newra}
                     end;
                     end;
                   opdone := true;
                   opdone := true;
                 end
                 end
@@ -625,12 +649,20 @@ interface
                 begin
                 begin
                   if left.location.loc = LOC_CONSTANT then
                   if left.location.loc = LOC_CONSTANT then
                     begin
                     begin
+{$ifndef newra}
                       tmpreg := cg.get_scratch_reg_int(exprasmlist,OS_INT);
                       tmpreg := cg.get_scratch_reg_int(exprasmlist,OS_INT);
+{$else newra}
+                      tmpreg := rg.getregisterint(exprasmlist,OS_INT);
+{$endif newra}
                       cg.a_load_const_reg(exprasmlist,OS_INT,
                       cg.a_load_const_reg(exprasmlist,OS_INT,
                         aword(left.location.value),tmpreg);
                         aword(left.location.value),tmpreg);
                       exprasmlist.concat(taicpu.op_reg_reg_reg(A_ANDC,
                       exprasmlist.concat(taicpu.op_reg_reg_reg(A_ANDC,
                         location.register,tmpreg,right.location.register));
                         location.register,tmpreg,right.location.register));
+{$ifndef newra}
                       cg.free_scratch_reg(exprasmlist,tmpreg);
                       cg.free_scratch_reg(exprasmlist,tmpreg);
+{$else newra}
+                      rg.ungetregisterint(exprasmlist,tmpreg);
+{$endif newra}
                     end
                     end
                   else
                   else
                     exprasmlist.concat(taicpu.op_reg_reg_reg(A_ANDC,
                     exprasmlist.concat(taicpu.op_reg_reg_reg(A_ANDC,
@@ -652,7 +684,11 @@ interface
                   (nodetype = gten)) then
                   (nodetype = gten)) then
                 swapleftright;
                 swapleftright;
               // now we have to check whether left >= right
               // now we have to check whether left >= right
+{$ifndef newra}
               tmpreg := cg.get_scratch_reg_int(exprasmlist,OS_INT);
               tmpreg := cg.get_scratch_reg_int(exprasmlist,OS_INT);
+{$else newra}
+              tmpreg := rg.getregisterint(exprasmlist,OS_INT);
+{$endif newra}
               if left.location.loc = LOC_CONSTANT then
               if left.location.loc = LOC_CONSTANT then
                 begin
                 begin
                   cg.a_op_const_reg_reg(exprasmlist,OP_AND,OS_INT,
                   cg.a_op_const_reg_reg(exprasmlist,OP_AND,OS_INT,
@@ -674,7 +710,11 @@ interface
                     exprasmlist.concat(taicpu.op_reg_reg_reg(A_ANDC_,tmpreg,
                     exprasmlist.concat(taicpu.op_reg_reg_reg(A_ANDC_,tmpreg,
                       right.location.register,left.location.register));
                       right.location.register,left.location.register));
                 end;
                 end;
+{$ifndef newra}
               cg.free_scratch_reg(exprasmlist,tmpreg);
               cg.free_scratch_reg(exprasmlist,tmpreg);
+{$else newra}
+              rg.ungetregisterint(exprasmlist,tmpreg);
+{$endif newra}
               location.resflags.cr := R_CR0;
               location.resflags.cr := R_CR0;
               location.resflags.flag := F_EQ;
               location.resflags.flag := F_EQ;
               opdone := true;
               opdone := true;
@@ -900,11 +940,19 @@ interface
                       else
                       else
                         begin
                         begin
                           if (aword(right.location.valueqword) <> 0) then
                           if (aword(right.location.valueqword) <> 0) then
-                            tempreg64.reglo := cg.get_scratch_reg_int(exprasmlist,OS_INT)
+{$ifndef newra}
+                            tempreg64.reglo := cg.get_scratch_reg_int(exprasmlist,OS_32)
+{$else newra}
+                            tempreg64.reglo := rg.getregisterint(exprasmlist,OS_32)
+{$endif newra}
                           else
                           else
                             tempreg64.reglo := left.location.registerlow;
                             tempreg64.reglo := left.location.registerlow;
                           if ((right.location.valueqword shr 32) <> 0) then
                           if ((right.location.valueqword shr 32) <> 0) then
-                            tempreg64.reghi := cg.get_scratch_reg_int(exprasmlist,OS_INT)
+{$ifndef newra}
+                            tempreg64.reghi := cg.get_scratch_reg_int(exprasmlist,OS_32)
+{$else newra}
+                            tempreg64.reghi := rg.getregisterint(exprasmlist,OS_32)
+{$endif newra}
                           else
                           else
                             tempreg64.reghi := left.location.registerhigh;
                             tempreg64.reghi := left.location.registerhigh;
                         end;
                         end;
@@ -935,8 +983,13 @@ interface
                     end
                     end
                   else
                   else
                     begin
                     begin
-                       tempreg64.reglo := cg.get_scratch_reg_int(exprasmlist,OS_INT);
-                       tempreg64.reghi := cg.get_scratch_reg_int(exprasmlist,OS_INT);
+{$ifndef newra}
+                       tempreg64.reglo := cg.get_scratch_reg_int(exprasmlist,OS_32);
+                       tempreg64.reghi := cg.get_scratch_reg_int(exprasmlist,OS_32);
+{$else newra}
+                       tempreg64.reglo := rg.getregisterint(exprasmlist,OS_INT);
+                       tempreg64.reghi := rg.getregisterint(exprasmlist,OS_INT);
+{$endif newra}
                        cg64.a_op64_reg_reg_reg(exprasmlist,OP_XOR,
                        cg64.a_op64_reg_reg_reg(exprasmlist,OP_XOR,
                          left.location.register64,right.location.register64,
                          left.location.register64,right.location.register64,
                          tempreg64);
                          tempreg64);
@@ -949,9 +1002,17 @@ interface
                     tempreg64.reglo,tempreg64.reghi));
                     tempreg64.reglo,tempreg64.reghi));
                   cg.a_reg_dealloc(exprasmlist,r);
                   cg.a_reg_dealloc(exprasmlist,r);
                   if (tempreg64.reglo.number <> left.location.registerlow.number) then
                   if (tempreg64.reglo.number <> left.location.registerlow.number) then
+{$ifndef newra}
                     cg.free_scratch_reg(exprasmlist,tempreg64.reglo);
                     cg.free_scratch_reg(exprasmlist,tempreg64.reglo);
+{$else newra}
+                    rg.ungetregisterint(exprasmlist,tempreg64.reglo);                                          
+{$endif newra}
                   if (tempreg64.reghi.number <> left.location.registerhigh.number) then
                   if (tempreg64.reghi.number <> left.location.registerhigh.number) then
+{$ifndef newra}
                     cg.free_scratch_reg(exprasmlist,tempreg64.reghi);
                     cg.free_scratch_reg(exprasmlist,tempreg64.reghi);
+{$else newra}
+                    rg.ungetregisterint(exprasmlist,tempreg64.reghi);
+{$endif newra}
 
 
                   location_reset(location,LOC_FLAGS,OS_NO);
                   location_reset(location,LOC_FLAGS,OS_NO);
                   location.resflags := getresflags;
                   location.resflags := getresflags;
@@ -1432,12 +1493,20 @@ interface
                        end
                        end
                      else
                      else
                        begin
                        begin
+{$ifndef newra}
                          tmpreg := cg.get_scratch_reg_int(exprasmlist,OS_INT);
                          tmpreg := cg.get_scratch_reg_int(exprasmlist,OS_INT);
+{$else newra}
+                         tmpreg := rg.getregisterint(exprasmlist,OS_INT);               
+{$endif newra}
                          cg.a_load_const_reg(exprasmlist,OS_INT,
                          cg.a_load_const_reg(exprasmlist,OS_INT,
                            aword(left.location.value),tmpreg);
                            aword(left.location.value),tmpreg);
                          cg.a_op_reg_reg_reg(exprasmlist,OP_SUB,OS_INT,
                          cg.a_op_reg_reg_reg(exprasmlist,OP_SUB,OS_INT,
                            right.location.register,tmpreg,location.register);
                            right.location.register,tmpreg,location.register);
+{$ifndef newra}
                          cg.free_scratch_reg(exprasmlist,tmpreg);
                          cg.free_scratch_reg(exprasmlist,tmpreg);
+{$else newra}
+                         rg.ungetregisterint(exprasmlist,tmpreg);
+{$endif newra}
                        end;
                        end;
                  end;
                  end;
                ltn,lten,gtn,gten,equaln,unequaln :
                ltn,lten,gtn,gten,equaln,unequaln :
@@ -1472,7 +1541,11 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.32  2003-06-04 11:58:58  jonas
+  Revision 1.33  2003-06-14 22:32:43  jonas
+    * ppc compiles with -dnewra, haven't tried to compile anything with it
+      yet though
+
+  Revision 1.32  2003/06/04 11:58:58  jonas
     * calculate localsize also in g_return_from_proc since it's now called
     * calculate localsize also in g_return_from_proc since it's now called
       before g_stackframe_entry (still have to fix macos)
       before g_stackframe_entry (still have to fix macos)
     * compilation fixes (cycle doesn't work yet though)
     * compilation fixes (cycle doesn't work yet though)

+ 31 - 4
compiler/powerpc/nppccnv.pas

@@ -190,7 +190,11 @@ implementation
               leftreg := left.location.register;
               leftreg := left.location.register;
               if signed then
               if signed then
                 begin
                 begin
+{$ifndef newra}
                   valuereg := cg.get_scratch_reg_int(exprasmlist,OS_INT);
                   valuereg := cg.get_scratch_reg_int(exprasmlist,OS_INT);
+{$else newra}
+                  valuereg := rg.getregisterint(exprasmlist,OS_INT);               
+{$endif newra}
                   valuereg_is_scratch := true;
                   valuereg_is_scratch := true;
                 end
                 end
               else
               else
@@ -198,7 +202,11 @@ implementation
             end;
             end;
           LOC_REFERENCE,LOC_CREFERENCE:
           LOC_REFERENCE,LOC_CREFERENCE:
             begin
             begin
+{$ifndef newra}
               leftreg := cg.get_scratch_reg_int(exprasmlist,OS_INT);
               leftreg := cg.get_scratch_reg_int(exprasmlist,OS_INT);
+{$else newra}
+              leftreg := rg.getregisterint(exprasmlist,OS_INT);               
+{$endif newra}
               valuereg := leftreg;
               valuereg := leftreg;
               valuereg_is_scratch := true;
               valuereg_is_scratch := true;
               if signed then
               if signed then
@@ -211,10 +219,18 @@ implementation
           else
           else
             internalerror(200110012);
             internalerror(200110012);
          end;
          end;
+{$ifndef newra}
          tempreg := cg.get_scratch_reg_int(exprasmlist,OS_INT);
          tempreg := cg.get_scratch_reg_int(exprasmlist,OS_INT);
+{$else newra}
+         tempreg := rg.getregisterint(exprasmlist,OS_INT);               
+{$endif newra}
          exprasmlist.concat(taicpu.op_reg_const(A_LIS,tempreg,$4330));
          exprasmlist.concat(taicpu.op_reg_const(A_LIS,tempreg,$4330));
          cg.a_load_reg_ref(exprasmlist,OS_32,OS_32,tempreg,ref);
          cg.a_load_reg_ref(exprasmlist,OS_32,OS_32,tempreg,ref);
+{$ifndef newra}
          cg.free_scratch_reg(exprasmlist,tempreg);
          cg.free_scratch_reg(exprasmlist,tempreg);
+{$else newra}
+         rg.ungetregisterint(exprasmlist,tempreg);               
+{$endif newra}
          if signed then
          if signed then
            exprasmlist.concat(taicpu.op_reg_reg_const(A_XORIS,valuereg,
            exprasmlist.concat(taicpu.op_reg_reg_const(A_XORIS,valuereg,
              { xoris expects a unsigned 16 bit int (FK) }
              { xoris expects a unsigned 16 bit int (FK) }
@@ -223,15 +239,23 @@ implementation
          cg.a_load_reg_ref(exprasmlist,OS_32,OS_32,valuereg,ref);
          cg.a_load_reg_ref(exprasmlist,OS_32,OS_32,valuereg,ref);
          dec(ref.offset,4);
          dec(ref.offset,4);
          if (valuereg_is_scratch) then
          if (valuereg_is_scratch) then
+{$ifndef newra}
            cg.free_scratch_reg(exprasmlist,valuereg);
            cg.free_scratch_reg(exprasmlist,valuereg);
-
+{$else newra}         
+           rg.ungetregisterint(exprasmlist,valuereg);
+{$endif newra}         
+ 
          if (left.location.loc = LOC_REGISTER) or
          if (left.location.loc = LOC_REGISTER) or
             ((left.location.loc = LOC_CREGISTER) and
             ((left.location.loc = LOC_CREGISTER) and
              not signed) then
              not signed) then
            rg.ungetregisterint(exprasmlist,leftreg)
            rg.ungetregisterint(exprasmlist,leftreg)
          else
          else
+{$ifndef newra}
            cg.free_scratch_reg(exprasmlist,valuereg);
            cg.free_scratch_reg(exprasmlist,valuereg);
-
+{$else newra}         
+           rg.ungetregisterint(exprasmlist,valuereg);                                         
+{$endif newra}         
+ 
          tmpfpureg := rg.getregisterfpu(exprasmlist,OS_F64);
          tmpfpureg := rg.getregisterfpu(exprasmlist,OS_F64);
          cg.a_loadfpu_ref_reg(exprasmlist,OS_F64,tempconst.location.reference,
          cg.a_loadfpu_ref_reg(exprasmlist,OS_F64,tempconst.location.reference,
            tmpfpureg);
            tmpfpureg);
@@ -267,7 +291,6 @@ implementation
 
 
 
 
 
 
-
     procedure tppctypeconvnode.second_int_to_bool;
     procedure tppctypeconvnode.second_int_to_bool;
       var
       var
         hreg1,
         hreg1,
@@ -434,7 +457,11 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.39  2003-06-12 22:09:54  jonas
+  Revision 1.40  2003-06-14 22:32:43  jonas
+    * ppc compiles with -dnewra, haven't tried to compile anything with it
+      yet though
+
+  Revision 1.39  2003/06/12 22:09:54  jonas
     * tcginnode.pass_2 doesn't call a helper anymore in any case
     * tcginnode.pass_2 doesn't call a helper anymore in any case
     * fixed ungetregisterfpu compilation problems
     * fixed ungetregisterfpu compilation problems
 
 

+ 25 - 3
compiler/powerpc/nppcmat.pas

@@ -82,9 +82,13 @@ implementation
 
 
       begin
       begin
          secondpass(left);
          secondpass(left);
+{$ifndef newra}
          maybe_save(exprasmlist,right.registers32,left.location,saved);
          maybe_save(exprasmlist,right.registers32,left.location,saved);
+{$endif newra}
          secondpass(right);
          secondpass(right);
+{$ifndef newra}
          maybe_restore(exprasmlist,left.location,saved);
          maybe_restore(exprasmlist,left.location,saved);
+{$endif newra}
          location_copy(location,left.location);
          location_copy(location,left.location);
 
 
          { put numerator in register }
          { put numerator in register }
@@ -102,8 +106,12 @@ implementation
            end;
            end;
          if (nodetype = modn) then
          if (nodetype = modn) then
            begin
            begin
+{$ifndef newra}
              resultreg := cg.get_scratch_reg_int(exprasmlist,size);
              resultreg := cg.get_scratch_reg_int(exprasmlist,size);
-           end;
+{$else newra}         
+             resultreg := rg.getregisterint(exprasmlist,size);                                         
+{$endif newra}         
+            end;
 
 
          if (nodetype = divn) and
          if (nodetype = divn) and
             (right.nodetype = ordconstn) and
             (right.nodetype = ordconstn) and
@@ -145,7 +153,11 @@ implementation
                rg.ungetregisterint(exprasmlist,divider);
                rg.ungetregisterint(exprasmlist,divider);
                exprasmlist.concat(taicpu.op_reg_reg_reg(A_SUB,location.register,
                exprasmlist.concat(taicpu.op_reg_reg_reg(A_SUB,location.register,
                  numerator,resultreg));
                  numerator,resultreg));
+{$ifndef newra}
                cg.free_scratch_reg(exprasmlist,resultreg);
                cg.free_scratch_reg(exprasmlist,resultreg);
+{$else newra}         
+               rg.ungetregisterint(exprasmlist,resultreg);
+{$endif newra}         
                resultreg := location.register;
                resultreg := location.register;
              end
              end
            else
            else
@@ -183,9 +195,13 @@ implementation
 
 
       begin
       begin
          secondpass(left);
          secondpass(left);
+{$ifndef newra}
          maybe_save(exprasmlist,right.registers32,left.location,saved);
          maybe_save(exprasmlist,right.registers32,left.location,saved);
+{$endif newra}
          secondpass(right);
          secondpass(right);
+{$ifndef newra}
          maybe_restore(exprasmlist,left.location,saved);
          maybe_restore(exprasmlist,left.location,saved);
+{$endif newra}
 
 
          if is_64bitint(left.resulttype.def) then
          if is_64bitint(left.resulttype.def) then
            begin
            begin
@@ -296,9 +312,11 @@ implementation
                      location.registerlow := resultreg;
                      location.registerlow := resultreg;
                    end;
                    end;
 
 
+{$ifndef newra}
                  if right.location.loc in [LOC_CREFERENCE,LOC_REFERENCE] then
                  if right.location.loc in [LOC_CREFERENCE,LOC_REFERENCE] then
                    cg.free_scratch_reg(exprasmlist,hregister1)
                    cg.free_scratch_reg(exprasmlist,hregister1)
-                 else
+                  else
+{$endif newra}
                    rg.ungetregisterint(exprasmlist,hregister1);
                    rg.ungetregisterint(exprasmlist,hregister1);
                end
                end
            end
            end
@@ -520,7 +538,11 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.30  2003-06-08 18:20:02  jonas
+  Revision 1.31  2003-06-14 22:32:43  jonas
+    * ppc compiles with -dnewra, haven't tried to compile anything with it
+      yet though
+
+  Revision 1.30  2003/06/08 18:20:02  jonas
     * fixed small bug where a location was set to LOC_CREGISTER instead of
     * fixed small bug where a location was set to LOC_CREGISTER instead of
       LOC_REGISTER
       LOC_REGISTER
 
 

+ 15 - 3
compiler/powerpc/nppcset.pas

@@ -78,12 +78,20 @@ implementation
                 hregister,value))
                 hregister,value))
             else
             else
               begin
               begin
+{$ifndef newra}
                 tmpreg := cg.get_scratch_reg_int(exprasmlist,OS_INT);
                 tmpreg := cg.get_scratch_reg_int(exprasmlist,OS_INT);
-                cg.a_load_const_reg(exprasmlist,OS_INT,aword(value),tmpreg);
+{$else newra}         
+                tmpreg := rg.getregisterint(exprasmlist,OS_INT);
+{$endif newra}         
+                 cg.a_load_const_reg(exprasmlist,OS_INT,aword(value),tmpreg);
                 exprasmlist.concat(taicpu.op_reg_reg_reg(A_ADD_,hregister,
                 exprasmlist.concat(taicpu.op_reg_reg_reg(A_ADD_,hregister,
                   hregister,tmpreg));
                   hregister,tmpreg));
+{$ifndef newra}
                 cg.free_scratch_reg(exprasmlist,tmpreg);
                 cg.free_scratch_reg(exprasmlist,tmpreg);
-              end;
+{$else newra}         
+                rg.ungetregisterint(exprasmlist,tmpreg);                                         
+{$endif newra}         
+               end;
           end;
           end;
 
 
         begin
         begin
@@ -159,7 +167,11 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.7  2003-02-19 22:00:16  daniel
+  Revision 1.8  2003-06-14 22:32:43  jonas
+    * ppc compiles with -dnewra, haven't tried to compile anything with it
+      yet though
+
+  Revision 1.7  2003/02/19 22:00:16  daniel
     * Code generator converted to new register notation
     * Code generator converted to new register notation
     - Horribily outdated todo.txt removed
     - Horribily outdated todo.txt removed
 
 

+ 9 - 1
compiler/powerpc/rgcpu.pas

@@ -40,12 +40,14 @@ unit rgcpu;
          procedure ungetregisterint(list: taasmoutput; reg: tregister); override;
          procedure ungetregisterint(list: taasmoutput; reg: tregister); override;
          function getexplicitregisterfpu(list : taasmoutput; r : Toldregister) : tregister;override;
          function getexplicitregisterfpu(list : taasmoutput; r : Toldregister) : tregister;override;
          procedure ungetregisterfpu(list: taasmoutput; r : tregister; size:TCGsize);override;
          procedure ungetregisterfpu(list: taasmoutput; r : tregister; size:TCGsize);override;
+{$ifndef newra}
          procedure saveusedintregisters(list:Taasmoutput;
          procedure saveusedintregisters(list:Taasmoutput;
                                          var saved:Tpushedsavedint;
                                          var saved:Tpushedsavedint;
                                          const s:Tsupregset);override;
                                          const s:Tsupregset);override;
          procedure saveusedotherregisters(list:Taasmoutput;
          procedure saveusedotherregisters(list:Taasmoutput;
                                            var saved:Tpushedsavedother;
                                            var saved:Tpushedsavedother;
                                            const s:Tregisterset);override;
                                            const s:Tregisterset);override;
+{$endif newra}
          procedure cleartempgen; override;
          procedure cleartempgen; override;
         private
         private
          usedpararegs: Tsupregset;
          usedpararegs: Tsupregset;
@@ -121,6 +123,7 @@ unit rgcpu;
       end;
       end;
 
 
 
 
+{$ifndef newra}
     procedure trgcpu.saveusedintregisters(list:Taasmoutput;
     procedure trgcpu.saveusedintregisters(list:Taasmoutput;
                                          var saved:Tpushedsavedint;
                                          var saved:Tpushedsavedint;
                                          const s:Tsupregset);
                                          const s:Tsupregset);
@@ -141,6 +144,7 @@ unit rgcpu;
         // correctly yet)
         // correctly yet)
         filldword(saved,sizeof(saved) div 4,reg_not_saved);
         filldword(saved,sizeof(saved) div 4,reg_not_saved);
       end;
       end;
+{$endif newra}
 
 
 
 
     procedure trgcpu.cleartempgen;
     procedure trgcpu.cleartempgen;
@@ -157,7 +161,11 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.10  2003-06-12 22:09:54  jonas
+  Revision 1.11  2003-06-14 22:32:43  jonas
+    * ppc compiles with -dnewra, haven't tried to compile anything with it
+      yet though
+
+  Revision 1.10  2003/06/12 22:09:54  jonas
     * tcginnode.pass_2 doesn't call a helper anymore in any case
     * tcginnode.pass_2 doesn't call a helper anymore in any case
     * fixed ungetregisterfpu compilation problems
     * fixed ungetregisterfpu compilation problems