generating proper tasking function for nvptx

This commit is contained in:
Evghenii
2013-10-28 11:36:08 +01:00
parent 8391d05697
commit b68a751f4e
2 changed files with 77 additions and 70 deletions

View File

@@ -240,16 +240,6 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function,
// thread index, and the thread count variables. // thread index, and the thread count variables.
llvm::Function::arg_iterator argIter = function->arg_begin(); llvm::Function::arg_iterator argIter = function->arg_begin();
llvm::Value *structParamPtr = argIter++; llvm::Value *structParamPtr = argIter++;
llvm::Value *threadIndex = argIter++;
llvm::Value *threadCount = argIter++;
llvm::Value *taskIndex = argIter++;
llvm::Value *taskCount = argIter++;
llvm::Value *taskIndex0 = argIter++;
llvm::Value *taskIndex1 = argIter++;
llvm::Value *taskIndex2 = argIter++;
llvm::Value *taskCount0 = argIter++;
llvm::Value *taskCount1 = argIter++;
llvm::Value *taskCount2 = argIter++;
// Copy the function parameter values from the structure into local // Copy the function parameter values from the structure into local
// storage // storage
@@ -266,6 +256,19 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function,
ctx->SetFunctionMask(ptrval); ctx->SetFunctionMask(ptrval);
} }
if (g->target->getISA() != Target::NVPTX64)
{
llvm::Value *threadIndex = argIter++;
llvm::Value *threadCount = argIter++;
llvm::Value *taskIndex = argIter++;
llvm::Value *taskCount = argIter++;
llvm::Value *taskIndex0 = argIter++;
llvm::Value *taskIndex1 = argIter++;
llvm::Value *taskIndex2 = argIter++;
llvm::Value *taskCount0 = argIter++;
llvm::Value *taskCount1 = argIter++;
llvm::Value *taskCount2 = argIter++;
// Copy threadIndex and threadCount into stack-allocated storage so // Copy threadIndex and threadCount into stack-allocated storage so
// that their symbols point to something reasonable. // that their symbols point to something reasonable.
threadIndexSym->storagePtr = ctx->AllocaInst(LLVMTypes::Int32Type, "threadIndex"); threadIndexSym->storagePtr = ctx->AllocaInst(LLVMTypes::Int32Type, "threadIndex");
@@ -313,6 +316,7 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function,
taskCountSym2->storagePtr = ctx->AllocaInst(LLVMTypes::Int32Type, "taskCount2"); taskCountSym2->storagePtr = ctx->AllocaInst(LLVMTypes::Int32Type, "taskCount2");
ctx->StoreInst(taskCount2, taskCountSym2->storagePtr); ctx->StoreInst(taskCount2, taskCountSym2->storagePtr);
} }
}
else { else {
// Regular, non-task function // Regular, non-task function
llvm::Function::arg_iterator argIter = function->arg_begin(); llvm::Function::arg_iterator argIter = function->arg_begin();

View File

@@ -2957,6 +2957,8 @@ FunctionType::LLVMFunctionType(llvm::LLVMContext *ctx, bool removeMask) const {
// hold them until the task actually runs.) // hold them until the task actually runs.)
llvm::Type *st = llvm::StructType::get(*ctx, llvmArgTypes); llvm::Type *st = llvm::StructType::get(*ctx, llvmArgTypes);
callTypes.push_back(llvm::PointerType::getUnqual(st)); callTypes.push_back(llvm::PointerType::getUnqual(st));
if (g->target->getISA() != Target::NVPTX64)
{
callTypes.push_back(LLVMTypes::Int32Type); // threadIndex callTypes.push_back(LLVMTypes::Int32Type); // threadIndex
callTypes.push_back(LLVMTypes::Int32Type); // threadCount callTypes.push_back(LLVMTypes::Int32Type); // threadCount
callTypes.push_back(LLVMTypes::Int32Type); // taskIndex callTypes.push_back(LLVMTypes::Int32Type); // taskIndex
@@ -2968,6 +2970,7 @@ FunctionType::LLVMFunctionType(llvm::LLVMContext *ctx, bool removeMask) const {
callTypes.push_back(LLVMTypes::Int32Type); // taskCount1 callTypes.push_back(LLVMTypes::Int32Type); // taskCount1
callTypes.push_back(LLVMTypes::Int32Type); // taskCount2 callTypes.push_back(LLVMTypes::Int32Type); // taskCount2
} }
}
else else
// Otherwise we already have the types of the arguments // Otherwise we already have the types of the arguments
callTypes = llvmArgTypes; callTypes = llvmArgTypes;