{
if (type.floating) {
switch(type.width) {
+ case 16:
+ return LLVMIntTypeInContext(gallivm->context, 16);
+ break;
case 32:
return LLVMFloatTypeInContext(gallivm->context);
break;
if (type.floating) {
switch(type.width) {
+ case 16:
+ if(elem_kind != LLVMIntegerTypeKind)
+ return FALSE;
+ break;
case 32:
if(elem_kind != LLVMFloatTypeKind)
return FALSE;
}
-/**
- * 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
*/
return "LLVMArrayTypeKind";
case LLVMPointerTypeKind:
return "LLVMPointerTypeKind";
-#if HAVE_LLVM < 0x0300
- case LLVMOpaqueTypeKind:
- return "LLVMOpaqueTypeKind";
-#endif
case LLVMVectorTypeKind:
return "LLVMVectorTypeKind";
case LLVMMetadataTypeKind:
return "LLVMMetadataTypeKind";
-#if HAVE_LLVM == 0x0207
- case LLVMUnionTypeKind:
- return "LLVMUnionTypeKind";
-#endif
default:
return "unknown LLVMTypeKind";
}
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;
+}