20 #include <llvm/Transforms/Utils/Cloning.h>
24 extern std::unique_ptr<llvm::Module> g_rt_geos_module;
34 return llInt(int64_t(0));
59 return llInt(int64_t(0));
83 const size_t byte_width,
84 const bool is_signed) {
85 int64_t max_int{0}, min_int{0};
89 uint64_t max_uint{0}, min_uint{0};
91 max_int =
static_cast<int64_t
>(max_uint);
96 return std::make_pair(::
ll_int(static_cast<int8_t>(max_int),
context_),
99 return std::make_pair(::
ll_int(static_cast<int16_t>(max_int),
context_),
102 return std::make_pair(::
ll_int(static_cast<int32_t>(max_int),
context_),
112 auto src_bits = val->getType()->getScalarSizeInBits();
113 if (src_bits == dst_bits) {
116 if (val->getType()->isIntegerTy()) {
121 if (val->getType()->isPointerTy()) {
125 CHECK(val->getType()->isFloatTy() || val->getType()->isDoubleTy());
130 dst_type = llvm::Type::getDoubleTy(
context_);
133 dst_type = llvm::Type::getFloatTy(
context_);
143 const std::vector<llvm::Value*>&
args) {
146 CHECK(func_impl) << fname;
148 auto func =
module_->getFunction(fname);
152 if (func->isDeclaration() && !func_impl->isDeclaration()) {
153 auto DestI = func->arg_begin();
154 for (
auto arg_it = func_impl->arg_begin(); arg_it != func_impl->arg_end(); ++arg_it) {
155 DestI->setName(arg_it->getName());
156 vmap_[&*arg_it] = &*DestI++;
159 llvm::SmallVector<llvm::ReturnInst*, 8> Returns;
160 llvm::CloneFunctionInto(func, func_impl,
vmap_,
true, Returns);
167 llvm::Value* errorCode,
172 ir_builder_.CreateCondBr(condition, check_ok, check_fail);
llvm::Value * castToTypeIn(llvm::Value *val, const size_t bit_width)
llvm::ConstantInt * ll_int(const T v, llvm::LLVMContext &context)
llvm::IRBuilder ir_builder_
HOST DEVICE SQLTypes get_type() const
llvm::Type * get_int_type(const int width, llvm::LLVMContext &context)
llvm::LLVMContext & context_
llvm::Function * current_func_
llvm::ConstantInt * inlineIntNull(const SQLTypeInfo &)
std::unique_ptr< llvm::Module > g_rt_module
llvm::ConstantFP * llFp(const float v) const
llvm::Value * emitCall(const std::string &fname, const std::vector< llvm::Value * > &args)
std::pair< uint64_t, uint64_t > inline_uint_max_min(const size_t byte_width)
llvm::Constant * inlineNull(const SQLTypeInfo &)
HOST DEVICE EncodingType get_compression() const
void emitErrorCheck(llvm::Value *condition, llvm::Value *errorCode, std::string label)
llvm::ConstantInt * llInt(const T v) const
llvm::ValueToValueMapTy vmap_
int64_t inline_int_null_val(const SQL_TYPE_INFO &ti)
std::pair< int64_t, int64_t > inline_int_max_min(const size_t byte_width)
std::pair< llvm::ConstantInt *, llvm::ConstantInt * > inlineIntMaxMin(const size_t byte_width, const bool is_signed)
llvm::ConstantFP * inlineFpNull(const SQLTypeInfo &)