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

Functions

llvm::Typeext_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

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

Definition at line 238 of file ExtensionsIR.cpp.

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

Referenced by CodeGenerator::codegenFunctionOperWithCustomTypeHandling().

238  {
239  const auto& ret_ti = function_oper->get_type_info();
240  if (!ret_ti.is_integer() && !ret_ti.is_fp()) {
241  return true;
242  }
243  for (size_t i = 0; i < function_oper->getArity(); ++i) {
244  const auto arg = function_oper->getArg(i);
245  const auto& arg_ti = arg->get_type_info();
246  if (!arg_ti.is_integer() && !arg_ti.is_fp()) {
247  return true;
248  }
249  }
250  return false;
251 }
size_t getArity() const
Definition: Analyzer.h:1309
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:78
const Analyzer::Expr * getArg(const size_t i) const
Definition: Analyzer.h:1311

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 29 of file ExtensionsIR.cpp.

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

Referenced by CodeGenerator::codegenFunctionOper().

30  {
31  switch (ext_arg_type) {
32  case ExtArgumentType::Bool: // pass thru to Int8
34  return get_int_type(8, ctx);
36  return get_int_type(16, ctx);
38  return get_int_type(32, ctx);
40  return get_int_type(64, ctx);
42  return llvm::Type::getFloatTy(ctx);
44  return llvm::Type::getDoubleTy(ctx);
45  default:
46  CHECK(false);
47  }
48  CHECK(false);
49  return nullptr;
50 }
llvm::Type * get_int_type(const int width, llvm::LLVMContext &context)
CHECK(cgen_state)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 87 of file ExtensionsIR.cpp.

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

Referenced by CodeGenerator::beginArgsNullcheck().

87  {
88  for (size_t i = 0; i < function_oper->getArity(); ++i) {
89  const auto arg = function_oper->getArg(i);
90  const auto& arg_ti = arg->get_type_info();
91  if (!arg_ti.get_notnull() && !arg_ti.is_array() && !arg_ti.is_geometry()) {
92  return true;
93  }
94  }
95  return false;
96 }
size_t getArity() const
Definition: Analyzer.h:1309
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:78
const Analyzer::Expr * getArg(const size_t i) const
Definition: Analyzer.h:1311

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 52 of file ExtensionsIR.cpp.

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

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

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function: