提交 5996aaa7 编写于 作者: S Shreedhar Hardikar

Keep a reference to the CodegenManager in code generators

上级 c1a94208
......@@ -130,7 +130,7 @@ ClassType* CodegenEnroll(FuncType regular_func_ptr,
}
ClassType* generator = new ClassType(
regular_func_ptr, ptr_to_chosen_func_ptr, std::forward<Args>(args)...);
manager, regular_func_ptr, ptr_to_chosen_func_ptr, std::forward<Args>(args)...);
bool is_enrolled = manager->EnrollCodeGenerator(
CodegenFuncLifespan_Parameter_Invariant, generator);
assert(is_enrolled);
......
......@@ -48,18 +48,19 @@ using gpcodegen::SlotGetAttrCodegen;
constexpr char ExecEvalExprCodegen::kExecEvalExprPrefix[];
ExecEvalExprCodegen::ExecEvalExprCodegen
(
ExecEvalExprCodegen::ExecEvalExprCodegen(
CodegenManager* manager,
ExecEvalExprFn regular_func_ptr,
ExecEvalExprFn* ptr_to_regular_func_ptr,
ExprState *exprstate,
ExprContext *econtext,
PlanState* plan_state) :
BaseCodegen(kExecEvalExprPrefix,
regular_func_ptr, ptr_to_regular_func_ptr),
exprstate_(exprstate),
econtext_(econtext),
plan_state_(plan_state) {
PlanState* plan_state)
: BaseCodegen(manager,
kExecEvalExprPrefix,
regular_func_ptr, ptr_to_regular_func_ptr),
exprstate_(exprstate),
econtext_(econtext),
plan_state_(plan_state) {
}
void ExecEvalExprCodegen::PrepareSlotGetAttr(
......
......@@ -51,17 +51,18 @@ using gpcodegen::SlotGetAttrCodegen;
constexpr char ExecVariableListCodegen::kExecVariableListPrefix[];
ExecVariableListCodegen::ExecVariableListCodegen
(
ExecVariableListCodegen::ExecVariableListCodegen(
CodegenManager* manager,
ExecVariableListFn regular_func_ptr,
ExecVariableListFn* ptr_to_regular_func_ptr,
ProjectionInfo* proj_info,
TupleTableSlot* slot) :
BaseCodegen(kExecVariableListPrefix,
regular_func_ptr,
ptr_to_regular_func_ptr),
proj_info_(proj_info),
slot_(slot) {
TupleTableSlot* slot)
: BaseCodegen(manager,
kExecVariableListPrefix,
regular_func_ptr,
ptr_to_regular_func_ptr),
proj_info_(proj_info),
slot_(slot) {
}
......
......@@ -19,6 +19,7 @@ extern "C" {
#include <string>
#include <vector>
#include "codegen/utils/gp_codegen_utils.h"
#include "codegen/codegen_manager.h"
#include "codegen/codegen_interface.h"
#include "llvm/IR/Function.h"
......@@ -127,6 +128,10 @@ class BaseCodegen: public CodegenInterface {
return regular_func_ptr_;
}
gpcodegen::CodegenManager* manager() const {
return manager;
}
/**
* @brief Sets up the caller to use the corresponding regular version of the
* target function.
......@@ -148,6 +153,7 @@ class BaseCodegen: public CodegenInterface {
/**
* @brief Constructor
*
* @param manager The manager in which this is enrolled.
* @param orig_func_name Original function name.
* @param regular_func_ptr Regular version of the target function.
* @param ptr_to_chosen_func_ptr Reference to the function pointer that the caller will call.
......@@ -156,14 +162,16 @@ class BaseCodegen: public CodegenInterface {
* corresponding regular version.
*
**/
explicit BaseCodegen(const std::string& orig_func_name,
explicit BaseCodegen(gpcodegen::CodegenManager* manager,
const std::string& orig_func_name,
FuncPtrType regular_func_ptr,
FuncPtrType* ptr_to_chosen_func_ptr)
: orig_func_name_(orig_func_name),
unique_func_name_(CodegenInterface::GenerateUniqueName(orig_func_name)),
regular_func_ptr_(regular_func_ptr),
ptr_to_chosen_func_ptr_(ptr_to_chosen_func_ptr),
is_generated_(false) {
is_generated_(false),
manager_(manager) {
// Initialize the caller to use regular version of target function.
SetToRegular(regular_func_ptr, ptr_to_chosen_func_ptr);
}
......@@ -214,6 +222,7 @@ class BaseCodegen: public CodegenInterface {
FuncPtrType regular_func_ptr_;
FuncPtrType* ptr_to_chosen_func_ptr_;
bool is_generated_;
gpcodegen::CodegenManager* manager_;
// To track uncompiled llvm functions it creates and erase from
// llvm module on failed generations.
std::vector<llvm::Function*> uncompiled_generated_functions_;
......
......@@ -39,7 +39,8 @@ class ExecEvalExprCodegen: public BaseCodegen<ExecEvalExprFn> {
* function or the corresponding regular version.
*
**/
explicit ExecEvalExprCodegen(ExecEvalExprFn regular_func_ptr,
explicit ExecEvalExprCodegen(CodegenManager* manager,
ExecEvalExprFn regular_func_ptr,
ExecEvalExprFn* ptr_to_regular_func_ptr,
ExprState *exprstate,
ExprContext *econtext,
......
......@@ -35,7 +35,8 @@ class ExecVariableListCodegen: public BaseCodegen<ExecVariableListFn> {
* corresponding regular version.
*
**/
explicit ExecVariableListCodegen(ExecVariableListFn regular_func_ptr,
explicit ExecVariableListCodegen(CodegenManager* manager,
ExecVariableListFn regular_func_ptr,
ExecVariableListFn* ptr_to_regular_func_ptr,
ProjectionInfo* proj_info,
TupleTableSlot* slot);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册