OmniSciDB  a987f07e93
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
anonymous_namespace{TableFunctionCompilationContext.cpp} Namespace Reference

Functions

llvm::Function * generate_entry_point (const CgenState *cgen_state)
 
llvm::Typeget_llvm_type_from_sql_column_type (const SQLTypeInfo elem_ti, llvm::LLVMContext &ctx)
 
void initialize_ptr_member (llvm::Value *member_ptr, llvm::Type *member_llvm_type, llvm::Value *value_ptr, llvm::IRBuilder<> &ir_builder)
 
void initialize_int64_member (llvm::Value *member_ptr, llvm::Value *value, int64_t default_value, llvm::LLVMContext &ctx, llvm::IRBuilder<> &ir_builder)
 
std::tuple< llvm::Value
*, llvm::Value * > 
alloc_column (std::string col_name, const size_t index, const SQLTypeInfo &data_target_info, llvm::Value *data_ptr, llvm::Value *data_size, llvm::Value *data_str_dict_proxy_ptr, llvm::LLVMContext &ctx, llvm::IRBuilder<> &ir_builder)
 
llvm::Value * alloc_column_list (std::string col_list_name, const SQLTypeInfo &data_target_info, llvm::Value *data_ptrs, int length, llvm::Value *data_size, llvm::Value *data_str_dict_proxy_ptrs, llvm::LLVMContext &ctx, llvm::IRBuilder<> &ir_builder)
 
static bool columnTypeRequiresCasting (const SQLTypeInfo &ti)
 
llvm::Value * cast_value (llvm::Value *value, SQLTypeInfo &orig_ti, SQLTypeInfo &dest_ti, bool nullable, CodeGenerator &codeGenerator)
 
void cast_column (llvm::Value *col_base_ptr, llvm::Function *func, SQLTypeInfo &orig_ti, SQLTypeInfo &dest_ti, std::string index, llvm::IRBuilder<> &ir_builder, llvm::LLVMContext &ctx, CodeGenerator &codeGenerator)
 
std::string exprsKey (const std::vector< Analyzer::Expr * > &exprs)
 

Function Documentation

std::tuple<llvm::Value*, llvm::Value*> anonymous_namespace{TableFunctionCompilationContext.cpp}::alloc_column ( std::string  col_name,
const size_t  index,
const SQLTypeInfo data_target_info,
llvm::Value *  data_ptr,
llvm::Value *  data_size,
llvm::Value *  data_str_dict_proxy_ptr,
llvm::LLVMContext &  ctx,
llvm::IRBuilder<> &  ir_builder 
)

Definition at line 129 of file TableFunctionCompilationContext.cpp.

References SQLTypeInfo::get_compression(), get_llvm_type_from_sql_column_type(), initialize_int64_member(), initialize_ptr_member(), SQLTypeInfo::is_string(), and kENCODING_DICT.

Referenced by TableFunctionCompilationContext::generateEntryPoint().

136  {
137  /*
138  Creates a new Column instance of given element type and initialize
139  its data ptr and sz members when specified. If data ptr or sz are
140  unspecified (have nullptr values) then the corresponding members
141  are initialized with NULL and -1, respectively.
142 
143  If we are allocating a TextEncodingDict Column type, this function
144  adds and populates a int8* pointer to a StringDictProxy object.
145 
146  Return a pair of Column allocation (caller should apply
147  builder.CreateLoad to it in order to construct a Column instance
148  as a value) and a pointer to the Column instance.
149  */
150  const bool is_text_encoding_dict_type =
151  data_target_info.is_string() &&
152  data_target_info.get_compression() == kENCODING_DICT;
153  llvm::StructType* col_struct_type;
154  llvm::Type* data_ptr_llvm_type =
155  get_llvm_type_from_sql_column_type(data_target_info, ctx);
156  if (is_text_encoding_dict_type) {
157  col_struct_type = llvm::StructType::get(
158  ctx,
159  {
160  data_ptr_llvm_type, /* T* ptr */
161  llvm::Type::getInt64Ty(ctx), /* int64_t sz */
162  llvm::Type::getInt8PtrTy(ctx) /* int8_t* string_dictionary_ptr */
163  });
164  } else {
165  col_struct_type =
166  llvm::StructType::get(ctx,
167  {
168  data_ptr_llvm_type, /* T* ptr */
169  llvm::Type::getInt64Ty(ctx) /* int64_t sz */
170  });
171  }
172 
173  auto col = ir_builder.CreateAlloca(col_struct_type);
174  col->setName(col_name);
175  auto col_ptr_ptr = ir_builder.CreateStructGEP(col_struct_type, col, 0);
176  auto col_sz_ptr = ir_builder.CreateStructGEP(col_struct_type, col, 1);
177  auto col_str_dict_ptr = is_text_encoding_dict_type
178  ? ir_builder.CreateStructGEP(col_struct_type, col, 2)
179  : nullptr;
180  col_ptr_ptr->setName(col_name + ".ptr");
181  col_sz_ptr->setName(col_name + ".sz");
182  if (is_text_encoding_dict_type) {
183  col_str_dict_ptr->setName(col_name + ".string_dict_proxy");
184  }
185 
186  initialize_ptr_member(col_ptr_ptr, data_ptr_llvm_type, data_ptr, ir_builder);
187  initialize_int64_member(col_sz_ptr, data_size, -1, ctx, ir_builder);
188  if (is_text_encoding_dict_type) {
189  initialize_ptr_member(col_str_dict_ptr,
190  llvm::Type::getInt8PtrTy(ctx),
191  data_str_dict_proxy_ptr,
192  ir_builder);
193  }
194  auto col_ptr = ir_builder.CreatePointerCast(
195  col_ptr_ptr, llvm::PointerType::get(llvm::Type::getInt8Ty(ctx), 0));
196  col_ptr->setName(col_name + "_ptr");
197  return {col, col_ptr};
198 }
void initialize_ptr_member(llvm::Value *member_ptr, llvm::Type *member_llvm_type, llvm::Value *value_ptr, llvm::IRBuilder<> &ir_builder)
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:388
llvm::Type * get_llvm_type_from_sql_column_type(const SQLTypeInfo elem_ti, llvm::LLVMContext &ctx)
void initialize_int64_member(llvm::Value *member_ptr, llvm::Value *value, int64_t default_value, llvm::LLVMContext &ctx, llvm::IRBuilder<> &ir_builder)
bool is_string() const
Definition: sqltypes.h:576

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

llvm::Value* anonymous_namespace{TableFunctionCompilationContext.cpp}::alloc_column_list ( std::string  col_list_name,
const SQLTypeInfo data_target_info,
llvm::Value *  data_ptrs,
int  length,
llvm::Value *  data_size,
llvm::Value *  data_str_dict_proxy_ptrs,
llvm::LLVMContext &  ctx,
llvm::IRBuilder<> &  ir_builder 
)

Definition at line 200 of file TableFunctionCompilationContext.cpp.

References CHECK, SQLTypeInfo::get_compression(), initialize_int64_member(), initialize_ptr_member(), SQLTypeInfo::is_string(), and kENCODING_DICT.

Referenced by TableFunctionCompilationContext::generateEntryPoint().

207  {
208  /*
209  Creates a new ColumnList instance of given element type and initialize
210  its members. If data ptr or size are unspecified (have nullptr
211  values) then the corresponding members are initialized with NULL
212  and -1, respectively.
213  */
214  llvm::Type* data_ptrs_llvm_type = llvm::Type::getInt8PtrTy(ctx);
215  const bool is_text_encoding_dict_type =
216  data_target_info.is_string() &&
217  data_target_info.get_compression() == kENCODING_DICT;
218 
219  llvm::StructType* col_list_struct_type =
220  is_text_encoding_dict_type
221  ? llvm::StructType::get(
222  ctx,
223  {
224  data_ptrs_llvm_type, /* int8_t* ptrs */
225  llvm::Type::getInt64Ty(ctx), /* int64_t length */
226  llvm::Type::getInt64Ty(ctx), /* int64_t size */
227  data_ptrs_llvm_type /* int8_t* str_dict_proxy_ptrs */
228  })
229  : llvm::StructType::get(ctx,
230  {
231  data_ptrs_llvm_type, /* int8_t* ptrs */
232  llvm::Type::getInt64Ty(ctx), /* int64_t length */
233  llvm::Type::getInt64Ty(ctx) /* int64_t size */
234  });
235 
236  auto col_list = ir_builder.CreateAlloca(col_list_struct_type);
237  col_list->setName(col_list_name);
238  auto col_list_ptr_ptr = ir_builder.CreateStructGEP(col_list_struct_type, col_list, 0);
239  auto col_list_length_ptr =
240  ir_builder.CreateStructGEP(col_list_struct_type, col_list, 1);
241  auto col_list_size_ptr = ir_builder.CreateStructGEP(col_list_struct_type, col_list, 2);
242  auto col_str_dict_ptr_ptr =
243  is_text_encoding_dict_type
244  ? ir_builder.CreateStructGEP(col_list_struct_type, col_list, 3)
245  : nullptr;
246 
247  col_list_ptr_ptr->setName(col_list_name + ".ptrs");
248  col_list_length_ptr->setName(col_list_name + ".length");
249  col_list_size_ptr->setName(col_list_name + ".size");
250  if (is_text_encoding_dict_type) {
251  col_str_dict_ptr_ptr->setName(col_list_name + ".string_dict_proxies");
252  }
253 
254  initialize_ptr_member(col_list_ptr_ptr, data_ptrs_llvm_type, data_ptrs, ir_builder);
255 
256  CHECK(length >= 0);
257  auto const_length = llvm::ConstantInt::get(llvm::Type::getInt64Ty(ctx), length, true);
258  ir_builder.CreateStore(const_length, col_list_length_ptr);
259 
260  initialize_int64_member(col_list_size_ptr, data_size, -1, ctx, ir_builder);
261 
262  if (is_text_encoding_dict_type) {
263  initialize_ptr_member(col_str_dict_ptr_ptr,
264  data_str_dict_proxy_ptrs->getType(),
265  data_str_dict_proxy_ptrs,
266  ir_builder);
267  }
268 
269  auto col_list_ptr = ir_builder.CreatePointerCast(
270  col_list_ptr_ptr, llvm::PointerType::get(llvm::Type::getInt8Ty(ctx), 0));
271  col_list_ptr->setName(col_list_name + "_ptrs");
272  return col_list_ptr;
273 }
void initialize_ptr_member(llvm::Value *member_ptr, llvm::Type *member_llvm_type, llvm::Value *value_ptr, llvm::IRBuilder<> &ir_builder)
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:388
#define CHECK(condition)
Definition: Logger.h:289
void initialize_int64_member(llvm::Value *member_ptr, llvm::Value *value, int64_t default_value, llvm::LLVMContext &ctx, llvm::IRBuilder<> &ir_builder)
bool is_string() const
Definition: sqltypes.h:576

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void anonymous_namespace{TableFunctionCompilationContext.cpp}::cast_column ( llvm::Value *  col_base_ptr,
llvm::Function *  func,
SQLTypeInfo orig_ti,
SQLTypeInfo dest_ti,
std::string  index,
llvm::IRBuilder<> &  ir_builder,
llvm::LLVMContext &  ctx,
CodeGenerator codeGenerator 
)

Definition at line 311 of file TableFunctionCompilationContext.cpp.

References cast_value(), and get_llvm_type_from_sql_column_type().

Referenced by TableFunctionCompilationContext::generateCastsForInputTypes().

318  {
319  /*
320  Generates code to cast a Column instance from a given origin
321  SQLType to a new destinaton SQLType. To do so, it generates a
322  loop with the following overall structure:
323 
324  --------------
325  | pre_header |
326  | i = 0 |
327  --------------
328  |
329  v
330  ---------------- ----------------
331  | cond | | body |
332  | i < col.size | (True) -> | cast(col[i]) |
333  ---------------- | i++ |
334  (False) ^ ----------------
335  | \____________________/
336  |
337  v
338  ---------------
339  | end |
340  ---------------
341 
342  The correctness of the cast as well as error handling/early
343  exiting in case of cast failures are left to the CodeGenerator
344  which generates the code for the cast operation itself.
345  */
346 
347  llvm::BasicBlock* for_pre =
348  llvm::BasicBlock::Create(ctx, "for_pre_cast." + index, func);
349  llvm::BasicBlock* for_cond =
350  llvm::BasicBlock::Create(ctx, "for_cond_cast." + index, func);
351  llvm::BasicBlock* for_body =
352  llvm::BasicBlock::Create(ctx, "for_body_cast." + index, func);
353  llvm::BasicBlock* for_end =
354  llvm::BasicBlock::Create(ctx, "for_end_cast." + index, func);
355  ir_builder.CreateBr(for_pre);
356 
357  // pre-header: load column ptr and size
358  ir_builder.SetInsertPoint(for_pre);
359  llvm::Type* data_type = get_llvm_type_from_sql_column_type(orig_ti, ctx);
360  llvm::StructType* col_struct_type =
361  llvm::StructType::get(ctx, {data_type, ir_builder.getInt64Ty()});
362  llvm::Value* struct_cast = ir_builder.CreateBitCast(
363  col_base_ptr, col_struct_type->getPointerTo(), "col_struct." + index);
364  llvm::Value* gep_ptr = ir_builder.CreateStructGEP(
365  col_struct_type, struct_cast, 0, "col_ptr_addr." + index);
366  llvm::Value* col_ptr = ir_builder.CreateLoad(data_type, gep_ptr, "col_ptr." + index);
367  llvm::Value* gep_sz =
368  ir_builder.CreateStructGEP(col_struct_type, struct_cast, 1, "col_sz_addr." + index);
369  llvm::Value* col_sz =
370  ir_builder.CreateLoad(ir_builder.getInt64Ty(), gep_sz, "col_sz." + index);
371  ir_builder.CreateBr(for_cond);
372 
373  // condition: check induction variable against loop predicate
374  ir_builder.SetInsertPoint(for_cond);
375  llvm::PHINode* for_ind_var =
376  ir_builder.CreatePHI(ir_builder.getInt64Ty(), 2, "for_ind_var." + index);
377  for_ind_var->addIncoming(ir_builder.getInt64(0), for_pre);
378  llvm::Value* for_pred =
379  ir_builder.CreateICmpSLT(for_ind_var, col_sz, "for_pred." + index);
380  ir_builder.CreateCondBr(for_pred, for_body, for_end);
381 
382  // body: perform value cast, increment induction variable
383  ir_builder.SetInsertPoint(for_body);
384  ;
385  llvm::Value* val_gep = ir_builder.CreateInBoundsGEP(
386  ir_builder.getInt64Ty(), col_ptr, for_ind_var, "val_gep." + index);
387  llvm::Value* val_load =
388  ir_builder.CreateLoad(ir_builder.getInt64Ty(), val_gep, "val_load." + index);
389  llvm::Value* cast_result = cast_value(val_load, orig_ti, dest_ti, false, codeGenerator);
390  cast_result->setName("cast_result." + index);
391  ir_builder.CreateStore(cast_result, val_gep);
392  llvm::Value* for_inc =
393  ir_builder.CreateAdd(for_ind_var, ir_builder.getInt64(1), "for_inc." + index);
394  ir_builder.CreateBr(for_cond);
395  // the cast codegening may have generated extra blocks, so for_body does not necessarily
396  // jump to for_cond directly
397  llvm::Instruction* inc_as_inst = llvm::cast<llvm::Instruction>(for_inc);
398  for_ind_var->addIncoming(for_inc, inc_as_inst->getParent());
399  ir_builder.SetInsertPoint(for_end);
400 }
llvm::Type * get_llvm_type_from_sql_column_type(const SQLTypeInfo elem_ti, llvm::LLVMContext &ctx)
llvm::Value * cast_value(llvm::Value *value, SQLTypeInfo &orig_ti, SQLTypeInfo &dest_ti, bool nullable, CodeGenerator &codeGenerator)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

llvm::Value* anonymous_namespace{TableFunctionCompilationContext.cpp}::cast_value ( llvm::Value *  value,
SQLTypeInfo orig_ti,
SQLTypeInfo dest_ti,
bool  nullable,
CodeGenerator codeGenerator 
)

Definition at line 293 of file TableFunctionCompilationContext.cpp.

References CodeGenerator::codegenCastBetweenTimestamps(), SQLTypeInfo::get_notnull(), SQLTypeInfo::get_type_name(), and SQLTypeInfo::is_timestamp().

Referenced by cast_column().

297  {
298  /*
299  Codegens a cast of a value from a given origin type to a given destination type, if such
300  implementation is available. Errors for unsupported casts.
301  */
302  if (orig_ti.is_timestamp() && dest_ti.is_timestamp()) {
303  return codeGenerator.codegenCastBetweenTimestamps(
304  value, orig_ti, dest_ti, !dest_ti.get_notnull());
305  } else {
306  throw std::runtime_error("Unsupported cast from " + orig_ti.get_type_name() + " to " +
307  dest_ti.get_type_name() + " during UDTF code generation.");
308  }
309 }
bool is_timestamp() const
Definition: sqltypes.h:1000
std::string get_type_name() const
Definition: sqltypes.h:504
llvm::Value * codegenCastBetweenTimestamps(llvm::Value *ts_lv, const SQLTypeInfo &operand_dimen, const SQLTypeInfo &target_dimen, const bool nullable)
Definition: CastIR.cpp:199
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:387

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool anonymous_namespace{TableFunctionCompilationContext.cpp}::columnTypeRequiresCasting ( const SQLTypeInfo ti)
static

Definition at line 275 of file TableFunctionCompilationContext.cpp.

References SQLTypeInfo::get_precision(), SQLTypeInfo::get_subtype(), SQLTypeInfo::is_column(), and kTIMESTAMP.

Referenced by TableFunctionCompilationContext::generateEntryPoint().

275  {
276  /*
277  Returns whether a column requires casting before table function execution based on its
278  underlying SQL type
279  */
280 
281  if (!ti.is_column()) {
282  return false;
283  }
284 
285  // TIMESTAMP columns should always have nanosecond precision
286  if (ti.get_subtype() == kTIMESTAMP && ti.get_precision() != 9) {
287  return true;
288  }
289 
290  return false;
291 }
HOST DEVICE SQLTypes get_subtype() const
Definition: sqltypes.h:381
int get_precision() const
Definition: sqltypes.h:383
bool is_column() const
Definition: sqltypes.h:589

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string anonymous_namespace{TableFunctionCompilationContext.cpp}::exprsKey ( const std::vector< Analyzer::Expr * > &  exprs)

Definition at line 402 of file TableFunctionCompilationContext.cpp.

References run_benchmark_import::result.

Referenced by TableFunctionCompilationContext::compile().

402  {
403  std::string result;
404  for (const auto& expr : exprs) {
405  const auto& ti = expr->get_type_info();
406  result += ti.to_string() + ", ";
407  }
408  return result;
409 }

+ Here is the caller graph for this function:

llvm::Function* anonymous_namespace{TableFunctionCompilationContext.cpp}::generate_entry_point ( const CgenState cgen_state)

Definition at line 31 of file TableFunctionCompilationContext.cpp.

References CgenState::context_, get_int_type(), and CgenState::module_.

Referenced by TableFunctionCompilationContext::compile().

31  {
32  auto& ctx = cgen_state->context_;
33  const auto pi8_type = llvm::PointerType::get(get_int_type(8, ctx), 0);
34  const auto ppi8_type = llvm::PointerType::get(pi8_type, 0);
35  const auto pi64_type = llvm::PointerType::get(get_int_type(64, ctx), 0);
36  const auto ppi64_type = llvm::PointerType::get(pi64_type, 0);
37  const auto i32_type = get_int_type(32, ctx);
38 
39  const auto func_type = llvm::FunctionType::get(
40  i32_type,
41  {pi8_type, ppi8_type, pi64_type, ppi8_type, ppi64_type, ppi8_type, pi64_type},
42  false);
43 
44  auto func = llvm::Function::Create(func_type,
45  llvm::Function::ExternalLinkage,
46  "call_table_function",
47  cgen_state->module_);
48  auto arg_it = func->arg_begin();
49  const auto mgr_arg = &*arg_it;
50  mgr_arg->setName("mgr_ptr");
51  const auto input_cols_arg = &*(++arg_it);
52  input_cols_arg->setName("input_col_buffers");
53  const auto input_row_counts = &*(++arg_it);
54  input_row_counts->setName("input_row_counts");
55  const auto input_str_dict_proxies = &*(++arg_it);
56  input_str_dict_proxies->setName("input_str_dict_proxies");
57  const auto output_buffers = &*(++arg_it);
58  output_buffers->setName("output_buffers");
59  const auto output_str_dict_proxies = &*(++arg_it);
60  output_str_dict_proxies->setName("output_str_dict_proxies");
61  const auto output_row_count = &*(++arg_it);
62  output_row_count->setName("output_row_count");
63  return func;
64 }
llvm::Type * get_int_type(const int width, llvm::LLVMContext &context)
llvm::Module * module_
Definition: CgenState.h:364
llvm::LLVMContext & context_
Definition: CgenState.h:373

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

llvm::Type* anonymous_namespace{TableFunctionCompilationContext.cpp}::get_llvm_type_from_sql_column_type ( const SQLTypeInfo  elem_ti,
llvm::LLVMContext &  ctx 
)
inline

Definition at line 66 of file TableFunctionCompilationContext.cpp.

References CHECK, logger::FATAL, SQLTypeInfo::get_compression(), get_fp_ptr_type(), get_int_ptr_type(), SQLTypeInfo::get_size(), SQLTypeInfo::is_array(), SQLTypeInfo::is_boolean(), SQLTypeInfo::is_bytes(), SQLTypeInfo::is_fp(), SQLTypeInfo::is_integer(), SQLTypeInfo::is_string(), SQLTypeInfo::is_timestamp(), kENCODING_DICT, LOG, and toString().

Referenced by alloc_column(), and cast_column().

67  {
68  if (elem_ti.is_fp()) {
69  return get_fp_ptr_type(elem_ti.get_size() * 8, ctx);
70  } else if (elem_ti.is_boolean()) {
71  return get_int_ptr_type(8, ctx);
72  } else if (elem_ti.is_integer()) {
73  return get_int_ptr_type(elem_ti.get_size() * 8, ctx);
74  } else if (elem_ti.is_string()) {
75  if (elem_ti.get_compression() == kENCODING_DICT) {
76  return get_int_ptr_type(elem_ti.get_size() * 8, ctx);
77  }
78  CHECK(elem_ti.is_bytes()); // None encoded string
79  return get_int_ptr_type(8, ctx);
80  } else if (elem_ti.is_timestamp()) {
81  return get_int_ptr_type(elem_ti.get_size() * 8, ctx);
82  } else if (elem_ti.is_array()) {
83  return get_int_ptr_type(8, ctx);
84  }
85  LOG(FATAL) << "get_llvm_type_from_sql_column_type: not implemented for "
86  << ::toString(elem_ti);
87  return nullptr;
88 }
llvm::Type * get_fp_ptr_type(const int width, llvm::LLVMContext &context)
HOST DEVICE int get_size() const
Definition: sqltypes.h:390
bool is_timestamp() const
Definition: sqltypes.h:1000
#define LOG(tag)
Definition: Logger.h:283
bool is_fp() const
Definition: sqltypes.h:580
bool is_integer() const
Definition: sqltypes.h:578
std::string toString(const ExecutorDeviceType &device_type)
bool is_boolean() const
Definition: sqltypes.h:583
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:388
bool is_bytes() const
Definition: sqltypes.h:599
#define CHECK(condition)
Definition: Logger.h:289
bool is_string() const
Definition: sqltypes.h:576
llvm::Type * get_int_ptr_type(const int width, llvm::LLVMContext &context)
bool is_array() const
Definition: sqltypes.h:584

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void anonymous_namespace{TableFunctionCompilationContext.cpp}::initialize_int64_member ( llvm::Value *  member_ptr,
llvm::Value *  value,
int64_t  default_value,
llvm::LLVMContext &  ctx,
llvm::IRBuilder<> &  ir_builder 
)

Definition at line 106 of file TableFunctionCompilationContext.cpp.

References CHECK.

Referenced by alloc_column(), and alloc_column_list().

110  {
111  llvm::Value* val = nullptr;
112  if (value != nullptr) {
113  auto value_type = value->getType();
114  if (value_type->isPointerTy()) {
115  CHECK(value_type->getPointerElementType()->isIntegerTy(64));
116  val = ir_builder.CreateLoad(value->getType()->getPointerElementType(), value);
117  } else {
118  CHECK(value_type->isIntegerTy(64));
119  val = value;
120  }
121  ir_builder.CreateStore(val, member_ptr);
122  } else {
123  auto const_default =
124  llvm::ConstantInt::get(llvm::Type::getInt64Ty(ctx), default_value, true);
125  ir_builder.CreateStore(const_default, member_ptr);
126  }
127 }
#define CHECK(condition)
Definition: Logger.h:289

+ Here is the caller graph for this function:

void anonymous_namespace{TableFunctionCompilationContext.cpp}::initialize_ptr_member ( llvm::Value *  member_ptr,
llvm::Type member_llvm_type,
llvm::Value *  value_ptr,
llvm::IRBuilder<> &  ir_builder 
)

Definition at line 90 of file TableFunctionCompilationContext.cpp.

Referenced by alloc_column(), and alloc_column_list().

93  {
94  if (value_ptr != nullptr) {
95  if (value_ptr->getType() == member_llvm_type->getPointerElementType()) {
96  ir_builder.CreateStore(value_ptr, member_ptr);
97  } else {
98  auto tmp = ir_builder.CreateBitCast(value_ptr, member_llvm_type);
99  ir_builder.CreateStore(tmp, member_ptr);
100  }
101  } else {
102  ir_builder.CreateStore(llvm::Constant::getNullValue(member_llvm_type), member_ptr);
103  }
104 }

+ Here is the caller graph for this function: