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