OmniSciDB  04ee39c94c
CodeCache.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019 OmniSci, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include "CompilationOptions.h"
20 
21 #include "../StringDictionary/LruCache.hpp"
22 
23 #include <llvm/ExecutionEngine/ExecutionEngine.h>
24 #include <llvm/ExecutionEngine/JITEventListener.h>
25 #include <llvm/IR/Module.h>
26 #include <boost/functional/hash.hpp>
27 
28 #include <memory>
29 
31  public:
33  ExecutionEngineWrapper(llvm::ExecutionEngine* execution_engine);
34  ExecutionEngineWrapper(llvm::ExecutionEngine* execution_engine,
35  const CompilationOptions& co);
36 
37  ExecutionEngineWrapper(const ExecutionEngineWrapper& other) = delete;
39 
42 
43  ExecutionEngineWrapper& operator=(llvm::ExecutionEngine* execution_engine);
44 
45  llvm::ExecutionEngine* get() { return execution_engine_.get(); }
46  const llvm::ExecutionEngine* get() const { return execution_engine_.get(); }
47 
48  llvm::ExecutionEngine& operator*() { return *execution_engine_; }
49  const llvm::ExecutionEngine& operator*() const { return *execution_engine_; }
50 
51  llvm::ExecutionEngine* operator->() { return execution_engine_.get(); }
52  const llvm::ExecutionEngine* operator->() const { return execution_engine_.get(); }
53 
54  private:
55  std::unique_ptr<llvm::ExecutionEngine> execution_engine_;
56  std::unique_ptr<llvm::JITEventListener> intel_jit_listener_;
57 };
58 
60 
61 using CodeCacheKey = std::vector<std::string>;
62 using CodeCacheVal = std::vector<
63  std::tuple<void*, ExecutionEngineWrapper, std::unique_ptr<GpuCompilationContext>>>;
64 using CodeCacheValWithModule = std::pair<CodeCacheVal, llvm::Module*>;
65 using CodeCache =
std::pair< CodeCacheVal, llvm::Module * > CodeCacheValWithModule
Definition: CodeCache.h:64
std::vector< std::tuple< void *, ExecutionEngineWrapper, std::unique_ptr< GpuCompilationContext > >> CodeCacheVal
Definition: CodeCache.h:63
std::vector< std::string > CodeCacheKey
Definition: CodeCache.h:61
ExecutionEngineWrapper & operator=(const ExecutionEngineWrapper &other)=delete
std::unique_ptr< llvm::JITEventListener > intel_jit_listener_
Definition: CodeCache.h:56
llvm::ExecutionEngine * operator->()
Definition: CodeCache.h:51
std::unique_ptr< llvm::ExecutionEngine > execution_engine_
Definition: CodeCache.h:55
const llvm::ExecutionEngine & operator*() const
Definition: CodeCache.h:49
llvm::ExecutionEngine & operator*()
Definition: CodeCache.h:48
const llvm::ExecutionEngine * operator->() const
Definition: CodeCache.h:52