Przeglądaj źródła

* handle case tables correctly when inserting pc relative data

git-svn-id: trunk@12805 -
florian 16 lat temu
rodzic
commit
20db8dc978
1 zmienionych plików z 22 dodań i 6 usunięć
  1. 22 6
      compiler/arm/aasmcpu.pas

+ 22 - 6
compiler/arm/aasmcpu.pas

@@ -634,6 +634,22 @@ implementation
       end;
       end;
 
 
 
 
+    Function SimpleGetNextInstruction(Current: tai; Var Next: tai): Boolean;
+      Begin
+        Current:=tai(Current.Next);
+        While Assigned(Current) And (Current.typ In SkipInstr) Do
+          Current:=tai(Current.Next);
+        Next:=Current;
+        If Assigned(Next) And Not(Next.typ In SkipInstr) Then
+           Result:=True
+          Else
+            Begin
+              Next:=Nil;
+              Result:=False;
+            End;
+      End;
+
+
     procedure insertpcrelativedata(list,listtoinsert : TAsmList);
     procedure insertpcrelativedata(list,listtoinsert : TAsmList);
       var
       var
         curpos,
         curpos,
@@ -715,14 +731,14 @@ implementation
                 inc(curpos);
                 inc(curpos);
 
 
             { special case for case jump tables }
             { special case for case jump tables }
-            if assigned(curtai.next) and
-              (tai(curtai.next).typ=ait_instruction) and
-              (taicpu(curtai.next).opcode=A_LDR) and
-              (taicpu(curtai.next).oper[0]^.typ=top_reg) and
-              (taicpu(curtai.next).oper[0]^.reg=NR_PC) then
+            if SimpleGetNextInstruction(curtai,hp) and
+              (tai(hp).typ=ait_instruction) and
+              (taicpu(hp).opcode=A_LDR) and
+              (taicpu(hp).oper[0]^.typ=top_reg) and
+              (taicpu(hp).oper[0]^.reg=NR_PC) then
               begin
               begin
                 penalty:=1;
                 penalty:=1;
-                hp:=tai(curtai.next.next);
+                hp:=tai(hp.next);
                 while assigned(hp) and (hp.typ=ait_const) do
                 while assigned(hp) and (hp.typ=ait_const) do
                   begin
                   begin
                     inc(penalty);
                     inc(penalty);