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