Skip to content
Snippets Groups Projects
Commit ace5e441 authored by Hashim Sharif's avatar Hashim Sharif
Browse files

Adding barebones pass for inserting ApproxInfo - incomplete

parent a5a81edf
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,7 @@ add_subdirectory(DFG2LLVM_SPIR)
add_subdirectory(DFG2LLVM_X86)
add_subdirectory(LocalMem)
add_subdirectory(InPlaceDFG)
add_subdirectory(InsertApproxInfo)
add_subdirectory(GenVISC)
add_subdirectory(MergeDFN)
add_subdirectory(FuseHPVMTensorNodes)
if(WIN32 OR CYGWIN)
set(LLVM_LINK_COMPONENTS Core Support)
endif()
add_llvm_loadable_module( InsertApproxInfo
InsertApproxInfo.cpp
DEPENDS
intrinsics_gen
PLUGIN_TOOL
opt
)
//===------------------------ InPlaceDFGAnalysis.cpp ----------------------===//
//
//
//
// The LLVM Compiler Infrastructure
//
//
//
// This file is distributed under the University of Illinois Open Source
//
// License. See LICENSE.TXT for details.
//
//
//
//===----------------------------------------------------------------------===//
#define DEBUG_TYPE "InsertApproxInfo"
#include "llvm/IR/Module.h"
#include "llvm/Pass.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/InPlaceDFG/InPlaceDFGAnalysis.h"
#include "llvm/SupportVISC/DFG2LLVM.h"
using namespace llvm;
using namespace builddfg;
using namespace dfg2llvm;
using namespace inplacedfg;
namespace {
struct InsertApproxInfoWrapperPass : public ModulePass {
static char ID; // Pass identification, replacement for typeid
InsertApproxInfoWrapperPass() : ModulePass(ID) {}
public:
// Functions
bool runOnModule(Module &M);
void getAnalysisUsage(AnalysisUsage &AU) const;
};
// Visitor for Code generation traversal (tree traversal for now)
class InsertApproxInfo : public CodeGenTraversal {
private:
// Virtual Functions
void init() {}
void initRuntimeAPI() {}
void codeGen(DFInternalNode* N);
void codeGen(DFLeafNode* N);
public:
// Constructor
InsertApproxInfo(Module &_M, BuildDFG &_DFG) :
CodeGenTraversal(_M, _DFG){
}
//void run(Module &M, BuildDFG &DFG);
void run();
};
void InsertApproxInfoWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<BuildDFG>();
AU.addPreserved<BuildDFG>();
}
bool InsertApproxInfoWrapperPass::runOnModule(Module &M) {
// Get the BuildDFG Analysis Results:
// - Dataflow graph
BuildDFG &DFG = getAnalysis<BuildDFG>();
InsertApproxInfo IApprox(M, DFG);
IApprox.run();
return false;
}
/*** Methods of InPlaceDFGAnalysis ***/
void InsertApproxInfo::run() {
errs() << "\n NOTE: ApproxInfo INSERTION TRANSFORM \n";
std::vector<DFInternalNode*> Roots = DFG.getRoots();
// Iterate over all the DFGs
// Analyse the edges for parameters that are valid to be used in place
for (auto rootNode: Roots) {
//ATVisitor->visit(rootNode);
this->visit(rootNode);
}
//delete ATVisitor;
return;
}
/*** Analysis of internal node ***/
void InsertApproxInfo::codeGen(DFInternalNode* N) {
DEBUG(errs() << "Analysing Node: " << N->getFuncPointer()->getName() << "\n");
}
/*** Analysis of leaf node ***/
void InsertApproxInfo::codeGen(DFLeafNode* N) {
DEBUG(errs() << "Analysing Node: " << N->getFuncPointer()->getName() << "\n");
}
char InsertApproxInfoWrapperPass::ID = 0;
static RegisterPass<InsertApproxInfoWrapperPass> X("insert-approxinfo",
"Pass to add approximation information (l-norm metrics) in the ApproxHPVM DFG",
false /* does not modify the CFG */,
false /* not transformation, just analysis */);
} // End of namespace
;===- ./lib/Transforms/LocalMem/LLVMBuild.txt ------------------*- Conf -*--===;
;
; The LLVM Compiler Infrastructure
;
; This file is distributed under the University of Illinois Open Source
; License. See LICENSE.TXT for details.
;
;===------------------------------------------------------------------------===;
;
; This is an LLVMBuild description file for the components in this subdirectory.
;
; For more information on the LLVMBuild system, please see:
;
; http://llvm.org/docs/LLVMBuild.html
;
;===------------------------------------------------------------------------===;
[component_0]
type = Library
name = InsertApproxInfo
parent = Transforms
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment