OmniSciDB  471d68cefb
 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  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.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->getElementType();
39 }
Type pointer_type(const Type pointee)
#define CHECK(condition)
Definition: Logger.h:209

+ 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.

References i.

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(pi64_type); // varlen output buffer
145  func_args.push_back(pi32_type); // 1 iff current row matched, else 0
146  func_args.push_back(pi32_type); // total rows matched from the caller
147  func_args.push_back(pi32_type); // total rows matched before atomic increment
148  func_args.push_back(pi32_type); // max number of slots in the output buffer
149  }
150 
151  func_args.push_back(pi64_type); // aggregate init values
152 
153  func_args.push_back(i64_type);
154  func_args.push_back(pi64_type);
155  func_args.push_back(pi64_type);
156  if (hoist_literals) {
157  func_args.push_back(PointerType::get(i8_type, 0));
158  }
159  FunctionType* func_type = FunctionType::get(
160  /*Result=*/i32_type,
161  /*Params=*/func_args,
162  /*isVarArg=*/false);
163 
164  std::string func_name{"row_process"};
165  auto func_ptr = mod->getFunction(func_name);
166 
167  if (!func_ptr) {
168  func_ptr = Function::Create(
169  /*Type=*/func_type,
170  /*Linkage=*/GlobalValue::ExternalLinkage,
171  /*Name=*/func_name,
172  mod); // (external, no body)
173  func_ptr->setCallingConv(CallingConv::C);
174 
175  Attributes func_pal;
176  {
177  SmallVector<Attributes, 4> Attrs;
178  Attributes PAS;
179  {
180  AttrBuilder B;
181  PAS = Attributes::get(mod->getContext(), ~0U, B);
182  }
183 
184  Attrs.push_back(PAS);
185  func_pal = Attributes::get(mod->getContext(), Attrs);
186  }
187  func_ptr->setAttributes(func_pal);
188  }
189 
190  return func_ptr;
191 }

+ Here is the caller graph for this function: