summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/llvmpipe/lp_jit.c
diff options
context:
space:
mode:
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 c3ba03a5a18..92d5d43d0cc 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);
}