From 852ae48cb7b900e2d64e0c5b3a641670014fccc7 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Mon, 5 Sep 2011 20:33:15 +0000 Subject: [PATCH] * also use blx instead of bl for direct calls on ARMv5+, since the target may be thumb(2) (mantis #19896) * don't conditionalize "blx ", because that's not a valid encoding git-svn-id: trunk@18984 - --- compiler/arm/aoptcpu.pas | 6 +++++- compiler/arm/cgcpu.pas | 13 ++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/compiler/arm/aoptcpu.pas b/compiler/arm/aoptcpu.pas index 9d01be84b8..3f116a5dfd 100644 --- a/compiler/arm/aoptcpu.pas +++ b/compiler/arm/aoptcpu.pas @@ -51,7 +51,11 @@ Implementation function CanBeCond(p : tai) : boolean; 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; diff --git a/compiler/arm/cgcpu.pas b/compiler/arm/cgcpu.pas index 8623c6a357..7114ac8789 100644 --- a/compiler/arm/cgcpu.pas +++ b/compiler/arm/cgcpu.pas @@ -510,14 +510,21 @@ unit cgcpu; procedure tcgarm.a_call_name(list : TAsmList;const s : string; weak: boolean); + var + branchopcode: tasmop; begin + { check not really correct: should only be used for non-Thumb cpus } + if (current_settings.cputypesystem_arm_darwin 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 - list.concat(taicpu.op_sym(A_BL,current_asmdata.WeakRefAsmSymbol(s))) + list.concat(taicpu.op_sym(branchopcode,current_asmdata.WeakRefAsmSymbol(s))) 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 for now we only need it after pass 2 (I hope) (JM)