summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/llvmpipe/lp_jit.c
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2009-08-23 06:35:09 +0100
committerJosé Fonseca <jfonseca@vmware.com>2009-08-29 09:21:41 +0100
commitc022e15d1e56ba3a9c6b74eef6556d6063e2e322 (patch)
tree86d4db84ea403791b5eba29ebc2f336bab07e305 /src/gallium/drivers/llvmpipe/lp_jit.c
parent8c7c108d712f17a5f307b9c8914b4abc4d5f148e (diff)
llvmpipe: Pass fragment context to generated function in a single structure.
Diffstat (limited to 'src/gallium/drivers/llvmpipe/lp_jit.c')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_jit.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_jit.c b/src/gallium/drivers/llvmpipe/lp_jit.c
index c3ba03a5a1..92d5d43d0c 100644
--- a/src/gallium/drivers/llvmpipe/lp_jit.c
+++ b/src/gallium/drivers/llvmpipe/lp_jit.c
@@ -35,10 +35,42 @@
#include <llvm-c/Transforms/Scalar.h>
+#include "util/u_memory.h"
#include "lp_screen.h"
#include "lp_jit.h"
+static void
+lp_jit_init_types(struct llvmpipe_screen *screen)
+{
+ /* struct lp_jit_context */
+ {
+ LLVMTypeRef elem_types[2];
+ LLVMTypeRef context_type;
+
+ elem_types[0] = LLVMPointerType(LLVMFloatType(), 0); /* constants */
+ elem_types[1] = LLVMPointerType(LLVMInt8Type(), 0); /* samplers */
+
+ context_type = LLVMStructType(elem_types, Elements(elem_types), 0);
+
+ LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, constants,
+ screen->target, context_type, 0);
+ LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, samplers,
+ screen->target, context_type, 1);
+ LP_CHECK_STRUCT_SIZE(struct lp_jit_context,
+ screen->target, context_type);
+
+ LLVMAddTypeName(screen->module, "context", context_type);
+
+ screen->context_ptr_type = LLVMPointerType(context_type, 0);
+ }
+
+#ifdef DEBUG
+ LLVMDumpModule(screen->module);
+#endif
+}
+
+
void
lp_jit_screen_cleanup(struct llvmpipe_screen *screen)
{
@@ -65,8 +97,10 @@ lp_jit_screen_init(struct llvmpipe_screen *screen)
abort();
}
+ screen->target = LLVMGetExecutionEngineTargetData(screen->engine);
+
screen->pass = LLVMCreateFunctionPassManager(screen->provider);
- LLVMAddTargetData(LLVMGetExecutionEngineTargetData(screen->engine), screen->pass);
+ LLVMAddTargetData(screen->target, screen->pass);
/* These are the passes currently listed in llvm-c/Transforms/Scalar.h,
* but there are more on SVN. */
LLVMAddConstantPropagationPass(screen->pass);
@@ -74,4 +108,6 @@ lp_jit_screen_init(struct llvmpipe_screen *screen)
LLVMAddPromoteMemoryToRegisterPass(screen->pass);
LLVMAddGVNPass(screen->pass);
LLVMAddCFGSimplificationPass(screen->pass);
+
+ lp_jit_init_types(screen);
}