diff --git a/decl.cpp b/decl.cpp index 47443375..f21e3c41 100644 --- a/decl.cpp +++ b/decl.cpp @@ -531,7 +531,7 @@ 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) + if (isTask && g->target->isPTX()) //getISA() == Target::NVPTX64) { ds->storageClass = SC_EXTERN_C; ds->typeQualifiers |= TYPEQUAL_UNMASKED; @@ -546,13 +546,12 @@ Declarator::InitFromType(const Type *baseType, DeclSpecs *ds) { "qualifiers"); return; } -#if 0 /* NVPTX64::task_and_externC */ - if (isExternC && isTask) { - Error(pos, "Function can't have both \"extern \"C\"\" and \"task\" " - "qualifiers"); - return; - } -#endif + if (!g->target->isPTX()) + if (isExternC && isTask) { + Error(pos, "Function can't have both \"extern \"C\"\" and \"task\" " + "qualifiers"); + return; + } if (isExternC && isExported) { Error(pos, "Function can't have both \"extern \"C\"\" and \"export\" " "qualifiers"); diff --git a/func.cpp b/func.cpp index 62372a21..f930ce10 100644 --- a/func.cpp +++ b/func.cpp @@ -527,6 +527,8 @@ Function::GenerateIR() { const FunctionType *type= CastType(sym->type); if (g->target->getISA() == Target::NVPTX64 && type->isExported) return; + if (g->target->getISA() != Target::NVPTX64 && g->target->isPTX() && !type->isExported) + return; } { FunctionEmitContext ec(this, sym, function, firstStmtPos); diff --git a/module.cpp b/module.cpp index 071013b8..2f5e6167 100644 --- a/module.cpp +++ b/module.cpp @@ -733,7 +733,7 @@ Module::AddFunctionDeclaration(const std::string &name, if (storageClass == SC_EXTERN_C) { // Make sure the user hasn't supplied both an 'extern "C"' and a // 'task' qualifier with the function - if (functionType->isTask && g->target->getISA() != Target::NVPTX64) { + if (functionType->isTask && !g->target->isPTX()) { //tISA() != Target::NVPTX64) { Error(pos, "\"task\" qualifier is illegal with C-linkage extern " "function \"%s\". Ignoring this function.", name.c_str()); return; @@ -2319,6 +2319,11 @@ Module::CompileAndOutput(const char *srcFile, // We're only compiling to a single target const char * target_list[] = {"nvptx64", "avx"}; int errorCount = 0; + + const char *suffix_orig = strrchr(outFileName, '.'); + ++suffix_orig; + assert(suffix_orig!=NULL); + for (int itarget = 0; itarget < 2; itarget++) { fprintf(stderr, "compiling nvptx64 : target= %s\n",target_list[itarget]); @@ -2345,8 +2350,19 @@ Module::CompileAndOutput(const char *srcFile, } assert(outFileName != NULL); - std::string targetOutFileName = + + std::string targetOutFileName = lGetTargetFileName(outFileName, target_list[itarget]); + if (outputType == Asm) + { + const char * targetOutFileName_c = targetOutFileName.c_str(); + const int suffix = strrchr(targetOutFileName_c, '.') - targetOutFileName_c + 1; + if (itarget == 1 && !strcasecmp(suffix_orig, "ptx")) + { + targetOutFileName[suffix ] = 's'; + targetOutFileName[suffix+1] = 0; + } + } if (!m->writeOutput(outputType, targetOutFileName.c_str(), includeFileName)) return 1; diff --git a/type.cpp b/type.cpp index 23594e2f..04c02989 100644 --- a/type.cpp +++ b/type.cpp @@ -2925,7 +2925,7 @@ FunctionType::GetReturnTypeString() const { llvm::FunctionType * FunctionType::LLVMFunctionType(llvm::LLVMContext *ctx, bool removeMask) const { - if (isTask == true && g->target->getISA() != Target::NVPTX64) + if (isTask == true && !g->target->isPTX()) //getISA() != Target::NVPTX64) Assert(removeMask == false); // Get the LLVM Type *s for the function arguments