MCPcopy Create free account
hub / github.com/apache/arrow / CodeGenExprValue

Method CodeGenExprValue

cpp/src/gandiva/llvm_generator.cc:277–449  ·  view source on GitHub ↗

Sample IR code for "c1:int + c2:int" The C-code equivalent is : ------------------------------ int expr_0(int64_t *addrs, int64_t *local_bitmaps, int64_t execution_context_ptr, int64_t nrecords) { int *outVec = (int *) addrs[5]; int *c0Vec = (int *) addrs[1]; int *c1Vec = (int *) addrs[3]; for (int loop_var = 0; loop_var < nrecords; ++loop_var) { int c0 = c0Vec[loop_var]; int c1 = c1Vec[loop_var]

Source from the content-addressed store, hash-verified

275// ret i32 0
276// }
277Status LLVMGenerator::CodeGenExprValue(DexPtr value_expr, int buffer_count,
278 FieldDescriptorPtr output, int suffix_idx,
279 std::string& fn_name,
280 SelectionVector::Mode selection_vector_mode) {
281 llvm::IRBuilder<>* builder = ir_builder();
282 const auto output_type_id = output->Type()->id();
283
284 // Create fn prototype :
285 // int expr_1 (long **addrs, long *offsets, long **bitmaps,
286 // long *context_ptr, long nrec)
287 std::vector<llvm::Type*> arguments;
288 arguments.push_back(types()->i64_ptr_type()); // addrs
289 arguments.push_back(types()->i64_ptr_type()); // offsets
290 arguments.push_back(types()->i64_ptr_type()); // bitmaps
291 arguments.push_back(types()->i64_ptr_type()); // holders
292 llvm::Type* selection_vector_type = nullptr;
293 switch (selection_vector_mode) {
294 case SelectionVector::MODE_NONE:
295 case SelectionVector::MODE_UINT16:
296 arguments.push_back(types()->ptr_type(types()->i16_type()));
297 selection_vector_type = types()->i16_type();
298 break;
299 case SelectionVector::MODE_UINT32:
300 arguments.push_back(types()->i32_ptr_type());
301 selection_vector_type = types()->i32_type();
302 break;
303 case SelectionVector::MODE_UINT64:
304 arguments.push_back(types()->i64_ptr_type());
305 selection_vector_type = types()->i64_type();
306 break;
307 }
308 arguments.push_back(types()->i64_type()); // ctx_ptr
309 arguments.push_back(types()->i64_type()); // nrec
310 llvm::FunctionType* prototype =
311 llvm::FunctionType::get(types()->i32_type(), arguments, false /*isVarArg*/);
312
313 // Create fn
314 engine_->AddFunctionToCompile(fn_name);
315 llvm::Function* fn = llvm::Function::Create(
316 prototype, llvm::GlobalValue::ExternalLinkage, fn_name, module());
317 ARROW_RETURN_IF((fn == nullptr), Status::CodeGenError("Error creating function."));
318
319 // Name the arguments
320 llvm::Function::arg_iterator args = (fn)->arg_begin();
321 llvm::Value* arg_addrs = &*args;
322 arg_addrs->setName("inputs_addr");
323 ++args;
324 llvm::Value* arg_addr_offsets = &*args;
325 arg_addr_offsets->setName("inputs_addr_offsets");
326 ++args;
327 llvm::Value* arg_local_bitmaps = &*args;
328 arg_local_bitmaps->setName("local_bitmaps");
329 ++args;
330 llvm::Value* arg_holder_ptrs = &*args;
331 arg_holder_ptrs->setName("holder_ptrs");
332 ++args;
333 llvm::Value* arg_selection_vector = &*args;
334 arg_selection_vector->setName("selection_vector");

Callers 1

TEST_FFunction · 0.80

Calls 15

moduleFunction · 0.85
CodeGenErrorFunction · 0.85
is_binary_likeFunction · 0.85
push_backMethod · 0.80
data_idxMethod · 0.80
data_buffer_ptr_idxMethod · 0.80
offsets_idxMethod · 0.80
has_arena_allocsMethod · 0.80
ir_builderFunction · 0.70
typesFunction · 0.70
contextFunction · 0.70
is_primitiveFunction · 0.50

Tested by 1

TEST_FFunction · 0.64