26 if (
const auto geo_constant = dynamic_cast<const Analyzer::GeoConstant*>(constant)) {
29 std::vector<const Analyzer::Constant*> constants(
67 llvm::Constant::getNullValue(
75 ->getStringDictionaryProxy(
76 dict_id,
executor()->getRowSetMemoryOwner(),
true)
77 ->getIdOfString(str_const))};
146 const int16_t lit_off,
147 const size_t lit_bytes) {
152 lit_buff_query_func_lv->getType()->getScalarType()->getPointerElementType(),
153 lit_buff_query_func_lv,
165 off_and_len_ptr->getType()->getPointerElementType(), off_and_len_ptr);
175 lit_buff_query_func_lv->getType()->getScalarType()->getPointerElementType(),
176 lit_buff_query_func_lv,
178 auto var_length = len_lv;
180 var_start->setName(literal_name +
"_start");
181 var_start_address->setName(literal_name +
"_start_address");
182 var_length->setName(literal_name +
"_length");
184 return {var_start, var_start_address, var_length};
199 off_and_len_ptr->getType()->getPointerElementType(), off_and_len_ptr);
208 lit_buff_query_func_lv->getType()->getScalarType()->getPointerElementType(),
209 lit_buff_query_func_lv,
211 auto var_length = len_lv;
213 var_start_address->setName(literal_name +
"_start_address");
214 var_length->setName(literal_name +
"_length");
216 return {var_start_address, var_length};
224 const size_t lit_bits = lit_bytes * 8;
226 const size_t val_bits_in = type_info.
is_decimal() ? lit_bits : val_bits_out;
229 std::stringstream ss;
230 ss <<
"Invalid literal buffer read size " << val_bits_in <<
" (expected " << lit_bits
232 <<
". See also: --allow-invalid-literal-buffer-reads";
233 LOG(
ERROR) <<
"ERROR: " << ss.str();
235 throw std::runtime_error(ss.str());
237 CHECK_EQ(
size_t(0), val_bits_in % 8);
238 CHECK_EQ(
size_t(0), val_bits_out % 8);
241 val_ptr_type = llvm::PointerType::get(
253 if (type_info.
is_decimal() && val_bits_in != val_bits_out) {
276 lit_lv->setName(literal_name);
283 const int16_t lit_off,
284 const std::vector<llvm::Value*>& literal_loads) {
292 llvm::Value* var_start = literal_loads[0];
293 llvm::Value* var_start_address = literal_loads[1];
294 llvm::Value* var_length = literal_loads[2];
296 llvm::PointerType* placeholder0_type =
297 llvm::PointerType::get(var_start->getType(), 0);
301 int_to_ptr0->getType()->getPointerElementType(),
303 "__placeholder__" + literal_name +
"_start");
304 llvm::PointerType* placeholder1_type =
305 llvm::PointerType::get(var_start_address->getType(), 0);
309 int_to_ptr1->getType()->getPointerElementType(),
311 "__placeholder__" + literal_name +
"_start_address");
312 llvm::PointerType* placeholder2_type =
313 llvm::PointerType::get(var_length->getType(), 0);
317 int_to_ptr2->getType()->getPointerElementType(),
319 "__placeholder__" + literal_name +
"_length");
325 return {placeholder0, placeholder1, placeholder2};
332 llvm::Value* var_start_address = literal_loads[0];
333 llvm::Value* var_length = literal_loads[1];
335 llvm::PointerType* placeholder0_type =
336 llvm::PointerType::get(var_start_address->getType(), 0);
340 int_to_ptr0->getType()->getPointerElementType(),
342 "__placeholder__" + literal_name +
"_start_address");
343 llvm::PointerType* placeholder1_type =
344 llvm::PointerType::get(var_length->getType(), 0);
348 int_to_ptr1->getType()->getPointerElementType(),
350 "__placeholder__" + literal_name +
"_length");
355 return {placeholder0, placeholder1};
359 llvm::Value* to_return_lv = literal_loads[0];
366 "__placeholder__" + literal_name);
370 return {placeholder0};
374 const std::vector<const Analyzer::Constant*>& constants,
378 CHECK(!constants.empty());
379 const auto& type_info = constants.front()->get_type_info();
381 size_t next_lit_bytes{0};
390 for (
size_t device_id = 0; device_id < constants.size(); ++device_id) {
391 const auto constant = constants[device_id];
393 CHECK(type_info == crt_type_info);
394 std::tie(checked_lit_off, next_lit_bytes) =
398 CHECK_EQ(lit_bytes, next_lit_bytes);
400 lit_off =
static_cast<int16_t
>(checked_lit_off);
401 lit_bytes = next_lit_bytes;
404 }
catch (
const std::range_error& e) {
411 std::vector<llvm::Value*> hoisted_literal_loads;
415 hoisted_literal_loads =
419 hoisted_literal_loads = entry->second;
423 type_info, enc_type, lit_off, hoisted_literal_loads);
424 return literal_placeholders;
HOST DEVICE SQLTypes get_subtype() const
llvm::Value * emitEntryCall(const std::string &fname, const std::vector< llvm::Value * > &args)
llvm::Value * addStringConstant(const std::string &str)
HOST DEVICE int get_scale() const
llvm::Function * query_func_
std::unordered_map< llvm::Value *, HoistedLiteralLoadLocator > row_func_hoisted_literals_
llvm::IRBuilder ir_builder_
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 15, 15, boost::multiprecision::signed_magnitude, boost::multiprecision::checked, void >> checked_int16_t
std::unordered_map< int, std::vector< llvm::Value * > > query_func_literal_loads_
std::vector< llvm::Value * > codegenHoistedConstants(const std::vector< const Analyzer::Constant * > &constants, const EncodingType enc_type, const shared::StringDictKey &dict_id)
HOST DEVICE SQLTypes get_type() const
llvm::Type * get_int_type(const int width, llvm::LLVMContext &context)
static size_t literalBytes(const CgenState::LiteralValue &lit)
boost::variant< int8_t, int16_t, int32_t, int64_t, float, double, std::pair< std::string, shared::StringDictKey >, std::string, std::vector< double >, std::vector< int32_t >, std::vector< int8_t >, std::pair< std::vector< int8_t >, int >> LiteralValue
std::string to_string() const
size_t get_bit_width(const SQLTypeInfo &ti)
llvm::LLVMContext & context_
llvm::Value * get_arg_by_name(llvm::Function *func, const std::string &name)
llvm::ConstantInt * inlineIntNull(const SQLTypeInfo &)
std::vector< llvm::Value * > codegenHoistedConstantsLoads(const SQLTypeInfo &type_info, const EncodingType enc_type, const shared::StringDictKey &dict_id, const int16_t lit_off, const size_t lit_bytes)
std::vector< llvm::Value * > codegenHoistedConstantsPlaceholders(const SQLTypeInfo &type_info, const EncodingType enc_type, const int16_t lit_off, const std::vector< llvm::Value * > &literal_loads)
bool is_timeinterval() const
llvm::IRBuilder query_func_entry_ir_builder_
std::string toString(const Executor::ExtModuleKinds &kind)
const SQLTypeInfo & get_type_info() const
SQLTypes decimal_to_int_type(const SQLTypeInfo &ti)
ExecutorDeviceType device_type
std::vector< llvm::Value * > codegen(const Analyzer::Expr *, const bool fetch_columns, const CompilationOptions &)
static llvm::ConstantInt * codegenIntConst(const Analyzer::Constant *constant, CgenState *cgen_state)
HOST DEVICE EncodingType get_compression() const
Datum get_constval() const
HOST DEVICE int get_dimension() const
bool g_allow_invalid_literal_buffer_reads
llvm::ConstantInt * llInt(const T v) const
int64_t inline_int_null_val(const SQL_TYPE_INFO &ti)
std::vector< llvm::Value * > codegenGeoConstant(const Analyzer::GeoConstant *, const CompilationOptions &)
SQLTypes get_phys_int_type(const size_t byte_sz)
std::tuple< size_t, size_t > getOrAddLiteral(const Analyzer::Constant *constant, const EncodingType enc_type, const shared::StringDictKey &dict_id, const int device_id)
Executor * executor() const