r600g: add POW instruction
[mesa.git] / src / mesa / slang / slang_storage.h
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.5
4 *
5 * Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25 #ifndef SLANG_STORAGE_H
26 #define SLANG_STORAGE_H
27
28 #include "main/glheader.h"
29 #include "slang_compile_function.h"
30 #include "slang_compile_struct.h"
31 #include "slang_compile_variable.h"
32 #include "slang_typeinfo.h"
33 #include "slang_utility.h"
34
35
36 /*
37 * Program variable data storage is kept completely transparent to the
38 * front-end compiler. It is up to the back-end how the data is
39 * actually allocated. The slang_storage_type enum provides the basic
40 * information about how the memory is interpreted. This abstract
41 * piece of memory is called a data slot. A data slot of a particular
42 * type has a fixed size.
43 *
44 * For now, only the three basic types are supported, that is bool,
45 * int and float. Other built-in types like vector or matrix can
46 * easily be decomposed into a series of basic types.
47 *
48 * If the vec4 module is enabled, 4-component vectors of floats are
49 * used when possible. 4x4 matrices are constructed of 4 vec4 slots.
50 */
51 typedef enum slang_storage_type_
52 {
53 /* core */
54 SLANG_STORE_AGGREGATE,
55 SLANG_STORE_BOOL,
56 SLANG_STORE_INT,
57 SLANG_STORE_FLOAT,
58 /* vec4 */
59 SLANG_STORE_VEC4
60 } slang_storage_type;
61
62
63 /**
64 * The slang_storage_array structure groups data slots of the same
65 * type into an array. This array has a fixed length. Arrays are
66 * required to have a size equal to the sum of sizes of its
67 * elements. They are also required to support indirect
68 * addressing. That is, if B references first data slot in the array,
69 * S is the size of the data slot and I is the integral index that is
70 * not known at compile time, B+I*S references I-th data slot.
71 *
72 * This structure is also used to break down built-in data types that
73 * are not supported directly. Vectors, like vec3, are constructed
74 * from arrays of their basic types. Matrices are formed of an array
75 * of column vectors, which are in turn processed as other vectors.
76 */
77 typedef struct slang_storage_array_
78 {
79 slang_storage_type type;
80 struct slang_storage_aggregate_ *aggregate;
81 GLuint length;
82 } slang_storage_array;
83
84 GLboolean slang_storage_array_construct (slang_storage_array *);
85 GLvoid slang_storage_array_destruct (slang_storage_array *);
86
87
88 /**
89 * The slang_storage_aggregate structure relaxes the indirect
90 * addressing requirement for slang_storage_array
91 * structure. Aggregates are always accessed statically - its member
92 * addresses are well-known at compile time. For example, user-defined
93 * types are implemented as aggregates. Aggregates can collect data of
94 * a different type.
95 */
96 typedef struct slang_storage_aggregate_
97 {
98 slang_storage_array *arrays;
99 GLuint count;
100 } slang_storage_aggregate;
101
102 GLboolean slang_storage_aggregate_construct (slang_storage_aggregate *);
103 GLvoid slang_storage_aggregate_destruct (slang_storage_aggregate *);
104
105
106 extern GLboolean
107 _slang_aggregate_variable(slang_storage_aggregate *agg,
108 slang_type_specifier *spec,
109 GLuint array_len,
110 slang_function_scope *funcs,
111 slang_struct_scope *structs,
112 slang_variable_scope *vars,
113 slang_atom_pool *atoms);
114
115 /*
116 * Returns the size (in machine units) of the given storage type.
117 * It is an error to pass-in SLANG_STORE_AGGREGATE.
118 * Returns 0 on error.
119 */
120 extern GLuint
121 _slang_sizeof_type (slang_storage_type);
122
123
124 /**
125 * Returns total size (in machine units) of the given aggregate.
126 * Returns 0 on error.
127 */
128 extern GLuint
129 _slang_sizeof_aggregate (const slang_storage_aggregate *);
130
131
132 #if 0
133 /**
134 * Converts structured aggregate to a flat one, with arrays of generic
135 * type being one-element long. Returns GL_TRUE on success. Returns
136 * GL_FALSE otherwise.
137 */
138 extern GLboolean
139 _slang_flatten_aggregate (slang_storage_aggregate *,
140 const slang_storage_aggregate *);
141
142 #endif
143
144 #endif /* SLANG_STORAGE_H */