Commit 06e70007 authored by guruhegde's avatar guruhegde

Refactor

parent 46bc369e
......@@ -15,30 +15,19 @@ using namespace llvm;
namespace tas {
auto detectExpPtrUses(SmallVectorImpl<Value *> & AnnotatedVars) {
SmallVector<LoadInst *, 4> VarUsePoints;
for_each(AnnotatedVars, [&]
(const auto & Var) {
auto FU = findFirstUseOfValueInInstType<LoadInst>(Var);
if (!FU) return;
// TODO Assume Load instruction immeditately follows.
if (auto * Ptr = dyn_cast<LoadInst>(FU->getNextNode())) {
if (Ptr->getOperand(0) == FU)
VarUsePoints.push_back(const_cast<LoadInst *>(FU));
}
});
return VarUsePoints;
}
bool LoopSplitter::run() {
void addPrefetchCallForPointers(Function *F, Stats & stat) {
auto AnnotatedVars = detectExpPtrVars(F);
auto VarUsePoints = detectExpPtrUses(AnnotatedVars);
for_each(VarUsePoints,
[&] (auto & VarUse) { insertLLVMPrefetchIntrinsic(F, VarUse); });
stat = Stats(AnnotatedVars.size(), VarUsePoints.size());
stat.AnnotatedVarsSize = AnnotatedVars.size();
stat.VarUsePointsSize = VarUsePoints.size();
}
bool LoopSplitter::run() {
Stats stat;
addPrefetchCallForPointers(F, stat);
return true;
}
......
......@@ -91,6 +91,21 @@ SmallVector<Value *, 4> detectExpPtrVars(Function * F) {
return ExpensivePointers;
}
SmallVector<LoadInst *, 4> detectExpPtrUses(SmallVectorImpl<Value *> & AnnotatedVars) {
SmallVector<LoadInst *, 4> VarUsePoints;
for_each(AnnotatedVars, [&]
(const auto & Var) {
auto FU = findFirstUseOfValueInInstType<LoadInst>(Var);
if (!FU) return;
// TODO Assume Load instruction immeditately follows.
if (auto * Ptr = dyn_cast<LoadInst>(FU->getNextNode())) {
if (Ptr->getOperand(0) == FU)
VarUsePoints.push_back(const_cast<LoadInst *>(FU));
}
});
return VarUsePoints;
}
Instruction * findBatchBeginMarkerInstruction(Function * F) {
auto varAnnotIntrinsic = Function::lookupIntrinsicID("llvm.var.annotation");
// XXX Checking only entry basic block for annotated variables.
......
......@@ -44,6 +44,10 @@ unsigned getTypeSizeInBits(llvm::Type * Ty);
llvm::SmallVector<llvm::Value *, 4> detectExpPtrVars(llvm::Function * F);
llvm::SmallVector<llvm::LoadInst *, 4>
detectExpPtrUses(llvm::SmallVectorImpl<llvm::Value *> & AnnotatedVars);
void detectBatchParameters(llvm::Function * F,
llvm::SmallPtrSet<llvm::Value *, 4> & BatchParameters);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment