OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Codegen.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 #include "Analyzer/Analyzer.h"
18 #include "Catalog/Catalog.h"
20 #include "Shared/sqltypes.h"
21 
22 #pragma once
23 
24 namespace spatial_type {
25 
26 class Codegen {
27  public:
28  Codegen(const Analyzer::GeoOperator* geo_operator) : operator_(geo_operator) {}
29 
30  static std::unique_ptr<Codegen> init(const Analyzer::GeoOperator* geo_operator);
31 
32  auto isNullable() const { return is_nullable_; }
33 
34  auto getTypeInfo() const { return operator_->get_type_info(); }
35 
36  std::string getName() const { return operator_->getName(); }
37 
38  virtual std::unique_ptr<CodeGenerator::NullCheckCodegen>
39  getNullCheckCodegen(llvm::Value* null_lv, CgenState* cgen_state, Executor* executor);
40 
41  // number of loads/arguments for the operator
42  virtual size_t size() const = 0;
43 
44  virtual SQLTypeInfo getNullType() const = 0;
45 
46  // by default index into the operator, but allow overloading for special cases. In those
47  // special cases, we typically create a synthethic operator and manipulate state, so
48  // this method cannot be const
49  virtual const Analyzer::Expr* getOperand(const size_t index);
50 
51  // returns arguments lvs and null lv
52  virtual std::tuple<std::vector<llvm::Value*>, llvm::Value*> codegenLoads(
53  const std::vector<llvm::Value*>& arg_lvs,
54  const std::vector<llvm::Value*>& pos_lvs,
55  CgenState* cgen_state) = 0;
56 
57  // codegen function operation post loads
58  virtual std::vector<llvm::Value*> codegen(
59  const std::vector<llvm::Value*>& args,
60  CodeGenerator::NullCheckCodegen* nullcheck_codegen,
61  CgenState* cgen_state,
62  const CompilationOptions& co) = 0;
63 
64  virtual ~Codegen() {}
65 
66  static char const* pointIsNullFunctionName(SQLTypeInfo const&);
67 
68  protected:
70  bool is_nullable_{true};
71 };
72 
73 std::string suffix(SQLTypes type);
74 
75 } // namespace spatial_type
Defines data structures for the semantic analysis phase of query processing.
virtual ~Codegen()
Definition: Codegen.h:64
SQLTypes
Definition: sqltypes.h:65
virtual std::tuple< std::vector< llvm::Value * >, llvm::Value * > codegenLoads(const std::vector< llvm::Value * > &arg_lvs, const std::vector< llvm::Value * > &pos_lvs, CgenState *cgen_state)=0
virtual size_t size() const =0
Constants for Builtin SQL Types supported by HEAVY.AI.
static char const * pointIsNullFunctionName(SQLTypeInfo const &)
Definition: Codegen.cpp:69
std::string suffix(SQLTypes type)
Definition: Codegen.cpp:75
auto getTypeInfo() const
Definition: Codegen.h:34
This file contains the class specification and related data structures for Catalog.
virtual std::vector< llvm::Value * > codegen(const std::vector< llvm::Value * > &args, CodeGenerator::NullCheckCodegen *nullcheck_codegen, CgenState *cgen_state, const CompilationOptions &co)=0
const std::string & getName() const
Definition: Analyzer.h:3298
auto isNullable() const
Definition: Codegen.h:32
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:79
virtual SQLTypeInfo getNullType() const =0
virtual std::unique_ptr< CodeGenerator::NullCheckCodegen > getNullCheckCodegen(llvm::Value *null_lv, CgenState *cgen_state, Executor *executor)
Definition: Codegen.cpp:51
const Analyzer::GeoOperator * operator_
Definition: Codegen.h:69
virtual const Analyzer::Expr * getOperand(const size_t index)
Definition: Codegen.cpp:64
std::string getName() const
Definition: Codegen.h:36
static std::unique_ptr< Codegen > init(const Analyzer::GeoOperator *geo_operator)
Definition: Codegen.cpp:22
Codegen(const Analyzer::GeoOperator *geo_operator)
Definition: Codegen.h:28