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