OmniSciDB  95562058bd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CodeGenerator::NullCheckCodegen Struct Reference

#include <CodeGenerator.h>

+ Collaboration diagram for CodeGenerator::NullCheckCodegen:

Public Member Functions

 NullCheckCodegen (CgenState *cgen_state, Executor *executor, llvm::Value *nullable_lv, const SQLTypeInfo &nullable_ti, const std::string &name="")
 
llvm::Value * finalize (llvm::Value *null_lv, llvm::Value *notnull_lv)
 

Public Attributes

CgenStatecgen_state {nullptr}
 
std::string name
 
llvm::BasicBlock * nullcheck_bb {nullptr}
 
llvm::PHINode * nullcheck_value {nullptr}
 
std::unique_ptr
< GroupByAndAggregate::DiamondCodegen
null_check
 

Detailed Description

Definition at line 116 of file CodeGenerator.h.

Constructor & Destructor Documentation

CodeGenerator::NullCheckCodegen::NullCheckCodegen ( CgenState cgen_state,
Executor executor,
llvm::Value *  nullable_lv,
const SQLTypeInfo nullable_ti,
const std::string &  name = "" 
)

Definition at line 810 of file IRCodegen.cpp.

References AUTOMATIC_IR_METADATA, CHECK, CgenState::context_, CgenState::current_func_, CgenState::inlineFpNull(), CgenState::inlineIntNull(), CgenState::ir_builder_, SQLTypeInfo::is_fp(), SQLTypeInfo::is_number(), SQLTypeInfo::is_time(), null_check, and nullcheck_bb.

815  : cgen_state(cgen_state), name(name) {
816  AUTOMATIC_IR_METADATA(cgen_state);
817  CHECK(nullable_ti.is_number() || nullable_ti.is_time());
818 
819  null_check = std::make_unique<GroupByAndAggregate::DiamondCodegen>(
820  nullable_ti.is_fp()
821  ? cgen_state->ir_builder_.CreateFCmp(llvm::FCmpInst::FCMP_OEQ,
822  nullable_lv,
823  cgen_state->inlineFpNull(nullable_ti))
824  : cgen_state->ir_builder_.CreateICmp(llvm::ICmpInst::ICMP_EQ,
825  nullable_lv,
826  cgen_state->inlineIntNull(nullable_ti)),
827  executor,
828  false,
829  name,
830  nullptr,
831  false);
832 
833  // generate a phi node depending on whether we got a null or not
834  nullcheck_bb = llvm::BasicBlock::Create(
835  cgen_state->context_, name + "_bb", cgen_state->current_func_);
836 
837  // update the blocks created by diamond codegen to point to the newly created phi
838  // block
839  cgen_state->ir_builder_.SetInsertPoint(null_check->cond_true_);
840  cgen_state->ir_builder_.CreateBr(nullcheck_bb);
841  cgen_state->ir_builder_.SetInsertPoint(null_check->cond_false_);
842 }
llvm::BasicBlock * nullcheck_bb
bool is_fp() const
Definition: sqltypes.h:421
llvm::IRBuilder ir_builder_
Definition: CgenState.h:341
bool is_number() const
Definition: sqltypes.h:422
bool is_time() const
Definition: sqltypes.h:423
llvm::LLVMContext & context_
Definition: CgenState.h:339
llvm::Function * current_func_
Definition: CgenState.h:333
llvm::ConstantInt * inlineIntNull(const SQLTypeInfo &)
Definition: CgenState.cpp:27
#define AUTOMATIC_IR_METADATA(CGENSTATE)
std::unique_ptr< GroupByAndAggregate::DiamondCodegen > null_check
#define CHECK(condition)
Definition: Logger.h:197
llvm::ConstantFP * inlineFpNull(const SQLTypeInfo &)
Definition: CgenState.cpp:65
Executor * executor() const

+ Here is the call graph for this function:

Member Function Documentation

llvm::Value * CodeGenerator::NullCheckCodegen::finalize ( llvm::Value *  null_lv,
llvm::Value *  notnull_lv 
)

Definition at line 844 of file IRCodegen.cpp.

References AUTOMATIC_IR_METADATA, CHECK, CHECK_EQ, and setup::name.

845  {
847  CHECK(null_check);
849 
850  CHECK_EQ(null_lv->getType(), notnull_lv->getType());
851 
852  cgen_state->ir_builder_.SetInsertPoint(nullcheck_bb);
854  cgen_state->ir_builder_.CreatePHI(null_lv->getType(), 2, name + "_value");
855  nullcheck_value->addIncoming(notnull_lv, null_check->cond_false_);
856  nullcheck_value->addIncoming(null_lv, null_check->cond_true_);
857 
858  null_check.reset(nullptr);
859  cgen_state->ir_builder_.SetInsertPoint(nullcheck_bb);
860  return nullcheck_value;
861 }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
llvm::BasicBlock * nullcheck_bb
llvm::IRBuilder ir_builder_
Definition: CgenState.h:341
#define AUTOMATIC_IR_METADATA(CGENSTATE)
std::unique_ptr< GroupByAndAggregate::DiamondCodegen > null_check
#define CHECK(condition)
Definition: Logger.h:197

Member Data Documentation

CgenState* CodeGenerator::NullCheckCodegen::cgen_state {nullptr}

Definition at line 125 of file CodeGenerator.h.

std::string CodeGenerator::NullCheckCodegen::name

Definition at line 126 of file CodeGenerator.h.

std::unique_ptr<GroupByAndAggregate::DiamondCodegen> CodeGenerator::NullCheckCodegen::null_check

Definition at line 129 of file CodeGenerator.h.

Referenced by NullCheckCodegen().

llvm::BasicBlock* CodeGenerator::NullCheckCodegen::nullcheck_bb {nullptr}

Definition at line 127 of file CodeGenerator.h.

Referenced by NullCheckCodegen().

llvm::PHINode* CodeGenerator::NullCheckCodegen::nullcheck_value {nullptr}

Definition at line 128 of file CodeGenerator.h.


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