23 namespace spatial_type {
30 :
Codegen(geo_operator, catalog) {
33 if (ti.get_notnull()) {
43 Executor* executor)
final {
47 auto nullcheck_codegen = std::make_unique<CodeGenerator::NullCheckCodegen>(
50 auto& builder = cgen_state->ir_builder_;
53 auto prev_insert_block = builder.GetInsertBlock();
54 auto crt_insert_block = nullcheck_codegen->null_check->cond_true_;
55 CHECK(crt_insert_block);
56 auto& instruction_list = crt_insert_block->getInstList();
57 CHECK_EQ(instruction_list.size(), size_t(1));
58 builder.SetInsertPoint(crt_insert_block, instruction_list.begin());
60 auto x_coord_ptr = builder.CreateGEP(
63 {cgen_state->llInt(0), cgen_state->llInt(0)},
74 builder.SetInsertPoint(prev_insert_block);
76 return nullcheck_codegen;
82 size_t size() const final {
return 2; }
88 const std::vector<llvm::Value*>& arg_lvs,
89 const std::vector<llvm::Value*>& pos_lvs,
97 auto& builder = cgen_state->ir_builder_;
101 const auto& x_ti = x_operand->get_type_info();
102 if (!x_ti.get_notnull()) {
103 CHECK(x_ti.is_integer() || x_ti.is_fp());
106 ? builder.CreateICmp(llvm::CmpInst::ICMP_EQ,
109 : builder.CreateFCmp(llvm::FCmpInst::FCMP_OEQ,
115 const auto& y_ti = y_operand->get_type_info();
116 if (!y_ti.get_notnull()) {
119 ? builder.CreateICmp(llvm::CmpInst::ICMP_EQ,
122 : builder.CreateFCmp(llvm::FCmpInst::FCMP_OEQ,
143 llvm::ArrayType* arr_type{
nullptr};
145 auto elem_ty = llvm::Type::getInt32Ty(cgen_state->context_);
146 arr_type = llvm::ArrayType::get(elem_ty, 2);
149 auto elem_ty = llvm::Type::getDoubleTy(cgen_state->context_);
150 arr_type = llvm::ArrayType::get(elem_ty, 2);
153 builder.CreateAlloca(arr_type,
nullptr,
operator_->
getName() +
"_Local_Storage");
155 return std::make_tuple(arg_lvs,
is_null);
158 std::vector<llvm::Value*>
codegen(
const std::vector<llvm::Value*>&
args,
167 auto& builder = cgen_state->ir_builder_;
173 auto x_coord_ptr = builder.CreateGEP(
176 {cgen_state->llInt(0), cgen_state->llInt(0)},
180 cgen_state->emitExternalCall(
"compress_x_coord_geoint",
181 llvm::Type::getInt32Ty(cgen_state->context_),
183 builder.CreateStore(compressed_lv, x_coord_ptr);
185 builder.CreateStore(
args.front(), x_coord_ptr);
189 auto y_coord_ptr = builder.CreateGEP(
192 {cgen_state->llInt(0), cgen_state->llInt(1)},
196 cgen_state->emitExternalCall(
"compress_y_coord_geoint",
197 llvm::Type::getInt32Ty(cgen_state->context_),
199 builder.CreateStore(compressed_lv, y_coord_ptr);
201 builder.CreateStore(
args.back(), y_coord_ptr);
204 llvm::Value* ret = pt_local_storage_lv_;
206 CHECK(nullcheck_codegen);
207 ret = nullcheck_codegen->finalize(ret, ret);
209 return {builder.CreateBitCast(ret,
211 ? llvm::Type::getInt32PtrTy(cgen_state->context_)
212 : llvm::
Type::getDoublePtrTy(cgen_state->context_)),
213 cgen_state->llInt(static_cast<int32_t>(
218 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
class for a per-database catalog. also includes metadata for the current database and the current use...
SQLTypeInfo getNullType() const final
PointConstructor(const Analyzer::GeoOperator *geo_operator, const Catalog_Namespace::Catalog *catalog)
double inline_fp_null_val(const SQL_TYPE_INFO &ti)
CONSTEXPR DEVICE bool is_null(const T &value)
const std::string & getName() 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
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