Main.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Standard includes
  2. #include <cstdio>
  3. //LLVM includes
  4. #include "llvm/Support/TargetSelect.h"
  5. #include "KaleidoscopeJIT.h"
  6. // Local includes
  7. #include "Ast.h"
  8. #include "Parser.h"
  9. #include "JIT.h"
  10. using namespace parser;
  11. using namespace jit;
  12. namespace helper {
  13. // Cloning make_unique here until it's standard in C++14.
  14. // Using a namespace to avoid conflicting with MSVC's std::make_unique (which
  15. // ADL can sometimes find in unqualified calls).
  16. template <class T, class... Args>
  17. static
  18. typename std::enable_if<!std::is_array<T>::value, std::unique_ptr<T>>::type
  19. make_unique(Args &&... args) {
  20. return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
  21. }
  22. }
  23. //===----------------------------------------------------------------------===//
  24. // "Library" functions that can be "extern'd" from user code.
  25. //===----------------------------------------------------------------------===//
  26. //===----------------------------------------------------------------------===//
  27. // Main driver code.
  28. //===----------------------------------------------------------------------===//
  29. int main() {
  30. InitializeNativeTarget();
  31. InitializeNativeTargetAsmPrinter();
  32. InitializeNativeTargetAsmParser();
  33. JITObjects::TheJIT = llvm::make_unique<llvm::orc::KaleidoscopeJIT>();
  34. jit::InitializeModuleAndPassManager();
  35. // Prime the first token.
  36. fprintf(stderr, "ready> ");
  37. getNextToken();
  38. // Run the main "interpreter loop" now.
  39. MainLoop();
  40. AstObjects::TheModule->dump();
  41. return 0;
  42. }