OmniSciDB  ca0c39ec8f
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CompilationContext.h
Go to the documentation of this file.
1 /*
2  * Copyright 2022 HEAVY.AI, 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 <llvm/ExecutionEngine/ExecutionEngine.h>
20 #include <llvm/ExecutionEngine/JITEventListener.h>
21 #include <llvm/IR/Module.h>
22 
23 #include <memory>
24 
26  public:
27  virtual ~CompilationContext() {}
28 };
29 
30 struct CompilationOptions;
31 
33  public:
35  ExecutionEngineWrapper(llvm::ExecutionEngine* execution_engine);
36  ExecutionEngineWrapper(llvm::ExecutionEngine* execution_engine,
37  const CompilationOptions& co);
38 
39  ExecutionEngineWrapper(const ExecutionEngineWrapper& other) = delete;
41 
44 
45  ExecutionEngineWrapper& operator=(llvm::ExecutionEngine* execution_engine);
46 
47  llvm::ExecutionEngine* get() { return execution_engine_.get(); }
48  const llvm::ExecutionEngine* get() const { return execution_engine_.get(); }
49 
50  llvm::ExecutionEngine& operator*() { return *execution_engine_; }
51  const llvm::ExecutionEngine& operator*() const { return *execution_engine_; }
52 
53  llvm::ExecutionEngine* operator->() { return execution_engine_.get(); }
54  const llvm::ExecutionEngine* operator->() const { return execution_engine_.get(); }
55 
56  private:
57  std::unique_ptr<llvm::ExecutionEngine> execution_engine_;
58  std::unique_ptr<llvm::JITEventListener> intel_jit_listener_;
59 };
60 
62  public:
64  : execution_engine_(std::move(execution_engine)) {}
65 
66  void setFunctionPointer(llvm::Function* function) {
67  func_ = execution_engine_->getPointerToFunction(function);
68  CHECK(func_);
69  execution_engine_->removeModule(function->getParent());
70  }
71 
72  void* func() const { return func_; }
73 
74  using TableFunctionEntryPointPtr = int32_t (*)(const int8_t* mgr_ptr,
75  const int8_t** input_cols,
76  const int64_t* input_row_count,
77  const int8_t** input_str_dict_proxy_ptrs,
78  int64_t** out,
79  int8_t** output_str_dict_proxy_ptrs,
80  int64_t* output_row_count);
83  }
84 
85  private:
86  void* func_{nullptr};
88 };
CpuCompilationContext(ExecutionEngineWrapper &&execution_engine)
void setFunctionPointer(llvm::Function *function)
ExecutionEngineWrapper execution_engine_
ExecutionEngineWrapper & operator=(const ExecutionEngineWrapper &other)=delete
std::unique_ptr< llvm::JITEventListener > intel_jit_listener_
const llvm::ExecutionEngine & operator*() const
TableFunctionEntryPointPtr table_function_entry_point() const
llvm::ExecutionEngine * operator->()
const llvm::ExecutionEngine * operator->() const
std::unique_ptr< llvm::ExecutionEngine > execution_engine_
#define CHECK(condition)
Definition: Logger.h:222
llvm::ExecutionEngine & operator*()
int32_t(*)(const int8_t *mgr_ptr, const int8_t **input_cols, const int64_t *input_row_count, const int8_t **input_str_dict_proxy_ptrs, int64_t **out, int8_t **output_str_dict_proxy_ptrs, int64_t *output_row_count) TableFunctionEntryPointPtr