diff options
author | José Fonseca <[email protected]> | 2012-12-06 08:50:46 +0000 |
---|---|---|
committer | José Fonseca <[email protected]> | 2012-12-06 15:58:40 +0000 |
commit | 33ffca713a5e593beda34d6bcbee8fb1af472cf7 (patch) | |
tree | 817307a4f3d0fbdb4d32eb01227063dcd094f762 /src/gallium/auxiliary/gallivm | |
parent | 5396582f5e0f327437159d0a844eeaeba8146fde (diff) |
gallivm: Fix lp_build_print_value of smaller integer types.
They need to be converted to the native integer type to prevent garbage
in higher order bits from being printed.
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/gallivm')
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_printf.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_printf.c b/src/gallium/auxiliary/gallivm/lp_bld_printf.c index 0de6a0882ba..7a6bbd960be 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_printf.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_printf.c @@ -125,8 +125,19 @@ lp_build_print_value(struct gallivm_state *gallivm, params[2] = value; } else { for (i = 0; i < length; ++i) { + LLVMValueRef param; util_strncat(format, type_fmt, sizeof(format) - strlen(format) - 1); - params[2 + i] = LLVMBuildExtractElement(builder, value, lp_build_const_int32(gallivm, i), ""); + param = LLVMBuildExtractElement(builder, value, lp_build_const_int32(gallivm, i), ""); + if (type_kind == LLVMIntegerTypeKind && + LLVMGetIntTypeWidth(type_ref) < sizeof(int) * 8) { + LLVMTypeRef int_type = LLVMIntTypeInContext(gallivm->context, sizeof(int) * 8); + if (LLVMGetIntTypeWidth(type_ref) == 8) { + param = LLVMBuildZExt(builder, param, int_type, ""); + } else { + param = LLVMBuildSExt(builder, param, int_type, ""); + } + } + params[2 + i] = param; } } |