#include "lp_bld_logic.h"
#include "lp_bld_swizzle.h"
#include "lp_bld_blend.h"
+#include "lp_bld_debug.h"
/**
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);
#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);
#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
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, "");
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;
}
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;
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;
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, ""));
}
LLVMValueRef pos[NUM_CHANNELS];
LLVMValueRef outputs[PIPE_MAX_SHADER_OUTPUTS][NUM_CHANNELS];
LLVMValueRef mask;
- char name[32];
unsigned i, j;
type.value = 0;
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();
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);
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]);
}
}
}
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);
}
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, ""));
}
}