gallivm: added aligned pointer get/set
[mesa.git] / src / gallium / auxiliary / gallivm / lp_bld_struct.h
index eb87a8eee9ee40a24fbf74d1c2f695be4f669eeb..6b7b4f2a6bf7d6949b0f001da9412fec27025ed0 100644 (file)
@@ -38,7 +38,7 @@
 
 
 #include "gallivm/lp_bld.h"
-#include <llvm-c/Target.h>
+#include "gallivm/lp_bld_init.h"
 
 #include "util/u_debug.h"
 #include "util/u_memory.h"
@@ -57,7 +57,7 @@
  * Get value pointer to a structure member.
  */
 LLVMValueRef
-lp_build_struct_get_ptr(LLVMBuilderRef builder,
+lp_build_struct_get_ptr(struct gallivm_state *gallivm,
                         LLVMValueRef ptr,
                         unsigned member,
                         const char *name);
@@ -66,7 +66,7 @@ lp_build_struct_get_ptr(LLVMBuilderRef builder,
  * Get the value of a structure member.
  */
 LLVMValueRef
-lp_build_struct_get(LLVMBuilderRef builder,
+lp_build_struct_get(struct gallivm_state *gallivm,
                     LLVMValueRef ptr,
                     unsigned member,
                     const char *name);
@@ -75,7 +75,7 @@ lp_build_struct_get(LLVMBuilderRef builder,
  * Get value pointer to an array element.
  */
 LLVMValueRef
-lp_build_array_get_ptr(LLVMBuilderRef builder,
+lp_build_array_get_ptr(struct gallivm_state *gallivm,
                        LLVMValueRef ptr,
                        LLVMValueRef index);
 
@@ -83,7 +83,7 @@ lp_build_array_get_ptr(LLVMBuilderRef builder,
  * Get the value of an array element.
  */
 LLVMValueRef
-lp_build_array_get(LLVMBuilderRef builder,
+lp_build_array_get(struct gallivm_state *gallivm,
                    LLVMValueRef ptr,
                    LLVMValueRef index);
 
@@ -91,7 +91,7 @@ lp_build_array_get(LLVMBuilderRef builder,
  * Set the value of an array element.
  */
 void
-lp_build_array_set(LLVMBuilderRef builder,
+lp_build_array_set(struct gallivm_state *gallivm,
                    LLVMValueRef ptr,
                    LLVMValueRef index,
                    LLVMValueRef value);
@@ -104,6 +104,18 @@ lp_build_pointer_get(LLVMBuilderRef builder,
                    LLVMValueRef ptr,
                    LLVMValueRef index);
 
+/**
+ * Get the value of an array element, with explicit alignment.
+ *
+ * If the element size is different from the alignment this will
+ * cause llvm to emit an unaligned load
+ */
+LLVMValueRef
+lp_build_pointer_get_unaligned(LLVMBuilderRef builder,
+                               LLVMValueRef ptr,
+                               LLVMValueRef index,
+                               unsigned alignment);
+
 /**
  * Set the value of an array element.
  */
@@ -113,4 +125,17 @@ lp_build_pointer_set(LLVMBuilderRef builder,
                      LLVMValueRef index,
                      LLVMValueRef value);
 
+/**
+ * Set the value of an array element, with explicit alignment.
+ *
+ * If the element size is different from the alignment this will
+ * cause llvm to emit an unaligned store
+ */
+void
+lp_build_pointer_set_unaligned(LLVMBuilderRef builder,
+                               LLVMValueRef ptr,
+                               LLVMValueRef index,
+                               LLVMValueRef value,
+                               unsigned alignment);
+
 #endif /* !LP_BLD_STRUCT_H */