Path: blob/21.2-virgl/src/gallium/auxiliary/gallivm/lp_bld_intr.h
4565 views
/**************************************************************************1*2* Copyright 2009 VMware, Inc.3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sub license, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial portions15* of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS18* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.20* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR21* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,22* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE23* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24*25**************************************************************************/2627/**28* @file29* Helper functions for calling intrinsics.30*31* @author Jose Fonseca <[email protected]>32*/333435#ifndef LP_BLD_INTR_H36#define LP_BLD_INTR_H3738#include <llvm/Config/llvm-config.h>3940#include "gallivm/lp_bld.h"41#include "gallivm/lp_bld_init.h"424344/**45* Max number of arguments in an intrinsic.46*/47#define LP_MAX_FUNC_ARGS 324849enum lp_func_attr {50LP_FUNC_ATTR_ALWAYSINLINE = (1 << 0),51LP_FUNC_ATTR_INREG = (1 << 2),52LP_FUNC_ATTR_NOALIAS = (1 << 3),53LP_FUNC_ATTR_NOUNWIND = (1 << 4),54LP_FUNC_ATTR_READNONE = (1 << 5),55LP_FUNC_ATTR_READONLY = (1 << 6),56LP_FUNC_ATTR_WRITEONLY = LLVM_VERSION_MAJOR >= 4 ? (1 << 7) : 0,57LP_FUNC_ATTR_INACCESSIBLE_MEM_ONLY = LLVM_VERSION_MAJOR >= 4 ? (1 << 8) : 0,58LP_FUNC_ATTR_CONVERGENT = LLVM_VERSION_MAJOR >= 4 ? (1 << 9) : 0,5960/* Legacy intrinsic that needs attributes on function declarations61* and they must match the internal LLVM definition exactly, otherwise62* intrinsic selection fails.63*/64LP_FUNC_ATTR_LEGACY = (1u << 31),65};6667void68lp_format_intrinsic(char *name,69size_t size,70const char *name_root,71LLVMTypeRef type);7273LLVMValueRef74lp_declare_intrinsic(LLVMModuleRef module,75const char *name,76LLVMTypeRef ret_type,77LLVMTypeRef *arg_types,78unsigned num_args);7980void81lp_add_function_attr(LLVMValueRef function_or_call,82int attr_idx, enum lp_func_attr attr);8384LLVMValueRef85lp_build_intrinsic(LLVMBuilderRef builder,86const char *name,87LLVMTypeRef ret_type,88LLVMValueRef *args,89unsigned num_args,90unsigned attr_mask);919293LLVMValueRef94lp_build_intrinsic_unary(LLVMBuilderRef builder,95const char *name,96LLVMTypeRef ret_type,97LLVMValueRef a);9899100LLVMValueRef101lp_build_intrinsic_binary(LLVMBuilderRef builder,102const char *name,103LLVMTypeRef ret_type,104LLVMValueRef a,105LLVMValueRef b);106107108LLVMValueRef109lp_build_intrinsic_binary_anylength(struct gallivm_state *gallivm,110const char *name,111struct lp_type src_type,112unsigned intr_size,113LLVMValueRef a,114LLVMValueRef b);115116117LLVMValueRef118lp_build_intrinsic_map(struct gallivm_state *gallivm,119const char *name,120LLVMTypeRef ret_type,121LLVMValueRef *args,122unsigned num_args);123124125LLVMValueRef126lp_build_intrinsic_map_unary(struct gallivm_state *gallivm,127const char *name,128LLVMTypeRef ret_type,129LLVMValueRef a);130131132LLVMValueRef133lp_build_intrinsic_map_binary(struct gallivm_state *gallivm,134const char *name,135LLVMTypeRef ret_type,136LLVMValueRef a,137LLVMValueRef b);138139140#endif /* !LP_BLD_INTR_H */141142143