freedreno/a3xx: shadow sampler support
[mesa.git] / src / gallium / auxiliary / gallivm / lp_bld_printf.c
index 0de6a0882ba6eff0e660b1a240c058e3b99887a6..69d829ea6762a45956605f39742a8831c4dfced6 100644 (file)
@@ -26,6 +26,7 @@
  **************************************************************************/
 
 #include <stdio.h>
+#include <inttypes.h>
 
 #include "util/u_debug.h"
 #include "util/u_memory.h"
@@ -106,11 +107,17 @@ lp_build_print_value(struct gallivm_state *gallivm,
       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);
@@ -125,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;
       }
    }