diff --git a/decl.cpp b/decl.cpp index 40d7eb72..47443375 100644 --- a/decl.cpp +++ b/decl.cpp @@ -530,16 +530,22 @@ Declarator::InitFromType(const Type *baseType, DeclSpecs *ds) { returnType = returnType->ResolveUnboundVariability(Variability::Varying); + bool isTask = ds && ((ds->typeQualifiers & TYPEQUAL_TASK) != 0); + if (isTask && g->target->getISA() == Target::NVPTX64) + { + ds->storageClass = SC_EXTERN_C; + ds->typeQualifiers |= TYPEQUAL_UNMASKED; + } + bool isExternC = ds && (ds->storageClass == SC_EXTERN_C); bool isExported = ds && ((ds->typeQualifiers & TYPEQUAL_EXPORT) != 0); - bool isTask = ds && ((ds->typeQualifiers & TYPEQUAL_TASK) != 0); bool isUnmasked = ds && ((ds->typeQualifiers & TYPEQUAL_UNMASKED) != 0); if (isExported && isTask) { Error(pos, "Function can't have both \"task\" and \"export\" " "qualifiers"); return; - }j + } #if 0 /* NVPTX64::task_and_externC */ if (isExternC && isTask) { Error(pos, "Function can't have both \"extern \"C\"\" and \"task\" " diff --git a/func.cpp b/func.cpp index 7c041bc8..597c42d2 100644 --- a/func.cpp +++ b/func.cpp @@ -336,11 +336,12 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function, ctx->StoreInst(argIter, sym->storagePtr); ctx->EmitFunctionParameterDebugInfo(sym, i); } - if (argIter == function->arg_end()) { + if (argIter == function->arg_end()) + { Assert(type->isUnmasked || type->isExported); ctx->SetFunctionMask(LLVMMaskAllOn); } - else + else /* for NVPTX64 , function must be unmasked */ assert(0); llvm::NamedMDNode* annotations = diff --git a/module.cpp b/module.cpp index bb081656..602f1b21 100644 --- a/module.cpp +++ b/module.cpp @@ -734,7 +734,7 @@ Module::AddFunctionDeclaration(const std::string &name, // Make sure the user hasn't supplied both an 'extern "C"' and a // 'task' qualifier with the function #if 0 /* NVPTX64::task_and_externC */ - if (functionType->isTask) { + if (functionType->isTask && g->target->getISA() != Target::NVPTX64) { Error(pos, "\"task\" qualifier is illegal with C-linkage extern " "function \"%s\". Ignoring this function.", name.c_str()); return; diff --git a/type.cpp b/type.cpp index d1588c99..23594e2f 100644 --- a/type.cpp +++ b/type.cpp @@ -2925,10 +2925,8 @@ FunctionType::GetReturnTypeString() const { llvm::FunctionType * FunctionType::LLVMFunctionType(llvm::LLVMContext *ctx, bool removeMask) const { -#if 0 /* NVPTX64::task_and_externC */ - if (isTask == true) + if (isTask == true && g->target->getISA() != Target::NVPTX64) Assert(removeMask == false); -#endif // Get the LLVM Type *s for the function arguments std::vector llvmArgTypes;