Browse Source

+ AVR: helpers take care of ADIW

florian 3 years ago
parent
commit
46b52d92d3
2 changed files with 13 additions and 1 deletions
  1. 6 1
      compiler/avr/aoptcpu.pas
  2. 7 0
      compiler/avr/aoptcpub.pas

+ 6 - 1
compiler/avr/aoptcpu.pas

@@ -169,6 +169,9 @@ Implementation
         ((TRegister(ord(taicpu(p1).oper[0]^.reg)+1)=reg) or (TRegister(ord(taicpu(p1).oper[1]^.reg)+1)=reg) or
          (taicpu(p1).oper[0]^.reg=reg) or (taicpu(p1).oper[1]^.reg=reg)) then
         Result:=true
+      else if (p1.typ = ait_instruction) and (taicpu(p1).opcode=A_ADIW) and
+        ((TRegister(ord(taicpu(p1).oper[0]^.reg)+1)=reg) or (taicpu(p1).oper[0]^.reg=reg)) then
+        Result:=true
       else
         Result:=inherited RegInInstruction(Reg, p1);
     end;
@@ -231,7 +234,9 @@ Implementation
             top_reg:
               Result := (p.oper[i]^.reg = reg) or
                 { MOVW }
-                ((i=1) and (p.opcode=A_MOVW) and (getsupreg(p.oper[i]^.reg)+1=getsupreg(reg)));
+                ((i=1) and (p.opcode=A_MOVW) and (getsupreg(p.oper[i]^.reg)+1=getsupreg(reg))) or
+                { ADIW }
+                ((i=0) and (p.opcode=A_ADIW) and (getsupreg(p.oper[i]^.reg)+1=getsupreg(reg)));
             top_ref:
               Result :=
                 (p.oper[i]^.ref^.base = reg) or

+ 7 - 0
compiler/avr/aoptcpub.pas

@@ -133,6 +133,13 @@ Implementation
           exit;
         end;
 
+      If (taicpu(p1).opcode=A_ADIW) and
+        (TRegister(ord(taicpu(p1).oper[0]^.reg)+1)=reg) then
+        begin
+          Result:=true;
+          exit;
+        end;
+
       for i:=0 to taicpu(p1).ops-1 do
         if (taicpu(p1).oper[i]^.typ=top_reg) and (taicpu(p1).oper[i]^.reg=Reg) and (taicpu(p1).spilling_get_operation_type(i) in [operand_write,operand_readwrite]) then
           begin