added now NVPTX64 automatically emits unmasked extern "C" for task function with kernel attributes

This commit is contained in:
Evghenii
2013-10-28 13:58:01 +01:00
parent a7aa1ac1cf
commit 1bd5360d3b
4 changed files with 13 additions and 8 deletions

View File

@@ -530,16 +530,22 @@ Declarator::InitFromType(const Type *baseType, DeclSpecs *ds) {
returnType = returnType->ResolveUnboundVariability(Variability::Varying); 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 isExternC = ds && (ds->storageClass == SC_EXTERN_C);
bool isExported = ds && ((ds->typeQualifiers & TYPEQUAL_EXPORT) != 0); bool isExported = ds && ((ds->typeQualifiers & TYPEQUAL_EXPORT) != 0);
bool isTask = ds && ((ds->typeQualifiers & TYPEQUAL_TASK) != 0);
bool isUnmasked = ds && ((ds->typeQualifiers & TYPEQUAL_UNMASKED) != 0); bool isUnmasked = ds && ((ds->typeQualifiers & TYPEQUAL_UNMASKED) != 0);
if (isExported && isTask) { if (isExported && isTask) {
Error(pos, "Function can't have both \"task\" and \"export\" " Error(pos, "Function can't have both \"task\" and \"export\" "
"qualifiers"); "qualifiers");
return; return;
}j }
#if 0 /* NVPTX64::task_and_externC */ #if 0 /* NVPTX64::task_and_externC */
if (isExternC && isTask) { if (isExternC && isTask) {
Error(pos, "Function can't have both \"extern \"C\"\" and \"task\" " Error(pos, "Function can't have both \"extern \"C\"\" and \"task\" "

View File

@@ -336,11 +336,12 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function,
ctx->StoreInst(argIter, sym->storagePtr); ctx->StoreInst(argIter, sym->storagePtr);
ctx->EmitFunctionParameterDebugInfo(sym, i); ctx->EmitFunctionParameterDebugInfo(sym, i);
} }
if (argIter == function->arg_end()) { if (argIter == function->arg_end())
{
Assert(type->isUnmasked || type->isExported); Assert(type->isUnmasked || type->isExported);
ctx->SetFunctionMask(LLVMMaskAllOn); ctx->SetFunctionMask(LLVMMaskAllOn);
} }
else else /* for NVPTX64 , function must be unmasked */
assert(0); assert(0);
llvm::NamedMDNode* annotations = llvm::NamedMDNode* annotations =

View File

@@ -734,7 +734,7 @@ Module::AddFunctionDeclaration(const std::string &name,
// 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 0 /* NVPTX64::task_and_externC */ #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 " 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;

View File

@@ -2925,10 +2925,8 @@ FunctionType::GetReturnTypeString() const {
llvm::FunctionType * llvm::FunctionType *
FunctionType::LLVMFunctionType(llvm::LLVMContext *ctx, bool removeMask) const { FunctionType::LLVMFunctionType(llvm::LLVMContext *ctx, bool removeMask) const {
#if 0 /* NVPTX64::task_and_externC */ if (isTask == true && g->target->getISA() != Target::NVPTX64)
if (isTask == true)
Assert(removeMask == false); Assert(removeMask == false);
#endif
// Get the LLVM Type *s for the function arguments // Get the LLVM Type *s for the function arguments
std::vector<llvm::Type *> llvmArgTypes; std::vector<llvm::Type *> llvmArgTypes;