26 #ifndef CASADI_CLANG_COMPILER_HPP
27 #define CASADI_CLANG_COMPILER_HPP
29 #include "casadi/core/importer_internal.hpp"
30 #include <casadi/interfaces/clang/casadi_importer_clang_export.h>
32 #include <clang/CodeGen/CodeGenAction.h>
33 #include <clang/Basic/DiagnosticOptions.h>
34 #include <clang/Basic/TargetInfo.h>
35 #include <clang/Basic/Version.h>
36 #include <clang/Driver/Compilation.h>
37 #include <clang/Driver/Driver.h>
38 #include <clang/Driver/Tool.h>
39 #include <clang/Frontend/CompilerInstance.h>
40 #include <clang/Frontend/CompilerInvocation.h>
41 #include <clang/Frontend/FrontendDiagnostic.h>
42 #include <clang/Frontend/TextDiagnosticPrinter.h>
44 #include <llvm/ADT/SmallString.h>
45 #include <llvm/ExecutionEngine/ExecutionEngine.h>
46 #if (LLVM_VERSION_MAJOR>=4) || (LLVM_VERSION_MAJOR==3 && LLVM_VERSION_MINOR>=5)
47 #include <llvm/ExecutionEngine/MCJIT.h>
49 #include "llvm/ExecutionEngine/JIT.h"
51 #include <llvm/IR/Module.h>
52 #include "llvm/IR/LLVMContext.h"
54 #include <llvm/Support/FileSystem.h>
55 #include <llvm/Support/Host.h>
56 #include <llvm/Support/ManagedStatic.h>
57 #include <llvm/Support/Path.h>
58 #include <llvm/Support/TargetSelect.h>
59 #include <llvm/Support/raw_ostream.h>
60 #include <llvm/Support/raw_os_ostream.h>
83 class ClangCompiler :
public ImporterInternal {
87 explicit ClangCompiler(
const std::string& name);
90 static ImporterInternal* creator(
const std::string& name) {
91 return new ClangCompiler(name);
95 ~ClangCompiler()
override;
99 static const Options options_;
100 const Options& get_options()
const override {
return options_;}
104 void init(
const Dict& opts)
override;
107 static const std::string meta_doc;
110 const char* plugin_name()
const override {
return "clang";}
113 std::string class_name()
const override {
return "ClangCompiler";}
116 signal_t get_function(
const std::string& symname)
override;
119 static std::vector<std::pair<std::string, bool> >
120 getIncludes(
const std::string& file,
const std::string& path);
123 std::string include_path_;
124 std::vector<std::string> flags_;
127 clang::EmitLLVMOnlyAction* act_;
128 llvm::ExecutionEngine* executionEngine_;
129 llvm::LLVMContext* context_;
130 llvm::raw_ostream* myerr_;
131 llvm::Module* module_;
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.