OmniSciDB  ba1bac9284
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Codegen.h
Go to the documentation of this file.
1 /*
2  * Copyright 2021 OmniSci, 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 
21 #pragma once
22 
23 namespace spatial_type {
24 
25 class Codegen {
26  public:
27  Codegen(const Analyzer::GeoOperator* geo_operator,
28  const Catalog_Namespace::Catalog* catalog)
29  : operator_(geo_operator), cat_(catalog) {}
30 
31  static std::unique_ptr<Codegen> init(const Analyzer::GeoOperator* geo_operator,
32  const Catalog_Namespace::Catalog* catalog);
33 
34  auto isNullable() const { return is_nullable_; }
35 
36  auto getTypeInfo() const { return operator_->get_type_info(); }
37 
38  std::string getName() const { return operator_->getName(); }
39 
40  // number of loads/arguments for the operator
41  virtual size_t size() const = 0;
42 
43  virtual SQLTypeInfo getNullType() const = 0;
44 
45  virtual const Analyzer::Expr* getPositionOperand() const = 0;
46 
47  virtual const Analyzer::Expr* getOperand(const size_t index) = 0;
48 
49  // returns arguments lvs and null lv
50  virtual std::tuple<std::vector<llvm::Value*>, llvm::Value*> codegenLoads(
51  const std::vector<llvm::Value*>& arg_lvs,
52  llvm::Value* pos_lv,
53  CgenState* cgen_state) = 0;
54 
55  // codegen function operation post loads
56  virtual std::vector<llvm::Value*> codegen(
57  const std::vector<llvm::Value*>& args,
58  CodeGenerator::NullCheckCodegen* nullcheck_codegen,
59  CgenState* cgen_state) = 0;
60 
61  virtual ~Codegen() {}
62 
63  protected:
66  bool is_nullable_{true};
67 };
68 
69 } // namespace spatial_type
Codegen(const Analyzer::GeoOperator *geo_operator, const Catalog_Namespace::Catalog *catalog)
Definition: Codegen.h:27
Defines data structures for the semantic analysis phase of query processing.
virtual ~Codegen()
Definition: Codegen.h:61
virtual std::tuple< std::vector< llvm::Value * >, llvm::Value * > codegenLoads(const std::vector< llvm::Value * > &arg_lvs, llvm::Value *pos_lv, CgenState *cgen_state)=0
class for a per-database catalog. also includes metadata for the current database and the current use...
Definition: Catalog.h:102
virtual size_t size() const =0
auto getTypeInfo() const
Definition: Codegen.h:36
This file contains the class specification and related data structures for Catalog.
virtual const Analyzer::Expr * getPositionOperand() const =0
const std::string & getName() const
Definition: Analyzer.h:1749
const Catalog_Namespace::Catalog * cat_
Definition: Codegen.h:65
auto isNullable() const
Definition: Codegen.h:34
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:78
virtual SQLTypeInfo getNullType() const =0
const Analyzer::GeoOperator * operator_
Definition: Codegen.h:64
virtual std::vector< llvm::Value * > codegen(const std::vector< llvm::Value * > &args, CodeGenerator::NullCheckCodegen *nullcheck_codegen, CgenState *cgen_state)=0
virtual const Analyzer::Expr * getOperand(const size_t index)=0
std::string getName() const
Definition: Codegen.h:38
static std::unique_ptr< Codegen > init(const Analyzer::GeoOperator *geo_operator, const Catalog_Namespace::Catalog *catalog)
Definition: Codegen.cpp:22