diff options
author | Zack Rusin <zackr@vmware.com> | 2010-03-31 21:30:37 -0400 |
---|---|---|
committer | Zack Rusin <zackr@vmware.com> | 2010-03-31 21:30:37 -0400 |
commit | 2fb655d1dbb3f8425aeff1597271262661ef206b (patch) | |
tree | c58403272994f876e899e66dcdacec36bf62f420 /src/gallium/auxiliary/gallivm/lp_bld_printf.c | |
parent | 2ab737557258148d52d9b9e983e4b18560b7a460 (diff) | |
download | external_mesa3d-2fb655d1dbb3f8425aeff1597271262661ef206b.zip external_mesa3d-2fb655d1dbb3f8425aeff1597271262661ef206b.tar.gz external_mesa3d-2fb655d1dbb3f8425aeff1597271262661ef206b.tar.bz2 |
gallivm: convert floats to doubles
printf can't handle floats, convert them to doubles so that we can
actually print floats.
Diffstat (limited to 'src/gallium/auxiliary/gallivm/lp_bld_printf.c')
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_printf.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_printf.c b/src/gallium/auxiliary/gallivm/lp_bld_printf.c index 78c9ec7..e4fa2c2 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_printf.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_printf.c @@ -104,8 +104,15 @@ lp_build_printf(LLVMBuilderRef builder, const char *fmt, ...) params[0] = LLVMBuildGEP(builder, fmtarg, index, 2, ""); va_start(arglist, fmt); - for (i = 1; i <= argcount; i++) - params[i] = va_arg(arglist, LLVMValueRef); + for (i = 1; i <= argcount; i++) { + LLVMValueRef val = va_arg(arglist, LLVMValueRef); + LLVMTypeRef type = LLVMTypeOf(val); + /* printf wants doubles, so lets convert so that + * we can actually print them */ + if (LLVMGetTypeKind(type) == LLVMFloatTypeKind) + val = LLVMBuildFPExt(builder, val, LLVMDoubleType(), ""); + params[i] = val; + } va_end(arglist); return LLVMBuildCall(builder, func_printf, params, argcount + 1, ""); |