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

Functions

llvm::Function * findCalledFunction (llvm::CallInst &call_inst)
 
std::optional< std::string_view > getCalledFunctionName (llvm::CallInst &call_inst)
 
std::vector< llvm::Value * > createPtrWithHoistedMemoryAddr (CgenState *cgen_state, CodeGenerator *code_generator, CompilationOptions const &co, llvm::ConstantInt *ptr_int_val, llvm::Type *type, size_t num_devices_to_hoist_literal)
 

Function Documentation

std::vector< llvm::Value * > CodegenUtil::createPtrWithHoistedMemoryAddr ( CgenState cgen_state,
CodeGenerator code_generator,
CompilationOptions const &  co,
llvm::ConstantInt *  ptr_int_val,
llvm::Type type,
size_t  num_devices_to_hoist_literal 
)

Definition at line 49 of file CodegenHelper.cpp.

References Datum::bigintval, CodeGenerator::codegenHoistedConstants(), CompilationOptions::hoist_literals, CgenState::ir_builder_, kBIGINT, and kENCODING_NONE.

Referenced by Executor::aggregateWindowStatePtr(), Executor::codegenAggregateWindowState(), Executor::codegenCurrentPartitionIndex(), CodeGenerator::codegenFixedLengthColVarInWindow(), Executor::codegenFrameNullRange(), Executor::codegenLoadOrderKeyBufPtr(), Executor::codegenLoadPartitionBuffers(), Executor::codegenWindowAvgEpilogue(), Executor::codegenWindowFunctionAggregate(), Executor::codegenWindowFunctionAggregateCalls(), Executor::codegenWindowNavigationFunctionOnFrame(), and Executor::codegenWindowResetStateControlFlow().

55  {
56  if (!co.hoist_literals) {
57  return {cgen_state->ir_builder_.CreateIntToPtr(ptr_int_val, type)};
58  }
59  Datum d;
60  d.bigintval = ptr_int_val->getSExtValue();
61  auto ptr = makeExpr<Analyzer::Constant>(kBIGINT, false, d);
62  std::vector<Analyzer::Constant const*> literals(num_devices_to_hoist_literal,
63  ptr.get());
64  auto hoisted_literal_lvs =
65  code_generator->codegenHoistedConstants(literals, kENCODING_NONE, {});
66  std::vector<llvm::Value*> hoisted_ptrs;
67  hoisted_ptrs.reserve(num_devices_to_hoist_literal);
68  for (size_t device_id = 0; device_id < num_devices_to_hoist_literal; device_id++) {
69  hoisted_ptrs[device_id] =
70  cgen_state->ir_builder_.CreateIntToPtr(hoisted_literal_lvs[device_id], type);
71  }
72  return hoisted_ptrs;
73 }
llvm::IRBuilder ir_builder_
Definition: CgenState.h:384
std::vector< llvm::Value * > codegenHoistedConstants(const std::vector< const Analyzer::Constant * > &constants, const EncodingType enc_type, const shared::StringDictKey &dict_id)
Definition: ConstantIR.cpp:373
int64_t bigintval
Definition: Datum.h:74
Definition: Datum.h:69

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

llvm::Function * CodegenUtil::findCalledFunction ( llvm::CallInst &  call_inst)

Definition at line 21 of file CodegenHelper.cpp.

Referenced by getCalledFunctionName(), and CgenState::replaceFunctionForGpu().

21  {
22  if (llvm::Function* cf = call_inst.getCalledFunction()) {
23  return cf;
24  } else if (llvm::Value* cv = call_inst.getCalledOperand()) {
25  if (llvm::Function* cvf = llvm::dyn_cast<llvm::Function>(cv->stripPointerCasts())) {
26  // this happens when bitcast function is called first before calling the actual
27  // function i.e., %17 = call i64 bitcast (i64 (i8*)* @actual_func to i64 (i32*)*)
28  return cvf;
29  }
30  }
31  return nullptr;
32 }

+ Here is the caller graph for this function:

std::optional< std::string_view > CodegenUtil::getCalledFunctionName ( llvm::CallInst &  call_inst)

Definition at line 34 of file CodegenHelper.cpp.

References findCalledFunction().

Referenced by GpuSharedMemCodeBuilder::codegenReduction(), CgenState::gpuFunctionsToReplace(), and anonymous_namespace{GpuSharedMemoryUtils.cpp}::replace_called_function_with().

34  {
35  if (llvm::Function* cf = findCalledFunction(call_inst)) {
36  return std::make_optional<std::string_view>(cf->getName().data(),
37  cf->getName().size());
38  }
39  return std::nullopt;
40 }
llvm::Function * findCalledFunction(llvm::CallInst &call_inst)

+ Here is the call graph for this function:

+ Here is the caller graph for this function: