blob: 54a4bfa5555034da390d781ab84a3ffef4f52b4d [file] [log] [blame]
Nicolas Capens598f8d82016-09-26 15:09:10 -04001// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#include "Nucleus.hpp"
16
17#include "Reactor.hpp"
18#include "Routine.hpp"
19
20#include "src/IceTypes.h"
21#include "src/IceCfg.h"
22#include "src/IceELFStreamer.h"
23#include "src/IceGlobalContext.h"
24#include "src/IceCfgNode.h"
25#include "src/IceELFObjectWriter.h"
Nicolas Capens8dfd9a72016-10-13 17:44:51 -040026#include "src/IceGlobalInits.h"
Nicolas Capens598f8d82016-09-26 15:09:10 -040027
28#include "llvm/Support/FileSystem.h"
29#include "llvm/Support/raw_os_ostream.h"
30
31#define WIN32_LEAN_AND_MEAN
32#define NOMINMAX
33#include <Windows.h>
34
35#include <mutex>
36#include <limits>
37#include <iostream>
38#include <cassert>
39
40namespace
41{
42 Ice::GlobalContext *context = nullptr;
43 Ice::Cfg *function = nullptr;
44 Ice::CfgNode *basicBlock = nullptr;
45 Ice::CfgLocalAllocatorScope *allocator = nullptr;
46 sw::Routine *routine = nullptr;
47
48 std::mutex codegenMutex;
49
Nicolas Capens9ed1a182016-10-24 09:52:23 -040050 sw::BasicBlock *falseBB = nullptr;
51
Nicolas Capens598f8d82016-09-26 15:09:10 -040052 Ice::ELFFileStreamer *elfFile = nullptr;
53 Ice::Fdstream *out = nullptr;
54}
55
56namespace sw
57{
Nicolas Capens23d99a42016-09-30 14:57:16 -040058 enum EmulatedType
59 {
60 EmulatedShift = 16,
61 EmulatedV2 = 2 << EmulatedShift,
62 EmulatedV4 = 4 << EmulatedShift,
63 EmulatedV8 = 8 << EmulatedShift,
64 EmulatedBits = EmulatedV2 | EmulatedV4 | EmulatedV8,
65
66 Type_v2i32 = Ice::IceType_v4i32 | EmulatedV2,
67 Type_v4i16 = Ice::IceType_v8i16 | EmulatedV4,
68 Type_v2i16 = Ice::IceType_v8i16 | EmulatedV2,
69 Type_v8i8 = Ice::IceType_v16i8 | EmulatedV8,
70 Type_v4i8 = Ice::IceType_v16i8 | EmulatedV4,
Nicolas Capens4cfd4572016-10-20 01:00:19 -040071 Type_v2f32 = Ice::IceType_v4f32 | EmulatedV2,
Nicolas Capens23d99a42016-09-30 14:57:16 -040072 };
73
Nicolas Capens598f8d82016-09-26 15:09:10 -040074 class Value : public Ice::Variable {};
75 class BasicBlock : public Ice::CfgNode {};
76
77 Ice::Type T(Type *t)
78 {
Nicolas Capens23d99a42016-09-30 14:57:16 -040079 static_assert(Ice::IceType_NUM < EmulatedBits, "Ice::Type overlaps with our emulated types!");
80 return (Ice::Type)(reinterpret_cast<std::intptr_t>(t) & ~EmulatedBits);
Nicolas Capens598f8d82016-09-26 15:09:10 -040081 }
82
83 Type *T(Ice::Type t)
84 {
85 return reinterpret_cast<Type*>(t);
86 }
87
Nicolas Capens23d99a42016-09-30 14:57:16 -040088 Type *T(EmulatedType t)
89 {
90 return reinterpret_cast<Type*>(t);
91 }
92
Nicolas Capens598f8d82016-09-26 15:09:10 -040093 Value *V(Ice::Variable *v)
94 {
95 return reinterpret_cast<Value*>(v);
96 }
97
Nicolas Capens327f1df2016-10-21 14:26:34 -040098 Value *C(Ice::Constant *c) // Only safe for casting right-hand side operand
99 {
100 return reinterpret_cast<Value*>(c);
101 }
102
Nicolas Capens611642a2016-09-28 16:45:04 -0400103 BasicBlock *B(Ice::CfgNode *b)
104 {
105 return reinterpret_cast<BasicBlock*>(b);
106 }
107
Nicolas Capens598f8d82016-09-26 15:09:10 -0400108 Optimization optimization[10] = {InstructionCombining, Disabled};
109
Nicolas Capens66478362016-10-13 15:36:36 -0400110 using ElfHeader = std::conditional<sizeof(void*) == 8, Elf64_Ehdr, Elf32_Ehdr>::type;
111 using SectionHeader = std::conditional<sizeof(void*) == 8, Elf64_Shdr, Elf32_Shdr>::type;
112
113 inline const SectionHeader *sectionHeader(const ElfHeader *elfHeader)
114 {
115 return reinterpret_cast<const SectionHeader*>((intptr_t)elfHeader + elfHeader->e_shoff);
116 }
117
118 inline const SectionHeader *elfSection(const ElfHeader *elfHeader, int index)
119 {
120 return &sectionHeader(elfHeader)[index];
121 }
122
123 static void *relocateSymbol(const ElfHeader *elfHeader, const Elf32_Rel &relocation, const SectionHeader &relocationTable)
124 {
125 const SectionHeader *target = elfSection(elfHeader, relocationTable.sh_info);
126
127 intptr_t address = (intptr_t)elfHeader + target->sh_offset;
128 int32_t *patchSite = (int*)(address + relocation.r_offset);
129 uint32_t index = relocation.getSymbol();
130 int table = relocationTable.sh_link;
131 void *symbolValue = nullptr;
132
133 if(index != SHN_UNDEF)
134 {
135 if(table == SHN_UNDEF) return nullptr;
136 const SectionHeader *symbolTable = elfSection(elfHeader, table);
137
138 uint32_t symtab_entries = symbolTable->sh_size / symbolTable->sh_entsize;
139 if(index >= symtab_entries)
140 {
141 assert(index < symtab_entries && "Symbol Index out of range");
142 return nullptr;
143 }
144
145 intptr_t symbolAddress = (intptr_t)elfHeader + symbolTable->sh_offset;
146 Elf32_Sym &symbol = ((Elf32_Sym*)symbolAddress)[index];
147 uint16_t section = symbol.st_shndx;
148
149 if(section != SHN_UNDEF && section < SHN_LORESERVE)
150 {
151 const SectionHeader *target = elfSection(elfHeader, symbol.st_shndx);
152 symbolValue = reinterpret_cast<void*>((intptr_t)elfHeader + symbol.st_value + target->sh_offset);
153 }
154 else
155 {
156 return nullptr;
157 }
158 }
159
160 switch(relocation.getType())
161 {
162 case R_386_NONE:
163 // No relocation
164 break;
165 case R_386_32:
166 *patchSite = (int32_t)((intptr_t)symbolValue + *patchSite);
167 break;
168 // case R_386_PC32:
169 // *patchSite = (int32_t)((intptr_t)symbolValue + *patchSite - (intptr_t)patchSite);
170 // break;
171 default:
172 assert(false && "Unsupported relocation type");
173 return nullptr;
174 }
175
176 return symbolValue;
177 }
178
179 static void *relocateSymbol(const ElfHeader *elfHeader, const Elf64_Rela &relocation, const SectionHeader &relocationTable)
180 {
181 const SectionHeader *target = elfSection(elfHeader, relocationTable.sh_info);
182
183 intptr_t address = (intptr_t)elfHeader + target->sh_offset;
184 int32_t *patchSite = (int*)(address + relocation.r_offset);
185 uint32_t index = relocation.getSymbol();
186 int table = relocationTable.sh_link;
187 void *symbolValue = nullptr;
188
189 if(index != SHN_UNDEF)
190 {
191 if(table == SHN_UNDEF) return nullptr;
192 const SectionHeader *symbolTable = elfSection(elfHeader, table);
193
194 uint32_t symtab_entries = symbolTable->sh_size / symbolTable->sh_entsize;
195 if(index >= symtab_entries)
196 {
197 assert(index < symtab_entries && "Symbol Index out of range");
198 return nullptr;
199 }
200
201 intptr_t symbolAddress = (intptr_t)elfHeader + symbolTable->sh_offset;
202 Elf64_Sym &symbol = ((Elf64_Sym*)symbolAddress)[index];
203 uint16_t section = symbol.st_shndx;
204
205 if(section != SHN_UNDEF && section < SHN_LORESERVE)
206 {
207 const SectionHeader *target = elfSection(elfHeader, symbol.st_shndx);
208 symbolValue = reinterpret_cast<void*>((intptr_t)elfHeader + symbol.st_value + target->sh_offset);
209 }
210 else
211 {
212 return nullptr;
213 }
214 }
215
216 switch(relocation.getType())
217 {
218 case R_X86_64_NONE:
219 // No relocation
220 break;
221 // case R_X86_64_64:
222 // *patchSite = (int32_t)((intptr_t)symbolValue + *patchSite) + relocation->r_addend;
223 // break;
224 case R_X86_64_PC32:
225 *patchSite = (int32_t)((intptr_t)symbolValue + *patchSite - (intptr_t)patchSite) + relocation.r_addend;
226 break;
227 // case R_X86_64_32S:
228 // *patchSite = (int32_t)((intptr_t)symbolValue + *patchSite) + relocation.r_addend;
229 // break;
230 default:
231 assert(false && "Unsupported relocation type");
232 return nullptr;
233 }
234
235 return symbolValue;
236 }
237
Nicolas Capens598f8d82016-09-26 15:09:10 -0400238 void *loadImage(uint8_t *const elfImage)
239 {
Nicolas Capens598f8d82016-09-26 15:09:10 -0400240 ElfHeader *elfHeader = (ElfHeader*)elfImage;
241
242 if(!elfHeader->checkMagic())
243 {
244 return nullptr;
245 }
246
Nicolas Capens66478362016-10-13 15:36:36 -0400247 // Expect ELF bitness to match platform
248 assert(sizeof(void*) == 8 ? elfHeader->e_machine == EM_X86_64 : elfHeader->e_machine == EM_386);
249
Nicolas Capens598f8d82016-09-26 15:09:10 -0400250 SectionHeader *sectionHeader = (SectionHeader*)(elfImage + elfHeader->e_shoff);
251 void *entry = nullptr;
252
253 for(int i = 0; i < elfHeader->e_shnum; i++)
254 {
Nicolas Capens66478362016-10-13 15:36:36 -0400255 if(sectionHeader[i].sh_type == SHT_PROGBITS)
Nicolas Capens598f8d82016-09-26 15:09:10 -0400256 {
Nicolas Capens66478362016-10-13 15:36:36 -0400257 if(sectionHeader[i].sh_flags & SHF_EXECINSTR)
258 {
259 entry = elfImage + sectionHeader[i].sh_offset;
260 }
261 }
262 else if(sectionHeader[i].sh_type == SHT_REL)
263 {
264 assert(sizeof(void*) == 4 && "UNIMPLEMENTED"); // Only expected/implemented for 32-bit code
265
266 for(int index = 0; index < sectionHeader[i].sh_size / sectionHeader[i].sh_entsize; index++)
267 {
268 const Elf32_Rel &relocation = ((const Elf32_Rel*)(elfImage + sectionHeader[i].sh_offset))[index];
269 void *symbol = relocateSymbol(elfHeader, relocation, sectionHeader[i]);
270 }
271 }
272 else if(sectionHeader[i].sh_type == SHT_RELA)
273 {
274 assert(sizeof(void*) == 8 && "UNIMPLEMENTED"); // Only expected/implemented for 64-bit code
275
276 for(int index = 0; index < sectionHeader[i].sh_size / sectionHeader[i].sh_entsize; index++)
277 {
278 const Elf64_Rela &relocation = ((const Elf64_Rela*)(elfImage + sectionHeader[i].sh_offset))[index];
279 void *symbol = relocateSymbol(elfHeader, relocation, sectionHeader[i]);
280 }
Nicolas Capens598f8d82016-09-26 15:09:10 -0400281 }
282 }
283
284 return entry;
285 }
286
287 template<typename T>
288 struct ExecutableAllocator
289 {
290 ExecutableAllocator() {};
291 template<class U> ExecutableAllocator(const ExecutableAllocator<U> &other) {};
292
293 using value_type = T;
294 using size_type = std::size_t;
295
296 T *allocate(size_type n)
297 {
298 return (T*)VirtualAlloc(NULL, sizeof(T) * n, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
299 }
300
301 void deallocate(T *p, size_type n)
302 {
303 VirtualFree(p, 0, MEM_RELEASE);
304 }
305 };
306
307 class ELFMemoryStreamer : public Ice::ELFStreamer, public Routine
308 {
309 ELFMemoryStreamer(const ELFMemoryStreamer &) = delete;
310 ELFMemoryStreamer &operator=(const ELFMemoryStreamer &) = delete;
311
312 public:
Nicolas Capens58274b52016-10-19 23:45:19 -0400313 ELFMemoryStreamer() : Routine(), entry(nullptr)
Nicolas Capens598f8d82016-09-26 15:09:10 -0400314 {
315 position = 0;
316 buffer.reserve(0x1000);
317 }
318
319 virtual ~ELFMemoryStreamer()
320 {
321 if(buffer.size() != 0)
322 {
323 DWORD exeProtection;
324 VirtualProtect(&buffer[0], buffer.size(), oldProtection, &exeProtection);
325 }
326 }
327
328 void write8(uint8_t Value) override
329 {
330 if(position == (uint64_t)buffer.size())
331 {
332 buffer.push_back(Value);
333 position++;
334 }
335 else if(position < (uint64_t)buffer.size())
336 {
337 buffer[position] = Value;
338 position++;
339 }
340 else assert(false && "UNIMPLEMENTED");
341 }
342
343 void writeBytes(llvm::StringRef Bytes) override
344 {
345 std::size_t oldSize = buffer.size();
346 buffer.resize(oldSize + Bytes.size());
347 memcpy(&buffer[oldSize], Bytes.begin(), Bytes.size());
348 position += Bytes.size();
349 }
350
351 uint64_t tell() const override { return position; }
352
353 void seek(uint64_t Off) override { position = Off; }
354
355 const void *getEntry() override
356 {
Nicolas Capens58274b52016-10-19 23:45:19 -0400357 if(!entry)
358 {
359 VirtualProtect(&buffer[0], buffer.size(), PAGE_EXECUTE_READWRITE, &oldProtection);
360 position = std::numeric_limits<std::size_t>::max(); // Can't stream more data after this
Nicolas Capens598f8d82016-09-26 15:09:10 -0400361
Nicolas Capens58274b52016-10-19 23:45:19 -0400362 entry = loadImage(&buffer[0]);
363 }
364
365 return entry;
Nicolas Capens598f8d82016-09-26 15:09:10 -0400366 }
367
368 private:
Nicolas Capens58274b52016-10-19 23:45:19 -0400369 void *entry;
Nicolas Capens598f8d82016-09-26 15:09:10 -0400370 std::vector<uint8_t, ExecutableAllocator<uint8_t>> buffer;
371 std::size_t position;
372 DWORD oldProtection;
373 };
374
375 Nucleus::Nucleus()
376 {
377 ::codegenMutex.lock(); // Reactor is currently not thread safe
378
Nicolas Capens66478362016-10-13 15:36:36 -0400379 Ice::ClFlags &Flags = Ice::ClFlags::Flags;
380 Ice::ClFlags::getParsedClFlags(Flags);
381
382 Flags.setTargetArch(sizeof(void*) == 8 ? Ice::Target_X8664 : Ice::Target_X8632);
383 Flags.setOutFileType(Ice::FT_Elf);
384 Flags.setOptLevel(Ice::Opt_2);
385 Flags.setApplicationBinaryInterface(Ice::ABI_Platform);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400386
387 std::unique_ptr<Ice::Ostream> cout(new llvm::raw_os_ostream(std::cout));
388
389 if(false) // Write out to a file
390 {
391 std::error_code errorCode;
392 ::out = new Ice::Fdstream("out.o", errorCode, llvm::sys::fs::F_None);
393 ::elfFile = new Ice::ELFFileStreamer(*out);
394 ::context = new Ice::GlobalContext(cout.get(), cout.get(), cout.get(), elfFile);
395 }
396 else
397 {
398 ELFMemoryStreamer *elfMemory = new ELFMemoryStreamer();
399 ::context = new Ice::GlobalContext(cout.get(), cout.get(), cout.get(), elfMemory);
400 ::routine = elfMemory;
401 }
402 }
403
404 Nucleus::~Nucleus()
405 {
406 delete ::allocator;
407 delete ::function;
408 delete ::context;
409
410 delete ::elfFile;
411 delete ::out;
412
413 ::codegenMutex.unlock();
414 }
415
416 Routine *Nucleus::acquireRoutine(const wchar_t *name, bool runOptimizations)
417 {
418 if(basicBlock->getInsts().empty() || basicBlock->getInsts().back().getKind() != Ice::Inst::Ret)
419 {
420 createRetVoid();
421 }
422
423 std::wstring wideName(name);
424 std::string asciiName(wideName.begin(), wideName.end());
425 ::function->setFunctionName(Ice::GlobalString::createWithString(::context, asciiName));
426
427 ::function->translate();
Nicolas Capensde19f392016-10-19 10:29:49 -0400428 assert(!::function->hasError());
429
Nicolas Capens66478362016-10-13 15:36:36 -0400430 auto *globals = ::function->getGlobalInits().release();
431
432 if(globals && !globals->empty())
433 {
434 ::context->getGlobals()->merge(globals);
435 }
Nicolas Capens598f8d82016-09-26 15:09:10 -0400436
437 ::context->emitFileHeader();
438 ::function->emitIAS();
439 auto assembler = ::function->releaseAssembler();
Nicolas Capens66478362016-10-13 15:36:36 -0400440 auto objectWriter = ::context->getObjectWriter();
441 assembler->alignFunction();
442 objectWriter->writeFunctionCode(::function->getFunctionName(), false, assembler.get());
443 ::context->lowerGlobals("last");
Nicolas Capens73dd7a22016-10-20 13:20:34 -0400444 ::context->lowerConstants();
Nicolas Capens66478362016-10-13 15:36:36 -0400445 objectWriter->setUndefinedSyms(::context->getConstantExternSyms());
446 objectWriter->writeNonUserSections();
Nicolas Capens598f8d82016-09-26 15:09:10 -0400447
448 return ::routine;
449 }
450
451 void Nucleus::optimize()
452 {
453 }
454
455 Value *Nucleus::allocateStackVariable(Type *t, int arraySize)
456 {
457 Ice::Type type = T(t);
Nicolas Capensa8f98632016-10-20 11:25:55 -0400458 int typeSize = Ice::typeWidthInBytes(type);
459 int totalSize = typeSize * (arraySize ? arraySize : 1);
Nicolas Capense12780d2016-09-27 14:18:07 -0400460
Nicolas Capensa8f98632016-10-20 11:25:55 -0400461 auto bytes = Ice::ConstantInteger32::create(::context, type, totalSize);
Nicolas Capense12780d2016-09-27 14:18:07 -0400462 auto address = ::function->makeVariable(T(getPointerType(t)));
Nicolas Capensa8f98632016-10-20 11:25:55 -0400463 auto alloca = Ice::InstAlloca::create(::function, address, bytes, typeSize);
Nicolas Capense12780d2016-09-27 14:18:07 -0400464 ::function->getEntryNode()->getInsts().push_front(alloca);
465
466 return V(address);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400467 }
468
469 BasicBlock *Nucleus::createBasicBlock()
470 {
Nicolas Capens611642a2016-09-28 16:45:04 -0400471 return B(::function->makeNode());
Nicolas Capens598f8d82016-09-26 15:09:10 -0400472 }
473
474 BasicBlock *Nucleus::getInsertBlock()
475 {
Nicolas Capens611642a2016-09-28 16:45:04 -0400476 return B(::basicBlock);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400477 }
478
479 void Nucleus::setInsertBlock(BasicBlock *basicBlock)
480 {
Nicolas Capens9ed1a182016-10-24 09:52:23 -0400481 // assert(::basicBlock->getInsts().back().getTerminatorEdges().size() >= 0 && "Previous basic block must have a terminator");
Nicolas Capens611642a2016-09-28 16:45:04 -0400482 ::basicBlock = basicBlock;
Nicolas Capens598f8d82016-09-26 15:09:10 -0400483 }
484
Nicolas Capens598f8d82016-09-26 15:09:10 -0400485 void Nucleus::createFunction(Type *ReturnType, std::vector<Type*> &Params)
486 {
487 uint32_t sequenceNumber = 0;
488 ::function = Ice::Cfg::create(::context, sequenceNumber).release();
489 ::allocator = new Ice::CfgLocalAllocatorScope(::function);
490
491 for(Type *type : Params)
492 {
493 Ice::Variable *arg = ::function->makeVariable(T(type));
494 ::function->addArg(arg);
495 }
496
497 Ice::CfgNode *node = ::function->makeNode();
498 ::function->setEntryNode(node);
499 ::basicBlock = node;
500 }
501
502 Value *Nucleus::getArgument(unsigned int index)
503 {
504 return V(::function->getArgs()[index]);
505 }
506
507 void Nucleus::createRetVoid()
508 {
Nicolas Capensfdcca2d2016-10-20 11:31:36 -0400509 Ice::InstRet *ret = Ice::InstRet::create(::function);
510 ::basicBlock->appendInst(ret);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400511 }
512
513 void Nucleus::createRet(Value *v)
514 {
Nicolas Capensfdcca2d2016-10-20 11:31:36 -0400515 Ice::InstRet *ret = Ice::InstRet::create(::function, v);
516 ::basicBlock->appendInst(ret);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400517 }
518
519 void Nucleus::createBr(BasicBlock *dest)
520 {
Nicolas Capens611642a2016-09-28 16:45:04 -0400521 auto br = Ice::InstBr::create(::function, dest);
522 ::basicBlock->appendInst(br);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400523 }
524
525 void Nucleus::createCondBr(Value *cond, BasicBlock *ifTrue, BasicBlock *ifFalse)
526 {
Nicolas Capens611642a2016-09-28 16:45:04 -0400527 auto br = Ice::InstBr::create(::function, cond, ifTrue, ifFalse);
528 ::basicBlock->appendInst(br);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400529 }
530
Nicolas Capens7d9f76d2016-09-29 13:39:44 -0400531 static Value *createArithmetic(Ice::InstArithmetic::OpKind op, Value *lhs, Value *rhs)
532 {
Nicolas Capens327f1df2016-10-21 14:26:34 -0400533 assert(lhs->getType() == rhs->getType() || (llvm::isa<Ice::Constant>(rhs) && (op == Ice::InstArithmetic::Shl || Ice::InstArithmetic::Lshr || Ice::InstArithmetic::Ashr)));
Nicolas Capens7d9f76d2016-09-29 13:39:44 -0400534
535 Ice::Variable *result = ::function->makeVariable(lhs->getType());
536 Ice::InstArithmetic *arithmetic = Ice::InstArithmetic::create(::function, op, result, lhs, rhs);
537 ::basicBlock->appendInst(arithmetic);
538
539 return V(result);
540 }
541
Nicolas Capens598f8d82016-09-26 15:09:10 -0400542 Value *Nucleus::createAdd(Value *lhs, Value *rhs)
543 {
Nicolas Capens7d9f76d2016-09-29 13:39:44 -0400544 return createArithmetic(Ice::InstArithmetic::Add, lhs, rhs);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400545 }
546
547 Value *Nucleus::createSub(Value *lhs, Value *rhs)
548 {
Nicolas Capens7d9f76d2016-09-29 13:39:44 -0400549 return createArithmetic(Ice::InstArithmetic::Sub, lhs, rhs);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400550 }
551
552 Value *Nucleus::createMul(Value *lhs, Value *rhs)
553 {
Nicolas Capens7d9f76d2016-09-29 13:39:44 -0400554 return createArithmetic(Ice::InstArithmetic::Mul, lhs, rhs);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400555 }
556
557 Value *Nucleus::createUDiv(Value *lhs, Value *rhs)
558 {
Nicolas Capens7d9f76d2016-09-29 13:39:44 -0400559 return createArithmetic(Ice::InstArithmetic::Udiv, lhs, rhs);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400560 }
561
562 Value *Nucleus::createSDiv(Value *lhs, Value *rhs)
563 {
Nicolas Capens7d9f76d2016-09-29 13:39:44 -0400564 return createArithmetic(Ice::InstArithmetic::Sdiv, lhs, rhs);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400565 }
566
567 Value *Nucleus::createFAdd(Value *lhs, Value *rhs)
568 {
Nicolas Capens7d9f76d2016-09-29 13:39:44 -0400569 return createArithmetic(Ice::InstArithmetic::Fadd, lhs, rhs);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400570 }
571
572 Value *Nucleus::createFSub(Value *lhs, Value *rhs)
573 {
Nicolas Capens7d9f76d2016-09-29 13:39:44 -0400574 return createArithmetic(Ice::InstArithmetic::Fsub, lhs, rhs);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400575 }
576
577 Value *Nucleus::createFMul(Value *lhs, Value *rhs)
578 {
Nicolas Capens7d9f76d2016-09-29 13:39:44 -0400579 return createArithmetic(Ice::InstArithmetic::Fmul, lhs, rhs);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400580 }
581
582 Value *Nucleus::createFDiv(Value *lhs, Value *rhs)
583 {
Nicolas Capens7d9f76d2016-09-29 13:39:44 -0400584 return createArithmetic(Ice::InstArithmetic::Fdiv, lhs, rhs);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400585 }
586
587 Value *Nucleus::createURem(Value *lhs, Value *rhs)
588 {
Nicolas Capens7d9f76d2016-09-29 13:39:44 -0400589 return createArithmetic(Ice::InstArithmetic::Urem, lhs, rhs);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400590 }
591
592 Value *Nucleus::createSRem(Value *lhs, Value *rhs)
593 {
Nicolas Capens7d9f76d2016-09-29 13:39:44 -0400594 return createArithmetic(Ice::InstArithmetic::Srem, lhs, rhs);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400595 }
596
597 Value *Nucleus::createFRem(Value *lhs, Value *rhs)
598 {
Nicolas Capens7d9f76d2016-09-29 13:39:44 -0400599 return createArithmetic(Ice::InstArithmetic::Frem, lhs, rhs);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400600 }
601
602 Value *Nucleus::createShl(Value *lhs, Value *rhs)
603 {
Nicolas Capens7d9f76d2016-09-29 13:39:44 -0400604 return createArithmetic(Ice::InstArithmetic::Shl, lhs, rhs);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400605 }
606
607 Value *Nucleus::createLShr(Value *lhs, Value *rhs)
608 {
Nicolas Capens7d9f76d2016-09-29 13:39:44 -0400609 return createArithmetic(Ice::InstArithmetic::Lshr, lhs, rhs);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400610 }
611
612 Value *Nucleus::createAShr(Value *lhs, Value *rhs)
613 {
Nicolas Capens7d9f76d2016-09-29 13:39:44 -0400614 return createArithmetic(Ice::InstArithmetic::Ashr, lhs, rhs);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400615 }
616
617 Value *Nucleus::createAnd(Value *lhs, Value *rhs)
618 {
Nicolas Capens7d9f76d2016-09-29 13:39:44 -0400619 return createArithmetic(Ice::InstArithmetic::And, lhs, rhs);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400620 }
621
622 Value *Nucleus::createOr(Value *lhs, Value *rhs)
623 {
Nicolas Capens7d9f76d2016-09-29 13:39:44 -0400624 return createArithmetic(Ice::InstArithmetic::Or, lhs, rhs);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400625 }
626
627 Value *Nucleus::createXor(Value *lhs, Value *rhs)
628 {
Nicolas Capens7d9f76d2016-09-29 13:39:44 -0400629 return createArithmetic(Ice::InstArithmetic::Xor, lhs, rhs);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400630 }
631
Nicolas Capens13ac2322016-10-13 14:52:12 -0400632 static Value *createAssign(Ice::Constant *constant)
Nicolas Capensb955d5b2016-09-28 22:36:28 -0400633 {
634 Ice::Variable *value = ::function->makeVariable(constant->getType());
635 auto assign = Ice::InstAssign::create(::function, value, constant);
636 ::basicBlock->appendInst(assign);
637
638 return V(value);
639 }
640
Nicolas Capens598f8d82016-09-26 15:09:10 -0400641 Value *Nucleus::createNeg(Value *v)
642 {
643 assert(false && "UNIMPLEMENTED"); return nullptr;
644 }
645
646 Value *Nucleus::createFNeg(Value *v)
647 {
648 assert(false && "UNIMPLEMENTED"); return nullptr;
649 }
650
651 Value *Nucleus::createNot(Value *v)
652 {
653 assert(false && "UNIMPLEMENTED"); return nullptr;
654 }
655
Nicolas Capense12780d2016-09-27 14:18:07 -0400656 Value *Nucleus::createLoad(Value *ptr, Type *type, bool isVolatile, unsigned int align)
Nicolas Capens598f8d82016-09-26 15:09:10 -0400657 {
Nicolas Capens23d99a42016-09-30 14:57:16 -0400658 int valueType = (int)reinterpret_cast<intptr_t>(type);
659 Ice::Variable *result = ::function->makeVariable(T(type));
660
661 if(valueType & EmulatedBits)
662 {
663 switch(valueType)
664 {
665 case Type_v4i8:
666 case Type_v2i16:
667 {
668 const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::LoadSubVector, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F};
669 auto target = ::context->getConstantUndef(Ice::IceType_i32);
670 auto load = Ice::InstIntrinsicCall::create(::function, 2, result, target, intrinsic);
671 load->addArg(::context->getConstantInt32(4));
672 load->addArg(ptr);
673 ::basicBlock->appendInst(load);
674 }
675 break;
676 case Type_v2i32:
677 case Type_v8i8:
678 case Type_v4i16:
Nicolas Capens4cfd4572016-10-20 01:00:19 -0400679 case Type_v2f32:
Nicolas Capens23d99a42016-09-30 14:57:16 -0400680 {
681 const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::LoadSubVector, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F};
682 auto target = ::context->getConstantUndef(Ice::IceType_i32);
683 auto load = Ice::InstIntrinsicCall::create(::function, 2, result, target, intrinsic);
684 load->addArg(::context->getConstantInt32(8));
685 load->addArg(ptr);
686 ::basicBlock->appendInst(load);
687 }
688 break;
689 default: assert(false && "UNIMPLEMENTED");
690 }
691 }
692 else
693 {
694 auto load = Ice::InstLoad::create(::function, result, ptr, align);
695 ::basicBlock->appendInst(load);
696 }
697
698 return V(result);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400699 }
700
Nicolas Capens6d738712016-09-30 04:15:22 -0400701 Value *Nucleus::createStore(Value *value, Value *ptr, Type *type, bool isVolatile, unsigned int align)
Nicolas Capens598f8d82016-09-26 15:09:10 -0400702 {
Nicolas Capens23d99a42016-09-30 14:57:16 -0400703 int valueType = (int)reinterpret_cast<intptr_t>(type);
704
705 if(valueType & EmulatedBits)
706 {
707 switch(valueType)
708 {
709 case Type_v4i8:
710 case Type_v2i16:
711 {
712 const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::StoreSubVector, Ice::Intrinsics::SideEffects_T, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_T};
713 auto target = ::context->getConstantUndef(Ice::IceType_i32);
714 auto store = Ice::InstIntrinsicCall::create(::function, 3, nullptr, target, intrinsic);
715 store->addArg(::context->getConstantInt32(4));
716 store->addArg(value);
717 store->addArg(ptr);
718 ::basicBlock->appendInst(store);
719 }
720 break;
721 case Type_v2i32:
722 case Type_v8i8:
723 case Type_v4i16:
Nicolas Capens4cfd4572016-10-20 01:00:19 -0400724 case Type_v2f32:
Nicolas Capens23d99a42016-09-30 14:57:16 -0400725 {
726 const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::StoreSubVector, Ice::Intrinsics::SideEffects_T, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_T};
727 auto target = ::context->getConstantUndef(Ice::IceType_i32);
728 auto store = Ice::InstIntrinsicCall::create(::function, 3, nullptr, target, intrinsic);
729 store->addArg(::context->getConstantInt32(8));
730 store->addArg(value);
731 store->addArg(ptr);
732 ::basicBlock->appendInst(store);
733 }
734 break;
735 default: assert(false && "UNIMPLEMENTED");
736 }
737 }
738 else
739 {
740 assert(T(value->getType()) == type);
741
742 auto store = Ice::InstStore::create(::function, value, ptr, align);
743 ::basicBlock->appendInst(store);
744 }
745
Nicolas Capens598f8d82016-09-26 15:09:10 -0400746 return value;
747 }
748
Nicolas Capens6d738712016-09-30 04:15:22 -0400749 Value *Nucleus::createGEP(Value *ptr, Type *type, Value *index)
Nicolas Capens598f8d82016-09-26 15:09:10 -0400750 {
Nicolas Capens8820f642016-09-30 04:42:43 -0400751 assert(index->getType() == Ice::IceType_i32);
752
753 if(!Ice::isByteSizedType(T(type)))
754 {
Nicolas Capens13ac2322016-10-13 14:52:12 -0400755 index = createMul(index, createConstantInt((int)Ice::typeWidthInBytes(T(type))));
Nicolas Capens8820f642016-09-30 04:42:43 -0400756 }
757
758 if(sizeof(void*) == 8)
759 {
760 index = createSExt(index, T(Ice::IceType_i64));
761 }
762
763 return createAdd(ptr, index);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400764 }
765
766 Value *Nucleus::createAtomicAdd(Value *ptr, Value *value)
767 {
768 assert(false && "UNIMPLEMENTED"); return nullptr;
769 }
770
Nicolas Capensa0c2fc52016-09-30 05:04:21 -0400771 static Value *createCast(Ice::InstCast::OpKind op, Value *v, Type *destType)
772 {
Nicolas Capens23d99a42016-09-30 14:57:16 -0400773 if(v->getType() == T(destType))
Nicolas Capensa0c2fc52016-09-30 05:04:21 -0400774 {
775 return v;
776 }
777
778 Ice::Variable *result = ::function->makeVariable(T(destType));
779 Ice::InstCast *cast = Ice::InstCast::create(::function, op, result, v);
780 ::basicBlock->appendInst(cast);
781
782 return V(result);
783 }
784
Nicolas Capens598f8d82016-09-26 15:09:10 -0400785 Value *Nucleus::createTrunc(Value *v, Type *destType)
786 {
Nicolas Capensa0c2fc52016-09-30 05:04:21 -0400787 return createCast(Ice::InstCast::Trunc, v, destType);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400788 }
789
790 Value *Nucleus::createZExt(Value *v, Type *destType)
791 {
Nicolas Capensa0c2fc52016-09-30 05:04:21 -0400792 return createCast(Ice::InstCast::Zext, v, destType);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400793 }
794
795 Value *Nucleus::createSExt(Value *v, Type *destType)
796 {
Nicolas Capensa0c2fc52016-09-30 05:04:21 -0400797 return createCast(Ice::InstCast::Sext, v, destType);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400798 }
799
800 Value *Nucleus::createFPToSI(Value *v, Type *destType)
801 {
Nicolas Capensa0c2fc52016-09-30 05:04:21 -0400802 return createCast(Ice::InstCast::Fptosi, v, destType);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400803 }
804
805 Value *Nucleus::createUIToFP(Value *v, Type *destType)
806 {
Nicolas Capensa0c2fc52016-09-30 05:04:21 -0400807 return createCast(Ice::InstCast::Uitofp, v, destType);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400808 }
809
810 Value *Nucleus::createSIToFP(Value *v, Type *destType)
811 {
Nicolas Capensa0c2fc52016-09-30 05:04:21 -0400812 return createCast(Ice::InstCast::Sitofp, v, destType);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400813 }
814
815 Value *Nucleus::createFPTrunc(Value *v, Type *destType)
816 {
Nicolas Capensa0c2fc52016-09-30 05:04:21 -0400817 return createCast(Ice::InstCast::Fptrunc, v, destType);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400818 }
819
820 Value *Nucleus::createFPExt(Value *v, Type *destType)
821 {
Nicolas Capensa0c2fc52016-09-30 05:04:21 -0400822 return createCast(Ice::InstCast::Fpext, v, destType);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400823 }
824
825 Value *Nucleus::createBitCast(Value *v, Type *destType)
826 {
Nicolas Capensa0c2fc52016-09-30 05:04:21 -0400827 return createCast(Ice::InstCast::Bitcast, v, destType);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400828 }
829
830 Value *Nucleus::createIntCast(Value *v, Type *destType, bool isSigned)
831 {
832 assert(false && "UNIMPLEMENTED"); return nullptr;
833 }
834
Nicolas Capens43dc6292016-10-20 00:01:38 -0400835 static Value *createIntCompare(Ice::InstIcmp::ICond condition, Value *lhs, Value *rhs)
Nicolas Capens598f8d82016-09-26 15:09:10 -0400836 {
Nicolas Capens611642a2016-09-28 16:45:04 -0400837 assert(lhs->getType() == rhs->getType());
838
Nicolas Capens43dc6292016-10-20 00:01:38 -0400839 auto result = ::function->makeVariable(Ice::isScalarIntegerType(lhs->getType()) ? Ice::IceType_i1 : lhs->getType());
840 auto cmp = Ice::InstIcmp::create(::function, condition, result, lhs, rhs);
Nicolas Capens611642a2016-09-28 16:45:04 -0400841 ::basicBlock->appendInst(cmp);
842
843 return V(result);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400844 }
845
Nicolas Capens43dc6292016-10-20 00:01:38 -0400846 Value *Nucleus::createICmpEQ(Value *lhs, Value *rhs)
847 {
848 return createIntCompare(Ice::InstIcmp::Eq, lhs, rhs);
849 }
850
851 Value *Nucleus::createICmpNE(Value *lhs, Value *rhs)
852 {
853 return createIntCompare(Ice::InstIcmp::Ne, lhs, rhs);
854 }
855
856 Value *Nucleus::createICmpUGT(Value *lhs, Value *rhs)
857 {
858 return createIntCompare(Ice::InstIcmp::Ugt, lhs, rhs);
859 }
860
861 Value *Nucleus::createICmpUGE(Value *lhs, Value *rhs)
862 {
863 return createIntCompare(Ice::InstIcmp::Uge, lhs, rhs);
864 }
865
866 Value *Nucleus::createICmpULT(Value *lhs, Value *rhs)
867 {
868 return createIntCompare(Ice::InstIcmp::Ult, lhs, rhs);
869 }
870
871 Value *Nucleus::createICmpULE(Value *lhs, Value *rhs)
872 {
873 return createIntCompare(Ice::InstIcmp::Ule, lhs, rhs);
874 }
875
876 Value *Nucleus::createICmpSGT(Value *lhs, Value *rhs)
877 {
878 return createIntCompare(Ice::InstIcmp::Sgt, lhs, rhs);
879 }
880
881 Value *Nucleus::createICmpSGE(Value *lhs, Value *rhs)
882 {
883 return createIntCompare(Ice::InstIcmp::Sge, lhs, rhs);
884 }
885
886 Value *Nucleus::createICmpSLT(Value *lhs, Value *rhs)
887 {
888 return createIntCompare(Ice::InstIcmp::Slt, lhs, rhs);
889 }
890
Nicolas Capens598f8d82016-09-26 15:09:10 -0400891 Value *Nucleus::createICmpSLE(Value *lhs, Value *rhs)
892 {
Nicolas Capens43dc6292016-10-20 00:01:38 -0400893 return createIntCompare(Ice::InstIcmp::Sle, lhs, rhs);
894 }
895
896 static Value *createFloatCompare(Ice::InstFcmp::FCond condition, Value *lhs, Value *rhs)
897 {
898 assert(lhs->getType() == rhs->getType());
899 assert(Ice::isScalarFloatingType(lhs->getType()) || lhs->getType() == Ice::IceType_v4f32);
900
901 auto result = ::function->makeVariable(Ice::isScalarFloatingType(lhs->getType()) ? Ice::IceType_i1 : Ice::IceType_v4i32);
902 auto cmp = Ice::InstFcmp::create(::function, condition, result, lhs, rhs);
903 ::basicBlock->appendInst(cmp);
904
905 return V(result);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400906 }
907
908 Value *Nucleus::createFCmpOEQ(Value *lhs, Value *rhs)
909 {
Nicolas Capens43dc6292016-10-20 00:01:38 -0400910 return createFloatCompare(Ice::InstFcmp::Oeq, lhs, rhs);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400911 }
912
913 Value *Nucleus::createFCmpOGT(Value *lhs, Value *rhs)
914 {
Nicolas Capens43dc6292016-10-20 00:01:38 -0400915 return createFloatCompare(Ice::InstFcmp::Ogt, lhs, rhs);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400916 }
917
918 Value *Nucleus::createFCmpOGE(Value *lhs, Value *rhs)
919 {
Nicolas Capens43dc6292016-10-20 00:01:38 -0400920 return createFloatCompare(Ice::InstFcmp::Oge, lhs, rhs);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400921 }
922
923 Value *Nucleus::createFCmpOLT(Value *lhs, Value *rhs)
924 {
Nicolas Capens43dc6292016-10-20 00:01:38 -0400925 return createFloatCompare(Ice::InstFcmp::Olt, lhs, rhs);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400926 }
927
928 Value *Nucleus::createFCmpOLE(Value *lhs, Value *rhs)
929 {
Nicolas Capens43dc6292016-10-20 00:01:38 -0400930 return createFloatCompare(Ice::InstFcmp::Ole, lhs, rhs);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400931 }
932
933 Value *Nucleus::createFCmpONE(Value *lhs, Value *rhs)
934 {
Nicolas Capens43dc6292016-10-20 00:01:38 -0400935 return createFloatCompare(Ice::InstFcmp::One, lhs, rhs);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400936 }
937
938 Value *Nucleus::createFCmpORD(Value *lhs, Value *rhs)
939 {
Nicolas Capens43dc6292016-10-20 00:01:38 -0400940 return createFloatCompare(Ice::InstFcmp::Ord, lhs, rhs);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400941 }
942
943 Value *Nucleus::createFCmpUNO(Value *lhs, Value *rhs)
944 {
Nicolas Capens43dc6292016-10-20 00:01:38 -0400945 return createFloatCompare(Ice::InstFcmp::Uno, lhs, rhs);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400946 }
947
948 Value *Nucleus::createFCmpUEQ(Value *lhs, Value *rhs)
949 {
Nicolas Capens43dc6292016-10-20 00:01:38 -0400950 return createFloatCompare(Ice::InstFcmp::Ueq, lhs, rhs);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400951 }
952
953 Value *Nucleus::createFCmpUGT(Value *lhs, Value *rhs)
954 {
Nicolas Capens43dc6292016-10-20 00:01:38 -0400955 return createFloatCompare(Ice::InstFcmp::Ugt, lhs, rhs);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400956 }
957
958 Value *Nucleus::createFCmpUGE(Value *lhs, Value *rhs)
959 {
Nicolas Capens43dc6292016-10-20 00:01:38 -0400960 return createFloatCompare(Ice::InstFcmp::Uge, lhs, rhs);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400961 }
962
963 Value *Nucleus::createFCmpULT(Value *lhs, Value *rhs)
964 {
Nicolas Capens43dc6292016-10-20 00:01:38 -0400965 return createFloatCompare(Ice::InstFcmp::Ult, lhs, rhs);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400966 }
967
968 Value *Nucleus::createFCmpULE(Value *lhs, Value *rhs)
969 {
Nicolas Capens43dc6292016-10-20 00:01:38 -0400970 return createFloatCompare(Ice::InstFcmp::Ule, lhs, rhs);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400971 }
972
973 Value *Nucleus::createFCmpUNE(Value *lhs, Value *rhs)
974 {
Nicolas Capens43dc6292016-10-20 00:01:38 -0400975 return createFloatCompare(Ice::InstFcmp::Une, lhs, rhs);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400976 }
977
Nicolas Capense95d5342016-09-30 11:37:28 -0400978 Value *Nucleus::createExtractElement(Value *vector, Type *type, int index)
Nicolas Capens598f8d82016-09-26 15:09:10 -0400979 {
Nicolas Capens9709d4f2016-09-30 11:44:14 -0400980 auto result = ::function->makeVariable(T(type));
981 auto extract = Ice::InstExtractElement::create(::function, result, vector, ::context->getConstantInt32(index));
982 ::basicBlock->appendInst(extract);
983
984 return V(result);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400985 }
986
987 Value *Nucleus::createInsertElement(Value *vector, Value *element, int index)
988 {
Nicolas Capens9709d4f2016-09-30 11:44:14 -0400989 auto result = ::function->makeVariable(vector->getType());
990 auto insert = Ice::InstInsertElement::create(::function, result, vector, element, ::context->getConstantInt32(index));
991 ::basicBlock->appendInst(insert);
992
993 return V(result);
Nicolas Capens598f8d82016-09-26 15:09:10 -0400994 }
995
Nicolas Capense89cd582016-09-30 14:23:47 -0400996 Value *Nucleus::createShuffleVector(Value *V1, Value *V2, const int *select)
Nicolas Capens598f8d82016-09-26 15:09:10 -0400997 {
Nicolas Capens619c0ab2016-09-30 14:46:24 -0400998 assert(V1->getType() == V2->getType());
999
1000 int size = Ice::typeNumElements(V1->getType());
1001 auto result = ::function->makeVariable(V1->getType());
1002 auto shuffle = Ice::InstShuffleVector::create(::function, result, V1, V2);
1003
1004 for(int i = 0; i < size; i++)
1005 {
1006 shuffle->addIndex(llvm::cast<Ice::ConstantInteger32>(::context->getConstantInt32(select[i])));
1007 }
1008
1009 ::basicBlock->appendInst(shuffle);
1010
1011 return V(result);
Nicolas Capens598f8d82016-09-26 15:09:10 -04001012 }
1013
1014 Value *Nucleus::createSelect(Value *C, Value *ifTrue, Value *ifFalse)
1015 {
1016 assert(false && "UNIMPLEMENTED"); return nullptr;
1017 }
1018
1019 Value *Nucleus::createSwitch(Value *v, BasicBlock *Dest, unsigned NumCases)
1020 {
1021 assert(false && "UNIMPLEMENTED"); return nullptr;
1022 }
1023
1024 void Nucleus::addSwitchCase(Value *Switch, int Case, BasicBlock *Branch)
1025 {
1026 assert(false && "UNIMPLEMENTED"); return;
1027 }
1028
1029 void Nucleus::createUnreachable()
1030 {
Nicolas Capensfdcca2d2016-10-20 11:31:36 -04001031 Ice::InstUnreachable *unreachable = Ice::InstUnreachable::create(::function);
1032 ::basicBlock->appendInst(unreachable);
Nicolas Capens598f8d82016-09-26 15:09:10 -04001033 }
1034
Nicolas Capense95d5342016-09-30 11:37:28 -04001035 static Value *createSwizzle4(Value *val, unsigned char select)
Nicolas Capens598f8d82016-09-26 15:09:10 -04001036 {
Nicolas Capens619c0ab2016-09-30 14:46:24 -04001037 int swizzle[4] =
1038 {
1039 (select >> 0) & 0x03,
1040 (select >> 2) & 0x03,
1041 (select >> 4) & 0x03,
1042 (select >> 6) & 0x03,
1043 };
Nicolas Capens9709d4f2016-09-30 11:44:14 -04001044
Nicolas Capens619c0ab2016-09-30 14:46:24 -04001045 return Nucleus::createShuffleVector(val, val, swizzle);
Nicolas Capens598f8d82016-09-26 15:09:10 -04001046 }
1047
Nicolas Capense95d5342016-09-30 11:37:28 -04001048 static Value *createMask4(Value *lhs, Value *rhs, unsigned char select)
Nicolas Capens598f8d82016-09-26 15:09:10 -04001049 {
1050 assert(false && "UNIMPLEMENTED"); return nullptr;
1051 }
1052
Nicolas Capens73dd7a22016-10-20 13:20:34 -04001053 Value *Nucleus::createConstantPointer(const void *address, Type *Ty, unsigned int align)
Nicolas Capens598f8d82016-09-26 15:09:10 -04001054 {
Nicolas Capens8dfd9a72016-10-13 17:44:51 -04001055 if(sizeof(void*) == 8)
1056 {
1057 return createAssign(::context->getConstantInt64(reinterpret_cast<intptr_t>(address)));
1058 }
1059 else
1060 {
1061 return createAssign(::context->getConstantInt32(reinterpret_cast<intptr_t>(address)));
1062 }
Nicolas Capens598f8d82016-09-26 15:09:10 -04001063 }
1064
1065 Type *Nucleus::getPointerType(Type *ElementType)
1066 {
Nicolas Capense12780d2016-09-27 14:18:07 -04001067 if(sizeof(void*) == 8)
1068 {
1069 return T(Ice::IceType_i64);
1070 }
1071 else
1072 {
1073 return T(Ice::IceType_i32);
1074 }
Nicolas Capens598f8d82016-09-26 15:09:10 -04001075 }
1076
Nicolas Capens13ac2322016-10-13 14:52:12 -04001077 Value *Nucleus::createNullValue(Type *Ty)
Nicolas Capens598f8d82016-09-26 15:09:10 -04001078 {
Nicolas Capens73dd7a22016-10-20 13:20:34 -04001079 if(Ice::isVectorType(T(Ty)))
1080 {
1081 int64_t c[4] = {0, 0, 0, 0};
1082 return createConstantVector(c, Ty);
1083 }
1084 else
1085 {
1086 return createAssign(::context->getConstantZero(T(Ty)));
1087 }
Nicolas Capens598f8d82016-09-26 15:09:10 -04001088 }
1089
Nicolas Capens13ac2322016-10-13 14:52:12 -04001090 Value *Nucleus::createConstantLong(int64_t i)
Nicolas Capens598f8d82016-09-26 15:09:10 -04001091 {
Nicolas Capens73dd7a22016-10-20 13:20:34 -04001092 return createAssign(::context->getConstantInt64(i));
Nicolas Capens598f8d82016-09-26 15:09:10 -04001093 }
1094
Nicolas Capens13ac2322016-10-13 14:52:12 -04001095 Value *Nucleus::createConstantInt(int i)
Nicolas Capens598f8d82016-09-26 15:09:10 -04001096 {
Nicolas Capens13ac2322016-10-13 14:52:12 -04001097 return createAssign(::context->getConstantInt32(i));
Nicolas Capens598f8d82016-09-26 15:09:10 -04001098 }
1099
Nicolas Capens13ac2322016-10-13 14:52:12 -04001100 Value *Nucleus::createConstantInt(unsigned int i)
Nicolas Capens598f8d82016-09-26 15:09:10 -04001101 {
Nicolas Capens73dd7a22016-10-20 13:20:34 -04001102 return createAssign(::context->getConstantInt32(i));
Nicolas Capens598f8d82016-09-26 15:09:10 -04001103 }
1104
Nicolas Capens13ac2322016-10-13 14:52:12 -04001105 Value *Nucleus::createConstantBool(bool b)
Nicolas Capens598f8d82016-09-26 15:09:10 -04001106 {
Nicolas Capens73dd7a22016-10-20 13:20:34 -04001107 return createAssign(::context->getConstantInt1(b));
Nicolas Capens598f8d82016-09-26 15:09:10 -04001108 }
1109
Nicolas Capens13ac2322016-10-13 14:52:12 -04001110 Value *Nucleus::createConstantByte(signed char i)
Nicolas Capens598f8d82016-09-26 15:09:10 -04001111 {
Nicolas Capens73dd7a22016-10-20 13:20:34 -04001112 return createAssign(::context->getConstantInt8(i));
Nicolas Capens598f8d82016-09-26 15:09:10 -04001113 }
1114
Nicolas Capens13ac2322016-10-13 14:52:12 -04001115 Value *Nucleus::createConstantByte(unsigned char i)
Nicolas Capens598f8d82016-09-26 15:09:10 -04001116 {
Nicolas Capens73dd7a22016-10-20 13:20:34 -04001117 return createAssign(::context->getConstantInt8(i));
Nicolas Capens598f8d82016-09-26 15:09:10 -04001118 }
1119
Nicolas Capens13ac2322016-10-13 14:52:12 -04001120 Value *Nucleus::createConstantShort(short i)
Nicolas Capens598f8d82016-09-26 15:09:10 -04001121 {
Nicolas Capens8dfd9a72016-10-13 17:44:51 -04001122 return createAssign(::context->getConstantInt16(i));
Nicolas Capens598f8d82016-09-26 15:09:10 -04001123 }
1124
Nicolas Capens13ac2322016-10-13 14:52:12 -04001125 Value *Nucleus::createConstantShort(unsigned short i)
Nicolas Capens598f8d82016-09-26 15:09:10 -04001126 {
Nicolas Capens73dd7a22016-10-20 13:20:34 -04001127 return createAssign(::context->getConstantInt16(i));
Nicolas Capens598f8d82016-09-26 15:09:10 -04001128 }
1129
Nicolas Capens13ac2322016-10-13 14:52:12 -04001130 Value *Nucleus::createConstantFloat(float x)
Nicolas Capens598f8d82016-09-26 15:09:10 -04001131 {
Nicolas Capens73dd7a22016-10-20 13:20:34 -04001132 return createAssign(::context->getConstantFloat(x));
Nicolas Capens598f8d82016-09-26 15:09:10 -04001133 }
1134
Nicolas Capens13ac2322016-10-13 14:52:12 -04001135 Value *Nucleus::createNullPointer(Type *Ty)
Nicolas Capens598f8d82016-09-26 15:09:10 -04001136 {
Nicolas Capens73dd7a22016-10-20 13:20:34 -04001137 if(true)
1138 {
1139 return createNullValue(T(sizeof(void*) == 8 ? Ice::IceType_i64 : Ice::IceType_i32));
1140 }
1141 else
1142 {
1143 return createConstantPointer(nullptr, Ty);
1144 }
Nicolas Capens598f8d82016-09-26 15:09:10 -04001145 }
1146
Nicolas Capens7f3f69c2016-10-20 01:29:33 -04001147 Value *Nucleus::createConstantVector(const int64_t *constants, Type *type)
Nicolas Capens13ac2322016-10-13 14:52:12 -04001148 {
Nicolas Capens8dfd9a72016-10-13 17:44:51 -04001149 const int vectorSize = 16;
1150 assert(Ice::typeWidthInBytes(T(type)) == vectorSize);
1151 const int alignment = vectorSize;
1152 auto globalPool = ::function->getGlobalPool();
1153
Nicolas Capens7f3f69c2016-10-20 01:29:33 -04001154 const int64_t *i = constants;
1155 const double *f = reinterpret_cast<const double*>(constants);
Nicolas Capens8dfd9a72016-10-13 17:44:51 -04001156 Ice::VariableDeclaration::DataInitializer *dataInitializer = nullptr;
Nicolas Capens7f3f69c2016-10-20 01:29:33 -04001157
Nicolas Capens8dfd9a72016-10-13 17:44:51 -04001158 switch((int)reinterpret_cast<intptr_t>(type))
1159 {
1160 case Ice::IceType_v4i32:
Nicolas Capens7f3f69c2016-10-20 01:29:33 -04001161 {
1162 const int initializer[4] = {(int)i[0], (int)i[1], (int)i[2], (int)i[3]};
1163 static_assert(sizeof(initializer) == vectorSize, "!");
1164 dataInitializer = Ice::VariableDeclaration::DataInitializer::create(globalPool, (const char*)initializer, vectorSize);
1165 }
1166 break;
Nicolas Capens8dfd9a72016-10-13 17:44:51 -04001167 case Ice::IceType_v4f32:
1168 {
Nicolas Capens7f3f69c2016-10-20 01:29:33 -04001169 const float initializer[4] = {(float)f[0], (float)f[1], (float)f[2], (float)f[3]};
Nicolas Capens8dfd9a72016-10-13 17:44:51 -04001170 static_assert(sizeof(initializer) == vectorSize, "!");
1171 dataInitializer = Ice::VariableDeclaration::DataInitializer::create(globalPool, (const char*)initializer, vectorSize);
1172 }
1173 break;
1174 case Ice::IceType_v8i16:
1175 {
Nicolas Capens7f3f69c2016-10-20 01:29:33 -04001176 const short initializer[8] = {(short)i[0], (short)i[1], (short)i[2], (short)i[3], (short)i[4], (short)i[5], (short)i[6], (short)i[7]};
Nicolas Capens8dfd9a72016-10-13 17:44:51 -04001177 static_assert(sizeof(initializer) == vectorSize, "!");
1178 dataInitializer = Ice::VariableDeclaration::DataInitializer::create(globalPool, (const char*)initializer, vectorSize);
1179 }
1180 break;
1181 case Ice::IceType_v16i8:
1182 {
Nicolas Capens7f3f69c2016-10-20 01:29:33 -04001183 const char initializer[16] = {(char)i[0], (char)i[1], (char)i[2], (char)i[3], (char)i[4], (char)i[5], (char)i[6], (char)i[7], (char)i[8], (char)i[9], (char)i[10], (char)i[11], (char)i[12], (char)i[13], (char)i[14], (char)i[15]};
Nicolas Capens8dfd9a72016-10-13 17:44:51 -04001184 static_assert(sizeof(initializer) == vectorSize, "!");
1185 dataInitializer = Ice::VariableDeclaration::DataInitializer::create(globalPool, (const char*)initializer, vectorSize);
1186 }
1187 break;
1188 case Type_v2i32:
Nicolas Capens7f3f69c2016-10-20 01:29:33 -04001189 {
1190 const int initializer[4] = {(int)i[0], (int)i[1], (int)i[0], (int)i[1]};
1191 static_assert(sizeof(initializer) == vectorSize, "!");
1192 dataInitializer = Ice::VariableDeclaration::DataInitializer::create(globalPool, (const char*)initializer, vectorSize);
1193 }
1194 break;
Nicolas Capens4cfd4572016-10-20 01:00:19 -04001195 case Type_v2f32:
Nicolas Capens8dfd9a72016-10-13 17:44:51 -04001196 {
Nicolas Capens7f3f69c2016-10-20 01:29:33 -04001197 const float initializer[4] = {(float)f[0], (float)f[1], (float)f[0], (float)f[1]};
Nicolas Capens8dfd9a72016-10-13 17:44:51 -04001198 static_assert(sizeof(initializer) == vectorSize, "!");
1199 dataInitializer = Ice::VariableDeclaration::DataInitializer::create(globalPool, (const char*)initializer, vectorSize);
1200 }
1201 break;
1202 case Type_v4i16:
1203 {
Nicolas Capens7f3f69c2016-10-20 01:29:33 -04001204 const short initializer[8] = {(short)i[0], (short)i[1], (short)i[2], (short)i[3], (short)i[0], (short)i[1], (short)i[2], (short)i[3]};
Nicolas Capens8dfd9a72016-10-13 17:44:51 -04001205 static_assert(sizeof(initializer) == vectorSize, "!");
1206 dataInitializer = Ice::VariableDeclaration::DataInitializer::create(globalPool, (const char*)initializer, vectorSize);
1207 }
1208 break;
1209 case Type_v8i8:
1210 {
Nicolas Capens7f3f69c2016-10-20 01:29:33 -04001211 const char initializer[16] = {(char)i[0], (char)i[1], (char)i[2], (char)i[3], (char)i[4], (char)i[5], (char)i[6], (char)i[7], (char)i[0], (char)i[1], (char)i[2], (char)i[3], (char)i[4], (char)i[5], (char)i[6], (char)i[7]};
Nicolas Capens8dfd9a72016-10-13 17:44:51 -04001212 static_assert(sizeof(initializer) == vectorSize, "!");
1213 dataInitializer = Ice::VariableDeclaration::DataInitializer::create(globalPool, (const char*)initializer, vectorSize);
1214 }
1215 break;
1216 case Type_v4i8:
1217 {
Nicolas Capens7f3f69c2016-10-20 01:29:33 -04001218 const char initializer[16] = {(char)i[0], (char)i[1], (char)i[2], (char)i[3], (char)i[0], (char)i[1], (char)i[2], (char)i[3], (char)i[0], (char)i[1], (char)i[2], (char)i[3], (char)i[0], (char)i[1], (char)i[2], (char)i[3]};
Nicolas Capens8dfd9a72016-10-13 17:44:51 -04001219 static_assert(sizeof(initializer) == vectorSize, "!");
1220 dataInitializer = Ice::VariableDeclaration::DataInitializer::create(globalPool, (const char*)initializer, vectorSize);
1221 }
1222 break;
1223 default:
1224 assert(false && "Unknown constant vector type" && type);
1225 }
1226
1227 auto name = Ice::GlobalString::createWithoutString(::context);
1228 auto *variableDeclaration = Ice::VariableDeclaration::create(globalPool);
1229 variableDeclaration->setName(name);
1230 variableDeclaration->setAlignment(alignment);
1231 variableDeclaration->setIsConstant(true);
1232 variableDeclaration->addInitializer(dataInitializer);
1233
1234 ::function->addGlobal(variableDeclaration);
1235
1236 constexpr int32_t offset = 0;
1237 Ice::Operand *ptr = ::context->getConstantSym(offset, name);
1238
1239 Ice::Variable *result = ::function->makeVariable(T(type));
1240 auto load = Ice::InstLoad::create(::function, result, ptr, alignment);
1241 ::basicBlock->appendInst(load);
1242
1243 return V(result);
Nicolas Capens13ac2322016-10-13 14:52:12 -04001244 }
1245
1246 Value *Nucleus::createConstantVector(const double *constants, Type *type)
Nicolas Capens598f8d82016-09-26 15:09:10 -04001247 {
Nicolas Capens8dfd9a72016-10-13 17:44:51 -04001248 return createConstantVector((const int64_t*)constants, type);
Nicolas Capens598f8d82016-09-26 15:09:10 -04001249 }
1250
1251 Type *Void::getType()
1252 {
1253 return T(Ice::IceType_void);
1254 }
1255
Nicolas Capens598f8d82016-09-26 15:09:10 -04001256 Bool::Bool(Argument<Bool> argument)
1257 {
1258 storeValue(argument.value);
1259 }
1260
1261 Bool::Bool()
1262 {
1263 }
1264
1265 Bool::Bool(bool x)
1266 {
1267 storeValue(Nucleus::createConstantBool(x));
1268 }
1269
1270 Bool::Bool(RValue<Bool> rhs)
1271 {
1272 storeValue(rhs.value);
1273 }
1274
1275 Bool::Bool(const Bool &rhs)
1276 {
1277 Value *value = rhs.loadValue();
1278 storeValue(value);
1279 }
1280
1281 Bool::Bool(const Reference<Bool> &rhs)
1282 {
1283 Value *value = rhs.loadValue();
1284 storeValue(value);
1285 }
1286
1287 RValue<Bool> Bool::operator=(RValue<Bool> rhs) const
1288 {
1289 storeValue(rhs.value);
1290
1291 return rhs;
1292 }
1293
1294 RValue<Bool> Bool::operator=(const Bool &rhs) const
1295 {
1296 Value *value = rhs.loadValue();
1297 storeValue(value);
1298
1299 return RValue<Bool>(value);
1300 }
1301
1302 RValue<Bool> Bool::operator=(const Reference<Bool> &rhs) const
1303 {
1304 Value *value = rhs.loadValue();
1305 storeValue(value);
1306
1307 return RValue<Bool>(value);
1308 }
1309
1310 RValue<Bool> operator!(RValue<Bool> val)
1311 {
1312 return RValue<Bool>(Nucleus::createNot(val.value));
1313 }
1314
1315 RValue<Bool> operator&&(RValue<Bool> lhs, RValue<Bool> rhs)
1316 {
1317 return RValue<Bool>(Nucleus::createAnd(lhs.value, rhs.value));
1318 }
1319
1320 RValue<Bool> operator||(RValue<Bool> lhs, RValue<Bool> rhs)
1321 {
1322 return RValue<Bool>(Nucleus::createOr(lhs.value, rhs.value));
1323 }
1324
1325 Type *Bool::getType()
1326 {
Nicolas Capens4cfd4572016-10-20 01:00:19 -04001327 return T(Ice::IceType_i1);
Nicolas Capens598f8d82016-09-26 15:09:10 -04001328 }
1329
1330 Byte::Byte(Argument<Byte> argument)
1331 {
1332 storeValue(argument.value);
1333 }
1334
1335 Byte::Byte(RValue<Int> cast)
1336 {
1337 Value *integer = Nucleus::createTrunc(cast.value, Byte::getType());
1338
1339 storeValue(integer);
1340 }
1341
1342 Byte::Byte(RValue<UInt> cast)
1343 {
1344 Value *integer = Nucleus::createTrunc(cast.value, Byte::getType());
1345
1346 storeValue(integer);
1347 }
1348
1349 Byte::Byte(RValue<UShort> cast)
1350 {
1351 Value *integer = Nucleus::createTrunc(cast.value, Byte::getType());
1352
1353 storeValue(integer);
1354 }
1355
1356 Byte::Byte()
1357 {
1358 }
1359
1360 Byte::Byte(int x)
1361 {
1362 storeValue(Nucleus::createConstantByte((unsigned char)x));
1363 }
1364
1365 Byte::Byte(unsigned char x)
1366 {
1367 storeValue(Nucleus::createConstantByte(x));
1368 }
1369
1370 Byte::Byte(RValue<Byte> rhs)
1371 {
1372 storeValue(rhs.value);
1373 }
1374
1375 Byte::Byte(const Byte &rhs)
1376 {
1377 Value *value = rhs.loadValue();
1378 storeValue(value);
1379 }
1380
1381 Byte::Byte(const Reference<Byte> &rhs)
1382 {
1383 Value *value = rhs.loadValue();
1384 storeValue(value);
1385 }
1386
1387 RValue<Byte> Byte::operator=(RValue<Byte> rhs) const
1388 {
1389 storeValue(rhs.value);
1390
1391 return rhs;
1392 }
1393
1394 RValue<Byte> Byte::operator=(const Byte &rhs) const
1395 {
1396 Value *value = rhs.loadValue();
1397 storeValue(value);
1398
1399 return RValue<Byte>(value);
1400 }
1401
1402 RValue<Byte> Byte::operator=(const Reference<Byte> &rhs) const
1403 {
1404 Value *value = rhs.loadValue();
1405 storeValue(value);
1406
1407 return RValue<Byte>(value);
1408 }
1409
1410 RValue<Byte> operator+(RValue<Byte> lhs, RValue<Byte> rhs)
1411 {
1412 return RValue<Byte>(Nucleus::createAdd(lhs.value, rhs.value));
1413 }
1414
1415 RValue<Byte> operator-(RValue<Byte> lhs, RValue<Byte> rhs)
1416 {
1417 return RValue<Byte>(Nucleus::createSub(lhs.value, rhs.value));
1418 }
1419
1420 RValue<Byte> operator*(RValue<Byte> lhs, RValue<Byte> rhs)
1421 {
1422 return RValue<Byte>(Nucleus::createMul(lhs.value, rhs.value));
1423 }
1424
1425 RValue<Byte> operator/(RValue<Byte> lhs, RValue<Byte> rhs)
1426 {
1427 return RValue<Byte>(Nucleus::createUDiv(lhs.value, rhs.value));
1428 }
1429
1430 RValue<Byte> operator%(RValue<Byte> lhs, RValue<Byte> rhs)
1431 {
1432 return RValue<Byte>(Nucleus::createURem(lhs.value, rhs.value));
1433 }
1434
1435 RValue<Byte> operator&(RValue<Byte> lhs, RValue<Byte> rhs)
1436 {
1437 return RValue<Byte>(Nucleus::createAnd(lhs.value, rhs.value));
1438 }
1439
1440 RValue<Byte> operator|(RValue<Byte> lhs, RValue<Byte> rhs)
1441 {
1442 return RValue<Byte>(Nucleus::createOr(lhs.value, rhs.value));
1443 }
1444
1445 RValue<Byte> operator^(RValue<Byte> lhs, RValue<Byte> rhs)
1446 {
1447 return RValue<Byte>(Nucleus::createXor(lhs.value, rhs.value));
1448 }
1449
1450 RValue<Byte> operator<<(RValue<Byte> lhs, RValue<Byte> rhs)
1451 {
1452 return RValue<Byte>(Nucleus::createShl(lhs.value, rhs.value));
1453 }
1454
1455 RValue<Byte> operator>>(RValue<Byte> lhs, RValue<Byte> rhs)
1456 {
1457 return RValue<Byte>(Nucleus::createLShr(lhs.value, rhs.value));
1458 }
1459
1460 RValue<Byte> operator+=(const Byte &lhs, RValue<Byte> rhs)
1461 {
1462 return lhs = lhs + rhs;
1463 }
1464
1465 RValue<Byte> operator-=(const Byte &lhs, RValue<Byte> rhs)
1466 {
1467 return lhs = lhs - rhs;
1468 }
1469
1470 RValue<Byte> operator*=(const Byte &lhs, RValue<Byte> rhs)
1471 {
1472 return lhs = lhs * rhs;
1473 }
1474
1475 RValue<Byte> operator/=(const Byte &lhs, RValue<Byte> rhs)
1476 {
1477 return lhs = lhs / rhs;
1478 }
1479
1480 RValue<Byte> operator%=(const Byte &lhs, RValue<Byte> rhs)
1481 {
1482 return lhs = lhs % rhs;
1483 }
1484
1485 RValue<Byte> operator&=(const Byte &lhs, RValue<Byte> rhs)
1486 {
1487 return lhs = lhs & rhs;
1488 }
1489
1490 RValue<Byte> operator|=(const Byte &lhs, RValue<Byte> rhs)
1491 {
1492 return lhs = lhs | rhs;
1493 }
1494
1495 RValue<Byte> operator^=(const Byte &lhs, RValue<Byte> rhs)
1496 {
1497 return lhs = lhs ^ rhs;
1498 }
1499
1500 RValue<Byte> operator<<=(const Byte &lhs, RValue<Byte> rhs)
1501 {
1502 return lhs = lhs << rhs;
1503 }
1504
1505 RValue<Byte> operator>>=(const Byte &lhs, RValue<Byte> rhs)
1506 {
1507 return lhs = lhs >> rhs;
1508 }
1509
1510 RValue<Byte> operator+(RValue<Byte> val)
1511 {
1512 return val;
1513 }
1514
1515 RValue<Byte> operator-(RValue<Byte> val)
1516 {
1517 return RValue<Byte>(Nucleus::createNeg(val.value));
1518 }
1519
1520 RValue<Byte> operator~(RValue<Byte> val)
1521 {
1522 return RValue<Byte>(Nucleus::createNot(val.value));
1523 }
1524
1525 RValue<Byte> operator++(const Byte &val, int) // Post-increment
1526 {
1527 RValue<Byte> res = val;
1528
1529 assert(false && "UNIMPLEMENTED");
1530
1531 return res;
1532 }
1533
1534 const Byte &operator++(const Byte &val) // Pre-increment
1535 {
1536 assert(false && "UNIMPLEMENTED");
1537
1538 return val;
1539 }
1540
1541 RValue<Byte> operator--(const Byte &val, int) // Post-decrement
1542 {
1543 RValue<Byte> res = val;
1544
1545 assert(false && "UNIMPLEMENTED");
1546
1547 return res;
1548 }
1549
1550 const Byte &operator--(const Byte &val) // Pre-decrement
1551 {
1552 assert(false && "UNIMPLEMENTED");
1553
1554 return val;
1555 }
1556
1557 RValue<Bool> operator<(RValue<Byte> lhs, RValue<Byte> rhs)
1558 {
1559 return RValue<Bool>(Nucleus::createICmpULT(lhs.value, rhs.value));
1560 }
1561
1562 RValue<Bool> operator<=(RValue<Byte> lhs, RValue<Byte> rhs)
1563 {
1564 return RValue<Bool>(Nucleus::createICmpULE(lhs.value, rhs.value));
1565 }
1566
1567 RValue<Bool> operator>(RValue<Byte> lhs, RValue<Byte> rhs)
1568 {
1569 return RValue<Bool>(Nucleus::createICmpUGT(lhs.value, rhs.value));
1570 }
1571
1572 RValue<Bool> operator>=(RValue<Byte> lhs, RValue<Byte> rhs)
1573 {
1574 return RValue<Bool>(Nucleus::createICmpUGE(lhs.value, rhs.value));
1575 }
1576
1577 RValue<Bool> operator!=(RValue<Byte> lhs, RValue<Byte> rhs)
1578 {
1579 return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value));
1580 }
1581
1582 RValue<Bool> operator==(RValue<Byte> lhs, RValue<Byte> rhs)
1583 {
1584 return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value));
1585 }
1586
1587 Type *Byte::getType()
1588 {
Nicolas Capens6d738712016-09-30 04:15:22 -04001589 return T(Ice::IceType_i8);
Nicolas Capens598f8d82016-09-26 15:09:10 -04001590 }
1591
1592 SByte::SByte(Argument<SByte> argument)
1593 {
1594 storeValue(argument.value);
1595 }
1596
1597 SByte::SByte(RValue<Int> cast)
1598 {
1599 Value *integer = Nucleus::createTrunc(cast.value, SByte::getType());
1600
1601 storeValue(integer);
1602 }
1603
1604 SByte::SByte(RValue<Short> cast)
1605 {
1606 Value *integer = Nucleus::createTrunc(cast.value, SByte::getType());
1607
1608 storeValue(integer);
1609 }
1610
1611 SByte::SByte()
1612 {
1613 }
1614
1615 SByte::SByte(signed char x)
1616 {
1617 storeValue(Nucleus::createConstantByte(x));
1618 }
1619
1620 SByte::SByte(RValue<SByte> rhs)
1621 {
1622 storeValue(rhs.value);
1623 }
1624
1625 SByte::SByte(const SByte &rhs)
1626 {
1627 Value *value = rhs.loadValue();
1628 storeValue(value);
1629 }
1630
1631 SByte::SByte(const Reference<SByte> &rhs)
1632 {
1633 Value *value = rhs.loadValue();
1634 storeValue(value);
1635 }
1636
1637 RValue<SByte> SByte::operator=(RValue<SByte> rhs) const
1638 {
1639 storeValue(rhs.value);
1640
1641 return rhs;
1642 }
1643
1644 RValue<SByte> SByte::operator=(const SByte &rhs) const
1645 {
1646 Value *value = rhs.loadValue();
1647 storeValue(value);
1648
1649 return RValue<SByte>(value);
1650 }
1651
1652 RValue<SByte> SByte::operator=(const Reference<SByte> &rhs) const
1653 {
1654 Value *value = rhs.loadValue();
1655 storeValue(value);
1656
1657 return RValue<SByte>(value);
1658 }
1659
1660 RValue<SByte> operator+(RValue<SByte> lhs, RValue<SByte> rhs)
1661 {
1662 return RValue<SByte>(Nucleus::createAdd(lhs.value, rhs.value));
1663 }
1664
1665 RValue<SByte> operator-(RValue<SByte> lhs, RValue<SByte> rhs)
1666 {
1667 return RValue<SByte>(Nucleus::createSub(lhs.value, rhs.value));
1668 }
1669
1670 RValue<SByte> operator*(RValue<SByte> lhs, RValue<SByte> rhs)
1671 {
1672 return RValue<SByte>(Nucleus::createMul(lhs.value, rhs.value));
1673 }
1674
1675 RValue<SByte> operator/(RValue<SByte> lhs, RValue<SByte> rhs)
1676 {
1677 return RValue<SByte>(Nucleus::createSDiv(lhs.value, rhs.value));
1678 }
1679
1680 RValue<SByte> operator%(RValue<SByte> lhs, RValue<SByte> rhs)
1681 {
1682 return RValue<SByte>(Nucleus::createSRem(lhs.value, rhs.value));
1683 }
1684
1685 RValue<SByte> operator&(RValue<SByte> lhs, RValue<SByte> rhs)
1686 {
1687 return RValue<SByte>(Nucleus::createAnd(lhs.value, rhs.value));
1688 }
1689
1690 RValue<SByte> operator|(RValue<SByte> lhs, RValue<SByte> rhs)
1691 {
1692 return RValue<SByte>(Nucleus::createOr(lhs.value, rhs.value));
1693 }
1694
1695 RValue<SByte> operator^(RValue<SByte> lhs, RValue<SByte> rhs)
1696 {
1697 return RValue<SByte>(Nucleus::createXor(lhs.value, rhs.value));
1698 }
1699
1700 RValue<SByte> operator<<(RValue<SByte> lhs, RValue<SByte> rhs)
1701 {
1702 return RValue<SByte>(Nucleus::createShl(lhs.value, rhs.value));
1703 }
1704
1705 RValue<SByte> operator>>(RValue<SByte> lhs, RValue<SByte> rhs)
1706 {
1707 return RValue<SByte>(Nucleus::createAShr(lhs.value, rhs.value));
1708 }
1709
1710 RValue<SByte> operator+=(const SByte &lhs, RValue<SByte> rhs)
1711 {
1712 return lhs = lhs + rhs;
1713 }
1714
1715 RValue<SByte> operator-=(const SByte &lhs, RValue<SByte> rhs)
1716 {
1717 return lhs = lhs - rhs;
1718 }
1719
1720 RValue<SByte> operator*=(const SByte &lhs, RValue<SByte> rhs)
1721 {
1722 return lhs = lhs * rhs;
1723 }
1724
1725 RValue<SByte> operator/=(const SByte &lhs, RValue<SByte> rhs)
1726 {
1727 return lhs = lhs / rhs;
1728 }
1729
1730 RValue<SByte> operator%=(const SByte &lhs, RValue<SByte> rhs)
1731 {
1732 return lhs = lhs % rhs;
1733 }
1734
1735 RValue<SByte> operator&=(const SByte &lhs, RValue<SByte> rhs)
1736 {
1737 return lhs = lhs & rhs;
1738 }
1739
1740 RValue<SByte> operator|=(const SByte &lhs, RValue<SByte> rhs)
1741 {
1742 return lhs = lhs | rhs;
1743 }
1744
1745 RValue<SByte> operator^=(const SByte &lhs, RValue<SByte> rhs)
1746 {
1747 return lhs = lhs ^ rhs;
1748 }
1749
1750 RValue<SByte> operator<<=(const SByte &lhs, RValue<SByte> rhs)
1751 {
1752 return lhs = lhs << rhs;
1753 }
1754
1755 RValue<SByte> operator>>=(const SByte &lhs, RValue<SByte> rhs)
1756 {
1757 return lhs = lhs >> rhs;
1758 }
1759
1760 RValue<SByte> operator+(RValue<SByte> val)
1761 {
1762 return val;
1763 }
1764
1765 RValue<SByte> operator-(RValue<SByte> val)
1766 {
1767 return RValue<SByte>(Nucleus::createNeg(val.value));
1768 }
1769
1770 RValue<SByte> operator~(RValue<SByte> val)
1771 {
1772 return RValue<SByte>(Nucleus::createNot(val.value));
1773 }
1774
1775 RValue<SByte> operator++(const SByte &val, int) // Post-increment
1776 {
1777 RValue<SByte> res = val;
1778
1779 assert(false && "UNIMPLEMENTED");
1780
1781 return res;
1782 }
1783
1784 const SByte &operator++(const SByte &val) // Pre-increment
1785 {
1786 assert(false && "UNIMPLEMENTED");
1787 assert(false && "UNIMPLEMENTED");
1788
1789 return val;
1790 }
1791
1792 RValue<SByte> operator--(const SByte &val, int) // Post-decrement
1793 {
1794 RValue<SByte> res = val;
1795
1796 assert(false && "UNIMPLEMENTED");
1797 assert(false && "UNIMPLEMENTED");
1798
1799 return res;
1800 }
1801
1802 const SByte &operator--(const SByte &val) // Pre-decrement
1803 {
1804 assert(false && "UNIMPLEMENTED");
1805 assert(false && "UNIMPLEMENTED");
1806
1807 return val;
1808 }
1809
1810 RValue<Bool> operator<(RValue<SByte> lhs, RValue<SByte> rhs)
1811 {
1812 return RValue<Bool>(Nucleus::createICmpSLT(lhs.value, rhs.value));
1813 }
1814
1815 RValue<Bool> operator<=(RValue<SByte> lhs, RValue<SByte> rhs)
1816 {
1817 return RValue<Bool>(Nucleus::createICmpSLE(lhs.value, rhs.value));
1818 }
1819
1820 RValue<Bool> operator>(RValue<SByte> lhs, RValue<SByte> rhs)
1821 {
1822 return RValue<Bool>(Nucleus::createICmpSGT(lhs.value, rhs.value));
1823 }
1824
1825 RValue<Bool> operator>=(RValue<SByte> lhs, RValue<SByte> rhs)
1826 {
1827 return RValue<Bool>(Nucleus::createICmpSGE(lhs.value, rhs.value));
1828 }
1829
1830 RValue<Bool> operator!=(RValue<SByte> lhs, RValue<SByte> rhs)
1831 {
1832 return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value));
1833 }
1834
1835 RValue<Bool> operator==(RValue<SByte> lhs, RValue<SByte> rhs)
1836 {
1837 return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value));
1838 }
1839
1840 Type *SByte::getType()
1841 {
Nicolas Capens4cfd4572016-10-20 01:00:19 -04001842 return T(Ice::IceType_i8);
Nicolas Capens598f8d82016-09-26 15:09:10 -04001843 }
1844
1845 Short::Short(Argument<Short> argument)
1846 {
1847 storeValue(argument.value);
1848 }
1849
1850 Short::Short(RValue<Int> cast)
1851 {
1852 Value *integer = Nucleus::createTrunc(cast.value, Short::getType());
1853
1854 storeValue(integer);
1855 }
1856
1857 Short::Short()
1858 {
1859 }
1860
1861 Short::Short(short x)
1862 {
1863 storeValue(Nucleus::createConstantShort(x));
1864 }
1865
1866 Short::Short(RValue<Short> rhs)
1867 {
1868 storeValue(rhs.value);
1869 }
1870
1871 Short::Short(const Short &rhs)
1872 {
1873 Value *value = rhs.loadValue();
1874 storeValue(value);
1875 }
1876
1877 Short::Short(const Reference<Short> &rhs)
1878 {
1879 Value *value = rhs.loadValue();
1880 storeValue(value);
1881 }
1882
1883 RValue<Short> Short::operator=(RValue<Short> rhs) const
1884 {
1885 storeValue(rhs.value);
1886
1887 return rhs;
1888 }
1889
1890 RValue<Short> Short::operator=(const Short &rhs) const
1891 {
1892 Value *value = rhs.loadValue();
1893 storeValue(value);
1894
1895 return RValue<Short>(value);
1896 }
1897
1898 RValue<Short> Short::operator=(const Reference<Short> &rhs) const
1899 {
1900 Value *value = rhs.loadValue();
1901 storeValue(value);
1902
1903 return RValue<Short>(value);
1904 }
1905
1906 RValue<Short> operator+(RValue<Short> lhs, RValue<Short> rhs)
1907 {
1908 return RValue<Short>(Nucleus::createAdd(lhs.value, rhs.value));
1909 }
1910
1911 RValue<Short> operator-(RValue<Short> lhs, RValue<Short> rhs)
1912 {
1913 return RValue<Short>(Nucleus::createSub(lhs.value, rhs.value));
1914 }
1915
1916 RValue<Short> operator*(RValue<Short> lhs, RValue<Short> rhs)
1917 {
1918 return RValue<Short>(Nucleus::createMul(lhs.value, rhs.value));
1919 }
1920
1921 RValue<Short> operator/(RValue<Short> lhs, RValue<Short> rhs)
1922 {
1923 return RValue<Short>(Nucleus::createSDiv(lhs.value, rhs.value));
1924 }
1925
1926 RValue<Short> operator%(RValue<Short> lhs, RValue<Short> rhs)
1927 {
1928 return RValue<Short>(Nucleus::createSRem(lhs.value, rhs.value));
1929 }
1930
1931 RValue<Short> operator&(RValue<Short> lhs, RValue<Short> rhs)
1932 {
1933 return RValue<Short>(Nucleus::createAnd(lhs.value, rhs.value));
1934 }
1935
1936 RValue<Short> operator|(RValue<Short> lhs, RValue<Short> rhs)
1937 {
1938 return RValue<Short>(Nucleus::createOr(lhs.value, rhs.value));
1939 }
1940
1941 RValue<Short> operator^(RValue<Short> lhs, RValue<Short> rhs)
1942 {
1943 return RValue<Short>(Nucleus::createXor(lhs.value, rhs.value));
1944 }
1945
1946 RValue<Short> operator<<(RValue<Short> lhs, RValue<Short> rhs)
1947 {
1948 return RValue<Short>(Nucleus::createShl(lhs.value, rhs.value));
1949 }
1950
1951 RValue<Short> operator>>(RValue<Short> lhs, RValue<Short> rhs)
1952 {
1953 return RValue<Short>(Nucleus::createAShr(lhs.value, rhs.value));
1954 }
1955
1956 RValue<Short> operator+=(const Short &lhs, RValue<Short> rhs)
1957 {
1958 return lhs = lhs + rhs;
1959 }
1960
1961 RValue<Short> operator-=(const Short &lhs, RValue<Short> rhs)
1962 {
1963 return lhs = lhs - rhs;
1964 }
1965
1966 RValue<Short> operator*=(const Short &lhs, RValue<Short> rhs)
1967 {
1968 return lhs = lhs * rhs;
1969 }
1970
1971 RValue<Short> operator/=(const Short &lhs, RValue<Short> rhs)
1972 {
1973 return lhs = lhs / rhs;
1974 }
1975
1976 RValue<Short> operator%=(const Short &lhs, RValue<Short> rhs)
1977 {
1978 return lhs = lhs % rhs;
1979 }
1980
1981 RValue<Short> operator&=(const Short &lhs, RValue<Short> rhs)
1982 {
1983 return lhs = lhs & rhs;
1984 }
1985
1986 RValue<Short> operator|=(const Short &lhs, RValue<Short> rhs)
1987 {
1988 return lhs = lhs | rhs;
1989 }
1990
1991 RValue<Short> operator^=(const Short &lhs, RValue<Short> rhs)
1992 {
1993 return lhs = lhs ^ rhs;
1994 }
1995
1996 RValue<Short> operator<<=(const Short &lhs, RValue<Short> rhs)
1997 {
1998 return lhs = lhs << rhs;
1999 }
2000
2001 RValue<Short> operator>>=(const Short &lhs, RValue<Short> rhs)
2002 {
2003 return lhs = lhs >> rhs;
2004 }
2005
2006 RValue<Short> operator+(RValue<Short> val)
2007 {
2008 return val;
2009 }
2010
2011 RValue<Short> operator-(RValue<Short> val)
2012 {
2013 return RValue<Short>(Nucleus::createNeg(val.value));
2014 }
2015
2016 RValue<Short> operator~(RValue<Short> val)
2017 {
2018 return RValue<Short>(Nucleus::createNot(val.value));
2019 }
2020
2021 RValue<Short> operator++(const Short &val, int) // Post-increment
2022 {
2023 RValue<Short> res = val;
2024
2025 assert(false && "UNIMPLEMENTED");
2026 assert(false && "UNIMPLEMENTED");
2027
2028 return res;
2029 }
2030
2031 const Short &operator++(const Short &val) // Pre-increment
2032 {
2033 assert(false && "UNIMPLEMENTED");
2034 assert(false && "UNIMPLEMENTED");
2035
2036 return val;
2037 }
2038
2039 RValue<Short> operator--(const Short &val, int) // Post-decrement
2040 {
2041 RValue<Short> res = val;
2042
2043 assert(false && "UNIMPLEMENTED");
2044 assert(false && "UNIMPLEMENTED");
2045
2046 return res;
2047 }
2048
2049 const Short &operator--(const Short &val) // Pre-decrement
2050 {
2051 assert(false && "UNIMPLEMENTED");
2052 assert(false && "UNIMPLEMENTED");
2053
2054 return val;
2055 }
2056
2057 RValue<Bool> operator<(RValue<Short> lhs, RValue<Short> rhs)
2058 {
2059 return RValue<Bool>(Nucleus::createICmpSLT(lhs.value, rhs.value));
2060 }
2061
2062 RValue<Bool> operator<=(RValue<Short> lhs, RValue<Short> rhs)
2063 {
2064 return RValue<Bool>(Nucleus::createICmpSLE(lhs.value, rhs.value));
2065 }
2066
2067 RValue<Bool> operator>(RValue<Short> lhs, RValue<Short> rhs)
2068 {
2069 return RValue<Bool>(Nucleus::createICmpSGT(lhs.value, rhs.value));
2070 }
2071
2072 RValue<Bool> operator>=(RValue<Short> lhs, RValue<Short> rhs)
2073 {
2074 return RValue<Bool>(Nucleus::createICmpSGE(lhs.value, rhs.value));
2075 }
2076
2077 RValue<Bool> operator!=(RValue<Short> lhs, RValue<Short> rhs)
2078 {
2079 return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value));
2080 }
2081
2082 RValue<Bool> operator==(RValue<Short> lhs, RValue<Short> rhs)
2083 {
2084 return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value));
2085 }
2086
2087 Type *Short::getType()
2088 {
Nicolas Capens4cfd4572016-10-20 01:00:19 -04002089 return T(Ice::IceType_i16);
Nicolas Capens598f8d82016-09-26 15:09:10 -04002090 }
2091
2092 UShort::UShort(Argument<UShort> argument)
2093 {
2094 storeValue(argument.value);
2095 }
2096
2097 UShort::UShort(RValue<UInt> cast)
2098 {
2099 Value *integer = Nucleus::createTrunc(cast.value, UShort::getType());
2100
2101 storeValue(integer);
2102 }
2103
2104 UShort::UShort(RValue<Int> cast)
2105 {
2106 Value *integer = Nucleus::createTrunc(cast.value, UShort::getType());
2107
2108 storeValue(integer);
2109 }
2110
2111 UShort::UShort()
2112 {
2113 }
2114
2115 UShort::UShort(unsigned short x)
2116 {
2117 storeValue(Nucleus::createConstantShort(x));
2118 }
2119
2120 UShort::UShort(RValue<UShort> rhs)
2121 {
2122 storeValue(rhs.value);
2123 }
2124
2125 UShort::UShort(const UShort &rhs)
2126 {
2127 Value *value = rhs.loadValue();
2128 storeValue(value);
2129 }
2130
2131 UShort::UShort(const Reference<UShort> &rhs)
2132 {
2133 Value *value = rhs.loadValue();
2134 storeValue(value);
2135 }
2136
2137 RValue<UShort> UShort::operator=(RValue<UShort> rhs) const
2138 {
2139 storeValue(rhs.value);
2140
2141 return rhs;
2142 }
2143
2144 RValue<UShort> UShort::operator=(const UShort &rhs) const
2145 {
2146 Value *value = rhs.loadValue();
2147 storeValue(value);
2148
2149 return RValue<UShort>(value);
2150 }
2151
2152 RValue<UShort> UShort::operator=(const Reference<UShort> &rhs) const
2153 {
2154 Value *value = rhs.loadValue();
2155 storeValue(value);
2156
2157 return RValue<UShort>(value);
2158 }
2159
2160 RValue<UShort> operator+(RValue<UShort> lhs, RValue<UShort> rhs)
2161 {
2162 return RValue<UShort>(Nucleus::createAdd(lhs.value, rhs.value));
2163 }
2164
2165 RValue<UShort> operator-(RValue<UShort> lhs, RValue<UShort> rhs)
2166 {
2167 return RValue<UShort>(Nucleus::createSub(lhs.value, rhs.value));
2168 }
2169
2170 RValue<UShort> operator*(RValue<UShort> lhs, RValue<UShort> rhs)
2171 {
2172 return RValue<UShort>(Nucleus::createMul(lhs.value, rhs.value));
2173 }
2174
2175 RValue<UShort> operator/(RValue<UShort> lhs, RValue<UShort> rhs)
2176 {
2177 return RValue<UShort>(Nucleus::createUDiv(lhs.value, rhs.value));
2178 }
2179
2180 RValue<UShort> operator%(RValue<UShort> lhs, RValue<UShort> rhs)
2181 {
2182 return RValue<UShort>(Nucleus::createURem(lhs.value, rhs.value));
2183 }
2184
2185 RValue<UShort> operator&(RValue<UShort> lhs, RValue<UShort> rhs)
2186 {
2187 return RValue<UShort>(Nucleus::createAnd(lhs.value, rhs.value));
2188 }
2189
2190 RValue<UShort> operator|(RValue<UShort> lhs, RValue<UShort> rhs)
2191 {
2192 return RValue<UShort>(Nucleus::createOr(lhs.value, rhs.value));
2193 }
2194
2195 RValue<UShort> operator^(RValue<UShort> lhs, RValue<UShort> rhs)
2196 {
2197 return RValue<UShort>(Nucleus::createXor(lhs.value, rhs.value));
2198 }
2199
2200 RValue<UShort> operator<<(RValue<UShort> lhs, RValue<UShort> rhs)
2201 {
2202 return RValue<UShort>(Nucleus::createShl(lhs.value, rhs.value));
2203 }
2204
2205 RValue<UShort> operator>>(RValue<UShort> lhs, RValue<UShort> rhs)
2206 {
2207 return RValue<UShort>(Nucleus::createLShr(lhs.value, rhs.value));
2208 }
2209
2210 RValue<UShort> operator+=(const UShort &lhs, RValue<UShort> rhs)
2211 {
2212 return lhs = lhs + rhs;
2213 }
2214
2215 RValue<UShort> operator-=(const UShort &lhs, RValue<UShort> rhs)
2216 {
2217 return lhs = lhs - rhs;
2218 }
2219
2220 RValue<UShort> operator*=(const UShort &lhs, RValue<UShort> rhs)
2221 {
2222 return lhs = lhs * rhs;
2223 }
2224
2225 RValue<UShort> operator/=(const UShort &lhs, RValue<UShort> rhs)
2226 {
2227 return lhs = lhs / rhs;
2228 }
2229
2230 RValue<UShort> operator%=(const UShort &lhs, RValue<UShort> rhs)
2231 {
2232 return lhs = lhs % rhs;
2233 }
2234
2235 RValue<UShort> operator&=(const UShort &lhs, RValue<UShort> rhs)
2236 {
2237 return lhs = lhs & rhs;
2238 }
2239
2240 RValue<UShort> operator|=(const UShort &lhs, RValue<UShort> rhs)
2241 {
2242 return lhs = lhs | rhs;
2243 }
2244
2245 RValue<UShort> operator^=(const UShort &lhs, RValue<UShort> rhs)
2246 {
2247 return lhs = lhs ^ rhs;
2248 }
2249
2250 RValue<UShort> operator<<=(const UShort &lhs, RValue<UShort> rhs)
2251 {
2252 return lhs = lhs << rhs;
2253 }
2254
2255 RValue<UShort> operator>>=(const UShort &lhs, RValue<UShort> rhs)
2256 {
2257 return lhs = lhs >> rhs;
2258 }
2259
2260 RValue<UShort> operator+(RValue<UShort> val)
2261 {
2262 return val;
2263 }
2264
2265 RValue<UShort> operator-(RValue<UShort> val)
2266 {
2267 return RValue<UShort>(Nucleus::createNeg(val.value));
2268 }
2269
2270 RValue<UShort> operator~(RValue<UShort> val)
2271 {
2272 return RValue<UShort>(Nucleus::createNot(val.value));
2273 }
2274
2275 RValue<UShort> operator++(const UShort &val, int) // Post-increment
2276 {
2277 RValue<UShort> res = val;
2278
2279 assert(false && "UNIMPLEMENTED");
2280 assert(false && "UNIMPLEMENTED");
2281
2282 return res;
2283 }
2284
2285 const UShort &operator++(const UShort &val) // Pre-increment
2286 {
2287 assert(false && "UNIMPLEMENTED");
2288 assert(false && "UNIMPLEMENTED");
2289
2290 return val;
2291 }
2292
2293 RValue<UShort> operator--(const UShort &val, int) // Post-decrement
2294 {
2295 RValue<UShort> res = val;
2296
2297 assert(false && "UNIMPLEMENTED");
2298 assert(false && "UNIMPLEMENTED");
2299
2300 return res;
2301 }
2302
2303 const UShort &operator--(const UShort &val) // Pre-decrement
2304 {
2305 assert(false && "UNIMPLEMENTED");
2306 assert(false && "UNIMPLEMENTED");
2307
2308 return val;
2309 }
2310
2311 RValue<Bool> operator<(RValue<UShort> lhs, RValue<UShort> rhs)
2312 {
2313 return RValue<Bool>(Nucleus::createICmpULT(lhs.value, rhs.value));
2314 }
2315
2316 RValue<Bool> operator<=(RValue<UShort> lhs, RValue<UShort> rhs)
2317 {
2318 return RValue<Bool>(Nucleus::createICmpULE(lhs.value, rhs.value));
2319 }
2320
2321 RValue<Bool> operator>(RValue<UShort> lhs, RValue<UShort> rhs)
2322 {
2323 return RValue<Bool>(Nucleus::createICmpUGT(lhs.value, rhs.value));
2324 }
2325
2326 RValue<Bool> operator>=(RValue<UShort> lhs, RValue<UShort> rhs)
2327 {
2328 return RValue<Bool>(Nucleus::createICmpUGE(lhs.value, rhs.value));
2329 }
2330
2331 RValue<Bool> operator!=(RValue<UShort> lhs, RValue<UShort> rhs)
2332 {
2333 return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value));
2334 }
2335
2336 RValue<Bool> operator==(RValue<UShort> lhs, RValue<UShort> rhs)
2337 {
2338 return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value));
2339 }
2340
2341 Type *UShort::getType()
2342 {
Nicolas Capens4cfd4572016-10-20 01:00:19 -04002343 return T(Ice::IceType_i16);
Nicolas Capens598f8d82016-09-26 15:09:10 -04002344 }
2345
Nicolas Capens16b5f152016-10-13 13:39:01 -04002346 Byte4::Byte4(RValue<Byte8> cast)
2347 {
2348 // xyzw.parent = this;
2349
2350 storeValue(Nucleus::createBitCast(cast.value, getType()));
2351 }
2352
2353 Byte4::Byte4(const Reference<Byte4> &rhs)
2354 {
2355 // xyzw.parent = this;
2356
2357 assert(false && "UNIMPLEMENTED");
2358 }
2359
Nicolas Capens598f8d82016-09-26 15:09:10 -04002360 Type *Byte4::getType()
2361 {
Nicolas Capens23d99a42016-09-30 14:57:16 -04002362 return T(Type_v4i8);
Nicolas Capens598f8d82016-09-26 15:09:10 -04002363 }
2364
2365 Type *SByte4::getType()
2366 {
Nicolas Capens4cfd4572016-10-20 01:00:19 -04002367 return T(Type_v4i8);
Nicolas Capens598f8d82016-09-26 15:09:10 -04002368 }
2369
2370 Byte8::Byte8()
2371 {
Nicolas Capens598f8d82016-09-26 15:09:10 -04002372 }
2373
2374 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)
2375 {
Nicolas Capens8dfd9a72016-10-13 17:44:51 -04002376 int64_t constantVector[8] = {x0, x1, x2, x3, x4, x5, x6, x7};
2377 storeValue(Nucleus::createConstantVector(constantVector, getType()));
Nicolas Capens598f8d82016-09-26 15:09:10 -04002378 }
2379
2380 Byte8::Byte8(RValue<Byte8> rhs)
2381 {
Nicolas Capens598f8d82016-09-26 15:09:10 -04002382 storeValue(rhs.value);
2383 }
2384
2385 Byte8::Byte8(const Byte8 &rhs)
2386 {
Nicolas Capens598f8d82016-09-26 15:09:10 -04002387 Value *value = rhs.loadValue();
2388 storeValue(value);
2389 }
2390
2391 Byte8::Byte8(const Reference<Byte8> &rhs)
2392 {
Nicolas Capens598f8d82016-09-26 15:09:10 -04002393 Value *value = rhs.loadValue();
2394 storeValue(value);
2395 }
2396
2397 RValue<Byte8> Byte8::operator=(RValue<Byte8> rhs) const
2398 {
2399 storeValue(rhs.value);
2400
2401 return rhs;
2402 }
2403
2404 RValue<Byte8> Byte8::operator=(const Byte8 &rhs) const
2405 {
2406 Value *value = rhs.loadValue();
2407 storeValue(value);
2408
2409 return RValue<Byte8>(value);
2410 }
2411
2412 RValue<Byte8> Byte8::operator=(const Reference<Byte8> &rhs) const
2413 {
2414 Value *value = rhs.loadValue();
2415 storeValue(value);
2416
2417 return RValue<Byte8>(value);
2418 }
2419
2420 RValue<Byte8> operator+(RValue<Byte8> lhs, RValue<Byte8> rhs)
2421 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04002422 assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04002423 }
2424
2425 RValue<Byte8> operator-(RValue<Byte8> lhs, RValue<Byte8> rhs)
2426 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04002427 assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04002428 }
2429
2430// RValue<Byte8> operator*(RValue<Byte8> lhs, RValue<Byte8> rhs)
2431// {
2432// return RValue<Byte8>(Nucleus::createMul(lhs.value, rhs.value));
2433// }
2434
2435// RValue<Byte8> operator/(RValue<Byte8> lhs, RValue<Byte8> rhs)
2436// {
2437// return RValue<Byte8>(Nucleus::createUDiv(lhs.value, rhs.value));
2438// }
2439
2440// RValue<Byte8> operator%(RValue<Byte8> lhs, RValue<Byte8> rhs)
2441// {
2442// return RValue<Byte8>(Nucleus::createURem(lhs.value, rhs.value));
2443// }
2444
2445 RValue<Byte8> operator&(RValue<Byte8> lhs, RValue<Byte8> rhs)
2446 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04002447 assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04002448 }
2449
2450 RValue<Byte8> operator|(RValue<Byte8> lhs, RValue<Byte8> rhs)
2451 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04002452 assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04002453 }
2454
2455 RValue<Byte8> operator^(RValue<Byte8> lhs, RValue<Byte8> rhs)
2456 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04002457 assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04002458 }
2459
2460// RValue<Byte8> operator<<(RValue<Byte8> lhs, unsigned char rhs)
2461// {
Nicolas Capens327f1df2016-10-21 14:26:34 -04002462// return RValue<Byte8>(Nucleus::createShl(lhs.value, C(::context->getConstantInt32(rhs))));
Nicolas Capens598f8d82016-09-26 15:09:10 -04002463// }
2464
2465// RValue<Byte8> operator>>(RValue<Byte8> lhs, unsigned char rhs)
2466// {
Nicolas Capens327f1df2016-10-21 14:26:34 -04002467// return RValue<Byte8>(Nucleus::createLShr(lhs.value, C(::context->getConstantInt32(rhs))));
Nicolas Capens598f8d82016-09-26 15:09:10 -04002468// }
2469
2470 RValue<Byte8> operator+=(const Byte8 &lhs, RValue<Byte8> rhs)
2471 {
2472 return lhs = lhs + rhs;
2473 }
2474
2475 RValue<Byte8> operator-=(const Byte8 &lhs, RValue<Byte8> rhs)
2476 {
2477 return lhs = lhs - rhs;
2478 }
2479
2480// RValue<Byte8> operator*=(const Byte8 &lhs, RValue<Byte8> rhs)
2481// {
2482// return lhs = lhs * rhs;
2483// }
2484
2485// RValue<Byte8> operator/=(const Byte8 &lhs, RValue<Byte8> rhs)
2486// {
2487// return lhs = lhs / rhs;
2488// }
2489
2490// RValue<Byte8> operator%=(const Byte8 &lhs, RValue<Byte8> rhs)
2491// {
2492// return lhs = lhs % rhs;
2493// }
2494
2495 RValue<Byte8> operator&=(const Byte8 &lhs, RValue<Byte8> rhs)
2496 {
2497 return lhs = lhs & rhs;
2498 }
2499
2500 RValue<Byte8> operator|=(const Byte8 &lhs, RValue<Byte8> rhs)
2501 {
2502 return lhs = lhs | rhs;
2503 }
2504
2505 RValue<Byte8> operator^=(const Byte8 &lhs, RValue<Byte8> rhs)
2506 {
2507 return lhs = lhs ^ rhs;
2508 }
2509
2510// RValue<Byte8> operator<<=(const Byte8 &lhs, RValue<Byte8> rhs)
2511// {
2512// return lhs = lhs << rhs;
2513// }
2514
2515// RValue<Byte8> operator>>=(const Byte8 &lhs, RValue<Byte8> rhs)
2516// {
2517// return lhs = lhs >> rhs;
2518// }
2519
2520// RValue<Byte8> operator+(RValue<Byte8> val)
2521// {
2522// return val;
2523// }
2524
2525// RValue<Byte8> operator-(RValue<Byte8> val)
2526// {
2527// return RValue<Byte8>(Nucleus::createNeg(val.value));
2528// }
2529
2530 RValue<Byte8> operator~(RValue<Byte8> val)
2531 {
2532 return RValue<Byte8>(Nucleus::createNot(val.value));
2533 }
2534
2535 RValue<Byte8> AddSat(RValue<Byte8> x, RValue<Byte8> y)
2536 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04002537 assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04002538 }
2539
2540 RValue<Byte8> SubSat(RValue<Byte8> x, RValue<Byte8> y)
2541 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04002542 assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04002543 }
2544
2545 RValue<Short4> Unpack(RValue<Byte4> x)
2546 {
Nicolas Capens37fbece2016-10-21 15:08:56 -04002547 int shuffle[16] = {0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7}; // Real type is v16i8
2548 return RValue<Short4>(Nucleus::createShuffleVector(x.value, x.value, shuffle));
Nicolas Capens598f8d82016-09-26 15:09:10 -04002549 }
2550
2551 RValue<Short4> UnpackLow(RValue<Byte8> x, RValue<Byte8> y)
2552 {
Nicolas Capens37fbece2016-10-21 15:08:56 -04002553 int shuffle[16] = {0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23}; // Real type is v16i8
2554 return RValue<Short4>(Nucleus::createShuffleVector(x.value, y.value, shuffle));
Nicolas Capens598f8d82016-09-26 15:09:10 -04002555 }
2556
2557 RValue<Short4> UnpackHigh(RValue<Byte8> x, RValue<Byte8> y)
2558 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04002559 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04002560 }
2561
2562 RValue<Int> SignMask(RValue<Byte8> x)
2563 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04002564 assert(false && "UNIMPLEMENTED"); return RValue<Int>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04002565 }
2566
2567// RValue<Byte8> CmpGT(RValue<Byte8> x, RValue<Byte8> y)
2568// {
Nicolas Capensc37252c2016-09-28 16:11:54 -04002569// assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04002570// }
2571
2572 RValue<Byte8> CmpEQ(RValue<Byte8> x, RValue<Byte8> y)
2573 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04002574 assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04002575 }
2576
2577 Type *Byte8::getType()
2578 {
Nicolas Capens23d99a42016-09-30 14:57:16 -04002579 return T(Type_v8i8);
Nicolas Capens598f8d82016-09-26 15:09:10 -04002580 }
2581
2582 SByte8::SByte8()
2583 {
2584 // xyzw.parent = this;
2585 }
2586
2587 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)
2588 {
2589 // xyzw.parent = this;
2590
Nicolas Capens8dfd9a72016-10-13 17:44:51 -04002591 int64_t constantVector[8] = { x0, x1, x2, x3, x4, x5, x6, x7 };
2592 Value *vector = V(Nucleus::createConstantVector(constantVector, getType()));
2593
2594 storeValue(Nucleus::createBitCast(vector, getType()));
Nicolas Capens598f8d82016-09-26 15:09:10 -04002595 }
2596
Nicolas Capens598f8d82016-09-26 15:09:10 -04002597 SByte8::SByte8(RValue<SByte8> rhs)
2598 {
2599 // xyzw.parent = this;
2600
2601 storeValue(rhs.value);
2602 }
2603
2604 SByte8::SByte8(const SByte8 &rhs)
2605 {
2606 // xyzw.parent = this;
2607
2608 Value *value = rhs.loadValue();
2609 storeValue(value);
2610 }
2611
2612 SByte8::SByte8(const Reference<SByte8> &rhs)
2613 {
2614 // xyzw.parent = this;
2615
2616 Value *value = rhs.loadValue();
2617 storeValue(value);
2618 }
2619
2620 RValue<SByte8> SByte8::operator=(RValue<SByte8> rhs) const
2621 {
2622 storeValue(rhs.value);
2623
2624 return rhs;
2625 }
2626
2627 RValue<SByte8> SByte8::operator=(const SByte8 &rhs) const
2628 {
2629 Value *value = rhs.loadValue();
2630 storeValue(value);
2631
2632 return RValue<SByte8>(value);
2633 }
2634
2635 RValue<SByte8> SByte8::operator=(const Reference<SByte8> &rhs) const
2636 {
2637 Value *value = rhs.loadValue();
2638 storeValue(value);
2639
2640 return RValue<SByte8>(value);
2641 }
2642
2643 RValue<SByte8> operator+(RValue<SByte8> lhs, RValue<SByte8> rhs)
2644 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04002645 assert(false && "UNIMPLEMENTED"); return RValue<SByte8>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04002646 }
2647
2648 RValue<SByte8> operator-(RValue<SByte8> lhs, RValue<SByte8> rhs)
2649 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04002650 assert(false && "UNIMPLEMENTED"); return RValue<SByte8>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04002651 }
2652
2653// RValue<SByte8> operator*(RValue<SByte8> lhs, RValue<SByte8> rhs)
2654// {
2655// return RValue<SByte8>(Nucleus::createMul(lhs.value, rhs.value));
2656// }
2657
2658// RValue<SByte8> operator/(RValue<SByte8> lhs, RValue<SByte8> rhs)
2659// {
2660// return RValue<SByte8>(Nucleus::createSDiv(lhs.value, rhs.value));
2661// }
2662
2663// RValue<SByte8> operator%(RValue<SByte8> lhs, RValue<SByte8> rhs)
2664// {
2665// return RValue<SByte8>(Nucleus::createSRem(lhs.value, rhs.value));
2666// }
2667
2668 RValue<SByte8> operator&(RValue<SByte8> lhs, RValue<SByte8> rhs)
2669 {
2670 return RValue<SByte8>(Nucleus::createAnd(lhs.value, rhs.value));
2671 }
2672
2673 RValue<SByte8> operator|(RValue<SByte8> lhs, RValue<SByte8> rhs)
2674 {
2675 return RValue<SByte8>(Nucleus::createOr(lhs.value, rhs.value));
2676 }
2677
2678 RValue<SByte8> operator^(RValue<SByte8> lhs, RValue<SByte8> rhs)
2679 {
2680 return RValue<SByte8>(Nucleus::createXor(lhs.value, rhs.value));
2681 }
2682
2683// RValue<SByte8> operator<<(RValue<SByte8> lhs, unsigned char rhs)
2684// {
Nicolas Capens327f1df2016-10-21 14:26:34 -04002685// return RValue<SByte8>(Nucleus::createShl(lhs.value, C(::context->getConstantInt32(rhs))));
Nicolas Capens598f8d82016-09-26 15:09:10 -04002686// }
2687
2688// RValue<SByte8> operator>>(RValue<SByte8> lhs, unsigned char rhs)
2689// {
Nicolas Capens327f1df2016-10-21 14:26:34 -04002690// return RValue<SByte8>(Nucleus::createAShr(lhs.value, C(::context->getConstantInt32(rhs))));
Nicolas Capens598f8d82016-09-26 15:09:10 -04002691// }
2692
2693 RValue<SByte8> operator+=(const SByte8 &lhs, RValue<SByte8> rhs)
2694 {
2695 return lhs = lhs + rhs;
2696 }
2697
2698 RValue<SByte8> operator-=(const SByte8 &lhs, RValue<SByte8> rhs)
2699 {
2700 return lhs = lhs - rhs;
2701 }
2702
2703// RValue<SByte8> operator*=(const SByte8 &lhs, RValue<SByte8> rhs)
2704// {
2705// return lhs = lhs * rhs;
2706// }
2707
2708// RValue<SByte8> operator/=(const SByte8 &lhs, RValue<SByte8> rhs)
2709// {
2710// return lhs = lhs / rhs;
2711// }
2712
2713// RValue<SByte8> operator%=(const SByte8 &lhs, RValue<SByte8> rhs)
2714// {
2715// return lhs = lhs % rhs;
2716// }
2717
2718 RValue<SByte8> operator&=(const SByte8 &lhs, RValue<SByte8> rhs)
2719 {
2720 return lhs = lhs & rhs;
2721 }
2722
2723 RValue<SByte8> operator|=(const SByte8 &lhs, RValue<SByte8> rhs)
2724 {
2725 return lhs = lhs | rhs;
2726 }
2727
2728 RValue<SByte8> operator^=(const SByte8 &lhs, RValue<SByte8> rhs)
2729 {
2730 return lhs = lhs ^ rhs;
2731 }
2732
2733// RValue<SByte8> operator<<=(const SByte8 &lhs, RValue<SByte8> rhs)
2734// {
2735// return lhs = lhs << rhs;
2736// }
2737
2738// RValue<SByte8> operator>>=(const SByte8 &lhs, RValue<SByte8> rhs)
2739// {
2740// return lhs = lhs >> rhs;
2741// }
2742
2743// RValue<SByte8> operator+(RValue<SByte8> val)
2744// {
2745// return val;
2746// }
2747
2748// RValue<SByte8> operator-(RValue<SByte8> val)
2749// {
2750// return RValue<SByte8>(Nucleus::createNeg(val.value));
2751// }
2752
2753 RValue<SByte8> operator~(RValue<SByte8> val)
2754 {
2755 return RValue<SByte8>(Nucleus::createNot(val.value));
2756 }
2757
2758 RValue<SByte8> AddSat(RValue<SByte8> x, RValue<SByte8> y)
2759 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04002760 assert(false && "UNIMPLEMENTED"); return RValue<SByte8>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04002761 }
2762
2763 RValue<SByte8> SubSat(RValue<SByte8> x, RValue<SByte8> y)
2764 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04002765 assert(false && "UNIMPLEMENTED"); return RValue<SByte8>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04002766 }
2767
2768 RValue<Short4> UnpackLow(RValue<SByte8> x, RValue<SByte8> y)
2769 {
Nicolas Capens37fbece2016-10-21 15:08:56 -04002770 int shuffle[16] = {0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23}; // Real type is v16i8
2771 return RValue<Short4>(Nucleus::createShuffleVector(x.value, y.value, shuffle));
Nicolas Capens598f8d82016-09-26 15:09:10 -04002772 }
2773
2774 RValue<Short4> UnpackHigh(RValue<SByte8> x, RValue<SByte8> y)
2775 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04002776 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04002777 }
2778
2779 RValue<Int> SignMask(RValue<SByte8> x)
2780 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04002781 assert(false && "UNIMPLEMENTED"); return RValue<Int>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04002782 }
2783
2784 RValue<Byte8> CmpGT(RValue<SByte8> x, RValue<SByte8> y)
2785 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04002786 assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04002787 }
2788
2789 RValue<Byte8> CmpEQ(RValue<SByte8> x, RValue<SByte8> y)
2790 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04002791 assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04002792 }
2793
2794 Type *SByte8::getType()
2795 {
Nicolas Capens4cfd4572016-10-20 01:00:19 -04002796 return T(Type_v8i8);
Nicolas Capens598f8d82016-09-26 15:09:10 -04002797 }
2798
2799 Byte16::Byte16(RValue<Byte16> rhs)
2800 {
2801 // xyzw.parent = this;
2802
2803 storeValue(rhs.value);
2804 }
2805
2806 Byte16::Byte16(const Byte16 &rhs)
2807 {
2808 // xyzw.parent = this;
2809
2810 Value *value = rhs.loadValue();
2811 storeValue(value);
2812 }
2813
2814 Byte16::Byte16(const Reference<Byte16> &rhs)
2815 {
2816 // xyzw.parent = this;
2817
2818 Value *value = rhs.loadValue();
2819 storeValue(value);
2820 }
2821
2822 RValue<Byte16> Byte16::operator=(RValue<Byte16> rhs) const
2823 {
2824 storeValue(rhs.value);
2825
2826 return rhs;
2827 }
2828
2829 RValue<Byte16> Byte16::operator=(const Byte16 &rhs) const
2830 {
2831 Value *value = rhs.loadValue();
2832 storeValue(value);
2833
2834 return RValue<Byte16>(value);
2835 }
2836
2837 RValue<Byte16> Byte16::operator=(const Reference<Byte16> &rhs) const
2838 {
2839 Value *value = rhs.loadValue();
2840 storeValue(value);
2841
2842 return RValue<Byte16>(value);
2843 }
2844
2845 Type *Byte16::getType()
2846 {
Nicolas Capens23d99a42016-09-30 14:57:16 -04002847 return T(Ice::IceType_v16i8);
Nicolas Capens598f8d82016-09-26 15:09:10 -04002848 }
2849
2850 Type *SByte16::getType()
2851 {
Nicolas Capens23d99a42016-09-30 14:57:16 -04002852 return T(Ice::IceType_v16i8);
Nicolas Capens598f8d82016-09-26 15:09:10 -04002853 }
2854
Nicolas Capens16b5f152016-10-13 13:39:01 -04002855 Short2::Short2(RValue<Short4> cast)
2856 {
2857 assert(false && "UNIMPLEMENTED");
2858 }
2859
2860 Type *Short2::getType()
2861 {
Nicolas Capens23d99a42016-09-30 14:57:16 -04002862 return T(Type_v2i16);
Nicolas Capens16b5f152016-10-13 13:39:01 -04002863 }
2864
2865 UShort2::UShort2(RValue<UShort4> cast)
2866 {
2867 assert(false && "UNIMPLEMENTED");
2868 }
2869
2870 Type *UShort2::getType()
2871 {
Nicolas Capens23d99a42016-09-30 14:57:16 -04002872 return T(Type_v2i16);
Nicolas Capens16b5f152016-10-13 13:39:01 -04002873 }
2874
Nicolas Capens598f8d82016-09-26 15:09:10 -04002875 Short4::Short4(RValue<Int> cast)
2876 {
2877 Value *extend = Nucleus::createZExt(cast.value, Long::getType());
2878 Value *swizzle = Swizzle(RValue<Short4>(extend), 0x00).value;
2879
2880 storeValue(swizzle);
2881 }
2882
2883 Short4::Short4(RValue<Int4> cast)
2884 {
2885 assert(false && "UNIMPLEMENTED");
2886 }
2887
2888// Short4::Short4(RValue<Float> cast)
2889// {
2890// }
2891
2892 Short4::Short4(RValue<Float4> cast)
2893 {
2894 assert(false && "UNIMPLEMENTED");
2895 }
2896
2897 Short4::Short4()
2898 {
2899 // xyzw.parent = this;
2900 }
2901
2902 Short4::Short4(short xyzw)
2903 {
2904 // xyzw.parent = this;
2905
Nicolas Capens8dfd9a72016-10-13 17:44:51 -04002906 int64_t constantVector[4] = {xyzw, xyzw, xyzw, xyzw};
2907 storeValue(Nucleus::createConstantVector(constantVector, getType()));
Nicolas Capens598f8d82016-09-26 15:09:10 -04002908 }
2909
2910 Short4::Short4(short x, short y, short z, short w)
2911 {
Nicolas Capens8dfd9a72016-10-13 17:44:51 -04002912 // xyzw.parent = this;
Nicolas Capens598f8d82016-09-26 15:09:10 -04002913
Nicolas Capens8dfd9a72016-10-13 17:44:51 -04002914 int64_t constantVector[4] = {x, y, z, w};
2915 storeValue(Nucleus::createConstantVector(constantVector, getType()));
Nicolas Capens598f8d82016-09-26 15:09:10 -04002916 }
2917
2918 Short4::Short4(RValue<Short4> rhs)
2919 {
2920 // xyzw.parent = this;
2921
2922 storeValue(rhs.value);
2923 }
2924
2925 Short4::Short4(const Short4 &rhs)
2926 {
2927 // xyzw.parent = this;
2928
2929 Value *value = rhs.loadValue();
2930 storeValue(value);
2931 }
2932
2933 Short4::Short4(const Reference<Short4> &rhs)
2934 {
2935 // xyzw.parent = this;
2936
2937 Value *value = rhs.loadValue();
2938 storeValue(value);
2939 }
2940
2941 Short4::Short4(RValue<UShort4> rhs)
2942 {
2943 // xyzw.parent = this;
2944
2945 storeValue(rhs.value);
2946 }
2947
2948 Short4::Short4(const UShort4 &rhs)
2949 {
2950 // xyzw.parent = this;
2951
2952 storeValue(rhs.loadValue());
2953 }
2954
2955 Short4::Short4(const Reference<UShort4> &rhs)
2956 {
2957 // xyzw.parent = this;
2958
2959 storeValue(rhs.loadValue());
2960 }
2961
2962 RValue<Short4> Short4::operator=(RValue<Short4> rhs) const
2963 {
2964 storeValue(rhs.value);
2965
2966 return rhs;
2967 }
2968
2969 RValue<Short4> Short4::operator=(const Short4 &rhs) const
2970 {
2971 Value *value = rhs.loadValue();
2972 storeValue(value);
2973
2974 return RValue<Short4>(value);
2975 }
2976
2977 RValue<Short4> Short4::operator=(const Reference<Short4> &rhs) const
2978 {
2979 Value *value = rhs.loadValue();
2980 storeValue(value);
2981
2982 return RValue<Short4>(value);
2983 }
2984
2985 RValue<Short4> Short4::operator=(RValue<UShort4> rhs) const
2986 {
2987 storeValue(rhs.value);
2988
2989 return RValue<Short4>(rhs);
2990 }
2991
2992 RValue<Short4> Short4::operator=(const UShort4 &rhs) const
2993 {
2994 Value *value = rhs.loadValue();
2995 storeValue(value);
2996
2997 return RValue<Short4>(value);
2998 }
2999
3000 RValue<Short4> Short4::operator=(const Reference<UShort4> &rhs) const
3001 {
3002 Value *value = rhs.loadValue();
3003 storeValue(value);
3004
3005 return RValue<Short4>(value);
3006 }
3007
3008 RValue<Short4> operator+(RValue<Short4> lhs, RValue<Short4> rhs)
3009 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003010 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003011 }
3012
3013 RValue<Short4> operator-(RValue<Short4> lhs, RValue<Short4> rhs)
3014 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003015 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003016 }
3017
3018 RValue<Short4> operator*(RValue<Short4> lhs, RValue<Short4> rhs)
3019 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003020 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003021 }
3022
3023// RValue<Short4> operator/(RValue<Short4> lhs, RValue<Short4> rhs)
3024// {
3025// return RValue<Short4>(Nucleus::createSDiv(lhs.value, rhs.value));
3026// }
3027
3028// RValue<Short4> operator%(RValue<Short4> lhs, RValue<Short4> rhs)
3029// {
3030// return RValue<Short4>(Nucleus::createSRem(lhs.value, rhs.value));
3031// }
3032
3033 RValue<Short4> operator&(RValue<Short4> lhs, RValue<Short4> rhs)
3034 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003035 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003036 }
3037
3038 RValue<Short4> operator|(RValue<Short4> lhs, RValue<Short4> rhs)
3039 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003040 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003041 }
3042
3043 RValue<Short4> operator^(RValue<Short4> lhs, RValue<Short4> rhs)
3044 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003045 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003046 }
3047
3048 RValue<Short4> operator<<(RValue<Short4> lhs, unsigned char rhs)
3049 {
Nicolas Capens327f1df2016-10-21 14:26:34 -04003050 return RValue<Short4>(Nucleus::createShl(lhs.value, C(::context->getConstantInt32(rhs))));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003051 }
3052
3053 RValue<Short4> operator>>(RValue<Short4> lhs, unsigned char rhs)
3054 {
Nicolas Capens327f1df2016-10-21 14:26:34 -04003055 return RValue<Short4>(Nucleus::createAShr(lhs.value, C(::context->getConstantInt32(rhs))));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003056 }
3057
3058 RValue<Short4> operator<<(RValue<Short4> lhs, RValue<Long1> rhs)
3059 {
3060 // return RValue<Short4>(Nucleus::createShl(lhs.value, rhs.value));
3061
Nicolas Capensc37252c2016-09-28 16:11:54 -04003062 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003063 }
3064
3065 RValue<Short4> operator>>(RValue<Short4> lhs, RValue<Long1> rhs)
3066 {
3067 // return RValue<Short4>(Nucleus::createAShr(lhs.value, rhs.value));
3068
Nicolas Capensc37252c2016-09-28 16:11:54 -04003069 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003070 }
3071
3072 RValue<Short4> operator+=(const Short4 &lhs, RValue<Short4> rhs)
3073 {
3074 return lhs = lhs + rhs;
3075 }
3076
3077 RValue<Short4> operator-=(const Short4 &lhs, RValue<Short4> rhs)
3078 {
3079 return lhs = lhs - rhs;
3080 }
3081
3082 RValue<Short4> operator*=(const Short4 &lhs, RValue<Short4> rhs)
3083 {
3084 return lhs = lhs * rhs;
3085 }
3086
3087// RValue<Short4> operator/=(const Short4 &lhs, RValue<Short4> rhs)
3088// {
3089// return lhs = lhs / rhs;
3090// }
3091
3092// RValue<Short4> operator%=(const Short4 &lhs, RValue<Short4> rhs)
3093// {
3094// return lhs = lhs % rhs;
3095// }
3096
3097 RValue<Short4> operator&=(const Short4 &lhs, RValue<Short4> rhs)
3098 {
3099 return lhs = lhs & rhs;
3100 }
3101
3102 RValue<Short4> operator|=(const Short4 &lhs, RValue<Short4> rhs)
3103 {
3104 return lhs = lhs | rhs;
3105 }
3106
3107 RValue<Short4> operator^=(const Short4 &lhs, RValue<Short4> rhs)
3108 {
3109 return lhs = lhs ^ rhs;
3110 }
3111
3112 RValue<Short4> operator<<=(const Short4 &lhs, unsigned char rhs)
3113 {
3114 return lhs = lhs << rhs;
3115 }
3116
3117 RValue<Short4> operator>>=(const Short4 &lhs, unsigned char rhs)
3118 {
3119 return lhs = lhs >> rhs;
3120 }
3121
3122 RValue<Short4> operator<<=(const Short4 &lhs, RValue<Long1> rhs)
3123 {
3124 return lhs = lhs << rhs;
3125 }
3126
3127 RValue<Short4> operator>>=(const Short4 &lhs, RValue<Long1> rhs)
3128 {
3129 return lhs = lhs >> rhs;
3130 }
3131
3132// RValue<Short4> operator+(RValue<Short4> val)
3133// {
3134// return val;
3135// }
3136
3137 RValue<Short4> operator-(RValue<Short4> val)
3138 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003139 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003140 }
3141
3142 RValue<Short4> operator~(RValue<Short4> val)
3143 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003144 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003145 }
3146
3147 RValue<Short4> RoundShort4(RValue<Float4> cast)
3148 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003149 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003150 }
3151
3152 RValue<Short4> Max(RValue<Short4> x, RValue<Short4> y)
3153 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003154 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003155 }
3156
3157 RValue<Short4> Min(RValue<Short4> x, RValue<Short4> y)
3158 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003159 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003160 }
3161
3162 RValue<Short4> AddSat(RValue<Short4> x, RValue<Short4> y)
3163 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003164 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003165 }
3166
3167 RValue<Short4> SubSat(RValue<Short4> x, RValue<Short4> y)
3168 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003169 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003170 }
3171
3172 RValue<Short4> MulHigh(RValue<Short4> x, RValue<Short4> y)
3173 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003174 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003175 }
3176
3177 RValue<Int2> MulAdd(RValue<Short4> x, RValue<Short4> y)
3178 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003179 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003180 }
3181
3182 RValue<SByte8> Pack(RValue<Short4> x, RValue<Short4> y)
3183 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003184 assert(false && "UNIMPLEMENTED"); return RValue<SByte8>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003185 }
3186
3187 RValue<Int2> UnpackLow(RValue<Short4> x, RValue<Short4> y)
3188 {
Nicolas Capens37fbece2016-10-21 15:08:56 -04003189 int shuffle[8] = {0, 8, 1, 9, 2, 10, 3, 11}; // Real type is v8i16
3190 return RValue<Int2>(Nucleus::createShuffleVector(x.value, y.value, shuffle));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003191 }
3192
3193 RValue<Int2> UnpackHigh(RValue<Short4> x, RValue<Short4> y)
3194 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003195 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003196 }
3197
3198 RValue<Short4> Swizzle(RValue<Short4> x, unsigned char select)
3199 {
Nicolas Capens37fbece2016-10-21 15:08:56 -04003200 // Real type is v8i16
3201 int shuffle[8] =
3202 {
3203 (select >> 0) & 0x03,
3204 (select >> 2) & 0x03,
3205 (select >> 4) & 0x03,
3206 (select >> 6) & 0x03,
3207 (select >> 0) & 0x03,
3208 (select >> 2) & 0x03,
3209 (select >> 4) & 0x03,
3210 (select >> 6) & 0x03,
3211 };
3212
3213 return RValue<Short4>(Nucleus::createShuffleVector(x.value, x.value, shuffle));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003214 }
3215
3216 RValue<Short4> Insert(RValue<Short4> val, RValue<Short> element, int i)
3217 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003218 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003219 }
3220
3221 RValue<Short> Extract(RValue<Short4> val, int i)
3222 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003223 assert(false && "UNIMPLEMENTED"); return RValue<Short>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003224 }
3225
3226 RValue<Short4> CmpGT(RValue<Short4> x, RValue<Short4> y)
3227 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003228 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003229 }
3230
3231 RValue<Short4> CmpEQ(RValue<Short4> x, RValue<Short4> y)
3232 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003233 assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003234 }
3235
3236 Type *Short4::getType()
3237 {
Nicolas Capens23d99a42016-09-30 14:57:16 -04003238 return T(Type_v4i16);
Nicolas Capens598f8d82016-09-26 15:09:10 -04003239 }
3240
3241 UShort4::UShort4(RValue<Int4> cast)
3242 {
3243 *this = Short4(cast);
3244 }
3245
3246 UShort4::UShort4(RValue<Float4> cast, bool saturate)
3247 {
3248 assert(false && "UNIMPLEMENTED");
3249 }
3250
3251 UShort4::UShort4()
3252 {
3253 // xyzw.parent = this;
3254 }
3255
3256 UShort4::UShort4(unsigned short xyzw)
3257 {
Nicolas Capens8dfd9a72016-10-13 17:44:51 -04003258 // xyzw.parent = this;
Nicolas Capens598f8d82016-09-26 15:09:10 -04003259
Nicolas Capens8dfd9a72016-10-13 17:44:51 -04003260 int64_t constantVector[4] = {xyzw, xyzw, xyzw, xyzw};
3261 storeValue(Nucleus::createConstantVector(constantVector, getType()));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003262 }
3263
3264 UShort4::UShort4(unsigned short x, unsigned short y, unsigned short z, unsigned short w)
3265 {
3266 // xyzw.parent = this;
3267
Nicolas Capens8dfd9a72016-10-13 17:44:51 -04003268 int64_t constantVector[4] = {x, y, z, w};
3269 storeValue(Nucleus::createConstantVector(constantVector, getType()));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003270 }
3271
3272 UShort4::UShort4(RValue<UShort4> rhs)
3273 {
3274 // xyzw.parent = this;
3275
3276 storeValue(rhs.value);
3277 }
3278
3279 UShort4::UShort4(const UShort4 &rhs)
3280 {
3281 // xyzw.parent = this;
3282
3283 Value *value = rhs.loadValue();
3284 storeValue(value);
3285 }
3286
3287 UShort4::UShort4(const Reference<UShort4> &rhs)
3288 {
3289 // xyzw.parent = this;
3290
3291 Value *value = rhs.loadValue();
3292 storeValue(value);
3293 }
3294
3295 UShort4::UShort4(RValue<Short4> rhs)
3296 {
3297 // xyzw.parent = this;
3298
3299 storeValue(rhs.value);
3300 }
3301
3302 UShort4::UShort4(const Short4 &rhs)
3303 {
3304 // xyzw.parent = this;
3305
3306 Value *value = rhs.loadValue();
3307 storeValue(value);
3308 }
3309
3310 UShort4::UShort4(const Reference<Short4> &rhs)
3311 {
3312 // xyzw.parent = this;
3313
3314 Value *value = rhs.loadValue();
3315 storeValue(value);
3316 }
3317
3318 RValue<UShort4> UShort4::operator=(RValue<UShort4> rhs) const
3319 {
3320 storeValue(rhs.value);
3321
3322 return rhs;
3323 }
3324
3325 RValue<UShort4> UShort4::operator=(const UShort4 &rhs) const
3326 {
3327 Value *value = rhs.loadValue();
3328 storeValue(value);
3329
3330 return RValue<UShort4>(value);
3331 }
3332
3333 RValue<UShort4> UShort4::operator=(const Reference<UShort4> &rhs) const
3334 {
3335 Value *value = rhs.loadValue();
3336 storeValue(value);
3337
3338 return RValue<UShort4>(value);
3339 }
3340
3341 RValue<UShort4> UShort4::operator=(RValue<Short4> rhs) const
3342 {
3343 storeValue(rhs.value);
3344
3345 return RValue<UShort4>(rhs);
3346 }
3347
3348 RValue<UShort4> UShort4::operator=(const Short4 &rhs) const
3349 {
3350 Value *value = rhs.loadValue();
3351 storeValue(value);
3352
3353 return RValue<UShort4>(value);
3354 }
3355
3356 RValue<UShort4> UShort4::operator=(const Reference<Short4> &rhs) const
3357 {
3358 Value *value = rhs.loadValue();
3359 storeValue(value);
3360
3361 return RValue<UShort4>(value);
3362 }
3363
3364 RValue<UShort4> operator+(RValue<UShort4> lhs, RValue<UShort4> rhs)
3365 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003366 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003367 }
3368
3369 RValue<UShort4> operator-(RValue<UShort4> lhs, RValue<UShort4> rhs)
3370 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003371 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003372 }
3373
3374 RValue<UShort4> operator*(RValue<UShort4> lhs, RValue<UShort4> rhs)
3375 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003376 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003377 }
3378
Nicolas Capens16b5f152016-10-13 13:39:01 -04003379 RValue<UShort4> operator&(RValue<UShort4> lhs, RValue<UShort4> rhs)
3380 {
3381 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3382 }
3383
3384 RValue<UShort4> operator|(RValue<UShort4> lhs, RValue<UShort4> rhs)
3385 {
3386 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3387 }
3388
3389 RValue<UShort4> operator^(RValue<UShort4> lhs, RValue<UShort4> rhs)
3390 {
3391 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
3392 }
3393
Nicolas Capens598f8d82016-09-26 15:09:10 -04003394 RValue<UShort4> operator<<(RValue<UShort4> lhs, unsigned char rhs)
3395 {
Nicolas Capens327f1df2016-10-21 14:26:34 -04003396 return RValue<UShort4>(Nucleus::createShl(lhs.value, C(::context->getConstantInt32(rhs))));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003397 }
3398
3399 RValue<UShort4> operator>>(RValue<UShort4> lhs, unsigned char rhs)
3400 {
Nicolas Capens327f1df2016-10-21 14:26:34 -04003401 return RValue<UShort4>(Nucleus::createLShr(lhs.value, C(::context->getConstantInt32(rhs))));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003402 }
3403
3404 RValue<UShort4> operator<<(RValue<UShort4> lhs, RValue<Long1> rhs)
3405 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003406 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003407 }
3408
3409 RValue<UShort4> operator>>(RValue<UShort4> lhs, RValue<Long1> rhs)
3410 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003411 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003412 }
3413
3414 RValue<UShort4> operator<<=(const UShort4 &lhs, unsigned char rhs)
3415 {
3416 return lhs = lhs << rhs;
3417 }
3418
3419 RValue<UShort4> operator>>=(const UShort4 &lhs, unsigned char rhs)
3420 {
3421 return lhs = lhs >> rhs;
3422 }
3423
3424 RValue<UShort4> operator<<=(const UShort4 &lhs, RValue<Long1> rhs)
3425 {
3426 return lhs = lhs << rhs;
3427 }
3428
3429 RValue<UShort4> operator>>=(const UShort4 &lhs, RValue<Long1> rhs)
3430 {
3431 return lhs = lhs >> rhs;
3432 }
3433
3434 RValue<UShort4> operator~(RValue<UShort4> val)
3435 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003436 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003437 }
3438
3439 RValue<UShort4> Max(RValue<UShort4> x, RValue<UShort4> y)
3440 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003441 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003442 }
3443
3444 RValue<UShort4> Min(RValue<UShort4> x, RValue<UShort4> y)
3445 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003446 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003447 }
3448
3449 RValue<UShort4> AddSat(RValue<UShort4> x, RValue<UShort4> y)
3450 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003451 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003452 }
3453
3454 RValue<UShort4> SubSat(RValue<UShort4> x, RValue<UShort4> y)
3455 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003456 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003457 }
3458
3459 RValue<UShort4> MulHigh(RValue<UShort4> x, RValue<UShort4> y)
3460 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003461 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003462 }
3463
3464 RValue<UShort4> Average(RValue<UShort4> x, RValue<UShort4> y)
3465 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003466 assert(false && "UNIMPLEMENTED"); return RValue<UShort4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003467 }
3468
3469 RValue<Byte8> Pack(RValue<UShort4> x, RValue<UShort4> y)
3470 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003471 assert(false && "UNIMPLEMENTED"); return RValue<Byte8>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003472 }
3473
3474 Type *UShort4::getType()
3475 {
Nicolas Capens23d99a42016-09-30 14:57:16 -04003476 return T(Type_v4i16);
Nicolas Capens598f8d82016-09-26 15:09:10 -04003477 }
3478
3479 Short8::Short8(short c0, short c1, short c2, short c3, short c4, short c5, short c6, short c7)
3480 {
3481 // xyzw.parent = this;
3482
Nicolas Capens8dfd9a72016-10-13 17:44:51 -04003483 int64_t constantVector[8] = {c0, c1, c2, c3, c4, c5, c6, c7};
3484 storeValue(Nucleus::createConstantVector(constantVector, getType()));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003485 }
3486
3487 Short8::Short8(RValue<Short8> rhs)
3488 {
3489 // xyzw.parent = this;
3490
3491 storeValue(rhs.value);
3492 }
3493
3494 Short8::Short8(const Reference<Short8> &rhs)
3495 {
3496 // xyzw.parent = this;
3497
3498 Value *value = rhs.loadValue();
3499 storeValue(value);
3500 }
3501
3502 Short8::Short8(RValue<Short4> lo, RValue<Short4> hi)
3503 {
3504 assert(false && "UNIMPLEMENTED");
3505 }
3506
3507 RValue<Short8> operator+(RValue<Short8> lhs, RValue<Short8> rhs)
3508 {
3509 return RValue<Short8>(Nucleus::createAdd(lhs.value, rhs.value));
3510 }
3511
3512 RValue<Short8> operator&(RValue<Short8> lhs, RValue<Short8> rhs)
3513 {
3514 return RValue<Short8>(Nucleus::createAnd(lhs.value, rhs.value));
3515 }
3516
3517 RValue<Short8> operator<<(RValue<Short8> lhs, unsigned char rhs)
3518 {
Nicolas Capens327f1df2016-10-21 14:26:34 -04003519 return RValue<Short8>(Nucleus::createShl(lhs.value, C(::context->getConstantInt32(rhs))));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003520 }
3521
3522 RValue<Short8> operator>>(RValue<Short8> lhs, unsigned char rhs)
3523 {
Nicolas Capens327f1df2016-10-21 14:26:34 -04003524 return RValue<Short8>(Nucleus::createAShr(lhs.value, C(::context->getConstantInt32(rhs))));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003525 }
3526
3527 RValue<Int4> MulAdd(RValue<Short8> x, RValue<Short8> y)
3528 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003529 assert(false && "UNIMPLEMENTED"); return RValue<Int4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003530 }
3531
3532 RValue<Int4> Abs(RValue<Int4> x)
3533 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003534 assert(false && "UNIMPLEMENTED"); return RValue<Int4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003535 }
3536
3537 RValue<Short8> MulHigh(RValue<Short8> x, RValue<Short8> y)
3538 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003539 assert(false && "UNIMPLEMENTED"); return RValue<Short8>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003540 }
3541
3542 Type *Short8::getType()
3543 {
Nicolas Capens4cfd4572016-10-20 01:00:19 -04003544 return T(Ice::IceType_v8i16);
Nicolas Capens598f8d82016-09-26 15:09:10 -04003545 }
3546
3547 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)
3548 {
Nicolas Capens8dfd9a72016-10-13 17:44:51 -04003549 int64_t constantVector[8] = {c0, c1, c2, c3, c4, c5, c6, c7};
3550 storeValue(Nucleus::createConstantVector(constantVector, getType()));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003551 }
3552
3553 UShort8::UShort8(RValue<UShort8> rhs)
3554 {
Nicolas Capens598f8d82016-09-26 15:09:10 -04003555 storeValue(rhs.value);
3556 }
3557
3558 UShort8::UShort8(const Reference<UShort8> &rhs)
3559 {
Nicolas Capens598f8d82016-09-26 15:09:10 -04003560 Value *value = rhs.loadValue();
3561 storeValue(value);
3562 }
3563
3564 UShort8::UShort8(RValue<UShort4> lo, RValue<UShort4> hi)
3565 {
3566 assert(false && "UNIMPLEMENTED");
3567 }
3568
3569 RValue<UShort8> UShort8::operator=(RValue<UShort8> rhs) const
3570 {
3571 storeValue(rhs.value);
3572
3573 return rhs;
3574 }
3575
3576 RValue<UShort8> UShort8::operator=(const UShort8 &rhs) const
3577 {
3578 Value *value = rhs.loadValue();
3579 storeValue(value);
3580
3581 return RValue<UShort8>(value);
3582 }
3583
3584 RValue<UShort8> UShort8::operator=(const Reference<UShort8> &rhs) const
3585 {
3586 Value *value = rhs.loadValue();
3587 storeValue(value);
3588
3589 return RValue<UShort8>(value);
3590 }
3591
3592 RValue<UShort8> operator&(RValue<UShort8> lhs, RValue<UShort8> rhs)
3593 {
3594 return RValue<UShort8>(Nucleus::createAnd(lhs.value, rhs.value));
3595 }
3596
3597 RValue<UShort8> operator<<(RValue<UShort8> lhs, unsigned char rhs)
3598 {
Nicolas Capens327f1df2016-10-21 14:26:34 -04003599 return RValue<UShort8>(Nucleus::createShl(lhs.value, C(::context->getConstantInt32(rhs))));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003600 }
3601
3602 RValue<UShort8> operator>>(RValue<UShort8> lhs, unsigned char rhs)
3603 {
Nicolas Capens327f1df2016-10-21 14:26:34 -04003604 return RValue<UShort8>(Nucleus::createLShr(lhs.value, C(::context->getConstantInt32(rhs))));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003605 }
3606
3607 RValue<UShort8> operator+(RValue<UShort8> lhs, RValue<UShort8> rhs)
3608 {
3609 return RValue<UShort8>(Nucleus::createAdd(lhs.value, rhs.value));
3610 }
3611
3612 RValue<UShort8> operator*(RValue<UShort8> lhs, RValue<UShort8> rhs)
3613 {
3614 return RValue<UShort8>(Nucleus::createMul(lhs.value, rhs.value));
3615 }
3616
3617 RValue<UShort8> operator+=(const UShort8 &lhs, RValue<UShort8> rhs)
3618 {
3619 return lhs = lhs + rhs;
3620 }
3621
3622 RValue<UShort8> operator~(RValue<UShort8> val)
3623 {
3624 return RValue<UShort8>(Nucleus::createNot(val.value));
3625 }
3626
3627 RValue<UShort8> Swizzle(RValue<UShort8> x, char select0, char select1, char select2, char select3, char select4, char select5, char select6, char select7)
3628 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003629 assert(false && "UNIMPLEMENTED"); return RValue<UShort8>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003630 }
3631
3632 RValue<UShort8> MulHigh(RValue<UShort8> x, RValue<UShort8> y)
3633 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003634 assert(false && "UNIMPLEMENTED"); return RValue<UShort8>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003635 }
3636
3637 // FIXME: Implement as Shuffle(x, y, Select(i0, ..., i16)) and Shuffle(x, y, SELECT_PACK_REPEAT(element))
3638// RValue<UShort8> PackRepeat(RValue<Byte16> x, RValue<Byte16> y, int element)
3639// {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003640// assert(false && "UNIMPLEMENTED"); return RValue<UShort8>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003641// }
3642
3643 Type *UShort8::getType()
3644 {
Nicolas Capens4cfd4572016-10-20 01:00:19 -04003645 return T(Ice::IceType_v8i16);
Nicolas Capens598f8d82016-09-26 15:09:10 -04003646 }
3647
3648 Int::Int(Argument<Int> argument)
3649 {
3650 storeValue(argument.value);
3651 }
3652
3653 Int::Int(RValue<Byte> cast)
3654 {
3655 Value *integer = Nucleus::createZExt(cast.value, Int::getType());
3656
3657 storeValue(integer);
3658 }
3659
3660 Int::Int(RValue<SByte> cast)
3661 {
3662 Value *integer = Nucleus::createSExt(cast.value, Int::getType());
3663
3664 storeValue(integer);
3665 }
3666
3667 Int::Int(RValue<Short> cast)
3668 {
3669 Value *integer = Nucleus::createSExt(cast.value, Int::getType());
3670
3671 storeValue(integer);
3672 }
3673
3674 Int::Int(RValue<UShort> cast)
3675 {
3676 Value *integer = Nucleus::createZExt(cast.value, Int::getType());
3677
3678 storeValue(integer);
3679 }
3680
3681 Int::Int(RValue<Int2> cast)
3682 {
3683 *this = Extract(cast, 0);
3684 }
3685
3686 Int::Int(RValue<Long> cast)
3687 {
3688 Value *integer = Nucleus::createTrunc(cast.value, Int::getType());
3689
3690 storeValue(integer);
3691 }
3692
3693 Int::Int(RValue<Float> cast)
3694 {
3695 Value *integer = Nucleus::createFPToSI(cast.value, Int::getType());
3696
3697 storeValue(integer);
3698 }
3699
3700 Int::Int()
3701 {
3702 }
3703
3704 Int::Int(int x)
3705 {
3706 storeValue(Nucleus::createConstantInt(x));
3707 }
3708
3709 Int::Int(RValue<Int> rhs)
3710 {
3711 storeValue(rhs.value);
3712 }
3713
3714 Int::Int(RValue<UInt> rhs)
3715 {
3716 storeValue(rhs.value);
3717 }
3718
3719 Int::Int(const Int &rhs)
3720 {
3721 Value *value = rhs.loadValue();
3722 storeValue(value);
3723 }
3724
3725 Int::Int(const Reference<Int> &rhs)
3726 {
3727 Value *value = rhs.loadValue();
3728 storeValue(value);
3729 }
3730
3731 Int::Int(const UInt &rhs)
3732 {
3733 Value *value = rhs.loadValue();
3734 storeValue(value);
3735 }
3736
3737 Int::Int(const Reference<UInt> &rhs)
3738 {
3739 Value *value = rhs.loadValue();
3740 storeValue(value);
3741 }
3742
3743 RValue<Int> Int::operator=(int rhs) const
3744 {
3745 return RValue<Int>(storeValue(Nucleus::createConstantInt(rhs)));
3746 }
3747
3748 RValue<Int> Int::operator=(RValue<Int> rhs) const
3749 {
3750 storeValue(rhs.value);
3751
3752 return rhs;
3753 }
3754
3755 RValue<Int> Int::operator=(RValue<UInt> rhs) const
3756 {
3757 storeValue(rhs.value);
3758
3759 return RValue<Int>(rhs);
3760 }
3761
3762 RValue<Int> Int::operator=(const Int &rhs) const
3763 {
3764 Value *value = rhs.loadValue();
3765 storeValue(value);
3766
3767 return RValue<Int>(value);
3768 }
3769
3770 RValue<Int> Int::operator=(const Reference<Int> &rhs) const
3771 {
3772 Value *value = rhs.loadValue();
3773 storeValue(value);
3774
3775 return RValue<Int>(value);
3776 }
3777
3778 RValue<Int> Int::operator=(const UInt &rhs) const
3779 {
3780 Value *value = rhs.loadValue();
3781 storeValue(value);
3782
3783 return RValue<Int>(value);
3784 }
3785
3786 RValue<Int> Int::operator=(const Reference<UInt> &rhs) const
3787 {
3788 Value *value = rhs.loadValue();
3789 storeValue(value);
3790
3791 return RValue<Int>(value);
3792 }
3793
3794 RValue<Int> operator+(RValue<Int> lhs, RValue<Int> rhs)
3795 {
3796 return RValue<Int>(Nucleus::createAdd(lhs.value, rhs.value));
3797 }
3798
3799 RValue<Int> operator-(RValue<Int> lhs, RValue<Int> rhs)
3800 {
3801 return RValue<Int>(Nucleus::createSub(lhs.value, rhs.value));
3802 }
3803
3804 RValue<Int> operator*(RValue<Int> lhs, RValue<Int> rhs)
3805 {
3806 return RValue<Int>(Nucleus::createMul(lhs.value, rhs.value));
3807 }
3808
3809 RValue<Int> operator/(RValue<Int> lhs, RValue<Int> rhs)
3810 {
3811 return RValue<Int>(Nucleus::createSDiv(lhs.value, rhs.value));
3812 }
3813
3814 RValue<Int> operator%(RValue<Int> lhs, RValue<Int> rhs)
3815 {
3816 return RValue<Int>(Nucleus::createSRem(lhs.value, rhs.value));
3817 }
3818
3819 RValue<Int> operator&(RValue<Int> lhs, RValue<Int> rhs)
3820 {
3821 return RValue<Int>(Nucleus::createAnd(lhs.value, rhs.value));
3822 }
3823
3824 RValue<Int> operator|(RValue<Int> lhs, RValue<Int> rhs)
3825 {
3826 return RValue<Int>(Nucleus::createOr(lhs.value, rhs.value));
3827 }
3828
3829 RValue<Int> operator^(RValue<Int> lhs, RValue<Int> rhs)
3830 {
3831 return RValue<Int>(Nucleus::createXor(lhs.value, rhs.value));
3832 }
3833
3834 RValue<Int> operator<<(RValue<Int> lhs, RValue<Int> rhs)
3835 {
3836 return RValue<Int>(Nucleus::createShl(lhs.value, rhs.value));
3837 }
3838
3839 RValue<Int> operator>>(RValue<Int> lhs, RValue<Int> rhs)
3840 {
3841 return RValue<Int>(Nucleus::createAShr(lhs.value, rhs.value));
3842 }
3843
3844 RValue<Int> operator+=(const Int &lhs, RValue<Int> rhs)
3845 {
3846 return lhs = lhs + rhs;
3847 }
3848
3849 RValue<Int> operator-=(const Int &lhs, RValue<Int> rhs)
3850 {
3851 return lhs = lhs - rhs;
3852 }
3853
3854 RValue<Int> operator*=(const Int &lhs, RValue<Int> rhs)
3855 {
3856 return lhs = lhs * rhs;
3857 }
3858
3859 RValue<Int> operator/=(const Int &lhs, RValue<Int> rhs)
3860 {
3861 return lhs = lhs / rhs;
3862 }
3863
3864 RValue<Int> operator%=(const Int &lhs, RValue<Int> rhs)
3865 {
3866 return lhs = lhs % rhs;
3867 }
3868
3869 RValue<Int> operator&=(const Int &lhs, RValue<Int> rhs)
3870 {
3871 return lhs = lhs & rhs;
3872 }
3873
3874 RValue<Int> operator|=(const Int &lhs, RValue<Int> rhs)
3875 {
3876 return lhs = lhs | rhs;
3877 }
3878
3879 RValue<Int> operator^=(const Int &lhs, RValue<Int> rhs)
3880 {
3881 return lhs = lhs ^ rhs;
3882 }
3883
3884 RValue<Int> operator<<=(const Int &lhs, RValue<Int> rhs)
3885 {
3886 return lhs = lhs << rhs;
3887 }
3888
3889 RValue<Int> operator>>=(const Int &lhs, RValue<Int> rhs)
3890 {
3891 return lhs = lhs >> rhs;
3892 }
3893
3894 RValue<Int> operator+(RValue<Int> val)
3895 {
3896 return val;
3897 }
3898
3899 RValue<Int> operator-(RValue<Int> val)
3900 {
3901 return RValue<Int>(Nucleus::createNeg(val.value));
3902 }
3903
3904 RValue<Int> operator~(RValue<Int> val)
3905 {
3906 return RValue<Int>(Nucleus::createNot(val.value));
3907 }
3908
3909 RValue<Int> operator++(const Int &val, int) // Post-increment
3910 {
Nicolas Capens611642a2016-09-28 16:45:04 -04003911 auto oldValue = val.loadValue();
3912 auto newValue = ::function->makeVariable(Ice::IceType_i32);
3913 auto inc = Ice::InstArithmetic::create(::function, Ice::InstArithmetic::Add, newValue, oldValue, ::context->getConstantInt32(1));
3914 ::basicBlock->appendInst(inc);
3915 val.storeValue(V(newValue));
3916
3917 return RValue<Int>(oldValue);
Nicolas Capens598f8d82016-09-26 15:09:10 -04003918 }
3919
3920 const Int &operator++(const Int &val) // Pre-increment
3921 {
3922 assert(false && "UNIMPLEMENTED"); return val;
3923 }
3924
3925 RValue<Int> operator--(const Int &val, int) // Post-decrement
3926 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003927 assert(false && "UNIMPLEMENTED"); return RValue<Int>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003928 }
3929
3930 const Int &operator--(const Int &val) // Pre-decrement
3931 {
3932 assert(false && "UNIMPLEMENTED"); return val;
3933 }
3934
3935 RValue<Bool> operator<(RValue<Int> lhs, RValue<Int> rhs)
3936 {
3937 return RValue<Bool>(Nucleus::createICmpSLT(lhs.value, rhs.value));
3938 }
3939
3940 RValue<Bool> operator<=(RValue<Int> lhs, RValue<Int> rhs)
3941 {
3942 return RValue<Bool>(Nucleus::createICmpSLE(lhs.value, rhs.value));
3943 }
3944
3945 RValue<Bool> operator>(RValue<Int> lhs, RValue<Int> rhs)
3946 {
3947 return RValue<Bool>(Nucleus::createICmpSGT(lhs.value, rhs.value));
3948 }
3949
3950 RValue<Bool> operator>=(RValue<Int> lhs, RValue<Int> rhs)
3951 {
3952 return RValue<Bool>(Nucleus::createICmpSGE(lhs.value, rhs.value));
3953 }
3954
3955 RValue<Bool> operator!=(RValue<Int> lhs, RValue<Int> rhs)
3956 {
3957 return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value));
3958 }
3959
3960 RValue<Bool> operator==(RValue<Int> lhs, RValue<Int> rhs)
3961 {
3962 return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value));
3963 }
3964
3965 RValue<Int> Max(RValue<Int> x, RValue<Int> y)
3966 {
3967 return IfThenElse(x > y, x, y);
3968 }
3969
3970 RValue<Int> Min(RValue<Int> x, RValue<Int> y)
3971 {
3972 return IfThenElse(x < y, x, y);
3973 }
3974
3975 RValue<Int> Clamp(RValue<Int> x, RValue<Int> min, RValue<Int> max)
3976 {
3977 return Min(Max(x, min), max);
3978 }
3979
3980 RValue<Int> RoundInt(RValue<Float> cast)
3981 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04003982 assert(false && "UNIMPLEMENTED"); return RValue<Int>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04003983 }
3984
3985 Type *Int::getType()
3986 {
3987 return T(Ice::IceType_i32);
3988 }
3989
3990 Long::Long(RValue<Int> cast)
3991 {
3992 Value *integer = Nucleus::createSExt(cast.value, Long::getType());
3993
3994 storeValue(integer);
3995 }
3996
3997 Long::Long(RValue<UInt> cast)
3998 {
3999 Value *integer = Nucleus::createZExt(cast.value, Long::getType());
4000
4001 storeValue(integer);
4002 }
4003
4004 Long::Long()
4005 {
4006 }
4007
4008 Long::Long(RValue<Long> rhs)
4009 {
4010 storeValue(rhs.value);
4011 }
4012
4013 RValue<Long> Long::operator=(int64_t rhs) const
4014 {
Nicolas Capens13ac2322016-10-13 14:52:12 -04004015 return RValue<Long>(storeValue(Nucleus::createConstantLong(rhs)));
Nicolas Capens598f8d82016-09-26 15:09:10 -04004016 }
4017
4018 RValue<Long> Long::operator=(RValue<Long> rhs) const
4019 {
4020 storeValue(rhs.value);
4021
4022 return rhs;
4023 }
4024
4025 RValue<Long> Long::operator=(const Long &rhs) const
4026 {
4027 Value *value = rhs.loadValue();
4028 storeValue(value);
4029
4030 return RValue<Long>(value);
4031 }
4032
4033 RValue<Long> Long::operator=(const Reference<Long> &rhs) const
4034 {
4035 Value *value = rhs.loadValue();
4036 storeValue(value);
4037
4038 return RValue<Long>(value);
4039 }
4040
4041 RValue<Long> operator+(RValue<Long> lhs, RValue<Long> rhs)
4042 {
4043 return RValue<Long>(Nucleus::createAdd(lhs.value, rhs.value));
4044 }
4045
4046 RValue<Long> operator-(RValue<Long> lhs, RValue<Long> rhs)
4047 {
4048 return RValue<Long>(Nucleus::createSub(lhs.value, rhs.value));
4049 }
4050
4051 RValue<Long> operator+=(const Long &lhs, RValue<Long> rhs)
4052 {
4053 return lhs = lhs + rhs;
4054 }
4055
4056 RValue<Long> operator-=(const Long &lhs, RValue<Long> rhs)
4057 {
4058 return lhs = lhs - rhs;
4059 }
4060
4061 RValue<Long> AddAtomic(RValue<Pointer<Long> > x, RValue<Long> y)
4062 {
4063 return RValue<Long>(Nucleus::createAtomicAdd(x.value, y.value));
4064 }
4065
4066 Type *Long::getType()
4067 {
Nicolas Capens4cfd4572016-10-20 01:00:19 -04004068 return T(Ice::IceType_i64);
Nicolas Capens598f8d82016-09-26 15:09:10 -04004069 }
4070
4071 Long1::Long1(const RValue<UInt> cast)
4072 {
4073 assert(false && "UNIMPLEMENTED");
4074 }
4075
4076 Long1::Long1(RValue<Long1> rhs)
4077 {
4078 storeValue(rhs.value);
4079 }
4080
4081 Type *Long1::getType()
4082 {
4083 assert(false && "UNIMPLEMENTED"); return nullptr;
4084 }
4085
Nicolas Capens598f8d82016-09-26 15:09:10 -04004086 UInt::UInt(Argument<UInt> argument)
4087 {
4088 storeValue(argument.value);
4089 }
4090
4091 UInt::UInt(RValue<UShort> cast)
4092 {
4093 Value *integer = Nucleus::createZExt(cast.value, UInt::getType());
4094
4095 storeValue(integer);
4096 }
4097
4098 UInt::UInt(RValue<Long> cast)
4099 {
4100 Value *integer = Nucleus::createTrunc(cast.value, UInt::getType());
4101
4102 storeValue(integer);
4103 }
4104
4105 UInt::UInt(RValue<Float> cast)
4106 {
4107 assert(false && "UNIMPLEMENTED");
4108 }
4109
4110 UInt::UInt()
4111 {
4112 }
4113
4114 UInt::UInt(int x)
4115 {
4116 storeValue(Nucleus::createConstantInt(x));
4117 }
4118
4119 UInt::UInt(unsigned int x)
4120 {
4121 storeValue(Nucleus::createConstantInt(x));
4122 }
4123
4124 UInt::UInt(RValue<UInt> rhs)
4125 {
4126 storeValue(rhs.value);
4127 }
4128
4129 UInt::UInt(RValue<Int> rhs)
4130 {
4131 storeValue(rhs.value);
4132 }
4133
4134 UInt::UInt(const UInt &rhs)
4135 {
4136 Value *value = rhs.loadValue();
4137 storeValue(value);
4138 }
4139
4140 UInt::UInt(const Reference<UInt> &rhs)
4141 {
4142 Value *value = rhs.loadValue();
4143 storeValue(value);
4144 }
4145
4146 UInt::UInt(const Int &rhs)
4147 {
4148 Value *value = rhs.loadValue();
4149 storeValue(value);
4150 }
4151
4152 UInt::UInt(const Reference<Int> &rhs)
4153 {
4154 Value *value = rhs.loadValue();
4155 storeValue(value);
4156 }
4157
4158 RValue<UInt> UInt::operator=(unsigned int rhs) const
4159 {
4160 return RValue<UInt>(storeValue(Nucleus::createConstantInt(rhs)));
4161 }
4162
4163 RValue<UInt> UInt::operator=(RValue<UInt> rhs) const
4164 {
4165 storeValue(rhs.value);
4166
4167 return rhs;
4168 }
4169
4170 RValue<UInt> UInt::operator=(RValue<Int> rhs) const
4171 {
4172 storeValue(rhs.value);
4173
4174 return RValue<UInt>(rhs);
4175 }
4176
4177 RValue<UInt> UInt::operator=(const UInt &rhs) const
4178 {
4179 Value *value = rhs.loadValue();
4180 storeValue(value);
4181
4182 return RValue<UInt>(value);
4183 }
4184
4185 RValue<UInt> UInt::operator=(const Reference<UInt> &rhs) const
4186 {
4187 Value *value = rhs.loadValue();
4188 storeValue(value);
4189
4190 return RValue<UInt>(value);
4191 }
4192
4193 RValue<UInt> UInt::operator=(const Int &rhs) const
4194 {
4195 Value *value = rhs.loadValue();
4196 storeValue(value);
4197
4198 return RValue<UInt>(value);
4199 }
4200
4201 RValue<UInt> UInt::operator=(const Reference<Int> &rhs) const
4202 {
4203 Value *value = rhs.loadValue();
4204 storeValue(value);
4205
4206 return RValue<UInt>(value);
4207 }
4208
4209 RValue<UInt> operator+(RValue<UInt> lhs, RValue<UInt> rhs)
4210 {
4211 return RValue<UInt>(Nucleus::createAdd(lhs.value, rhs.value));
4212 }
4213
4214 RValue<UInt> operator-(RValue<UInt> lhs, RValue<UInt> rhs)
4215 {
4216 return RValue<UInt>(Nucleus::createSub(lhs.value, rhs.value));
4217 }
4218
4219 RValue<UInt> operator*(RValue<UInt> lhs, RValue<UInt> rhs)
4220 {
4221 return RValue<UInt>(Nucleus::createMul(lhs.value, rhs.value));
4222 }
4223
4224 RValue<UInt> operator/(RValue<UInt> lhs, RValue<UInt> rhs)
4225 {
4226 return RValue<UInt>(Nucleus::createUDiv(lhs.value, rhs.value));
4227 }
4228
4229 RValue<UInt> operator%(RValue<UInt> lhs, RValue<UInt> rhs)
4230 {
4231 return RValue<UInt>(Nucleus::createURem(lhs.value, rhs.value));
4232 }
4233
4234 RValue<UInt> operator&(RValue<UInt> lhs, RValue<UInt> rhs)
4235 {
4236 return RValue<UInt>(Nucleus::createAnd(lhs.value, rhs.value));
4237 }
4238
4239 RValue<UInt> operator|(RValue<UInt> lhs, RValue<UInt> rhs)
4240 {
4241 return RValue<UInt>(Nucleus::createOr(lhs.value, rhs.value));
4242 }
4243
4244 RValue<UInt> operator^(RValue<UInt> lhs, RValue<UInt> rhs)
4245 {
4246 return RValue<UInt>(Nucleus::createXor(lhs.value, rhs.value));
4247 }
4248
4249 RValue<UInt> operator<<(RValue<UInt> lhs, RValue<UInt> rhs)
4250 {
4251 return RValue<UInt>(Nucleus::createShl(lhs.value, rhs.value));
4252 }
4253
4254 RValue<UInt> operator>>(RValue<UInt> lhs, RValue<UInt> rhs)
4255 {
4256 return RValue<UInt>(Nucleus::createLShr(lhs.value, rhs.value));
4257 }
4258
4259 RValue<UInt> operator+=(const UInt &lhs, RValue<UInt> rhs)
4260 {
4261 return lhs = lhs + rhs;
4262 }
4263
4264 RValue<UInt> operator-=(const UInt &lhs, RValue<UInt> rhs)
4265 {
4266 return lhs = lhs - rhs;
4267 }
4268
4269 RValue<UInt> operator*=(const UInt &lhs, RValue<UInt> rhs)
4270 {
4271 return lhs = lhs * rhs;
4272 }
4273
4274 RValue<UInt> operator/=(const UInt &lhs, RValue<UInt> rhs)
4275 {
4276 return lhs = lhs / rhs;
4277 }
4278
4279 RValue<UInt> operator%=(const UInt &lhs, RValue<UInt> rhs)
4280 {
4281 return lhs = lhs % rhs;
4282 }
4283
4284 RValue<UInt> operator&=(const UInt &lhs, RValue<UInt> rhs)
4285 {
4286 return lhs = lhs & rhs;
4287 }
4288
4289 RValue<UInt> operator|=(const UInt &lhs, RValue<UInt> rhs)
4290 {
4291 return lhs = lhs | rhs;
4292 }
4293
4294 RValue<UInt> operator^=(const UInt &lhs, RValue<UInt> rhs)
4295 {
4296 return lhs = lhs ^ rhs;
4297 }
4298
4299 RValue<UInt> operator<<=(const UInt &lhs, RValue<UInt> rhs)
4300 {
4301 return lhs = lhs << rhs;
4302 }
4303
4304 RValue<UInt> operator>>=(const UInt &lhs, RValue<UInt> rhs)
4305 {
4306 return lhs = lhs >> rhs;
4307 }
4308
4309 RValue<UInt> operator+(RValue<UInt> val)
4310 {
4311 return val;
4312 }
4313
4314 RValue<UInt> operator-(RValue<UInt> val)
4315 {
4316 return RValue<UInt>(Nucleus::createNeg(val.value));
4317 }
4318
4319 RValue<UInt> operator~(RValue<UInt> val)
4320 {
4321 return RValue<UInt>(Nucleus::createNot(val.value));
4322 }
4323
4324 RValue<UInt> operator++(const UInt &val, int) // Post-increment
4325 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04004326 assert(false && "UNIMPLEMENTED"); return RValue<UInt>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04004327 }
4328
4329 const UInt &operator++(const UInt &val) // Pre-increment
4330 {
4331 assert(false && "UNIMPLEMENTED"); return val;
4332 }
4333
4334 RValue<UInt> operator--(const UInt &val, int) // Post-decrement
4335 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04004336 assert(false && "UNIMPLEMENTED"); return RValue<UInt>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04004337 }
4338
4339 const UInt &operator--(const UInt &val) // Pre-decrement
4340 {
4341 assert(false && "UNIMPLEMENTED"); return val;
4342 }
4343
4344 RValue<UInt> Max(RValue<UInt> x, RValue<UInt> y)
4345 {
4346 return IfThenElse(x > y, x, y);
4347 }
4348
4349 RValue<UInt> Min(RValue<UInt> x, RValue<UInt> y)
4350 {
4351 return IfThenElse(x < y, x, y);
4352 }
4353
4354 RValue<UInt> Clamp(RValue<UInt> x, RValue<UInt> min, RValue<UInt> max)
4355 {
4356 return Min(Max(x, min), max);
4357 }
4358
4359 RValue<Bool> operator<(RValue<UInt> lhs, RValue<UInt> rhs)
4360 {
4361 return RValue<Bool>(Nucleus::createICmpULT(lhs.value, rhs.value));
4362 }
4363
4364 RValue<Bool> operator<=(RValue<UInt> lhs, RValue<UInt> rhs)
4365 {
4366 return RValue<Bool>(Nucleus::createICmpULE(lhs.value, rhs.value));
4367 }
4368
4369 RValue<Bool> operator>(RValue<UInt> lhs, RValue<UInt> rhs)
4370 {
4371 return RValue<Bool>(Nucleus::createICmpUGT(lhs.value, rhs.value));
4372 }
4373
4374 RValue<Bool> operator>=(RValue<UInt> lhs, RValue<UInt> rhs)
4375 {
4376 return RValue<Bool>(Nucleus::createICmpUGE(lhs.value, rhs.value));
4377 }
4378
4379 RValue<Bool> operator!=(RValue<UInt> lhs, RValue<UInt> rhs)
4380 {
4381 return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value));
4382 }
4383
4384 RValue<Bool> operator==(RValue<UInt> lhs, RValue<UInt> rhs)
4385 {
4386 return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value));
4387 }
4388
4389// RValue<UInt> RoundUInt(RValue<Float> cast)
4390// {
Nicolas Capensc37252c2016-09-28 16:11:54 -04004391// assert(false && "UNIMPLEMENTED"); return RValue<UInt>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04004392// }
4393
4394 Type *UInt::getType()
4395 {
Nicolas Capens4cfd4572016-10-20 01:00:19 -04004396 return T(Ice::IceType_i32);
Nicolas Capens598f8d82016-09-26 15:09:10 -04004397 }
4398
4399// Int2::Int2(RValue<Int> cast)
4400// {
4401// Value *extend = Nucleus::createZExt(cast.value, Long::getType());
4402// Value *vector = Nucleus::createBitCast(extend, Int2::getType());
4403//
4404// Constant *shuffle[2];
4405// shuffle[0] = Nucleus::createConstantInt(0);
4406// shuffle[1] = Nucleus::createConstantInt(0);
4407//
4408// Value *replicate = Nucleus::createShuffleVector(vector, UndefValue::get(Int2::getType()), Nucleus::createConstantVector(shuffle, 2));
4409//
4410// storeValue(replicate);
4411// }
4412
4413 Int2::Int2(RValue<Int4> cast)
4414 {
Nicolas Capens22008782016-10-20 01:11:47 -04004415 storeValue(Nucleus::createBitCast(cast.value, getType()));
Nicolas Capens598f8d82016-09-26 15:09:10 -04004416 }
4417
4418 Int2::Int2()
4419 {
4420 // xy.parent = this;
4421 }
4422
4423 Int2::Int2(int x, int y)
4424 {
4425 // xy.parent = this;
4426
Nicolas Capens8dfd9a72016-10-13 17:44:51 -04004427 int64_t constantVector[2] = {x, y};
4428 storeValue(Nucleus::createConstantVector(constantVector, getType()));
Nicolas Capens598f8d82016-09-26 15:09:10 -04004429 }
4430
4431 Int2::Int2(RValue<Int2> rhs)
4432 {
4433 // xy.parent = this;
4434
4435 storeValue(rhs.value);
4436 }
4437
4438 Int2::Int2(const Int2 &rhs)
4439 {
4440 // xy.parent = this;
4441
4442 Value *value = rhs.loadValue();
4443 storeValue(value);
4444 }
4445
4446 Int2::Int2(const Reference<Int2> &rhs)
4447 {
4448 // xy.parent = this;
4449
4450 Value *value = rhs.loadValue();
4451 storeValue(value);
4452 }
4453
4454 Int2::Int2(RValue<Int> lo, RValue<Int> hi)
4455 {
4456 assert(false && "UNIMPLEMENTED");
4457 }
4458
4459 RValue<Int2> Int2::operator=(RValue<Int2> rhs) const
4460 {
4461 storeValue(rhs.value);
4462
4463 return rhs;
4464 }
4465
4466 RValue<Int2> Int2::operator=(const Int2 &rhs) const
4467 {
4468 Value *value = rhs.loadValue();
4469 storeValue(value);
4470
4471 return RValue<Int2>(value);
4472 }
4473
4474 RValue<Int2> Int2::operator=(const Reference<Int2> &rhs) const
4475 {
4476 Value *value = rhs.loadValue();
4477 storeValue(value);
4478
4479 return RValue<Int2>(value);
4480 }
4481
4482 RValue<Int2> operator+(RValue<Int2> lhs, RValue<Int2> rhs)
4483 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04004484 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04004485 }
4486
4487 RValue<Int2> operator-(RValue<Int2> lhs, RValue<Int2> rhs)
4488 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04004489 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04004490 }
4491
4492// RValue<Int2> operator*(RValue<Int2> lhs, RValue<Int2> rhs)
4493// {
4494// return RValue<Int2>(Nucleus::createMul(lhs.value, rhs.value));
4495// }
4496
4497// RValue<Int2> operator/(RValue<Int2> lhs, RValue<Int2> rhs)
4498// {
4499// return RValue<Int2>(Nucleus::createSDiv(lhs.value, rhs.value));
4500// }
4501
4502// RValue<Int2> operator%(RValue<Int2> lhs, RValue<Int2> rhs)
4503// {
4504// return RValue<Int2>(Nucleus::createSRem(lhs.value, rhs.value));
4505// }
4506
4507 RValue<Int2> operator&(RValue<Int2> lhs, RValue<Int2> rhs)
4508 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04004509 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04004510 }
4511
4512 RValue<Int2> operator|(RValue<Int2> lhs, RValue<Int2> rhs)
4513 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04004514 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04004515 }
4516
4517 RValue<Int2> operator^(RValue<Int2> lhs, RValue<Int2> rhs)
4518 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04004519 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04004520 }
4521
4522 RValue<Int2> operator<<(RValue<Int2> lhs, unsigned char rhs)
4523 {
Nicolas Capens327f1df2016-10-21 14:26:34 -04004524 return RValue<Int2>(Nucleus::createShl(lhs.value, C(::context->getConstantInt32(rhs))));
Nicolas Capens598f8d82016-09-26 15:09:10 -04004525 }
4526
4527 RValue<Int2> operator>>(RValue<Int2> lhs, unsigned char rhs)
4528 {
Nicolas Capens327f1df2016-10-21 14:26:34 -04004529 return RValue<Int2>(Nucleus::createAShr(lhs.value, C(::context->getConstantInt32(rhs))));
Nicolas Capens598f8d82016-09-26 15:09:10 -04004530 }
4531
4532 RValue<Int2> operator<<(RValue<Int2> lhs, RValue<Long1> rhs)
4533 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04004534 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04004535 }
4536
4537 RValue<Int2> operator>>(RValue<Int2> lhs, RValue<Long1> rhs)
4538 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04004539 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04004540 }
4541
4542 RValue<Int2> operator+=(const Int2 &lhs, RValue<Int2> rhs)
4543 {
4544 return lhs = lhs + rhs;
4545 }
4546
4547 RValue<Int2> operator-=(const Int2 &lhs, RValue<Int2> rhs)
4548 {
4549 return lhs = lhs - rhs;
4550 }
4551
4552// RValue<Int2> operator*=(const Int2 &lhs, RValue<Int2> rhs)
4553// {
4554// return lhs = lhs * rhs;
4555// }
4556
4557// RValue<Int2> operator/=(const Int2 &lhs, RValue<Int2> rhs)
4558// {
4559// return lhs = lhs / rhs;
4560// }
4561
4562// RValue<Int2> operator%=(const Int2 &lhs, RValue<Int2> rhs)
4563// {
4564// return lhs = lhs % rhs;
4565// }
4566
4567 RValue<Int2> operator&=(const Int2 &lhs, RValue<Int2> rhs)
4568 {
4569 return lhs = lhs & rhs;
4570 }
4571
4572 RValue<Int2> operator|=(const Int2 &lhs, RValue<Int2> rhs)
4573 {
4574 return lhs = lhs | rhs;
4575 }
4576
4577 RValue<Int2> operator^=(const Int2 &lhs, RValue<Int2> rhs)
4578 {
4579 return lhs = lhs ^ rhs;
4580 }
4581
4582 RValue<Int2> operator<<=(const Int2 &lhs, unsigned char rhs)
4583 {
4584 return lhs = lhs << rhs;
4585 }
4586
4587 RValue<Int2> operator>>=(const Int2 &lhs, unsigned char rhs)
4588 {
4589 return lhs = lhs >> rhs;
4590 }
4591
4592 RValue<Int2> operator<<=(const Int2 &lhs, RValue<Long1> rhs)
4593 {
4594 return lhs = lhs << rhs;
4595 }
4596
4597 RValue<Int2> operator>>=(const Int2 &lhs, RValue<Long1> rhs)
4598 {
4599 return lhs = lhs >> rhs;
4600 }
4601
4602// RValue<Int2> operator+(RValue<Int2> val)
4603// {
4604// return val;
4605// }
4606
4607// RValue<Int2> operator-(RValue<Int2> val)
4608// {
4609// return RValue<Int2>(Nucleus::createNeg(val.value));
4610// }
4611
4612 RValue<Int2> operator~(RValue<Int2> val)
4613 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04004614 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04004615 }
4616
4617 RValue<Long1> UnpackLow(RValue<Int2> x, RValue<Int2> y)
4618 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04004619 assert(false && "UNIMPLEMENTED"); return RValue<Long1>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04004620 }
4621
4622 RValue<Long1> UnpackHigh(RValue<Int2> x, RValue<Int2> y)
4623 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04004624 assert(false && "UNIMPLEMENTED"); return RValue<Long1>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04004625 }
4626
4627 RValue<Int> Extract(RValue<Int2> val, int i)
4628 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04004629 assert(false && "UNIMPLEMENTED"); return RValue<Int>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04004630 }
4631
4632 RValue<Int2> Insert(RValue<Int2> val, RValue<Int> element, int i)
4633 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04004634 assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04004635 }
4636
4637 Type *Int2::getType()
4638 {
Nicolas Capens8dfd9a72016-10-13 17:44:51 -04004639 return T(Type_v2i32);
Nicolas Capens598f8d82016-09-26 15:09:10 -04004640 }
4641
4642 UInt2::UInt2()
4643 {
4644 // xy.parent = this;
4645 }
4646
4647 UInt2::UInt2(unsigned int x, unsigned int y)
4648 {
4649 // xy.parent = this;
4650
Nicolas Capens8dfd9a72016-10-13 17:44:51 -04004651 int64_t constantVector[2] = {x, y};
4652 storeValue(Nucleus::createConstantVector(constantVector, getType()));
Nicolas Capens598f8d82016-09-26 15:09:10 -04004653 }
4654
4655 UInt2::UInt2(RValue<UInt2> rhs)
4656 {
4657 // xy.parent = this;
4658
4659 storeValue(rhs.value);
4660 }
4661
4662 UInt2::UInt2(const UInt2 &rhs)
4663 {
4664 // xy.parent = this;
4665
4666 Value *value = rhs.loadValue();
4667 storeValue(value);
4668 }
4669
4670 UInt2::UInt2(const Reference<UInt2> &rhs)
4671 {
4672 // xy.parent = this;
4673
4674 Value *value = rhs.loadValue();
4675 storeValue(value);
4676 }
4677
4678 RValue<UInt2> UInt2::operator=(RValue<UInt2> rhs) const
4679 {
4680 storeValue(rhs.value);
4681
4682 return rhs;
4683 }
4684
4685 RValue<UInt2> UInt2::operator=(const UInt2 &rhs) const
4686 {
4687 Value *value = rhs.loadValue();
4688 storeValue(value);
4689
4690 return RValue<UInt2>(value);
4691 }
4692
4693 RValue<UInt2> UInt2::operator=(const Reference<UInt2> &rhs) const
4694 {
4695 Value *value = rhs.loadValue();
4696 storeValue(value);
4697
4698 return RValue<UInt2>(value);
4699 }
4700
4701 RValue<UInt2> operator+(RValue<UInt2> lhs, RValue<UInt2> rhs)
4702 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04004703 assert(false && "UNIMPLEMENTED"); return RValue<UInt2>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04004704 }
4705
4706 RValue<UInt2> operator-(RValue<UInt2> lhs, RValue<UInt2> rhs)
4707 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04004708 assert(false && "UNIMPLEMENTED"); return RValue<UInt2>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04004709 }
4710
4711// RValue<UInt2> operator*(RValue<UInt2> lhs, RValue<UInt2> rhs)
4712// {
4713// return RValue<UInt2>(Nucleus::createMul(lhs.value, rhs.value));
4714// }
4715
4716// RValue<UInt2> operator/(RValue<UInt2> lhs, RValue<UInt2> rhs)
4717// {
4718// return RValue<UInt2>(Nucleus::createUDiv(lhs.value, rhs.value));
4719// }
4720
4721// RValue<UInt2> operator%(RValue<UInt2> lhs, RValue<UInt2> rhs)
4722// {
4723// return RValue<UInt2>(Nucleus::createURem(lhs.value, rhs.value));
4724// }
4725
4726 RValue<UInt2> operator&(RValue<UInt2> lhs, RValue<UInt2> rhs)
4727 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04004728 assert(false && "UNIMPLEMENTED"); return RValue<UInt2>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04004729 }
4730
4731 RValue<UInt2> operator|(RValue<UInt2> lhs, RValue<UInt2> rhs)
4732 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04004733 assert(false && "UNIMPLEMENTED"); return RValue<UInt2>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04004734 }
4735
4736 RValue<UInt2> operator^(RValue<UInt2> lhs, RValue<UInt2> rhs)
4737 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04004738 assert(false && "UNIMPLEMENTED"); return RValue<UInt2>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04004739 }
4740
4741 RValue<UInt2> operator<<(RValue<UInt2> lhs, unsigned char rhs)
4742 {
Nicolas Capens327f1df2016-10-21 14:26:34 -04004743 return RValue<UInt2>(Nucleus::createShl(lhs.value, C(::context->getConstantInt32(rhs))));
Nicolas Capens598f8d82016-09-26 15:09:10 -04004744 }
4745
4746 RValue<UInt2> operator>>(RValue<UInt2> lhs, unsigned char rhs)
4747 {
Nicolas Capens327f1df2016-10-21 14:26:34 -04004748 return RValue<UInt2>(Nucleus::createLShr(lhs.value, C(::context->getConstantInt32(rhs))));
Nicolas Capens598f8d82016-09-26 15:09:10 -04004749 }
4750
4751 RValue<UInt2> operator<<(RValue<UInt2> lhs, RValue<Long1> rhs)
4752 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04004753 assert(false && "UNIMPLEMENTED"); return RValue<UInt2>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04004754 }
4755
4756 RValue<UInt2> operator>>(RValue<UInt2> lhs, RValue<Long1> rhs)
4757 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04004758 assert(false && "UNIMPLEMENTED"); return RValue<UInt2>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04004759 }
4760
4761 RValue<UInt2> operator+=(const UInt2 &lhs, RValue<UInt2> rhs)
4762 {
4763 return lhs = lhs + rhs;
4764 }
4765
4766 RValue<UInt2> operator-=(const UInt2 &lhs, RValue<UInt2> rhs)
4767 {
4768 return lhs = lhs - rhs;
4769 }
4770
4771// RValue<UInt2> operator*=(const UInt2 &lhs, RValue<UInt2> rhs)
4772// {
4773// return lhs = lhs * rhs;
4774// }
4775
4776// RValue<UInt2> operator/=(const UInt2 &lhs, RValue<UInt2> rhs)
4777// {
4778// return lhs = lhs / rhs;
4779// }
4780
4781// RValue<UInt2> operator%=(const UInt2 &lhs, RValue<UInt2> rhs)
4782// {
4783// return lhs = lhs % rhs;
4784// }
4785
4786 RValue<UInt2> operator&=(const UInt2 &lhs, RValue<UInt2> rhs)
4787 {
4788 return lhs = lhs & rhs;
4789 }
4790
4791 RValue<UInt2> operator|=(const UInt2 &lhs, RValue<UInt2> rhs)
4792 {
4793 return lhs = lhs | rhs;
4794 }
4795
4796 RValue<UInt2> operator^=(const UInt2 &lhs, RValue<UInt2> rhs)
4797 {
4798 return lhs = lhs ^ rhs;
4799 }
4800
4801 RValue<UInt2> operator<<=(const UInt2 &lhs, unsigned char rhs)
4802 {
4803 return lhs = lhs << rhs;
4804 }
4805
4806 RValue<UInt2> operator>>=(const UInt2 &lhs, unsigned char rhs)
4807 {
4808 return lhs = lhs >> rhs;
4809 }
4810
4811 RValue<UInt2> operator<<=(const UInt2 &lhs, RValue<Long1> rhs)
4812 {
4813 return lhs = lhs << rhs;
4814 }
4815
4816 RValue<UInt2> operator>>=(const UInt2 &lhs, RValue<Long1> rhs)
4817 {
4818 return lhs = lhs >> rhs;
4819 }
4820
4821// RValue<UInt2> operator+(RValue<UInt2> val)
4822// {
4823// return val;
4824// }
4825
4826// RValue<UInt2> operator-(RValue<UInt2> val)
4827// {
4828// return RValue<UInt2>(Nucleus::createNeg(val.value));
4829// }
4830
4831 RValue<UInt2> operator~(RValue<UInt2> val)
4832 {
4833 return RValue<UInt2>(Nucleus::createNot(val.value));
4834 }
4835
4836 Type *UInt2::getType()
4837 {
Nicolas Capens4cfd4572016-10-20 01:00:19 -04004838 return T(Type_v2i32);
Nicolas Capens598f8d82016-09-26 15:09:10 -04004839 }
4840
4841 Int4::Int4(RValue<Byte4> cast)
4842 {
4843 assert(false && "UNIMPLEMENTED");
4844 }
4845
4846 Int4::Int4(RValue<SByte4> cast)
4847 {
4848 assert(false && "UNIMPLEMENTED");
4849 }
4850
4851 Int4::Int4(RValue<Float4> cast)
4852 {
4853 // xyzw.parent = this;
4854
4855 Value *xyzw = Nucleus::createFPToSI(cast.value, Int4::getType());
4856
4857 storeValue(xyzw);
4858 }
4859
4860 Int4::Int4(RValue<Short4> cast)
4861 {
4862 assert(false && "UNIMPLEMENTED");
4863 }
4864
4865 Int4::Int4(RValue<UShort4> cast)
4866 {
4867 assert(false && "UNIMPLEMENTED");
4868 }
4869
4870 Int4::Int4()
4871 {
4872 // xyzw.parent = this;
4873 }
4874
4875 Int4::Int4(int xyzw)
4876 {
4877 constant(xyzw, xyzw, xyzw, xyzw);
4878 }
4879
4880 Int4::Int4(int x, int yzw)
4881 {
4882 constant(x, yzw, yzw, yzw);
4883 }
4884
4885 Int4::Int4(int x, int y, int zw)
4886 {
4887 constant(x, y, zw, zw);
4888 }
4889
4890 Int4::Int4(int x, int y, int z, int w)
4891 {
4892 constant(x, y, z, w);
4893 }
4894
4895 void Int4::constant(int x, int y, int z, int w)
4896 {
4897 // xyzw.parent = this;
4898
Nicolas Capens13ac2322016-10-13 14:52:12 -04004899 int64_t constantVector[4] = {x, y, z, w};
Nicolas Capens8dfd9a72016-10-13 17:44:51 -04004900 storeValue(Nucleus::createConstantVector(constantVector, getType()));
Nicolas Capens598f8d82016-09-26 15:09:10 -04004901 }
4902
4903 Int4::Int4(RValue<Int4> rhs)
4904 {
4905 // xyzw.parent = this;
4906
4907 storeValue(rhs.value);
4908 }
4909
4910 Int4::Int4(const Int4 &rhs)
4911 {
4912 // xyzw.parent = this;
4913
4914 Value *value = rhs.loadValue();
4915 storeValue(value);
4916 }
4917
4918 Int4::Int4(const Reference<Int4> &rhs)
4919 {
4920 // xyzw.parent = this;
4921
4922 Value *value = rhs.loadValue();
4923 storeValue(value);
4924 }
4925
4926 Int4::Int4(RValue<UInt4> rhs)
4927 {
4928 // xyzw.parent = this;
4929
4930 storeValue(rhs.value);
4931 }
4932
4933 Int4::Int4(const UInt4 &rhs)
4934 {
4935 // xyzw.parent = this;
4936
4937 Value *value = rhs.loadValue();
4938 storeValue(value);
4939 }
4940
4941 Int4::Int4(const Reference<UInt4> &rhs)
4942 {
4943 // xyzw.parent = this;
4944
4945 Value *value = rhs.loadValue();
4946 storeValue(value);
4947 }
4948
4949 Int4::Int4(RValue<Int2> lo, RValue<Int2> hi)
4950 {
4951 assert(false && "UNIMPLEMENTED");
4952 }
4953
4954 Int4::Int4(RValue<Int> rhs)
4955 {
4956 // xyzw.parent = this;
4957
4958 assert(false && "UNIMPLEMENTED");
4959 }
4960
4961 Int4::Int4(const Int &rhs)
4962 {
4963 // xyzw.parent = this;
4964
4965 *this = RValue<Int>(rhs.loadValue());
4966 }
4967
4968 Int4::Int4(const Reference<Int> &rhs)
4969 {
4970 // xyzw.parent = this;
4971
4972 *this = RValue<Int>(rhs.loadValue());
4973 }
4974
4975 RValue<Int4> Int4::operator=(RValue<Int4> rhs) const
4976 {
4977 storeValue(rhs.value);
4978
4979 return rhs;
4980 }
4981
4982 RValue<Int4> Int4::operator=(const Int4 &rhs) const
4983 {
4984 Value *value = rhs.loadValue();
4985 storeValue(value);
4986
4987 return RValue<Int4>(value);
4988 }
4989
4990 RValue<Int4> Int4::operator=(const Reference<Int4> &rhs) const
4991 {
4992 Value *value = rhs.loadValue();
4993 storeValue(value);
4994
4995 return RValue<Int4>(value);
4996 }
4997
4998 RValue<Int4> operator+(RValue<Int4> lhs, RValue<Int4> rhs)
4999 {
5000 return RValue<Int4>(Nucleus::createAdd(lhs.value, rhs.value));
5001 }
5002
5003 RValue<Int4> operator-(RValue<Int4> lhs, RValue<Int4> rhs)
5004 {
5005 return RValue<Int4>(Nucleus::createSub(lhs.value, rhs.value));
5006 }
5007
5008 RValue<Int4> operator*(RValue<Int4> lhs, RValue<Int4> rhs)
5009 {
5010 return RValue<Int4>(Nucleus::createMul(lhs.value, rhs.value));
5011 }
5012
5013 RValue<Int4> operator/(RValue<Int4> lhs, RValue<Int4> rhs)
5014 {
5015 return RValue<Int4>(Nucleus::createSDiv(lhs.value, rhs.value));
5016 }
5017
5018 RValue<Int4> operator%(RValue<Int4> lhs, RValue<Int4> rhs)
5019 {
5020 return RValue<Int4>(Nucleus::createSRem(lhs.value, rhs.value));
5021 }
5022
5023 RValue<Int4> operator&(RValue<Int4> lhs, RValue<Int4> rhs)
5024 {
5025 return RValue<Int4>(Nucleus::createAnd(lhs.value, rhs.value));
5026 }
5027
5028 RValue<Int4> operator|(RValue<Int4> lhs, RValue<Int4> rhs)
5029 {
5030 return RValue<Int4>(Nucleus::createOr(lhs.value, rhs.value));
5031 }
5032
5033 RValue<Int4> operator^(RValue<Int4> lhs, RValue<Int4> rhs)
5034 {
5035 return RValue<Int4>(Nucleus::createXor(lhs.value, rhs.value));
5036 }
5037
5038 RValue<Int4> operator<<(RValue<Int4> lhs, unsigned char rhs)
5039 {
Nicolas Capens327f1df2016-10-21 14:26:34 -04005040 return RValue<Int4>(Nucleus::createShl(lhs.value, C(::context->getConstantInt32(rhs))));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005041 }
5042
5043 RValue<Int4> operator>>(RValue<Int4> lhs, unsigned char rhs)
5044 {
Nicolas Capens327f1df2016-10-21 14:26:34 -04005045 return RValue<Int4>(Nucleus::createAShr(lhs.value, C(::context->getConstantInt32(rhs))));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005046 }
5047
5048 RValue<Int4> operator<<(RValue<Int4> lhs, RValue<Int4> rhs)
5049 {
5050 return RValue<Int4>(Nucleus::createShl(lhs.value, rhs.value));
5051 }
5052
5053 RValue<Int4> operator>>(RValue<Int4> lhs, RValue<Int4> rhs)
5054 {
5055 return RValue<Int4>(Nucleus::createAShr(lhs.value, rhs.value));
5056 }
5057
5058 RValue<Int4> operator+=(const Int4 &lhs, RValue<Int4> rhs)
5059 {
5060 return lhs = lhs + rhs;
5061 }
5062
5063 RValue<Int4> operator-=(const Int4 &lhs, RValue<Int4> rhs)
5064 {
5065 return lhs = lhs - rhs;
5066 }
5067
5068 RValue<Int4> operator*=(const Int4 &lhs, RValue<Int4> rhs)
5069 {
5070 return lhs = lhs * rhs;
5071 }
5072
5073// RValue<Int4> operator/=(const Int4 &lhs, RValue<Int4> rhs)
5074// {
5075// return lhs = lhs / rhs;
5076// }
5077
5078// RValue<Int4> operator%=(const Int4 &lhs, RValue<Int4> rhs)
5079// {
5080// return lhs = lhs % rhs;
5081// }
5082
5083 RValue<Int4> operator&=(const Int4 &lhs, RValue<Int4> rhs)
5084 {
5085 return lhs = lhs & rhs;
5086 }
5087
5088 RValue<Int4> operator|=(const Int4 &lhs, RValue<Int4> rhs)
5089 {
5090 return lhs = lhs | rhs;
5091 }
5092
5093 RValue<Int4> operator^=(const Int4 &lhs, RValue<Int4> rhs)
5094 {
5095 return lhs = lhs ^ rhs;
5096 }
5097
5098 RValue<Int4> operator<<=(const Int4 &lhs, unsigned char rhs)
5099 {
5100 return lhs = lhs << rhs;
5101 }
5102
5103 RValue<Int4> operator>>=(const Int4 &lhs, unsigned char rhs)
5104 {
5105 return lhs = lhs >> rhs;
5106 }
5107
5108 RValue<Int4> operator+(RValue<Int4> val)
5109 {
5110 return val;
5111 }
5112
5113 RValue<Int4> operator-(RValue<Int4> val)
5114 {
5115 return RValue<Int4>(Nucleus::createNeg(val.value));
5116 }
5117
5118 RValue<Int4> operator~(RValue<Int4> val)
5119 {
5120 return RValue<Int4>(Nucleus::createNot(val.value));
5121 }
5122
5123 RValue<Int4> CmpEQ(RValue<Int4> x, RValue<Int4> y)
5124 {
5125 return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpEQ(x.value, y.value), Int4::getType()));
5126 }
5127
5128 RValue<Int4> CmpLT(RValue<Int4> x, RValue<Int4> y)
5129 {
5130 return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSLT(x.value, y.value), Int4::getType()));
5131 }
5132
5133 RValue<Int4> CmpLE(RValue<Int4> x, RValue<Int4> y)
5134 {
5135 return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSLE(x.value, y.value), Int4::getType()));
5136 }
5137
5138 RValue<Int4> CmpNEQ(RValue<Int4> x, RValue<Int4> y)
5139 {
5140 return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpNE(x.value, y.value), Int4::getType()));
5141 }
5142
5143 RValue<Int4> CmpNLT(RValue<Int4> x, RValue<Int4> y)
5144 {
5145 return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSGE(x.value, y.value), Int4::getType()));
5146 }
5147
5148 RValue<Int4> CmpNLE(RValue<Int4> x, RValue<Int4> y)
5149 {
5150 return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSGT(x.value, y.value), Int4::getType()));
5151 }
5152
5153 RValue<Int4> Max(RValue<Int4> x, RValue<Int4> y)
5154 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04005155 assert(false && "UNIMPLEMENTED"); return RValue<Int4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005156 }
5157
5158 RValue<Int4> Min(RValue<Int4> x, RValue<Int4> y)
5159 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04005160 assert(false && "UNIMPLEMENTED"); return RValue<Int4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005161 }
5162
5163 RValue<Int4> RoundInt(RValue<Float4> cast)
5164 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04005165 assert(false && "UNIMPLEMENTED"); return RValue<Int4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005166 }
5167
5168 RValue<Short8> Pack(RValue<Int4> x, RValue<Int4> y)
5169 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04005170 assert(false && "UNIMPLEMENTED"); return RValue<Short8>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005171 }
5172
5173 RValue<Int> Extract(RValue<Int4> x, int i)
5174 {
Nicolas Capense95d5342016-09-30 11:37:28 -04005175 return RValue<Int>(Nucleus::createExtractElement(x.value, Int::getType(), i));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005176 }
5177
5178 RValue<Int4> Insert(RValue<Int4> x, RValue<Int> element, int i)
5179 {
5180 return RValue<Int4>(Nucleus::createInsertElement(x.value, element.value, i));
5181 }
5182
5183 RValue<Int> SignMask(RValue<Int4> x)
5184 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04005185 assert(false && "UNIMPLEMENTED"); return RValue<Int>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005186 }
5187
5188 RValue<Int4> Swizzle(RValue<Int4> x, unsigned char select)
5189 {
Nicolas Capense95d5342016-09-30 11:37:28 -04005190 return RValue<Int4>(createSwizzle4(x.value, select));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005191 }
5192
5193 Type *Int4::getType()
5194 {
Nicolas Capens23d99a42016-09-30 14:57:16 -04005195 return T(Ice::IceType_v4i32);
Nicolas Capens598f8d82016-09-26 15:09:10 -04005196 }
5197
5198 UInt4::UInt4(RValue<Float4> cast)
5199 {
5200 // xyzw.parent = this;
5201
5202 assert(false && "UNIMPLEMENTED");
5203 }
5204
5205 UInt4::UInt4()
5206 {
5207 // xyzw.parent = this;
5208 }
5209
5210 UInt4::UInt4(int xyzw)
5211 {
5212 constant(xyzw, xyzw, xyzw, xyzw);
5213 }
5214
5215 UInt4::UInt4(int x, int yzw)
5216 {
5217 constant(x, yzw, yzw, yzw);
5218 }
5219
5220 UInt4::UInt4(int x, int y, int zw)
5221 {
5222 constant(x, y, zw, zw);
5223 }
5224
5225 UInt4::UInt4(int x, int y, int z, int w)
5226 {
5227 constant(x, y, z, w);
5228 }
5229
5230 void UInt4::constant(int x, int y, int z, int w)
5231 {
5232 // xyzw.parent = this;
5233
Nicolas Capens13ac2322016-10-13 14:52:12 -04005234 int64_t constantVector[4] = {x, y, z, w};
Nicolas Capens8dfd9a72016-10-13 17:44:51 -04005235 storeValue(Nucleus::createConstantVector(constantVector, getType()));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005236 }
5237
5238 UInt4::UInt4(RValue<UInt4> rhs)
5239 {
5240 // xyzw.parent = this;
5241
5242 storeValue(rhs.value);
5243 }
5244
5245 UInt4::UInt4(const UInt4 &rhs)
5246 {
5247 // xyzw.parent = this;
5248
5249 Value *value = rhs.loadValue();
5250 storeValue(value);
5251 }
5252
5253 UInt4::UInt4(const Reference<UInt4> &rhs)
5254 {
5255 // xyzw.parent = this;
5256
5257 Value *value = rhs.loadValue();
5258 storeValue(value);
5259 }
5260
5261 UInt4::UInt4(RValue<Int4> rhs)
5262 {
5263 // xyzw.parent = this;
5264
5265 storeValue(rhs.value);
5266 }
5267
5268 UInt4::UInt4(const Int4 &rhs)
5269 {
5270 // xyzw.parent = this;
5271
5272 Value *value = rhs.loadValue();
5273 storeValue(value);
5274 }
5275
5276 UInt4::UInt4(const Reference<Int4> &rhs)
5277 {
5278 // xyzw.parent = this;
5279
5280 Value *value = rhs.loadValue();
5281 storeValue(value);
5282 }
5283
5284 UInt4::UInt4(RValue<UInt2> lo, RValue<UInt2> hi)
5285 {
5286 assert(false && "UNIMPLEMENTED");
5287 }
5288
5289 RValue<UInt4> UInt4::operator=(RValue<UInt4> rhs) const
5290 {
5291 storeValue(rhs.value);
5292
5293 return rhs;
5294 }
5295
5296 RValue<UInt4> UInt4::operator=(const UInt4 &rhs) const
5297 {
5298 Value *value = rhs.loadValue();
5299 storeValue(value);
5300
5301 return RValue<UInt4>(value);
5302 }
5303
5304 RValue<UInt4> UInt4::operator=(const Reference<UInt4> &rhs) const
5305 {
5306 Value *value = rhs.loadValue();
5307 storeValue(value);
5308
5309 return RValue<UInt4>(value);
5310 }
5311
5312 RValue<UInt4> operator+(RValue<UInt4> lhs, RValue<UInt4> rhs)
5313 {
5314 return RValue<UInt4>(Nucleus::createAdd(lhs.value, rhs.value));
5315 }
5316
5317 RValue<UInt4> operator-(RValue<UInt4> lhs, RValue<UInt4> rhs)
5318 {
5319 return RValue<UInt4>(Nucleus::createSub(lhs.value, rhs.value));
5320 }
5321
5322 RValue<UInt4> operator*(RValue<UInt4> lhs, RValue<UInt4> rhs)
5323 {
5324 return RValue<UInt4>(Nucleus::createMul(lhs.value, rhs.value));
5325 }
5326
5327 RValue<UInt4> operator/(RValue<UInt4> lhs, RValue<UInt4> rhs)
5328 {
5329 return RValue<UInt4>(Nucleus::createUDiv(lhs.value, rhs.value));
5330 }
5331
5332 RValue<UInt4> operator%(RValue<UInt4> lhs, RValue<UInt4> rhs)
5333 {
5334 return RValue<UInt4>(Nucleus::createURem(lhs.value, rhs.value));
5335 }
5336
5337 RValue<UInt4> operator&(RValue<UInt4> lhs, RValue<UInt4> rhs)
5338 {
5339 return RValue<UInt4>(Nucleus::createAnd(lhs.value, rhs.value));
5340 }
5341
5342 RValue<UInt4> operator|(RValue<UInt4> lhs, RValue<UInt4> rhs)
5343 {
5344 return RValue<UInt4>(Nucleus::createOr(lhs.value, rhs.value));
5345 }
5346
5347 RValue<UInt4> operator^(RValue<UInt4> lhs, RValue<UInt4> rhs)
5348 {
5349 return RValue<UInt4>(Nucleus::createXor(lhs.value, rhs.value));
5350 }
5351
5352 RValue<UInt4> operator<<(RValue<UInt4> lhs, unsigned char rhs)
5353 {
Nicolas Capens327f1df2016-10-21 14:26:34 -04005354 return RValue<UInt4>(Nucleus::createShl(lhs.value, C(::context->getConstantInt32(rhs))));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005355 }
5356
5357 RValue<UInt4> operator>>(RValue<UInt4> lhs, unsigned char rhs)
5358 {
Nicolas Capens327f1df2016-10-21 14:26:34 -04005359 return RValue<UInt4>(Nucleus::createLShr(lhs.value, C(::context->getConstantInt32(rhs))));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005360 }
5361
5362 RValue<UInt4> operator<<(RValue<UInt4> lhs, RValue<UInt4> rhs)
5363 {
5364 return RValue<UInt4>(Nucleus::createShl(lhs.value, rhs.value));
5365 }
5366
5367 RValue<UInt4> operator>>(RValue<UInt4> lhs, RValue<UInt4> rhs)
5368 {
5369 return RValue<UInt4>(Nucleus::createLShr(lhs.value, rhs.value));
5370 }
5371
5372 RValue<UInt4> operator+=(const UInt4 &lhs, RValue<UInt4> rhs)
5373 {
5374 return lhs = lhs + rhs;
5375 }
5376
5377 RValue<UInt4> operator-=(const UInt4 &lhs, RValue<UInt4> rhs)
5378 {
5379 return lhs = lhs - rhs;
5380 }
5381
5382 RValue<UInt4> operator*=(const UInt4 &lhs, RValue<UInt4> rhs)
5383 {
5384 return lhs = lhs * rhs;
5385 }
5386
5387// RValue<UInt4> operator/=(const UInt4 &lhs, RValue<UInt4> rhs)
5388// {
5389// return lhs = lhs / rhs;
5390// }
5391
5392// RValue<UInt4> operator%=(const UInt4 &lhs, RValue<UInt4> rhs)
5393// {
5394// return lhs = lhs % rhs;
5395// }
5396
5397 RValue<UInt4> operator&=(const UInt4 &lhs, RValue<UInt4> rhs)
5398 {
5399 return lhs = lhs & rhs;
5400 }
5401
5402 RValue<UInt4> operator|=(const UInt4 &lhs, RValue<UInt4> rhs)
5403 {
5404 return lhs = lhs | rhs;
5405 }
5406
5407 RValue<UInt4> operator^=(const UInt4 &lhs, RValue<UInt4> rhs)
5408 {
5409 return lhs = lhs ^ rhs;
5410 }
5411
5412 RValue<UInt4> operator<<=(const UInt4 &lhs, unsigned char rhs)
5413 {
5414 return lhs = lhs << rhs;
5415 }
5416
5417 RValue<UInt4> operator>>=(const UInt4 &lhs, unsigned char rhs)
5418 {
5419 return lhs = lhs >> rhs;
5420 }
5421
5422 RValue<UInt4> operator+(RValue<UInt4> val)
5423 {
5424 return val;
5425 }
5426
5427 RValue<UInt4> operator-(RValue<UInt4> val)
5428 {
5429 return RValue<UInt4>(Nucleus::createNeg(val.value));
5430 }
5431
5432 RValue<UInt4> operator~(RValue<UInt4> val)
5433 {
5434 return RValue<UInt4>(Nucleus::createNot(val.value));
5435 }
5436
5437 RValue<UInt4> CmpEQ(RValue<UInt4> x, RValue<UInt4> y)
5438 {
5439 return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpEQ(x.value, y.value), Int4::getType()));
5440 }
5441
5442 RValue<UInt4> CmpLT(RValue<UInt4> x, RValue<UInt4> y)
5443 {
5444 return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpULT(x.value, y.value), Int4::getType()));
5445 }
5446
5447 RValue<UInt4> CmpLE(RValue<UInt4> x, RValue<UInt4> y)
5448 {
5449 return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpULE(x.value, y.value), Int4::getType()));
5450 }
5451
5452 RValue<UInt4> CmpNEQ(RValue<UInt4> x, RValue<UInt4> y)
5453 {
5454 return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpNE(x.value, y.value), Int4::getType()));
5455 }
5456
5457 RValue<UInt4> CmpNLT(RValue<UInt4> x, RValue<UInt4> y)
5458 {
5459 return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpUGE(x.value, y.value), Int4::getType()));
5460 }
5461
5462 RValue<UInt4> CmpNLE(RValue<UInt4> x, RValue<UInt4> y)
5463 {
5464 return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpUGT(x.value, y.value), Int4::getType()));
5465 }
5466
5467 RValue<UInt4> Max(RValue<UInt4> x, RValue<UInt4> y)
5468 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04005469 assert(false && "UNIMPLEMENTED"); return RValue<UInt4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005470 }
5471
5472 RValue<UInt4> Min(RValue<UInt4> x, RValue<UInt4> y)
5473 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04005474 assert(false && "UNIMPLEMENTED"); return RValue<UInt4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005475 }
5476
5477 RValue<UShort8> Pack(RValue<UInt4> x, RValue<UInt4> y)
5478 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04005479 assert(false && "UNIMPLEMENTED"); return RValue<UShort8>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005480 }
5481
5482 Type *UInt4::getType()
5483 {
Nicolas Capens4cfd4572016-10-20 01:00:19 -04005484 return T(Ice::IceType_v4i32);
Nicolas Capens598f8d82016-09-26 15:09:10 -04005485 }
5486
5487 Float::Float(RValue<Int> cast)
5488 {
5489 Value *integer = Nucleus::createSIToFP(cast.value, Float::getType());
5490
5491 storeValue(integer);
5492 }
5493
5494 Float::Float()
5495 {
5496 }
5497
5498 Float::Float(float x)
5499 {
5500 storeValue(Nucleus::createConstantFloat(x));
5501 }
5502
5503 Float::Float(RValue<Float> rhs)
5504 {
5505 storeValue(rhs.value);
5506 }
5507
5508 Float::Float(const Float &rhs)
5509 {
5510 Value *value = rhs.loadValue();
5511 storeValue(value);
5512 }
5513
5514 Float::Float(const Reference<Float> &rhs)
5515 {
5516 Value *value = rhs.loadValue();
5517 storeValue(value);
5518 }
5519
5520 RValue<Float> Float::operator=(RValue<Float> rhs) const
5521 {
5522 storeValue(rhs.value);
5523
5524 return rhs;
5525 }
5526
5527 RValue<Float> Float::operator=(const Float &rhs) const
5528 {
5529 Value *value = rhs.loadValue();
5530 storeValue(value);
5531
5532 return RValue<Float>(value);
5533 }
5534
5535 RValue<Float> Float::operator=(const Reference<Float> &rhs) const
5536 {
5537 Value *value = rhs.loadValue();
5538 storeValue(value);
5539
5540 return RValue<Float>(value);
5541 }
5542
5543 RValue<Float> operator+(RValue<Float> lhs, RValue<Float> rhs)
5544 {
5545 return RValue<Float>(Nucleus::createFAdd(lhs.value, rhs.value));
5546 }
5547
5548 RValue<Float> operator-(RValue<Float> lhs, RValue<Float> rhs)
5549 {
5550 return RValue<Float>(Nucleus::createFSub(lhs.value, rhs.value));
5551 }
5552
5553 RValue<Float> operator*(RValue<Float> lhs, RValue<Float> rhs)
5554 {
5555 return RValue<Float>(Nucleus::createFMul(lhs.value, rhs.value));
5556 }
5557
5558 RValue<Float> operator/(RValue<Float> lhs, RValue<Float> rhs)
5559 {
5560 return RValue<Float>(Nucleus::createFDiv(lhs.value, rhs.value));
5561 }
5562
5563 RValue<Float> operator+=(const Float &lhs, RValue<Float> rhs)
5564 {
5565 return lhs = lhs + rhs;
5566 }
5567
5568 RValue<Float> operator-=(const Float &lhs, RValue<Float> rhs)
5569 {
5570 return lhs = lhs - rhs;
5571 }
5572
5573 RValue<Float> operator*=(const Float &lhs, RValue<Float> rhs)
5574 {
5575 return lhs = lhs * rhs;
5576 }
5577
5578 RValue<Float> operator/=(const Float &lhs, RValue<Float> rhs)
5579 {
5580 return lhs = lhs / rhs;
5581 }
5582
5583 RValue<Float> operator+(RValue<Float> val)
5584 {
5585 return val;
5586 }
5587
5588 RValue<Float> operator-(RValue<Float> val)
5589 {
5590 return RValue<Float>(Nucleus::createFNeg(val.value));
5591 }
5592
5593 RValue<Bool> operator<(RValue<Float> lhs, RValue<Float> rhs)
5594 {
5595 return RValue<Bool>(Nucleus::createFCmpOLT(lhs.value, rhs.value));
5596 }
5597
5598 RValue<Bool> operator<=(RValue<Float> lhs, RValue<Float> rhs)
5599 {
5600 return RValue<Bool>(Nucleus::createFCmpOLE(lhs.value, rhs.value));
5601 }
5602
5603 RValue<Bool> operator>(RValue<Float> lhs, RValue<Float> rhs)
5604 {
5605 return RValue<Bool>(Nucleus::createFCmpOGT(lhs.value, rhs.value));
5606 }
5607
5608 RValue<Bool> operator>=(RValue<Float> lhs, RValue<Float> rhs)
5609 {
5610 return RValue<Bool>(Nucleus::createFCmpOGE(lhs.value, rhs.value));
5611 }
5612
5613 RValue<Bool> operator!=(RValue<Float> lhs, RValue<Float> rhs)
5614 {
5615 return RValue<Bool>(Nucleus::createFCmpONE(lhs.value, rhs.value));
5616 }
5617
5618 RValue<Bool> operator==(RValue<Float> lhs, RValue<Float> rhs)
5619 {
5620 return RValue<Bool>(Nucleus::createFCmpOEQ(lhs.value, rhs.value));
5621 }
5622
5623 RValue<Float> Abs(RValue<Float> x)
5624 {
5625 return IfThenElse(x > 0.0f, x, -x);
5626 }
5627
5628 RValue<Float> Max(RValue<Float> x, RValue<Float> y)
5629 {
5630 return IfThenElse(x > y, x, y);
5631 }
5632
5633 RValue<Float> Min(RValue<Float> x, RValue<Float> y)
5634 {
5635 return IfThenElse(x < y, x, y);
5636 }
5637
5638 RValue<Float> Rcp_pp(RValue<Float> x, bool exactAtPow2)
5639 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04005640 assert(false && "UNIMPLEMENTED"); return RValue<Float>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005641 }
5642
5643 RValue<Float> RcpSqrt_pp(RValue<Float> x)
5644 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04005645 assert(false && "UNIMPLEMENTED"); return RValue<Float>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005646 }
5647
5648 RValue<Float> Sqrt(RValue<Float> x)
5649 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04005650 assert(false && "UNIMPLEMENTED"); return RValue<Float>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005651 }
5652
5653 RValue<Float> Round(RValue<Float> x)
5654 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04005655 assert(false && "UNIMPLEMENTED"); return RValue<Float>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005656 }
5657
5658 RValue<Float> Trunc(RValue<Float> x)
5659 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04005660 assert(false && "UNIMPLEMENTED"); return RValue<Float>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005661 }
5662
5663 RValue<Float> Frac(RValue<Float> x)
5664 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04005665 assert(false && "UNIMPLEMENTED"); return RValue<Float>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005666 }
5667
5668 RValue<Float> Floor(RValue<Float> x)
5669 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04005670 assert(false && "UNIMPLEMENTED"); return RValue<Float>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005671 }
5672
5673 RValue<Float> Ceil(RValue<Float> x)
5674 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04005675 assert(false && "UNIMPLEMENTED"); return RValue<Float>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005676 }
5677
5678 Type *Float::getType()
5679 {
Nicolas Capens9709d4f2016-09-30 11:44:14 -04005680 return T(Ice::IceType_f32);
Nicolas Capens598f8d82016-09-26 15:09:10 -04005681 }
5682
5683 Float2::Float2(RValue<Float4> cast)
5684 {
Nicolas Capens22008782016-10-20 01:11:47 -04005685 storeValue(Nucleus::createBitCast(cast.value, getType()));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005686 }
5687
5688 Type *Float2::getType()
5689 {
Nicolas Capens4cfd4572016-10-20 01:00:19 -04005690 return T(Type_v2f32);
Nicolas Capens598f8d82016-09-26 15:09:10 -04005691 }
5692
5693 Float4::Float4(RValue<Byte4> cast)
5694 {
5695 xyzw.parent = this;
5696
5697 assert(false && "UNIMPLEMENTED");
5698 }
5699
5700 Float4::Float4(RValue<SByte4> cast)
5701 {
5702 xyzw.parent = this;
5703
5704 assert(false && "UNIMPLEMENTED");
5705 }
5706
5707 Float4::Float4(RValue<Short4> cast)
5708 {
5709 xyzw.parent = this;
5710
5711 Int4 c(cast);
5712 storeValue(Nucleus::createSIToFP(RValue<Int4>(c).value, Float4::getType()));
5713 }
5714
5715 Float4::Float4(RValue<UShort4> cast)
5716 {
5717 xyzw.parent = this;
5718
5719 Int4 c(cast);
5720 storeValue(Nucleus::createSIToFP(RValue<Int4>(c).value, Float4::getType()));
5721 }
5722
5723 Float4::Float4(RValue<Int4> cast)
5724 {
5725 xyzw.parent = this;
5726
5727 Value *xyzw = Nucleus::createSIToFP(cast.value, Float4::getType());
5728
5729 storeValue(xyzw);
5730 }
5731
5732 Float4::Float4(RValue<UInt4> cast)
5733 {
5734 xyzw.parent = this;
5735
5736 Value *xyzw = Nucleus::createUIToFP(cast.value, Float4::getType());
5737
5738 storeValue(xyzw);
5739 }
5740
5741 Float4::Float4()
5742 {
5743 xyzw.parent = this;
5744 }
5745
5746 Float4::Float4(float xyzw)
5747 {
5748 constant(xyzw, xyzw, xyzw, xyzw);
5749 }
5750
5751 Float4::Float4(float x, float yzw)
5752 {
5753 constant(x, yzw, yzw, yzw);
5754 }
5755
5756 Float4::Float4(float x, float y, float zw)
5757 {
5758 constant(x, y, zw, zw);
5759 }
5760
5761 Float4::Float4(float x, float y, float z, float w)
5762 {
5763 constant(x, y, z, w);
5764 }
5765
5766 void Float4::constant(float x, float y, float z, float w)
5767 {
5768 xyzw.parent = this;
5769
Nicolas Capens13ac2322016-10-13 14:52:12 -04005770 double constantVector[4] = {x, y, z, w};
Nicolas Capens8dfd9a72016-10-13 17:44:51 -04005771 storeValue(Nucleus::createConstantVector(constantVector, getType()));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005772 }
5773
5774 Float4::Float4(RValue<Float4> rhs)
5775 {
5776 xyzw.parent = this;
5777
5778 storeValue(rhs.value);
5779 }
5780
5781 Float4::Float4(const Float4 &rhs)
5782 {
5783 xyzw.parent = this;
5784
5785 Value *value = rhs.loadValue();
5786 storeValue(value);
5787 }
5788
5789 Float4::Float4(const Reference<Float4> &rhs)
5790 {
5791 xyzw.parent = this;
5792
5793 Value *value = rhs.loadValue();
5794 storeValue(value);
5795 }
5796
5797 Float4::Float4(RValue<Float> rhs)
5798 {
5799 xyzw.parent = this;
5800
5801 assert(false && "UNIMPLEMENTED");
5802 }
5803
5804 Float4::Float4(const Float &rhs)
5805 {
5806 xyzw.parent = this;
5807
5808 *this = RValue<Float>(rhs.loadValue());
5809 }
5810
5811 Float4::Float4(const Reference<Float> &rhs)
5812 {
5813 xyzw.parent = this;
5814
5815 *this = RValue<Float>(rhs.loadValue());
5816 }
5817
5818 RValue<Float4> Float4::operator=(float x) const
5819 {
5820 return *this = Float4(x, x, x, x);
5821 }
5822
5823 RValue<Float4> Float4::operator=(RValue<Float4> rhs) const
5824 {
5825 storeValue(rhs.value);
5826
5827 return rhs;
5828 }
5829
5830 RValue<Float4> Float4::operator=(const Float4 &rhs) const
5831 {
5832 Value *value = rhs.loadValue();
5833 storeValue(value);
5834
5835 return RValue<Float4>(value);
5836 }
5837
5838 RValue<Float4> Float4::operator=(const Reference<Float4> &rhs) const
5839 {
5840 Value *value = rhs.loadValue();
5841 storeValue(value);
5842
5843 return RValue<Float4>(value);
5844 }
5845
5846 RValue<Float4> Float4::operator=(RValue<Float> rhs) const
5847 {
5848 return *this = Float4(rhs);
5849 }
5850
5851 RValue<Float4> Float4::operator=(const Float &rhs) const
5852 {
5853 return *this = Float4(rhs);
5854 }
5855
5856 RValue<Float4> Float4::operator=(const Reference<Float> &rhs) const
5857 {
5858 return *this = Float4(rhs);
5859 }
5860
5861 RValue<Float4> operator+(RValue<Float4> lhs, RValue<Float4> rhs)
5862 {
5863 return RValue<Float4>(Nucleus::createFAdd(lhs.value, rhs.value));
5864 }
5865
5866 RValue<Float4> operator-(RValue<Float4> lhs, RValue<Float4> rhs)
5867 {
5868 return RValue<Float4>(Nucleus::createFSub(lhs.value, rhs.value));
5869 }
5870
5871 RValue<Float4> operator*(RValue<Float4> lhs, RValue<Float4> rhs)
5872 {
5873 return RValue<Float4>(Nucleus::createFMul(lhs.value, rhs.value));
5874 }
5875
5876 RValue<Float4> operator/(RValue<Float4> lhs, RValue<Float4> rhs)
5877 {
5878 return RValue<Float4>(Nucleus::createFDiv(lhs.value, rhs.value));
5879 }
5880
5881 RValue<Float4> operator%(RValue<Float4> lhs, RValue<Float4> rhs)
5882 {
5883 return RValue<Float4>(Nucleus::createFRem(lhs.value, rhs.value));
5884 }
5885
5886 RValue<Float4> operator+=(const Float4 &lhs, RValue<Float4> rhs)
5887 {
5888 return lhs = lhs + rhs;
5889 }
5890
5891 RValue<Float4> operator-=(const Float4 &lhs, RValue<Float4> rhs)
5892 {
5893 return lhs = lhs - rhs;
5894 }
5895
5896 RValue<Float4> operator*=(const Float4 &lhs, RValue<Float4> rhs)
5897 {
5898 return lhs = lhs * rhs;
5899 }
5900
5901 RValue<Float4> operator/=(const Float4 &lhs, RValue<Float4> rhs)
5902 {
5903 return lhs = lhs / rhs;
5904 }
5905
5906 RValue<Float4> operator%=(const Float4 &lhs, RValue<Float4> rhs)
5907 {
5908 return lhs = lhs % rhs;
5909 }
5910
5911 RValue<Float4> operator+(RValue<Float4> val)
5912 {
5913 return val;
5914 }
5915
5916 RValue<Float4> operator-(RValue<Float4> val)
5917 {
5918 return RValue<Float4>(Nucleus::createFNeg(val.value));
5919 }
5920
5921 RValue<Float4> Abs(RValue<Float4> x)
5922 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04005923 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005924 }
5925
5926 RValue<Float4> Max(RValue<Float4> x, RValue<Float4> y)
5927 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04005928 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005929 }
5930
5931 RValue<Float4> Min(RValue<Float4> x, RValue<Float4> y)
5932 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04005933 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005934 }
5935
5936 RValue<Float4> Rcp_pp(RValue<Float4> x, bool exactAtPow2)
5937 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04005938 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005939 }
5940
5941 RValue<Float4> RcpSqrt_pp(RValue<Float4> x)
5942 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04005943 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005944 }
5945
5946 RValue<Float4> Sqrt(RValue<Float4> x)
5947 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04005948 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005949 }
5950
5951 RValue<Float4> Insert(const Float4 &val, RValue<Float> element, int i)
5952 {
5953 Value *value = val.loadValue();
5954 Value *insert = Nucleus::createInsertElement(value, element.value, i);
5955
5956 val = RValue<Float4>(insert);
5957
5958 return val;
5959 }
5960
5961 RValue<Float> Extract(RValue<Float4> x, int i)
5962 {
Nicolas Capense95d5342016-09-30 11:37:28 -04005963 return RValue<Float>(Nucleus::createExtractElement(x.value, Float::getType(), i));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005964 }
5965
5966 RValue<Float4> Swizzle(RValue<Float4> x, unsigned char select)
5967 {
Nicolas Capense95d5342016-09-30 11:37:28 -04005968 return RValue<Float4>(createSwizzle4(x.value, select));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005969 }
5970
5971 RValue<Float4> ShuffleLowHigh(RValue<Float4> x, RValue<Float4> y, unsigned char imm)
5972 {
Nicolas Capens37fbece2016-10-21 15:08:56 -04005973 int shuffle[4] =
5974 {
5975 ((imm >> 0) & 0x03) + 0,
5976 ((imm >> 2) & 0x03) + 0,
5977 ((imm >> 4) & 0x03) + 4,
5978 ((imm >> 6) & 0x03) + 4,
5979 };
5980
5981 return RValue<Float4>(Nucleus::createShuffleVector(x.value, y.value, shuffle));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005982 }
5983
5984 RValue<Float4> UnpackLow(RValue<Float4> x, RValue<Float4> y)
5985 {
Nicolas Capens37fbece2016-10-21 15:08:56 -04005986 int shuffle[4] = {0, 4, 1, 5};
5987 return RValue<Float4>(Nucleus::createShuffleVector(x.value, y.value, shuffle));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005988 }
5989
5990 RValue<Float4> UnpackHigh(RValue<Float4> x, RValue<Float4> y)
5991 {
Nicolas Capens37fbece2016-10-21 15:08:56 -04005992 int shuffle[4] = {2, 6, 3, 7};
5993 return RValue<Float4>(Nucleus::createShuffleVector(x.value, y.value, shuffle));
Nicolas Capens598f8d82016-09-26 15:09:10 -04005994 }
5995
5996 RValue<Float4> Mask(Float4 &lhs, RValue<Float4> rhs, unsigned char select)
5997 {
5998 Value *vector = lhs.loadValue();
Nicolas Capense95d5342016-09-30 11:37:28 -04005999 Value *shuffle = createMask4(vector, rhs.value, select);
Nicolas Capens598f8d82016-09-26 15:09:10 -04006000 lhs.storeValue(shuffle);
6001
6002 return RValue<Float4>(shuffle);
6003 }
6004
6005 RValue<Int> SignMask(RValue<Float4> x)
6006 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04006007 assert(false && "UNIMPLEMENTED"); return RValue<Int>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04006008 }
6009
6010 RValue<Int4> CmpEQ(RValue<Float4> x, RValue<Float4> y)
6011 {
6012 return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOEQ(x.value, y.value), Int4::getType()));
6013 }
6014
6015 RValue<Int4> CmpLT(RValue<Float4> x, RValue<Float4> y)
6016 {
6017 return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOLT(x.value, y.value), Int4::getType()));
6018 }
6019
6020 RValue<Int4> CmpLE(RValue<Float4> x, RValue<Float4> y)
6021 {
6022 return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOLE(x.value, y.value), Int4::getType()));
6023 }
6024
6025 RValue<Int4> CmpNEQ(RValue<Float4> x, RValue<Float4> y)
6026 {
6027 return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpONE(x.value, y.value), Int4::getType()));
6028 }
6029
6030 RValue<Int4> CmpNLT(RValue<Float4> x, RValue<Float4> y)
6031 {
6032 return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOGE(x.value, y.value), Int4::getType()));
6033 }
6034
6035 RValue<Int4> CmpNLE(RValue<Float4> x, RValue<Float4> y)
6036 {
6037 return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOGT(x.value, y.value), Int4::getType()));
6038 }
6039
6040 RValue<Float4> Round(RValue<Float4> x)
6041 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04006042 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04006043 }
6044
6045 RValue<Float4> Trunc(RValue<Float4> x)
6046 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04006047 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04006048 }
6049
6050 RValue<Float4> Frac(RValue<Float4> x)
6051 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04006052 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04006053 }
6054
6055 RValue<Float4> Floor(RValue<Float4> x)
6056 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04006057 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04006058 }
6059
6060 RValue<Float4> Ceil(RValue<Float4> x)
6061 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04006062 assert(false && "UNIMPLEMENTED"); return RValue<Float4>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04006063 }
6064
6065 Type *Float4::getType()
6066 {
Nicolas Capens9709d4f2016-09-30 11:44:14 -04006067 return T(Ice::IceType_v4f32);
Nicolas Capens598f8d82016-09-26 15:09:10 -04006068 }
6069
6070 RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, int offset)
6071 {
Nicolas Capens8820f642016-09-30 04:42:43 -04006072 return lhs + RValue<Int>(Nucleus::createConstantInt(offset));
Nicolas Capens598f8d82016-09-26 15:09:10 -04006073 }
6074
6075 RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<Int> offset)
6076 {
Nicolas Capens6d738712016-09-30 04:15:22 -04006077 return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value, Byte::getType(), offset.value));
Nicolas Capens598f8d82016-09-26 15:09:10 -04006078 }
6079
6080 RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<UInt> offset)
6081 {
Nicolas Capens6d738712016-09-30 04:15:22 -04006082 return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value, Byte::getType(), offset.value));
Nicolas Capens598f8d82016-09-26 15:09:10 -04006083 }
6084
6085 RValue<Pointer<Byte>> operator+=(const Pointer<Byte> &lhs, int offset)
6086 {
6087 return lhs = lhs + offset;
6088 }
6089
6090 RValue<Pointer<Byte>> operator+=(const Pointer<Byte> &lhs, RValue<Int> offset)
6091 {
6092 return lhs = lhs + offset;
6093 }
6094
6095 RValue<Pointer<Byte>> operator+=(const Pointer<Byte> &lhs, RValue<UInt> offset)
6096 {
6097 return lhs = lhs + offset;
6098 }
6099
6100 RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, int offset)
6101 {
6102 return lhs + -offset;
6103 }
6104
6105 RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, RValue<Int> offset)
6106 {
6107 return lhs + -offset;
6108 }
6109
6110 RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, RValue<UInt> offset)
6111 {
6112 return lhs + -offset;
6113 }
6114
6115 RValue<Pointer<Byte>> operator-=(const Pointer<Byte> &lhs, int offset)
6116 {
6117 return lhs = lhs - offset;
6118 }
6119
6120 RValue<Pointer<Byte>> operator-=(const Pointer<Byte> &lhs, RValue<Int> offset)
6121 {
6122 return lhs = lhs - offset;
6123 }
6124
6125 RValue<Pointer<Byte>> operator-=(const Pointer<Byte> &lhs, RValue<UInt> offset)
6126 {
6127 return lhs = lhs - offset;
6128 }
6129
6130 void Return()
6131 {
6132 Nucleus::createRetVoid();
6133 Nucleus::setInsertBlock(Nucleus::createBasicBlock());
6134 Nucleus::createUnreachable();
6135 }
6136
6137 void Return(bool ret)
6138 {
Nicolas Capensfdcca2d2016-10-20 11:31:36 -04006139 Nucleus::createRet(Nucleus::createConstantInt(ret));
6140 Nucleus::setInsertBlock(Nucleus::createBasicBlock());
6141 Nucleus::createUnreachable();
Nicolas Capens598f8d82016-09-26 15:09:10 -04006142 }
6143
6144 void Return(const Int &ret)
6145 {
Nicolas Capensfdcca2d2016-10-20 11:31:36 -04006146 Nucleus::createRet(ret.loadValue());
6147 Nucleus::setInsertBlock(Nucleus::createBasicBlock());
6148 Nucleus::createUnreachable();
Nicolas Capens598f8d82016-09-26 15:09:10 -04006149 }
6150
Nicolas Capens598f8d82016-09-26 15:09:10 -04006151 bool branch(RValue<Bool> cmp, BasicBlock *bodyBB, BasicBlock *endBB)
6152 {
6153 Nucleus::createCondBr(cmp.value, bodyBB, endBB);
6154 Nucleus::setInsertBlock(bodyBB);
6155
6156 return true;
6157 }
6158
Nicolas Capens9ed1a182016-10-24 09:52:23 -04006159 void endIf(BasicBlock *falseBB)
6160 {
6161 ::falseBB = falseBB;
6162 }
6163
Nicolas Capens598f8d82016-09-26 15:09:10 -04006164 bool elseBlock(BasicBlock *falseBB)
6165 {
Nicolas Capens9ed1a182016-10-24 09:52:23 -04006166 assert(falseBB && "Else not preceded by If");
6167 falseBB->getInsts().back().setDeleted();
Nicolas Capens598f8d82016-09-26 15:09:10 -04006168 Nucleus::setInsertBlock(falseBB);
6169
6170 return true;
6171 }
6172
Nicolas Capens9ed1a182016-10-24 09:52:23 -04006173 BasicBlock *beginElse()
6174 {
6175 BasicBlock *falseBB = ::falseBB;
6176 ::falseBB = nullptr;
6177
6178 return falseBB;
6179 }
6180
Nicolas Capens598f8d82016-09-26 15:09:10 -04006181 RValue<Long> Ticks()
6182 {
Nicolas Capensc37252c2016-09-28 16:11:54 -04006183 assert(false && "UNIMPLEMENTED"); return RValue<Long>(V(nullptr));
Nicolas Capens598f8d82016-09-26 15:09:10 -04006184 }
6185}
6186