Fix for Windows build and making NEON target optional
This commit is contained in:
31
ispc.cpp
31
ispc.cpp
@@ -141,10 +141,12 @@ lGetSystemISA() {
|
||||
|
||||
|
||||
static const char *supportedCPUs[] = {
|
||||
#ifdef ISPC_ARM_ENABLED
|
||||
// FIXME: LLVM supports a ton of different ARM CPU variants--not just
|
||||
// cortex-a9 and a15. We should be able to handle any of them that also
|
||||
// have NEON support.
|
||||
"cortex-a9", "cortex-a15",
|
||||
#endif
|
||||
"atom", "penryn", "core2", "corei7", "corei7-avx"
|
||||
#if !defined(LLVM_3_1)
|
||||
, "core-avx-i", "core-avx2"
|
||||
@@ -185,9 +187,11 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
||||
// possible ISA based on that.
|
||||
if (!strcmp(cpu, "core-avx2"))
|
||||
isa = "avx2";
|
||||
#ifdef ISPC_ARM_ENABLED
|
||||
else if (!strcmp(cpu, "cortex-a9") ||
|
||||
!strcmp(cpu, "cortex-a15"))
|
||||
isa = "neon";
|
||||
#endif
|
||||
else if (!strcmp(cpu, "core-avx-i"))
|
||||
isa = "avx1.1";
|
||||
else if (!strcmp(cpu, "sandybridge") ||
|
||||
@@ -211,7 +215,7 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(__arm__)
|
||||
#if defined(ISPC_ARM_ENABLED) && !defined(__arm__)
|
||||
if (cpu == NULL && !strcmp(isa, "neon"))
|
||||
// If we're compiling NEON on an x86 host and the CPU wasn't
|
||||
// supplied, don't go and set the CPU based on the host...
|
||||
@@ -246,9 +250,11 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
||||
this->m_cpu = cpu;
|
||||
|
||||
if (arch == NULL) {
|
||||
#ifdef ISPC_ARM_ENABLED
|
||||
if (!strcmp(isa, "neon"))
|
||||
arch = "arm";
|
||||
else
|
||||
#endif
|
||||
arch = "x86-64";
|
||||
}
|
||||
|
||||
@@ -445,6 +451,7 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
||||
this->m_hasGather = true;
|
||||
#endif
|
||||
}
|
||||
#ifdef ISPC_ARM_ENABLED
|
||||
else if (!strcasecmp(isa, "neon")) {
|
||||
this->m_isa = Target::NEON;
|
||||
this->m_nativeVectorWidth = 4;
|
||||
@@ -454,6 +461,7 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
||||
this->m_maskingIsFree = false;
|
||||
this->m_maskBitCount = 32;
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
fprintf(stderr, "Target ISA \"%s\" is unknown. Choices are: %s\n",
|
||||
isa, SupportedTargetISAs());
|
||||
@@ -468,8 +476,10 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
||||
llvm::Reloc::Default;
|
||||
std::string featuresString = m_attributes;
|
||||
llvm::TargetOptions options;
|
||||
#ifdef ISPC_ARM_ENABLED
|
||||
if (m_isa == Target::NEON)
|
||||
options.FloatABIType = llvm::FloatABI::Hard;
|
||||
#endif
|
||||
#if !defined(LLVM_3_1)
|
||||
if (g->opt.disableFMA == false)
|
||||
options.AllowFPOpFusion = llvm::FPOpFusion::Fast;
|
||||
@@ -561,13 +571,21 @@ Target::SupportedTargetCPUs() {
|
||||
|
||||
const char *
|
||||
Target::SupportedTargetArchs() {
|
||||
return "arm, x86, x86-64";
|
||||
return
|
||||
#ifdef ISPC_ARM_ENABLED
|
||||
"arm, "
|
||||
#endif
|
||||
"x86, x86-64";
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
Target::SupportedTargetISAs() {
|
||||
return "neon, sse2, sse2-x2, sse4, sse4-x2, avx, avx-x2"
|
||||
return
|
||||
#ifdef ISPC_ARM_ENABLED
|
||||
"neon, "
|
||||
#endif
|
||||
"sse2, sse2-x2, sse4, sse4-x2, avx, avx-x2"
|
||||
", avx1.1, avx1.1-x2, avx2, avx2-x2"
|
||||
", generic-1, generic-4, generic-8, generic-16, generic-32";
|
||||
}
|
||||
@@ -576,10 +594,13 @@ Target::SupportedTargetISAs() {
|
||||
std::string
|
||||
Target::GetTripleString() const {
|
||||
llvm::Triple triple;
|
||||
#ifdef ISPC_ARM_ENABLED
|
||||
if (m_arch == "arm") {
|
||||
triple.setTriple("armv7-eabi");
|
||||
}
|
||||
else {
|
||||
else
|
||||
#endif
|
||||
{
|
||||
// Start with the host triple as the default
|
||||
triple.setTriple(llvm::sys::getDefaultTargetTriple());
|
||||
|
||||
@@ -602,7 +623,9 @@ Target::GetTripleString() const {
|
||||
const char *
|
||||
Target::ISAToString(ISA isa) {
|
||||
switch (isa) {
|
||||
#ifdef ISPC_ARM_ENABLED
|
||||
case Target::NEON:
|
||||
#endif
|
||||
return "neon";
|
||||
case Target::SSE2:
|
||||
return "sse2";
|
||||
|
||||
Reference in New Issue
Block a user