changeset 1930:6571641c60ab

Update Shark for LLVM r95390 API change. 2010-02-21 Xerxes R?nby <xerxes@zafena.se> * ports/hotspot/src/share/vm/shark/sharkCompiler.cpp (MCPU): Explicitly defined for use by LLVM command line parser. (MAttrs): Likewise. (SharkCompiler::SharkCompiler): Create the JIT using LLVM EngineBuilder in order to explicitly set MCPU and MAttrs when using LLVM 2.7. * ports/hotspot/src/share/vm/shark/llvmHeaders.hpp: Include llvm/ExecutionEngine/JIT.h for LLVM 2.7 to make sure the JIT are linked in.
author Xerxes R?nby <xerxes@zafena.se>
date Sun, 21 Feb 2010 16:24:11 +0100
parents ede5e9311ef4
children b30c8301d479
files ChangeLog ports/hotspot/src/share/vm/shark/llvmHeaders.hpp ports/hotspot/src/share/vm/shark/sharkCompiler.cpp
diffstat 3 files changed, 41 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Feb 21 12:38:45 2010 +0000
+++ b/ChangeLog	Sun Feb 21 16:24:11 2010 +0100
@@ -1,3 +1,14 @@
+2010-02-21  Xerxes RĂ„nby  <xerxes@zafena.se>
+
+	* ports/hotspot/src/share/vm/shark/sharkCompiler.cpp
+	(MCPU): Explicitly defined for use by LLVM command line parser.
+	(MAttrs): Likewise.
+	(SharkCompiler::SharkCompiler): Create the JIT using LLVM EngineBuilder
+	in order to explicitly set MCPU and MAttrs when using LLVM 2.7.
+	* ports/hotspot/src/share/vm/shark/llvmHeaders.hpp:
+	Include llvm/ExecutionEngine/JIT.h for LLVM 2.7 to make sure the
+	JIT are linked in.
+
 2010-02-21 Andrew John Hughes  <ahughes@redhat.com>
 
 	* Makefile.am:
--- a/ports/hotspot/src/share/vm/shark/llvmHeaders.hpp	Sun Feb 21 12:38:45 2010 +0000
+++ b/ports/hotspot/src/share/vm/shark/llvmHeaders.hpp	Sun Feb 21 16:24:11 2010 +0100
@@ -44,6 +44,7 @@
 #include <llvm/ExecutionEngine/JITMemoryManager.h>
 #include <llvm/Support/CommandLine.h>
 #if SHARK_LLVM_VERSION >= 27
+#include <llvm/ExecutionEngine/JIT.h>
 #include <llvm/ADT/StringMap.h>
 #include <llvm/Support/Debug.h>
 #include <llvm/System/Host.h>
--- a/ports/hotspot/src/share/vm/shark/sharkCompiler.cpp	Sun Feb 21 12:38:45 2010 +0000
+++ b/ports/hotspot/src/share/vm/shark/sharkCompiler.cpp	Sun Feb 21 16:24:11 2010 +0100
@@ -30,6 +30,17 @@
 
 using namespace llvm;
 
+#if SHARK_LLVM_VERSION >= 27
+namespace {
+  cl::opt<std::string>
+  MCPU("mcpu");
+
+  cl::list<std::string>
+  MAttrs("mattr",
+         cl::CommaSeparated);
+}
+#endif
+
 SharkCompiler::SharkCompiler()
   : AbstractCompiler()
 {
@@ -77,9 +88,24 @@
   cl::ParseCommandLineOptions(args.size() - 1, (char **) &args[0]);
 
   // Create the JIT
-  _execution_engine = ExecutionEngine::createJIT(
-    _normal_context->module(),
-    NULL, memory_manager(), CodeGenOpt::Default);
+  std::string ErrorMsg;
+
+  EngineBuilder builder(_normal_context->module());
+  builder.setMCPU(MCPU);
+  builder.setMAttrs(MAttrs);
+  builder.setJITMemoryManager(memory_manager());
+  builder.setEngineKind(EngineKind::JIT);
+  builder.setErrorStr(&ErrorMsg);
+  _execution_engine = builder.create();
+
+  if (!execution_engine()) {
+    if (!ErrorMsg.empty())
+      printf("Error while creating Shark JIT: %s\n",ErrorMsg.c_str());
+    else
+      printf("Unknown error while creating Shark JIT\n");
+    exit(1);
+  }
+
   execution_engine()->addModule(
     _native_context->module());
 #else