OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
spatial_type::PointAccessors Class Reference

#include <PointAccessors.h>

+ Inheritance diagram for spatial_type::PointAccessors:
+ Collaboration diagram for spatial_type::PointAccessors:

Public Member Functions

 PointAccessors (const Analyzer::GeoOperator *geo_operator)
 
size_t size () const final
 
SQLTypeInfo getNullType () const final
 
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
 
std::vector< llvm::Value * > codegen (const std::vector< llvm::Value * > &args, CodeGenerator::NullCheckCodegen *nullcheck_codegen, CgenState *cgen_state, const CompilationOptions &co) final
 
- Public Member Functions inherited from spatial_type::Codegen
 Codegen (const Analyzer::GeoOperator *geo_operator)
 
auto isNullable () const
 
auto getTypeInfo () const
 
std::string getName () const
 
virtual std::unique_ptr
< CodeGenerator::NullCheckCodegen
getNullCheckCodegen (llvm::Value *null_lv, CgenState *cgen_state, Executor *executor)
 
virtual const Analyzer::ExprgetOperand (const size_t index)
 
virtual ~Codegen ()
 

Additional Inherited Members

- Static Public Member Functions inherited from spatial_type::Codegen
static std::unique_ptr< Codegeninit (const Analyzer::GeoOperator *geo_operator)
 
- Protected Attributes inherited from spatial_type::Codegen
const Analyzer::GeoOperatoroperator_
 
bool is_nullable_ {true}
 

Detailed Description

Definition at line 24 of file PointAccessors.h.

Constructor & Destructor Documentation

spatial_type::PointAccessors::PointAccessors ( const Analyzer::GeoOperator geo_operator)
inline

Definition at line 26 of file PointAccessors.h.

References CHECK_EQ, spatial_type::Codegen::operator_, and Analyzer::GeoOperator::size().

26  : Codegen(geo_operator) {
27  CHECK_EQ(operator_->size(), size_t(1));
28  }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
const Analyzer::GeoOperator * operator_
Definition: Codegen.h:67
size_t size() const
Definition: Analyzer.cpp:4182
Codegen(const Analyzer::GeoOperator *geo_operator)
Definition: Codegen.h:28

+ Here is the call graph for this function:

Member Function Documentation

std::vector<llvm::Value*> spatial_type::PointAccessors::codegen ( const std::vector< llvm::Value * > &  args,
CodeGenerator::NullCheckCodegen nullcheck_codegen,
CgenState cgen_state,
const CompilationOptions co 
)
inlinefinalvirtual

Implements spatial_type::Codegen.

Definition at line 88 of file PointAccessors.h.

References run_benchmark_import::args, CHECK, CHECK_EQ, Analyzer::Expr::get_type_info(), Analyzer::GeoOperator::getName(), spatial_type::Codegen::getOperand(), kENCODING_GEOINT, and spatial_type::Codegen::operator_.

91  {
92  CHECK_EQ(args.size(), size_t(1));
93  const auto array_buff_ptr = args.front();
94 
95  const auto& geo_ti = getOperand(0)->get_type_info();
96  CHECK(geo_ti.is_geometry());
97  auto& builder = cgen_state->ir_builder_;
98 
99  const bool is_x = operator_->getName() == "ST_X";
100  const std::string expr_name = is_x ? "x" : "y";
101 
102  llvm::Value* coord_lv;
103  if (geo_ti.get_compression() == kENCODING_GEOINT) {
104  auto compressed_arr_ptr = builder.CreateBitCast(
105  array_buff_ptr, llvm::Type::getInt32PtrTy(cgen_state->context_));
106  auto coord_index = is_x ? cgen_state->llInt(0) : cgen_state->llInt(1);
107  auto coord_lv_ptr = builder.CreateGEP(
108  compressed_arr_ptr->getType()->getScalarType()->getPointerElementType(),
109  compressed_arr_ptr,
110  coord_index,
111  expr_name + "_coord_ptr");
112  auto compressed_coord_lv =
113  builder.CreateLoad(coord_lv_ptr->getType()->getPointerElementType(),
114  coord_lv_ptr,
115  expr_name + "_coord_compressed");
116 
117  coord_lv =
118  cgen_state->emitExternalCall("decompress_" + expr_name + "_coord_geoint",
119  llvm::Type::getDoubleTy(cgen_state->context_),
120  {compressed_coord_lv});
121  } else {
122  auto coord_arr_ptr = builder.CreateBitCast(
123  array_buff_ptr, llvm::Type::getDoublePtrTy(cgen_state->context_));
124  auto coord_index = is_x ? cgen_state->llInt(0) : cgen_state->llInt(1);
125  auto coord_lv_ptr = builder.CreateGEP(
126  coord_arr_ptr->getType()->getScalarType()->getPointerElementType(),
127  coord_arr_ptr,
128  coord_index,
129  expr_name + "_coord_ptr");
130  coord_lv = builder.CreateLoad(coord_lv_ptr->getType()->getPointerElementType(),
131  coord_lv_ptr,
132  expr_name + "_coord");
133  }
134 
135  auto ret = coord_lv;
136  if (is_nullable_) {
137  CHECK(nullcheck_codegen);
138  ret = nullcheck_codegen->finalize(cgen_state->inlineFpNull(SQLTypeInfo(kDOUBLE)),
139  ret);
140  }
141  const auto key = operator_->toString();
142  CHECK(cgen_state->geo_target_cache_.insert(std::make_pair(key, ret)).second);
143  return {ret};
144  }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
llvm::IRBuilder ir_builder_
Definition: CgenState.h:384
std::unordered_map< std::string, llvm::Value * > geo_target_cache_
Definition: CgenState.h:404
llvm::LLVMContext & context_
Definition: CgenState.h:382
llvm::Value * emitExternalCall(const std::string &fname, llvm::Type *ret_type, const std::vector< llvm::Value * > args, const std::vector< llvm::Attribute::AttrKind > &fnattrs={}, const bool has_struct_return=false)
Definition: CgenState.cpp:395
const std::string & getName() const
Definition: Analyzer.h:3167
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:79
const Analyzer::GeoOperator * operator_
Definition: Codegen.h:67
llvm::ConstantInt * llInt(const T v) const
Definition: CgenState.h:249
llvm::Value * finalize(llvm::Value *null_lv, llvm::Value *notnull_lv)
Definition: IRCodegen.cpp:1529
#define CHECK(condition)
Definition: Logger.h:291
virtual const Analyzer::Expr * getOperand(const size_t index)
Definition: Codegen.cpp:64
std::string toString() const override
Definition: Analyzer.cpp:4154
llvm::ConstantFP * inlineFpNull(const SQLTypeInfo &)
Definition: CgenState.cpp:104

+ Here is the call graph for this function:

std::tuple<std::vector<llvm::Value*>, llvm::Value*> spatial_type::PointAccessors::codegenLoads ( const std::vector< llvm::Value * > &  arg_lvs,
const std::vector< llvm::Value * > &  pos_lvs,
CgenState cgen_state 
)
inlinefinalvirtual

Implements spatial_type::Codegen.

Definition at line 35 of file PointAccessors.h.

References ArrayLoadCodegen::buffer, CHECK, CHECK_EQ, CodeGenerator::codegenGeoArrayLoadAndNullcheck(), spatial_type::Codegen::getOperand(), is_null(), spatial_type::Codegen::is_nullable_, kENCODING_GEOINT, spatial_type::Codegen::operator_, size(), and Analyzer::GeoOperator::toString().

38  {
39  CHECK_EQ(pos_lvs.size(), size());
40  auto operand = getOperand(0);
41  CHECK(operand);
42  const auto& geo_ti = operand->get_type_info();
43  CHECK(geo_ti.is_geometry());
44  auto& builder = cgen_state->ir_builder_;
45 
46  llvm::Value* array_buff_ptr{nullptr};
47  llvm::Value* is_null{nullptr};
48  if (arg_lvs.size() == 1) {
49  if (dynamic_cast<const Analyzer::GeoExpr*>(operand)) {
50  const auto ptr_type =
51  llvm::dyn_cast<llvm::PointerType>(arg_lvs.front()->getType());
52  CHECK(ptr_type);
53  const auto is_null_lv =
54  builder.CreateICmp(llvm::CmpInst::ICMP_EQ,
55  arg_lvs.front(),
56  llvm::ConstantPointerNull::get(ptr_type));
57  return std::make_tuple(arg_lvs, is_null_lv);
58  }
59  // col byte stream, get the array buffer ptr and is null attributes and cache
61  arg_lvs.front(), pos_lvs.front(), geo_ti, cgen_state);
62  array_buff_ptr = arr_load_lvs.buffer;
63  is_null = arr_load_lvs.is_null;
64  } else {
65  // ptr and size
66  CHECK_EQ(arg_lvs.size(), size_t(2));
67  if (dynamic_cast<const Analyzer::GeoOperator*>(operand)) {
68  // null check will be if the ptr is a nullptr
69  is_null = builder.CreateICmp(
70  llvm::CmpInst::ICMP_EQ,
71  arg_lvs.front(),
72  llvm::ConstantPointerNull::get( // TODO: check ptr address space
73  geo_ti.get_compression() == kENCODING_GEOINT
74  ? llvm::Type::getInt32PtrTy(cgen_state->context_)
75  : llvm::Type::getDoublePtrTy(cgen_state->context_)));
76  }
77 
78  // TODO: nulls from other types not yet supported
79  array_buff_ptr = arg_lvs.front();
80  }
81  CHECK(array_buff_ptr) << operator_->toString();
82  if (!is_null) {
83  is_nullable_ = false;
84  }
85  return std::make_tuple(std::vector<llvm::Value*>{array_buff_ptr}, is_null);
86  }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
size_t size() const final
llvm::IRBuilder ir_builder_
Definition: CgenState.h:384
llvm::Value * buffer
Definition: CgenState.h:36
llvm::LLVMContext & context_
Definition: CgenState.h:382
CONSTEXPR DEVICE bool is_null(const T &value)
static ArrayLoadCodegen codegenGeoArrayLoadAndNullcheck(llvm::Value *byte_stream, llvm::Value *pos, const SQLTypeInfo &ti, CgenState *cgen_state)
Definition: GeoIR.cpp:23
const Analyzer::GeoOperator * operator_
Definition: Codegen.h:67
#define CHECK(condition)
Definition: Logger.h:291
virtual const Analyzer::Expr * getOperand(const size_t index)
Definition: Codegen.cpp:64
std::string toString() const override
Definition: Analyzer.cpp:4154

+ Here is the call graph for this function:

SQLTypeInfo spatial_type::PointAccessors::getNullType ( ) const
inlinefinalvirtual

Implements spatial_type::Codegen.

Definition at line 32 of file PointAccessors.h.

References kBOOLEAN.

32 { return SQLTypeInfo(kBOOLEAN); }
size_t spatial_type::PointAccessors::size ( ) const
inlinefinalvirtual

Implements spatial_type::Codegen.

Definition at line 30 of file PointAccessors.h.

Referenced by codegenLoads().

30 { return 1; }

+ Here is the caller graph for this function:


The documentation for this class was generated from the following file: