diff options
author | Chad Rosier <mcrosier@apple.com> | 2012-05-23 18:38:57 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@apple.com> | 2012-05-23 18:38:57 +0000 |
commit | 1c8fccbc12e6348c8003aff9b89078324257fc4e (patch) | |
tree | d76ee6c0b5349ef2ad5a5529f3e7515aa62c1172 /lib/Target/ARM/ARMFastISel.cpp | |
parent | 2b526300944b3f9cb3147ae1b72653cdab9fe1f9 (diff) |
[arm-fast-isel] Add support for non-global callee.
Patch by Jush Lu <jush.msn@gmail.com>.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157336 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/ARM/ARMFastISel.cpp')
-rw-r--r-- | lib/Target/ARM/ARMFastISel.cpp | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/Target/ARM/ARMFastISel.cpp b/lib/Target/ARM/ARMFastISel.cpp index 97131cd698..c13f283a84 100644 --- a/lib/Target/ARM/ARMFastISel.cpp +++ b/lib/Target/ARM/ARMFastISel.cpp @@ -2216,11 +2216,6 @@ bool ARMFastISel::SelectCall(const Instruction *I, // Can't handle inline asm. if (isa<InlineAsm>(Callee)) return false; - // Only handle global variable Callees. - const GlobalValue *GV = dyn_cast<GlobalValue>(Callee); - if (!GV) - return false; - // Check the calling convention. ImmutableCallSite CS(CI); CallingConv::ID CC = CS.getCallingConv(); @@ -2313,18 +2308,33 @@ bool ARMFastISel::SelectCall(const Instruction *I, // Issue the call. MachineInstrBuilder MIB; + const GlobalValue *GV = dyn_cast<GlobalValue>(Callee); unsigned CallOpc = ARMSelectCallOp(GV); + unsigned CalleeReg = 0; + + if (!GV){ + CallOpc = isThumb2 ? ARM::tBLXr : ARM::BLX; + CalleeReg = getRegForValue(Callee); + if (CalleeReg == 0) return false; + } + // Explicitly adding the predicate here. if(isThumb2) { // Explicitly adding the predicate here. MIB = AddDefaultPred(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(CallOpc))); - if (!IntrMemName) + if (!GV) + MIB.addReg(CalleeReg); + else if (!IntrMemName) MIB.addGlobalAddress(GV, 0, 0); else MIB.addExternalSymbol(IntrMemName, 0); } else { - if (!IntrMemName) + if (!GV) + MIB = AddDefaultPred(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, + TII.get(CallOpc)) + .addReg(CalleeReg)); + else if (!IntrMemName) // Explicitly adding the predicate here. MIB = AddDefaultPred(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(CallOpc)) |