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