mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-17 04:24:00 +00:00
Convert the first batch of passes to use LLVMContext.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74748 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -21,6 +21,7 @@
|
|||||||
#include "llvm/InlineAsm.h"
|
#include "llvm/InlineAsm.h"
|
||||||
#include "llvm/Instructions.h"
|
#include "llvm/Instructions.h"
|
||||||
#include "llvm/IntrinsicInst.h"
|
#include "llvm/IntrinsicInst.h"
|
||||||
|
#include "llvm/LLVMContext.h"
|
||||||
#include "llvm/Pass.h"
|
#include "llvm/Pass.h"
|
||||||
#include "llvm/Target/TargetAsmInfo.h"
|
#include "llvm/Target/TargetAsmInfo.h"
|
||||||
#include "llvm/Target/TargetData.h"
|
#include "llvm/Target/TargetData.h"
|
||||||
@ -615,8 +616,8 @@ bool CodeGenPrepare::OptimizeMemoryInst(Instruction *MemoryInst, Value *Addr,
|
|||||||
V = new SExtInst(V, IntPtrTy, "sunkaddr", InsertPt);
|
V = new SExtInst(V, IntPtrTy, "sunkaddr", InsertPt);
|
||||||
}
|
}
|
||||||
if (AddrMode.Scale != 1)
|
if (AddrMode.Scale != 1)
|
||||||
V = BinaryOperator::CreateMul(V, ConstantInt::get(IntPtrTy,
|
V = BinaryOperator::CreateMul(V, Context->getConstantInt(IntPtrTy,
|
||||||
AddrMode.Scale),
|
AddrMode.Scale),
|
||||||
"sunkaddr", InsertPt);
|
"sunkaddr", InsertPt);
|
||||||
Result = V;
|
Result = V;
|
||||||
}
|
}
|
||||||
@ -647,7 +648,7 @@ bool CodeGenPrepare::OptimizeMemoryInst(Instruction *MemoryInst, Value *Addr,
|
|||||||
|
|
||||||
// Add in the Base Offset if present.
|
// Add in the Base Offset if present.
|
||||||
if (AddrMode.BaseOffs) {
|
if (AddrMode.BaseOffs) {
|
||||||
Value *V = ConstantInt::get(IntPtrTy, AddrMode.BaseOffs);
|
Value *V = Context->getConstantInt(IntPtrTy, AddrMode.BaseOffs);
|
||||||
if (Result)
|
if (Result)
|
||||||
Result = BinaryOperator::CreateAdd(Result, V, "sunkaddr", InsertPt);
|
Result = BinaryOperator::CreateAdd(Result, V, "sunkaddr", InsertPt);
|
||||||
else
|
else
|
||||||
@ -655,7 +656,7 @@ bool CodeGenPrepare::OptimizeMemoryInst(Instruction *MemoryInst, Value *Addr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Result == 0)
|
if (Result == 0)
|
||||||
SunkAddr = Constant::getNullValue(Addr->getType());
|
SunkAddr = Context->getNullValue(Addr->getType());
|
||||||
else
|
else
|
||||||
SunkAddr = new IntToPtrInst(Result, Addr->getType(), "sunkaddr",InsertPt);
|
SunkAddr = new IntToPtrInst(Result, Addr->getType(), "sunkaddr",InsertPt);
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "llvm/DerivedTypes.h"
|
#include "llvm/DerivedTypes.h"
|
||||||
#include "llvm/Function.h"
|
#include "llvm/Function.h"
|
||||||
#include "llvm/IntrinsicInst.h"
|
#include "llvm/IntrinsicInst.h"
|
||||||
|
#include "llvm/LLVMContext.h"
|
||||||
#include "llvm/Value.h"
|
#include "llvm/Value.h"
|
||||||
#include "llvm/ADT/DenseMap.h"
|
#include "llvm/ADT/DenseMap.h"
|
||||||
#include "llvm/ADT/DepthFirstIterator.h"
|
#include "llvm/ADT/DepthFirstIterator.h"
|
||||||
@ -795,7 +796,7 @@ Value *GVN::GetValueForBlock(BasicBlock *BB, Instruction* orig,
|
|||||||
// If the block is unreachable, just return undef, since this path
|
// If the block is unreachable, just return undef, since this path
|
||||||
// can't actually occur at runtime.
|
// can't actually occur at runtime.
|
||||||
if (!DT->isReachableFromEntry(BB))
|
if (!DT->isReachableFromEntry(BB))
|
||||||
return Phis[BB] = UndefValue::get(orig->getType());
|
return Phis[BB] = Context->getUndef(orig->getType());
|
||||||
|
|
||||||
if (BasicBlock *Pred = BB->getSinglePredecessor()) {
|
if (BasicBlock *Pred = BB->getSinglePredecessor()) {
|
||||||
Value *ret = GetValueForBlock(Pred, orig, Phis);
|
Value *ret = GetValueForBlock(Pred, orig, Phis);
|
||||||
@ -983,7 +984,7 @@ bool GVN::processNonLocalLoad(LoadInst *LI,
|
|||||||
// Loading the allocation -> undef.
|
// Loading the allocation -> undef.
|
||||||
if (isa<AllocationInst>(DepInst)) {
|
if (isa<AllocationInst>(DepInst)) {
|
||||||
ValuesPerBlock.push_back(std::make_pair(DepBB,
|
ValuesPerBlock.push_back(std::make_pair(DepBB,
|
||||||
UndefValue::get(LI->getType())));
|
Context->getUndef(LI->getType())));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1270,7 +1271,7 @@ bool GVN::processLoad(LoadInst *L, SmallVectorImpl<Instruction*> &toErase) {
|
|||||||
// undef value. This can happen when loading for a fresh allocation with no
|
// undef value. This can happen when loading for a fresh allocation with no
|
||||||
// intervening stores, for example.
|
// intervening stores, for example.
|
||||||
if (isa<AllocationInst>(DepInst)) {
|
if (isa<AllocationInst>(DepInst)) {
|
||||||
L->replaceAllUsesWith(UndefValue::get(L->getType()));
|
L->replaceAllUsesWith(Context->getUndef(L->getType()));
|
||||||
toErase.push_back(L);
|
toErase.push_back(L);
|
||||||
NumGVNLoad++;
|
NumGVNLoad++;
|
||||||
return true;
|
return true;
|
||||||
@ -1382,9 +1383,9 @@ bool GVN::processInstruction(Instruction *I,
|
|||||||
BasicBlock* falseSucc = BI->getSuccessor(1);
|
BasicBlock* falseSucc = BI->getSuccessor(1);
|
||||||
|
|
||||||
if (trueSucc->getSinglePredecessor())
|
if (trueSucc->getSinglePredecessor())
|
||||||
localAvail[trueSucc]->table[condVN] = ConstantInt::getTrue();
|
localAvail[trueSucc]->table[condVN] = Context->getConstantIntTrue();
|
||||||
if (falseSucc->getSinglePredecessor())
|
if (falseSucc->getSinglePredecessor())
|
||||||
localAvail[falseSucc]->table[condVN] = ConstantInt::getFalse();
|
localAvail[falseSucc]->table[condVN] = Context->getConstantIntFalse();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
#include "llvm/BasicBlock.h"
|
#include "llvm/BasicBlock.h"
|
||||||
#include "llvm/Constants.h"
|
#include "llvm/Constants.h"
|
||||||
#include "llvm/Instructions.h"
|
#include "llvm/Instructions.h"
|
||||||
|
#include "llvm/LLVMContext.h"
|
||||||
#include "llvm/Type.h"
|
#include "llvm/Type.h"
|
||||||
#include "llvm/Analysis/Dominators.h"
|
#include "llvm/Analysis/Dominators.h"
|
||||||
#include "llvm/Analysis/IVUsers.h"
|
#include "llvm/Analysis/IVUsers.h"
|
||||||
@ -711,18 +712,18 @@ void IndVarSimplify::HandleFloatingPointIV(Loop *L, PHINode *PH) {
|
|||||||
// Insert new integer induction variable.
|
// Insert new integer induction variable.
|
||||||
PHINode *NewPHI = PHINode::Create(Type::Int32Ty,
|
PHINode *NewPHI = PHINode::Create(Type::Int32Ty,
|
||||||
PH->getName()+".int", PH);
|
PH->getName()+".int", PH);
|
||||||
NewPHI->addIncoming(ConstantInt::get(Type::Int32Ty, newInitValue),
|
NewPHI->addIncoming(Context->getConstantInt(Type::Int32Ty, newInitValue),
|
||||||
PH->getIncomingBlock(IncomingEdge));
|
PH->getIncomingBlock(IncomingEdge));
|
||||||
|
|
||||||
Value *NewAdd = BinaryOperator::CreateAdd(NewPHI,
|
Value *NewAdd = BinaryOperator::CreateAdd(NewPHI,
|
||||||
ConstantInt::get(Type::Int32Ty,
|
Context->getConstantInt(Type::Int32Ty,
|
||||||
newIncrValue),
|
newIncrValue),
|
||||||
Incr->getName()+".int", Incr);
|
Incr->getName()+".int", Incr);
|
||||||
NewPHI->addIncoming(NewAdd, PH->getIncomingBlock(BackEdge));
|
NewPHI->addIncoming(NewAdd, PH->getIncomingBlock(BackEdge));
|
||||||
|
|
||||||
// The back edge is edge 1 of newPHI, whatever it may have been in the
|
// The back edge is edge 1 of newPHI, whatever it may have been in the
|
||||||
// original PHI.
|
// original PHI.
|
||||||
ConstantInt *NewEV = ConstantInt::get(Type::Int32Ty, intEV);
|
ConstantInt *NewEV = Context->getConstantInt(Type::Int32Ty, intEV);
|
||||||
Value *LHS = (EVIndex == 1 ? NewPHI->getIncomingValue(1) : NewEV);
|
Value *LHS = (EVIndex == 1 ? NewPHI->getIncomingValue(1) : NewEV);
|
||||||
Value *RHS = (EVIndex == 1 ? NewEV : NewPHI->getIncomingValue(1));
|
Value *RHS = (EVIndex == 1 ? NewEV : NewPHI->getIncomingValue(1));
|
||||||
ICmpInst *NewEC = new ICmpInst(NewPred, LHS, RHS, EC->getNameStart(),
|
ICmpInst *NewEC = new ICmpInst(NewPred, LHS, RHS, EC->getNameStart(),
|
||||||
@ -738,7 +739,7 @@ void IndVarSimplify::HandleFloatingPointIV(Loop *L, PHINode *PH) {
|
|||||||
RecursivelyDeleteTriviallyDeadInstructions(EC);
|
RecursivelyDeleteTriviallyDeadInstructions(EC);
|
||||||
|
|
||||||
// Delete old, floating point, increment instruction.
|
// Delete old, floating point, increment instruction.
|
||||||
Incr->replaceAllUsesWith(UndefValue::get(Incr->getType()));
|
Incr->replaceAllUsesWith(Context->getUndef(Incr->getType()));
|
||||||
RecursivelyDeleteTriviallyDeadInstructions(Incr);
|
RecursivelyDeleteTriviallyDeadInstructions(Incr);
|
||||||
|
|
||||||
// Replace floating induction variable, if it isn't already deleted.
|
// Replace floating induction variable, if it isn't already deleted.
|
||||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user