OmniSciDB  21ac014ffc
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CgenState Struct Reference

#include <CgenState.h>

+ Collaboration diagram for CgenState:

Classes

struct  FunctionOperValue
 
struct  HoistedLiteralLoadLocator
 

Public Types

using LiteralValue = boost::variant< int8_t, int16_t, int32_t, int64_t, float, double, std::pair< std::string, int >, std::string, std::vector< double >, std::vector< int32_t >, std::vector< int8_t >, std::pair< std::vector< int8_t >, int >>
 
using LiteralValues = std::vector< LiteralValue >
 

Public Member Functions

 CgenState (const size_t num_query_infos, const bool contains_left_deep_outer_join)
 
 CgenState (llvm::LLVMContext &context)
 
size_t getOrAddLiteral (const Analyzer::Constant *constant, const EncodingType enc_type, const int dict_id, const int device_id)
 
const std::unordered_map< int,
LiteralValues > & 
getLiterals () const
 
llvm::Value * addStringConstant (const std::string &str)
 
const InValuesBitmapaddInValuesBitmap (std::unique_ptr< InValuesBitmap > &in_values_bitmap)
 
llvm::Value * emitExternalCall (const std::string &fname, llvm::Type *ret_type, const std::vector< llvm::Value * > args, const std::vector< llvm::Attribute::AttrKind > &fnattrs={}, const bool has_struct_return=false)
 
llvm::Value * emitCall (const std::string &fname, const std::vector< llvm::Value * > &args)
 
size_t getLiteralBufferUsage (const int device_id)
 
llvm::Value * castToTypeIn (llvm::Value *val, const size_t bit_width)
 
std::pair< llvm::ConstantInt
*, llvm::ConstantInt * > 
inlineIntMaxMin (const size_t byte_width, const bool is_signed)
 
llvm::ConstantInt * inlineIntNull (const SQLTypeInfo &)
 
llvm::ConstantFP * inlineFpNull (const SQLTypeInfo &)
 
llvm::Constant * inlineNull (const SQLTypeInfo &)
 
template<class T >
llvm::ConstantInt * llInt (const T v) const
 
llvm::ConstantFP * llFp (const float v) const
 
llvm::ConstantFP * llFp (const double v) const
 
llvm::ConstantInt * llBool (const bool v) const
 
void emitErrorCheck (llvm::Value *condition, llvm::Value *errorCode, std::string label)
 
std::vector< std::string > gpuFunctionsToReplace (llvm::Function *fn)
 
void replaceFunctionForGpu (const std::string &fcn_to_replace, llvm::Function *fn)
 
void maybeCloneFunctionRecursive (llvm::Function *fn)
 

Static Public Member Functions

static size_t literalBytes (const CgenState::LiteralValue &lit)
 
static size_t addAligned (const size_t off_in, const size_t alignment)
 

Public Attributes

llvm::Module * module_
 
llvm::Function * row_func_
 
llvm::Function * filter_func_
 
llvm::Function * current_func_
 
llvm::BasicBlock * row_func_bb_
 
llvm::BasicBlock * filter_func_bb_
 
llvm::CallInst * row_func_call_
 
llvm::CallInst * filter_func_call_
 
std::vector< llvm::Function * > helper_functions_
 
llvm::LLVMContext & context_
 
llvm::ValueToValueMapTy vmap_
 
llvm::IRBuilder ir_builder_
 
std::unordered_map< int,
std::vector< llvm::Value * > > 
fetch_cache_
 
std::vector< FunctionOperValueext_call_cache_
 
std::vector< llvm::Value * > group_by_expr_cache_
 
std::vector< llvm::Value * > str_constants_
 
std::vector< llvm::Value * > frag_offsets_
 
const bool contains_left_deep_outer_join_
 
std::vector< llvm::Value * > outer_join_match_found_per_level_
 
std::unordered_map< int,
llvm::Value * > 
scan_idx_to_hash_pos_
 
InsertionOrderedMap filter_func_args_
 
std::vector< std::unique_ptr
< const InValuesBitmap > > 
in_values_bitmaps_
 
std::map< std::pair
< llvm::Value *, llvm::Value * >
, ArrayLoadCodegen
array_load_cache_
 
std::unordered_map
< std::string, llvm::Value * > 
geo_target_cache_
 
bool needs_error_check_
 
bool needs_geos_
 
llvm::Function * query_func_
 
llvm::IRBuilder query_func_entry_ir_builder_
 
std::unordered_map< int,
std::vector< llvm::Value * > > 
query_func_literal_loads_
 
std::unordered_map
< llvm::Value
*, HoistedLiteralLoadLocator
row_func_hoisted_literals_
 

Private Member Functions

template<class T >
size_t getOrAddLiteral (const T &val, const int device_id)
 

Private Attributes

std::unordered_map< int,
LiteralValues
literals_
 
std::unordered_map< int, size_t > literal_bytes_
 

Detailed Description

Definition at line 37 of file CgenState.h.

Member Typedef Documentation

using CgenState::LiteralValue = boost::variant<int8_t, int16_t, int32_t, int64_t, float, double, std::pair<std::string, int>, std::string, std::vector<double>, std::vector<int32_t>, std::vector<int8_t>, std::pair<std::vector<int8_t>, int>>

Definition at line 204 of file CgenState.h.

using CgenState::LiteralValues = std::vector<LiteralValue>

Definition at line 205 of file CgenState.h.

Constructor & Destructor Documentation

CgenState::CgenState ( const size_t  num_query_infos,
const bool  contains_left_deep_outer_join 
)
inline

Definition at line 39 of file CgenState.h.

40  : module_(nullptr)
41  , row_func_(nullptr)
42  , filter_func_(nullptr)
43  , current_func_(nullptr)
44  , row_func_bb_(nullptr)
45  , filter_func_bb_(nullptr)
46  , row_func_call_(nullptr)
47  , filter_func_call_(nullptr)
50  , contains_left_deep_outer_join_(contains_left_deep_outer_join)
51  , outer_join_match_found_per_level_(std::max(num_query_infos, size_t(1)) - 1)
52  , needs_error_check_(false)
53  , needs_geos_(false)
54  , query_func_(nullptr)
std::vector< llvm::Value * > outer_join_match_found_per_level_
Definition: CgenState.h:351
llvm::Function * query_func_
Definition: CgenState.h:361
llvm::IRBuilder ir_builder_
Definition: CgenState.h:340
bool needs_geos_
Definition: CgenState.h:359
const bool contains_left_deep_outer_join_
Definition: CgenState.h:350
llvm::Function * row_func_
Definition: CgenState.h:330
llvm::Module * module_
Definition: CgenState.h:329
llvm::LLVMContext & context_
Definition: CgenState.h:338
llvm::Function * current_func_
Definition: CgenState.h:332
llvm::CallInst * filter_func_call_
Definition: CgenState.h:336
bool needs_error_check_
Definition: CgenState.h:358
llvm::IRBuilder query_func_entry_ir_builder_
Definition: CgenState.h:362
llvm::BasicBlock * filter_func_bb_
Definition: CgenState.h:334
llvm::Function * filter_func_
Definition: CgenState.h:331
llvm::LLVMContext & getGlobalLLVMContext()
llvm::CallInst * row_func_call_
Definition: CgenState.h:335
llvm::BasicBlock * row_func_bb_
Definition: CgenState.h:333
CgenState::CgenState ( llvm::LLVMContext &  context)
inline

Definition at line 57 of file CgenState.h.

58  : module_(nullptr)
59  , row_func_(nullptr)
60  , context_(context)
63  , needs_error_check_(false)
64  , needs_geos_(false)
65  , query_func_(nullptr)
llvm::Function * query_func_
Definition: CgenState.h:361
llvm::IRBuilder ir_builder_
Definition: CgenState.h:340
bool needs_geos_
Definition: CgenState.h:359
const bool contains_left_deep_outer_join_
Definition: CgenState.h:350
llvm::Function * row_func_
Definition: CgenState.h:330
llvm::Module * module_
Definition: CgenState.h:329
llvm::LLVMContext & context_
Definition: CgenState.h:338
bool needs_error_check_
Definition: CgenState.h:358
llvm::IRBuilder query_func_entry_ir_builder_
Definition: CgenState.h:362

Member Function Documentation

static size_t CgenState::addAligned ( const size_t  off_in,
const size_t  alignment 
)
inlinestatic

Definition at line 402 of file CgenState.h.

Referenced by getOrAddLiteral(), and Executor::serializeLiterals().

402  {
403  size_t off = off_in;
404  if (off % alignment != 0) {
405  off += (alignment - off % alignment);
406  }
407  return off + alignment;
408  }

+ Here is the caller graph for this function:

const InValuesBitmap* CgenState::addInValuesBitmap ( std::unique_ptr< InValuesBitmap > &  in_values_bitmap)
inline

Definition at line 218 of file CgenState.h.

References in_values_bitmaps_.

Referenced by CodeGenerator::codegen().

219  {
220  if (in_values_bitmap->isEmpty()) {
221  return in_values_bitmap.get();
222  }
223  in_values_bitmaps_.emplace_back(std::move(in_values_bitmap));
224  return in_values_bitmaps_.back().get();
225  }
std::vector< std::unique_ptr< const InValuesBitmap > > in_values_bitmaps_
Definition: CgenState.h:354

+ Here is the caller graph for this function:

llvm::Value* CgenState::addStringConstant ( const std::string &  str)
inline

Definition at line 209 of file CgenState.h.

References context_, get_int_type(), ir_builder_, str_constants_, and to_string().

Referenced by CodeGenerator::codegen().

209  {
210  llvm::Value* str_lv = ir_builder_.CreateGlobalString(
211  str, "str_const_" + std::to_string(std::hash<std::string>()(str)));
212  auto i8_ptr = llvm::PointerType::get(get_int_type(8, context_), 0);
213  str_constants_.push_back(str_lv);
214  str_lv = ir_builder_.CreateBitCast(str_lv, i8_ptr);
215  return str_lv;
216  }
llvm::IRBuilder ir_builder_
Definition: CgenState.h:340
std::vector< llvm::Value * > str_constants_
Definition: CgenState.h:348
llvm::Type * get_int_type(const int width, llvm::LLVMContext &context)
std::string to_string(char const *&&v)
llvm::LLVMContext & context_
Definition: CgenState.h:338

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

llvm::Value * CgenState::castToTypeIn ( llvm::Value *  val,
const size_t  bit_width 
)

Definition at line 113 of file CgenState.cpp.

References CHECK, context_, get_int_type(), and ir_builder_.

Referenced by CodeGenerator::codegenCast(), CodeGenerator::codegenLogical(), and CodeGenerator::codegenLogicalShortCircuit().

113  {
114  auto src_bits = val->getType()->getScalarSizeInBits();
115  if (src_bits == dst_bits) {
116  return val;
117  }
118  if (val->getType()->isIntegerTy()) {
119  return ir_builder_.CreateIntCast(
120  val, get_int_type(dst_bits, context_), src_bits != 1);
121  }
122  // real (not dictionary-encoded) strings; store the pointer to the payload
123  if (val->getType()->isPointerTy()) {
124  return ir_builder_.CreatePointerCast(val, get_int_type(dst_bits, context_));
125  }
126 
127  CHECK(val->getType()->isFloatTy() || val->getType()->isDoubleTy());
128 
129  llvm::Type* dst_type = nullptr;
130  switch (dst_bits) {
131  case 64:
132  dst_type = llvm::Type::getDoubleTy(context_);
133  break;
134  case 32:
135  dst_type = llvm::Type::getFloatTy(context_);
136  break;
137  default:
138  CHECK(false);
139  }
140 
141  return ir_builder_.CreateFPCast(val, dst_type);
142 }
llvm::IRBuilder ir_builder_
Definition: CgenState.h:340
llvm::Type * get_int_type(const int width, llvm::LLVMContext &context)
llvm::LLVMContext & context_
Definition: CgenState.h:338
#define CHECK(condition)
Definition: Logger.h:206

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

llvm::Value * CgenState::emitCall ( const std::string &  fname,
const std::vector< llvm::Value * > &  args 
)

Definition at line 175 of file CgenState.cpp.

References CHECK, ir_builder_, maybeCloneFunctionRecursive(), and module_.

Referenced by CodeGenerator::codegen(), CodeGenerator::codegenAdd(), CodeGenerator::codegenCase(), CodeGenerator::codegenCast(), CodeGenerator::codegenCastBetweenIntTypes(), CodeGenerator::codegenCastBetweenIntTypesOverflowChecks(), CodeGenerator::codegenCastBetweenTimestamps(), CodeGenerator::codegenCastFromFp(), CodeGenerator::codegenCastToFp(), CodeGenerator::codegenCmp(), CodeGenerator::codegenDateTruncHighPrecisionTimestamps(), CodeGenerator::codegenDiv(), CodeGenerator::codegenExtractHighPrecisionTimestamps(), CodeGenerator::codegenFpArith(), CodeGenerator::codegenFunctionOperWithCustomTypeHandling(), CodeGenerator::codegenLogical(), CodeGenerator::codegenMod(), CodeGenerator::codegenMul(), CodeGenerator::codegenSub(), CodeGenerator::codegenUMinus(), CodeGenerator::codegenWindowPosition(), and CodeGenerator::codgenAdjustFixedEncNull().

176  {
177  // Get the function reference from the query module.
178  auto func = module_->getFunction(fname);
179  CHECK(func);
180  // If the function called isn't external, clone the implementation from the runtime
181  // module.
183 
184  return ir_builder_.CreateCall(func, args);
185 }
void maybeCloneFunctionRecursive(llvm::Function *fn)
Definition: CgenState.cpp:144
llvm::IRBuilder ir_builder_
Definition: CgenState.h:340
llvm::Module * module_
Definition: CgenState.h:329
#define CHECK(condition)
Definition: Logger.h:206

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CgenState::emitErrorCheck ( llvm::Value *  condition,
llvm::Value *  errorCode,
std::string  label 
)

Definition at line 187 of file CgenState.cpp.

References context_, current_func_, ir_builder_, and needs_error_check_.

189  {
190  needs_error_check_ = true;
191  auto check_ok = llvm::BasicBlock::Create(context_, label + "_ok", current_func_);
192  auto check_fail = llvm::BasicBlock::Create(context_, label + "_fail", current_func_);
193  ir_builder_.CreateCondBr(condition, check_ok, check_fail);
194  ir_builder_.SetInsertPoint(check_fail);
195  ir_builder_.CreateRet(errorCode);
196  ir_builder_.SetInsertPoint(check_ok);
197 }
llvm::IRBuilder ir_builder_
Definition: CgenState.h:340
llvm::LLVMContext & context_
Definition: CgenState.h:338
llvm::Function * current_func_
Definition: CgenState.h:332
bool needs_error_check_
Definition: CgenState.h:358
llvm::Value* CgenState::emitExternalCall ( const std::string &  fname,
llvm::Type ret_type,
const std::vector< llvm::Value * >  args,
const std::vector< llvm::Attribute::AttrKind > &  fnattrs = {},
const bool  has_struct_return = false 
)
inline

Definition at line 228 of file CgenState.h.

Referenced by spatial_type::Transform::codegen(), CodeGenerator::codegen(), CodeGenerator::codegenArrayAt(), CodeGenerator::codegenArrayBuff(), CodeGenerator::codegenArrayExpr(), CodeGenerator::codegenCastFromString(), CodeGenerator::codegenCastTimestampToDate(), CodeGenerator::codegenDateTruncHighPrecisionTimestamps(), CodeGenerator::codegenFunctionOper(), CodeGenerator::codegenFunctionOperCastArgs(), CodeGenerator::codegenFunctionOperNullArg(), CodeGenerator::codegenFunctionOperWithCustomTypeHandling(), CodeGenerator::codegenGeoArgs(), CodeGenerator::codegenGeoArrayLoadAndNullcheck(), CodeGenerator::codegenGeoFunctionOperator(), CodeGenerator::codegenGeosConstructorCall(), CodeGenerator::codegenGeosPredicateCall(), CodeGenerator::codegenIsNull(), CodeGenerator::codegenQualifierCmp(), CodeGenerator::codegenVariableLengthStringColVar(), and Executor::groupByColumnCodegen().

232  {},
233  const bool has_struct_return = false) {
234  std::vector<llvm::Type*> arg_types;
235  for (const auto arg : args) {
236  CHECK(arg);
237  arg_types.push_back(arg->getType());
238  }
239  auto func_ty = llvm::FunctionType::get(ret_type, arg_types, false);
240  llvm::AttributeList attrs;
241  if (!fnattrs.empty()) {
242  std::vector<std::pair<unsigned, llvm::Attribute>> indexedAttrs;
243  indexedAttrs.reserve(fnattrs.size());
244  for (auto attr : fnattrs) {
245  indexedAttrs.emplace_back(llvm::AttributeList::FunctionIndex,
246  llvm::Attribute::get(context_, attr));
247  }
248  attrs = llvm::AttributeList::get(context_,
249  {&indexedAttrs.front(), indexedAttrs.size()});
250  }
251 
252  auto func_p = module_->getOrInsertFunction(fname, func_ty, attrs);
253  CHECK(func_p);
254  auto callee = func_p.getCallee();
255  llvm::Function* func{nullptr};
256  if (auto callee_cast = llvm::dyn_cast<llvm::ConstantExpr>(callee)) {
257  // Get or insert function automatically adds a ConstantExpr cast if the return type
258  // of the existing function does not match the supplied return type.
259  CHECK(callee_cast->isCast());
260  CHECK_EQ(callee_cast->getNumOperands(), size_t(1));
261  func = llvm::dyn_cast<llvm::Function>(callee_cast->getOperand(0));
262  } else {
263  func = llvm::dyn_cast<llvm::Function>(callee);
264  }
265  CHECK(func);
266  llvm::FunctionType* func_type = func_p.getFunctionType();
267  CHECK(func_type);
268  if (has_struct_return) {
269  const auto arg_ti = func_type->getParamType(0);
270  CHECK(arg_ti->isPointerTy() && arg_ti->getPointerElementType()->isStructTy());
271  auto attr_list = func->getAttributes();
272  llvm::AttrBuilder arr_arg_builder(attr_list.getParamAttributes(0));
273  arr_arg_builder.addAttribute(llvm::Attribute::StructRet);
274  func->addParamAttrs(0, arr_arg_builder);
275  }
276  const size_t arg_start = has_struct_return ? 1 : 0;
277  for (size_t i = arg_start; i < func->arg_size(); i++) {
278  const auto arg_ti = func_type->getParamType(i);
279  if (arg_ti->isPointerTy() && arg_ti->getPointerElementType()->isStructTy()) {
280  auto attr_list = func->getAttributes();
281  llvm::AttrBuilder arr_arg_builder(attr_list.getParamAttributes(i));
282  arr_arg_builder.addByValAttr(arg_ti->getPointerElementType());
283  func->addParamAttrs(i, arr_arg_builder);
284  }
285  }
286  llvm::Value* result = ir_builder_.CreateCall(func_p, args);
287  // check the assumed type
288  CHECK_EQ(result->getType(), ret_type);
289  return result;
290  }
#define CHECK_EQ(x, y)
Definition: Logger.h:214
llvm::IRBuilder ir_builder_
Definition: CgenState.h:340
llvm::Module * module_
Definition: CgenState.h:329
llvm::LLVMContext & context_
Definition: CgenState.h:338
#define CHECK(condition)
Definition: Logger.h:206

+ Here is the caller graph for this function:

size_t CgenState::getLiteralBufferUsage ( const int  device_id)
inline

Definition at line 294 of file CgenState.h.

References literal_bytes_.

294 { return literal_bytes_[device_id]; }
std::unordered_map< int, size_t > literal_bytes_
Definition: CgenState.h:432
const std::unordered_map<int, LiteralValues>& CgenState::getLiterals ( ) const
inline

Definition at line 207 of file CgenState.h.

References literals_.

207 { return literals_; }
std::unordered_map< int, LiteralValues > literals_
Definition: CgenState.h:431
size_t CgenState::getOrAddLiteral ( const Analyzer::Constant constant,
const EncodingType  enc_type,
const int  dict_id,
const int  device_id 
)
inline

Definition at line 68 of file CgenState.h.

References Datum::bigintval, Datum::boolval, CHECK, CHECK_EQ, test_fsi::d, decimal_to_int_type(), Datum::doubleval, Datum::floatval, Analyzer::Constant::get_constval(), Analyzer::Constant::get_is_null(), Analyzer::Expr::get_type_info(), Analyzer::Constant::get_value_list(), i, inline_fp_null_val(), inline_int_null_val(), Datum::intval, kARRAY, kBIGINT, kBOOLEAN, kCHAR, kDATE, kDOUBLE, kENCODING_DICT, kENCODING_GEOINT, kENCODING_NONE, kFLOAT, kINT, kINTERVAL_DAY_TIME, kINTERVAL_YEAR_MONTH, kSMALLINT, kTEXT, kTIME, kTIMESTAMP, kTINYINT, kVARCHAR, Datum::smallintval, Datum::stringval, Datum::tinyintval, and run_benchmark_import::type.

Referenced by CodeGenerator::codegenHoistedConstants().

71  {
72  const auto& ti = constant->get_type_info();
73  const auto type = ti.is_decimal() ? decimal_to_int_type(ti) : ti.get_type();
74  switch (type) {
75  case kBOOLEAN:
76  return getOrAddLiteral(constant->get_is_null()
77  ? int8_t(inline_int_null_val(ti))
78  : int8_t(constant->get_constval().boolval ? 1 : 0),
79  device_id);
80  case kTINYINT:
81  return getOrAddLiteral(constant->get_is_null()
82  ? int8_t(inline_int_null_val(ti))
83  : constant->get_constval().tinyintval,
84  device_id);
85  case kSMALLINT:
86  return getOrAddLiteral(constant->get_is_null()
87  ? int16_t(inline_int_null_val(ti))
88  : constant->get_constval().smallintval,
89  device_id);
90  case kINT:
91  return getOrAddLiteral(constant->get_is_null() ? int32_t(inline_int_null_val(ti))
92  : constant->get_constval().intval,
93  device_id);
94  case kBIGINT:
95  return getOrAddLiteral(constant->get_is_null()
96  ? int64_t(inline_int_null_val(ti))
97  : constant->get_constval().bigintval,
98  device_id);
99  case kFLOAT:
100  return getOrAddLiteral(constant->get_is_null()
101  ? float(inline_fp_null_val(ti))
102  : constant->get_constval().floatval,
103  device_id);
104  case kDOUBLE:
105  return getOrAddLiteral(constant->get_is_null()
106  ? inline_fp_null_val(ti)
107  : constant->get_constval().doubleval,
108  device_id);
109  case kCHAR:
110  case kTEXT:
111  case kVARCHAR:
112  if (enc_type == kENCODING_DICT) {
113  if (constant->get_is_null()) {
114  return getOrAddLiteral(int32_t(inline_int_null_val(ti)), device_id);
115  }
116  return getOrAddLiteral(
117  std::make_pair(*constant->get_constval().stringval, dict_id), device_id);
118  }
119  CHECK_EQ(kENCODING_NONE, enc_type);
120  if (constant->get_is_null()) {
121  throw std::runtime_error(
122  "CHAR / VARCHAR NULL literal not supported in this context"); // TODO(alex):
123  // support
124  // null
125  }
126  return getOrAddLiteral(*constant->get_constval().stringval, device_id);
127  case kTIME:
128  case kTIMESTAMP:
129  case kDATE:
130  case kINTERVAL_DAY_TIME:
132  // TODO(alex): support null
133  return getOrAddLiteral(constant->get_constval().bigintval, device_id);
134  case kARRAY: {
135  if (enc_type == kENCODING_NONE) {
136  if (ti.get_subtype() == kDOUBLE) {
137  std::vector<double> double_array_literal;
138  for (const auto& value : constant->get_value_list()) {
139  const auto c = dynamic_cast<const Analyzer::Constant*>(value.get());
140  CHECK(c);
141  double d = c->get_constval().doubleval;
142  double_array_literal.push_back(d);
143  }
144  return getOrAddLiteral(double_array_literal, device_id);
145  }
146  if (ti.get_subtype() == kINT) {
147  std::vector<int32_t> int32_array_literal;
148  for (const auto& value : constant->get_value_list()) {
149  const auto c = dynamic_cast<const Analyzer::Constant*>(value.get());
150  CHECK(c);
151  int32_t i = c->get_constval().intval;
152  int32_array_literal.push_back(i);
153  }
154  return getOrAddLiteral(int32_array_literal, device_id);
155  }
156  if (ti.get_subtype() == kTINYINT) {
157  std::vector<int8_t> int8_array_literal;
158  for (const auto& value : constant->get_value_list()) {
159  const auto c = dynamic_cast<const Analyzer::Constant*>(value.get());
160  CHECK(c);
161  int8_t i = c->get_constval().tinyintval;
162  int8_array_literal.push_back(i);
163  }
164  if (ti.get_comp_param() == 64) {
165  return getOrAddLiteral(std::make_pair(int8_array_literal, 64), device_id);
166  }
167  return getOrAddLiteral(int8_array_literal, device_id);
168  }
169  throw std::runtime_error("Unsupported literal array");
170  }
171  if (enc_type == kENCODING_GEOINT) {
172  if (ti.get_subtype() == kTINYINT) {
173  std::vector<int8_t> int8_array_literal;
174  for (const auto& value : constant->get_value_list()) {
175  const auto c = dynamic_cast<const Analyzer::Constant*>(value.get());
176  CHECK(c);
177  int8_t i = c->get_constval().tinyintval;
178  int8_array_literal.push_back(i);
179  }
180  if (ti.get_comp_param() == 32) {
181  return getOrAddLiteral(std::make_pair(int8_array_literal, 32), device_id);
182  }
183  return getOrAddLiteral(int8_array_literal, device_id);
184  }
185  }
186  throw std::runtime_error("Encoded literal arrays are not supported");
187  }
188  default:
189  abort();
190  }
191  }
const std::list< std::shared_ptr< Analyzer::Expr > > & get_value_list() const
Definition: Analyzer.h:337
#define CHECK_EQ(x, y)
Definition: Logger.h:214
Definition: sqltypes.h:48
tuple d
Definition: test_fsi.py:9
bool get_is_null() const
Definition: Analyzer.h:334
double inline_fp_null_val(const SQL_TYPE_INFO &ti)
size_t getOrAddLiteral(const Analyzer::Constant *constant, const EncodingType enc_type, const int dict_id, const int device_id)
Definition: CgenState.h:68
int64_t bigintval
Definition: sqltypes.h:209
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:78
std::string * stringval
Definition: sqltypes.h:214
SQLTypes decimal_to_int_type(const SQLTypeInfo &ti)
Definition: Datum.cpp:419
Definition: sqltypes.h:51
Definition: sqltypes.h:52
Datum get_constval() const
Definition: Analyzer.h:335
Definition: sqltypes.h:40
#define CHECK(condition)
Definition: Logger.h:206
int64_t inline_int_null_val(const SQL_TYPE_INFO &ti)
Definition: sqltypes.h:44

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class T >
size_t CgenState::getOrAddLiteral ( const T &  val,
const int  device_id 
)
inlineprivate

Definition at line 414 of file CgenState.h.

References addAligned(), literal_bytes_, literalBytes(), and literals_.

414  {
415  const LiteralValue var_val(val);
416  size_t literal_found_off{0};
417  auto& literals = literals_[device_id];
418  for (const auto& literal : literals) {
419  const auto lit_bytes = literalBytes(literal);
420  literal_found_off = addAligned(literal_found_off, lit_bytes);
421  if (literal == var_val) {
422  return literal_found_off - lit_bytes;
423  }
424  }
425  literals.emplace_back(val);
426  const auto lit_bytes = literalBytes(var_val);
427  literal_bytes_[device_id] = addAligned(literal_bytes_[device_id], lit_bytes);
428  return literal_bytes_[device_id] - lit_bytes;
429  }
static size_t literalBytes(const CgenState::LiteralValue &lit)
Definition: CgenState.h:371
boost::variant< int8_t, int16_t, int32_t, int64_t, float, double, std::pair< std::string, int >, std::string, std::vector< double >, std::vector< int32_t >, std::vector< int8_t >, std::pair< std::vector< int8_t >, int >> LiteralValue
Definition: CgenState.h:204
static size_t addAligned(const size_t off_in, const size_t alignment)
Definition: CgenState.h:402
std::unordered_map< int, size_t > literal_bytes_
Definition: CgenState.h:432
std::unordered_map< int, LiteralValues > literals_
Definition: CgenState.h:431

+ Here is the call graph for this function:

std::vector< std::string > CgenState::gpuFunctionsToReplace ( llvm::Function *  fn)

Definition at line 276 of file CgenState.cpp.

References CHECK, and anonymous_namespace{CgenState.cpp}::gpu_replacement_functions.

276  {
277  std::vector<std::string> ret;
278 
279  CHECK(fn);
280  CHECK(!fn->isDeclaration());
281 
282  for (auto& basic_block : *fn) {
283  auto& inst_list = basic_block.getInstList();
284  for (auto inst_itr = inst_list.begin(); inst_itr != inst_list.end(); ++inst_itr) {
285  if (auto call_inst = llvm::dyn_cast<llvm::CallInst>(inst_itr)) {
286  auto called_fcn = call_inst->getCalledFunction();
287  CHECK(called_fcn);
288 
289  if (gpu_replacement_functions.find(called_fcn->getName().str()) !=
291  ret.emplace_back(called_fcn->getName());
292  }
293  }
294  }
295  }
296  return ret;
297 }
static const std::unordered_map< std::string, std::shared_ptr< GpuFunctionDefinition > > gpu_replacement_functions
Definition: CgenState.cpp:268
#define CHECK(condition)
Definition: Logger.h:206
llvm::ConstantFP * CgenState::inlineFpNull ( const SQLTypeInfo type_info)

Definition at line 67 of file CgenState.cpp.

References CHECK, SQLTypeInfo::get_type(), SQLTypeInfo::is_fp(), kDOUBLE, kFLOAT, llFp(), NULL_DOUBLE, and NULL_FLOAT.

Referenced by CodeGenerator::codegenArrayAt(), CodeGenerator::codegenCastFromFp(), CodeGenerator::codegenCastToFp(), CodeGenerator::codegenFixedLengthColVarInWindow(), CodeGenerator::codegenGeoFunctionOperator(), CodeGenerator::codegenUMinus(), CodeGenerator::endArgsNullcheck(), inlineNull(), and CodeGenerator::NullCheckCodegen::NullCheckCodegen().

67  {
68  CHECK(type_info.is_fp());
69  switch (type_info.get_type()) {
70  case kFLOAT:
71  return llFp(NULL_FLOAT);
72  case kDOUBLE:
73  return llFp(NULL_DOUBLE);
74  default:
75  abort();
76  }
77 }
#define NULL_DOUBLE
#define NULL_FLOAT
bool is_fp() const
Definition: sqltypes.h:502
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:323
llvm::ConstantFP * llFp(const float v) const
Definition: CgenState.h:311
#define CHECK(condition)
Definition: Logger.h:206

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::pair< llvm::ConstantInt *, llvm::ConstantInt * > CgenState::inlineIntMaxMin ( const size_t  byte_width,
const bool  is_signed 
)

Definition at line 84 of file CgenState.cpp.

References CHECK_EQ, context_, inline_int_max_min(), inline_uint_max_min(), and ll_int().

Referenced by CodeGenerator::codegenAdd(), CodeGenerator::codegenCastBetweenIntTypesOverflowChecks(), CodeGenerator::codegenDiv(), CodeGenerator::codegenMul(), CodeGenerator::codegenSub(), and CodeGenerator::codegenUMinus().

86  {
87  int64_t max_int{0}, min_int{0};
88  if (is_signed) {
89  std::tie(max_int, min_int) = inline_int_max_min(byte_width);
90  } else {
91  uint64_t max_uint{0}, min_uint{0};
92  std::tie(max_uint, min_uint) = inline_uint_max_min(byte_width);
93  max_int = static_cast<int64_t>(max_uint);
94  CHECK_EQ(uint64_t(0), min_uint);
95  }
96  switch (byte_width) {
97  case 1:
98  return std::make_pair(::ll_int(static_cast<int8_t>(max_int), context_),
99  ::ll_int(static_cast<int8_t>(min_int), context_));
100  case 2:
101  return std::make_pair(::ll_int(static_cast<int16_t>(max_int), context_),
102  ::ll_int(static_cast<int16_t>(min_int), context_));
103  case 4:
104  return std::make_pair(::ll_int(static_cast<int32_t>(max_int), context_),
105  ::ll_int(static_cast<int32_t>(min_int), context_));
106  case 8:
107  return std::make_pair(::ll_int(max_int, context_), ::ll_int(min_int, context_));
108  default:
109  abort();
110  }
111 }
#define CHECK_EQ(x, y)
Definition: Logger.h:214
llvm::ConstantInt * ll_int(const T v, llvm::LLVMContext &context)
llvm::LLVMContext & context_
Definition: CgenState.h:338
std::pair< uint64_t, uint64_t > inline_uint_max_min(const size_t byte_width)
std::pair< int64_t, int64_t > inline_int_max_min(const size_t byte_width)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

llvm::ConstantInt * CgenState::inlineIntNull ( const SQLTypeInfo type_info)

Definition at line 29 of file CgenState.cpp.

References CHECK, SQLTypeInfo::get_compression(), SQLTypeInfo::get_type(), inline_int_null_val(), SQLTypeInfo::is_string(), kARRAY, kBIGINT, kBOOLEAN, kDATE, kDECIMAL, kENCODING_DICT, kENCODING_NONE, kINT, kINTERVAL_DAY_TIME, kINTERVAL_YEAR_MONTH, kNUMERIC, kSMALLINT, kTIME, kTIMESTAMP, kTINYINT, llInt(), and run_benchmark_import::type.

Referenced by CodeGenerator::codegen(), CodeGenerator::codegenArrayAt(), CodeGenerator::codegenCastBetweenIntTypes(), CodeGenerator::codegenCastBetweenIntTypesOverflowChecks(), CodeGenerator::codegenCastBetweenTimestamps(), CodeGenerator::codegenCastFromFp(), CodeGenerator::codegenCastTimestampToDate(), CodeGenerator::codegenCastToFp(), CodeGenerator::codegenDateTruncHighPrecisionTimestamps(), CodeGenerator::codegenDiv(), CodeGenerator::codegenExtractHighPrecisionTimestamps(), CodeGenerator::codegenFixedLengthColVarInWindow(), CodeGenerator::codegenIntConst(), CodeGenerator::codegenIsNullNumber(), CodeGenerator::codegenLogical(), CodeGenerator::codegenLogicalShortCircuit(), CodeGenerator::codegenQualifierCmp(), CodeGenerator::codegenUMinus(), CodeGenerator::codgenAdjustFixedEncNull(), CodeGenerator::endArgsNullcheck(), inlineNull(), and CodeGenerator::NullCheckCodegen::NullCheckCodegen().

29  {
30  auto type = type_info.get_type();
31  if (type_info.is_string()) {
32  switch (type_info.get_compression()) {
33  case kENCODING_DICT:
34  return llInt(static_cast<int32_t>(inline_int_null_val(type_info)));
35  case kENCODING_NONE:
36  return llInt(int64_t(0));
37  default:
38  CHECK(false);
39  }
40  }
41  switch (type) {
42  case kBOOLEAN:
43  return llInt(static_cast<int8_t>(inline_int_null_val(type_info)));
44  case kTINYINT:
45  return llInt(static_cast<int8_t>(inline_int_null_val(type_info)));
46  case kSMALLINT:
47  return llInt(static_cast<int16_t>(inline_int_null_val(type_info)));
48  case kINT:
49  return llInt(static_cast<int32_t>(inline_int_null_val(type_info)));
50  case kBIGINT:
51  case kTIME:
52  case kTIMESTAMP:
53  case kDATE:
54  case kINTERVAL_DAY_TIME:
56  return llInt(inline_int_null_val(type_info));
57  case kDECIMAL:
58  case kNUMERIC:
59  return llInt(inline_int_null_val(type_info));
60  case kARRAY:
61  return llInt(int64_t(0));
62  default:
63  abort();
64  }
65 }
Definition: sqltypes.h:48
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:323
Definition: sqltypes.h:52
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:331
llvm::ConstantInt * llInt(const T v) const
Definition: CgenState.h:307
#define CHECK(condition)
Definition: Logger.h:206
int64_t inline_int_null_val(const SQL_TYPE_INFO &ti)
Definition: sqltypes.h:44
bool is_string() const
Definition: sqltypes.h:498

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

llvm::Constant * CgenState::inlineNull ( const SQLTypeInfo ti)

Definition at line 79 of file CgenState.cpp.

References inlineFpNull(), inlineIntNull(), and SQLTypeInfo::is_fp().

79  {
80  return ti.is_fp() ? static_cast<llvm::Constant*>(inlineFpNull(ti))
81  : static_cast<llvm::Constant*>(inlineIntNull(ti));
82 }
bool is_fp() const
Definition: sqltypes.h:502
llvm::ConstantInt * inlineIntNull(const SQLTypeInfo &)
Definition: CgenState.cpp:29
llvm::ConstantFP * inlineFpNull(const SQLTypeInfo &)
Definition: CgenState.cpp:67

+ Here is the call graph for this function:

static size_t CgenState::literalBytes ( const CgenState::LiteralValue lit)
inlinestatic

Definition at line 371 of file CgenState.h.

Referenced by CodeGenerator::codegenHoistedConstantsLoads(), getOrAddLiteral(), and Executor::serializeLiterals().

371  {
372  switch (lit.which()) {
373  case 0:
374  return 1; // int8_t
375  case 1:
376  return 2; // int16_t
377  case 2:
378  return 4; // int32_t
379  case 3:
380  return 8; // int64_t
381  case 4:
382  return 4; // float
383  case 5:
384  return 8; // double
385  case 6:
386  return 4; // std::pair<std::string, int>
387  case 7:
388  return 4; // std::string
389  case 8:
390  return 4; // std::vector<double>
391  case 9:
392  return 4; // std::vector<int32_t>
393  case 10:
394  return 4; // std::vector<int8_t>
395  case 11:
396  return 4; // std::pair<std::vector<int8_t>, int>
397  default:
398  abort();
399  }
400  }

+ Here is the caller graph for this function:

llvm::ConstantInt* CgenState::llBool ( const bool  v) const
inline

Definition at line 321 of file CgenState.h.

References context_, and ll_bool().

Referenced by Executor::buildHoistLeftHandSideFiltersCb(), Executor::buildIsDeletedCb(), Executor::buildJoinLoops(), CodeGenerator::codegenGeosConstructorCall(), CodeGenerator::codegenGeosPredicateCall(), and CodeGenerator::NullCheckCodegen::NullCheckCodegen().

321 { return ::ll_bool(v, context_); }
llvm::LLVMContext & context_
Definition: CgenState.h:338
llvm::ConstantInt * ll_bool(const bool v, llvm::LLVMContext &context)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

llvm::ConstantFP* CgenState::llFp ( const float  v) const
inline

Definition at line 311 of file CgenState.h.

References context_.

Referenced by CodeGenerator::codegenArrayExpr(), CodeGenerator::codegenDiv(), CodeGenerator::codegenFpArith(), CodeGenerator::codegenIsNullNumber(), and inlineFpNull().

311  {
312  return static_cast<llvm::ConstantFP*>(
313  llvm::ConstantFP::get(llvm::Type::getFloatTy(context_), v));
314  }
llvm::LLVMContext & context_
Definition: CgenState.h:338

+ Here is the caller graph for this function:

llvm::ConstantFP* CgenState::llFp ( const double  v) const
inline

Definition at line 316 of file CgenState.h.

References context_.

316  {
317  return static_cast<llvm::ConstantFP*>(
318  llvm::ConstantFP::get(llvm::Type::getDoubleTy(context_), v));
319  }
llvm::LLVMContext & context_
Definition: CgenState.h:338
template<class T >
llvm::ConstantInt* CgenState::llInt ( const v) const
inline

Definition at line 307 of file CgenState.h.

References context_, and ll_int().

Referenced by Executor::buildIsDeletedCb(), spatial_type::Transform::codegen(), CodeGenerator::codegen(), CodeGenerator::codegenAdd(), CodeGenerator::codegenArrayExpr(), CodeGenerator::codegenBinOpWithOverflowForCPU(), CodeGenerator::codegenCastBetweenIntTypes(), CodeGenerator::codegenCastBetweenIntTypesOverflowChecks(), CodeGenerator::codegenCastBetweenTimestamps(), CodeGenerator::codegenCastFromString(), CodeGenerator::codegenCastTimestampToDate(), CodeGenerator::codegenCompression(), CodeGenerator::codegenDateTruncHighPrecisionTimestamps(), CodeGenerator::codegenDiv(), CodeGenerator::codegenExtractHighPrecisionTimestamps(), CodeGenerator::codegenFixedLengthColVarInWindow(), CodeGenerator::codegenFunctionOper(), CodeGenerator::codegenFunctionOperCastArgs(), CodeGenerator::codegenFunctionOperWithCustomTypeHandling(), CodeGenerator::codegenGeoArgs(), CodeGenerator::codegenGeoBinOper(), CodeGenerator::codegenGeoFunctionOperator(), CodeGenerator::codegenGeosConstructorCall(), CodeGenerator::codegenGeosPredicateCall(), CodeGenerator::codegenGeoUOper(), CodeGenerator::codegenHoistedConstantsLoads(), CodeGenerator::codegenHoistedConstantsPlaceholders(), CodeGenerator::codegenIntConst(), Executor::codegenJoinLoops(), CodeGenerator::codegenMod(), CodeGenerator::codegenMul(), CodeGenerator::codegenQualifierCmp(), CodeGenerator::codegenRowId(), CodeGenerator::codegenSub(), CodeGenerator::codegenUMinus(), CodeGenerator::codegenWindowPosition(), CodeGenerator::codgenAdjustFixedEncNull(), Executor::groupByColumnCodegen(), and inlineIntNull().

307  {
309  }
llvm::ConstantInt * ll_int(const T v, llvm::LLVMContext &context)
llvm::LLVMContext & context_
Definition: CgenState.h:338

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CgenState::maybeCloneFunctionRecursive ( llvm::Function *  fn)

Definition at line 144 of file CgenState.cpp.

References CHECK, g_rt_module, and vmap_.

Referenced by emitCall().

144  {
145  CHECK(fn);
146  if (!fn->isDeclaration()) {
147  return;
148  }
149 
150  // Get the implementation from the runtime module.
151  auto func_impl = g_rt_module->getFunction(fn->getName());
152  CHECK(func_impl) << fn->getName().str();
153 
154  if (func_impl->isDeclaration()) {
155  return;
156  }
157 
158  auto DestI = fn->arg_begin();
159  for (auto arg_it = func_impl->arg_begin(); arg_it != func_impl->arg_end(); ++arg_it) {
160  DestI->setName(arg_it->getName());
161  vmap_[&*arg_it] = &*DestI++;
162  }
163 
164  llvm::SmallVector<llvm::ReturnInst*, 8> Returns; // Ignore returns cloned.
165  llvm::CloneFunctionInto(fn, func_impl, vmap_, /*ModuleLevelChanges=*/true, Returns);
166 
167  for (auto it = llvm::inst_begin(fn), e = llvm::inst_end(fn); it != e; ++it) {
168  if (llvm::isa<llvm::CallInst>(*it)) {
169  auto& call = llvm::cast<llvm::CallInst>(*it);
170  maybeCloneFunctionRecursive(call.getCalledFunction());
171  }
172  }
173 }
void maybeCloneFunctionRecursive(llvm::Function *fn)
Definition: CgenState.cpp:144
std::unique_ptr< llvm::Module > g_rt_module
#define CHECK(condition)
Definition: Logger.h:206
llvm::ValueToValueMapTy vmap_
Definition: CgenState.h:339

+ Here is the caller graph for this function:

void CgenState::replaceFunctionForGpu ( const std::string &  fcn_to_replace,
llvm::Function *  fn 
)

Definition at line 299 of file CgenState.cpp.

References run_benchmark_import::args, CHECK, CHECK_EQ, context_, anonymous_namespace{CgenState.cpp}::gpu_replacement_functions, module_, and VLOG.

300  {
301  CHECK(fn);
302  CHECK(!fn->isDeclaration());
303 
304  auto map_it = gpu_replacement_functions.find(fcn_to_replace);
305  if (map_it == gpu_replacement_functions.end()) {
306  throw QueryMustRunOnCpu("Codegen failed: Could not find replacement functon for " +
307  fcn_to_replace +
308  " to run on gpu. Query must run in cpu mode.");
309  }
310  const auto& gpu_fcn_obj = map_it->second;
311  CHECK(gpu_fcn_obj);
312  const auto& gpu_fcn_name = gpu_fcn_obj->name;
313  VLOG(1) << "Replacing " << fcn_to_replace << " with " << gpu_fcn_name
314  << " for parent function " << fn->getName().str();
315 
316  for (auto& basic_block : *fn) {
317  auto& inst_list = basic_block.getInstList();
318  for (auto inst_itr = inst_list.begin(); inst_itr != inst_list.end(); ++inst_itr) {
319  if (auto call_inst = llvm::dyn_cast<llvm::CallInst>(inst_itr)) {
320  auto called_fcn = call_inst->getCalledFunction();
321  CHECK(called_fcn);
322 
323  if (called_fcn->getName() == fcn_to_replace) {
324  std::vector<llvm::Value*> args;
325  std::vector<llvm::Type*> arg_types;
326  for (auto& arg : call_inst->args()) {
327  arg_types.push_back(arg.get()->getType());
328  args.push_back(arg.get());
329  }
330  auto gpu_func = gpu_fcn_obj->getFunction(module_, context_);
331  CHECK(gpu_func);
332  auto gpu_func_type = gpu_func.getFunctionType();
333  CHECK(gpu_func_type);
334  CHECK_EQ(gpu_func_type->getReturnType(), called_fcn->getReturnType());
335  llvm::ReplaceInstWithInst(call_inst,
336  llvm::CallInst::Create(gpu_func, args, ""));
337  return;
338  }
339  }
340  }
341  }
342 }
#define CHECK_EQ(x, y)
Definition: Logger.h:214
static const std::unordered_map< std::string, std::shared_ptr< GpuFunctionDefinition > > gpu_replacement_functions
Definition: CgenState.cpp:268
llvm::Module * module_
Definition: CgenState.h:329
llvm::LLVMContext & context_
Definition: CgenState.h:338
#define CHECK(condition)
Definition: Logger.h:206
#define VLOG(n)
Definition: Logger.h:300

Member Data Documentation

std::map<std::pair<llvm::Value*, llvm::Value*>, ArrayLoadCodegen> CgenState::array_load_cache_

Definition at line 356 of file CgenState.h.

Referenced by CodeGenerator::codegenGeoArrayLoadAndNullcheck().

const bool CgenState::contains_left_deep_outer_join_

Definition at line 350 of file CgenState.h.

llvm::LLVMContext& CgenState::context_

Definition at line 338 of file CgenState.h.

Referenced by addStringConstant(), CodeGenerator::beginArgsNullcheck(), Executor::buildIsDeletedCb(), CodeGenerator::castArrayPointer(), castToTypeIn(), spatial_type::Transform::codegen(), CodeGenerator::codegen(), CodeGenerator::codegenAdd(), CodeGenerator::codegenArrayAt(), CodeGenerator::codegenArrayBuff(), CodeGenerator::codegenArrayExpr(), CodeGenerator::codegenBinOpWithOverflowForCPU(), CodeGenerator::codegenBufferArgs(), CodeGenerator::codegenCase(), CodeGenerator::codegenCast(), CodeGenerator::codegenCastBetweenIntTypes(), CodeGenerator::codegenCastBetweenIntTypesOverflowChecks(), CodeGenerator::codegenCastFromFp(), CodeGenerator::codegenCastFromString(), CodeGenerator::codegenCastTimestampToDate(), CodeGenerator::codegenCastToFp(), CodeGenerator::codegenDateTruncHighPrecisionTimestamps(), CodeGenerator::codegenDiv(), CodeGenerator::codegenFixedLengthColVar(), CodeGenerator::codegenFixedLengthColVarInWindow(), CodeGenerator::codegenFunctionOper(), CodeGenerator::codegenFunctionOperCastArgs(), CodeGenerator::codegenFunctionOperNullArg(), CodeGenerator::codegenFunctionOperWithCustomTypeHandling(), CodeGenerator::codegenGeoArgs(), CodeGenerator::codegenGeoArrayLoadAndNullcheck(), CodeGenerator::codegenGeoBinOper(), CodeGenerator::codegenGeoFunctionOperator(), CodeGenerator::codegenGeosConstructorCall(), CodeGenerator::codegenGeosPredicateCall(), CodeGenerator::codegenGeoUOper(), CodeGenerator::codegenHoistedConstantsLoads(), CodeGenerator::codegenIsNull(), Executor::codegenJoinLoops(), spatial_type::Transform::codegenLoads(), CodeGenerator::codegenLogicalShortCircuit(), CodeGenerator::codegenMod(), CodeGenerator::codegenMul(), CodeGenerator::codegenOuterJoinNullPlaceholder(), CodeGenerator::codegenOverlaps(), CodeGenerator::codegenQualifierCmp(), CodeGenerator::codegenSkipOverflowCheckForNull(), CodeGenerator::codegenSub(), CodeGenerator::codegenUMinus(), CodeGenerator::codegenVariableLengthStringColVar(), CodeGenerator::codgenAdjustFixedEncNull(), CodeGenerator::colByteStream(), anonymous_namespace{ResultSetReductionCodegen.cpp}::create_entry_block(), anonymous_namespace{ResultSetReductionJIT.cpp}::create_llvm_function(), anonymous_namespace{ResultSetReductionInterpreterStubs.cpp}::create_stub_function(), CodeGenerator::createLineStringStructType(), CodeGenerator::createMultiPolygonStructType(), CodeGenerator::createPointStructType(), CodeGenerator::createPolygonStructType(), emitErrorCheck(), CodeGenerator::endArgsNullcheck(), anonymous_namespace{TableFunctionCompilationContext.cpp}::generate_entry_point(), anonymous_namespace{ExtensionsIR.cpp}::get_buffer_struct_type(), Executor::groupByColumnCodegen(), inlineIntMaxMin(), llBool(), llFp(), llInt(), AutomaticIRMetadataGuard::markInstructions(), CodeGenerator::NullCheckCodegen::NullCheckCodegen(), CodeGenerator::posArg(), Executor::redeclareFilterFunction(), and replaceFunctionForGpu().

std::vector<FunctionOperValue> CgenState::ext_call_cache_

Definition at line 346 of file CgenState.h.

Referenced by CodeGenerator::codegenFunctionOper().

std::unordered_map<int, std::vector<llvm::Value*> > CgenState::fetch_cache_
llvm::Function* CgenState::filter_func_

Definition at line 331 of file CgenState.h.

Referenced by Executor::redeclareFilterFunction().

InsertionOrderedMap CgenState::filter_func_args_

Definition at line 353 of file CgenState.h.

Referenced by Executor::redeclareFilterFunction().

llvm::BasicBlock* CgenState::filter_func_bb_

Definition at line 334 of file CgenState.h.

llvm::CallInst* CgenState::filter_func_call_

Definition at line 336 of file CgenState.h.

std::vector<llvm::Value*> CgenState::frag_offsets_

Definition at line 349 of file CgenState.h.

Referenced by CodeGenerator::codegenColVar(), and CodeGenerator::codegenRowId().

std::unordered_map<std::string, llvm::Value*> CgenState::geo_target_cache_

Definition at line 357 of file CgenState.h.

Referenced by CodeGenerator::codegenGeoOperator().

std::vector<llvm::Value*> CgenState::group_by_expr_cache_

Definition at line 347 of file CgenState.h.

Referenced by CodeGenerator::resolveGroupedColumnReference().

std::vector<llvm::Function*> CgenState::helper_functions_

Definition at line 337 of file CgenState.h.

std::vector<std::unique_ptr<const InValuesBitmap> > CgenState::in_values_bitmaps_

Definition at line 354 of file CgenState.h.

Referenced by addInValuesBitmap().

llvm::IRBuilder CgenState::ir_builder_

Definition at line 340 of file CgenState.h.

Referenced by addStringConstant(), CodeGenerator::beginArgsNullcheck(), Executor::buildIsDeletedCb(), Executor::buildJoinLoops(), CodeGenerator::castArrayPointer(), castToTypeIn(), JoinLoop::codegen(), spatial_type::Transform::codegen(), CodeGenerator::codegen(), CodeGenerator::codegenAdd(), CodeGenerator::codegenArrayAt(), CodeGenerator::codegenArrayExpr(), CodeGenerator::codegenBinOpWithOverflowForCPU(), CodeGenerator::codegenBufferArgs(), CodeGenerator::codegenCase(), CodeGenerator::codegenCast(), CodeGenerator::codegenCastBetweenIntTypes(), CodeGenerator::codegenCastBetweenIntTypesOverflowChecks(), CodeGenerator::codegenCastBetweenTimestamps(), CodeGenerator::codegenCastFromFp(), CodeGenerator::codegenCastToFp(), CodeGenerator::codegenColVar(), CodeGenerator::codegenDateTruncHighPrecisionTimestamps(), CodeGenerator::codegenDiv(), CodeGenerator::codegenExtractHighPrecisionTimestamps(), CodeGenerator::codegenFixedLengthColVar(), CodeGenerator::codegenFixedLengthColVarInWindow(), CodeGenerator::codegenFpArith(), CodeGenerator::codegenFunctionOper(), CodeGenerator::codegenFunctionOperCastArgs(), CodeGenerator::codegenFunctionOperNullArg(), CodeGenerator::codegenFunctionOperWithCustomTypeHandling(), CodeGenerator::codegenGeoArgs(), CodeGenerator::codegenGeoFunctionOperator(), CodeGenerator::codegenGeoLineStringArgs(), CodeGenerator::codegenGeoMultiPolygonArgs(), CodeGenerator::codegenGeoPointArgs(), CodeGenerator::codegenGeoPolygonArgs(), CodeGenerator::codegenGeosConstructorCall(), CodeGenerator::codegenGeosPredicateCall(), CodeGenerator::codegenHoistedConstantsPlaceholders(), CodeGenerator::codegenIsNullNumber(), Executor::codegenJoinLoops(), spatial_type::Transform::codegenLoads(), CodeGenerator::codegenLogical(), CodeGenerator::codegenLogicalShortCircuit(), CodeGenerator::codegenMod(), CodeGenerator::codegenMul(), CodeGenerator::codegenOuterJoinNullPlaceholder(), CodeGenerator::codegenRowId(), CodeGenerator::codegenSkipOverflowCheckForNull(), CodeGenerator::codegenSub(), CodeGenerator::codegenUMinus(), CodeGenerator::codgenAdjustFixedEncNull(), ScalarCodeGenerator::compile(), anonymous_namespace{ResultSetReductionCodegen.cpp}::create_entry_block(), anonymous_namespace{ResultSetReductionInterpreterStubs.cpp}::create_stub_function(), emitCall(), emitErrorCheck(), CodeGenerator::endArgsNullcheck(), JoinLoop::evaluateOuterJoinCondition(), Executor::groupByColumnCodegen(), CodeGenerator::NullCheckCodegen::NullCheckCodegen(), CodeGenerator::posArg(), and CodeGenerator::toBool().

std::unordered_map<int, size_t> CgenState::literal_bytes_
private

Definition at line 432 of file CgenState.h.

Referenced by getLiteralBufferUsage(), and getOrAddLiteral().

std::unordered_map<int, LiteralValues> CgenState::literals_
private

Definition at line 431 of file CgenState.h.

Referenced by getLiterals(), and getOrAddLiteral().

bool CgenState::needs_geos_
std::vector<llvm::Value*> CgenState::outer_join_match_found_per_level_
llvm::Function* CgenState::query_func_

Definition at line 361 of file CgenState.h.

Referenced by CodeGenerator::codegenHoistedConstantsLoads().

llvm::IRBuilder CgenState::query_func_entry_ir_builder_

Definition at line 362 of file CgenState.h.

Referenced by CodeGenerator::codegenHoistedConstantsLoads().

std::unordered_map<int, std::vector<llvm::Value*> > CgenState::query_func_literal_loads_

Definition at line 363 of file CgenState.h.

Referenced by CodeGenerator::codegenHoistedConstants().

llvm::BasicBlock* CgenState::row_func_bb_

Definition at line 333 of file CgenState.h.

llvm::CallInst* CgenState::row_func_call_

Definition at line 335 of file CgenState.h.

std::unordered_map<llvm::Value*, HoistedLiteralLoadLocator> CgenState::row_func_hoisted_literals_

Definition at line 369 of file CgenState.h.

Referenced by CodeGenerator::codegenHoistedConstantsPlaceholders().

std::unordered_map<int, llvm::Value*> CgenState::scan_idx_to_hash_pos_

Definition at line 352 of file CgenState.h.

Referenced by Executor::addJoinLoopIterator(), and CodeGenerator::posArg().

std::vector<llvm::Value*> CgenState::str_constants_

Definition at line 348 of file CgenState.h.

Referenced by addStringConstant().

llvm::ValueToValueMapTy CgenState::vmap_

Definition at line 339 of file CgenState.h.

Referenced by CodeGenerator::link_udf_module(), and maybeCloneFunctionRecursive().


The documentation for this struct was generated from the following files: