nvptx64 generates 2 targets: task and normal function for nvptx64 and export for avx only

This commit is contained in:
Evghenii
2013-10-29 14:46:51 +01:00
parent b31fc6f66d
commit f15cdc03e3
4 changed files with 28 additions and 11 deletions

View File

@@ -531,7 +531,7 @@ 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); 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->storageClass = SC_EXTERN_C;
ds->typeQualifiers |= TYPEQUAL_UNMASKED; ds->typeQualifiers |= TYPEQUAL_UNMASKED;
@@ -546,13 +546,12 @@ Declarator::InitFromType(const Type *baseType, DeclSpecs *ds) {
"qualifiers"); "qualifiers");
return; return;
} }
#if 0 /* NVPTX64::task_and_externC */ if (!g->target->isPTX())
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\" "
"qualifiers"); "qualifiers");
return; return;
} }
#endif
if (isExternC && isExported) { if (isExternC && isExported) {
Error(pos, "Function can't have both \"extern \"C\"\" and \"export\" " Error(pos, "Function can't have both \"extern \"C\"\" and \"export\" "
"qualifiers"); "qualifiers");

View File

@@ -527,6 +527,8 @@ Function::GenerateIR() {
const FunctionType *type= CastType<FunctionType>(sym->type); const FunctionType *type= CastType<FunctionType>(sym->type);
if (g->target->getISA() == Target::NVPTX64 && type->isExported) if (g->target->getISA() == Target::NVPTX64 && type->isExported)
return; return;
if (g->target->getISA() != Target::NVPTX64 && g->target->isPTX() && !type->isExported)
return;
} }
{ {
FunctionEmitContext ec(this, sym, function, firstStmtPos); FunctionEmitContext ec(this, sym, function, firstStmtPos);

View File

@@ -733,7 +733,7 @@ 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->getISA() != 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;
@@ -2319,6 +2319,11 @@ Module::CompileAndOutput(const char *srcFile,
// We're only compiling to a single target // We're only compiling to a single target
const char * target_list[] = {"nvptx64", "avx"}; const char * target_list[] = {"nvptx64", "avx"};
int errorCount = 0; int errorCount = 0;
const char *suffix_orig = strrchr(outFileName, '.');
++suffix_orig;
assert(suffix_orig!=NULL);
for (int itarget = 0; itarget < 2; itarget++) for (int itarget = 0; itarget < 2; itarget++)
{ {
fprintf(stderr, "compiling nvptx64 : target= %s\n",target_list[itarget]); fprintf(stderr, "compiling nvptx64 : target= %s\n",target_list[itarget]);
@@ -2345,8 +2350,19 @@ Module::CompileAndOutput(const char *srcFile,
} }
assert(outFileName != NULL); assert(outFileName != NULL);
std::string targetOutFileName =
std::string targetOutFileName =
lGetTargetFileName(outFileName, target_list[itarget]); 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)) if (!m->writeOutput(outputType, targetOutFileName.c_str(), includeFileName))
return 1; return 1;

View File

@@ -2925,7 +2925,7 @@ FunctionType::GetReturnTypeString() const {
llvm::FunctionType * llvm::FunctionType *
FunctionType::LLVMFunctionType(llvm::LLVMContext *ctx, bool removeMask) const { 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); Assert(removeMask == false);
// Get the LLVM Type *s for the function arguments // Get the LLVM Type *s for the function arguments