now can generate both targets for npvtx64. m_isPTX is set true, to distuish when to either skip or exlcusive euse export

This commit is contained in:
Evghenii
2013-10-29 14:17:11 +01:00
parent 8baef6daa3
commit b31fc6f66d
3 changed files with 61 additions and 52 deletions

View File

@@ -157,7 +157,7 @@ static const char *supportedCPUs[] = {
#endif // LLVM 3.4+ #endif // LLVM 3.4+
}; };
Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) : Target::Target(const char *arch, const char *cpu, const char *isa, bool pic, bool isPTX) :
m_target(NULL), m_target(NULL),
m_targetMachine(NULL), m_targetMachine(NULL),
#if defined(LLVM_3_1) #if defined(LLVM_3_1)
@@ -167,7 +167,7 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
#endif #endif
m_valid(false), m_valid(false),
m_isa(SSE2), m_isa(SSE2),
m_isPTX(false), m_isPTX(isPTX),
m_arch(""), m_arch(""),
m_is32Bit(true), m_is32Bit(true),
m_cpu(""), m_cpu(""),

2
ispc.h
View File

@@ -189,7 +189,7 @@ public:
/** Initializes the given Target pointer for a target of the given /** Initializes the given Target pointer for a target of the given
name, if the name is a known target. Returns true if the name, if the name is a known target. Returns true if the
target was initialized and false if the name is unknown. */ target was initialized and false if the name is unknown. */
Target(const char *arch, const char *cpu, const char *isa, bool pic); Target(const char *arch, const char *cpu, const char *isa, bool pic, bool isPTX = false);
/** Returns a comma-delimited string giving the names of the currently /** Returns a comma-delimited string giving the names of the currently
supported compilation targets. */ supported compilation targets. */

View File

@@ -733,13 +733,11 @@ 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 0 /* NVPTX64::task_and_externC */
if (functionType->isTask && g->target->getISA() != Target::NVPTX64) { 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;
} }
#endif
std::vector<Symbol *> funcs; std::vector<Symbol *> funcs;
symbolTable->LookupFunction(name.c_str(), &funcs); symbolTable->LookupFunction(name.c_str(), &funcs);
@@ -2316,62 +2314,72 @@ Module::CompileAndOutput(const char *srcFile,
const char *hostStubFileName, const char *hostStubFileName,
const char *devStubFileName) const char *devStubFileName)
{ {
if (target != NULL && !strcmp(target,"nvptx64")) if (target != NULL && !strcmp(target,"nvptx64")) // NVPTX64
{ {
fprintf(stderr, "compiling nvptx64 \n");
// We're only compiling to a single target // We're only compiling to a single target
g->target = new Target(arch, cpu, target, generatePIC); const char * target_list[] = {"nvptx64", "avx"};
if (!g->target->isValid()) int errorCount = 0;
return 1; for (int itarget = 0; itarget < 2; itarget++)
{
fprintf(stderr, "compiling nvptx64 : target= %s\n",target_list[itarget]);
g->target = new Target(arch, cpu, target_list[itarget], generatePIC, /* isPTX= */ true);
if (!g->target->isValid())
return 1;
m = new Module(srcFile); m = new Module(srcFile);
if (m->CompileFile() == 0) { if (m->CompileFile() == 0) {
if (outputType == CXX) { if (outputType == CXX) {
if (target == NULL || strncmp(target, "generic-", 8) != 0) { if (target == NULL || strncmp(target, "generic-", 8) != 0) {
Error(SourcePos(), "When generating C++ output, one of the \"generic-*\" " Error(SourcePos(), "When generating C++ output, one of the \"generic-*\" "
"targets must be used."); "targets must be used.");
return 1; return 1;
} }
} }
else if (outputType == Asm || outputType == Object) { else if (outputType == Asm || outputType == Object) {
if (target != NULL && strncmp(target, "generic-", 8) == 0) { if (target != NULL && strncmp(target, "generic-", 8) == 0) {
Error(SourcePos(), "When using a \"generic-*\" compilation target, " Error(SourcePos(), "When using a \"generic-*\" compilation target, "
"%s output can not be used.", "%s output can not be used.",
(outputType == Asm) ? "assembly" : "object file"); (outputType == Asm) ? "assembly" : "object file");
return 1; return 1;
}
}
assert(outFileName != NULL);
std::string targetOutFileName =
lGetTargetFileName(outFileName, target_list[itarget]);
if (!m->writeOutput(outputType, targetOutFileName.c_str(), includeFileName))
return 1;
if (itarget > 0)
{
if (headerFileName != NULL)
if (!m->writeOutput(Module::Header, headerFileName))
return 1;
if (depsFileName != NULL)
if (!m->writeOutput(Module::Deps,depsFileName))
return 1;
if (hostStubFileName != NULL)
if (!m->writeOutput(Module::HostStub,hostStubFileName))
return 1;
if (devStubFileName != NULL)
if (!m->writeOutput(Module::DevStub,devStubFileName))
return 1;
} }
} }
else
++m->errorCount;
errorCount += m->errorCount;
delete m;
m = NULL;
delete g->target;
g->target = NULL;
if (outFileName != NULL)
if (!m->writeOutput(outputType, outFileName, includeFileName))
return 1;
if (headerFileName != NULL)
if (!m->writeOutput(Module::Header, headerFileName))
return 1;
if (depsFileName != NULL)
if (!m->writeOutput(Module::Deps,depsFileName))
return 1;
if (hostStubFileName != NULL)
if (!m->writeOutput(Module::HostStub,hostStubFileName))
return 1;
if (devStubFileName != NULL)
if (!m->writeOutput(Module::DevStub,devStubFileName))
return 1;
} }
else
++m->errorCount;
int errorCount = m->errorCount;
delete m;
m = NULL;
delete g->target;
g->target = NULL;
return errorCount > 0; return errorCount > 0;
} }
else else if (target == NULL || strchr(target, ',') == NULL) {
if (target == NULL || strchr(target, ',') == NULL) {
// We're only compiling to a single target // We're only compiling to a single target
g->target = new Target(arch, cpu, target, generatePIC); g->target = new Target(arch, cpu, target, generatePIC);
if (!g->target->isValid()) if (!g->target->isValid())
@@ -2542,4 +2550,5 @@ Module::CompileAndOutput(const char *srcFile,
return errorCount > 0; return errorCount > 0;
} }
return true;
} }