MCPcopy Create free account
hub / github.com/apache/impala / StructToReadWriteInfo

Method StructToReadWriteInfo

be/src/codegen/codegen-anyval.cc:1146–1197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1144}
1145
1146void CodegenAnyVal::StructToReadWriteInfo(
1147 CodegenAnyValReadWriteInfo* read_write_info,
1148 llvm::Value* children_ptr) {
1149 const ColumnType& type = read_write_info->type();
1150 DCHECK(type.IsStructType());
1151
1152 LlvmCodeGen* codegen = read_write_info->codegen();
1153 llvm::LLVMContext& context = codegen->context();
1154 LlvmBuilder* builder = read_write_info->builder();
1155 llvm::Function* fn = builder->GetInsertBlock()->getParent();
1156
1157 llvm::Value* cast_children_ptr = builder->CreateBitCast(
1158 children_ptr, codegen->ptr_ptr_type(), "cast_children_ptr");
1159
1160 for (int i = 0; i < type.children.size(); ++i) {
1161 const ColumnType& child_type = type.children[i];
1162 CodegenAnyValReadWriteInfo child_read_write_info(codegen, builder, child_type);
1163
1164 llvm::BasicBlock* child_entry_block = llvm::BasicBlock::Create(context, "entry", fn);
1165
1166 builder->SetInsertPoint(child_entry_block);
1167 llvm::Value* child_ptr_addr = builder->CreateInBoundsGEP(cast_children_ptr,
1168 codegen->GetI32Constant(i), "child_ptr_addr");
1169 llvm::Value* child_ptr = builder->CreateLoad(codegen->ptr_type(), child_ptr_addr,
1170 "child_ptr");
1171
1172 // Check whether child_ptr is NULL.
1173 llvm::Value* child_is_null = builder->CreateIsNull(child_ptr, "child_is_null");
1174
1175 llvm::BasicBlock* non_null_block =
1176 llvm::BasicBlock::Create(context, "non_null", fn);
1177 llvm::BasicBlock* null_block =
1178 llvm::BasicBlock::Create(context, "null", fn);
1179 builder->CreateCondBr(child_is_null, null_block, non_null_block);
1180 builder->SetInsertPoint(non_null_block);
1181
1182 if (child_type.IsStructType()) {
1183 llvm::Value* child_struct_ptr = builder->CreateBitCast(
1184 child_ptr, GetLoweredPtrType(codegen, child_type), "child_struct_ptr");
1185 llvm::Value* child_struct = builder->CreateLoad(child_struct_ptr, "child_struct");
1186 CodegenAnyVal child_anyval = CodegenAnyVal(
1187 codegen, builder, child_type, child_struct);
1188 llvm::Value* child_children_ptr = child_anyval.GetPtr();
1189 StructToReadWriteInfo(&child_read_write_info, child_children_ptr);
1190 } else {
1191 StructChildToReadWriteInfo(&child_read_write_info, child_type, child_ptr);
1192 }
1193
1194 child_read_write_info.SetBlocks(child_entry_block, null_block, non_null_block);
1195 read_write_info->children().emplace_back(std::move(child_read_write_info));
1196 }
1197}

Callers

nothing calls this directly

Calls 15

CreateClass · 0.85
moveFunction · 0.85
IsStructTypeMethod · 0.80
contextMethod · 0.80
getParentMethod · 0.80
ptr_ptr_typeMethod · 0.80
GetI32ConstantMethod · 0.80
ptr_typeMethod · 0.80
SetBlocksMethod · 0.80
childrenMethod · 0.80
CodegenAnyValClass · 0.70
typeMethod · 0.45

Tested by

no test coverage detected