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

Checkpoint commit in coding GenVISC pass

parent 8f0d5fe7
No related branches found
No related tags found
No related merge requests found
......@@ -36,8 +36,8 @@ public:
virtual bool runOnModule(Module &M);
static bool isVISCNodeCall(Instruction* I);
static void genKernel(Function* KernelFunction, CallInst* CI);
static void genHost(CallInst* CI);
void genKernel(Function* KernelFunction, CallInst* CI);
void genHost(CallInst* CI);
};
} // End of namespace
......
......@@ -47,7 +47,13 @@ bool GenVISC::runOnModule(Module &M) {
}
// Helper Functions
static unsigned getNumericValue(Value* V) {
assert(isa<ConstantInt>(V)
&& "Number of arguments should be a constant");
return cast<ConstantInt>(V)->getZExtValue();
}
// Public Functions of GenVISC pass
bool GenVISC::isVISCNodeCall(Instruction* I) {
if(!isa<CallInst>(I))
return false;
......@@ -64,6 +70,36 @@ void GenVISC::genKernel(Function* KernelF, CallInst* CI) {
void GenVISC::genHost(CallInst* CI) {
// Make host code changes here
errs() << "Modifying Host code for __visc__node call site: " << *CI << "\n";
// Find number of dimensions
unsigned offset = 1; // argument at offset 1 is the number of dimensions
assert(CI->getNumArgOperands() > offset
&& "Too few arguments for __visc_node call!");
unsigned numDims = getNumericValue(CI->getOperand(offset));
errs () << "Num of dimensions = " << numDims << "\n";
// Find number of arguments
offset += numDims + 1; // skip the dimesnions
assert(CI->getNumArgOperands() > offset
&& "Too few arguments for __visc_node call!");
unsigned numArgs = getNumericValue(CI->getArgOperand(offset));
errs () << "Num of kernel arguments = " << numArgs << "\n";
// Find number of outputs
offset += numArgs + 1; // skip the kernel arguments
assert(CI->getNumArgOperands() > offset
&& "Too few arguments for __visc_node call!");
unsigned numOutputs = getNumericValue(CI->getArgOperand(offset));
errs () << "Num of kernel outputs = " << numOutputs << "\n";
// Find return struct type
// Generate argument struct type (All arguments followed by return struct type)
// Insert alloca inst for this argument struct type
// Marshall all input arguments into argument struct type
// Type cast argument struct to i8*
// Replace CI with launch call
// Add wait call
// Get result (optional)
}
char GenVISC::ID = 0;
......
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