OSDN Git Service

Limit loop init scope to till end of loop.
[android-x86/external-swiftshader.git] / src / Reactor / Reactor.hpp
1 // Copyright 2016 The SwiftShader Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //    http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #ifndef sw_Reactor_hpp
16 #define sw_Reactor_hpp
17
18 #include "Nucleus.hpp"
19 #include "Routine.hpp"
20
21 #include <cstddef>
22 #include <cwchar>
23 #undef Bool
24
25 namespace sw
26 {
27         class Byte;
28         class SByte;
29         class Byte4;
30         class SByte4;
31         class Byte8;
32         class SByte8;
33         class Byte16;
34         class SByte16;
35         class Short;
36         class UShort;
37         class Short2;
38         class UShort2;
39         class Short4;
40         class UShort4;
41         class Short8;
42         class UShort8;
43         class Int;
44         class UInt;
45         class Int2;
46         class UInt2;
47         class Int4;
48         class UInt4;
49         class Long;
50         class Long1;
51         class Float;
52         class Float2;
53         class Float4;
54
55         class Void
56         {
57         public:
58                 static Type *getType();
59
60                 static bool isVoid()
61                 {
62                         return true;
63                 }
64         };
65
66         template<class T>
67         class RValue;
68
69         template<class T>
70         class Pointer;
71
72         template<class T>
73         class LValue
74         {
75         public:
76                 LValue(int arraySize = 0);
77
78                 static bool isVoid()
79                 {
80                         return false;
81                 }
82
83                 Value *loadValue(unsigned int alignment = 0) const;
84                 Value *storeValue(Value *value, unsigned int alignment = 0) const;
85                 Value *getAddress(Value *index) const;
86
87         protected:
88                 Value *address;
89         };
90
91         template<class T>
92         class Variable : public LValue<T>
93         {
94         public:
95                 Variable(int arraySize = 0);
96
97                 RValue<Pointer<T>> operator&();
98         };
99
100         template<class T>
101         class Reference
102         {
103         public:
104                 explicit Reference(Value *pointer, int alignment = 1);
105
106                 RValue<T> operator=(RValue<T> rhs) const;
107                 RValue<T> operator=(const Reference<T> &ref) const;
108
109                 RValue<T> operator+=(RValue<T> rhs) const;
110
111                 Value *loadValue() const;
112                 int getAlignment() const;
113
114         private:
115                 Value *address;
116
117                 const int alignment;
118         };
119
120         template<class T>
121         struct IntLiteral
122         {
123                 struct type;
124         };
125
126         template<> struct
127         IntLiteral<Int>
128         {
129                 typedef int type;
130         };
131
132         template<> struct
133         IntLiteral<UInt>
134         {
135                 typedef unsigned int type;
136         };
137
138         template<> struct
139         IntLiteral<Long>
140         {
141                 typedef int64_t type;
142         };
143
144         template<class T>
145         struct FloatLiteral
146         {
147                 struct type;
148         };
149
150         template<> struct
151         FloatLiteral<Float>
152         {
153                 typedef float type;
154         };
155
156         template<class T>
157         class RValue
158         {
159         public:
160                 explicit RValue(Value *rvalue);
161
162                 RValue(const T &lvalue);
163                 RValue(typename IntLiteral<T>::type i);
164                 RValue(typename FloatLiteral<T>::type f);
165                 RValue(const Reference<T> &rhs);
166
167                 RValue<T> &operator=(const RValue<T>&) = delete;
168
169                 Value *value;   // FIXME: Make private
170         };
171
172         template<typename T>
173         struct Argument
174         {
175                 explicit Argument(Value *value) : value(value) {}
176
177                 Value *value;
178         };
179
180         class Bool : public Variable<Bool>
181         {
182         public:
183                 Bool(Argument<Bool> argument);
184
185                 Bool();
186                 Bool(bool x);
187                 Bool(RValue<Bool> rhs);
188                 Bool(const Bool &rhs);
189                 Bool(const Reference<Bool> &rhs);
190
191         //      RValue<Bool> operator=(bool rhs) const;   // FIXME: Implement
192                 RValue<Bool> operator=(RValue<Bool> rhs) const;
193                 RValue<Bool> operator=(const Bool &rhs) const;
194                 RValue<Bool> operator=(const Reference<Bool> &rhs) const;
195
196                 static Type *getType();
197         };
198
199         RValue<Bool> operator!(RValue<Bool> val);
200         RValue<Bool> operator&&(RValue<Bool> lhs, RValue<Bool> rhs);
201         RValue<Bool> operator||(RValue<Bool> lhs, RValue<Bool> rhs);
202
203         class Byte : public Variable<Byte>
204         {
205         public:
206                 Byte(Argument<Byte> argument);
207
208                 explicit Byte(RValue<Int> cast);
209                 explicit Byte(RValue<UInt> cast);
210                 explicit Byte(RValue<UShort> cast);
211
212                 Byte();
213                 Byte(int x);
214                 Byte(unsigned char x);
215                 Byte(RValue<Byte> rhs);
216                 Byte(const Byte &rhs);
217                 Byte(const Reference<Byte> &rhs);
218
219         //      RValue<Byte> operator=(unsigned char rhs) const;   // FIXME: Implement
220                 RValue<Byte> operator=(RValue<Byte> rhs) const;
221                 RValue<Byte> operator=(const Byte &rhs) const;
222                 RValue<Byte> operator=(const Reference<Byte> &rhs) const;
223
224                 static Type *getType();
225         };
226
227         RValue<Byte> operator+(RValue<Byte> lhs, RValue<Byte> rhs);
228         RValue<Byte> operator-(RValue<Byte> lhs, RValue<Byte> rhs);
229         RValue<Byte> operator*(RValue<Byte> lhs, RValue<Byte> rhs);
230         RValue<Byte> operator/(RValue<Byte> lhs, RValue<Byte> rhs);
231         RValue<Byte> operator%(RValue<Byte> lhs, RValue<Byte> rhs);
232         RValue<Byte> operator&(RValue<Byte> lhs, RValue<Byte> rhs);
233         RValue<Byte> operator|(RValue<Byte> lhs, RValue<Byte> rhs);
234         RValue<Byte> operator^(RValue<Byte> lhs, RValue<Byte> rhs);
235         RValue<Byte> operator<<(RValue<Byte> lhs, RValue<Byte> rhs);
236         RValue<Byte> operator>>(RValue<Byte> lhs, RValue<Byte> rhs);
237         RValue<Byte> operator+=(const Byte &lhs, RValue<Byte> rhs);
238         RValue<Byte> operator-=(const Byte &lhs, RValue<Byte> rhs);
239         RValue<Byte> operator*=(const Byte &lhs, RValue<Byte> rhs);
240         RValue<Byte> operator/=(const Byte &lhs, RValue<Byte> rhs);
241         RValue<Byte> operator%=(const Byte &lhs, RValue<Byte> rhs);
242         RValue<Byte> operator&=(const Byte &lhs, RValue<Byte> rhs);
243         RValue<Byte> operator|=(const Byte &lhs, RValue<Byte> rhs);
244         RValue<Byte> operator^=(const Byte &lhs, RValue<Byte> rhs);
245         RValue<Byte> operator<<=(const Byte &lhs, RValue<Byte> rhs);
246         RValue<Byte> operator>>=(const Byte &lhs, RValue<Byte> rhs);
247         RValue<Byte> operator+(RValue<Byte> val);
248         RValue<Byte> operator-(RValue<Byte> val);
249         RValue<Byte> operator~(RValue<Byte> val);
250         RValue<Byte> operator++(const Byte &val, int);   // Post-increment
251         const Byte &operator++(const Byte &val);   // Pre-increment
252         RValue<Byte> operator--(const Byte &val, int);   // Post-decrement
253         const Byte &operator--(const Byte &val);   // Pre-decrement
254         RValue<Bool> operator<(RValue<Byte> lhs, RValue<Byte> rhs);
255         RValue<Bool> operator<=(RValue<Byte> lhs, RValue<Byte> rhs);
256         RValue<Bool> operator>(RValue<Byte> lhs, RValue<Byte> rhs);
257         RValue<Bool> operator>=(RValue<Byte> lhs, RValue<Byte> rhs);
258         RValue<Bool> operator!=(RValue<Byte> lhs, RValue<Byte> rhs);
259         RValue<Bool> operator==(RValue<Byte> lhs, RValue<Byte> rhs);
260
261         class SByte : public Variable<SByte>
262         {
263         public:
264                 SByte(Argument<SByte> argument);
265
266                 explicit SByte(RValue<Int> cast);
267                 explicit SByte(RValue<Short> cast);
268
269                 SByte();
270                 SByte(signed char x);
271                 SByte(RValue<SByte> rhs);
272                 SByte(const SByte &rhs);
273                 SByte(const Reference<SByte> &rhs);
274
275         //      RValue<SByte> operator=(signed char rhs) const;   // FIXME: Implement
276                 RValue<SByte> operator=(RValue<SByte> rhs) const;
277                 RValue<SByte> operator=(const SByte &rhs) const;
278                 RValue<SByte> operator=(const Reference<SByte> &rhs) const;
279
280                 static Type *getType();
281         };
282
283         RValue<SByte> operator+(RValue<SByte> lhs, RValue<SByte> rhs);
284         RValue<SByte> operator-(RValue<SByte> lhs, RValue<SByte> rhs);
285         RValue<SByte> operator*(RValue<SByte> lhs, RValue<SByte> rhs);
286         RValue<SByte> operator/(RValue<SByte> lhs, RValue<SByte> rhs);
287         RValue<SByte> operator%(RValue<SByte> lhs, RValue<SByte> rhs);
288         RValue<SByte> operator&(RValue<SByte> lhs, RValue<SByte> rhs);
289         RValue<SByte> operator|(RValue<SByte> lhs, RValue<SByte> rhs);
290         RValue<SByte> operator^(RValue<SByte> lhs, RValue<SByte> rhs);
291         RValue<SByte> operator<<(RValue<SByte> lhs, RValue<SByte> rhs);
292         RValue<SByte> operator>>(RValue<SByte> lhs, RValue<SByte> rhs);
293         RValue<SByte> operator+=(const SByte &lhs, RValue<SByte> rhs);
294         RValue<SByte> operator-=(const SByte &lhs, RValue<SByte> rhs);
295         RValue<SByte> operator*=(const SByte &lhs, RValue<SByte> rhs);
296         RValue<SByte> operator/=(const SByte &lhs, RValue<SByte> rhs);
297         RValue<SByte> operator%=(const SByte &lhs, RValue<SByte> rhs);
298         RValue<SByte> operator&=(const SByte &lhs, RValue<SByte> rhs);
299         RValue<SByte> operator|=(const SByte &lhs, RValue<SByte> rhs);
300         RValue<SByte> operator^=(const SByte &lhs, RValue<SByte> rhs);
301         RValue<SByte> operator<<=(const SByte &lhs, RValue<SByte> rhs);
302         RValue<SByte> operator>>=(const SByte &lhs, RValue<SByte> rhs);
303         RValue<SByte> operator+(RValue<SByte> val);
304         RValue<SByte> operator-(RValue<SByte> val);
305         RValue<SByte> operator~(RValue<SByte> val);
306         RValue<SByte> operator++(const SByte &val, int);   // Post-increment
307         const SByte &operator++(const SByte &val);   // Pre-increment
308         RValue<SByte> operator--(const SByte &val, int);   // Post-decrement
309         const SByte &operator--(const SByte &val);   // Pre-decrement
310         RValue<Bool> operator<(RValue<SByte> lhs, RValue<SByte> rhs);
311         RValue<Bool> operator<=(RValue<SByte> lhs, RValue<SByte> rhs);
312         RValue<Bool> operator>(RValue<SByte> lhs, RValue<SByte> rhs);
313         RValue<Bool> operator>=(RValue<SByte> lhs, RValue<SByte> rhs);
314         RValue<Bool> operator!=(RValue<SByte> lhs, RValue<SByte> rhs);
315         RValue<Bool> operator==(RValue<SByte> lhs, RValue<SByte> rhs);
316
317         class Short : public Variable<Short>
318         {
319         public:
320                 Short(Argument<Short> argument);
321
322                 explicit Short(RValue<Int> cast);
323
324                 Short();
325                 Short(short x);
326                 Short(RValue<Short> rhs);
327                 Short(const Short &rhs);
328                 Short(const Reference<Short> &rhs);
329
330         //      RValue<Short> operator=(short rhs) const;   // FIXME: Implement
331                 RValue<Short> operator=(RValue<Short> rhs) const;
332                 RValue<Short> operator=(const Short &rhs) const;
333                 RValue<Short> operator=(const Reference<Short> &rhs) const;
334
335                 static Type *getType();
336         };
337
338         RValue<Short> operator+(RValue<Short> lhs, RValue<Short> rhs);
339         RValue<Short> operator-(RValue<Short> lhs, RValue<Short> rhs);
340         RValue<Short> operator*(RValue<Short> lhs, RValue<Short> rhs);
341         RValue<Short> operator/(RValue<Short> lhs, RValue<Short> rhs);
342         RValue<Short> operator%(RValue<Short> lhs, RValue<Short> rhs);
343         RValue<Short> operator&(RValue<Short> lhs, RValue<Short> rhs);
344         RValue<Short> operator|(RValue<Short> lhs, RValue<Short> rhs);
345         RValue<Short> operator^(RValue<Short> lhs, RValue<Short> rhs);
346         RValue<Short> operator<<(RValue<Short> lhs, RValue<Short> rhs);
347         RValue<Short> operator>>(RValue<Short> lhs, RValue<Short> rhs);
348         RValue<Short> operator+=(const Short &lhs, RValue<Short> rhs);
349         RValue<Short> operator-=(const Short &lhs, RValue<Short> rhs);
350         RValue<Short> operator*=(const Short &lhs, RValue<Short> rhs);
351         RValue<Short> operator/=(const Short &lhs, RValue<Short> rhs);
352         RValue<Short> operator%=(const Short &lhs, RValue<Short> rhs);
353         RValue<Short> operator&=(const Short &lhs, RValue<Short> rhs);
354         RValue<Short> operator|=(const Short &lhs, RValue<Short> rhs);
355         RValue<Short> operator^=(const Short &lhs, RValue<Short> rhs);
356         RValue<Short> operator<<=(const Short &lhs, RValue<Short> rhs);
357         RValue<Short> operator>>=(const Short &lhs, RValue<Short> rhs);
358         RValue<Short> operator+(RValue<Short> val);
359         RValue<Short> operator-(RValue<Short> val);
360         RValue<Short> operator~(RValue<Short> val);
361         RValue<Short> operator++(const Short &val, int);   // Post-increment
362         const Short &operator++(const Short &val);   // Pre-increment
363         RValue<Short> operator--(const Short &val, int);   // Post-decrement
364         const Short &operator--(const Short &val);   // Pre-decrement
365         RValue<Bool> operator<(RValue<Short> lhs, RValue<Short> rhs);
366         RValue<Bool> operator<=(RValue<Short> lhs, RValue<Short> rhs);
367         RValue<Bool> operator>(RValue<Short> lhs, RValue<Short> rhs);
368         RValue<Bool> operator>=(RValue<Short> lhs, RValue<Short> rhs);
369         RValue<Bool> operator!=(RValue<Short> lhs, RValue<Short> rhs);
370         RValue<Bool> operator==(RValue<Short> lhs, RValue<Short> rhs);
371
372         class UShort : public Variable<UShort>
373         {
374         public:
375                 UShort(Argument<UShort> argument);
376
377                 explicit UShort(RValue<UInt> cast);
378                 explicit UShort(RValue<Int> cast);
379
380                 UShort();
381                 UShort(unsigned short x);
382                 UShort(RValue<UShort> rhs);
383                 UShort(const UShort &rhs);
384                 UShort(const Reference<UShort> &rhs);
385
386         //      RValue<UShort> operator=(unsigned short rhs) const;   // FIXME: Implement
387                 RValue<UShort> operator=(RValue<UShort> rhs) const;
388                 RValue<UShort> operator=(const UShort &rhs) const;
389                 RValue<UShort> operator=(const Reference<UShort> &rhs) const;
390
391                 static Type *getType();
392         };
393
394         RValue<UShort> operator+(RValue<UShort> lhs, RValue<UShort> rhs);
395         RValue<UShort> operator-(RValue<UShort> lhs, RValue<UShort> rhs);
396         RValue<UShort> operator*(RValue<UShort> lhs, RValue<UShort> rhs);
397         RValue<UShort> operator/(RValue<UShort> lhs, RValue<UShort> rhs);
398         RValue<UShort> operator%(RValue<UShort> lhs, RValue<UShort> rhs);
399         RValue<UShort> operator&(RValue<UShort> lhs, RValue<UShort> rhs);
400         RValue<UShort> operator|(RValue<UShort> lhs, RValue<UShort> rhs);
401         RValue<UShort> operator^(RValue<UShort> lhs, RValue<UShort> rhs);
402         RValue<UShort> operator<<(RValue<UShort> lhs, RValue<UShort> rhs);
403         RValue<UShort> operator>>(RValue<UShort> lhs, RValue<UShort> rhs);
404         RValue<UShort> operator+=(const UShort &lhs, RValue<UShort> rhs);
405         RValue<UShort> operator-=(const UShort &lhs, RValue<UShort> rhs);
406         RValue<UShort> operator*=(const UShort &lhs, RValue<UShort> rhs);
407         RValue<UShort> operator/=(const UShort &lhs, RValue<UShort> rhs);
408         RValue<UShort> operator%=(const UShort &lhs, RValue<UShort> rhs);
409         RValue<UShort> operator&=(const UShort &lhs, RValue<UShort> rhs);
410         RValue<UShort> operator|=(const UShort &lhs, RValue<UShort> rhs);
411         RValue<UShort> operator^=(const UShort &lhs, RValue<UShort> rhs);
412         RValue<UShort> operator<<=(const UShort &lhs, RValue<UShort> rhs);
413         RValue<UShort> operator>>=(const UShort &lhs, RValue<UShort> rhs);
414         RValue<UShort> operator+(RValue<UShort> val);
415         RValue<UShort> operator-(RValue<UShort> val);
416         RValue<UShort> operator~(RValue<UShort> val);
417         RValue<UShort> operator++(const UShort &val, int);   // Post-increment
418         const UShort &operator++(const UShort &val);   // Pre-increment
419         RValue<UShort> operator--(const UShort &val, int);   // Post-decrement
420         const UShort &operator--(const UShort &val);   // Pre-decrement
421         RValue<Bool> operator<(RValue<UShort> lhs, RValue<UShort> rhs);
422         RValue<Bool> operator<=(RValue<UShort> lhs, RValue<UShort> rhs);
423         RValue<Bool> operator>(RValue<UShort> lhs, RValue<UShort> rhs);
424         RValue<Bool> operator>=(RValue<UShort> lhs, RValue<UShort> rhs);
425         RValue<Bool> operator!=(RValue<UShort> lhs, RValue<UShort> rhs);
426         RValue<Bool> operator==(RValue<UShort> lhs, RValue<UShort> rhs);
427
428         class Byte4 : public Variable<Byte4>
429         {
430         public:
431                 explicit Byte4(RValue<Byte8> cast);
432
433         //      Byte4();
434         //      Byte4(int x, int y, int z, int w);
435         //      Byte4(RValue<Byte4> rhs);
436         //      Byte4(const Byte4 &rhs);
437                 Byte4(const Reference<Byte4> &rhs);
438
439         //      RValue<Byte4> operator=(RValue<Byte4> rhs) const;
440         //      RValue<Byte4> operator=(const Byte4 &rhs) const;
441         //      RValue<Byte4> operator=(const Reference<Byte4> &rhs) const;
442
443                 static Type *getType();
444         };
445
446 //      RValue<Byte4> operator+(RValue<Byte4> lhs, RValue<Byte4> rhs);
447 //      RValue<Byte4> operator-(RValue<Byte4> lhs, RValue<Byte4> rhs);
448 //      RValue<Byte4> operator*(RValue<Byte4> lhs, RValue<Byte4> rhs);
449 //      RValue<Byte4> operator/(RValue<Byte4> lhs, RValue<Byte4> rhs);
450 //      RValue<Byte4> operator%(RValue<Byte4> lhs, RValue<Byte4> rhs);
451 //      RValue<Byte4> operator&(RValue<Byte4> lhs, RValue<Byte4> rhs);
452 //      RValue<Byte4> operator|(RValue<Byte4> lhs, RValue<Byte4> rhs);
453 //      RValue<Byte4> operator^(RValue<Byte4> lhs, RValue<Byte4> rhs);
454 //      RValue<Byte4> operator<<(RValue<Byte4> lhs, RValue<Byte4> rhs);
455 //      RValue<Byte4> operator>>(RValue<Byte4> lhs, RValue<Byte4> rhs);
456 //      RValue<Byte4> operator+=(const Byte4 &lhs, RValue<Byte4> rhs);
457 //      RValue<Byte4> operator-=(const Byte4 &lhs, RValue<Byte4> rhs);
458 //      RValue<Byte4> operator*=(const Byte4 &lhs, RValue<Byte4> rhs);
459 //      RValue<Byte4> operator/=(const Byte4 &lhs, RValue<Byte4> rhs);
460 //      RValue<Byte4> operator%=(const Byte4 &lhs, RValue<Byte4> rhs);
461 //      RValue<Byte4> operator&=(const Byte4 &lhs, RValue<Byte4> rhs);
462 //      RValue<Byte4> operator|=(const Byte4 &lhs, RValue<Byte4> rhs);
463 //      RValue<Byte4> operator^=(const Byte4 &lhs, RValue<Byte4> rhs);
464 //      RValue<Byte4> operator<<=(const Byte4 &lhs, RValue<Byte4> rhs);
465 //      RValue<Byte4> operator>>=(const Byte4 &lhs, RValue<Byte4> rhs);
466 //      RValue<Byte4> operator+(RValue<Byte4> val);
467 //      RValue<Byte4> operator-(RValue<Byte4> val);
468 //      RValue<Byte4> operator~(RValue<Byte4> val);
469 //      RValue<Byte4> operator++(const Byte4 &val, int);   // Post-increment
470 //      const Byte4 &operator++(const Byte4 &val);   // Pre-increment
471 //      RValue<Byte4> operator--(const Byte4 &val, int);   // Post-decrement
472 //      const Byte4 &operator--(const Byte4 &val);   // Pre-decrement
473
474         class SByte4 : public Variable<SByte4>
475         {
476         public:
477         //      SByte4();
478         //      SByte4(int x, int y, int z, int w);
479         //      SByte4(RValue<SByte4> rhs);
480         //      SByte4(const SByte4 &rhs);
481         //      SByte4(const Reference<SByte4> &rhs);
482
483         //      RValue<SByte4> operator=(RValue<SByte4> rhs) const;
484         //      RValue<SByte4> operator=(const SByte4 &rhs) const;
485         //      RValue<SByte4> operator=(const Reference<SByte4> &rhs) const;
486
487                 static Type *getType();
488         };
489
490 //      RValue<SByte4> operator+(RValue<SByte4> lhs, RValue<SByte4> rhs);
491 //      RValue<SByte4> operator-(RValue<SByte4> lhs, RValue<SByte4> rhs);
492 //      RValue<SByte4> operator*(RValue<SByte4> lhs, RValue<SByte4> rhs);
493 //      RValue<SByte4> operator/(RValue<SByte4> lhs, RValue<SByte4> rhs);
494 //      RValue<SByte4> operator%(RValue<SByte4> lhs, RValue<SByte4> rhs);
495 //      RValue<SByte4> operator&(RValue<SByte4> lhs, RValue<SByte4> rhs);
496 //      RValue<SByte4> operator|(RValue<SByte4> lhs, RValue<SByte4> rhs);
497 //      RValue<SByte4> operator^(RValue<SByte4> lhs, RValue<SByte4> rhs);
498 //      RValue<SByte4> operator<<(RValue<SByte4> lhs, RValue<SByte4> rhs);
499 //      RValue<SByte4> operator>>(RValue<SByte4> lhs, RValue<SByte4> rhs);
500 //      RValue<SByte4> operator+=(const SByte4 &lhs, RValue<SByte4> rhs);
501 //      RValue<SByte4> operator-=(const SByte4 &lhs, RValue<SByte4> rhs);
502 //      RValue<SByte4> operator*=(const SByte4 &lhs, RValue<SByte4> rhs);
503 //      RValue<SByte4> operator/=(const SByte4 &lhs, RValue<SByte4> rhs);
504 //      RValue<SByte4> operator%=(const SByte4 &lhs, RValue<SByte4> rhs);
505 //      RValue<SByte4> operator&=(const SByte4 &lhs, RValue<SByte4> rhs);
506 //      RValue<SByte4> operator|=(const SByte4 &lhs, RValue<SByte4> rhs);
507 //      RValue<SByte4> operator^=(const SByte4 &lhs, RValue<SByte4> rhs);
508 //      RValue<SByte4> operator<<=(const SByte4 &lhs, RValue<SByte4> rhs);
509 //      RValue<SByte4> operator>>=(const SByte4 &lhs, RValue<SByte4> rhs);
510 //      RValue<SByte4> operator+(RValue<SByte4> val);
511 //      RValue<SByte4> operator-(RValue<SByte4> val);
512 //      RValue<SByte4> operator~(RValue<SByte4> val);
513 //      RValue<SByte4> operator++(const SByte4 &val, int);   // Post-increment
514 //      const SByte4 &operator++(const SByte4 &val);   // Pre-increment
515 //      RValue<SByte4> operator--(const SByte4 &val, int);   // Post-decrement
516 //      const SByte4 &operator--(const SByte4 &val);   // Pre-decrement
517
518         class Byte8 : public Variable<Byte8>
519         {
520         public:
521                 Byte8();
522                 Byte8(uint8_t x0, uint8_t x1, uint8_t x2, uint8_t x3, uint8_t x4, uint8_t x5, uint8_t x6, uint8_t x7);
523                 Byte8(RValue<Byte8> rhs);
524                 Byte8(const Byte8 &rhs);
525                 Byte8(const Reference<Byte8> &rhs);
526
527                 RValue<Byte8> operator=(RValue<Byte8> rhs) const;
528                 RValue<Byte8> operator=(const Byte8 &rhs) const;
529                 RValue<Byte8> operator=(const Reference<Byte8> &rhs) const;
530
531                 static Type *getType();
532         };
533
534         RValue<Byte8> operator+(RValue<Byte8> lhs, RValue<Byte8> rhs);
535         RValue<Byte8> operator-(RValue<Byte8> lhs, RValue<Byte8> rhs);
536 //      RValue<Byte8> operator*(RValue<Byte8> lhs, RValue<Byte8> rhs);
537 //      RValue<Byte8> operator/(RValue<Byte8> lhs, RValue<Byte8> rhs);
538 //      RValue<Byte8> operator%(RValue<Byte8> lhs, RValue<Byte8> rhs);
539         RValue<Byte8> operator&(RValue<Byte8> lhs, RValue<Byte8> rhs);
540         RValue<Byte8> operator|(RValue<Byte8> lhs, RValue<Byte8> rhs);
541         RValue<Byte8> operator^(RValue<Byte8> lhs, RValue<Byte8> rhs);
542 //      RValue<Byte8> operator<<(RValue<Byte8> lhs, RValue<Byte8> rhs);
543 //      RValue<Byte8> operator>>(RValue<Byte8> lhs, RValue<Byte8> rhs);
544         RValue<Byte8> operator+=(const Byte8 &lhs, RValue<Byte8> rhs);
545         RValue<Byte8> operator-=(const Byte8 &lhs, RValue<Byte8> rhs);
546 //      RValue<Byte8> operator*=(const Byte8 &lhs, RValue<Byte8> rhs);
547 //      RValue<Byte8> operator/=(const Byte8 &lhs, RValue<Byte8> rhs);
548 //      RValue<Byte8> operator%=(const Byte8 &lhs, RValue<Byte8> rhs);
549         RValue<Byte8> operator&=(const Byte8 &lhs, RValue<Byte8> rhs);
550         RValue<Byte8> operator|=(const Byte8 &lhs, RValue<Byte8> rhs);
551         RValue<Byte8> operator^=(const Byte8 &lhs, RValue<Byte8> rhs);
552 //      RValue<Byte8> operator<<=(const Byte8 &lhs, RValue<Byte8> rhs);
553 //      RValue<Byte8> operator>>=(const Byte8 &lhs, RValue<Byte8> rhs);
554 //      RValue<Byte8> operator+(RValue<Byte8> val);
555 //      RValue<Byte8> operator-(RValue<Byte8> val);
556         RValue<Byte8> operator~(RValue<Byte8> val);
557 //      RValue<Byte8> operator++(const Byte8 &val, int);   // Post-increment
558 //      const Byte8 &operator++(const Byte8 &val);   // Pre-increment
559 //      RValue<Byte8> operator--(const Byte8 &val, int);   // Post-decrement
560 //      const Byte8 &operator--(const Byte8 &val);   // Pre-decrement
561
562         RValue<Byte8> AddSat(RValue<Byte8> x, RValue<Byte8> y);
563         RValue<Byte8> SubSat(RValue<Byte8> x, RValue<Byte8> y);
564         RValue<Short4> Unpack(RValue<Byte4> x);
565         RValue<Short4> UnpackLow(RValue<Byte8> x, RValue<Byte8> y);
566         RValue<Short4> UnpackHigh(RValue<Byte8> x, RValue<Byte8> y);
567         RValue<Int> SignMask(RValue<Byte8> x);
568 //      RValue<Byte8> CmpGT(RValue<Byte8> x, RValue<Byte8> y);
569         RValue<Byte8> CmpEQ(RValue<Byte8> x, RValue<Byte8> y);
570
571         class SByte8 : public Variable<SByte8>
572         {
573         public:
574                 SByte8();
575                 SByte8(uint8_t x0, uint8_t x1, uint8_t x2, uint8_t x3, uint8_t x4, uint8_t x5, uint8_t x6, uint8_t x7);
576                 SByte8(RValue<SByte8> rhs);
577                 SByte8(const SByte8 &rhs);
578                 SByte8(const Reference<SByte8> &rhs);
579
580                 RValue<SByte8> operator=(RValue<SByte8> rhs) const;
581                 RValue<SByte8> operator=(const SByte8 &rhs) const;
582                 RValue<SByte8> operator=(const Reference<SByte8> &rhs) const;
583
584                 static Type *getType();
585         };
586
587         RValue<SByte8> operator+(RValue<SByte8> lhs, RValue<SByte8> rhs);
588         RValue<SByte8> operator-(RValue<SByte8> lhs, RValue<SByte8> rhs);
589 //      RValue<SByte8> operator*(RValue<SByte8> lhs, RValue<SByte8> rhs);
590 //      RValue<SByte8> operator/(RValue<SByte8> lhs, RValue<SByte8> rhs);
591 //      RValue<SByte8> operator%(RValue<SByte8> lhs, RValue<SByte8> rhs);
592         RValue<SByte8> operator&(RValue<SByte8> lhs, RValue<SByte8> rhs);
593         RValue<SByte8> operator|(RValue<SByte8> lhs, RValue<SByte8> rhs);
594         RValue<SByte8> operator^(RValue<SByte8> lhs, RValue<SByte8> rhs);
595 //      RValue<SByte8> operator<<(RValue<SByte8> lhs, RValue<SByte8> rhs);
596 //      RValue<SByte8> operator>>(RValue<SByte8> lhs, RValue<SByte8> rhs);
597         RValue<SByte8> operator+=(const SByte8 &lhs, RValue<SByte8> rhs);
598         RValue<SByte8> operator-=(const SByte8 &lhs, RValue<SByte8> rhs);
599 //      RValue<SByte8> operator*=(const SByte8 &lhs, RValue<SByte8> rhs);
600 //      RValue<SByte8> operator/=(const SByte8 &lhs, RValue<SByte8> rhs);
601 //      RValue<SByte8> operator%=(const SByte8 &lhs, RValue<SByte8> rhs);
602         RValue<SByte8> operator&=(const SByte8 &lhs, RValue<SByte8> rhs);
603         RValue<SByte8> operator|=(const SByte8 &lhs, RValue<SByte8> rhs);
604         RValue<SByte8> operator^=(const SByte8 &lhs, RValue<SByte8> rhs);
605 //      RValue<SByte8> operator<<=(const SByte8 &lhs, RValue<SByte8> rhs);
606 //      RValue<SByte8> operator>>=(const SByte8 &lhs, RValue<SByte8> rhs);
607 //      RValue<SByte8> operator+(RValue<SByte8> val);
608 //      RValue<SByte8> operator-(RValue<SByte8> val);
609         RValue<SByte8> operator~(RValue<SByte8> val);
610 //      RValue<SByte8> operator++(const SByte8 &val, int);   // Post-increment
611 //      const SByte8 &operator++(const SByte8 &val);   // Pre-increment
612 //      RValue<SByte8> operator--(const SByte8 &val, int);   // Post-decrement
613 //      const SByte8 &operator--(const SByte8 &val);   // Pre-decrement
614
615         RValue<SByte8> AddSat(RValue<SByte8> x, RValue<SByte8> y);
616         RValue<SByte8> SubSat(RValue<SByte8> x, RValue<SByte8> y);
617         RValue<Short4> UnpackLow(RValue<SByte8> x, RValue<SByte8> y);
618         RValue<Short4> UnpackHigh(RValue<SByte8> x, RValue<SByte8> y);
619         RValue<Int> SignMask(RValue<SByte8> x);
620         RValue<Byte8> CmpGT(RValue<SByte8> x, RValue<SByte8> y);
621         RValue<Byte8> CmpEQ(RValue<SByte8> x, RValue<SByte8> y);
622
623         class Byte16 : public Variable<Byte16>
624         {
625         public:
626         //      Byte16();
627         //      Byte16(int x, int y, int z, int w);
628                 Byte16(RValue<Byte16> rhs);
629                 Byte16(const Byte16 &rhs);
630                 Byte16(const Reference<Byte16> &rhs);
631
632                 RValue<Byte16> operator=(RValue<Byte16> rhs) const;
633                 RValue<Byte16> operator=(const Byte16 &rhs) const;
634                 RValue<Byte16> operator=(const Reference<Byte16> &rhs) const;
635
636                 static Type *getType();
637         };
638
639 //      RValue<Byte16> operator+(RValue<Byte16> lhs, RValue<Byte16> rhs);
640 //      RValue<Byte16> operator-(RValue<Byte16> lhs, RValue<Byte16> rhs);
641 //      RValue<Byte16> operator*(RValue<Byte16> lhs, RValue<Byte16> rhs);
642 //      RValue<Byte16> operator/(RValue<Byte16> lhs, RValue<Byte16> rhs);
643 //      RValue<Byte16> operator%(RValue<Byte16> lhs, RValue<Byte16> rhs);
644 //      RValue<Byte16> operator&(RValue<Byte16> lhs, RValue<Byte16> rhs);
645 //      RValue<Byte16> operator|(RValue<Byte16> lhs, RValue<Byte16> rhs);
646 //      RValue<Byte16> operator^(RValue<Byte16> lhs, RValue<Byte16> rhs);
647 //      RValue<Byte16> operator<<(RValue<Byte16> lhs, RValue<Byte16> rhs);
648 //      RValue<Byte16> operator>>(RValue<Byte16> lhs, RValue<Byte16> rhs);
649 //      RValue<Byte16> operator+=(const Byte16 &lhs, RValue<Byte16> rhs);
650 //      RValue<Byte16> operator-=(const Byte16 &lhs, RValue<Byte16> rhs);
651 //      RValue<Byte16> operator*=(const Byte16 &lhs, RValue<Byte16> rhs);
652 //      RValue<Byte16> operator/=(const Byte16 &lhs, RValue<Byte16> rhs);
653 //      RValue<Byte16> operator%=(const Byte16 &lhs, RValue<Byte16> rhs);
654 //      RValue<Byte16> operator&=(const Byte16 &lhs, RValue<Byte16> rhs);
655 //      RValue<Byte16> operator|=(const Byte16 &lhs, RValue<Byte16> rhs);
656 //      RValue<Byte16> operator^=(const Byte16 &lhs, RValue<Byte16> rhs);
657 //      RValue<Byte16> operator<<=(const Byte16 &lhs, RValue<Byte16> rhs);
658 //      RValue<Byte16> operator>>=(const Byte16 &lhs, RValue<Byte16> rhs);
659 //      RValue<Byte16> operator+(RValue<Byte16> val);
660 //      RValue<Byte16> operator-(RValue<Byte16> val);
661 //      RValue<Byte16> operator~(RValue<Byte16> val);
662 //      RValue<Byte16> operator++(const Byte16 &val, int);   // Post-increment
663 //      const Byte16 &operator++(const Byte16 &val);   // Pre-increment
664 //      RValue<Byte16> operator--(const Byte16 &val, int);   // Post-decrement
665 //      const Byte16 &operator--(const Byte16 &val);   // Pre-decrement
666
667         class SByte16 : public Variable<SByte16>
668         {
669         public:
670         //      SByte16();
671         //      SByte16(int x, int y, int z, int w);
672         //      SByte16(RValue<SByte16> rhs);
673         //      SByte16(const SByte16 &rhs);
674         //      SByte16(const Reference<SByte16> &rhs);
675
676         //      RValue<SByte16> operator=(RValue<SByte16> rhs) const;
677         //      RValue<SByte16> operator=(const SByte16 &rhs) const;
678         //      RValue<SByte16> operator=(const Reference<SByte16> &rhs) const;
679
680                 static Type *getType();
681         };
682
683 //      RValue<SByte16> operator+(RValue<SByte16> lhs, RValue<SByte16> rhs);
684 //      RValue<SByte16> operator-(RValue<SByte16> lhs, RValue<SByte16> rhs);
685 //      RValue<SByte16> operator*(RValue<SByte16> lhs, RValue<SByte16> rhs);
686 //      RValue<SByte16> operator/(RValue<SByte16> lhs, RValue<SByte16> rhs);
687 //      RValue<SByte16> operator%(RValue<SByte16> lhs, RValue<SByte16> rhs);
688 //      RValue<SByte16> operator&(RValue<SByte16> lhs, RValue<SByte16> rhs);
689 //      RValue<SByte16> operator|(RValue<SByte16> lhs, RValue<SByte16> rhs);
690 //      RValue<SByte16> operator^(RValue<SByte16> lhs, RValue<SByte16> rhs);
691 //      RValue<SByte16> operator<<(RValue<SByte16> lhs, RValue<SByte16> rhs);
692 //      RValue<SByte16> operator>>(RValue<SByte16> lhs, RValue<SByte16> rhs);
693 //      RValue<SByte16> operator+=(const SByte16 &lhs, RValue<SByte16> rhs);
694 //      RValue<SByte16> operator-=(const SByte16 &lhs, RValue<SByte16> rhs);
695 //      RValue<SByte16> operator*=(const SByte16 &lhs, RValue<SByte16> rhs);
696 //      RValue<SByte16> operator/=(const SByte16 &lhs, RValue<SByte16> rhs);
697 //      RValue<SByte16> operator%=(const SByte16 &lhs, RValue<SByte16> rhs);
698 //      RValue<SByte16> operator&=(const SByte16 &lhs, RValue<SByte16> rhs);
699 //      RValue<SByte16> operator|=(const SByte16 &lhs, RValue<SByte16> rhs);
700 //      RValue<SByte16> operator^=(const SByte16 &lhs, RValue<SByte16> rhs);
701 //      RValue<SByte16> operator<<=(const SByte16 &lhs, RValue<SByte16> rhs);
702 //      RValue<SByte16> operator>>=(const SByte16 &lhs, RValue<SByte16> rhs);
703 //      RValue<SByte16> operator+(RValue<SByte16> val);
704 //      RValue<SByte16> operator-(RValue<SByte16> val);
705 //      RValue<SByte16> operator~(RValue<SByte16> val);
706 //      RValue<SByte16> operator++(const SByte16 &val, int);   // Post-increment
707 //      const SByte16 &operator++(const SByte16 &val);   // Pre-increment
708 //      RValue<SByte16> operator--(const SByte16 &val, int);   // Post-decrement
709 //      const SByte16 &operator--(const SByte16 &val);   // Pre-decrement
710
711         class Short2 : public Variable<Short2>
712         {
713         public:
714                 explicit Short2(RValue<Short4> cast);
715
716                 static Type *getType();
717         };
718
719         class UShort2 : public Variable<UShort2>
720         {
721         public:
722                 explicit UShort2(RValue<UShort4> cast);
723
724                 static Type *getType();
725         };
726
727         class Short4 : public Variable<Short4>
728         {
729         public:
730                 explicit Short4(RValue<Int> cast);
731                 explicit Short4(RValue<Int4> cast);
732         //      explicit Short4(RValue<Float> cast);
733                 explicit Short4(RValue<Float4> cast);
734
735                 Short4();
736                 Short4(short xyzw);
737                 Short4(short x, short y, short z, short w);
738                 Short4(RValue<Short4> rhs);
739                 Short4(const Short4 &rhs);
740                 Short4(const Reference<Short4> &rhs);
741                 Short4(RValue<UShort4> rhs);
742                 Short4(const UShort4 &rhs);
743                 Short4(const Reference<UShort4> &rhs);
744
745                 RValue<Short4> operator=(RValue<Short4> rhs) const;
746                 RValue<Short4> operator=(const Short4 &rhs) const;
747                 RValue<Short4> operator=(const Reference<Short4> &rhs) const;
748                 RValue<Short4> operator=(RValue<UShort4> rhs) const;
749                 RValue<Short4> operator=(const UShort4 &rhs) const;
750                 RValue<Short4> operator=(const Reference<UShort4> &rhs) const;
751
752                 static Type *getType();
753         };
754
755         RValue<Short4> operator+(RValue<Short4> lhs, RValue<Short4> rhs);
756         RValue<Short4> operator-(RValue<Short4> lhs, RValue<Short4> rhs);
757         RValue<Short4> operator*(RValue<Short4> lhs, RValue<Short4> rhs);
758 //      RValue<Short4> operator/(RValue<Short4> lhs, RValue<Short4> rhs);
759 //      RValue<Short4> operator%(RValue<Short4> lhs, RValue<Short4> rhs);
760         RValue<Short4> operator&(RValue<Short4> lhs, RValue<Short4> rhs);
761         RValue<Short4> operator|(RValue<Short4> lhs, RValue<Short4> rhs);
762         RValue<Short4> operator^(RValue<Short4> lhs, RValue<Short4> rhs);
763         RValue<Short4> operator<<(RValue<Short4> lhs, unsigned char rhs);
764         RValue<Short4> operator>>(RValue<Short4> lhs, unsigned char rhs);
765         RValue<Short4> operator<<(RValue<Short4> lhs, RValue<Long1> rhs);
766         RValue<Short4> operator>>(RValue<Short4> lhs, RValue<Long1> rhs);
767         RValue<Short4> operator+=(const Short4 &lhs, RValue<Short4> rhs);
768         RValue<Short4> operator-=(const Short4 &lhs, RValue<Short4> rhs);
769         RValue<Short4> operator*=(const Short4 &lhs, RValue<Short4> rhs);
770 //      RValue<Short4> operator/=(const Short4 &lhs, RValue<Short4> rhs);
771 //      RValue<Short4> operator%=(const Short4 &lhs, RValue<Short4> rhs);
772         RValue<Short4> operator&=(const Short4 &lhs, RValue<Short4> rhs);
773         RValue<Short4> operator|=(const Short4 &lhs, RValue<Short4> rhs);
774         RValue<Short4> operator^=(const Short4 &lhs, RValue<Short4> rhs);
775         RValue<Short4> operator<<=(const Short4 &lhs, unsigned char rhs);
776         RValue<Short4> operator>>=(const Short4 &lhs, unsigned char rhs);
777         RValue<Short4> operator<<=(const Short4 &lhs, RValue<Long1> rhs);
778         RValue<Short4> operator>>=(const Short4 &lhs, RValue<Long1> rhs);
779 //      RValue<Short4> operator+(RValue<Short4> val);
780         RValue<Short4> operator-(RValue<Short4> val);
781         RValue<Short4> operator~(RValue<Short4> val);
782 //      RValue<Short4> operator++(const Short4 &val, int);   // Post-increment
783 //      const Short4 &operator++(const Short4 &val);   // Pre-increment
784 //      RValue<Short4> operator--(const Short4 &val, int);   // Post-decrement
785 //      const Short4 &operator--(const Short4 &val);   // Pre-decrement
786 //      RValue<Bool> operator<(RValue<Short4> lhs, RValue<Short4> rhs);
787 //      RValue<Bool> operator<=(RValue<Short4> lhs, RValue<Short4> rhs);
788 //      RValue<Bool> operator>(RValue<Short4> lhs, RValue<Short4> rhs);
789 //      RValue<Bool> operator>=(RValue<Short4> lhs, RValue<Short4> rhs);
790 //      RValue<Bool> operator!=(RValue<Short4> lhs, RValue<Short4> rhs);
791 //      RValue<Bool> operator==(RValue<Short4> lhs, RValue<Short4> rhs);
792
793         RValue<Short4> RoundShort4(RValue<Float4> cast);
794         RValue<Short4> Max(RValue<Short4> x, RValue<Short4> y);
795         RValue<Short4> Min(RValue<Short4> x, RValue<Short4> y);
796         RValue<Short4> AddSat(RValue<Short4> x, RValue<Short4> y);
797         RValue<Short4> SubSat(RValue<Short4> x, RValue<Short4> y);
798         RValue<Short4> MulHigh(RValue<Short4> x, RValue<Short4> y);
799         RValue<Int2> MulAdd(RValue<Short4> x, RValue<Short4> y);
800         RValue<SByte8> Pack(RValue<Short4> x, RValue<Short4> y);
801         RValue<Int2> UnpackLow(RValue<Short4> x, RValue<Short4> y);
802         RValue<Int2> UnpackHigh(RValue<Short4> x, RValue<Short4> y);
803         RValue<Short4> Swizzle(RValue<Short4> x, unsigned char select);
804         RValue<Short4> Insert(RValue<Short4> val, RValue<Short> element, int i);
805         RValue<Short> Extract(RValue<Short4> val, int i);
806         RValue<Short4> CmpGT(RValue<Short4> x, RValue<Short4> y);
807         RValue<Short4> CmpEQ(RValue<Short4> x, RValue<Short4> y);
808
809         class UShort4 : public Variable<UShort4>
810         {
811         public:
812                 explicit UShort4(RValue<Int4> cast);
813                 explicit UShort4(RValue<Float4> cast, bool saturate = false);
814
815                 UShort4();
816                 UShort4(unsigned short xyzw);
817                 UShort4(unsigned short x, unsigned short y, unsigned short z, unsigned short w);
818                 UShort4(RValue<UShort4> rhs);
819                 UShort4(const UShort4 &rhs);
820                 UShort4(const Reference<UShort4> &rhs);
821                 UShort4(RValue<Short4> rhs);
822                 UShort4(const Short4 &rhs);
823                 UShort4(const Reference<Short4> &rhs);
824
825                 RValue<UShort4> operator=(RValue<UShort4> rhs) const;
826                 RValue<UShort4> operator=(const UShort4 &rhs) const;
827                 RValue<UShort4> operator=(const Reference<UShort4> &rhs) const;
828                 RValue<UShort4> operator=(RValue<Short4> rhs) const;
829                 RValue<UShort4> operator=(const Short4 &rhs) const;
830                 RValue<UShort4> operator=(const Reference<Short4> &rhs) const;
831
832                 static Type *getType();
833         };
834
835         RValue<UShort4> operator+(RValue<UShort4> lhs, RValue<UShort4> rhs);
836         RValue<UShort4> operator-(RValue<UShort4> lhs, RValue<UShort4> rhs);
837         RValue<UShort4> operator*(RValue<UShort4> lhs, RValue<UShort4> rhs);
838 //      RValue<UShort4> operator/(RValue<UShort4> lhs, RValue<UShort4> rhs);
839 //      RValue<UShort4> operator%(RValue<UShort4> lhs, RValue<UShort4> rhs);
840         RValue<UShort4> operator&(RValue<UShort4> lhs, RValue<UShort4> rhs);
841         RValue<UShort4> operator|(RValue<UShort4> lhs, RValue<UShort4> rhs);
842         RValue<UShort4> operator^(RValue<UShort4> lhs, RValue<UShort4> rhs);
843         RValue<UShort4> operator<<(RValue<UShort4> lhs, unsigned char rhs);
844         RValue<UShort4> operator>>(RValue<UShort4> lhs, unsigned char rhs);
845         RValue<UShort4> operator<<(RValue<UShort4> lhs, RValue<Long1> rhs);
846         RValue<UShort4> operator>>(RValue<UShort4> lhs, RValue<Long1> rhs);
847 //      RValue<UShort4> operator+=(const UShort4 &lhs, RValue<UShort4> rhs);
848 //      RValue<UShort4> operator-=(const UShort4 &lhs, RValue<UShort4> rhs);
849 //      RValue<UShort4> operator*=(const UShort4 &lhs, RValue<UShort4> rhs);
850 //      RValue<UShort4> operator/=(const UShort4 &lhs, RValue<UShort4> rhs);
851 //      RValue<UShort4> operator%=(const UShort4 &lhs, RValue<UShort4> rhs);
852 //      RValue<UShort4> operator&=(const UShort4 &lhs, RValue<UShort4> rhs);
853 //      RValue<UShort4> operator|=(const UShort4 &lhs, RValue<UShort4> rhs);
854 //      RValue<UShort4> operator^=(const UShort4 &lhs, RValue<UShort4> rhs);
855         RValue<UShort4> operator<<=(const UShort4 &lhs, unsigned char rhs);
856         RValue<UShort4> operator>>=(const UShort4 &lhs, unsigned char rhs);
857         RValue<UShort4> operator<<=(const UShort4 &lhs, RValue<Long1> rhs);
858         RValue<UShort4> operator>>=(const UShort4 &lhs, RValue<Long1> rhs);
859 //      RValue<UShort4> operator+(RValue<UShort4> val);
860 //      RValue<UShort4> operator-(RValue<UShort4> val);
861         RValue<UShort4> operator~(RValue<UShort4> val);
862 //      RValue<UShort4> operator++(const UShort4 &val, int);   // Post-increment
863 //      const UShort4 &operator++(const UShort4 &val);   // Pre-increment
864 //      RValue<UShort4> operator--(const UShort4 &val, int);   // Post-decrement
865 //      const UShort4 &operator--(const UShort4 &val);   // Pre-decrement
866
867         RValue<UShort4> Max(RValue<UShort4> x, RValue<UShort4> y);
868         RValue<UShort4> Min(RValue<UShort4> x, RValue<UShort4> y);
869         RValue<UShort4> AddSat(RValue<UShort4> x, RValue<UShort4> y);
870         RValue<UShort4> SubSat(RValue<UShort4> x, RValue<UShort4> y);
871         RValue<UShort4> MulHigh(RValue<UShort4> x, RValue<UShort4> y);
872         RValue<UShort4> Average(RValue<UShort4> x, RValue<UShort4> y);
873         RValue<Byte8> Pack(RValue<UShort4> x, RValue<UShort4> y);
874
875         class Short8 : public Variable<Short8>
876         {
877         public:
878         //      Short8();
879                 Short8(short c0, short c1, short c2, short c3, short c4, short c5, short c6, short c7);
880                 Short8(RValue<Short8> rhs);
881         //      Short8(const Short8 &rhs);
882                 Short8(const Reference<Short8> &rhs);
883                 Short8(RValue<Short4> lo, RValue<Short4> hi);
884
885         //      RValue<Short8> operator=(RValue<Short8> rhs) const;
886         //      RValue<Short8> operator=(const Short8 &rhs) const;
887         //      RValue<Short8> operator=(const Reference<Short8> &rhs) const;
888
889                 static Type *getType();
890         };
891
892         RValue<Short8> operator+(RValue<Short8> lhs, RValue<Short8> rhs);
893 //      RValue<Short8> operator-(RValue<Short8> lhs, RValue<Short8> rhs);
894 //      RValue<Short8> operator*(RValue<Short8> lhs, RValue<Short8> rhs);
895 //      RValue<Short8> operator/(RValue<Short8> lhs, RValue<Short8> rhs);
896 //      RValue<Short8> operator%(RValue<Short8> lhs, RValue<Short8> rhs);
897         RValue<Short8> operator&(RValue<Short8> lhs, RValue<Short8> rhs);
898 //      RValue<Short8> operator|(RValue<Short8> lhs, RValue<Short8> rhs);
899 //      RValue<Short8> operator^(RValue<Short8> lhs, RValue<Short8> rhs);
900         RValue<Short8> operator<<(RValue<Short8> lhs, unsigned char rhs);
901         RValue<Short8> operator>>(RValue<Short8> lhs, unsigned char rhs);
902 //      RValue<Short8> operator<<(RValue<Short8> lhs, RValue<Short8> rhs);
903 //      RValue<Short8> operator>>(RValue<Short8> lhs, RValue<Short8> rhs);
904 //      RValue<Short8> operator+=(const Short8 &lhs, RValue<Short8> rhs);
905 //      RValue<Short8> operator-=(const Short8 &lhs, RValue<Short8> rhs);
906 //      RValue<Short8> operator*=(const Short8 &lhs, RValue<Short8> rhs);
907 //      RValue<Short8> operator/=(const Short8 &lhs, RValue<Short8> rhs);
908 //      RValue<Short8> operator%=(const Short8 &lhs, RValue<Short8> rhs);
909 //      RValue<Short8> operator&=(const Short8 &lhs, RValue<Short8> rhs);
910 //      RValue<Short8> operator|=(const Short8 &lhs, RValue<Short8> rhs);
911 //      RValue<Short8> operator^=(const Short8 &lhs, RValue<Short8> rhs);
912 //      RValue<Short8> operator<<=(const Short8 &lhs, RValue<Short8> rhs);
913 //      RValue<Short8> operator>>=(const Short8 &lhs, RValue<Short8> rhs);
914 //      RValue<Short8> operator+(RValue<Short8> val);
915 //      RValue<Short8> operator-(RValue<Short8> val);
916 //      RValue<Short8> operator~(RValue<Short8> val);
917 //      RValue<Short8> operator++(const Short8 &val, int);   // Post-increment
918 //      const Short8 &operator++(const Short8 &val);   // Pre-increment
919 //      RValue<Short8> operator--(const Short8 &val, int);   // Post-decrement
920 //      const Short8 &operator--(const Short8 &val);   // Pre-decrement
921 //      RValue<Bool> operator<(RValue<Short8> lhs, RValue<Short8> rhs);
922 //      RValue<Bool> operator<=(RValue<Short8> lhs, RValue<Short8> rhs);
923 //      RValue<Bool> operator>(RValue<Short8> lhs, RValue<Short8> rhs);
924 //      RValue<Bool> operator>=(RValue<Short8> lhs, RValue<Short8> rhs);
925 //      RValue<Bool> operator!=(RValue<Short8> lhs, RValue<Short8> rhs);
926 //      RValue<Bool> operator==(RValue<Short8> lhs, RValue<Short8> rhs);
927
928         RValue<Short8> MulHigh(RValue<Short8> x, RValue<Short8> y);
929         RValue<Int4> MulAdd(RValue<Short8> x, RValue<Short8> y);
930         RValue<Int4> Abs(RValue<Int4> x);
931
932         class UShort8 : public Variable<UShort8>
933         {
934         public:
935         //      UShort8();
936                 UShort8(unsigned short c0, unsigned short c1, unsigned short c2, unsigned short c3, unsigned short c4, unsigned short c5, unsigned short c6, unsigned short c7);
937                 UShort8(RValue<UShort8> rhs);
938         //      UShort8(const UShort8 &rhs);
939                 UShort8(const Reference<UShort8> &rhs);
940                 UShort8(RValue<UShort4> lo, RValue<UShort4> hi);
941
942                 RValue<UShort8> operator=(RValue<UShort8> rhs) const;
943                 RValue<UShort8> operator=(const UShort8 &rhs) const;
944                 RValue<UShort8> operator=(const Reference<UShort8> &rhs) const;
945
946                 static Type *getType();
947         };
948
949         RValue<UShort8> operator+(RValue<UShort8> lhs, RValue<UShort8> rhs);
950 //      RValue<UShort8> operator-(RValue<UShort8> lhs, RValue<UShort8> rhs);
951         RValue<UShort8> operator*(RValue<UShort8> lhs, RValue<UShort8> rhs);
952 //      RValue<UShort8> operator/(RValue<UShort8> lhs, RValue<UShort8> rhs);
953 //      RValue<UShort8> operator%(RValue<UShort8> lhs, RValue<UShort8> rhs);
954         RValue<UShort8> operator&(RValue<UShort8> lhs, RValue<UShort8> rhs);
955 //      RValue<UShort8> operator|(RValue<UShort8> lhs, RValue<UShort8> rhs);
956 //      RValue<UShort8> operator^(RValue<UShort8> lhs, RValue<UShort8> rhs);
957         RValue<UShort8> operator<<(RValue<UShort8> lhs, unsigned char rhs);
958         RValue<UShort8> operator>>(RValue<UShort8> lhs, unsigned char rhs);
959 //      RValue<UShort8> operator<<(RValue<UShort8> lhs, RValue<UShort8> rhs);
960 //      RValue<UShort8> operator>>(RValue<UShort8> lhs, RValue<UShort8> rhs);
961         RValue<UShort8> operator+=(const UShort8 &lhs, RValue<UShort8> rhs);
962 //      RValue<UShort8> operator-=(const UShort8 &lhs, RValue<UShort8> rhs);
963 //      RValue<UShort8> operator*=(const UShort8 &lhs, RValue<UShort8> rhs);
964 //      RValue<UShort8> operator/=(const UShort8 &lhs, RValue<UShort8> rhs);
965 //      RValue<UShort8> operator%=(const UShort8 &lhs, RValue<UShort8> rhs);
966 //      RValue<UShort8> operator&=(const UShort8 &lhs, RValue<UShort8> rhs);
967 //      RValue<UShort8> operator|=(const UShort8 &lhs, RValue<UShort8> rhs);
968 //      RValue<UShort8> operator^=(const UShort8 &lhs, RValue<UShort8> rhs);
969 //      RValue<UShort8> operator<<=(const UShort8 &lhs, RValue<UShort8> rhs);
970 //      RValue<UShort8> operator>>=(const UShort8 &lhs, RValue<UShort8> rhs);
971 //      RValue<UShort8> operator+(RValue<UShort8> val);
972 //      RValue<UShort8> operator-(RValue<UShort8> val);
973         RValue<UShort8> operator~(RValue<UShort8> val);
974 //      RValue<UShort8> operator++(const UShort8 &val, int);   // Post-increment
975 //      const UShort8 &operator++(const UShort8 &val);   // Pre-increment
976 //      RValue<UShort8> operator--(const UShort8 &val, int);   // Post-decrement
977 //      const UShort8 &operator--(const UShort8 &val);   // Pre-decrement
978 //      RValue<Bool> operator<(RValue<UShort8> lhs, RValue<UShort8> rhs);
979 //      RValue<Bool> operator<=(RValue<UShort8> lhs, RValue<UShort8> rhs);
980 //      RValue<Bool> operator>(RValue<UShort8> lhs, RValue<UShort8> rhs);
981 //      RValue<Bool> operator>=(RValue<UShort8> lhs, RValue<UShort8> rhs);
982 //      RValue<Bool> operator!=(RValue<UShort8> lhs, RValue<UShort8> rhs);
983 //      RValue<Bool> operator==(RValue<UShort8> lhs, RValue<UShort8> rhs);
984
985         RValue<UShort8> Swizzle(RValue<UShort8> x, char select0, char select1, char select2, char select3, char select4, char select5, char select6, char select7);
986         RValue<UShort8> MulHigh(RValue<UShort8> x, RValue<UShort8> y);
987
988         class Int : public Variable<Int>
989         {
990         public:
991                 Int(Argument<Int> argument);
992
993                 explicit Int(RValue<Byte> cast);
994                 explicit Int(RValue<SByte> cast);
995                 explicit Int(RValue<Short> cast);
996                 explicit Int(RValue<UShort> cast);
997                 explicit Int(RValue<Int2> cast);
998                 explicit Int(RValue<Long> cast);
999                 explicit Int(RValue<Float> cast);
1000
1001                 Int();
1002                 Int(int x);
1003                 Int(RValue<Int> rhs);
1004                 Int(RValue<UInt> rhs);
1005                 Int(const Int &rhs);
1006                 Int(const UInt &rhs);
1007                 Int(const Reference<Int> &rhs);
1008                 Int(const Reference<UInt> &rhs);
1009
1010                 RValue<Int> operator=(int rhs) const;
1011                 RValue<Int> operator=(RValue<Int> rhs) const;
1012                 RValue<Int> operator=(RValue<UInt> rhs) const;
1013                 RValue<Int> operator=(const Int &rhs) const;
1014                 RValue<Int> operator=(const UInt &rhs) const;
1015                 RValue<Int> operator=(const Reference<Int> &rhs) const;
1016                 RValue<Int> operator=(const Reference<UInt> &rhs) const;
1017
1018                 static Type *getType();
1019         };
1020
1021         RValue<Int> operator+(RValue<Int> lhs, RValue<Int> rhs);
1022         RValue<Int> operator-(RValue<Int> lhs, RValue<Int> rhs);
1023         RValue<Int> operator*(RValue<Int> lhs, RValue<Int> rhs);
1024         RValue<Int> operator/(RValue<Int> lhs, RValue<Int> rhs);
1025         RValue<Int> operator%(RValue<Int> lhs, RValue<Int> rhs);
1026         RValue<Int> operator&(RValue<Int> lhs, RValue<Int> rhs);
1027         RValue<Int> operator|(RValue<Int> lhs, RValue<Int> rhs);
1028         RValue<Int> operator^(RValue<Int> lhs, RValue<Int> rhs);
1029         RValue<Int> operator<<(RValue<Int> lhs, RValue<Int> rhs);
1030         RValue<Int> operator>>(RValue<Int> lhs, RValue<Int> rhs);
1031         RValue<Int> operator+=(const Int &lhs, RValue<Int> rhs);
1032         RValue<Int> operator-=(const Int &lhs, RValue<Int> rhs);
1033         RValue<Int> operator*=(const Int &lhs, RValue<Int> rhs);
1034         RValue<Int> operator/=(const Int &lhs, RValue<Int> rhs);
1035         RValue<Int> operator%=(const Int &lhs, RValue<Int> rhs);
1036         RValue<Int> operator&=(const Int &lhs, RValue<Int> rhs);
1037         RValue<Int> operator|=(const Int &lhs, RValue<Int> rhs);
1038         RValue<Int> operator^=(const Int &lhs, RValue<Int> rhs);
1039         RValue<Int> operator<<=(const Int &lhs, RValue<Int> rhs);
1040         RValue<Int> operator>>=(const Int &lhs, RValue<Int> rhs);
1041         RValue<Int> operator+(RValue<Int> val);
1042         RValue<Int> operator-(RValue<Int> val);
1043         RValue<Int> operator~(RValue<Int> val);
1044         RValue<Int> operator++(const Int &val, int);   // Post-increment
1045         const Int &operator++(const Int &val);   // Pre-increment
1046         RValue<Int> operator--(const Int &val, int);   // Post-decrement
1047         const Int &operator--(const Int &val);   // Pre-decrement
1048         RValue<Bool> operator<(RValue<Int> lhs, RValue<Int> rhs);
1049         RValue<Bool> operator<=(RValue<Int> lhs, RValue<Int> rhs);
1050         RValue<Bool> operator>(RValue<Int> lhs, RValue<Int> rhs);
1051         RValue<Bool> operator>=(RValue<Int> lhs, RValue<Int> rhs);
1052         RValue<Bool> operator!=(RValue<Int> lhs, RValue<Int> rhs);
1053         RValue<Bool> operator==(RValue<Int> lhs, RValue<Int> rhs);
1054
1055         RValue<Int> Max(RValue<Int> x, RValue<Int> y);
1056         RValue<Int> Min(RValue<Int> x, RValue<Int> y);
1057         RValue<Int> Clamp(RValue<Int> x, RValue<Int> min, RValue<Int> max);
1058         RValue<Int> RoundInt(RValue<Float> cast);
1059
1060         class Long : public Variable<Long>
1061         {
1062         public:
1063         //      Long(Argument<Long> argument);
1064
1065         //      explicit Long(RValue<Short> cast);
1066         //      explicit Long(RValue<UShort> cast);
1067                 explicit Long(RValue<Int> cast);
1068                 explicit Long(RValue<UInt> cast);
1069         //      explicit Long(RValue<Float> cast);
1070
1071                 Long();
1072         //      Long(qword x);
1073                 Long(RValue<Long> rhs);
1074         //      Long(RValue<ULong> rhs);
1075         //      Long(const Long &rhs);
1076         //      Long(const Reference<Long> &rhs);
1077         //      Long(const ULong &rhs);
1078         //      Long(const Reference<ULong> &rhs);
1079
1080                 RValue<Long> operator=(int64_t rhs) const;
1081                 RValue<Long> operator=(RValue<Long> rhs) const;
1082         //      RValue<Long> operator=(RValue<ULong> rhs) const;
1083                 RValue<Long> operator=(const Long &rhs) const;
1084                 RValue<Long> operator=(const Reference<Long> &rhs) const;
1085         //      RValue<Long> operator=(const ULong &rhs) const;
1086         //      RValue<Long> operator=(const Reference<ULong> &rhs) const;
1087
1088                 static Type *getType();
1089         };
1090
1091         RValue<Long> operator+(RValue<Long> lhs, RValue<Long> rhs);
1092         RValue<Long> operator-(RValue<Long> lhs, RValue<Long> rhs);
1093 //      RValue<Long> operator*(RValue<Long> lhs, RValue<Long> rhs);
1094 //      RValue<Long> operator/(RValue<Long> lhs, RValue<Long> rhs);
1095 //      RValue<Long> operator%(RValue<Long> lhs, RValue<Long> rhs);
1096 //      RValue<Long> operator&(RValue<Long> lhs, RValue<Long> rhs);
1097 //      RValue<Long> operator|(RValue<Long> lhs, RValue<Long> rhs);
1098 //      RValue<Long> operator^(RValue<Long> lhs, RValue<Long> rhs);
1099 //      RValue<Long> operator<<(RValue<Long> lhs, RValue<Long> rhs);
1100 //      RValue<Long> operator>>(RValue<Long> lhs, RValue<Long> rhs);
1101         RValue<Long> operator+=(const Long &lhs, RValue<Long> rhs);
1102         RValue<Long> operator-=(const Long &lhs, RValue<Long> rhs);
1103 //      RValue<Long> operator*=(const Long &lhs, RValue<Long> rhs);
1104 //      RValue<Long> operator/=(const Long &lhs, RValue<Long> rhs);
1105 //      RValue<Long> operator%=(const Long &lhs, RValue<Long> rhs);
1106 //      RValue<Long> operator&=(const Long &lhs, RValue<Long> rhs);
1107 //      RValue<Long> operator|=(const Long &lhs, RValue<Long> rhs);
1108 //      RValue<Long> operator^=(const Long &lhs, RValue<Long> rhs);
1109 //      RValue<Long> operator<<=(const Long &lhs, RValue<Long> rhs);
1110 //      RValue<Long> operator>>=(const Long &lhs, RValue<Long> rhs);
1111 //      RValue<Long> operator+(RValue<Long> val);
1112 //      RValue<Long> operator-(RValue<Long> val);
1113 //      RValue<Long> operator~(RValue<Long> val);
1114 //      RValue<Long> operator++(const Long &val, int);   // Post-increment
1115 //      const Long &operator++(const Long &val);   // Pre-increment
1116 //      RValue<Long> operator--(const Long &val, int);   // Post-decrement
1117 //      const Long &operator--(const Long &val);   // Pre-decrement
1118 //      RValue<Bool> operator<(RValue<Long> lhs, RValue<Long> rhs);
1119 //      RValue<Bool> operator<=(RValue<Long> lhs, RValue<Long> rhs);
1120 //      RValue<Bool> operator>(RValue<Long> lhs, RValue<Long> rhs);
1121 //      RValue<Bool> operator>=(RValue<Long> lhs, RValue<Long> rhs);
1122 //      RValue<Bool> operator!=(RValue<Long> lhs, RValue<Long> rhs);
1123 //      RValue<Bool> operator==(RValue<Long> lhs, RValue<Long> rhs);
1124
1125 //      RValue<Long> RoundLong(RValue<Float> cast);
1126         RValue<Long> AddAtomic( RValue<Pointer<Long>> x, RValue<Long> y);
1127
1128         class Long1 : public Variable<Long1>
1129         {
1130         public:
1131         //      Long1(Argument<Long1> argument);
1132
1133         //      explicit Long1(RValue<Short> cast);
1134         //      explicit Long1(RValue<UShort> cast);
1135         //      explicit Long1(RValue<Int> cast);
1136                 explicit Long1(RValue<UInt> cast);
1137         //      explicit Long1(RValue<Float> cast);
1138
1139         //      Long1();
1140         //      Long1(qword x);
1141                 Long1(RValue<Long1> rhs);
1142         //      Long1(RValue<ULong1> rhs);
1143         //      Long1(const Long1 &rhs);
1144         //      Long1(const Reference<Long1> &rhs);
1145         //      Long1(const ULong1 &rhs);
1146         //      Long1(const Reference<ULong1> &rhs);
1147
1148         //      RValue<Long1> operator=(qword rhs) const;
1149         //      RValue<Long1> operator=(RValue<Long1> rhs) const;
1150         //      RValue<Long1> operator=(RValue<ULong1> rhs) const;
1151         //      RValue<Long1> operator=(const Long1 &rhs) const;
1152         //      RValue<Long1> operator=(const Reference<Long1> &rhs) const;
1153         //      RValue<Long1> operator=(const ULong1 &rhs) const;
1154         //      RValue<Long1> operator=(const Reference<ULong1> &rhs) const;
1155
1156                 static Type *getType();
1157         };
1158
1159 //      RValue<Long1> operator+(RValue<Long1> lhs, RValue<Long1> rhs);
1160 //      RValue<Long1> operator-(RValue<Long1> lhs, RValue<Long1> rhs);
1161 //      RValue<Long1> operator*(RValue<Long1> lhs, RValue<Long1> rhs);
1162 //      RValue<Long1> operator/(RValue<Long1> lhs, RValue<Long1> rhs);
1163 //      RValue<Long1> operator%(RValue<Long1> lhs, RValue<Long1> rhs);
1164 //      RValue<Long1> operator&(RValue<Long1> lhs, RValue<Long1> rhs);
1165 //      RValue<Long1> operator|(RValue<Long1> lhs, RValue<Long1> rhs);
1166 //      RValue<Long1> operator^(RValue<Long1> lhs, RValue<Long1> rhs);
1167 //      RValue<Long1> operator<<(RValue<Long1> lhs, RValue<Long1> rhs);
1168 //      RValue<Long1> operator>>(RValue<Long1> lhs, RValue<Long1> rhs);
1169 //      RValue<Long1> operator+=(const Long1 &lhs, RValue<Long1> rhs);
1170 //      RValue<Long1> operator-=(const Long1 &lhs, RValue<Long1> rhs);
1171 //      RValue<Long1> operator*=(const Long1 &lhs, RValue<Long1> rhs);
1172 //      RValue<Long1> operator/=(const Long1 &lhs, RValue<Long1> rhs);
1173 //      RValue<Long1> operator%=(const Long1 &lhs, RValue<Long1> rhs);
1174 //      RValue<Long1> operator&=(const Long1 &lhs, RValue<Long1> rhs);
1175 //      RValue<Long1> operator|=(const Long1 &lhs, RValue<Long1> rhs);
1176 //      RValue<Long1> operator^=(const Long1 &lhs, RValue<Long1> rhs);
1177 //      RValue<Long1> operator<<=(const Long1 &lhs, RValue<Long1> rhs);
1178 //      RValue<Long1> operator>>=(const Long1 &lhs, RValue<Long1> rhs);
1179 //      RValue<Long1> operator+(RValue<Long1> val);
1180 //      RValue<Long1> operator-(RValue<Long1> val);
1181 //      RValue<Long1> operator~(RValue<Long1> val);
1182 //      RValue<Long1> operator++(const Long1 &val, int);   // Post-increment
1183 //      const Long1 &operator++(const Long1 &val);   // Pre-increment
1184 //      RValue<Long1> operator--(const Long1 &val, int);   // Post-decrement
1185 //      const Long1 &operator--(const Long1 &val);   // Pre-decrement
1186 //      RValue<Bool> operator<(RValue<Long1> lhs, RValue<Long1> rhs);
1187 //      RValue<Bool> operator<=(RValue<Long1> lhs, RValue<Long1> rhs);
1188 //      RValue<Bool> operator>(RValue<Long1> lhs, RValue<Long1> rhs);
1189 //      RValue<Bool> operator>=(RValue<Long1> lhs, RValue<Long1> rhs);
1190 //      RValue<Bool> operator!=(RValue<Long1> lhs, RValue<Long1> rhs);
1191 //      RValue<Bool> operator==(RValue<Long1> lhs, RValue<Long1> rhs);
1192
1193 //      RValue<Long1> RoundLong1(RValue<Float> cast);
1194
1195         class UInt : public Variable<UInt>
1196         {
1197         public:
1198                 UInt(Argument<UInt> argument);
1199
1200                 explicit UInt(RValue<UShort> cast);
1201                 explicit UInt(RValue<Long> cast);
1202                 explicit UInt(RValue<Float> cast);
1203
1204                 UInt();
1205                 UInt(int x);
1206                 UInt(unsigned int x);
1207                 UInt(RValue<UInt> rhs);
1208                 UInt(RValue<Int> rhs);
1209                 UInt(const UInt &rhs);
1210                 UInt(const Int &rhs);
1211                 UInt(const Reference<UInt> &rhs);
1212                 UInt(const Reference<Int> &rhs);
1213
1214                 RValue<UInt> operator=(unsigned int rhs) const;
1215                 RValue<UInt> operator=(RValue<UInt> rhs) const;
1216                 RValue<UInt> operator=(RValue<Int> rhs) const;
1217                 RValue<UInt> operator=(const UInt &rhs) const;
1218                 RValue<UInt> operator=(const Int &rhs) const;
1219                 RValue<UInt> operator=(const Reference<UInt> &rhs) const;
1220                 RValue<UInt> operator=(const Reference<Int> &rhs) const;
1221
1222                 static Type *getType();
1223         };
1224
1225         RValue<UInt> operator+(RValue<UInt> lhs, RValue<UInt> rhs);
1226         RValue<UInt> operator-(RValue<UInt> lhs, RValue<UInt> rhs);
1227         RValue<UInt> operator*(RValue<UInt> lhs, RValue<UInt> rhs);
1228         RValue<UInt> operator/(RValue<UInt> lhs, RValue<UInt> rhs);
1229         RValue<UInt> operator%(RValue<UInt> lhs, RValue<UInt> rhs);
1230         RValue<UInt> operator&(RValue<UInt> lhs, RValue<UInt> rhs);
1231         RValue<UInt> operator|(RValue<UInt> lhs, RValue<UInt> rhs);
1232         RValue<UInt> operator^(RValue<UInt> lhs, RValue<UInt> rhs);
1233         RValue<UInt> operator<<(RValue<UInt> lhs, RValue<UInt> rhs);
1234         RValue<UInt> operator>>(RValue<UInt> lhs, RValue<UInt> rhs);
1235         RValue<UInt> operator+=(const UInt &lhs, RValue<UInt> rhs);
1236         RValue<UInt> operator-=(const UInt &lhs, RValue<UInt> rhs);
1237         RValue<UInt> operator*=(const UInt &lhs, RValue<UInt> rhs);
1238         RValue<UInt> operator/=(const UInt &lhs, RValue<UInt> rhs);
1239         RValue<UInt> operator%=(const UInt &lhs, RValue<UInt> rhs);
1240         RValue<UInt> operator&=(const UInt &lhs, RValue<UInt> rhs);
1241         RValue<UInt> operator|=(const UInt &lhs, RValue<UInt> rhs);
1242         RValue<UInt> operator^=(const UInt &lhs, RValue<UInt> rhs);
1243         RValue<UInt> operator<<=(const UInt &lhs, RValue<UInt> rhs);
1244         RValue<UInt> operator>>=(const UInt &lhs, RValue<UInt> rhs);
1245         RValue<UInt> operator+(RValue<UInt> val);
1246         RValue<UInt> operator-(RValue<UInt> val);
1247         RValue<UInt> operator~(RValue<UInt> val);
1248         RValue<UInt> operator++(const UInt &val, int);   // Post-increment
1249         const UInt &operator++(const UInt &val);   // Pre-increment
1250         RValue<UInt> operator--(const UInt &val, int);   // Post-decrement
1251         const UInt &operator--(const UInt &val);   // Pre-decrement
1252         RValue<Bool> operator<(RValue<UInt> lhs, RValue<UInt> rhs);
1253         RValue<Bool> operator<=(RValue<UInt> lhs, RValue<UInt> rhs);
1254         RValue<Bool> operator>(RValue<UInt> lhs, RValue<UInt> rhs);
1255         RValue<Bool> operator>=(RValue<UInt> lhs, RValue<UInt> rhs);
1256         RValue<Bool> operator!=(RValue<UInt> lhs, RValue<UInt> rhs);
1257         RValue<Bool> operator==(RValue<UInt> lhs, RValue<UInt> rhs);
1258
1259         RValue<UInt> Max(RValue<UInt> x, RValue<UInt> y);
1260         RValue<UInt> Min(RValue<UInt> x, RValue<UInt> y);
1261         RValue<UInt> Clamp(RValue<UInt> x, RValue<UInt> min, RValue<UInt> max);
1262 //      RValue<UInt> RoundUInt(RValue<Float> cast);
1263
1264         class Int2 : public Variable<Int2>
1265         {
1266         public:
1267         //      explicit Int2(RValue<Int> cast);
1268                 explicit Int2(RValue<Int4> cast);
1269
1270                 Int2();
1271                 Int2(int x, int y);
1272                 Int2(RValue<Int2> rhs);
1273                 Int2(const Int2 &rhs);
1274                 Int2(const Reference<Int2> &rhs);
1275                 Int2(RValue<Int> lo, RValue<Int> hi);
1276
1277                 RValue<Int2> operator=(RValue<Int2> rhs) const;
1278                 RValue<Int2> operator=(const Int2 &rhs) const;
1279                 RValue<Int2> operator=(const Reference<Int2> &rhs) const;
1280
1281                 static Type *getType();
1282         };
1283
1284         RValue<Int2> operator+(RValue<Int2> lhs, RValue<Int2> rhs);
1285         RValue<Int2> operator-(RValue<Int2> lhs, RValue<Int2> rhs);
1286 //      RValue<Int2> operator*(RValue<Int2> lhs, RValue<Int2> rhs);
1287 //      RValue<Int2> operator/(RValue<Int2> lhs, RValue<Int2> rhs);
1288 //      RValue<Int2> operator%(RValue<Int2> lhs, RValue<Int2> rhs);
1289         RValue<Int2> operator&(RValue<Int2> lhs, RValue<Int2> rhs);
1290         RValue<Int2> operator|(RValue<Int2> lhs, RValue<Int2> rhs);
1291         RValue<Int2> operator^(RValue<Int2> lhs, RValue<Int2> rhs);
1292         RValue<Int2> operator<<(RValue<Int2> lhs, unsigned char rhs);
1293         RValue<Int2> operator>>(RValue<Int2> lhs, unsigned char rhs);
1294         RValue<Int2> operator<<(RValue<Int2> lhs, RValue<Long1> rhs);
1295         RValue<Int2> operator>>(RValue<Int2> lhs, RValue<Long1> rhs);
1296         RValue<Int2> operator+=(const Int2 &lhs, RValue<Int2> rhs);
1297         RValue<Int2> operator-=(const Int2 &lhs, RValue<Int2> rhs);
1298 //      RValue<Int2> operator*=(const Int2 &lhs, RValue<Int2> rhs);
1299 //      RValue<Int2> operator/=(const Int2 &lhs, RValue<Int2> rhs);
1300 //      RValue<Int2> operator%=(const Int2 &lhs, RValue<Int2> rhs);
1301         RValue<Int2> operator&=(const Int2 &lhs, RValue<Int2> rhs);
1302         RValue<Int2> operator|=(const Int2 &lhs, RValue<Int2> rhs);
1303         RValue<Int2> operator^=(const Int2 &lhs, RValue<Int2> rhs);
1304         RValue<Int2> operator<<=(const Int2 &lhs, unsigned char rhs);
1305         RValue<Int2> operator>>=(const Int2 &lhs, unsigned char rhs);
1306         RValue<Int2> operator<<=(const Int2 &lhs, RValue<Long1> rhs);
1307         RValue<Int2> operator>>=(const Int2 &lhs, RValue<Long1> rhs);
1308 //      RValue<Int2> operator+(RValue<Int2> val);
1309 //      RValue<Int2> operator-(RValue<Int2> val);
1310         RValue<Int2> operator~(RValue<Int2> val);
1311 //      RValue<Int2> operator++(const Int2 &val, int);   // Post-increment
1312 //      const Int2 &operator++(const Int2 &val);   // Pre-increment
1313 //      RValue<Int2> operator--(const Int2 &val, int);   // Post-decrement
1314 //      const Int2 &operator--(const Int2 &val);   // Pre-decrement
1315 //      RValue<Bool> operator<(RValue<Int2> lhs, RValue<Int2> rhs);
1316 //      RValue<Bool> operator<=(RValue<Int2> lhs, RValue<Int2> rhs);
1317 //      RValue<Bool> operator>(RValue<Int2> lhs, RValue<Int2> rhs);
1318 //      RValue<Bool> operator>=(RValue<Int2> lhs, RValue<Int2> rhs);
1319 //      RValue<Bool> operator!=(RValue<Int2> lhs, RValue<Int2> rhs);
1320 //      RValue<Bool> operator==(RValue<Int2> lhs, RValue<Int2> rhs);
1321
1322 //      RValue<Int2> RoundInt(RValue<Float4> cast);
1323         RValue<Long1> UnpackLow(RValue<Int2> x, RValue<Int2> y);
1324         RValue<Long1> UnpackHigh(RValue<Int2> x, RValue<Int2> y);
1325         RValue<Int> Extract(RValue<Int2> val, int i);
1326         RValue<Int2> Insert(RValue<Int2> val, RValue<Int> element, int i);
1327
1328         class UInt2 : public Variable<UInt2>
1329         {
1330         public:
1331                 UInt2();
1332                 UInt2(unsigned int x, unsigned int y);
1333                 UInt2(RValue<UInt2> rhs);
1334                 UInt2(const UInt2 &rhs);
1335                 UInt2(const Reference<UInt2> &rhs);
1336
1337                 RValue<UInt2> operator=(RValue<UInt2> rhs) const;
1338                 RValue<UInt2> operator=(const UInt2 &rhs) const;
1339                 RValue<UInt2> operator=(const Reference<UInt2> &rhs) const;
1340
1341                 static Type *getType();
1342         };
1343
1344         RValue<UInt2> operator+(RValue<UInt2> lhs, RValue<UInt2> rhs);
1345         RValue<UInt2> operator-(RValue<UInt2> lhs, RValue<UInt2> rhs);
1346 //      RValue<UInt2> operator*(RValue<UInt2> lhs, RValue<UInt2> rhs);
1347 //      RValue<UInt2> operator/(RValue<UInt2> lhs, RValue<UInt2> rhs);
1348 //      RValue<UInt2> operator%(RValue<UInt2> lhs, RValue<UInt2> rhs);
1349         RValue<UInt2> operator&(RValue<UInt2> lhs, RValue<UInt2> rhs);
1350         RValue<UInt2> operator|(RValue<UInt2> lhs, RValue<UInt2> rhs);
1351         RValue<UInt2> operator^(RValue<UInt2> lhs, RValue<UInt2> rhs);
1352         RValue<UInt2> operator<<(RValue<UInt2> lhs, unsigned char rhs);
1353         RValue<UInt2> operator>>(RValue<UInt2> lhs, unsigned char rhs);
1354         RValue<UInt2> operator<<(RValue<UInt2> lhs, RValue<Long1> rhs);
1355         RValue<UInt2> operator>>(RValue<UInt2> lhs, RValue<Long1> rhs);
1356         RValue<UInt2> operator+=(const UInt2 &lhs, RValue<UInt2> rhs);
1357         RValue<UInt2> operator-=(const UInt2 &lhs, RValue<UInt2> rhs);
1358 //      RValue<UInt2> operator*=(const UInt2 &lhs, RValue<UInt2> rhs);
1359 //      RValue<UInt2> operator/=(const UInt2 &lhs, RValue<UInt2> rhs);
1360 //      RValue<UInt2> operator%=(const UInt2 &lhs, RValue<UInt2> rhs);
1361         RValue<UInt2> operator&=(const UInt2 &lhs, RValue<UInt2> rhs);
1362         RValue<UInt2> operator|=(const UInt2 &lhs, RValue<UInt2> rhs);
1363         RValue<UInt2> operator^=(const UInt2 &lhs, RValue<UInt2> rhs);
1364         RValue<UInt2> operator<<=(const UInt2 &lhs, unsigned char rhs);
1365         RValue<UInt2> operator>>=(const UInt2 &lhs, unsigned char rhs);
1366         RValue<UInt2> operator<<=(const UInt2 &lhs, RValue<Long1> rhs);
1367         RValue<UInt2> operator>>=(const UInt2 &lhs, RValue<Long1> rhs);
1368 //      RValue<UInt2> operator+(RValue<UInt2> val);
1369 //      RValue<UInt2> operator-(RValue<UInt2> val);
1370         RValue<UInt2> operator~(RValue<UInt2> val);
1371 //      RValue<UInt2> operator++(const UInt2 &val, int);   // Post-increment
1372 //      const UInt2 &operator++(const UInt2 &val);   // Pre-increment
1373 //      RValue<UInt2> operator--(const UInt2 &val, int);   // Post-decrement
1374 //      const UInt2 &operator--(const UInt2 &val);   // Pre-decrement
1375 //      RValue<Bool> operator<(RValue<UInt2> lhs, RValue<UInt2> rhs);
1376 //      RValue<Bool> operator<=(RValue<UInt2> lhs, RValue<UInt2> rhs);
1377 //      RValue<Bool> operator>(RValue<UInt2> lhs, RValue<UInt2> rhs);
1378 //      RValue<Bool> operator>=(RValue<UInt2> lhs, RValue<UInt2> rhs);
1379 //      RValue<Bool> operator!=(RValue<UInt2> lhs, RValue<UInt2> rhs);
1380 //      RValue<Bool> operator==(RValue<UInt2> lhs, RValue<UInt2> rhs);
1381
1382 //      RValue<UInt2> RoundInt(RValue<Float4> cast);
1383
1384         class Int4 : public Variable<Int4>
1385         {
1386         public:
1387                 explicit Int4(RValue<Byte4> cast);
1388                 explicit Int4(RValue<SByte4> cast);
1389                 explicit Int4(RValue<Float4> cast);
1390                 explicit Int4(RValue<Short4> cast);
1391                 explicit Int4(RValue<UShort4> cast);
1392
1393                 Int4();
1394                 Int4(int xyzw);
1395                 Int4(int x, int yzw);
1396                 Int4(int x, int y, int zw);
1397                 Int4(int x, int y, int z, int w);
1398                 Int4(RValue<Int4> rhs);
1399                 Int4(const Int4 &rhs);
1400                 Int4(const Reference<Int4> &rhs);
1401                 Int4(RValue<UInt4> rhs);
1402                 Int4(const UInt4 &rhs);
1403                 Int4(const Reference<UInt4> &rhs);
1404                 Int4(RValue<Int2> lo, RValue<Int2> hi);
1405                 Int4(RValue<Int> rhs);
1406                 Int4(const Int &rhs);
1407                 Int4(const Reference<Int> &rhs);
1408
1409                 RValue<Int4> operator=(RValue<Int4> rhs) const;
1410                 RValue<Int4> operator=(const Int4 &rhs) const;
1411                 RValue<Int4> operator=(const Reference<Int4> &rhs) const;
1412
1413                 static Type *getType();
1414
1415         private:
1416                 void constant(int x, int y, int z, int w);
1417         };
1418
1419         RValue<Int4> operator+(RValue<Int4> lhs, RValue<Int4> rhs);
1420         RValue<Int4> operator-(RValue<Int4> lhs, RValue<Int4> rhs);
1421         RValue<Int4> operator*(RValue<Int4> lhs, RValue<Int4> rhs);
1422         RValue<Int4> operator/(RValue<Int4> lhs, RValue<Int4> rhs);
1423         RValue<Int4> operator%(RValue<Int4> lhs, RValue<Int4> rhs);
1424         RValue<Int4> operator&(RValue<Int4> lhs, RValue<Int4> rhs);
1425         RValue<Int4> operator|(RValue<Int4> lhs, RValue<Int4> rhs);
1426         RValue<Int4> operator^(RValue<Int4> lhs, RValue<Int4> rhs);
1427         RValue<Int4> operator<<(RValue<Int4> lhs, unsigned char rhs);
1428         RValue<Int4> operator>>(RValue<Int4> lhs, unsigned char rhs);
1429         RValue<Int4> operator<<(RValue<Int4> lhs, RValue<Int4> rhs);
1430         RValue<Int4> operator>>(RValue<Int4> lhs, RValue<Int4> rhs);
1431         RValue<Int4> operator+=(const Int4 &lhs, RValue<Int4> rhs);
1432         RValue<Int4> operator-=(const Int4 &lhs, RValue<Int4> rhs);
1433         RValue<Int4> operator*=(const Int4 &lhs, RValue<Int4> rhs);
1434 //      RValue<Int4> operator/=(const Int4 &lhs, RValue<Int4> rhs);
1435 //      RValue<Int4> operator%=(const Int4 &lhs, RValue<Int4> rhs);
1436         RValue<Int4> operator&=(const Int4 &lhs, RValue<Int4> rhs);
1437         RValue<Int4> operator|=(const Int4 &lhs, RValue<Int4> rhs);
1438         RValue<Int4> operator^=(const Int4 &lhs, RValue<Int4> rhs);
1439         RValue<Int4> operator<<=(const Int4 &lhs, unsigned char rhs);
1440         RValue<Int4> operator>>=(const Int4 &lhs, unsigned char rhs);
1441         RValue<Int4> operator+(RValue<Int4> val);
1442         RValue<Int4> operator-(RValue<Int4> val);
1443         RValue<Int4> operator~(RValue<Int4> val);
1444 //      RValue<Int4> operator++(const Int4 &val, int);   // Post-increment
1445 //      const Int4 &operator++(const Int4 &val);   // Pre-increment
1446 //      RValue<Int4> operator--(const Int4 &val, int);   // Post-decrement
1447 //      const Int4 &operator--(const Int4 &val);   // Pre-decrement
1448 //      RValue<Bool> operator<(RValue<Int4> lhs, RValue<Int4> rhs);
1449 //      RValue<Bool> operator<=(RValue<Int4> lhs, RValue<Int4> rhs);
1450 //      RValue<Bool> operator>(RValue<Int4> lhs, RValue<Int4> rhs);
1451 //      RValue<Bool> operator>=(RValue<Int4> lhs, RValue<Int4> rhs);
1452 //      RValue<Bool> operator!=(RValue<Int4> lhs, RValue<Int4> rhs);
1453 //      RValue<Bool> operator==(RValue<Int4> lhs, RValue<Int4> rhs);
1454
1455         RValue<Int4> CmpEQ(RValue<Int4> x, RValue<Int4> y);
1456         RValue<Int4> CmpLT(RValue<Int4> x, RValue<Int4> y);
1457         RValue<Int4> CmpLE(RValue<Int4> x, RValue<Int4> y);
1458         RValue<Int4> CmpNEQ(RValue<Int4> x, RValue<Int4> y);
1459         RValue<Int4> CmpNLT(RValue<Int4> x, RValue<Int4> y);
1460         RValue<Int4> CmpNLE(RValue<Int4> x, RValue<Int4> y);
1461         RValue<Int4> Max(RValue<Int4> x, RValue<Int4> y);
1462         RValue<Int4> Min(RValue<Int4> x, RValue<Int4> y);
1463         RValue<Int4> RoundInt(RValue<Float4> cast);
1464         RValue<Short8> Pack(RValue<Int4> x, RValue<Int4> y);
1465         RValue<Int> Extract(RValue<Int4> x, int i);
1466         RValue<Int4> Insert(RValue<Int4> val, RValue<Int> element, int i);
1467         RValue<Int> SignMask(RValue<Int4> x);
1468         RValue<Int4> Swizzle(RValue<Int4> x, unsigned char select);
1469
1470         class UInt4 : public Variable<UInt4>
1471         {
1472         public:
1473                 explicit UInt4(RValue<Float4> cast);
1474
1475                 UInt4();
1476                 UInt4(int xyzw);
1477                 UInt4(int x, int yzw);
1478                 UInt4(int x, int y, int zw);
1479                 UInt4(int x, int y, int z, int w);
1480                 UInt4(unsigned int x, unsigned int y, unsigned int z, unsigned int w);
1481                 UInt4(RValue<UInt4> rhs);
1482                 UInt4(const UInt4 &rhs);
1483                 UInt4(const Reference<UInt4> &rhs);
1484                 UInt4(RValue<Int4> rhs);
1485                 UInt4(const Int4 &rhs);
1486                 UInt4(const Reference<Int4> &rhs);
1487                 UInt4(RValue<UInt2> lo, RValue<UInt2> hi);
1488
1489                 RValue<UInt4> operator=(RValue<UInt4> rhs) const;
1490                 RValue<UInt4> operator=(const UInt4 &rhs) const;
1491                 RValue<UInt4> operator=(const Reference<UInt4> &rhs) const;
1492
1493                 static Type *getType();
1494
1495         private:
1496                 void constant(int x, int y, int z, int w);
1497         };
1498
1499         RValue<UInt4> operator+(RValue<UInt4> lhs, RValue<UInt4> rhs);
1500         RValue<UInt4> operator-(RValue<UInt4> lhs, RValue<UInt4> rhs);
1501         RValue<UInt4> operator*(RValue<UInt4> lhs, RValue<UInt4> rhs);
1502         RValue<UInt4> operator/(RValue<UInt4> lhs, RValue<UInt4> rhs);
1503         RValue<UInt4> operator%(RValue<UInt4> lhs, RValue<UInt4> rhs);
1504         RValue<UInt4> operator&(RValue<UInt4> lhs, RValue<UInt4> rhs);
1505         RValue<UInt4> operator|(RValue<UInt4> lhs, RValue<UInt4> rhs);
1506         RValue<UInt4> operator^(RValue<UInt4> lhs, RValue<UInt4> rhs);
1507         RValue<UInt4> operator<<(RValue<UInt4> lhs, unsigned char rhs);
1508         RValue<UInt4> operator>>(RValue<UInt4> lhs, unsigned char rhs);
1509         RValue<UInt4> operator<<(RValue<UInt4> lhs, RValue<UInt4> rhs);
1510         RValue<UInt4> operator>>(RValue<UInt4> lhs, RValue<UInt4> rhs);
1511         RValue<UInt4> operator+=(const UInt4 &lhs, RValue<UInt4> rhs);
1512         RValue<UInt4> operator-=(const UInt4 &lhs, RValue<UInt4> rhs);
1513         RValue<UInt4> operator*=(const UInt4 &lhs, RValue<UInt4> rhs);
1514 //      RValue<UInt4> operator/=(const UInt4 &lhs, RValue<UInt4> rhs);
1515 //      RValue<UInt4> operator%=(const UInt4 &lhs, RValue<UInt4> rhs);
1516         RValue<UInt4> operator&=(const UInt4 &lhs, RValue<UInt4> rhs);
1517         RValue<UInt4> operator|=(const UInt4 &lhs, RValue<UInt4> rhs);
1518         RValue<UInt4> operator^=(const UInt4 &lhs, RValue<UInt4> rhs);
1519         RValue<UInt4> operator<<=(const UInt4 &lhs, unsigned char rhs);
1520         RValue<UInt4> operator>>=(const UInt4 &lhs, unsigned char rhs);
1521         RValue<UInt4> operator+(RValue<UInt4> val);
1522         RValue<UInt4> operator-(RValue<UInt4> val);
1523         RValue<UInt4> operator~(RValue<UInt4> val);
1524 //      RValue<UInt4> operator++(const UInt4 &val, int);   // Post-increment
1525 //      const UInt4 &operator++(const UInt4 &val);   // Pre-increment
1526 //      RValue<UInt4> operator--(const UInt4 &val, int);   // Post-decrement
1527 //      const UInt4 &operator--(const UInt4 &val);   // Pre-decrement
1528 //      RValue<Bool> operator<(RValue<UInt4> lhs, RValue<UInt4> rhs);
1529 //      RValue<Bool> operator<=(RValue<UInt4> lhs, RValue<UInt4> rhs);
1530 //      RValue<Bool> operator>(RValue<UInt4> lhs, RValue<UInt4> rhs);
1531 //      RValue<Bool> operator>=(RValue<UInt4> lhs, RValue<UInt4> rhs);
1532 //      RValue<Bool> operator!=(RValue<UInt4> lhs, RValue<UInt4> rhs);
1533 //      RValue<Bool> operator==(RValue<UInt4> lhs, RValue<UInt4> rhs);
1534
1535         RValue<UInt4> CmpEQ(RValue<UInt4> x, RValue<UInt4> y);
1536         RValue<UInt4> CmpLT(RValue<UInt4> x, RValue<UInt4> y);
1537         RValue<UInt4> CmpLE(RValue<UInt4> x, RValue<UInt4> y);
1538         RValue<UInt4> CmpNEQ(RValue<UInt4> x, RValue<UInt4> y);
1539         RValue<UInt4> CmpNLT(RValue<UInt4> x, RValue<UInt4> y);
1540         RValue<UInt4> CmpNLE(RValue<UInt4> x, RValue<UInt4> y);
1541         RValue<UInt4> Max(RValue<UInt4> x, RValue<UInt4> y);
1542         RValue<UInt4> Min(RValue<UInt4> x, RValue<UInt4> y);
1543 //      RValue<UInt4> RoundInt(RValue<Float4> cast);
1544         RValue<UShort8> Pack(RValue<UInt4> x, RValue<UInt4> y);
1545
1546         template<int T>
1547         class Swizzle2Float4
1548         {
1549                 friend class Float4;
1550
1551         public:
1552                 operator RValue<Float4>() const;
1553
1554         private:
1555                 Float4 *parent;
1556         };
1557
1558         template<int T>
1559         class SwizzleFloat4
1560         {
1561         public:
1562                 operator RValue<Float4>() const;
1563
1564         private:
1565                 Float4 *parent;
1566         };
1567
1568         template<int T>
1569         class SwizzleMaskFloat4
1570         {
1571                 friend class Float4;
1572
1573         public:
1574                 operator RValue<Float4>() const;
1575
1576                 RValue<Float4> operator=(RValue<Float4> rhs) const;
1577                 RValue<Float4> operator=(RValue<Float> rhs) const;
1578
1579         private:
1580                 Float4 *parent;
1581         };
1582
1583         template<int T>
1584         class SwizzleMask1Float4
1585         {
1586         public:
1587                 operator RValue<Float>() const;
1588                 operator RValue<Float4>() const;
1589
1590                 RValue<Float4> operator=(float x) const;
1591                 RValue<Float4> operator=(RValue<Float4> rhs) const;
1592                 RValue<Float4> operator=(RValue<Float> rhs) const;
1593
1594         private:
1595                 Float4 *parent;
1596         };
1597
1598         template<int T>
1599         class SwizzleMask2Float4
1600         {
1601                 friend class Float4;
1602
1603         public:
1604                 operator RValue<Float4>() const;
1605
1606                 RValue<Float4> operator=(RValue<Float4> rhs) const;
1607
1608         private:
1609                 Float4 *parent;
1610         };
1611
1612         class Float : public Variable<Float>
1613         {
1614         public:
1615                 explicit Float(RValue<Int> cast);
1616
1617                 Float();
1618                 Float(float x);
1619                 Float(RValue<Float> rhs);
1620                 Float(const Float &rhs);
1621                 Float(const Reference<Float> &rhs);
1622
1623                 template<int T>
1624                 Float(const SwizzleMask1Float4<T> &rhs);
1625
1626         //      RValue<Float> operator=(float rhs) const;   // FIXME: Implement
1627                 RValue<Float> operator=(RValue<Float> rhs) const;
1628                 RValue<Float> operator=(const Float &rhs) const;
1629                 RValue<Float> operator=(const Reference<Float> &rhs) const;
1630
1631                 template<int T>
1632                 RValue<Float> operator=(const SwizzleMask1Float4<T> &rhs) const;
1633
1634                 static Type *getType();
1635         };
1636
1637         RValue<Float> operator+(RValue<Float> lhs, RValue<Float> rhs);
1638         RValue<Float> operator-(RValue<Float> lhs, RValue<Float> rhs);
1639         RValue<Float> operator*(RValue<Float> lhs, RValue<Float> rhs);
1640         RValue<Float> operator/(RValue<Float> lhs, RValue<Float> rhs);
1641         RValue<Float> operator+=(const Float &lhs, RValue<Float> rhs);
1642         RValue<Float> operator-=(const Float &lhs, RValue<Float> rhs);
1643         RValue<Float> operator*=(const Float &lhs, RValue<Float> rhs);
1644         RValue<Float> operator/=(const Float &lhs, RValue<Float> rhs);
1645         RValue<Float> operator+(RValue<Float> val);
1646         RValue<Float> operator-(RValue<Float> val);
1647         RValue<Bool> operator<(RValue<Float> lhs, RValue<Float> rhs);
1648         RValue<Bool> operator<=(RValue<Float> lhs, RValue<Float> rhs);
1649         RValue<Bool> operator>(RValue<Float> lhs, RValue<Float> rhs);
1650         RValue<Bool> operator>=(RValue<Float> lhs, RValue<Float> rhs);
1651         RValue<Bool> operator!=(RValue<Float> lhs, RValue<Float> rhs);
1652         RValue<Bool> operator==(RValue<Float> lhs, RValue<Float> rhs);
1653
1654         RValue<Float> Abs(RValue<Float> x);
1655         RValue<Float> Max(RValue<Float> x, RValue<Float> y);
1656         RValue<Float> Min(RValue<Float> x, RValue<Float> y);
1657         RValue<Float> Rcp_pp(RValue<Float> val, bool exactAtPow2 = false);
1658         RValue<Float> RcpSqrt_pp(RValue<Float> val);
1659         RValue<Float> Sqrt(RValue<Float> x);
1660         RValue<Float> Round(RValue<Float> val);
1661         RValue<Float> Trunc(RValue<Float> val);
1662         RValue<Float> Frac(RValue<Float> val);
1663         RValue<Float> Floor(RValue<Float> val);
1664         RValue<Float> Ceil(RValue<Float> val);
1665
1666         class Float2 : public Variable<Float2>
1667         {
1668         public:
1669         //      explicit Float2(RValue<Byte2> cast);
1670         //      explicit Float2(RValue<Short2> cast);
1671         //      explicit Float2(RValue<UShort2> cast);
1672         //      explicit Float2(RValue<Int2> cast);
1673         //      explicit Float2(RValue<UInt2> cast);
1674                 explicit Float2(RValue<Float4> cast);
1675
1676         //      Float2();
1677         //      Float2(float x, float y);
1678         //      Float2(RValue<Float2> rhs);
1679         //      Float2(const Float2 &rhs);
1680         //      Float2(const Reference<Float2> &rhs);
1681         //      Float2(RValue<Float> rhs);
1682         //      Float2(const Float &rhs);
1683         //      Float2(const Reference<Float> &rhs);
1684
1685         //      template<int T>
1686         //      Float2(const SwizzleMask1Float4<T> &rhs);
1687
1688         //      RValue<Float2> operator=(float replicate) const;
1689         //      RValue<Float2> operator=(RValue<Float2> rhs) const;
1690         //      RValue<Float2> operator=(const Float2 &rhs) const;
1691         //      RValue<Float2> operator=(const Reference<Float2> &rhs) const;
1692         //      RValue<Float2> operator=(RValue<Float> rhs) const;
1693         //      RValue<Float2> operator=(const Float &rhs) const;
1694         //      RValue<Float2> operator=(const Reference<Float> &rhs) const;
1695
1696         //      template<int T>
1697         //      RValue<Float2> operator=(const SwizzleMask1Float4<T> &rhs);
1698
1699                 static Type *getType();
1700         };
1701
1702 //      RValue<Float2> operator+(RValue<Float2> lhs, RValue<Float2> rhs);
1703 //      RValue<Float2> operator-(RValue<Float2> lhs, RValue<Float2> rhs);
1704 //      RValue<Float2> operator*(RValue<Float2> lhs, RValue<Float2> rhs);
1705 //      RValue<Float2> operator/(RValue<Float2> lhs, RValue<Float2> rhs);
1706 //      RValue<Float2> operator%(RValue<Float2> lhs, RValue<Float2> rhs);
1707 //      RValue<Float2> operator+=(const Float2 &lhs, RValue<Float2> rhs);
1708 //      RValue<Float2> operator-=(const Float2 &lhs, RValue<Float2> rhs);
1709 //      RValue<Float2> operator*=(const Float2 &lhs, RValue<Float2> rhs);
1710 //      RValue<Float2> operator/=(const Float2 &lhs, RValue<Float2> rhs);
1711 //      RValue<Float2> operator%=(const Float2 &lhs, RValue<Float2> rhs);
1712 //      RValue<Float2> operator+(RValue<Float2> val);
1713 //      RValue<Float2> operator-(RValue<Float2> val);
1714
1715 //      RValue<Float2> Abs(RValue<Float2> x);
1716 //      RValue<Float2> Max(RValue<Float2> x, RValue<Float2> y);
1717 //      RValue<Float2> Min(RValue<Float2> x, RValue<Float2> y);
1718 //      RValue<Float2> Swizzle(RValue<Float2> x, unsigned char select);
1719 //      RValue<Float2> Mask(Float2 &lhs, RValue<Float2> rhs, unsigned char select);
1720
1721         class Float4 : public Variable<Float4>
1722         {
1723         public:
1724                 explicit Float4(RValue<Byte4> cast);
1725                 explicit Float4(RValue<SByte4> cast);
1726                 explicit Float4(RValue<Short4> cast);
1727                 explicit Float4(RValue<UShort4> cast);
1728                 explicit Float4(RValue<Int4> cast);
1729                 explicit Float4(RValue<UInt4> cast);
1730
1731                 Float4();
1732                 Float4(float xyzw);
1733                 Float4(float x, float yzw);
1734                 Float4(float x, float y, float zw);
1735                 Float4(float x, float y, float z, float w);
1736                 Float4(RValue<Float4> rhs);
1737                 Float4(const Float4 &rhs);
1738                 Float4(const Reference<Float4> &rhs);
1739                 Float4(RValue<Float> rhs);
1740                 Float4(const Float &rhs);
1741                 Float4(const Reference<Float> &rhs);
1742
1743                 template<int T>
1744                 Float4(const SwizzleMask1Float4<T> &rhs);
1745                 template<int T>
1746                 Float4(const SwizzleFloat4<T> &rhs);
1747                 template<int X, int Y>
1748                 Float4(const Swizzle2Float4<X> &x, const Swizzle2Float4<Y> &y);
1749                 template<int X, int Y>
1750                 Float4(const SwizzleMask2Float4<X> &x, const Swizzle2Float4<Y> &y);
1751                 template<int X, int Y>
1752                 Float4(const Swizzle2Float4<X> &x, const SwizzleMask2Float4<Y> &y);
1753                 template<int X, int Y>
1754                 Float4(const SwizzleMask2Float4<X> &x, const SwizzleMask2Float4<Y> &y);
1755
1756                 RValue<Float4> operator=(float replicate) const;
1757                 RValue<Float4> operator=(RValue<Float4> rhs) const;
1758                 RValue<Float4> operator=(const Float4 &rhs) const;
1759                 RValue<Float4> operator=(const Reference<Float4> &rhs) const;
1760                 RValue<Float4> operator=(RValue<Float> rhs) const;
1761                 RValue<Float4> operator=(const Float &rhs) const;
1762                 RValue<Float4> operator=(const Reference<Float> &rhs) const;
1763
1764                 template<int T>
1765                 RValue<Float4> operator=(const SwizzleMask1Float4<T> &rhs);
1766                 template<int T>
1767                 RValue<Float4> operator=(const SwizzleFloat4<T> &rhs);
1768
1769                 static Type *getType();
1770
1771                 union
1772                 {
1773                         SwizzleMask1Float4<0x00> x;
1774                         SwizzleMask1Float4<0x55> y;
1775                         SwizzleMask1Float4<0xAA> z;
1776                         SwizzleMask1Float4<0xFF> w;
1777                         Swizzle2Float4<0x00>     xx;
1778                         Swizzle2Float4<0x01>     yx;
1779                         Swizzle2Float4<0x02>     zx;
1780                         Swizzle2Float4<0x03>     wx;
1781                         SwizzleMask2Float4<0x54> xy;
1782                         Swizzle2Float4<0x55>     yy;
1783                         Swizzle2Float4<0x56>     zy;
1784                         Swizzle2Float4<0x57>     wy;
1785                         SwizzleMask2Float4<0xA8> xz;
1786                         SwizzleMask2Float4<0xA9> yz;
1787                         Swizzle2Float4<0xAA>     zz;
1788                         Swizzle2Float4<0xAB>     wz;
1789                         SwizzleMask2Float4<0xFC> xw;
1790                         SwizzleMask2Float4<0xFD> yw;
1791                         SwizzleMask2Float4<0xFE> zw;
1792                         Swizzle2Float4<0xFF>     ww;
1793                         SwizzleFloat4<0x00>      xxx;
1794                         SwizzleFloat4<0x01>      yxx;
1795                         SwizzleFloat4<0x02>      zxx;
1796                         SwizzleFloat4<0x03>      wxx;
1797                         SwizzleFloat4<0x04>      xyx;
1798                         SwizzleFloat4<0x05>      yyx;
1799                         SwizzleFloat4<0x06>      zyx;
1800                         SwizzleFloat4<0x07>      wyx;
1801                         SwizzleFloat4<0x08>      xzx;
1802                         SwizzleFloat4<0x09>      yzx;
1803                         SwizzleFloat4<0x0A>      zzx;
1804                         SwizzleFloat4<0x0B>      wzx;
1805                         SwizzleFloat4<0x0C>      xwx;
1806                         SwizzleFloat4<0x0D>      ywx;
1807                         SwizzleFloat4<0x0E>      zwx;
1808                         SwizzleFloat4<0x0F>      wwx;
1809                         SwizzleFloat4<0x50>      xxy;
1810                         SwizzleFloat4<0x51>      yxy;
1811                         SwizzleFloat4<0x52>      zxy;
1812                         SwizzleFloat4<0x53>      wxy;
1813                         SwizzleFloat4<0x54>      xyy;
1814                         SwizzleFloat4<0x55>      yyy;
1815                         SwizzleFloat4<0x56>      zyy;
1816                         SwizzleFloat4<0x57>      wyy;
1817                         SwizzleFloat4<0x58>      xzy;
1818                         SwizzleFloat4<0x59>      yzy;
1819                         SwizzleFloat4<0x5A>      zzy;
1820                         SwizzleFloat4<0x5B>      wzy;
1821                         SwizzleFloat4<0x5C>      xwy;
1822                         SwizzleFloat4<0x5D>      ywy;
1823                         SwizzleFloat4<0x5E>      zwy;
1824                         SwizzleFloat4<0x5F>      wwy;
1825                         SwizzleFloat4<0xA0>      xxz;
1826                         SwizzleFloat4<0xA1>      yxz;
1827                         SwizzleFloat4<0xA2>      zxz;
1828                         SwizzleFloat4<0xA3>      wxz;
1829                         SwizzleMaskFloat4<0xA4>  xyz;
1830                         SwizzleFloat4<0xA5>      yyz;
1831                         SwizzleFloat4<0xA6>      zyz;
1832                         SwizzleFloat4<0xA7>      wyz;
1833                         SwizzleFloat4<0xA8>      xzz;
1834                         SwizzleFloat4<0xA9>      yzz;
1835                         SwizzleFloat4<0xAA>      zzz;
1836                         SwizzleFloat4<0xAB>      wzz;
1837                         SwizzleFloat4<0xAC>      xwz;
1838                         SwizzleFloat4<0xAD>      ywz;
1839                         SwizzleFloat4<0xAE>      zwz;
1840                         SwizzleFloat4<0xAF>      wwz;
1841                         SwizzleFloat4<0xF0>      xxw;
1842                         SwizzleFloat4<0xF1>      yxw;
1843                         SwizzleFloat4<0xF2>      zxw;
1844                         SwizzleFloat4<0xF3>      wxw;
1845                         SwizzleMaskFloat4<0xF4>  xyw;
1846                         SwizzleFloat4<0xF5>      yyw;
1847                         SwizzleFloat4<0xF6>      zyw;
1848                         SwizzleFloat4<0xF7>      wyw;
1849                         SwizzleMaskFloat4<0xF8>  xzw;
1850                         SwizzleMaskFloat4<0xF9>  yzw;
1851                         SwizzleFloat4<0xFA>      zzw;
1852                         SwizzleFloat4<0xFB>      wzw;
1853                         SwizzleFloat4<0xFC>      xww;
1854                         SwizzleFloat4<0xFD>      yww;
1855                         SwizzleFloat4<0xFE>      zww;
1856                         SwizzleFloat4<0xFF>      www;
1857                         SwizzleFloat4<0x00>      xxxx;
1858                         SwizzleFloat4<0x01>      yxxx;
1859                         SwizzleFloat4<0x02>      zxxx;
1860                         SwizzleFloat4<0x03>      wxxx;
1861                         SwizzleFloat4<0x04>      xyxx;
1862                         SwizzleFloat4<0x05>      yyxx;
1863                         SwizzleFloat4<0x06>      zyxx;
1864                         SwizzleFloat4<0x07>      wyxx;
1865                         SwizzleFloat4<0x08>      xzxx;
1866                         SwizzleFloat4<0x09>      yzxx;
1867                         SwizzleFloat4<0x0A>      zzxx;
1868                         SwizzleFloat4<0x0B>      wzxx;
1869                         SwizzleFloat4<0x0C>      xwxx;
1870                         SwizzleFloat4<0x0D>      ywxx;
1871                         SwizzleFloat4<0x0E>      zwxx;
1872                         SwizzleFloat4<0x0F>      wwxx;
1873                         SwizzleFloat4<0x10>      xxyx;
1874                         SwizzleFloat4<0x11>      yxyx;
1875                         SwizzleFloat4<0x12>      zxyx;
1876                         SwizzleFloat4<0x13>      wxyx;
1877                         SwizzleFloat4<0x14>      xyyx;
1878                         SwizzleFloat4<0x15>      yyyx;
1879                         SwizzleFloat4<0x16>      zyyx;
1880                         SwizzleFloat4<0x17>      wyyx;
1881                         SwizzleFloat4<0x18>      xzyx;
1882                         SwizzleFloat4<0x19>      yzyx;
1883                         SwizzleFloat4<0x1A>      zzyx;
1884                         SwizzleFloat4<0x1B>      wzyx;
1885                         SwizzleFloat4<0x1C>      xwyx;
1886                         SwizzleFloat4<0x1D>      ywyx;
1887                         SwizzleFloat4<0x1E>      zwyx;
1888                         SwizzleFloat4<0x1F>      wwyx;
1889                         SwizzleFloat4<0x20>      xxzx;
1890                         SwizzleFloat4<0x21>      yxzx;
1891                         SwizzleFloat4<0x22>      zxzx;
1892                         SwizzleFloat4<0x23>      wxzx;
1893                         SwizzleFloat4<0x24>      xyzx;
1894                         SwizzleFloat4<0x25>      yyzx;
1895                         SwizzleFloat4<0x26>      zyzx;
1896                         SwizzleFloat4<0x27>      wyzx;
1897                         SwizzleFloat4<0x28>      xzzx;
1898                         SwizzleFloat4<0x29>      yzzx;
1899                         SwizzleFloat4<0x2A>      zzzx;
1900                         SwizzleFloat4<0x2B>      wzzx;
1901                         SwizzleFloat4<0x2C>      xwzx;
1902                         SwizzleFloat4<0x2D>      ywzx;
1903                         SwizzleFloat4<0x2E>      zwzx;
1904                         SwizzleFloat4<0x2F>      wwzx;
1905                         SwizzleFloat4<0x30>      xxwx;
1906                         SwizzleFloat4<0x31>      yxwx;
1907                         SwizzleFloat4<0x32>      zxwx;
1908                         SwizzleFloat4<0x33>      wxwx;
1909                         SwizzleFloat4<0x34>      xywx;
1910                         SwizzleFloat4<0x35>      yywx;
1911                         SwizzleFloat4<0x36>      zywx;
1912                         SwizzleFloat4<0x37>      wywx;
1913                         SwizzleFloat4<0x38>      xzwx;
1914                         SwizzleFloat4<0x39>      yzwx;
1915                         SwizzleFloat4<0x3A>      zzwx;
1916                         SwizzleFloat4<0x3B>      wzwx;
1917                         SwizzleFloat4<0x3C>      xwwx;
1918                         SwizzleFloat4<0x3D>      ywwx;
1919                         SwizzleFloat4<0x3E>      zwwx;
1920                         SwizzleFloat4<0x3F>      wwwx;
1921                         SwizzleFloat4<0x40>      xxxy;
1922                         SwizzleFloat4<0x41>      yxxy;
1923                         SwizzleFloat4<0x42>      zxxy;
1924                         SwizzleFloat4<0x43>      wxxy;
1925                         SwizzleFloat4<0x44>      xyxy;
1926                         SwizzleFloat4<0x45>      yyxy;
1927                         SwizzleFloat4<0x46>      zyxy;
1928                         SwizzleFloat4<0x47>      wyxy;
1929                         SwizzleFloat4<0x48>      xzxy;
1930                         SwizzleFloat4<0x49>      yzxy;
1931                         SwizzleFloat4<0x4A>      zzxy;
1932                         SwizzleFloat4<0x4B>      wzxy;
1933                         SwizzleFloat4<0x4C>      xwxy;
1934                         SwizzleFloat4<0x4D>      ywxy;
1935                         SwizzleFloat4<0x4E>      zwxy;
1936                         SwizzleFloat4<0x4F>      wwxy;
1937                         SwizzleFloat4<0x50>      xxyy;
1938                         SwizzleFloat4<0x51>      yxyy;
1939                         SwizzleFloat4<0x52>      zxyy;
1940                         SwizzleFloat4<0x53>      wxyy;
1941                         SwizzleFloat4<0x54>      xyyy;
1942                         SwizzleFloat4<0x55>      yyyy;
1943                         SwizzleFloat4<0x56>      zyyy;
1944                         SwizzleFloat4<0x57>      wyyy;
1945                         SwizzleFloat4<0x58>      xzyy;
1946                         SwizzleFloat4<0x59>      yzyy;
1947                         SwizzleFloat4<0x5A>      zzyy;
1948                         SwizzleFloat4<0x5B>      wzyy;
1949                         SwizzleFloat4<0x5C>      xwyy;
1950                         SwizzleFloat4<0x5D>      ywyy;
1951                         SwizzleFloat4<0x5E>      zwyy;
1952                         SwizzleFloat4<0x5F>      wwyy;
1953                         SwizzleFloat4<0x60>      xxzy;
1954                         SwizzleFloat4<0x61>      yxzy;
1955                         SwizzleFloat4<0x62>      zxzy;
1956                         SwizzleFloat4<0x63>      wxzy;
1957                         SwizzleFloat4<0x64>      xyzy;
1958                         SwizzleFloat4<0x65>      yyzy;
1959                         SwizzleFloat4<0x66>      zyzy;
1960                         SwizzleFloat4<0x67>      wyzy;
1961                         SwizzleFloat4<0x68>      xzzy;
1962                         SwizzleFloat4<0x69>      yzzy;
1963                         SwizzleFloat4<0x6A>      zzzy;
1964                         SwizzleFloat4<0x6B>      wzzy;
1965                         SwizzleFloat4<0x6C>      xwzy;
1966                         SwizzleFloat4<0x6D>      ywzy;
1967                         SwizzleFloat4<0x6E>      zwzy;
1968                         SwizzleFloat4<0x6F>      wwzy;
1969                         SwizzleFloat4<0x70>      xxwy;
1970                         SwizzleFloat4<0x71>      yxwy;
1971                         SwizzleFloat4<0x72>      zxwy;
1972                         SwizzleFloat4<0x73>      wxwy;
1973                         SwizzleFloat4<0x74>      xywy;
1974                         SwizzleFloat4<0x75>      yywy;
1975                         SwizzleFloat4<0x76>      zywy;
1976                         SwizzleFloat4<0x77>      wywy;
1977                         SwizzleFloat4<0x78>      xzwy;
1978                         SwizzleFloat4<0x79>      yzwy;
1979                         SwizzleFloat4<0x7A>      zzwy;
1980                         SwizzleFloat4<0x7B>      wzwy;
1981                         SwizzleFloat4<0x7C>      xwwy;
1982                         SwizzleFloat4<0x7D>      ywwy;
1983                         SwizzleFloat4<0x7E>      zwwy;
1984                         SwizzleFloat4<0x7F>      wwwy;
1985                         SwizzleFloat4<0x80>      xxxz;
1986                         SwizzleFloat4<0x81>      yxxz;
1987                         SwizzleFloat4<0x82>      zxxz;
1988                         SwizzleFloat4<0x83>      wxxz;
1989                         SwizzleFloat4<0x84>      xyxz;
1990                         SwizzleFloat4<0x85>      yyxz;
1991                         SwizzleFloat4<0x86>      zyxz;
1992                         SwizzleFloat4<0x87>      wyxz;
1993                         SwizzleFloat4<0x88>      xzxz;
1994                         SwizzleFloat4<0x89>      yzxz;
1995                         SwizzleFloat4<0x8A>      zzxz;
1996                         SwizzleFloat4<0x8B>      wzxz;
1997                         SwizzleFloat4<0x8C>      xwxz;
1998                         SwizzleFloat4<0x8D>      ywxz;
1999                         SwizzleFloat4<0x8E>      zwxz;
2000                         SwizzleFloat4<0x8F>      wwxz;
2001                         SwizzleFloat4<0x90>      xxyz;
2002                         SwizzleFloat4<0x91>      yxyz;
2003                         SwizzleFloat4<0x92>      zxyz;
2004                         SwizzleFloat4<0x93>      wxyz;
2005                         SwizzleFloat4<0x94>      xyyz;
2006                         SwizzleFloat4<0x95>      yyyz;
2007                         SwizzleFloat4<0x96>      zyyz;
2008                         SwizzleFloat4<0x97>      wyyz;
2009                         SwizzleFloat4<0x98>      xzyz;
2010                         SwizzleFloat4<0x99>      yzyz;
2011                         SwizzleFloat4<0x9A>      zzyz;
2012                         SwizzleFloat4<0x9B>      wzyz;
2013                         SwizzleFloat4<0x9C>      xwyz;
2014                         SwizzleFloat4<0x9D>      ywyz;
2015                         SwizzleFloat4<0x9E>      zwyz;
2016                         SwizzleFloat4<0x9F>      wwyz;
2017                         SwizzleFloat4<0xA0>      xxzz;
2018                         SwizzleFloat4<0xA1>      yxzz;
2019                         SwizzleFloat4<0xA2>      zxzz;
2020                         SwizzleFloat4<0xA3>      wxzz;
2021                         SwizzleFloat4<0xA4>      xyzz;
2022                         SwizzleFloat4<0xA5>      yyzz;
2023                         SwizzleFloat4<0xA6>      zyzz;
2024                         SwizzleFloat4<0xA7>      wyzz;
2025                         SwizzleFloat4<0xA8>      xzzz;
2026                         SwizzleFloat4<0xA9>      yzzz;
2027                         SwizzleFloat4<0xAA>      zzzz;
2028                         SwizzleFloat4<0xAB>      wzzz;
2029                         SwizzleFloat4<0xAC>      xwzz;
2030                         SwizzleFloat4<0xAD>      ywzz;
2031                         SwizzleFloat4<0xAE>      zwzz;
2032                         SwizzleFloat4<0xAF>      wwzz;
2033                         SwizzleFloat4<0xB0>      xxwz;
2034                         SwizzleFloat4<0xB1>      yxwz;
2035                         SwizzleFloat4<0xB2>      zxwz;
2036                         SwizzleFloat4<0xB3>      wxwz;
2037                         SwizzleFloat4<0xB4>      xywz;
2038                         SwizzleFloat4<0xB5>      yywz;
2039                         SwizzleFloat4<0xB6>      zywz;
2040                         SwizzleFloat4<0xB7>      wywz;
2041                         SwizzleFloat4<0xB8>      xzwz;
2042                         SwizzleFloat4<0xB9>      yzwz;
2043                         SwizzleFloat4<0xBA>      zzwz;
2044                         SwizzleFloat4<0xBB>      wzwz;
2045                         SwizzleFloat4<0xBC>      xwwz;
2046                         SwizzleFloat4<0xBD>      ywwz;
2047                         SwizzleFloat4<0xBE>      zwwz;
2048                         SwizzleFloat4<0xBF>      wwwz;
2049                         SwizzleFloat4<0xC0>      xxxw;
2050                         SwizzleFloat4<0xC1>      yxxw;
2051                         SwizzleFloat4<0xC2>      zxxw;
2052                         SwizzleFloat4<0xC3>      wxxw;
2053                         SwizzleFloat4<0xC4>      xyxw;
2054                         SwizzleFloat4<0xC5>      yyxw;
2055                         SwizzleFloat4<0xC6>      zyxw;
2056                         SwizzleFloat4<0xC7>      wyxw;
2057                         SwizzleFloat4<0xC8>      xzxw;
2058                         SwizzleFloat4<0xC9>      yzxw;
2059                         SwizzleFloat4<0xCA>      zzxw;
2060                         SwizzleFloat4<0xCB>      wzxw;
2061                         SwizzleFloat4<0xCC>      xwxw;
2062                         SwizzleFloat4<0xCD>      ywxw;
2063                         SwizzleFloat4<0xCE>      zwxw;
2064                         SwizzleFloat4<0xCF>      wwxw;
2065                         SwizzleFloat4<0xD0>      xxyw;
2066                         SwizzleFloat4<0xD1>      yxyw;
2067                         SwizzleFloat4<0xD2>      zxyw;
2068                         SwizzleFloat4<0xD3>      wxyw;
2069                         SwizzleFloat4<0xD4>      xyyw;
2070                         SwizzleFloat4<0xD5>      yyyw;
2071                         SwizzleFloat4<0xD6>      zyyw;
2072                         SwizzleFloat4<0xD7>      wyyw;
2073                         SwizzleFloat4<0xD8>      xzyw;
2074                         SwizzleFloat4<0xD9>      yzyw;
2075                         SwizzleFloat4<0xDA>      zzyw;
2076                         SwizzleFloat4<0xDB>      wzyw;
2077                         SwizzleFloat4<0xDC>      xwyw;
2078                         SwizzleFloat4<0xDD>      ywyw;
2079                         SwizzleFloat4<0xDE>      zwyw;
2080                         SwizzleFloat4<0xDF>      wwyw;
2081                         SwizzleFloat4<0xE0>      xxzw;
2082                         SwizzleFloat4<0xE1>      yxzw;
2083                         SwizzleFloat4<0xE2>      zxzw;
2084                         SwizzleFloat4<0xE3>      wxzw;
2085                         SwizzleMaskFloat4<0xE4>  xyzw;
2086                         SwizzleFloat4<0xE5>      yyzw;
2087                         SwizzleFloat4<0xE6>      zyzw;
2088                         SwizzleFloat4<0xE7>      wyzw;
2089                         SwizzleFloat4<0xE8>      xzzw;
2090                         SwizzleFloat4<0xE9>      yzzw;
2091                         SwizzleFloat4<0xEA>      zzzw;
2092                         SwizzleFloat4<0xEB>      wzzw;
2093                         SwizzleFloat4<0xEC>      xwzw;
2094                         SwizzleFloat4<0xED>      ywzw;
2095                         SwizzleFloat4<0xEE>      zwzw;
2096                         SwizzleFloat4<0xEF>      wwzw;
2097                         SwizzleFloat4<0xF0>      xxww;
2098                         SwizzleFloat4<0xF1>      yxww;
2099                         SwizzleFloat4<0xF2>      zxww;
2100                         SwizzleFloat4<0xF3>      wxww;
2101                         SwizzleFloat4<0xF4>      xyww;
2102                         SwizzleFloat4<0xF5>      yyww;
2103                         SwizzleFloat4<0xF6>      zyww;
2104                         SwizzleFloat4<0xF7>      wyww;
2105                         SwizzleFloat4<0xF8>      xzww;
2106                         SwizzleFloat4<0xF9>      yzww;
2107                         SwizzleFloat4<0xFA>      zzww;
2108                         SwizzleFloat4<0xFB>      wzww;
2109                         SwizzleFloat4<0xFC>      xwww;
2110                         SwizzleFloat4<0xFD>      ywww;
2111                         SwizzleFloat4<0xFE>      zwww;
2112                         SwizzleFloat4<0xFF>      wwww;
2113                 };
2114
2115         private:
2116                 void constant(float x, float y, float z, float w);
2117         };
2118
2119         RValue<Float4> operator+(RValue<Float4> lhs, RValue<Float4> rhs);
2120         RValue<Float4> operator-(RValue<Float4> lhs, RValue<Float4> rhs);
2121         RValue<Float4> operator*(RValue<Float4> lhs, RValue<Float4> rhs);
2122         RValue<Float4> operator/(RValue<Float4> lhs, RValue<Float4> rhs);
2123         RValue<Float4> operator%(RValue<Float4> lhs, RValue<Float4> rhs);
2124         RValue<Float4> operator+=(const Float4 &lhs, RValue<Float4> rhs);
2125         RValue<Float4> operator-=(const Float4 &lhs, RValue<Float4> rhs);
2126         RValue<Float4> operator*=(const Float4 &lhs, RValue<Float4> rhs);
2127         RValue<Float4> operator/=(const Float4 &lhs, RValue<Float4> rhs);
2128         RValue<Float4> operator%=(const Float4 &lhs, RValue<Float4> rhs);
2129         RValue<Float4> operator+(RValue<Float4> val);
2130         RValue<Float4> operator-(RValue<Float4> val);
2131
2132         RValue<Float4> Abs(RValue<Float4> x);
2133         RValue<Float4> Max(RValue<Float4> x, RValue<Float4> y);
2134         RValue<Float4> Min(RValue<Float4> x, RValue<Float4> y);
2135         RValue<Float4> Rcp_pp(RValue<Float4> val, bool exactAtPow2 = false);
2136         RValue<Float4> RcpSqrt_pp(RValue<Float4> val);
2137         RValue<Float4> Sqrt(RValue<Float4> x);
2138         RValue<Float4> Insert(const Float4 &val, RValue<Float> element, int i);
2139         RValue<Float> Extract(RValue<Float4> x, int i);
2140         RValue<Float4> Swizzle(RValue<Float4> x, unsigned char select);
2141         RValue<Float4> ShuffleLowHigh(RValue<Float4> x, RValue<Float4> y, unsigned char imm);
2142         RValue<Float4> UnpackLow(RValue<Float4> x, RValue<Float4> y);
2143         RValue<Float4> UnpackHigh(RValue<Float4> x, RValue<Float4> y);
2144         RValue<Float4> Mask(Float4 &lhs, RValue<Float4> rhs, unsigned char select);
2145         RValue<Int> SignMask(RValue<Float4> x);
2146         RValue<Int4> CmpEQ(RValue<Float4> x, RValue<Float4> y);
2147         RValue<Int4> CmpLT(RValue<Float4> x, RValue<Float4> y);
2148         RValue<Int4> CmpLE(RValue<Float4> x, RValue<Float4> y);
2149         RValue<Int4> CmpNEQ(RValue<Float4> x, RValue<Float4> y);
2150         RValue<Int4> CmpNLT(RValue<Float4> x, RValue<Float4> y);
2151         RValue<Int4> CmpNLE(RValue<Float4> x, RValue<Float4> y);
2152         RValue<Float4> Round(RValue<Float4> x);
2153         RValue<Float4> Trunc(RValue<Float4> x);
2154         RValue<Float4> Frac(RValue<Float4> x);
2155         RValue<Float4> Floor(RValue<Float4> x);
2156         RValue<Float4> Ceil(RValue<Float4> x);
2157
2158         template<class T>
2159         class Pointer : public Variable<Pointer<T>>
2160         {
2161         public:
2162                 template<class S>
2163                 Pointer(RValue<Pointer<S>> pointerS, int alignment = 1) : alignment(alignment)
2164                 {
2165                         Value *pointerT = Nucleus::createBitCast(pointerS.value, Nucleus::getPointerType(T::getType()));
2166                         LValue<Pointer<T>>::storeValue(pointerT);
2167                 }
2168
2169                 template<class S>
2170                 Pointer(const Pointer<S> &pointer, int alignment = 1) : alignment(alignment)
2171                 {
2172                         Value *pointerS = pointer.loadValue(alignment);
2173                         Value *pointerT = Nucleus::createBitCast(pointerS, Nucleus::getPointerType(T::getType()));
2174                         LValue<Pointer<T>>::storeValue(pointerT);
2175                 }
2176
2177                 Pointer(Argument<Pointer<T>> argument);
2178                 explicit Pointer(const void *external);
2179
2180                 Pointer();
2181                 Pointer(RValue<Pointer<T>> rhs);
2182                 Pointer(const Pointer<T> &rhs);
2183                 Pointer(const Reference<Pointer<T>> &rhs);
2184
2185                 RValue<Pointer<T>> operator=(RValue<Pointer<T>> rhs) const;
2186                 RValue<Pointer<T>> operator=(const Pointer<T> &rhs) const;
2187                 RValue<Pointer<T>> operator=(const Reference<Pointer<T>> &rhs) const;
2188
2189                 Reference<T> operator*();
2190                 Reference<T> operator[](int index);
2191                 Reference<T> operator[](RValue<Int> index);
2192
2193                 static Type *getType();
2194
2195         private:
2196                 const int alignment;
2197         };
2198
2199         RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, int offset);
2200         RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<Int> offset);
2201         RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<UInt> offset);
2202         RValue<Pointer<Byte>> operator+=(const Pointer<Byte> &lhs, int offset);
2203         RValue<Pointer<Byte>> operator+=(const Pointer<Byte> &lhs, RValue<Int> offset);
2204         RValue<Pointer<Byte>> operator+=(const Pointer<Byte> &lhs, RValue<UInt> offset);
2205
2206         RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, int offset);
2207         RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, RValue<Int> offset);
2208         RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, RValue<UInt> offset);
2209         RValue<Pointer<Byte>> operator-=(const Pointer<Byte> &lhs, int offset);
2210         RValue<Pointer<Byte>> operator-=(const Pointer<Byte> &lhs, RValue<Int> offset);
2211         RValue<Pointer<Byte>> operator-=(const Pointer<Byte> &lhs, RValue<UInt> offset);
2212
2213         template<class T, int S = 1>
2214         class Array : public Variable<T>
2215         {
2216         public:
2217                 Array(int size = S);
2218
2219                 Reference<T> operator[](int index);
2220                 Reference<T> operator[](RValue<Int> index);
2221         };
2222
2223 //      RValue<Array<T>> operator++(const Array<T> &val, int);   // Post-increment
2224 //      const Array<T> &operator++(const Array<T> &val);   // Pre-increment
2225 //      RValue<Array<T>> operator--(const Array<T> &val, int);   // Post-decrement
2226 //      const Array<T> &operator--(const Array<T> &val);   // Pre-decrement
2227
2228         struct Loop
2229         {
2230                 Loop(bool init) : loopOnce(init)
2231                 {
2232                 }
2233
2234                 operator bool()
2235                 {
2236                         return loopOnce;
2237                 }
2238
2239                 bool operator=(bool value)
2240                 {
2241                         return loopOnce = value;
2242                 }
2243
2244                 bool setup()
2245                 {
2246                         if(Nucleus::getInsertBlock() != endBB)
2247                         {
2248                                 testBB = Nucleus::createBasicBlock();
2249
2250                                 Nucleus::createBr(testBB);
2251                                 Nucleus::setInsertBlock(testBB);
2252
2253                                 return true;
2254                         }
2255
2256                         return false;
2257                 }
2258
2259                 bool test(RValue<Bool> cmp)
2260                 {
2261                         BasicBlock *bodyBB = Nucleus::createBasicBlock();
2262                         endBB = Nucleus::createBasicBlock();
2263
2264                         Nucleus::createCondBr(cmp.value, bodyBB, endBB);
2265                         Nucleus::setInsertBlock(bodyBB);
2266
2267                         return true;
2268                 }
2269
2270                 void end()
2271                 {
2272                         Nucleus::createBr(testBB);
2273                         Nucleus::setInsertBlock(endBB);
2274                 }
2275
2276         private:
2277                 BasicBlock *testBB = nullptr;
2278                 BasicBlock *endBB = nullptr;
2279                 bool loopOnce = true;
2280         };
2281
2282         bool branch(RValue<Bool> cmp, BasicBlock *bodyBB, BasicBlock *endBB);
2283         void endIf(BasicBlock *falseBB);
2284         bool elseBlock(BasicBlock *falseBB);
2285         BasicBlock *beginElse();
2286
2287         void Return();
2288         void Return(bool ret);
2289         void Return(const Int &ret);
2290
2291         template<class T>
2292         void Return(const Pointer<T> &ret);
2293
2294         template<class T>
2295         void Return(RValue<Pointer<T>> ret);
2296
2297         template<unsigned int index, typename... Arguments>
2298         struct ArgI;
2299
2300         template<typename Arg0, typename... Arguments>
2301         struct ArgI<0, Arg0, Arguments...>
2302         {
2303                 typedef Arg0 Type;
2304         };
2305
2306         template<unsigned int index, typename Arg0, typename... Arguments>
2307         struct ArgI<index, Arg0, Arguments...>
2308         {
2309                 typedef typename ArgI<index - 1, Arguments...>::Type Type;
2310         };
2311
2312         // Generic template, leave undefined!
2313         template<typename FunctionType>
2314         class Function;
2315
2316         // Specialized for function types
2317         template<typename Return, typename... Arguments>
2318         class Function<Return(Arguments...)>
2319         {
2320         public:
2321                 Function();
2322
2323                 virtual ~Function();
2324
2325                 template<int index>
2326                 Argument<typename ArgI<index, Arguments...>::Type> Arg() const
2327                 {
2328                         Value *arg = Nucleus::getArgument(index);
2329                         return Argument<typename ArgI<index, Arguments...>::Type>(arg);
2330                 }
2331
2332                 Routine *operator()(const wchar_t *name, ...);
2333
2334         protected:
2335                 Nucleus *core;
2336                 std::vector<Type*> arguments;
2337         };
2338
2339         template<typename Return>
2340         class Function<Return()> : public Function<Return(Void)>
2341         {
2342         };
2343
2344         template<int index, typename Return, typename... Arguments>
2345         Argument<typename ArgI<index, Arguments...>::Type> Arg(Function<Return(Arguments...)> &function)
2346         {
2347                 return Argument<typename ArgI<index, Arguments...>::Type>(function.arg(index));
2348         }
2349
2350         RValue<Long> Ticks();
2351 }
2352
2353 namespace sw
2354 {
2355         template<class T>
2356         LValue<T>::LValue(int arraySize)
2357         {
2358                 address = Nucleus::allocateStackVariable(T::getType(), arraySize);
2359         }
2360
2361         template<class T>
2362         Value *LValue<T>::loadValue(unsigned int alignment) const
2363         {
2364                 return Nucleus::createLoad(address, T::getType(), false, alignment);
2365         }
2366
2367         template<class T>
2368         Value *LValue<T>::storeValue(Value *value, unsigned int alignment) const
2369         {
2370                 return Nucleus::createStore(value, address, T::getType(), false, alignment);
2371         }
2372
2373         template<class T>
2374         Value *LValue<T>::getAddress(Value *index) const
2375         {
2376                 return Nucleus::createGEP(address, T::getType(), index);
2377         }
2378
2379         template<class T>
2380         Variable<T>::Variable(int arraySize) : LValue<T>(arraySize)
2381         {
2382         }
2383
2384         template<class T>
2385         RValue<Pointer<T>> Variable<T>::operator&()
2386         {
2387                 return RValue<Pointer<T>>(LValue<T>::address);
2388         }
2389
2390         template<class T>
2391         Reference<T>::Reference(Value *pointer, int alignment) : alignment(alignment)
2392         {
2393                 address = pointer;
2394         }
2395
2396         template<class T>
2397         RValue<T> Reference<T>::operator=(RValue<T> rhs) const
2398         {
2399                 Nucleus::createStore(rhs.value, address, T::getType(), false, alignment);
2400
2401                 return rhs;
2402         }
2403
2404         template<class T>
2405         RValue<T> Reference<T>::operator=(const Reference<T> &ref) const
2406         {
2407                 Value *tmp = Nucleus::createLoad(ref.address, T::getType(), false, ref.alignment);
2408                 Nucleus::createStore(tmp, address, T::getType(), false, alignment);
2409
2410                 return RValue<T>(tmp);
2411         }
2412
2413         template<class T>
2414         RValue<T> Reference<T>::operator+=(RValue<T> rhs) const
2415         {
2416                 return *this = *this + rhs;
2417         }
2418
2419         template<class T>
2420         Value *Reference<T>::loadValue() const
2421         {
2422                 return Nucleus::createLoad(address, T::getType(), false, alignment);
2423         }
2424
2425         template<class T>
2426         int Reference<T>::getAlignment() const
2427         {
2428                 return alignment;
2429         }
2430
2431         template<class T>
2432         RValue<T>::RValue(Value *rvalue)
2433         {
2434                 value = rvalue;
2435         }
2436
2437         template<class T>
2438         RValue<T>::RValue(const T &lvalue)
2439         {
2440                 value = lvalue.loadValue();
2441         }
2442
2443         template<class T>
2444         RValue<T>::RValue(typename IntLiteral<T>::type i)
2445         {
2446                 value = (Value*)Nucleus::createConstantInt(i);
2447         }
2448
2449         template<class T>
2450         RValue<T>::RValue(typename FloatLiteral<T>::type f)
2451         {
2452                 value = (Value*)Nucleus::createConstantFloat(f);
2453         }
2454
2455         template<class T>
2456         RValue<T>::RValue(const Reference<T> &ref)
2457         {
2458                 value = ref.loadValue();
2459         }
2460
2461         template<int T>
2462         Swizzle2Float4<T>::operator RValue<Float4>() const
2463         {
2464                 Value *vector = parent->loadValue();
2465
2466                 return Swizzle(RValue<Float4>(vector), T);
2467         }
2468
2469         template<int T>
2470         SwizzleFloat4<T>::operator RValue<Float4>() const
2471         {
2472                 Value *vector = parent->loadValue();
2473
2474                 return Swizzle(RValue<Float4>(vector), T);
2475         }
2476
2477         template<int T>
2478         SwizzleMaskFloat4<T>::operator RValue<Float4>() const
2479         {
2480                 Value *vector = parent->loadValue();
2481
2482                 return Swizzle(RValue<Float4>(vector), T);
2483         }
2484
2485         template<int T>
2486         RValue<Float4> SwizzleMaskFloat4<T>::operator=(RValue<Float4> rhs) const
2487         {
2488                 return Mask(*parent, rhs, T);
2489         }
2490
2491         template<int T>
2492         RValue<Float4> SwizzleMaskFloat4<T>::operator=(RValue<Float> rhs) const
2493         {
2494                 return Mask(*parent, Float4(rhs), T);
2495         }
2496
2497         template<int T>
2498         SwizzleMask1Float4<T>::operator RValue<Float>() const   // FIXME: Call a non-template function
2499         {
2500                 return Extract(*parent, T & 0x3);
2501         }
2502
2503         template<int T>
2504         SwizzleMask1Float4<T>::operator RValue<Float4>() const
2505         {
2506                 Value *vector = parent->loadValue();
2507
2508                 return Swizzle(RValue<Float4>(vector), T);
2509         }
2510
2511         template<int T>
2512         RValue<Float4> SwizzleMask1Float4<T>::operator=(float x) const
2513         {
2514                 return Insert(*parent, Float(x), T & 0x3);
2515         }
2516
2517         template<int T>
2518         RValue<Float4> SwizzleMask1Float4<T>::operator=(RValue<Float4> rhs) const
2519         {
2520                 return Mask(*parent, Float4(rhs), T);
2521         }
2522
2523         template<int T>
2524         RValue<Float4> SwizzleMask1Float4<T>::operator=(RValue<Float> rhs) const   // FIXME: Call a non-template function
2525         {
2526                 return Insert(*parent, rhs, T & 0x3);
2527         }
2528
2529         template<int T>
2530         SwizzleMask2Float4<T>::operator RValue<Float4>() const
2531         {
2532                 Value *vector = parent->loadValue();
2533
2534                 return Swizzle(RValue<Float4>(vector), T);
2535         }
2536
2537         template<int T>
2538         RValue<Float4> SwizzleMask2Float4<T>::operator=(RValue<Float4> rhs) const
2539         {
2540                 return Mask(*parent, Float4(rhs), T);
2541         }
2542
2543         template<int T>
2544         Float::Float(const SwizzleMask1Float4<T> &rhs)
2545         {
2546                 *this = rhs.operator RValue<Float>();
2547         }
2548
2549         template<int T>
2550         RValue<Float> Float::operator=(const SwizzleMask1Float4<T> &rhs) const
2551         {
2552                 return *this = rhs.operator RValue<Float>();
2553         }
2554
2555         template<int T>
2556         Float4::Float4(const SwizzleMask1Float4<T> &rhs)
2557         {
2558                 xyzw.parent = this;
2559
2560                 *this = rhs.operator RValue<Float4>();
2561         }
2562
2563         template<int T>
2564         Float4::Float4(const SwizzleFloat4<T> &rhs)
2565         {
2566                 xyzw.parent = this;
2567
2568                 *this = rhs.operator RValue<Float4>();
2569         }
2570
2571         template<int X, int Y>
2572         Float4::Float4(const Swizzle2Float4<X> &x, const Swizzle2Float4<Y> &y)
2573         {
2574                 xyzw.parent = this;
2575
2576                 *this = ShuffleLowHigh(*x.parent, *y.parent, (X & 0xF) | (Y & 0xF) << 4);
2577         }
2578
2579         template<int X, int Y>
2580         Float4::Float4(const SwizzleMask2Float4<X> &x, const Swizzle2Float4<Y> &y)
2581         {
2582                 xyzw.parent = this;
2583
2584                 *this = ShuffleLowHigh(*x.parent, *y.parent, (X & 0xF) | (Y & 0xF) << 4);
2585         }
2586
2587         template<int X, int Y>
2588         Float4::Float4(const Swizzle2Float4<X> &x, const SwizzleMask2Float4<Y> &y)
2589         {
2590                 xyzw.parent = this;
2591
2592                 *this = ShuffleLowHigh(*x.parent, *y.parent, (X & 0xF) | (Y & 0xF) << 4);
2593         }
2594
2595         template<int X, int Y>
2596         Float4::Float4(const SwizzleMask2Float4<X> &x, const SwizzleMask2Float4<Y> &y)
2597         {
2598                 xyzw.parent = this;
2599
2600                 *this = ShuffleLowHigh(*x.parent, *y.parent, (X & 0xF) | (Y & 0xF) << 4);
2601         }
2602
2603         template<int T>
2604         RValue<Float4> Float4::operator=(const SwizzleMask1Float4<T> &rhs)
2605         {
2606                 return *this = rhs.operator RValue<Float4>();
2607         }
2608
2609         template<int T>
2610         RValue<Float4> Float4::operator=(const SwizzleFloat4<T> &rhs)
2611         {
2612                 return *this = rhs.operator RValue<Float4>();
2613         }
2614
2615         template<class T>
2616         Pointer<T>::Pointer(Argument<Pointer<T>> argument) : alignment(1)
2617         {
2618                 LValue<Pointer<T>>::storeValue(argument.value);
2619         }
2620
2621         template<class T>
2622         Pointer<T>::Pointer(const void *external) : alignment((intptr_t)external & 0x0000000F ? 1 : 16)
2623         {
2624                 Value *globalPointer = Nucleus::createConstantPointer(external, T::getType(), alignment);
2625
2626                 LValue<Pointer<T>>::storeValue(globalPointer);
2627         }
2628
2629         template<class T>
2630         Pointer<T>::Pointer() : alignment(1)
2631         {
2632                 LValue<Pointer<T>>::storeValue(Nucleus::createNullPointer(T::getType()));
2633         }
2634
2635         template<class T>
2636         Pointer<T>::Pointer(RValue<Pointer<T>> rhs) : alignment(1)
2637         {
2638                 LValue<Pointer<T>>::storeValue(rhs.value);
2639         }
2640
2641         template<class T>
2642         Pointer<T>::Pointer(const Pointer<T> &rhs) : alignment(rhs.alignment)
2643         {
2644                 Value *value = rhs.loadValue();
2645                 LValue<Pointer<T>>::storeValue(value);
2646         }
2647
2648         template<class T>
2649         Pointer<T>::Pointer(const Reference<Pointer<T>> &rhs) : alignment(rhs.getAlignment())
2650         {
2651                 Value *value = rhs.loadValue();
2652                 LValue<Pointer<T>>::storeValue(value);
2653         }
2654
2655         template<class T>
2656         RValue<Pointer<T>> Pointer<T>::operator=(RValue<Pointer<T>> rhs) const
2657         {
2658                 LValue<Pointer<T>>::storeValue(rhs.value);
2659
2660                 return rhs;
2661         }
2662
2663         template<class T>
2664         RValue<Pointer<T>> Pointer<T>::operator=(const Pointer<T> &rhs) const
2665         {
2666                 Value *value = rhs.loadValue();
2667                 LValue<Pointer<T>>::storeValue(value);
2668
2669                 return RValue<Pointer<T>>(value);
2670         }
2671
2672         template<class T>
2673         RValue<Pointer<T>> Pointer<T>::operator=(const Reference<Pointer<T>> &rhs) const
2674         {
2675                 Value *value = rhs.loadValue();
2676                 LValue<Pointer<T>>::storeValue(value);
2677
2678                 return RValue<Pointer<T>>(value);
2679         }
2680
2681         template<class T>
2682         Reference<T> Pointer<T>::operator*()
2683         {
2684                 return Reference<T>(LValue<Pointer<T>>::loadValue(), alignment);
2685         }
2686
2687         template<class T>
2688         Reference<T> Pointer<T>::operator[](int index)
2689         {
2690                 Value *element = Nucleus::createGEP(LValue<Pointer<T>>::loadValue(), T::getType(), (Value*)Nucleus::createConstantInt(index));
2691
2692                 return Reference<T>(element, alignment);
2693         }
2694
2695         template<class T>
2696         Reference<T> Pointer<T>::operator[](RValue<Int> index)
2697         {
2698                 Value *element = Nucleus::createGEP(LValue<Pointer<T>>::loadValue(), T::getType(), index.value);
2699
2700                 return Reference<T>(element, alignment);
2701         }
2702
2703         template<class T>
2704         Type *Pointer<T>::getType()
2705         {
2706                 return Nucleus::getPointerType(T::getType());
2707         }
2708
2709         template<class T, int S>
2710         Array<T, S>::Array(int size) : Variable<T>(size)
2711         {
2712         }
2713
2714         template<class T, int S>
2715         Reference<T> Array<T, S>::operator[](int index)
2716         {
2717                 Value *element = LValue<T>::getAddress((Value*)Nucleus::createConstantInt(index));
2718
2719                 return Reference<T>(element);
2720         }
2721
2722         template<class T, int S>
2723         Reference<T> Array<T, S>::operator[](RValue<Int> index)
2724         {
2725                 Value *element = LValue<T>::getAddress(index.value);
2726
2727                 return Reference<T>(element);
2728         }
2729
2730 //      template<class T>
2731 //      RValue<Array<T>> operator++(const Array<T> &val, int)
2732 //      {
2733 //              // FIXME: Requires storing the address of the array
2734 //      }
2735
2736 //      template<class T>
2737 //      const Array<T> &operator++(const Array<T> &val)
2738 //      {
2739 //              // FIXME: Requires storing the address of the array
2740 //      }
2741
2742 //      template<class T>
2743 //      RValue<Array<T>> operator--(const Array<T> &val, int)
2744 //      {
2745 //              // FIXME: Requires storing the address of the array
2746 //      }
2747
2748 //      template<class T>
2749 //      const Array<T> &operator--(const Array<T> &val)
2750 //      {
2751 //              // FIXME: Requires storing the address of the array
2752 //      }
2753
2754         template<class T>
2755         RValue<T> IfThenElse(RValue<Bool> condition, RValue<T> ifTrue, RValue<T> ifFalse)
2756         {
2757                 return RValue<T>(Nucleus::createSelect(condition.value, ifTrue.value, ifFalse.value));
2758         }
2759
2760         template<class T>
2761         RValue<T> IfThenElse(RValue<Bool> condition, const T &ifTrue, RValue<T> ifFalse)
2762         {
2763                 Value *trueValue = ifTrue.loadValue();
2764
2765                 return RValue<T>(Nucleus::createSelect(condition.value, trueValue, ifFalse.value));
2766         }
2767
2768         template<class T>
2769         RValue<T> IfThenElse(RValue<Bool> condition, RValue<T> ifTrue, const T &ifFalse)
2770         {
2771                 Value *falseValue = ifFalse.loadValue();
2772
2773                 return RValue<T>(Nucleus::createSelect(condition.value, ifTrue.value, falseValue));
2774         }
2775
2776         template<class T>
2777         RValue<T> IfThenElse(RValue<Bool> condition, const T &ifTrue, const T &ifFalse)
2778         {
2779                 Value *trueValue = ifTrue.loadValue();
2780                 Value *falseValue = ifFalse.loadValue();
2781
2782                 return RValue<T>(Nucleus::createSelect(condition.value, trueValue, falseValue));
2783         }
2784
2785         template<class T>
2786         void Return(const Pointer<T> &ret)
2787         {
2788                 Nucleus::createRet(Nucleus::createLoad(ret.address, Pointer<T>::getType()));
2789                 Nucleus::setInsertBlock(Nucleus::createBasicBlock());
2790         }
2791
2792         template<class T>
2793         void Return(RValue<Pointer<T>> ret)
2794         {
2795                 Nucleus::createRet(ret.value);
2796                 Nucleus::setInsertBlock(Nucleus::createBasicBlock());
2797         }
2798
2799         template<typename Return, typename... Arguments>
2800         Function<Return(Arguments...)>::Function()
2801         {
2802                 core = new Nucleus();
2803
2804                 Type *types[] = {Arguments::getType()...};
2805                 for(Type *type : types)
2806                 {
2807                         if(type != Void::getType())
2808                         {
2809                                 arguments.push_back(type);
2810                         }
2811                 }
2812
2813                 Nucleus::createFunction(Return::getType(), arguments);
2814         }
2815
2816         template<typename Return, typename... Arguments>
2817         Function<Return(Arguments...)>::~Function()
2818         {
2819                 delete core;
2820         }
2821
2822         template<typename Return, typename... Arguments>
2823         Routine *Function<Return(Arguments...)>::operator()(const wchar_t *name, ...)
2824         {
2825                 wchar_t fullName[1024 + 1];
2826
2827                 va_list vararg;
2828                 va_start(vararg, name);
2829                 vswprintf(fullName, 1024, name, vararg);
2830                 va_end(vararg);
2831
2832                 return core->acquireRoutine(fullName, true);
2833         }
2834
2835         template<class T, class S>
2836         RValue<T> ReinterpretCast(RValue<S> val)
2837         {
2838                 return RValue<T>(Nucleus::createBitCast(val.value, T::getType()));
2839         }
2840
2841         template<class T, class S>
2842         RValue<T> ReinterpretCast(const LValue<S> &var)
2843         {
2844                 Value *val = var.loadValue();
2845
2846                 return RValue<T>(Nucleus::createBitCast(val, T::getType()));
2847         }
2848
2849         template<class T, class S>
2850         RValue<T> ReinterpretCast(const Reference<S> &var)
2851         {
2852                 return ReinterpretCast<T>(RValue<S>(var));
2853         }
2854
2855         template<class T, class S>
2856         RValue<T> As(RValue<S> val)
2857         {
2858                 return ReinterpretCast<T>(val);
2859         }
2860
2861         template<class T, class S>
2862         RValue<T> As(const LValue<S> &var)
2863         {
2864                 return ReinterpretCast<T>(var);
2865         }
2866
2867         template<class T, class S>
2868         RValue<T> As(const Reference<S> &val)
2869         {
2870                 return ReinterpretCast<T>(val);
2871         }
2872
2873         extern BasicBlock *falseBB__;
2874
2875         #define For(init, cond, inc) \
2876         for(Loop loop__ = true; loop__; loop__ = false) \
2877         for(init; loop__.setup() && loop__.test(cond); inc, loop__.end())
2878
2879         #define While(cond) For((void)0, cond, (void)0)
2880
2881         #define Do                                            \
2882         {                                                     \
2883                 BasicBlock *body__ = Nucleus::createBasicBlock(); \
2884                 Nucleus::createBr(body__);                        \
2885                 Nucleus::setInsertBlock(body__);
2886
2887         #define Until(cond)                                     \
2888                 BasicBlock *end__ = Nucleus::createBasicBlock();    \
2889                 Nucleus::createCondBr((cond).value, end__, body__); \
2890                 Nucleus::setInsertBlock(end__);                     \
2891         }
2892
2893         #define If(cond)                                        \
2894         for(BasicBlock *trueBB__ = Nucleus::createBasicBlock(), \
2895             *falseBB__ = Nucleus::createBasicBlock(),           \
2896             *endBB__ = Nucleus::createBasicBlock(),             \
2897             *onceBB__ = endBB__;                                \
2898             onceBB__ && branch(cond, trueBB__, falseBB__);      \
2899             onceBB__ = nullptr,                                 \
2900             Nucleus::createBr(endBB__),                         \
2901             Nucleus::setInsertBlock(falseBB__),                 \
2902             Nucleus::createBr(endBB__),                         \
2903             Nucleus::setInsertBlock(endBB__),                   \
2904             endIf(falseBB__))
2905
2906         #define Else                                         \
2907         for(BasicBlock *elseBB__ = beginElse(),              \
2908             *endBB__ = Nucleus::getInsertBlock(),            \
2909             *onceBB__ = endBB__;                             \
2910             onceBB__ && elseBlock(elseBB__);                 \
2911             onceBB__ = nullptr,                              \
2912             Nucleus::createBr(endBB__),                      \
2913             Nucleus::setInsertBlock(endBB__))
2914 }
2915
2916 #endif   // sw_Reactor_hpp