OSDN Git Service

4cdb9bef86377245de73250ff6b113279546961c
[android-x86/external-swiftshader.git] / src / Reactor / SubzeroReactor.cpp
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 #include "Nucleus.hpp"
16
17 #include "Reactor.hpp"
18 #include "Routine.hpp"
19
20 #include "src/IceTypes.h"
21 #include "src/IceCfg.h"
22 #include "src/IceELFStreamer.h"
23 #include "src/IceGlobalContext.h"
24 #include "src/IceCfgNode.h"
25 #include "src/IceELFObjectWriter.h"
26
27 #include "llvm/Support/FileSystem.h"
28 #include "llvm/Support/raw_os_ostream.h"
29
30 #define WIN32_LEAN_AND_MEAN
31 #define NOMINMAX
32 #include <Windows.h>
33
34 #include <mutex>
35 #include <limits>
36 #include <iostream>
37 #include <cassert>
38
39 namespace
40 {
41         Ice::GlobalContext *context = nullptr;
42         Ice::Cfg *function = nullptr;
43         Ice::CfgNode *basicBlock = nullptr;
44         Ice::CfgLocalAllocatorScope *allocator = nullptr;
45         sw::Routine *routine = nullptr;
46
47         std::mutex codegenMutex;
48
49         Ice::ELFFileStreamer *elfFile = nullptr;
50         Ice::Fdstream *out = nullptr;
51 }
52
53 namespace sw
54 {
55         enum EmulatedType
56         {
57                 EmulatedShift = 16,
58                 EmulatedV2 = 2 << EmulatedShift,
59                 EmulatedV4 = 4 << EmulatedShift,
60                 EmulatedV8 = 8 << EmulatedShift,
61                 EmulatedBits = EmulatedV2 | EmulatedV4 | EmulatedV8,
62
63                 Type_v2i32 = Ice::IceType_v4i32 | EmulatedV2,
64                 Type_v4i16 = Ice::IceType_v8i16 | EmulatedV4,
65                 Type_v2i16 = Ice::IceType_v8i16 | EmulatedV2,
66                 Type_v8i8 =  Ice::IceType_v16i8 | EmulatedV8,
67                 Type_v4i8 =  Ice::IceType_v16i8 | EmulatedV4,
68         };
69
70         class Value : public Ice::Variable {};
71         class BasicBlock : public Ice::CfgNode {};
72
73         Ice::Type T(Type *t)
74         {
75                 static_assert(Ice::IceType_NUM < EmulatedBits, "Ice::Type overlaps with our emulated types!");
76                 return (Ice::Type)(reinterpret_cast<std::intptr_t>(t) & ~EmulatedBits);
77         }
78
79         Type *T(Ice::Type t)
80         {
81                 return reinterpret_cast<Type*>(t);
82         }
83
84         Type *T(EmulatedType t)
85         {
86                 return reinterpret_cast<Type*>(t);
87         }
88
89         Value *V(Ice::Variable *v)
90         {
91                 return reinterpret_cast<Value*>(v);
92         }
93
94         BasicBlock *B(Ice::CfgNode *b)
95         {
96                 return reinterpret_cast<BasicBlock*>(b);
97         }
98
99         Optimization optimization[10] = {InstructionCombining, Disabled};
100
101         using ElfHeader = std::conditional<sizeof(void*) == 8, Elf64_Ehdr, Elf32_Ehdr>::type;
102         using SectionHeader = std::conditional<sizeof(void*) == 8, Elf64_Shdr, Elf32_Shdr>::type;
103
104         inline const SectionHeader *sectionHeader(const ElfHeader *elfHeader)
105         {
106                 return reinterpret_cast<const SectionHeader*>((intptr_t)elfHeader + elfHeader->e_shoff);
107         }
108  
109         inline const SectionHeader *elfSection(const ElfHeader *elfHeader, int index)
110         {
111                 return &sectionHeader(elfHeader)[index];
112         }
113
114         static void *relocateSymbol(const ElfHeader *elfHeader, const Elf32_Rel &relocation, const SectionHeader &relocationTable)
115         {
116                 const SectionHeader *target = elfSection(elfHeader, relocationTable.sh_info);
117  
118                 intptr_t address = (intptr_t)elfHeader + target->sh_offset;
119                 int32_t *patchSite = (int*)(address + relocation.r_offset);
120                 uint32_t index = relocation.getSymbol();
121                 int table = relocationTable.sh_link;
122                 void *symbolValue = nullptr;
123                 
124                 if(index != SHN_UNDEF)
125                 {
126                         if(table == SHN_UNDEF) return nullptr;
127                         const SectionHeader *symbolTable = elfSection(elfHeader, table);
128  
129                         uint32_t symtab_entries = symbolTable->sh_size / symbolTable->sh_entsize;
130                         if(index >= symtab_entries)
131                         {
132                                 assert(index < symtab_entries && "Symbol Index out of range");
133                                 return nullptr;
134                         }
135  
136                         intptr_t symbolAddress = (intptr_t)elfHeader + symbolTable->sh_offset;
137                         Elf32_Sym &symbol = ((Elf32_Sym*)symbolAddress)[index];
138                         uint16_t section = symbol.st_shndx;
139
140                         if(section != SHN_UNDEF && section < SHN_LORESERVE)
141                         {
142                                 const SectionHeader *target = elfSection(elfHeader, symbol.st_shndx);
143                                 symbolValue = reinterpret_cast<void*>((intptr_t)elfHeader + symbol.st_value + target->sh_offset);
144                         }
145                         else
146                         {
147                                 return nullptr;
148                         }
149                 }
150
151                 switch(relocation.getType())
152                 {
153                 case R_386_NONE:
154                         // No relocation
155                         break;
156                 case R_386_32:
157                         *patchSite = (int32_t)((intptr_t)symbolValue + *patchSite);
158                         break;
159         //      case R_386_PC32:
160         //              *patchSite = (int32_t)((intptr_t)symbolValue + *patchSite - (intptr_t)patchSite);
161         //              break;
162                 default:
163                         assert(false && "Unsupported relocation type");
164                         return nullptr;
165                 }
166
167                 return symbolValue;
168         }
169
170         static void *relocateSymbol(const ElfHeader *elfHeader, const Elf64_Rela &relocation, const SectionHeader &relocationTable)
171         {
172                 const SectionHeader *target = elfSection(elfHeader, relocationTable.sh_info);
173  
174                 intptr_t address = (intptr_t)elfHeader + target->sh_offset;
175                 int32_t *patchSite = (int*)(address + relocation.r_offset);
176                 uint32_t index = relocation.getSymbol();
177                 int table = relocationTable.sh_link;
178                 void *symbolValue = nullptr;
179
180                 if(index != SHN_UNDEF)
181                 {
182                         if(table == SHN_UNDEF) return nullptr;
183                         const SectionHeader *symbolTable = elfSection(elfHeader, table);
184  
185                         uint32_t symtab_entries = symbolTable->sh_size / symbolTable->sh_entsize;
186                         if(index >= symtab_entries)
187                         {
188                                 assert(index < symtab_entries && "Symbol Index out of range");
189                                 return nullptr;
190                         }
191  
192                         intptr_t symbolAddress = (intptr_t)elfHeader + symbolTable->sh_offset;
193                         Elf64_Sym &symbol = ((Elf64_Sym*)symbolAddress)[index];
194                         uint16_t section = symbol.st_shndx;
195
196                         if(section != SHN_UNDEF && section < SHN_LORESERVE)
197                         {
198                                 const SectionHeader *target = elfSection(elfHeader, symbol.st_shndx);
199                                 symbolValue = reinterpret_cast<void*>((intptr_t)elfHeader + symbol.st_value + target->sh_offset);
200                         }
201                         else
202                         {
203                                 return nullptr;
204                         }
205                 }
206
207                 switch(relocation.getType())
208                 {
209                 case R_X86_64_NONE:
210                         // No relocation
211                         break;
212         //      case R_X86_64_64:
213         //              *patchSite = (int32_t)((intptr_t)symbolValue + *patchSite) + relocation->r_addend;
214         //              break;
215                 case R_X86_64_PC32:
216                         *patchSite = (int32_t)((intptr_t)symbolValue + *patchSite - (intptr_t)patchSite) + relocation.r_addend;
217                         break;
218         //      case R_X86_64_32S:
219         //              *patchSite = (int32_t)((intptr_t)symbolValue + *patchSite) + relocation.r_addend;
220         //              break;
221                 default:
222                         assert(false && "Unsupported relocation type");
223                         return nullptr;
224                 }
225
226                 return symbolValue;
227         }
228
229         void *loadImage(uint8_t *const elfImage)
230         {
231                 ElfHeader *elfHeader = (ElfHeader*)elfImage;
232
233                 if(!elfHeader->checkMagic())
234                 {
235                         return nullptr;
236                 }
237
238                 // Expect ELF bitness to match platform
239                 assert(sizeof(void*) == 8 ? elfHeader->e_machine == EM_X86_64 : elfHeader->e_machine == EM_386);
240
241                 SectionHeader *sectionHeader = (SectionHeader*)(elfImage + elfHeader->e_shoff);
242                 void *entry = nullptr;
243
244                 for(int i = 0; i < elfHeader->e_shnum; i++)
245                 {
246                         if(sectionHeader[i].sh_type == SHT_PROGBITS)
247                         {
248                                 if(sectionHeader[i].sh_flags & SHF_EXECINSTR)
249                                 {
250                                         entry = elfImage + sectionHeader[i].sh_offset;
251                                 }
252                         }
253                         else if(sectionHeader[i].sh_type == SHT_REL)
254                         {
255                                 assert(sizeof(void*) == 4 && "UNIMPLEMENTED");   // Only expected/implemented for 32-bit code
256
257                                 for(int index = 0; index < sectionHeader[i].sh_size / sectionHeader[i].sh_entsize; index++)
258                                 {
259                                         const Elf32_Rel &relocation = ((const Elf32_Rel*)(elfImage + sectionHeader[i].sh_offset))[index];
260                                         void *symbol = relocateSymbol(elfHeader, relocation, sectionHeader[i]);
261                                 }
262                         }
263                         else if(sectionHeader[i].sh_type == SHT_RELA)
264                         {
265                                 assert(sizeof(void*) == 8 && "UNIMPLEMENTED");   // Only expected/implemented for 64-bit code
266
267                                 for(int index = 0; index < sectionHeader[i].sh_size / sectionHeader[i].sh_entsize; index++)
268                                 {
269                                         const Elf64_Rela &relocation = ((const Elf64_Rela*)(elfImage + sectionHeader[i].sh_offset))[index];
270                                         void *symbol = relocateSymbol(elfHeader, relocation, sectionHeader[i]);
271                                 }
272                         }
273                 }
274
275                 return entry;
276         }
277
278         template<typename T>
279         struct ExecutableAllocator
280         {
281                 ExecutableAllocator() {};
282                 template<class U> ExecutableAllocator(const ExecutableAllocator<U> &other) {};
283
284                 using value_type = T;
285                 using size_type = std::size_t;
286
287                 T *allocate(size_type n)
288                 {
289                         return (T*)VirtualAlloc(NULL, sizeof(T) * n, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
290                 }
291
292                 void deallocate(T *p, size_type n)
293                 {
294                         VirtualFree(p, 0, MEM_RELEASE);
295                 }
296         };
297
298         class ELFMemoryStreamer : public Ice::ELFStreamer, public Routine
299         {
300                 ELFMemoryStreamer(const ELFMemoryStreamer &) = delete;
301                 ELFMemoryStreamer &operator=(const ELFMemoryStreamer &) = delete;
302
303         public:
304                 ELFMemoryStreamer() : Routine()
305                 {
306                         position = 0;
307                         buffer.reserve(0x1000);
308                 }
309
310                 virtual ~ELFMemoryStreamer()
311                 {
312                         if(buffer.size() != 0)
313                         {
314                                 DWORD exeProtection;
315                                 VirtualProtect(&buffer[0], buffer.size(), oldProtection, &exeProtection);
316                         }
317                 }
318
319                 void write8(uint8_t Value) override
320                 {
321                         if(position == (uint64_t)buffer.size())
322                         {
323                                 buffer.push_back(Value);
324                                 position++;
325                         }
326                         else if(position < (uint64_t)buffer.size())
327                         {
328                                 buffer[position] = Value;
329                                 position++;
330                         }
331                         else assert(false && "UNIMPLEMENTED");
332                 }
333
334                 void writeBytes(llvm::StringRef Bytes) override
335                 {
336                         std::size_t oldSize = buffer.size();
337                         buffer.resize(oldSize + Bytes.size());
338                         memcpy(&buffer[oldSize], Bytes.begin(), Bytes.size());
339                         position += Bytes.size();
340                 }
341
342                 uint64_t tell() const override { return position; }
343
344                 void seek(uint64_t Off) override { position = Off; }
345
346                 const void *getEntry() override
347                 {
348                         VirtualProtect(&buffer[0], buffer.size(), PAGE_EXECUTE_READWRITE, &oldProtection);
349                         position = std::numeric_limits<std::size_t>::max();  // Can't stream more data after this
350
351                         return loadImage(&buffer[0]);
352                 }
353
354         private:
355                 std::vector<uint8_t, ExecutableAllocator<uint8_t>> buffer;
356                 std::size_t position;
357                 DWORD oldProtection;
358         };
359
360         Nucleus::Nucleus()
361         {
362                 ::codegenMutex.lock();   // Reactor is currently not thread safe
363
364                 Ice::ClFlags &Flags = Ice::ClFlags::Flags;
365                 Ice::ClFlags::getParsedClFlags(Flags);
366
367                 Flags.setTargetArch(sizeof(void*) == 8 ? Ice::Target_X8664 : Ice::Target_X8632);
368                 Flags.setOutFileType(Ice::FT_Elf);
369                 Flags.setOptLevel(Ice::Opt_2);
370                 Flags.setApplicationBinaryInterface(Ice::ABI_Platform);
371
372                 std::unique_ptr<Ice::Ostream> cout(new llvm::raw_os_ostream(std::cout));
373
374                 if(false)   // Write out to a file
375                 {
376                         std::error_code errorCode;
377                         ::out = new Ice::Fdstream("out.o", errorCode, llvm::sys::fs::F_None);
378                         ::elfFile = new Ice::ELFFileStreamer(*out);
379                         ::context = new Ice::GlobalContext(cout.get(), cout.get(), cout.get(), elfFile);
380                 }
381                 else
382                 {
383                         ELFMemoryStreamer *elfMemory = new ELFMemoryStreamer();
384                         ::context = new Ice::GlobalContext(cout.get(), cout.get(), cout.get(), elfMemory);
385                         ::routine = elfMemory;
386                 }
387         }
388
389         Nucleus::~Nucleus()
390         {
391                 delete ::allocator;
392                 delete ::function;
393                 delete ::context;
394
395                 delete ::elfFile;
396                 delete ::out;
397
398                 ::codegenMutex.unlock();
399         }
400
401         Routine *Nucleus::acquireRoutine(const wchar_t *name, bool runOptimizations)
402         {
403                 if(basicBlock->getInsts().empty() || basicBlock->getInsts().back().getKind() != Ice::Inst::Ret)
404                 {
405                         createRetVoid();
406                 }
407
408                 std::wstring wideName(name);
409                 std::string asciiName(wideName.begin(), wideName.end());
410                 ::function->setFunctionName(Ice::GlobalString::createWithString(::context, asciiName));
411
412                 ::function->translate();
413                 auto *globals = ::function->getGlobalInits().release();
414
415                 if(globals && !globals->empty())
416                 {
417                         ::context->getGlobals()->merge(globals);
418                 }
419
420                 ::context->emitFileHeader();
421                 ::function->emitIAS();
422                 auto assembler = ::function->releaseAssembler();
423                 auto objectWriter = ::context->getObjectWriter();
424                 assembler->alignFunction();
425                 objectWriter->writeFunctionCode(::function->getFunctionName(), false, assembler.get());
426                 ::context->lowerGlobals("last");
427                 objectWriter->setUndefinedSyms(::context->getConstantExternSyms());
428                 objectWriter->writeNonUserSections();
429
430                 return ::routine;
431         }
432
433         void Nucleus::optimize()
434         {
435         }
436
437         Value *Nucleus::allocateStackVariable(Type *t, int arraySize)
438         {
439                 assert(arraySize == 0 && "UNIMPLEMENTED");
440
441                 Ice::Type type = T(t);
442                 int size = Ice::typeWidthInBytes(type);
443
444                 auto bytes = Ice::ConstantInteger32::create(::context, type, size);
445                 auto address = ::function->makeVariable(T(getPointerType(t)));
446                 auto alloca = Ice::InstAlloca::create(::function, address, bytes, size);
447                 ::function->getEntryNode()->getInsts().push_front(alloca);
448
449                 return V(address);
450         }
451
452         BasicBlock *Nucleus::createBasicBlock()
453         {
454                 return B(::function->makeNode());
455         }
456
457         BasicBlock *Nucleus::getInsertBlock()
458         {
459                 return B(::basicBlock);
460         }
461
462         void Nucleus::setInsertBlock(BasicBlock *basicBlock)
463         {
464                 assert(::basicBlock->getInsts().back().getTerminatorEdges().size() >= 0 && "Previous basic block must have a terminator");
465                 ::basicBlock = basicBlock;
466         }
467
468         BasicBlock *Nucleus::getPredecessor(BasicBlock *basicBlock)
469         {
470                 assert(false && "UNIMPLEMENTED"); return nullptr;
471         }
472
473         void Nucleus::createFunction(Type *ReturnType, std::vector<Type*> &Params)
474         {
475                 uint32_t sequenceNumber = 0;
476                 ::function = Ice::Cfg::create(::context, sequenceNumber).release();
477                 ::allocator = new Ice::CfgLocalAllocatorScope(::function);
478
479                 for(Type *type : Params)
480                 {
481                         Ice::Variable *arg = ::function->makeVariable(T(type));
482                         ::function->addArg(arg);
483                 }
484
485                 Ice::CfgNode *node = ::function->makeNode();
486                 ::function->setEntryNode(node);
487                 ::basicBlock = node;
488         }
489
490         Value *Nucleus::getArgument(unsigned int index)
491         {
492                 return V(::function->getArgs()[index]);
493         }
494
495         void Nucleus::createRetVoid()
496         {
497                 assert(false && "UNIMPLEMENTED");
498         }
499
500         void Nucleus::createRet(Value *v)
501         {
502                 assert(false && "UNIMPLEMENTED");
503         }
504
505         void Nucleus::createBr(BasicBlock *dest)
506         {
507                 auto br = Ice::InstBr::create(::function, dest);
508                 ::basicBlock->appendInst(br);
509         }
510
511         void Nucleus::createCondBr(Value *cond, BasicBlock *ifTrue, BasicBlock *ifFalse)
512         {
513                 auto br = Ice::InstBr::create(::function, cond, ifTrue, ifFalse);
514                 ::basicBlock->appendInst(br);
515         }
516
517         static Value *createArithmetic(Ice::InstArithmetic::OpKind op, Value *lhs, Value *rhs)
518         {
519                 assert(lhs->getType() == rhs->getType());
520
521                 Ice::Variable *result = ::function->makeVariable(lhs->getType());
522                 Ice::InstArithmetic *arithmetic = Ice::InstArithmetic::create(::function, op, result, lhs, rhs);
523                 ::basicBlock->appendInst(arithmetic);
524
525                 return V(result);
526         }
527
528         Value *Nucleus::createAdd(Value *lhs, Value *rhs)
529         {
530                 return createArithmetic(Ice::InstArithmetic::Add, lhs, rhs);
531         }
532
533         Value *Nucleus::createSub(Value *lhs, Value *rhs)
534         {
535                 return createArithmetic(Ice::InstArithmetic::Sub, lhs, rhs);
536         }
537
538         Value *Nucleus::createMul(Value *lhs, Value *rhs)
539         {
540                 return createArithmetic(Ice::InstArithmetic::Mul, lhs, rhs);
541         }
542
543         Value *Nucleus::createUDiv(Value *lhs, Value *rhs)
544         {
545                 return createArithmetic(Ice::InstArithmetic::Udiv, lhs, rhs);
546         }
547
548         Value *Nucleus::createSDiv(Value *lhs, Value *rhs)
549         {
550                 return createArithmetic(Ice::InstArithmetic::Sdiv, lhs, rhs);
551         }
552
553         Value *Nucleus::createFAdd(Value *lhs, Value *rhs)
554         {
555                 return createArithmetic(Ice::InstArithmetic::Fadd, lhs, rhs);
556         }
557
558         Value *Nucleus::createFSub(Value *lhs, Value *rhs)
559         {
560                 return createArithmetic(Ice::InstArithmetic::Fsub, lhs, rhs);
561         }
562
563         Value *Nucleus::createFMul(Value *lhs, Value *rhs)
564         {
565                 return createArithmetic(Ice::InstArithmetic::Fmul, lhs, rhs);
566         }
567
568         Value *Nucleus::createFDiv(Value *lhs, Value *rhs)
569         {
570                 return createArithmetic(Ice::InstArithmetic::Fdiv, lhs, rhs);
571         }
572
573         Value *Nucleus::createURem(Value *lhs, Value *rhs)
574         {
575                 return createArithmetic(Ice::InstArithmetic::Urem, lhs, rhs);
576         }
577
578         Value *Nucleus::createSRem(Value *lhs, Value *rhs)
579         {
580                 return createArithmetic(Ice::InstArithmetic::Srem, lhs, rhs);
581         }
582
583         Value *Nucleus::createFRem(Value *lhs, Value *rhs)
584         {
585                 return createArithmetic(Ice::InstArithmetic::Frem, lhs, rhs);
586         }
587
588         Value *Nucleus::createShl(Value *lhs, Value *rhs)
589         {
590                 return createArithmetic(Ice::InstArithmetic::Shl, lhs, rhs);
591         }
592
593         Value *Nucleus::createLShr(Value *lhs, Value *rhs)
594         {
595                 return createArithmetic(Ice::InstArithmetic::Lshr, lhs, rhs);
596         }
597
598         Value *Nucleus::createAShr(Value *lhs, Value *rhs)
599         {
600                 return createArithmetic(Ice::InstArithmetic::Ashr, lhs, rhs);
601         }
602
603         Value *Nucleus::createAnd(Value *lhs, Value *rhs)
604         {
605                 return createArithmetic(Ice::InstArithmetic::And, lhs, rhs);
606         }
607
608         Value *Nucleus::createOr(Value *lhs, Value *rhs)
609         {
610                 return createArithmetic(Ice::InstArithmetic::Or, lhs, rhs);
611         }
612
613         Value *Nucleus::createXor(Value *lhs, Value *rhs)
614         {
615                 return createArithmetic(Ice::InstArithmetic::Xor, lhs, rhs);
616         }
617
618         static Value *createAssign(Ice::Constant *constant)
619         {
620                 Ice::Variable *value = ::function->makeVariable(constant->getType());
621                 auto assign = Ice::InstAssign::create(::function, value, constant);
622                 ::basicBlock->appendInst(assign);
623
624                 return V(value);
625         }
626
627         Value *Nucleus::createNeg(Value *v)
628         {
629                 assert(false && "UNIMPLEMENTED"); return nullptr;
630         }
631
632         Value *Nucleus::createFNeg(Value *v)
633         {
634                 assert(false && "UNIMPLEMENTED"); return nullptr;
635         }
636
637         Value *Nucleus::createNot(Value *v)
638         {
639                 assert(false && "UNIMPLEMENTED"); return nullptr;
640         }
641
642         Value *Nucleus::createLoad(Value *ptr, Type *type, bool isVolatile, unsigned int align)
643         {
644                 int valueType = (int)reinterpret_cast<intptr_t>(type);
645                 Ice::Variable *result = ::function->makeVariable(T(type));
646
647                 if(valueType & EmulatedBits)
648                 {
649                         switch(valueType)
650                         {
651                         case Type_v4i8:
652                         case Type_v2i16:
653                                 {
654                                         const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::LoadSubVector, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F};
655                                         auto target = ::context->getConstantUndef(Ice::IceType_i32);
656                                         auto load = Ice::InstIntrinsicCall::create(::function, 2, result, target, intrinsic);
657                                         load->addArg(::context->getConstantInt32(4));
658                                         load->addArg(ptr);
659                                         ::basicBlock->appendInst(load);
660                                 }
661                                 break;
662                         case Type_v2i32:
663                         case Type_v8i8:
664                         case Type_v4i16:
665                                 {
666                                         const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::LoadSubVector, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F};
667                                         auto target = ::context->getConstantUndef(Ice::IceType_i32);
668                                         auto load = Ice::InstIntrinsicCall::create(::function, 2, result, target, intrinsic);
669                                         load->addArg(::context->getConstantInt32(8));
670                                         load->addArg(ptr);
671                                         ::basicBlock->appendInst(load);
672                                 }
673                                 break;
674                         default: assert(false && "UNIMPLEMENTED");
675                         }
676                 }
677                 else
678                 {
679                         auto load = Ice::InstLoad::create(::function, result, ptr, align);
680                         ::basicBlock->appendInst(load);
681                 }
682
683                 return V(result);
684         }
685
686         Value *Nucleus::createStore(Value *value, Value *ptr, Type *type, bool isVolatile, unsigned int align)
687         {
688                 int valueType = (int)reinterpret_cast<intptr_t>(type);
689
690                 if(valueType & EmulatedBits)
691                 {
692                         switch(valueType)
693                         {
694                         case Type_v4i8:
695                         case Type_v2i16:
696                                 {
697                                         const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::StoreSubVector, Ice::Intrinsics::SideEffects_T, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_T};
698                                         auto target = ::context->getConstantUndef(Ice::IceType_i32);
699                                         auto store = Ice::InstIntrinsicCall::create(::function, 3, nullptr, target, intrinsic);
700                                         store->addArg(::context->getConstantInt32(4));
701                                         store->addArg(value);
702                                         store->addArg(ptr);
703                                         ::basicBlock->appendInst(store);
704                                 }
705                                 break;
706                         case Type_v2i32:
707                         case Type_v8i8:
708                         case Type_v4i16:
709                                 {
710                                         const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::StoreSubVector, Ice::Intrinsics::SideEffects_T, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_T};
711                                         auto target = ::context->getConstantUndef(Ice::IceType_i32);
712                                         auto store = Ice::InstIntrinsicCall::create(::function, 3, nullptr, target, intrinsic);
713                                         store->addArg(::context->getConstantInt32(8));
714                                         store->addArg(value);
715                                         store->addArg(ptr);
716                                         ::basicBlock->appendInst(store);
717                                 }
718                                 break;
719                         default: assert(false && "UNIMPLEMENTED");
720                         }
721                 }
722                 else
723                 {
724                         assert(T(value->getType()) == type);
725
726                         auto store = Ice::InstStore::create(::function, value, ptr, align);
727                         ::basicBlock->appendInst(store);
728                 }
729
730                 return value;
731         }
732
733         Value *Nucleus::createGEP(Value *ptr, Type *type, Value *index)
734         {
735                 assert(index->getType() == Ice::IceType_i32);
736
737                 if(!Ice::isByteSizedType(T(type)))
738                 {
739                         index = createMul(index, createConstantInt((int)Ice::typeWidthInBytes(T(type))));
740                 }
741
742                 if(sizeof(void*) == 8)
743                 {
744                         index = createSExt(index, T(Ice::IceType_i64));
745                 }
746
747                 return createAdd(ptr, index);
748         }
749
750         Value *Nucleus::createAtomicAdd(Value *ptr, Value *value)
751         {
752                 assert(false && "UNIMPLEMENTED"); return nullptr;
753         }
754
755         static Value *createCast(Ice::InstCast::OpKind op, Value *v, Type *destType)
756         {
757                 if(v->getType() == T(destType))
758                 {
759                         return v;
760                 }
761
762                 Ice::Variable *result = ::function->makeVariable(T(destType));
763                 Ice::InstCast *cast = Ice::InstCast::create(::function, op, result, v);
764                 ::basicBlock->appendInst(cast);
765
766                 return V(result);
767         }
768
769         Value *Nucleus::createTrunc(Value *v, Type *destType)
770         {
771                 return createCast(Ice::InstCast::Trunc, v, destType);
772         }
773
774         Value *Nucleus::createZExt(Value *v, Type *destType)
775         {
776                 return createCast(Ice::InstCast::Zext, v, destType);
777         }
778
779         Value *Nucleus::createSExt(Value *v, Type *destType)
780         {
781                 return createCast(Ice::InstCast::Sext, v, destType);
782         }
783
784         Value *Nucleus::createFPToSI(Value *v, Type *destType)
785         {
786                 return createCast(Ice::InstCast::Fptosi, v, destType);
787         }
788
789         Value *Nucleus::createUIToFP(Value *v, Type *destType)
790         {
791                 return createCast(Ice::InstCast::Uitofp, v, destType);
792         }
793
794         Value *Nucleus::createSIToFP(Value *v, Type *destType)
795         {
796                 return createCast(Ice::InstCast::Sitofp, v, destType);
797         }
798
799         Value *Nucleus::createFPTrunc(Value *v, Type *destType)
800         {
801                 return createCast(Ice::InstCast::Fptrunc, v, destType);
802         }
803
804         Value *Nucleus::createFPExt(Value *v, Type *destType)
805         {
806                 return createCast(Ice::InstCast::Fpext, v, destType);
807         }
808
809         Value *Nucleus::createBitCast(Value *v, Type *destType)
810         {
811                 return createCast(Ice::InstCast::Bitcast, v, destType);
812         }
813
814         Value *Nucleus::createIntCast(Value *v, Type *destType, bool isSigned)
815         {
816                 assert(false && "UNIMPLEMENTED"); return nullptr;
817         }
818
819         Value *Nucleus::createICmpEQ(Value *lhs, Value *rhs)
820         {
821                 assert(false && "UNIMPLEMENTED"); return nullptr;
822         }
823
824         Value *Nucleus::createICmpNE(Value *lhs, Value *rhs)
825         {
826                 assert(false && "UNIMPLEMENTED"); return nullptr;
827         }
828
829         Value *Nucleus::createICmpUGT(Value *lhs, Value *rhs)
830         {
831                 assert(false && "UNIMPLEMENTED"); return nullptr;
832         }
833
834         Value *Nucleus::createICmpUGE(Value *lhs, Value *rhs)
835         {
836                 assert(false && "UNIMPLEMENTED"); return nullptr;
837         }
838
839         Value *Nucleus::createICmpULT(Value *lhs, Value *rhs)
840         {
841                 assert(false && "UNIMPLEMENTED"); return nullptr;
842         }
843
844         Value *Nucleus::createICmpULE(Value *lhs, Value *rhs)
845         {
846                 assert(false && "UNIMPLEMENTED"); return nullptr;
847         }
848
849         Value *Nucleus::createICmpSGT(Value *lhs, Value *rhs)
850         {
851                 assert(false && "UNIMPLEMENTED"); return nullptr;
852         }
853
854         Value *Nucleus::createICmpSGE(Value *lhs, Value *rhs)
855         {
856                 assert(false && "UNIMPLEMENTED"); return nullptr;
857         }
858
859         Value *Nucleus::createICmpSLT(Value *lhs, Value *rhs)
860         {
861                 assert(lhs->getType() == rhs->getType());
862
863                 auto result = ::function->makeVariable(Ice::IceType_i1);
864                 auto cmp = Ice::InstIcmp::create(::function, Ice::InstIcmp::Slt, result, lhs, rhs);
865                 ::basicBlock->appendInst(cmp);
866
867                 return V(result);
868         }
869
870         Value *Nucleus::createICmpSLE(Value *lhs, Value *rhs)
871         {
872                 assert(false && "UNIMPLEMENTED"); return nullptr;
873         }
874
875         Value *Nucleus::createFCmpOEQ(Value *lhs, Value *rhs)
876         {
877                 assert(false && "UNIMPLEMENTED"); return nullptr;
878         }
879
880         Value *Nucleus::createFCmpOGT(Value *lhs, Value *rhs)
881         {
882                 assert(false && "UNIMPLEMENTED"); return nullptr;
883         }
884
885         Value *Nucleus::createFCmpOGE(Value *lhs, Value *rhs)
886         {
887                 assert(false && "UNIMPLEMENTED"); return nullptr;
888         }
889
890         Value *Nucleus::createFCmpOLT(Value *lhs, Value *rhs)
891         {
892                 assert(false && "UNIMPLEMENTED"); return nullptr;
893         }
894
895         Value *Nucleus::createFCmpOLE(Value *lhs, Value *rhs)
896         {
897                 assert(false && "UNIMPLEMENTED"); return nullptr;
898         }
899
900         Value *Nucleus::createFCmpONE(Value *lhs, Value *rhs)
901         {
902                 assert(false && "UNIMPLEMENTED"); return nullptr;
903         }
904
905         Value *Nucleus::createFCmpORD(Value *lhs, Value *rhs)
906         {
907                 assert(false && "UNIMPLEMENTED"); return nullptr;
908         }
909
910         Value *Nucleus::createFCmpUNO(Value *lhs, Value *rhs)
911         {
912                 assert(false && "UNIMPLEMENTED"); return nullptr;
913         }
914
915         Value *Nucleus::createFCmpUEQ(Value *lhs, Value *rhs)
916         {
917                 assert(false && "UNIMPLEMENTED"); return nullptr;
918         }
919
920         Value *Nucleus::createFCmpUGT(Value *lhs, Value *rhs)
921         {
922                 assert(false && "UNIMPLEMENTED"); return nullptr;
923         }
924
925         Value *Nucleus::createFCmpUGE(Value *lhs, Value *rhs)
926         {
927                 assert(false && "UNIMPLEMENTED"); return nullptr;
928         }
929
930         Value *Nucleus::createFCmpULT(Value *lhs, Value *rhs)
931         {
932                 assert(false && "UNIMPLEMENTED"); return nullptr;
933         }
934
935         Value *Nucleus::createFCmpULE(Value *lhs, Value *rhs)
936         {
937                 assert(false && "UNIMPLEMENTED"); return nullptr;
938         }
939
940         Value *Nucleus::createFCmpUNE(Value *lhs, Value *rhs)
941         {
942                 assert(false && "UNIMPLEMENTED"); return nullptr;
943         }
944
945         Value *Nucleus::createExtractElement(Value *vector, Type *type, int index)
946         {
947                 auto result = ::function->makeVariable(T(type));
948                 auto extract = Ice::InstExtractElement::create(::function, result, vector, ::context->getConstantInt32(index));
949                 ::basicBlock->appendInst(extract);
950
951                 return V(result);
952         }
953
954         Value *Nucleus::createInsertElement(Value *vector, Value *element, int index)
955         {
956                 auto result = ::function->makeVariable(vector->getType());
957                 auto insert = Ice::InstInsertElement::create(::function, result, vector, element, ::context->getConstantInt32(index));
958                 ::basicBlock->appendInst(insert);
959
960                 return V(result);
961         }
962
963         Value *Nucleus::createShuffleVector(Value *V1, Value *V2, const int *select)
964         {
965                 assert(V1->getType() == V2->getType());
966
967                 int size = Ice::typeNumElements(V1->getType());
968                 auto result = ::function->makeVariable(V1->getType());
969                 auto shuffle = Ice::InstShuffleVector::create(::function, result, V1, V2);
970
971                 for(int i = 0; i < size; i++)
972                 {
973                         shuffle->addIndex(llvm::cast<Ice::ConstantInteger32>(::context->getConstantInt32(select[i])));
974                 }
975
976                 ::basicBlock->appendInst(shuffle);
977
978                 return V(result);
979         }
980
981         Value *Nucleus::createSelect(Value *C, Value *ifTrue, Value *ifFalse)
982         {
983                 assert(false && "UNIMPLEMENTED"); return nullptr;
984         }
985
986         Value *Nucleus::createSwitch(Value *v, BasicBlock *Dest, unsigned NumCases)
987         {
988                 assert(false && "UNIMPLEMENTED"); return nullptr;
989         }
990
991         void Nucleus::addSwitchCase(Value *Switch, int Case, BasicBlock *Branch)
992         {
993                 assert(false && "UNIMPLEMENTED"); return;
994         }
995
996         void Nucleus::createUnreachable()
997         {
998                 assert(false && "UNIMPLEMENTED");
999         }
1000
1001         static Value *createSwizzle4(Value *val, unsigned char select)
1002         {
1003                 int swizzle[4] =
1004                 {
1005                         (select >> 0) & 0x03,
1006                         (select >> 2) & 0x03,
1007                         (select >> 4) & 0x03,
1008                         (select >> 6) & 0x03,
1009                 };
1010
1011                 return Nucleus::createShuffleVector(val, val, swizzle);
1012         }
1013
1014         static Value *createMask4(Value *lhs, Value *rhs, unsigned char select)
1015         {
1016                 assert(false && "UNIMPLEMENTED"); return nullptr;
1017         }
1018
1019         Value *Nucleus::createConstantPointer(const void *address, Type *Ty, bool isConstant, unsigned int Align)
1020         {
1021                 assert(false && "UNIMPLEMENTED"); return nullptr;
1022         }
1023
1024         Type *Nucleus::getPointerType(Type *ElementType)
1025         {
1026                 if(sizeof(void*) == 8)
1027                 {
1028                         return T(Ice::IceType_i64);
1029                 }
1030                 else
1031                 {
1032                         return T(Ice::IceType_i32);
1033                 }
1034         }
1035
1036         Value *Nucleus::createNullValue(Type *Ty)
1037         {
1038                 assert(false && "UNIMPLEMENTED"); return nullptr;
1039         }
1040
1041         Value *Nucleus::createConstantLong(int64_t i)
1042         {
1043                 assert(false && "UNIMPLEMENTED"); return nullptr;
1044         }
1045
1046         Value *Nucleus::createConstantInt(int i)
1047         {
1048                 return createAssign(::context->getConstantInt32(i));
1049         }
1050
1051         Value *Nucleus::createConstantInt(unsigned int i)
1052         {
1053                 assert(false && "UNIMPLEMENTED"); return nullptr;
1054         }
1055
1056         Value *Nucleus::createConstantBool(bool b)
1057         {
1058                 assert(false && "UNIMPLEMENTED"); return nullptr;
1059         }
1060
1061         Value *Nucleus::createConstantByte(signed char i)
1062         {
1063                 assert(false && "UNIMPLEMENTED"); return nullptr;
1064         }
1065
1066         Value *Nucleus::createConstantByte(unsigned char i)
1067         {
1068                 assert(false && "UNIMPLEMENTED"); return nullptr;
1069         }
1070
1071         Value *Nucleus::createConstantShort(short i)
1072         {
1073                 assert(false && "UNIMPLEMENTED"); return nullptr;
1074         }
1075
1076         Value *Nucleus::createConstantShort(unsigned short i)
1077         {
1078                 assert(false && "UNIMPLEMENTED"); return nullptr;
1079         }
1080
1081         Value *Nucleus::createConstantFloat(float x)
1082         {
1083                 assert(false && "UNIMPLEMENTED"); return nullptr;
1084         }
1085
1086         Value *Nucleus::createNullPointer(Type *Ty)
1087         {
1088                 assert(false && "UNIMPLEMENTED"); return nullptr;
1089         }
1090
1091         Value *Nucleus::createConstantVector(const int64_t *constants, Type *type)
1092         {
1093                 assert(false && "UNIMPLEMENTED"); return nullptr;
1094         }
1095
1096         Value *Nucleus::createConstantVector(const double *constants, Type *type)
1097         {
1098                 assert(false && "UNIMPLEMENTED"); return nullptr;
1099         }
1100
1101         Type *Void::getType()
1102         {
1103                 return T(Ice::IceType_void);
1104         }
1105
1106         Bool::Bool(Argument<Bool> argument)
1107         {
1108                 storeValue(argument.value);
1109         }
1110
1111         Bool::Bool()
1112         {
1113         }
1114
1115         Bool::Bool(bool x)
1116         {
1117                 storeValue(Nucleus::createConstantBool(x));
1118         }
1119
1120         Bool::Bool(RValue<Bool> rhs)
1121         {
1122                 storeValue(rhs.value);
1123         }
1124
1125         Bool::Bool(const Bool &rhs)
1126         {
1127                 Value *value = rhs.loadValue();
1128                 storeValue(value);
1129         }
1130
1131         Bool::Bool(const Reference<Bool> &rhs)
1132         {
1133                 Value *value = rhs.loadValue();
1134                 storeValue(value);
1135         }
1136
1137         RValue<Bool> Bool::operator=(RValue<Bool> rhs) const
1138         {
1139                 storeValue(rhs.value);
1140
1141                 return rhs;
1142         }
1143
1144         RValue<Bool> Bool::operator=(const Bool &rhs) const
1145         {
1146                 Value *value = rhs.loadValue();
1147                 storeValue(value);
1148
1149                 return RValue<Bool>(value);
1150         }
1151
1152         RValue<Bool> Bool::operator=(const Reference<Bool> &rhs) const
1153         {
1154                 Value *value = rhs.loadValue();
1155                 storeValue(value);
1156
1157                 return RValue<Bool>(value);
1158         }
1159
1160         RValue<Bool> operator!(RValue<Bool> val)
1161         {
1162                 return RValue<Bool>(Nucleus::createNot(val.value));
1163         }
1164
1165         RValue<Bool> operator&&(RValue<Bool> lhs, RValue<Bool> rhs)
1166         {
1167                 return RValue<Bool>(Nucleus::createAnd(lhs.value, rhs.value));
1168         }
1169
1170         RValue<Bool> operator||(RValue<Bool> lhs, RValue<Bool> rhs)
1171         {
1172                 return RValue<Bool>(Nucleus::createOr(lhs.value, rhs.value));
1173         }
1174
1175         Type *Bool::getType()
1176         {
1177                 assert(false && "UNIMPLEMENTED"); return nullptr;
1178         }
1179
1180         Byte::Byte(Argument<Byte> argument)
1181         {
1182                 storeValue(argument.value);
1183         }
1184
1185         Byte::Byte(RValue<Int> cast)
1186         {
1187                 Value *integer = Nucleus::createTrunc(cast.value, Byte::getType());
1188
1189                 storeValue(integer);
1190         }
1191
1192         Byte::Byte(RValue<UInt> cast)
1193         {
1194                 Value *integer = Nucleus::createTrunc(cast.value, Byte::getType());
1195
1196                 storeValue(integer);
1197         }
1198
1199         Byte::Byte(RValue<UShort> cast)
1200         {
1201                 Value *integer = Nucleus::createTrunc(cast.value, Byte::getType());
1202
1203                 storeValue(integer);
1204         }
1205
1206         Byte::Byte()
1207         {
1208         }
1209
1210         Byte::Byte(int x)
1211         {
1212                 storeValue(Nucleus::createConstantByte((unsigned char)x));
1213         }
1214
1215         Byte::Byte(unsigned char x)
1216         {
1217                 storeValue(Nucleus::createConstantByte(x));
1218         }
1219
1220         Byte::Byte(RValue<Byte> rhs)
1221         {
1222                 storeValue(rhs.value);
1223         }
1224
1225         Byte::Byte(const Byte &rhs)
1226         {
1227                 Value *value = rhs.loadValue();
1228                 storeValue(value);
1229         }
1230
1231         Byte::Byte(const Reference<Byte> &rhs)
1232         {
1233                 Value *value = rhs.loadValue();
1234                 storeValue(value);
1235         }
1236
1237         RValue<Byte> Byte::operator=(RValue<Byte> rhs) const
1238         {
1239                 storeValue(rhs.value);
1240
1241                 return rhs;
1242         }
1243
1244         RValue<Byte> Byte::operator=(const Byte &rhs) const
1245         {
1246                 Value *value = rhs.loadValue();
1247                 storeValue(value);
1248
1249                 return RValue<Byte>(value);
1250         }
1251
1252         RValue<Byte> Byte::operator=(const Reference<Byte> &rhs) const
1253         {
1254                 Value *value = rhs.loadValue();
1255                 storeValue(value);
1256
1257                 return RValue<Byte>(value);
1258         }
1259
1260         RValue<Byte> operator+(RValue<Byte> lhs, RValue<Byte> rhs)
1261         {
1262                 return RValue<Byte>(Nucleus::createAdd(lhs.value, rhs.value));
1263         }
1264
1265         RValue<Byte> operator-(RValue<Byte> lhs, RValue<Byte> rhs)
1266         {
1267                 return RValue<Byte>(Nucleus::createSub(lhs.value, rhs.value));
1268         }
1269
1270         RValue<Byte> operator*(RValue<Byte> lhs, RValue<Byte> rhs)
1271         {
1272                 return RValue<Byte>(Nucleus::createMul(lhs.value, rhs.value));
1273         }
1274
1275         RValue<Byte> operator/(RValue<Byte> lhs, RValue<Byte> rhs)
1276         {
1277                 return RValue<Byte>(Nucleus::createUDiv(lhs.value, rhs.value));
1278         }
1279
1280         RValue<Byte> operator%(RValue<Byte> lhs, RValue<Byte> rhs)
1281         {
1282                 return RValue<Byte>(Nucleus::createURem(lhs.value, rhs.value));
1283         }
1284
1285         RValue<Byte> operator&(RValue<Byte> lhs, RValue<Byte> rhs)
1286         {
1287                 return RValue<Byte>(Nucleus::createAnd(lhs.value, rhs.value));
1288         }
1289
1290         RValue<Byte> operator|(RValue<Byte> lhs, RValue<Byte> rhs)
1291         {
1292                 return RValue<Byte>(Nucleus::createOr(lhs.value, rhs.value));
1293         }
1294
1295         RValue<Byte> operator^(RValue<Byte> lhs, RValue<Byte> rhs)
1296         {
1297                 return RValue<Byte>(Nucleus::createXor(lhs.value, rhs.value));
1298         }
1299
1300         RValue<Byte> operator<<(RValue<Byte> lhs, RValue<Byte> rhs)
1301         {
1302                 return RValue<Byte>(Nucleus::createShl(lhs.value, rhs.value));
1303         }
1304
1305         RValue<Byte> operator>>(RValue<Byte> lhs, RValue<Byte> rhs)
1306         {
1307                 return RValue<Byte>(Nucleus::createLShr(lhs.value, rhs.value));
1308         }
1309
1310         RValue<Byte> operator+=(const Byte &lhs, RValue<Byte> rhs)
1311         {
1312                 return lhs = lhs + rhs;
1313         }
1314
1315         RValue<Byte> operator-=(const Byte &lhs, RValue<Byte> rhs)
1316         {
1317                 return lhs = lhs - rhs;
1318         }
1319
1320         RValue<Byte> operator*=(const Byte &lhs, RValue<Byte> rhs)
1321         {
1322                 return lhs = lhs * rhs;
1323         }
1324
1325         RValue<Byte> operator/=(const Byte &lhs, RValue<Byte> rhs)
1326         {
1327                 return lhs = lhs / rhs;
1328         }
1329
1330         RValue<Byte> operator%=(const Byte &lhs, RValue<Byte> rhs)
1331         {
1332                 return lhs = lhs % rhs;
1333         }
1334
1335         RValue<Byte> operator&=(const Byte &lhs, RValue<Byte> rhs)
1336         {
1337                 return lhs = lhs & rhs;
1338         }
1339
1340         RValue<Byte> operator|=(const Byte &lhs, RValue<Byte> rhs)
1341         {
1342                 return lhs = lhs | rhs;
1343         }
1344
1345         RValue<Byte> operator^=(const Byte &lhs, RValue<Byte> rhs)
1346         {
1347                 return lhs = lhs ^ rhs;
1348         }
1349
1350         RValue<Byte> operator<<=(const Byte &lhs, RValue<Byte> rhs)
1351         {
1352                 return lhs = lhs << rhs;
1353         }
1354
1355         RValue<Byte> operator>>=(const Byte &lhs, RValue<Byte> rhs)
1356         {
1357                 return lhs = lhs >> rhs;
1358         }
1359
1360         RValue<Byte> operator+(RValue<Byte> val)
1361         {
1362                 return val;
1363         }
1364
1365         RValue<Byte> operator-(RValue<Byte> val)
1366         {
1367                 return RValue<Byte>(Nucleus::createNeg(val.value));
1368         }
1369
1370         RValue<Byte> operator~(RValue<Byte> val)
1371         {
1372                 return RValue<Byte>(Nucleus::createNot(val.value));
1373         }
1374
1375         RValue<Byte> operator++(const Byte &val, int)   // Post-increment
1376         {
1377                 RValue<Byte> res = val;
1378
1379                 assert(false && "UNIMPLEMENTED");
1380
1381                 return res;
1382         }
1383
1384         const Byte &operator++(const Byte &val)   // Pre-increment
1385         {
1386                 assert(false && "UNIMPLEMENTED");
1387
1388                 return val;
1389         }
1390
1391         RValue<Byte> operator--(const Byte &val, int)   // Post-decrement
1392         {
1393                 RValue<Byte> res = val;
1394
1395                 assert(false && "UNIMPLEMENTED");
1396
1397                 return res;
1398         }
1399
1400         const Byte &operator--(const Byte &val)   // Pre-decrement
1401         {
1402                 assert(false && "UNIMPLEMENTED");
1403
1404                 return val;
1405         }
1406
1407         RValue<Bool> operator<(RValue<Byte> lhs, RValue<Byte> rhs)
1408         {
1409                 return RValue<Bool>(Nucleus::createICmpULT(lhs.value, rhs.value));
1410         }
1411
1412         RValue<Bool> operator<=(RValue<Byte> lhs, RValue<Byte> rhs)
1413         {
1414                 return RValue<Bool>(Nucleus::createICmpULE(lhs.value, rhs.value));
1415         }
1416
1417         RValue<Bool> operator>(RValue<Byte> lhs, RValue<Byte> rhs)
1418         {
1419                 return RValue<Bool>(Nucleus::createICmpUGT(lhs.value, rhs.value));
1420         }
1421
1422         RValue<Bool> operator>=(RValue<Byte> lhs, RValue<Byte> rhs)
1423         {
1424                 return RValue<Bool>(Nucleus::createICmpUGE(lhs.value, rhs.value));
1425         }
1426
1427         RValue<Bool> operator!=(RValue<Byte> lhs, RValue<Byte> rhs)
1428         {
1429                 return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value));
1430         }
1431
1432         RValue<Bool> operator==(RValue<Byte> lhs, RValue<Byte> rhs)
1433         {
1434                 return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value));
1435         }
1436
1437         Type *Byte::getType()
1438         {
1439                 return T(Ice::IceType_i8);
1440         }
1441
1442         SByte::SByte(Argument<SByte> argument)
1443         {
1444                 storeValue(argument.value);
1445         }
1446
1447         SByte::SByte(RValue<Int> cast)
1448         {
1449                 Value *integer = Nucleus::createTrunc(cast.value, SByte::getType());
1450
1451                 storeValue(integer);
1452         }
1453
1454         SByte::SByte(RValue<Short> cast)
1455         {
1456                 Value *integer = Nucleus::createTrunc(cast.value, SByte::getType());
1457
1458                 storeValue(integer);
1459         }
1460
1461         SByte::SByte()
1462         {
1463         }
1464
1465         SByte::SByte(signed char x)
1466         {
1467                 storeValue(Nucleus::createConstantByte(x));
1468         }
1469
1470         SByte::SByte(RValue<SByte> rhs)
1471         {
1472                 storeValue(rhs.value);
1473         }
1474
1475         SByte::SByte(const SByte &rhs)
1476         {
1477                 Value *value = rhs.loadValue();
1478                 storeValue(value);
1479         }
1480
1481         SByte::SByte(const Reference<SByte> &rhs)
1482         {
1483                 Value *value = rhs.loadValue();
1484                 storeValue(value);
1485         }
1486
1487         RValue<SByte> SByte::operator=(RValue<SByte> rhs) const
1488         {
1489                 storeValue(rhs.value);
1490
1491                 return rhs;
1492         }
1493
1494         RValue<SByte> SByte::operator=(const SByte &rhs) const
1495         {
1496                 Value *value = rhs.loadValue();
1497                 storeValue(value);
1498
1499                 return RValue<SByte>(value);
1500         }
1501
1502         RValue<SByte> SByte::operator=(const Reference<SByte> &rhs) const
1503         {
1504                 Value *value = rhs.loadValue();
1505                 storeValue(value);
1506
1507                 return RValue<SByte>(value);
1508         }
1509
1510         RValue<SByte> operator+(RValue<SByte> lhs, RValue<SByte> rhs)
1511         {
1512                 return RValue<SByte>(Nucleus::createAdd(lhs.value, rhs.value));
1513         }
1514
1515         RValue<SByte> operator-(RValue<SByte> lhs, RValue<SByte> rhs)
1516         {
1517                 return RValue<SByte>(Nucleus::createSub(lhs.value, rhs.value));
1518         }
1519
1520         RValue<SByte> operator*(RValue<SByte> lhs, RValue<SByte> rhs)
1521         {
1522                 return RValue<SByte>(Nucleus::createMul(lhs.value, rhs.value));
1523         }
1524
1525         RValue<SByte> operator/(RValue<SByte> lhs, RValue<SByte> rhs)
1526         {
1527                 return RValue<SByte>(Nucleus::createSDiv(lhs.value, rhs.value));
1528         }
1529
1530         RValue<SByte> operator%(RValue<SByte> lhs, RValue<SByte> rhs)
1531         {
1532                 return RValue<SByte>(Nucleus::createSRem(lhs.value, rhs.value));
1533         }
1534
1535         RValue<SByte> operator&(RValue<SByte> lhs, RValue<SByte> rhs)
1536         {
1537                 return RValue<SByte>(Nucleus::createAnd(lhs.value, rhs.value));
1538         }
1539
1540         RValue<SByte> operator|(RValue<SByte> lhs, RValue<SByte> rhs)
1541         {
1542                 return RValue<SByte>(Nucleus::createOr(lhs.value, rhs.value));
1543         }
1544
1545         RValue<SByte> operator^(RValue<SByte> lhs, RValue<SByte> rhs)
1546         {
1547                 return RValue<SByte>(Nucleus::createXor(lhs.value, rhs.value));
1548         }
1549
1550         RValue<SByte> operator<<(RValue<SByte> lhs, RValue<SByte> rhs)
1551         {
1552                 return RValue<SByte>(Nucleus::createShl(lhs.value, rhs.value));
1553         }
1554
1555         RValue<SByte> operator>>(RValue<SByte> lhs, RValue<SByte> rhs)
1556         {
1557                 return RValue<SByte>(Nucleus::createAShr(lhs.value, rhs.value));
1558         }
1559
1560         RValue<SByte> operator+=(const SByte &lhs, RValue<SByte> rhs)
1561         {
1562                 return lhs = lhs + rhs;
1563         }
1564
1565         RValue<SByte> operator-=(const SByte &lhs, RValue<SByte> rhs)
1566         {
1567                 return lhs = lhs - rhs;
1568         }
1569
1570         RValue<SByte> operator*=(const SByte &lhs, RValue<SByte> rhs)
1571         {
1572                 return lhs = lhs * rhs;
1573         }
1574
1575         RValue<SByte> operator/=(const SByte &lhs, RValue<SByte> rhs)
1576         {
1577                 return lhs = lhs / rhs;
1578         }
1579
1580         RValue<SByte> operator%=(const SByte &lhs, RValue<SByte> rhs)
1581         {
1582                 return lhs = lhs % rhs;
1583         }
1584
1585         RValue<SByte> operator&=(const SByte &lhs, RValue<SByte> rhs)
1586         {
1587                 return lhs = lhs & rhs;
1588         }
1589
1590         RValue<SByte> operator|=(const SByte &lhs, RValue<SByte> rhs)
1591         {
1592                 return lhs = lhs | rhs;
1593         }
1594
1595         RValue<SByte> operator^=(const SByte &lhs, RValue<SByte> rhs)
1596         {
1597                 return lhs = lhs ^ rhs;
1598         }
1599
1600         RValue<SByte> operator<<=(const SByte &lhs, RValue<SByte> rhs)
1601         {
1602                 return lhs = lhs << rhs;
1603         }
1604
1605         RValue<SByte> operator>>=(const SByte &lhs, RValue<SByte> rhs)
1606         {
1607                 return lhs = lhs >> rhs;
1608         }
1609
1610         RValue<SByte> operator+(RValue<SByte> val)
1611         {
1612                 return val;
1613         }
1614
1615         RValue<SByte> operator-(RValue<SByte> val)
1616         {
1617                 return RValue<SByte>(Nucleus::createNeg(val.value));
1618         }
1619
1620         RValue<SByte> operator~(RValue<SByte> val)
1621         {
1622                 return RValue<SByte>(Nucleus::createNot(val.value));
1623         }
1624
1625         RValue<SByte> operator++(const SByte &val, int)   // Post-increment
1626         {
1627                 RValue<SByte> res = val;
1628
1629                 assert(false && "UNIMPLEMENTED");
1630
1631                 return res;
1632         }
1633
1634         const SByte &operator++(const SByte &val)   // Pre-increment
1635         {
1636                 assert(false && "UNIMPLEMENTED");
1637                 assert(false && "UNIMPLEMENTED");
1638
1639                 return val;
1640         }
1641
1642         RValue<SByte> operator--(const SByte &val, int)   // Post-decrement
1643         {
1644                 RValue<SByte> res = val;
1645
1646                 assert(false && "UNIMPLEMENTED");
1647                 assert(false && "UNIMPLEMENTED");
1648
1649                 return res;
1650         }
1651
1652         const SByte &operator--(const SByte &val)   // Pre-decrement
1653         {
1654                 assert(false && "UNIMPLEMENTED");
1655                 assert(false && "UNIMPLEMENTED");
1656
1657                 return val;
1658         }
1659
1660         RValue<Bool> operator<(RValue<SByte> lhs, RValue<SByte> rhs)
1661         {
1662                 return RValue<Bool>(Nucleus::createICmpSLT(lhs.value, rhs.value));
1663         }
1664
1665         RValue<Bool> operator<=(RValue<SByte> lhs, RValue<SByte> rhs)
1666         {
1667                 return RValue<Bool>(Nucleus::createICmpSLE(lhs.value, rhs.value));
1668         }
1669
1670         RValue<Bool> operator>(RValue<SByte> lhs, RValue<SByte> rhs)
1671         {
1672                 return RValue<Bool>(Nucleus::createICmpSGT(lhs.value, rhs.value));
1673         }
1674
1675         RValue<Bool> operator>=(RValue<SByte> lhs, RValue<SByte> rhs)
1676         {
1677                 return RValue<Bool>(Nucleus::createICmpSGE(lhs.value, rhs.value));
1678         }
1679
1680         RValue<Bool> operator!=(RValue<SByte> lhs, RValue<SByte> rhs)
1681         {
1682                 return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value));
1683         }
1684
1685         RValue<Bool> operator==(RValue<SByte> lhs, RValue<SByte> rhs)
1686         {
1687                 return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value));
1688         }
1689
1690         Type *SByte::getType()
1691         {
1692                 assert(false && "UNIMPLEMENTED"); return nullptr;
1693         }
1694
1695         Short::Short(Argument<Short> argument)
1696         {
1697                 storeValue(argument.value);
1698         }
1699
1700         Short::Short(RValue<Int> cast)
1701         {
1702                 Value *integer = Nucleus::createTrunc(cast.value, Short::getType());
1703
1704                 storeValue(integer);
1705         }
1706
1707         Short::Short()
1708         {
1709         }
1710
1711         Short::Short(short x)
1712         {
1713                 storeValue(Nucleus::createConstantShort(x));
1714         }
1715
1716         Short::Short(RValue<Short> rhs)
1717         {
1718                 storeValue(rhs.value);
1719         }
1720
1721         Short::Short(const Short &rhs)
1722         {
1723                 Value *value = rhs.loadValue();
1724                 storeValue(value);
1725         }
1726
1727         Short::Short(const Reference<Short> &rhs)
1728         {
1729                 Value *value = rhs.loadValue();
1730                 storeValue(value);
1731         }
1732
1733         RValue<Short> Short::operator=(RValue<Short> rhs) const
1734         {
1735                 storeValue(rhs.value);
1736
1737                 return rhs;
1738         }
1739
1740         RValue<Short> Short::operator=(const Short &rhs) const
1741         {
1742                 Value *value = rhs.loadValue();
1743                 storeValue(value);
1744
1745                 return RValue<Short>(value);
1746         }
1747
1748         RValue<Short> Short::operator=(const Reference<Short> &rhs) const
1749         {
1750                 Value *value = rhs.loadValue();
1751                 storeValue(value);
1752
1753                 return RValue<Short>(value);
1754         }
1755
1756         RValue<Short> operator+(RValue<Short> lhs, RValue<Short> rhs)
1757         {
1758                 return RValue<Short>(Nucleus::createAdd(lhs.value, rhs.value));
1759         }
1760
1761         RValue<Short> operator-(RValue<Short> lhs, RValue<Short> rhs)
1762         {
1763                 return RValue<Short>(Nucleus::createSub(lhs.value, rhs.value));
1764         }
1765
1766         RValue<Short> operator*(RValue<Short> lhs, RValue<Short> rhs)
1767         {
1768                 return RValue<Short>(Nucleus::createMul(lhs.value, rhs.value));
1769         }
1770
1771         RValue<Short> operator/(RValue<Short> lhs, RValue<Short> rhs)
1772         {
1773                 return RValue<Short>(Nucleus::createSDiv(lhs.value, rhs.value));
1774         }
1775
1776         RValue<Short> operator%(RValue<Short> lhs, RValue<Short> rhs)
1777         {
1778                 return RValue<Short>(Nucleus::createSRem(lhs.value, rhs.value));
1779         }
1780
1781         RValue<Short> operator&(RValue<Short> lhs, RValue<Short> rhs)
1782         {
1783                 return RValue<Short>(Nucleus::createAnd(lhs.value, rhs.value));
1784         }
1785
1786         RValue<Short> operator|(RValue<Short> lhs, RValue<Short> rhs)
1787         {
1788                 return RValue<Short>(Nucleus::createOr(lhs.value, rhs.value));
1789         }
1790
1791         RValue<Short> operator^(RValue<Short> lhs, RValue<Short> rhs)
1792         {
1793                 return RValue<Short>(Nucleus::createXor(lhs.value, rhs.value));
1794         }
1795
1796         RValue<Short> operator<<(RValue<Short> lhs, RValue<Short> rhs)
1797         {
1798                 return RValue<Short>(Nucleus::createShl(lhs.value, rhs.value));
1799         }
1800
1801         RValue<Short> operator>>(RValue<Short> lhs, RValue<Short> rhs)
1802         {
1803                 return RValue<Short>(Nucleus::createAShr(lhs.value, rhs.value));
1804         }
1805
1806         RValue<Short> operator+=(const Short &lhs, RValue<Short> rhs)
1807         {
1808                 return lhs = lhs + rhs;
1809         }
1810
1811         RValue<Short> operator-=(const Short &lhs, RValue<Short> rhs)
1812         {
1813                 return lhs = lhs - rhs;
1814         }
1815
1816         RValue<Short> operator*=(const Short &lhs, RValue<Short> rhs)
1817         {
1818                 return lhs = lhs * rhs;
1819         }
1820
1821         RValue<Short> operator/=(const Short &lhs, RValue<Short> rhs)
1822         {
1823                 return lhs = lhs / rhs;
1824         }
1825
1826         RValue<Short> operator%=(const Short &lhs, RValue<Short> rhs)
1827         {
1828                 return lhs = lhs % rhs;
1829         }
1830
1831         RValue<Short> operator&=(const Short &lhs, RValue<Short> rhs)
1832         {
1833                 return lhs = lhs & rhs;
1834         }
1835
1836         RValue<Short> operator|=(const Short &lhs, RValue<Short> rhs)
1837         {
1838                 return lhs = lhs | rhs;
1839         }
1840
1841         RValue<Short> operator^=(const Short &lhs, RValue<Short> rhs)
1842         {
1843                 return lhs = lhs ^ rhs;
1844         }
1845
1846         RValue<Short> operator<<=(const Short &lhs, RValue<Short> rhs)
1847         {
1848                 return lhs = lhs << rhs;
1849         }
1850
1851         RValue<Short> operator>>=(const Short &lhs, RValue<Short> rhs)
1852         {
1853                 return lhs = lhs >> rhs;
1854         }
1855
1856         RValue<Short> operator+(RValue<Short> val)
1857         {
1858                 return val;
1859         }
1860
1861         RValue<Short> operator-(RValue<Short> val)
1862         {
1863                 return RValue<Short>(Nucleus::createNeg(val.value));
1864         }
1865
1866         RValue<Short> operator~(RValue<Short> val)
1867         {
1868                 return RValue<Short>(Nucleus::createNot(val.value));
1869         }
1870
1871         RValue<Short> operator++(const Short &val, int)   // Post-increment
1872         {
1873                 RValue<Short> res = val;
1874
1875                 assert(false && "UNIMPLEMENTED");
1876                 assert(false && "UNIMPLEMENTED");
1877
1878                 return res;
1879         }
1880
1881         const Short &operator++(const Short &val)   // Pre-increment
1882         {
1883                 assert(false && "UNIMPLEMENTED");
1884                 assert(false && "UNIMPLEMENTED");
1885
1886                 return val;
1887         }
1888
1889         RValue<Short> operator--(const Short &val, int)   // Post-decrement
1890         {
1891                 RValue<Short> res = val;
1892
1893                 assert(false && "UNIMPLEMENTED");
1894                 assert(false && "UNIMPLEMENTED");
1895
1896                 return res;
1897         }
1898
1899         const Short &operator--(const Short &val)   // Pre-decrement
1900         {
1901                 assert(false && "UNIMPLEMENTED");
1902                 assert(false && "UNIMPLEMENTED");
1903
1904                 return val;
1905         }
1906
1907         RValue<Bool> operator<(RValue<Short> lhs, RValue<Short> rhs)
1908         {
1909                 return RValue<Bool>(Nucleus::createICmpSLT(lhs.value, rhs.value));
1910         }
1911
1912         RValue<Bool> operator<=(RValue<Short> lhs, RValue<Short> rhs)
1913         {
1914                 return RValue<Bool>(Nucleus::createICmpSLE(lhs.value, rhs.value));
1915         }
1916
1917         RValue<Bool> operator>(RValue<Short> lhs, RValue<Short> rhs)
1918         {
1919                 return RValue<Bool>(Nucleus::createICmpSGT(lhs.value, rhs.value));
1920         }
1921
1922         RValue<Bool> operator>=(RValue<Short> lhs, RValue<Short> rhs)
1923         {
1924                 return RValue<Bool>(Nucleus::createICmpSGE(lhs.value, rhs.value));
1925         }
1926
1927         RValue<Bool> operator!=(RValue<Short> lhs, RValue<Short> rhs)
1928         {
1929                 return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value));
1930         }
1931
1932         RValue<Bool> operator==(RValue<Short> lhs, RValue<Short> rhs)
1933         {
1934                 return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value));
1935         }
1936
1937         Type *Short::getType()
1938         {
1939                 assert(false && "UNIMPLEMENTED"); return nullptr;
1940         }
1941
1942         UShort::UShort(Argument<UShort> argument)
1943         {
1944                 storeValue(argument.value);
1945         }
1946
1947         UShort::UShort(RValue<UInt> cast)
1948         {
1949                 Value *integer = Nucleus::createTrunc(cast.value, UShort::getType());
1950
1951                 storeValue(integer);
1952         }
1953
1954         UShort::UShort(RValue<Int> cast)
1955         {
1956                 Value *integer = Nucleus::createTrunc(cast.value, UShort::getType());
1957
1958                 storeValue(integer);
1959         }
1960
1961         UShort::UShort()
1962         {
1963         }
1964
1965         UShort::UShort(unsigned short x)
1966         {
1967                 storeValue(Nucleus::createConstantShort(x));
1968         }
1969
1970         UShort::UShort(RValue<UShort> rhs)
1971         {
1972                 storeValue(rhs.value);
1973         }
1974
1975         UShort::UShort(const UShort &rhs)
1976         {
1977                 Value *value = rhs.loadValue();
1978                 storeValue(value);
1979         }
1980
1981         UShort::UShort(const Reference<UShort> &rhs)
1982         {
1983                 Value *value = rhs.loadValue();
1984                 storeValue(value);
1985         }
1986
1987         RValue<UShort> UShort::operator=(RValue<UShort> rhs) const
1988         {
1989                 storeValue(rhs.value);
1990
1991                 return rhs;
1992         }
1993
1994         RValue<UShort> UShort::operator=(const UShort &rhs) const
1995         {
1996                 Value *value = rhs.loadValue();
1997                 storeValue(value);
1998
1999                 return RValue<UShort>(value);
2000         }
2001
2002         RValue<UShort> UShort::operator=(const Reference<UShort> &rhs) const
2003         {
2004                 Value *value = rhs.loadValue();
2005                 storeValue(value);
2006
2007                 return RValue<UShort>(value);
2008         }
2009
2010         RValue<UShort> operator+(RValue<UShort> lhs, RValue<UShort> rhs)
2011         {
2012                 return RValue<UShort>(Nucleus::createAdd(lhs.value, rhs.value));
2013         }
2014
2015         RValue<UShort> operator-(RValue<UShort> lhs, RValue<UShort> rhs)
2016         {
2017                 return RValue<UShort>(Nucleus::createSub(lhs.value, rhs.value));
2018         }
2019
2020         RValue<UShort> operator*(RValue<UShort> lhs, RValue<UShort> rhs)
2021         {
2022                 return RValue<UShort>(Nucleus::createMul(lhs.value, rhs.value));
2023         }
2024
2025         RValue<UShort> operator/(RValue<UShort> lhs, RValue<UShort> rhs)
2026         {
2027                 return RValue<UShort>(Nucleus::createUDiv(lhs.value, rhs.value));
2028         }
2029
2030         RValue<UShort> operator%(RValue<UShort> lhs, RValue<UShort> rhs)
2031         {
2032                 return RValue<UShort>(Nucleus::createURem(lhs.value, rhs.value));
2033         }
2034
2035         RValue<UShort> operator&(RValue<UShort> lhs, RValue<UShort> rhs)
2036         {
2037                 return RValue<UShort>(Nucleus::createAnd(lhs.value, rhs.value));
2038         }
2039
2040         RValue<UShort> operator|(RValue<UShort> lhs, RValue<UShort> rhs)
2041         {
2042                 return RValue<UShort>(Nucleus::createOr(lhs.value, rhs.value));
2043         }
2044
2045         RValue<UShort> operator^(RValue<UShort> lhs, RValue<UShort> rhs)
2046         {
2047                 return RValue<UShort>(Nucleus::createXor(lhs.value, rhs.value));
2048         }
2049
2050         RValue<UShort> operator<<(RValue<UShort> lhs, RValue<UShort> rhs)
2051         {
2052                 return RValue<UShort>(Nucleus::createShl(lhs.value, rhs.value));
2053         }
2054
2055         RValue<UShort> operator>>(RValue<UShort> lhs, RValue<UShort> rhs)
2056         {
2057                 return RValue<UShort>(Nucleus::createLShr(lhs.value, rhs.value));
2058         }
2059
2060         RValue<UShort> operator+=(const UShort &lhs, RValue<UShort> rhs)
2061         {
2062                 return lhs = lhs + rhs;
2063         }
2064
2065         RValue<UShort> operator-=(const UShort &lhs, RValue<UShort> rhs)
2066         {
2067                 return lhs = lhs - rhs;
2068         }
2069
2070         RValue<UShort> operator*=(const UShort &lhs, RValue<UShort> rhs)
2071         {
2072                 return lhs = lhs * rhs;
2073         }
2074
2075         RValue<UShort> operator/=(const UShort &lhs, RValue<UShort> rhs)
2076         {
2077                 return lhs = lhs / rhs;
2078         }
2079
2080         RValue<UShort> operator%=(const UShort &lhs, RValue<UShort> rhs)
2081         {
2082                 return lhs = lhs % rhs;
2083         }
2084
2085         RValue<UShort> operator&=(const UShort &lhs, RValue<UShort> rhs)
2086         {
2087                 return lhs = lhs & rhs;
2088         }
2089
2090         RValue<UShort> operator|=(const UShort &lhs, RValue<UShort> rhs)
2091         {
2092                 return lhs = lhs | rhs;
2093         }
2094
2095         RValue<UShort> operator^=(const UShort &lhs, RValue<UShort> rhs)
2096         {
2097                 return lhs = lhs ^ rhs;
2098         }
2099
2100         RValue<UShort> operator<<=(const UShort &lhs, RValue<UShort> rhs)
2101         {
2102                 return lhs = lhs << rhs;
2103         }
2104
2105         RValue<UShort> operator>>=(const UShort &lhs, RValue<UShort> rhs)
2106         {
2107                 return lhs = lhs >> rhs;
2108         }
2109
2110         RValue<UShort> operator+(RValue<UShort> val)
2111         {
2112                 return val;
2113         }
2114
2115         RValue<UShort> operator-(RValue<UShort> val)
2116         {
2117                 return RValue<UShort>(Nucleus::createNeg(val.value));
2118         }
2119
2120         RValue<UShort> operator~(RValue<UShort> val)
2121         {
2122                 return RValue<UShort>(Nucleus::createNot(val.value));
2123         }
2124
2125         RValue<UShort> operator++(const UShort &val, int)   // Post-increment
2126         {
2127                 RValue<UShort> res = val;
2128
2129                 assert(false && "UNIMPLEMENTED");
2130                 assert(false && "UNIMPLEMENTED");
2131
2132                 return res;
2133         }
2134
2135         const UShort &operator++(const UShort &val)   // Pre-increment
2136         {
2137                 assert(false && "UNIMPLEMENTED");
2138                 assert(false && "UNIMPLEMENTED");
2139
2140                 return val;
2141         }
2142
2143         RValue<UShort> operator--(const UShort &val, int)   // Post-decrement
2144         {
2145                 RValue<UShort> res = val;
2146
2147                 assert(false && "UNIMPLEMENTED");
2148                 assert(false && "UNIMPLEMENTED");
2149
2150                 return res;
2151         }
2152
2153         const UShort &operator--(const UShort &val)   // Pre-decrement
2154         {
2155                 assert(false && "UNIMPLEMENTED");
2156                 assert(false && "UNIMPLEMENTED");
2157
2158                 return val;
2159         }
2160
2161         RValue<Bool> operator<(RValue<UShort> lhs, RValue<UShort> rhs)
2162         {
2163                 return RValue<Bool>(Nucleus::createICmpULT(lhs.value, rhs.value));
2164         }
2165
2166         RValue<Bool> operator<=(RValue<UShort> lhs, RValue<UShort> rhs)
2167         {
2168                 return RValue<Bool>(Nucleus::createICmpULE(lhs.value, rhs.value));
2169         }
2170
2171         RValue<Bool> operator>(RValue<UShort> lhs, RValue<UShort> rhs)
2172         {
2173                 return RValue<Bool>(Nucleus::createICmpUGT(lhs.value, rhs.value));
2174         }
2175
2176         RValue<Bool> operator>=(RValue<UShort> lhs, RValue<UShort> rhs)
2177         {
2178                 return RValue<Bool>(Nucleus::createICmpUGE(lhs.value, rhs.value));
2179         }
2180
2181         RValue<Bool> operator!=(RValue<UShort> lhs, RValue<UShort> rhs)
2182         {
2183                 return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value));
2184         }
2185
2186         RValue<Bool> operator==(RValue<UShort> lhs, RValue<UShort> rhs)
2187         {
2188                 return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value));
2189         }
2190
2191         Type *UShort::getType()
2192         {
2193                 assert(false && "UNIMPLEMENTED"); return nullptr;
2194         }
2195
2196         Byte4::Byte4(RValue<Byte8> cast)
2197         {
2198         //      xyzw.parent = this;
2199
2200                 storeValue(Nucleus::createBitCast(cast.value, getType()));
2201         }
2202
2203         Byte4::Byte4(const Reference<Byte4> &rhs)
2204         {
2205         //      xyzw.parent = this;
2206
2207                 assert(false && "UNIMPLEMENTED");
2208         }
2209
2210         Type *Byte4::getType()
2211         {
2212                 return T(Type_v4i8);
2213         }
2214
2215         Type *SByte4::getType()
2216         {
2217                 assert(false && "UNIMPLEMENTED"); return nullptr;
2218         }
2219
2220         Byte8::Byte8()
2221         {
2222         //      xyzw.parent = this;
2223         }
2224
2225         Byte8::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)
2226         {
2227         //      xyzw.parent = this;
2228
2229                 assert(false && "UNIMPLEMENTED");
2230         }
2231
2232         Byte8::Byte8(RValue<Byte8> rhs)
2233         {
2234         //      xyzw.parent = this;
2235
2236                 storeValue(rhs.value);
2237         }
2238
2239         Byte8::Byte8(const Byte8 &rhs)
2240         {
2241         //      xyzw.parent = this;
2242
2243                 Value *value = rhs.loadValue();
2244                 storeValue(value);
2245         }
2246
2247         Byte8::Byte8(const Reference<Byte8> &rhs)
2248         {
2249         //      xyzw.parent = this;
2250
2251                 Value *value = rhs.loadValue();
2252                 storeValue(value);
2253         }
2254
2255         RValue<Byte8> Byte8::operator=(RValue<Byte8> rhs) const
2256         {
2257                 storeValue(rhs.value);
2258
2259                 return rhs;
2260         }
2261
2262         RValue<Byte8> Byte8::operator=(const Byte8 &rhs) const
2263         {
2264                 Value *value = rhs.loadValue();
2265                 storeValue(value);
2266
2267                 return RValue<Byte8>(value);
2268         }
2269
2270         RValue<Byte8> Byte8::operator=(const Reference<Byte8> &rhs) const
2271         {
2272                 Value *value = rhs.loadValue();
2273                 storeValue(value);
2274
2275                 return RValue<Byte8>(value);
2276         }
2277
2278         RValue<Byte8> operator+(RValue<Byte8> lhs, RValue<Byte8> rhs)
2279         {
2280                 assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
2281         }
2282
2283         RValue<Byte8> operator-(RValue<Byte8> lhs, RValue<Byte8> rhs)
2284         {
2285                 assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
2286         }
2287
2288 //      RValue<Byte8> operator*(RValue<Byte8> lhs, RValue<Byte8> rhs)
2289 //      {
2290 //              return RValue<Byte8>(Nucleus::createMul(lhs.value, rhs.value));
2291 //      }
2292
2293 //      RValue<Byte8> operator/(RValue<Byte8> lhs, RValue<Byte8> rhs)
2294 //      {
2295 //              return RValue<Byte8>(Nucleus::createUDiv(lhs.value, rhs.value));
2296 //      }
2297
2298 //      RValue<Byte8> operator%(RValue<Byte8> lhs, RValue<Byte8> rhs)
2299 //      {
2300 //              return RValue<Byte8>(Nucleus::createURem(lhs.value, rhs.value));
2301 //      }
2302
2303         RValue<Byte8> operator&(RValue<Byte8> lhs, RValue<Byte8> rhs)
2304         {
2305                 assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
2306         }
2307
2308         RValue<Byte8> operator|(RValue<Byte8> lhs, RValue<Byte8> rhs)
2309         {
2310                 assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
2311         }
2312
2313         RValue<Byte8> operator^(RValue<Byte8> lhs, RValue<Byte8> rhs)
2314         {
2315                 assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
2316         }
2317
2318 //      RValue<Byte8> operator<<(RValue<Byte8> lhs, unsigned char rhs)
2319 //      {
2320 //              return RValue<Byte8>(Nucleus::createShl(lhs.value, rhs.value));
2321 //      }
2322
2323 //      RValue<Byte8> operator>>(RValue<Byte8> lhs, unsigned char rhs)
2324 //      {
2325 //              return RValue<Byte8>(Nucleus::createLShr(lhs.value, rhs.value));
2326 //      }
2327
2328         RValue<Byte8> operator+=(const Byte8 &lhs, RValue<Byte8> rhs)
2329         {
2330                 return lhs = lhs + rhs;
2331         }
2332
2333         RValue<Byte8> operator-=(const Byte8 &lhs, RValue<Byte8> rhs)
2334         {
2335                 return lhs = lhs - rhs;
2336         }
2337
2338 //      RValue<Byte8> operator*=(const Byte8 &lhs, RValue<Byte8> rhs)
2339 //      {
2340 //              return lhs = lhs * rhs;
2341 //      }
2342
2343 //      RValue<Byte8> operator/=(const Byte8 &lhs, RValue<Byte8> rhs)
2344 //      {
2345 //              return lhs = lhs / rhs;
2346 //      }
2347
2348 //      RValue<Byte8> operator%=(const Byte8 &lhs, RValue<Byte8> rhs)
2349 //      {
2350 //              return lhs = lhs % rhs;
2351 //      }
2352
2353         RValue<Byte8> operator&=(const Byte8 &lhs, RValue<Byte8> rhs)
2354         {
2355                 return lhs = lhs & rhs;
2356         }
2357
2358         RValue<Byte8> operator|=(const Byte8 &lhs, RValue<Byte8> rhs)
2359         {
2360                 return lhs = lhs | rhs;
2361         }
2362
2363         RValue<Byte8> operator^=(const Byte8 &lhs, RValue<Byte8> rhs)
2364         {
2365                 return lhs = lhs ^ rhs;
2366         }
2367
2368 //      RValue<Byte8> operator<<=(const Byte8 &lhs, RValue<Byte8> rhs)
2369 //      {
2370 //              return lhs = lhs << rhs;
2371 //      }
2372
2373 //      RValue<Byte8> operator>>=(const Byte8 &lhs, RValue<Byte8> rhs)
2374 //      {
2375 //              return lhs = lhs >> rhs;
2376 //      }
2377
2378 //      RValue<Byte8> operator+(RValue<Byte8> val)
2379 //      {
2380 //              return val;
2381 //      }
2382
2383 //      RValue<Byte8> operator-(RValue<Byte8> val)
2384 //      {
2385 //              return RValue<Byte8>(Nucleus::createNeg(val.value));
2386 //      }
2387
2388         RValue<Byte8> operator~(RValue<Byte8> val)
2389         {
2390                 return RValue<Byte8>(Nucleus::createNot(val.value));
2391         }
2392
2393         RValue<Byte8> AddSat(RValue<Byte8> x, RValue<Byte8> y)
2394         {
2395                 assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
2396         }
2397
2398         RValue<Byte8> SubSat(RValue<Byte8> x, RValue<Byte8> y)
2399         {
2400                 assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
2401         }
2402
2403         RValue<Short4> Unpack(RValue<Byte4> x)
2404         {
2405                 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
2406         }
2407
2408         RValue<Short4> UnpackLow(RValue<Byte8> x, RValue<Byte8> y)
2409         {
2410                 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
2411         }
2412
2413         RValue<Short4> UnpackHigh(RValue<Byte8> x, RValue<Byte8> y)
2414         {
2415                 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
2416         }
2417
2418         RValue<Int> SignMask(RValue<Byte8> x)
2419         {
2420                 assert(false && "UNIMPLEMENTED"); return RValue<Int>(V(nullptr));
2421         }
2422
2423 //      RValue<Byte8> CmpGT(RValue<Byte8> x, RValue<Byte8> y)
2424 //      {
2425 //              assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
2426 //      }
2427
2428         RValue<Byte8> CmpEQ(RValue<Byte8> x, RValue<Byte8> y)
2429         {
2430                 assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
2431         }
2432
2433         Type *Byte8::getType()
2434         {
2435                 return T(Type_v8i8);
2436         }
2437
2438         SByte8::SByte8()
2439         {
2440         //      xyzw.parent = this;
2441         }
2442
2443         SByte8::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)
2444         {
2445         //      xyzw.parent = this;
2446
2447                 assert(false && "UNIMPLEMENTED");
2448         }
2449
2450         SByte8::SByte8(RValue<SByte8> rhs)
2451         {
2452         //      xyzw.parent = this;
2453
2454                 storeValue(rhs.value);
2455         }
2456
2457         SByte8::SByte8(const SByte8 &rhs)
2458         {
2459         //      xyzw.parent = this;
2460
2461                 Value *value = rhs.loadValue();
2462                 storeValue(value);
2463         }
2464
2465         SByte8::SByte8(const Reference<SByte8> &rhs)
2466         {
2467         //      xyzw.parent = this;
2468
2469                 Value *value = rhs.loadValue();
2470                 storeValue(value);
2471         }
2472
2473         RValue<SByte8> SByte8::operator=(RValue<SByte8> rhs) const
2474         {
2475                 storeValue(rhs.value);
2476
2477                 return rhs;
2478         }
2479
2480         RValue<SByte8> SByte8::operator=(const SByte8 &rhs) const
2481         {
2482                 Value *value = rhs.loadValue();
2483                 storeValue(value);
2484
2485                 return RValue<SByte8>(value);
2486         }
2487
2488         RValue<SByte8> SByte8::operator=(const Reference<SByte8> &rhs) const
2489         {
2490                 Value *value = rhs.loadValue();
2491                 storeValue(value);
2492
2493                 return RValue<SByte8>(value);
2494         }
2495
2496         RValue<SByte8> operator+(RValue<SByte8> lhs, RValue<SByte8> rhs)
2497         {
2498                 assert(false && "UNIMPLEMENTED"); return RValue<SByte8>(V(nullptr));
2499         }
2500
2501         RValue<SByte8> operator-(RValue<SByte8> lhs, RValue<SByte8> rhs)
2502         {
2503                 assert(false && "UNIMPLEMENTED"); return RValue<SByte8>(V(nullptr));
2504         }
2505
2506 //      RValue<SByte8> operator*(RValue<SByte8> lhs, RValue<SByte8> rhs)
2507 //      {
2508 //              return RValue<SByte8>(Nucleus::createMul(lhs.value, rhs.value));
2509 //      }
2510
2511 //      RValue<SByte8> operator/(RValue<SByte8> lhs, RValue<SByte8> rhs)
2512 //      {
2513 //              return RValue<SByte8>(Nucleus::createSDiv(lhs.value, rhs.value));
2514 //      }
2515
2516 //      RValue<SByte8> operator%(RValue<SByte8> lhs, RValue<SByte8> rhs)
2517 //      {
2518 //              return RValue<SByte8>(Nucleus::createSRem(lhs.value, rhs.value));
2519 //      }
2520
2521         RValue<SByte8> operator&(RValue<SByte8> lhs, RValue<SByte8> rhs)
2522         {
2523                 return RValue<SByte8>(Nucleus::createAnd(lhs.value, rhs.value));
2524         }
2525
2526         RValue<SByte8> operator|(RValue<SByte8> lhs, RValue<SByte8> rhs)
2527         {
2528                 return RValue<SByte8>(Nucleus::createOr(lhs.value, rhs.value));
2529         }
2530
2531         RValue<SByte8> operator^(RValue<SByte8> lhs, RValue<SByte8> rhs)
2532         {
2533                 return RValue<SByte8>(Nucleus::createXor(lhs.value, rhs.value));
2534         }
2535
2536 //      RValue<SByte8> operator<<(RValue<SByte8> lhs, unsigned char rhs)
2537 //      {
2538 //              return RValue<SByte8>(Nucleus::createShl(lhs.value, rhs.value));
2539 //      }
2540
2541 //      RValue<SByte8> operator>>(RValue<SByte8> lhs, unsigned char rhs)
2542 //      {
2543 //              return RValue<SByte8>(Nucleus::createAShr(lhs.value, rhs.value));
2544 //      }
2545
2546         RValue<SByte8> operator+=(const SByte8 &lhs, RValue<SByte8> rhs)
2547         {
2548                 return lhs = lhs + rhs;
2549         }
2550
2551         RValue<SByte8> operator-=(const SByte8 &lhs, RValue<SByte8> rhs)
2552         {
2553                 return lhs = lhs - rhs;
2554         }
2555
2556 //      RValue<SByte8> operator*=(const SByte8 &lhs, RValue<SByte8> rhs)
2557 //      {
2558 //              return lhs = lhs * rhs;
2559 //      }
2560
2561 //      RValue<SByte8> operator/=(const SByte8 &lhs, RValue<SByte8> rhs)
2562 //      {
2563 //              return lhs = lhs / rhs;
2564 //      }
2565
2566 //      RValue<SByte8> operator%=(const SByte8 &lhs, RValue<SByte8> rhs)
2567 //      {
2568 //              return lhs = lhs % rhs;
2569 //      }
2570
2571         RValue<SByte8> operator&=(const SByte8 &lhs, RValue<SByte8> rhs)
2572         {
2573                 return lhs = lhs & rhs;
2574         }
2575
2576         RValue<SByte8> operator|=(const SByte8 &lhs, RValue<SByte8> rhs)
2577         {
2578                 return lhs = lhs | rhs;
2579         }
2580
2581         RValue<SByte8> operator^=(const SByte8 &lhs, RValue<SByte8> rhs)
2582         {
2583                 return lhs = lhs ^ rhs;
2584         }
2585
2586 //      RValue<SByte8> operator<<=(const SByte8 &lhs, RValue<SByte8> rhs)
2587 //      {
2588 //              return lhs = lhs << rhs;
2589 //      }
2590
2591 //      RValue<SByte8> operator>>=(const SByte8 &lhs, RValue<SByte8> rhs)
2592 //      {
2593 //              return lhs = lhs >> rhs;
2594 //      }
2595
2596 //      RValue<SByte8> operator+(RValue<SByte8> val)
2597 //      {
2598 //              return val;
2599 //      }
2600
2601 //      RValue<SByte8> operator-(RValue<SByte8> val)
2602 //      {
2603 //              return RValue<SByte8>(Nucleus::createNeg(val.value));
2604 //      }
2605
2606         RValue<SByte8> operator~(RValue<SByte8> val)
2607         {
2608                 return RValue<SByte8>(Nucleus::createNot(val.value));
2609         }
2610
2611         RValue<SByte8> AddSat(RValue<SByte8> x, RValue<SByte8> y)
2612         {
2613                 assert(false && "UNIMPLEMENTED"); return RValue<SByte8>(V(nullptr));
2614         }
2615
2616         RValue<SByte8> SubSat(RValue<SByte8> x, RValue<SByte8> y)
2617         {
2618                 assert(false && "UNIMPLEMENTED"); return RValue<SByte8>(V(nullptr));
2619         }
2620
2621         RValue<Short4> UnpackLow(RValue<SByte8> x, RValue<SByte8> y)
2622         {
2623                 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
2624         }
2625
2626         RValue<Short4> UnpackHigh(RValue<SByte8> x, RValue<SByte8> y)
2627         {
2628                 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
2629         }
2630
2631         RValue<Int> SignMask(RValue<SByte8> x)
2632         {
2633                 assert(false && "UNIMPLEMENTED"); return RValue<Int>(V(nullptr));
2634         }
2635
2636         RValue<Byte8> CmpGT(RValue<SByte8> x, RValue<SByte8> y)
2637         {
2638                 assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
2639         }
2640
2641         RValue<Byte8> CmpEQ(RValue<SByte8> x, RValue<SByte8> y)
2642         {
2643                 assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
2644         }
2645
2646         Type *SByte8::getType()
2647         {
2648                 assert(false && "UNIMPLEMENTED"); return nullptr;
2649         }
2650
2651         Byte16::Byte16(RValue<Byte16> rhs)
2652         {
2653         //      xyzw.parent = this;
2654
2655                 storeValue(rhs.value);
2656         }
2657
2658         Byte16::Byte16(const Byte16 &rhs)
2659         {
2660         //      xyzw.parent = this;
2661
2662                 Value *value = rhs.loadValue();
2663                 storeValue(value);
2664         }
2665
2666         Byte16::Byte16(const Reference<Byte16> &rhs)
2667         {
2668         //      xyzw.parent = this;
2669
2670                 Value *value = rhs.loadValue();
2671                 storeValue(value);
2672         }
2673
2674         RValue<Byte16> Byte16::operator=(RValue<Byte16> rhs) const
2675         {
2676                 storeValue(rhs.value);
2677
2678                 return rhs;
2679         }
2680
2681         RValue<Byte16> Byte16::operator=(const Byte16 &rhs) const
2682         {
2683                 Value *value = rhs.loadValue();
2684                 storeValue(value);
2685
2686                 return RValue<Byte16>(value);
2687         }
2688
2689         RValue<Byte16> Byte16::operator=(const Reference<Byte16> &rhs) const
2690         {
2691                 Value *value = rhs.loadValue();
2692                 storeValue(value);
2693
2694                 return RValue<Byte16>(value);
2695         }
2696
2697         Type *Byte16::getType()
2698         {
2699                 return T(Ice::IceType_v16i8);
2700         }
2701
2702         Type *SByte16::getType()
2703         {
2704                 return T(Ice::IceType_v16i8);
2705         }
2706
2707         Short2::Short2(RValue<Short4> cast)
2708         {
2709                 assert(false && "UNIMPLEMENTED");
2710         }
2711
2712         Type *Short2::getType()
2713         {
2714                 return T(Type_v2i16);
2715         }
2716
2717         UShort2::UShort2(RValue<UShort4> cast)
2718         {
2719                 assert(false && "UNIMPLEMENTED");
2720         }
2721
2722         Type *UShort2::getType()
2723         {
2724                 return T(Type_v2i16);
2725         }
2726
2727         Short4::Short4(RValue<Int> cast)
2728         {
2729                 Value *extend = Nucleus::createZExt(cast.value, Long::getType());
2730                 Value *swizzle = Swizzle(RValue<Short4>(extend), 0x00).value;
2731
2732                 storeValue(swizzle);
2733         }
2734
2735         Short4::Short4(RValue<Int4> cast)
2736         {
2737                 assert(false && "UNIMPLEMENTED");
2738         }
2739
2740 //      Short4::Short4(RValue<Float> cast)
2741 //      {
2742 //      }
2743
2744         Short4::Short4(RValue<Float4> cast)
2745         {
2746                 assert(false && "UNIMPLEMENTED");
2747         }
2748
2749         Short4::Short4()
2750         {
2751         //      xyzw.parent = this;
2752         }
2753
2754         Short4::Short4(short xyzw)
2755         {
2756                 //      xyzw.parent = this;
2757
2758                 assert(false && "UNIMPLEMENTED");
2759         }
2760
2761         Short4::Short4(short x, short y, short z, short w)
2762         {
2763         //      xyzw.parent = this;
2764
2765                 assert(false && "UNIMPLEMENTED");
2766         }
2767
2768         Short4::Short4(RValue<Short4> rhs)
2769         {
2770         //      xyzw.parent = this;
2771
2772                 storeValue(rhs.value);
2773         }
2774
2775         Short4::Short4(const Short4 &rhs)
2776         {
2777         //      xyzw.parent = this;
2778
2779                 Value *value = rhs.loadValue();
2780                 storeValue(value);
2781         }
2782
2783         Short4::Short4(const Reference<Short4> &rhs)
2784         {
2785         //      xyzw.parent = this;
2786
2787                 Value *value = rhs.loadValue();
2788                 storeValue(value);
2789         }
2790
2791         Short4::Short4(RValue<UShort4> rhs)
2792         {
2793         //      xyzw.parent = this;
2794
2795                 storeValue(rhs.value);
2796         }
2797
2798         Short4::Short4(const UShort4 &rhs)
2799         {
2800         //      xyzw.parent = this;
2801
2802                 storeValue(rhs.loadValue());
2803         }
2804
2805         Short4::Short4(const Reference<UShort4> &rhs)
2806         {
2807         //      xyzw.parent = this;
2808
2809                 storeValue(rhs.loadValue());
2810         }
2811
2812         RValue<Short4> Short4::operator=(RValue<Short4> rhs) const
2813         {
2814                 storeValue(rhs.value);
2815
2816                 return rhs;
2817         }
2818
2819         RValue<Short4> Short4::operator=(const Short4 &rhs) const
2820         {
2821                 Value *value = rhs.loadValue();
2822                 storeValue(value);
2823
2824                 return RValue<Short4>(value);
2825         }
2826
2827         RValue<Short4> Short4::operator=(const Reference<Short4> &rhs) const
2828         {
2829                 Value *value = rhs.loadValue();
2830                 storeValue(value);
2831
2832                 return RValue<Short4>(value);
2833         }
2834
2835         RValue<Short4> Short4::operator=(RValue<UShort4> rhs) const
2836         {
2837                 storeValue(rhs.value);
2838
2839                 return RValue<Short4>(rhs);
2840         }
2841
2842         RValue<Short4> Short4::operator=(const UShort4 &rhs) const
2843         {
2844                 Value *value = rhs.loadValue();
2845                 storeValue(value);
2846
2847                 return RValue<Short4>(value);
2848         }
2849
2850         RValue<Short4> Short4::operator=(const Reference<UShort4> &rhs) const
2851         {
2852                 Value *value = rhs.loadValue();
2853                 storeValue(value);
2854
2855                 return RValue<Short4>(value);
2856         }
2857
2858         RValue<Short4> operator+(RValue<Short4> lhs, RValue<Short4> rhs)
2859         {
2860                 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
2861         }
2862
2863         RValue<Short4> operator-(RValue<Short4> lhs, RValue<Short4> rhs)
2864         {
2865                 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
2866         }
2867
2868         RValue<Short4> operator*(RValue<Short4> lhs, RValue<Short4> rhs)
2869         {
2870                 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
2871         }
2872
2873 //      RValue<Short4> operator/(RValue<Short4> lhs, RValue<Short4> rhs)
2874 //      {
2875 //              return RValue<Short4>(Nucleus::createSDiv(lhs.value, rhs.value));
2876 //      }
2877
2878 //      RValue<Short4> operator%(RValue<Short4> lhs, RValue<Short4> rhs)
2879 //      {
2880 //              return RValue<Short4>(Nucleus::createSRem(lhs.value, rhs.value));
2881 //      }
2882
2883         RValue<Short4> operator&(RValue<Short4> lhs, RValue<Short4> rhs)
2884         {
2885                 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
2886         }
2887
2888         RValue<Short4> operator|(RValue<Short4> lhs, RValue<Short4> rhs)
2889         {
2890                 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
2891         }
2892
2893         RValue<Short4> operator^(RValue<Short4> lhs, RValue<Short4> rhs)
2894         {
2895                 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
2896         }
2897
2898         RValue<Short4> operator<<(RValue<Short4> lhs, unsigned char rhs)
2899         {
2900         //      return RValue<Short4>(Nucleus::createShl(lhs.value, rhs.value));
2901
2902                 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
2903         }
2904
2905         RValue<Short4> operator>>(RValue<Short4> lhs, unsigned char rhs)
2906         {
2907         //      return RValue<Short4>(Nucleus::createAShr(lhs.value, rhs.value));
2908
2909                 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
2910         }
2911
2912         RValue<Short4> operator<<(RValue<Short4> lhs, RValue<Long1> rhs)
2913         {
2914         //      return RValue<Short4>(Nucleus::createShl(lhs.value, rhs.value));
2915
2916                 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
2917         }
2918
2919         RValue<Short4> operator>>(RValue<Short4> lhs, RValue<Long1> rhs)
2920         {
2921         //      return RValue<Short4>(Nucleus::createAShr(lhs.value, rhs.value));
2922
2923                 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
2924         }
2925
2926         RValue<Short4> operator+=(const Short4 &lhs, RValue<Short4> rhs)
2927         {
2928                 return lhs = lhs + rhs;
2929         }
2930
2931         RValue<Short4> operator-=(const Short4 &lhs, RValue<Short4> rhs)
2932         {
2933                 return lhs = lhs - rhs;
2934         }
2935
2936         RValue<Short4> operator*=(const Short4 &lhs, RValue<Short4> rhs)
2937         {
2938                 return lhs = lhs * rhs;
2939         }
2940
2941 //      RValue<Short4> operator/=(const Short4 &lhs, RValue<Short4> rhs)
2942 //      {
2943 //              return lhs = lhs / rhs;
2944 //      }
2945
2946 //      RValue<Short4> operator%=(const Short4 &lhs, RValue<Short4> rhs)
2947 //      {
2948 //              return lhs = lhs % rhs;
2949 //      }
2950
2951         RValue<Short4> operator&=(const Short4 &lhs, RValue<Short4> rhs)
2952         {
2953                 return lhs = lhs & rhs;
2954         }
2955
2956         RValue<Short4> operator|=(const Short4 &lhs, RValue<Short4> rhs)
2957         {
2958                 return lhs = lhs | rhs;
2959         }
2960
2961         RValue<Short4> operator^=(const Short4 &lhs, RValue<Short4> rhs)
2962         {
2963                 return lhs = lhs ^ rhs;
2964         }
2965
2966         RValue<Short4> operator<<=(const Short4 &lhs, unsigned char rhs)
2967         {
2968                 return lhs = lhs << rhs;
2969         }
2970
2971         RValue<Short4> operator>>=(const Short4 &lhs, unsigned char rhs)
2972         {
2973                 return lhs = lhs >> rhs;
2974         }
2975
2976         RValue<Short4> operator<<=(const Short4 &lhs, RValue<Long1> rhs)
2977         {
2978                 return lhs = lhs << rhs;
2979         }
2980
2981         RValue<Short4> operator>>=(const Short4 &lhs, RValue<Long1> rhs)
2982         {
2983                 return lhs = lhs >> rhs;
2984         }
2985
2986 //      RValue<Short4> operator+(RValue<Short4> val)
2987 //      {
2988 //              return val;
2989 //      }
2990
2991         RValue<Short4> operator-(RValue<Short4> val)
2992         {
2993                 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
2994         }
2995
2996         RValue<Short4> operator~(RValue<Short4> val)
2997         {
2998                 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
2999         }
3000
3001         RValue<Short4> RoundShort4(RValue<Float4> cast)
3002         {
3003                 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
3004         }
3005
3006         RValue<Short4> Max(RValue<Short4> x, RValue<Short4> y)
3007         {
3008                 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
3009         }
3010
3011         RValue<Short4> Min(RValue<Short4> x, RValue<Short4> y)
3012         {
3013                 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
3014         }
3015
3016         RValue<Short4> AddSat(RValue<Short4> x, RValue<Short4> y)
3017         {
3018                 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
3019         }
3020
3021         RValue<Short4> SubSat(RValue<Short4> x, RValue<Short4> y)
3022         {
3023                 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
3024         }
3025
3026         RValue<Short4> MulHigh(RValue<Short4> x, RValue<Short4> y)
3027         {
3028                 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
3029         }
3030
3031         RValue<Int2> MulAdd(RValue<Short4> x, RValue<Short4> y)
3032         {
3033                 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
3034         }
3035
3036         RValue<SByte8> Pack(RValue<Short4> x, RValue<Short4> y)
3037         {
3038                 assert(false && "UNIMPLEMENTED"); return RValue<SByte8>(V(nullptr));
3039         }
3040
3041         RValue<Int2> UnpackLow(RValue<Short4> x, RValue<Short4> y)
3042         {
3043                 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
3044         }
3045
3046         RValue<Int2> UnpackHigh(RValue<Short4> x, RValue<Short4> y)
3047         {
3048                 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
3049         }
3050
3051         RValue<Short4> Swizzle(RValue<Short4> x, unsigned char select)
3052         {
3053                 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
3054         }
3055
3056         RValue<Short4> Insert(RValue<Short4> val, RValue<Short> element, int i)
3057         {
3058                 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
3059         }
3060
3061         RValue<Short> Extract(RValue<Short4> val, int i)
3062         {
3063                 assert(false && "UNIMPLEMENTED"); return RValue<Short>(V(nullptr));
3064         }
3065
3066         RValue<Short4> CmpGT(RValue<Short4> x, RValue<Short4> y)
3067         {
3068                 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
3069         }
3070
3071         RValue<Short4> CmpEQ(RValue<Short4> x, RValue<Short4> y)
3072         {
3073                 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
3074         }
3075
3076         Type *Short4::getType()
3077         {
3078                 return T(Type_v4i16);
3079         }
3080
3081         UShort4::UShort4(RValue<Int4> cast)
3082         {
3083                 *this = Short4(cast);
3084         }
3085
3086         UShort4::UShort4(RValue<Float4> cast, bool saturate)
3087         {
3088                 assert(false && "UNIMPLEMENTED");
3089         }
3090
3091         UShort4::UShort4()
3092         {
3093         //      xyzw.parent = this;
3094         }
3095
3096         UShort4::UShort4(unsigned short xyzw)
3097         {
3098                 //      xyzw.parent = this;
3099
3100                 assert(false && "UNIMPLEMENTED");
3101         }
3102
3103         UShort4::UShort4(unsigned short x, unsigned short y, unsigned short z, unsigned short w)
3104         {
3105         //      xyzw.parent = this;
3106
3107                 assert(false && "UNIMPLEMENTED");
3108         }
3109
3110         UShort4::UShort4(RValue<UShort4> rhs)
3111         {
3112         //      xyzw.parent = this;
3113
3114                 storeValue(rhs.value);
3115         }
3116
3117         UShort4::UShort4(const UShort4 &rhs)
3118         {
3119         //      xyzw.parent = this;
3120
3121                 Value *value = rhs.loadValue();
3122                 storeValue(value);
3123         }
3124
3125         UShort4::UShort4(const Reference<UShort4> &rhs)
3126         {
3127         //      xyzw.parent = this;
3128
3129                 Value *value = rhs.loadValue();
3130                 storeValue(value);
3131         }
3132
3133         UShort4::UShort4(RValue<Short4> rhs)
3134         {
3135         //      xyzw.parent = this;
3136
3137                 storeValue(rhs.value);
3138         }
3139
3140         UShort4::UShort4(const Short4 &rhs)
3141         {
3142         //      xyzw.parent = this;
3143
3144                 Value *value = rhs.loadValue();
3145                 storeValue(value);
3146         }
3147
3148         UShort4::UShort4(const Reference<Short4> &rhs)
3149         {
3150         //      xyzw.parent = this;
3151
3152                 Value *value = rhs.loadValue();
3153                 storeValue(value);
3154         }
3155
3156         RValue<UShort4> UShort4::operator=(RValue<UShort4> rhs) const
3157         {
3158                 storeValue(rhs.value);
3159
3160                 return rhs;
3161         }
3162
3163         RValue<UShort4> UShort4::operator=(const UShort4 &rhs) const
3164         {
3165                 Value *value = rhs.loadValue();
3166                 storeValue(value);
3167
3168                 return RValue<UShort4>(value);
3169         }
3170
3171         RValue<UShort4> UShort4::operator=(const Reference<UShort4> &rhs) const
3172         {
3173                 Value *value = rhs.loadValue();
3174                 storeValue(value);
3175
3176                 return RValue<UShort4>(value);
3177         }
3178
3179         RValue<UShort4> UShort4::operator=(RValue<Short4> rhs) const
3180         {
3181                 storeValue(rhs.value);
3182
3183                 return RValue<UShort4>(rhs);
3184         }
3185
3186         RValue<UShort4> UShort4::operator=(const Short4 &rhs) const
3187         {
3188                 Value *value = rhs.loadValue();
3189                 storeValue(value);
3190
3191                 return RValue<UShort4>(value);
3192         }
3193
3194         RValue<UShort4> UShort4::operator=(const Reference<Short4> &rhs) const
3195         {
3196                 Value *value = rhs.loadValue();
3197                 storeValue(value);
3198
3199                 return RValue<UShort4>(value);
3200         }
3201
3202         RValue<UShort4> operator+(RValue<UShort4> lhs, RValue<UShort4> rhs)
3203         {
3204                 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3205         }
3206
3207         RValue<UShort4> operator-(RValue<UShort4> lhs, RValue<UShort4> rhs)
3208         {
3209                 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3210         }
3211
3212         RValue<UShort4> operator*(RValue<UShort4> lhs, RValue<UShort4> rhs)
3213         {
3214                 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3215         }
3216
3217         RValue<UShort4> operator&(RValue<UShort4> lhs, RValue<UShort4> rhs)
3218         {
3219                 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3220         }
3221
3222         RValue<UShort4> operator|(RValue<UShort4> lhs, RValue<UShort4> rhs)
3223         {
3224                 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3225         }
3226
3227         RValue<UShort4> operator^(RValue<UShort4> lhs, RValue<UShort4> rhs)
3228         {
3229                 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3230         }
3231
3232         RValue<UShort4> operator<<(RValue<UShort4> lhs, unsigned char rhs)
3233         {
3234                 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3235         }
3236
3237         RValue<UShort4> operator>>(RValue<UShort4> lhs, unsigned char rhs)
3238         {
3239                 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3240         }
3241
3242         RValue<UShort4> operator<<(RValue<UShort4> lhs, RValue<Long1> rhs)
3243         {
3244                 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3245         }
3246
3247         RValue<UShort4> operator>>(RValue<UShort4> lhs, RValue<Long1> rhs)
3248         {
3249                 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3250         }
3251
3252         RValue<UShort4> operator<<=(const UShort4 &lhs, unsigned char rhs)
3253         {
3254                 return lhs = lhs << rhs;
3255         }
3256
3257         RValue<UShort4> operator>>=(const UShort4 &lhs, unsigned char rhs)
3258         {
3259                 return lhs = lhs >> rhs;
3260         }
3261
3262         RValue<UShort4> operator<<=(const UShort4 &lhs, RValue<Long1> rhs)
3263         {
3264                 return lhs = lhs << rhs;
3265         }
3266
3267         RValue<UShort4> operator>>=(const UShort4 &lhs, RValue<Long1> rhs)
3268         {
3269                 return lhs = lhs >> rhs;
3270         }
3271
3272         RValue<UShort4> operator~(RValue<UShort4> val)
3273         {
3274                 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3275         }
3276
3277         RValue<UShort4> Max(RValue<UShort4> x, RValue<UShort4> y)
3278         {
3279                 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3280         }
3281
3282         RValue<UShort4> Min(RValue<UShort4> x, RValue<UShort4> y)
3283         {
3284                 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3285         }
3286
3287         RValue<UShort4> AddSat(RValue<UShort4> x, RValue<UShort4> y)
3288         {
3289                 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3290         }
3291
3292         RValue<UShort4> SubSat(RValue<UShort4> x, RValue<UShort4> y)
3293         {
3294                 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3295         }
3296
3297         RValue<UShort4> MulHigh(RValue<UShort4> x, RValue<UShort4> y)
3298         {
3299                 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3300         }
3301
3302         RValue<UShort4> Average(RValue<UShort4> x, RValue<UShort4> y)
3303         {
3304                 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3305         }
3306
3307         RValue<Byte8> Pack(RValue<UShort4> x, RValue<UShort4> y)
3308         {
3309                 assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
3310         }
3311
3312         Type *UShort4::getType()
3313         {
3314                 return T(Type_v4i16);
3315         }
3316
3317         Short8::Short8(short c0, short c1, short c2, short c3, short c4, short c5, short c6, short c7)
3318         {
3319         //      xyzw.parent = this;
3320
3321                 assert(false && "UNIMPLEMENTED");
3322         }
3323
3324         Short8::Short8(RValue<Short8> rhs)
3325         {
3326         //      xyzw.parent = this;
3327
3328                 storeValue(rhs.value);
3329         }
3330
3331         Short8::Short8(const Reference<Short8> &rhs)
3332         {
3333         //      xyzw.parent = this;
3334
3335                 Value *value = rhs.loadValue();
3336                 storeValue(value);
3337         }
3338
3339         Short8::Short8(RValue<Short4> lo, RValue<Short4> hi)
3340         {
3341                 assert(false && "UNIMPLEMENTED");
3342         }
3343
3344         RValue<Short8> operator+(RValue<Short8> lhs, RValue<Short8> rhs)
3345         {
3346                 return RValue<Short8>(Nucleus::createAdd(lhs.value, rhs.value));
3347         }
3348
3349         RValue<Short8> operator&(RValue<Short8> lhs, RValue<Short8> rhs)
3350         {
3351                 return RValue<Short8>(Nucleus::createAnd(lhs.value, rhs.value));
3352         }
3353
3354         RValue<Short8> operator<<(RValue<Short8> lhs, unsigned char rhs)
3355         {
3356                 assert(false && "UNIMPLEMENTED"); return RValue<Short8>(V(nullptr));
3357         }
3358
3359         RValue<Short8> operator>>(RValue<Short8> lhs, unsigned char rhs)
3360         {
3361                 assert(false && "UNIMPLEMENTED"); return RValue<Short8>(V(nullptr));
3362         }
3363
3364         RValue<Int4> MulAdd(RValue<Short8> x, RValue<Short8> y)
3365         {
3366                 assert(false && "UNIMPLEMENTED"); return RValue<Int4>(V(nullptr));
3367         }
3368
3369         RValue<Int4> Abs(RValue<Int4> x)
3370         {
3371                 assert(false && "UNIMPLEMENTED"); return RValue<Int4>(V(nullptr));
3372         }
3373
3374         RValue<Short8> MulHigh(RValue<Short8> x, RValue<Short8> y)
3375         {
3376                 assert(false && "UNIMPLEMENTED"); return RValue<Short8>(V(nullptr));
3377         }
3378
3379         Type *Short8::getType()
3380         {
3381                 assert(false && "UNIMPLEMENTED"); return nullptr;
3382         }
3383
3384         UShort8::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)
3385         {
3386         //      xyzw.parent = this;
3387
3388                 assert(false && "UNIMPLEMENTED");
3389         }
3390
3391         UShort8::UShort8(RValue<UShort8> rhs)
3392         {
3393         //      xyzw.parent = this;
3394
3395                 storeValue(rhs.value);
3396         }
3397
3398         UShort8::UShort8(const Reference<UShort8> &rhs)
3399         {
3400         //      xyzw.parent = this;
3401
3402                 Value *value = rhs.loadValue();
3403                 storeValue(value);
3404         }
3405
3406         UShort8::UShort8(RValue<UShort4> lo, RValue<UShort4> hi)
3407         {
3408                 assert(false && "UNIMPLEMENTED");
3409         }
3410
3411         RValue<UShort8> UShort8::operator=(RValue<UShort8> rhs) const
3412         {
3413                 storeValue(rhs.value);
3414
3415                 return rhs;
3416         }
3417
3418         RValue<UShort8> UShort8::operator=(const UShort8 &rhs) const
3419         {
3420                 Value *value = rhs.loadValue();
3421                 storeValue(value);
3422
3423                 return RValue<UShort8>(value);
3424         }
3425
3426         RValue<UShort8> UShort8::operator=(const Reference<UShort8> &rhs) const
3427         {
3428                 Value *value = rhs.loadValue();
3429                 storeValue(value);
3430
3431                 return RValue<UShort8>(value);
3432         }
3433
3434         RValue<UShort8> operator&(RValue<UShort8> lhs, RValue<UShort8> rhs)
3435         {
3436                 return RValue<UShort8>(Nucleus::createAnd(lhs.value, rhs.value));
3437         }
3438
3439         RValue<UShort8> operator<<(RValue<UShort8> lhs, unsigned char rhs)
3440         {
3441                 assert(false && "UNIMPLEMENTED"); return RValue<UShort8>(V(nullptr));
3442         }
3443
3444         RValue<UShort8> operator>>(RValue<UShort8> lhs, unsigned char rhs)
3445         {
3446                 assert(false && "UNIMPLEMENTED"); return RValue<UShort8>(V(nullptr));
3447         }
3448
3449         RValue<UShort8> operator+(RValue<UShort8> lhs, RValue<UShort8> rhs)
3450         {
3451                 return RValue<UShort8>(Nucleus::createAdd(lhs.value, rhs.value));
3452         }
3453
3454         RValue<UShort8> operator*(RValue<UShort8> lhs, RValue<UShort8> rhs)
3455         {
3456                 return RValue<UShort8>(Nucleus::createMul(lhs.value, rhs.value));
3457         }
3458
3459         RValue<UShort8> operator+=(const UShort8 &lhs, RValue<UShort8> rhs)
3460         {
3461                 return lhs = lhs + rhs;
3462         }
3463
3464         RValue<UShort8> operator~(RValue<UShort8> val)
3465         {
3466                 return RValue<UShort8>(Nucleus::createNot(val.value));
3467         }
3468
3469         RValue<UShort8> Swizzle(RValue<UShort8> x, char select0, char select1, char select2, char select3, char select4, char select5, char select6, char select7)
3470         {
3471                 assert(false && "UNIMPLEMENTED"); return RValue<UShort8>(V(nullptr));
3472         }
3473
3474         RValue<UShort8> MulHigh(RValue<UShort8> x, RValue<UShort8> y)
3475         {
3476                 assert(false && "UNIMPLEMENTED"); return RValue<UShort8>(V(nullptr));
3477         }
3478
3479         // FIXME: Implement as Shuffle(x, y, Select(i0, ..., i16)) and Shuffle(x, y, SELECT_PACK_REPEAT(element))
3480 //      RValue<UShort8> PackRepeat(RValue<Byte16> x, RValue<Byte16> y, int element)
3481 //      {
3482 //              assert(false && "UNIMPLEMENTED"); return RValue<UShort8>(V(nullptr));
3483 //      }
3484
3485         Type *UShort8::getType()
3486         {
3487                 assert(false && "UNIMPLEMENTED"); return nullptr;
3488         }
3489
3490         Int::Int(Argument<Int> argument)
3491         {
3492                 storeValue(argument.value);
3493         }
3494
3495         Int::Int(RValue<Byte> cast)
3496         {
3497                 Value *integer = Nucleus::createZExt(cast.value, Int::getType());
3498
3499                 storeValue(integer);
3500         }
3501
3502         Int::Int(RValue<SByte> cast)
3503         {
3504                 Value *integer = Nucleus::createSExt(cast.value, Int::getType());
3505
3506                 storeValue(integer);
3507         }
3508
3509         Int::Int(RValue<Short> cast)
3510         {
3511                 Value *integer = Nucleus::createSExt(cast.value, Int::getType());
3512
3513                 storeValue(integer);
3514         }
3515
3516         Int::Int(RValue<UShort> cast)
3517         {
3518                 Value *integer = Nucleus::createZExt(cast.value, Int::getType());
3519
3520                 storeValue(integer);
3521         }
3522
3523         Int::Int(RValue<Int2> cast)
3524         {
3525                 *this = Extract(cast, 0);
3526         }
3527
3528         Int::Int(RValue<Long> cast)
3529         {
3530                 Value *integer = Nucleus::createTrunc(cast.value, Int::getType());
3531
3532                 storeValue(integer);
3533         }
3534
3535         Int::Int(RValue<Float> cast)
3536         {
3537                 Value *integer = Nucleus::createFPToSI(cast.value, Int::getType());
3538
3539                 storeValue(integer);
3540         }
3541
3542         Int::Int()
3543         {
3544         }
3545
3546         Int::Int(int x)
3547         {
3548                 storeValue(Nucleus::createConstantInt(x));
3549         }
3550
3551         Int::Int(RValue<Int> rhs)
3552         {
3553                 storeValue(rhs.value);
3554         }
3555
3556         Int::Int(RValue<UInt> rhs)
3557         {
3558                 storeValue(rhs.value);
3559         }
3560
3561         Int::Int(const Int &rhs)
3562         {
3563                 Value *value = rhs.loadValue();
3564                 storeValue(value);
3565         }
3566
3567         Int::Int(const Reference<Int> &rhs)
3568         {
3569                 Value *value = rhs.loadValue();
3570                 storeValue(value);
3571         }
3572
3573         Int::Int(const UInt &rhs)
3574         {
3575                 Value *value = rhs.loadValue();
3576                 storeValue(value);
3577         }
3578
3579         Int::Int(const Reference<UInt> &rhs)
3580         {
3581                 Value *value = rhs.loadValue();
3582                 storeValue(value);
3583         }
3584
3585         RValue<Int> Int::operator=(int rhs) const
3586         {
3587                 return RValue<Int>(storeValue(Nucleus::createConstantInt(rhs)));
3588         }
3589
3590         RValue<Int> Int::operator=(RValue<Int> rhs) const
3591         {
3592                 storeValue(rhs.value);
3593
3594                 return rhs;
3595         }
3596
3597         RValue<Int> Int::operator=(RValue<UInt> rhs) const
3598         {
3599                 storeValue(rhs.value);
3600
3601                 return RValue<Int>(rhs);
3602         }
3603
3604         RValue<Int> Int::operator=(const Int &rhs) const
3605         {
3606                 Value *value = rhs.loadValue();
3607                 storeValue(value);
3608
3609                 return RValue<Int>(value);
3610         }
3611
3612         RValue<Int> Int::operator=(const Reference<Int> &rhs) const
3613         {
3614                 Value *value = rhs.loadValue();
3615                 storeValue(value);
3616
3617                 return RValue<Int>(value);
3618         }
3619
3620         RValue<Int> Int::operator=(const UInt &rhs) const
3621         {
3622                 Value *value = rhs.loadValue();
3623                 storeValue(value);
3624
3625                 return RValue<Int>(value);
3626         }
3627
3628         RValue<Int> Int::operator=(const Reference<UInt> &rhs) const
3629         {
3630                 Value *value = rhs.loadValue();
3631                 storeValue(value);
3632
3633                 return RValue<Int>(value);
3634         }
3635
3636         RValue<Int> operator+(RValue<Int> lhs, RValue<Int> rhs)
3637         {
3638                 return RValue<Int>(Nucleus::createAdd(lhs.value, rhs.value));
3639         }
3640
3641         RValue<Int> operator-(RValue<Int> lhs, RValue<Int> rhs)
3642         {
3643                 return RValue<Int>(Nucleus::createSub(lhs.value, rhs.value));
3644         }
3645
3646         RValue<Int> operator*(RValue<Int> lhs, RValue<Int> rhs)
3647         {
3648                 return RValue<Int>(Nucleus::createMul(lhs.value, rhs.value));
3649         }
3650
3651         RValue<Int> operator/(RValue<Int> lhs, RValue<Int> rhs)
3652         {
3653                 return RValue<Int>(Nucleus::createSDiv(lhs.value, rhs.value));
3654         }
3655
3656         RValue<Int> operator%(RValue<Int> lhs, RValue<Int> rhs)
3657         {
3658                 return RValue<Int>(Nucleus::createSRem(lhs.value, rhs.value));
3659         }
3660
3661         RValue<Int> operator&(RValue<Int> lhs, RValue<Int> rhs)
3662         {
3663                 return RValue<Int>(Nucleus::createAnd(lhs.value, rhs.value));
3664         }
3665
3666         RValue<Int> operator|(RValue<Int> lhs, RValue<Int> rhs)
3667         {
3668                 return RValue<Int>(Nucleus::createOr(lhs.value, rhs.value));
3669         }
3670
3671         RValue<Int> operator^(RValue<Int> lhs, RValue<Int> rhs)
3672         {
3673                 return RValue<Int>(Nucleus::createXor(lhs.value, rhs.value));
3674         }
3675
3676         RValue<Int> operator<<(RValue<Int> lhs, RValue<Int> rhs)
3677         {
3678                 return RValue<Int>(Nucleus::createShl(lhs.value, rhs.value));
3679         }
3680
3681         RValue<Int> operator>>(RValue<Int> lhs, RValue<Int> rhs)
3682         {
3683                 return RValue<Int>(Nucleus::createAShr(lhs.value, rhs.value));
3684         }
3685
3686         RValue<Int> operator+=(const Int &lhs, RValue<Int> rhs)
3687         {
3688                 return lhs = lhs + rhs;
3689         }
3690
3691         RValue<Int> operator-=(const Int &lhs, RValue<Int> rhs)
3692         {
3693                 return lhs = lhs - rhs;
3694         }
3695
3696         RValue<Int> operator*=(const Int &lhs, RValue<Int> rhs)
3697         {
3698                 return lhs = lhs * rhs;
3699         }
3700
3701         RValue<Int> operator/=(const Int &lhs, RValue<Int> rhs)
3702         {
3703                 return lhs = lhs / rhs;
3704         }
3705
3706         RValue<Int> operator%=(const Int &lhs, RValue<Int> rhs)
3707         {
3708                 return lhs = lhs % rhs;
3709         }
3710
3711         RValue<Int> operator&=(const Int &lhs, RValue<Int> rhs)
3712         {
3713                 return lhs = lhs & rhs;
3714         }
3715
3716         RValue<Int> operator|=(const Int &lhs, RValue<Int> rhs)
3717         {
3718                 return lhs = lhs | rhs;
3719         }
3720
3721         RValue<Int> operator^=(const Int &lhs, RValue<Int> rhs)
3722         {
3723                 return lhs = lhs ^ rhs;
3724         }
3725
3726         RValue<Int> operator<<=(const Int &lhs, RValue<Int> rhs)
3727         {
3728                 return lhs = lhs << rhs;
3729         }
3730
3731         RValue<Int> operator>>=(const Int &lhs, RValue<Int> rhs)
3732         {
3733                 return lhs = lhs >> rhs;
3734         }
3735
3736         RValue<Int> operator+(RValue<Int> val)
3737         {
3738                 return val;
3739         }
3740
3741         RValue<Int> operator-(RValue<Int> val)
3742         {
3743                 return RValue<Int>(Nucleus::createNeg(val.value));
3744         }
3745
3746         RValue<Int> operator~(RValue<Int> val)
3747         {
3748                 return RValue<Int>(Nucleus::createNot(val.value));
3749         }
3750
3751         RValue<Int> operator++(const Int &val, int)   // Post-increment
3752         {
3753                 auto oldValue = val.loadValue();
3754                 auto newValue = ::function->makeVariable(Ice::IceType_i32);
3755                 auto inc = Ice::InstArithmetic::create(::function, Ice::InstArithmetic::Add, newValue, oldValue, ::context->getConstantInt32(1));
3756                 ::basicBlock->appendInst(inc);
3757                 val.storeValue(V(newValue));
3758
3759                 return RValue<Int>(oldValue);
3760         }
3761
3762         const Int &operator++(const Int &val)   // Pre-increment
3763         {
3764                 assert(false && "UNIMPLEMENTED"); return val;
3765         }
3766
3767         RValue<Int> operator--(const Int &val, int)   // Post-decrement
3768         {
3769                 assert(false && "UNIMPLEMENTED"); return RValue<Int>(V(nullptr));
3770         }
3771
3772         const Int &operator--(const Int &val)   // Pre-decrement
3773         {
3774                 assert(false && "UNIMPLEMENTED"); return val;
3775         }
3776
3777         RValue<Bool> operator<(RValue<Int> lhs, RValue<Int> rhs)
3778         {
3779                 return RValue<Bool>(Nucleus::createICmpSLT(lhs.value, rhs.value));
3780         }
3781
3782         RValue<Bool> operator<=(RValue<Int> lhs, RValue<Int> rhs)
3783         {
3784                 return RValue<Bool>(Nucleus::createICmpSLE(lhs.value, rhs.value));
3785         }
3786
3787         RValue<Bool> operator>(RValue<Int> lhs, RValue<Int> rhs)
3788         {
3789                 return RValue<Bool>(Nucleus::createICmpSGT(lhs.value, rhs.value));
3790         }
3791
3792         RValue<Bool> operator>=(RValue<Int> lhs, RValue<Int> rhs)
3793         {
3794                 return RValue<Bool>(Nucleus::createICmpSGE(lhs.value, rhs.value));
3795         }
3796
3797         RValue<Bool> operator!=(RValue<Int> lhs, RValue<Int> rhs)
3798         {
3799                 return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value));
3800         }
3801
3802         RValue<Bool> operator==(RValue<Int> lhs, RValue<Int> rhs)
3803         {
3804                 return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value));
3805         }
3806
3807         RValue<Int> Max(RValue<Int> x, RValue<Int> y)
3808         {
3809                 return IfThenElse(x > y, x, y);
3810         }
3811
3812         RValue<Int> Min(RValue<Int> x, RValue<Int> y)
3813         {
3814                 return IfThenElse(x < y, x, y);
3815         }
3816
3817         RValue<Int> Clamp(RValue<Int> x, RValue<Int> min, RValue<Int> max)
3818         {
3819                 return Min(Max(x, min), max);
3820         }
3821
3822         RValue<Int> RoundInt(RValue<Float> cast)
3823         {
3824                 assert(false && "UNIMPLEMENTED"); return RValue<Int>(V(nullptr));
3825         }
3826
3827         Type *Int::getType()
3828         {
3829                 return T(Ice::IceType_i32);
3830         }
3831
3832         Long::Long(RValue<Int> cast)
3833         {
3834                 Value *integer = Nucleus::createSExt(cast.value, Long::getType());
3835
3836                 storeValue(integer);
3837         }
3838
3839         Long::Long(RValue<UInt> cast)
3840         {
3841                 Value *integer = Nucleus::createZExt(cast.value, Long::getType());
3842
3843                 storeValue(integer);
3844         }
3845
3846         Long::Long()
3847         {
3848         }
3849
3850         Long::Long(RValue<Long> rhs)
3851         {
3852                 storeValue(rhs.value);
3853         }
3854
3855         RValue<Long> Long::operator=(int64_t rhs) const
3856         {
3857                 return RValue<Long>(storeValue(Nucleus::createConstantLong(rhs)));
3858         }
3859
3860         RValue<Long> Long::operator=(RValue<Long> rhs) const
3861         {
3862                 storeValue(rhs.value);
3863
3864                 return rhs;
3865         }
3866
3867         RValue<Long> Long::operator=(const Long &rhs) const
3868         {
3869                 Value *value = rhs.loadValue();
3870                 storeValue(value);
3871
3872                 return RValue<Long>(value);
3873         }
3874
3875         RValue<Long> Long::operator=(const Reference<Long> &rhs) const
3876         {
3877                 Value *value = rhs.loadValue();
3878                 storeValue(value);
3879
3880                 return RValue<Long>(value);
3881         }
3882
3883         RValue<Long> operator+(RValue<Long> lhs, RValue<Long> rhs)
3884         {
3885                 return RValue<Long>(Nucleus::createAdd(lhs.value, rhs.value));
3886         }
3887
3888         RValue<Long> operator-(RValue<Long> lhs, RValue<Long> rhs)
3889         {
3890                 return RValue<Long>(Nucleus::createSub(lhs.value, rhs.value));
3891         }
3892
3893         RValue<Long> operator+=(const Long &lhs, RValue<Long> rhs)
3894         {
3895                 return lhs = lhs + rhs;
3896         }
3897
3898         RValue<Long> operator-=(const Long &lhs, RValue<Long> rhs)
3899         {
3900                 return lhs = lhs - rhs;
3901         }
3902
3903         RValue<Long> AddAtomic(RValue<Pointer<Long> > x, RValue<Long> y)
3904         {
3905                 return RValue<Long>(Nucleus::createAtomicAdd(x.value, y.value));
3906         }
3907
3908         Type *Long::getType()
3909         {
3910                 assert(false && "UNIMPLEMENTED"); return nullptr;
3911         }
3912
3913         Long1::Long1(const RValue<UInt> cast)
3914         {
3915                 assert(false && "UNIMPLEMENTED");
3916         }
3917
3918         Long1::Long1(RValue<Long1> rhs)
3919         {
3920                 storeValue(rhs.value);
3921         }
3922
3923         Type *Long1::getType()
3924         {
3925                 assert(false && "UNIMPLEMENTED"); return nullptr;
3926         }
3927
3928         RValue<Long2> UnpackHigh(RValue<Long2> x, RValue<Long2> y)
3929         {
3930                 assert(false && "UNIMPLEMENTED"); return RValue<Long2>(V(nullptr));
3931         }
3932
3933         Type *Long2::getType()
3934         {
3935                 assert(false && "UNIMPLEMENTED"); return nullptr;
3936         }
3937
3938         UInt::UInt(Argument<UInt> argument)
3939         {
3940                 storeValue(argument.value);
3941         }
3942
3943         UInt::UInt(RValue<UShort> cast)
3944         {
3945                 Value *integer = Nucleus::createZExt(cast.value, UInt::getType());
3946
3947                 storeValue(integer);
3948         }
3949
3950         UInt::UInt(RValue<Long> cast)
3951         {
3952                 Value *integer = Nucleus::createTrunc(cast.value, UInt::getType());
3953
3954                 storeValue(integer);
3955         }
3956
3957         UInt::UInt(RValue<Float> cast)
3958         {
3959                 assert(false && "UNIMPLEMENTED");
3960         }
3961
3962         UInt::UInt()
3963         {
3964         }
3965
3966         UInt::UInt(int x)
3967         {
3968                 storeValue(Nucleus::createConstantInt(x));
3969         }
3970
3971         UInt::UInt(unsigned int x)
3972         {
3973                 storeValue(Nucleus::createConstantInt(x));
3974         }
3975
3976         UInt::UInt(RValue<UInt> rhs)
3977         {
3978                 storeValue(rhs.value);
3979         }
3980
3981         UInt::UInt(RValue<Int> rhs)
3982         {
3983                 storeValue(rhs.value);
3984         }
3985
3986         UInt::UInt(const UInt &rhs)
3987         {
3988                 Value *value = rhs.loadValue();
3989                 storeValue(value);
3990         }
3991
3992         UInt::UInt(const Reference<UInt> &rhs)
3993         {
3994                 Value *value = rhs.loadValue();
3995                 storeValue(value);
3996         }
3997
3998         UInt::UInt(const Int &rhs)
3999         {
4000                 Value *value = rhs.loadValue();
4001                 storeValue(value);
4002         }
4003
4004         UInt::UInt(const Reference<Int> &rhs)
4005         {
4006                 Value *value = rhs.loadValue();
4007                 storeValue(value);
4008         }
4009
4010         RValue<UInt> UInt::operator=(unsigned int rhs) const
4011         {
4012                 return RValue<UInt>(storeValue(Nucleus::createConstantInt(rhs)));
4013         }
4014
4015         RValue<UInt> UInt::operator=(RValue<UInt> rhs) const
4016         {
4017                 storeValue(rhs.value);
4018
4019                 return rhs;
4020         }
4021
4022         RValue<UInt> UInt::operator=(RValue<Int> rhs) const
4023         {
4024                 storeValue(rhs.value);
4025
4026                 return RValue<UInt>(rhs);
4027         }
4028
4029         RValue<UInt> UInt::operator=(const UInt &rhs) const
4030         {
4031                 Value *value = rhs.loadValue();
4032                 storeValue(value);
4033
4034                 return RValue<UInt>(value);
4035         }
4036
4037         RValue<UInt> UInt::operator=(const Reference<UInt> &rhs) const
4038         {
4039                 Value *value = rhs.loadValue();
4040                 storeValue(value);
4041
4042                 return RValue<UInt>(value);
4043         }
4044
4045         RValue<UInt> UInt::operator=(const Int &rhs) const
4046         {
4047                 Value *value = rhs.loadValue();
4048                 storeValue(value);
4049
4050                 return RValue<UInt>(value);
4051         }
4052
4053         RValue<UInt> UInt::operator=(const Reference<Int> &rhs) const
4054         {
4055                 Value *value = rhs.loadValue();
4056                 storeValue(value);
4057
4058                 return RValue<UInt>(value);
4059         }
4060
4061         RValue<UInt> operator+(RValue<UInt> lhs, RValue<UInt> rhs)
4062         {
4063                 return RValue<UInt>(Nucleus::createAdd(lhs.value, rhs.value));
4064         }
4065
4066         RValue<UInt> operator-(RValue<UInt> lhs, RValue<UInt> rhs)
4067         {
4068                 return RValue<UInt>(Nucleus::createSub(lhs.value, rhs.value));
4069         }
4070
4071         RValue<UInt> operator*(RValue<UInt> lhs, RValue<UInt> rhs)
4072         {
4073                 return RValue<UInt>(Nucleus::createMul(lhs.value, rhs.value));
4074         }
4075
4076         RValue<UInt> operator/(RValue<UInt> lhs, RValue<UInt> rhs)
4077         {
4078                 return RValue<UInt>(Nucleus::createUDiv(lhs.value, rhs.value));
4079         }
4080
4081         RValue<UInt> operator%(RValue<UInt> lhs, RValue<UInt> rhs)
4082         {
4083                 return RValue<UInt>(Nucleus::createURem(lhs.value, rhs.value));
4084         }
4085
4086         RValue<UInt> operator&(RValue<UInt> lhs, RValue<UInt> rhs)
4087         {
4088                 return RValue<UInt>(Nucleus::createAnd(lhs.value, rhs.value));
4089         }
4090
4091         RValue<UInt> operator|(RValue<UInt> lhs, RValue<UInt> rhs)
4092         {
4093                 return RValue<UInt>(Nucleus::createOr(lhs.value, rhs.value));
4094         }
4095
4096         RValue<UInt> operator^(RValue<UInt> lhs, RValue<UInt> rhs)
4097         {
4098                 return RValue<UInt>(Nucleus::createXor(lhs.value, rhs.value));
4099         }
4100
4101         RValue<UInt> operator<<(RValue<UInt> lhs, RValue<UInt> rhs)
4102         {
4103                 return RValue<UInt>(Nucleus::createShl(lhs.value, rhs.value));
4104         }
4105
4106         RValue<UInt> operator>>(RValue<UInt> lhs, RValue<UInt> rhs)
4107         {
4108                 return RValue<UInt>(Nucleus::createLShr(lhs.value, rhs.value));
4109         }
4110
4111         RValue<UInt> operator+=(const UInt &lhs, RValue<UInt> rhs)
4112         {
4113                 return lhs = lhs + rhs;
4114         }
4115
4116         RValue<UInt> operator-=(const UInt &lhs, RValue<UInt> rhs)
4117         {
4118                 return lhs = lhs - rhs;
4119         }
4120
4121         RValue<UInt> operator*=(const UInt &lhs, RValue<UInt> rhs)
4122         {
4123                 return lhs = lhs * rhs;
4124         }
4125
4126         RValue<UInt> operator/=(const UInt &lhs, RValue<UInt> rhs)
4127         {
4128                 return lhs = lhs / rhs;
4129         }
4130
4131         RValue<UInt> operator%=(const UInt &lhs, RValue<UInt> rhs)
4132         {
4133                 return lhs = lhs % rhs;
4134         }
4135
4136         RValue<UInt> operator&=(const UInt &lhs, RValue<UInt> rhs)
4137         {
4138                 return lhs = lhs & rhs;
4139         }
4140
4141         RValue<UInt> operator|=(const UInt &lhs, RValue<UInt> rhs)
4142         {
4143                 return lhs = lhs | rhs;
4144         }
4145
4146         RValue<UInt> operator^=(const UInt &lhs, RValue<UInt> rhs)
4147         {
4148                 return lhs = lhs ^ rhs;
4149         }
4150
4151         RValue<UInt> operator<<=(const UInt &lhs, RValue<UInt> rhs)
4152         {
4153                 return lhs = lhs << rhs;
4154         }
4155
4156         RValue<UInt> operator>>=(const UInt &lhs, RValue<UInt> rhs)
4157         {
4158                 return lhs = lhs >> rhs;
4159         }
4160
4161         RValue<UInt> operator+(RValue<UInt> val)
4162         {
4163                 return val;
4164         }
4165
4166         RValue<UInt> operator-(RValue<UInt> val)
4167         {
4168                 return RValue<UInt>(Nucleus::createNeg(val.value));
4169         }
4170
4171         RValue<UInt> operator~(RValue<UInt> val)
4172         {
4173                 return RValue<UInt>(Nucleus::createNot(val.value));
4174         }
4175
4176         RValue<UInt> operator++(const UInt &val, int)   // Post-increment
4177         {
4178                 assert(false && "UNIMPLEMENTED"); return RValue<UInt>(V(nullptr));
4179         }
4180
4181         const UInt &operator++(const UInt &val)   // Pre-increment
4182         {
4183                 assert(false && "UNIMPLEMENTED"); return val;
4184         }
4185
4186         RValue<UInt> operator--(const UInt &val, int)   // Post-decrement
4187         {
4188                 assert(false && "UNIMPLEMENTED"); return RValue<UInt>(V(nullptr));
4189         }
4190
4191         const UInt &operator--(const UInt &val)   // Pre-decrement
4192         {
4193                 assert(false && "UNIMPLEMENTED"); return val;
4194         }
4195
4196         RValue<UInt> Max(RValue<UInt> x, RValue<UInt> y)
4197         {
4198                 return IfThenElse(x > y, x, y);
4199         }
4200
4201         RValue<UInt> Min(RValue<UInt> x, RValue<UInt> y)
4202         {
4203                 return IfThenElse(x < y, x, y);
4204         }
4205
4206         RValue<UInt> Clamp(RValue<UInt> x, RValue<UInt> min, RValue<UInt> max)
4207         {
4208                 return Min(Max(x, min), max);
4209         }
4210
4211         RValue<Bool> operator<(RValue<UInt> lhs, RValue<UInt> rhs)
4212         {
4213                 return RValue<Bool>(Nucleus::createICmpULT(lhs.value, rhs.value));
4214         }
4215
4216         RValue<Bool> operator<=(RValue<UInt> lhs, RValue<UInt> rhs)
4217         {
4218                 return RValue<Bool>(Nucleus::createICmpULE(lhs.value, rhs.value));
4219         }
4220
4221         RValue<Bool> operator>(RValue<UInt> lhs, RValue<UInt> rhs)
4222         {
4223                 return RValue<Bool>(Nucleus::createICmpUGT(lhs.value, rhs.value));
4224         }
4225
4226         RValue<Bool> operator>=(RValue<UInt> lhs, RValue<UInt> rhs)
4227         {
4228                 return RValue<Bool>(Nucleus::createICmpUGE(lhs.value, rhs.value));
4229         }
4230
4231         RValue<Bool> operator!=(RValue<UInt> lhs, RValue<UInt> rhs)
4232         {
4233                 return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value));
4234         }
4235
4236         RValue<Bool> operator==(RValue<UInt> lhs, RValue<UInt> rhs)
4237         {
4238                 return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value));
4239         }
4240
4241 //      RValue<UInt> RoundUInt(RValue<Float> cast)
4242 //      {
4243 //              assert(false && "UNIMPLEMENTED"); return RValue<UInt>(V(nullptr));
4244 //      }
4245
4246         Type *UInt::getType()
4247         {
4248                 assert(false && "UNIMPLEMENTED"); return nullptr;
4249         }
4250
4251 //      Int2::Int2(RValue<Int> cast)
4252 //      {
4253 //              Value *extend = Nucleus::createZExt(cast.value, Long::getType());
4254 //              Value *vector = Nucleus::createBitCast(extend, Int2::getType());
4255 //
4256 //              Constant *shuffle[2];
4257 //              shuffle[0] = Nucleus::createConstantInt(0);
4258 //              shuffle[1] = Nucleus::createConstantInt(0);
4259 //
4260 //              Value *replicate = Nucleus::createShuffleVector(vector, UndefValue::get(Int2::getType()), Nucleus::createConstantVector(shuffle, 2));
4261 //
4262 //              storeValue(replicate);
4263 //      }
4264
4265         Int2::Int2(RValue<Int4> cast)
4266         {
4267                 Value *long2 = Nucleus::createBitCast(cast.value, Long2::getType());
4268                 Value *element = Nucleus::createExtractElement(long2, Long2::getType(), 0);
4269                 Value *int2 = Nucleus::createBitCast(element, Int2::getType());
4270
4271                 storeValue(int2);
4272         }
4273
4274         Int2::Int2()
4275         {
4276         //      xy.parent = this;
4277         }
4278
4279         Int2::Int2(int x, int y)
4280         {
4281         //      xy.parent = this;
4282
4283                 assert(false && "UNIMPLEMENTED");
4284         }
4285
4286         Int2::Int2(RValue<Int2> rhs)
4287         {
4288         //      xy.parent = this;
4289
4290                 storeValue(rhs.value);
4291         }
4292
4293         Int2::Int2(const Int2 &rhs)
4294         {
4295         //      xy.parent = this;
4296
4297                 Value *value = rhs.loadValue();
4298                 storeValue(value);
4299         }
4300
4301         Int2::Int2(const Reference<Int2> &rhs)
4302         {
4303         //      xy.parent = this;
4304
4305                 Value *value = rhs.loadValue();
4306                 storeValue(value);
4307         }
4308
4309         Int2::Int2(RValue<Int> lo, RValue<Int> hi)
4310         {
4311                 assert(false && "UNIMPLEMENTED");
4312         }
4313
4314         RValue<Int2> Int2::operator=(RValue<Int2> rhs) const
4315         {
4316                 storeValue(rhs.value);
4317
4318                 return rhs;
4319         }
4320
4321         RValue<Int2> Int2::operator=(const Int2 &rhs) const
4322         {
4323                 Value *value = rhs.loadValue();
4324                 storeValue(value);
4325
4326                 return RValue<Int2>(value);
4327         }
4328
4329         RValue<Int2> Int2::operator=(const Reference<Int2> &rhs) const
4330         {
4331                 Value *value = rhs.loadValue();
4332                 storeValue(value);
4333
4334                 return RValue<Int2>(value);
4335         }
4336
4337         RValue<Int2> operator+(RValue<Int2> lhs, RValue<Int2> rhs)
4338         {
4339                 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
4340         }
4341
4342         RValue<Int2> operator-(RValue<Int2> lhs, RValue<Int2> rhs)
4343         {
4344                 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
4345         }
4346
4347 //      RValue<Int2> operator*(RValue<Int2> lhs, RValue<Int2> rhs)
4348 //      {
4349 //              return RValue<Int2>(Nucleus::createMul(lhs.value, rhs.value));
4350 //      }
4351
4352 //      RValue<Int2> operator/(RValue<Int2> lhs, RValue<Int2> rhs)
4353 //      {
4354 //              return RValue<Int2>(Nucleus::createSDiv(lhs.value, rhs.value));
4355 //      }
4356
4357 //      RValue<Int2> operator%(RValue<Int2> lhs, RValue<Int2> rhs)
4358 //      {
4359 //              return RValue<Int2>(Nucleus::createSRem(lhs.value, rhs.value));
4360 //      }
4361
4362         RValue<Int2> operator&(RValue<Int2> lhs, RValue<Int2> rhs)
4363         {
4364                 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
4365         }
4366
4367         RValue<Int2> operator|(RValue<Int2> lhs, RValue<Int2> rhs)
4368         {
4369                 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
4370         }
4371
4372         RValue<Int2> operator^(RValue<Int2> lhs, RValue<Int2> rhs)
4373         {
4374                 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
4375         }
4376
4377         RValue<Int2> operator<<(RValue<Int2> lhs, unsigned char rhs)
4378         {
4379                 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
4380         }
4381
4382         RValue<Int2> operator>>(RValue<Int2> lhs, unsigned char rhs)
4383         {
4384                 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
4385         }
4386
4387         RValue<Int2> operator<<(RValue<Int2> lhs, RValue<Long1> rhs)
4388         {
4389                 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
4390         }
4391
4392         RValue<Int2> operator>>(RValue<Int2> lhs, RValue<Long1> rhs)
4393         {
4394                 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
4395         }
4396
4397         RValue<Int2> operator+=(const Int2 &lhs, RValue<Int2> rhs)
4398         {
4399                 return lhs = lhs + rhs;
4400         }
4401
4402         RValue<Int2> operator-=(const Int2 &lhs, RValue<Int2> rhs)
4403         {
4404                 return lhs = lhs - rhs;
4405         }
4406
4407 //      RValue<Int2> operator*=(const Int2 &lhs, RValue<Int2> rhs)
4408 //      {
4409 //              return lhs = lhs * rhs;
4410 //      }
4411
4412 //      RValue<Int2> operator/=(const Int2 &lhs, RValue<Int2> rhs)
4413 //      {
4414 //              return lhs = lhs / rhs;
4415 //      }
4416
4417 //      RValue<Int2> operator%=(const Int2 &lhs, RValue<Int2> rhs)
4418 //      {
4419 //              return lhs = lhs % rhs;
4420 //      }
4421
4422         RValue<Int2> operator&=(const Int2 &lhs, RValue<Int2> rhs)
4423         {
4424                 return lhs = lhs & rhs;
4425         }
4426
4427         RValue<Int2> operator|=(const Int2 &lhs, RValue<Int2> rhs)
4428         {
4429                 return lhs = lhs | rhs;
4430         }
4431
4432         RValue<Int2> operator^=(const Int2 &lhs, RValue<Int2> rhs)
4433         {
4434                 return lhs = lhs ^ rhs;
4435         }
4436
4437         RValue<Int2> operator<<=(const Int2 &lhs, unsigned char rhs)
4438         {
4439                 return lhs = lhs << rhs;
4440         }
4441
4442         RValue<Int2> operator>>=(const Int2 &lhs, unsigned char rhs)
4443         {
4444                 return lhs = lhs >> rhs;
4445         }
4446
4447         RValue<Int2> operator<<=(const Int2 &lhs, RValue<Long1> rhs)
4448         {
4449                 return lhs = lhs << rhs;
4450         }
4451
4452         RValue<Int2> operator>>=(const Int2 &lhs, RValue<Long1> rhs)
4453         {
4454                 return lhs = lhs >> rhs;
4455         }
4456
4457 //      RValue<Int2> operator+(RValue<Int2> val)
4458 //      {
4459 //              return val;
4460 //      }
4461
4462 //      RValue<Int2> operator-(RValue<Int2> val)
4463 //      {
4464 //              return RValue<Int2>(Nucleus::createNeg(val.value));
4465 //      }
4466
4467         RValue<Int2> operator~(RValue<Int2> val)
4468         {
4469                 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
4470         }
4471
4472         RValue<Long1> UnpackLow(RValue<Int2> x, RValue<Int2> y)
4473         {
4474                 assert(false && "UNIMPLEMENTED"); return RValue<Long1>(V(nullptr));
4475         }
4476
4477         RValue<Long1> UnpackHigh(RValue<Int2> x, RValue<Int2> y)
4478         {
4479                 assert(false && "UNIMPLEMENTED"); return RValue<Long1>(V(nullptr));
4480         }
4481
4482         RValue<Int> Extract(RValue<Int2> val, int i)
4483         {
4484                 assert(false && "UNIMPLEMENTED"); return RValue<Int>(V(nullptr));
4485         }
4486
4487         RValue<Int2> Insert(RValue<Int2> val, RValue<Int> element, int i)
4488         {
4489                 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
4490         }
4491
4492         Type *Int2::getType()
4493         {
4494                 assert(false && "UNIMPLEMENTED"); return nullptr;
4495         }
4496
4497         UInt2::UInt2()
4498         {
4499         //      xy.parent = this;
4500         }
4501
4502         UInt2::UInt2(unsigned int x, unsigned int y)
4503         {
4504         //      xy.parent = this;
4505
4506                 assert(false && "UNIMPLEMENTED");
4507         }
4508
4509         UInt2::UInt2(RValue<UInt2> rhs)
4510         {
4511         //      xy.parent = this;
4512
4513                 storeValue(rhs.value);
4514         }
4515
4516         UInt2::UInt2(const UInt2 &rhs)
4517         {
4518         //      xy.parent = this;
4519
4520                 Value *value = rhs.loadValue();
4521                 storeValue(value);
4522         }
4523
4524         UInt2::UInt2(const Reference<UInt2> &rhs)
4525         {
4526         //      xy.parent = this;
4527
4528                 Value *value = rhs.loadValue();
4529                 storeValue(value);
4530         }
4531
4532         RValue<UInt2> UInt2::operator=(RValue<UInt2> rhs) const
4533         {
4534                 storeValue(rhs.value);
4535
4536                 return rhs;
4537         }
4538
4539         RValue<UInt2> UInt2::operator=(const UInt2 &rhs) const
4540         {
4541                 Value *value = rhs.loadValue();
4542                 storeValue(value);
4543
4544                 return RValue<UInt2>(value);
4545         }
4546
4547         RValue<UInt2> UInt2::operator=(const Reference<UInt2> &rhs) const
4548         {
4549                 Value *value = rhs.loadValue();
4550                 storeValue(value);
4551
4552                 return RValue<UInt2>(value);
4553         }
4554
4555         RValue<UInt2> operator+(RValue<UInt2> lhs, RValue<UInt2> rhs)
4556         {
4557                 assert(false && "UNIMPLEMENTED"); return RValue<UInt2>(V(nullptr));
4558         }
4559
4560         RValue<UInt2> operator-(RValue<UInt2> lhs, RValue<UInt2> rhs)
4561         {
4562                 assert(false && "UNIMPLEMENTED"); return RValue<UInt2>(V(nullptr));
4563         }
4564
4565 //      RValue<UInt2> operator*(RValue<UInt2> lhs, RValue<UInt2> rhs)
4566 //      {
4567 //              return RValue<UInt2>(Nucleus::createMul(lhs.value, rhs.value));
4568 //      }
4569
4570 //      RValue<UInt2> operator/(RValue<UInt2> lhs, RValue<UInt2> rhs)
4571 //      {
4572 //              return RValue<UInt2>(Nucleus::createUDiv(lhs.value, rhs.value));
4573 //      }
4574
4575 //      RValue<UInt2> operator%(RValue<UInt2> lhs, RValue<UInt2> rhs)
4576 //      {
4577 //              return RValue<UInt2>(Nucleus::createURem(lhs.value, rhs.value));
4578 //      }
4579
4580         RValue<UInt2> operator&(RValue<UInt2> lhs, RValue<UInt2> rhs)
4581         {
4582                 assert(false && "UNIMPLEMENTED"); return RValue<UInt2>(V(nullptr));
4583         }
4584
4585         RValue<UInt2> operator|(RValue<UInt2> lhs, RValue<UInt2> rhs)
4586         {
4587                 assert(false && "UNIMPLEMENTED"); return RValue<UInt2>(V(nullptr));
4588         }
4589
4590         RValue<UInt2> operator^(RValue<UInt2> lhs, RValue<UInt2> rhs)
4591         {
4592                 assert(false && "UNIMPLEMENTED"); return RValue<UInt2>(V(nullptr));
4593         }
4594
4595         RValue<UInt2> operator<<(RValue<UInt2> lhs, unsigned char rhs)
4596         {
4597                 assert(false && "UNIMPLEMENTED"); return RValue<UInt2>(V(nullptr));
4598         }
4599
4600         RValue<UInt2> operator>>(RValue<UInt2> lhs, unsigned char rhs)
4601         {
4602                 assert(false && "UNIMPLEMENTED"); return RValue<UInt2>(V(nullptr));
4603         }
4604
4605         RValue<UInt2> operator<<(RValue<UInt2> lhs, RValue<Long1> rhs)
4606         {
4607                 assert(false && "UNIMPLEMENTED"); return RValue<UInt2>(V(nullptr));
4608         }
4609
4610         RValue<UInt2> operator>>(RValue<UInt2> lhs, RValue<Long1> rhs)
4611         {
4612                 assert(false && "UNIMPLEMENTED"); return RValue<UInt2>(V(nullptr));
4613         }
4614
4615         RValue<UInt2> operator+=(const UInt2 &lhs, RValue<UInt2> rhs)
4616         {
4617                 return lhs = lhs + rhs;
4618         }
4619
4620         RValue<UInt2> operator-=(const UInt2 &lhs, RValue<UInt2> rhs)
4621         {
4622                 return lhs = lhs - rhs;
4623         }
4624
4625 //      RValue<UInt2> operator*=(const UInt2 &lhs, RValue<UInt2> rhs)
4626 //      {
4627 //              return lhs = lhs * rhs;
4628 //      }
4629
4630 //      RValue<UInt2> operator/=(const UInt2 &lhs, RValue<UInt2> rhs)
4631 //      {
4632 //              return lhs = lhs / rhs;
4633 //      }
4634
4635 //      RValue<UInt2> operator%=(const UInt2 &lhs, RValue<UInt2> rhs)
4636 //      {
4637 //              return lhs = lhs % rhs;
4638 //      }
4639
4640         RValue<UInt2> operator&=(const UInt2 &lhs, RValue<UInt2> rhs)
4641         {
4642                 return lhs = lhs & rhs;
4643         }
4644
4645         RValue<UInt2> operator|=(const UInt2 &lhs, RValue<UInt2> rhs)
4646         {
4647                 return lhs = lhs | rhs;
4648         }
4649
4650         RValue<UInt2> operator^=(const UInt2 &lhs, RValue<UInt2> rhs)
4651         {
4652                 return lhs = lhs ^ rhs;
4653         }
4654
4655         RValue<UInt2> operator<<=(const UInt2 &lhs, unsigned char rhs)
4656         {
4657                 return lhs = lhs << rhs;
4658         }
4659
4660         RValue<UInt2> operator>>=(const UInt2 &lhs, unsigned char rhs)
4661         {
4662                 return lhs = lhs >> rhs;
4663         }
4664
4665         RValue<UInt2> operator<<=(const UInt2 &lhs, RValue<Long1> rhs)
4666         {
4667                 return lhs = lhs << rhs;
4668         }
4669
4670         RValue<UInt2> operator>>=(const UInt2 &lhs, RValue<Long1> rhs)
4671         {
4672                 return lhs = lhs >> rhs;
4673         }
4674
4675 //      RValue<UInt2> operator+(RValue<UInt2> val)
4676 //      {
4677 //              return val;
4678 //      }
4679
4680 //      RValue<UInt2> operator-(RValue<UInt2> val)
4681 //      {
4682 //              return RValue<UInt2>(Nucleus::createNeg(val.value));
4683 //      }
4684
4685         RValue<UInt2> operator~(RValue<UInt2> val)
4686         {
4687                 return RValue<UInt2>(Nucleus::createNot(val.value));
4688         }
4689
4690         Type *UInt2::getType()
4691         {
4692                 assert(false && "UNIMPLEMENTED"); return nullptr;
4693         }
4694
4695         Int4::Int4(RValue<Byte4> cast)
4696         {
4697                 assert(false && "UNIMPLEMENTED");
4698         }
4699
4700         Int4::Int4(RValue<SByte4> cast)
4701         {
4702                 assert(false && "UNIMPLEMENTED");
4703         }
4704
4705         Int4::Int4(RValue<Float4> cast)
4706         {
4707         //      xyzw.parent = this;
4708
4709                 Value *xyzw = Nucleus::createFPToSI(cast.value, Int4::getType());
4710
4711                 storeValue(xyzw);
4712         }
4713
4714         Int4::Int4(RValue<Short4> cast)
4715         {
4716                 assert(false && "UNIMPLEMENTED");
4717         }
4718
4719         Int4::Int4(RValue<UShort4> cast)
4720         {
4721                 assert(false && "UNIMPLEMENTED");
4722         }
4723
4724         Int4::Int4()
4725         {
4726         //      xyzw.parent = this;
4727         }
4728
4729         Int4::Int4(int xyzw)
4730         {
4731                 constant(xyzw, xyzw, xyzw, xyzw);
4732         }
4733
4734         Int4::Int4(int x, int yzw)
4735         {
4736                 constant(x, yzw, yzw, yzw);
4737         }
4738
4739         Int4::Int4(int x, int y, int zw)
4740         {
4741                 constant(x, y, zw, zw);
4742         }
4743
4744         Int4::Int4(int x, int y, int z, int w)
4745         {
4746                 constant(x, y, z, w);
4747         }
4748
4749         void Int4::constant(int x, int y, int z, int w)
4750         {
4751         //      xyzw.parent = this;
4752
4753                 int64_t constantVector[4] = {x, y, z, w};
4754                 storeValue(Nucleus::createConstantVector(constantVector, Int4::getType()));
4755         }
4756
4757         Int4::Int4(RValue<Int4> rhs)
4758         {
4759         //      xyzw.parent = this;
4760
4761                 storeValue(rhs.value);
4762         }
4763
4764         Int4::Int4(const Int4 &rhs)
4765         {
4766         //      xyzw.parent = this;
4767
4768                 Value *value = rhs.loadValue();
4769                 storeValue(value);
4770         }
4771
4772         Int4::Int4(const Reference<Int4> &rhs)
4773         {
4774         //      xyzw.parent = this;
4775
4776                 Value *value = rhs.loadValue();
4777                 storeValue(value);
4778         }
4779
4780         Int4::Int4(RValue<UInt4> rhs)
4781         {
4782         //      xyzw.parent = this;
4783
4784                 storeValue(rhs.value);
4785         }
4786
4787         Int4::Int4(const UInt4 &rhs)
4788         {
4789         //      xyzw.parent = this;
4790
4791                 Value *value = rhs.loadValue();
4792                 storeValue(value);
4793         }
4794
4795         Int4::Int4(const Reference<UInt4> &rhs)
4796         {
4797         //      xyzw.parent = this;
4798
4799                 Value *value = rhs.loadValue();
4800                 storeValue(value);
4801         }
4802
4803         Int4::Int4(RValue<Int2> lo, RValue<Int2> hi)
4804         {
4805                 assert(false && "UNIMPLEMENTED");
4806         }
4807
4808         Int4::Int4(RValue<Int> rhs)
4809         {
4810         //      xyzw.parent = this;
4811
4812                 assert(false && "UNIMPLEMENTED");
4813         }
4814
4815         Int4::Int4(const Int &rhs)
4816         {
4817         //      xyzw.parent = this;
4818
4819                 *this = RValue<Int>(rhs.loadValue());
4820         }
4821
4822         Int4::Int4(const Reference<Int> &rhs)
4823         {
4824         //      xyzw.parent = this;
4825
4826                 *this = RValue<Int>(rhs.loadValue());
4827         }
4828
4829         RValue<Int4> Int4::operator=(RValue<Int4> rhs) const
4830         {
4831                 storeValue(rhs.value);
4832
4833                 return rhs;
4834         }
4835
4836         RValue<Int4> Int4::operator=(const Int4 &rhs) const
4837         {
4838                 Value *value = rhs.loadValue();
4839                 storeValue(value);
4840
4841                 return RValue<Int4>(value);
4842         }
4843
4844         RValue<Int4> Int4::operator=(const Reference<Int4> &rhs) const
4845         {
4846                 Value *value = rhs.loadValue();
4847                 storeValue(value);
4848
4849                 return RValue<Int4>(value);
4850         }
4851
4852         RValue<Int4> operator+(RValue<Int4> lhs, RValue<Int4> rhs)
4853         {
4854                 return RValue<Int4>(Nucleus::createAdd(lhs.value, rhs.value));
4855         }
4856
4857         RValue<Int4> operator-(RValue<Int4> lhs, RValue<Int4> rhs)
4858         {
4859                 return RValue<Int4>(Nucleus::createSub(lhs.value, rhs.value));
4860         }
4861
4862         RValue<Int4> operator*(RValue<Int4> lhs, RValue<Int4> rhs)
4863         {
4864                 return RValue<Int4>(Nucleus::createMul(lhs.value, rhs.value));
4865         }
4866
4867         RValue<Int4> operator/(RValue<Int4> lhs, RValue<Int4> rhs)
4868         {
4869                 return RValue<Int4>(Nucleus::createSDiv(lhs.value, rhs.value));
4870         }
4871
4872         RValue<Int4> operator%(RValue<Int4> lhs, RValue<Int4> rhs)
4873         {
4874                 return RValue<Int4>(Nucleus::createSRem(lhs.value, rhs.value));
4875         }
4876
4877         RValue<Int4> operator&(RValue<Int4> lhs, RValue<Int4> rhs)
4878         {
4879                 return RValue<Int4>(Nucleus::createAnd(lhs.value, rhs.value));
4880         }
4881
4882         RValue<Int4> operator|(RValue<Int4> lhs, RValue<Int4> rhs)
4883         {
4884                 return RValue<Int4>(Nucleus::createOr(lhs.value, rhs.value));
4885         }
4886
4887         RValue<Int4> operator^(RValue<Int4> lhs, RValue<Int4> rhs)
4888         {
4889                 return RValue<Int4>(Nucleus::createXor(lhs.value, rhs.value));
4890         }
4891
4892         RValue<Int4> operator<<(RValue<Int4> lhs, unsigned char rhs)
4893         {
4894                 assert(false && "UNIMPLEMENTED"); return RValue<Int4>(V(nullptr));
4895         }
4896
4897         RValue<Int4> operator>>(RValue<Int4> lhs, unsigned char rhs)
4898         {
4899                 assert(false && "UNIMPLEMENTED"); return RValue<Int4>(V(nullptr));
4900         }
4901
4902         RValue<Int4> operator<<(RValue<Int4> lhs, RValue<Int4> rhs)
4903         {
4904                 return RValue<Int4>(Nucleus::createShl(lhs.value, rhs.value));
4905         }
4906
4907         RValue<Int4> operator>>(RValue<Int4> lhs, RValue<Int4> rhs)
4908         {
4909                 return RValue<Int4>(Nucleus::createAShr(lhs.value, rhs.value));
4910         }
4911
4912         RValue<Int4> operator+=(const Int4 &lhs, RValue<Int4> rhs)
4913         {
4914                 return lhs = lhs + rhs;
4915         }
4916
4917         RValue<Int4> operator-=(const Int4 &lhs, RValue<Int4> rhs)
4918         {
4919                 return lhs = lhs - rhs;
4920         }
4921
4922         RValue<Int4> operator*=(const Int4 &lhs, RValue<Int4> rhs)
4923         {
4924                 return lhs = lhs * rhs;
4925         }
4926
4927 //      RValue<Int4> operator/=(const Int4 &lhs, RValue<Int4> rhs)
4928 //      {
4929 //              return lhs = lhs / rhs;
4930 //      }
4931
4932 //      RValue<Int4> operator%=(const Int4 &lhs, RValue<Int4> rhs)
4933 //      {
4934 //              return lhs = lhs % rhs;
4935 //      }
4936
4937         RValue<Int4> operator&=(const Int4 &lhs, RValue<Int4> rhs)
4938         {
4939                 return lhs = lhs & rhs;
4940         }
4941
4942         RValue<Int4> operator|=(const Int4 &lhs, RValue<Int4> rhs)
4943         {
4944                 return lhs = lhs | rhs;
4945         }
4946
4947         RValue<Int4> operator^=(const Int4 &lhs, RValue<Int4> rhs)
4948         {
4949                 return lhs = lhs ^ rhs;
4950         }
4951
4952         RValue<Int4> operator<<=(const Int4 &lhs, unsigned char rhs)
4953         {
4954                 return lhs = lhs << rhs;
4955         }
4956
4957         RValue<Int4> operator>>=(const Int4 &lhs, unsigned char rhs)
4958         {
4959                 return lhs = lhs >> rhs;
4960         }
4961
4962         RValue<Int4> operator+(RValue<Int4> val)
4963         {
4964                 return val;
4965         }
4966
4967         RValue<Int4> operator-(RValue<Int4> val)
4968         {
4969                 return RValue<Int4>(Nucleus::createNeg(val.value));
4970         }
4971
4972         RValue<Int4> operator~(RValue<Int4> val)
4973         {
4974                 return RValue<Int4>(Nucleus::createNot(val.value));
4975         }
4976
4977         RValue<Int4> CmpEQ(RValue<Int4> x, RValue<Int4> y)
4978         {
4979                 return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpEQ(x.value, y.value), Int4::getType()));
4980         }
4981
4982         RValue<Int4> CmpLT(RValue<Int4> x, RValue<Int4> y)
4983         {
4984                 return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSLT(x.value, y.value), Int4::getType()));
4985         }
4986
4987         RValue<Int4> CmpLE(RValue<Int4> x, RValue<Int4> y)
4988         {
4989                 return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSLE(x.value, y.value), Int4::getType()));
4990         }
4991
4992         RValue<Int4> CmpNEQ(RValue<Int4> x, RValue<Int4> y)
4993         {
4994                 return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpNE(x.value, y.value), Int4::getType()));
4995         }
4996
4997         RValue<Int4> CmpNLT(RValue<Int4> x, RValue<Int4> y)
4998         {
4999                 return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSGE(x.value, y.value), Int4::getType()));
5000         }
5001
5002         RValue<Int4> CmpNLE(RValue<Int4> x, RValue<Int4> y)
5003         {
5004                 return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSGT(x.value, y.value), Int4::getType()));
5005         }
5006
5007         RValue<Int4> Max(RValue<Int4> x, RValue<Int4> y)
5008         {
5009                 assert(false && "UNIMPLEMENTED"); return RValue<Int4>(V(nullptr));
5010         }
5011
5012         RValue<Int4> Min(RValue<Int4> x, RValue<Int4> y)
5013         {
5014                 assert(false && "UNIMPLEMENTED"); return RValue<Int4>(V(nullptr));
5015         }
5016
5017         RValue<Int4> RoundInt(RValue<Float4> cast)
5018         {
5019                 assert(false && "UNIMPLEMENTED"); return RValue<Int4>(V(nullptr));
5020         }
5021
5022         RValue<Short8> Pack(RValue<Int4> x, RValue<Int4> y)
5023         {
5024                 assert(false && "UNIMPLEMENTED"); return RValue<Short8>(V(nullptr));
5025         }
5026
5027         RValue<Int> Extract(RValue<Int4> x, int i)
5028         {
5029                 return RValue<Int>(Nucleus::createExtractElement(x.value, Int::getType(), i));
5030         }
5031
5032         RValue<Int4> Insert(RValue<Int4> x, RValue<Int> element, int i)
5033         {
5034                 return RValue<Int4>(Nucleus::createInsertElement(x.value, element.value, i));
5035         }
5036
5037         RValue<Int> SignMask(RValue<Int4> x)
5038         {
5039                 assert(false && "UNIMPLEMENTED"); return RValue<Int>(V(nullptr));
5040         }
5041
5042         RValue<Int4> Swizzle(RValue<Int4> x, unsigned char select)
5043         {
5044                 return RValue<Int4>(createSwizzle4(x.value, select));
5045         }
5046
5047         Type *Int4::getType()
5048         {
5049                 return T(Ice::IceType_v4i32);
5050         }
5051
5052         UInt4::UInt4(RValue<Float4> cast)
5053         {
5054         //      xyzw.parent = this;
5055
5056                 assert(false && "UNIMPLEMENTED");
5057         }
5058
5059         UInt4::UInt4()
5060         {
5061         //      xyzw.parent = this;
5062         }
5063
5064         UInt4::UInt4(int xyzw)
5065         {
5066                 constant(xyzw, xyzw, xyzw, xyzw);
5067         }
5068
5069         UInt4::UInt4(int x, int yzw)
5070         {
5071                 constant(x, yzw, yzw, yzw);
5072         }
5073
5074         UInt4::UInt4(int x, int y, int zw)
5075         {
5076                 constant(x, y, zw, zw);
5077         }
5078
5079         UInt4::UInt4(int x, int y, int z, int w)
5080         {
5081                 constant(x, y, z, w);
5082         }
5083
5084         void UInt4::constant(int x, int y, int z, int w)
5085         {
5086         //      xyzw.parent = this;
5087
5088                 int64_t constantVector[4] = {x, y, z, w};
5089                 storeValue(Nucleus::createConstantVector(constantVector, UInt4::getType()));
5090         }
5091
5092         UInt4::UInt4(RValue<UInt4> rhs)
5093         {
5094         //      xyzw.parent = this;
5095
5096                 storeValue(rhs.value);
5097         }
5098
5099         UInt4::UInt4(const UInt4 &rhs)
5100         {
5101         //      xyzw.parent = this;
5102
5103                 Value *value = rhs.loadValue();
5104                 storeValue(value);
5105         }
5106
5107         UInt4::UInt4(const Reference<UInt4> &rhs)
5108         {
5109         //      xyzw.parent = this;
5110
5111                 Value *value = rhs.loadValue();
5112                 storeValue(value);
5113         }
5114
5115         UInt4::UInt4(RValue<Int4> rhs)
5116         {
5117         //      xyzw.parent = this;
5118
5119                 storeValue(rhs.value);
5120         }
5121
5122         UInt4::UInt4(const Int4 &rhs)
5123         {
5124         //      xyzw.parent = this;
5125
5126                 Value *value = rhs.loadValue();
5127                 storeValue(value);
5128         }
5129
5130         UInt4::UInt4(const Reference<Int4> &rhs)
5131         {
5132         //      xyzw.parent = this;
5133
5134                 Value *value = rhs.loadValue();
5135                 storeValue(value);
5136         }
5137
5138         UInt4::UInt4(RValue<UInt2> lo, RValue<UInt2> hi)
5139         {
5140                 assert(false && "UNIMPLEMENTED");
5141         }
5142
5143         RValue<UInt4> UInt4::operator=(RValue<UInt4> rhs) const
5144         {
5145                 storeValue(rhs.value);
5146
5147                 return rhs;
5148         }
5149
5150         RValue<UInt4> UInt4::operator=(const UInt4 &rhs) const
5151         {
5152                 Value *value = rhs.loadValue();
5153                 storeValue(value);
5154
5155                 return RValue<UInt4>(value);
5156         }
5157
5158         RValue<UInt4> UInt4::operator=(const Reference<UInt4> &rhs) const
5159         {
5160                 Value *value = rhs.loadValue();
5161                 storeValue(value);
5162
5163                 return RValue<UInt4>(value);
5164         }
5165
5166         RValue<UInt4> operator+(RValue<UInt4> lhs, RValue<UInt4> rhs)
5167         {
5168                 return RValue<UInt4>(Nucleus::createAdd(lhs.value, rhs.value));
5169         }
5170
5171         RValue<UInt4> operator-(RValue<UInt4> lhs, RValue<UInt4> rhs)
5172         {
5173                 return RValue<UInt4>(Nucleus::createSub(lhs.value, rhs.value));
5174         }
5175
5176         RValue<UInt4> operator*(RValue<UInt4> lhs, RValue<UInt4> rhs)
5177         {
5178                 return RValue<UInt4>(Nucleus::createMul(lhs.value, rhs.value));
5179         }
5180
5181         RValue<UInt4> operator/(RValue<UInt4> lhs, RValue<UInt4> rhs)
5182         {
5183                 return RValue<UInt4>(Nucleus::createUDiv(lhs.value, rhs.value));
5184         }
5185
5186         RValue<UInt4> operator%(RValue<UInt4> lhs, RValue<UInt4> rhs)
5187         {
5188                 return RValue<UInt4>(Nucleus::createURem(lhs.value, rhs.value));
5189         }
5190
5191         RValue<UInt4> operator&(RValue<UInt4> lhs, RValue<UInt4> rhs)
5192         {
5193                 return RValue<UInt4>(Nucleus::createAnd(lhs.value, rhs.value));
5194         }
5195
5196         RValue<UInt4> operator|(RValue<UInt4> lhs, RValue<UInt4> rhs)
5197         {
5198                 return RValue<UInt4>(Nucleus::createOr(lhs.value, rhs.value));
5199         }
5200
5201         RValue<UInt4> operator^(RValue<UInt4> lhs, RValue<UInt4> rhs)
5202         {
5203                 return RValue<UInt4>(Nucleus::createXor(lhs.value, rhs.value));
5204         }
5205
5206         RValue<UInt4> operator<<(RValue<UInt4> lhs, unsigned char rhs)
5207         {
5208                 assert(false && "UNIMPLEMENTED"); return RValue<UInt4>(V(nullptr));
5209         }
5210
5211         RValue<UInt4> operator>>(RValue<UInt4> lhs, unsigned char rhs)
5212         {
5213                 assert(false && "UNIMPLEMENTED"); return RValue<UInt4>(V(nullptr));
5214         }
5215
5216         RValue<UInt4> operator<<(RValue<UInt4> lhs, RValue<UInt4> rhs)
5217         {
5218                 return RValue<UInt4>(Nucleus::createShl(lhs.value, rhs.value));
5219         }
5220
5221         RValue<UInt4> operator>>(RValue<UInt4> lhs, RValue<UInt4> rhs)
5222         {
5223                 return RValue<UInt4>(Nucleus::createLShr(lhs.value, rhs.value));
5224         }
5225
5226         RValue<UInt4> operator+=(const UInt4 &lhs, RValue<UInt4> rhs)
5227         {
5228                 return lhs = lhs + rhs;
5229         }
5230
5231         RValue<UInt4> operator-=(const UInt4 &lhs, RValue<UInt4> rhs)
5232         {
5233                 return lhs = lhs - rhs;
5234         }
5235
5236         RValue<UInt4> operator*=(const UInt4 &lhs, RValue<UInt4> rhs)
5237         {
5238                 return lhs = lhs * rhs;
5239         }
5240
5241 //      RValue<UInt4> operator/=(const UInt4 &lhs, RValue<UInt4> rhs)
5242 //      {
5243 //              return lhs = lhs / rhs;
5244 //      }
5245
5246 //      RValue<UInt4> operator%=(const UInt4 &lhs, RValue<UInt4> rhs)
5247 //      {
5248 //              return lhs = lhs % rhs;
5249 //      }
5250
5251         RValue<UInt4> operator&=(const UInt4 &lhs, RValue<UInt4> rhs)
5252         {
5253                 return lhs = lhs & rhs;
5254         }
5255
5256         RValue<UInt4> operator|=(const UInt4 &lhs, RValue<UInt4> rhs)
5257         {
5258                 return lhs = lhs | rhs;
5259         }
5260
5261         RValue<UInt4> operator^=(const UInt4 &lhs, RValue<UInt4> rhs)
5262         {
5263                 return lhs = lhs ^ rhs;
5264         }
5265
5266         RValue<UInt4> operator<<=(const UInt4 &lhs, unsigned char rhs)
5267         {
5268                 return lhs = lhs << rhs;
5269         }
5270
5271         RValue<UInt4> operator>>=(const UInt4 &lhs, unsigned char rhs)
5272         {
5273                 return lhs = lhs >> rhs;
5274         }
5275
5276         RValue<UInt4> operator+(RValue<UInt4> val)
5277         {
5278                 return val;
5279         }
5280
5281         RValue<UInt4> operator-(RValue<UInt4> val)
5282         {
5283                 return RValue<UInt4>(Nucleus::createNeg(val.value));
5284         }
5285
5286         RValue<UInt4> operator~(RValue<UInt4> val)
5287         {
5288                 return RValue<UInt4>(Nucleus::createNot(val.value));
5289         }
5290
5291         RValue<UInt4> CmpEQ(RValue<UInt4> x, RValue<UInt4> y)
5292         {
5293                 return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpEQ(x.value, y.value), Int4::getType()));
5294         }
5295
5296         RValue<UInt4> CmpLT(RValue<UInt4> x, RValue<UInt4> y)
5297         {
5298                 return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpULT(x.value, y.value), Int4::getType()));
5299         }
5300
5301         RValue<UInt4> CmpLE(RValue<UInt4> x, RValue<UInt4> y)
5302         {
5303                 return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpULE(x.value, y.value), Int4::getType()));
5304         }
5305
5306         RValue<UInt4> CmpNEQ(RValue<UInt4> x, RValue<UInt4> y)
5307         {
5308                 return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpNE(x.value, y.value), Int4::getType()));
5309         }
5310
5311         RValue<UInt4> CmpNLT(RValue<UInt4> x, RValue<UInt4> y)
5312         {
5313                 return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpUGE(x.value, y.value), Int4::getType()));
5314         }
5315
5316         RValue<UInt4> CmpNLE(RValue<UInt4> x, RValue<UInt4> y)
5317         {
5318                 return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpUGT(x.value, y.value), Int4::getType()));
5319         }
5320
5321         RValue<UInt4> Max(RValue<UInt4> x, RValue<UInt4> y)
5322         {
5323                 assert(false && "UNIMPLEMENTED"); return RValue<UInt4>(V(nullptr));
5324         }
5325
5326         RValue<UInt4> Min(RValue<UInt4> x, RValue<UInt4> y)
5327         {
5328                 assert(false && "UNIMPLEMENTED"); return RValue<UInt4>(V(nullptr));
5329         }
5330
5331         RValue<UShort8> Pack(RValue<UInt4> x, RValue<UInt4> y)
5332         {
5333                 assert(false && "UNIMPLEMENTED"); return RValue<UShort8>(V(nullptr));
5334         }
5335
5336         Type *UInt4::getType()
5337         {
5338                 assert(false && "UNIMPLEMENTED"); return nullptr;
5339         }
5340
5341         Float::Float(RValue<Int> cast)
5342         {
5343                 Value *integer = Nucleus::createSIToFP(cast.value, Float::getType());
5344
5345                 storeValue(integer);
5346         }
5347
5348         Float::Float()
5349         {
5350         }
5351
5352         Float::Float(float x)
5353         {
5354                 storeValue(Nucleus::createConstantFloat(x));
5355         }
5356
5357         Float::Float(RValue<Float> rhs)
5358         {
5359                 storeValue(rhs.value);
5360         }
5361
5362         Float::Float(const Float &rhs)
5363         {
5364                 Value *value = rhs.loadValue();
5365                 storeValue(value);
5366         }
5367
5368         Float::Float(const Reference<Float> &rhs)
5369         {
5370                 Value *value = rhs.loadValue();
5371                 storeValue(value);
5372         }
5373
5374         RValue<Float> Float::operator=(RValue<Float> rhs) const
5375         {
5376                 storeValue(rhs.value);
5377
5378                 return rhs;
5379         }
5380
5381         RValue<Float> Float::operator=(const Float &rhs) const
5382         {
5383                 Value *value = rhs.loadValue();
5384                 storeValue(value);
5385
5386                 return RValue<Float>(value);
5387         }
5388
5389         RValue<Float> Float::operator=(const Reference<Float> &rhs) const
5390         {
5391                 Value *value = rhs.loadValue();
5392                 storeValue(value);
5393
5394                 return RValue<Float>(value);
5395         }
5396
5397         RValue<Float> operator+(RValue<Float> lhs, RValue<Float> rhs)
5398         {
5399                 return RValue<Float>(Nucleus::createFAdd(lhs.value, rhs.value));
5400         }
5401
5402         RValue<Float> operator-(RValue<Float> lhs, RValue<Float> rhs)
5403         {
5404                 return RValue<Float>(Nucleus::createFSub(lhs.value, rhs.value));
5405         }
5406
5407         RValue<Float> operator*(RValue<Float> lhs, RValue<Float> rhs)
5408         {
5409                 return RValue<Float>(Nucleus::createFMul(lhs.value, rhs.value));
5410         }
5411
5412         RValue<Float> operator/(RValue<Float> lhs, RValue<Float> rhs)
5413         {
5414                 return RValue<Float>(Nucleus::createFDiv(lhs.value, rhs.value));
5415         }
5416
5417         RValue<Float> operator+=(const Float &lhs, RValue<Float> rhs)
5418         {
5419                 return lhs = lhs + rhs;
5420         }
5421
5422         RValue<Float> operator-=(const Float &lhs, RValue<Float> rhs)
5423         {
5424                 return lhs = lhs - rhs;
5425         }
5426
5427         RValue<Float> operator*=(const Float &lhs, RValue<Float> rhs)
5428         {
5429                 return lhs = lhs * rhs;
5430         }
5431
5432         RValue<Float> operator/=(const Float &lhs, RValue<Float> rhs)
5433         {
5434                 return lhs = lhs / rhs;
5435         }
5436
5437         RValue<Float> operator+(RValue<Float> val)
5438         {
5439                 return val;
5440         }
5441
5442         RValue<Float> operator-(RValue<Float> val)
5443         {
5444                 return RValue<Float>(Nucleus::createFNeg(val.value));
5445         }
5446
5447         RValue<Bool> operator<(RValue<Float> lhs, RValue<Float> rhs)
5448         {
5449                 return RValue<Bool>(Nucleus::createFCmpOLT(lhs.value, rhs.value));
5450         }
5451
5452         RValue<Bool> operator<=(RValue<Float> lhs, RValue<Float> rhs)
5453         {
5454                 return RValue<Bool>(Nucleus::createFCmpOLE(lhs.value, rhs.value));
5455         }
5456
5457         RValue<Bool> operator>(RValue<Float> lhs, RValue<Float> rhs)
5458         {
5459                 return RValue<Bool>(Nucleus::createFCmpOGT(lhs.value, rhs.value));
5460         }
5461
5462         RValue<Bool> operator>=(RValue<Float> lhs, RValue<Float> rhs)
5463         {
5464                 return RValue<Bool>(Nucleus::createFCmpOGE(lhs.value, rhs.value));
5465         }
5466
5467         RValue<Bool> operator!=(RValue<Float> lhs, RValue<Float> rhs)
5468         {
5469                 return RValue<Bool>(Nucleus::createFCmpONE(lhs.value, rhs.value));
5470         }
5471
5472         RValue<Bool> operator==(RValue<Float> lhs, RValue<Float> rhs)
5473         {
5474                 return RValue<Bool>(Nucleus::createFCmpOEQ(lhs.value, rhs.value));
5475         }
5476
5477         RValue<Float> Abs(RValue<Float> x)
5478         {
5479                 return IfThenElse(x > 0.0f, x, -x);
5480         }
5481
5482         RValue<Float> Max(RValue<Float> x, RValue<Float> y)
5483         {
5484                 return IfThenElse(x > y, x, y);
5485         }
5486
5487         RValue<Float> Min(RValue<Float> x, RValue<Float> y)
5488         {
5489                 return IfThenElse(x < y, x, y);
5490         }
5491
5492         RValue<Float> Rcp_pp(RValue<Float> x, bool exactAtPow2)
5493         {
5494                 assert(false && "UNIMPLEMENTED"); return RValue<Float>(V(nullptr));
5495         }
5496
5497         RValue<Float> RcpSqrt_pp(RValue<Float> x)
5498         {
5499                 assert(false && "UNIMPLEMENTED"); return RValue<Float>(V(nullptr));
5500         }
5501
5502         RValue<Float> Sqrt(RValue<Float> x)
5503         {
5504                 assert(false && "UNIMPLEMENTED"); return RValue<Float>(V(nullptr));
5505         }
5506
5507         RValue<Float> Round(RValue<Float> x)
5508         {
5509                 assert(false && "UNIMPLEMENTED"); return RValue<Float>(V(nullptr));
5510         }
5511
5512         RValue<Float> Trunc(RValue<Float> x)
5513         {
5514                 assert(false && "UNIMPLEMENTED"); return RValue<Float>(V(nullptr));
5515         }
5516
5517         RValue<Float> Frac(RValue<Float> x)
5518         {
5519                 assert(false && "UNIMPLEMENTED"); return RValue<Float>(V(nullptr));
5520         }
5521
5522         RValue<Float> Floor(RValue<Float> x)
5523         {
5524                 assert(false && "UNIMPLEMENTED"); return RValue<Float>(V(nullptr));
5525         }
5526
5527         RValue<Float> Ceil(RValue<Float> x)
5528         {
5529                 assert(false && "UNIMPLEMENTED"); return RValue<Float>(V(nullptr));
5530         }
5531
5532         Type *Float::getType()
5533         {
5534                 return T(Ice::IceType_f32);
5535         }
5536
5537         Float2::Float2(RValue<Float4> cast)
5538         {
5539         //      xyzw.parent = this;
5540
5541                 Value *int64x2 = Nucleus::createBitCast(cast.value, Long2::getType());
5542                 Value *int64 = Nucleus::createExtractElement(int64x2, Long::getType(), 0);
5543                 Value *float2 = Nucleus::createBitCast(int64, Float2::getType());
5544
5545                 storeValue(float2);
5546         }
5547
5548         Type *Float2::getType()
5549         {
5550                 assert(false && "UNIMPLEMENTED"); return nullptr;
5551         }
5552
5553         Float4::Float4(RValue<Byte4> cast)
5554         {
5555                 xyzw.parent = this;
5556
5557                 assert(false && "UNIMPLEMENTED");
5558         }
5559
5560         Float4::Float4(RValue<SByte4> cast)
5561         {
5562                 xyzw.parent = this;
5563
5564                 assert(false && "UNIMPLEMENTED");
5565         }
5566
5567         Float4::Float4(RValue<Short4> cast)
5568         {
5569                 xyzw.parent = this;
5570
5571                 Int4 c(cast);
5572                 storeValue(Nucleus::createSIToFP(RValue<Int4>(c).value, Float4::getType()));
5573         }
5574
5575         Float4::Float4(RValue<UShort4> cast)
5576         {
5577                 xyzw.parent = this;
5578
5579                 Int4 c(cast);
5580                 storeValue(Nucleus::createSIToFP(RValue<Int4>(c).value, Float4::getType()));
5581         }
5582
5583         Float4::Float4(RValue<Int4> cast)
5584         {
5585                 xyzw.parent = this;
5586
5587                 Value *xyzw = Nucleus::createSIToFP(cast.value, Float4::getType());
5588
5589                 storeValue(xyzw);
5590         }
5591
5592         Float4::Float4(RValue<UInt4> cast)
5593         {
5594                 xyzw.parent = this;
5595
5596                 Value *xyzw = Nucleus::createUIToFP(cast.value, Float4::getType());
5597
5598                 storeValue(xyzw);
5599         }
5600
5601         Float4::Float4()
5602         {
5603                 xyzw.parent = this;
5604         }
5605
5606         Float4::Float4(float xyzw)
5607         {
5608                 constant(xyzw, xyzw, xyzw, xyzw);
5609         }
5610
5611         Float4::Float4(float x, float yzw)
5612         {
5613                 constant(x, yzw, yzw, yzw);
5614         }
5615
5616         Float4::Float4(float x, float y, float zw)
5617         {
5618                 constant(x, y, zw, zw);
5619         }
5620
5621         Float4::Float4(float x, float y, float z, float w)
5622         {
5623                 constant(x, y, z, w);
5624         }
5625
5626         void Float4::constant(float x, float y, float z, float w)
5627         {
5628                 xyzw.parent = this;
5629
5630                 double constantVector[4] = {x, y, z, w};
5631                 storeValue(Nucleus::createConstantVector(constantVector, Float4::getType()));
5632         }
5633
5634         Float4::Float4(RValue<Float4> rhs)
5635         {
5636                 xyzw.parent = this;
5637
5638                 storeValue(rhs.value);
5639         }
5640
5641         Float4::Float4(const Float4 &rhs)
5642         {
5643                 xyzw.parent = this;
5644
5645                 Value *value = rhs.loadValue();
5646                 storeValue(value);
5647         }
5648
5649         Float4::Float4(const Reference<Float4> &rhs)
5650         {
5651                 xyzw.parent = this;
5652
5653                 Value *value = rhs.loadValue();
5654                 storeValue(value);
5655         }
5656
5657         Float4::Float4(RValue<Float> rhs)
5658         {
5659                 xyzw.parent = this;
5660
5661                 assert(false && "UNIMPLEMENTED");
5662         }
5663
5664         Float4::Float4(const Float &rhs)
5665         {
5666                 xyzw.parent = this;
5667
5668                 *this = RValue<Float>(rhs.loadValue());
5669         }
5670
5671         Float4::Float4(const Reference<Float> &rhs)
5672         {
5673                 xyzw.parent = this;
5674
5675                 *this = RValue<Float>(rhs.loadValue());
5676         }
5677
5678         RValue<Float4> Float4::operator=(float x) const
5679         {
5680                 return *this = Float4(x, x, x, x);
5681         }
5682
5683         RValue<Float4> Float4::operator=(RValue<Float4> rhs) const
5684         {
5685                 storeValue(rhs.value);
5686
5687                 return rhs;
5688         }
5689
5690         RValue<Float4> Float4::operator=(const Float4 &rhs) const
5691         {
5692                 Value *value = rhs.loadValue();
5693                 storeValue(value);
5694
5695                 return RValue<Float4>(value);
5696         }
5697
5698         RValue<Float4> Float4::operator=(const Reference<Float4> &rhs) const
5699         {
5700                 Value *value = rhs.loadValue();
5701                 storeValue(value);
5702
5703                 return RValue<Float4>(value);
5704         }
5705
5706         RValue<Float4> Float4::operator=(RValue<Float> rhs) const
5707         {
5708                 return *this = Float4(rhs);
5709         }
5710
5711         RValue<Float4> Float4::operator=(const Float &rhs) const
5712         {
5713                 return *this = Float4(rhs);
5714         }
5715
5716         RValue<Float4> Float4::operator=(const Reference<Float> &rhs) const
5717         {
5718                 return *this = Float4(rhs);
5719         }
5720
5721         RValue<Float4> operator+(RValue<Float4> lhs, RValue<Float4> rhs)
5722         {
5723                 return RValue<Float4>(Nucleus::createFAdd(lhs.value, rhs.value));
5724         }
5725
5726         RValue<Float4> operator-(RValue<Float4> lhs, RValue<Float4> rhs)
5727         {
5728                 return RValue<Float4>(Nucleus::createFSub(lhs.value, rhs.value));
5729         }
5730
5731         RValue<Float4> operator*(RValue<Float4> lhs, RValue<Float4> rhs)
5732         {
5733                 return RValue<Float4>(Nucleus::createFMul(lhs.value, rhs.value));
5734         }
5735
5736         RValue<Float4> operator/(RValue<Float4> lhs, RValue<Float4> rhs)
5737         {
5738                 return RValue<Float4>(Nucleus::createFDiv(lhs.value, rhs.value));
5739         }
5740
5741         RValue<Float4> operator%(RValue<Float4> lhs, RValue<Float4> rhs)
5742         {
5743                 return RValue<Float4>(Nucleus::createFRem(lhs.value, rhs.value));
5744         }
5745
5746         RValue<Float4> operator+=(const Float4 &lhs, RValue<Float4> rhs)
5747         {
5748                 return lhs = lhs + rhs;
5749         }
5750
5751         RValue<Float4> operator-=(const Float4 &lhs, RValue<Float4> rhs)
5752         {
5753                 return lhs = lhs - rhs;
5754         }
5755
5756         RValue<Float4> operator*=(const Float4 &lhs, RValue<Float4> rhs)
5757         {
5758                 return lhs = lhs * rhs;
5759         }
5760
5761         RValue<Float4> operator/=(const Float4 &lhs, RValue<Float4> rhs)
5762         {
5763                 return lhs = lhs / rhs;
5764         }
5765
5766         RValue<Float4> operator%=(const Float4 &lhs, RValue<Float4> rhs)
5767         {
5768                 return lhs = lhs % rhs;
5769         }
5770
5771         RValue<Float4> operator+(RValue<Float4> val)
5772         {
5773                 return val;
5774         }
5775
5776         RValue<Float4> operator-(RValue<Float4> val)
5777         {
5778                 return RValue<Float4>(Nucleus::createFNeg(val.value));
5779         }
5780
5781         RValue<Float4> Abs(RValue<Float4> x)
5782         {
5783                 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
5784         }
5785
5786         RValue<Float4> Max(RValue<Float4> x, RValue<Float4> y)
5787         {
5788                 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
5789         }
5790
5791         RValue<Float4> Min(RValue<Float4> x, RValue<Float4> y)
5792         {
5793                 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
5794         }
5795
5796         RValue<Float4> Rcp_pp(RValue<Float4> x, bool exactAtPow2)
5797         {
5798                 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
5799         }
5800
5801         RValue<Float4> RcpSqrt_pp(RValue<Float4> x)
5802         {
5803                 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
5804         }
5805
5806         RValue<Float4> Sqrt(RValue<Float4> x)
5807         {
5808                 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
5809         }
5810
5811         RValue<Float4> Insert(const Float4 &val, RValue<Float> element, int i)
5812         {
5813                 Value *value = val.loadValue();
5814                 Value *insert = Nucleus::createInsertElement(value, element.value, i);
5815
5816                 val = RValue<Float4>(insert);
5817
5818                 return val;
5819         }
5820
5821         RValue<Float> Extract(RValue<Float4> x, int i)
5822         {
5823                 return RValue<Float>(Nucleus::createExtractElement(x.value, Float::getType(), i));
5824         }
5825
5826         RValue<Float4> Swizzle(RValue<Float4> x, unsigned char select)
5827         {
5828                 return RValue<Float4>(createSwizzle4(x.value, select));
5829         }
5830
5831         RValue<Float4> ShuffleLowHigh(RValue<Float4> x, RValue<Float4> y, unsigned char imm)
5832         {
5833                 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
5834         }
5835
5836         RValue<Float4> UnpackLow(RValue<Float4> x, RValue<Float4> y)
5837         {
5838                 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
5839         }
5840
5841         RValue<Float4> UnpackHigh(RValue<Float4> x, RValue<Float4> y)
5842         {
5843                 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
5844         }
5845
5846         RValue<Float4> Mask(Float4 &lhs, RValue<Float4> rhs, unsigned char select)
5847         {
5848                 Value *vector = lhs.loadValue();
5849                 Value *shuffle = createMask4(vector, rhs.value, select);
5850                 lhs.storeValue(shuffle);
5851
5852                 return RValue<Float4>(shuffle);
5853         }
5854
5855         RValue<Int> SignMask(RValue<Float4> x)
5856         {
5857                 assert(false && "UNIMPLEMENTED"); return RValue<Int>(V(nullptr));
5858         }
5859
5860         RValue<Int4> CmpEQ(RValue<Float4> x, RValue<Float4> y)
5861         {
5862                 return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOEQ(x.value, y.value), Int4::getType()));
5863         }
5864
5865         RValue<Int4> CmpLT(RValue<Float4> x, RValue<Float4> y)
5866         {
5867                 return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOLT(x.value, y.value), Int4::getType()));
5868         }
5869
5870         RValue<Int4> CmpLE(RValue<Float4> x, RValue<Float4> y)
5871         {
5872                 return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOLE(x.value, y.value), Int4::getType()));
5873         }
5874
5875         RValue<Int4> CmpNEQ(RValue<Float4> x, RValue<Float4> y)
5876         {
5877                 return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpONE(x.value, y.value), Int4::getType()));
5878         }
5879
5880         RValue<Int4> CmpNLT(RValue<Float4> x, RValue<Float4> y)
5881         {
5882                 return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOGE(x.value, y.value), Int4::getType()));
5883         }
5884
5885         RValue<Int4> CmpNLE(RValue<Float4> x, RValue<Float4> y)
5886         {
5887                 return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOGT(x.value, y.value), Int4::getType()));
5888         }
5889
5890         RValue<Float4> Round(RValue<Float4> x)
5891         {
5892                 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
5893         }
5894
5895         RValue<Float4> Trunc(RValue<Float4> x)
5896         {
5897                 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
5898         }
5899
5900         RValue<Float4> Frac(RValue<Float4> x)
5901         {
5902                 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
5903         }
5904
5905         RValue<Float4> Floor(RValue<Float4> x)
5906         {
5907                 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
5908         }
5909
5910         RValue<Float4> Ceil(RValue<Float4> x)
5911         {
5912                 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
5913         }
5914
5915         Type *Float4::getType()
5916         {
5917                 return T(Ice::IceType_v4f32);
5918         }
5919
5920         RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, int offset)
5921         {
5922                 return lhs + RValue<Int>(Nucleus::createConstantInt(offset));
5923         }
5924
5925         RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<Int> offset)
5926         {
5927                 return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value, Byte::getType(), offset.value));
5928         }
5929
5930         RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<UInt> offset)
5931         {
5932                 return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value, Byte::getType(), offset.value));
5933         }
5934
5935         RValue<Pointer<Byte>> operator+=(const Pointer<Byte> &lhs, int offset)
5936         {
5937                 return lhs = lhs + offset;
5938         }
5939
5940         RValue<Pointer<Byte>> operator+=(const Pointer<Byte> &lhs, RValue<Int> offset)
5941         {
5942                 return lhs = lhs + offset;
5943         }
5944
5945         RValue<Pointer<Byte>> operator+=(const Pointer<Byte> &lhs, RValue<UInt> offset)
5946         {
5947                 return lhs = lhs + offset;
5948         }
5949
5950         RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, int offset)
5951         {
5952                 return lhs + -offset;
5953         }
5954
5955         RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, RValue<Int> offset)
5956         {
5957                 return lhs + -offset;
5958         }
5959
5960         RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, RValue<UInt> offset)
5961         {
5962                 return lhs + -offset;
5963         }
5964
5965         RValue<Pointer<Byte>> operator-=(const Pointer<Byte> &lhs, int offset)
5966         {
5967                 return lhs = lhs - offset;
5968         }
5969
5970         RValue<Pointer<Byte>> operator-=(const Pointer<Byte> &lhs, RValue<Int> offset)
5971         {
5972                 return lhs = lhs - offset;
5973         }
5974
5975         RValue<Pointer<Byte>> operator-=(const Pointer<Byte> &lhs, RValue<UInt> offset)
5976         {
5977                 return lhs = lhs - offset;
5978         }
5979
5980         void Return()
5981         {
5982                 Nucleus::createRetVoid();
5983                 Nucleus::setInsertBlock(Nucleus::createBasicBlock());
5984                 Nucleus::createUnreachable();
5985         }
5986
5987         void Return(bool ret)
5988         {
5989                 Ice::Operand *Ret = Ice::ConstantInteger32::create(::context, Ice::IceType_i32, ret ? 1 : 0);
5990                 Ice::InstRet *retu = Ice::InstRet::create(::function, Ret);
5991                 ::basicBlock->appendInst(retu);
5992         }
5993
5994         void Return(const Int &ret)
5995         {
5996                 Ice::InstRet *retu = Ice::InstRet::create(::function, ret.loadValue());
5997                 ::basicBlock->appendInst(retu);
5998         }
5999
6000         BasicBlock *beginLoop()
6001         {
6002                 BasicBlock *loopBB = Nucleus::createBasicBlock();
6003
6004                 Nucleus::createBr(loopBB);
6005                 Nucleus::setInsertBlock(loopBB);
6006
6007                 return loopBB;
6008         }
6009
6010         bool branch(RValue<Bool> cmp, BasicBlock *bodyBB, BasicBlock *endBB)
6011         {
6012                 Nucleus::createCondBr(cmp.value, bodyBB, endBB);
6013                 Nucleus::setInsertBlock(bodyBB);
6014
6015                 return true;
6016         }
6017
6018         bool elseBlock(BasicBlock *falseBB)
6019         {
6020                 Nucleus::setInsertBlock(falseBB);
6021
6022                 return true;
6023         }
6024
6025         RValue<Long> Ticks()
6026         {
6027                 assert(false && "UNIMPLEMENTED"); return RValue<Long>(V(nullptr));
6028         }
6029 }
6030