Skip to content
Snippets Groups Projects
Commit 8f0d5fe7 authored by Prakalp Srivastava's avatar Prakalp Srivastava
Browse files

Changes to GenVISC pass to find the __visc__node call site and call appropriate

functions to generate changes to host and kernel code
parent 74b0c13f
No related branches found
No related tags found
No related merge requests found
......@@ -35,6 +35,9 @@ public:
// Functions
virtual bool runOnModule(Module &M);
static bool isVISCNodeCall(Instruction* I);
static void genKernel(Function* KernelFunction, CallInst* CI);
static void genHost(CallInst* CI);
};
} // End of namespace
......
......@@ -25,8 +25,6 @@ bool GenVISC::runOnModule(Module &M) {
errs() << "-------- Searching for launch sites ----------\n";
IntrinsicInst* II;
// Iterate over all functions in the module
for (Module::iterator mi = M.begin(), me = M.end(); mi != me; ++mi) {
Function* f = &*mi;
......@@ -34,15 +32,40 @@ bool GenVISC::runOnModule(Module &M) {
for (inst_iterator i = inst_begin(f), e = inst_end(f); i != e ; ++i) {
Instruction* I = &*i; // Grab pointer to Instruction
if(isVISCNodeCall(I)) {
CallInst* CI = cast<CallInst>(I);
errs() << "Found visc node call\n";
assert(CI->getNumArgOperands() >= 4
&& "__visc_node call should have atleast 4 arguments!");
genKernel(cast<Function>(CI->getArgOperand(0)), CI);
genHost(CI);
}
}
}
// Checking that we found at least one launch site
//assert((Roots.size() != 0) && "Launch site not found.");
return false; //TODO: What does returning "false" mean?
}
// Helper Functions
bool GenVISC::isVISCNodeCall(Instruction* I) {
if(!isa<CallInst>(I))
return false;
CallInst* CI = cast<CallInst>(I);
DEBUG(errs() << *I << "\n");
return (CI->getCalledValue()->stripPointerCasts()->getName()).equals("__visc__node");
}
void GenVISC::genKernel(Function* KernelF, CallInst* CI) {
// Make changes to kernel here
errs() << "Modifying Node Function: " << KernelF->getName() << "\n";
}
void GenVISC::genHost(CallInst* CI) {
// Make host code changes here
errs() << "Modifying Host code for __visc__node call site: " << *CI << "\n";
}
char GenVISC::ID = 0;
static RegisterPass<GenVISC> X("genvisc", "Pass to generate VISC IR from LLVM IR (with dummy function calls)", false, false);
......
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