OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ReductionInterpreterImpl Class Reference

Public Member Functions

 ReductionInterpreterImpl (const size_t executor_id, const std::vector< ReductionInterpreter::EvalValue > &vars)
 
std::optional
< ReductionInterpreter::EvalValue
ret () const
 
size_t getExecutorId () const
 

Static Public Member Functions

static void runGetElementPtr (const Instruction *instruction, ReductionInterpreterImpl *interpreter)
 
static void runLoad (const Instruction *instruction, ReductionInterpreterImpl *interpreter)
 
static void runICmp (const Instruction *instruction, ReductionInterpreterImpl *interpreter)
 
static void runBinaryOperator (const Instruction *instruction, ReductionInterpreterImpl *interpreter)
 
static void runCast (const Instruction *instruction, ReductionInterpreterImpl *interpreter)
 
static void runRet (const Instruction *instruction, ReductionInterpreterImpl *interpreter)
 
static void runCall (const Instruction *instruction, ReductionInterpreterImpl *interpreter)
 
static void runExternalCall (const Instruction *instruction, ReductionInterpreterImpl *interpreter)
 
static void runAlloca (const Instruction *instruction, ReductionInterpreterImpl *interpreter)
 
static void runMemCpy (const Instruction *instruction, ReductionInterpreterImpl *interpreter)
 
static void runReturnEarly (const Instruction *instruction, ReductionInterpreterImpl *interpreter)
 
static void runFor (const Instruction *instruction, ReductionInterpreterImpl *interpreter)
 

Private Member Functions

void setVar (const Value *var, ReductionInterpreter::EvalValue value)
 

Static Private Member Functions

template<class Call >
static std::vector
< ReductionInterpreter::EvalValue
getCallInputs (const Call *call, const ReductionInterpreterImpl *interpreter)
 
template<class Call >
static StubGenerator::Stub bindStub (const size_t executor_id, const Call *call)
 

Private Attributes

size_t executor_id_
 
std::vector
< ReductionInterpreter::EvalValue
vars_
 
std::vector< std::vector
< int8_t > > 
alloca_buffers_
 
std::optional
< ReductionInterpreter::EvalValue
ret_ = std::nullopt
 

Detailed Description

Definition at line 56 of file ResultSetReductionInterpreter.cpp.

Constructor & Destructor Documentation

ReductionInterpreterImpl::ReductionInterpreterImpl ( const size_t  executor_id,
const std::vector< ReductionInterpreter::EvalValue > &  vars 
)
inline

Definition at line 58 of file ResultSetReductionInterpreter.cpp.

60  : executor_id_(executor_id), vars_(vars) {}
std::vector< ReductionInterpreter::EvalValue > vars_

Member Function Documentation

template<class Call >
static StubGenerator::Stub ReductionInterpreterImpl::bindStub ( const size_t  executor_id,
const Call call 
)
inlinestaticprivate

Definition at line 339 of file ResultSetReductionInterpreter.cpp.

References Call::arguments(), Call::cached_callee(), Call::callee_name(), CHECK, Call::external(), StubGenerator::generateStub(), anonymous_namespace{ResultSetReductionInterpreter.cpp}::get_value_types(), Call::set_cached_callee(), and Value::type().

Referenced by runCall(), and runExternalCall().

339  {
340  const auto func_ptr =
341  call->cached_callee()
342  ? reinterpret_cast<StubGenerator::Stub>(call->cached_callee())
343  : StubGenerator::generateStub(executor_id,
344  call->callee_name(),
345  get_value_types(call->arguments()),
346  call->type(),
347  call->external());
348  CHECK(func_ptr);
349  call->set_cached_callee(reinterpret_cast<void*>(func_ptr));
350  return func_ptr;
351  }
bool external() const
Type type() const
static Stub generateStub(const size_t executor_id, const std::string &name, const std::vector< Type > &arg_types, const Type ret_type, const bool is_external)
const std::string & callee_name() const
std::vector< Type > get_value_types(const std::vector< const Value * > &values)
void * cached_callee() const
ReductionInterpreter::EvalValue(*)(void *output_handle, const void *inputs_handle) Stub
#define CHECK(condition)
Definition: Logger.h:291
void set_cached_callee(void *cached_callee) const
const std::vector< const Value * > & arguments() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class Call >
static std::vector<ReductionInterpreter::EvalValue> ReductionInterpreterImpl::getCallInputs ( const Call call,
const ReductionInterpreterImpl interpreter 
)
inlinestaticprivate

Definition at line 326 of file ResultSetReductionInterpreter.cpp.

References Call::arguments(), and vars_.

Referenced by runCall(), and runExternalCall().

328  {
329  std::vector<ReductionInterpreter::EvalValue> inputs;
330  inputs.reserve(interpreter->vars_.size());
331  for (const auto argument : call->arguments()) {
332  inputs.push_back(interpreter->vars_[argument->id()]);
333  }
334  return inputs;
335  }
std::vector< ReductionInterpreter::EvalValue > vars_
const std::vector< const Value * > & arguments() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t ReductionInterpreterImpl::getExecutorId ( ) const
inline

Definition at line 65 of file ResultSetReductionInterpreter.cpp.

References executor_id_.

Referenced by runCall(), runExternalCall(), and runFor().

+ Here is the caller graph for this function:

std::optional<ReductionInterpreter::EvalValue> ReductionInterpreterImpl::ret ( ) const
inline

Definition at line 62 of file ResultSetReductionInterpreter.cpp.

References ret_.

Referenced by runCall(), runFor(), and runRet().

62 { return ret_; }
std::optional< ReductionInterpreter::EvalValue > ret_

+ Here is the caller graph for this function:

static void ReductionInterpreterImpl::runAlloca ( const Instruction instruction,
ReductionInterpreterImpl interpreter 
)
inlinestatic

Definition at line 252 of file ResultSetReductionInterpreter.cpp.

References alloca_buffers_, CHECK, anonymous_namespace{ResultSetReductionInterpreter.cpp}::get_element_size(), is_integer_type(), ReductionInterpreter::EvalValue::mutable_ptr, ret_, setVar(), and vars_.

Referenced by Alloca::run().

253  {
254  CHECK(!interpreter->ret_) << "Function has already returned";
255  const auto alloca = static_cast<const Alloca*>(instruction);
256  const auto element_size = get_element_size(alloca->type());
257  CHECK(is_integer_type(alloca->array_size()->type()));
258  const auto array_size = interpreter->vars_[alloca->array_size()->id()];
259  interpreter->alloca_buffers_.emplace_back(element_size * array_size.int_val);
261  eval_value.mutable_ptr = interpreter->alloca_buffers_.back().data();
262  interpreter->setVar(alloca, eval_value);
263  }
void setVar(const Value *var, ReductionInterpreter::EvalValue value)
std::vector< ReductionInterpreter::EvalValue > vars_
std::optional< ReductionInterpreter::EvalValue > ret_
#define CHECK(condition)
Definition: Logger.h:291
std::vector< std::vector< int8_t > > alloca_buffers_
bool is_integer_type(const Type type)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void ReductionInterpreterImpl::runBinaryOperator ( const Instruction instruction,
ReductionInterpreterImpl interpreter 
)
inlinestatic

Definition at line 148 of file ResultSetReductionInterpreter.cpp.

References BinaryOperator::Add, CHECK, logger::FATAL, is_integer_type(), LOG, ReductionInterpreter::MakeEvalValue(), BinaryOperator::Mul, run_benchmark_import::result, ret_, setVar(), and vars_.

Referenced by BinaryOperator::run().

149  {
150  CHECK(!interpreter->ret_) << "Function has already returned";
151  const auto binary_operator = static_cast<const BinaryOperator*>(instruction);
152  CHECK(is_integer_type(binary_operator->type()));
153  const auto lhs = interpreter->vars_[binary_operator->lhs()->id()];
154  const auto rhs = interpreter->vars_[binary_operator->rhs()->id()];
155  int64_t result = 0;
156  switch (binary_operator->op()) {
158  result = lhs.int_val + rhs.int_val;
159  break;
160  }
162  result = lhs.int_val * rhs.int_val;
163  break;
164  }
165  default: {
166  LOG(FATAL) << "Binary operator not supported: "
167  << static_cast<int>(binary_operator->op());
168  }
169  }
170  interpreter->setVar(binary_operator, ReductionInterpreter::MakeEvalValue(result));
171  }
void setVar(const Value *var, ReductionInterpreter::EvalValue value)
#define LOG(tag)
Definition: Logger.h:285
std::vector< ReductionInterpreter::EvalValue > vars_
static EvalValue MakeEvalValue(const T &val)
std::optional< ReductionInterpreter::EvalValue > ret_
#define CHECK(condition)
Definition: Logger.h:291
bool is_integer_type(const Type type)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void ReductionInterpreterImpl::runCall ( const Instruction instruction,
ReductionInterpreterImpl interpreter 
)
inlinestatic

Definition at line 211 of file ResultSetReductionInterpreter.cpp.

References bindStub(), CHECK, getCallInputs(), getExecutorId(), ret(), ret_, ReductionInterpreter::run(), setVar(), and Void.

Referenced by Call::run().

212  {
213  auto executor_id = interpreter->getExecutorId();
214  CHECK(!interpreter->ret_) << "Function has already returned";
215  const auto call = static_cast<const Call*>(instruction);
216  if (call->callee()) {
217  // Call one of the functions generated to implement reduction.
218  const auto inputs = getCallInputs(call, interpreter);
219  auto ret = ReductionInterpreter::run(executor_id, call->callee(), inputs);
220  if (call->type() != Type::Void) {
221  // Assign the returned value.
222  interpreter->setVar(call, ret);
223  }
224  } else {
225  // Call an internal runtime function.
226  const auto func_ptr = bindStub(executor_id, call);
227  const auto inputs = getCallInputs(call, interpreter);
229  func_ptr(&ret, &inputs);
230  if (call->type() != Type::Void) {
231  // Assign the returned value.
232  interpreter->setVar(call, ret);
233  }
234  }
235  return;
236  }
void setVar(const Value *var, ReductionInterpreter::EvalValue value)
static StubGenerator::Stub bindStub(const size_t executor_id, const Call *call)
static std::vector< ReductionInterpreter::EvalValue > getCallInputs(const Call *call, const ReductionInterpreterImpl *interpreter)
std::optional< ReductionInterpreter::EvalValue > ret() const
std::optional< ReductionInterpreter::EvalValue > ret_
#define CHECK(condition)
Definition: Logger.h:291
static EvalValue run(const size_t execution_id, const Function *function, const std::vector< EvalValue > &inputs)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void ReductionInterpreterImpl::runCast ( const Instruction instruction,
ReductionInterpreterImpl interpreter 
)
inlinestatic

Definition at line 173 of file ResultSetReductionInterpreter.cpp.

References Cast::BitCast, CHECK, logger::FATAL, is_integer_type(), is_pointer_type(), LOG, ReductionInterpreter::MakeEvalValue(), ret_, setVar(), Cast::SExt, Cast::Trunc, and vars_.

Referenced by Cast::run().

174  {
175  CHECK(!interpreter->ret_) << "Function has already returned";
176  const auto cast = static_cast<const Cast*>(instruction);
177  const auto source = interpreter->vars_[cast->source()->id()];
178  // Given that evaluated values store all values as int64_t or void*, Trunc and SExt
179  // are no-op. The information about the type is already part of the destination.
180  switch (cast->op()) {
181  case Cast::CastOp::Trunc:
182  case Cast::CastOp::SExt: {
183  CHECK(is_integer_type(cast->source()->type()));
184  interpreter->setVar(cast, ReductionInterpreter::MakeEvalValue(source.int_val));
185  break;
186  }
187  case Cast::CastOp::BitCast: {
188  CHECK(is_pointer_type(cast->source()->type()));
189  interpreter->setVar(cast, ReductionInterpreter::MakeEvalValue(source.ptr));
190  break;
191  }
192  default: {
193  LOG(FATAL) << "Cast operator not supported: " << static_cast<int>(cast->op());
194  }
195  }
196  }
void setVar(const Value *var, ReductionInterpreter::EvalValue value)
#define LOG(tag)
Definition: Logger.h:285
std::vector< ReductionInterpreter::EvalValue > vars_
static EvalValue MakeEvalValue(const T &val)
std::optional< ReductionInterpreter::EvalValue > ret_
#define CHECK(condition)
Definition: Logger.h:291
bool is_pointer_type(const Type type)
bool is_integer_type(const Type type)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void ReductionInterpreterImpl::runExternalCall ( const Instruction instruction,
ReductionInterpreterImpl interpreter 
)
inlinestatic

Definition at line 238 of file ResultSetReductionInterpreter.cpp.

References ExternalCall::arguments(), bindStub(), CHECK, anonymous_namespace{ResultSetReductionInterpreter.cpp}::get_value_types(), getCallInputs(), getExecutorId(), ret_, and setVar().

Referenced by ExternalCall::run().

239  {
240  auto executor_id = interpreter->getExecutorId();
241  CHECK(!interpreter->ret_) << "Function has already returned";
242  const auto external_call = static_cast<const ExternalCall*>(instruction);
243  const auto& arguments = external_call->arguments();
244  const auto argument_types = get_value_types(arguments);
245  const auto func_ptr = bindStub(executor_id, external_call);
246  const auto inputs = getCallInputs(external_call, interpreter);
248  func_ptr(&output, &inputs);
249  interpreter->setVar(external_call, output);
250  }
void setVar(const Value *var, ReductionInterpreter::EvalValue value)
static StubGenerator::Stub bindStub(const size_t executor_id, const Call *call)
static std::vector< ReductionInterpreter::EvalValue > getCallInputs(const Call *call, const ReductionInterpreterImpl *interpreter)
const std::vector< const Value * > & arguments() const
std::vector< Type > get_value_types(const std::vector< const Value * > &values)
std::optional< ReductionInterpreter::EvalValue > ret_
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void ReductionInterpreterImpl::runFor ( const Instruction instruction,
ReductionInterpreterImpl interpreter 
)
inlinestatic

Definition at line 293 of file ResultSetReductionInterpreter.cpp.

References alloca_buffers_, CHECK, getExecutorId(), is_integer_type(), ret(), ret_, ReductionInterpreter::run(), and vars_.

Referenced by For::run().

294  {
295  auto executor_id = interpreter->getExecutorId();
296  CHECK(!interpreter->ret_) << "Function has already returned";
297  const size_t saved_alloca_count = interpreter->alloca_buffers_.size();
298  const auto for_loop = static_cast<const For*>(instruction);
299  CHECK(is_integer_type(for_loop->start()->type()));
300  CHECK(is_integer_type(for_loop->end()->type()));
301  const auto start = interpreter->vars_[for_loop->start()->id()];
302  const auto end = interpreter->vars_[for_loop->end()->id()];
303  for (int64_t i = start.int_val; i < end.int_val; ++i) {
304  // The start and end indices are absolute, but the iteration happens from 0.
305  // Subtract the start index before setting the iterator.
306  interpreter->vars_[for_loop->iter()->id()].int_val = i - start.int_val;
307  auto ret =
308  ReductionInterpreter::run(executor_id, for_loop->body(), interpreter->vars_);
309  if (ret) {
310  interpreter->ret_ = *ret;
311  break;
312  }
313  }
314  // Pop all the alloca buffers allocated by the code in the loop.
315  interpreter->alloca_buffers_.resize(saved_alloca_count);
316  }
std::vector< ReductionInterpreter::EvalValue > vars_
std::optional< ReductionInterpreter::EvalValue > ret() const
std::optional< ReductionInterpreter::EvalValue > ret_
#define CHECK(condition)
Definition: Logger.h:291
std::vector< std::vector< int8_t > > alloca_buffers_
static EvalValue run(const size_t execution_id, const Function *function, const std::vector< EvalValue > &inputs)
bool is_integer_type(const Type type)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void ReductionInterpreterImpl::runGetElementPtr ( const Instruction instruction,
ReductionInterpreterImpl interpreter 
)
inlinestatic

Definition at line 66 of file ResultSetReductionInterpreter.cpp.

References CHECK, anonymous_namespace{ResultSetReductionInterpreter.cpp}::get_element_size(), ReductionInterpreter::MakeEvalValue(), ret_, setVar(), and vars_.

Referenced by GetElementPtr::run().

67  {
68  CHECK(!interpreter->ret_) << "Function has already returned";
69  const auto gep = static_cast<const GetElementPtr*>(instruction);
70  const auto element_size = get_element_size(gep->base()->type());
71  const auto base = interpreter->vars_[gep->base()->id()];
72  const auto index = interpreter->vars_[gep->index()->id()];
73  auto result_ptr =
74  reinterpret_cast<const int8_t*>(base.ptr) + index.int_val * element_size;
75  interpreter->setVar(gep, ReductionInterpreter::MakeEvalValue(result_ptr));
76  }
void setVar(const Value *var, ReductionInterpreter::EvalValue value)
std::vector< ReductionInterpreter::EvalValue > vars_
static EvalValue MakeEvalValue(const T &val)
std::optional< ReductionInterpreter::EvalValue > ret_
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void ReductionInterpreterImpl::runICmp ( const Instruction instruction,
ReductionInterpreterImpl interpreter 
)
inlinestatic

Definition at line 123 of file ResultSetReductionInterpreter.cpp.

References CHECK, ICmp::EQ, logger::FATAL, is_integer_type(), LOG, ReductionInterpreter::MakeEvalValue(), ICmp::NE, run_benchmark_import::result, ret_, setVar(), and vars_.

Referenced by ICmp::run().

124  {
125  CHECK(!interpreter->ret_) << "Function has already returned";
126  const auto icmp = static_cast<const ICmp*>(instruction);
127  CHECK(is_integer_type(icmp->lhs()->type()));
128  CHECK(is_integer_type(icmp->rhs()->type()));
129  const auto lhs = interpreter->vars_[icmp->lhs()->id()];
130  const auto rhs = interpreter->vars_[icmp->rhs()->id()];
131  bool result = false;
132  switch (icmp->predicate()) {
133  case ICmp::Predicate::EQ: {
134  result = lhs.int_val == rhs.int_val;
135  break;
136  }
137  case ICmp::Predicate::NE: {
138  result = lhs.int_val != rhs.int_val;
139  break;
140  }
141  default: {
142  LOG(FATAL) << "Predicate not supported: " << static_cast<int>(icmp->predicate());
143  }
144  }
145  interpreter->setVar(icmp, ReductionInterpreter::MakeEvalValue(result));
146  }
void setVar(const Value *var, ReductionInterpreter::EvalValue value)
#define LOG(tag)
Definition: Logger.h:285
std::vector< ReductionInterpreter::EvalValue > vars_
static EvalValue MakeEvalValue(const T &val)
std::optional< ReductionInterpreter::EvalValue > ret_
#define CHECK(condition)
Definition: Logger.h:291
bool is_integer_type(const Type type)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void ReductionInterpreterImpl::runLoad ( const Instruction instruction,
ReductionInterpreterImpl interpreter 
)
inlinestatic

Definition at line 78 of file ResultSetReductionInterpreter.cpp.

References CHECK, DoublePtr, logger::FATAL, FloatPtr, Int32Ptr, Int64Ptr, Int64PtrPtr, Int8Ptr, is_pointer_type(), boost::serialization::load(), LOG, ReductionInterpreter::MakeEvalValue(), ret_, setVar(), and vars_.

Referenced by Load::run().

79  {
80  CHECK(!interpreter->ret_) << "Function has already returned";
81  const auto load = static_cast<const Load*>(instruction);
82  const auto source_type = load->source()->type();
83  CHECK(is_pointer_type(source_type));
84  const auto source = interpreter->vars_[load->source()->id()];
85  switch (source_type) {
86  case Type::Int8Ptr: {
87  const auto int_val = *reinterpret_cast<const int8_t*>(source.ptr);
88  interpreter->setVar(load, ReductionInterpreter::MakeEvalValue(int_val));
89  break;
90  }
91  case Type::Int32Ptr: {
92  const auto int_val = *reinterpret_cast<const int32_t*>(source.ptr);
93  interpreter->setVar(load, ReductionInterpreter::MakeEvalValue(int_val));
94  break;
95  }
96  case Type::Int64Ptr: {
97  const auto int_val = *reinterpret_cast<const int64_t*>(source.ptr);
98  interpreter->setVar(load, ReductionInterpreter::MakeEvalValue(int_val));
99  break;
100  }
101  case Type::FloatPtr: {
102  const auto float_val = *reinterpret_cast<const float*>(source.ptr);
103  interpreter->setVar(load, ReductionInterpreter::MakeEvalValue(float_val));
104  break;
105  }
106  case Type::DoublePtr: {
107  const auto double_val = *reinterpret_cast<const double*>(source.ptr);
108  interpreter->setVar(load, ReductionInterpreter::MakeEvalValue(double_val));
109  break;
110  }
111  case Type::Int64PtrPtr: {
112  const auto int_ptr_val = *reinterpret_cast<const int64_t* const*>(source.ptr);
113  interpreter->setVar(load, ReductionInterpreter::MakeEvalValue(int_ptr_val));
114  break;
115  }
116  default: {
117  LOG(FATAL) << "Source pointer type not supported: "
118  << static_cast<int>(source_type);
119  }
120  }
121  }
void setVar(const Value *var, ReductionInterpreter::EvalValue value)
void load(Archive &ar, ExplainedQueryHint &query_hint, const unsigned int version)
#define LOG(tag)
Definition: Logger.h:285
std::vector< ReductionInterpreter::EvalValue > vars_
static EvalValue MakeEvalValue(const T &val)
std::optional< ReductionInterpreter::EvalValue > ret_
#define CHECK(condition)
Definition: Logger.h:291
bool is_pointer_type(const Type type)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void ReductionInterpreterImpl::runMemCpy ( const Instruction instruction,
ReductionInterpreterImpl interpreter 
)
inlinestatic

Definition at line 265 of file ResultSetReductionInterpreter.cpp.

References CHECK, run_benchmark_import::dest, is_integer_type(), is_pointer_type(), ret_, and vars_.

Referenced by MemCpy::run().

266  {
267  CHECK(!interpreter->ret_) << "Function has already returned";
268  const auto memcpy = static_cast<const MemCpy*>(instruction);
269  CHECK(is_pointer_type(memcpy->dest()->type()));
270  CHECK(is_pointer_type(memcpy->source()->type()));
271  CHECK(is_integer_type(memcpy->size()->type()));
272  const auto dest = interpreter->vars_[memcpy->dest()->id()];
273  const auto source = interpreter->vars_[memcpy->source()->id()];
274  const auto size = interpreter->vars_[memcpy->size()->id()];
275  ::memcpy(dest.mutable_ptr, source.ptr, size.int_val);
276  }
std::vector< ReductionInterpreter::EvalValue > vars_
std::optional< ReductionInterpreter::EvalValue > ret_
#define CHECK(condition)
Definition: Logger.h:291
bool is_pointer_type(const Type type)
bool is_integer_type(const Type type)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void ReductionInterpreterImpl::runRet ( const Instruction instruction,
ReductionInterpreterImpl interpreter 
)
inlinestatic

Definition at line 198 of file ResultSetReductionInterpreter.cpp.

References CHECK, ret(), ret_, vars_, and Void.

Referenced by Ret::run().

199  {
200  CHECK(!interpreter->ret_) << "Function has already returned";
201  const auto ret = static_cast<const Ret*>(instruction);
202  if (ret->type() == Type::Void) {
203  // Even if the returned type is void, the return value still needs to be set to
204  // something to inform the caller that it should stop evaluating.
205  interpreter->ret_ = ReductionInterpreter::EvalValue{};
206  } else {
207  interpreter->ret_ = interpreter->vars_[ret->value()->id()];
208  }
209  }
std::vector< ReductionInterpreter::EvalValue > vars_
std::optional< ReductionInterpreter::EvalValue > ret() const
std::optional< ReductionInterpreter::EvalValue > ret_
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void ReductionInterpreterImpl::runReturnEarly ( const Instruction instruction,
ReductionInterpreterImpl interpreter 
)
inlinestatic

Definition at line 278 of file ResultSetReductionInterpreter.cpp.

References CHECK, report::error_code(), Int1, ReductionInterpreter::MakeEvalValue(), ret_, and vars_.

Referenced by ReturnEarly::run().

279  {
280  CHECK(!interpreter->ret_) << "Function has already returned";
281  const auto ret_early = static_cast<const ReturnEarly*>(instruction);
282  CHECK(ret_early->cond()->type() == Type::Int1);
283  const auto cond = interpreter->vars_[ret_early->cond()->id()];
284 
285  auto error_code = ret_early->error_code();
286 
287  if (cond.int_val) {
288  auto rc = interpreter->vars_[error_code->id()].int_val;
289  interpreter->ret_ = ReductionInterpreter::MakeEvalValue(rc);
290  }
291  }
std::vector< ReductionInterpreter::EvalValue > vars_
static EvalValue MakeEvalValue(const T &val)
std::optional< ReductionInterpreter::EvalValue > ret_
def error_code
Definition: report.py:244
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ReductionInterpreterImpl::setVar ( const Value var,
ReductionInterpreter::EvalValue  value 
)
inlineprivate

Definition at line 320 of file ResultSetReductionInterpreter.cpp.

References Value::id(), and vars_.

Referenced by runAlloca(), runBinaryOperator(), runCall(), runCast(), runExternalCall(), runGetElementPtr(), runICmp(), and runLoad().

320  {
321  vars_[var->id()] = value;
322  }
size_t id() const
std::vector< ReductionInterpreter::EvalValue > vars_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

std::vector<std::vector<int8_t> > ReductionInterpreterImpl::alloca_buffers_
private

Definition at line 358 of file ResultSetReductionInterpreter.cpp.

Referenced by runAlloca(), and runFor().

size_t ReductionInterpreterImpl::executor_id_
private

Definition at line 354 of file ResultSetReductionInterpreter.cpp.

Referenced by getExecutorId().

std::optional<ReductionInterpreter::EvalValue> ReductionInterpreterImpl::ret_ = std::nullopt
private

The documentation for this class was generated from the following file: