1 // Copyright 2016 The SwiftShader Authors. All Rights Reserved.
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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.
15 #include "Nucleus.hpp"
17 #include "Reactor.hpp"
18 #include "Routine.hpp"
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"
27 #include "llvm/Support/FileSystem.h"
28 #include "llvm/Support/raw_os_ostream.h"
30 #define WIN32_LEAN_AND_MEAN
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;
47 std::mutex codegenMutex;
49 Ice::ELFFileStreamer *elfFile = nullptr;
50 Ice::Fdstream *out = nullptr;
58 EmulatedV2 = 2 << EmulatedShift,
59 EmulatedV4 = 4 << EmulatedShift,
60 EmulatedV8 = 8 << EmulatedShift,
61 EmulatedBits = EmulatedV2 | EmulatedV4 | EmulatedV8,
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,
70 class Value : public Ice::Variable {};
71 class BasicBlock : public Ice::CfgNode {};
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);
81 return reinterpret_cast<Type*>(t);
84 Type *T(EmulatedType t)
86 return reinterpret_cast<Type*>(t);
89 Value *V(Ice::Variable *v)
91 return reinterpret_cast<Value*>(v);
94 BasicBlock *B(Ice::CfgNode *b)
96 return reinterpret_cast<BasicBlock*>(b);
99 Optimization optimization[10] = {InstructionCombining, Disabled};
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;
104 inline const SectionHeader *sectionHeader(const ElfHeader *elfHeader)
106 return reinterpret_cast<const SectionHeader*>((intptr_t)elfHeader + elfHeader->e_shoff);
109 inline const SectionHeader *elfSection(const ElfHeader *elfHeader, int index)
111 return §ionHeader(elfHeader)[index];
114 static void *relocateSymbol(const ElfHeader *elfHeader, const Elf32_Rel &relocation, const SectionHeader &relocationTable)
116 const SectionHeader *target = elfSection(elfHeader, relocationTable.sh_info);
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;
124 if(index != SHN_UNDEF)
126 if(table == SHN_UNDEF) return nullptr;
127 const SectionHeader *symbolTable = elfSection(elfHeader, table);
129 uint32_t symtab_entries = symbolTable->sh_size / symbolTable->sh_entsize;
130 if(index >= symtab_entries)
132 assert(index < symtab_entries && "Symbol Index out of range");
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;
140 if(section != SHN_UNDEF && section < SHN_LORESERVE)
142 const SectionHeader *target = elfSection(elfHeader, symbol.st_shndx);
143 symbolValue = reinterpret_cast<void*>((intptr_t)elfHeader + symbol.st_value + target->sh_offset);
151 switch(relocation.getType())
157 *patchSite = (int32_t)((intptr_t)symbolValue + *patchSite);
160 // *patchSite = (int32_t)((intptr_t)symbolValue + *patchSite - (intptr_t)patchSite);
163 assert(false && "Unsupported relocation type");
170 static void *relocateSymbol(const ElfHeader *elfHeader, const Elf64_Rela &relocation, const SectionHeader &relocationTable)
172 const SectionHeader *target = elfSection(elfHeader, relocationTable.sh_info);
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;
180 if(index != SHN_UNDEF)
182 if(table == SHN_UNDEF) return nullptr;
183 const SectionHeader *symbolTable = elfSection(elfHeader, table);
185 uint32_t symtab_entries = symbolTable->sh_size / symbolTable->sh_entsize;
186 if(index >= symtab_entries)
188 assert(index < symtab_entries && "Symbol Index out of range");
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;
196 if(section != SHN_UNDEF && section < SHN_LORESERVE)
198 const SectionHeader *target = elfSection(elfHeader, symbol.st_shndx);
199 symbolValue = reinterpret_cast<void*>((intptr_t)elfHeader + symbol.st_value + target->sh_offset);
207 switch(relocation.getType())
213 // *patchSite = (int32_t)((intptr_t)symbolValue + *patchSite) + relocation->r_addend;
216 *patchSite = (int32_t)((intptr_t)symbolValue + *patchSite - (intptr_t)patchSite) + relocation.r_addend;
218 // case R_X86_64_32S:
219 // *patchSite = (int32_t)((intptr_t)symbolValue + *patchSite) + relocation.r_addend;
222 assert(false && "Unsupported relocation type");
229 void *loadImage(uint8_t *const elfImage)
231 ElfHeader *elfHeader = (ElfHeader*)elfImage;
233 if(!elfHeader->checkMagic())
238 // Expect ELF bitness to match platform
239 assert(sizeof(void*) == 8 ? elfHeader->e_machine == EM_X86_64 : elfHeader->e_machine == EM_386);
241 SectionHeader *sectionHeader = (SectionHeader*)(elfImage + elfHeader->e_shoff);
242 void *entry = nullptr;
244 for(int i = 0; i < elfHeader->e_shnum; i++)
246 if(sectionHeader[i].sh_type == SHT_PROGBITS)
248 if(sectionHeader[i].sh_flags & SHF_EXECINSTR)
250 entry = elfImage + sectionHeader[i].sh_offset;
253 else if(sectionHeader[i].sh_type == SHT_REL)
255 assert(sizeof(void*) == 4 && "UNIMPLEMENTED"); // Only expected/implemented for 32-bit code
257 for(int index = 0; index < sectionHeader[i].sh_size / sectionHeader[i].sh_entsize; index++)
259 const Elf32_Rel &relocation = ((const Elf32_Rel*)(elfImage + sectionHeader[i].sh_offset))[index];
260 void *symbol = relocateSymbol(elfHeader, relocation, sectionHeader[i]);
263 else if(sectionHeader[i].sh_type == SHT_RELA)
265 assert(sizeof(void*) == 8 && "UNIMPLEMENTED"); // Only expected/implemented for 64-bit code
267 for(int index = 0; index < sectionHeader[i].sh_size / sectionHeader[i].sh_entsize; index++)
269 const Elf64_Rela &relocation = ((const Elf64_Rela*)(elfImage + sectionHeader[i].sh_offset))[index];
270 void *symbol = relocateSymbol(elfHeader, relocation, sectionHeader[i]);
279 struct ExecutableAllocator
281 ExecutableAllocator() {};
282 template<class U> ExecutableAllocator(const ExecutableAllocator<U> &other) {};
284 using value_type = T;
285 using size_type = std::size_t;
287 T *allocate(size_type n)
289 return (T*)VirtualAlloc(NULL, sizeof(T) * n, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
292 void deallocate(T *p, size_type n)
294 VirtualFree(p, 0, MEM_RELEASE);
298 class ELFMemoryStreamer : public Ice::ELFStreamer, public Routine
300 ELFMemoryStreamer(const ELFMemoryStreamer &) = delete;
301 ELFMemoryStreamer &operator=(const ELFMemoryStreamer &) = delete;
304 ELFMemoryStreamer() : Routine()
307 buffer.reserve(0x1000);
310 virtual ~ELFMemoryStreamer()
312 if(buffer.size() != 0)
315 VirtualProtect(&buffer[0], buffer.size(), oldProtection, &exeProtection);
319 void write8(uint8_t Value) override
321 if(position == (uint64_t)buffer.size())
323 buffer.push_back(Value);
326 else if(position < (uint64_t)buffer.size())
328 buffer[position] = Value;
331 else assert(false && "UNIMPLEMENTED");
334 void writeBytes(llvm::StringRef Bytes) override
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();
342 uint64_t tell() const override { return position; }
344 void seek(uint64_t Off) override { position = Off; }
346 const void *getEntry() override
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
351 return loadImage(&buffer[0]);
355 std::vector<uint8_t, ExecutableAllocator<uint8_t>> buffer;
356 std::size_t position;
362 ::codegenMutex.lock(); // Reactor is currently not thread safe
364 Ice::ClFlags &Flags = Ice::ClFlags::Flags;
365 Ice::ClFlags::getParsedClFlags(Flags);
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);
372 std::unique_ptr<Ice::Ostream> cout(new llvm::raw_os_ostream(std::cout));
374 if(false) // Write out to a file
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);
383 ELFMemoryStreamer *elfMemory = new ELFMemoryStreamer();
384 ::context = new Ice::GlobalContext(cout.get(), cout.get(), cout.get(), elfMemory);
385 ::routine = elfMemory;
398 ::codegenMutex.unlock();
401 Routine *Nucleus::acquireRoutine(const wchar_t *name, bool runOptimizations)
403 if(basicBlock->getInsts().empty() || basicBlock->getInsts().back().getKind() != Ice::Inst::Ret)
408 std::wstring wideName(name);
409 std::string asciiName(wideName.begin(), wideName.end());
410 ::function->setFunctionName(Ice::GlobalString::createWithString(::context, asciiName));
412 ::function->translate();
413 auto *globals = ::function->getGlobalInits().release();
415 if(globals && !globals->empty())
417 ::context->getGlobals()->merge(globals);
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();
433 void Nucleus::optimize()
437 Value *Nucleus::allocateStackVariable(Type *t, int arraySize)
439 assert(arraySize == 0 && "UNIMPLEMENTED");
441 Ice::Type type = T(t);
442 int size = Ice::typeWidthInBytes(type);
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);
452 BasicBlock *Nucleus::createBasicBlock()
454 return B(::function->makeNode());
457 BasicBlock *Nucleus::getInsertBlock()
459 return B(::basicBlock);
462 void Nucleus::setInsertBlock(BasicBlock *basicBlock)
464 assert(::basicBlock->getInsts().back().getTerminatorEdges().size() >= 0 && "Previous basic block must have a terminator");
465 ::basicBlock = basicBlock;
468 BasicBlock *Nucleus::getPredecessor(BasicBlock *basicBlock)
470 assert(false && "UNIMPLEMENTED"); return nullptr;
473 void Nucleus::createFunction(Type *ReturnType, std::vector<Type*> &Params)
475 uint32_t sequenceNumber = 0;
476 ::function = Ice::Cfg::create(::context, sequenceNumber).release();
477 ::allocator = new Ice::CfgLocalAllocatorScope(::function);
479 for(Type *type : Params)
481 Ice::Variable *arg = ::function->makeVariable(T(type));
482 ::function->addArg(arg);
485 Ice::CfgNode *node = ::function->makeNode();
486 ::function->setEntryNode(node);
490 Value *Nucleus::getArgument(unsigned int index)
492 return V(::function->getArgs()[index]);
495 void Nucleus::createRetVoid()
497 assert(false && "UNIMPLEMENTED");
500 void Nucleus::createRet(Value *v)
502 assert(false && "UNIMPLEMENTED");
505 void Nucleus::createBr(BasicBlock *dest)
507 auto br = Ice::InstBr::create(::function, dest);
508 ::basicBlock->appendInst(br);
511 void Nucleus::createCondBr(Value *cond, BasicBlock *ifTrue, BasicBlock *ifFalse)
513 auto br = Ice::InstBr::create(::function, cond, ifTrue, ifFalse);
514 ::basicBlock->appendInst(br);
517 static Value *createArithmetic(Ice::InstArithmetic::OpKind op, Value *lhs, Value *rhs)
519 assert(lhs->getType() == rhs->getType());
521 Ice::Variable *result = ::function->makeVariable(lhs->getType());
522 Ice::InstArithmetic *arithmetic = Ice::InstArithmetic::create(::function, op, result, lhs, rhs);
523 ::basicBlock->appendInst(arithmetic);
528 Value *Nucleus::createAdd(Value *lhs, Value *rhs)
530 return createArithmetic(Ice::InstArithmetic::Add, lhs, rhs);
533 Value *Nucleus::createSub(Value *lhs, Value *rhs)
535 return createArithmetic(Ice::InstArithmetic::Sub, lhs, rhs);
538 Value *Nucleus::createMul(Value *lhs, Value *rhs)
540 return createArithmetic(Ice::InstArithmetic::Mul, lhs, rhs);
543 Value *Nucleus::createUDiv(Value *lhs, Value *rhs)
545 return createArithmetic(Ice::InstArithmetic::Udiv, lhs, rhs);
548 Value *Nucleus::createSDiv(Value *lhs, Value *rhs)
550 return createArithmetic(Ice::InstArithmetic::Sdiv, lhs, rhs);
553 Value *Nucleus::createFAdd(Value *lhs, Value *rhs)
555 return createArithmetic(Ice::InstArithmetic::Fadd, lhs, rhs);
558 Value *Nucleus::createFSub(Value *lhs, Value *rhs)
560 return createArithmetic(Ice::InstArithmetic::Fsub, lhs, rhs);
563 Value *Nucleus::createFMul(Value *lhs, Value *rhs)
565 return createArithmetic(Ice::InstArithmetic::Fmul, lhs, rhs);
568 Value *Nucleus::createFDiv(Value *lhs, Value *rhs)
570 return createArithmetic(Ice::InstArithmetic::Fdiv, lhs, rhs);
573 Value *Nucleus::createURem(Value *lhs, Value *rhs)
575 return createArithmetic(Ice::InstArithmetic::Urem, lhs, rhs);
578 Value *Nucleus::createSRem(Value *lhs, Value *rhs)
580 return createArithmetic(Ice::InstArithmetic::Srem, lhs, rhs);
583 Value *Nucleus::createFRem(Value *lhs, Value *rhs)
585 return createArithmetic(Ice::InstArithmetic::Frem, lhs, rhs);
588 Value *Nucleus::createShl(Value *lhs, Value *rhs)
590 return createArithmetic(Ice::InstArithmetic::Shl, lhs, rhs);
593 Value *Nucleus::createLShr(Value *lhs, Value *rhs)
595 return createArithmetic(Ice::InstArithmetic::Lshr, lhs, rhs);
598 Value *Nucleus::createAShr(Value *lhs, Value *rhs)
600 return createArithmetic(Ice::InstArithmetic::Ashr, lhs, rhs);
603 Value *Nucleus::createAnd(Value *lhs, Value *rhs)
605 return createArithmetic(Ice::InstArithmetic::And, lhs, rhs);
608 Value *Nucleus::createOr(Value *lhs, Value *rhs)
610 return createArithmetic(Ice::InstArithmetic::Or, lhs, rhs);
613 Value *Nucleus::createXor(Value *lhs, Value *rhs)
615 return createArithmetic(Ice::InstArithmetic::Xor, lhs, rhs);
618 static Value *createAssign(Ice::Constant *constant)
620 Ice::Variable *value = ::function->makeVariable(constant->getType());
621 auto assign = Ice::InstAssign::create(::function, value, constant);
622 ::basicBlock->appendInst(assign);
627 Value *Nucleus::createNeg(Value *v)
629 assert(false && "UNIMPLEMENTED"); return nullptr;
632 Value *Nucleus::createFNeg(Value *v)
634 assert(false && "UNIMPLEMENTED"); return nullptr;
637 Value *Nucleus::createNot(Value *v)
639 assert(false && "UNIMPLEMENTED"); return nullptr;
642 Value *Nucleus::createLoad(Value *ptr, Type *type, bool isVolatile, unsigned int align)
644 int valueType = (int)reinterpret_cast<intptr_t>(type);
645 Ice::Variable *result = ::function->makeVariable(T(type));
647 if(valueType & EmulatedBits)
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));
659 ::basicBlock->appendInst(load);
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));
671 ::basicBlock->appendInst(load);
674 default: assert(false && "UNIMPLEMENTED");
679 auto load = Ice::InstLoad::create(::function, result, ptr, align);
680 ::basicBlock->appendInst(load);
686 Value *Nucleus::createStore(Value *value, Value *ptr, Type *type, bool isVolatile, unsigned int align)
688 int valueType = (int)reinterpret_cast<intptr_t>(type);
690 if(valueType & EmulatedBits)
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);
703 ::basicBlock->appendInst(store);
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);
716 ::basicBlock->appendInst(store);
719 default: assert(false && "UNIMPLEMENTED");
724 assert(T(value->getType()) == type);
726 auto store = Ice::InstStore::create(::function, value, ptr, align);
727 ::basicBlock->appendInst(store);
733 Value *Nucleus::createGEP(Value *ptr, Type *type, Value *index)
735 assert(index->getType() == Ice::IceType_i32);
737 if(!Ice::isByteSizedType(T(type)))
739 index = createMul(index, createConstantInt((int)Ice::typeWidthInBytes(T(type))));
742 if(sizeof(void*) == 8)
744 index = createSExt(index, T(Ice::IceType_i64));
747 return createAdd(ptr, index);
750 Value *Nucleus::createAtomicAdd(Value *ptr, Value *value)
752 assert(false && "UNIMPLEMENTED"); return nullptr;
755 static Value *createCast(Ice::InstCast::OpKind op, Value *v, Type *destType)
757 if(v->getType() == T(destType))
762 Ice::Variable *result = ::function->makeVariable(T(destType));
763 Ice::InstCast *cast = Ice::InstCast::create(::function, op, result, v);
764 ::basicBlock->appendInst(cast);
769 Value *Nucleus::createTrunc(Value *v, Type *destType)
771 return createCast(Ice::InstCast::Trunc, v, destType);
774 Value *Nucleus::createZExt(Value *v, Type *destType)
776 return createCast(Ice::InstCast::Zext, v, destType);
779 Value *Nucleus::createSExt(Value *v, Type *destType)
781 return createCast(Ice::InstCast::Sext, v, destType);
784 Value *Nucleus::createFPToSI(Value *v, Type *destType)
786 return createCast(Ice::InstCast::Fptosi, v, destType);
789 Value *Nucleus::createUIToFP(Value *v, Type *destType)
791 return createCast(Ice::InstCast::Uitofp, v, destType);
794 Value *Nucleus::createSIToFP(Value *v, Type *destType)
796 return createCast(Ice::InstCast::Sitofp, v, destType);
799 Value *Nucleus::createFPTrunc(Value *v, Type *destType)
801 return createCast(Ice::InstCast::Fptrunc, v, destType);
804 Value *Nucleus::createFPExt(Value *v, Type *destType)
806 return createCast(Ice::InstCast::Fpext, v, destType);
809 Value *Nucleus::createBitCast(Value *v, Type *destType)
811 return createCast(Ice::InstCast::Bitcast, v, destType);
814 Value *Nucleus::createIntCast(Value *v, Type *destType, bool isSigned)
816 assert(false && "UNIMPLEMENTED"); return nullptr;
819 Value *Nucleus::createICmpEQ(Value *lhs, Value *rhs)
821 assert(false && "UNIMPLEMENTED"); return nullptr;
824 Value *Nucleus::createICmpNE(Value *lhs, Value *rhs)
826 assert(false && "UNIMPLEMENTED"); return nullptr;
829 Value *Nucleus::createICmpUGT(Value *lhs, Value *rhs)
831 assert(false && "UNIMPLEMENTED"); return nullptr;
834 Value *Nucleus::createICmpUGE(Value *lhs, Value *rhs)
836 assert(false && "UNIMPLEMENTED"); return nullptr;
839 Value *Nucleus::createICmpULT(Value *lhs, Value *rhs)
841 assert(false && "UNIMPLEMENTED"); return nullptr;
844 Value *Nucleus::createICmpULE(Value *lhs, Value *rhs)
846 assert(false && "UNIMPLEMENTED"); return nullptr;
849 Value *Nucleus::createICmpSGT(Value *lhs, Value *rhs)
851 assert(false && "UNIMPLEMENTED"); return nullptr;
854 Value *Nucleus::createICmpSGE(Value *lhs, Value *rhs)
856 assert(false && "UNIMPLEMENTED"); return nullptr;
859 Value *Nucleus::createICmpSLT(Value *lhs, Value *rhs)
861 assert(lhs->getType() == rhs->getType());
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);
870 Value *Nucleus::createICmpSLE(Value *lhs, Value *rhs)
872 assert(false && "UNIMPLEMENTED"); return nullptr;
875 Value *Nucleus::createFCmpOEQ(Value *lhs, Value *rhs)
877 assert(false && "UNIMPLEMENTED"); return nullptr;
880 Value *Nucleus::createFCmpOGT(Value *lhs, Value *rhs)
882 assert(false && "UNIMPLEMENTED"); return nullptr;
885 Value *Nucleus::createFCmpOGE(Value *lhs, Value *rhs)
887 assert(false && "UNIMPLEMENTED"); return nullptr;
890 Value *Nucleus::createFCmpOLT(Value *lhs, Value *rhs)
892 assert(false && "UNIMPLEMENTED"); return nullptr;
895 Value *Nucleus::createFCmpOLE(Value *lhs, Value *rhs)
897 assert(false && "UNIMPLEMENTED"); return nullptr;
900 Value *Nucleus::createFCmpONE(Value *lhs, Value *rhs)
902 assert(false && "UNIMPLEMENTED"); return nullptr;
905 Value *Nucleus::createFCmpORD(Value *lhs, Value *rhs)
907 assert(false && "UNIMPLEMENTED"); return nullptr;
910 Value *Nucleus::createFCmpUNO(Value *lhs, Value *rhs)
912 assert(false && "UNIMPLEMENTED"); return nullptr;
915 Value *Nucleus::createFCmpUEQ(Value *lhs, Value *rhs)
917 assert(false && "UNIMPLEMENTED"); return nullptr;
920 Value *Nucleus::createFCmpUGT(Value *lhs, Value *rhs)
922 assert(false && "UNIMPLEMENTED"); return nullptr;
925 Value *Nucleus::createFCmpUGE(Value *lhs, Value *rhs)
927 assert(false && "UNIMPLEMENTED"); return nullptr;
930 Value *Nucleus::createFCmpULT(Value *lhs, Value *rhs)
932 assert(false && "UNIMPLEMENTED"); return nullptr;
935 Value *Nucleus::createFCmpULE(Value *lhs, Value *rhs)
937 assert(false && "UNIMPLEMENTED"); return nullptr;
940 Value *Nucleus::createFCmpUNE(Value *lhs, Value *rhs)
942 assert(false && "UNIMPLEMENTED"); return nullptr;
945 Value *Nucleus::createExtractElement(Value *vector, Type *type, int index)
947 auto result = ::function->makeVariable(T(type));
948 auto extract = Ice::InstExtractElement::create(::function, result, vector, ::context->getConstantInt32(index));
949 ::basicBlock->appendInst(extract);
954 Value *Nucleus::createInsertElement(Value *vector, Value *element, int index)
956 auto result = ::function->makeVariable(vector->getType());
957 auto insert = Ice::InstInsertElement::create(::function, result, vector, element, ::context->getConstantInt32(index));
958 ::basicBlock->appendInst(insert);
963 Value *Nucleus::createShuffleVector(Value *V1, Value *V2, const int *select)
965 assert(V1->getType() == V2->getType());
967 int size = Ice::typeNumElements(V1->getType());
968 auto result = ::function->makeVariable(V1->getType());
969 auto shuffle = Ice::InstShuffleVector::create(::function, result, V1, V2);
971 for(int i = 0; i < size; i++)
973 shuffle->addIndex(llvm::cast<Ice::ConstantInteger32>(::context->getConstantInt32(select[i])));
976 ::basicBlock->appendInst(shuffle);
981 Value *Nucleus::createSelect(Value *C, Value *ifTrue, Value *ifFalse)
983 assert(false && "UNIMPLEMENTED"); return nullptr;
986 Value *Nucleus::createSwitch(Value *v, BasicBlock *Dest, unsigned NumCases)
988 assert(false && "UNIMPLEMENTED"); return nullptr;
991 void Nucleus::addSwitchCase(Value *Switch, int Case, BasicBlock *Branch)
993 assert(false && "UNIMPLEMENTED"); return;
996 void Nucleus::createUnreachable()
998 assert(false && "UNIMPLEMENTED");
1001 static Value *createSwizzle4(Value *val, unsigned char select)
1005 (select >> 0) & 0x03,
1006 (select >> 2) & 0x03,
1007 (select >> 4) & 0x03,
1008 (select >> 6) & 0x03,
1011 return Nucleus::createShuffleVector(val, val, swizzle);
1014 static Value *createMask4(Value *lhs, Value *rhs, unsigned char select)
1016 assert(false && "UNIMPLEMENTED"); return nullptr;
1019 Value *Nucleus::createConstantPointer(const void *address, Type *Ty, bool isConstant, unsigned int Align)
1021 assert(false && "UNIMPLEMENTED"); return nullptr;
1024 Type *Nucleus::getPointerType(Type *ElementType)
1026 if(sizeof(void*) == 8)
1028 return T(Ice::IceType_i64);
1032 return T(Ice::IceType_i32);
1036 Value *Nucleus::createNullValue(Type *Ty)
1038 assert(false && "UNIMPLEMENTED"); return nullptr;
1041 Value *Nucleus::createConstantLong(int64_t i)
1043 assert(false && "UNIMPLEMENTED"); return nullptr;
1046 Value *Nucleus::createConstantInt(int i)
1048 return createAssign(::context->getConstantInt32(i));
1051 Value *Nucleus::createConstantInt(unsigned int i)
1053 assert(false && "UNIMPLEMENTED"); return nullptr;
1056 Value *Nucleus::createConstantBool(bool b)
1058 assert(false && "UNIMPLEMENTED"); return nullptr;
1061 Value *Nucleus::createConstantByte(signed char i)
1063 assert(false && "UNIMPLEMENTED"); return nullptr;
1066 Value *Nucleus::createConstantByte(unsigned char i)
1068 assert(false && "UNIMPLEMENTED"); return nullptr;
1071 Value *Nucleus::createConstantShort(short i)
1073 assert(false && "UNIMPLEMENTED"); return nullptr;
1076 Value *Nucleus::createConstantShort(unsigned short i)
1078 assert(false && "UNIMPLEMENTED"); return nullptr;
1081 Value *Nucleus::createConstantFloat(float x)
1083 assert(false && "UNIMPLEMENTED"); return nullptr;
1086 Value *Nucleus::createNullPointer(Type *Ty)
1088 assert(false && "UNIMPLEMENTED"); return nullptr;
1091 Value *Nucleus::createConstantVector(const int64_t *constants, Type *type)
1093 assert(false && "UNIMPLEMENTED"); return nullptr;
1096 Value *Nucleus::createConstantVector(const double *constants, Type *type)
1098 assert(false && "UNIMPLEMENTED"); return nullptr;
1101 Type *Void::getType()
1103 return T(Ice::IceType_void);
1106 Bool::Bool(Argument<Bool> argument)
1108 storeValue(argument.value);
1117 storeValue(Nucleus::createConstantBool(x));
1120 Bool::Bool(RValue<Bool> rhs)
1122 storeValue(rhs.value);
1125 Bool::Bool(const Bool &rhs)
1127 Value *value = rhs.loadValue();
1131 Bool::Bool(const Reference<Bool> &rhs)
1133 Value *value = rhs.loadValue();
1137 RValue<Bool> Bool::operator=(RValue<Bool> rhs) const
1139 storeValue(rhs.value);
1144 RValue<Bool> Bool::operator=(const Bool &rhs) const
1146 Value *value = rhs.loadValue();
1149 return RValue<Bool>(value);
1152 RValue<Bool> Bool::operator=(const Reference<Bool> &rhs) const
1154 Value *value = rhs.loadValue();
1157 return RValue<Bool>(value);
1160 RValue<Bool> operator!(RValue<Bool> val)
1162 return RValue<Bool>(Nucleus::createNot(val.value));
1165 RValue<Bool> operator&&(RValue<Bool> lhs, RValue<Bool> rhs)
1167 return RValue<Bool>(Nucleus::createAnd(lhs.value, rhs.value));
1170 RValue<Bool> operator||(RValue<Bool> lhs, RValue<Bool> rhs)
1172 return RValue<Bool>(Nucleus::createOr(lhs.value, rhs.value));
1175 Type *Bool::getType()
1177 assert(false && "UNIMPLEMENTED"); return nullptr;
1180 Byte::Byte(Argument<Byte> argument)
1182 storeValue(argument.value);
1185 Byte::Byte(RValue<Int> cast)
1187 Value *integer = Nucleus::createTrunc(cast.value, Byte::getType());
1189 storeValue(integer);
1192 Byte::Byte(RValue<UInt> cast)
1194 Value *integer = Nucleus::createTrunc(cast.value, Byte::getType());
1196 storeValue(integer);
1199 Byte::Byte(RValue<UShort> cast)
1201 Value *integer = Nucleus::createTrunc(cast.value, Byte::getType());
1203 storeValue(integer);
1212 storeValue(Nucleus::createConstantByte((unsigned char)x));
1215 Byte::Byte(unsigned char x)
1217 storeValue(Nucleus::createConstantByte(x));
1220 Byte::Byte(RValue<Byte> rhs)
1222 storeValue(rhs.value);
1225 Byte::Byte(const Byte &rhs)
1227 Value *value = rhs.loadValue();
1231 Byte::Byte(const Reference<Byte> &rhs)
1233 Value *value = rhs.loadValue();
1237 RValue<Byte> Byte::operator=(RValue<Byte> rhs) const
1239 storeValue(rhs.value);
1244 RValue<Byte> Byte::operator=(const Byte &rhs) const
1246 Value *value = rhs.loadValue();
1249 return RValue<Byte>(value);
1252 RValue<Byte> Byte::operator=(const Reference<Byte> &rhs) const
1254 Value *value = rhs.loadValue();
1257 return RValue<Byte>(value);
1260 RValue<Byte> operator+(RValue<Byte> lhs, RValue<Byte> rhs)
1262 return RValue<Byte>(Nucleus::createAdd(lhs.value, rhs.value));
1265 RValue<Byte> operator-(RValue<Byte> lhs, RValue<Byte> rhs)
1267 return RValue<Byte>(Nucleus::createSub(lhs.value, rhs.value));
1270 RValue<Byte> operator*(RValue<Byte> lhs, RValue<Byte> rhs)
1272 return RValue<Byte>(Nucleus::createMul(lhs.value, rhs.value));
1275 RValue<Byte> operator/(RValue<Byte> lhs, RValue<Byte> rhs)
1277 return RValue<Byte>(Nucleus::createUDiv(lhs.value, rhs.value));
1280 RValue<Byte> operator%(RValue<Byte> lhs, RValue<Byte> rhs)
1282 return RValue<Byte>(Nucleus::createURem(lhs.value, rhs.value));
1285 RValue<Byte> operator&(RValue<Byte> lhs, RValue<Byte> rhs)
1287 return RValue<Byte>(Nucleus::createAnd(lhs.value, rhs.value));
1290 RValue<Byte> operator|(RValue<Byte> lhs, RValue<Byte> rhs)
1292 return RValue<Byte>(Nucleus::createOr(lhs.value, rhs.value));
1295 RValue<Byte> operator^(RValue<Byte> lhs, RValue<Byte> rhs)
1297 return RValue<Byte>(Nucleus::createXor(lhs.value, rhs.value));
1300 RValue<Byte> operator<<(RValue<Byte> lhs, RValue<Byte> rhs)
1302 return RValue<Byte>(Nucleus::createShl(lhs.value, rhs.value));
1305 RValue<Byte> operator>>(RValue<Byte> lhs, RValue<Byte> rhs)
1307 return RValue<Byte>(Nucleus::createLShr(lhs.value, rhs.value));
1310 RValue<Byte> operator+=(const Byte &lhs, RValue<Byte> rhs)
1312 return lhs = lhs + rhs;
1315 RValue<Byte> operator-=(const Byte &lhs, RValue<Byte> rhs)
1317 return lhs = lhs - rhs;
1320 RValue<Byte> operator*=(const Byte &lhs, RValue<Byte> rhs)
1322 return lhs = lhs * rhs;
1325 RValue<Byte> operator/=(const Byte &lhs, RValue<Byte> rhs)
1327 return lhs = lhs / rhs;
1330 RValue<Byte> operator%=(const Byte &lhs, RValue<Byte> rhs)
1332 return lhs = lhs % rhs;
1335 RValue<Byte> operator&=(const Byte &lhs, RValue<Byte> rhs)
1337 return lhs = lhs & rhs;
1340 RValue<Byte> operator|=(const Byte &lhs, RValue<Byte> rhs)
1342 return lhs = lhs | rhs;
1345 RValue<Byte> operator^=(const Byte &lhs, RValue<Byte> rhs)
1347 return lhs = lhs ^ rhs;
1350 RValue<Byte> operator<<=(const Byte &lhs, RValue<Byte> rhs)
1352 return lhs = lhs << rhs;
1355 RValue<Byte> operator>>=(const Byte &lhs, RValue<Byte> rhs)
1357 return lhs = lhs >> rhs;
1360 RValue<Byte> operator+(RValue<Byte> val)
1365 RValue<Byte> operator-(RValue<Byte> val)
1367 return RValue<Byte>(Nucleus::createNeg(val.value));
1370 RValue<Byte> operator~(RValue<Byte> val)
1372 return RValue<Byte>(Nucleus::createNot(val.value));
1375 RValue<Byte> operator++(const Byte &val, int) // Post-increment
1377 RValue<Byte> res = val;
1379 assert(false && "UNIMPLEMENTED");
1384 const Byte &operator++(const Byte &val) // Pre-increment
1386 assert(false && "UNIMPLEMENTED");
1391 RValue<Byte> operator--(const Byte &val, int) // Post-decrement
1393 RValue<Byte> res = val;
1395 assert(false && "UNIMPLEMENTED");
1400 const Byte &operator--(const Byte &val) // Pre-decrement
1402 assert(false && "UNIMPLEMENTED");
1407 RValue<Bool> operator<(RValue<Byte> lhs, RValue<Byte> rhs)
1409 return RValue<Bool>(Nucleus::createICmpULT(lhs.value, rhs.value));
1412 RValue<Bool> operator<=(RValue<Byte> lhs, RValue<Byte> rhs)
1414 return RValue<Bool>(Nucleus::createICmpULE(lhs.value, rhs.value));
1417 RValue<Bool> operator>(RValue<Byte> lhs, RValue<Byte> rhs)
1419 return RValue<Bool>(Nucleus::createICmpUGT(lhs.value, rhs.value));
1422 RValue<Bool> operator>=(RValue<Byte> lhs, RValue<Byte> rhs)
1424 return RValue<Bool>(Nucleus::createICmpUGE(lhs.value, rhs.value));
1427 RValue<Bool> operator!=(RValue<Byte> lhs, RValue<Byte> rhs)
1429 return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value));
1432 RValue<Bool> operator==(RValue<Byte> lhs, RValue<Byte> rhs)
1434 return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value));
1437 Type *Byte::getType()
1439 return T(Ice::IceType_i8);
1442 SByte::SByte(Argument<SByte> argument)
1444 storeValue(argument.value);
1447 SByte::SByte(RValue<Int> cast)
1449 Value *integer = Nucleus::createTrunc(cast.value, SByte::getType());
1451 storeValue(integer);
1454 SByte::SByte(RValue<Short> cast)
1456 Value *integer = Nucleus::createTrunc(cast.value, SByte::getType());
1458 storeValue(integer);
1465 SByte::SByte(signed char x)
1467 storeValue(Nucleus::createConstantByte(x));
1470 SByte::SByte(RValue<SByte> rhs)
1472 storeValue(rhs.value);
1475 SByte::SByte(const SByte &rhs)
1477 Value *value = rhs.loadValue();
1481 SByte::SByte(const Reference<SByte> &rhs)
1483 Value *value = rhs.loadValue();
1487 RValue<SByte> SByte::operator=(RValue<SByte> rhs) const
1489 storeValue(rhs.value);
1494 RValue<SByte> SByte::operator=(const SByte &rhs) const
1496 Value *value = rhs.loadValue();
1499 return RValue<SByte>(value);
1502 RValue<SByte> SByte::operator=(const Reference<SByte> &rhs) const
1504 Value *value = rhs.loadValue();
1507 return RValue<SByte>(value);
1510 RValue<SByte> operator+(RValue<SByte> lhs, RValue<SByte> rhs)
1512 return RValue<SByte>(Nucleus::createAdd(lhs.value, rhs.value));
1515 RValue<SByte> operator-(RValue<SByte> lhs, RValue<SByte> rhs)
1517 return RValue<SByte>(Nucleus::createSub(lhs.value, rhs.value));
1520 RValue<SByte> operator*(RValue<SByte> lhs, RValue<SByte> rhs)
1522 return RValue<SByte>(Nucleus::createMul(lhs.value, rhs.value));
1525 RValue<SByte> operator/(RValue<SByte> lhs, RValue<SByte> rhs)
1527 return RValue<SByte>(Nucleus::createSDiv(lhs.value, rhs.value));
1530 RValue<SByte> operator%(RValue<SByte> lhs, RValue<SByte> rhs)
1532 return RValue<SByte>(Nucleus::createSRem(lhs.value, rhs.value));
1535 RValue<SByte> operator&(RValue<SByte> lhs, RValue<SByte> rhs)
1537 return RValue<SByte>(Nucleus::createAnd(lhs.value, rhs.value));
1540 RValue<SByte> operator|(RValue<SByte> lhs, RValue<SByte> rhs)
1542 return RValue<SByte>(Nucleus::createOr(lhs.value, rhs.value));
1545 RValue<SByte> operator^(RValue<SByte> lhs, RValue<SByte> rhs)
1547 return RValue<SByte>(Nucleus::createXor(lhs.value, rhs.value));
1550 RValue<SByte> operator<<(RValue<SByte> lhs, RValue<SByte> rhs)
1552 return RValue<SByte>(Nucleus::createShl(lhs.value, rhs.value));
1555 RValue<SByte> operator>>(RValue<SByte> lhs, RValue<SByte> rhs)
1557 return RValue<SByte>(Nucleus::createAShr(lhs.value, rhs.value));
1560 RValue<SByte> operator+=(const SByte &lhs, RValue<SByte> rhs)
1562 return lhs = lhs + rhs;
1565 RValue<SByte> operator-=(const SByte &lhs, RValue<SByte> rhs)
1567 return lhs = lhs - rhs;
1570 RValue<SByte> operator*=(const SByte &lhs, RValue<SByte> rhs)
1572 return lhs = lhs * rhs;
1575 RValue<SByte> operator/=(const SByte &lhs, RValue<SByte> rhs)
1577 return lhs = lhs / rhs;
1580 RValue<SByte> operator%=(const SByte &lhs, RValue<SByte> rhs)
1582 return lhs = lhs % rhs;
1585 RValue<SByte> operator&=(const SByte &lhs, RValue<SByte> rhs)
1587 return lhs = lhs & rhs;
1590 RValue<SByte> operator|=(const SByte &lhs, RValue<SByte> rhs)
1592 return lhs = lhs | rhs;
1595 RValue<SByte> operator^=(const SByte &lhs, RValue<SByte> rhs)
1597 return lhs = lhs ^ rhs;
1600 RValue<SByte> operator<<=(const SByte &lhs, RValue<SByte> rhs)
1602 return lhs = lhs << rhs;
1605 RValue<SByte> operator>>=(const SByte &lhs, RValue<SByte> rhs)
1607 return lhs = lhs >> rhs;
1610 RValue<SByte> operator+(RValue<SByte> val)
1615 RValue<SByte> operator-(RValue<SByte> val)
1617 return RValue<SByte>(Nucleus::createNeg(val.value));
1620 RValue<SByte> operator~(RValue<SByte> val)
1622 return RValue<SByte>(Nucleus::createNot(val.value));
1625 RValue<SByte> operator++(const SByte &val, int) // Post-increment
1627 RValue<SByte> res = val;
1629 assert(false && "UNIMPLEMENTED");
1634 const SByte &operator++(const SByte &val) // Pre-increment
1636 assert(false && "UNIMPLEMENTED");
1637 assert(false && "UNIMPLEMENTED");
1642 RValue<SByte> operator--(const SByte &val, int) // Post-decrement
1644 RValue<SByte> res = val;
1646 assert(false && "UNIMPLEMENTED");
1647 assert(false && "UNIMPLEMENTED");
1652 const SByte &operator--(const SByte &val) // Pre-decrement
1654 assert(false && "UNIMPLEMENTED");
1655 assert(false && "UNIMPLEMENTED");
1660 RValue<Bool> operator<(RValue<SByte> lhs, RValue<SByte> rhs)
1662 return RValue<Bool>(Nucleus::createICmpSLT(lhs.value, rhs.value));
1665 RValue<Bool> operator<=(RValue<SByte> lhs, RValue<SByte> rhs)
1667 return RValue<Bool>(Nucleus::createICmpSLE(lhs.value, rhs.value));
1670 RValue<Bool> operator>(RValue<SByte> lhs, RValue<SByte> rhs)
1672 return RValue<Bool>(Nucleus::createICmpSGT(lhs.value, rhs.value));
1675 RValue<Bool> operator>=(RValue<SByte> lhs, RValue<SByte> rhs)
1677 return RValue<Bool>(Nucleus::createICmpSGE(lhs.value, rhs.value));
1680 RValue<Bool> operator!=(RValue<SByte> lhs, RValue<SByte> rhs)
1682 return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value));
1685 RValue<Bool> operator==(RValue<SByte> lhs, RValue<SByte> rhs)
1687 return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value));
1690 Type *SByte::getType()
1692 assert(false && "UNIMPLEMENTED"); return nullptr;
1695 Short::Short(Argument<Short> argument)
1697 storeValue(argument.value);
1700 Short::Short(RValue<Int> cast)
1702 Value *integer = Nucleus::createTrunc(cast.value, Short::getType());
1704 storeValue(integer);
1711 Short::Short(short x)
1713 storeValue(Nucleus::createConstantShort(x));
1716 Short::Short(RValue<Short> rhs)
1718 storeValue(rhs.value);
1721 Short::Short(const Short &rhs)
1723 Value *value = rhs.loadValue();
1727 Short::Short(const Reference<Short> &rhs)
1729 Value *value = rhs.loadValue();
1733 RValue<Short> Short::operator=(RValue<Short> rhs) const
1735 storeValue(rhs.value);
1740 RValue<Short> Short::operator=(const Short &rhs) const
1742 Value *value = rhs.loadValue();
1745 return RValue<Short>(value);
1748 RValue<Short> Short::operator=(const Reference<Short> &rhs) const
1750 Value *value = rhs.loadValue();
1753 return RValue<Short>(value);
1756 RValue<Short> operator+(RValue<Short> lhs, RValue<Short> rhs)
1758 return RValue<Short>(Nucleus::createAdd(lhs.value, rhs.value));
1761 RValue<Short> operator-(RValue<Short> lhs, RValue<Short> rhs)
1763 return RValue<Short>(Nucleus::createSub(lhs.value, rhs.value));
1766 RValue<Short> operator*(RValue<Short> lhs, RValue<Short> rhs)
1768 return RValue<Short>(Nucleus::createMul(lhs.value, rhs.value));
1771 RValue<Short> operator/(RValue<Short> lhs, RValue<Short> rhs)
1773 return RValue<Short>(Nucleus::createSDiv(lhs.value, rhs.value));
1776 RValue<Short> operator%(RValue<Short> lhs, RValue<Short> rhs)
1778 return RValue<Short>(Nucleus::createSRem(lhs.value, rhs.value));
1781 RValue<Short> operator&(RValue<Short> lhs, RValue<Short> rhs)
1783 return RValue<Short>(Nucleus::createAnd(lhs.value, rhs.value));
1786 RValue<Short> operator|(RValue<Short> lhs, RValue<Short> rhs)
1788 return RValue<Short>(Nucleus::createOr(lhs.value, rhs.value));
1791 RValue<Short> operator^(RValue<Short> lhs, RValue<Short> rhs)
1793 return RValue<Short>(Nucleus::createXor(lhs.value, rhs.value));
1796 RValue<Short> operator<<(RValue<Short> lhs, RValue<Short> rhs)
1798 return RValue<Short>(Nucleus::createShl(lhs.value, rhs.value));
1801 RValue<Short> operator>>(RValue<Short> lhs, RValue<Short> rhs)
1803 return RValue<Short>(Nucleus::createAShr(lhs.value, rhs.value));
1806 RValue<Short> operator+=(const Short &lhs, RValue<Short> rhs)
1808 return lhs = lhs + rhs;
1811 RValue<Short> operator-=(const Short &lhs, RValue<Short> rhs)
1813 return lhs = lhs - rhs;
1816 RValue<Short> operator*=(const Short &lhs, RValue<Short> rhs)
1818 return lhs = lhs * rhs;
1821 RValue<Short> operator/=(const Short &lhs, RValue<Short> rhs)
1823 return lhs = lhs / rhs;
1826 RValue<Short> operator%=(const Short &lhs, RValue<Short> rhs)
1828 return lhs = lhs % rhs;
1831 RValue<Short> operator&=(const Short &lhs, RValue<Short> rhs)
1833 return lhs = lhs & rhs;
1836 RValue<Short> operator|=(const Short &lhs, RValue<Short> rhs)
1838 return lhs = lhs | rhs;
1841 RValue<Short> operator^=(const Short &lhs, RValue<Short> rhs)
1843 return lhs = lhs ^ rhs;
1846 RValue<Short> operator<<=(const Short &lhs, RValue<Short> rhs)
1848 return lhs = lhs << rhs;
1851 RValue<Short> operator>>=(const Short &lhs, RValue<Short> rhs)
1853 return lhs = lhs >> rhs;
1856 RValue<Short> operator+(RValue<Short> val)
1861 RValue<Short> operator-(RValue<Short> val)
1863 return RValue<Short>(Nucleus::createNeg(val.value));
1866 RValue<Short> operator~(RValue<Short> val)
1868 return RValue<Short>(Nucleus::createNot(val.value));
1871 RValue<Short> operator++(const Short &val, int) // Post-increment
1873 RValue<Short> res = val;
1875 assert(false && "UNIMPLEMENTED");
1876 assert(false && "UNIMPLEMENTED");
1881 const Short &operator++(const Short &val) // Pre-increment
1883 assert(false && "UNIMPLEMENTED");
1884 assert(false && "UNIMPLEMENTED");
1889 RValue<Short> operator--(const Short &val, int) // Post-decrement
1891 RValue<Short> res = val;
1893 assert(false && "UNIMPLEMENTED");
1894 assert(false && "UNIMPLEMENTED");
1899 const Short &operator--(const Short &val) // Pre-decrement
1901 assert(false && "UNIMPLEMENTED");
1902 assert(false && "UNIMPLEMENTED");
1907 RValue<Bool> operator<(RValue<Short> lhs, RValue<Short> rhs)
1909 return RValue<Bool>(Nucleus::createICmpSLT(lhs.value, rhs.value));
1912 RValue<Bool> operator<=(RValue<Short> lhs, RValue<Short> rhs)
1914 return RValue<Bool>(Nucleus::createICmpSLE(lhs.value, rhs.value));
1917 RValue<Bool> operator>(RValue<Short> lhs, RValue<Short> rhs)
1919 return RValue<Bool>(Nucleus::createICmpSGT(lhs.value, rhs.value));
1922 RValue<Bool> operator>=(RValue<Short> lhs, RValue<Short> rhs)
1924 return RValue<Bool>(Nucleus::createICmpSGE(lhs.value, rhs.value));
1927 RValue<Bool> operator!=(RValue<Short> lhs, RValue<Short> rhs)
1929 return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value));
1932 RValue<Bool> operator==(RValue<Short> lhs, RValue<Short> rhs)
1934 return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value));
1937 Type *Short::getType()
1939 assert(false && "UNIMPLEMENTED"); return nullptr;
1942 UShort::UShort(Argument<UShort> argument)
1944 storeValue(argument.value);
1947 UShort::UShort(RValue<UInt> cast)
1949 Value *integer = Nucleus::createTrunc(cast.value, UShort::getType());
1951 storeValue(integer);
1954 UShort::UShort(RValue<Int> cast)
1956 Value *integer = Nucleus::createTrunc(cast.value, UShort::getType());
1958 storeValue(integer);
1965 UShort::UShort(unsigned short x)
1967 storeValue(Nucleus::createConstantShort(x));
1970 UShort::UShort(RValue<UShort> rhs)
1972 storeValue(rhs.value);
1975 UShort::UShort(const UShort &rhs)
1977 Value *value = rhs.loadValue();
1981 UShort::UShort(const Reference<UShort> &rhs)
1983 Value *value = rhs.loadValue();
1987 RValue<UShort> UShort::operator=(RValue<UShort> rhs) const
1989 storeValue(rhs.value);
1994 RValue<UShort> UShort::operator=(const UShort &rhs) const
1996 Value *value = rhs.loadValue();
1999 return RValue<UShort>(value);
2002 RValue<UShort> UShort::operator=(const Reference<UShort> &rhs) const
2004 Value *value = rhs.loadValue();
2007 return RValue<UShort>(value);
2010 RValue<UShort> operator+(RValue<UShort> lhs, RValue<UShort> rhs)
2012 return RValue<UShort>(Nucleus::createAdd(lhs.value, rhs.value));
2015 RValue<UShort> operator-(RValue<UShort> lhs, RValue<UShort> rhs)
2017 return RValue<UShort>(Nucleus::createSub(lhs.value, rhs.value));
2020 RValue<UShort> operator*(RValue<UShort> lhs, RValue<UShort> rhs)
2022 return RValue<UShort>(Nucleus::createMul(lhs.value, rhs.value));
2025 RValue<UShort> operator/(RValue<UShort> lhs, RValue<UShort> rhs)
2027 return RValue<UShort>(Nucleus::createUDiv(lhs.value, rhs.value));
2030 RValue<UShort> operator%(RValue<UShort> lhs, RValue<UShort> rhs)
2032 return RValue<UShort>(Nucleus::createURem(lhs.value, rhs.value));
2035 RValue<UShort> operator&(RValue<UShort> lhs, RValue<UShort> rhs)
2037 return RValue<UShort>(Nucleus::createAnd(lhs.value, rhs.value));
2040 RValue<UShort> operator|(RValue<UShort> lhs, RValue<UShort> rhs)
2042 return RValue<UShort>(Nucleus::createOr(lhs.value, rhs.value));
2045 RValue<UShort> operator^(RValue<UShort> lhs, RValue<UShort> rhs)
2047 return RValue<UShort>(Nucleus::createXor(lhs.value, rhs.value));
2050 RValue<UShort> operator<<(RValue<UShort> lhs, RValue<UShort> rhs)
2052 return RValue<UShort>(Nucleus::createShl(lhs.value, rhs.value));
2055 RValue<UShort> operator>>(RValue<UShort> lhs, RValue<UShort> rhs)
2057 return RValue<UShort>(Nucleus::createLShr(lhs.value, rhs.value));
2060 RValue<UShort> operator+=(const UShort &lhs, RValue<UShort> rhs)
2062 return lhs = lhs + rhs;
2065 RValue<UShort> operator-=(const UShort &lhs, RValue<UShort> rhs)
2067 return lhs = lhs - rhs;
2070 RValue<UShort> operator*=(const UShort &lhs, RValue<UShort> rhs)
2072 return lhs = lhs * rhs;
2075 RValue<UShort> operator/=(const UShort &lhs, RValue<UShort> rhs)
2077 return lhs = lhs / rhs;
2080 RValue<UShort> operator%=(const UShort &lhs, RValue<UShort> rhs)
2082 return lhs = lhs % rhs;
2085 RValue<UShort> operator&=(const UShort &lhs, RValue<UShort> rhs)
2087 return lhs = lhs & rhs;
2090 RValue<UShort> operator|=(const UShort &lhs, RValue<UShort> rhs)
2092 return lhs = lhs | rhs;
2095 RValue<UShort> operator^=(const UShort &lhs, RValue<UShort> rhs)
2097 return lhs = lhs ^ rhs;
2100 RValue<UShort> operator<<=(const UShort &lhs, RValue<UShort> rhs)
2102 return lhs = lhs << rhs;
2105 RValue<UShort> operator>>=(const UShort &lhs, RValue<UShort> rhs)
2107 return lhs = lhs >> rhs;
2110 RValue<UShort> operator+(RValue<UShort> val)
2115 RValue<UShort> operator-(RValue<UShort> val)
2117 return RValue<UShort>(Nucleus::createNeg(val.value));
2120 RValue<UShort> operator~(RValue<UShort> val)
2122 return RValue<UShort>(Nucleus::createNot(val.value));
2125 RValue<UShort> operator++(const UShort &val, int) // Post-increment
2127 RValue<UShort> res = val;
2129 assert(false && "UNIMPLEMENTED");
2130 assert(false && "UNIMPLEMENTED");
2135 const UShort &operator++(const UShort &val) // Pre-increment
2137 assert(false && "UNIMPLEMENTED");
2138 assert(false && "UNIMPLEMENTED");
2143 RValue<UShort> operator--(const UShort &val, int) // Post-decrement
2145 RValue<UShort> res = val;
2147 assert(false && "UNIMPLEMENTED");
2148 assert(false && "UNIMPLEMENTED");
2153 const UShort &operator--(const UShort &val) // Pre-decrement
2155 assert(false && "UNIMPLEMENTED");
2156 assert(false && "UNIMPLEMENTED");
2161 RValue<Bool> operator<(RValue<UShort> lhs, RValue<UShort> rhs)
2163 return RValue<Bool>(Nucleus::createICmpULT(lhs.value, rhs.value));
2166 RValue<Bool> operator<=(RValue<UShort> lhs, RValue<UShort> rhs)
2168 return RValue<Bool>(Nucleus::createICmpULE(lhs.value, rhs.value));
2171 RValue<Bool> operator>(RValue<UShort> lhs, RValue<UShort> rhs)
2173 return RValue<Bool>(Nucleus::createICmpUGT(lhs.value, rhs.value));
2176 RValue<Bool> operator>=(RValue<UShort> lhs, RValue<UShort> rhs)
2178 return RValue<Bool>(Nucleus::createICmpUGE(lhs.value, rhs.value));
2181 RValue<Bool> operator!=(RValue<UShort> lhs, RValue<UShort> rhs)
2183 return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value));
2186 RValue<Bool> operator==(RValue<UShort> lhs, RValue<UShort> rhs)
2188 return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value));
2191 Type *UShort::getType()
2193 assert(false && "UNIMPLEMENTED"); return nullptr;
2196 Byte4::Byte4(RValue<Byte8> cast)
2198 // xyzw.parent = this;
2200 storeValue(Nucleus::createBitCast(cast.value, getType()));
2203 Byte4::Byte4(const Reference<Byte4> &rhs)
2205 // xyzw.parent = this;
2207 assert(false && "UNIMPLEMENTED");
2210 Type *Byte4::getType()
2212 return T(Type_v4i8);
2215 Type *SByte4::getType()
2217 assert(false && "UNIMPLEMENTED"); return nullptr;
2222 // xyzw.parent = this;
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)
2227 // xyzw.parent = this;
2229 assert(false && "UNIMPLEMENTED");
2232 Byte8::Byte8(RValue<Byte8> rhs)
2234 // xyzw.parent = this;
2236 storeValue(rhs.value);
2239 Byte8::Byte8(const Byte8 &rhs)
2241 // xyzw.parent = this;
2243 Value *value = rhs.loadValue();
2247 Byte8::Byte8(const Reference<Byte8> &rhs)
2249 // xyzw.parent = this;
2251 Value *value = rhs.loadValue();
2255 RValue<Byte8> Byte8::operator=(RValue<Byte8> rhs) const
2257 storeValue(rhs.value);
2262 RValue<Byte8> Byte8::operator=(const Byte8 &rhs) const
2264 Value *value = rhs.loadValue();
2267 return RValue<Byte8>(value);
2270 RValue<Byte8> Byte8::operator=(const Reference<Byte8> &rhs) const
2272 Value *value = rhs.loadValue();
2275 return RValue<Byte8>(value);
2278 RValue<Byte8> operator+(RValue<Byte8> lhs, RValue<Byte8> rhs)
2280 assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
2283 RValue<Byte8> operator-(RValue<Byte8> lhs, RValue<Byte8> rhs)
2285 assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
2288 // RValue<Byte8> operator*(RValue<Byte8> lhs, RValue<Byte8> rhs)
2290 // return RValue<Byte8>(Nucleus::createMul(lhs.value, rhs.value));
2293 // RValue<Byte8> operator/(RValue<Byte8> lhs, RValue<Byte8> rhs)
2295 // return RValue<Byte8>(Nucleus::createUDiv(lhs.value, rhs.value));
2298 // RValue<Byte8> operator%(RValue<Byte8> lhs, RValue<Byte8> rhs)
2300 // return RValue<Byte8>(Nucleus::createURem(lhs.value, rhs.value));
2303 RValue<Byte8> operator&(RValue<Byte8> lhs, RValue<Byte8> rhs)
2305 assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
2308 RValue<Byte8> operator|(RValue<Byte8> lhs, RValue<Byte8> rhs)
2310 assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
2313 RValue<Byte8> operator^(RValue<Byte8> lhs, RValue<Byte8> rhs)
2315 assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
2318 // RValue<Byte8> operator<<(RValue<Byte8> lhs, unsigned char rhs)
2320 // return RValue<Byte8>(Nucleus::createShl(lhs.value, rhs.value));
2323 // RValue<Byte8> operator>>(RValue<Byte8> lhs, unsigned char rhs)
2325 // return RValue<Byte8>(Nucleus::createLShr(lhs.value, rhs.value));
2328 RValue<Byte8> operator+=(const Byte8 &lhs, RValue<Byte8> rhs)
2330 return lhs = lhs + rhs;
2333 RValue<Byte8> operator-=(const Byte8 &lhs, RValue<Byte8> rhs)
2335 return lhs = lhs - rhs;
2338 // RValue<Byte8> operator*=(const Byte8 &lhs, RValue<Byte8> rhs)
2340 // return lhs = lhs * rhs;
2343 // RValue<Byte8> operator/=(const Byte8 &lhs, RValue<Byte8> rhs)
2345 // return lhs = lhs / rhs;
2348 // RValue<Byte8> operator%=(const Byte8 &lhs, RValue<Byte8> rhs)
2350 // return lhs = lhs % rhs;
2353 RValue<Byte8> operator&=(const Byte8 &lhs, RValue<Byte8> rhs)
2355 return lhs = lhs & rhs;
2358 RValue<Byte8> operator|=(const Byte8 &lhs, RValue<Byte8> rhs)
2360 return lhs = lhs | rhs;
2363 RValue<Byte8> operator^=(const Byte8 &lhs, RValue<Byte8> rhs)
2365 return lhs = lhs ^ rhs;
2368 // RValue<Byte8> operator<<=(const Byte8 &lhs, RValue<Byte8> rhs)
2370 // return lhs = lhs << rhs;
2373 // RValue<Byte8> operator>>=(const Byte8 &lhs, RValue<Byte8> rhs)
2375 // return lhs = lhs >> rhs;
2378 // RValue<Byte8> operator+(RValue<Byte8> val)
2383 // RValue<Byte8> operator-(RValue<Byte8> val)
2385 // return RValue<Byte8>(Nucleus::createNeg(val.value));
2388 RValue<Byte8> operator~(RValue<Byte8> val)
2390 return RValue<Byte8>(Nucleus::createNot(val.value));
2393 RValue<Byte8> AddSat(RValue<Byte8> x, RValue<Byte8> y)
2395 assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
2398 RValue<Byte8> SubSat(RValue<Byte8> x, RValue<Byte8> y)
2400 assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
2403 RValue<Short4> Unpack(RValue<Byte4> x)
2405 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
2408 RValue<Short4> UnpackLow(RValue<Byte8> x, RValue<Byte8> y)
2410 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
2413 RValue<Short4> UnpackHigh(RValue<Byte8> x, RValue<Byte8> y)
2415 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
2418 RValue<Int> SignMask(RValue<Byte8> x)
2420 assert(false && "UNIMPLEMENTED"); return RValue<Int>(V(nullptr));
2423 // RValue<Byte8> CmpGT(RValue<Byte8> x, RValue<Byte8> y)
2425 // assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
2428 RValue<Byte8> CmpEQ(RValue<Byte8> x, RValue<Byte8> y)
2430 assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
2433 Type *Byte8::getType()
2435 return T(Type_v8i8);
2440 // xyzw.parent = this;
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)
2445 // xyzw.parent = this;
2447 assert(false && "UNIMPLEMENTED");
2450 SByte8::SByte8(RValue<SByte8> rhs)
2452 // xyzw.parent = this;
2454 storeValue(rhs.value);
2457 SByte8::SByte8(const SByte8 &rhs)
2459 // xyzw.parent = this;
2461 Value *value = rhs.loadValue();
2465 SByte8::SByte8(const Reference<SByte8> &rhs)
2467 // xyzw.parent = this;
2469 Value *value = rhs.loadValue();
2473 RValue<SByte8> SByte8::operator=(RValue<SByte8> rhs) const
2475 storeValue(rhs.value);
2480 RValue<SByte8> SByte8::operator=(const SByte8 &rhs) const
2482 Value *value = rhs.loadValue();
2485 return RValue<SByte8>(value);
2488 RValue<SByte8> SByte8::operator=(const Reference<SByte8> &rhs) const
2490 Value *value = rhs.loadValue();
2493 return RValue<SByte8>(value);
2496 RValue<SByte8> operator+(RValue<SByte8> lhs, RValue<SByte8> rhs)
2498 assert(false && "UNIMPLEMENTED"); return RValue<SByte8>(V(nullptr));
2501 RValue<SByte8> operator-(RValue<SByte8> lhs, RValue<SByte8> rhs)
2503 assert(false && "UNIMPLEMENTED"); return RValue<SByte8>(V(nullptr));
2506 // RValue<SByte8> operator*(RValue<SByte8> lhs, RValue<SByte8> rhs)
2508 // return RValue<SByte8>(Nucleus::createMul(lhs.value, rhs.value));
2511 // RValue<SByte8> operator/(RValue<SByte8> lhs, RValue<SByte8> rhs)
2513 // return RValue<SByte8>(Nucleus::createSDiv(lhs.value, rhs.value));
2516 // RValue<SByte8> operator%(RValue<SByte8> lhs, RValue<SByte8> rhs)
2518 // return RValue<SByte8>(Nucleus::createSRem(lhs.value, rhs.value));
2521 RValue<SByte8> operator&(RValue<SByte8> lhs, RValue<SByte8> rhs)
2523 return RValue<SByte8>(Nucleus::createAnd(lhs.value, rhs.value));
2526 RValue<SByte8> operator|(RValue<SByte8> lhs, RValue<SByte8> rhs)
2528 return RValue<SByte8>(Nucleus::createOr(lhs.value, rhs.value));
2531 RValue<SByte8> operator^(RValue<SByte8> lhs, RValue<SByte8> rhs)
2533 return RValue<SByte8>(Nucleus::createXor(lhs.value, rhs.value));
2536 // RValue<SByte8> operator<<(RValue<SByte8> lhs, unsigned char rhs)
2538 // return RValue<SByte8>(Nucleus::createShl(lhs.value, rhs.value));
2541 // RValue<SByte8> operator>>(RValue<SByte8> lhs, unsigned char rhs)
2543 // return RValue<SByte8>(Nucleus::createAShr(lhs.value, rhs.value));
2546 RValue<SByte8> operator+=(const SByte8 &lhs, RValue<SByte8> rhs)
2548 return lhs = lhs + rhs;
2551 RValue<SByte8> operator-=(const SByte8 &lhs, RValue<SByte8> rhs)
2553 return lhs = lhs - rhs;
2556 // RValue<SByte8> operator*=(const SByte8 &lhs, RValue<SByte8> rhs)
2558 // return lhs = lhs * rhs;
2561 // RValue<SByte8> operator/=(const SByte8 &lhs, RValue<SByte8> rhs)
2563 // return lhs = lhs / rhs;
2566 // RValue<SByte8> operator%=(const SByte8 &lhs, RValue<SByte8> rhs)
2568 // return lhs = lhs % rhs;
2571 RValue<SByte8> operator&=(const SByte8 &lhs, RValue<SByte8> rhs)
2573 return lhs = lhs & rhs;
2576 RValue<SByte8> operator|=(const SByte8 &lhs, RValue<SByte8> rhs)
2578 return lhs = lhs | rhs;
2581 RValue<SByte8> operator^=(const SByte8 &lhs, RValue<SByte8> rhs)
2583 return lhs = lhs ^ rhs;
2586 // RValue<SByte8> operator<<=(const SByte8 &lhs, RValue<SByte8> rhs)
2588 // return lhs = lhs << rhs;
2591 // RValue<SByte8> operator>>=(const SByte8 &lhs, RValue<SByte8> rhs)
2593 // return lhs = lhs >> rhs;
2596 // RValue<SByte8> operator+(RValue<SByte8> val)
2601 // RValue<SByte8> operator-(RValue<SByte8> val)
2603 // return RValue<SByte8>(Nucleus::createNeg(val.value));
2606 RValue<SByte8> operator~(RValue<SByte8> val)
2608 return RValue<SByte8>(Nucleus::createNot(val.value));
2611 RValue<SByte8> AddSat(RValue<SByte8> x, RValue<SByte8> y)
2613 assert(false && "UNIMPLEMENTED"); return RValue<SByte8>(V(nullptr));
2616 RValue<SByte8> SubSat(RValue<SByte8> x, RValue<SByte8> y)
2618 assert(false && "UNIMPLEMENTED"); return RValue<SByte8>(V(nullptr));
2621 RValue<Short4> UnpackLow(RValue<SByte8> x, RValue<SByte8> y)
2623 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
2626 RValue<Short4> UnpackHigh(RValue<SByte8> x, RValue<SByte8> y)
2628 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
2631 RValue<Int> SignMask(RValue<SByte8> x)
2633 assert(false && "UNIMPLEMENTED"); return RValue<Int>(V(nullptr));
2636 RValue<Byte8> CmpGT(RValue<SByte8> x, RValue<SByte8> y)
2638 assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
2641 RValue<Byte8> CmpEQ(RValue<SByte8> x, RValue<SByte8> y)
2643 assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
2646 Type *SByte8::getType()
2648 assert(false && "UNIMPLEMENTED"); return nullptr;
2651 Byte16::Byte16(RValue<Byte16> rhs)
2653 // xyzw.parent = this;
2655 storeValue(rhs.value);
2658 Byte16::Byte16(const Byte16 &rhs)
2660 // xyzw.parent = this;
2662 Value *value = rhs.loadValue();
2666 Byte16::Byte16(const Reference<Byte16> &rhs)
2668 // xyzw.parent = this;
2670 Value *value = rhs.loadValue();
2674 RValue<Byte16> Byte16::operator=(RValue<Byte16> rhs) const
2676 storeValue(rhs.value);
2681 RValue<Byte16> Byte16::operator=(const Byte16 &rhs) const
2683 Value *value = rhs.loadValue();
2686 return RValue<Byte16>(value);
2689 RValue<Byte16> Byte16::operator=(const Reference<Byte16> &rhs) const
2691 Value *value = rhs.loadValue();
2694 return RValue<Byte16>(value);
2697 Type *Byte16::getType()
2699 return T(Ice::IceType_v16i8);
2702 Type *SByte16::getType()
2704 return T(Ice::IceType_v16i8);
2707 Short2::Short2(RValue<Short4> cast)
2709 assert(false && "UNIMPLEMENTED");
2712 Type *Short2::getType()
2714 return T(Type_v2i16);
2717 UShort2::UShort2(RValue<UShort4> cast)
2719 assert(false && "UNIMPLEMENTED");
2722 Type *UShort2::getType()
2724 return T(Type_v2i16);
2727 Short4::Short4(RValue<Int> cast)
2729 Value *extend = Nucleus::createZExt(cast.value, Long::getType());
2730 Value *swizzle = Swizzle(RValue<Short4>(extend), 0x00).value;
2732 storeValue(swizzle);
2735 Short4::Short4(RValue<Int4> cast)
2737 assert(false && "UNIMPLEMENTED");
2740 // Short4::Short4(RValue<Float> cast)
2744 Short4::Short4(RValue<Float4> cast)
2746 assert(false && "UNIMPLEMENTED");
2751 // xyzw.parent = this;
2754 Short4::Short4(short xyzw)
2756 // xyzw.parent = this;
2758 assert(false && "UNIMPLEMENTED");
2761 Short4::Short4(short x, short y, short z, short w)
2763 // xyzw.parent = this;
2765 assert(false && "UNIMPLEMENTED");
2768 Short4::Short4(RValue<Short4> rhs)
2770 // xyzw.parent = this;
2772 storeValue(rhs.value);
2775 Short4::Short4(const Short4 &rhs)
2777 // xyzw.parent = this;
2779 Value *value = rhs.loadValue();
2783 Short4::Short4(const Reference<Short4> &rhs)
2785 // xyzw.parent = this;
2787 Value *value = rhs.loadValue();
2791 Short4::Short4(RValue<UShort4> rhs)
2793 // xyzw.parent = this;
2795 storeValue(rhs.value);
2798 Short4::Short4(const UShort4 &rhs)
2800 // xyzw.parent = this;
2802 storeValue(rhs.loadValue());
2805 Short4::Short4(const Reference<UShort4> &rhs)
2807 // xyzw.parent = this;
2809 storeValue(rhs.loadValue());
2812 RValue<Short4> Short4::operator=(RValue<Short4> rhs) const
2814 storeValue(rhs.value);
2819 RValue<Short4> Short4::operator=(const Short4 &rhs) const
2821 Value *value = rhs.loadValue();
2824 return RValue<Short4>(value);
2827 RValue<Short4> Short4::operator=(const Reference<Short4> &rhs) const
2829 Value *value = rhs.loadValue();
2832 return RValue<Short4>(value);
2835 RValue<Short4> Short4::operator=(RValue<UShort4> rhs) const
2837 storeValue(rhs.value);
2839 return RValue<Short4>(rhs);
2842 RValue<Short4> Short4::operator=(const UShort4 &rhs) const
2844 Value *value = rhs.loadValue();
2847 return RValue<Short4>(value);
2850 RValue<Short4> Short4::operator=(const Reference<UShort4> &rhs) const
2852 Value *value = rhs.loadValue();
2855 return RValue<Short4>(value);
2858 RValue<Short4> operator+(RValue<Short4> lhs, RValue<Short4> rhs)
2860 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
2863 RValue<Short4> operator-(RValue<Short4> lhs, RValue<Short4> rhs)
2865 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
2868 RValue<Short4> operator*(RValue<Short4> lhs, RValue<Short4> rhs)
2870 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
2873 // RValue<Short4> operator/(RValue<Short4> lhs, RValue<Short4> rhs)
2875 // return RValue<Short4>(Nucleus::createSDiv(lhs.value, rhs.value));
2878 // RValue<Short4> operator%(RValue<Short4> lhs, RValue<Short4> rhs)
2880 // return RValue<Short4>(Nucleus::createSRem(lhs.value, rhs.value));
2883 RValue<Short4> operator&(RValue<Short4> lhs, RValue<Short4> rhs)
2885 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
2888 RValue<Short4> operator|(RValue<Short4> lhs, RValue<Short4> rhs)
2890 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
2893 RValue<Short4> operator^(RValue<Short4> lhs, RValue<Short4> rhs)
2895 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
2898 RValue<Short4> operator<<(RValue<Short4> lhs, unsigned char rhs)
2900 // return RValue<Short4>(Nucleus::createShl(lhs.value, rhs.value));
2902 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
2905 RValue<Short4> operator>>(RValue<Short4> lhs, unsigned char rhs)
2907 // return RValue<Short4>(Nucleus::createAShr(lhs.value, rhs.value));
2909 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
2912 RValue<Short4> operator<<(RValue<Short4> lhs, RValue<Long1> rhs)
2914 // return RValue<Short4>(Nucleus::createShl(lhs.value, rhs.value));
2916 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
2919 RValue<Short4> operator>>(RValue<Short4> lhs, RValue<Long1> rhs)
2921 // return RValue<Short4>(Nucleus::createAShr(lhs.value, rhs.value));
2923 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
2926 RValue<Short4> operator+=(const Short4 &lhs, RValue<Short4> rhs)
2928 return lhs = lhs + rhs;
2931 RValue<Short4> operator-=(const Short4 &lhs, RValue<Short4> rhs)
2933 return lhs = lhs - rhs;
2936 RValue<Short4> operator*=(const Short4 &lhs, RValue<Short4> rhs)
2938 return lhs = lhs * rhs;
2941 // RValue<Short4> operator/=(const Short4 &lhs, RValue<Short4> rhs)
2943 // return lhs = lhs / rhs;
2946 // RValue<Short4> operator%=(const Short4 &lhs, RValue<Short4> rhs)
2948 // return lhs = lhs % rhs;
2951 RValue<Short4> operator&=(const Short4 &lhs, RValue<Short4> rhs)
2953 return lhs = lhs & rhs;
2956 RValue<Short4> operator|=(const Short4 &lhs, RValue<Short4> rhs)
2958 return lhs = lhs | rhs;
2961 RValue<Short4> operator^=(const Short4 &lhs, RValue<Short4> rhs)
2963 return lhs = lhs ^ rhs;
2966 RValue<Short4> operator<<=(const Short4 &lhs, unsigned char rhs)
2968 return lhs = lhs << rhs;
2971 RValue<Short4> operator>>=(const Short4 &lhs, unsigned char rhs)
2973 return lhs = lhs >> rhs;
2976 RValue<Short4> operator<<=(const Short4 &lhs, RValue<Long1> rhs)
2978 return lhs = lhs << rhs;
2981 RValue<Short4> operator>>=(const Short4 &lhs, RValue<Long1> rhs)
2983 return lhs = lhs >> rhs;
2986 // RValue<Short4> operator+(RValue<Short4> val)
2991 RValue<Short4> operator-(RValue<Short4> val)
2993 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
2996 RValue<Short4> operator~(RValue<Short4> val)
2998 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
3001 RValue<Short4> RoundShort4(RValue<Float4> cast)
3003 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
3006 RValue<Short4> Max(RValue<Short4> x, RValue<Short4> y)
3008 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
3011 RValue<Short4> Min(RValue<Short4> x, RValue<Short4> y)
3013 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
3016 RValue<Short4> AddSat(RValue<Short4> x, RValue<Short4> y)
3018 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
3021 RValue<Short4> SubSat(RValue<Short4> x, RValue<Short4> y)
3023 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
3026 RValue<Short4> MulHigh(RValue<Short4> x, RValue<Short4> y)
3028 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
3031 RValue<Int2> MulAdd(RValue<Short4> x, RValue<Short4> y)
3033 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
3036 RValue<SByte8> Pack(RValue<Short4> x, RValue<Short4> y)
3038 assert(false && "UNIMPLEMENTED"); return RValue<SByte8>(V(nullptr));
3041 RValue<Int2> UnpackLow(RValue<Short4> x, RValue<Short4> y)
3043 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
3046 RValue<Int2> UnpackHigh(RValue<Short4> x, RValue<Short4> y)
3048 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
3051 RValue<Short4> Swizzle(RValue<Short4> x, unsigned char select)
3053 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
3056 RValue<Short4> Insert(RValue<Short4> val, RValue<Short> element, int i)
3058 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
3061 RValue<Short> Extract(RValue<Short4> val, int i)
3063 assert(false && "UNIMPLEMENTED"); return RValue<Short>(V(nullptr));
3066 RValue<Short4> CmpGT(RValue<Short4> x, RValue<Short4> y)
3068 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
3071 RValue<Short4> CmpEQ(RValue<Short4> x, RValue<Short4> y)
3073 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
3076 Type *Short4::getType()
3078 return T(Type_v4i16);
3081 UShort4::UShort4(RValue<Int4> cast)
3083 *this = Short4(cast);
3086 UShort4::UShort4(RValue<Float4> cast, bool saturate)
3088 assert(false && "UNIMPLEMENTED");
3093 // xyzw.parent = this;
3096 UShort4::UShort4(unsigned short xyzw)
3098 // xyzw.parent = this;
3100 assert(false && "UNIMPLEMENTED");
3103 UShort4::UShort4(unsigned short x, unsigned short y, unsigned short z, unsigned short w)
3105 // xyzw.parent = this;
3107 assert(false && "UNIMPLEMENTED");
3110 UShort4::UShort4(RValue<UShort4> rhs)
3112 // xyzw.parent = this;
3114 storeValue(rhs.value);
3117 UShort4::UShort4(const UShort4 &rhs)
3119 // xyzw.parent = this;
3121 Value *value = rhs.loadValue();
3125 UShort4::UShort4(const Reference<UShort4> &rhs)
3127 // xyzw.parent = this;
3129 Value *value = rhs.loadValue();
3133 UShort4::UShort4(RValue<Short4> rhs)
3135 // xyzw.parent = this;
3137 storeValue(rhs.value);
3140 UShort4::UShort4(const Short4 &rhs)
3142 // xyzw.parent = this;
3144 Value *value = rhs.loadValue();
3148 UShort4::UShort4(const Reference<Short4> &rhs)
3150 // xyzw.parent = this;
3152 Value *value = rhs.loadValue();
3156 RValue<UShort4> UShort4::operator=(RValue<UShort4> rhs) const
3158 storeValue(rhs.value);
3163 RValue<UShort4> UShort4::operator=(const UShort4 &rhs) const
3165 Value *value = rhs.loadValue();
3168 return RValue<UShort4>(value);
3171 RValue<UShort4> UShort4::operator=(const Reference<UShort4> &rhs) const
3173 Value *value = rhs.loadValue();
3176 return RValue<UShort4>(value);
3179 RValue<UShort4> UShort4::operator=(RValue<Short4> rhs) const
3181 storeValue(rhs.value);
3183 return RValue<UShort4>(rhs);
3186 RValue<UShort4> UShort4::operator=(const Short4 &rhs) const
3188 Value *value = rhs.loadValue();
3191 return RValue<UShort4>(value);
3194 RValue<UShort4> UShort4::operator=(const Reference<Short4> &rhs) const
3196 Value *value = rhs.loadValue();
3199 return RValue<UShort4>(value);
3202 RValue<UShort4> operator+(RValue<UShort4> lhs, RValue<UShort4> rhs)
3204 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3207 RValue<UShort4> operator-(RValue<UShort4> lhs, RValue<UShort4> rhs)
3209 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3212 RValue<UShort4> operator*(RValue<UShort4> lhs, RValue<UShort4> rhs)
3214 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3217 RValue<UShort4> operator&(RValue<UShort4> lhs, RValue<UShort4> rhs)
3219 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3222 RValue<UShort4> operator|(RValue<UShort4> lhs, RValue<UShort4> rhs)
3224 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3227 RValue<UShort4> operator^(RValue<UShort4> lhs, RValue<UShort4> rhs)
3229 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3232 RValue<UShort4> operator<<(RValue<UShort4> lhs, unsigned char rhs)
3234 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3237 RValue<UShort4> operator>>(RValue<UShort4> lhs, unsigned char rhs)
3239 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3242 RValue<UShort4> operator<<(RValue<UShort4> lhs, RValue<Long1> rhs)
3244 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3247 RValue<UShort4> operator>>(RValue<UShort4> lhs, RValue<Long1> rhs)
3249 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3252 RValue<UShort4> operator<<=(const UShort4 &lhs, unsigned char rhs)
3254 return lhs = lhs << rhs;
3257 RValue<UShort4> operator>>=(const UShort4 &lhs, unsigned char rhs)
3259 return lhs = lhs >> rhs;
3262 RValue<UShort4> operator<<=(const UShort4 &lhs, RValue<Long1> rhs)
3264 return lhs = lhs << rhs;
3267 RValue<UShort4> operator>>=(const UShort4 &lhs, RValue<Long1> rhs)
3269 return lhs = lhs >> rhs;
3272 RValue<UShort4> operator~(RValue<UShort4> val)
3274 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3277 RValue<UShort4> Max(RValue<UShort4> x, RValue<UShort4> y)
3279 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3282 RValue<UShort4> Min(RValue<UShort4> x, RValue<UShort4> y)
3284 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3287 RValue<UShort4> AddSat(RValue<UShort4> x, RValue<UShort4> y)
3289 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3292 RValue<UShort4> SubSat(RValue<UShort4> x, RValue<UShort4> y)
3294 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3297 RValue<UShort4> MulHigh(RValue<UShort4> x, RValue<UShort4> y)
3299 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3302 RValue<UShort4> Average(RValue<UShort4> x, RValue<UShort4> y)
3304 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3307 RValue<Byte8> Pack(RValue<UShort4> x, RValue<UShort4> y)
3309 assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
3312 Type *UShort4::getType()
3314 return T(Type_v4i16);
3317 Short8::Short8(short c0, short c1, short c2, short c3, short c4, short c5, short c6, short c7)
3319 // xyzw.parent = this;
3321 assert(false && "UNIMPLEMENTED");
3324 Short8::Short8(RValue<Short8> rhs)
3326 // xyzw.parent = this;
3328 storeValue(rhs.value);
3331 Short8::Short8(const Reference<Short8> &rhs)
3333 // xyzw.parent = this;
3335 Value *value = rhs.loadValue();
3339 Short8::Short8(RValue<Short4> lo, RValue<Short4> hi)
3341 assert(false && "UNIMPLEMENTED");
3344 RValue<Short8> operator+(RValue<Short8> lhs, RValue<Short8> rhs)
3346 return RValue<Short8>(Nucleus::createAdd(lhs.value, rhs.value));
3349 RValue<Short8> operator&(RValue<Short8> lhs, RValue<Short8> rhs)
3351 return RValue<Short8>(Nucleus::createAnd(lhs.value, rhs.value));
3354 RValue<Short8> operator<<(RValue<Short8> lhs, unsigned char rhs)
3356 assert(false && "UNIMPLEMENTED"); return RValue<Short8>(V(nullptr));
3359 RValue<Short8> operator>>(RValue<Short8> lhs, unsigned char rhs)
3361 assert(false && "UNIMPLEMENTED"); return RValue<Short8>(V(nullptr));
3364 RValue<Int4> MulAdd(RValue<Short8> x, RValue<Short8> y)
3366 assert(false && "UNIMPLEMENTED"); return RValue<Int4>(V(nullptr));
3369 RValue<Int4> Abs(RValue<Int4> x)
3371 assert(false && "UNIMPLEMENTED"); return RValue<Int4>(V(nullptr));
3374 RValue<Short8> MulHigh(RValue<Short8> x, RValue<Short8> y)
3376 assert(false && "UNIMPLEMENTED"); return RValue<Short8>(V(nullptr));
3379 Type *Short8::getType()
3381 assert(false && "UNIMPLEMENTED"); return nullptr;
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)
3386 // xyzw.parent = this;
3388 assert(false && "UNIMPLEMENTED");
3391 UShort8::UShort8(RValue<UShort8> rhs)
3393 // xyzw.parent = this;
3395 storeValue(rhs.value);
3398 UShort8::UShort8(const Reference<UShort8> &rhs)
3400 // xyzw.parent = this;
3402 Value *value = rhs.loadValue();
3406 UShort8::UShort8(RValue<UShort4> lo, RValue<UShort4> hi)
3408 assert(false && "UNIMPLEMENTED");
3411 RValue<UShort8> UShort8::operator=(RValue<UShort8> rhs) const
3413 storeValue(rhs.value);
3418 RValue<UShort8> UShort8::operator=(const UShort8 &rhs) const
3420 Value *value = rhs.loadValue();
3423 return RValue<UShort8>(value);
3426 RValue<UShort8> UShort8::operator=(const Reference<UShort8> &rhs) const
3428 Value *value = rhs.loadValue();
3431 return RValue<UShort8>(value);
3434 RValue<UShort8> operator&(RValue<UShort8> lhs, RValue<UShort8> rhs)
3436 return RValue<UShort8>(Nucleus::createAnd(lhs.value, rhs.value));
3439 RValue<UShort8> operator<<(RValue<UShort8> lhs, unsigned char rhs)
3441 assert(false && "UNIMPLEMENTED"); return RValue<UShort8>(V(nullptr));
3444 RValue<UShort8> operator>>(RValue<UShort8> lhs, unsigned char rhs)
3446 assert(false && "UNIMPLEMENTED"); return RValue<UShort8>(V(nullptr));
3449 RValue<UShort8> operator+(RValue<UShort8> lhs, RValue<UShort8> rhs)
3451 return RValue<UShort8>(Nucleus::createAdd(lhs.value, rhs.value));
3454 RValue<UShort8> operator*(RValue<UShort8> lhs, RValue<UShort8> rhs)
3456 return RValue<UShort8>(Nucleus::createMul(lhs.value, rhs.value));
3459 RValue<UShort8> operator+=(const UShort8 &lhs, RValue<UShort8> rhs)
3461 return lhs = lhs + rhs;
3464 RValue<UShort8> operator~(RValue<UShort8> val)
3466 return RValue<UShort8>(Nucleus::createNot(val.value));
3469 RValue<UShort8> Swizzle(RValue<UShort8> x, char select0, char select1, char select2, char select3, char select4, char select5, char select6, char select7)
3471 assert(false && "UNIMPLEMENTED"); return RValue<UShort8>(V(nullptr));
3474 RValue<UShort8> MulHigh(RValue<UShort8> x, RValue<UShort8> y)
3476 assert(false && "UNIMPLEMENTED"); return RValue<UShort8>(V(nullptr));
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)
3482 // assert(false && "UNIMPLEMENTED"); return RValue<UShort8>(V(nullptr));
3485 Type *UShort8::getType()
3487 assert(false && "UNIMPLEMENTED"); return nullptr;
3490 Int::Int(Argument<Int> argument)
3492 storeValue(argument.value);
3495 Int::Int(RValue<Byte> cast)
3497 Value *integer = Nucleus::createZExt(cast.value, Int::getType());
3499 storeValue(integer);
3502 Int::Int(RValue<SByte> cast)
3504 Value *integer = Nucleus::createSExt(cast.value, Int::getType());
3506 storeValue(integer);
3509 Int::Int(RValue<Short> cast)
3511 Value *integer = Nucleus::createSExt(cast.value, Int::getType());
3513 storeValue(integer);
3516 Int::Int(RValue<UShort> cast)
3518 Value *integer = Nucleus::createZExt(cast.value, Int::getType());
3520 storeValue(integer);
3523 Int::Int(RValue<Int2> cast)
3525 *this = Extract(cast, 0);
3528 Int::Int(RValue<Long> cast)
3530 Value *integer = Nucleus::createTrunc(cast.value, Int::getType());
3532 storeValue(integer);
3535 Int::Int(RValue<Float> cast)
3537 Value *integer = Nucleus::createFPToSI(cast.value, Int::getType());
3539 storeValue(integer);
3548 storeValue(Nucleus::createConstantInt(x));
3551 Int::Int(RValue<Int> rhs)
3553 storeValue(rhs.value);
3556 Int::Int(RValue<UInt> rhs)
3558 storeValue(rhs.value);
3561 Int::Int(const Int &rhs)
3563 Value *value = rhs.loadValue();
3567 Int::Int(const Reference<Int> &rhs)
3569 Value *value = rhs.loadValue();
3573 Int::Int(const UInt &rhs)
3575 Value *value = rhs.loadValue();
3579 Int::Int(const Reference<UInt> &rhs)
3581 Value *value = rhs.loadValue();
3585 RValue<Int> Int::operator=(int rhs) const
3587 return RValue<Int>(storeValue(Nucleus::createConstantInt(rhs)));
3590 RValue<Int> Int::operator=(RValue<Int> rhs) const
3592 storeValue(rhs.value);
3597 RValue<Int> Int::operator=(RValue<UInt> rhs) const
3599 storeValue(rhs.value);
3601 return RValue<Int>(rhs);
3604 RValue<Int> Int::operator=(const Int &rhs) const
3606 Value *value = rhs.loadValue();
3609 return RValue<Int>(value);
3612 RValue<Int> Int::operator=(const Reference<Int> &rhs) const
3614 Value *value = rhs.loadValue();
3617 return RValue<Int>(value);
3620 RValue<Int> Int::operator=(const UInt &rhs) const
3622 Value *value = rhs.loadValue();
3625 return RValue<Int>(value);
3628 RValue<Int> Int::operator=(const Reference<UInt> &rhs) const
3630 Value *value = rhs.loadValue();
3633 return RValue<Int>(value);
3636 RValue<Int> operator+(RValue<Int> lhs, RValue<Int> rhs)
3638 return RValue<Int>(Nucleus::createAdd(lhs.value, rhs.value));
3641 RValue<Int> operator-(RValue<Int> lhs, RValue<Int> rhs)
3643 return RValue<Int>(Nucleus::createSub(lhs.value, rhs.value));
3646 RValue<Int> operator*(RValue<Int> lhs, RValue<Int> rhs)
3648 return RValue<Int>(Nucleus::createMul(lhs.value, rhs.value));
3651 RValue<Int> operator/(RValue<Int> lhs, RValue<Int> rhs)
3653 return RValue<Int>(Nucleus::createSDiv(lhs.value, rhs.value));
3656 RValue<Int> operator%(RValue<Int> lhs, RValue<Int> rhs)
3658 return RValue<Int>(Nucleus::createSRem(lhs.value, rhs.value));
3661 RValue<Int> operator&(RValue<Int> lhs, RValue<Int> rhs)
3663 return RValue<Int>(Nucleus::createAnd(lhs.value, rhs.value));
3666 RValue<Int> operator|(RValue<Int> lhs, RValue<Int> rhs)
3668 return RValue<Int>(Nucleus::createOr(lhs.value, rhs.value));
3671 RValue<Int> operator^(RValue<Int> lhs, RValue<Int> rhs)
3673 return RValue<Int>(Nucleus::createXor(lhs.value, rhs.value));
3676 RValue<Int> operator<<(RValue<Int> lhs, RValue<Int> rhs)
3678 return RValue<Int>(Nucleus::createShl(lhs.value, rhs.value));
3681 RValue<Int> operator>>(RValue<Int> lhs, RValue<Int> rhs)
3683 return RValue<Int>(Nucleus::createAShr(lhs.value, rhs.value));
3686 RValue<Int> operator+=(const Int &lhs, RValue<Int> rhs)
3688 return lhs = lhs + rhs;
3691 RValue<Int> operator-=(const Int &lhs, RValue<Int> rhs)
3693 return lhs = lhs - rhs;
3696 RValue<Int> operator*=(const Int &lhs, RValue<Int> rhs)
3698 return lhs = lhs * rhs;
3701 RValue<Int> operator/=(const Int &lhs, RValue<Int> rhs)
3703 return lhs = lhs / rhs;
3706 RValue<Int> operator%=(const Int &lhs, RValue<Int> rhs)
3708 return lhs = lhs % rhs;
3711 RValue<Int> operator&=(const Int &lhs, RValue<Int> rhs)
3713 return lhs = lhs & rhs;
3716 RValue<Int> operator|=(const Int &lhs, RValue<Int> rhs)
3718 return lhs = lhs | rhs;
3721 RValue<Int> operator^=(const Int &lhs, RValue<Int> rhs)
3723 return lhs = lhs ^ rhs;
3726 RValue<Int> operator<<=(const Int &lhs, RValue<Int> rhs)
3728 return lhs = lhs << rhs;
3731 RValue<Int> operator>>=(const Int &lhs, RValue<Int> rhs)
3733 return lhs = lhs >> rhs;
3736 RValue<Int> operator+(RValue<Int> val)
3741 RValue<Int> operator-(RValue<Int> val)
3743 return RValue<Int>(Nucleus::createNeg(val.value));
3746 RValue<Int> operator~(RValue<Int> val)
3748 return RValue<Int>(Nucleus::createNot(val.value));
3751 RValue<Int> operator++(const Int &val, int) // Post-increment
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));
3759 return RValue<Int>(oldValue);
3762 const Int &operator++(const Int &val) // Pre-increment
3764 assert(false && "UNIMPLEMENTED"); return val;
3767 RValue<Int> operator--(const Int &val, int) // Post-decrement
3769 assert(false && "UNIMPLEMENTED"); return RValue<Int>(V(nullptr));
3772 const Int &operator--(const Int &val) // Pre-decrement
3774 assert(false && "UNIMPLEMENTED"); return val;
3777 RValue<Bool> operator<(RValue<Int> lhs, RValue<Int> rhs)
3779 return RValue<Bool>(Nucleus::createICmpSLT(lhs.value, rhs.value));
3782 RValue<Bool> operator<=(RValue<Int> lhs, RValue<Int> rhs)
3784 return RValue<Bool>(Nucleus::createICmpSLE(lhs.value, rhs.value));
3787 RValue<Bool> operator>(RValue<Int> lhs, RValue<Int> rhs)
3789 return RValue<Bool>(Nucleus::createICmpSGT(lhs.value, rhs.value));
3792 RValue<Bool> operator>=(RValue<Int> lhs, RValue<Int> rhs)
3794 return RValue<Bool>(Nucleus::createICmpSGE(lhs.value, rhs.value));
3797 RValue<Bool> operator!=(RValue<Int> lhs, RValue<Int> rhs)
3799 return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value));
3802 RValue<Bool> operator==(RValue<Int> lhs, RValue<Int> rhs)
3804 return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value));
3807 RValue<Int> Max(RValue<Int> x, RValue<Int> y)
3809 return IfThenElse(x > y, x, y);
3812 RValue<Int> Min(RValue<Int> x, RValue<Int> y)
3814 return IfThenElse(x < y, x, y);
3817 RValue<Int> Clamp(RValue<Int> x, RValue<Int> min, RValue<Int> max)
3819 return Min(Max(x, min), max);
3822 RValue<Int> RoundInt(RValue<Float> cast)
3824 assert(false && "UNIMPLEMENTED"); return RValue<Int>(V(nullptr));
3827 Type *Int::getType()
3829 return T(Ice::IceType_i32);
3832 Long::Long(RValue<Int> cast)
3834 Value *integer = Nucleus::createSExt(cast.value, Long::getType());
3836 storeValue(integer);
3839 Long::Long(RValue<UInt> cast)
3841 Value *integer = Nucleus::createZExt(cast.value, Long::getType());
3843 storeValue(integer);
3850 Long::Long(RValue<Long> rhs)
3852 storeValue(rhs.value);
3855 RValue<Long> Long::operator=(int64_t rhs) const
3857 return RValue<Long>(storeValue(Nucleus::createConstantLong(rhs)));
3860 RValue<Long> Long::operator=(RValue<Long> rhs) const
3862 storeValue(rhs.value);
3867 RValue<Long> Long::operator=(const Long &rhs) const
3869 Value *value = rhs.loadValue();
3872 return RValue<Long>(value);
3875 RValue<Long> Long::operator=(const Reference<Long> &rhs) const
3877 Value *value = rhs.loadValue();
3880 return RValue<Long>(value);
3883 RValue<Long> operator+(RValue<Long> lhs, RValue<Long> rhs)
3885 return RValue<Long>(Nucleus::createAdd(lhs.value, rhs.value));
3888 RValue<Long> operator-(RValue<Long> lhs, RValue<Long> rhs)
3890 return RValue<Long>(Nucleus::createSub(lhs.value, rhs.value));
3893 RValue<Long> operator+=(const Long &lhs, RValue<Long> rhs)
3895 return lhs = lhs + rhs;
3898 RValue<Long> operator-=(const Long &lhs, RValue<Long> rhs)
3900 return lhs = lhs - rhs;
3903 RValue<Long> AddAtomic(RValue<Pointer<Long> > x, RValue<Long> y)
3905 return RValue<Long>(Nucleus::createAtomicAdd(x.value, y.value));
3908 Type *Long::getType()
3910 assert(false && "UNIMPLEMENTED"); return nullptr;
3913 Long1::Long1(const RValue<UInt> cast)
3915 assert(false && "UNIMPLEMENTED");
3918 Long1::Long1(RValue<Long1> rhs)
3920 storeValue(rhs.value);
3923 Type *Long1::getType()
3925 assert(false && "UNIMPLEMENTED"); return nullptr;
3928 RValue<Long2> UnpackHigh(RValue<Long2> x, RValue<Long2> y)
3930 assert(false && "UNIMPLEMENTED"); return RValue<Long2>(V(nullptr));
3933 Type *Long2::getType()
3935 assert(false && "UNIMPLEMENTED"); return nullptr;
3938 UInt::UInt(Argument<UInt> argument)
3940 storeValue(argument.value);
3943 UInt::UInt(RValue<UShort> cast)
3945 Value *integer = Nucleus::createZExt(cast.value, UInt::getType());
3947 storeValue(integer);
3950 UInt::UInt(RValue<Long> cast)
3952 Value *integer = Nucleus::createTrunc(cast.value, UInt::getType());
3954 storeValue(integer);
3957 UInt::UInt(RValue<Float> cast)
3959 assert(false && "UNIMPLEMENTED");
3968 storeValue(Nucleus::createConstantInt(x));
3971 UInt::UInt(unsigned int x)
3973 storeValue(Nucleus::createConstantInt(x));
3976 UInt::UInt(RValue<UInt> rhs)
3978 storeValue(rhs.value);
3981 UInt::UInt(RValue<Int> rhs)
3983 storeValue(rhs.value);
3986 UInt::UInt(const UInt &rhs)
3988 Value *value = rhs.loadValue();
3992 UInt::UInt(const Reference<UInt> &rhs)
3994 Value *value = rhs.loadValue();
3998 UInt::UInt(const Int &rhs)
4000 Value *value = rhs.loadValue();
4004 UInt::UInt(const Reference<Int> &rhs)
4006 Value *value = rhs.loadValue();
4010 RValue<UInt> UInt::operator=(unsigned int rhs) const
4012 return RValue<UInt>(storeValue(Nucleus::createConstantInt(rhs)));
4015 RValue<UInt> UInt::operator=(RValue<UInt> rhs) const
4017 storeValue(rhs.value);
4022 RValue<UInt> UInt::operator=(RValue<Int> rhs) const
4024 storeValue(rhs.value);
4026 return RValue<UInt>(rhs);
4029 RValue<UInt> UInt::operator=(const UInt &rhs) const
4031 Value *value = rhs.loadValue();
4034 return RValue<UInt>(value);
4037 RValue<UInt> UInt::operator=(const Reference<UInt> &rhs) const
4039 Value *value = rhs.loadValue();
4042 return RValue<UInt>(value);
4045 RValue<UInt> UInt::operator=(const Int &rhs) const
4047 Value *value = rhs.loadValue();
4050 return RValue<UInt>(value);
4053 RValue<UInt> UInt::operator=(const Reference<Int> &rhs) const
4055 Value *value = rhs.loadValue();
4058 return RValue<UInt>(value);
4061 RValue<UInt> operator+(RValue<UInt> lhs, RValue<UInt> rhs)
4063 return RValue<UInt>(Nucleus::createAdd(lhs.value, rhs.value));
4066 RValue<UInt> operator-(RValue<UInt> lhs, RValue<UInt> rhs)
4068 return RValue<UInt>(Nucleus::createSub(lhs.value, rhs.value));
4071 RValue<UInt> operator*(RValue<UInt> lhs, RValue<UInt> rhs)
4073 return RValue<UInt>(Nucleus::createMul(lhs.value, rhs.value));
4076 RValue<UInt> operator/(RValue<UInt> lhs, RValue<UInt> rhs)
4078 return RValue<UInt>(Nucleus::createUDiv(lhs.value, rhs.value));
4081 RValue<UInt> operator%(RValue<UInt> lhs, RValue<UInt> rhs)
4083 return RValue<UInt>(Nucleus::createURem(lhs.value, rhs.value));
4086 RValue<UInt> operator&(RValue<UInt> lhs, RValue<UInt> rhs)
4088 return RValue<UInt>(Nucleus::createAnd(lhs.value, rhs.value));
4091 RValue<UInt> operator|(RValue<UInt> lhs, RValue<UInt> rhs)
4093 return RValue<UInt>(Nucleus::createOr(lhs.value, rhs.value));
4096 RValue<UInt> operator^(RValue<UInt> lhs, RValue<UInt> rhs)
4098 return RValue<UInt>(Nucleus::createXor(lhs.value, rhs.value));
4101 RValue<UInt> operator<<(RValue<UInt> lhs, RValue<UInt> rhs)
4103 return RValue<UInt>(Nucleus::createShl(lhs.value, rhs.value));
4106 RValue<UInt> operator>>(RValue<UInt> lhs, RValue<UInt> rhs)
4108 return RValue<UInt>(Nucleus::createLShr(lhs.value, rhs.value));
4111 RValue<UInt> operator+=(const UInt &lhs, RValue<UInt> rhs)
4113 return lhs = lhs + rhs;
4116 RValue<UInt> operator-=(const UInt &lhs, RValue<UInt> rhs)
4118 return lhs = lhs - rhs;
4121 RValue<UInt> operator*=(const UInt &lhs, RValue<UInt> rhs)
4123 return lhs = lhs * rhs;
4126 RValue<UInt> operator/=(const UInt &lhs, RValue<UInt> rhs)
4128 return lhs = lhs / rhs;
4131 RValue<UInt> operator%=(const UInt &lhs, RValue<UInt> rhs)
4133 return lhs = lhs % rhs;
4136 RValue<UInt> operator&=(const UInt &lhs, RValue<UInt> rhs)
4138 return lhs = lhs & rhs;
4141 RValue<UInt> operator|=(const UInt &lhs, RValue<UInt> rhs)
4143 return lhs = lhs | rhs;
4146 RValue<UInt> operator^=(const UInt &lhs, RValue<UInt> rhs)
4148 return lhs = lhs ^ rhs;
4151 RValue<UInt> operator<<=(const UInt &lhs, RValue<UInt> rhs)
4153 return lhs = lhs << rhs;
4156 RValue<UInt> operator>>=(const UInt &lhs, RValue<UInt> rhs)
4158 return lhs = lhs >> rhs;
4161 RValue<UInt> operator+(RValue<UInt> val)
4166 RValue<UInt> operator-(RValue<UInt> val)
4168 return RValue<UInt>(Nucleus::createNeg(val.value));
4171 RValue<UInt> operator~(RValue<UInt> val)
4173 return RValue<UInt>(Nucleus::createNot(val.value));
4176 RValue<UInt> operator++(const UInt &val, int) // Post-increment
4178 assert(false && "UNIMPLEMENTED"); return RValue<UInt>(V(nullptr));
4181 const UInt &operator++(const UInt &val) // Pre-increment
4183 assert(false && "UNIMPLEMENTED"); return val;
4186 RValue<UInt> operator--(const UInt &val, int) // Post-decrement
4188 assert(false && "UNIMPLEMENTED"); return RValue<UInt>(V(nullptr));
4191 const UInt &operator--(const UInt &val) // Pre-decrement
4193 assert(false && "UNIMPLEMENTED"); return val;
4196 RValue<UInt> Max(RValue<UInt> x, RValue<UInt> y)
4198 return IfThenElse(x > y, x, y);
4201 RValue<UInt> Min(RValue<UInt> x, RValue<UInt> y)
4203 return IfThenElse(x < y, x, y);
4206 RValue<UInt> Clamp(RValue<UInt> x, RValue<UInt> min, RValue<UInt> max)
4208 return Min(Max(x, min), max);
4211 RValue<Bool> operator<(RValue<UInt> lhs, RValue<UInt> rhs)
4213 return RValue<Bool>(Nucleus::createICmpULT(lhs.value, rhs.value));
4216 RValue<Bool> operator<=(RValue<UInt> lhs, RValue<UInt> rhs)
4218 return RValue<Bool>(Nucleus::createICmpULE(lhs.value, rhs.value));
4221 RValue<Bool> operator>(RValue<UInt> lhs, RValue<UInt> rhs)
4223 return RValue<Bool>(Nucleus::createICmpUGT(lhs.value, rhs.value));
4226 RValue<Bool> operator>=(RValue<UInt> lhs, RValue<UInt> rhs)
4228 return RValue<Bool>(Nucleus::createICmpUGE(lhs.value, rhs.value));
4231 RValue<Bool> operator!=(RValue<UInt> lhs, RValue<UInt> rhs)
4233 return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value));
4236 RValue<Bool> operator==(RValue<UInt> lhs, RValue<UInt> rhs)
4238 return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value));
4241 // RValue<UInt> RoundUInt(RValue<Float> cast)
4243 // assert(false && "UNIMPLEMENTED"); return RValue<UInt>(V(nullptr));
4246 Type *UInt::getType()
4248 assert(false && "UNIMPLEMENTED"); return nullptr;
4251 // Int2::Int2(RValue<Int> cast)
4253 // Value *extend = Nucleus::createZExt(cast.value, Long::getType());
4254 // Value *vector = Nucleus::createBitCast(extend, Int2::getType());
4256 // Constant *shuffle[2];
4257 // shuffle[0] = Nucleus::createConstantInt(0);
4258 // shuffle[1] = Nucleus::createConstantInt(0);
4260 // Value *replicate = Nucleus::createShuffleVector(vector, UndefValue::get(Int2::getType()), Nucleus::createConstantVector(shuffle, 2));
4262 // storeValue(replicate);
4265 Int2::Int2(RValue<Int4> cast)
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());
4276 // xy.parent = this;
4279 Int2::Int2(int x, int y)
4281 // xy.parent = this;
4283 assert(false && "UNIMPLEMENTED");
4286 Int2::Int2(RValue<Int2> rhs)
4288 // xy.parent = this;
4290 storeValue(rhs.value);
4293 Int2::Int2(const Int2 &rhs)
4295 // xy.parent = this;
4297 Value *value = rhs.loadValue();
4301 Int2::Int2(const Reference<Int2> &rhs)
4303 // xy.parent = this;
4305 Value *value = rhs.loadValue();
4309 Int2::Int2(RValue<Int> lo, RValue<Int> hi)
4311 assert(false && "UNIMPLEMENTED");
4314 RValue<Int2> Int2::operator=(RValue<Int2> rhs) const
4316 storeValue(rhs.value);
4321 RValue<Int2> Int2::operator=(const Int2 &rhs) const
4323 Value *value = rhs.loadValue();
4326 return RValue<Int2>(value);
4329 RValue<Int2> Int2::operator=(const Reference<Int2> &rhs) const
4331 Value *value = rhs.loadValue();
4334 return RValue<Int2>(value);
4337 RValue<Int2> operator+(RValue<Int2> lhs, RValue<Int2> rhs)
4339 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
4342 RValue<Int2> operator-(RValue<Int2> lhs, RValue<Int2> rhs)
4344 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
4347 // RValue<Int2> operator*(RValue<Int2> lhs, RValue<Int2> rhs)
4349 // return RValue<Int2>(Nucleus::createMul(lhs.value, rhs.value));
4352 // RValue<Int2> operator/(RValue<Int2> lhs, RValue<Int2> rhs)
4354 // return RValue<Int2>(Nucleus::createSDiv(lhs.value, rhs.value));
4357 // RValue<Int2> operator%(RValue<Int2> lhs, RValue<Int2> rhs)
4359 // return RValue<Int2>(Nucleus::createSRem(lhs.value, rhs.value));
4362 RValue<Int2> operator&(RValue<Int2> lhs, RValue<Int2> rhs)
4364 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
4367 RValue<Int2> operator|(RValue<Int2> lhs, RValue<Int2> rhs)
4369 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
4372 RValue<Int2> operator^(RValue<Int2> lhs, RValue<Int2> rhs)
4374 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
4377 RValue<Int2> operator<<(RValue<Int2> lhs, unsigned char rhs)
4379 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
4382 RValue<Int2> operator>>(RValue<Int2> lhs, unsigned char rhs)
4384 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
4387 RValue<Int2> operator<<(RValue<Int2> lhs, RValue<Long1> rhs)
4389 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
4392 RValue<Int2> operator>>(RValue<Int2> lhs, RValue<Long1> rhs)
4394 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
4397 RValue<Int2> operator+=(const Int2 &lhs, RValue<Int2> rhs)
4399 return lhs = lhs + rhs;
4402 RValue<Int2> operator-=(const Int2 &lhs, RValue<Int2> rhs)
4404 return lhs = lhs - rhs;
4407 // RValue<Int2> operator*=(const Int2 &lhs, RValue<Int2> rhs)
4409 // return lhs = lhs * rhs;
4412 // RValue<Int2> operator/=(const Int2 &lhs, RValue<Int2> rhs)
4414 // return lhs = lhs / rhs;
4417 // RValue<Int2> operator%=(const Int2 &lhs, RValue<Int2> rhs)
4419 // return lhs = lhs % rhs;
4422 RValue<Int2> operator&=(const Int2 &lhs, RValue<Int2> rhs)
4424 return lhs = lhs & rhs;
4427 RValue<Int2> operator|=(const Int2 &lhs, RValue<Int2> rhs)
4429 return lhs = lhs | rhs;
4432 RValue<Int2> operator^=(const Int2 &lhs, RValue<Int2> rhs)
4434 return lhs = lhs ^ rhs;
4437 RValue<Int2> operator<<=(const Int2 &lhs, unsigned char rhs)
4439 return lhs = lhs << rhs;
4442 RValue<Int2> operator>>=(const Int2 &lhs, unsigned char rhs)
4444 return lhs = lhs >> rhs;
4447 RValue<Int2> operator<<=(const Int2 &lhs, RValue<Long1> rhs)
4449 return lhs = lhs << rhs;
4452 RValue<Int2> operator>>=(const Int2 &lhs, RValue<Long1> rhs)
4454 return lhs = lhs >> rhs;
4457 // RValue<Int2> operator+(RValue<Int2> val)
4462 // RValue<Int2> operator-(RValue<Int2> val)
4464 // return RValue<Int2>(Nucleus::createNeg(val.value));
4467 RValue<Int2> operator~(RValue<Int2> val)
4469 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
4472 RValue<Long1> UnpackLow(RValue<Int2> x, RValue<Int2> y)
4474 assert(false && "UNIMPLEMENTED"); return RValue<Long1>(V(nullptr));
4477 RValue<Long1> UnpackHigh(RValue<Int2> x, RValue<Int2> y)
4479 assert(false && "UNIMPLEMENTED"); return RValue<Long1>(V(nullptr));
4482 RValue<Int> Extract(RValue<Int2> val, int i)
4484 assert(false && "UNIMPLEMENTED"); return RValue<Int>(V(nullptr));
4487 RValue<Int2> Insert(RValue<Int2> val, RValue<Int> element, int i)
4489 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
4492 Type *Int2::getType()
4494 assert(false && "UNIMPLEMENTED"); return nullptr;
4499 // xy.parent = this;
4502 UInt2::UInt2(unsigned int x, unsigned int y)
4504 // xy.parent = this;
4506 assert(false && "UNIMPLEMENTED");
4509 UInt2::UInt2(RValue<UInt2> rhs)
4511 // xy.parent = this;
4513 storeValue(rhs.value);
4516 UInt2::UInt2(const UInt2 &rhs)
4518 // xy.parent = this;
4520 Value *value = rhs.loadValue();
4524 UInt2::UInt2(const Reference<UInt2> &rhs)
4526 // xy.parent = this;
4528 Value *value = rhs.loadValue();
4532 RValue<UInt2> UInt2::operator=(RValue<UInt2> rhs) const
4534 storeValue(rhs.value);
4539 RValue<UInt2> UInt2::operator=(const UInt2 &rhs) const
4541 Value *value = rhs.loadValue();
4544 return RValue<UInt2>(value);
4547 RValue<UInt2> UInt2::operator=(const Reference<UInt2> &rhs) const
4549 Value *value = rhs.loadValue();
4552 return RValue<UInt2>(value);
4555 RValue<UInt2> operator+(RValue<UInt2> lhs, RValue<UInt2> rhs)
4557 assert(false && "UNIMPLEMENTED"); return RValue<UInt2>(V(nullptr));
4560 RValue<UInt2> operator-(RValue<UInt2> lhs, RValue<UInt2> rhs)
4562 assert(false && "UNIMPLEMENTED"); return RValue<UInt2>(V(nullptr));
4565 // RValue<UInt2> operator*(RValue<UInt2> lhs, RValue<UInt2> rhs)
4567 // return RValue<UInt2>(Nucleus::createMul(lhs.value, rhs.value));
4570 // RValue<UInt2> operator/(RValue<UInt2> lhs, RValue<UInt2> rhs)
4572 // return RValue<UInt2>(Nucleus::createUDiv(lhs.value, rhs.value));
4575 // RValue<UInt2> operator%(RValue<UInt2> lhs, RValue<UInt2> rhs)
4577 // return RValue<UInt2>(Nucleus::createURem(lhs.value, rhs.value));
4580 RValue<UInt2> operator&(RValue<UInt2> lhs, RValue<UInt2> rhs)
4582 assert(false && "UNIMPLEMENTED"); return RValue<UInt2>(V(nullptr));
4585 RValue<UInt2> operator|(RValue<UInt2> lhs, RValue<UInt2> rhs)
4587 assert(false && "UNIMPLEMENTED"); return RValue<UInt2>(V(nullptr));
4590 RValue<UInt2> operator^(RValue<UInt2> lhs, RValue<UInt2> rhs)
4592 assert(false && "UNIMPLEMENTED"); return RValue<UInt2>(V(nullptr));
4595 RValue<UInt2> operator<<(RValue<UInt2> lhs, unsigned char rhs)
4597 assert(false && "UNIMPLEMENTED"); return RValue<UInt2>(V(nullptr));
4600 RValue<UInt2> operator>>(RValue<UInt2> lhs, unsigned char rhs)
4602 assert(false && "UNIMPLEMENTED"); return RValue<UInt2>(V(nullptr));
4605 RValue<UInt2> operator<<(RValue<UInt2> lhs, RValue<Long1> rhs)
4607 assert(false && "UNIMPLEMENTED"); return RValue<UInt2>(V(nullptr));
4610 RValue<UInt2> operator>>(RValue<UInt2> lhs, RValue<Long1> rhs)
4612 assert(false && "UNIMPLEMENTED"); return RValue<UInt2>(V(nullptr));
4615 RValue<UInt2> operator+=(const UInt2 &lhs, RValue<UInt2> rhs)
4617 return lhs = lhs + rhs;
4620 RValue<UInt2> operator-=(const UInt2 &lhs, RValue<UInt2> rhs)
4622 return lhs = lhs - rhs;
4625 // RValue<UInt2> operator*=(const UInt2 &lhs, RValue<UInt2> rhs)
4627 // return lhs = lhs * rhs;
4630 // RValue<UInt2> operator/=(const UInt2 &lhs, RValue<UInt2> rhs)
4632 // return lhs = lhs / rhs;
4635 // RValue<UInt2> operator%=(const UInt2 &lhs, RValue<UInt2> rhs)
4637 // return lhs = lhs % rhs;
4640 RValue<UInt2> operator&=(const UInt2 &lhs, RValue<UInt2> rhs)
4642 return lhs = lhs & rhs;
4645 RValue<UInt2> operator|=(const UInt2 &lhs, RValue<UInt2> rhs)
4647 return lhs = lhs | rhs;
4650 RValue<UInt2> operator^=(const UInt2 &lhs, RValue<UInt2> rhs)
4652 return lhs = lhs ^ rhs;
4655 RValue<UInt2> operator<<=(const UInt2 &lhs, unsigned char rhs)
4657 return lhs = lhs << rhs;
4660 RValue<UInt2> operator>>=(const UInt2 &lhs, unsigned char rhs)
4662 return lhs = lhs >> rhs;
4665 RValue<UInt2> operator<<=(const UInt2 &lhs, RValue<Long1> rhs)
4667 return lhs = lhs << rhs;
4670 RValue<UInt2> operator>>=(const UInt2 &lhs, RValue<Long1> rhs)
4672 return lhs = lhs >> rhs;
4675 // RValue<UInt2> operator+(RValue<UInt2> val)
4680 // RValue<UInt2> operator-(RValue<UInt2> val)
4682 // return RValue<UInt2>(Nucleus::createNeg(val.value));
4685 RValue<UInt2> operator~(RValue<UInt2> val)
4687 return RValue<UInt2>(Nucleus::createNot(val.value));
4690 Type *UInt2::getType()
4692 assert(false && "UNIMPLEMENTED"); return nullptr;
4695 Int4::Int4(RValue<Byte4> cast)
4697 assert(false && "UNIMPLEMENTED");
4700 Int4::Int4(RValue<SByte4> cast)
4702 assert(false && "UNIMPLEMENTED");
4705 Int4::Int4(RValue<Float4> cast)
4707 // xyzw.parent = this;
4709 Value *xyzw = Nucleus::createFPToSI(cast.value, Int4::getType());
4714 Int4::Int4(RValue<Short4> cast)
4716 assert(false && "UNIMPLEMENTED");
4719 Int4::Int4(RValue<UShort4> cast)
4721 assert(false && "UNIMPLEMENTED");
4726 // xyzw.parent = this;
4729 Int4::Int4(int xyzw)
4731 constant(xyzw, xyzw, xyzw, xyzw);
4734 Int4::Int4(int x, int yzw)
4736 constant(x, yzw, yzw, yzw);
4739 Int4::Int4(int x, int y, int zw)
4741 constant(x, y, zw, zw);
4744 Int4::Int4(int x, int y, int z, int w)
4746 constant(x, y, z, w);
4749 void Int4::constant(int x, int y, int z, int w)
4751 // xyzw.parent = this;
4753 int64_t constantVector[4] = {x, y, z, w};
4754 storeValue(Nucleus::createConstantVector(constantVector, Int4::getType()));
4757 Int4::Int4(RValue<Int4> rhs)
4759 // xyzw.parent = this;
4761 storeValue(rhs.value);
4764 Int4::Int4(const Int4 &rhs)
4766 // xyzw.parent = this;
4768 Value *value = rhs.loadValue();
4772 Int4::Int4(const Reference<Int4> &rhs)
4774 // xyzw.parent = this;
4776 Value *value = rhs.loadValue();
4780 Int4::Int4(RValue<UInt4> rhs)
4782 // xyzw.parent = this;
4784 storeValue(rhs.value);
4787 Int4::Int4(const UInt4 &rhs)
4789 // xyzw.parent = this;
4791 Value *value = rhs.loadValue();
4795 Int4::Int4(const Reference<UInt4> &rhs)
4797 // xyzw.parent = this;
4799 Value *value = rhs.loadValue();
4803 Int4::Int4(RValue<Int2> lo, RValue<Int2> hi)
4805 assert(false && "UNIMPLEMENTED");
4808 Int4::Int4(RValue<Int> rhs)
4810 // xyzw.parent = this;
4812 assert(false && "UNIMPLEMENTED");
4815 Int4::Int4(const Int &rhs)
4817 // xyzw.parent = this;
4819 *this = RValue<Int>(rhs.loadValue());
4822 Int4::Int4(const Reference<Int> &rhs)
4824 // xyzw.parent = this;
4826 *this = RValue<Int>(rhs.loadValue());
4829 RValue<Int4> Int4::operator=(RValue<Int4> rhs) const
4831 storeValue(rhs.value);
4836 RValue<Int4> Int4::operator=(const Int4 &rhs) const
4838 Value *value = rhs.loadValue();
4841 return RValue<Int4>(value);
4844 RValue<Int4> Int4::operator=(const Reference<Int4> &rhs) const
4846 Value *value = rhs.loadValue();
4849 return RValue<Int4>(value);
4852 RValue<Int4> operator+(RValue<Int4> lhs, RValue<Int4> rhs)
4854 return RValue<Int4>(Nucleus::createAdd(lhs.value, rhs.value));
4857 RValue<Int4> operator-(RValue<Int4> lhs, RValue<Int4> rhs)
4859 return RValue<Int4>(Nucleus::createSub(lhs.value, rhs.value));
4862 RValue<Int4> operator*(RValue<Int4> lhs, RValue<Int4> rhs)
4864 return RValue<Int4>(Nucleus::createMul(lhs.value, rhs.value));
4867 RValue<Int4> operator/(RValue<Int4> lhs, RValue<Int4> rhs)
4869 return RValue<Int4>(Nucleus::createSDiv(lhs.value, rhs.value));
4872 RValue<Int4> operator%(RValue<Int4> lhs, RValue<Int4> rhs)
4874 return RValue<Int4>(Nucleus::createSRem(lhs.value, rhs.value));
4877 RValue<Int4> operator&(RValue<Int4> lhs, RValue<Int4> rhs)
4879 return RValue<Int4>(Nucleus::createAnd(lhs.value, rhs.value));
4882 RValue<Int4> operator|(RValue<Int4> lhs, RValue<Int4> rhs)
4884 return RValue<Int4>(Nucleus::createOr(lhs.value, rhs.value));
4887 RValue<Int4> operator^(RValue<Int4> lhs, RValue<Int4> rhs)
4889 return RValue<Int4>(Nucleus::createXor(lhs.value, rhs.value));
4892 RValue<Int4> operator<<(RValue<Int4> lhs, unsigned char rhs)
4894 assert(false && "UNIMPLEMENTED"); return RValue<Int4>(V(nullptr));
4897 RValue<Int4> operator>>(RValue<Int4> lhs, unsigned char rhs)
4899 assert(false && "UNIMPLEMENTED"); return RValue<Int4>(V(nullptr));
4902 RValue<Int4> operator<<(RValue<Int4> lhs, RValue<Int4> rhs)
4904 return RValue<Int4>(Nucleus::createShl(lhs.value, rhs.value));
4907 RValue<Int4> operator>>(RValue<Int4> lhs, RValue<Int4> rhs)
4909 return RValue<Int4>(Nucleus::createAShr(lhs.value, rhs.value));
4912 RValue<Int4> operator+=(const Int4 &lhs, RValue<Int4> rhs)
4914 return lhs = lhs + rhs;
4917 RValue<Int4> operator-=(const Int4 &lhs, RValue<Int4> rhs)
4919 return lhs = lhs - rhs;
4922 RValue<Int4> operator*=(const Int4 &lhs, RValue<Int4> rhs)
4924 return lhs = lhs * rhs;
4927 // RValue<Int4> operator/=(const Int4 &lhs, RValue<Int4> rhs)
4929 // return lhs = lhs / rhs;
4932 // RValue<Int4> operator%=(const Int4 &lhs, RValue<Int4> rhs)
4934 // return lhs = lhs % rhs;
4937 RValue<Int4> operator&=(const Int4 &lhs, RValue<Int4> rhs)
4939 return lhs = lhs & rhs;
4942 RValue<Int4> operator|=(const Int4 &lhs, RValue<Int4> rhs)
4944 return lhs = lhs | rhs;
4947 RValue<Int4> operator^=(const Int4 &lhs, RValue<Int4> rhs)
4949 return lhs = lhs ^ rhs;
4952 RValue<Int4> operator<<=(const Int4 &lhs, unsigned char rhs)
4954 return lhs = lhs << rhs;
4957 RValue<Int4> operator>>=(const Int4 &lhs, unsigned char rhs)
4959 return lhs = lhs >> rhs;
4962 RValue<Int4> operator+(RValue<Int4> val)
4967 RValue<Int4> operator-(RValue<Int4> val)
4969 return RValue<Int4>(Nucleus::createNeg(val.value));
4972 RValue<Int4> operator~(RValue<Int4> val)
4974 return RValue<Int4>(Nucleus::createNot(val.value));
4977 RValue<Int4> CmpEQ(RValue<Int4> x, RValue<Int4> y)
4979 return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpEQ(x.value, y.value), Int4::getType()));
4982 RValue<Int4> CmpLT(RValue<Int4> x, RValue<Int4> y)
4984 return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSLT(x.value, y.value), Int4::getType()));
4987 RValue<Int4> CmpLE(RValue<Int4> x, RValue<Int4> y)
4989 return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSLE(x.value, y.value), Int4::getType()));
4992 RValue<Int4> CmpNEQ(RValue<Int4> x, RValue<Int4> y)
4994 return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpNE(x.value, y.value), Int4::getType()));
4997 RValue<Int4> CmpNLT(RValue<Int4> x, RValue<Int4> y)
4999 return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSGE(x.value, y.value), Int4::getType()));
5002 RValue<Int4> CmpNLE(RValue<Int4> x, RValue<Int4> y)
5004 return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSGT(x.value, y.value), Int4::getType()));
5007 RValue<Int4> Max(RValue<Int4> x, RValue<Int4> y)
5009 assert(false && "UNIMPLEMENTED"); return RValue<Int4>(V(nullptr));
5012 RValue<Int4> Min(RValue<Int4> x, RValue<Int4> y)
5014 assert(false && "UNIMPLEMENTED"); return RValue<Int4>(V(nullptr));
5017 RValue<Int4> RoundInt(RValue<Float4> cast)
5019 assert(false && "UNIMPLEMENTED"); return RValue<Int4>(V(nullptr));
5022 RValue<Short8> Pack(RValue<Int4> x, RValue<Int4> y)
5024 assert(false && "UNIMPLEMENTED"); return RValue<Short8>(V(nullptr));
5027 RValue<Int> Extract(RValue<Int4> x, int i)
5029 return RValue<Int>(Nucleus::createExtractElement(x.value, Int::getType(), i));
5032 RValue<Int4> Insert(RValue<Int4> x, RValue<Int> element, int i)
5034 return RValue<Int4>(Nucleus::createInsertElement(x.value, element.value, i));
5037 RValue<Int> SignMask(RValue<Int4> x)
5039 assert(false && "UNIMPLEMENTED"); return RValue<Int>(V(nullptr));
5042 RValue<Int4> Swizzle(RValue<Int4> x, unsigned char select)
5044 return RValue<Int4>(createSwizzle4(x.value, select));
5047 Type *Int4::getType()
5049 return T(Ice::IceType_v4i32);
5052 UInt4::UInt4(RValue<Float4> cast)
5054 // xyzw.parent = this;
5056 assert(false && "UNIMPLEMENTED");
5061 // xyzw.parent = this;
5064 UInt4::UInt4(int xyzw)
5066 constant(xyzw, xyzw, xyzw, xyzw);
5069 UInt4::UInt4(int x, int yzw)
5071 constant(x, yzw, yzw, yzw);
5074 UInt4::UInt4(int x, int y, int zw)
5076 constant(x, y, zw, zw);
5079 UInt4::UInt4(int x, int y, int z, int w)
5081 constant(x, y, z, w);
5084 void UInt4::constant(int x, int y, int z, int w)
5086 // xyzw.parent = this;
5088 int64_t constantVector[4] = {x, y, z, w};
5089 storeValue(Nucleus::createConstantVector(constantVector, UInt4::getType()));
5092 UInt4::UInt4(RValue<UInt4> rhs)
5094 // xyzw.parent = this;
5096 storeValue(rhs.value);
5099 UInt4::UInt4(const UInt4 &rhs)
5101 // xyzw.parent = this;
5103 Value *value = rhs.loadValue();
5107 UInt4::UInt4(const Reference<UInt4> &rhs)
5109 // xyzw.parent = this;
5111 Value *value = rhs.loadValue();
5115 UInt4::UInt4(RValue<Int4> rhs)
5117 // xyzw.parent = this;
5119 storeValue(rhs.value);
5122 UInt4::UInt4(const Int4 &rhs)
5124 // xyzw.parent = this;
5126 Value *value = rhs.loadValue();
5130 UInt4::UInt4(const Reference<Int4> &rhs)
5132 // xyzw.parent = this;
5134 Value *value = rhs.loadValue();
5138 UInt4::UInt4(RValue<UInt2> lo, RValue<UInt2> hi)
5140 assert(false && "UNIMPLEMENTED");
5143 RValue<UInt4> UInt4::operator=(RValue<UInt4> rhs) const
5145 storeValue(rhs.value);
5150 RValue<UInt4> UInt4::operator=(const UInt4 &rhs) const
5152 Value *value = rhs.loadValue();
5155 return RValue<UInt4>(value);
5158 RValue<UInt4> UInt4::operator=(const Reference<UInt4> &rhs) const
5160 Value *value = rhs.loadValue();
5163 return RValue<UInt4>(value);
5166 RValue<UInt4> operator+(RValue<UInt4> lhs, RValue<UInt4> rhs)
5168 return RValue<UInt4>(Nucleus::createAdd(lhs.value, rhs.value));
5171 RValue<UInt4> operator-(RValue<UInt4> lhs, RValue<UInt4> rhs)
5173 return RValue<UInt4>(Nucleus::createSub(lhs.value, rhs.value));
5176 RValue<UInt4> operator*(RValue<UInt4> lhs, RValue<UInt4> rhs)
5178 return RValue<UInt4>(Nucleus::createMul(lhs.value, rhs.value));
5181 RValue<UInt4> operator/(RValue<UInt4> lhs, RValue<UInt4> rhs)
5183 return RValue<UInt4>(Nucleus::createUDiv(lhs.value, rhs.value));
5186 RValue<UInt4> operator%(RValue<UInt4> lhs, RValue<UInt4> rhs)
5188 return RValue<UInt4>(Nucleus::createURem(lhs.value, rhs.value));
5191 RValue<UInt4> operator&(RValue<UInt4> lhs, RValue<UInt4> rhs)
5193 return RValue<UInt4>(Nucleus::createAnd(lhs.value, rhs.value));
5196 RValue<UInt4> operator|(RValue<UInt4> lhs, RValue<UInt4> rhs)
5198 return RValue<UInt4>(Nucleus::createOr(lhs.value, rhs.value));
5201 RValue<UInt4> operator^(RValue<UInt4> lhs, RValue<UInt4> rhs)
5203 return RValue<UInt4>(Nucleus::createXor(lhs.value, rhs.value));
5206 RValue<UInt4> operator<<(RValue<UInt4> lhs, unsigned char rhs)
5208 assert(false && "UNIMPLEMENTED"); return RValue<UInt4>(V(nullptr));
5211 RValue<UInt4> operator>>(RValue<UInt4> lhs, unsigned char rhs)
5213 assert(false && "UNIMPLEMENTED"); return RValue<UInt4>(V(nullptr));
5216 RValue<UInt4> operator<<(RValue<UInt4> lhs, RValue<UInt4> rhs)
5218 return RValue<UInt4>(Nucleus::createShl(lhs.value, rhs.value));
5221 RValue<UInt4> operator>>(RValue<UInt4> lhs, RValue<UInt4> rhs)
5223 return RValue<UInt4>(Nucleus::createLShr(lhs.value, rhs.value));
5226 RValue<UInt4> operator+=(const UInt4 &lhs, RValue<UInt4> rhs)
5228 return lhs = lhs + rhs;
5231 RValue<UInt4> operator-=(const UInt4 &lhs, RValue<UInt4> rhs)
5233 return lhs = lhs - rhs;
5236 RValue<UInt4> operator*=(const UInt4 &lhs, RValue<UInt4> rhs)
5238 return lhs = lhs * rhs;
5241 // RValue<UInt4> operator/=(const UInt4 &lhs, RValue<UInt4> rhs)
5243 // return lhs = lhs / rhs;
5246 // RValue<UInt4> operator%=(const UInt4 &lhs, RValue<UInt4> rhs)
5248 // return lhs = lhs % rhs;
5251 RValue<UInt4> operator&=(const UInt4 &lhs, RValue<UInt4> rhs)
5253 return lhs = lhs & rhs;
5256 RValue<UInt4> operator|=(const UInt4 &lhs, RValue<UInt4> rhs)
5258 return lhs = lhs | rhs;
5261 RValue<UInt4> operator^=(const UInt4 &lhs, RValue<UInt4> rhs)
5263 return lhs = lhs ^ rhs;
5266 RValue<UInt4> operator<<=(const UInt4 &lhs, unsigned char rhs)
5268 return lhs = lhs << rhs;
5271 RValue<UInt4> operator>>=(const UInt4 &lhs, unsigned char rhs)
5273 return lhs = lhs >> rhs;
5276 RValue<UInt4> operator+(RValue<UInt4> val)
5281 RValue<UInt4> operator-(RValue<UInt4> val)
5283 return RValue<UInt4>(Nucleus::createNeg(val.value));
5286 RValue<UInt4> operator~(RValue<UInt4> val)
5288 return RValue<UInt4>(Nucleus::createNot(val.value));
5291 RValue<UInt4> CmpEQ(RValue<UInt4> x, RValue<UInt4> y)
5293 return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpEQ(x.value, y.value), Int4::getType()));
5296 RValue<UInt4> CmpLT(RValue<UInt4> x, RValue<UInt4> y)
5298 return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpULT(x.value, y.value), Int4::getType()));
5301 RValue<UInt4> CmpLE(RValue<UInt4> x, RValue<UInt4> y)
5303 return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpULE(x.value, y.value), Int4::getType()));
5306 RValue<UInt4> CmpNEQ(RValue<UInt4> x, RValue<UInt4> y)
5308 return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpNE(x.value, y.value), Int4::getType()));
5311 RValue<UInt4> CmpNLT(RValue<UInt4> x, RValue<UInt4> y)
5313 return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpUGE(x.value, y.value), Int4::getType()));
5316 RValue<UInt4> CmpNLE(RValue<UInt4> x, RValue<UInt4> y)
5318 return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpUGT(x.value, y.value), Int4::getType()));
5321 RValue<UInt4> Max(RValue<UInt4> x, RValue<UInt4> y)
5323 assert(false && "UNIMPLEMENTED"); return RValue<UInt4>(V(nullptr));
5326 RValue<UInt4> Min(RValue<UInt4> x, RValue<UInt4> y)
5328 assert(false && "UNIMPLEMENTED"); return RValue<UInt4>(V(nullptr));
5331 RValue<UShort8> Pack(RValue<UInt4> x, RValue<UInt4> y)
5333 assert(false && "UNIMPLEMENTED"); return RValue<UShort8>(V(nullptr));
5336 Type *UInt4::getType()
5338 assert(false && "UNIMPLEMENTED"); return nullptr;
5341 Float::Float(RValue<Int> cast)
5343 Value *integer = Nucleus::createSIToFP(cast.value, Float::getType());
5345 storeValue(integer);
5352 Float::Float(float x)
5354 storeValue(Nucleus::createConstantFloat(x));
5357 Float::Float(RValue<Float> rhs)
5359 storeValue(rhs.value);
5362 Float::Float(const Float &rhs)
5364 Value *value = rhs.loadValue();
5368 Float::Float(const Reference<Float> &rhs)
5370 Value *value = rhs.loadValue();
5374 RValue<Float> Float::operator=(RValue<Float> rhs) const
5376 storeValue(rhs.value);
5381 RValue<Float> Float::operator=(const Float &rhs) const
5383 Value *value = rhs.loadValue();
5386 return RValue<Float>(value);
5389 RValue<Float> Float::operator=(const Reference<Float> &rhs) const
5391 Value *value = rhs.loadValue();
5394 return RValue<Float>(value);
5397 RValue<Float> operator+(RValue<Float> lhs, RValue<Float> rhs)
5399 return RValue<Float>(Nucleus::createFAdd(lhs.value, rhs.value));
5402 RValue<Float> operator-(RValue<Float> lhs, RValue<Float> rhs)
5404 return RValue<Float>(Nucleus::createFSub(lhs.value, rhs.value));
5407 RValue<Float> operator*(RValue<Float> lhs, RValue<Float> rhs)
5409 return RValue<Float>(Nucleus::createFMul(lhs.value, rhs.value));
5412 RValue<Float> operator/(RValue<Float> lhs, RValue<Float> rhs)
5414 return RValue<Float>(Nucleus::createFDiv(lhs.value, rhs.value));
5417 RValue<Float> operator+=(const Float &lhs, RValue<Float> rhs)
5419 return lhs = lhs + rhs;
5422 RValue<Float> operator-=(const Float &lhs, RValue<Float> rhs)
5424 return lhs = lhs - rhs;
5427 RValue<Float> operator*=(const Float &lhs, RValue<Float> rhs)
5429 return lhs = lhs * rhs;
5432 RValue<Float> operator/=(const Float &lhs, RValue<Float> rhs)
5434 return lhs = lhs / rhs;
5437 RValue<Float> operator+(RValue<Float> val)
5442 RValue<Float> operator-(RValue<Float> val)
5444 return RValue<Float>(Nucleus::createFNeg(val.value));
5447 RValue<Bool> operator<(RValue<Float> lhs, RValue<Float> rhs)
5449 return RValue<Bool>(Nucleus::createFCmpOLT(lhs.value, rhs.value));
5452 RValue<Bool> operator<=(RValue<Float> lhs, RValue<Float> rhs)
5454 return RValue<Bool>(Nucleus::createFCmpOLE(lhs.value, rhs.value));
5457 RValue<Bool> operator>(RValue<Float> lhs, RValue<Float> rhs)
5459 return RValue<Bool>(Nucleus::createFCmpOGT(lhs.value, rhs.value));
5462 RValue<Bool> operator>=(RValue<Float> lhs, RValue<Float> rhs)
5464 return RValue<Bool>(Nucleus::createFCmpOGE(lhs.value, rhs.value));
5467 RValue<Bool> operator!=(RValue<Float> lhs, RValue<Float> rhs)
5469 return RValue<Bool>(Nucleus::createFCmpONE(lhs.value, rhs.value));
5472 RValue<Bool> operator==(RValue<Float> lhs, RValue<Float> rhs)
5474 return RValue<Bool>(Nucleus::createFCmpOEQ(lhs.value, rhs.value));
5477 RValue<Float> Abs(RValue<Float> x)
5479 return IfThenElse(x > 0.0f, x, -x);
5482 RValue<Float> Max(RValue<Float> x, RValue<Float> y)
5484 return IfThenElse(x > y, x, y);
5487 RValue<Float> Min(RValue<Float> x, RValue<Float> y)
5489 return IfThenElse(x < y, x, y);
5492 RValue<Float> Rcp_pp(RValue<Float> x, bool exactAtPow2)
5494 assert(false && "UNIMPLEMENTED"); return RValue<Float>(V(nullptr));
5497 RValue<Float> RcpSqrt_pp(RValue<Float> x)
5499 assert(false && "UNIMPLEMENTED"); return RValue<Float>(V(nullptr));
5502 RValue<Float> Sqrt(RValue<Float> x)
5504 assert(false && "UNIMPLEMENTED"); return RValue<Float>(V(nullptr));
5507 RValue<Float> Round(RValue<Float> x)
5509 assert(false && "UNIMPLEMENTED"); return RValue<Float>(V(nullptr));
5512 RValue<Float> Trunc(RValue<Float> x)
5514 assert(false && "UNIMPLEMENTED"); return RValue<Float>(V(nullptr));
5517 RValue<Float> Frac(RValue<Float> x)
5519 assert(false && "UNIMPLEMENTED"); return RValue<Float>(V(nullptr));
5522 RValue<Float> Floor(RValue<Float> x)
5524 assert(false && "UNIMPLEMENTED"); return RValue<Float>(V(nullptr));
5527 RValue<Float> Ceil(RValue<Float> x)
5529 assert(false && "UNIMPLEMENTED"); return RValue<Float>(V(nullptr));
5532 Type *Float::getType()
5534 return T(Ice::IceType_f32);
5537 Float2::Float2(RValue<Float4> cast)
5539 // xyzw.parent = this;
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());
5548 Type *Float2::getType()
5550 assert(false && "UNIMPLEMENTED"); return nullptr;
5553 Float4::Float4(RValue<Byte4> cast)
5557 assert(false && "UNIMPLEMENTED");
5560 Float4::Float4(RValue<SByte4> cast)
5564 assert(false && "UNIMPLEMENTED");
5567 Float4::Float4(RValue<Short4> cast)
5572 storeValue(Nucleus::createSIToFP(RValue<Int4>(c).value, Float4::getType()));
5575 Float4::Float4(RValue<UShort4> cast)
5580 storeValue(Nucleus::createSIToFP(RValue<Int4>(c).value, Float4::getType()));
5583 Float4::Float4(RValue<Int4> cast)
5587 Value *xyzw = Nucleus::createSIToFP(cast.value, Float4::getType());
5592 Float4::Float4(RValue<UInt4> cast)
5596 Value *xyzw = Nucleus::createUIToFP(cast.value, Float4::getType());
5606 Float4::Float4(float xyzw)
5608 constant(xyzw, xyzw, xyzw, xyzw);
5611 Float4::Float4(float x, float yzw)
5613 constant(x, yzw, yzw, yzw);
5616 Float4::Float4(float x, float y, float zw)
5618 constant(x, y, zw, zw);
5621 Float4::Float4(float x, float y, float z, float w)
5623 constant(x, y, z, w);
5626 void Float4::constant(float x, float y, float z, float w)
5630 double constantVector[4] = {x, y, z, w};
5631 storeValue(Nucleus::createConstantVector(constantVector, Float4::getType()));
5634 Float4::Float4(RValue<Float4> rhs)
5638 storeValue(rhs.value);
5641 Float4::Float4(const Float4 &rhs)
5645 Value *value = rhs.loadValue();
5649 Float4::Float4(const Reference<Float4> &rhs)
5653 Value *value = rhs.loadValue();
5657 Float4::Float4(RValue<Float> rhs)
5661 assert(false && "UNIMPLEMENTED");
5664 Float4::Float4(const Float &rhs)
5668 *this = RValue<Float>(rhs.loadValue());
5671 Float4::Float4(const Reference<Float> &rhs)
5675 *this = RValue<Float>(rhs.loadValue());
5678 RValue<Float4> Float4::operator=(float x) const
5680 return *this = Float4(x, x, x, x);
5683 RValue<Float4> Float4::operator=(RValue<Float4> rhs) const
5685 storeValue(rhs.value);
5690 RValue<Float4> Float4::operator=(const Float4 &rhs) const
5692 Value *value = rhs.loadValue();
5695 return RValue<Float4>(value);
5698 RValue<Float4> Float4::operator=(const Reference<Float4> &rhs) const
5700 Value *value = rhs.loadValue();
5703 return RValue<Float4>(value);
5706 RValue<Float4> Float4::operator=(RValue<Float> rhs) const
5708 return *this = Float4(rhs);
5711 RValue<Float4> Float4::operator=(const Float &rhs) const
5713 return *this = Float4(rhs);
5716 RValue<Float4> Float4::operator=(const Reference<Float> &rhs) const
5718 return *this = Float4(rhs);
5721 RValue<Float4> operator+(RValue<Float4> lhs, RValue<Float4> rhs)
5723 return RValue<Float4>(Nucleus::createFAdd(lhs.value, rhs.value));
5726 RValue<Float4> operator-(RValue<Float4> lhs, RValue<Float4> rhs)
5728 return RValue<Float4>(Nucleus::createFSub(lhs.value, rhs.value));
5731 RValue<Float4> operator*(RValue<Float4> lhs, RValue<Float4> rhs)
5733 return RValue<Float4>(Nucleus::createFMul(lhs.value, rhs.value));
5736 RValue<Float4> operator/(RValue<Float4> lhs, RValue<Float4> rhs)
5738 return RValue<Float4>(Nucleus::createFDiv(lhs.value, rhs.value));
5741 RValue<Float4> operator%(RValue<Float4> lhs, RValue<Float4> rhs)
5743 return RValue<Float4>(Nucleus::createFRem(lhs.value, rhs.value));
5746 RValue<Float4> operator+=(const Float4 &lhs, RValue<Float4> rhs)
5748 return lhs = lhs + rhs;
5751 RValue<Float4> operator-=(const Float4 &lhs, RValue<Float4> rhs)
5753 return lhs = lhs - rhs;
5756 RValue<Float4> operator*=(const Float4 &lhs, RValue<Float4> rhs)
5758 return lhs = lhs * rhs;
5761 RValue<Float4> operator/=(const Float4 &lhs, RValue<Float4> rhs)
5763 return lhs = lhs / rhs;
5766 RValue<Float4> operator%=(const Float4 &lhs, RValue<Float4> rhs)
5768 return lhs = lhs % rhs;
5771 RValue<Float4> operator+(RValue<Float4> val)
5776 RValue<Float4> operator-(RValue<Float4> val)
5778 return RValue<Float4>(Nucleus::createFNeg(val.value));
5781 RValue<Float4> Abs(RValue<Float4> x)
5783 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
5786 RValue<Float4> Max(RValue<Float4> x, RValue<Float4> y)
5788 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
5791 RValue<Float4> Min(RValue<Float4> x, RValue<Float4> y)
5793 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
5796 RValue<Float4> Rcp_pp(RValue<Float4> x, bool exactAtPow2)
5798 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
5801 RValue<Float4> RcpSqrt_pp(RValue<Float4> x)
5803 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
5806 RValue<Float4> Sqrt(RValue<Float4> x)
5808 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
5811 RValue<Float4> Insert(const Float4 &val, RValue<Float> element, int i)
5813 Value *value = val.loadValue();
5814 Value *insert = Nucleus::createInsertElement(value, element.value, i);
5816 val = RValue<Float4>(insert);
5821 RValue<Float> Extract(RValue<Float4> x, int i)
5823 return RValue<Float>(Nucleus::createExtractElement(x.value, Float::getType(), i));
5826 RValue<Float4> Swizzle(RValue<Float4> x, unsigned char select)
5828 return RValue<Float4>(createSwizzle4(x.value, select));
5831 RValue<Float4> ShuffleLowHigh(RValue<Float4> x, RValue<Float4> y, unsigned char imm)
5833 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
5836 RValue<Float4> UnpackLow(RValue<Float4> x, RValue<Float4> y)
5838 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
5841 RValue<Float4> UnpackHigh(RValue<Float4> x, RValue<Float4> y)
5843 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
5846 RValue<Float4> Mask(Float4 &lhs, RValue<Float4> rhs, unsigned char select)
5848 Value *vector = lhs.loadValue();
5849 Value *shuffle = createMask4(vector, rhs.value, select);
5850 lhs.storeValue(shuffle);
5852 return RValue<Float4>(shuffle);
5855 RValue<Int> SignMask(RValue<Float4> x)
5857 assert(false && "UNIMPLEMENTED"); return RValue<Int>(V(nullptr));
5860 RValue<Int4> CmpEQ(RValue<Float4> x, RValue<Float4> y)
5862 return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOEQ(x.value, y.value), Int4::getType()));
5865 RValue<Int4> CmpLT(RValue<Float4> x, RValue<Float4> y)
5867 return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOLT(x.value, y.value), Int4::getType()));
5870 RValue<Int4> CmpLE(RValue<Float4> x, RValue<Float4> y)
5872 return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOLE(x.value, y.value), Int4::getType()));
5875 RValue<Int4> CmpNEQ(RValue<Float4> x, RValue<Float4> y)
5877 return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpONE(x.value, y.value), Int4::getType()));
5880 RValue<Int4> CmpNLT(RValue<Float4> x, RValue<Float4> y)
5882 return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOGE(x.value, y.value), Int4::getType()));
5885 RValue<Int4> CmpNLE(RValue<Float4> x, RValue<Float4> y)
5887 return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOGT(x.value, y.value), Int4::getType()));
5890 RValue<Float4> Round(RValue<Float4> x)
5892 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
5895 RValue<Float4> Trunc(RValue<Float4> x)
5897 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
5900 RValue<Float4> Frac(RValue<Float4> x)
5902 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
5905 RValue<Float4> Floor(RValue<Float4> x)
5907 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
5910 RValue<Float4> Ceil(RValue<Float4> x)
5912 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
5915 Type *Float4::getType()
5917 return T(Ice::IceType_v4f32);
5920 RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, int offset)
5922 return lhs + RValue<Int>(Nucleus::createConstantInt(offset));
5925 RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<Int> offset)
5927 return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value, Byte::getType(), offset.value));
5930 RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<UInt> offset)
5932 return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value, Byte::getType(), offset.value));
5935 RValue<Pointer<Byte>> operator+=(const Pointer<Byte> &lhs, int offset)
5937 return lhs = lhs + offset;
5940 RValue<Pointer<Byte>> operator+=(const Pointer<Byte> &lhs, RValue<Int> offset)
5942 return lhs = lhs + offset;
5945 RValue<Pointer<Byte>> operator+=(const Pointer<Byte> &lhs, RValue<UInt> offset)
5947 return lhs = lhs + offset;
5950 RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, int offset)
5952 return lhs + -offset;
5955 RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, RValue<Int> offset)
5957 return lhs + -offset;
5960 RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, RValue<UInt> offset)
5962 return lhs + -offset;
5965 RValue<Pointer<Byte>> operator-=(const Pointer<Byte> &lhs, int offset)
5967 return lhs = lhs - offset;
5970 RValue<Pointer<Byte>> operator-=(const Pointer<Byte> &lhs, RValue<Int> offset)
5972 return lhs = lhs - offset;
5975 RValue<Pointer<Byte>> operator-=(const Pointer<Byte> &lhs, RValue<UInt> offset)
5977 return lhs = lhs - offset;
5982 Nucleus::createRetVoid();
5983 Nucleus::setInsertBlock(Nucleus::createBasicBlock());
5984 Nucleus::createUnreachable();
5987 void Return(bool ret)
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);
5994 void Return(const Int &ret)
5996 Ice::InstRet *retu = Ice::InstRet::create(::function, ret.loadValue());
5997 ::basicBlock->appendInst(retu);
6000 BasicBlock *beginLoop()
6002 BasicBlock *loopBB = Nucleus::createBasicBlock();
6004 Nucleus::createBr(loopBB);
6005 Nucleus::setInsertBlock(loopBB);
6010 bool branch(RValue<Bool> cmp, BasicBlock *bodyBB, BasicBlock *endBB)
6012 Nucleus::createCondBr(cmp.value, bodyBB, endBB);
6013 Nucleus::setInsertBlock(bodyBB);
6018 bool elseBlock(BasicBlock *falseBB)
6020 Nucleus::setInsertBlock(falseBB);
6025 RValue<Long> Ticks()
6027 assert(false && "UNIMPLEMENTED"); return RValue<Long>(V(nullptr));