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