OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DiamondCodegen Struct Reference

#include <DiamondCodegen.h>

+ Collaboration diagram for DiamondCodegen:

Public Member Functions

 DiamondCodegen (llvm::Value *cond, Executor *executor, const bool chain_to_next, const std::string &label_prefix, DiamondCodegen *parent, const bool share_false_edge_with_parent)
 
void setChainToNext ()
 
void setFalseTarget (llvm::BasicBlock *cond_false)
 
 ~DiamondCodegen ()
 

Public Attributes

Executorexecutor_
 
llvm::BasicBlock * cond_true_
 
llvm::BasicBlock * cond_false_
 
llvm::BasicBlock * orig_cond_false_
 
bool chain_to_next_
 
DiamondCodegenparent_
 

Detailed Description

Helper struct for generating a branching instruction in LLVM IR. The diamond refers to both branches, the starting basic block, and the ending block. The true and false basic blocks are created on initialization, and the branches are created at destruction.

Definition at line 30 of file DiamondCodegen.h.

Constructor & Destructor Documentation

DiamondCodegen::DiamondCodegen ( llvm::Value *  cond,
Executor executor,
const bool  chain_to_next,
const std::string &  label_prefix,
DiamondCodegen parent,
const bool  share_false_edge_with_parent 
)

Definition at line 22 of file DiamondCodegen.cpp.

References AUTOMATIC_IR_METADATA, chain_to_next_, CHECK, cond_false_, cond_true_, executor_, orig_cond_false_, and parent_.

28  : executor_(executor), chain_to_next_(chain_to_next), parent_(parent) {
29  auto* cgen_state = executor_->cgen_state_.get();
30  CHECK(cgen_state);
31  AUTOMATIC_IR_METADATA(cgen_state);
32  if (parent_) {
34  }
35  cond_true_ = llvm::BasicBlock::Create(
36  cgen_state->context_, label_prefix + "_true", cgen_state->current_func_);
37  if (share_false_edge_with_parent) {
38  CHECK(parent);
40  } else {
41  orig_cond_false_ = cond_false_ = llvm::BasicBlock::Create(
42  cgen_state->context_, label_prefix + "_false", cgen_state->current_func_);
43  }
44 
45  cgen_state->ir_builder_.CreateCondBr(cond, cond_true_, cond_false_);
46  cgen_state->ir_builder_.SetInsertPoint(cond_true_);
47 }
llvm::BasicBlock * cond_false_
llvm::BasicBlock * cond_true_
DiamondCodegen * parent_
#define AUTOMATIC_IR_METADATA(CGENSTATE)
llvm::BasicBlock * orig_cond_false_
#define CHECK(condition)
Definition: Logger.h:291
Executor * executor_
DiamondCodegen::~DiamondCodegen ( )

Definition at line 59 of file DiamondCodegen.cpp.

References AUTOMATIC_IR_METADATA, chain_to_next_, cond_false_, executor_, orig_cond_false_, and parent_.

59  {
60  AUTOMATIC_IR_METADATA(executor_->cgen_state_.get());
61  auto& builder = executor_->cgen_state_->ir_builder_;
63  builder.CreateBr(parent_->cond_false_);
64  } else if (chain_to_next_) {
65  builder.CreateBr(cond_false_);
66  }
68  builder.SetInsertPoint(orig_cond_false_);
69  }
70 }
llvm::BasicBlock * cond_false_
DiamondCodegen * parent_
#define AUTOMATIC_IR_METADATA(CGENSTATE)
llvm::BasicBlock * orig_cond_false_
Executor * executor_

Member Function Documentation

void DiamondCodegen::setChainToNext ( )

Definition at line 49 of file DiamondCodegen.cpp.

References chain_to_next_, CHECK, and parent_.

49  {
50  CHECK(!parent_);
51  chain_to_next_ = true;
52 }
DiamondCodegen * parent_
#define CHECK(condition)
Definition: Logger.h:291
void DiamondCodegen::setFalseTarget ( llvm::BasicBlock *  cond_false)

Definition at line 54 of file DiamondCodegen.cpp.

References CHECK, cond_false_, orig_cond_false_, and parent_.

Referenced by Executor::groupByColumnCodegen().

54  {
56  cond_false_ = cond_false;
57 }
llvm::BasicBlock * cond_false_
DiamondCodegen * parent_
llvm::BasicBlock * orig_cond_false_
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the caller graph for this function:

Member Data Documentation

bool DiamondCodegen::chain_to_next_

Definition at line 45 of file DiamondCodegen.h.

Referenced by DiamondCodegen(), setChainToNext(), and ~DiamondCodegen().

llvm::BasicBlock* DiamondCodegen::cond_false_
llvm::BasicBlock* DiamondCodegen::cond_true_

Definition at line 42 of file DiamondCodegen.h.

Referenced by TargetExprCodegen::codegenAggregate(), and DiamondCodegen().

Executor* DiamondCodegen::executor_

Definition at line 41 of file DiamondCodegen.h.

Referenced by DiamondCodegen(), and ~DiamondCodegen().

llvm::BasicBlock* DiamondCodegen::orig_cond_false_
DiamondCodegen* DiamondCodegen::parent_

Definition at line 46 of file DiamondCodegen.h.

Referenced by DiamondCodegen(), setChainToNext(), setFalseTarget(), and ~DiamondCodegen().


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