gallivm: Setup a global optimization pass.
[mesa.git] / src / gallium / auxiliary / gallivm / lp_bld_type.h
index 62ee05be4df932a63b6859e2c0ce9b4494df4116..df77ef2155130cd3341cbcf4fe10f29e646fe977 100644 (file)
@@ -37,9 +37,9 @@
 #define LP_BLD_TYPE_H
 
 
-#include <llvm-c/Core.h>  
+#include "pipe/p_compiler.h"
+#include "gallivm/lp_bld.h"
 
-#include <pipe/p_compiler.h>
 
 
 /**
@@ -103,7 +103,7 @@ struct lp_type {
    unsigned width:14;
 
    /**
-    * Vector length.
+    * Vector length.  If length==1, this is a scalar (float/int) type.
     *
     * width*length should be a power of two greater or equal to eight.
     *
@@ -128,6 +128,18 @@ struct lp_build_context
     */
    struct lp_type type;
 
+   /** Same as lp_build_undef(type) */
+   LLVMTypeRef elem_type;
+
+   /** Same as lp_build_undef(type) */
+   LLVMTypeRef vec_type;
+
+   /** Same as lp_build_undef(type) */
+   LLVMTypeRef int_elem_type;
+
+   /** Same as lp_build_undef(type) */
+   LLVMTypeRef int_vec_type;
+
    /** Same as lp_build_undef(type) */
    LLVMValueRef undef;
 
@@ -139,11 +151,28 @@ struct lp_build_context
 };
 
 
+/** Create scalar float type */
 static INLINE struct lp_type
 lp_type_float(unsigned width)
 {
    struct lp_type res_type;
 
+   memset(&res_type, 0, sizeof res_type);
+   res_type.floating = TRUE;
+   res_type.sign = TRUE;
+   res_type.width = width;
+   res_type.length = 1;
+
+   return res_type;
+}
+
+
+/** Create vector of float type */
+static INLINE struct lp_type
+lp_type_float_vec(unsigned width)
+{
+   struct lp_type res_type;
+
    memset(&res_type, 0, sizeof res_type);
    res_type.floating = TRUE;
    res_type.sign = TRUE;
@@ -154,11 +183,27 @@ lp_type_float(unsigned width)
 }
 
 
+/** Create scalar int type */
 static INLINE struct lp_type
 lp_type_int(unsigned width)
 {
    struct lp_type res_type;
 
+   memset(&res_type, 0, sizeof res_type);
+   res_type.sign = TRUE;
+   res_type.width = width;
+   res_type.length = 1;
+
+   return res_type;
+}
+
+
+/** Create vector int type */
+static INLINE struct lp_type
+lp_type_int_vec(unsigned width)
+{
+   struct lp_type res_type;
+
    memset(&res_type, 0, sizeof res_type);
    res_type.sign = TRUE;
    res_type.width = width;
@@ -168,11 +213,26 @@ lp_type_int(unsigned width)
 }
 
 
+/** Create scalar uint type */
 static INLINE struct lp_type
 lp_type_uint(unsigned width)
 {
    struct lp_type res_type;
 
+   memset(&res_type, 0, sizeof res_type);
+   res_type.width = width;
+   res_type.length = 1;
+
+   return res_type;
+}
+
+
+/** Create vector uint type */
+static INLINE struct lp_type
+lp_type_uint_vec(unsigned width)
+{
+   struct lp_type res_type;
+
    memset(&res_type, 0, sizeof res_type);
    res_type.width = width;
    res_type.length = LP_NATIVE_VECTOR_WIDTH / width;
@@ -256,6 +316,10 @@ LLVMTypeRef
 lp_build_int32_vec4_type(void);
 
 
+struct lp_type
+lp_uint_type(struct lp_type type);
+
+
 struct lp_type
 lp_int_type(struct lp_type type);
 
@@ -264,6 +328,18 @@ struct lp_type
 lp_wider_type(struct lp_type type);
 
 
+unsigned
+lp_sizeof_llvm_type(LLVMTypeRef t);
+
+
+const char *
+lp_typekind_name(LLVMTypeKind t);
+
+
+void
+lp_dump_llvmtype(LLVMTypeRef t);
+
+
 void
 lp_build_context_init(struct lp_build_context *bld,
                       LLVMBuilderRef builder,