freedreno/a3xx: fd3_util -> fd3_format
[mesa.git] / src / gallium / auxiliary / gallivm / lp_bld_type.c
index c5cf6d4a6c4f85480287f7750304996b3e18fbf4..5a8019990808c2c89559d5250394fbf177853163 100644 (file)
@@ -38,6 +38,9 @@ lp_build_elem_type(struct gallivm_state *gallivm, struct lp_type type)
 {
    if (type.floating) {
       switch(type.width) {
+      case 16:
+         return LLVMIntTypeInContext(gallivm->context, 16);
+         break;
       case 32:
          return LLVMFloatTypeInContext(gallivm->context);
          break;
@@ -85,6 +88,10 @@ lp_check_elem_type(struct lp_type type, LLVMTypeRef elem_type)
 
    if (type.floating) {
       switch(type.width) {
+      case 16:
+         if(elem_kind != LLVMIntegerTypeKind)
+            return FALSE;
+         break;
       case 32:
          if(elem_kind != LLVMFloatTypeKind)
             return FALSE;
@@ -167,27 +174,6 @@ lp_build_int_vec_type(struct gallivm_state *gallivm, struct lp_type type)
 }
 
 
-/**
- * Build int32[4] vector type
- */
-LLVMTypeRef
-lp_build_int32_vec4_type(struct gallivm_state *gallivm)
-{
-   struct lp_type t;
-   LLVMTypeRef type;
-
-   memset(&t, 0, sizeof(t));
-   t.floating = FALSE; /* floating point values */
-   t.sign = TRUE;      /* values are signed */
-   t.norm = FALSE;     /* values are not limited to [0,1] or [-1,1] */
-   t.width = 32;       /* 32-bit int */
-   t.length = 4;       /* 4 elements per vector */
-
-   type = lp_build_int_elem_type(gallivm, t);
-   return LLVMVectorType(type, t.length);
-}
-
-
 /**
  * Create element of vector type
  */
@@ -325,16 +311,10 @@ lp_typekind_name(LLVMTypeKind t)
       return "LLVMArrayTypeKind";
    case LLVMPointerTypeKind:
       return "LLVMPointerTypeKind";
-   case LLVMOpaqueTypeKind:
-      return "LLVMOpaqueTypeKind";
    case LLVMVectorTypeKind:
       return "LLVMVectorTypeKind";
    case LLVMMetadataTypeKind:
       return "LLVMMetadataTypeKind";
-   /* Only in LLVM 2.7 and later???
-   case LLVMUnionTypeKind:
-      return "LLVMUnionTypeKind";
-   */
    default:
       return "unknown LLVMTypeKind";
    }
@@ -409,3 +389,46 @@ lp_build_context_init(struct lp_build_context *bld,
    bld->zero = LLVMConstNull(bld->vec_type);
    bld->one = lp_build_one(gallivm, type);
 }
+
+
+/**
+ * Count the number of instructions in a function.
+ */
+static unsigned
+lp_build_count_instructions(LLVMValueRef function)
+{
+   unsigned num_instrs = 0;
+   LLVMBasicBlockRef block;
+
+   block = LLVMGetFirstBasicBlock(function);
+   while (block) {
+      LLVMValueRef instr;
+      instr = LLVMGetFirstInstruction(block);
+      while (instr) {
+         ++num_instrs;
+
+         instr = LLVMGetNextInstruction(instr);
+      }
+      block = LLVMGetNextBasicBlock(block);
+   }
+
+   return num_instrs;
+}
+
+
+/**
+ * Count the number of instructions in a module.
+ */
+unsigned
+lp_build_count_ir_module(LLVMModuleRef module)
+{
+   LLVMValueRef func;
+   unsigned num_instrs = 0;
+
+   func = LLVMGetFirstFunction(module);
+   while (func) {
+      num_instrs += lp_build_count_instructions(func);
+      func = LLVMGetNextFunction(func);
+   }
+   return num_instrs;
+}