From 03180dca7a3b5d57100158eb06d00419e55d9dc8 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sun, 23 Aug 2009 07:55:29 +0100 Subject: llvmpipe: Pre-declare fetch_texel. --- src/gallium/drivers/llvmpipe/lp_bld_intr.c | 49 ++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 13 deletions(-) (limited to 'src/gallium/drivers/llvmpipe/lp_bld_intr.c') diff --git a/src/gallium/drivers/llvmpipe/lp_bld_intr.c b/src/gallium/drivers/llvmpipe/lp_bld_intr.c index 42fd57fdf0..9895749d56 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_intr.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_intr.c @@ -49,6 +49,37 @@ #include "lp_bld_intr.h" +LLVMValueRef +lp_declare_intrinsic(LLVMModuleRef module, + const char *name, + LLVMTypeRef ret_type, + LLVMTypeRef *arg_types, + unsigned num_args) +{ + LLVMTypeRef function_type; + LLVMValueRef function; + + assert(!LLVMGetNamedFunction(module, name)); + + function_type = LLVMFunctionType(ret_type, arg_types, num_args, 0); + function = LLVMAddFunction(module, name, function_type); + + LLVMSetFunctionCallConv(function, LLVMCCallConv); + LLVMSetLinkage(function, LLVMExternalLinkage); + + assert(LLVMIsDeclaration(function)); + + if(name[0] == 'l' && + name[1] == 'l' && + name[2] == 'v' && + name[3] == 'm' && + name[4] == '.') + assert(LLVMGetIntrinsicID(function)); + + return function; +} + + LLVMValueRef lp_build_intrinsic(LLVMBuilderRef builder, const char *name, @@ -59,28 +90,20 @@ lp_build_intrinsic(LLVMBuilderRef builder, LLVMModuleRef module = LLVMGetGlobalParent(LLVMGetBasicBlockParent(LLVMGetInsertBlock(builder))); LLVMValueRef function; - assert(num_args <= LP_MAX_FUNC_ARGS); - function = LLVMGetNamedFunction(module, name); if(!function) { LLVMTypeRef arg_types[LP_MAX_FUNC_ARGS]; unsigned i; + + assert(num_args <= LP_MAX_FUNC_ARGS); + for(i = 0; i < num_args; ++i) { assert(args[i]); arg_types[i] = LLVMTypeOf(args[i]); } - function = LLVMAddFunction(module, name, LLVMFunctionType(ret_type, arg_types, num_args, 0)); - LLVMSetFunctionCallConv(function, LLVMCCallConv); - LLVMSetLinkage(function, LLVMExternalLinkage); - } - assert(LLVMIsDeclaration(function)); - if(name[0] == 'l' && - name[1] == 'l' && - name[2] == 'v' && - name[3] == 'm' && - name[4] == '.') - assert(LLVMGetIntrinsicID(function)); + function = lp_declare_intrinsic(module, name, ret_type, arg_types, num_args); + } return LLVMBuildCall(builder, function, args, num_args, ""); } -- cgit v1.2.3