OSDN Git Service

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