mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-25 00:24:26 +00:00
[PM] Replace an abuse of inheritance to override a single function with
a more direct approach: a type-erased glorified function pointer. Now we can pass a function pointer into this for the easy case and we can even pass a lambda into it in the interesting case in the instruction combiner. I'll be using this shortly to simplify the interfaces to InstCombiner, but this helps pave the way and seems like a better design for the libcall simplifier utility. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226640 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -71,12 +71,21 @@ private:
|
||||
const DataLayout *DL;
|
||||
const TargetLibraryInfo *TLI;
|
||||
bool UnsafeFPShrink;
|
||||
function_ref<void(Instruction *, Value *)> Replacer;
|
||||
|
||||
protected:
|
||||
~LibCallSimplifier() {}
|
||||
/// \brief Internal wrapper for RAUW that is the default implementation.
|
||||
///
|
||||
/// Other users may provide an alternate function with this signature instead
|
||||
/// of this one.
|
||||
static void replaceAllUsesWithDefault(Instruction *I, Value *With);
|
||||
|
||||
/// \brief Replace an instruction's uses with a value using our replacer.
|
||||
void replaceAllUsesWith(Instruction *I, Value *With);
|
||||
|
||||
public:
|
||||
LibCallSimplifier(const DataLayout *TD, const TargetLibraryInfo *TLI);
|
||||
LibCallSimplifier(const DataLayout *TD, const TargetLibraryInfo *TLI,
|
||||
function_ref<void(Instruction *, Value *)> Replacer =
|
||||
&replaceAllUsesWithDefault);
|
||||
|
||||
/// optimizeCall - Take the given call instruction and return a more
|
||||
/// optimal value to replace the instruction with or 0 if a more
|
||||
@ -87,11 +96,6 @@ public:
|
||||
/// The call must not be an indirect call.
|
||||
Value *optimizeCall(CallInst *CI);
|
||||
|
||||
/// replaceAllUsesWith - This method is used when the library call
|
||||
/// simplifier needs to replace instructions other than the library
|
||||
/// call being modified.
|
||||
virtual void replaceAllUsesWith(Instruction *I, Value *With) const;
|
||||
|
||||
private:
|
||||
// String and Memory Library Call Optimizations
|
||||
Value *optimizeStrCat(CallInst *CI, IRBuilder<> &B);
|
||||
|
Reference in New Issue
Block a user