lp_bld_const.h revision b0636f78aa63aed2a68e86e7770c2a91c80bbb80
1/************************************************************************** 2 * 3 * Copyright 2009 VMware, Inc. 4 * All Rights Reserved. 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 * copy of this software and associated documentation files (the 8 * "Software"), to deal in the Software without restriction, including 9 * without limitation the rights to use, copy, modify, merge, publish, 10 * distribute, sub license, and/or sell copies of the Software, and to 11 * permit persons to whom the Software is furnished to do so, subject to 12 * the following conditions: 13 * 14 * The above copyright notice and this permission notice (including the 15 * next paragraph) shall be included in all copies or substantial portions 16 * of the Software. 17 * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 * 26 **************************************************************************/ 27 28/** 29 * @file 30 * Helper functions for constant building. 31 * 32 * @author Jose Fonseca <jfonseca@vmware.com> 33 */ 34 35 36#ifndef LP_BLD_CONST_H 37#define LP_BLD_CONST_H 38 39 40#include "pipe/p_compiler.h" 41#include "gallivm/lp_bld.h" 42 43 44 45struct lp_type; 46 47 48unsigned 49lp_mantissa(struct lp_type type); 50 51 52unsigned 53lp_const_shift(struct lp_type type); 54 55 56unsigned 57lp_const_offset(struct lp_type type); 58 59 60double 61lp_const_scale(struct lp_type type); 62 63double 64lp_const_min(struct lp_type type); 65 66 67double 68lp_const_max(struct lp_type type); 69 70 71double 72lp_const_eps(struct lp_type type); 73 74 75LLVMValueRef 76lp_build_undef(struct lp_type type); 77 78 79LLVMValueRef 80lp_build_zero(struct lp_type type); 81 82 83LLVMValueRef 84lp_build_one(struct lp_type type); 85 86 87LLVMValueRef 88lp_build_const_elem(struct lp_type type, 89 double val); 90 91LLVMValueRef 92lp_build_const_vec(struct lp_type type, double val); 93 94 95LLVMValueRef 96lp_build_const_int_vec(struct lp_type type, long long val); 97 98 99LLVMValueRef 100lp_build_const_aos(struct lp_type type, 101 double r, double g, double b, double a, 102 const unsigned char *swizzle); 103 104 105LLVMValueRef 106lp_build_const_mask_aos(struct lp_type type, 107 const boolean cond[4]); 108 109 110static INLINE LLVMValueRef 111lp_build_const_int32(int i) 112{ 113 return LLVMConstInt(LLVMInt32Type(), i, 0); 114} 115 116 117 118#endif /* !LP_BLD_CONST_H */ 119