OmniSciDB  bf83d84833
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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  AttrBuilder B;
67  PAS = Attributes::get(mod->getContext(), ~0U, B);
68  }
69 
70  Attrs.push_back(PAS);
71  func_pal = Attributes::get(mod->getContext(), Attrs);
72  }
73  func_ptr->setAttributes(func_pal);
74 
75  return func_ptr;
76 }
string name
Definition: setup.py:35
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->getElementType();
39 }
Type pointer_type(const Type pointee)
#define CHECK(condition)
Definition: Logger.h:197

+ 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 84 of file QueryTemplateGenerator.cpp.

Referenced by query_group_by_template_impl(), and query_template_impl().

84  {
85  return default_func_builder<Attributes>(mod, "group_buff_idx");
86 }

+ 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 79 of file QueryTemplateGenerator.cpp.

Referenced by query_group_by_template_impl(), and query_template_impl().

79  {
80  return default_func_builder<Attributes>(mod, "pos_start");
81 }

+ 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 89 of file QueryTemplateGenerator.cpp.

Referenced by query_group_by_template_impl(), and query_template_impl().

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

+ 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 126 of file QueryTemplateGenerator.cpp.

Referenced by query_group_by_template_impl(), and query_template_impl().

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

+ Here is the caller graph for this function: