OmniSciDB  1dac507f6e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IRCodegenUtils.h File Reference
#include <llvm/IR/Constants.h>
#include <llvm/IR/LLVMContext.h>
#include <llvm/IR/Type.h>
#include "Shared/Logger.h"
+ Include dependency graph for IRCodegenUtils.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

llvm::ArrayType * get_int_array_type (int const width, int count, llvm::LLVMContext &context)
 
llvm::VectorType * get_int_vector_type (int const width, int count, llvm::LLVMContext &context)
 
llvm::Typeget_int_type (const int width, llvm::LLVMContext &context)
 
llvm::Typeget_fp_type (const int width, llvm::LLVMContext &context)
 
template<class T >
llvm::ConstantInt * ll_int (const T v, llvm::LLVMContext &context)
 
llvm::ConstantInt * ll_bool (const bool v, llvm::LLVMContext &context)
 
llvm::Module * read_template_module (llvm::LLVMContext &context)
 
template<class T >
std::string serialize_llvm_object (const T *llvm_obj)
 
void verify_function_ir (const llvm::Function *func)
 

Function Documentation

llvm::Type* get_fp_type ( const int  width,
llvm::LLVMContext &  context 
)
inline

Definition at line 95 of file IRCodegenUtils.h.

References logger::FATAL, LOG, and UNREACHABLE.

Referenced by CodeGenerator::endArgsNullcheck(), TableFunctionCompilationContext::generateEntryPoint(), and llvm_type().

95  {
96  switch (width) {
97  case 64:
98  return llvm::Type::getDoubleTy(context);
99  case 32:
100  return llvm::Type::getFloatTy(context);
101  default:
102  LOG(FATAL) << "Unsupported floating point width: " << width;
103  }
104  UNREACHABLE();
105  return nullptr;
106 }
#define LOG(tag)
Definition: Logger.h:185
#define UNREACHABLE()
Definition: Logger.h:234

+ Here is the caller graph for this function:

llvm::ArrayType* get_int_array_type ( int const  width,
int  count,
llvm::LLVMContext &  context 
)
inline

Definition at line 24 of file IRCodegenUtils.h.

References logger::FATAL, and LOG.

Referenced by CodeGenerator::codegenArrayExpr(), and CodeGenerator::codegenCast().

26  {
27  switch (width) {
28  case 64:
29  return llvm::ArrayType::get(llvm::Type::getInt64Ty(context), count);
30  case 32:
31  return llvm::ArrayType::get(llvm::Type::getInt32Ty(context), count);
32  break;
33  case 16:
34  return llvm::ArrayType::get(llvm::Type::getInt16Ty(context), count);
35  break;
36  case 8:
37  return llvm::ArrayType::get(llvm::Type::getInt8Ty(context), count);
38  break;
39  case 1:
40  return llvm::ArrayType::get(llvm::Type::getInt1Ty(context), count);
41  break;
42  default:
43  LOG(FATAL) << "Unsupported integer width: " << width;
44  }
45  return nullptr;
46 }
#define LOG(tag)
Definition: Logger.h:185

+ Here is the caller graph for this function:

llvm::Type* get_int_type ( const int  width,
llvm::LLVMContext &  context 
)
inline

Definition at line 72 of file IRCodegenUtils.h.

References logger::FATAL, LOG, and UNREACHABLE.

Referenced by CgenState::addStringConstant(), Executor::aggregateWindowStatePtr(), Executor::castToIntPtrTyIn(), CgenState::castToTypeIn(), TargetExprCodegen::codegen(), JoinLoop::codegen(), GroupByAndAggregate::codegen(), CodeGenerator::codegen(), GroupByAndAggregate::codegenAggArg(), GroupByAndAggregate::codegenAggColumnPtr(), Executor::codegenAggregateWindowState(), CodeGenerator::codegenArrayAt(), CodeGenerator::codegenArrayExpr(), CodeGenerator::codegenCastBetweenIntTypes(), CodeGenerator::codegenCastBetweenIntTypesOverflowChecks(), CodeGenerator::codegenCastBetweenTimestamps(), CodeGenerator::codegenCastFromFp(), CodeGenerator::codegenCastFromString(), CodeGenerator::codegenCastTimestampToDate(), GroupByAndAggregate::codegenCountDistinct(), CodeGenerator::codegenDiv(), GroupByAndAggregate::codegenEstimator(), CodeGenerator::codegenFixedLengthColVar(), CodeGenerator::codegenFunctionOperCastArgs(), CodeGenerator::codegenFunctionOperWithCustomTypeHandling(), CodeGenerator::codegenHoistedConstantsLoads(), CodeGenerator::codegenIsNull(), OverlapsJoinHashTable::codegenKey(), BaselineJoinHashTable::codegenKey(), BaselineJoinHashTable::codegenMatchingSet(), GroupByAndAggregate::codegenMultiColumnPerfectHash(), GroupByAndAggregate::codegenPerfectHashFunction(), CodeGenerator::codegenQualifierCmp(), BaselineJoinHashTable::codegenSlot(), TargetExprCodegenBuilder::codegenSlotEmptyKey(), CodeGenerator::codegenVariableLengthStringColVar(), Executor::codegenWindowAvgEpilogue(), Executor::codegenWindowFunctionAggregate(), Executor::codegenWindowFunctionStateInit(), GroupByAndAggregate::codegenWindowRowPointer(), CodeGenerator::codgenAdjustFixedEncNull(), ScalarCodeGenerator::compile(), anonymous_namespace{ResultSetReductionInterpreterStubs.cpp}::create_stub_function(), CodeGenerator::endArgsNullcheck(), JoinLoop::evaluateOuterJoinCondition(), anonymous_namespace{ExtensionsIR.cpp}::ext_arg_type_to_llvm_type(), anonymous_namespace{TableFunctionCompilationContext.cpp}::generate_entry_point(), TableFunctionCompilationContext::generateEntryPoint(), TableFunctionCompilationContext::generateGpuKernel(), StubGenerator::generateStub(), GroupByAndAggregate::getAdditionalLiteral(), Executor::groupByColumnCodegen(), ll_bool(), ll_int(), llvm_type(), anonymous_namespace{ScalarCodeGenerator.cpp}::llvm_type_from_sql(), CodeGenerator::posArg(), and anonymous_namespace{ResultSetReductionCodegen.cpp}::translate_for().

72  {
73  switch (width) {
74  case 64:
75  return llvm::Type::getInt64Ty(context);
76  case 32:
77  return llvm::Type::getInt32Ty(context);
78  break;
79  case 16:
80  return llvm::Type::getInt16Ty(context);
81  break;
82  case 8:
83  return llvm::Type::getInt8Ty(context);
84  break;
85  case 1:
86  return llvm::Type::getInt1Ty(context);
87  break;
88  default:
89  LOG(FATAL) << "Unsupported integer width: " << width;
90  }
91  UNREACHABLE();
92  return nullptr;
93 }
#define LOG(tag)
Definition: Logger.h:185
#define UNREACHABLE()
Definition: Logger.h:234
llvm::VectorType* get_int_vector_type ( int const  width,
int  count,
llvm::LLVMContext &  context 
)
inline

Definition at line 48 of file IRCodegenUtils.h.

References logger::FATAL, and LOG.

50  {
51  switch (width) {
52  case 64:
53  return llvm::VectorType::get(llvm::Type::getInt64Ty(context), count);
54  case 32:
55  return llvm::VectorType::get(llvm::Type::getInt32Ty(context), count);
56  break;
57  case 16:
58  return llvm::VectorType::get(llvm::Type::getInt16Ty(context), count);
59  break;
60  case 8:
61  return llvm::VectorType::get(llvm::Type::getInt8Ty(context), count);
62  break;
63  case 1:
64  return llvm::VectorType::get(llvm::Type::getInt1Ty(context), count);
65  break;
66  default:
67  LOG(FATAL) << "Unsupported integer width: " << width;
68  }
69  return nullptr;
70 }
#define LOG(tag)
Definition: Logger.h:185
llvm::ConstantInt* ll_bool ( const bool  v,
llvm::LLVMContext &  context 
)
inline

Definition at line 114 of file IRCodegenUtils.h.

References get_int_type().

Referenced by JoinLoop::codegen(), JoinLoop::evaluateOuterJoinCondition(), and CgenState::llBool().

114  {
115  return static_cast<llvm::ConstantInt*>(
116  llvm::ConstantInt::get(get_int_type(1, context), v));
117 }
llvm::Type * get_int_type(const int width, llvm::LLVMContext &context)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class T >
llvm::ConstantInt* ll_int ( const T  v,
llvm::LLVMContext &  context 
)
inline

Definition at line 109 of file IRCodegenUtils.h.

References get_int_type().

Referenced by JoinLoop::codegen(), anonymous_namespace{JoinLoopTest.cpp}::generate_descriptors(), CgenState::inlineIntMaxMin(), and CgenState::llInt().

109  {
110  return static_cast<llvm::ConstantInt*>(
111  llvm::ConstantInt::get(get_int_type(sizeof(v) * 8, context), v));
112 }
llvm::Type * get_int_type(const int width, llvm::LLVMContext &context)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

llvm::Module* read_template_module ( llvm::LLVMContext &  context)

Definition at line 926 of file NativeCodegen.cpp.

926  {
927  llvm::SMDiagnostic err;
928 
929  auto buffer_or_error = llvm::MemoryBuffer::getFile(mapd_root_abs_path() +
930  "/QueryEngine/RuntimeFunctions.bc");
931  CHECK(!buffer_or_error.getError());
932  llvm::MemoryBuffer* buffer = buffer_or_error.get().get();
933 
934  auto owner = llvm::parseBitcodeFile(buffer->getMemBufferRef(), context);
935  CHECK(!owner.takeError());
936  auto module = owner.get().release();
937  CHECK(module);
938 
939  return module;
940 }
std::unique_ptr< llvm::Module > module(runtime_module_shallow_copy(cgen_state))
std::string mapd_root_abs_path()
Definition: mapdpath.h:30
CHECK(cgen_state)
template<class T >
std::string serialize_llvm_object ( const T *  llvm_obj)

Definition at line 129 of file NativeCodegen.cpp.

Referenced by TableFunctionCompilationContext::finalize(), and Executor::optimizeAndCodegenCPU().

129  {
130  std::stringstream ss;
131  llvm::raw_os_ostream os(ss);
132  llvm_obj->print(os);
133  os.flush();
134  return ss.str();
135 }

+ Here is the caller graph for this function:

void verify_function_ir ( const llvm::Function *  func)

Definition at line 44 of file JoinLoopTest.cpp.

References logger::FATAL, and LOG.

Referenced by anonymous_namespace{JoinLoopTest.cpp}::create_loop_test_function(), TableFunctionCompilationContext::generateEntryPoint(), StubGenerator::generateStub(), and translate_function().

44  {
45  std::stringstream err_ss;
46  llvm::raw_os_ostream err_os(err_ss);
47  if (llvm::verifyFunction(*func, &err_os)) {
48  func->print(llvm::outs());
49  LOG(FATAL) << err_ss.str();
50  }
51 }
#define LOG(tag)
Definition: Logger.h:185

+ Here is the caller graph for this function: