mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-09 10:31:14 +00:00
63 lines
1.9 KiB
C++
63 lines
1.9 KiB
C++
|
//===- EarlyCSE.cpp - Simple and fast CSE pass ----------------------------===//
|
||
|
//
|
||
|
// The LLVM Compiler Infrastructure
|
||
|
//
|
||
|
// This file is distributed under the University of Illinois Open Source
|
||
|
// License. See LICENSE.TXT for details.
|
||
|
//
|
||
|
//===----------------------------------------------------------------------===//
|
||
|
//
|
||
|
// This pass performs a simple dominator tree walk that eliminates trivially
|
||
|
// redundant instructions.
|
||
|
//
|
||
|
//===----------------------------------------------------------------------===//
|
||
|
|
||
|
#define DEBUG_TYPE "early-cse"
|
||
|
#include "llvm/Transforms/Scalar.h"
|
||
|
#include "llvm/Analysis/Dominators.h"
|
||
|
#include "llvm/Pass.h"
|
||
|
using namespace llvm;
|
||
|
|
||
|
namespace {
|
||
|
/// EarlyCSE - This pass does a simple depth-first walk over the dominator
|
||
|
/// tree, eliminating trivially redundant instructions and using instsimplify
|
||
|
/// to canonicalize things as it goes. It is intended to be fast and catch
|
||
|
/// obvious cases so that instcombine and other passes are more effective. It
|
||
|
/// is expected that a later pass of GVN will catch the interesting/hard
|
||
|
/// cases.
|
||
|
class EarlyCSE : public FunctionPass {
|
||
|
public:
|
||
|
static char ID;
|
||
|
explicit EarlyCSE()
|
||
|
: FunctionPass(ID) {
|
||
|
initializeEarlyCSEPass(*PassRegistry::getPassRegistry());
|
||
|
}
|
||
|
|
||
|
bool runOnFunction(Function &F);
|
||
|
|
||
|
private:
|
||
|
// This transformation requires dominator postdominator info
|
||
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
||
|
AU.addRequired<DominatorTree>();
|
||
|
AU.setPreservesCFG();
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
|
||
|
char EarlyCSE::ID = 0;
|
||
|
|
||
|
// createEarlyCSEPass - The public interface to this file.
|
||
|
FunctionPass *llvm::createEarlyCSEPass() {
|
||
|
return new EarlyCSE();
|
||
|
}
|
||
|
|
||
|
INITIALIZE_PASS_BEGIN(EarlyCSE, "early-cse", "Early CSE", false, false)
|
||
|
INITIALIZE_PASS_DEPENDENCY(DominatorTree)
|
||
|
INITIALIZE_PASS_END(EarlyCSE, "early-cse", "Early CSE", false, false)
|
||
|
|
||
|
bool EarlyCSE::runOnFunction(Function &F) {
|
||
|
DominatorTree &DT = getAnalysis<DominatorTree>();
|
||
|
(void)DT;
|
||
|
return false;
|
||
|
}
|