Codegens reading the members of a StringVal or a CollectionVal from the slot pointed to by 'val_ptr'. Returns the resulting values in '*ptr' and '*len'.
| 279 | // Codegens reading the members of a StringVal or a CollectionVal from the slot pointed to |
| 280 | // by 'val_ptr'. Returns the resulting values in '*ptr' and '*len'. |
| 281 | void CodegenReadingStringOrCollectionVal(LlvmCodeGen* codegen, LlvmBuilder* builder, |
| 282 | const ColumnType& type, llvm::Value* val_ptr, llvm::Value** ptr, llvm::Value** len) { |
| 283 | if (type.IsVarLenStringType()) { |
| 284 | llvm::Function* str_ptr_fn = codegen->GetFunction( |
| 285 | IRFunction::STRING_VALUE_PTR, false); |
| 286 | llvm::Function* str_len_fn = codegen->GetFunction( |
| 287 | IRFunction::STRING_VALUE_LEN, false); |
| 288 | |
| 289 | *ptr = builder->CreateCall(str_ptr_fn, |
| 290 | llvm::ArrayRef<llvm::Value*>({val_ptr}), "ptr"); |
| 291 | *len = builder->CreateCall(str_len_fn, |
| 292 | llvm::ArrayRef<llvm::Value*>({val_ptr}), "len"); |
| 293 | } else if (type.IsCollectionType()) { |
| 294 | llvm::Value* ptr_ptr = builder->CreateStructGEP(nullptr, val_ptr, 0, "ptr_ptr"); |
| 295 | *ptr = builder->CreateLoad(ptr_ptr, "ptr"); |
| 296 | llvm::Value* len_ptr = builder->CreateStructGEP(nullptr, val_ptr, 1, "len_ptr"); |
| 297 | *len = builder->CreateLoad(len_ptr, "len"); |
| 298 | } else { |
| 299 | DCHECK(type.type == TYPE_CHAR || type.type == TYPE_FIXED_UDA_INTERMEDIATE); |
| 300 | // ptr and len are the slot and its fixed length. |
| 301 | *ptr = builder->CreateBitCast(val_ptr, codegen->ptr_type()); |
| 302 | *len = codegen->GetI32Constant(type.len); |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | void CodegenReadingTimestamp(LlvmCodeGen* codegen, LlvmBuilder* builder, |
| 307 | llvm::Value* val_ptr, llvm::Value** time_of_day, llvm::Value** date) { |
no test coverage detected