From 9e0e9dbecc484fdbc6fd16a3fca283df71572f65 Mon Sep 17 00:00:00 2001 From: Preston Gurd Date: Fri, 20 Sep 2013 14:42:46 -0400 Subject: [PATCH 1/2] - Add Silvermont (--cpu=slm) option for llvm 3.4+. - Change default Sandybridge isa name to avx1-i32x8 from avx-i32x8, to conform with replacement of avx-i32x8 by avx1-i32x8 everywhere else. - Add "target-cpu" attribute, when using AttrBuilder, to correct a problem whereby llvm would switch from the command line cpu setting to the native (auto-detected) cpu setting on second and subsequent functions. e.g. if I wanted to build for Silvermont on a Sandy Bridge machine, ispc/llvm would correctly use Silvermont and turn on the Silvermont scheduler. For the second and subsequent functions, it would auto-detect Sandy Bridge, but still run the Silvermont scheduler. --- ispc.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ispc.cpp b/ispc.cpp index 82f0518b..ea7bfcd7 100644 --- a/ispc.cpp +++ b/ispc.cpp @@ -126,7 +126,7 @@ lGetSystemISA() { return "avx1.1-i32x8"; } // Regular AVX - return "avx-i32x8"; + return "avx1-i32x8"; } else if ((info[2] & (1 << 19)) != 0) return "sse4-i32x4"; @@ -149,8 +149,11 @@ static const char *supportedCPUs[] = { #endif "atom", "penryn", "core2", "corei7", "corei7-avx" #if !defined(LLVM_3_1) - , "core-avx-i", "core-avx2" + , "core-avx-i", "core-avx2", "slm" #endif // LLVM 3.2+ +#if !defined(LLVM_3_1) && !defined(LLVM_3_2) && !defined(LLVM_3_3) + , "slm" +#endif // LLVM 3.4+ }; Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) : @@ -196,9 +199,10 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) : isa = "avx1.1-i32x8"; else if (!strcmp(cpu, "sandybridge") || !strcmp(cpu, "corei7-avx")) - isa = "avx-i32x8"; + isa = "avx1-i32x8"; else if (!strcmp(cpu, "corei7") || - !strcmp(cpu, "penryn")) + !strcmp(cpu, "penryn") || + !strcmp(cpu, "slm")) isa = "sse4-i32x4"; else isa = "sse2-i32x4"; @@ -660,6 +664,7 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) : // Initialize target-specific "target-feature" attribute. if (!m_attributes.empty()) { llvm::AttrBuilder attrBuilder; + attrBuilder.addAttribute("target-cpu", this->m_cpu); attrBuilder.addAttribute("target-features", this->m_attributes); this->m_tf_attributes = new llvm::AttributeSet( llvm::AttributeSet::get( From 4b26b8b4309ffb3295db16815620d2ab751c61c7 Mon Sep 17 00:00:00 2001 From: Preston Gurd Date: Fri, 20 Sep 2013 16:44:01 -0400 Subject: [PATCH 2/2] Remove redundant "slm". --- ispc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ispc.cpp b/ispc.cpp index ea7bfcd7..bec7baf7 100644 --- a/ispc.cpp +++ b/ispc.cpp @@ -149,7 +149,7 @@ static const char *supportedCPUs[] = { #endif "atom", "penryn", "core2", "corei7", "corei7-avx" #if !defined(LLVM_3_1) - , "core-avx-i", "core-avx2", "slm" + , "core-avx-i", "core-avx2" #endif // LLVM 3.2+ #if !defined(LLVM_3_1) && !defined(LLVM_3_2) && !defined(LLVM_3_3) , "slm"