OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CgenState.h
Go to the documentation of this file.
1 /*
2  * Copyright 2022 HEAVY.AI, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include "IRCodegenUtils.h"
20 #include "InValuesBitmap.h"
21 #include "InputMetadata.h"
22 #include "LLVMGlobalContext.h"
24 #include "TreeModelPredictionMgr.h"
25 
26 #include "../Analyzer/Analyzer.h"
27 #include "../Shared/InsertionOrderedMap.h"
28 
29 #include <llvm/IR/Constants.h>
30 #include <llvm/IR/IRBuilder.h>
31 #include <llvm/Transforms/Utils/ValueMapper.h>
32 
33 #include "Shared/DbObjectKeys.h"
34 
36  llvm::Value* buffer;
37  llvm::Value* size;
38  llvm::Value* is_null;
39 };
40 
41 struct CgenState {
42  public:
43  CgenState(const size_t num_query_infos,
44  const bool contains_left_deep_outer_join,
45  Executor* executor);
46  CgenState(const size_t num_query_infos, const bool contains_left_deep_outer_join);
47  CgenState(llvm::LLVMContext& context);
48 
49  std::tuple<size_t, size_t> getOrAddLiteral(const Analyzer::Constant* constant,
50  const EncodingType enc_type,
51  const shared::StringDictKey& dict_id,
52  const int device_id) {
53  const auto& ti = constant->get_type_info();
54  const auto type = ti.is_decimal() ? decimal_to_int_type(ti) : ti.get_type();
55  switch (type) {
56  case kBOOLEAN:
57  return getOrAddLiteral(constant->get_is_null()
58  ? int8_t(inline_int_null_val(ti))
59  : int8_t(constant->get_constval().boolval ? 1 : 0),
60  device_id);
61  case kTINYINT:
62  return getOrAddLiteral(constant->get_is_null()
63  ? int8_t(inline_int_null_val(ti))
64  : constant->get_constval().tinyintval,
65  device_id);
66  case kSMALLINT:
67  return getOrAddLiteral(constant->get_is_null()
68  ? int16_t(inline_int_null_val(ti))
69  : constant->get_constval().smallintval,
70  device_id);
71  case kINT:
72  return getOrAddLiteral(constant->get_is_null() ? int32_t(inline_int_null_val(ti))
73  : constant->get_constval().intval,
74  device_id);
75  case kBIGINT:
76  return getOrAddLiteral(constant->get_is_null()
77  ? int64_t(inline_int_null_val(ti))
78  : constant->get_constval().bigintval,
79  device_id);
80  case kFLOAT:
81  return getOrAddLiteral(constant->get_is_null()
82  ? float(inline_fp_null_val(ti))
83  : constant->get_constval().floatval,
84  device_id);
85  case kDOUBLE:
86  return getOrAddLiteral(constant->get_is_null()
87  ? inline_fp_null_val(ti)
88  : constant->get_constval().doubleval,
89  device_id);
90  case kCHAR:
91  case kTEXT:
92  case kVARCHAR:
93  if (enc_type == kENCODING_DICT) {
94  if (constant->get_is_null()) {
95  return getOrAddLiteral(int32_t(inline_int_null_val(ti)), device_id);
96  }
97  return getOrAddLiteral(
98  std::make_pair(*constant->get_constval().stringval, dict_id), device_id);
99  }
100  CHECK_EQ(kENCODING_NONE, enc_type);
101  if (constant->get_is_null()) {
102  throw std::runtime_error(
103  "CHAR / VARCHAR NULL literal not supported in this context"); // TODO(alex):
104  // support
105  // null
106  }
107  return getOrAddLiteral(*constant->get_constval().stringval, device_id);
108  case kTIME:
109  case kTIMESTAMP:
110  case kDATE:
111  case kINTERVAL_DAY_TIME:
113  // TODO(alex): support null
114  return getOrAddLiteral(constant->get_constval().bigintval, device_id);
115  case kARRAY: {
116  if (enc_type == kENCODING_NONE) {
117  if (ti.get_subtype() == kDOUBLE) {
118  std::vector<double> double_array_literal;
119  for (const auto& value : constant->get_value_list()) {
120  const auto c = dynamic_cast<const Analyzer::Constant*>(value.get());
121  CHECK(c);
122  double d = c->get_constval().doubleval;
123  double_array_literal.push_back(d);
124  }
125  return getOrAddLiteral(double_array_literal, device_id);
126  }
127  if (ti.get_subtype() == kINT) {
128  std::vector<int32_t> int32_array_literal;
129  for (const auto& value : constant->get_value_list()) {
130  const auto c = dynamic_cast<const Analyzer::Constant*>(value.get());
131  CHECK(c);
132  int32_t i = c->get_constval().intval;
133  int32_array_literal.push_back(i);
134  }
135  return getOrAddLiteral(int32_array_literal, device_id);
136  }
137  if (ti.get_subtype() == kTINYINT) {
138  std::vector<int8_t> int8_array_literal;
139  for (const auto& value : constant->get_value_list()) {
140  const auto c = dynamic_cast<const Analyzer::Constant*>(value.get());
141  CHECK(c);
142  int8_t i = c->get_constval().tinyintval;
143  int8_array_literal.push_back(i);
144  }
145  if (ti.get_comp_param() == 64) {
146  return getOrAddLiteral(std::make_pair(int8_array_literal, 64), device_id);
147  }
148  return getOrAddLiteral(int8_array_literal, device_id);
149  }
150  throw std::runtime_error("Unsupported literal array");
151  }
152  if (enc_type == kENCODING_GEOINT) {
153  if (ti.get_subtype() == kTINYINT) {
154  std::vector<int8_t> int8_array_literal;
155  for (const auto& value : constant->get_value_list()) {
156  const auto c = dynamic_cast<const Analyzer::Constant*>(value.get());
157  CHECK(c);
158  int8_t i = c->get_constval().tinyintval;
159  int8_array_literal.push_back(i);
160  }
161  if (ti.get_comp_param() == 32) {
162  return getOrAddLiteral(std::make_pair(int8_array_literal, 32), device_id);
163  }
164  return getOrAddLiteral(int8_array_literal, device_id);
165  }
166  }
167  throw std::runtime_error("Encoded literal arrays are not supported");
168  }
169  default:
170  abort();
171  }
172  }
173 
174  using LiteralValue = boost::variant<int8_t,
175  int16_t,
176  int32_t,
177  int64_t,
178  float,
179  double,
180  std::pair<std::string, shared::StringDictKey>,
181  std::string,
182  std::vector<double>,
183  std::vector<int32_t>,
184  std::vector<int8_t>,
185  std::pair<std::vector<int8_t>, int>>;
186  using LiteralValues = std::vector<LiteralValue>;
187 
188  const std::unordered_map<int, LiteralValues>& getLiterals() const { return literals_; }
189 
190  llvm::Value* addStringConstant(const std::string& str) {
191  llvm::Value* str_lv = ir_builder_.CreateGlobalString(
192  str, "str_const_" + std::to_string(std::hash<std::string>()(str)));
193  auto i8_ptr = llvm::PointerType::get(get_int_type(8, context_), 0);
194  str_constants_.push_back(str_lv);
195  str_lv = ir_builder_.CreateBitCast(str_lv, i8_ptr);
196  return str_lv;
197  }
198 
200  std::unique_ptr<const StringDictionaryTranslationMgr>&& str_dict_translation_mgr) {
201  str_dict_translation_mgrs_.emplace_back(std::move(str_dict_translation_mgr));
202  return str_dict_translation_mgrs_.back().get();
203  }
204 
206  std::unique_ptr<const TreeModelPredictionMgr>&& tree_model_prediction_mgr) {
207  tree_model_prediction_mgrs_.emplace_back(std::move(tree_model_prediction_mgr));
208  return tree_model_prediction_mgrs_.back().get();
209  }
210 
212  std::unique_ptr<InValuesBitmap>& in_values_bitmap) {
213  if (in_values_bitmap->isEmpty()) {
214  return in_values_bitmap.get();
215  }
216  in_values_bitmaps_.emplace_back(std::move(in_values_bitmap));
217  return in_values_bitmaps_.back().get();
218  }
219  void moveInValuesBitmap(std::unique_ptr<const InValuesBitmap>& in_values_bitmap) {
220  if (!in_values_bitmap->isEmpty()) {
221  in_values_bitmaps_.emplace_back(std::move(in_values_bitmap));
222  }
223  }
224  // look up a runtime function based on the name, return type and type of
225  // the arguments and call it; x64 only, don't call from GPU codegen
226  llvm::Value* emitExternalCall(
227  const std::string& fname,
228  llvm::Type* ret_type,
229  const std::vector<llvm::Value*> args,
230  const std::vector<llvm::Attribute::AttrKind>& fnattrs = {},
231  const bool has_struct_return = false);
232  llvm::Value* emitCall(const std::string& fname, const std::vector<llvm::Value*>& args);
233  llvm::Value* emitEntryCall(const std::string& fname,
234  const std::vector<llvm::Value*>& args);
235 
236  size_t getLiteralBufferUsage(const int device_id) { return literal_bytes_[device_id]; }
237 
238  llvm::Value* castToTypeIn(llvm::Value* val, const size_t bit_width);
239 
240  std::pair<llvm::ConstantInt*, llvm::ConstantInt*> inlineIntMaxMin(
241  const size_t byte_width,
242  const bool is_signed);
243 
244  llvm::ConstantInt* inlineIntNull(const SQLTypeInfo&);
245  llvm::ConstantFP* inlineFpNull(const SQLTypeInfo&);
246  llvm::Constant* inlineNull(const SQLTypeInfo&);
247 
248  template <class T>
249  llvm::ConstantInt* llInt(const T v) const {
251  }
252 
253  llvm::ConstantFP* llFp(const float v) const {
254  return static_cast<llvm::ConstantFP*>(
255  llvm::ConstantFP::get(llvm::Type::getFloatTy(context_), v));
256  }
257 
258  llvm::ConstantFP* llFp(const double v) const {
259  return static_cast<llvm::ConstantFP*>(
260  llvm::ConstantFP::get(llvm::Type::getDoubleTy(context_), v));
261  }
262 
263  llvm::ConstantInt* llBool(const bool v) const { return ::ll_bool(v, context_); }
264 
265  void emitErrorCheck(llvm::Value* condition, llvm::Value* errorCode, std::string label);
266 
267  std::vector<std::string> gpuFunctionsToReplace(llvm::Function* fn);
268 
269  void replaceFunctionForGpu(const std::string& fcn_to_replace, llvm::Function* fn);
270 
271  std::shared_ptr<Executor> getExecutor() const;
272  llvm::LLVMContext& getExecutorContext() const;
273  void set_module_shallow_copy(const std::unique_ptr<llvm::Module>& module,
274  bool always_clone = false);
275 
276  size_t executor_id_;
277 
278  /*
279  Managing LLVM modules
280  ---------------------
281 
282  Quoting https://groups.google.com/g/llvm-dev/c/kuil5XjasUs/m/7PBpOWZFDAAJ :
283  """
284  The state of Module/Context ownership is very muddled in the
285  codebase. As you have discovered: LLVMContext’s notionally own
286  their modules (via raw pointers deleted upon destruction of the
287  context), however in practice we always hold llvm Modules by
288  unique_ptr. Since the Module destructor removes the raw pointer
289  from the Context, this doesn’t usually blow up. It’s pretty broken
290  though.
291 
292  I would argue that you should use unique_ptr and ignore
293  LLVMContext ownership.
294  """
295 
296  Here we follow the last argument only partially for reasons
297  explained below.
298 
299  HeavyDB supports concurrent query executions. For that, a global
300  cache of Executor instances is used. Each instance is able to
301  generate LLVM code, compile it to machine code (with code
302  caching), and execute the code --- all that concurrently with
303  other Executor instances.
304 
305  Each Executor instance holds as set of extension modules (LLVM
306  Module instances) that are either loaded at Executor construction
307  time (template module from RuntimeFunctions.bc, rt_geos from
308  GeosRuntime.bc, rt_libdevice from libdevice.10.bc, udf_cpu/gpu
309  modules from LLVM IR file), or at run-time (rt_udf_cpu/gpu modules
310  from LLVM IR string). All these extension modules are owned by
311  the Executor instance via unique_ptr. Since Executor also owns the
312  LLVM Context instance that technically also owns these extension
313  modules, then the LLVM Context-Module ownership can be ignored
314  (see the quote above).
315 
316  Code generation is a process that compiles
317  (generated/user-provided) LLVM IR code into machine code that can
318  be executed on a CPU or GPU.
319 
320  Typically, a copy of the template module (let's call this copy as
321  a worker module) is used as an input to code generation that is
322  updated with generated/user-provided LLVM Functions and with other
323  extension modules being linked in. The worker module is created by
324  set_module_shallow_copy and is owned by an Executor instance as a
325  raw pointer (via cgen_state member). Notice that
326  set_module_shallow_copy clones the template module and then
327  releases unique_ptr as a raw pointer. This means that Executor is
328  now responsible of deleting the worker module after the
329  compilation process completes.
330 
331  The reason why the worker module is stored via raw pointer value
332  (rather than using unique_ptr as suggested in the quote above) is
333  as follows. First, the code generation in HeavyDB can be a
334  recursive process (e.g. in the case of multi-step
335  multi-subqueries) that involves temporary "shelving" of parent
336  compilation processes (the corresponding worker modules are put on
337  hold). In addition, the Executor may trigger threaded compilations
338  that involve "resetting" the worker module for different threads
339  (btw, these compilations cannot be concurrent because LLVM Context
340  is not threadsafe. The shelving and resetting of worker modules
341  makes the scope of a worker module dynamic (only one worker module
342  instance can be in scope while other worker modules are on hold)
343  that contradicts with the purpose of unique_ptr (out-of-scope
344  worker modules can be destroyed) and would make managing all
345  worker modules very painful if these would be stored as unique_ptr
346  instances.
347 
348  An entry point to the code generation is Executor::compileWorkUnit
349  method. Its scope includes creating an Executor::CgenStateManager
350  instance that uses RAII pattern to manage the CgenState instance
351  held by an Executor instance. In addition, the CgenStateManager
352  locks other compilations within the same Executor instance. The
353  compilation lock enables the threaded compilation feature.
354 
355  Construction of CgenStateManager (i) stores the existing CgenState
356  instance held by the Executor instance, and (ii) creates an new
357  CgenState instance with un-instantiated worker module. The worker
358  module is instantiated after the construction (unless
359  QueryMustRunOnCpu is thrown) via set_module_shallow_copy, followed
360  by updating the worker module according to the given query and
361  compiling it to machine code. Destruction of CgenStateManager
362  (read: when leaving the compileWorkUnit method) will delete the
363  instantiated worker module and restores the previous CgenState
364  instance. This CgenState management enables the recursive
365  compilation feature.
366 
367  Finally, we note that the worker module compilation caches the
368  compilation results using the full LLVM IR as the cache
369  key. Caching compilation results is especially effective for CUDA
370  target due to a considerable overhead from the CUDA compilation.
371  */
372 
373  llvm::Module* module_;
374  llvm::Function* row_func_;
375  llvm::Function* filter_func_;
376  llvm::Function* current_func_;
377  llvm::BasicBlock* row_func_bb_;
378  llvm::BasicBlock* filter_func_bb_;
379  llvm::CallInst* row_func_call_;
380  llvm::CallInst* filter_func_call_;
381  std::vector<llvm::Function*> helper_functions_;
382  llvm::LLVMContext& context_; // LLVMContext instance is held by an Executor instance.
383  llvm::ValueToValueMapTy vmap_; // used for cloning the runtime module
384  llvm::IRBuilder<> ir_builder_;
385  std::unordered_map<size_t, std::vector<llvm::Value*>> fetch_cache_;
388  llvm::Value* lv;
389  };
390  std::vector<FunctionOperValue> ext_call_cache_;
391  std::vector<llvm::Value*> group_by_expr_cache_;
392  std::vector<llvm::Value*> str_constants_;
393  std::vector<llvm::Value*> frag_offsets_;
395  std::vector<llvm::Value*> outer_join_match_found_per_level_;
396  std::unordered_map<int, llvm::Value*> scan_idx_to_hash_pos_;
398  std::vector<std::unique_ptr<const InValuesBitmap>> in_values_bitmaps_;
399  std::vector<std::unique_ptr<const TreeModelPredictionMgr>> tree_model_prediction_mgrs_;
400  std::vector<std::unique_ptr<const StringDictionaryTranslationMgr>>
402  std::map<std::pair<llvm::Value*, llvm::Value*>, ArrayLoadCodegen>
403  array_load_cache_; // byte stream to array info
404  std::unordered_map<std::string, llvm::Value*> geo_target_cache_;
407 
408  llvm::Function* query_func_;
409  llvm::IRBuilder<> query_func_entry_ir_builder_;
410  std::unordered_map<int, std::vector<llvm::Value*>> query_func_literal_loads_;
411 
415  };
416  std::unordered_map<llvm::Value*, HoistedLiteralLoadLocator> row_func_hoisted_literals_;
417 
418  static size_t literalBytes(const CgenState::LiteralValue& lit) {
419  switch (lit.which()) {
420  case 0:
421  return 1; // int8_t
422  case 1:
423  return 2; // int16_t
424  case 2:
425  return 4; // int32_t
426  case 3:
427  return 8; // int64_t
428  case 4:
429  return 4; // float
430  case 5:
431  return 8; // double
432  case 6:
433  return 4; // std::pair<std::string, int>
434  case 7:
435  return 4; // std::string
436  case 8:
437  return 4; // std::vector<double>
438  case 9:
439  return 4; // std::vector<int32_t>
440  case 10:
441  return 4; // std::vector<int8_t>
442  case 11:
443  return 4; // std::pair<std::vector<int8_t>, int>
444  default:
445  abort();
446  }
447  }
448 
449  static size_t addAligned(const size_t off_in, const size_t alignment) {
450  size_t off = off_in;
451  if (off % alignment != 0) {
452  off += (alignment - off % alignment);
453  }
454  return off + alignment;
455  }
456 
457  void maybeCloneFunctionRecursive(llvm::Function* fn);
458 
459  private:
460  // todo (yoonmin) : avoid linear scanning of `literals` map
461  template <class T>
462  std::tuple<size_t, size_t> getOrAddLiteral(const T& val, const int device_id) {
463  const LiteralValue var_val(val);
464  size_t literal_found_off{0};
465  auto& literals = literals_[device_id];
466  for (const auto& literal : literals) {
467  const auto lit_bytes = literalBytes(literal);
468  literal_found_off = addAligned(literal_found_off, lit_bytes);
469  if (literal == var_val) {
470  return {literal_found_off - lit_bytes, lit_bytes};
471  }
472  }
473  literals.emplace_back(val);
474  const auto lit_bytes = literalBytes(var_val);
475  literal_bytes_[device_id] = addAligned(literal_bytes_[device_id], lit_bytes);
476  return {literal_bytes_[device_id] - lit_bytes, lit_bytes};
477  }
478 
479  std::unordered_map<int, LiteralValues> literals_;
480  std::unordered_map<int, size_t> literal_bytes_;
481 };
482 
std::vector< llvm::Function * > helper_functions_
Definition: CgenState.h:381
int8_t tinyintval
Definition: Datum.h:73
const std::list< std::shared_ptr< Analyzer::Expr > > & get_value_list() const
Definition: Analyzer.h:350
#define CHECK_EQ(x, y)
Definition: Logger.h:301
llvm::Value * castToTypeIn(llvm::Value *val, const size_t bit_width)
Definition: CgenState.cpp:150
llvm::Value * emitEntryCall(const std::string &fname, const std::vector< llvm::Value * > &args)
Definition: CgenState.cpp:229
std::vector< llvm::Value * > outer_join_match_found_per_level_
Definition: CgenState.h:395
std::unordered_map< size_t, std::vector< llvm::Value * > > fetch_cache_
Definition: CgenState.h:385
Definition: sqltypes.h:76
llvm::LLVMContext & getExecutorContext() const
Definition: CgenState.cpp:376
std::shared_ptr< Executor > getExecutor() const
Definition: CgenState.cpp:371
std::map< std::pair< llvm::Value *, llvm::Value * >, ArrayLoadCodegen > array_load_cache_
Definition: CgenState.h:403
const Analyzer::FunctionOper * foper
Definition: CgenState.h:387
llvm::Value * addStringConstant(const std::string &str)
Definition: CgenState.h:190
void maybeCloneFunctionRecursive(llvm::Function *fn)
Definition: CgenState.cpp:181
llvm::Function * query_func_
Definition: CgenState.h:408
llvm::ConstantInt * ll_int(const T v, llvm::LLVMContext &context)
std::unordered_map< llvm::Value *, HoistedLiteralLoadLocator > row_func_hoisted_literals_
Definition: CgenState.h:416
llvm::IRBuilder ir_builder_
Definition: CgenState.h:384
int8_t boolval
Definition: Datum.h:72
bool get_is_null() const
Definition: Analyzer.h:347
void moveInValuesBitmap(std::unique_ptr< const InValuesBitmap > &in_values_bitmap)
Definition: CgenState.h:219
std::vector< llvm::Value * > str_constants_
Definition: CgenState.h:392
llvm::ConstantInt * llBool(const bool v) const
Definition: CgenState.h:263
std::unordered_map< int, std::vector< llvm::Value * > > query_func_literal_loads_
Definition: CgenState.h:410
bool needs_geos_
Definition: CgenState.h:406
InsertionOrderedMap filter_func_args_
Definition: CgenState.h:397
const bool contains_left_deep_outer_join_
Definition: CgenState.h:394
llvm::Value * buffer
Definition: CgenState.h:36
llvm::Type * get_int_type(const int width, llvm::LLVMContext &context)
const std::unordered_map< int, LiteralValues > & getLiterals() const
Definition: CgenState.h:188
double inline_fp_null_val(const SQL_TYPE_INFO &ti)
int32_t intval
Definition: Datum.h:75
std::unordered_map< std::string, llvm::Value * > geo_target_cache_
Definition: CgenState.h:404
llvm::ConstantFP * llFp(const double v) const
Definition: CgenState.h:258
std::string to_string(char const *&&v)
static size_t literalBytes(const CgenState::LiteralValue &lit)
Definition: CgenState.h:418
std::vector< FunctionOperValue > ext_call_cache_
Definition: CgenState.h:390
llvm::Function * row_func_
Definition: CgenState.h:374
boost::variant< int8_t, int16_t, int32_t, int64_t, float, double, std::pair< std::string, shared::StringDictKey >, std::string, std::vector< double >, std::vector< int32_t >, std::vector< int8_t >, std::pair< std::vector< int8_t >, int >> LiteralValue
Definition: CgenState.h:185
float floatval
Definition: Datum.h:77
std::vector< llvm::Value * > group_by_expr_cache_
Definition: CgenState.h:391
EncodingType
Definition: sqltypes.h:240
llvm::Module * module_
Definition: CgenState.h:373
size_t executor_id_
Definition: CgenState.h:276
llvm::LLVMContext & context_
Definition: CgenState.h:382
llvm::Function * current_func_
Definition: CgenState.h:376
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 TreeModelPredictionMgr * moveTreeModelPredictionMgr(std::unique_ptr< const TreeModelPredictionMgr > &&tree_model_prediction_mgr)
Definition: CgenState.h:205
static size_t addAligned(const size_t off_in, const size_t alignment)
Definition: CgenState.h:449
llvm::CallInst * filter_func_call_
Definition: CgenState.h:380
llvm::ConstantInt * inlineIntNull(const SQLTypeInfo &)
Definition: CgenState.cpp:65
int64_t bigintval
Definition: Datum.h:76
std::vector< LiteralValue > LiteralValues
Definition: CgenState.h:186
const InValuesBitmap * addInValuesBitmap(std::unique_ptr< InValuesBitmap > &in_values_bitmap)
Definition: CgenState.h:211
void replaceFunctionForGpu(const std::string &fcn_to_replace, llvm::Function *fn)
Definition: CgenState.cpp:329
std::unordered_map< int, size_t > literal_bytes_
Definition: CgenState.h:480
int16_t smallintval
Definition: Datum.h:74
std::unordered_map< int, llvm::Value * > scan_idx_to_hash_pos_
Definition: CgenState.h:396
bool needs_error_check_
Definition: CgenState.h:405
llvm::ConstantFP * llFp(const float v) const
Definition: CgenState.h:253
std::vector< std::string > gpuFunctionsToReplace(llvm::Function *fn)
Definition: CgenState.cpp:306
llvm::IRBuilder query_func_entry_ir_builder_
Definition: CgenState.h:409
llvm::BasicBlock * filter_func_bb_
Definition: CgenState.h:378
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:79
llvm::Value * emitCall(const std::string &fname, const std::vector< llvm::Value * > &args)
Definition: CgenState.cpp:217
std::string * stringval
Definition: Datum.h:81
SQLTypes decimal_to_int_type(const SQLTypeInfo &ti)
Definition: Datum.cpp:561
llvm::Constant * inlineNull(const SQLTypeInfo &)
Definition: CgenState.cpp:116
void set_module_shallow_copy(const std::unique_ptr< llvm::Module > &module, bool always_clone=false)
Definition: CgenState.cpp:380
std::vector< std::unique_ptr< const InValuesBitmap > > in_values_bitmaps_
Definition: CgenState.h:398
Definition: sqltypes.h:79
Definition: sqltypes.h:80
llvm::Function * filter_func_
Definition: CgenState.h:375
std::unordered_map< int, LiteralValues > literals_
Definition: CgenState.h:479
std::vector< llvm::Value * > frag_offsets_
Definition: CgenState.h:393
llvm::Value * is_null
Definition: CgenState.h:38
size_t getLiteralBufferUsage(const int device_id)
Definition: CgenState.h:236
Datum get_constval() const
Definition: Analyzer.h:348
void emitErrorCheck(llvm::Value *condition, llvm::Value *errorCode, std::string label)
Definition: CgenState.cpp:241
Definition: sqltypes.h:68
std::vector< std::unique_ptr< const TreeModelPredictionMgr > > tree_model_prediction_mgrs_
Definition: CgenState.h:399
llvm::ConstantInt * llInt(const T v) const
Definition: CgenState.h:249
#define CHECK(condition)
Definition: Logger.h:291
llvm::ValueToValueMapTy vmap_
Definition: CgenState.h:383
int64_t inline_int_null_val(const SQL_TYPE_INFO &ti)
llvm::ConstantInt * ll_bool(const bool v, llvm::LLVMContext &context)
const StringDictionaryTranslationMgr * moveStringDictionaryTranslationMgr(std::unique_ptr< const StringDictionaryTranslationMgr > &&str_dict_translation_mgr)
Definition: CgenState.h:199
Definition: sqltypes.h:72
std::vector< std::unique_ptr< const StringDictionaryTranslationMgr > > str_dict_translation_mgrs_
Definition: CgenState.h:401
std::tuple< size_t, size_t > getOrAddLiteral(const T &val, const int device_id)
Definition: CgenState.h:462
llvm::Value * size
Definition: CgenState.h:37
llvm::CallInst * row_func_call_
Definition: CgenState.h:379
CgenState(const size_t num_query_infos, const bool contains_left_deep_outer_join, Executor *executor)
Definition: CgenState.cpp:26
std::pair< llvm::ConstantInt *, llvm::ConstantInt * > inlineIntMaxMin(const size_t byte_width, const bool is_signed)
Definition: CgenState.cpp:121
double doubleval
Definition: Datum.h:78
llvm::BasicBlock * row_func_bb_
Definition: CgenState.h:377
std::tuple< size_t, size_t > getOrAddLiteral(const Analyzer::Constant *constant, const EncodingType enc_type, const shared::StringDictKey &dict_id, const int device_id)
Definition: CgenState.h:49
llvm::ConstantFP * inlineFpNull(const SQLTypeInfo &)
Definition: CgenState.cpp:104