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