forked from greenplum-db/gpdb-archive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconst_expr_tree_generator.cc
52 lines (45 loc) · 1.74 KB
/
const_expr_tree_generator.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//---------------------------------------------------------------------------
// Greenplum Database
// Copyright (C) 2016 Pivotal Software, Inc.
//
// @filename:
// const_expr_tree_generator.cc
//
// @doc:
// Object that generate code for const expression.
//
//---------------------------------------------------------------------------
#include "codegen/expr_tree_generator.h"
#include "codegen/const_expr_tree_generator.h"
#include "llvm/IR/Value.h"
extern "C" {
#include "postgres.h" // NOLINT(build/include)
#include "nodes/execnodes.h"
}
using gpcodegen::ConstExprTreeGenerator;
using gpcodegen::ExprTreeGenerator;
bool ConstExprTreeGenerator::VerifyAndCreateExprTree(
ExprState* expr_state,
ExprContext* econtext,
std::unique_ptr<ExprTreeGenerator>* expr_tree) {
assert(nullptr != expr_state &&
nullptr != expr_state->expr &&
T_Const == nodeTag(expr_state->expr) &&
nullptr != expr_tree);
expr_tree->reset(new ConstExprTreeGenerator(expr_state));
return true;
}
ConstExprTreeGenerator::ConstExprTreeGenerator(ExprState* expr_state) :
ExprTreeGenerator(expr_state, ExprTreeNodeType::kConst) {
}
bool ConstExprTreeGenerator::GenerateCode(CodegenUtils* codegen_utils,
ExprContext* econtext,
llvm::Function* llvm_main_func,
llvm::BasicBlock* llvm_error_block,
llvm::Value* llvm_isnull_arg,
llvm::Value** llvm_out_value) {
assert(nullptr != llvm_out_value);
Const* const_expr = reinterpret_cast<Const*>(expr_state()->expr);
*llvm_out_value = codegen_utils->GetConstant(const_expr->constvalue);
return true;
}