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

Functions

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

33  {
34  using namespace llvm;
35 
36  std::vector<Type*> func_args;
37  FunctionType* func_type = FunctionType::get(
38  /*Result=*/IntegerType::get(mod->getContext(), 32),
39  /*Params=*/func_args,
40  /*isVarArg=*/false);
41 
42  auto func_ptr = mod->getFunction(name);
43  if (!func_ptr) {
44  func_ptr = Function::Create(
45  /*Type=*/func_type,
46  /*Linkage=*/GlobalValue::ExternalLinkage,
47  /*Name=*/name,
48  mod); // (external, no body)
49  func_ptr->setCallingConv(CallingConv::C);
50  }
51 
52  Attributes func_pal;
53  {
54  SmallVector<Attributes, 4> Attrs;
55  Attributes PAS;
56  {
57  AttrBuilder B;
58  PAS = Attributes::get(mod->getContext(), ~0U, B);
59  }
60 
61  Attrs.push_back(PAS);
62  func_pal = Attributes::get(mod->getContext(), Attrs);
63  }
64  func_ptr->setAttributes(func_pal);
65 
66  return func_ptr;
67 }
template<class Attributes >
llvm::Function* anonymous_namespace{QueryTemplateGenerator.cpp}::group_buff_idx ( llvm::Module *  mod)

Definition at line 75 of file QueryTemplateGenerator.cpp.

Referenced by query_group_by_template_impl(), and query_template_impl().

75  {
76  return default_func_builder<Attributes>(mod, "group_buff_idx");
77 }

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

Referenced by query_group_by_template_impl(), and query_template_impl().

70  {
71  return default_func_builder<Attributes>(mod, "pos_start");
72 }

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

Referenced by query_group_by_template_impl(), and query_template_impl().

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

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

Referenced by query_group_by_template_impl(), and query_template_impl().

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

+ Here is the caller graph for this function: