vm.cpp 1.3 KB

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