summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2009-08-18 20:23:35 +0100
committerJosé Fonseca <[email protected]>2009-08-29 09:21:34 +0100
commit5999ebfb69a47fa12d1f534871ea01a3f889f62f (patch)
treea8f3dfe882844fcb9424ba88888389dec9b85cca /src
parenta22f87c99462fd83dc398f4c06fc6d9997e15dba (diff)
llvmpipe: Debug helper function to name llvm intermediate values.
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c7
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_debug.h23
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_tgsi_soa.c17
-rw-r--r--src/gallium/drivers/llvmpipe/lp_state_blend.c19
-rw-r--r--src/gallium/drivers/llvmpipe/lp_state_fs.c25
-rw-r--r--src/gallium/drivers/llvmpipe/lp_test_blend.c19
6 files changed, 63 insertions, 47 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c b/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c
index 880235bc009..87ba4560653 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c
@@ -42,6 +42,7 @@
#include "lp_bld_logic.h"
#include "lp_bld_swizzle.h"
#include "lp_bld_blend.h"
+#include "lp_bld_debug.h"
/**
@@ -326,10 +327,8 @@ lp_build_blend_aos(LLVMBuilderRef builder,
src_term = lp_build_blend_factor(&bld, src, blend->rgb_src_factor, blend->alpha_src_factor, alpha_swizzle);
dst_term = lp_build_blend_factor(&bld, dst, blend->rgb_dst_factor, blend->alpha_dst_factor, alpha_swizzle);
-#ifdef DEBUG
- LLVMSetValueName(src_term, "src_term");
- LLVMSetValueName(dst_term, "dst_term");
-#endif
+ lp_build_name(src_term, "src_term");
+ lp_build_name(dst_term, "dst_term");
if(blend->rgb_func == blend->alpha_func) {
return lp_build_blend_func(&bld.base, blend->rgb_func, src_term, dst_term);
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_debug.h b/src/gallium/drivers/llvmpipe/lp_bld_debug.h
index d83652504bb..ecdafef76d0 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_debug.h
+++ b/src/gallium/drivers/llvmpipe/lp_bld_debug.h
@@ -30,6 +30,29 @@
#define LP_BLD_DEBUG_H
+#include <llvm-c/Core.h>
+
+#include "pipe/p_compiler.h"
+#include "util/u_string.h"
+
+
+static INLINE void
+lp_build_name(LLVMValueRef val, const char *format, ...)
+{
+#ifdef DEBUG
+ char name[32];
+ va_list ap;
+ va_start(ap, format);
+ util_vsnprintf(name, sizeof name, format, ap);
+ va_end(ap);
+ LLVMSetValueName(val, name);
+#else
+ (void)val;
+ (void)format;
+#endif
+}
+
+
void
lp_disassemble(const void* func);
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_tgsi_soa.c b/src/gallium/drivers/llvmpipe/lp_bld_tgsi_soa.c
index b7b1df9aded..451915f23f6 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_tgsi_soa.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_tgsi_soa.c
@@ -42,6 +42,7 @@
#include "lp_bld_logic.h"
#include "lp_bld_swizzle.h"
#include "lp_bld_tgsi.h"
+#include "lp_bld_debug.h"
#define LP_MAX_TEMPS 256
@@ -1353,10 +1354,11 @@ emit_declaration(
LLVMValueRef a0;
LLVMValueRef dadx;
LLVMValueRef dady;
- char name[32];
switch( decl->Declaration.Interpolate ) {
case TGSI_INTERPOLATE_PERSPECTIVE:
+ /* fall-through */
+
case TGSI_INTERPOLATE_LINEAR: {
LLVMValueRef dadx_ptr = LLVMBuildGEP(builder, bld->dadx_ptr, &index, 1, "");
LLVMValueRef dady_ptr = LLVMBuildGEP(builder, bld->dady_ptr, &index, 1, "");
@@ -1364,18 +1366,16 @@ emit_declaration(
dady = LLVMBuildLoad(builder, dady_ptr, "");
dadx = lp_build_broadcast_scalar(&bld->base, dadx);
dady = lp_build_broadcast_scalar(&bld->base, dady);
- util_snprintf(name, sizeof name, "dadx_%u.%c", attrib, "xyzw"[chan]);
- LLVMSetValueName(dadx, name);
- util_snprintf(name, sizeof name, "dady_%u.%c", attrib, "xyzw"[chan]);
- LLVMSetValueName(dady, name);
+ lp_build_name(dadx, "dadx_%u.%c", attrib, "xyzw"[chan]);
+ lp_build_name(dady, "dady_%u.%c", attrib, "xyzw"[chan]);
+ /* fall-through */
}
case TGSI_INTERPOLATE_CONSTANT: {
LLVMValueRef a0_ptr = LLVMBuildGEP(builder, bld->a0_ptr, &index, 1, "");
a0 = LLVMBuildLoad(builder, a0_ptr, "");
a0 = lp_build_broadcast_scalar(&bld->base, a0);
- util_snprintf(name, sizeof name, "a0_%u.%c", attrib, "xyzw"[chan]);
- LLVMSetValueName(a0, name);
+ lp_build_name(a0, "a0_%u.%c", attrib, "xyzw"[chan]);
break;
}
@@ -1397,8 +1397,7 @@ emit_declaration(
input = lp_build_mul(&bld->base, input, bld->oow);
}
- util_snprintf(name, sizeof name, "input%u.%c", attrib, "xyzw"[chan]);
- LLVMSetValueName(input, name);
+ lp_build_name(input, "input%u.%c", attrib, "xyzw"[chan]);
}
bld->inputs[attrib][chan] = input;
diff --git a/src/gallium/drivers/llvmpipe/lp_state_blend.c b/src/gallium/drivers/llvmpipe/lp_state_blend.c
index 487146bcd4d..d1c8536acf7 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_blend.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_blend.c
@@ -66,10 +66,6 @@ blend_generate(struct llvmpipe_screen *screen,
LLVMValueRef con[4];
LLVMValueRef dst[4];
LLVMValueRef res[4];
- char src_name[5] = "src?";
- char con_name[5] = "con?";
- char dst_name[5] = "dst?";
- char res_name[5] = "res?";
unsigned i;
type.value = 0;
@@ -105,18 +101,21 @@ blend_generate(struct llvmpipe_screen *screen,
for(i = 0; i < 4; ++i) {
LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0);
- con_name[3] = dst_name[3] = src_name[3] = "rgba"[i];
- src[i] = LLVMBuildLoad(builder, LLVMBuildGEP(builder, src_ptr, &index, 1, ""), src_name);
- con[i] = LLVMBuildLoad(builder, LLVMBuildGEP(builder, const_ptr, &index, 1, ""), con_name);
- dst[i] = LLVMBuildLoad(builder, LLVMBuildGEP(builder, dst_ptr, &index, 1, ""), dst_name);
+
+ src[i] = LLVMBuildLoad(builder, LLVMBuildGEP(builder, src_ptr, &index, 1, ""), "");
+ con[i] = LLVMBuildLoad(builder, LLVMBuildGEP(builder, const_ptr, &index, 1, ""), "");
+ dst[i] = LLVMBuildLoad(builder, LLVMBuildGEP(builder, dst_ptr, &index, 1, ""), "");
+
+ lp_build_name(src[i], "src.%c", "rgba"[i]);
+ lp_build_name(con[i], "con.%c", "rgba"[i]);
+ lp_build_name(dst[i], "dst.%c", "rgba"[i]);
}
lp_build_blend_soa(builder, &blend->base, type, src, dst, con, res);
for(i = 0; i < 4; ++i) {
LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0);
- res_name[3] = "rgba"[i];
- LLVMSetValueName(res[i], res_name);
+ lp_build_name(res[i], "res.%c", "rgba"[i]);
res[i] = lp_build_select(&bld, mask, res[i], dst[i]);
LLVMBuildStore(builder, res[i], LLVMBuildGEP(builder, dst_ptr, &index, 1, ""));
}
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index fd93d6f9b42..1397f948b27 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -67,7 +67,6 @@ shader_generate(struct llvmpipe_screen *screen,
LLVMValueRef pos[NUM_CHANNELS];
LLVMValueRef outputs[PIPE_MAX_SHADER_OUTPUTS][NUM_CHANNELS];
LLVMValueRef mask;
- char name[32];
unsigned i, j;
type.value = 0;
@@ -106,14 +105,14 @@ shader_generate(struct llvmpipe_screen *screen,
mask_ptr = LLVMGetParam(shader->function, 6);
samplers_ptr = LLVMGetParam(shader->function, 7);
- LLVMSetValueName(pos_ptr, "pos");
- LLVMSetValueName(a0_ptr, "a0");
- LLVMSetValueName(dadx_ptr, "dadx");
- LLVMSetValueName(dady_ptr, "dady");
- LLVMSetValueName(consts_ptr, "consts");
- LLVMSetValueName(outputs_ptr, "outputs");
- LLVMSetValueName(mask_ptr, "mask");
- LLVMSetValueName(samplers_ptr, "samplers");
+ lp_build_name(pos_ptr, "pos");
+ lp_build_name(a0_ptr, "a0");
+ lp_build_name(dadx_ptr, "dadx");
+ lp_build_name(dady_ptr, "dady");
+ lp_build_name(consts_ptr, "consts");
+ lp_build_name(outputs_ptr, "outputs");
+ lp_build_name(mask_ptr, "mask");
+ lp_build_name(samplers_ptr, "samplers");
block = LLVMAppendBasicBlock(shader->function, "entry");
builder = LLVMCreateBuilder();
@@ -121,8 +120,8 @@ shader_generate(struct llvmpipe_screen *screen,
for(j = 0; j < NUM_CHANNELS; ++j) {
LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), j, 0);
- util_snprintf(name, sizeof name, "pos.%c", "xyzw"[j]);
- pos[j] = LLVMBuildLoad(builder, LLVMBuildGEP(builder, pos_ptr, &index, 1, ""), name);
+ pos[j] = LLVMBuildLoad(builder, LLVMBuildGEP(builder, pos_ptr, &index, 1, ""), "");
+ lp_build_name(pos[j], "pos.%c", "xyzw"[j]);
}
memset(outputs, 0, sizeof outputs);
@@ -135,8 +134,8 @@ shader_generate(struct llvmpipe_screen *screen,
for(j = 0; j < NUM_CHANNELS; ++j) {
if(outputs[i][j]) {
LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i*NUM_CHANNELS + j, 0);
- util_snprintf(name, sizeof name, "output%u.%c", i, "xyzw"[j]);
- LLVMBuildStore(builder, outputs[i][j], LLVMBuildGEP(builder, outputs_ptr, &index, 1, name));
+ LLVMBuildStore(builder, outputs[i][j], LLVMBuildGEP(builder, outputs_ptr, &index, 1, ""));
+ lp_build_name(pos[j], "output%u.%c", i, "xyzw"[j]);
}
}
}
diff --git a/src/gallium/drivers/llvmpipe/lp_test_blend.c b/src/gallium/drivers/llvmpipe/lp_test_blend.c
index 0b6d2da590a..8dfad468e3c 100644
--- a/src/gallium/drivers/llvmpipe/lp_test_blend.c
+++ b/src/gallium/drivers/llvmpipe/lp_test_blend.c
@@ -193,7 +193,7 @@ add_blend_test(LLVMModuleRef module,
res = lp_build_blend_aos(builder, blend, type, src, dst, con, 3);
- LLVMSetValueName(res, "res");
+ lp_build_name(res, "res");
LLVMBuildStore(builder, res, res_ptr);
}
@@ -203,26 +203,23 @@ add_blend_test(LLVMModuleRef module,
LLVMValueRef dst[4];
LLVMValueRef con[4];
LLVMValueRef res[4];
- char src_name[5] = "src?";
- char dst_name[5] = "dst?";
- char con_name[5] = "con?";
- char res_name[5] = "res?";
unsigned i;
for(i = 0; i < 4; ++i) {
LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0);
- con_name[3] = dst_name[3] = src_name[3] = "rgba"[i];
- src[i] = LLVMBuildLoad(builder, LLVMBuildGEP(builder, src_ptr, &index, 1, ""), src_name);
- dst[i] = LLVMBuildLoad(builder, LLVMBuildGEP(builder, dst_ptr, &index, 1, ""), dst_name);
- con[i] = LLVMBuildLoad(builder, LLVMBuildGEP(builder, const_ptr, &index, 1, ""), con_name);
+ src[i] = LLVMBuildLoad(builder, LLVMBuildGEP(builder, src_ptr, &index, 1, ""), "");
+ dst[i] = LLVMBuildLoad(builder, LLVMBuildGEP(builder, dst_ptr, &index, 1, ""), "");
+ con[i] = LLVMBuildLoad(builder, LLVMBuildGEP(builder, const_ptr, &index, 1, ""), "");
+ lp_build_name(src[i], "src.%c", "rgba"[i]);
+ lp_build_name(con[i], "con.%c", "rgba"[i]);
+ lp_build_name(dst[i], "dst.%c", "rgba"[i]);
}
lp_build_blend_soa(builder, blend, type, src, dst, con, res);
for(i = 0; i < 4; ++i) {
LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0);
- res_name[3] = "rgba"[i];
- LLVMSetValueName(res[i], res_name);
+ lp_build_name(res[i], "res.%c", "rgba"[i]);
LLVMBuildStore(builder, res[i], LLVMBuildGEP(builder, res_ptr, &index, 1, ""));
}
}