aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/llvmpipe/lp_test_blend.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2010-11-30 16:07:52 -0700
committerBrian Paul <[email protected]>2010-11-30 16:35:12 -0700
commitefc82aef35a2aac5d2ed9774f6d28f2626796416 (patch)
tree72fe4482d72dbeb8e41b15793b21f38de62ef834 /src/gallium/drivers/llvmpipe/lp_test_blend.c
parent1f1375d4d876c2c85156e02a177254684446040b (diff)
gallivm/llvmpipe: squash merge of the llvm-context branch
This branch defines a gallivm_state structure which contains the LLVMBuilderRef, LLVMContextRef, etc. All data structures built with this object can be periodically freed during a "garbage collection" operation. The gallivm_state object has to be passed to most of the builder functions where LLVMBuilderRef used to be used. Conflicts: src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c src/gallium/drivers/llvmpipe/lp_state_setup.c
Diffstat (limited to 'src/gallium/drivers/llvmpipe/lp_test_blend.c')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_test_blend.c65
1 files changed, 22 insertions, 43 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_test_blend.c b/src/gallium/drivers/llvmpipe/lp_test_blend.c
index 8b6b5e1298f..b3ca134131d 100644
--- a/src/gallium/drivers/llvmpipe/lp_test_blend.c
+++ b/src/gallium/drivers/llvmpipe/lp_test_blend.c
@@ -163,11 +163,13 @@ dump_blend_type(FILE *fp,
static LLVMValueRef
-add_blend_test(LLVMModuleRef module,
+add_blend_test(struct gallivm_state *gallivm,
const struct pipe_blend_state *blend,
enum vector_mode mode,
struct lp_type type)
{
+ LLVMModuleRef module = gallivm->module;
+ LLVMContextRef context = gallivm->context;
LLVMTypeRef vec_type;
LLVMTypeRef args[4];
LLVMValueRef func;
@@ -179,18 +181,18 @@ add_blend_test(LLVMModuleRef module,
LLVMBuilderRef builder;
const unsigned rt = 0;
- vec_type = lp_build_vec_type(type);
+ vec_type = lp_build_vec_type(gallivm, type);
args[3] = args[2] = args[1] = args[0] = LLVMPointerType(vec_type, 0);
- func = LLVMAddFunction(module, "test", LLVMFunctionType(LLVMVoidType(), args, 4, 0));
+ func = LLVMAddFunction(module, "test", LLVMFunctionType(LLVMVoidTypeInContext(context), args, 4, 0));
LLVMSetFunctionCallConv(func, LLVMCCallConv);
src_ptr = LLVMGetParam(func, 0);
dst_ptr = LLVMGetParam(func, 1);
const_ptr = LLVMGetParam(func, 2);
res_ptr = LLVMGetParam(func, 3);
- block = LLVMAppendBasicBlock(func, "entry");
- builder = LLVMCreateBuilder();
+ block = LLVMAppendBasicBlockInContext(context, func, "entry");
+ builder = gallivm->builder;
LLVMPositionBuilderAtEnd(builder, block);
if (mode == AoS) {
@@ -203,7 +205,7 @@ add_blend_test(LLVMModuleRef module,
dst = LLVMBuildLoad(builder, dst_ptr, "dst");
con = LLVMBuildLoad(builder, const_ptr, "const");
- res = lp_build_blend_aos(builder, blend, type, rt, src, dst, con, 3);
+ res = lp_build_blend_aos(gallivm, blend, type, rt, src, dst, con, 3);
lp_build_name(res, "res");
@@ -218,7 +220,7 @@ add_blend_test(LLVMModuleRef module,
unsigned i;
for(i = 0; i < 4; ++i) {
- LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0);
+ LLVMValueRef index = LLVMConstInt(LLVMInt32TypeInContext(context), i, 0);
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, ""), "");
@@ -227,10 +229,10 @@ add_blend_test(LLVMModuleRef module,
lp_build_name(dst[i], "dst.%c", "rgba"[i]);
}
- lp_build_blend_soa(builder, blend, type, rt, src, dst, con, res);
+ lp_build_blend_soa(gallivm, blend, type, rt, src, dst, con, res);
for(i = 0; i < 4; ++i) {
- LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0);
+ LLVMValueRef index = LLVMConstInt(LLVMInt32TypeInContext(context), i, 0);
lp_build_name(res[i], "res.%c", "rgba"[i]);
LLVMBuildStore(builder, res[i], LLVMBuildGEP(builder, res_ptr, &index, 1, ""));
}
@@ -238,7 +240,6 @@ add_blend_test(LLVMModuleRef module,
LLVMBuildRetVoid(builder);;
- LLVMDisposeBuilder(builder);
return func;
}
@@ -465,16 +466,16 @@ compute_blend_ref(const struct pipe_blend_state *blend,
PIPE_ALIGN_STACK
static boolean
-test_one(unsigned verbose,
+test_one(struct gallivm_state *gallivm,
+ unsigned verbose,
FILE *fp,
const struct pipe_blend_state *blend,
enum vector_mode mode,
struct lp_type type)
{
- LLVMModuleRef module = NULL;
+ LLVMModuleRef module = gallivm->module;
LLVMValueRef func = NULL;
- LLVMExecutionEngineRef engine = lp_build_engine;
- LLVMPassManagerRef pass = NULL;
+ LLVMExecutionEngineRef engine = gallivm->engine;
char *error = NULL;
blend_test_ptr_t blend_test_ptr;
boolean success;
@@ -487,9 +488,7 @@ test_one(unsigned verbose,
if(verbose >= 1)
dump_blend_type(stdout, blend, mode, type);
- module = LLVMModuleCreateWithName("test");
-
- func = add_blend_test(module, blend, mode, type);
+ func = add_blend_test(gallivm, blend, mode, type);
if(LLVMVerifyModule(module, LLVMPrintMessageAction, &error)) {
LLVMDumpModule(module);
@@ -497,24 +496,6 @@ test_one(unsigned verbose,
}
LLVMDisposeMessage(error);
-#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);
- LLVMAddGVNPass(pass);
- LLVMAddCFGSimplificationPass(pass);
- LLVMRunPassManager(pass, module);
-#else
- (void)pass;
-#endif
-
- if(verbose >= 2)
- LLVMDumpModule(module);
-
code = LLVMGetPointerToGlobal(engine, func);
blend_test_ptr = voidptr_to_blend_test_ptr_t(code);
@@ -715,9 +696,6 @@ test_one(unsigned verbose,
LLVMFreeMachineCodeForFunction(engine, func);
- if(pass)
- LLVMDisposePassManager(pass);
-
return success;
}
@@ -773,7 +751,7 @@ const unsigned num_types = sizeof(blend_types)/sizeof(blend_types[0]);
boolean
-test_all(unsigned verbose, FILE *fp)
+test_all(struct gallivm_state *gallivm, unsigned verbose, FILE *fp)
{
const unsigned *rgb_func;
const unsigned *rgb_src_factor;
@@ -809,7 +787,7 @@ test_all(unsigned verbose, FILE *fp)
blend.rt[0].alpha_dst_factor = *alpha_dst_factor;
blend.rt[0].colormask = PIPE_MASK_RGBA;
- if(!test_one(verbose, fp, &blend, mode, *type))
+ if(!test_one(gallivm, verbose, fp, &blend, mode, *type))
success = FALSE;
}
@@ -826,7 +804,8 @@ test_all(unsigned verbose, FILE *fp)
boolean
-test_some(unsigned verbose, FILE *fp, unsigned long n)
+test_some(struct gallivm_state *gallivm, unsigned verbose, FILE *fp,
+ unsigned long n)
{
const unsigned *rgb_func;
const unsigned *rgb_src_factor;
@@ -868,7 +847,7 @@ test_some(unsigned verbose, FILE *fp, unsigned long n)
blend.rt[0].alpha_dst_factor = *alpha_dst_factor;
blend.rt[0].colormask = PIPE_MASK_RGBA;
- if(!test_one(verbose, fp, &blend, mode, *type))
+ if(!test_one(gallivm, verbose, fp, &blend, mode, *type))
success = FALSE;
}
@@ -877,7 +856,7 @@ test_some(unsigned verbose, FILE *fp, unsigned long n)
boolean
-test_single(unsigned verbose, FILE *fp)
+test_single(struct gallivm_state *gallivm, unsigned verbose, FILE *fp)
{
printf("no test_single()");
return TRUE;