mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-23 22:23:00 +00:00
Add method for replacing instructions to LibCallSimplifier
In some cases the library call simplifier may need to replace instructions other than the library call being simplified. In those cases it may be necessary for clients of the simplifier to override how the replacements are actually done. As such, a new overrideable method for replacing instructions was added to LibCallSimplifier. A new subclass of LibCallSimplifier is also defined which overrides the instruction replacement method. This is because the instruction combiner defines its own replacement method which updates the worklist when instructions are replaced. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167681 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -2367,6 +2367,24 @@ bool InstCombiner::DoOneIteration(Function &F, unsigned Iteration) {
|
||||
return MadeIRChange;
|
||||
}
|
||||
|
||||
namespace {
|
||||
class InstCombinerLibCallSimplifier : public LibCallSimplifier {
|
||||
InstCombiner *IC;
|
||||
public:
|
||||
InstCombinerLibCallSimplifier(const DataLayout *TD,
|
||||
const TargetLibraryInfo *TLI,
|
||||
InstCombiner *IC)
|
||||
: LibCallSimplifier(TD, TLI) {
|
||||
this->IC = IC;
|
||||
}
|
||||
|
||||
/// replaceAllUsesWith - override so that instruction replacement
|
||||
/// can be defined in terms of the instruction combiner framework.
|
||||
virtual void replaceAllUsesWith(Instruction *I, Value *With) const {
|
||||
IC->ReplaceInstUsesWith(*I, With);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
bool InstCombiner::runOnFunction(Function &F) {
|
||||
TD = getAnalysisIfAvailable<DataLayout>();
|
||||
@@ -2379,7 +2397,7 @@ bool InstCombiner::runOnFunction(Function &F) {
|
||||
InstCombineIRInserter(Worklist));
|
||||
Builder = &TheBuilder;
|
||||
|
||||
LibCallSimplifier TheSimplifier(TD, TLI);
|
||||
InstCombinerLibCallSimplifier TheSimplifier(TD, TLI, this);
|
||||
Simplifier = &TheSimplifier;
|
||||
|
||||
bool EverMadeChange = false;
|
||||
|
||||
Reference in New Issue
Block a user