OmniSciDB  c1a53651b2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
anonymous_namespace{QueryTemplateGenerator.cpp} Namespace Reference

Functions

llvm::Typeget_pointer_element_type (llvm::Value *value)
 
template<class Attributes >
llvm::Function * default_func_builder (llvm::Module *mod, const std::string &name)
 
template<class Attributes >
llvm::Function * pos_start (llvm::Module *mod)
 
template<class Attributes >
llvm::Function * group_buff_idx (llvm::Module *mod)
 
template<class Attributes >
llvm::Function * pos_step (llvm::Module *mod)
 
template<class Attributes >
llvm::Function * row_process (llvm::Module *mod, const size_t aggr_col_count, const bool hoist_literals)
 

Function Documentation

template<class Attributes >
llvm::Function* anonymous_namespace{QueryTemplateGenerator.cpp}::default_func_builder ( llvm::Module *  mod,
const std::string &  name 
)

Definition at line 42 of file QueryTemplateGenerator.cpp.

42  {
43  using namespace llvm;
44 
45  std::vector<Type*> func_args;
46  FunctionType* func_type = FunctionType::get(
47  /*Result=*/IntegerType::get(mod->getContext(), 32),
48  /*Params=*/func_args,
49  /*isVarArg=*/false);
50 
51  auto func_ptr = mod->getFunction(name);
52  if (!func_ptr) {
53  func_ptr = Function::Create(
54  /*Type=*/func_type,
55  /*Linkage=*/GlobalValue::ExternalLinkage,
56  /*Name=*/name,
57  mod); // (external, no body)
58  func_ptr->setCallingConv(CallingConv::C);
59  }
60 
61  Attributes func_pal;
62  {
63  SmallVector<Attributes, 4> Attrs;
64  Attributes PAS;
65  {
66 #if 14 <= LLVM_VERSION_MAJOR
67  AttrBuilder B(mod->getContext());
68 #else
69  AttrBuilder B;
70 #endif
71  PAS = Attributes::get(mod->getContext(), ~0U, B);
72  }
73 
74  Attrs.push_back(PAS);
75  func_pal = Attributes::get(mod->getContext(), Attrs);
76  }
77  func_ptr->setAttributes(func_pal);
78 
79  return func_ptr;
80 }
string name
Definition: setup.in.py:72
llvm::Type* anonymous_namespace{QueryTemplateGenerator.cpp}::get_pointer_element_type ( llvm::Value *  value)
inline

Definition at line 32 of file QueryTemplateGenerator.cpp.

References CHECK, pointer_type(), and run_benchmark_import::type.

Referenced by query_group_by_template_impl(), and query_template_impl().

32  {
33  CHECK(value);
34  auto type = value->getType();
35  CHECK(type && type->isPointerTy());
36  auto pointer_type = llvm::dyn_cast<llvm::PointerType>(type);
37  CHECK(pointer_type);
38  return pointer_type->getPointerElementType();
39 }
Type pointer_type(const Type pointee)
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class Attributes >
llvm::Function* anonymous_namespace{QueryTemplateGenerator.cpp}::group_buff_idx ( llvm::Module *  mod)

Definition at line 88 of file QueryTemplateGenerator.cpp.

Referenced by query_group_by_template_impl(), and query_template_impl().

88  {
89  return default_func_builder<Attributes>(mod, "group_buff_idx");
90 }

+ Here is the caller graph for this function:

template<class Attributes >
llvm::Function* anonymous_namespace{QueryTemplateGenerator.cpp}::pos_start ( llvm::Module *  mod)

Definition at line 83 of file QueryTemplateGenerator.cpp.

Referenced by query_group_by_template_impl(), and query_template_impl().

83  {
84  return default_func_builder<Attributes>(mod, "pos_start");
85 }

+ Here is the caller graph for this function:

template<class Attributes >
llvm::Function* anonymous_namespace{QueryTemplateGenerator.cpp}::pos_step ( llvm::Module *  mod)

Definition at line 93 of file QueryTemplateGenerator.cpp.

Referenced by query_group_by_template_impl(), and query_template_impl().

93  {
94  using namespace llvm;
95 
96  std::vector<Type*> func_args;
97  FunctionType* func_type = FunctionType::get(
98  /*Result=*/IntegerType::get(mod->getContext(), 32),
99  /*Params=*/func_args,
100  /*isVarArg=*/false);
101 
102  auto func_ptr = mod->getFunction("pos_step");
103  if (!func_ptr) {
104  func_ptr = Function::Create(
105  /*Type=*/func_type,
106  /*Linkage=*/GlobalValue::ExternalLinkage,
107  /*Name=*/"pos_step",
108  mod); // (external, no body)
109  func_ptr->setCallingConv(CallingConv::C);
110  }
111 
112  Attributes func_pal;
113  {
114  SmallVector<Attributes, 4> Attrs;
115  Attributes PAS;
116  {
117 #if 14 <= LLVM_VERSION_MAJOR
118  AttrBuilder B(mod->getContext());
119 #else
120  AttrBuilder B;
121 #endif
122  PAS = Attributes::get(mod->getContext(), ~0U, B);
123  }
124 
125  Attrs.push_back(PAS);
126  func_pal = Attributes::get(mod->getContext(), Attrs);
127  }
128  func_ptr->setAttributes(func_pal);
129 
130  return func_ptr;
131 }

+ Here is the caller graph for this function:

template<class Attributes >
llvm::Function* anonymous_namespace{QueryTemplateGenerator.cpp}::row_process ( llvm::Module *  mod,
const size_t  aggr_col_count,
const bool  hoist_literals 
)

Definition at line 134 of file QueryTemplateGenerator.cpp.

Referenced by query_group_by_template_impl(), and query_template_impl().

136  {
137  using namespace llvm;
138 
139  std::vector<Type*> func_args;
140  auto i8_type = IntegerType::get(mod->getContext(), 8);
141  auto i32_type = IntegerType::get(mod->getContext(), 32);
142  auto i64_type = IntegerType::get(mod->getContext(), 64);
143  auto pi32_type = PointerType::get(i32_type, 0);
144  auto pi64_type = PointerType::get(i64_type, 0);
145 
146  if (aggr_col_count) {
147  for (size_t i = 0; i < aggr_col_count; ++i) {
148  func_args.push_back(pi64_type);
149  }
150  } else { // group by query
151  func_args.push_back(pi64_type); // groups buffer
152  func_args.push_back(pi64_type); // varlen output buffer
153  func_args.push_back(pi32_type); // 1 iff current row matched, else 0
154  func_args.push_back(pi32_type); // total rows matched from the caller
155  func_args.push_back(pi32_type); // total rows matched before atomic increment
156  func_args.push_back(pi32_type); // max number of slots in the output buffer
157  }
158 
159  func_args.push_back(pi64_type); // aggregate init values
160 
161  func_args.push_back(i64_type); // pos
162  func_args.push_back(pi64_type); // frag_row_off_ptr
163  func_args.push_back(pi64_type); // row_count_ptr
164  if (hoist_literals) {
165  func_args.push_back(PointerType::get(i8_type, 0)); // literals
166  }
167  FunctionType* func_type = FunctionType::get(
168  /*Result=*/i32_type,
169  /*Params=*/func_args,
170  /*isVarArg=*/false);
171 
172  std::string func_name{"row_process"};
173  auto func_ptr = mod->getFunction(func_name);
174 
175  if (!func_ptr) {
176  func_ptr = Function::Create(
177  /*Type=*/func_type,
178  /*Linkage=*/GlobalValue::ExternalLinkage,
179  /*Name=*/func_name,
180  mod); // (external, no body)
181  func_ptr->setCallingConv(CallingConv::C);
182 
183  Attributes func_pal;
184  {
185  SmallVector<Attributes, 4> Attrs;
186  Attributes PAS;
187  {
188 #if 14 <= LLVM_VERSION_MAJOR
189  AttrBuilder B(mod->getContext());
190 #else
191  AttrBuilder B;
192 #endif
193  PAS = Attributes::get(mod->getContext(), ~0U, B);
194  }
195 
196  Attrs.push_back(PAS);
197  func_pal = Attributes::get(mod->getContext(), Attrs);
198  }
199  func_ptr->setAttributes(func_pal);
200  }
201 
202  return func_ptr;
203 }

+ Here is the caller graph for this function: