23 namespace spatial_type {
31 if (ti.get_notnull()) {
41 Executor* executor)
final {
45 auto nullcheck_codegen = std::make_unique<CodeGenerator::NullCheckCodegen>(
48 auto& builder = cgen_state->ir_builder_;
51 auto prev_insert_block = builder.GetInsertBlock();
52 auto crt_insert_block = nullcheck_codegen->null_check->cond_true_;
53 CHECK(crt_insert_block);
54 auto& instruction_list = crt_insert_block->getInstList();
55 CHECK_EQ(instruction_list.size(), size_t(1));
56 builder.SetInsertPoint(crt_insert_block, instruction_list.begin());
58 auto x_coord_ptr = builder.CreateGEP(
61 {cgen_state->llInt(0), cgen_state->llInt(0)},
72 builder.SetInsertPoint(prev_insert_block);
74 return nullcheck_codegen;
80 size_t size() const final {
return 2; }
86 const std::vector<llvm::Value*>& arg_lvs,
87 const std::vector<llvm::Value*>& pos_lvs,
95 auto& builder = cgen_state->ir_builder_;
99 const auto& x_ti = x_operand->get_type_info();
100 if (!x_ti.get_notnull()) {
101 CHECK(x_ti.is_integer() || x_ti.is_fp());
104 ? builder.CreateICmp(llvm::CmpInst::ICMP_EQ,
107 : builder.CreateFCmp(llvm::FCmpInst::FCMP_OEQ,
113 const auto& y_ti = y_operand->get_type_info();
114 if (!y_ti.get_notnull()) {
117 ? builder.CreateICmp(llvm::CmpInst::ICMP_EQ,
120 : builder.CreateFCmp(llvm::FCmpInst::FCMP_OEQ,
141 llvm::ArrayType* arr_type{
nullptr};
143 auto elem_ty = llvm::Type::getInt32Ty(cgen_state->context_);
144 arr_type = llvm::ArrayType::get(elem_ty, 2);
147 auto elem_ty = llvm::Type::getDoubleTy(cgen_state->context_);
148 arr_type = llvm::ArrayType::get(elem_ty, 2);
151 builder.CreateAlloca(arr_type,
nullptr,
operator_->
getName() +
"_Local_Storage");
153 return std::make_tuple(arg_lvs,
is_null);
156 std::vector<llvm::Value*>
codegen(
const std::vector<llvm::Value*>&
args,
165 auto& builder = cgen_state->ir_builder_;
171 auto x_coord_ptr = builder.CreateGEP(
174 {cgen_state->llInt(0), cgen_state->llInt(0)},
178 cgen_state->emitExternalCall(
"compress_x_coord_geoint",
179 llvm::Type::getInt32Ty(cgen_state->context_),
181 builder.CreateStore(compressed_lv, x_coord_ptr);
183 builder.CreateStore(
args.front(), x_coord_ptr);
187 auto y_coord_ptr = builder.CreateGEP(
190 {cgen_state->llInt(0), cgen_state->llInt(1)},
194 cgen_state->emitExternalCall(
"compress_y_coord_geoint",
195 llvm::Type::getInt32Ty(cgen_state->context_),
197 builder.CreateStore(compressed_lv, y_coord_ptr);
199 builder.CreateStore(
args.back(), y_coord_ptr);
202 llvm::Value* ret = pt_local_storage_lv_;
204 CHECK(nullcheck_codegen);
205 ret = nullcheck_codegen->finalize(ret, ret);
207 return {builder.CreateBitCast(ret,
209 ? llvm::Type::getInt32PtrTy(cgen_state->context_)
210 : llvm::
Type::getDoublePtrTy(cgen_state->context_)),
211 cgen_state->llInt(static_cast<int32_t>(
216 llvm::AllocaInst* pt_local_storage_lv_{
nullptr};
std::vector< llvm::Value * > codegen(const std::vector< llvm::Value * > &args, CodeGenerator::NullCheckCodegen *nullcheck_codegen, CgenState *cgen_state, const CompilationOptions &co) final
SQLTypeInfo getNullType() const final
double inline_fp_null_val(const SQL_TYPE_INFO &ti)
CONSTEXPR DEVICE bool is_null(const T &value)
const std::string & getName() const
PointConstructor(const Analyzer::GeoOperator *geo_operator)
const SQLTypeInfo & get_type_info() const
std::tuple< std::vector< llvm::Value * >, llvm::Value * > codegenLoads(const std::vector< llvm::Value * > &arg_lvs, const std::vector< llvm::Value * > &pos_lvs, CgenState *cgen_state) final
llvm::AllocaInst * pt_local_storage_lv_
const Analyzer::GeoOperator * operator_
#define NULL_ARRAY_DOUBLE
size_t size() const final
virtual const Analyzer::Expr * getOperand(const size_t index)
int64_t inline_int_null_val(const SQL_TYPE_INFO &ti)
std::string getName() const
std::unique_ptr< CodeGenerator::NullCheckCodegen > getNullCheckCodegen(llvm::Value *null_lv, CgenState *cgen_state, Executor *executor) final