Added LLVM 3.7 support

This commit is contained in:
Andrey Guskov
2015-01-19 17:30:59 +03:00
parent abeda29087
commit ae8b724d92
7 changed files with 47 additions and 14 deletions

View File

@@ -109,6 +109,9 @@ def build_LLVM(version_LLVM, revision, folder, tarball, debug, selfbuild, extra,
FOLDER_NAME=version_LLVM FOLDER_NAME=version_LLVM
if version_LLVM == "trunk": if version_LLVM == "trunk":
SVN_PATH="trunk" SVN_PATH="trunk"
if version_LLVM == "3.6":
SVN_PATH="branches/release_36/"
version_LLVM = "3_6"
if version_LLVM == "3.5": if version_LLVM == "3.5":
SVN_PATH="tags/RELEASE_350/final" SVN_PATH="tags/RELEASE_350/final"
version_LLVM = "3_5" version_LLVM = "3_5"
@@ -387,8 +390,10 @@ def build_ispc(version_LLVM, make):
temp = "3_4" temp = "3_4"
if version_LLVM == "3.5": if version_LLVM == "3.5":
temp = "3_5" temp = "3_5"
if version_LLVM == "trunk": if version_LLVM == "3.6":
temp = "3_6" temp = "3_6"
if version_LLVM == "trunk":
temp = "3_7"
os.environ["LLVM_VERSION"] = "LLVM_" + temp os.environ["LLVM_VERSION"] = "LLVM_" + temp
try_do_LLVM("clean ISPC for building", "msbuild ispc.vcxproj /t:clean", True) try_do_LLVM("clean ISPC for building", "msbuild ispc.vcxproj /t:clean", True)
try_do_LLVM("build ISPC with LLVM version " + version_LLVM + " ", "msbuild ispc.vcxproj /V:m /p:Platform=Win32 /p:Configuration=Release /t:rebuild", True) try_do_LLVM("build ISPC with LLVM version " + version_LLVM + " ", "msbuild ispc.vcxproj /V:m /p:Platform=Win32 /p:Configuration=Release /t:rebuild", True)
@@ -475,7 +480,7 @@ def validation_run(only, only_targets, reference_branch, number, notify, update,
print_debug("Folder: " + os.environ["ISPC_HOME"] + "\n", False, "") print_debug("Folder: " + os.environ["ISPC_HOME"] + "\n", False, "")
date = datetime.datetime.now() date = datetime.datetime.now()
print_debug("Date: " + date.strftime('%H:%M %d/%m/%Y') + "\n", False, "") print_debug("Date: " + date.strftime('%H:%M %d/%m/%Y') + "\n", False, "")
newest_LLVM="3.5" newest_LLVM="3.6"
msg_additional_info = "" msg_additional_info = ""
# *** *** *** # *** *** ***
# Stability validation run # Stability validation run
@@ -522,7 +527,7 @@ def validation_run(only, only_targets, reference_branch, number, notify, update,
archs.append("x86-64") archs.append("x86-64")
if "native" in only: if "native" in only:
sde_targets_t = [] sde_targets_t = []
for i in ["3.2", "3.3", "3.4", "3.5", "trunk"]: for i in ["3.2", "3.3", "3.4", "3.5", "3.6", "trunk"]:
if i in only: if i in only:
LLVM.append(i) LLVM.append(i)
if "current" in only: if "current" in only:
@@ -775,7 +780,7 @@ def Main():
if os.environ.get("SMTP_ISPC") == None: if os.environ.get("SMTP_ISPC") == None:
error("you have no SMTP_ISPC in your environment for option notify", 1) error("you have no SMTP_ISPC in your environment for option notify", 1)
if options.only != "": if options.only != "":
test_only_r = " 3.2 3.3 3.4 3.5 trunk current build stability performance x86 x86-64 -O0 -O2 native " test_only_r = " 3.2 3.3 3.4 3.5 3.6 trunk current build stability performance x86 x86-64 -O0 -O2 native "
test_only = options.only.split(" ") test_only = options.only.split(" ")
for iterator in test_only: for iterator in test_only:
if not (" " + iterator + " " in test_only_r): if not (" " + iterator + " " in test_only_r):
@@ -884,7 +889,7 @@ if __name__ == '__main__':
llvm_group = OptionGroup(parser, "Options for building LLVM", llvm_group = OptionGroup(parser, "Options for building LLVM",
"These options must be used with -b option.") "These options must be used with -b option.")
llvm_group.add_option('--version', dest='version', llvm_group.add_option('--version', dest='version',
help='version of llvm to build: 3.2 3.3 3.4 3.5 trunk. Default: trunk', default="trunk") help='version of llvm to build: 3.2 3.3 3.4 3.5 3.6 trunk. Default: trunk', default="trunk")
llvm_group.add_option('--with-gcc-toolchain', dest='gcc_toolchain_path', llvm_group.add_option('--with-gcc-toolchain', dest='gcc_toolchain_path',
help='GCC install dir to use when building clang. It is important to set when ' + help='GCC install dir to use when building clang. It is important to set when ' +
'you have alternative gcc installation. Note that otherwise gcc from standard ' + 'you have alternative gcc installation. Note that otherwise gcc from standard ' +
@@ -925,10 +930,10 @@ if __name__ == '__main__':
run_group.add_option('--only', dest='only', run_group.add_option('--only', dest='only',
help='set types of tests. Possible values:\n' + help='set types of tests. Possible values:\n' +
'-O0, -O2, x86, x86-64, stability (test only stability), performance (test only performance)\n' + '-O0, -O2, x86, x86-64, stability (test only stability), performance (test only performance)\n' +
'build (only build with different LLVM), 3.2, 3.3, 3.4 3.5, trunk, native (do not use SDE), current (do not rebuild ISPC).', 'build (only build with different LLVM), 3.2, 3.3, 3.4, 3.5, 3.6, trunk, native (do not use SDE), current (do not rebuild ISPC).',
default="") default="")
run_group.add_option('--perf_LLVM', dest='perf_llvm', run_group.add_option('--perf_LLVM', dest='perf_llvm',
help='compare LLVM 3.5 with "--compare-with", default trunk', default=False, action='store_true') help='compare LLVM 3.6 with "--compare-with", default trunk', default=False, action='store_true')
parser.add_option_group(run_group) parser.add_option_group(run_group)
# options for activity "setup PATHS" # options for activity "setup PATHS"
setup_group = OptionGroup(parser, "Options for setup", setup_group = OptionGroup(parser, "Options for setup",

View File

@@ -1498,11 +1498,14 @@ define <$1 x $2> @__atomic_compare_exchange_$3_global($2* %ptr, <$1 x $2> %cmp,
%cmp_LANE_ID = extractelement <$1 x $2> %cmp, i32 LANE %cmp_LANE_ID = extractelement <$1 x $2> %cmp, i32 LANE
%val_LANE_ID = extractelement <$1 x $2> %val, i32 LANE %val_LANE_ID = extractelement <$1 x $2> %val, i32 LANE
;; 3.5 and 3.6 code is the same since m4 has no OR and AND operators ;; 3.5, 3.6 and 3.7 code is the same since m4 has no OR and AND operators
ifelse(LLVM_VERSION,LLVM_3_5,` ifelse(LLVM_VERSION,LLVM_3_5,`
%r_LANE_ID_t = cmpxchg $2 * %ptr, $2 %cmp_LANE_ID, $2 %val_LANE_ID seq_cst seq_cst %r_LANE_ID_t = cmpxchg $2 * %ptr, $2 %cmp_LANE_ID, $2 %val_LANE_ID seq_cst seq_cst
%r_LANE_ID = extractvalue { $2, i1 } %r_LANE_ID_t, 0 %r_LANE_ID = extractvalue { $2, i1 } %r_LANE_ID_t, 0
',LLVM_VERSION,LLVM_3_6,` ',LLVM_VERSION,LLVM_3_6,`
%r_LANE_ID_t = cmpxchg $2 * %ptr, $2 %cmp_LANE_ID, $2 %val_LANE_ID seq_cst seq_cst
%r_LANE_ID = extractvalue { $2, i1 } %r_LANE_ID_t, 0
',LLVM_VERSION,LLVM_3_7,`
%r_LANE_ID_t = cmpxchg $2 * %ptr, $2 %cmp_LANE_ID, $2 %val_LANE_ID seq_cst seq_cst %r_LANE_ID_t = cmpxchg $2 * %ptr, $2 %cmp_LANE_ID, $2 %val_LANE_ID seq_cst seq_cst
%r_LANE_ID = extractvalue { $2, i1 } %r_LANE_ID_t, 0 %r_LANE_ID = extractvalue { $2, i1 } %r_LANE_ID_t, 0
',` ',`
@@ -1517,13 +1520,16 @@ define <$1 x $2> @__atomic_compare_exchange_$3_global($2* %ptr, <$1 x $2> %cmp,
define $2 @__atomic_compare_exchange_uniform_$3_global($2* %ptr, $2 %cmp, define $2 @__atomic_compare_exchange_uniform_$3_global($2* %ptr, $2 %cmp,
$2 %val) nounwind alwaysinline { $2 %val) nounwind alwaysinline {
;; 3.5 and 3.6 code is the same since m4 has no OR and AND operators ;; 3.5, 3.6 and 3.7 code is the same since m4 has no OR and AND operators
ifelse(LLVM_VERSION,LLVM_3_5,` ifelse(LLVM_VERSION,LLVM_3_5,`
%r_t = cmpxchg $2 * %ptr, $2 %cmp, $2 %val seq_cst seq_cst %r_t = cmpxchg $2 * %ptr, $2 %cmp, $2 %val seq_cst seq_cst
%r = extractvalue { $2, i1 } %r_t, 0 %r = extractvalue { $2, i1 } %r_t, 0
',LLVM_VERSION,LLVM_3_6,` ',LLVM_VERSION,LLVM_3_6,`
%r_t = cmpxchg $2 * %ptr, $2 %cmp, $2 %val seq_cst seq_cst %r_t = cmpxchg $2 * %ptr, $2 %cmp, $2 %val seq_cst seq_cst
%r = extractvalue { $2, i1 } %r_t, 0 %r = extractvalue { $2, i1 } %r_t, 0
',LLVM_VERSION,LLVM_3_7,`
%r_t = cmpxchg $2 * %ptr, $2 %cmp, $2 %val seq_cst seq_cst
%r = extractvalue { $2, i1 } %r_t, 0
',` ',`
%r = cmpxchg $2 * %ptr, $2 %cmp, $2 %val seq_cst %r = cmpxchg $2 * %ptr, $2 %cmp, $2 %val seq_cst
') ')

View File

@@ -343,7 +343,11 @@ namespace {
OpaqueCounter(0), NextAnonValueNumber(0), OpaqueCounter(0), NextAnonValueNumber(0),
includeName(incname ? incname : "generic_defs.h"), includeName(incname ? incname : "generic_defs.h"),
vectorWidth(vecwidth) { vectorWidth(vecwidth) {
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
initializeLoopInfoPass(*llvm::PassRegistry::getPassRegistry()); initializeLoopInfoPass(*llvm::PassRegistry::getPassRegistry());
#else // LLVM 3.7+
initializeLoopInfoWrapperPassPass(*llvm::PassRegistry::getPassRegistry());
#endif
FPCounter = 0; FPCounter = 0;
VectorConstantIndex = 0; VectorConstantIndex = 0;
} }
@@ -351,7 +355,11 @@ namespace {
virtual const char *getPassName() const { return "C backend"; } virtual const char *getPassName() const { return "C backend"; }
void getAnalysisUsage(llvm::AnalysisUsage &AU) const { void getAnalysisUsage(llvm::AnalysisUsage &AU) const {
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
AU.addRequired<llvm::LoopInfo>(); AU.addRequired<llvm::LoopInfo>();
#else // LLVM 3.7+
AU.addRequired<llvm::LoopInfoWrapperPass>();
#endif
AU.setPreservesAll(); AU.setPreservesAll();
} }
@@ -363,7 +371,11 @@ namespace {
if (F.hasAvailableExternallyLinkage()) if (F.hasAvailableExternallyLinkage())
return false; return false;
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
LI = &getAnalysis<llvm::LoopInfo>(); LI = &getAnalysis<llvm::LoopInfo>();
#else // LLVM 3.7+
LI = &getAnalysis<llvm::LoopInfoWrapperPass>().getLoopInfo();
#endif
// Get rid of intrinsics we can't handle. // Get rid of intrinsics we can't handle.
lowerIntrinsics(F); lowerIntrinsics(F);

4
ispc.h
View File

@@ -40,8 +40,8 @@
#define ISPC_VERSION "1.8.2dev" #define ISPC_VERSION "1.8.2dev"
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5) && !defined(LLVM_3_6) #if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5) && !defined(LLVM_3_6) && !defined(LLVM_3_7)
#error "Only LLVM 3.2, 3.3, 3.4, 3.5 and the 3.6 development branch are supported" #error "Only LLVM 3.2, 3.3, 3.4, 3.5, 3.6 and 3.7 development branch are supported"
#endif #endif
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)

View File

@@ -72,6 +72,8 @@ lPrintVersion() {
"3.5" "3.5"
#elif defined(LLVM_3_6) #elif defined(LLVM_3_6)
"3.6" "3.6"
#elif defined(LLVM_3_7)
"3.7"
#else #else
#error "Unhandled LLVM version" #error "Unhandled LLVM version"
#endif #endif

10
opt.cpp
View File

@@ -86,7 +86,11 @@
#include <llvm/DebugInfo.h> #include <llvm/DebugInfo.h>
#endif #endif
#include <llvm/Analysis/ConstantFolding.h> #include <llvm/Analysis/ConstantFolding.h>
#include <llvm/Target/TargetLibraryInfo.h> #if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
#include <llvm/Target/TargetLibraryInfo.h>
#else // LLVM 3.7+
#include <llvm/Analysis/TargetLibraryInfo.h>
#endif
#include <llvm/ADT/Triple.h> #include <llvm/ADT/Triple.h>
#include <llvm/ADT/SmallSet.h> #include <llvm/ADT/SmallSet.h>
#include <llvm/Transforms/Scalar.h> #include <llvm/Transforms/Scalar.h>
@@ -503,7 +507,11 @@ Optimize(llvm::Module *module, int optLevel) {
llvm::TargetLibraryInfo *targetLibraryInfo = llvm::TargetLibraryInfo *targetLibraryInfo =
new llvm::TargetLibraryInfo(llvm::Triple(module->getTargetTriple())); new llvm::TargetLibraryInfo(llvm::Triple(module->getTargetTriple()));
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
optPM.add(targetLibraryInfo); optPM.add(targetLibraryInfo);
#else // LLVM 3.7+
optPM.add(new llvm::TargetLibraryInfoWrapperPass(*targetLibraryInfo));
#endif
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) #if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4)
optPM.add(new llvm::DataLayout(*g->target->getDataLayout())); optPM.add(new llvm::DataLayout(*g->target->getDataLayout()));

View File

@@ -541,7 +541,7 @@ def verify():
f_lines = f.readlines() f_lines = f.readlines()
f.close() f.close()
check = [["g++", "clang++", "cl"],["-O0", "-O2"],["x86","x86-64"], check = [["g++", "clang++", "cl"],["-O0", "-O2"],["x86","x86-64"],
["Linux","Windows","Mac"],["LLVM 3.2","LLVM 3.3","LLVM 3.4","LLVM 3.5","LLVM trunk"], ["Linux","Windows","Mac"],["LLVM 3.2","LLVM 3.3","LLVM 3.4","LLVM 3.5","LLVM 3.6","LLVM trunk"],
["sse2-i32x4", "sse2-i32x8", "sse4-i32x4", "sse4-i32x8", "sse4-i16x8", ["sse2-i32x4", "sse2-i32x8", "sse4-i32x4", "sse4-i32x8", "sse4-i16x8",
"sse4-i8x16", "avx1-i32x4" "avx1-i32x8", "avx1-i32x16", "avx1-i64x4", "avx1.1-i32x8", "sse4-i8x16", "avx1-i32x4" "avx1-i32x8", "avx1-i32x16", "avx1-i64x4", "avx1.1-i32x8",
"avx1.1-i32x16", "avx1.1-i64x4", "avx2-i32x8", "avx2-i32x16", "avx2-i64x4", "avx1.1-i32x16", "avx1.1-i64x4", "avx2-i32x8", "avx2-i32x16", "avx2-i64x4",