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

#include <NRings.h>

+ Inheritance diagram for spatial_type::NRings:
+ Collaboration diagram for spatial_type::NRings:

Public Member Functions

 NRings (const Analyzer::GeoOperator *geo_operator)
 
size_t size () const final
 
SQLTypeInfo getNullType () const final
 
const Analyzer::ExprgetOperand (const size_t index) 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 ~Codegen ()
 

Protected Attributes

std::unique_ptr
< Analyzer::ColumnVar
operand_owned_
 
- Protected Attributes inherited from spatial_type::Codegen
const Analyzer::GeoOperatoroperator_
 
bool is_nullable_ {true}
 

Additional Inherited Members

- Static Public Member Functions inherited from spatial_type::Codegen
static std::unique_ptr< Codegeninit (const Analyzer::GeoOperator *geo_operator)
 

Detailed Description

Definition at line 23 of file NRings.h.

Constructor & Destructor Documentation

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

Definition at line 25 of file NRings.h.

25 : Codegen(geo_operator) {}
Codegen(const Analyzer::GeoOperator *geo_operator)
Definition: Codegen.h:28

Member Function Documentation

std::vector<llvm::Value*> spatial_type::NRings::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 84 of file NRings.h.

References run_benchmark_import::args, CHECK, CHECK_EQ, spatial_type::Codegen::getTypeInfo(), and spatial_type::Codegen::isNullable().

87  {
88  CHECK_EQ(args.size(), size_t(1));
89  if (isNullable()) {
90  CHECK(nullcheck_codegen);
91  return {nullcheck_codegen->finalize(cgen_state->inlineIntNull(getTypeInfo()),
92  args.front())};
93  }
94  return {args.front()};
95  }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
auto getTypeInfo() const
Definition: Codegen.h:34
llvm::ConstantInt * inlineIntNull(const SQLTypeInfo &)
Definition: CgenState.cpp:65
auto isNullable() const
Definition: Codegen.h:32
llvm::Value * finalize(llvm::Value *null_lv, llvm::Value *notnull_lv)
Definition: IRCodegen.cpp:1529
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

std::tuple<std::vector<llvm::Value*>, llvm::Value*> spatial_type::NRings::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 57 of file NRings.h.

References CHECK_EQ, SQLTypeInfo::get_elem_type(), get_int_type(), Analyzer::Expr::get_type_info(), getOperand(), spatial_type::Codegen::getTypeInfo(), spatial_type::Codegen::isNullable(), log2_bytes(), and size().

60  {
61  CHECK_EQ(pos_lvs.size(), size());
62  CHECK_EQ(arg_lvs.size(), size_t(1));
63  auto& argument_lv = arg_lvs.front();
64  std::string fn_name("array_size");
65 
66  const auto& elem_ti = getOperand(0)->get_type_info().get_elem_type();
67  std::vector<llvm::Value*> array_size_args{
68  argument_lv,
69  pos_lvs.front(),
70  cgen_state->llInt(log2_bytes(elem_ti.get_logical_size()))};
71 
72  const bool is_nullable = isNullable();
73 
74  if (is_nullable) {
75  fn_name += "_nullable";
76  array_size_args.push_back(cgen_state->inlineIntNull(getTypeInfo()));
77  }
78  const auto total_num_rings_lv = cgen_state->emitExternalCall(
79  fn_name, get_int_type(32, cgen_state->context_), array_size_args);
80  return std::make_tuple(std::vector<llvm::Value*>{total_num_rings_lv},
81  total_num_rings_lv);
82  }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
llvm::Type * get_int_type(const int width, llvm::LLVMContext &context)
auto getTypeInfo() const
Definition: Codegen.h:34
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
llvm::ConstantInt * inlineIntNull(const SQLTypeInfo &)
Definition: CgenState.cpp:65
size_t size() const final
Definition: NRings.h:27
auto isNullable() const
Definition: Codegen.h:32
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:79
llvm::ConstantInt * llInt(const T v) const
Definition: CgenState.h:249
const Analyzer::Expr * getOperand(const size_t index) final
Definition: NRings.h:31
uint32_t log2_bytes(const uint32_t bytes)
Definition: Execute.h:198
SQLTypeInfo get_elem_type() const
Definition: sqltypes.h:975

+ Here is the call graph for this function:

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

Implements spatial_type::Codegen.

Definition at line 29 of file NRings.h.

References kINT.

29 { return SQLTypeInfo(kINT); }
Definition: sqltypes.h:72
const Analyzer::Expr* spatial_type::NRings::getOperand ( const size_t  index)
inlinefinalvirtual

Reimplemented from spatial_type::Codegen.

Definition at line 31 of file NRings.h.

References CHECK, CHECK_EQ, get_column_descriptor(), Analyzer::GeoOperator::getOperand(), spatial_type::Codegen::is_nullable_, operand_owned_, and spatial_type::Codegen::operator_.

Referenced by codegenLoads().

31  {
32  CHECK_EQ(index, size_t(0));
33  if (operand_owned_) {
34  return operand_owned_.get();
35  }
36 
37  const auto operand = operator_->getOperand(0);
38  auto col_var = dynamic_cast<const Analyzer::ColumnVar*>(operand);
39  CHECK(col_var);
40 
41  const auto& geo_ti = col_var->get_type_info();
42  CHECK(geo_ti.is_geometry());
43  is_nullable_ = !geo_ti.get_notnull();
44 
45  // create a new operand which is just the ring sizes and codegen it
46  auto column_key = col_var->getColumnKey();
47  column_key.column_id = column_key.column_id + 2; // + 2 for ring sizes
48  const auto ring_sizes_cd = get_column_descriptor(column_key);
49  CHECK(ring_sizes_cd);
50 
51  operand_owned_ = std::make_unique<Analyzer::ColumnVar>(
52  ring_sizes_cd->columnType, column_key, col_var->get_rte_idx());
53  return operand_owned_.get();
54  }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
const ColumnDescriptor * get_column_descriptor(const shared::ColumnKey &column_key)
Definition: Execute.h:213
const Analyzer::GeoOperator * operator_
Definition: Codegen.h:67
#define CHECK(condition)
Definition: Logger.h:291
Analyzer::Expr * getOperand(const size_t index) const
Definition: Analyzer.cpp:4186
std::unique_ptr< Analyzer::ColumnVar > operand_owned_
Definition: NRings.h:98

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t spatial_type::NRings::size ( ) const
inlinefinalvirtual

Implements spatial_type::Codegen.

Definition at line 27 of file NRings.h.

Referenced by codegenLoads().

27 { return 1; }

+ Here is the caller graph for this function:

Member Data Documentation

std::unique_ptr<Analyzer::ColumnVar> spatial_type::NRings::operand_owned_
protected

Definition at line 98 of file NRings.h.

Referenced by getOperand().


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