OmniSciDB  b24e664e58
 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 31 of file QueryTemplateGenerator.cpp.

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

Definition at line 73 of file QueryTemplateGenerator.cpp.

Referenced by query_group_by_template_impl(), and query_template_impl().

73  {
74  return default_func_builder<Attributes>(mod, "group_buff_idx");
75 }

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

Referenced by query_group_by_template_impl(), and query_template_impl().

68  {
69  return default_func_builder<Attributes>(mod, "pos_start");
70 }

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

Referenced by query_group_by_template_impl(), and query_template_impl().

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

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

Referenced by query_group_by_template_impl(), and query_template_impl().

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

+ Here is the caller graph for this function: