forked from greenplum-db/gpdb-archive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconst_expr_tree_generator.cc
62 lines (52 loc) · 1.87 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
53
54
55
56
57
58
59
60
61
62
//---------------------------------------------------------------------------
// Greenplum Database
// Copyright (C) 2016 Pivotal Software, Inc.
//
// @filename:
// const_expr_tree_generator.cc
//
// @doc:
// Object that generate code for const expression.
//
//---------------------------------------------------------------------------
#include <assert.h>
#include <memory>
#include "codegen/const_expr_tree_generator.h"
#include "codegen/expr_tree_generator.h"
#include "codegen/utils/gp_codegen_utils.h"
#include "llvm/IR/Constant.h"
extern "C" {
#include "postgres.h" // NOLINT(build/include)
#include "nodes/execnodes.h"
#include "nodes/nodes.h"
#include "nodes/primnodes.h"
}
namespace llvm {
class Value;
} // namespace llvm
using gpcodegen::ConstExprTreeGenerator;
using gpcodegen::ExprTreeGenerator;
bool ConstExprTreeGenerator::VerifyAndCreateExprTree(
const ExprState* expr_state,
ExprTreeGeneratorInfo* gen_info,
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(const ExprState* expr_state) :
ExprTreeGenerator(expr_state, ExprTreeNodeType::kConst) {
}
bool ConstExprTreeGenerator::GenerateCode(GpCodegenUtils* codegen_utils,
const ExprTreeGeneratorInfo& gen_info,
llvm::Value* llvm_isnull_ptr,
llvm::Value** llvm_out_value) {
assert(nullptr != llvm_out_value);
Const* const_expr = reinterpret_cast<Const*>(expr_state()->expr);
// const_expr->constvalue is a datum
*llvm_out_value = codegen_utils->GetConstant(const_expr->constvalue);
return true;
}