diff options
Diffstat (limited to 'src/gallium/drivers/llvmpipe/lp_bld_arit.c')
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_bld_arit.c | 112 |
1 files changed, 1 insertions, 111 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_arit.c b/src/gallium/drivers/llvmpipe/lp_bld_arit.c index db0db02c152..36b266a45a6 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_arit.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_arit.c @@ -47,120 +47,10 @@ #include "pipe/p_state.h" +#include "lp_bld_type.h" #include "lp_bld_arit.h" -LLVMTypeRef -lp_build_elem_type(union lp_type type) -{ - if (type.floating) { - assert(type.sign); - switch(type.width) { - case 32: - return LLVMFloatType(); - break; - case 64: - return LLVMDoubleType(); - break; - default: - assert(0); - return LLVMFloatType(); - } - } - else { - return LLVMIntType(type.width); - } -} - - -LLVMTypeRef -lp_build_vec_type(union lp_type type) -{ - LLVMTypeRef elem_type = lp_build_elem_type(type); - return LLVMVectorType(elem_type, type.length); -} - - -/** - * This function is a mirrot of lp_build_elem_type() above. - * - * XXX: I'm not sure if it wouldn't be easier/efficient to just recreate the - * type and check for identity. - */ -boolean -lp_check_elem_type(union lp_type type, LLVMTypeRef elem_type) -{ - LLVMTypeKind elem_kind; - - assert(elem_type); - if(!elem_type) - return FALSE; - - elem_kind = LLVMGetTypeKind(elem_type); - - if (type.floating) { - switch(type.width) { - case 32: - if(elem_kind != LLVMFloatTypeKind) - return FALSE; - break; - case 64: - if(elem_kind != LLVMDoubleTypeKind) - return FALSE; - break; - default: - assert(0); - return FALSE; - } - } - else { - if(elem_kind != LLVMIntegerTypeKind) - return FALSE; - - if(LLVMGetIntTypeWidth(elem_type) != type.width) - return FALSE; - } - - return TRUE; -} - - -boolean -lp_check_vec_type(union lp_type type, LLVMTypeRef vec_type) -{ - LLVMTypeRef elem_type; - - assert(vec_type); - if(!vec_type) - return FALSE; - - if(LLVMGetTypeKind(vec_type) != LLVMVectorTypeKind) - return FALSE; - - if(LLVMGetVectorSize(vec_type) != type.length) - return FALSE; - - elem_type = LLVMGetElementType(vec_type); - - return lp_check_elem_type(type, elem_type); -} - - -boolean -lp_check_value(union lp_type type, LLVMValueRef val) -{ - LLVMTypeRef vec_type; - - assert(val); - if(!val) - return FALSE; - - vec_type = LLVMTypeOf(val); - - return lp_check_vec_type(type, vec_type); -} - - LLVMValueRef lp_build_undef(union lp_type type) { |