OSDN Git Service

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