浏览代码

* improved r28534: LDR/STR on thumb do not support registers >r7 as destination/source

git-svn-id: trunk@28538 -
florian 11 年之前
父节点
当前提交
09728a9ae2
共有 1 个文件被更改,包括 8 次插入4 次删除
  1. 8 4
      compiler/arm/rgcpu.pas

+ 8 - 4
compiler/arm/rgcpu.pas

@@ -308,11 +308,10 @@ unit rgcpu;
                    (get_alias(getsupreg(oper[0]^.reg))=orgreg) and
                    (get_alias(getsupreg(oper[0]^.reg))=orgreg) and
                    (get_alias(getsupreg(oper[1]^.reg))<>orgreg) then
                    (get_alias(getsupreg(oper[1]^.reg))<>orgreg) then
                   begin
                   begin
-                    { do not replace if we're on Thumb, the offset is too
-                      large and the stack pointer reg would be the store source }
+                    { do not replace if we're on Thumb, ldr/str cannot be used with rX>r7 }
                     if GenerateThumbCode and
                     if GenerateThumbCode and
-                       (oper[1]^.reg = NR_STACK_POINTER_REG) and
-                       (abs(spilltemp.offset) > 63) then exit;
+                       (getsupreg(oper[1]^.reg)>RS_R7) then
+                       exit;
 
 
                     { str expects the register in oper[0] }
                     { str expects the register in oper[0] }
                     instr.loadreg(0,oper[1]^.reg);
                     instr.loadreg(0,oper[1]^.reg);
@@ -324,6 +323,11 @@ unit rgcpu;
                    (get_alias(getsupreg(oper[1]^.reg))=orgreg) and
                    (get_alias(getsupreg(oper[1]^.reg))=orgreg) and
                    (get_alias(getsupreg(oper[0]^.reg))<>orgreg) then
                    (get_alias(getsupreg(oper[0]^.reg))<>orgreg) then
                   begin
                   begin
+                    { do not replace if we're on Thumb, ldr/str cannot be used with rX>r7 }
+                    if GenerateThumbCode and
+                       (getsupreg(oper[0]^.reg)>RS_R7) then
+                       exit;
+
                     instr.loadref(1,spilltemp);
                     instr.loadref(1,spilltemp);
                     opcode:=A_LDR;
                     opcode:=A_LDR;
                     result:=true;
                     result:=true;