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

Method GetVal

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

Source from the content-addressed store, hash-verified

340}
341
342llvm::Value* CodegenAnyVal::GetVal(const char* name) {
343 DCHECK(type_.type != TYPE_STRING)
344 << "Use GetPtr and GetLen for StringVal";
345 DCHECK(type_.type != TYPE_VARCHAR)
346 << "Use GetPtr and GetLen for Varchar";
347 DCHECK(type_.type != TYPE_CHAR)
348 << "Use GetPtr and GetLen for Char";
349 DCHECK(type_.type != TYPE_FIXED_UDA_INTERMEDIATE)
350 << "Use GetPtr and GetLen for FixedUdaIntermediate";
351 DCHECK(type_.type != TYPE_TIMESTAMP)
352 << "Use GetDate and GetTimeOfDay for TimestampVals";
353 DCHECK(!type_.IsCollectionType())
354 << "Use GetPtr and GetLen for CollectionVal";
355 DCHECK(!type_.IsStructType())
356 << "Use GetPtr and GetLen for StructVal";
357 switch(type_.type) {
358 case TYPE_BOOLEAN:
359 case TYPE_TINYINT:
360 case TYPE_SMALLINT:
361 case TYPE_INT:
362 case TYPE_DATE: {
363 // Lowered type is an integer. Get the high bytes.
364 int num_bits = type_.GetByteSize() * 8;
365 llvm::Value* val = GetHighBits(num_bits, value_, name);
366 if (type_.type == TYPE_BOOLEAN) {
367 // Return booleans as i1 (vs. i8)
368 val = builder_->CreateTrunc(val, builder_->getInt1Ty(), name);
369 }
370 return val;
371 }
372 case TYPE_FLOAT: {
373 // Same as above, but we must cast the value to a float.
374 llvm::Value* val = GetHighBits(32, value_);
375 return builder_->CreateBitCast(val, codegen_->float_type());
376 }
377 case TYPE_BIGINT:
378 return builder_->CreateExtractValue(value_, 1, name);
379 case TYPE_DOUBLE: {
380 // Lowered type is of form { i8, * }. Get the second value.
381 llvm::Value* val = builder_->CreateExtractValue(value_, 1, name);
382#ifdef __aarch64__
383 val = builder_->CreateBitCast(val, codegen_->double_type());
384#endif
385 return val;
386 }
387 case TYPE_DECIMAL: {
388#ifdef __aarch64__
389 // On aarch64, the Lowered type is of form { {i8}, {i128} }. No padding add.
390 uint32_t idxs[] = {1, 0};
391#else
392 // On x86-64, Lowered type is of form { {i8}, [15 x i8], {i128} }.
393 uint32_t idxs[] = {2, 0};
394#endif
395 // Get the i128 value and truncate it to the correct size.
396 // (The {i128} corresponds to the union of the different width int types.)
397 llvm::Value* val = builder_->CreateExtractValue(value_, idxs, name);
398 return builder_->CreateTrunc(val,
399 codegen_->GetSlotType(type_), name);

Callers 1

EqMethod · 0.45

Calls 6

IsCollectionTypeMethod · 0.80
IsStructTypeMethod · 0.80
GetByteSizeMethod · 0.80
float_typeMethod · 0.80
double_typeMethod · 0.80
GetSlotTypeMethod · 0.80

Tested by

no test coverage detected