Browse Source

* avr: help the compiler with constant loading to avoid ie 200309041

git-svn-id: trunk@43350 -
florian 5 năm trước cách đây
mục cha
commit
701848889e
2 tập tin đã thay đổi với 18 bổ sung3 xóa
  1. 12 2
      compiler/avr/cgcpu.pas
  2. 6 1
      compiler/avr/navradd.pas

+ 12 - 2
compiler/avr/cgcpu.pas

@@ -887,7 +887,12 @@ unit cgcpu;
                    if ((qword(a) and mask) shr shift)=0 then
                      list.concat(taicpu.op_reg_reg(A_MOV,reg,NR_R1))
                    else if ((qword(a) and mask) shr shift)<>$ff then
-                     list.concat(taicpu.op_reg_const(A_ANDI,reg,(qword(a) and mask) shr shift));
+                     begin
+                       getcpuregister(list,NR_R26);
+                       list.concat(taicpu.op_reg_const(A_LDI,NR_R26,(qword(a) and mask) shr shift));
+                       list.concat(taicpu.op_reg_reg(A_AND,reg,NR_R26));
+                       ungetcpuregister(list,NR_R26);
+                     end;
                    { check if we are not in the last iteration to avoid an internalerror in GetNextReg }
                    if i<tcgsize2size[size] then
                      NextRegPostInc;
@@ -900,7 +905,12 @@ unit cgcpu;
                if ((a and mask)=1) and (tcgsize2size[size]=1) then
                  list.concat(taicpu.op_reg(A_DEC,reg))
                else
-                 list.concat(taicpu.op_reg_const(A_SUBI,reg,a and mask));
+                 begin
+                   getcpuregister(list,NR_R26);
+                   list.concat(taicpu.op_reg_const(A_LDI,NR_R26,a and mask));
+                   list.concat(taicpu.op_reg_reg(A_SUB,reg,NR_R26));
+                   ungetcpuregister(list,NR_R26);
+                 end;
                if size in [OS_S16,OS_16,OS_S32,OS_32,OS_S64,OS_64] then
                  begin
                    for i:=2 to tcgsize2size[size] do

+ 6 - 1
compiler/avr/navradd.pas

@@ -231,7 +231,12 @@ interface
             if (right.location.value and $ff)=0 then
               current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CP,left.location.register,NR_R1))
             else
-              current_asmdata.CurrAsmList.concat(taicpu.op_reg_const(A_CPI,left.location.register,right.location.value and $ff))
+              begin
+                cg.getcpuregister(current_asmdata.CurrAsmList,NR_R26);
+                current_asmdata.CurrAsmList.concat(taicpu.op_reg_const(A_LDI,NR_R26,right.location.value and $ff));
+                current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CP,left.location.register,NR_R26));
+                cg.ungetcpuregister(current_asmdata.CurrAsmList,NR_R26);
+              end;
           end
         { on the left side, we allow only a constant if it is 0 }
         else if (left.location.loc=LOC_CONSTANT) and (left.location.value=0) then