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