Updated logic for selecting target ISA when not specified.

Now, if the user specified a CPU then we base the ISA choice on that--only
if no CPU and no target is specified do we use the CPUID-based check to
pick a vector ISA.

Improvement to fix to #205.
This commit is contained in:
Matt Pharr
2012-03-30 16:35:55 -07:00
parent 87c8a89349
commit 560bf5ca09

View File

@@ -1,5 +1,5 @@
/* /*
Copyright (c) 2010-2011, Intel Corporation Copyright (c) 2010-2012, Intel Corporation
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
@@ -116,6 +116,34 @@ lGetSystemISA() {
bool bool
Target::GetTarget(const char *arch, const char *cpu, const char *isa, Target::GetTarget(const char *arch, const char *cpu, const char *isa,
bool pic, Target *t) { bool pic, Target *t) {
if (isa == NULL) {
if (cpu != NULL) {
// 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"))
isa = "avx";
else
#endif
if (!strcasecmp(cpu, "corei7") ||
!strcasecmp(cpu, "penryn"))
isa = "sse4";
else
isa = "sse2";
fprintf(stderr, "Notice: no --target specified on command-line. "
"Using ISA \"%s\" based on specified CPU \"%s\".\n", isa,
cpu);
}
else {
// No CPU and no ISA, so use CPUID to figure out what this CPU
// supports.
isa = lGetSystemISA();
fprintf(stderr, "Notice: no --target specified on command-line. "
"Using system ISA \"%s\".\n", isa);
}
}
if (cpu == NULL) { if (cpu == NULL) {
std::string hostCPU = llvm::sys::getHostCPUName(); std::string hostCPU = llvm::sys::getHostCPUName();
if (hostCPU.size() > 0) if (hostCPU.size() > 0)
@@ -127,11 +155,6 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa,
} }
t->cpu = cpu; t->cpu = cpu;
if (isa == NULL) {
isa = lGetSystemISA();
fprintf(stderr, "Notice: no --target specified on command-line. Using "
"system ISA \"%s\".\n", isa);
}
if (arch == NULL) if (arch == NULL)
arch = "x86-64"; arch = "x86-64";