| 1 | /*============================================================================= |
| 2 | Copyright (c) 2001-2011 Joel de Guzman |
| 3 | |
| 4 | Distributed under the Boost Software License, Version 1.0. (See accompanying |
| 5 | file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 6 | =============================================================================*/ |
| 7 | #include "config.hpp" |
| 8 | #include "vm.hpp" |
| 9 | #include <iostream> |
| 10 | |
| 11 | #if defined(_MSC_VER) |
| 12 | # pragma warning(disable: 4800) // forcing value to bool 'true' or 'false' |
| 13 | // (performance warning) |
| 14 | #endif |
| 15 | |
| 16 | namespace client |
| 17 | { |
| 18 | vmachine::vmachine() |
| 19 | { |
| 20 | llvm::InitializeNativeTarget(); |
| 21 | llvm::LLVMContext& context = llvm::getGlobalContext(); |
| 22 | |
| 23 | // Make the module, which holds all the code. |
| 24 | module_ = new llvm::Module("Conjure JIT" , context); |
| 25 | |
| 26 | // Create the JIT. This takes ownership of the module. |
| 27 | std::string error; |
| 28 | execution_engine_ = |
| 29 | llvm::EngineBuilder(module_).setErrorStr(&error).create(); |
| 30 | |
| 31 | BOOST_ASSERT(execution_engine_ != 0); |
| 32 | if (!execution_engine_) |
| 33 | { |
| 34 | std::cerr << |
| 35 | "Could not create ExecutionEngine: " << |
| 36 | error << std::endl; |
| 37 | |
| 38 | exit(status: 1); |
| 39 | } |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | |
| 44 | |