21 namespace spatial_type {
30 size_t size() const final {
return 1; }
35 auto*
const ptr_type = llvm::dyn_cast<llvm::PointerType>(arg_lv->getType());
37 return builder.CreateICmpEQ(arg_lv, llvm::ConstantPointerNull::get(ptr_type));
42 const std::vector<llvm::Value*>& arg_lvs,
43 const std::vector<llvm::Value*>& pos_lvs,
48 const auto& geo_ti = operand->get_type_info();
49 CHECK(geo_ti.is_geometry());
50 auto& builder = cgen_state->ir_builder_;
52 llvm::Value* array_buff_ptr{
nullptr};
54 if (arg_lvs.size() == 1) {
55 if (dynamic_cast<const Analyzer::GeoExpr*>(operand)) {
57 return std::make_tuple(arg_lvs,
is_null);
61 arg_lvs.front(), pos_lvs.front(), geo_ti, cgen_state);
62 array_buff_ptr = arr_load_lvs.
buffer;
67 if (dynamic_cast<const Analyzer::GeoOperator*>(operand)) {
68 if (geo_ti.get_type() ==
kPOINT && !geo_ti.is_variable_size()) {
70 is_null = cgen_state->emitCall(fname, {arg_lvs.front()});
80 array_buff_ptr = arg_lvs.front();
86 return std::make_tuple(std::vector<llvm::Value*>{array_buff_ptr},
is_null);
89 std::vector<llvm::Value*>
codegen(
const std::vector<llvm::Value*>&
args,
94 const auto array_buff_ptr =
args.front();
97 CHECK(geo_ti.is_geometry());
98 auto& builder = cgen_state->ir_builder_;
101 const std::string expr_name = is_x ?
"x" :
"y";
103 llvm::Value* coord_lv;
105 auto compressed_arr_ptr = builder.CreateBitCast(
106 array_buff_ptr, llvm::Type::getInt32PtrTy(cgen_state->context_));
107 auto coord_index = is_x ? cgen_state->llInt(0) : cgen_state->llInt(1);
108 auto coord_lv_ptr = builder.CreateGEP(
109 compressed_arr_ptr->getType()->getScalarType()->getPointerElementType(),
112 expr_name +
"_coord_ptr");
113 auto compressed_coord_lv =
114 builder.CreateLoad(coord_lv_ptr->getType()->getPointerElementType(),
116 expr_name +
"_coord_compressed");
119 cgen_state->emitExternalCall(
"decompress_" + expr_name +
"_coord_geoint",
120 llvm::Type::getDoubleTy(cgen_state->context_),
121 {compressed_coord_lv});
123 auto coord_arr_ptr = builder.CreateBitCast(
124 array_buff_ptr, llvm::Type::getDoublePtrTy(cgen_state->context_));
125 auto coord_index = is_x ? cgen_state->llInt(0) : cgen_state->llInt(1);
126 auto coord_lv_ptr = builder.CreateGEP(
127 coord_arr_ptr->getType()->getScalarType()->getPointerElementType(),
130 expr_name +
"_coord_ptr");
131 coord_lv = builder.CreateLoad(coord_lv_ptr->getType()->getPointerElementType(),
133 expr_name +
"_coord");
138 CHECK(nullcheck_codegen);
143 CHECK(cgen_state->geo_target_cache_.insert(std::make_pair(key, ret)).second);
PointAccessors(const Analyzer::GeoOperator *geo_operator)
size_t size() const final
llvm::Value * codegenCmpEqNullptr(llvm::IRBuilder<> &builder, llvm::Value *arg_lv)
static char const * pointIsNullFunctionName(SQLTypeInfo const &)
CONSTEXPR DEVICE bool is_null(const T &value)
const std::string & getName() 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
SQLTypeInfo getNullType() const final
const SQLTypeInfo & get_type_info() const
static ArrayLoadCodegen codegenGeoArrayLoadAndNullcheck(llvm::Value *byte_stream, llvm::Value *pos, const SQLTypeInfo &ti, CgenState *cgen_state)
const Analyzer::GeoOperator * operator_
std::vector< llvm::Value * > codegen(const std::vector< llvm::Value * > &args, CodeGenerator::NullCheckCodegen *nullcheck_codegen, CgenState *cgen_state, const CompilationOptions &co) final
virtual const Analyzer::Expr * getOperand(const size_t index)
std::string toString() const override