X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fauxiliary%2Fgallivm%2Flp_bld_printf.c;h=69d829ea6762a45956605f39742a8831c4dfced6;hb=52381a7ffba908410f7a53855f082401fca7293a;hp=8549b87a1c766ec6e63d53f7d991d4592ced0b25;hpb=bf679ce1dcc9cb90bb0092a550a03ad391f6ba72;p=mesa.git diff --git a/src/gallium/auxiliary/gallivm/lp_bld_printf.c b/src/gallium/auxiliary/gallivm/lp_bld_printf.c index 8549b87a1c7..69d829ea676 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_printf.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_printf.c @@ -26,6 +26,7 @@ **************************************************************************/ #include +#include #include "util/u_debug.h" #include "util/u_memory.h" @@ -83,8 +84,8 @@ lp_build_print_value(struct gallivm_state *gallivm, LLVMTypeKind type_kind; LLVMTypeRef type_ref; LLVMValueRef params[2 + LP_MAX_VECTOR_LENGTH]; - char type_fmt[4] = " %x"; - char format[2 + 3 * LP_MAX_VECTOR_LENGTH + 2] = "%s"; + char type_fmt[6] = " %x"; + char format[2 + 5 * LP_MAX_VECTOR_LENGTH + 2] = "%s"; unsigned length; unsigned i; @@ -101,13 +102,22 @@ lp_build_print_value(struct gallivm_state *gallivm, } if (type_kind == LLVMFloatTypeKind || type_kind == LLVMDoubleTypeKind) { - type_fmt[2] = 'f'; + type_fmt[2] = '.'; + type_fmt[3] = '9'; + type_fmt[4] = 'g'; + type_fmt[5] = '\0'; } else if (type_kind == LLVMIntegerTypeKind) { - if (LLVMGetIntTypeWidth(type_ref) == 8) { + if (LLVMGetIntTypeWidth(type_ref) == 64) { + unsigned flen = strlen(PRId64); + assert(flen <= 3); + strncpy(type_fmt + 2, PRId64, flen); + } else if (LLVMGetIntTypeWidth(type_ref) == 8) { type_fmt[2] = 'u'; } else { type_fmt[2] = 'i'; } + } else if (type_kind == LLVMPointerTypeKind) { + type_fmt[2] = 'p'; } else { /* Unsupported type */ assert(0); @@ -122,8 +132,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; } }