need to fix launch code

This commit is contained in:
Evghenii
2013-11-12 13:41:03 +01:00
parent 4cd7e10ad3
commit dbb96c1885
5 changed files with 22 additions and 8 deletions

View File

@@ -3524,8 +3524,9 @@ FunctionEmitContext::LaunchInst(llvm::Value *callee,
std::vector<llvm::Value *> &argVals, std::vector<llvm::Value *> &argVals,
llvm::Value *launchCount[3]){ llvm::Value *launchCount[3]){
if (1) // if (!g->target->isPTX()) if (!g->target->isPTX())
{ {
assert(0); /* evghenii: must be removed after testing is done */
if (callee == NULL) { if (callee == NULL) {
AssertPos(currentPos, m->errorCount > 0); AssertPos(currentPos, m->errorCount > 0);
return NULL; return NULL;
@@ -3594,7 +3595,8 @@ FunctionEmitContext::LaunchInst(llvm::Value *callee,
} }
else /* isPTX == true */ else /* isPTX == true */
{ {
assert(g->target->getISA() != Target::NVPTX64); assert(0); /* must only be called in export */
// assert(g->target->getISA() != Target::NVPTX64);
if (callee == NULL) { if (callee == NULL) {
AssertPos(currentPos, m->errorCount > 0); AssertPos(currentPos, m->errorCount > 0);
@@ -3673,8 +3675,10 @@ FunctionEmitContext::LaunchInst(llvm::Value *callee,
StoreInst(ptr_15, ptr_arrayinit_element); StoreInst(ptr_15, ptr_arrayinit_element);
} }
#if 0 /* evghenii:: must work uncommented */
if (argStructType->getNumElements() == argVals.size() + 1) if (argStructType->getNumElements() == argVals.size() + 1)
assert(0); /* must not happen as task function is unmasked for PTX target */ assert(0); /* must not happen as task function is unmasked for PTX target */
#endif
// And emit the call to the user-supplied task launch function, passing // And emit the call to the user-supplied task launch function, passing
// a pointer to the task function being called and a pointer to the // a pointer to the task function being called and a pointer to the

View File

@@ -534,7 +534,7 @@ Declarator::InitFromType(const Type *baseType, DeclSpecs *ds) {
if (isTask && g->target->isPTX()) //getISA() == Target::NVPTX64) if (isTask && g->target->isPTX()) //getISA() == Target::NVPTX64)
{ {
// ds->storageClass = SC_EXTERN_C; // ds->storageClass = SC_EXTERN_C;
// ds->typeQualifiers |= TYPEQUAL_UNMASKED; ds->typeQualifiers |= TYPEQUAL_UNMASKED;
} }
bool isExternC = ds && (ds->storageClass == SC_EXTERN_C); bool isExternC = ds && (ds->storageClass == SC_EXTERN_C);

View File

@@ -242,8 +242,9 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function,
// pointer to the structure that holds all of the arguments, the // pointer to the structure that holds all of the arguments, the
// thread index, and the thread count variables. // thread index, and the thread count variables.
if (1) //if (g->target->getISA() != Target::NVPTX64) if (!g->target->isPTX()) //if (g->target->getISA() != Target::NVPTX64)
{ {
assert(0); /* evghenii: must be removed in final, just for test for nvptx64 target */
llvm::Function::arg_iterator argIter = function->arg_begin(); llvm::Function::arg_iterator argIter = function->arg_begin();
llvm::Value *structParamPtr = argIter++; llvm::Value *structParamPtr = argIter++;
// Copy the function parameter values from the structure into local // Copy the function parameter values from the structure into local
@@ -343,7 +344,7 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function,
} }
else /* for NVPTX64 , function must be unmasked */ else /* for NVPTX64 , function must be unmasked */
{ {
//assert(0); assert(0);
Assert(type->isUnmasked == false); Assert(type->isUnmasked == false);
// Otherwise use the mask to set the entry mask value // Otherwise use the mask to set the entry mask value
@@ -353,6 +354,7 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function,
Assert(++argIter == function->arg_end()); Assert(++argIter == function->arg_end());
} }
#if 0
llvm::NamedMDNode* annotations = llvm::NamedMDNode* annotations =
m->module->getOrInsertNamedMetadata("nvvm.annotations"); m->module->getOrInsertNamedMetadata("nvvm.annotations");
llvm::SmallVector<llvm::Value*, 3> av; llvm::SmallVector<llvm::Value*, 3> av;
@@ -360,6 +362,7 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function,
av.push_back(llvm::MDString::get(*g->ctx, "kernel")); av.push_back(llvm::MDString::get(*g->ctx, "kernel"));
av.push_back(llvm::ConstantInt::get(llvm::IntegerType::get(*g->ctx,32), 1)); av.push_back(llvm::ConstantInt::get(llvm::IntegerType::get(*g->ctx,32), 1));
annotations->addOperand(llvm::MDNode::get(*g->ctx, av)); annotations->addOperand(llvm::MDNode::get(*g->ctx, av));
#endif
} }
} }
else { else {
@@ -535,8 +538,12 @@ Function::GenerateIR() {
/* export function with NVPTX64 target should be emitted host architecture */ /* export function with NVPTX64 target should be emitted host architecture */
#if 0 #if 0
const FunctionType *func_type= CastType<FunctionType>(sym->type); const FunctionType *func_type= CastType<FunctionType>(sym->type);
/* exported functions are not supported yet */
if (g->target->getISA() == Target::NVPTX64 && func_type->isExported) if (g->target->getISA() == Target::NVPTX64 && func_type->isExported)
return; return;
#endif
#if 0
if (g->target->getISA() != Target::NVPTX64 && g->target->isPTX() && func_type->isTask) if (g->target->getISA() != Target::NVPTX64 && g->target->isPTX() && func_type->isTask)
return; return;
#endif #endif

View File

@@ -733,7 +733,8 @@ Module::AddFunctionDeclaration(const std::string &name,
if (storageClass == SC_EXTERN_C) { if (storageClass == SC_EXTERN_C) {
// Make sure the user hasn't supplied both an 'extern "C"' and a // Make sure the user hasn't supplied both an 'extern "C"' and a
// 'task' qualifier with the function // 'task' qualifier with the function
if (functionType->isTask) { // && !g->target->isPTX()) { //tISA() != Target::NVPTX64) { if (functionType->isTask) //&& !g->target->isPTX()) //tISA() != Target::NVPTX64)
{
Error(pos, "\"task\" qualifier is illegal with C-linkage extern " Error(pos, "\"task\" qualifier is illegal with C-linkage extern "
"function \"%s\". Ignoring this function.", name.c_str()); "function \"%s\". Ignoring this function.", name.c_str());
return; return;
@@ -795,7 +796,7 @@ Module::AddFunctionDeclaration(const std::string &name,
#else // LLVM 3.1 and 3.3+ #else // LLVM 3.1 and 3.3+
function->addFnAttr(llvm::Attribute::AlwaysInline); function->addFnAttr(llvm::Attribute::AlwaysInline);
#endif #endif
if (functionType->isTask) // && g->target->getISA() != Target::NVPTX64) if (functionType->isTask && g->target->getISA() != Target::NVPTX64)
// This also applies transitively to members I think? // This also applies transitively to members I think?
#if defined(LLVM_3_1) #if defined(LLVM_3_1)
function->setDoesNotAlias(1, true); function->setDoesNotAlias(1, true);

View File

@@ -2957,8 +2957,9 @@ FunctionType::LLVMFunctionType(llvm::LLVMContext *ctx, bool removeMask) const {
// marshalled in a struct so that it's easy to allocate space to // marshalled in a struct so that it's easy to allocate space to
// hold them until the task actually runs.) // hold them until the task actually runs.)
// if (g->target->getISA() != Target::NVPTX64) // if (g->target->getISA() != Target::NVPTX64)
if (1) //if (!g->target->isPTX()) if (!g->target->isPTX())
{ {
assert(0); /* evghenii: must be removed in final, just for test for nvptx64 target */
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));
callTypes.push_back(LLVMTypes::Int32Type); // threadIndex callTypes.push_back(LLVMTypes::Int32Type); // threadIndex
@@ -2978,6 +2979,7 @@ FunctionType::LLVMFunctionType(llvm::LLVMContext *ctx, bool removeMask) const {
callTypes = llvmArgTypes; callTypes = llvmArgTypes;
else else
{ {
assert(0); /* evghenii: must be removed in final, just for test for nvptx64 target */
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));
} }