Browse Source

--- Merging r18984 into '.':
U compiler/arm/cgcpu.pas
U compiler/arm/aoptcpu.pas

# revisions: 18984
------------------------------------------------------------------------
r18984 | jonas | 2011-09-05 22:33:15 +0200 (Mon, 05 Sep 2011) | 5 lines
Changed paths:
M /trunk/compiler/arm/aoptcpu.pas
M /trunk/compiler/arm/cgcpu.pas

* also use blx instead of bl for direct calls on ARMv5+, since the target
may be thumb(2) (mantis #19896)
* don't conditionalize "blx <imm target>", because that's not a valid
encoding

------------------------------------------------------------------------

git-svn-id: branches/fixes_2_6@19205 -

marco 14 years ago
parent
commit
dda717f897
2 changed files with 15 additions and 4 deletions
  1. 5 1
      compiler/arm/aoptcpu.pas
  2. 10 3
      compiler/arm/cgcpu.pas

+ 5 - 1
compiler/arm/aoptcpu.pas

@@ -51,7 +51,11 @@ Implementation
 
 
   function CanBeCond(p : tai) : boolean;
   function CanBeCond(p : tai) : boolean;
     begin
     begin
-      result:=(p.typ=ait_instruction) and (taicpu(p).condition=C_None);
+      result:=
+        (p.typ=ait_instruction) and
+        (taicpu(p).condition=C_None) and
+        ((taicpu(p).opcode<>A_BLX) or
+         (taicpu(p).oper[0]^.typ=top_reg));
     end;
     end;
 
 
 
 

+ 10 - 3
compiler/arm/cgcpu.pas

@@ -510,14 +510,21 @@ unit cgcpu;
 
 
 
 
     procedure tcgarm.a_call_name(list : TAsmList;const s : string; weak: boolean);
     procedure tcgarm.a_call_name(list : TAsmList;const s : string; weak: boolean);
+      var
+        branchopcode: tasmop;
       begin
       begin
+        { check not really correct: should only be used for non-Thumb cpus }
+        if (current_settings.cputype<cpu_armv5) then
+          branchopcode:=A_BL
+        else
+          branchopcode:=A_BLX;
         if target_info.system<>system_arm_darwin then
         if target_info.system<>system_arm_darwin then
           if not weak then
           if not weak then
-            list.concat(taicpu.op_sym(A_BL,current_asmdata.RefAsmSymbol(s)))
+            list.concat(taicpu.op_sym(branchopcode,current_asmdata.RefAsmSymbol(s)))
           else
           else
-            list.concat(taicpu.op_sym(A_BL,current_asmdata.WeakRefAsmSymbol(s)))
+            list.concat(taicpu.op_sym(branchopcode,current_asmdata.WeakRefAsmSymbol(s)))
         else
         else
-          list.concat(taicpu.op_sym(A_BL,get_darwin_call_stub(s,weak)));
+          list.concat(taicpu.op_sym(branchopcode,get_darwin_call_stub(s,weak)));
 {
 {
         the compiler does not properly set this flag anymore in pass 1, and
         the compiler does not properly set this flag anymore in pass 1, and
         for now we only need it after pass 2 (I hope) (JM)
         for now we only need it after pass 2 (I hope) (JM)