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,
99 x_is_null && y_is_null ? cgen_state->ir_builder_.CreateOr(x_is_null, y_is_null)
100 : std::max(x_is_null, y_is_null);
112 llvm::ArrayType* arr_type{
nullptr};
114 auto elem_ty = llvm::Type::getInt32Ty(cgen_state->context_);
115 arr_type = llvm::ArrayType::get(elem_ty, 2);
118 auto elem_ty = llvm::Type::getDoubleTy(cgen_state->context_);
119 arr_type = llvm::ArrayType::get(elem_ty, 2);
124 return std::make_tuple(arg_lvs, is_null);
127 std::vector<llvm::Value*>
codegen(
const std::vector<llvm::Value*>&
args,
136 auto& builder = cgen_state->ir_builder_;
142 auto x_coord_ptr = builder.CreateGEP(
145 {cgen_state->llInt(0), cgen_state->llInt(0)},
149 cgen_state->emitExternalCall(
"compress_x_coord_geoint",
150 llvm::Type::getInt32Ty(cgen_state->context_),
152 builder.CreateStore(compressed_lv, x_coord_ptr);
154 builder.CreateStore(
args.front(), x_coord_ptr);
158 auto y_coord_ptr = builder.CreateGEP(
161 {cgen_state->llInt(0), cgen_state->llInt(1)},
165 cgen_state->emitExternalCall(
"compress_y_coord_geoint",
166 llvm::Type::getInt32Ty(cgen_state->context_),
168 builder.CreateStore(compressed_lv, y_coord_ptr);
170 builder.CreateStore(
args.back(), y_coord_ptr);
173 llvm::Value* ret = pt_local_storage_lv_;
175 CHECK(nullcheck_codegen);
176 ret = nullcheck_codegen->finalize(ret, ret);
178 return {builder.CreateBitCast(ret,
180 ? llvm::Type::getInt32PtrTy(cgen_state->context_)
181 : llvm::
Type::getDoublePtrTy(cgen_state->context_)),
182 cgen_state->llInt(static_cast<int32_t>(
190 auto const& ti = getOperand(idx)->get_type_info();
191 if (ti.get_notnull()) {
193 }
else if (ti.is_integer()) {
196 }
else if (ti.is_fp()) {
200 UNREACHABLE() <<
"Type is expected to be integer or floating point.";
205 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
llvm::Value * codegenOperandIsNull(size_t idx, llvm::Value *value, CgenState *cgen_state)
llvm::IRBuilder ir_builder_
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)
llvm::ConstantFP * llFp(const float v) const
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
llvm::ConstantInt * llInt(const T v) const
size_t size() const final
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