llvmpipe: silence cast warnings in test programs

This commit is contained in:
Brian Paul
2010-05-13 13:21:19 -06:00
parent 45d6289fab
commit 966d28cb2e
4 changed files with 63 additions and 6 deletions

View File

@@ -52,6 +52,19 @@ enum vector_mode
typedef void (*blend_test_ptr_t)(const void *src, const void *dst, const void *con, void *res); typedef void (*blend_test_ptr_t)(const void *src, const void *dst, const void *con, void *res);
/** cast wrapper */
static blend_test_ptr_t
voidptr_to_blend_test_ptr_t(void *p)
{
union {
void *v;
blend_test_ptr_t f;
} u;
u.v = p;
return u.f;
}
void void
write_tsv_header(FILE *fp) write_tsv_header(FILE *fp)
@@ -482,6 +495,7 @@ test_one(unsigned verbose,
int64_t cycles[LP_TEST_NUM_SAMPLES]; int64_t cycles[LP_TEST_NUM_SAMPLES];
double cycles_avg = 0.0; double cycles_avg = 0.0;
unsigned i, j; unsigned i, j;
void *code;
if(verbose >= 1) if(verbose >= 1)
dump_blend_type(stdout, blend, mode, type); dump_blend_type(stdout, blend, mode, type);
@@ -523,10 +537,11 @@ test_one(unsigned verbose,
if(verbose >= 2) if(verbose >= 2)
LLVMDumpModule(module); LLVMDumpModule(module);
blend_test_ptr = (blend_test_ptr_t)LLVMGetPointerToGlobal(engine, func); code = LLVMGetPointerToGlobal(engine, func);
blend_test_ptr = voidptr_to_blend_test_ptr_t(code);
if(verbose >= 2) if(verbose >= 2)
lp_disassemble(blend_test_ptr); lp_disassemble(code);
success = TRUE; success = TRUE;
for(i = 0; i < n && success; ++i) { for(i = 0; i < n && success; ++i) {

View File

@@ -43,6 +43,17 @@
typedef void (*conv_test_ptr_t)(const void *src, const void *dst); typedef void (*conv_test_ptr_t)(const void *src, const void *dst);
/** cast wrapper */
static conv_test_ptr_t
voidptr_to_conv_test_ptr_t(void *p)
{
union {
void *v;
conv_test_ptr_t f;
} u;
u.v = p;
return u.f;
}
void void
write_tsv_header(FILE *fp) write_tsv_header(FILE *fp)
@@ -164,6 +175,7 @@ test_one(unsigned verbose,
unsigned num_dsts; unsigned num_dsts;
double eps; double eps;
unsigned i, j; unsigned i, j;
void *code;
if(verbose >= 1) if(verbose >= 1)
dump_conv_types(stdout, src_type, dst_type); dump_conv_types(stdout, src_type, dst_type);
@@ -221,10 +233,11 @@ test_one(unsigned verbose,
if(verbose >= 2) if(verbose >= 2)
LLVMDumpModule(module); LLVMDumpModule(module);
conv_test_ptr = (conv_test_ptr_t)LLVMGetPointerToGlobal(engine, func); code = LLVMGetPointerToGlobal(engine, func);
conv_test_ptr = voidptr_to_conv_test_ptr_t(code);
if(verbose >= 2) if(verbose >= 2)
lp_disassemble(conv_test_ptr); lp_disassemble(code);
success = TRUE; success = TRUE;
for(i = 0; i < n && success; ++i) { for(i = 0; i < n && success; ++i) {

View File

@@ -73,6 +73,19 @@ typedef void
(*fetch_ptr_t)(float *, const void *packed, (*fetch_ptr_t)(float *, const void *packed,
unsigned i, unsigned j); unsigned i, unsigned j);
/** cast wrapper to avoid warnings */
static fetch_ptr_t
void_to_fetch_ptr_t(void *p)
{
union {
void *v;
fetch_ptr_t f;
} u;
u.v = p;
return u.f;
}
static LLVMValueRef static LLVMValueRef
add_fetch_rgba_test(LLVMModuleRef lp_build_module, add_fetch_rgba_test(LLVMModuleRef lp_build_module,
@@ -149,7 +162,7 @@ test_format(unsigned verbose, FILE *fp,
(void)pass; (void)pass;
#endif #endif
fetch_ptr = (fetch_ptr_t) LLVMGetPointerToGlobal(lp_build_engine, fetch); fetch_ptr = void_to_fetch_ptr_t(LLVMGetPointerToGlobal(lp_build_engine, fetch));
for (i = 0; i < desc->block.height; ++i) { for (i = 0; i < desc->block.height; ++i) {
for (j = 0; j < desc->block.width; ++j) { for (j = 0; j < desc->block.width; ++j) {

View File

@@ -41,6 +41,7 @@
struct printf_test_case { struct printf_test_case {
int foo;
}; };
void void
@@ -57,6 +58,19 @@ write_tsv_header(FILE *fp)
typedef void (*test_printf_t)(int i); typedef void (*test_printf_t)(int i);
/** cast wrapper */
static test_printf_t
voidptr_to_test_printf_t(void *p)
{
union {
void *v;
test_printf_t f;
} u;
u.v = p;
return u.f;
}
static LLVMValueRef static LLVMValueRef
add_printf_test(LLVMModuleRef module) add_printf_test(LLVMModuleRef module)
{ {
@@ -91,6 +105,7 @@ test_printf(unsigned verbose, FILE *fp, const struct printf_test_case *testcase)
float unpacked[4]; float unpacked[4];
unsigned packed; unsigned packed;
boolean success = TRUE; boolean success = TRUE;
void *code;
module = LLVMModuleCreateWithName("test"); module = LLVMModuleCreateWithName("test");
@@ -124,7 +139,8 @@ test_printf(unsigned verbose, FILE *fp, const struct printf_test_case *testcase)
(void)pass; (void)pass;
#endif #endif
test_printf = (test_printf_t)LLVMGetPointerToGlobal(engine, test); code = LLVMGetPointerToGlobal(engine, test);
test_printf = voidptr_to_test_printf_t(code);
memset(unpacked, 0, sizeof unpacked); memset(unpacked, 0, sizeof unpacked);
packed = 0; packed = 0;