OmniSciDB  5ade3759e0
anonymous_namespace{ExtensionsIR.cpp} Namespace Reference

Functions

llvm::Type * ext_arg_type_to_llvm_type (const ExtArgumentType ext_arg_type, llvm::LLVMContext &ctx)
 
SQLTypeInfo get_sql_type_from_llvm_type (const llvm::Type *ll_type)
 
bool ext_func_call_requires_nullcheck (const Analyzer::FunctionOper *function_oper)
 
bool call_requires_custom_type_handling (const Analyzer::FunctionOper *function_oper)
 

Function Documentation

◆ call_requires_custom_type_handling()

bool anonymous_namespace{ExtensionsIR.cpp}::call_requires_custom_type_handling ( const Analyzer::FunctionOper function_oper)

Definition at line 232 of file ExtensionsIR.cpp.

References Analyzer::Expr::get_type_info(), Analyzer::FunctionOper::getArg(), and Analyzer::FunctionOper::getArity().

Referenced by CodeGenerator::codegenFunctionOperWithCustomTypeHandling().

232  {
233  const auto& ret_ti = function_oper->get_type_info();
234  if (!ret_ti.is_integer() && !ret_ti.is_fp()) {
235  return true;
236  }
237  for (size_t i = 0; i < function_oper->getArity(); ++i) {
238  const auto arg = function_oper->getArg(i);
239  const auto& arg_ti = arg->get_type_info();
240  if (!arg_ti.is_integer() && !arg_ti.is_fp()) {
241  return true;
242  }
243  }
244  return false;
245 }
const Analyzer::Expr * getArg(const size_t i) const
Definition: Analyzer.h:1254
size_t getArity() const
Definition: Analyzer.h:1252
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:77
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ext_arg_type_to_llvm_type()

llvm::Type* anonymous_namespace{ExtensionsIR.cpp}::ext_arg_type_to_llvm_type ( const ExtArgumentType  ext_arg_type,
llvm::LLVMContext &  ctx 
)

Definition at line 25 of file ExtensionsIR.cpp.

References Bool, CHECK, Double, Float, get_int_type(), Int16, Int32, Int64, and Int8.

Referenced by CodeGenerator::codegenFunctionOper(), and CodeGenerator::codegenFunctionOperCastArgs().

26  {
27  switch (ext_arg_type) {
28  case ExtArgumentType::Bool: // pass thru to Int8
30  return get_int_type(8, ctx);
32  return get_int_type(16, ctx);
34  return get_int_type(32, ctx);
36  return get_int_type(64, ctx);
38  return llvm::Type::getFloatTy(ctx);
40  return llvm::Type::getDoubleTy(ctx);
41  default:
42  CHECK(false);
43  }
44  CHECK(false);
45  return nullptr;
46 }
llvm::Type * get_int_type(const int width, llvm::LLVMContext &context)
#define CHECK(condition)
Definition: Logger.h:187
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ext_func_call_requires_nullcheck()

bool anonymous_namespace{ExtensionsIR.cpp}::ext_func_call_requires_nullcheck ( const Analyzer::FunctionOper function_oper)

Definition at line 83 of file ExtensionsIR.cpp.

References Analyzer::Expr::get_type_info(), Analyzer::FunctionOper::getArg(), and Analyzer::FunctionOper::getArity().

Referenced by CodeGenerator::beginArgsNullcheck().

83  {
84  for (size_t i = 0; i < function_oper->getArity(); ++i) {
85  const auto arg = function_oper->getArg(i);
86  const auto& arg_ti = arg->get_type_info();
87  if (!arg_ti.get_notnull() && !arg_ti.is_array() && !arg_ti.is_geometry()) {
88  return true;
89  }
90  }
91  return false;
92 }
const Analyzer::Expr * getArg(const size_t i) const
Definition: Analyzer.h:1254
size_t getArity() const
Definition: Analyzer.h:1252
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:77
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_sql_type_from_llvm_type()

SQLTypeInfo anonymous_namespace{ExtensionsIR.cpp}::get_sql_type_from_llvm_type ( const llvm::Type *  ll_type)
inline

Definition at line 48 of file ExtensionsIR.cpp.

References CHECK, logger::FATAL, kBIGINT, kBOOLEAN, kDOUBLE, kFLOAT, kINT, kSMALLINT, kTINYINT, LOG, and UNREACHABLE.

Referenced by CodeGenerator::codegenFunctionOper().

48  {
49  CHECK(ll_type);
50  const auto bits = ll_type->getPrimitiveSizeInBits();
51 
52  if (ll_type->isFloatingPointTy()) {
53  switch (bits) {
54  case 32:
55  return SQLTypeInfo(kFLOAT, true);
56  case 64:
57  return SQLTypeInfo(kDOUBLE, true);
58  default:
59  LOG(FATAL) << "Unsupported llvm floating point type: " << bits
60  << ", only 32 and 64 bit floating point is supported.";
61  }
62  } else {
63  switch (bits) {
64  case 1:
65  return SQLTypeInfo(kBOOLEAN, true);
66  case 8:
67  return SQLTypeInfo(kTINYINT, true);
68  case 16:
69  return SQLTypeInfo(kSMALLINT, true);
70  case 32:
71  return SQLTypeInfo(kINT, true);
72  case 64:
73  return SQLTypeInfo(kBIGINT, true);
74  default:
75  LOG(FATAL) << "Unrecognized llvm type for SQL type: "
76  << bits; // TODO let's get the real name here
77  }
78  }
79  UNREACHABLE();
80  return SQLTypeInfo();
81 }
#define LOG(tag)
Definition: Logger.h:182
#define UNREACHABLE()
Definition: Logger.h:231
SQLTypeInfoCore< ArrayContextTypeSizer, ExecutorTypePackaging, DateTimeFacilities > SQLTypeInfo
Definition: sqltypes.h:823
#define CHECK(condition)
Definition: Logger.h:187
Definition: sqltypes.h:47
+ Here is the caller graph for this function: