Don't issue a slew of warnings if a bogus cpu type is specified.
Issue #221.
This commit is contained in:
51
ispc.cpp
51
ispc.cpp
@@ -113,6 +113,14 @@ lGetSystemISA() {
|
||||
}
|
||||
|
||||
|
||||
static const char *supportedCPUs[] = {
|
||||
"atom", "penryn", "core2", "corei7",
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
|
||||
"corei7-avx"
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
bool
|
||||
Target::GetTarget(const char *arch, const char *cpu, const char *isa,
|
||||
bool pic, Target *t) {
|
||||
@@ -121,13 +129,13 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa,
|
||||
// If a CPU was specified explicitly, try to pick the best
|
||||
// possible ISA based on that.
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
|
||||
if (!strcasecmp(cpu, "sandybridge") ||
|
||||
!strcasecmp(cpu, "corei7-avx"))
|
||||
if (!strcmp(cpu, "sandybridge") ||
|
||||
!strcmp(cpu, "corei7-avx"))
|
||||
isa = "avx";
|
||||
else
|
||||
#endif
|
||||
if (!strcasecmp(cpu, "corei7") ||
|
||||
!strcasecmp(cpu, "penryn"))
|
||||
if (!strcmp(cpu, "corei7") ||
|
||||
!strcmp(cpu, "penryn"))
|
||||
isa = "sse4";
|
||||
else
|
||||
isa = "sse2";
|
||||
@@ -153,6 +161,22 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa,
|
||||
cpu = "generic";
|
||||
}
|
||||
}
|
||||
else {
|
||||
bool foundCPU = false;
|
||||
for (int i = 0; i < int(sizeof(supportedCPUs) / sizeof(supportedCPUs[0]));
|
||||
++i) {
|
||||
if (!strcmp(cpu, supportedCPUs[i])) {
|
||||
foundCPU = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (foundCPU == false) {
|
||||
fprintf(stderr, "Error: CPU type \"%s\" unknown. Supported CPUs: "
|
||||
"%s.\n", cpu, SupportedTargetCPUs().c_str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
t->cpu = cpu;
|
||||
|
||||
if (arch == NULL)
|
||||
@@ -309,17 +333,16 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa,
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
std::string
|
||||
Target::SupportedTargetCPUs() {
|
||||
return "atom, barcelona, core2, corei7, "
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
|
||||
"corei7-avx, "
|
||||
#endif
|
||||
"istanbul, nocona, penryn, "
|
||||
#ifdef LLVM_2_9
|
||||
"sandybridge, "
|
||||
#endif
|
||||
"westmere";
|
||||
std::string ret;
|
||||
int count = sizeof(supportedCPUs) / sizeof(supportedCPUs[0]);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
ret += supportedCPUs[i];
|
||||
if (i != count - 1)
|
||||
ret += ", ";
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
2
ispc.h
2
ispc.h
@@ -164,7 +164,7 @@ struct Target {
|
||||
|
||||
/** Returns a comma-delimited string giving the names of the currently
|
||||
supported target CPUs. */
|
||||
static const char *SupportedTargetCPUs();
|
||||
static std::string SupportedTargetCPUs();
|
||||
|
||||
/** Returns a comma-delimited string giving the names of the currently
|
||||
supported target architectures. */
|
||||
|
||||
2
main.cpp
2
main.cpp
@@ -91,7 +91,7 @@ usage(int ret) {
|
||||
Target::SupportedTargetArchs());
|
||||
printf(" [--c++-include-file=<name>]\t\tSpecify name of file to emit in #include statement in generated C++ code.\n");
|
||||
printf(" [--cpu=<cpu>]\t\t\tSelect target CPU type\n");
|
||||
printf(" <cpu>={%s}\n", Target::SupportedTargetCPUs());
|
||||
printf(" <cpu>={%s}\n", Target::SupportedTargetCPUs().c_str());
|
||||
printf(" [-D<foo>]\t\t\t\t#define given value when running preprocessor\n");
|
||||
printf(" [--emit-asm]\t\t\tGenerate assembly language file as output\n");
|
||||
#ifndef LLVM_2_9
|
||||
|
||||
Reference in New Issue
Block a user