OmniSciDB  b24e664e58
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
anonymous_namespace{CompareIR.cpp} Namespace Reference

Functions

llvm::CmpInst::Predicate llvm_icmp_pred (const SQLOps op_type)
 
std::string icmp_name (const SQLOps op_type)
 
std::string icmp_arr_name (const SQLOps op_type)
 
llvm::CmpInst::Predicate llvm_fcmp_pred (const SQLOps op_type)
 
std::string string_cmp_func (const SQLOps optype)
 
std::shared_ptr
< Analyzer::BinOper
lower_bw_eq (const Analyzer::BinOper *bw_eq)
 
std::shared_ptr
< Analyzer::BinOper
make_eq (const std::shared_ptr< Analyzer::Expr > &lhs, const std::shared_ptr< Analyzer::Expr > &rhs, const SQLOps optype)
 
std::shared_ptr
< Analyzer::BinOper
lower_multicol_compare (const Analyzer::BinOper *multicol_compare)
 

Function Documentation

std::string anonymous_namespace{CompareIR.cpp}::icmp_arr_name ( const SQLOps  op_type)

Definition at line 64 of file CompareIR.cpp.

References kEQ, kGE, kGT, kLE, kLT, and kNE.

Referenced by CodeGenerator::codegenQualifierCmp().

64  {
65  switch (op_type) {
66  case kEQ:
67  return "eq";
68  case kNE:
69  return "ne";
70  case kLT:
71  return "gt";
72  case kGT:
73  return "lt";
74  case kLE:
75  return "ge";
76  case kGE:
77  return "le";
78  default:
79  abort();
80  }
81 }
Definition: sqldefs.h:35
Definition: sqldefs.h:36
Definition: sqldefs.h:30
Definition: sqldefs.h:34
Definition: sqldefs.h:32
Definition: sqldefs.h:33

+ Here is the caller graph for this function:

std::string anonymous_namespace{CompareIR.cpp}::icmp_name ( const SQLOps  op_type)

Definition at line 45 of file CompareIR.cpp.

References kEQ, kGE, kGT, kLE, kLT, and kNE.

45  {
46  switch (op_type) {
47  case kEQ:
48  return "eq";
49  case kNE:
50  return "ne";
51  case kLT:
52  return "lt";
53  case kGT:
54  return "gt";
55  case kLE:
56  return "le";
57  case kGE:
58  return "ge";
59  default:
60  abort();
61  }
62 }
Definition: sqldefs.h:35
Definition: sqldefs.h:36
Definition: sqldefs.h:30
Definition: sqldefs.h:34
Definition: sqldefs.h:32
Definition: sqldefs.h:33
llvm::CmpInst::Predicate anonymous_namespace{CompareIR.cpp}::llvm_fcmp_pred ( const SQLOps  op_type)

Definition at line 83 of file CompareIR.cpp.

References kEQ, kGE, kGT, kLE, kLT, and kNE.

83  {
84  switch (op_type) {
85  case kEQ:
86  return llvm::CmpInst::FCMP_OEQ;
87  case kNE:
88  return llvm::CmpInst::FCMP_ONE;
89  case kLT:
90  return llvm::CmpInst::FCMP_OLT;
91  case kGT:
92  return llvm::CmpInst::FCMP_OGT;
93  case kLE:
94  return llvm::CmpInst::FCMP_OLE;
95  case kGE:
96  return llvm::CmpInst::FCMP_OGE;
97  default:
98  abort();
99  }
100 }
Definition: sqldefs.h:35
Definition: sqldefs.h:36
Definition: sqldefs.h:30
Definition: sqldefs.h:34
Definition: sqldefs.h:32
Definition: sqldefs.h:33
llvm::CmpInst::Predicate anonymous_namespace{CompareIR.cpp}::llvm_icmp_pred ( const SQLOps  op_type)

Definition at line 26 of file CompareIR.cpp.

References kEQ, kGE, kGT, kLE, kLT, and kNE.

26  {
27  switch (op_type) {
28  case kEQ:
29  return llvm::ICmpInst::ICMP_EQ;
30  case kNE:
31  return llvm::ICmpInst::ICMP_NE;
32  case kLT:
33  return llvm::ICmpInst::ICMP_SLT;
34  case kGT:
35  return llvm::ICmpInst::ICMP_SGT;
36  case kLE:
37  return llvm::ICmpInst::ICMP_SLE;
38  case kGE:
39  return llvm::ICmpInst::ICMP_SGE;
40  default:
41  abort();
42  }
43 }
Definition: sqldefs.h:35
Definition: sqldefs.h:36
Definition: sqldefs.h:30
Definition: sqldefs.h:34
Definition: sqldefs.h:32
Definition: sqldefs.h:33
std::shared_ptr<Analyzer::BinOper> anonymous_namespace{CompareIR.cpp}::lower_bw_eq ( const Analyzer::BinOper bw_eq)

Definition at line 125 of file CompareIR.cpp.

References CHECK(), Analyzer::Expr::get_contains_agg(), Analyzer::BinOper::get_own_left_operand(), Analyzer::BinOper::get_own_right_operand(), Analyzer::BinOper::get_qualifier(), Analyzer::Expr::get_type_info(), kAND, kBOOLEAN, kEQ, kISNULL, kONE, kOR, and Parser::OperExpr::normalize().

Referenced by CodeGenerator::codegenCmp(), and make_eq().

125  {
126  const auto eq_oper =
127  std::make_shared<Analyzer::BinOper>(bw_eq->get_type_info(),
128  bw_eq->get_contains_agg(),
129  kEQ,
130  bw_eq->get_qualifier(),
131  bw_eq->get_own_left_operand(),
132  bw_eq->get_own_right_operand());
133  const auto lhs_is_null =
134  std::make_shared<Analyzer::UOper>(kBOOLEAN, kISNULL, bw_eq->get_own_left_operand());
135  const auto rhs_is_null = std::make_shared<Analyzer::UOper>(
137  const auto both_are_null =
138  Parser::OperExpr::normalize(kAND, kONE, lhs_is_null, rhs_is_null);
139  const auto bw_eq_oper = std::dynamic_pointer_cast<Analyzer::BinOper>(
140  Parser::OperExpr::normalize(kOR, kONE, eq_oper, both_are_null));
141  CHECK(bw_eq_oper);
142  return bw_eq_oper;
143 }
Definition: sqldefs.h:38
bool get_contains_agg() const
Definition: Analyzer.h:80
Definition: sqldefs.h:30
CHECK(cgen_state)
Definition: sqldefs.h:37
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:78
static std::shared_ptr< Analyzer::Expr > normalize(const SQLOps optype, const SQLQualifier qual, std::shared_ptr< Analyzer::Expr > left_expr, std::shared_ptr< Analyzer::Expr > right_expr)
Definition: ParserNode.cpp:261
Definition: sqldefs.h:69
const std::shared_ptr< Analyzer::Expr > get_own_right_operand() const
Definition: Analyzer.h:441
const std::shared_ptr< Analyzer::Expr > get_own_left_operand() const
Definition: Analyzer.h:438
SQLQualifier get_qualifier() const
Definition: Analyzer.h:435

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::shared_ptr<Analyzer::BinOper> anonymous_namespace{CompareIR.cpp}::lower_multicol_compare ( const Analyzer::BinOper multicol_compare)

Definition at line 159 of file CompareIR.cpp.

References CHECK(), CHECK_EQ, CHECK_GT, Analyzer::BinOper::get_left_operand(), Analyzer::BinOper::get_optype(), Analyzer::BinOper::get_right_operand(), kAND, kBOOLEAN, kONE, and make_eq().

Referenced by CodeGenerator::codegenCmp().

160  {
161  const auto left_tuple_expr = dynamic_cast<const Analyzer::ExpressionTuple*>(
162  multicol_compare->get_left_operand());
163  const auto right_tuple_expr = dynamic_cast<const Analyzer::ExpressionTuple*>(
164  multicol_compare->get_right_operand());
165  CHECK(left_tuple_expr && right_tuple_expr);
166  const auto& left_tuple = left_tuple_expr->getTuple();
167  const auto& right_tuple = right_tuple_expr->getTuple();
168  CHECK_EQ(left_tuple.size(), right_tuple.size());
169  CHECK_GT(left_tuple.size(), size_t(1));
170  auto acc =
171  make_eq(left_tuple.front(), right_tuple.front(), multicol_compare->get_optype());
172  for (size_t i = 1; i < left_tuple.size(); ++i) {
173  auto crt = make_eq(left_tuple[i], right_tuple[i], multicol_compare->get_optype());
174  const bool not_null =
175  acc->get_type_info().get_notnull() && crt->get_type_info().get_notnull();
176  acc = makeExpr<Analyzer::BinOper>(
177  SQLTypeInfo(kBOOLEAN, not_null), false, kAND, kONE, acc, crt);
178  }
179  return acc;
180 }
#define CHECK_EQ(x, y)
Definition: Logger.h:198
const Expr * get_right_operand() const
Definition: Analyzer.h:437
#define CHECK_GT(x, y)
Definition: Logger.h:202
SQLOps get_optype() const
Definition: Analyzer.h:433
CHECK(cgen_state)
Definition: sqldefs.h:37
SQLTypeInfoCore< ArrayContextTypeSizer, ExecutorTypePackaging, DateTimeFacilities > SQLTypeInfo
Definition: sqltypes.h:852
Definition: sqldefs.h:69
std::shared_ptr< Analyzer::BinOper > make_eq(const std::shared_ptr< Analyzer::Expr > &lhs, const std::shared_ptr< Analyzer::Expr > &rhs, const SQLOps optype)
Definition: CompareIR.cpp:145
const Expr * get_left_operand() const
Definition: Analyzer.h:436

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::shared_ptr<Analyzer::BinOper> anonymous_namespace{CompareIR.cpp}::make_eq ( const std::shared_ptr< Analyzer::Expr > &  lhs,
const std::shared_ptr< Analyzer::Expr > &  rhs,
const SQLOps  optype 
)

Definition at line 145 of file CompareIR.cpp.

References CHECK(), IS_EQUIVALENCE, kBW_EQ, kONE, lower_bw_eq(), and Parser::OperExpr::normalize().

Referenced by lower_multicol_compare().

147  {
148  CHECK(IS_EQUIVALENCE(optype));
149  // Sides of a tuple equality are stripped of cast operators to simplify the logic
150  // in the hash table construction algorithm. Add them back here.
151  auto eq_oper = std::dynamic_pointer_cast<Analyzer::BinOper>(
152  Parser::OperExpr::normalize(optype, kONE, lhs, rhs));
153  CHECK(eq_oper);
154  return optype == kBW_EQ ? lower_bw_eq(eq_oper.get()) : eq_oper;
155 }
#define IS_EQUIVALENCE(X)
Definition: sqldefs.h:67
std::shared_ptr< Analyzer::BinOper > lower_bw_eq(const Analyzer::BinOper *bw_eq)
Definition: CompareIR.cpp:125
CHECK(cgen_state)
static std::shared_ptr< Analyzer::Expr > normalize(const SQLOps optype, const SQLQualifier qual, std::shared_ptr< Analyzer::Expr > left_expr, std::shared_ptr< Analyzer::Expr > right_expr)
Definition: ParserNode.cpp:261
Definition: sqldefs.h:69
Definition: sqldefs.h:31

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string anonymous_namespace{CompareIR.cpp}::string_cmp_func ( const SQLOps  optype)

Definition at line 106 of file CompareIR.cpp.

References kEQ, kGE, kGT, kLE, kLT, and kNE.

106  {
107  switch (optype) {
108  case kLT:
109  return "string_lt";
110  case kLE:
111  return "string_le";
112  case kGT:
113  return "string_gt";
114  case kGE:
115  return "string_ge";
116  case kEQ:
117  return "string_eq";
118  case kNE:
119  return "string_ne";
120  default:
121  abort();
122  }
123 }
Definition: sqldefs.h:35
Definition: sqldefs.h:36
Definition: sqldefs.h:30
Definition: sqldefs.h:34
Definition: sqldefs.h:32
Definition: sqldefs.h:33