Mercurial > hg > release > icedtea7-2.0
changeset 2167:c2fd9278967c
Implemented Shark host CPU feature autotuner using LLVM 2.7 APIs.
2010-02-17 Xerxes R?nby <xerxes@zafena.se>
* ports/hotspot/src/share/vm/shark/sharkCompiler.cpp
(SharkCompiler::SharkCompiler): Implement host CPU feature
autotuner using LLVM 2.7 APIs.
* ports/hotspot/src/share/vm/shark/llvmHeaders.hpp:
Define llvm/ADT/StringMap.h and llvm/System/Host.h
depending on LLVM version.
Allways define llvm/Support/CommandLine.h.
author | Xerxes R?nby <xerxes@zafena.se> |
---|---|
date | Wed, 17 Feb 2010 14:46:46 +0100 |
parents | 6178ca4346ed |
children | 8dc6e1ff8ccf |
files | ChangeLog ports/hotspot/src/share/vm/shark/llvmHeaders.hpp ports/hotspot/src/share/vm/shark/sharkCompiler.cpp |
diffstat | 3 files changed, 38 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Tue Feb 16 15:54:50 2010 +0000 +++ b/ChangeLog Wed Feb 17 14:46:46 2010 +0100 @@ -1,3 +1,13 @@ +2010-02-17 Xerxes RĂ„nby <xerxes@zafena.se> + + * ports/hotspot/src/share/vm/shark/sharkCompiler.cpp + (SharkCompiler::SharkCompiler): Implement host CPU feature + autotuner using LLVM 2.7 APIs. + * ports/hotspot/src/share/vm/shark/llvmHeaders.hpp: + Define llvm/ADT/StringMap.h and llvm/System/Host.h + depending on LLVM version. + Allways define llvm/Support/CommandLine.h. + 2010-02-16 Gary Benson <gbenson@redhat.com> * contrib/jck/compile-native-code.sh: Add s390.
--- a/ports/hotspot/src/share/vm/shark/llvmHeaders.hpp Tue Feb 16 15:54:50 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/llvmHeaders.hpp Wed Feb 17 14:46:46 2010 +0100 @@ -42,10 +42,11 @@ #include <llvm/Target/TargetSelect.h> #include <llvm/Type.h> #include <llvm/ExecutionEngine/JITMemoryManager.h> -#if SHARK_LLVM_VERSION < 27 #include <llvm/Support/CommandLine.h> -#else +#if SHARK_LLVM_VERSION >= 27 +#include <llvm/ADT/StringMap.h> #include <llvm/Support/Debug.h> +#include <llvm/System/Host.h> #endif #include <map>
--- a/ports/hotspot/src/share/vm/shark/sharkCompiler.cpp Tue Feb 16 15:54:50 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkCompiler.cpp Wed Feb 17 14:46:46 2010 +0100 @@ -51,8 +51,32 @@ // Create the memory manager _memory_manager = new SharkMemoryManager(); +#if SHARK_LLVM_VERSION >= 27 + // Finetune LLVM for the current host CPU. + StringMap<bool> Features; + bool gotCpuFeatures = llvm::sys::getHostCPUFeatures(Features); + std::string cpu("-mcpu=" + llvm::sys::getHostCPUName()); + + std::vector<const char*> args; + args.push_back(""); // program name + args.push_back(cpu.c_str()); + + if(gotCpuFeatures){ + std::string mattr("-mattr="); + for(StringMap<bool>::iterator I = Features.begin(), + E = Features.end(); I != E; ++I){ + if(I->second){ + std::string attr(I->first()); + mattr+="+"+attr+","; + } + } + args.push_back(mattr.c_str()); + } + + args.push_back(0); // terminator + cl::ParseCommandLineOptions(args.size() - 1, (char **) &args[0]); + // Create the JIT -#if SHARK_LLVM_VERSION >= 27 _execution_engine = ExecutionEngine::createJIT( _normal_context->module(), NULL, memory_manager(), CodeGenOpt::Default);