Mesa (gallium-llvmpipe): llvmpipe: Split control flow function declarations and notes.
Jose Fonseca
jrfonseca at kemper.freedesktop.org
Sat Aug 22 11:40:43 UTC 2009
Module: Mesa
Branch: gallium-llvmpipe
Commit: 0a62714d6f628d66399a8c1e6701d3c0014c9725
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0a62714d6f628d66399a8c1e6701d3c0014c9725
Author: José Fonseca <jfonseca at vmware.com>
Date: Fri Aug 21 10:57:48 2009 +0100
llvmpipe: Split control flow function declarations and notes.
---
src/gallium/drivers/llvmpipe/Makefile | 2 +-
src/gallium/drivers/llvmpipe/README | 9 +++
src/gallium/drivers/llvmpipe/SConscript | 2 +-
.../llvmpipe/{lp_bld_loop.c => lp_bld_flow.c} | 15 ++---
.../llvmpipe/{lp_bld_loop.c => lp_bld_flow.h} | 60 ++++++-------------
.../drivers/llvmpipe/{lp_bld.h => lp_bld_format.h} | 21 -------
src/gallium/drivers/llvmpipe/lp_bld_load.c | 2 +-
src/gallium/drivers/llvmpipe/lp_bld_pack.c | 2 +-
src/gallium/drivers/llvmpipe/lp_bld_store.c | 2 +-
src/gallium/drivers/llvmpipe/lp_bld_unpack.c | 2 +-
src/gallium/drivers/llvmpipe/lp_test_format.c | 3 +-
11 files changed, 41 insertions(+), 79 deletions(-)
diff --git a/src/gallium/drivers/llvmpipe/Makefile b/src/gallium/drivers/llvmpipe/Makefile
index ed24a1c..91a2e2e 100644
--- a/src/gallium/drivers/llvmpipe/Makefile
+++ b/src/gallium/drivers/llvmpipe/Makefile
@@ -12,12 +12,12 @@ C_SOURCES = \
lp_bld_conv.c \
lp_bld_debug.c \
lp_bld_depth.c \
+ lp_bld_flow.c \
lp_bld_intr.c \
lp_bld_pack.c \
lp_bld_unpack.c \
lp_bld_load.c \
lp_bld_store.c \
- lp_bld_loop.c \
lp_bld_logic.c \
lp_bld_logicop.c \
lp_bld_swizzle.c \
diff --git a/src/gallium/drivers/llvmpipe/README b/src/gallium/drivers/llvmpipe/README
index 6e4edaa..677352e 100644
--- a/src/gallium/drivers/llvmpipe/README
+++ b/src/gallium/drivers/llvmpipe/README
@@ -106,3 +106,12 @@ for posterior analysis, e.g.:
build/linux-x86_64/gallium/drivers/llvmpipe/lp_test_blend -o blend.tsv
+
+Development Notes
+=================
+
+- We use LLVM-C bindings for now. They are not documented, but follow the C++
+ interfaces very closely, and appear to be complete enough for code
+ generation. See
+ http://npcontemplation.blogspot.com/2008/06/secret-of-llvm-c-bindings.html
+ for a standalone example.
diff --git a/src/gallium/drivers/llvmpipe/SConscript b/src/gallium/drivers/llvmpipe/SConscript
index a2987c1..b8b577f 100644
--- a/src/gallium/drivers/llvmpipe/SConscript
+++ b/src/gallium/drivers/llvmpipe/SConscript
@@ -16,12 +16,12 @@ llvmpipe = env.ConvenienceLibrary(
'lp_bld_conv.c',
'lp_bld_debug.c',
'lp_bld_depth.c',
+ 'lp_bld_flow.c',
'lp_bld_intr.c',
'lp_bld_pack.c',
'lp_bld_unpack.c',
'lp_bld_load.c',
'lp_bld_store.c',
- 'lp_bld_loop.c',
'lp_bld_logic.c',
'lp_bld_logicop.c',
'lp_bld_swizzle.c',
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_loop.c b/src/gallium/drivers/llvmpipe/lp_bld_flow.c
similarity index 90%
copy from src/gallium/drivers/llvmpipe/lp_bld_loop.c
copy to src/gallium/drivers/llvmpipe/lp_bld_flow.c
index eb6126e..5fc85a1 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_loop.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_flow.c
@@ -25,20 +25,15 @@
*
**************************************************************************/
-#include "lp_bld.h"
-
-
/**
- * @file
- * Auxiliaries to build loops.
- *
- * LLVM's IR doesn't represent for-loops directly. Furthermore it
- * it requires creating code blocks, branches, phi variables, so it
- * requires a fair amount of code.
+ * LLVM control flow build helpers.
*
- * @sa http://www.llvm.org/docs/tutorial/LangImpl5.html#for
+ * @author Jose Fonseca <jfonseca at vmware.com>
*/
+#include "lp_bld_flow.h"
+
+
void
lp_build_loop_begin(LLVMBuilderRef builder,
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_loop.c b/src/gallium/drivers/llvmpipe/lp_bld_flow.h
similarity index 60%
rename from src/gallium/drivers/llvmpipe/lp_bld_loop.c
rename to src/gallium/drivers/llvmpipe/lp_bld_flow.h
index eb6126e..7281b27 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_loop.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_flow.h
@@ -25,67 +25,45 @@
*
**************************************************************************/
-#include "lp_bld.h"
+/**
+ * LLVM control flow build helpers.
+ *
+ * @author Jose Fonseca <jfonseca at vmware.com>
+ */
+
+#ifndef LP_BLD_FLOW_H
+#define LP_BLD_FLOW_H
+
+
+#include <llvm-c/Core.h>
/**
- * @file
- * Auxiliaries to build loops.
- *
* LLVM's IR doesn't represent for-loops directly. Furthermore it
* it requires creating code blocks, branches, phi variables, so it
* requires a fair amount of code.
*
* @sa http://www.llvm.org/docs/tutorial/LangImpl5.html#for
*/
+struct lp_build_loop_state
+{
+ LLVMBasicBlockRef block;
+ LLVMValueRef counter;
+};
void
lp_build_loop_begin(LLVMBuilderRef builder,
LLVMValueRef start,
- struct lp_build_loop_state *state)
-{
- LLVMBasicBlockRef block = LLVMGetInsertBlock(builder);
- LLVMValueRef function = LLVMGetBasicBlockParent(block);
-
- state->block = LLVMAppendBasicBlock(function, "loop");
-
- LLVMBuildBr(builder, state->block);
-
- LLVMPositionBuilderAtEnd(builder, state->block);
-
- state->counter = LLVMBuildPhi(builder, LLVMTypeOf(start), "");
-
- LLVMAddIncoming(state->counter, &start, &block, 1);
-
-}
+ struct lp_build_loop_state *state);
void
lp_build_loop_end(LLVMBuilderRef builder,
LLVMValueRef end,
LLVMValueRef step,
- struct lp_build_loop_state *state)
-{
- LLVMBasicBlockRef block = LLVMGetInsertBlock(builder);
- LLVMValueRef function = LLVMGetBasicBlockParent(block);
- LLVMValueRef next;
- LLVMValueRef cond;
- LLVMBasicBlockRef after_block;
-
- if (!step)
- step = LLVMConstInt(LLVMTypeOf(end), 1, 0);
-
- next = LLVMBuildAdd(builder, state->counter, step, "");
-
- cond = LLVMBuildICmp(builder, LLVMIntNE, next, end, "");
-
- after_block = LLVMAppendBasicBlock(function, "");
-
- LLVMBuildCondBr(builder, cond, after_block, state->block);
+ struct lp_build_loop_state *state);
- LLVMAddIncoming(state->counter, &next, &block, 1);
- LLVMPositionBuilderAtEnd(builder, after_block);
-}
+#endif /* !LP_BLD_FLOW_H */
diff --git a/src/gallium/drivers/llvmpipe/lp_bld.h b/src/gallium/drivers/llvmpipe/lp_bld_format.h
similarity index 87%
rename from src/gallium/drivers/llvmpipe/lp_bld.h
rename to src/gallium/drivers/llvmpipe/lp_bld_format.h
index c2dea10..01c8a75 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld.h
+++ b/src/gallium/drivers/llvmpipe/lp_bld_format.h
@@ -98,25 +98,4 @@ lp_build_store_rgba(LLVMBuilderRef builder,
LLVMValueRef rgba);
-struct lp_build_loop_state
-{
- LLVMBasicBlockRef block;
- LLVMValueRef counter;
-};
-
-
-void
-lp_build_loop_begin(LLVMBuilderRef builder,
- LLVMValueRef start,
- struct lp_build_loop_state *state);
-
-
-void
-lp_build_loop_end(LLVMBuilderRef builder,
- LLVMValueRef end,
- LLVMValueRef step,
- struct lp_build_loop_state *state);
-
-
-
#endif /* !LP_BLD_H */
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_load.c b/src/gallium/drivers/llvmpipe/lp_bld_load.c
index b9734bd..27db7b2 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_load.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_load.c
@@ -28,7 +28,7 @@
#include "util/u_format.h"
-#include "lp_bld.h"
+#include "lp_bld_format.h"
LLVMValueRef
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_pack.c b/src/gallium/drivers/llvmpipe/lp_bld_pack.c
index f436f09..71261e4 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_pack.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_pack.c
@@ -28,7 +28,7 @@
#include "util/u_format.h"
-#include "lp_bld.h"
+#include "lp_bld_format.h"
LLVMValueRef
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_store.c b/src/gallium/drivers/llvmpipe/lp_bld_store.c
index 6273c9e..1da6dac 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_store.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_store.c
@@ -28,7 +28,7 @@
#include "util/u_format.h"
-#include "lp_bld.h"
+#include "lp_bld_format.h"
void
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_unpack.c b/src/gallium/drivers/llvmpipe/lp_bld_unpack.c
index 3545bdf..d70faac 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_unpack.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_unpack.c
@@ -28,7 +28,7 @@
#include "util/u_format.h"
-#include "lp_bld.h"
+#include "lp_bld_format.h"
LLVMValueRef
diff --git a/src/gallium/drivers/llvmpipe/lp_test_format.c b/src/gallium/drivers/llvmpipe/lp_test_format.c
index 3086bf8..1d19235 100644
--- a/src/gallium/drivers/llvmpipe/lp_test_format.c
+++ b/src/gallium/drivers/llvmpipe/lp_test_format.c
@@ -37,7 +37,8 @@
#include "util/u_format.h"
-#include "lp_bld.h"
+#include "lp_bld_flow.h"
+#include "lp_bld_format.h"
struct pixel_test_case
More information about the mesa-commit
mailing list