OmniSciDB  21ac014ffc
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IRCodegenUtils.h File Reference
#include <llvm/IR/Constants.h>
#include <llvm/IR/LLVMContext.h>
#include <llvm/IR/Module.h>
#include <llvm/IR/Type.h>
#include <llvm/Support/raw_os_ostream.h>
#include "Logger/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.

Macros

#define LLVM_ALIGN(alignment)   alignment
 
#define LLVM_MAYBE_ALIGN(alignment)   alignment
 

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)
 
llvm::Typeget_fp_ptr_type (const int width, llvm::LLVMContext &context)
 
llvm::Typeget_int_ptr_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)
 

Macro Definition Documentation

#define LLVM_ALIGN (   alignment)    alignment

Definition at line 31 of file IRCodegenUtils.h.

Referenced by query_group_by_template_impl(), and query_template_impl().

#define LLVM_MAYBE_ALIGN (   alignment)    alignment

Function Documentation

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

Definition at line 119 of file IRCodegenUtils.h.

References UNREACHABLE.

Referenced by anonymous_namespace{TableFunctionCompilationContext.cpp}::get_llvm_type_from_sql_column_type().

119  {
120  switch (width) {
121  case 64:
122  return llvm::Type::getDoublePtrTy(context);
123  case 32:
124  return llvm::Type::getFloatPtrTy(context);
125  }
126  UNREACHABLE();
127  return nullptr;
128 }
#define UNREACHABLE()
Definition: Logger.h:250

+ Here is the caller graph for this function:

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

Definition at line 106 of file IRCodegenUtils.h.

References logger::FATAL, LOG, and UNREACHABLE.

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

106  {
107  switch (width) {
108  case 64:
109  return llvm::Type::getDoubleTy(context);
110  case 32:
111  return llvm::Type::getFloatTy(context);
112  default:
113  LOG(FATAL) << "Unsupported floating point width: " << width;
114  }
115  UNREACHABLE();
116  return nullptr;
117 }
#define LOG(tag)
Definition: Logger.h:200
#define UNREACHABLE()
Definition: Logger.h:250

+ 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 35 of file IRCodegenUtils.h.

References logger::FATAL, and LOG.

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

37  {
38  switch (width) {
39  case 64:
40  return llvm::ArrayType::get(llvm::Type::getInt64Ty(context), count);
41  case 32:
42  return llvm::ArrayType::get(llvm::Type::getInt32Ty(context), count);
43  break;
44  case 16:
45  return llvm::ArrayType::get(llvm::Type::getInt16Ty(context), count);
46  break;
47  case 8:
48  return llvm::ArrayType::get(llvm::Type::getInt8Ty(context), count);
49  break;
50  case 1:
51  return llvm::ArrayType::get(llvm::Type::getInt1Ty(context), count);
52  break;
53  default:
54  LOG(FATAL) << "Unsupported integer width: " << width;
55  }
56  return nullptr;
57 }
#define LOG(tag)
Definition: Logger.h:200
int count

+ Here is the caller graph for this function:

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

Definition at line 130 of file IRCodegenUtils.h.

References UNREACHABLE.

Referenced by anonymous_namespace{TableFunctionCompilationContext.cpp}::get_llvm_type_from_sql_column_type().

130  {
131  switch (width) {
132  case 64:
133  return llvm::Type::getInt64PtrTy(context);
134  case 32:
135  return llvm::Type::getInt32PtrTy(context);
136  case 16:
137  return llvm::Type::getInt16PtrTy(context);
138  case 8:
139  return llvm::Type::getInt8PtrTy(context);
140  case 1:
141  return llvm::Type::getInt1PtrTy(context);
142  }
143  UNREACHABLE();
144  return nullptr;
145 }
#define UNREACHABLE()
Definition: Logger.h:250

+ Here is the caller graph for this function:

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

Definition at line 83 of file IRCodegenUtils.h.

References logger::FATAL, LOG, and UNREACHABLE.

Referenced by CgenState::addStringConstant(), Executor::aggregateWindowStatePtr(), Executor::castToIntPtrTyIn(), CgenState::castToTypeIn(), TargetExprCodegen::codegen(), GroupByAndAggregate::codegen(), JoinLoop::codegen(), CodeGenerator::codegen(), GroupByAndAggregate::codegenAggArg(), GroupByAndAggregate::codegenAggColumnPtr(), TargetExprCodegen::codegenAggregate(), Executor::codegenAggregateWindowState(), CodeGenerator::codegenArrayAt(), CodeGenerator::codegenArrayExpr(), CodeGenerator::codegenCastBetweenIntTypes(), CodeGenerator::codegenCastBetweenIntTypesOverflowChecks(), CodeGenerator::codegenCastFromFp(), CodeGenerator::codegenCastFromString(), CodeGenerator::codegenCastTimestampToDate(), GroupByAndAggregate::codegenCountDistinct(), CodeGenerator::codegenDateTruncHighPrecisionTimestamps(), CodeGenerator::codegenDiv(), GroupByAndAggregate::codegenEstimator(), CodeGenerator::codegenFixedLengthColVar(), CodeGenerator::codegenFunctionOperCastArgs(), CodeGenerator::codegenFunctionOperNullArg(), CodeGenerator::codegenFunctionOperWithCustomTypeHandling(), CodeGenerator::codegenGeoArgs(), CodeGenerator::codegenGeoFunctionOperator(), CodeGenerator::codegenGeosConstructorCall(), CodeGenerator::codegenGeosPredicateCall(), CodeGenerator::codegenHoistedConstantsLoads(), CodeGenerator::codegenIsNull(), BaselineJoinHashTable::codegenKey(), spatial_type::StartEndPoint::codegenLoads(), spatial_type::PointN::codegenLoads(), spatial_type::NPoints::codegenLoads(), spatial_type::NRings::codegenLoads(), BaselineJoinHashTable::codegenMatchingSet(), OverlapsJoinHashTable::codegenMatchingSet(), GroupByAndAggregate::codegenMultiColumnPerfectHash(), CodeGenerator::codegenOverlaps(), GroupByAndAggregate::codegenPerfectHashFunction(), CodeGenerator::codegenQualifierCmp(), GpuSharedMemCodeBuilder::codegenReduction(), 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(), 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(), Executor::redeclareFilterFunction(), and anonymous_namespace{ResultSetReductionCodegen.cpp}::translate_for().

83  {
84  switch (width) {
85  case 64:
86  return llvm::Type::getInt64Ty(context);
87  case 32:
88  return llvm::Type::getInt32Ty(context);
89  break;
90  case 16:
91  return llvm::Type::getInt16Ty(context);
92  break;
93  case 8:
94  return llvm::Type::getInt8Ty(context);
95  break;
96  case 1:
97  return llvm::Type::getInt1Ty(context);
98  break;
99  default:
100  LOG(FATAL) << "Unsupported integer width: " << width;
101  }
102  UNREACHABLE();
103  return nullptr;
104 }
#define LOG(tag)
Definition: Logger.h:200
#define UNREACHABLE()
Definition: Logger.h:250
llvm::VectorType* get_int_vector_type ( int const  width,
int  count,
llvm::LLVMContext &  context 
)
inline

Definition at line 59 of file IRCodegenUtils.h.

References logger::FATAL, and LOG.

61  {
62  switch (width) {
63  case 64:
64  return llvm::VectorType::get(llvm::Type::getInt64Ty(context), count, false);
65  case 32:
66  return llvm::VectorType::get(llvm::Type::getInt32Ty(context), count, false);
67  break;
68  case 16:
69  return llvm::VectorType::get(llvm::Type::getInt16Ty(context), count, false);
70  break;
71  case 8:
72  return llvm::VectorType::get(llvm::Type::getInt8Ty(context), count, false);
73  break;
74  case 1:
75  return llvm::VectorType::get(llvm::Type::getInt1Ty(context), count, false);
76  break;
77  default:
78  LOG(FATAL) << "Unsupported integer width: " << width;
79  }
80  return nullptr;
81 }
#define LOG(tag)
Definition: Logger.h:200
int count
llvm::ConstantInt* ll_bool ( const bool  v,
llvm::LLVMContext &  context 
)
inline

Definition at line 153 of file IRCodegenUtils.h.

References get_int_type().

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

153  {
154  return static_cast<llvm::ConstantInt*>(
155  llvm::ConstantInt::get(get_int_type(1, context), v));
156 }
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 v,
llvm::LLVMContext &  context 
)
inline

Definition at line 148 of file IRCodegenUtils.h.

References get_int_type().

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

148  {
149  return static_cast<llvm::ConstantInt*>(
150  llvm::ConstantInt::get(get_int_type(sizeof(v) * 8, context), v));
151 }
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 1384 of file NativeCodegen.cpp.

References run_benchmark_import::args, and i.

1384  {
1385  llvm::SMDiagnostic err;
1386 
1387  auto buffer_or_error = llvm::MemoryBuffer::getFile(omnisci::get_root_abs_path() +
1388  "/QueryEngine/RuntimeFunctions.bc");
1389  CHECK(!buffer_or_error.getError()) << "root path=" << omnisci::get_root_abs_path();
1390  llvm::MemoryBuffer* buffer = buffer_or_error.get().get();
1391 
1392  auto owner = llvm::parseBitcodeFile(buffer->getMemBufferRef(), context);
1393  CHECK(!owner.takeError());
1394  auto module = owner.get().release();
1395  CHECK(module);
1396 
1397  return module;
1398 }
#define CHECK(condition)
Definition: Logger.h:206
std::string get_root_abs_path()
template<class T >
std::string serialize_llvm_object ( const T *  llvm_obj)

Definition at line 161 of file IRCodegenUtils.h.

Referenced by TableFunctionCompilationContext::finalize(), ResultSetReductionJIT::finalizeReductionCode(), Executor::optimizeAndCodegenCPU(), and GpuSharedMemCodeBuilder::toString().

161  {
162  std::string str;
163  llvm::raw_string_ostream os(str);
164  os << *llvm_obj;
165  os.flush();
166  return str;
167 }

+ Here is the caller graph for this function:

void verify_function_ir ( const llvm::Function *  func)

Definition at line 46 of file JoinLoopTest.cpp.

References logger::FATAL, and LOG.

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

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

+ Here is the caller graph for this function: