1 /**************************************************************************
3 * Copyright 2009 VMware, Inc.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
26 **************************************************************************/
30 * Convenient representation of SIMD types.
32 * @author Jose Fonseca <jfonseca@vmware.com>
40 #include <llvm-c/Core.h>
42 #include <pipe/p_compiler.h>
46 * Several functions can only cope with vectors of length up to this value.
47 * You may need to increase that value if you want to represent bigger vectors.
49 #define LP_MAX_VECTOR_LENGTH 16
53 * The LLVM type system can't conveniently express all the things we care about
54 * on the types used for intermediate computations, such as signed vs unsigned,
55 * normalized values, or fixed point.
60 * Floating-point. Cannot be used with fixed. Integer numbers are
61 * represented by this zero.
66 * Fixed-point. Cannot be used with floating. Integer numbers are
67 * represented by this zero.
72 * Whether it can represent negative values or not.
74 * Floating point values should always have this bit set.
79 * Whether values are normalized to fit [0, 1] interval, or [-1, 1]
80 * interval for signed types.
82 * For integer types it means the representable integer range should be
83 * interpreted as the interval above.
85 * For floating and fixed point formats it means the values should be
86 * clamped to the interval above.
93 * For fixed point values, the fixed point is assumed to be at half the
101 * width*length should be a power of two greater or equal to eight.
103 * @sa LP_MAX_VECTOR_LENGTH
112 * We need most of the information here in order to correctly and efficiently
113 * translate an arithmetic operation into LLVM IR. Putting it here avoids the
114 * trouble of passing it as parameters.
116 struct lp_build_context
118 LLVMBuilderRef builder
;
121 * This not only describes the input/output LLVM types, but also whether
122 * to normalize/clamp the results.
126 /** Same as lp_build_undef(type) */
129 /** Same as lp_build_zero(type) */
132 /** Same as lp_build_one(type) */
138 lp_build_elem_type(union lp_type type
);
142 lp_build_vec_type(union lp_type type
);
146 lp_check_elem_type(union lp_type type
, LLVMTypeRef elem_type
);
150 lp_check_vec_type(union lp_type type
, LLVMTypeRef vec_type
);
154 lp_check_value(union lp_type type
, LLVMValueRef val
);
157 #endif /* !LP_BLD_TYPE_H */