mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-16 12:24:03 +00:00
Change over to use new style pass mechanism, now passes only expose small
creation functions in their public header file, unless they can help it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1816 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -29,6 +29,7 @@
|
||||
#include "llvm/iTerminators.h"
|
||||
#include "llvm/iPHINode.h"
|
||||
#include "llvm/iOther.h"
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/ConstantVals.h"
|
||||
|
||||
inline static bool
|
||||
@ -153,8 +154,7 @@ bool ConstantFoldTerminator(TerminatorInst *T) {
|
||||
// ConstantFoldInstruction - If an instruction references constants, try to fold
|
||||
// them together...
|
||||
//
|
||||
bool ConstantPropogation::doConstantPropogation(BasicBlock *BB,
|
||||
BasicBlock::iterator &II) {
|
||||
bool doConstantPropogation(BasicBlock *BB, BasicBlock::iterator &II) {
|
||||
Instruction *Inst = *II;
|
||||
if (isa<BinaryOperator>(Inst)) {
|
||||
Constant *D1 = dyn_cast<Constant>(Inst->getOperand(0));
|
||||
@ -200,7 +200,7 @@ static bool DoConstPropPass(Method *M) {
|
||||
for (Method::iterator BBI = M->begin(); BBI != M->end(); ++BBI) {
|
||||
BasicBlock *BB = *BBI;
|
||||
for (BasicBlock::iterator I = BB->begin(); I != BB->end(); )
|
||||
if (ConstantPropogation::doConstantPropogation(BB, I))
|
||||
if (doConstantPropogation(BB, I))
|
||||
SomethingChanged = true;
|
||||
else
|
||||
++I;
|
||||
@ -208,14 +208,20 @@ static bool DoConstPropPass(Method *M) {
|
||||
return SomethingChanged;
|
||||
}
|
||||
|
||||
namespace {
|
||||
struct ConstantPropogation : public MethodPass {
|
||||
inline bool runOnMethod(Method *M) {
|
||||
bool Modified = false;
|
||||
|
||||
// returns whether or not the underlying method was modified
|
||||
//
|
||||
bool ConstantPropogation::doConstantPropogation(Method *M) {
|
||||
bool Modified = false;
|
||||
|
||||
// Fold constants until we make no progress...
|
||||
while (DoConstPropPass(M)) Modified = true;
|
||||
|
||||
return Modified;
|
||||
// Fold constants until we make no progress...
|
||||
while (DoConstPropPass(M)) Modified = true;
|
||||
|
||||
return Modified;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Pass *createConstantPropogationPass() {
|
||||
return new ConstantPropogation();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user