OmniSciDB  c1a53651b2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CodeGenerator.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 <llvm/IR/Value.h>
20 
21 #include "../Analyzer/Analyzer.h"
22 #include "Execute.h"
23 #include "Shared/DbObjectKeys.h"
24 
25 // Code generation utility to be used for queries and scalar expressions.
27  public:
29  : executor_(executor)
30  , cgen_state_(executor->cgen_state_.get())
31  , plan_state_(executor->plan_state_.get()) {}
32 
33  // Overload which can be used without an executor, for SQL scalar expression code
34  // generation.
35  CodeGenerator(CgenState* cgen_state, PlanState* plan_state)
36  : executor_(nullptr), cgen_state_(cgen_state), plan_state_(plan_state) {}
37 
38  // Generates IR value(s) for the given analyzer expression.
39  std::vector<llvm::Value*> codegen(const Analyzer::Expr*,
40  const bool fetch_columns,
41  const CompilationOptions&);
42 
43  llvm::Value* codegenPerRowStringOper(const Analyzer::StringOper* string_oper,
44  const CompilationOptions& co);
45 
46  llvm::Value* codegenPseudoStringOper(
47  const Analyzer::ColumnVar*,
48  const std::vector<StringOps_Namespace::StringOpInfo>& string_op_infos,
49  const CompilationOptions&);
50 
51  // Generates constant values in the literal buffer of a query.
52  std::vector<llvm::Value*> codegenHoistedConstants(
53  const std::vector<const Analyzer::Constant*>& constants,
54  const EncodingType enc_type,
55  const shared::StringDictKey& dict_id);
56 
57  static llvm::ConstantInt* codegenIntConst(const Analyzer::Constant* constant,
58  CgenState* cgen_state);
59 
60  llvm::Value* codegenCastBetweenIntTypes(llvm::Value* operand_lv,
61  const SQLTypeInfo& operand_ti,
62  const SQLTypeInfo& ti,
63  bool upscale = true);
64 
65  void codegenCastBetweenIntTypesOverflowChecks(llvm::Value* operand_lv,
66  const SQLTypeInfo& operand_ti,
67  const SQLTypeInfo& ti,
68  const int64_t scale);
69 
70  // Generates the index of the current row in the context of query execution.
71  llvm::Value* posArg(const Analyzer::Expr*) const;
72 
73  llvm::Value* toBool(llvm::Value*);
74 
75  llvm::Value* castArrayPointer(llvm::Value* ptr, const SQLTypeInfo& elem_ti);
76 
77  static std::unordered_set<llvm::Function*> markDeadRuntimeFuncs(
78  llvm::Module& module,
79  const std::vector<llvm::Function*>& roots,
80  const std::vector<llvm::Function*>& leaves);
81 
83  llvm::Function* func,
84  const std::unordered_set<llvm::Function*>& live_funcs,
85  const CompilationOptions& co);
86 
87  static std::string generatePTX(const std::string& cuda_llir,
88  llvm::TargetMachine* nvptx_target_machine,
89  llvm::LLVMContext& context);
90 
91  static std::unique_ptr<llvm::TargetMachine> initializeNVPTXBackend(
93 
94  static bool alwaysCloneRuntimeFunction(const llvm::Function* func);
95 
96  struct GPUTarget {
97  llvm::TargetMachine* nvptx_target_machine;
101  };
102 
103  static void linkModuleWithLibdevice(Executor* executor,
104  llvm::Module& module,
105  llvm::PassManagerBuilder& pass_manager_builder,
106  const GPUTarget& gpu_target);
107 
108  static std::shared_ptr<GpuCompilationContext> generateNativeGPUCode(
109  Executor* executor,
110  llvm::Function* func,
111  llvm::Function* wrapper_func,
112  const std::unordered_set<llvm::Function*>& live_funcs,
113  const bool is_gpu_smem_used,
114  const CompilationOptions& co,
115  const GPUTarget& gpu_target);
116 
117  static void link_udf_module(const std::unique_ptr<llvm::Module>& udf_module,
118  llvm::Module& module,
119  CgenState* cgen_state,
120  llvm::Linker::Flags flags = llvm::Linker::Flags::None);
121 
122  static bool prioritizeQuals(const RelAlgExecutionUnit& ra_exe_unit,
123  std::vector<Analyzer::Expr*>& primary_quals,
124  std::vector<Analyzer::Expr*>& deferred_quals,
125  const PlanState::HoistedFiltersSet& hoisted_quals);
126 
127  struct ExecutorRequired : public std::runtime_error {
129  : std::runtime_error("Executor required to generate this expression") {}
130  };
131 
134  Executor* executor,
135  llvm::Value* nullable_lv,
136  const SQLTypeInfo& nullable_ti,
137  const std::string& name = "");
138 
139  llvm::Value* finalize(llvm::Value* null_lv, llvm::Value* notnull_lv);
140 
141  CgenState* cgen_state{nullptr};
142  std::string name;
143  llvm::BasicBlock* nullcheck_bb{nullptr};
144  llvm::PHINode* nullcheck_value{nullptr};
145  std::unique_ptr<DiamondCodegen> null_check;
146  };
147 
148  static ArrayLoadCodegen codegenGeoArrayLoadAndNullcheck(llvm::Value* byte_stream,
149  llvm::Value* pos,
150  const SQLTypeInfo& ti,
151  CgenState* cgen_state);
152 
153  llvm::Value* codegenCastBetweenTimestamps(llvm::Value* ts_lv,
154  const SQLTypeInfo& operand_dimen,
155  const SQLTypeInfo& target_dimen,
156  const bool nullable);
157 
158  // Generate the position for the given window function and the query iteration position.
159  llvm::Value* codegenWindowPosition(const WindowFunctionContext* window_func_context,
160  llvm::Value* pos_arg);
161 
162  private:
163  std::vector<llvm::Value*> codegen(const Analyzer::Constant*,
164  const EncodingType enc_type,
165  const shared::StringDictKey& dict_id,
166  const CompilationOptions&);
167 
168  virtual std::vector<llvm::Value*> codegenColumn(const Analyzer::ColumnVar*,
169  const bool fetch_column,
170  const CompilationOptions&);
171 
172  llvm::Value* codegenArith(const Analyzer::BinOper*, const CompilationOptions&);
173 
174  llvm::Value* codegenUMinus(const Analyzer::UOper*, const CompilationOptions&);
175 
176  llvm::Value* codegenCmp(const Analyzer::BinOper*, const CompilationOptions&);
177 
178  llvm::Value* codegenCmp(const SQLOps,
179  const SQLQualifier,
180  std::vector<llvm::Value*>,
181  const SQLTypeInfo&,
182  const Analyzer::Expr*,
183  const CompilationOptions&);
184 
185  llvm::Value* codegenIsNull(const Analyzer::UOper*, const CompilationOptions&);
186 
187  llvm::Value* codegenIsNullNumber(llvm::Value*, const SQLTypeInfo&);
188 
189  llvm::Value* codegenLogical(const Analyzer::BinOper*, const CompilationOptions&);
190 
191  llvm::Value* codegenLogical(const Analyzer::UOper*, const CompilationOptions&);
192 
193  llvm::Value* codegenCast(const Analyzer::UOper*, const CompilationOptions&);
194 
195  llvm::Value* codegenCast(llvm::Value* operand_lv,
196  const SQLTypeInfo& operand_ti,
197  const SQLTypeInfo& ti,
198  const bool operand_is_const,
199  const CompilationOptions& co);
200 
201  llvm::Value* codegen(const Analyzer::InValues*, const CompilationOptions&);
202 
203  llvm::Value* codegen(const Analyzer::InIntegerSet* expr, const CompilationOptions& co);
204 
205  std::vector<llvm::Value*> codegen(const Analyzer::CaseExpr*, const CompilationOptions&);
206 
207  llvm::Value* codegen(const Analyzer::ExtractExpr*, const CompilationOptions&);
208 
209  llvm::Value* codegen(const Analyzer::DateaddExpr*, const CompilationOptions&);
210 
211  llvm::Value* codegen(const Analyzer::DatediffExpr*, const CompilationOptions&);
212 
213  llvm::Value* codegen(const Analyzer::DatetruncExpr*, const CompilationOptions&);
214 
215  llvm::Value* codegen(const Analyzer::CharLengthExpr*, const CompilationOptions&);
216 
217  llvm::Value* codegen(const Analyzer::KeyForStringExpr*, const CompilationOptions&);
218 
219  llvm::Value* codegen(const Analyzer::SampleRatioExpr*, const CompilationOptions&);
220 
221  llvm::Value* codegen(const Analyzer::WidthBucketExpr*, const CompilationOptions&);
222 
224  const CompilationOptions&);
225 
227  const CompilationOptions&);
228 
229  llvm::Value* codegen(const Analyzer::StringOper*, const CompilationOptions&);
230 
231  llvm::Value* codegen(const Analyzer::LikeExpr*, const CompilationOptions&);
232 
233  llvm::Value* codegen(const Analyzer::RegexpExpr*, const CompilationOptions&);
234 
235  llvm::Value* codegenUnnest(const Analyzer::UOper*, const CompilationOptions&);
236 
237  llvm::Value* codegenArrayAt(const Analyzer::BinOper*, const CompilationOptions&);
238 
239  llvm::Value* codegen(const Analyzer::CardinalityExpr*, const CompilationOptions&);
240 
241  std::vector<llvm::Value*> codegenArrayExpr(const Analyzer::ArrayExpr*,
242  const CompilationOptions&);
243 
244  std::vector<llvm::Value*> codegenGeoColumnVar(const Analyzer::GeoColumnVar*,
245  const bool fetch_columns,
246  const CompilationOptions& co);
247 
248  std::vector<llvm::Value*> codegenGeoExpr(const Analyzer::GeoExpr*,
249  const CompilationOptions&);
250 
251  std::vector<llvm::Value*> codegenGeoConstant(const Analyzer::GeoConstant*,
252  const CompilationOptions&);
253 
254  std::vector<llvm::Value*> codegenGeoOperator(const Analyzer::GeoOperator*,
255  const CompilationOptions&);
256 
257  std::vector<llvm::Value*> codegenGeoUOper(const Analyzer::GeoUOper*,
258  const CompilationOptions&);
259 
260  std::vector<llvm::Value*> codegenGeoBinOper(const Analyzer::GeoBinOper*,
261  const CompilationOptions&);
262 
263  std::vector<llvm::Value*> codegenGeosPredicateCall(const std::string&,
264  std::vector<llvm::Value*>,
265  const CompilationOptions&);
266 
267  std::vector<llvm::Value*> codegenGeosConstructorCall(const std::string&,
268  std::vector<llvm::Value*>,
269  llvm::Value*,
270  const CompilationOptions&);
271 
272  std::vector<llvm::Value*> codegenGeoArgs(
273  const std::vector<std::shared_ptr<Analyzer::Expr>>&,
274  const CompilationOptions&);
275 
276  llvm::Value* codegenFunctionOper(const Analyzer::FunctionOper*,
277  const CompilationOptions&);
278 
281  const CompilationOptions&);
282 
283  llvm::Value* codegen(const Analyzer::BinOper*, const CompilationOptions&);
284 
285  llvm::Value* codegen(const Analyzer::UOper*, const CompilationOptions&);
286 
287  std::vector<llvm::Value*> codegenHoistedConstantsLoads(
288  const SQLTypeInfo& type_info,
289  const EncodingType enc_type,
290  const shared::StringDictKey& dict_id,
291  const int16_t lit_off,
292  const size_t lit_bytes);
293 
294  std::vector<llvm::Value*> codegenHoistedConstantsPlaceholders(
295  const SQLTypeInfo& type_info,
296  const EncodingType enc_type,
297  const int16_t lit_off,
298  const std::vector<llvm::Value*>& literal_loads);
299 
300  std::vector<llvm::Value*> codegenColVar(const Analyzer::ColumnVar*,
301  const bool fetch_column,
302  const bool update_query_plan,
303  const CompilationOptions&);
304 
305  llvm::Value* codegenFixedLengthColVar(
306  const Analyzer::ColumnVar* col_var,
307  llvm::Value* col_byte_stream,
308  llvm::Value* pos_arg,
309  const WindowFunctionContext* window_function_context = nullptr);
310 
311  // Generates code for a fixed length column when a window function is active.
313  const Analyzer::ColumnVar* col_var,
314  llvm::Value* col_byte_stream,
315  llvm::Value* pos_arg,
316  const WindowFunctionContext* window_function_context = nullptr);
317 
318  std::vector<llvm::Value*> codegenVariableLengthStringColVar(
319  llvm::Value* col_byte_stream,
320  llvm::Value* pos_arg);
321 
322  llvm::Value* codegenRowId(const Analyzer::ColumnVar* col_var,
323  const CompilationOptions& co);
324 
325  llvm::Value* codgenAdjustFixedEncNull(llvm::Value*, const SQLTypeInfo&);
326 
327  std::vector<llvm::Value*> codegenOuterJoinNullPlaceholder(
328  const Analyzer::ColumnVar* col_var,
329  const bool fetch_column,
330  const CompilationOptions& co);
331 
332  llvm::Value* codegenIntArith(const Analyzer::BinOper*,
333  llvm::Value*,
334  llvm::Value*,
335  const CompilationOptions&);
336 
337  llvm::Value* codegenFpArith(const Analyzer::BinOper*, llvm::Value*, llvm::Value*);
338 
339  llvm::Value* codegenCastTimestampToTime(llvm::Value* ts_lv,
340  const int dimen,
341  const bool nullable);
342 
343  llvm::Value* codegenCastTimestampToDate(llvm::Value* ts_lv,
344  const int dimen,
345  const bool nullable);
346 
347  llvm::Value* codegenCastFromString(llvm::Value* operand_lv,
348  const SQLTypeInfo& operand_ti,
349  const SQLTypeInfo& ti,
350  const bool operand_is_const,
351  const CompilationOptions& co);
352 
353  llvm::Value* codegenCastNonStringToString(llvm::Value* operand_lv,
354  const SQLTypeInfo& operand_ti,
355  const SQLTypeInfo& ti,
356  const bool operand_is_const,
357  const CompilationOptions& co);
358 
359  llvm::Value* codegenCastToFp(llvm::Value* operand_lv,
360  const SQLTypeInfo& operand_ti,
361  const SQLTypeInfo& ti);
362 
363  llvm::Value* codegenCastFromFp(llvm::Value* operand_lv,
364  const SQLTypeInfo& operand_ti,
365  const SQLTypeInfo& ti);
366 
367  llvm::Value* codegenAdd(const Analyzer::BinOper*,
368  llvm::Value*,
369  llvm::Value*,
370  const std::string& null_typename,
371  const std::string& null_check_suffix,
372  const SQLTypeInfo&,
373  const CompilationOptions&);
374 
375  llvm::Value* codegenSub(const Analyzer::BinOper*,
376  llvm::Value*,
377  llvm::Value*,
378  const std::string& null_typename,
379  const std::string& null_check_suffix,
380  const SQLTypeInfo&,
381  const CompilationOptions&);
382 
383  void codegenSkipOverflowCheckForNull(llvm::Value* lhs_lv,
384  llvm::Value* rhs_lv,
385  llvm::BasicBlock* no_overflow_bb,
386  const SQLTypeInfo& ti);
387 
388  llvm::Value* codegenMul(const Analyzer::BinOper*,
389  llvm::Value*,
390  llvm::Value*,
391  const std::string& null_typename,
392  const std::string& null_check_suffix,
393  const SQLTypeInfo&,
394  const CompilationOptions&,
395  bool downscale = true);
396 
397  llvm::Value* codegenDiv(llvm::Value*,
398  llvm::Value*,
399  const std::string& null_typename,
400  const std::string& null_check_suffix,
401  const SQLTypeInfo&,
402  bool upscale = true);
403 
404  llvm::Value* codegenDeciDiv(const Analyzer::BinOper*, const CompilationOptions&);
405 
406  llvm::Value* codegenMod(llvm::Value*,
407  llvm::Value*,
408  const std::string& null_typename,
409  const std::string& null_check_suffix,
410  const SQLTypeInfo&);
411 
412  llvm::Value* codegenCase(const Analyzer::CaseExpr*,
413  llvm::Type* case_llvm_type,
414  const bool is_real_str,
415  const CompilationOptions&);
416 
417  llvm::Value* codegenExtractHighPrecisionTimestamps(llvm::Value*,
418  const SQLTypeInfo&,
419  const ExtractField&);
420 
421  llvm::Value* codegenDateTruncHighPrecisionTimestamps(llvm::Value*,
422  const SQLTypeInfo&,
423  const DatetruncField&);
424 
425  llvm::Value* codegenCmpDecimalConst(const SQLOps,
426  const SQLQualifier,
427  const Analyzer::Expr*,
428  const SQLTypeInfo&,
429  const Analyzer::Expr*,
430  const CompilationOptions&);
431 
432  llvm::Value* codegenOverlaps(const SQLOps,
433  const SQLQualifier,
434  const std::shared_ptr<Analyzer::Expr>,
435  const std::shared_ptr<Analyzer::Expr>,
436  const CompilationOptions&);
437 
438  llvm::Value* codegenStrCmp(const SQLOps,
439  const SQLQualifier,
440  const std::shared_ptr<Analyzer::Expr>,
441  const std::shared_ptr<Analyzer::Expr>,
442  const CompilationOptions&);
443 
444  llvm::Value* codegenQualifierCmp(const SQLOps,
445  const SQLQualifier,
446  std::vector<llvm::Value*>,
447  const Analyzer::Expr*,
448  const CompilationOptions&);
449 
450  llvm::Value* codegenLogicalShortCircuit(const Analyzer::BinOper*,
451  const CompilationOptions&);
452 
453  llvm::Value* codegenDictLike(const std::shared_ptr<Analyzer::Expr> arg,
454  const Analyzer::Constant* pattern,
455  const bool ilike,
456  const bool is_simple,
457  const char escape_char,
458  const CompilationOptions&);
459 
460  llvm::Value* codegenDictStrCmp(const std::shared_ptr<Analyzer::Expr>,
461  const std::shared_ptr<Analyzer::Expr>,
462  const SQLOps,
463  const CompilationOptions& co);
464 
465  llvm::Value* codegenDictRegexp(const std::shared_ptr<Analyzer::Expr> arg,
466  const Analyzer::Constant* pattern,
467  const char escape_char,
468  const CompilationOptions&);
469 
470  // Returns the IR value which holds true iff at least one match has been found for outer
471  // join, null if there's no outer join condition on the given nesting level.
472  llvm::Value* foundOuterJoinMatch(const size_t nesting_level) const;
473 
475 
476  llvm::Value* colByteStream(const Analyzer::ColumnVar* col_var,
477  const bool fetch_column,
478  const bool hoist_literals);
479 
480  std::shared_ptr<const Analyzer::Expr> hashJoinLhs(const Analyzer::ColumnVar* rhs) const;
481 
482  std::shared_ptr<const Analyzer::ColumnVar> hashJoinLhsTuple(
483  const Analyzer::ColumnVar* rhs,
484  const Analyzer::BinOper* tautological_eq) const;
485 
486  bool needCastForHashJoinLhs(const Analyzer::ColumnVar* rhs) const;
487 
488  std::unique_ptr<InValuesBitmap> createInValuesBitmap(const Analyzer::InValues*,
489  const CompilationOptions&);
490 
491  bool checkExpressionRanges(const Analyzer::UOper*, int64_t, int64_t);
492 
493  bool checkExpressionRanges(const Analyzer::BinOper*, int64_t, int64_t);
494 
496  llvm::BasicBlock* args_null_bb;
497  llvm::BasicBlock* args_notnull_bb;
498  llvm::BasicBlock* orig_bb;
499  };
500 
501  std::tuple<ArgNullcheckBBs, llvm::Value*> beginArgsNullcheck(
502  const Analyzer::FunctionOper* function_oper,
503  const std::vector<llvm::Value*>& orig_arg_lvs);
504 
505  llvm::Value* endArgsNullcheck(const ArgNullcheckBBs&,
506  llvm::Value*,
507  llvm::Value*,
508  const Analyzer::FunctionOper*);
509 
511  const std::vector<llvm::Value*>&);
512 
513  llvm::Value* codegenCompression(const SQLTypeInfo& type_info);
514 
515  std::pair<llvm::Value*, llvm::Value*> codegenArrayBuff(llvm::Value* chunk,
516  llvm::Value* row_pos,
517  SQLTypes array_type,
518  bool cast_and_extend);
519 
520  void codegenBufferArgs(const std::string& udf_func_name,
521  size_t param_num,
522  llvm::Value* buffer_buf,
523  llvm::Value* buffer_size,
524  llvm::Value* buffer_is_null,
525  std::vector<llvm::Value*>& output_args);
526 
527  llvm::StructType* createPointStructType(const std::string& udf_func_name,
528  size_t param_num);
529 
530  void codegenGeoPointArgs(const std::string& udf_func_name,
531  size_t param_num,
532  llvm::Value* point_buf,
533  llvm::Value* point_size,
534  llvm::Value* compression,
535  llvm::Value* input_srid,
536  llvm::Value* output_srid,
537  std::vector<llvm::Value*>& output_args);
538 
539  llvm::StructType* createMultiPointStructType(const std::string& udf_func_name,
540  size_t param_num);
541 
542  void codegenGeoMultiPointArgs(const std::string& udf_func_name,
543  size_t param_num,
544  llvm::Value* multi_point_buf,
545  llvm::Value* multi_point_size,
546  // TODO: bounds?
547  llvm::Value* compression,
548  llvm::Value* input_srid,
549  llvm::Value* output_srid,
550  std::vector<llvm::Value*>& output_args);
551 
552  llvm::StructType* createLineStringStructType(const std::string& udf_func_name,
553  size_t param_num);
554 
555  void codegenGeoLineStringArgs(const std::string& udf_func_name,
556  size_t param_num,
557  llvm::Value* line_string_buf,
558  llvm::Value* line_string_size,
559  llvm::Value* compression,
560  llvm::Value* input_srid,
561  llvm::Value* output_srid,
562  std::vector<llvm::Value*>& output_args);
563 
564  llvm::StructType* createMultiLineStringStructType(const std::string& udf_func_name,
565  size_t param_num);
566 
567  void codegenGeoMultiLineStringArgs(const std::string& udf_func_name,
568  size_t param_num,
569  llvm::Value* multi_linestring_coords,
570  llvm::Value* multi_linestring_size,
571  llvm::Value* linestring_sizes,
572  llvm::Value* linestring_sizes_size,
573  // TODO: bounds?
574  llvm::Value* compression,
575  llvm::Value* input_srid,
576  llvm::Value* output_srid,
577  std::vector<llvm::Value*>& output_args);
578 
579  llvm::StructType* createPolygonStructType(const std::string& udf_func_name,
580  size_t param_num);
581 
582  void codegenGeoPolygonArgs(const std::string& udf_func_name,
583  size_t param_num,
584  llvm::Value* polygon_buf,
585  llvm::Value* polygon_size,
586  llvm::Value* ring_sizes_buf,
587  llvm::Value* num_rings,
588  llvm::Value* compression,
589  llvm::Value* input_srid,
590  llvm::Value* output_srid,
591  std::vector<llvm::Value*>& output_args);
592 
593  llvm::StructType* createMultiPolygonStructType(const std::string& udf_func_name,
594  size_t param_num);
595 
596  void codegenGeoMultiPolygonArgs(const std::string& udf_func_name,
597  size_t param_num,
598  llvm::Value* polygon_coords,
599  llvm::Value* polygon_coords_size,
600  llvm::Value* ring_sizes_buf,
601  llvm::Value* ring_sizes,
602  llvm::Value* polygon_bounds,
603  llvm::Value* polygon_bounds_sizes,
604  llvm::Value* compression,
605  llvm::Value* input_srid,
606  llvm::Value* output_srid,
607  std::vector<llvm::Value*>& output_args);
608 
609  std::vector<llvm::Value*> codegenFunctionOperCastArgs(
610  const Analyzer::FunctionOper*,
611  const ExtensionFunction*,
612  const std::vector<llvm::Value*>&,
613  const std::vector<size_t>&,
614  const std::unordered_map<llvm::Value*, llvm::Value*>&,
615  const CompilationOptions&);
616 
617  llvm::StructType* createStringViewStructType();
618 
619  // Return LLVM intrinsic providing fast arithmetic with overflow check
620  // for the given binary operation.
621  llvm::Function* getArithWithOverflowIntrinsic(const Analyzer::BinOper* bin_oper,
622  llvm::Type* type);
623 
624  // Generate code for the given binary operation with overflow check.
625  // Signed integer add, sub and mul operations are supported. Overflow
626  // check is performed using LLVM arithmetic intrinsics which are not
627  // supported for GPU. Return the IR value which holds operation result.
628  llvm::Value* codegenBinOpWithOverflowForCPU(const Analyzer::BinOper* bin_oper,
629  llvm::Value* lhs_lv,
630  llvm::Value* rhs_lv,
631  const std::string& null_check_suffix,
632  const SQLTypeInfo& ti);
633 
634  std::pair<std::vector<llvm::Value*>, std::unique_ptr<CodeGenerator::NullCheckCodegen>>
636  const CompilationOptions& co,
637  const size_t arg_idx,
638  const bool codegen_nullcheck);
639 
640  Executor* executor_;
641 
642  protected:
643  Executor* executor() const {
644  if (!executor_) {
645  throw ExecutorRequired();
646  }
647  return executor_;
648  }
649 
652 
653  friend class GroupByAndAggregate;
654 };
655 
656 // Code generator specialized for scalar expressions which doesn't require an executor.
658  public:
659  // Constructor which takes the runtime module.
660  ScalarCodeGenerator(std::unique_ptr<llvm::Module> llvm_module)
661  : CodeGenerator(nullptr, nullptr), module_(std::move(llvm_module)) {}
662 
663  // Function generated for a given analyzer expression. For GPU, a wrapper which meets
664  // the kernel signature constraints (returns void, takes all arguments as pointers) is
665  // generated. Also returns the list of column expressions for which compatible input
666  // parameters must be passed to the input of the generated function.
668  llvm::Function* func;
669  llvm::Function* wrapper_func;
670  std::vector<std::shared_ptr<Analyzer::ColumnVar>> inputs;
671  };
672 
673  // Compiles the given scalar expression to IR and the list of columns in the expression,
674  // needed to provide inputs to the generated function.
676  const bool fetch_columns,
677  const CompilationOptions& co);
678 
679  // Generates the native function pointers for each device.
680  // NB: this is separated from the compile method to allow building higher level code
681  // generators which can inline the IR for evaluating a single expression (for example
682  // loops).
683  std::vector<void*> generateNativeCode(Executor* executor,
684  const CompiledExpression& compiled_expression,
685  const CompilationOptions& co);
686 
688 
689  using ColumnMap =
690  std::unordered_map<InputColDescriptor, std::shared_ptr<Analyzer::ColumnVar>>;
691 
692  private:
693  std::vector<llvm::Value*> codegenColumn(const Analyzer::ColumnVar*,
694  const bool fetch_column,
695  const CompilationOptions&) override;
696 
697  // Collect the columns used by the given analyzer expressions and fills in the column
698  // map to be used during code generation.
700 
701  std::vector<void*> generateNativeGPUCode(Executor* executor,
702  llvm::Function* func,
703  llvm::Function* wrapper_func,
704  const CompilationOptions& co);
705 
706  std::unique_ptr<llvm::Module> module_;
708  std::unique_ptr<CgenState> own_cgen_state_;
709  std::unique_ptr<PlanState> own_plan_state_;
710  std::unique_ptr<CudaMgr_Namespace::CudaMgr> cuda_mgr_;
711  std::shared_ptr<GpuCompilationContext> gpu_compilation_context_;
712  std::unique_ptr<llvm::TargetMachine> nvptx_target_machine_;
713 };
714 
719 std::unique_ptr<llvm::Module> runtime_module_shallow_copy(CgenState* cgen_state);
720 
724 std::vector<llvm::Value*> generate_column_heads_load(const int num_columns,
725  llvm::Value* byte_stream_arg,
726  llvm::IRBuilder<>& ir_builder,
727  llvm::LLVMContext& ctx);
llvm::StructType * createLineStringStructType(const std::string &udf_func_name, size_t param_num)
void codegenGeoMultiPolygonArgs(const std::string &udf_func_name, size_t param_num, llvm::Value *polygon_coords, llvm::Value *polygon_coords_size, llvm::Value *ring_sizes_buf, llvm::Value *ring_sizes, llvm::Value *polygon_bounds, llvm::Value *polygon_bounds_sizes, llvm::Value *compression, llvm::Value *input_srid, llvm::Value *output_srid, std::vector< llvm::Value * > &output_args)
llvm::Value * codegenIntArith(const Analyzer::BinOper *, llvm::Value *, llvm::Value *, const CompilationOptions &)
llvm::Value * codegenPerRowStringOper(const Analyzer::StringOper *string_oper, const CompilationOptions &co)
CompiledExpression compile(const Analyzer::Expr *expr, const bool fetch_columns, const CompilationOptions &co)
NullCheckCodegen(CgenState *cgen_state, Executor *executor, llvm::Value *nullable_lv, const SQLTypeInfo &nullable_ti, const std::string &name="")
Definition: IRCodegen.cpp:1426
llvm::Value * codegenCastFromFp(llvm::Value *operand_lv, const SQLTypeInfo &operand_ti, const SQLTypeInfo &ti)
Definition: CastIR.cpp:601
std::vector< llvm::Value * > codegenColumn(const Analyzer::ColumnVar *, const bool fetch_column, const CompilationOptions &) override
llvm::Value * codegenStrCmp(const SQLOps, const SQLQualifier, const std::shared_ptr< Analyzer::Expr >, const std::shared_ptr< Analyzer::Expr >, const CompilationOptions &)
Definition: CompareIR.cpp:369
llvm::Value * codegenConstantWidthBucketExpr(const Analyzer::WidthBucketExpr *, const CompilationOptions &)
Definition: IRCodegen.cpp:303
std::unique_ptr< llvm::Module > runtime_module_shallow_copy(CgenState *cgen_state)
llvm::BasicBlock * args_notnull_bb
llvm::BasicBlock * nullcheck_bb
SQLTypes
Definition: sqltypes.h:55
std::unique_ptr< PlanState > own_plan_state_
llvm::Value * codegenArith(const Analyzer::BinOper *, const CompilationOptions &)
CgenState * cgen_state_
ExecutionEngineWrapper execution_engine_
void codegenGeoPolygonArgs(const std::string &udf_func_name, size_t param_num, llvm::Value *polygon_buf, llvm::Value *polygon_size, llvm::Value *ring_sizes_buf, llvm::Value *num_rings, llvm::Value *compression, llvm::Value *input_srid, llvm::Value *output_srid, std::vector< llvm::Value * > &output_args)
llvm::Value * codegenCastNonStringToString(llvm::Value *operand_lv, const SQLTypeInfo &operand_ti, const SQLTypeInfo &ti, const bool operand_is_const, const CompilationOptions &co)
Definition: CastIR.cpp:350
SQLQualifier
Definition: sqldefs.h:71
llvm::Value * codegenRowId(const Analyzer::ColumnVar *col_var, const CompilationOptions &co)
Definition: ColumnIR.cpp:376
llvm::StructType * createMultiPointStructType(const std::string &udf_func_name, size_t param_num)
llvm::Value * codegenFixedLengthColVarInWindow(const Analyzer::ColumnVar *col_var, llvm::Value *col_byte_stream, llvm::Value *pos_arg, const WindowFunctionContext *window_function_context=nullptr)
Definition: ColumnIR.cpp:291
std::vector< llvm::Value * > codegenFunctionOperCastArgs(const Analyzer::FunctionOper *, const ExtensionFunction *, const std::vector< llvm::Value * > &, const std::vector< size_t > &, const std::unordered_map< llvm::Value *, llvm::Value * > &, const CompilationOptions &)
llvm::StructType * createMultiLineStringStructType(const std::string &udf_func_name, size_t param_num)
SQLOps
Definition: sqldefs.h:28
llvm::Value * codegenMod(llvm::Value *, llvm::Value *, const std::string &null_typename, const std::string &null_check_suffix, const SQLTypeInfo &)
llvm::Value * codegenFunctionOperNullArg(const Analyzer::FunctionOper *, const std::vector< llvm::Value * > &)
std::vector< llvm::Value * > codegenOuterJoinNullPlaceholder(const Analyzer::ColumnVar *col_var, const bool fetch_column, const CompilationOptions &co)
Definition: ColumnIR.cpp:481
std::unique_ptr< llvm::TargetMachine > nvptx_target_machine_
llvm::Value * posArg(const Analyzer::Expr *) const
Definition: ColumnIR.cpp:580
std::shared_ptr< GpuCompilationContext > gpu_compilation_context_
llvm::Value * castArrayPointer(llvm::Value *ptr, const SQLTypeInfo &elem_ti)
llvm::Value * codegenCastToFp(llvm::Value *operand_lv, const SQLTypeInfo &operand_ti, const SQLTypeInfo &ti)
Definition: CastIR.cpp:558
llvm::Value * codgenAdjustFixedEncNull(llvm::Value *, const SQLTypeInfo &)
Definition: ColumnIR.cpp:433
llvm::Value * codegenPseudoStringOper(const Analyzer::ColumnVar *, const std::vector< StringOps_Namespace::StringOpInfo > &string_op_infos, const CompilationOptions &)
llvm::Value * foundOuterJoinMatch(const size_t nesting_level) const
Definition: ColumnIR.cpp:474
llvm::Value * codegenExtractHighPrecisionTimestamps(llvm::Value *, const SQLTypeInfo &, const ExtractField &)
Definition: DateTimeIR.cpp:260
llvm::StructType * createPointStructType(const std::string &udf_func_name, size_t param_num)
virtual std::vector< llvm::Value * > codegenColumn(const Analyzer::ColumnVar *, const bool fetch_column, const CompilationOptions &)
Definition: ColumnIR.cpp:93
std::unordered_set< std::shared_ptr< Analyzer::Expr >> HoistedFiltersSet
Definition: PlanState.h:44
llvm::Value * codegenDeciDiv(const Analyzer::BinOper *, const CompilationOptions &)
std::vector< llvm::Value * > codegenHoistedConstants(const std::vector< const Analyzer::Constant * > &constants, const EncodingType enc_type, const shared::StringDictKey &dict_id)
Definition: ConstantIR.cpp:373
static ExecutionEngineWrapper generateNativeCPUCode(llvm::Function *func, const std::unordered_set< llvm::Function * > &live_funcs, const CompilationOptions &co)
llvm::Value * codegenArrayAt(const Analyzer::BinOper *, const CompilationOptions &)
Definition: ArrayIR.cpp:26
std::unordered_map< InputColDescriptor, std::shared_ptr< Analyzer::ColumnVar >> ColumnMap
static std::string generatePTX(const std::string &cuda_llir, llvm::TargetMachine *nvptx_target_machine, llvm::LLVMContext &context)
std::vector< llvm::Value * > codegenGeoBinOper(const Analyzer::GeoBinOper *, const CompilationOptions &)
Definition: GeoIR.cpp:242
const CudaMgr_Namespace::CudaMgr * cuda_mgr
Definition: CodeGenerator.h:98
void codegenBufferArgs(const std::string &udf_func_name, size_t param_num, llvm::Value *buffer_buf, llvm::Value *buffer_size, llvm::Value *buffer_is_null, std::vector< llvm::Value * > &output_args)
std::unique_ptr< CudaMgr_Namespace::CudaMgr > cuda_mgr_
llvm::Value * codegenFpArith(const Analyzer::BinOper *, llvm::Value *, llvm::Value *)
llvm::Value * codegenIsNull(const Analyzer::UOper *, const CompilationOptions &)
Definition: LogicalIR.cpp:380
llvm::TargetMachine * nvptx_target_machine
Definition: CodeGenerator.h:97
std::pair< llvm::Value *, llvm::Value * > codegenArrayBuff(llvm::Value *chunk, llvm::Value *row_pos, SQLTypes array_type, bool cast_and_extend)
std::shared_ptr< const Analyzer::Expr > hashJoinLhs(const Analyzer::ColumnVar *rhs) const
Definition: ColumnIR.cpp:618
llvm::Value * codegenWindowPosition(const WindowFunctionContext *window_func_context, llvm::Value *pos_arg)
Definition: ColumnIR.cpp:227
EncodingType
Definition: sqltypes.h:230
CudaMgr_Namespace::CudaMgr * getCudaMgr() const
std::vector< llvm::Value * > codegenGeoExpr(const Analyzer::GeoExpr *, const CompilationOptions &)
Definition: GeoIR.cpp:95
llvm::Value * codegenDiv(llvm::Value *, llvm::Value *, const std::string &null_typename, const std::string &null_check_suffix, const SQLTypeInfo &, bool upscale=true)
llvm::Value * codegenCmpDecimalConst(const SQLOps, const SQLQualifier, const Analyzer::Expr *, const SQLTypeInfo &, const Analyzer::Expr *, const CompilationOptions &)
Definition: CompareIR.cpp:401
std::tuple< ArgNullcheckBBs, llvm::Value * > beginArgsNullcheck(const Analyzer::FunctionOper *function_oper, const std::vector< llvm::Value * > &orig_arg_lvs)
std::vector< llvm::Value * > codegenGeoOperator(const Analyzer::GeoOperator *, const CompilationOptions &)
Definition: GeoIR.cpp:130
static std::unordered_set< llvm::Function * > markDeadRuntimeFuncs(llvm::Module &module, const std::vector< llvm::Function * > &roots, const std::vector< llvm::Function * > &leaves)
DatetruncField
Definition: DateTruncate.h:27
std::vector< llvm::Value * > codegenGeoUOper(const Analyzer::GeoUOper *, const CompilationOptions &)
Definition: GeoIR.cpp:162
void codegenSkipOverflowCheckForNull(llvm::Value *lhs_lv, llvm::Value *rhs_lv, llvm::BasicBlock *no_overflow_bb, const SQLTypeInfo &ti)
std::vector< llvm::Value * > codegenHoistedConstantsLoads(const SQLTypeInfo &type_info, const EncodingType enc_type, const shared::StringDictKey &dict_id, const int16_t lit_off, const size_t lit_bytes)
Definition: ConstantIR.cpp:142
std::vector< llvm::Value * > codegenHoistedConstantsPlaceholders(const SQLTypeInfo &type_info, const EncodingType enc_type, const int16_t lit_off, const std::vector< llvm::Value * > &literal_loads)
Definition: ConstantIR.cpp:280
CodeGenerator(Executor *executor)
Definition: CodeGenerator.h:28
void codegenGeoMultiPointArgs(const std::string &udf_func_name, size_t param_num, llvm::Value *multi_point_buf, llvm::Value *multi_point_size, llvm::Value *compression, llvm::Value *input_srid, llvm::Value *output_srid, std::vector< llvm::Value * > &output_args)
llvm::Value * codegenBinOpWithOverflowForCPU(const Analyzer::BinOper *bin_oper, llvm::Value *lhs_lv, llvm::Value *rhs_lv, const std::string &null_check_suffix, const SQLTypeInfo &ti)
llvm::Value * codegenWidthBucketExpr(const Analyzer::WidthBucketExpr *, const CompilationOptions &)
Definition: IRCodegen.cpp:376
llvm::Value * codegenFunctionOper(const Analyzer::FunctionOper *, const CompilationOptions &)
llvm::Value * codegenCastBetweenIntTypes(llvm::Value *operand_lv, const SQLTypeInfo &operand_ti, const SQLTypeInfo &ti, bool upscale=true)
Definition: CastIR.cpp:427
Executor * executor_
llvm::Value * codegenOverlaps(const SQLOps, const SQLQualifier, const std::shared_ptr< Analyzer::Expr >, const std::shared_ptr< Analyzer::Expr >, const CompilationOptions &)
Definition: CompareIR.cpp:285
llvm::Value * codegenDictStrCmp(const std::shared_ptr< Analyzer::Expr >, const std::shared_ptr< Analyzer::Expr >, const SQLOps, const CompilationOptions &co)
llvm::Value * codegenCastTimestampToDate(llvm::Value *ts_lv, const int dimen, const bool nullable)
Definition: CastIR.cpp:162
static void link_udf_module(const std::unique_ptr< llvm::Module > &udf_module, llvm::Module &module, CgenState *cgen_state, llvm::Linker::Flags flags=llvm::Linker::Flags::None)
std::vector< llvm::Value * > codegenArrayExpr(const Analyzer::ArrayExpr *, const CompilationOptions &)
Definition: ArrayIR.cpp:91
llvm::Value * codegenDictRegexp(const std::shared_ptr< Analyzer::Expr > arg, const Analyzer::Constant *pattern, const char escape_char, const CompilationOptions &)
llvm::BasicBlock * args_null_bb
void codegenGeoMultiLineStringArgs(const std::string &udf_func_name, size_t param_num, llvm::Value *multi_linestring_coords, llvm::Value *multi_linestring_size, llvm::Value *linestring_sizes, llvm::Value *linestring_sizes_size, llvm::Value *compression, llvm::Value *input_srid, llvm::Value *output_srid, std::vector< llvm::Value * > &output_args)
llvm::Function * getArithWithOverflowIntrinsic(const Analyzer::BinOper *bin_oper, llvm::Type *type)
std::vector< llvm::Value * > codegenColVar(const Analyzer::ColumnVar *, const bool fetch_column, const bool update_query_plan, const CompilationOptions &)
Definition: ColumnIR.cpp:105
ScalarCodeGenerator(std::unique_ptr< llvm::Module > llvm_module)
std::vector< llvm::Value * > codegenGeosConstructorCall(const std::string &, std::vector< llvm::Value * >, llvm::Value *, const CompilationOptions &)
Definition: GeoIR.cpp:464
llvm::Value * codegenUMinus(const Analyzer::UOper *, const CompilationOptions &)
void codegenGeoPointArgs(const std::string &udf_func_name, size_t param_num, llvm::Value *point_buf, llvm::Value *point_size, llvm::Value *compression, llvm::Value *input_srid, llvm::Value *output_srid, std::vector< llvm::Value * > &output_args)
PlanState * plan_state_
std::vector< llvm::Value * > codegen(const Analyzer::Expr *, const bool fetch_columns, const CompilationOptions &)
Definition: IRCodegen.cpp:30
static llvm::ConstantInt * codegenIntConst(const Analyzer::Constant *constant, CgenState *cgen_state)
Definition: ConstantIR.cpp:89
Expression class for string functions The &quot;arg&quot; constructor parameter must be an expression that reso...
Definition: Analyzer.h:1479
std::vector< llvm::Value * > codegenGeosPredicateCall(const std::string &, std::vector< llvm::Value * >, const CompilationOptions &)
Definition: GeoIR.cpp:431
llvm::StructType * createPolygonStructType(const std::string &udf_func_name, size_t param_num)
static std::shared_ptr< GpuCompilationContext > generateNativeGPUCode(Executor *executor, llvm::Function *func, llvm::Function *wrapper_func, const std::unordered_set< llvm::Function * > &live_funcs, const bool is_gpu_smem_used, const CompilationOptions &co, const GPUTarget &gpu_target)
llvm::Value * codegenQualifierCmp(const SQLOps, const SQLQualifier, std::vector< llvm::Value * >, const Analyzer::Expr *, const CompilationOptions &)
Definition: CompareIR.cpp:555
llvm::Value * endArgsNullcheck(const ArgNullcheckBBs &, llvm::Value *, llvm::Value *, const Analyzer::FunctionOper *)
llvm::Value * codegenSub(const Analyzer::BinOper *, llvm::Value *, llvm::Value *, const std::string &null_typename, const std::string &null_check_suffix, const SQLTypeInfo &, const CompilationOptions &)
void codegenCastBetweenIntTypesOverflowChecks(llvm::Value *operand_lv, const SQLTypeInfo &operand_ti, const SQLTypeInfo &ti, const int64_t scale)
Definition: CastIR.cpp:500
static bool alwaysCloneRuntimeFunction(const llvm::Function *func)
ColumnMap prepare(const Analyzer::Expr *)
static ArrayLoadCodegen codegenGeoArrayLoadAndNullcheck(llvm::Value *byte_stream, llvm::Value *pos, const SQLTypeInfo &ti, CgenState *cgen_state)
Definition: GeoIR.cpp:23
llvm::StructType * createStringViewStructType()
std::unique_ptr< CgenState > own_cgen_state_
llvm::Value * codegenCase(const Analyzer::CaseExpr *, llvm::Type *case_llvm_type, const bool is_real_str, const CompilationOptions &)
Definition: CaseIR.cpp:57
std::vector< llvm::Value * > generate_column_heads_load(const int num_columns, llvm::Value *byte_stream_arg, llvm::IRBuilder<> &ir_builder, llvm::LLVMContext &ctx)
static void linkModuleWithLibdevice(Executor *executor, llvm::Module &module, llvm::PassManagerBuilder &pass_manager_builder, const GPUTarget &gpu_target)
ExtractField
llvm::Value * toBool(llvm::Value *)
Definition: LogicalIR.cpp:343
std::vector< llvm::Value * > codegenGeoColumnVar(const Analyzer::GeoColumnVar *, const bool fetch_columns, const CompilationOptions &co)
Definition: GeoIR.cpp:52
static bool prioritizeQuals(const RelAlgExecutionUnit &ra_exe_unit, std::vector< Analyzer::Expr * > &primary_quals, std::vector< Analyzer::Expr * > &deferred_quals, const PlanState::HoistedFiltersSet &hoisted_quals)
Definition: LogicalIR.cpp:157
std::vector< void * > generateNativeGPUCode(Executor *executor, llvm::Function *func, llvm::Function *wrapper_func, const CompilationOptions &co)
llvm::Value * codegenFunctionOperWithCustomTypeHandling(const Analyzer::FunctionOperWithCustomTypeHandling *, const CompilationOptions &)
llvm::Value * codegenCmp(const Analyzer::BinOper *, const CompilationOptions &)
Definition: CompareIR.cpp:230
bool needCastForHashJoinLhs(const Analyzer::ColumnVar *rhs) const
Definition: ColumnIR.cpp:684
llvm::Value * codegenCastBetweenTimestamps(llvm::Value *ts_lv, const SQLTypeInfo &operand_dimen, const SQLTypeInfo &target_dimen, const bool nullable)
Definition: CastIR.cpp:199
std::pair< std::vector< llvm::Value * >, std::unique_ptr< CodeGenerator::NullCheckCodegen > > codegenStringFetchAndEncode(const Analyzer::StringOper *expr, const CompilationOptions &co, const size_t arg_idx, const bool codegen_nullcheck)
llvm::Value * codegenUnnest(const Analyzer::UOper *, const CompilationOptions &)
Definition: ArrayIR.cpp:20
std::vector< llvm::Value * > codegenGeoArgs(const std::vector< std::shared_ptr< Analyzer::Expr >> &, const CompilationOptions &)
Definition: GeoIR.cpp:350
llvm::Value * finalize(llvm::Value *null_lv, llvm::Value *notnull_lv)
Definition: IRCodegen.cpp:1463
llvm::Value * colByteStream(const Analyzer::ColumnVar *col_var, const bool fetch_column, const bool hoist_literals)
Definition: ColumnIR.cpp:564
llvm::Value * codegenIsNullNumber(llvm::Value *, const SQLTypeInfo &)
Definition: LogicalIR.cpp:412
llvm::Value * codegenLogical(const Analyzer::BinOper *, const CompilationOptions &)
Definition: LogicalIR.cpp:298
std::unique_ptr< llvm::Module > module_
llvm::Value * codegenCompression(const SQLTypeInfo &type_info)
llvm::Value * codegenCastTimestampToTime(llvm::Value *ts_lv, const int dimen, const bool nullable)
Definition: CastIR.cpp:142
std::vector< llvm::Value * > codegenGeoConstant(const Analyzer::GeoConstant *, const CompilationOptions &)
Definition: GeoIR.cpp:109
std::vector< std::shared_ptr< Analyzer::ColumnVar > > inputs
llvm::Value * codegenCastFromString(llvm::Value *operand_lv, const SQLTypeInfo &operand_ti, const SQLTypeInfo &ti, const bool operand_is_const, const CompilationOptions &co)
Definition: CastIR.cpp:231
CodeGenerator(CgenState *cgen_state, PlanState *plan_state)
Definition: CodeGenerator.h:35
llvm::Value * codegenCast(const Analyzer::UOper *, const CompilationOptions &)
Definition: CastIR.cpp:21
llvm::Value * codegenDateTruncHighPrecisionTimestamps(llvm::Value *, const SQLTypeInfo &, const DatetruncField &)
Definition: DateTimeIR.cpp:304
std::unique_ptr< InValuesBitmap > createInValuesBitmap(const Analyzer::InValues *, const CompilationOptions &)
Definition: InValuesIR.cpp:111
llvm::Value * codegenMul(const Analyzer::BinOper *, llvm::Value *, llvm::Value *, const std::string &null_typename, const std::string &null_check_suffix, const SQLTypeInfo &, const CompilationOptions &, bool downscale=true)
std::shared_ptr< const Analyzer::ColumnVar > hashJoinLhsTuple(const Analyzer::ColumnVar *rhs, const Analyzer::BinOper *tautological_eq) const
Definition: ColumnIR.cpp:747
llvm::Value * codegenFixedLengthColVar(const Analyzer::ColumnVar *col_var, llvm::Value *col_byte_stream, llvm::Value *pos_arg, const WindowFunctionContext *window_function_context=nullptr)
Definition: ColumnIR.cpp:240
std::vector< llvm::Value * > codegenVariableLengthStringColVar(llvm::Value *col_byte_stream, llvm::Value *pos_arg)
Definition: ColumnIR.cpp:362
std::vector< void * > generateNativeCode(Executor *executor, const CompiledExpression &compiled_expression, const CompilationOptions &co)
void codegenGeoLineStringArgs(const std::string &udf_func_name, size_t param_num, llvm::Value *line_string_buf, llvm::Value *line_string_size, llvm::Value *compression, llvm::Value *input_srid, llvm::Value *output_srid, std::vector< llvm::Value * > &output_args)
llvm::Value * codegenAdd(const Analyzer::BinOper *, llvm::Value *, llvm::Value *, const std::string &null_typename, const std::string &null_check_suffix, const SQLTypeInfo &, const CompilationOptions &)
bool checkExpressionRanges(const Analyzer::UOper *, int64_t, int64_t)
llvm::Value * codegenLogicalShortCircuit(const Analyzer::BinOper *, const CompilationOptions &)
Definition: LogicalIR.cpp:196
std::unique_ptr< DiamondCodegen > null_check
static std::unique_ptr< llvm::TargetMachine > initializeNVPTXBackend(const CudaMgr_Namespace::NvidiaDeviceArch arch)
llvm::Value * resolveGroupedColumnReference(const Analyzer::ColumnVar *)
Definition: ColumnIR.cpp:544
llvm::Value * codegenDictLike(const std::shared_ptr< Analyzer::Expr > arg, const Analyzer::Constant *pattern, const bool ilike, const bool is_simple, const char escape_char, const CompilationOptions &)
Executor * executor() const
llvm::StructType * createMultiPolygonStructType(const std::string &udf_func_name, size_t param_num)