summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2009-08-01 18:35:04 +0100
committerJosé Fonseca <[email protected]>2009-08-29 09:21:21 +0100
commit7ace0b1f4ac48caaa8c477d0641cfc7c4d9518c0 (patch)
treeb7848e140790515b6babed8d823ef345d90e27df /src/gallium
parent7d043162c5d9150947d9341cfa22192bd4c70fde (diff)
llvmpipe: Cleanup test programs.
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/llvmpipe/SConscript4
-rw-r--r--src/gallium/drivers/llvmpipe/lp_test_blend.c7
-rw-r--r--src/gallium/drivers/llvmpipe/lp_test_format.c (renamed from src/gallium/drivers/llvmpipe/lp_bld_test.c)135
3 files changed, 83 insertions, 63 deletions
diff --git a/src/gallium/drivers/llvmpipe/SConscript b/src/gallium/drivers/llvmpipe/SConscript
index 4a365e0cb3f..8d4d6736fcc 100644
--- a/src/gallium/drivers/llvmpipe/SConscript
+++ b/src/gallium/drivers/llvmpipe/SConscript
@@ -54,8 +54,8 @@ env.ParseConfig('llvm-config --libs jit interpreter nativecodegen bitwriter')
env.Prepend(LIBS = [llvmpipe] + auxiliaries)
env.Program(
- target = 'lp_bld_test',
- source = ['lp_bld_test.c'],
+ target = 'lp_test_format',
+ source = ['lp_test_format.c'],
)
env.Program(
diff --git a/src/gallium/drivers/llvmpipe/lp_test_blend.c b/src/gallium/drivers/llvmpipe/lp_test_blend.c
index 1a1313a8849..1621fa79abf 100644
--- a/src/gallium/drivers/llvmpipe/lp_test_blend.c
+++ b/src/gallium/drivers/llvmpipe/lp_test_blend.c
@@ -369,9 +369,9 @@ test_one(const struct pipe_blend_state *blend)
if(LLVMVerifyModule(module, LLVMPrintMessageAction, &error)) {
LLVMDumpModule(module);
- LLVMDisposeMessage(error);
abort();
}
+ LLVMDisposeMessage(error);
provider = LLVMCreateModuleProviderForExistingModule(module);
if (LLVMCreateJITCompiler(&engine, provider, 1, &error)) {
@@ -432,8 +432,11 @@ test_one(const struct pipe_blend_state *blend)
}
}
+ LLVMFreeMachineCodeForFunction(engine, func);
+
LLVMDisposeExecutionEngine(engine);
- //LLVMDisposeModule(module);
+ if(pass)
+ LLVMDisposePassManager(pass);
return success;
}
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_test.c b/src/gallium/drivers/llvmpipe/lp_test_format.c
index 1f093102671..3086bf871bc 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_test.c
+++ b/src/gallium/drivers/llvmpipe/lp_test_format.c
@@ -88,26 +88,33 @@ struct pixel_test_case test_cases[] =
};
+typedef void (*load_ptr_t)(const void *, float *);
+
+
static LLVMValueRef
add_load_rgba_test(LLVMModuleRef module,
enum pipe_format format)
{
- LLVMTypeRef args[] = {
- LLVMPointerType(LLVMInt8Type(), 0),
- LLVMPointerType(LLVMVectorType(LLVMFloatType(), 4), 0)
- };
- LLVMValueRef func = LLVMAddFunction(module, "load", LLVMFunctionType(LLVMVoidType(), args, 2, 0));
- LLVMSetFunctionCallConv(func, LLVMCCallConv);
- LLVMValueRef ptr = LLVMGetParam(func, 0);
- LLVMValueRef rgba_ptr = LLVMGetParam(func, 1);
+ LLVMTypeRef args[2];
+ LLVMValueRef func;
+ LLVMValueRef ptr;
+ LLVMValueRef rgba_ptr;
+ LLVMBasicBlockRef block;
+ LLVMBuilderRef builder;
+ LLVMValueRef rgba;
+ struct lp_build_loop_state loop;
- LLVMBasicBlockRef block = LLVMAppendBasicBlock(func, "entry");
- LLVMBuilderRef builder = LLVMCreateBuilder();
- LLVMPositionBuilderAtEnd(builder, block);
+ args[0] = LLVMPointerType(LLVMInt8Type(), 0);
+ args[1] = LLVMPointerType(LLVMVectorType(LLVMFloatType(), 4), 0);
- LLVMValueRef rgba;
+ func = LLVMAddFunction(module, "load", LLVMFunctionType(LLVMVoidType(), args, 2, 0));
+ LLVMSetFunctionCallConv(func, LLVMCCallConv);
+ ptr = LLVMGetParam(func, 0);
+ rgba_ptr = LLVMGetParam(func, 1);
- struct lp_build_loop_state loop;
+ block = LLVMAppendBasicBlock(func, "entry");
+ builder = LLVMCreateBuilder();
+ LLVMPositionBuilderAtEnd(builder, block);
lp_build_loop_begin(builder, LLVMConstInt(LLVMInt32Type(), 1, 0), &loop);
@@ -123,25 +130,33 @@ add_load_rgba_test(LLVMModuleRef module,
}
+typedef void (*store_ptr_t)(void *, const float *);
+
+
static LLVMValueRef
add_store_rgba_test(LLVMModuleRef module,
enum pipe_format format)
{
- LLVMTypeRef args[] = {
- LLVMPointerType(LLVMInt8Type(), 0),
- LLVMPointerType(LLVMVectorType(LLVMFloatType(), 4), 0)
- };
- LLVMValueRef func = LLVMAddFunction(module, "store", LLVMFunctionType(LLVMVoidType(), args, 2, 0));
+ LLVMTypeRef args[2];
+ LLVMValueRef func;
+ LLVMValueRef ptr;
+ LLVMValueRef rgba_ptr;
+ LLVMBasicBlockRef block;
+ LLVMBuilderRef builder;
+ LLVMValueRef rgba;
+
+ args[0] = LLVMPointerType(LLVMInt8Type(), 0);
+ args[1] = LLVMPointerType(LLVMVectorType(LLVMFloatType(), 4), 0);
+
+ func = LLVMAddFunction(module, "store", LLVMFunctionType(LLVMVoidType(), args, 2, 0));
LLVMSetFunctionCallConv(func, LLVMCCallConv);
- LLVMValueRef ptr = LLVMGetParam(func, 0);
- LLVMValueRef rgba_ptr = LLVMGetParam(func, 1);
+ ptr = LLVMGetParam(func, 0);
+ rgba_ptr = LLVMGetParam(func, 1);
- LLVMBasicBlockRef block = LLVMAppendBasicBlock(func, "entry");
- LLVMBuilderRef builder = LLVMCreateBuilder();
+ block = LLVMAppendBasicBlock(func, "entry");
+ builder = LLVMCreateBuilder();
LLVMPositionBuilderAtEnd(builder, block);
- LLVMValueRef rgba;
-
rgba = LLVMBuildLoad(builder, rgba_ptr, "");
lp_build_store_rgba(builder, format, ptr, rgba);
@@ -156,68 +171,67 @@ add_store_rgba_test(LLVMModuleRef module,
static boolean
test_format(const struct pixel_test_case *test)
{
+ LLVMModuleRef module = NULL;
+ LLVMValueRef load = NULL;
+ LLVMValueRef store = NULL;
+ LLVMExecutionEngineRef engine = NULL;
+ LLVMModuleProviderRef provider = NULL;
+ LLVMPassManagerRef pass = NULL;
char *error = NULL;
const struct util_format_description *desc;
-
+ load_ptr_t load_ptr;
+ store_ptr_t store_ptr;
+ float unpacked[4];
+ unsigned packed;
+ boolean success;
+ unsigned i;
+
desc = util_format_description(test->format);
fprintf(stderr, "%s\n", desc->name);
- LLVMModuleRef module = LLVMModuleCreateWithName("test");
+ module = LLVMModuleCreateWithName("test");
- LLVMValueRef load = add_load_rgba_test(module, test->format);
- LLVMValueRef store = add_store_rgba_test(module, test->format);
+ load = add_load_rgba_test(module, test->format);
+ store = add_store_rgba_test(module, test->format);
- LLVMVerifyModule(module, LLVMAbortProcessAction, &error);
+ if(LLVMVerifyModule(module, LLVMPrintMessageAction, &error)) {
+ LLVMDumpModule(module);
+ abort();
+ }
LLVMDisposeMessage(error);
- LLVMExecutionEngineRef engine;
- LLVMModuleProviderRef provider = LLVMCreateModuleProviderForExistingModule(module);
- error = NULL;
- LLVMCreateJITCompiler(&engine, provider, 1, &error);
- if (error) {
+ provider = LLVMCreateModuleProviderForExistingModule(module);
+ if (LLVMCreateJITCompiler(&engine, provider, 1, &error)) {
fprintf(stderr, "%s\n", error);
LLVMDisposeMessage(error);
abort();
}
- LLVMPassManagerRef pass = LLVMCreatePassManager();
#if 0
+ pass = LLVMCreatePassManager();
LLVMAddTargetData(LLVMGetExecutionEngineTargetData(engine), pass);
/* These are the passes currently listed in llvm-c/Transforms/Scalar.h,
* but there are more on SVN. */
LLVMAddConstantPropagationPass(pass);
LLVMAddInstructionCombiningPass(pass);
LLVMAddPromoteMemoryToRegisterPass(pass);
- LLVMAddDemoteMemoryToRegisterPass(pass);
LLVMAddGVNPass(pass);
LLVMAddCFGSimplificationPass(pass);
LLVMRunPassManager(pass, module);
- LLVMDumpModule(module);
+#else
+ (void)pass;
#endif
+ load_ptr = (load_ptr_t) LLVMGetPointerToGlobal(engine, load);
+ store_ptr = (store_ptr_t)LLVMGetPointerToGlobal(engine, store);
- float unpacked[4] = {0, 0, 0, 0};
- unsigned packed = 0;
-
- {
- typedef void (*load_ptr_t)(const void *, float *);
- load_ptr_t load_ptr = (load_ptr_t)LLVMGetPointerToGlobal(engine, load);
-
- load_ptr(&test->packed, unpacked);
+ memset(unpacked, 0, sizeof unpacked);
+ packed = 0;
- }
-
-
- {
- typedef void (*store_ptr_t)(void *, const float *);
- store_ptr_t store_ptr = (store_ptr_t)LLVMGetPointerToGlobal(engine, store);
-
- store_ptr(&packed, unpacked);
+ load_ptr(&test->packed, unpacked);
+ store_ptr(&packed, unpacked);
- }
-
- boolean success = TRUE;
- unsigned i;
+ success = TRUE;
if(test->packed != packed)
success = FALSE;
for(i = 0; i < 4; ++i)
@@ -233,9 +247,12 @@ test_format(const struct pixel_test_case *test)
LLVMDumpModule(module);
}
- LLVMDisposePassManager(pass);
+ LLVMFreeMachineCodeForFunction(engine, store);
+ LLVMFreeMachineCodeForFunction(engine, load);
+
LLVMDisposeExecutionEngine(engine);
- //LLVMDisposeModule(module);
+ if(pass)
+ LLVMDisposePassManager(pass);
return success;
}