1f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/************************************************************************** 2f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 3f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Copyright 2009 VMware, Inc. 4f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * All Rights Reserved. 5f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 6f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Permission is hereby granted, free of charge, to any person obtaining a 7f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * copy of this software and associated documentation files (the 8f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * "Software"), to deal in the Software without restriction, including 9f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * without limitation the rights to use, copy, modify, merge, publish, 10f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * distribute, sub license, and/or sell copies of the Software, and to 11f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * permit persons to whom the Software is furnished to do so, subject to 12f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the following conditions: 13f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 14f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The above copyright notice and this permission notice (including the 15f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * next paragraph) shall be included in all copies or substantial portions 16f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * of the Software. 17f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 18f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 22f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 26f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org **************************************************************************/ 27f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 28f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 29f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * @file 30f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Convenient representation of SIMD types. 31f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 32f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * @author Jose Fonseca <jfonseca@vmware.com> 33f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 34f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 35f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 36f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#ifndef LP_BLD_TYPE_H 37f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define LP_BLD_TYPE_H 38f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 39f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 40f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "pipe/p_compiler.h" 41f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "gallivm/lp_bld.h" 42f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 43f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 44f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Native SIMD architecture width available at runtime. 45f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 46f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Using this width should give the best performance, 47f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * and it determines the necessary alignment of vector variables. 48f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 49f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgextern unsigned lp_native_vector_width; 50f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 51f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 52f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Maximum supported vector width (not necessarily supported at run-time). 53f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 54f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Should only be used when lp_native_vector_width isn't available, 55f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * i.e. sizing/alignment of non-malloced variables. 56f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 57f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define LP_MAX_VECTOR_WIDTH 256 58f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 59f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 60f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Minimum vector alignment for static variable alignment 61f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 62f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * It should always be a constant equal to LP_MAX_VECTOR_WIDTH/8. An 63f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * expression is non-portable. 64f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 65f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define LP_MIN_VECTOR_ALIGN 32 66f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 67f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 68f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Several functions can only cope with vectors of length up to this value. 69f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * You may need to increase that value if you want to represent bigger vectors. 70f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 71f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define LP_MAX_VECTOR_LENGTH (LP_MAX_VECTOR_WIDTH/8) 72f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 73f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 74f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The LLVM type system can't conveniently express all the things we care about 75f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * on the types used for intermediate computations, such as signed vs unsigned, 76f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * normalized values, or fixed point. 77f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 78f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct lp_type { 79f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /** 80f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Floating-point. Cannot be used with fixed. Integer numbers are 81f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * represented by this zero. 82f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 83f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned floating:1; 84f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 85f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /** 86f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Fixed-point. Cannot be used with floating. Integer numbers are 87f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * represented by this zero. 88f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 89f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned fixed:1; 90f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 91f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /** 92f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Whether it can represent negative values or not. 93f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 94f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * If this is not set for floating point, it means that all values are 95f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * assumed to be positive. 96f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 97f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned sign:1; 98f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 99f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /** 100f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Whether values are normalized to fit [0, 1] interval, or [-1, 1] 101f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * interval for signed types. 102f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 103f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * For integer types it means the representable integer range should be 104f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * interpreted as the interval above. 105f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 106f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * For floating and fixed point formats it means the values should be 107f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * clamped to the interval above. 108f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 109f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned norm:1; 110f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 111f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /** 112f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Element width. 113f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 114f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * For fixed point values, the fixed point is assumed to be at half the 115f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * width. 116f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 117f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned width:14; 118f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 119f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /** 120f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Vector length. If length==1, this is a scalar (float/int) type. 121f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 122f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * width*length should be a power of two greater or equal to eight. 123f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 124f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * @sa LP_MAX_VECTOR_LENGTH 125f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 126f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned length:14; 127f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 128f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 129f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 130f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 131f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * We need most of the information here in order to correctly and efficiently 132f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * translate an arithmetic operation into LLVM IR. Putting it here avoids the 133f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * trouble of passing it as parameters. 134f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 135f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct lp_build_context 136f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 137f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gallivm_state *gallivm; 138f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 139f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /** 140f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * This not only describes the input/output LLVM types, but also whether 141f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * to normalize/clamp the results. 142f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 143f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_type type; 144f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 145f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /** Same as lp_build_elem_type(type) */ 146f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMTypeRef elem_type; 147f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 148f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /** Same as lp_build_vec_type(type) */ 149f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMTypeRef vec_type; 150f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 151f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /** Same as lp_build_int_elem_type(type) */ 152f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMTypeRef int_elem_type; 153f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 154f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /** Same as lp_build_int_vec_type(type) */ 155f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMTypeRef int_vec_type; 156f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 157f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /** Same as lp_build_undef(type) */ 158f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef undef; 159f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 160f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /** Same as lp_build_zero(type) */ 161f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef zero; 162f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 163f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /** Same as lp_build_one(type) */ 164f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef one; 165f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 166f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 167f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 168f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE unsigned 169f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_type_width(struct lp_type type) 170f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 171f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return type.width * type.length; 172f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 173f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 174f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 175f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** Create scalar float type */ 176f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE struct lp_type 177f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_type_float(unsigned width) 178f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 179f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_type res_type; 180f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 181f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org memset(&res_type, 0, sizeof res_type); 182f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org res_type.floating = TRUE; 183f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org res_type.sign = TRUE; 184f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org res_type.width = width; 185f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org res_type.length = 1; 186f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 187f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return res_type; 188f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 189f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 190f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 191f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** Create vector of float type */ 192f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE struct lp_type 193f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_type_float_vec(unsigned width, unsigned total_width) 194f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 195f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_type res_type; 196f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 197f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org memset(&res_type, 0, sizeof res_type); 198f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org res_type.floating = TRUE; 199f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org res_type.sign = TRUE; 200f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org res_type.width = width; 201f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org res_type.length = total_width / width; 202f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 203f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return res_type; 204f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 205f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 206f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 207f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** Create scalar int type */ 208f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE struct lp_type 209f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_type_int(unsigned width) 210f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 211f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_type res_type; 212f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 213f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org memset(&res_type, 0, sizeof res_type); 214f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org res_type.sign = TRUE; 215f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org res_type.width = width; 216f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org res_type.length = 1; 217f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 218f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return res_type; 219f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 220f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 221f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 222f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** Create vector int type */ 223f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE struct lp_type 224f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_type_int_vec(unsigned width, unsigned total_width) 225f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 226f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_type res_type; 227f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 228f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org memset(&res_type, 0, sizeof res_type); 229f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org res_type.sign = TRUE; 230f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org res_type.width = width; 231f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org res_type.length = total_width / width; 232f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 233f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return res_type; 234f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 235f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 236f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 237f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** Create scalar uint type */ 238f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE struct lp_type 239f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_type_uint(unsigned width) 240f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 241f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_type res_type; 242f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 243f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org memset(&res_type, 0, sizeof res_type); 244f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org res_type.width = width; 245f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org res_type.length = 1; 246f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 247f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return res_type; 248f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 249f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 250f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 251f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** Create vector uint type */ 252f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE struct lp_type 253f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_type_uint_vec(unsigned width, unsigned total_width) 254f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 255f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_type res_type; 256f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 257f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org memset(&res_type, 0, sizeof res_type); 258f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org res_type.width = width; 259f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org res_type.length = total_width / width; 260f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 261f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return res_type; 262f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 263f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 264f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 265f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE struct lp_type 266f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_type_unorm(unsigned width, unsigned total_width) 267f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 268f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_type res_type; 269f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 270f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org memset(&res_type, 0, sizeof res_type); 271f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org res_type.norm = TRUE; 272f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org res_type.width = width; 273f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org res_type.length = total_width / width; 274f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 275f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return res_type; 276f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 277f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 278f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 279f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE struct lp_type 280f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_type_fixed(unsigned width, unsigned total_width) 281f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 282f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_type res_type; 283f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 284f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org memset(&res_type, 0, sizeof res_type); 285f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org res_type.sign = TRUE; 286f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org res_type.fixed = TRUE; 287f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org res_type.width = width; 288f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org res_type.length = total_width / width; 289f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 290f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return res_type; 291f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 292f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 293f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 294f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE struct lp_type 295f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_type_ufixed(unsigned width, unsigned total_width) 296f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 297f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_type res_type; 298f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 299f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org memset(&res_type, 0, sizeof res_type); 300f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org res_type.fixed = TRUE; 301f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org res_type.width = width; 302f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org res_type.length = total_width / width; 303f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 304f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return res_type; 305f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 306f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 307f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 308f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgLLVMTypeRef 309f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_build_elem_type(struct gallivm_state *gallivm, struct lp_type type); 310f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 311f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 312f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgLLVMTypeRef 313f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_build_vec_type(struct gallivm_state *gallivm, struct lp_type type); 314f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 315f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 316f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgboolean 317f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_check_elem_type(struct lp_type type, LLVMTypeRef elem_type); 318f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 319f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 320f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgboolean 321f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_check_vec_type(struct lp_type type, LLVMTypeRef vec_type); 322f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 323f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 324f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgboolean 325f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_check_value(struct lp_type type, LLVMValueRef val); 326f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 327f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 328f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgLLVMTypeRef 329f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_build_int_elem_type(struct gallivm_state *gallivm, struct lp_type type); 330f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 331f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 332f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgLLVMTypeRef 333f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_build_int_vec_type(struct gallivm_state *gallivm, struct lp_type type); 334f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 335f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 336f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE struct lp_type 337f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_float32_vec4_type(void) 338f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 339f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_type type; 340f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 341f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org memset(&type, 0, sizeof(type)); 342f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org type.floating = TRUE; 343f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org type.sign = TRUE; 344f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org type.norm = FALSE; 345f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org type.width = 32; 346f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org type.length = 4; 347f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 348f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return type; 349f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 350f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 351f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 352f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE struct lp_type 353f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_int32_vec4_type(void) 354f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 355f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_type type; 356f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 357f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org memset(&type, 0, sizeof(type)); 358f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org type.floating = FALSE; 359f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org type.sign = TRUE; 360f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org type.norm = FALSE; 361f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org type.width = 32; 362f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org type.length = 4; 363f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 364f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return type; 365f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 366f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 367f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 368f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE struct lp_type 369f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_unorm8_vec4_type(void) 370f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 371f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_type type; 372f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 373f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org memset(&type, 0, sizeof(type)); 374f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org type.floating = FALSE; 375f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org type.sign = FALSE; 376f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org type.norm = TRUE; 377f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org type.width = 8; 378f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org type.length = 4; 379f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 380f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return type; 381f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 382f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 383f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 384f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct lp_type 385f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_elem_type(struct lp_type type); 386f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 387f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 388f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct lp_type 389f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_uint_type(struct lp_type type); 390f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 391f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 392f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct lp_type 393f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_int_type(struct lp_type type); 394f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 395f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 396f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct lp_type 397f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_wider_type(struct lp_type type); 398f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 399f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 400f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgunsigned 401f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_sizeof_llvm_type(LLVMTypeRef t); 402f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 403f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 404f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgconst char * 405f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_typekind_name(LLVMTypeKind t); 406f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 407f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 408f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid 409f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_dump_llvmtype(LLVMTypeRef t); 410f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 411f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 412f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid 413f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_build_context_init(struct lp_build_context *bld, 414f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gallivm_state *gallivm, 415f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_type type); 416f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 417f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 418f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgunsigned 419f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_build_count_instructions(LLVMValueRef function); 420f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 421f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 422f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#endif /* !LP_BLD_TYPE_H */ 423