Target override to allow CodeGenPrepare to sink address operands to intrinsics in the same way it current does for loads and stores

llvm-svn: 152666
This commit is contained in:
Pete Cooper 2012-03-13 20:59:56 +00:00
parent ac2f0b1f91
commit 615fd897e0
2 changed files with 21 additions and 0 deletions

View File

@ -41,6 +41,7 @@ namespace llvm {
class FastISel;
class FunctionLoweringInfo;
class ImmutableCallSite;
class IntrinsicInst;
class MachineBasicBlock;
class MachineFunction;
class MachineInstr;
@ -1539,6 +1540,17 @@ public:
AddrMode() : BaseGV(0), BaseOffs(0), HasBaseReg(false), Scale(0) {}
};
/// GetAddrModeArguments - CodeGenPrepare sinks address calculations into the
/// same BB as Load/Store instructions reading the address. This allows as
/// much computation as possible to be done in the address mode for that
/// operand. This hook lets targets also pass back when this should be done
/// on intrinsics which load/store.
virtual bool GetAddrModeArguments(IntrinsicInst *I,
SmallVectorImpl<Value*> &Ops,
Type *&AccessTy) const {
return false;
}
/// isLegalAddressingMode - Return true if the addressing mode represented by
/// AM is legal for this target, for a load/store of the specified type.
/// The type may be VoidTy, in which case only return true if the addressing

View File

@ -579,6 +579,15 @@ bool CodeGenPrepare::OptimizeCallInst(CallInst *CI) {
return true;
}
if (II && TLI) {
SmallVector<Value*, 2> PtrOps;
Type *AccessTy;
if (TLI->GetAddrModeArguments(II, PtrOps, AccessTy))
while (!PtrOps.empty())
if (OptimizeMemoryInst(II, PtrOps.pop_back_val(), AccessTy))
return true;
}
// From here on out we're working with named functions.
if (CI->getCalledFunction() == 0) return false;