diff options
author | José Fonseca <[email protected]> | 2010-12-17 20:08:35 +0000 |
---|---|---|
committer | José Fonseca <[email protected]> | 2010-12-17 20:14:31 +0000 |
commit | 3f94d96fce244bbe8a9edc15758729ce0e604ae2 (patch) | |
tree | 4edbe784279c76fabb761c592ff3b91b34c9dcdf /src/gallium/auxiliary/gallivm | |
parent | 5c229e5fbd8ffa573ab2c1225f182036792a75af (diff) |
gallivm: Cleanup util_format_xxx_fetch_xxx call generation.
No need to register function prototypes in the module now that we call
the C function pointer directly -- less LLVM objects lying around.
Limited testing with lp_test_format.
Diffstat (limited to 'src/gallium/auxiliary/gallivm')
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_format_aos.c | 71 |
1 files changed, 24 insertions, 47 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c b/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c index 8a4261fb05b..82ab19eda14 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c @@ -512,8 +512,6 @@ lp_build_fetch_rgba_aos(struct gallivm_state *gallivm, * or incentive to optimize. */ - LLVMModuleRef module = LLVMGetGlobalParent(LLVMGetBasicBlockParent(LLVMGetInsertBlock(gallivm->builder))); - char name[256]; LLVMTypeRef i8t = LLVMInt8TypeInContext(gallivm->context); LLVMTypeRef pi8t = LLVMPointerType(i8t, 0); LLVMTypeRef i32t = LLVMInt32TypeInContext(gallivm->context); @@ -521,22 +519,18 @@ lp_build_fetch_rgba_aos(struct gallivm_state *gallivm, LLVMValueRef tmp_ptr; LLVMValueRef tmp; LLVMValueRef res; - LLVMValueRef callee; unsigned k; - util_snprintf(name, sizeof name, "util_format_%s_fetch_rgba_8unorm", - format_desc->short_name); - if (gallivm_debug & GALLIVM_DEBUG_PERF) { - debug_printf("%s: falling back to %s\n", __FUNCTION__, name); + debug_printf("%s: falling back to util_format_%s_fetch_rgba_8unorm\n", + __FUNCTION__, format_desc->short_name); } /* * Declare and bind format_desc->fetch_rgba_8unorm(). */ - function = LLVMGetNamedFunction(module, name); - if (!function) { + { /* * Function to call looks like: * fetch(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j) @@ -552,22 +546,17 @@ lp_build_fetch_rgba_aos(struct gallivm_state *gallivm, arg_types[3] = i32t; function_type = LLVMFunctionType(ret_type, arg_types, Elements(arg_types), 0); - function = LLVMAddFunction(module, name, function_type); - LLVMSetFunctionCallConv(function, LLVMCCallConv); - LLVMSetLinkage(function, LLVMExternalLinkage); + /* make const pointer for the C fetch_rgba_8unorm function */ + function = lp_build_const_int_pointer(gallivm, + func_to_pointer((func_pointer) format_desc->fetch_rgba_8unorm)); - assert(LLVMIsDeclaration(function)); + /* cast the callee pointer to the function's type */ + function = LLVMBuildBitCast(builder, function, + LLVMPointerType(function_type, 0), + "cast callee"); } - /* make const pointer for the C fetch_rgba_float function */ - callee = lp_build_const_int_pointer(gallivm, - func_to_pointer((func_pointer) format_desc->fetch_rgba_8unorm)); - - /* cast the callee pointer to the function's type */ - function = LLVMBuildBitCast(builder, callee, - LLVMTypeOf(function), "cast callee"); - tmp_ptr = lp_build_alloca(gallivm, i32t, ""); res = LLVMGetUndef(LLVMVectorType(i32t, num_pixels)); @@ -627,8 +616,6 @@ lp_build_fetch_rgba_aos(struct gallivm_state *gallivm, * or incentive to optimize. */ - LLVMModuleRef module = LLVMGetGlobalParent(LLVMGetBasicBlockParent(LLVMGetInsertBlock(builder))); - char name[256]; LLVMTypeRef f32t = LLVMFloatTypeInContext(gallivm->context); LLVMTypeRef f32x4t = LLVMVectorType(f32t, 4); LLVMTypeRef pf32t = LLVMPointerType(f32t, 0); @@ -638,22 +625,18 @@ lp_build_fetch_rgba_aos(struct gallivm_state *gallivm, LLVMValueRef tmp_ptr; LLVMValueRef tmps[LP_MAX_VECTOR_LENGTH/4]; LLVMValueRef res; - LLVMValueRef callee; unsigned k; - util_snprintf(name, sizeof name, "util_format_%s_fetch_rgba_float", - format_desc->short_name); - if (gallivm_debug & GALLIVM_DEBUG_PERF) { - debug_printf("%s: falling back to %s\n", __FUNCTION__, name); + debug_printf("%s: falling back to util_format_%s_fetch_rgba_float\n", + __FUNCTION__, format_desc->short_name); } /* * Declare and bind format_desc->fetch_rgba_float(). */ - function = LLVMGetNamedFunction(module, name); - if (!function) { + { /* * Function to call looks like: * fetch(float *dst, const uint8_t *src, unsigned i, unsigned j) @@ -669,26 +652,20 @@ lp_build_fetch_rgba_aos(struct gallivm_state *gallivm, arg_types[3] = i32t; function_type = LLVMFunctionType(ret_type, arg_types, Elements(arg_types), 0); - function = LLVMAddFunction(module, name, function_type); - - LLVMSetFunctionCallConv(function, LLVMCCallConv); - LLVMSetLinkage(function, LLVMExternalLinkage); - assert(LLVMIsDeclaration(function)); - } - - /* Note: we're using this casting here instead of LLVMAddGlobalMapping() - * to work around a bug in LLVM 2.6. - */ - - /* make const pointer for the C fetch_rgba_float function */ - callee = lp_build_const_int_pointer(gallivm, - func_to_pointer((func_pointer) format_desc->fetch_rgba_float)); + /* Note: we're using this casting here instead of LLVMAddGlobalMapping() + * to work around a bug in LLVM 2.6, and for efficiency/simplicity. + */ - /* cast the callee pointer to the function's type */ - function = LLVMBuildBitCast(builder, callee, - LLVMTypeOf(function), "cast callee"); + /* make const pointer for the C fetch_rgba_float function */ + function = lp_build_const_int_pointer(gallivm, + func_to_pointer((func_pointer) format_desc->fetch_rgba_float)); + /* cast the callee pointer to the function's type */ + function = LLVMBuildBitCast(builder, function, + LLVMPointerType(function_type, 0), + "cast callee"); + } tmp_ptr = lp_build_alloca(gallivm, f32x4t, ""); |