10bac285a78df6a6d7a6b68784748b92805420ffbNicolas Capens// Copyright 2016 The SwiftShader Authors. All Rights Reserved. 2894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// 30bac285a78df6a6d7a6b68784748b92805420ffbNicolas Capens// Licensed under the Apache License, Version 2.0 (the "License"); 40bac285a78df6a6d7a6b68784748b92805420ffbNicolas Capens// you may not use this file except in compliance with the License. 50bac285a78df6a6d7a6b68784748b92805420ffbNicolas Capens// You may obtain a copy of the License at 6894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// 70bac285a78df6a6d7a6b68784748b92805420ffbNicolas Capens// http://www.apache.org/licenses/LICENSE-2.0 8894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// 90bac285a78df6a6d7a6b68784748b92805420ffbNicolas Capens// Unless required by applicable law or agreed to in writing, software 100bac285a78df6a6d7a6b68784748b92805420ffbNicolas Capens// distributed under the License is distributed on an "AS IS" BASIS, 110bac285a78df6a6d7a6b68784748b92805420ffbNicolas Capens// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 120bac285a78df6a6d7a6b68784748b92805420ffbNicolas Capens// See the License for the specific language governing permissions and 130bac285a78df6a6d7a6b68784748b92805420ffbNicolas Capens// limitations under the License. 14894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 15cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens#include "Reactor.hpp" 16894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 17894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/Support/IRBuilder.h" 18894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/Function.h" 19894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/GlobalVariable.h" 20894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/Module.h" 21894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/LLVMContext.h" 22894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/Constants.h" 23894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/Intrinsics.h" 2466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman#include "llvm/PassManager.h" 25894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/Analysis/LoopPass.h" 26894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/Transforms/Scalar.h" 27894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/Target/TargetData.h" 28894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/Target/TargetOptions.h" 2919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman#include "llvm/Support/TargetSelect.h" 30894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "../lib/ExecutionEngine/JIT/JIT.h" 31894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 32daa5d9108b225760ef6676b19d874e9ee8ee9bd3Nicolas Capens#include "LLVMRoutine.hpp" 33daa5d9108b225760ef6676b19d874e9ee8ee9bd3Nicolas Capens#include "LLVMRoutineManager.hpp" 34894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "x86.hpp" 35708c24b3cd03b68aa98b29a9099d6a9ce96eca16Nicolas Capens#include "Common/CPUID.hpp" 36708c24b3cd03b68aa98b29a9099d6a9ce96eca16Nicolas Capens#include "Common/Thread.hpp" 37708c24b3cd03b68aa98b29a9099d6a9ce96eca16Nicolas Capens#include "Common/Memory.hpp" 38708c24b3cd03b68aa98b29a9099d6a9ce96eca16Nicolas Capens#include "Common/MutexLock.hpp" 39894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 40894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include <fstream> 41894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4247dc8676fcff01274de3d3fe98e1de607ff076d3Nicolas Capens#if defined(__i386__) || defined(__x86_64__) 4347dc8676fcff01274de3d3fe98e1de607ff076d3Nicolas Capens#include <xmmintrin.h> 4447dc8676fcff01274de3d3fe98e1de607ff076d3Nicolas Capens#endif 4547dc8676fcff01274de3d3fe98e1de607ff076d3Nicolas Capens 46cb1225825a82a52c16923d05da8a862544ff65ccNicolas Capens#if defined(__x86_64__) && defined(_WIN32) 4766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanextern "C" void X86CompilationCallback() 4866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman{ 4966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman assert(false); // UNIMPLEMENTED 5066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman} 5166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman#endif 5266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 53894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanextern "C" 54894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman{ 55894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman bool (*CodeAnalystInitialize)() = 0; 56894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman void (*CodeAnalystCompleteJITLog)() = 0; 57894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman bool (*CodeAnalystLogJITCode)(const void *jitCodeStartAddr, unsigned int jitCodeSize, const wchar_t *functionName) = 0; 58894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman} 59894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 60894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumannamespace llvm 61894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman{ 62894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman extern bool JITEmitDebugInfo; 63894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman} 64894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 655c1f5cc77307d87c0dfa768e89200fa574795508Nicolas Capensnamespace 66894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman{ 67daa5d9108b225760ef6676b19d874e9ee8ee9bd3Nicolas Capens sw::LLVMRoutineManager *routineManager = nullptr; 685c1f5cc77307d87c0dfa768e89200fa574795508Nicolas Capens llvm::ExecutionEngine *executionEngine = nullptr; 695c1f5cc77307d87c0dfa768e89200fa574795508Nicolas Capens llvm::IRBuilder<> *builder = nullptr; 705c1f5cc77307d87c0dfa768e89200fa574795508Nicolas Capens llvm::LLVMContext *context = nullptr; 715c1f5cc77307d87c0dfa768e89200fa574795508Nicolas Capens llvm::Module *module = nullptr; 725c1f5cc77307d87c0dfa768e89200fa574795508Nicolas Capens llvm::Function *function = nullptr; 733bbc5e16af2975cf3903ef47a21ed7d75d0874d9Nicolas Capens 74f8faed6dd2b2389bef3b9aae0f5ce9e8fcf950faJorge E. Moreira sw::MutexLock codegenMutex; 755c1f5cc77307d87c0dfa768e89200fa574795508Nicolas Capens} 76894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 775c1f5cc77307d87c0dfa768e89200fa574795508Nicolas Capensnamespace sw 785c1f5cc77307d87c0dfa768e89200fa574795508Nicolas Capens{ 795c1f5cc77307d87c0dfa768e89200fa574795508Nicolas Capens Optimization optimization[10] = {InstructionCombining, Disabled}; 80894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 81fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens enum EmulatedType 82fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens { 83fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens Type_v2i32, 84fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens Type_v4i16, 85fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens Type_v2i16, 86fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens Type_v8i8, 87fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens Type_v4i8, 88fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens Type_v2f32, 89fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens EmulatedTypeCount 90fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens }; 91fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens 921933654b62251805d4575b05b6829275b0fe6142Nicolas Capens class Value : public llvm::Value {}; 93b98fe5cd1eaa821083d816cf86a20eefe22f57c7Nicolas Capens class SwitchCases : public llvm::SwitchInst {}; 94c8b67a48e64ca05fbecfcd9990d16e1cb68a9578Nicolas Capens class BasicBlock : public llvm::BasicBlock {}; 95ac2301298a42723d2c88f8749cab434ddd64e82dNicolas Capens 96fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::Type *T(Type *t) 97fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens { 9801a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens uintptr_t type = reinterpret_cast<uintptr_t>(t); 99fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens if(type < EmulatedTypeCount) 100fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens { 10101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens // Use 128-bit vectors to implement logically shorter ones. 102fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens switch(type) 103fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens { 10401a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens case Type_v2i32: return T(Int4::getType()); 10501a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens case Type_v4i16: return T(Short8::getType()); 10601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens case Type_v2i16: return T(Short8::getType()); 10701a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens case Type_v8i8: return T(Byte16::getType()); 10801a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens case Type_v4i8: return T(Byte16::getType()); 10901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens case Type_v2f32: return T(Float4::getType()); 110fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens default: assert(false); 111fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens } 112fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens } 113fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens 114fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return reinterpret_cast<llvm::Type*>(t); 115fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens } 116fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens 117ac2301298a42723d2c88f8749cab434ddd64e82dNicolas Capens inline Type *T(llvm::Type *t) 118ac2301298a42723d2c88f8749cab434ddd64e82dNicolas Capens { 119ac2301298a42723d2c88f8749cab434ddd64e82dNicolas Capens return reinterpret_cast<Type*>(t); 120ac2301298a42723d2c88f8749cab434ddd64e82dNicolas Capens } 121ac2301298a42723d2c88f8749cab434ddd64e82dNicolas Capens 122fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens Type *T(EmulatedType t) 123fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens { 124fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return reinterpret_cast<Type*>(t); 125fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens } 126fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens 1271933654b62251805d4575b05b6829275b0fe6142Nicolas Capens inline Value *V(llvm::Value *t) 1281933654b62251805d4575b05b6829275b0fe6142Nicolas Capens { 1291933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return reinterpret_cast<Value*>(t); 1301933654b62251805d4575b05b6829275b0fe6142Nicolas Capens } 1311933654b62251805d4575b05b6829275b0fe6142Nicolas Capens 132ac2301298a42723d2c88f8749cab434ddd64e82dNicolas Capens inline std::vector<llvm::Type*> &T(std::vector<Type*> &t) 133ac2301298a42723d2c88f8749cab434ddd64e82dNicolas Capens { 134ac2301298a42723d2c88f8749cab434ddd64e82dNicolas Capens return reinterpret_cast<std::vector<llvm::Type*>&>(t); 135ac2301298a42723d2c88f8749cab434ddd64e82dNicolas Capens } 136ac2301298a42723d2c88f8749cab434ddd64e82dNicolas Capens 137c8b67a48e64ca05fbecfcd9990d16e1cb68a9578Nicolas Capens inline BasicBlock *B(llvm::BasicBlock *t) 138c8b67a48e64ca05fbecfcd9990d16e1cb68a9578Nicolas Capens { 139c8b67a48e64ca05fbecfcd9990d16e1cb68a9578Nicolas Capens return reinterpret_cast<BasicBlock*>(t); 140c8b67a48e64ca05fbecfcd9990d16e1cb68a9578Nicolas Capens } 141c8b67a48e64ca05fbecfcd9990d16e1cb68a9578Nicolas Capens 14201a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens static size_t typeSize(Type *type) 14301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens { 14401a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens uintptr_t t = reinterpret_cast<uintptr_t>(type); 14501a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens if(t < EmulatedTypeCount) 14601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens { 14701a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens switch(t) 14801a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens { 14901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens case Type_v2i32: return 8; 15001a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens case Type_v4i16: return 8; 15101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens case Type_v2i16: return 4; 15201a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens case Type_v8i8: return 8; 15301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens case Type_v4i8: return 4; 15401a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens case Type_v2f32: return 8; 15501a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens default: assert(false); 15601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens } 15701a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens } 15801a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens 15901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return T(type)->getPrimitiveSizeInBits() / 8; 16001a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens } 16101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens 16269674fb1f01c657bfeb5f2cb6389d4a959b973f6Nicolas Capens static unsigned int elementCount(Type *type) 16369674fb1f01c657bfeb5f2cb6389d4a959b973f6Nicolas Capens { 16469674fb1f01c657bfeb5f2cb6389d4a959b973f6Nicolas Capens uintptr_t t = reinterpret_cast<uintptr_t>(type); 16569674fb1f01c657bfeb5f2cb6389d4a959b973f6Nicolas Capens if(t < EmulatedTypeCount) 16669674fb1f01c657bfeb5f2cb6389d4a959b973f6Nicolas Capens { 16769674fb1f01c657bfeb5f2cb6389d4a959b973f6Nicolas Capens switch(t) 16869674fb1f01c657bfeb5f2cb6389d4a959b973f6Nicolas Capens { 16969674fb1f01c657bfeb5f2cb6389d4a959b973f6Nicolas Capens case Type_v2i32: return 2; 17069674fb1f01c657bfeb5f2cb6389d4a959b973f6Nicolas Capens case Type_v4i16: return 4; 17169674fb1f01c657bfeb5f2cb6389d4a959b973f6Nicolas Capens case Type_v2i16: return 2; 17269674fb1f01c657bfeb5f2cb6389d4a959b973f6Nicolas Capens case Type_v8i8: return 8; 17369674fb1f01c657bfeb5f2cb6389d4a959b973f6Nicolas Capens case Type_v4i8: return 4; 17469674fb1f01c657bfeb5f2cb6389d4a959b973f6Nicolas Capens case Type_v2f32: return 2; 17569674fb1f01c657bfeb5f2cb6389d4a959b973f6Nicolas Capens default: assert(false); 17669674fb1f01c657bfeb5f2cb6389d4a959b973f6Nicolas Capens } 17769674fb1f01c657bfeb5f2cb6389d4a959b973f6Nicolas Capens } 17869674fb1f01c657bfeb5f2cb6389d4a959b973f6Nicolas Capens 17969674fb1f01c657bfeb5f2cb6389d4a959b973f6Nicolas Capens return llvm::cast<llvm::VectorType>(T(type))->getNumElements(); 18069674fb1f01c657bfeb5f2cb6389d4a959b973f6Nicolas Capens } 18169674fb1f01c657bfeb5f2cb6389d4a959b973f6Nicolas Capens 182894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Nucleus::Nucleus() 183894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1843bbc5e16af2975cf3903ef47a21ed7d75d0874d9Nicolas Capens ::codegenMutex.lock(); // Reactor and LLVM are currently not thread safe 185b7ea984f9e483aba2c1c0f26adf5ddd604a5113eNicolas Capens 186fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::InitializeNativeTarget(); 187fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::JITEmitDebugInfo = false; 188894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1895c1f5cc77307d87c0dfa768e89200fa574795508Nicolas Capens if(!::context) 190894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 191fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens ::context = new llvm::LLVMContext(); 192894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 193894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 194fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens ::module = new llvm::Module("", *::context); 195daa5d9108b225760ef6676b19d874e9ee8ee9bd3Nicolas Capens ::routineManager = new LLVMRoutineManager(); 19666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 197894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman #if defined(__x86_64__) 198894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman const char *architecture = "x86-64"; 199894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman #else 200894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman const char *architecture = "x86"; 201894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman #endif 202894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 203fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::SmallVector<std::string, 1> MAttrs; 204894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman MAttrs.push_back(CPUID::supportsMMX() ? "+mmx" : "-mmx"); 205894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman MAttrs.push_back(CPUID::supportsCMOV() ? "+cmov" : "-cmov"); 206894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman MAttrs.push_back(CPUID::supportsSSE() ? "+sse" : "-sse"); 207894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman MAttrs.push_back(CPUID::supportsSSE2() ? "+sse2" : "-sse2"); 208894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman MAttrs.push_back(CPUID::supportsSSE3() ? "+sse3" : "-sse3"); 209894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman MAttrs.push_back(CPUID::supportsSSSE3() ? "+ssse3" : "-ssse3"); 210894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman MAttrs.push_back(CPUID::supportsSSE4_1() ? "+sse41" : "-sse41"); 211894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 21219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman std::string error; 213fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::TargetMachine *targetMachine = llvm::EngineBuilder::selectTarget(::module, architecture, "", MAttrs, llvm::Reloc::Default, llvm::CodeModel::JITDefault, &error); 214fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens ::executionEngine = llvm::JIT::createJIT(::module, 0, ::routineManager, llvm::CodeGenOpt::Aggressive, true, targetMachine); 215894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 2165c1f5cc77307d87c0dfa768e89200fa574795508Nicolas Capens if(!::builder) 217894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 218fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens ::builder = new llvm::IRBuilder<>(*::context); 219894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 22066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman #if defined(_WIN32) 22166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman HMODULE CodeAnalyst = LoadLibrary("CAJitNtfyLib.dll"); 22266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman if(CodeAnalyst) 22366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 22466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman CodeAnalystInitialize = (bool(*)())GetProcAddress(CodeAnalyst, "CAJIT_Initialize"); 22566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman CodeAnalystCompleteJITLog = (void(*)())GetProcAddress(CodeAnalyst, "CAJIT_CompleteJITLog"); 22666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman CodeAnalystLogJITCode = (bool(*)(const void*, unsigned int, const wchar_t*))GetProcAddress(CodeAnalyst, "CAJIT_LogJITCode"); 22766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 22866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman CodeAnalystInitialize(); 22966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 23066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman #endif 231894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 232894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 233894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 234894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Nucleus::~Nucleus() 235894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2365c1f5cc77307d87c0dfa768e89200fa574795508Nicolas Capens delete ::executionEngine; 2375c1f5cc77307d87c0dfa768e89200fa574795508Nicolas Capens ::executionEngine = nullptr; 238894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 2395c1f5cc77307d87c0dfa768e89200fa574795508Nicolas Capens ::routineManager = nullptr; 2405c1f5cc77307d87c0dfa768e89200fa574795508Nicolas Capens ::function = nullptr; 2415c1f5cc77307d87c0dfa768e89200fa574795508Nicolas Capens ::module = nullptr; 242b7ea984f9e483aba2c1c0f26adf5ddd604a5113eNicolas Capens 2433bbc5e16af2975cf3903ef47a21ed7d75d0874d9Nicolas Capens ::codegenMutex.unlock(); 244894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 245894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 246894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Routine *Nucleus::acquireRoutine(const wchar_t *name, bool runOptimizations) 247894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2485c1f5cc77307d87c0dfa768e89200fa574795508Nicolas Capens if(::builder->GetInsertBlock()->empty() || !::builder->GetInsertBlock()->back().isTerminator()) 24919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 250ac2301298a42723d2c88f8749cab434ddd64e82dNicolas Capens llvm::Type *type = ::function->getReturnType(); 25119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 25219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman if(type->isVoidTy()) 25319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 25419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman createRetVoid(); 25519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 25619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman else 25719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 258fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens createRet(V(llvm::UndefValue::get(type))); 25919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 26019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 261894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 262894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(false) 263894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 26466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman std::string error; 265fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::raw_fd_ostream file("llvm-dump-unopt.txt", error); 2665c1f5cc77307d87c0dfa768e89200fa574795508Nicolas Capens ::module->print(file, 0); 267894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 268894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 269894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(runOptimizations) 270894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 271894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman optimize(); 272894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 273894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 274894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(false) 275894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 27666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman std::string error; 277fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::raw_fd_ostream file("llvm-dump-opt.txt", error); 2785c1f5cc77307d87c0dfa768e89200fa574795508Nicolas Capens ::module->print(file, 0); 279894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 280894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 2815c1f5cc77307d87c0dfa768e89200fa574795508Nicolas Capens void *entry = ::executionEngine->getPointerToFunction(::function); 282daa5d9108b225760ef6676b19d874e9ee8ee9bd3Nicolas Capens LLVMRoutine *routine = ::routineManager->acquireRoutine(entry); 283894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 284894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(CodeAnalystLogJITCode) 285894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 286d946e0a3ab6030aad58a458e5a50b976364a01c1Nicolas Capens CodeAnalystLogJITCode(routine->getEntry(), routine->getCodeSize(), name); 287894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 288894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 289894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return routine; 290894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 291894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 292894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman void Nucleus::optimize() 293894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 294fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens static llvm::PassManager *passManager = nullptr; 29566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 296894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(!passManager) 297894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 298fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens passManager = new llvm::PassManager(); 299894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 300fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::UnsafeFPMath = true; 301fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens // llvm::NoInfsFPMath = true; 302fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens // llvm::NoNaNsFPMath = true; 303894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 304fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens passManager->add(new llvm::TargetData(*::executionEngine->getTargetData())); 305fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens passManager->add(llvm::createScalarReplAggregatesPass()); 306894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 307894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman for(int pass = 0; pass < 10 && optimization[pass] != Disabled; pass++) 308894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 309894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman switch(optimization[pass]) 310894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 311fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens case Disabled: break; 312fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens case CFGSimplification: passManager->add(llvm::createCFGSimplificationPass()); break; 313fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens case LICM: passManager->add(llvm::createLICMPass()); break; 314fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens case AggressiveDCE: passManager->add(llvm::createAggressiveDCEPass()); break; 315fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens case GVN: passManager->add(llvm::createGVNPass()); break; 316fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens case InstructionCombining: passManager->add(llvm::createInstructionCombiningPass()); break; 317fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens case Reassociate: passManager->add(llvm::createReassociatePass()); break; 318fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens case DeadStoreElimination: passManager->add(llvm::createDeadStoreEliminationPass()); break; 319fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens case SCCP: passManager->add(llvm::createSCCPPass()); break; 320fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens case ScalarReplAggregates: passManager->add(llvm::createScalarReplAggregatesPass()); break; 321894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman default: 322894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman assert(false); 323894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 324894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 325894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 326894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3275c1f5cc77307d87c0dfa768e89200fa574795508Nicolas Capens passManager->run(*::module); 328894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 329894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 33019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Value *Nucleus::allocateStackVariable(Type *type, int arraySize) 331894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 332894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // Need to allocate it in the entry block for mem2reg to work 333c8b67a48e64ca05fbecfcd9990d16e1cb68a9578Nicolas Capens llvm::BasicBlock &entryBlock = ::function->getEntryBlock(); 334894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 335fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::Instruction *declaration; 336894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 337894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(arraySize) 338894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 339fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens declaration = new llvm::AllocaInst(T(type), Nucleus::createConstantInt(arraySize)); 340894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 341894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman else 342894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 343fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens declaration = new llvm::AllocaInst(T(type), (Value*)nullptr); 344894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 345894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 346894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman entryBlock.getInstList().push_front(declaration); 347894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3481933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(declaration); 349894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 350894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 351894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman BasicBlock *Nucleus::createBasicBlock() 352894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 353c8b67a48e64ca05fbecfcd9990d16e1cb68a9578Nicolas Capens return B(BasicBlock::Create(*::context, "", ::function)); 354894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 355894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 356894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman BasicBlock *Nucleus::getInsertBlock() 357894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 358c8b67a48e64ca05fbecfcd9990d16e1cb68a9578Nicolas Capens return B(::builder->GetInsertBlock()); 359894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 360894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 361894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman void Nucleus::setInsertBlock(BasicBlock *basicBlock) 362894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3635c1f5cc77307d87c0dfa768e89200fa574795508Nicolas Capens // assert(::builder->GetInsertBlock()->back().isTerminator()); 3645c1f5cc77307d87c0dfa768e89200fa574795508Nicolas Capens return ::builder->SetInsertPoint(basicBlock); 365894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 366894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 367ac2301298a42723d2c88f8749cab434ddd64e82dNicolas Capens void Nucleus::createFunction(Type *ReturnType, std::vector<Type*> &Params) 368894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 369fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::FunctionType *functionType = llvm::FunctionType::get(T(ReturnType), T(Params), false); 3705c1f5cc77307d87c0dfa768e89200fa574795508Nicolas Capens ::function = llvm::Function::Create(functionType, llvm::GlobalValue::InternalLinkage, "", ::module); 3715c1f5cc77307d87c0dfa768e89200fa574795508Nicolas Capens ::function->setCallingConv(llvm::CallingConv::C); 372894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3735c1f5cc77307d87c0dfa768e89200fa574795508Nicolas Capens ::builder->SetInsertPoint(BasicBlock::Create(*::context, "", ::function)); 374894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 375894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3761933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *Nucleus::getArgument(unsigned int index) 377894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3785c1f5cc77307d87c0dfa768e89200fa574795508Nicolas Capens llvm::Function::arg_iterator args = ::function->arg_begin(); 379894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 380894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman while(index) 381894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 382894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman args++; 383894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman index--; 384894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 385894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3861933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(&*args); 387894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 388894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3893d7c35f224f985f3f4620be2f1bdc60b959b7724Nicolas Capens void Nucleus::createRetVoid() 390894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3913d7c35f224f985f3f4620be2f1bdc60b959b7724Nicolas Capens ::builder->CreateRetVoid(); 392894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 393894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3943d7c35f224f985f3f4620be2f1bdc60b959b7724Nicolas Capens void Nucleus::createRet(Value *v) 395894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3963d7c35f224f985f3f4620be2f1bdc60b959b7724Nicolas Capens ::builder->CreateRet(v); 397894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 398894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3993d7c35f224f985f3f4620be2f1bdc60b959b7724Nicolas Capens void Nucleus::createBr(BasicBlock *dest) 400894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4013d7c35f224f985f3f4620be2f1bdc60b959b7724Nicolas Capens ::builder->CreateBr(dest); 402894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 403894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4043d7c35f224f985f3f4620be2f1bdc60b959b7724Nicolas Capens void Nucleus::createCondBr(Value *cond, BasicBlock *ifTrue, BasicBlock *ifFalse) 405894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4063d7c35f224f985f3f4620be2f1bdc60b959b7724Nicolas Capens ::builder->CreateCondBr(cond, ifTrue, ifFalse); 407894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 408894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 409894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createAdd(Value *lhs, Value *rhs) 410894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4111933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateAdd(lhs, rhs)); 412894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 413894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 414894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createSub(Value *lhs, Value *rhs) 415894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4161933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateSub(lhs, rhs)); 417894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 418894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 419894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createMul(Value *lhs, Value *rhs) 420894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4211933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateMul(lhs, rhs)); 422894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 423894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 424894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createUDiv(Value *lhs, Value *rhs) 425894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4261933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateUDiv(lhs, rhs)); 427894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 428894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 429894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createSDiv(Value *lhs, Value *rhs) 430894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4311933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateSDiv(lhs, rhs)); 432894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 433894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 434894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createFAdd(Value *lhs, Value *rhs) 435894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4361933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateFAdd(lhs, rhs)); 437894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 438894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 439894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createFSub(Value *lhs, Value *rhs) 440894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4411933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateFSub(lhs, rhs)); 442894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 443894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 444894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createFMul(Value *lhs, Value *rhs) 445894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4461933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateFMul(lhs, rhs)); 447894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 448894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 449894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createFDiv(Value *lhs, Value *rhs) 450894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4511933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateFDiv(lhs, rhs)); 452894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 453894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 454894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createURem(Value *lhs, Value *rhs) 455894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4561933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateURem(lhs, rhs)); 457894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 458894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 459894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createSRem(Value *lhs, Value *rhs) 460894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4611933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateSRem(lhs, rhs)); 462894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 463894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 464894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createFRem(Value *lhs, Value *rhs) 465894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4661933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateFRem(lhs, rhs)); 467894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 468894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 469894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createShl(Value *lhs, Value *rhs) 470894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4711933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateShl(lhs, rhs)); 472894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 473894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 474894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createLShr(Value *lhs, Value *rhs) 475894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4761933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateLShr(lhs, rhs)); 477894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 478894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 479894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createAShr(Value *lhs, Value *rhs) 480894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4811933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateAShr(lhs, rhs)); 482894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 483894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 484894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createAnd(Value *lhs, Value *rhs) 485894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4861933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateAnd(lhs, rhs)); 487894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 488894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 489894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createOr(Value *lhs, Value *rhs) 490894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4911933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateOr(lhs, rhs)); 492894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 493894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 494894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createXor(Value *lhs, Value *rhs) 495894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4961933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateXor(lhs, rhs)); 497894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 498894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4991933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *Nucleus::createNeg(Value *v) 500894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5011933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateNeg(v)); 502894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 503894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5041933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *Nucleus::createFNeg(Value *v) 505894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5061933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateFNeg(v)); 507894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 508894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5091933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *Nucleus::createNot(Value *v) 510894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5111933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateNot(v)); 512894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 513894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 51401a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens Value *Nucleus::createLoad(Value *ptr, Type *type, bool isVolatile, unsigned int alignment) 515894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 51601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens uintptr_t t = reinterpret_cast<uintptr_t>(type); 51701a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens if(t < EmulatedTypeCount) 51801a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens { 51901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens switch(t) 52001a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens { 52101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens case Type_v2i32: 52201a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens case Type_v4i16: 52301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens case Type_v8i8: 52401a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens case Type_v2f32: 52501a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return createBitCast(createInsertElement(V(llvm::UndefValue::get(llvm::VectorType::get(T(Long::getType()), 2))), createLoad(createBitCast(ptr, Pointer<Long>::getType()), Long::getType(), isVolatile, alignment), 0), T(T(type))); 52601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens case Type_v2i16: 52701a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens case Type_v4i8: 52801a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens if(alignment != 0) // Not a local variable (all vectors are 128-bit). 52901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens { 53001a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens Value *u = V(llvm::UndefValue::get(llvm::VectorType::get(T(Long::getType()), 2))); 53101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens Value *i = V(createLoad(createBitCast(ptr, Pointer<Int>::getType()), Int::getType(), isVolatile, alignment)); 53201a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens i = createZExt(i, Long::getType()); 53301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens Value *v = V(createInsertElement(u, i, 0)); 53401a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return createBitCast(v, T(T(type))); 53501a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens } 53601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens break; 53701a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens default: 53801a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens assert(false); 53901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens } 54001a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens } 54101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens 542fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens assert(ptr->getType()->getContainedType(0) == T(type)); 54301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return V(::builder->Insert(new llvm::LoadInst(ptr, "", isVolatile, alignment))); 544894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 545894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 54601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens Value *Nucleus::createStore(Value *value, Value *ptr, Type *type, bool isVolatile, unsigned int alignment) 547894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 54801a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens uintptr_t t = reinterpret_cast<uintptr_t>(type); 54901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens if(t < EmulatedTypeCount) 55001a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens { 55101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens switch(t) 55201a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens { 55301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens case Type_v2i32: 55401a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens case Type_v4i16: 55501a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens case Type_v8i8: 55601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens case Type_v2f32: 55701a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens createStore(createExtractElement(createBitCast(value, T(llvm::VectorType::get(T(Long::getType()), 2))), Long::getType(), 0), createBitCast(ptr, Pointer<Long>::getType()), Long::getType(), isVolatile, alignment); 55801a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return value; 55901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens case Type_v2i16: 56001a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens case Type_v4i8: 56101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens if(alignment != 0) // Not a local variable (all vectors are 128-bit). 56201a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens { 56301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens createStore(createExtractElement(createBitCast(value, Int4::getType()), Int::getType(), 0), createBitCast(ptr, Pointer<Int>::getType()), Int::getType(), isVolatile, alignment); 56401a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return value; 56501a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens } 56601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens break; 56701a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens default: 56801a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens assert(false); 56901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens } 57001a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens } 57101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens 572fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens assert(ptr->getType()->getContainedType(0) == T(type)); 57301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens ::builder->Insert(new llvm::StoreInst(value, ptr, isVolatile, alignment)); 574b955d5b48bc9a611f1580270fab0ce2f2ffc64a9Nicolas Capens return value; 575894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 576894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 577d294def5b421885b259403efb9b1abddaae3a82cNicolas Capens Value *Nucleus::createGEP(Value *ptr, Type *type, Value *index, bool unsignedIndex) 578894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 57901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens if(sizeof(void*) == 8) 58001a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens { 58101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens if(unsignedIndex) 58201a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens { 58301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens index = createZExt(index, Long::getType()); 58401a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens } 58501a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens else 58601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens { 58701a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens index = createSExt(index, Long::getType()); 58801a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens } 58901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens 59001a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens index = createMul(index, createConstantLong((int64_t)typeSize(type))); 59101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens } 59201a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens else 593d294def5b421885b259403efb9b1abddaae3a82cNicolas Capens { 59401a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens index = createMul(index, createConstantInt((int)typeSize(type))); 595d294def5b421885b259403efb9b1abddaae3a82cNicolas Capens } 596d294def5b421885b259403efb9b1abddaae3a82cNicolas Capens 597fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens assert(ptr->getType()->getContainedType(0) == T(type)); 59801a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return createBitCast(V(::builder->CreateGEP(createBitCast(ptr, T(llvm::PointerType::get(T(Byte::getType()), 0))), index)), T(llvm::PointerType::get(T(type), 0))); 599894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 600894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 60119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Value *Nucleus::createAtomicAdd(Value *ptr, Value *value) 60219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 603fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return V(::builder->CreateAtomicRMW(llvm::AtomicRMWInst::Add, ptr, value, llvm::SequentiallyConsistent)); 60419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 60519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 6061933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *Nucleus::createTrunc(Value *v, Type *destType) 607894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 608fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return V(::builder->CreateTrunc(v, T(destType))); 609894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 610894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 6111933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *Nucleus::createZExt(Value *v, Type *destType) 612894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 613fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return V(::builder->CreateZExt(v, T(destType))); 614894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 615894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 6161933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *Nucleus::createSExt(Value *v, Type *destType) 617894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 618fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return V(::builder->CreateSExt(v, T(destType))); 619894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 620894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 6211933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *Nucleus::createFPToSI(Value *v, Type *destType) 622894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 623fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return V(::builder->CreateFPToSI(v, T(destType))); 624894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 625894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 6261933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *Nucleus::createSIToFP(Value *v, Type *destType) 627894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 628fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return V(::builder->CreateSIToFP(v, T(destType))); 629894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 630894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 6311933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *Nucleus::createFPTrunc(Value *v, Type *destType) 632894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 633fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return V(::builder->CreateFPTrunc(v, T(destType))); 634894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 635894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 6361933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *Nucleus::createFPExt(Value *v, Type *destType) 637894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 638fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return V(::builder->CreateFPExt(v, T(destType))); 639894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 640894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 6411933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *Nucleus::createBitCast(Value *v, Type *destType) 642894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 64301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens // Bitcasts must be between types of the same logical size. But with emulated narrow vectors we need 64401a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens // support for casting between scalars and wide vectors. Emulate them by writing to the stack and 64501a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens // reading back as the destination type. 64601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens if(!v->getType()->isVectorTy() && T(destType)->isVectorTy()) 64701a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens { 64801a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens Value *readAddress = allocateStackVariable(destType); 64901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens Value *writeAddress = createBitCast(readAddress, T(llvm::PointerType::get(v->getType(), 0))); 65001a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens createStore(v, writeAddress, T(v->getType())); 65101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return createLoad(readAddress, destType); 65201a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens } 65301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens else if(v->getType()->isVectorTy() && !T(destType)->isVectorTy()) 65401a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens { 65501a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens Value *writeAddress = allocateStackVariable(T(v->getType())); 65601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens createStore(v, writeAddress, T(v->getType())); 65701a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens Value *readAddress = createBitCast(writeAddress, T(llvm::PointerType::get(T(destType), 0))); 65801a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return createLoad(readAddress, destType); 65901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens } 66001a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens 661fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return V(::builder->CreateBitCast(v, T(destType))); 662894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 663894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 664894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createICmpEQ(Value *lhs, Value *rhs) 665894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 6661933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateICmpEQ(lhs, rhs)); 667894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 668894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 669894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createICmpNE(Value *lhs, Value *rhs) 670894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 6711933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateICmpNE(lhs, rhs)); 672894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 673894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 674894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createICmpUGT(Value *lhs, Value *rhs) 675894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 6761933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateICmpUGT(lhs, rhs)); 677894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 678894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 679894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createICmpUGE(Value *lhs, Value *rhs) 680894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 6811933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateICmpUGE(lhs, rhs)); 682894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 683894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 684894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createICmpULT(Value *lhs, Value *rhs) 685894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 6861933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateICmpULT(lhs, rhs)); 687894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 688894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 689894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createICmpULE(Value *lhs, Value *rhs) 690894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 6911933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateICmpULE(lhs, rhs)); 692894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 693894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 694894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createICmpSGT(Value *lhs, Value *rhs) 695894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 6961933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateICmpSGT(lhs, rhs)); 697894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 698894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 699894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createICmpSGE(Value *lhs, Value *rhs) 700894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 7011933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateICmpSGE(lhs, rhs)); 702894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 703894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 704894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createICmpSLT(Value *lhs, Value *rhs) 705894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 7061933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateICmpSLT(lhs, rhs)); 707894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 708894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 709894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createICmpSLE(Value *lhs, Value *rhs) 710894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 7111933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateICmpSLE(lhs, rhs)); 712894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 713894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 714894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createFCmpOEQ(Value *lhs, Value *rhs) 715894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 7161933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateFCmpOEQ(lhs, rhs)); 717894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 718894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 719894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createFCmpOGT(Value *lhs, Value *rhs) 720894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 7211933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateFCmpOGT(lhs, rhs)); 722894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 723894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 724894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createFCmpOGE(Value *lhs, Value *rhs) 725894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 7261933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateFCmpOGE(lhs, rhs)); 727894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 728894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 729894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createFCmpOLT(Value *lhs, Value *rhs) 730894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 7311933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateFCmpOLT(lhs, rhs)); 732894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 733894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 734894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createFCmpOLE(Value *lhs, Value *rhs) 735894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 7361933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateFCmpOLE(lhs, rhs)); 737894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 738894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 739894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createFCmpONE(Value *lhs, Value *rhs) 740894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 7411933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateFCmpONE(lhs, rhs)); 742894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 743894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 744894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createFCmpORD(Value *lhs, Value *rhs) 745894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 7461933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateFCmpORD(lhs, rhs)); 747894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 748894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 749894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createFCmpUNO(Value *lhs, Value *rhs) 750894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 7511933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateFCmpUNO(lhs, rhs)); 752894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 753894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 754894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createFCmpUEQ(Value *lhs, Value *rhs) 755894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 7561933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateFCmpUEQ(lhs, rhs)); 757894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 758894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 759894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createFCmpUGT(Value *lhs, Value *rhs) 760894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 7611933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateFCmpUGT(lhs, rhs)); 762894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 763894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 764894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createFCmpUGE(Value *lhs, Value *rhs) 765894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 7661933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateFCmpUGE(lhs, rhs)); 767894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 768894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 769894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createFCmpULT(Value *lhs, Value *rhs) 770894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 7711933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateFCmpULT(lhs, rhs)); 772894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 773894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 774894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createFCmpULE(Value *lhs, Value *rhs) 775894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 7761933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateFCmpULE(lhs, rhs)); 777894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 778894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 779894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createFCmpUNE(Value *lhs, Value *rhs) 780894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 7811933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateFCmpULE(lhs, rhs)); 782894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 783894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 784e95d534ac645273b3669ef62046d9aa612468e7eNicolas Capens Value *Nucleus::createExtractElement(Value *vector, Type *type, int index) 785894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 786fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens assert(vector->getType()->getContainedType(0) == T(type)); 7871933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateExtractElement(vector, createConstantInt(index))); 788894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 789894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 790894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createInsertElement(Value *vector, Value *element, int index) 791894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 7921933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateInsertElement(vector, element, createConstantInt(index))); 793894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 794894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 795e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens Value *Nucleus::createShuffleVector(Value *V1, Value *V2, const int *select) 796894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 797e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens int size = llvm::cast<llvm::VectorType>(V1->getType())->getNumElements(); 798e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens const int maxSize = 16; 799e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens llvm::Constant *swizzle[maxSize]; 800e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens assert(size <= maxSize); 801e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens 802e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens for(int i = 0; i < size; i++) 803e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens { 804fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens swizzle[i] = llvm::ConstantInt::get(llvm::Type::getInt32Ty(*::context), select[i]); 805e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens } 806e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens 807e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens llvm::Value *shuffle = llvm::ConstantVector::get(llvm::ArrayRef<llvm::Constant*>(swizzle, size)); 808e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens 809e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens return V(::builder->CreateShuffleVector(V1, V2, shuffle)); 810894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 811894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 812894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *Nucleus::createSelect(Value *C, Value *ifTrue, Value *ifFalse) 813894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 8141933654b62251805d4575b05b6829275b0fe6142Nicolas Capens return V(::builder->CreateSelect(C, ifTrue, ifFalse)); 815894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 816894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 817b98fe5cd1eaa821083d816cf86a20eefe22f57c7Nicolas Capens SwitchCases *Nucleus::createSwitch(Value *control, BasicBlock *defaultBranch, unsigned numCases) 818894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 819b98fe5cd1eaa821083d816cf86a20eefe22f57c7Nicolas Capens return reinterpret_cast<SwitchCases*>(::builder->CreateSwitch(control, defaultBranch, numCases)); 820894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 821894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 822b98fe5cd1eaa821083d816cf86a20eefe22f57c7Nicolas Capens void Nucleus::addSwitchCase(SwitchCases *switchCases, int label, BasicBlock *branch) 823894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 824fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens switchCases->addCase(llvm::ConstantInt::get(llvm::Type::getInt32Ty(*::context), label, true), branch); 825894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 826894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 8273d7c35f224f985f3f4620be2f1bdc60b959b7724Nicolas Capens void Nucleus::createUnreachable() 828894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 8293d7c35f224f985f3f4620be2f1bdc60b959b7724Nicolas Capens ::builder->CreateUnreachable(); 830894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 831894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 832e95d534ac645273b3669ef62046d9aa612468e7eNicolas Capens static Value *createSwizzle4(Value *val, unsigned char select) 833894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 834e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens int swizzle[4] = 835e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens { 836e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens (select >> 0) & 0x03, 837e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens (select >> 2) & 0x03, 838e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens (select >> 4) & 0x03, 839e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens (select >> 6) & 0x03, 840e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens }; 841894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 842e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens return Nucleus::createShuffleVector(val, val, swizzle); 843894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 844894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 845e95d534ac645273b3669ef62046d9aa612468e7eNicolas Capens static Value *createMask4(Value *lhs, Value *rhs, unsigned char select) 846894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 847894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman bool mask[4] = {false, false, false, false}; 848894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 849894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman mask[(select >> 0) & 0x03] = true; 850894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman mask[(select >> 2) & 0x03] = true; 851894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman mask[(select >> 4) & 0x03] = true; 852894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman mask[(select >> 6) & 0x03] = true; 853894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 854e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens int swizzle[4] = 855e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens { 856e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens mask[0] ? 4 : 0, 857e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens mask[1] ? 5 : 1, 858e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens mask[2] ? 6 : 2, 859e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens mask[3] ? 7 : 3, 860e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens }; 861894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 862a29d653e1378c38f41da3d02234ded50437a548aNicolas Capens return Nucleus::createShuffleVector(lhs, rhs, swizzle); 863894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 864894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 865ac2301298a42723d2c88f8749cab434ddd64e82dNicolas Capens Type *Nucleus::getPointerType(Type *ElementType) 866894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 867fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return T(llvm::PointerType::get(T(ElementType), 0)); 868894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 869894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 87013ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens Value *Nucleus::createNullValue(Type *Ty) 871894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 872fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return V(llvm::Constant::getNullValue(T(Ty))); 873894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 874894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 87513ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens Value *Nucleus::createConstantLong(int64_t i) 876894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 877fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return V(llvm::ConstantInt::get(llvm::Type::getInt64Ty(*::context), i, true)); 878894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 879894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 88013ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens Value *Nucleus::createConstantInt(int i) 881894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 882fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return V(llvm::ConstantInt::get(llvm::Type::getInt32Ty(*::context), i, true)); 883894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 884894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 88513ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens Value *Nucleus::createConstantInt(unsigned int i) 886894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 887fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return V(llvm::ConstantInt::get(llvm::Type::getInt32Ty(*::context), i, false)); 888894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 889894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 89013ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens Value *Nucleus::createConstantBool(bool b) 891894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 892fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return V(llvm::ConstantInt::get(llvm::Type::getInt1Ty(*::context), b)); 893894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 894894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 89513ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens Value *Nucleus::createConstantByte(signed char i) 896894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 897fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return V(llvm::ConstantInt::get(llvm::Type::getInt8Ty(*::context), i, true)); 898894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 899894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 90013ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens Value *Nucleus::createConstantByte(unsigned char i) 901894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 902fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return V(llvm::ConstantInt::get(llvm::Type::getInt8Ty(*::context), i, false)); 903894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 904894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 90513ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens Value *Nucleus::createConstantShort(short i) 906894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 907fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return V(llvm::ConstantInt::get(llvm::Type::getInt16Ty(*::context), i, true)); 908894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 909894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 91013ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens Value *Nucleus::createConstantShort(unsigned short i) 911894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 912fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return V(llvm::ConstantInt::get(llvm::Type::getInt16Ty(*::context), i, false)); 913894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 914894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 91513ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens Value *Nucleus::createConstantFloat(float x) 916894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 917fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return V(llvm::ConstantFP::get(T(Float::getType()), x)); 918894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 919894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 92013ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens Value *Nucleus::createNullPointer(Type *Ty) 921894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 922fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return V(llvm::ConstantPointerNull::get(llvm::PointerType::get(T(Ty), 0))); 92313ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens } 92413ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens 92513ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens Value *Nucleus::createConstantVector(const int64_t *constants, Type *type) 92613ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens { 927fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens assert(llvm::isa<llvm::VectorType>(T(type))); 92869674fb1f01c657bfeb5f2cb6389d4a959b973f6Nicolas Capens const int numConstants = elementCount(type); // Number of provided constants for the (emulated) type. 92969674fb1f01c657bfeb5f2cb6389d4a959b973f6Nicolas Capens const int numElements = llvm::cast<llvm::VectorType>(T(type))->getNumElements(); // Number of elements of the underlying vector type. 93069674fb1f01c657bfeb5f2cb6389d4a959b973f6Nicolas Capens assert(numElements <= 16 && numConstants <= numElements); 93113ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens llvm::Constant *constantVector[16]; 93213ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens 93369674fb1f01c657bfeb5f2cb6389d4a959b973f6Nicolas Capens for(int i = 0; i < numElements; i++) 93413ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens { 93569674fb1f01c657bfeb5f2cb6389d4a959b973f6Nicolas Capens constantVector[i] = llvm::ConstantInt::get(T(type)->getContainedType(0), constants[i % numConstants]); 93613ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens } 93713ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens 93869674fb1f01c657bfeb5f2cb6389d4a959b973f6Nicolas Capens return V(llvm::ConstantVector::get(llvm::ArrayRef<llvm::Constant*>(constantVector, numElements))); 939894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 940894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 94113ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens Value *Nucleus::createConstantVector(const double *constants, Type *type) 942894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 943fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens assert(llvm::isa<llvm::VectorType>(T(type))); 94469674fb1f01c657bfeb5f2cb6389d4a959b973f6Nicolas Capens const int numConstants = elementCount(type); // Number of provided constants for the (emulated) type. 94569674fb1f01c657bfeb5f2cb6389d4a959b973f6Nicolas Capens const int numElements = llvm::cast<llvm::VectorType>(T(type))->getNumElements(); // Number of elements of the underlying vector type. 94669674fb1f01c657bfeb5f2cb6389d4a959b973f6Nicolas Capens assert(numElements <= 8 && numConstants <= numElements); 94713ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens llvm::Constant *constantVector[8]; 94813ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens 94969674fb1f01c657bfeb5f2cb6389d4a959b973f6Nicolas Capens for(int i = 0; i < numElements; i++) 95013ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens { 95169674fb1f01c657bfeb5f2cb6389d4a959b973f6Nicolas Capens constantVector[i] = llvm::ConstantFP::get(T(type)->getContainedType(0), constants[i % numConstants]); 95213ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens } 95313ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens 95469674fb1f01c657bfeb5f2cb6389d4a959b973f6Nicolas Capens return V(llvm::ConstantVector::get(llvm::ArrayRef<llvm::Constant*>(constantVector, numElements))); 955894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 956894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 95719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Type *Void::getType() 958894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 959ac2301298a42723d2c88f8749cab434ddd64e82dNicolas Capens return T(llvm::Type::getVoidTy(*::context)); 960894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 961894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 96281f1830d46482cd635f7e7a92c55aec8683c1e55Nicolas Capens Bool::Bool(Argument<Bool> argument) 963894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 96481f1830d46482cd635f7e7a92c55aec8683c1e55Nicolas Capens storeValue(argument.value); 965894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 966894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 967894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Bool::Bool(bool x) 968894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 96966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(Nucleus::createConstantBool(x)); 970894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 971894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 97219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Bool::Bool(RValue<Bool> rhs) 973894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 97466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 975894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 976894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 977894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Bool::Bool(const Bool &rhs) 978894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 97966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 98066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 98166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 982894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 98366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Bool::Bool(const Reference<Bool> &rhs) 98466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 98566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 98666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 987894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 988894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 98996d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Bool> Bool::operator=(RValue<Bool> rhs) 990894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 99166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 992894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 993894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return rhs; 994894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 995894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 99696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Bool> Bool::operator=(const Bool &rhs) 997894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 99866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 99966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 1000894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1001894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(value); 1002894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1003894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 100496d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Bool> Bool::operator=(const Reference<Bool> &rhs) 1005894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 100666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 100766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 100866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 100966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman return RValue<Bool>(value); 1010894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1011894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 101219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator!(RValue<Bool> val) 1013894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1014894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createNot(val.value)); 1015894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1016894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 101719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator&&(RValue<Bool> lhs, RValue<Bool> rhs) 1018894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1019894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createAnd(lhs.value, rhs.value)); 1020894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1021894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 102219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator||(RValue<Bool> lhs, RValue<Bool> rhs) 1023894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1024894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createOr(lhs.value, rhs.value)); 1025894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1026894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 102719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Type *Bool::getType() 1028894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1029ac2301298a42723d2c88f8749cab434ddd64e82dNicolas Capens return T(llvm::Type::getInt1Ty(*::context)); 1030894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1031894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 103281f1830d46482cd635f7e7a92c55aec8683c1e55Nicolas Capens Byte::Byte(Argument<Byte> argument) 1033894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 103481f1830d46482cd635f7e7a92c55aec8683c1e55Nicolas Capens storeValue(argument.value); 1035894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1036894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 103719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Byte::Byte(RValue<Int> cast) 1038894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1039894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *integer = Nucleus::createTrunc(cast.value, Byte::getType()); 1040894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 104166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(integer); 1042894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1043894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 104477dfab49323d39ec681165a837dba5a48d2c2d11Alexis Hetu Byte::Byte(RValue<UInt> cast) 104577dfab49323d39ec681165a837dba5a48d2c2d11Alexis Hetu { 104677dfab49323d39ec681165a837dba5a48d2c2d11Alexis Hetu Value *integer = Nucleus::createTrunc(cast.value, Byte::getType()); 104777dfab49323d39ec681165a837dba5a48d2c2d11Alexis Hetu 104877dfab49323d39ec681165a837dba5a48d2c2d11Alexis Hetu storeValue(integer); 104977dfab49323d39ec681165a837dba5a48d2c2d11Alexis Hetu } 105077dfab49323d39ec681165a837dba5a48d2c2d11Alexis Hetu 105177dfab49323d39ec681165a837dba5a48d2c2d11Alexis Hetu Byte::Byte(RValue<UShort> cast) 105277dfab49323d39ec681165a837dba5a48d2c2d11Alexis Hetu { 105377dfab49323d39ec681165a837dba5a48d2c2d11Alexis Hetu Value *integer = Nucleus::createTrunc(cast.value, Byte::getType()); 105477dfab49323d39ec681165a837dba5a48d2c2d11Alexis Hetu 105577dfab49323d39ec681165a837dba5a48d2c2d11Alexis Hetu storeValue(integer); 105677dfab49323d39ec681165a837dba5a48d2c2d11Alexis Hetu } 105777dfab49323d39ec681165a837dba5a48d2c2d11Alexis Hetu 1058894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Byte::Byte(int x) 1059894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 106066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(Nucleus::createConstantByte((unsigned char)x)); 1061894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1062894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1063894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Byte::Byte(unsigned char x) 1064894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 106566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(Nucleus::createConstantByte(x)); 1066894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1067894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 106819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Byte::Byte(RValue<Byte> rhs) 1069894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 107066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 1071894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1072894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1073894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Byte::Byte(const Byte &rhs) 1074894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 107566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 107666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 107766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 1078894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 107966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Byte::Byte(const Reference<Byte> &rhs) 108066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 108166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 108266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 1083894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1084894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 108596d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Byte> Byte::operator=(RValue<Byte> rhs) 1086894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 108766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 1088894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1089894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return rhs; 1090894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1091894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 109296445fe36c80c3cb5443a29be673bedb7ad2fb2fNicolas Capens RValue<Byte> Byte::operator=(const Byte &rhs) 1093894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 109466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 109566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 1096894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1097894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Byte>(value); 1098894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1099894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 110096d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Byte> Byte::operator=(const Reference<Byte> &rhs) 1101894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 110266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 110366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 110466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 110566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman return RValue<Byte>(value); 1106894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1107894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 110819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Byte> operator+(RValue<Byte> lhs, RValue<Byte> rhs) 1109894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1110894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Byte>(Nucleus::createAdd(lhs.value, rhs.value)); 1111894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1112894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 111319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Byte> operator-(RValue<Byte> lhs, RValue<Byte> rhs) 1114894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1115894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Byte>(Nucleus::createSub(lhs.value, rhs.value)); 1116894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1117894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 111819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Byte> operator*(RValue<Byte> lhs, RValue<Byte> rhs) 1119894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1120894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Byte>(Nucleus::createMul(lhs.value, rhs.value)); 1121894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1122894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 112319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Byte> operator/(RValue<Byte> lhs, RValue<Byte> rhs) 1124894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1125894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Byte>(Nucleus::createUDiv(lhs.value, rhs.value)); 1126894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1127894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 112819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Byte> operator%(RValue<Byte> lhs, RValue<Byte> rhs) 1129894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1130894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Byte>(Nucleus::createURem(lhs.value, rhs.value)); 1131894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1132894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 113319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Byte> operator&(RValue<Byte> lhs, RValue<Byte> rhs) 1134894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1135894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Byte>(Nucleus::createAnd(lhs.value, rhs.value)); 1136894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1137894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 113819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Byte> operator|(RValue<Byte> lhs, RValue<Byte> rhs) 1139894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1140894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Byte>(Nucleus::createOr(lhs.value, rhs.value)); 1141894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1142894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 114319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Byte> operator^(RValue<Byte> lhs, RValue<Byte> rhs) 1144894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1145894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Byte>(Nucleus::createXor(lhs.value, rhs.value)); 1146894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1147894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 114819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Byte> operator<<(RValue<Byte> lhs, RValue<Byte> rhs) 1149894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1150894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Byte>(Nucleus::createShl(lhs.value, rhs.value)); 1151894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1152894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 115319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Byte> operator>>(RValue<Byte> lhs, RValue<Byte> rhs) 1154894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1155894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Byte>(Nucleus::createLShr(lhs.value, rhs.value)); 1156894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1157894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 115896d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Byte> operator+=(Byte &lhs, RValue<Byte> rhs) 1159894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1160894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs + rhs; 1161894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1162894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 116396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Byte> operator-=(Byte &lhs, RValue<Byte> rhs) 1164894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1165894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs - rhs; 1166894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1167894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 116896d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Byte> operator*=(Byte &lhs, RValue<Byte> rhs) 1169894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1170894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs * rhs; 1171894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1172894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 117396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Byte> operator/=(Byte &lhs, RValue<Byte> rhs) 1174894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1175894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs / rhs; 1176894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1177894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 117896d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Byte> operator%=(Byte &lhs, RValue<Byte> rhs) 1179894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1180894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs % rhs; 1181894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1182894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 118396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Byte> operator&=(Byte &lhs, RValue<Byte> rhs) 1184894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1185894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs & rhs; 1186894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1187894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 118896d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Byte> operator|=(Byte &lhs, RValue<Byte> rhs) 1189894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1190894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs | rhs; 1191894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1192894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 119396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Byte> operator^=(Byte &lhs, RValue<Byte> rhs) 1194894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1195894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs ^ rhs; 1196894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1197894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 119896d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Byte> operator<<=(Byte &lhs, RValue<Byte> rhs) 1199894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1200894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs << rhs; 1201894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1202894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 120396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Byte> operator>>=(Byte &lhs, RValue<Byte> rhs) 1204894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1205894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs >> rhs; 1206894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1207894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 120819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Byte> operator+(RValue<Byte> val) 1209894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1210894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return val; 1211894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1212894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 121319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Byte> operator-(RValue<Byte> val) 1214894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1215894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Byte>(Nucleus::createNeg(val.value)); 1216894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1217894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 121819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Byte> operator~(RValue<Byte> val) 1219894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1220894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Byte>(Nucleus::createNot(val.value)); 1221894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1222894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 122396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Byte> operator++(Byte &val, int) // Post-increment 1224894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1225894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman RValue<Byte> res = val; 1226894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 12271933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *inc = Nucleus::createAdd(res.value, V(Nucleus::createConstantByte((unsigned char)1))); 122866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman val.storeValue(inc); 1229894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1230894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return res; 1231894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1232894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 123396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens const Byte &operator++(Byte &val) // Pre-increment 1234894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 12351933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *inc = Nucleus::createAdd(val.loadValue(), V(Nucleus::createConstantByte((unsigned char)1))); 123666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman val.storeValue(inc); 1237894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1238894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return val; 1239894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1240894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 124196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Byte> operator--(Byte &val, int) // Post-decrement 1242894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1243894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman RValue<Byte> res = val; 1244894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 12451933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *inc = Nucleus::createSub(res.value, V(Nucleus::createConstantByte((unsigned char)1))); 124666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman val.storeValue(inc); 1247894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1248894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return res; 1249894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1250894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 125196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens const Byte &operator--(Byte &val) // Pre-decrement 1252894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 12531933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *inc = Nucleus::createSub(val.loadValue(), V(Nucleus::createConstantByte((unsigned char)1))); 125466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman val.storeValue(inc); 1255894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1256894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return val; 1257894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1258894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 125919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator<(RValue<Byte> lhs, RValue<Byte> rhs) 1260894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1261894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpULT(lhs.value, rhs.value)); 1262894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1263894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 126419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator<=(RValue<Byte> lhs, RValue<Byte> rhs) 1265894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1266894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpULE(lhs.value, rhs.value)); 1267894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1268894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 126919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator>(RValue<Byte> lhs, RValue<Byte> rhs) 1270894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1271894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpUGT(lhs.value, rhs.value)); 1272894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1273894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 127419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator>=(RValue<Byte> lhs, RValue<Byte> rhs) 1275894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1276894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpUGE(lhs.value, rhs.value)); 1277894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1278894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 127919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator!=(RValue<Byte> lhs, RValue<Byte> rhs) 1280894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1281894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value)); 1282894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1283894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 128419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator==(RValue<Byte> lhs, RValue<Byte> rhs) 1285894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1286894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value)); 1287894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1288894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 128919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Type *Byte::getType() 1290894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1291ac2301298a42723d2c88f8749cab434ddd64e82dNicolas Capens return T(llvm::Type::getInt8Ty(*::context)); 1292894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1293894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 129481f1830d46482cd635f7e7a92c55aec8683c1e55Nicolas Capens SByte::SByte(Argument<SByte> argument) 1295894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 129681f1830d46482cd635f7e7a92c55aec8683c1e55Nicolas Capens storeValue(argument.value); 1297894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1298894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 129977dfab49323d39ec681165a837dba5a48d2c2d11Alexis Hetu SByte::SByte(RValue<Int> cast) 130077dfab49323d39ec681165a837dba5a48d2c2d11Alexis Hetu { 130177dfab49323d39ec681165a837dba5a48d2c2d11Alexis Hetu Value *integer = Nucleus::createTrunc(cast.value, SByte::getType()); 130277dfab49323d39ec681165a837dba5a48d2c2d11Alexis Hetu 130377dfab49323d39ec681165a837dba5a48d2c2d11Alexis Hetu storeValue(integer); 130477dfab49323d39ec681165a837dba5a48d2c2d11Alexis Hetu } 130577dfab49323d39ec681165a837dba5a48d2c2d11Alexis Hetu 130677dfab49323d39ec681165a837dba5a48d2c2d11Alexis Hetu SByte::SByte(RValue<Short> cast) 130777dfab49323d39ec681165a837dba5a48d2c2d11Alexis Hetu { 130877dfab49323d39ec681165a837dba5a48d2c2d11Alexis Hetu Value *integer = Nucleus::createTrunc(cast.value, SByte::getType()); 130977dfab49323d39ec681165a837dba5a48d2c2d11Alexis Hetu 131077dfab49323d39ec681165a837dba5a48d2c2d11Alexis Hetu storeValue(integer); 131177dfab49323d39ec681165a837dba5a48d2c2d11Alexis Hetu } 131277dfab49323d39ec681165a837dba5a48d2c2d11Alexis Hetu 1313894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SByte::SByte(signed char x) 1314894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 131566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(Nucleus::createConstantByte(x)); 1316894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1317894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 131819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman SByte::SByte(RValue<SByte> rhs) 1319894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 132066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 1321894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1322894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1323894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SByte::SByte(const SByte &rhs) 1324894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 132566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 132666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 132766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 1328894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 132966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman SByte::SByte(const Reference<SByte> &rhs) 133066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 133166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 133266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 1333894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1334894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 133596d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<SByte> SByte::operator=(RValue<SByte> rhs) 1336894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 133766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 1338894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1339894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return rhs; 1340894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1341894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 134296d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<SByte> SByte::operator=(const SByte &rhs) 1343894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 134466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 134566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 1346894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1347894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<SByte>(value); 1348894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1349894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 135096d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<SByte> SByte::operator=(const Reference<SByte> &rhs) 1351894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 135266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 135366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 135466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 135566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman return RValue<SByte>(value); 1356894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1357894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 135819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<SByte> operator+(RValue<SByte> lhs, RValue<SByte> rhs) 1359894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1360894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<SByte>(Nucleus::createAdd(lhs.value, rhs.value)); 1361894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1362894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 136319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<SByte> operator-(RValue<SByte> lhs, RValue<SByte> rhs) 1364894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1365894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<SByte>(Nucleus::createSub(lhs.value, rhs.value)); 1366894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1367894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 136819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<SByte> operator*(RValue<SByte> lhs, RValue<SByte> rhs) 1369894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1370894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<SByte>(Nucleus::createMul(lhs.value, rhs.value)); 1371894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1372894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 137319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<SByte> operator/(RValue<SByte> lhs, RValue<SByte> rhs) 1374894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1375894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<SByte>(Nucleus::createSDiv(lhs.value, rhs.value)); 1376894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1377894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 137819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<SByte> operator%(RValue<SByte> lhs, RValue<SByte> rhs) 1379894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1380894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<SByte>(Nucleus::createSRem(lhs.value, rhs.value)); 1381894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1382894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 138319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<SByte> operator&(RValue<SByte> lhs, RValue<SByte> rhs) 1384894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1385894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<SByte>(Nucleus::createAnd(lhs.value, rhs.value)); 1386894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1387894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 138819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<SByte> operator|(RValue<SByte> lhs, RValue<SByte> rhs) 1389894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1390894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<SByte>(Nucleus::createOr(lhs.value, rhs.value)); 1391894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1392894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 139319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<SByte> operator^(RValue<SByte> lhs, RValue<SByte> rhs) 1394894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1395894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<SByte>(Nucleus::createXor(lhs.value, rhs.value)); 1396894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1397894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 139819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<SByte> operator<<(RValue<SByte> lhs, RValue<SByte> rhs) 1399894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1400894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<SByte>(Nucleus::createShl(lhs.value, rhs.value)); 1401894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1402894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 140319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<SByte> operator>>(RValue<SByte> lhs, RValue<SByte> rhs) 1404894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1405894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<SByte>(Nucleus::createAShr(lhs.value, rhs.value)); 1406894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1407894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 140896d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<SByte> operator+=(SByte &lhs, RValue<SByte> rhs) 1409894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1410894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs + rhs; 1411894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1412894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 141396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<SByte> operator-=(SByte &lhs, RValue<SByte> rhs) 1414894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1415894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs - rhs; 1416894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1417894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 141896d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<SByte> operator*=(SByte &lhs, RValue<SByte> rhs) 1419894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1420894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs * rhs; 1421894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1422894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 142396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<SByte> operator/=(SByte &lhs, RValue<SByte> rhs) 1424894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1425894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs / rhs; 1426894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1427894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 142896d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<SByte> operator%=(SByte &lhs, RValue<SByte> rhs) 1429894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1430894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs % rhs; 1431894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1432894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 143396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<SByte> operator&=(SByte &lhs, RValue<SByte> rhs) 1434894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1435894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs & rhs; 1436894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1437894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 143896d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<SByte> operator|=(SByte &lhs, RValue<SByte> rhs) 1439894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1440894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs | rhs; 1441894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1442894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 144396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<SByte> operator^=(SByte &lhs, RValue<SByte> rhs) 1444894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1445894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs ^ rhs; 1446894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1447894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 144896d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<SByte> operator<<=(SByte &lhs, RValue<SByte> rhs) 1449894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1450894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs << rhs; 1451894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1452894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 145396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<SByte> operator>>=(SByte &lhs, RValue<SByte> rhs) 1454894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1455894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs >> rhs; 1456894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1457894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 145819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<SByte> operator+(RValue<SByte> val) 1459894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1460894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return val; 1461894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1462894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 146319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<SByte> operator-(RValue<SByte> val) 1464894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1465894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<SByte>(Nucleus::createNeg(val.value)); 1466894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1467894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 146819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<SByte> operator~(RValue<SByte> val) 1469894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1470894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<SByte>(Nucleus::createNot(val.value)); 1471894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1472894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 147396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<SByte> operator++(SByte &val, int) // Post-increment 1474894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1475894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman RValue<SByte> res = val; 1476894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 14771933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *inc = Nucleus::createAdd(res.value, V(Nucleus::createConstantByte((signed char)1))); 147866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman val.storeValue(inc); 1479894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1480894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return res; 1481894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1482894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 148396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens const SByte &operator++(SByte &val) // Pre-increment 1484894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 14851933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *inc = Nucleus::createAdd(val.loadValue(), V(Nucleus::createConstantByte((signed char)1))); 148666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman val.storeValue(inc); 1487894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1488894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return val; 1489894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1490894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 149196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<SByte> operator--(SByte &val, int) // Post-decrement 1492894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1493894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman RValue<SByte> res = val; 1494894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 14951933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *inc = Nucleus::createSub(res.value, V(Nucleus::createConstantByte((signed char)1))); 149666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman val.storeValue(inc); 1497894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1498894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return res; 1499894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1500894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 150196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens const SByte &operator--(SByte &val) // Pre-decrement 1502894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 15031933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *inc = Nucleus::createSub(val.loadValue(), V(Nucleus::createConstantByte((signed char)1))); 150466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman val.storeValue(inc); 1505894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1506894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return val; 1507894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1508894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 150919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator<(RValue<SByte> lhs, RValue<SByte> rhs) 1510894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1511894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpSLT(lhs.value, rhs.value)); 1512894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1513894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 151419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator<=(RValue<SByte> lhs, RValue<SByte> rhs) 1515894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1516894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpSLE(lhs.value, rhs.value)); 1517894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1518894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 151919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator>(RValue<SByte> lhs, RValue<SByte> rhs) 1520894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1521894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpSGT(lhs.value, rhs.value)); 1522894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1523894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 152419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator>=(RValue<SByte> lhs, RValue<SByte> rhs) 1525894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1526894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpSGE(lhs.value, rhs.value)); 1527894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1528894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 152919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator!=(RValue<SByte> lhs, RValue<SByte> rhs) 1530894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1531894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value)); 1532894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1533894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 153419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator==(RValue<SByte> lhs, RValue<SByte> rhs) 1535894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1536894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value)); 1537894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1538894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 153919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Type *SByte::getType() 1540894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1541ac2301298a42723d2c88f8749cab434ddd64e82dNicolas Capens return T(llvm::Type::getInt8Ty(*::context)); 1542894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1543894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 154481f1830d46482cd635f7e7a92c55aec8683c1e55Nicolas Capens Short::Short(Argument<Short> argument) 1545894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 154681f1830d46482cd635f7e7a92c55aec8683c1e55Nicolas Capens storeValue(argument.value); 1547894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1548894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 154919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Short::Short(RValue<Int> cast) 1550894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1551894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *integer = Nucleus::createTrunc(cast.value, Short::getType()); 1552894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 155366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(integer); 1554894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1555894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1556894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Short::Short(short x) 1557894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 155866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(Nucleus::createConstantShort(x)); 1559894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1560894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 156119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Short::Short(RValue<Short> rhs) 1562894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 156366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 1564894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1565894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1566894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Short::Short(const Short &rhs) 1567894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 156866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 156966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 157066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 1571894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 157266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Short::Short(const Reference<Short> &rhs) 157366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 157466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 157566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 1576894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1577894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 157896d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Short> Short::operator=(RValue<Short> rhs) 1579894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 158066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 1581894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1582894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return rhs; 1583894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1584894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 158596d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Short> Short::operator=(const Short &rhs) 1586894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 158766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 158866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 1589894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1590894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Short>(value); 1591894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1592894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 159396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Short> Short::operator=(const Reference<Short> &rhs) 1594894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 159566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 159666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 159766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 159866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman return RValue<Short>(value); 1599894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1600894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 160119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short> operator+(RValue<Short> lhs, RValue<Short> rhs) 1602894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1603894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Short>(Nucleus::createAdd(lhs.value, rhs.value)); 1604894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1605894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 160619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short> operator-(RValue<Short> lhs, RValue<Short> rhs) 1607894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1608894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Short>(Nucleus::createSub(lhs.value, rhs.value)); 1609894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1610894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 161119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short> operator*(RValue<Short> lhs, RValue<Short> rhs) 1612894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1613894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Short>(Nucleus::createMul(lhs.value, rhs.value)); 1614894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1615894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 161619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short> operator/(RValue<Short> lhs, RValue<Short> rhs) 1617894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1618894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Short>(Nucleus::createSDiv(lhs.value, rhs.value)); 1619894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1620894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 162119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short> operator%(RValue<Short> lhs, RValue<Short> rhs) 1622894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1623894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Short>(Nucleus::createSRem(lhs.value, rhs.value)); 1624894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1625894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 162619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short> operator&(RValue<Short> lhs, RValue<Short> rhs) 1627894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1628894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Short>(Nucleus::createAnd(lhs.value, rhs.value)); 1629894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1630894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 163119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short> operator|(RValue<Short> lhs, RValue<Short> rhs) 1632894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1633894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Short>(Nucleus::createOr(lhs.value, rhs.value)); 1634894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1635894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 163619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short> operator^(RValue<Short> lhs, RValue<Short> rhs) 1637894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1638894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Short>(Nucleus::createXor(lhs.value, rhs.value)); 1639894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1640894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 164119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short> operator<<(RValue<Short> lhs, RValue<Short> rhs) 1642894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1643894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Short>(Nucleus::createShl(lhs.value, rhs.value)); 1644894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1645894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 164619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short> operator>>(RValue<Short> lhs, RValue<Short> rhs) 1647894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1648894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Short>(Nucleus::createAShr(lhs.value, rhs.value)); 1649894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1650894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 165196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Short> operator+=(Short &lhs, RValue<Short> rhs) 1652894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1653894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs + rhs; 1654894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1655894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 165696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Short> operator-=(Short &lhs, RValue<Short> rhs) 1657894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1658894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs - rhs; 1659894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1660894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 166196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Short> operator*=(Short &lhs, RValue<Short> rhs) 1662894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1663894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs * rhs; 1664894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1665894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 166696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Short> operator/=(Short &lhs, RValue<Short> rhs) 1667894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1668894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs / rhs; 1669894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1670894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 167196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Short> operator%=(Short &lhs, RValue<Short> rhs) 1672894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1673894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs % rhs; 1674894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1675894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 167696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Short> operator&=(Short &lhs, RValue<Short> rhs) 1677894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1678894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs & rhs; 1679894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1680894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 168196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Short> operator|=(Short &lhs, RValue<Short> rhs) 1682894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1683894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs | rhs; 1684894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1685894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 168696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Short> operator^=(Short &lhs, RValue<Short> rhs) 1687894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1688894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs ^ rhs; 1689894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1690894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 169196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Short> operator<<=(Short &lhs, RValue<Short> rhs) 1692894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1693894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs << rhs; 1694894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1695894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 169696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Short> operator>>=(Short &lhs, RValue<Short> rhs) 1697894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1698894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs >> rhs; 1699894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1700894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 170119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short> operator+(RValue<Short> val) 1702894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1703894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return val; 1704894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1705894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 170619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short> operator-(RValue<Short> val) 1707894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1708894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Short>(Nucleus::createNeg(val.value)); 1709894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1710894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 171119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short> operator~(RValue<Short> val) 1712894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1713894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Short>(Nucleus::createNot(val.value)); 1714894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1715894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 171696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Short> operator++(Short &val, int) // Post-increment 1717894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1718894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman RValue<Short> res = val; 1719894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 17201933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *inc = Nucleus::createAdd(res.value, V(Nucleus::createConstantShort((short)1))); 172166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman val.storeValue(inc); 1722894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1723894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return res; 1724894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1725894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 172696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens const Short &operator++(Short &val) // Pre-increment 1727894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 17281933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *inc = Nucleus::createAdd(val.loadValue(), V(Nucleus::createConstantShort((short)1))); 172966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman val.storeValue(inc); 1730894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1731894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return val; 1732894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1733894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 173496d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Short> operator--(Short &val, int) // Post-decrement 1735894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1736894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman RValue<Short> res = val; 1737894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 17381933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *inc = Nucleus::createSub(res.value, V(Nucleus::createConstantShort((short)1))); 173966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman val.storeValue(inc); 1740894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1741894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return res; 1742894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1743894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 174496d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens const Short &operator--(Short &val) // Pre-decrement 1745894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 17461933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *inc = Nucleus::createSub(val.loadValue(), V(Nucleus::createConstantShort((short)1))); 174766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman val.storeValue(inc); 1748894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1749894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return val; 1750894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1751894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 175219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator<(RValue<Short> lhs, RValue<Short> rhs) 1753894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1754894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpSLT(lhs.value, rhs.value)); 1755894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1756894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 175719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator<=(RValue<Short> lhs, RValue<Short> rhs) 1758894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1759894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpSLE(lhs.value, rhs.value)); 1760894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1761894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 176219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator>(RValue<Short> lhs, RValue<Short> rhs) 1763894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1764894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpSGT(lhs.value, rhs.value)); 1765894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1766894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 176719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator>=(RValue<Short> lhs, RValue<Short> rhs) 1768894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1769894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpSGE(lhs.value, rhs.value)); 1770894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1771894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 177219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator!=(RValue<Short> lhs, RValue<Short> rhs) 1773894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1774894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value)); 1775894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1776894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 177719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator==(RValue<Short> lhs, RValue<Short> rhs) 1778894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1779894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value)); 1780894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1781894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 178219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Type *Short::getType() 1783894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1784ac2301298a42723d2c88f8749cab434ddd64e82dNicolas Capens return T(llvm::Type::getInt16Ty(*::context)); 1785894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1786894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 178781f1830d46482cd635f7e7a92c55aec8683c1e55Nicolas Capens UShort::UShort(Argument<UShort> argument) 1788894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 178981f1830d46482cd635f7e7a92c55aec8683c1e55Nicolas Capens storeValue(argument.value); 1790894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1791894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 179277dfab49323d39ec681165a837dba5a48d2c2d11Alexis Hetu UShort::UShort(RValue<UInt> cast) 179377dfab49323d39ec681165a837dba5a48d2c2d11Alexis Hetu { 179477dfab49323d39ec681165a837dba5a48d2c2d11Alexis Hetu Value *integer = Nucleus::createTrunc(cast.value, UShort::getType()); 179577dfab49323d39ec681165a837dba5a48d2c2d11Alexis Hetu 179677dfab49323d39ec681165a837dba5a48d2c2d11Alexis Hetu storeValue(integer); 179777dfab49323d39ec681165a837dba5a48d2c2d11Alexis Hetu } 179877dfab49323d39ec681165a837dba5a48d2c2d11Alexis Hetu 179975b650f0e501750ae0ba66a435741731905dffc1Alexis Hetu UShort::UShort(RValue<Int> cast) 180075b650f0e501750ae0ba66a435741731905dffc1Alexis Hetu { 180175b650f0e501750ae0ba66a435741731905dffc1Alexis Hetu Value *integer = Nucleus::createTrunc(cast.value, UShort::getType()); 180275b650f0e501750ae0ba66a435741731905dffc1Alexis Hetu 180375b650f0e501750ae0ba66a435741731905dffc1Alexis Hetu storeValue(integer); 180475b650f0e501750ae0ba66a435741731905dffc1Alexis Hetu } 180575b650f0e501750ae0ba66a435741731905dffc1Alexis Hetu 1806894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman UShort::UShort(unsigned short x) 1807894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 180866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(Nucleus::createConstantShort(x)); 1809894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1810894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 181119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman UShort::UShort(RValue<UShort> rhs) 1812894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 181366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 1814894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1815894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1816894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman UShort::UShort(const UShort &rhs) 1817894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 181866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 181966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 182066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 1821894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 182266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman UShort::UShort(const Reference<UShort> &rhs) 182366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 182466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 182566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 1826894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1827894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 182896d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UShort> UShort::operator=(RValue<UShort> rhs) 1829894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 183066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 1831894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1832894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return rhs; 1833894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1834894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 183596d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UShort> UShort::operator=(const UShort &rhs) 1836894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 183766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 183866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 1839894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1840894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UShort>(value); 1841894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1842894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 184396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UShort> UShort::operator=(const Reference<UShort> &rhs) 1844894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 184566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 184666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 184766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 184866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman return RValue<UShort>(value); 1849894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1850894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 185119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort> operator+(RValue<UShort> lhs, RValue<UShort> rhs) 1852894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1853894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UShort>(Nucleus::createAdd(lhs.value, rhs.value)); 1854894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1855894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 185619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort> operator-(RValue<UShort> lhs, RValue<UShort> rhs) 1857894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1858894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UShort>(Nucleus::createSub(lhs.value, rhs.value)); 1859894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1860894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 186119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort> operator*(RValue<UShort> lhs, RValue<UShort> rhs) 1862894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1863894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UShort>(Nucleus::createMul(lhs.value, rhs.value)); 1864894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1865894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 186619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort> operator/(RValue<UShort> lhs, RValue<UShort> rhs) 1867894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1868894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UShort>(Nucleus::createUDiv(lhs.value, rhs.value)); 1869894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1870894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 187119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort> operator%(RValue<UShort> lhs, RValue<UShort> rhs) 1872894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1873894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UShort>(Nucleus::createURem(lhs.value, rhs.value)); 1874894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1875894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 187619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort> operator&(RValue<UShort> lhs, RValue<UShort> rhs) 1877894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1878894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UShort>(Nucleus::createAnd(lhs.value, rhs.value)); 1879894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1880894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 188119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort> operator|(RValue<UShort> lhs, RValue<UShort> rhs) 1882894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1883894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UShort>(Nucleus::createOr(lhs.value, rhs.value)); 1884894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1885894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 188619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort> operator^(RValue<UShort> lhs, RValue<UShort> rhs) 1887894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1888894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UShort>(Nucleus::createXor(lhs.value, rhs.value)); 1889894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1890894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 189119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort> operator<<(RValue<UShort> lhs, RValue<UShort> rhs) 1892894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1893894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UShort>(Nucleus::createShl(lhs.value, rhs.value)); 1894894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1895894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 189619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort> operator>>(RValue<UShort> lhs, RValue<UShort> rhs) 1897894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1898894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UShort>(Nucleus::createLShr(lhs.value, rhs.value)); 1899894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1900894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 190196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UShort> operator+=(UShort &lhs, RValue<UShort> rhs) 1902894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1903894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs + rhs; 1904894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1905894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 190696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UShort> operator-=(UShort &lhs, RValue<UShort> rhs) 1907894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1908894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs - rhs; 1909894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1910894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 191196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UShort> operator*=(UShort &lhs, RValue<UShort> rhs) 1912894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1913894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs * rhs; 1914894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1915894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 191696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UShort> operator/=(UShort &lhs, RValue<UShort> rhs) 1917894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1918894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs / rhs; 1919894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1920894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 192196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UShort> operator%=(UShort &lhs, RValue<UShort> rhs) 1922894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1923894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs % rhs; 1924894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1925894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 192696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UShort> operator&=(UShort &lhs, RValue<UShort> rhs) 1927894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1928894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs & rhs; 1929894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1930894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 193196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UShort> operator|=(UShort &lhs, RValue<UShort> rhs) 1932894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1933894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs | rhs; 1934894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1935894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 193696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UShort> operator^=(UShort &lhs, RValue<UShort> rhs) 1937894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1938894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs ^ rhs; 1939894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1940894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 194196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UShort> operator<<=(UShort &lhs, RValue<UShort> rhs) 1942894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1943894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs << rhs; 1944894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1945894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 194696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UShort> operator>>=(UShort &lhs, RValue<UShort> rhs) 1947894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1948894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs >> rhs; 1949894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1950894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 195119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort> operator+(RValue<UShort> val) 1952894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1953894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return val; 1954894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1955894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 195619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort> operator-(RValue<UShort> val) 1957894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1958894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UShort>(Nucleus::createNeg(val.value)); 1959894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1960894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 196119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort> operator~(RValue<UShort> val) 1962894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1963894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UShort>(Nucleus::createNot(val.value)); 1964894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1965894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 196696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UShort> operator++(UShort &val, int) // Post-increment 1967894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1968894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman RValue<UShort> res = val; 1969894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 19701933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *inc = Nucleus::createAdd(res.value, V(Nucleus::createConstantShort((unsigned short)1))); 197166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman val.storeValue(inc); 1972894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1973894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return res; 1974894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1975894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 197696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens const UShort &operator++(UShort &val) // Pre-increment 1977894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 19781933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *inc = Nucleus::createAdd(val.loadValue(), V(Nucleus::createConstantShort((unsigned short)1))); 197966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman val.storeValue(inc); 1980894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1981894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return val; 1982894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1983894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 198496d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UShort> operator--(UShort &val, int) // Post-decrement 1985894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 1986894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman RValue<UShort> res = val; 1987894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 19881933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *inc = Nucleus::createSub(res.value, V(Nucleus::createConstantShort((unsigned short)1))); 198966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman val.storeValue(inc); 1990894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1991894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return res; 1992894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1993894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 199496d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens const UShort &operator--(UShort &val) // Pre-decrement 1995894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 19961933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *inc = Nucleus::createSub(val.loadValue(), V(Nucleus::createConstantShort((unsigned short)1))); 199766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman val.storeValue(inc); 1998894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1999894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return val; 2000894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2001894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 200219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator<(RValue<UShort> lhs, RValue<UShort> rhs) 2003894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2004894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpULT(lhs.value, rhs.value)); 2005894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2006894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 200719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator<=(RValue<UShort> lhs, RValue<UShort> rhs) 2008894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2009894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpULE(lhs.value, rhs.value)); 2010894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2011894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 201219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator>(RValue<UShort> lhs, RValue<UShort> rhs) 2013894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2014894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpUGT(lhs.value, rhs.value)); 2015894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2016894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 201719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator>=(RValue<UShort> lhs, RValue<UShort> rhs) 2018894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2019894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpUGE(lhs.value, rhs.value)); 2020894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2021894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 202219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator!=(RValue<UShort> lhs, RValue<UShort> rhs) 2023894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2024894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value)); 2025894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2026894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 202719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator==(RValue<UShort> lhs, RValue<UShort> rhs) 2028894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2029894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value)); 2030894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2031894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 203219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Type *UShort::getType() 2033894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2034ac2301298a42723d2c88f8749cab434ddd64e82dNicolas Capens return T(llvm::Type::getInt16Ty(*::context)); 2035894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2036894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 203716b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens Byte4::Byte4(RValue<Byte8> cast) 203816b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens { 203901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens storeValue(Nucleus::createBitCast(cast.value, getType())); 204016b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens } 204116b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens 204216b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens Byte4::Byte4(const Reference<Byte4> &rhs) 204316b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens { 204416b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens Value *value = rhs.loadValue(); 204516b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens storeValue(value); 204616b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens } 204716b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens 204819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Type *Byte4::getType() 2049894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2050fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return T(Type_v4i8); 2051894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2052894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 205319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Type *SByte4::getType() 2054894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2055fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return T(Type_v4i8); 2056894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2057894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 20583bbc5e16af2975cf3903ef47a21ed7d75d0874d9Nicolas Capens 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) 2059894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 206013ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens int64_t constantVector[8] = {x0, x1, x2, x3, x4, x5, x6, x7}; 206101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens storeValue(Nucleus::createConstantVector(constantVector, getType())); 2062894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2063894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 206419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Byte8::Byte8(RValue<Byte8> rhs) 2065894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 206666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 2067894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2068894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 2069894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Byte8::Byte8(const Byte8 &rhs) 2070894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 207166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 207266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 207366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 207466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 207566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Byte8::Byte8(const Reference<Byte8> &rhs) 207666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 207766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 207866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 2079894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2080894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 208196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Byte8> Byte8::operator=(RValue<Byte8> rhs) 2082894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 208366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 2084894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 2085894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return rhs; 2086894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2087894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 208896d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Byte8> Byte8::operator=(const Byte8 &rhs) 2089894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 209066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 209166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 209266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 209366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman return RValue<Byte8>(value); 209466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 209566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 209696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Byte8> Byte8::operator=(const Reference<Byte8> &rhs) 209766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 209866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 209966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 2100894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 2101894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Byte8>(value); 2102894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2103894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 210419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Byte8> operator+(RValue<Byte8> lhs, RValue<Byte8> rhs) 2105894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 210601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<Byte8>(Nucleus::createAdd(lhs.value, rhs.value)); 2107894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2108894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 210919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Byte8> operator-(RValue<Byte8> lhs, RValue<Byte8> rhs) 2110894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 211101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<Byte8>(Nucleus::createSub(lhs.value, rhs.value)); 2112894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2113894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 211419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// RValue<Byte8> operator*(RValue<Byte8> lhs, RValue<Byte8> rhs) 211519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 211619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return RValue<Byte8>(Nucleus::createMul(lhs.value, rhs.value)); 211719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 2118894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 211919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// RValue<Byte8> operator/(RValue<Byte8> lhs, RValue<Byte8> rhs) 212019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 212119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return RValue<Byte8>(Nucleus::createUDiv(lhs.value, rhs.value)); 212219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 2123894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 212419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// RValue<Byte8> operator%(RValue<Byte8> lhs, RValue<Byte8> rhs) 212519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 212619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return RValue<Byte8>(Nucleus::createURem(lhs.value, rhs.value)); 212719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 2128894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 212919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Byte8> operator&(RValue<Byte8> lhs, RValue<Byte8> rhs) 2130894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 213101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<Byte8>(Nucleus::createAnd(lhs.value, rhs.value)); 2132894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2133894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 213419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Byte8> operator|(RValue<Byte8> lhs, RValue<Byte8> rhs) 2135894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 213601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<Byte8>(Nucleus::createOr(lhs.value, rhs.value)); 2137894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2138894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 213919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Byte8> operator^(RValue<Byte8> lhs, RValue<Byte8> rhs) 2140894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 214101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<Byte8>(Nucleus::createXor(lhs.value, rhs.value)); 2142894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2143894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 214419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// RValue<Byte8> operator<<(RValue<Byte8> lhs, unsigned char rhs) 2145894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// { 2146894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// return RValue<Byte8>(Nucleus::createShl(lhs.value, rhs.value)); 2147894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// } 2148894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 214919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// RValue<Byte8> operator>>(RValue<Byte8> lhs, unsigned char rhs) 2150894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// { 2151894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// return RValue<Byte8>(Nucleus::createLShr(lhs.value, rhs.value)); 2152894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// } 2153894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 215496d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Byte8> operator+=(Byte8 &lhs, RValue<Byte8> rhs) 2155894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2156894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs + rhs; 2157894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2158894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 215996d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Byte8> operator-=(Byte8 &lhs, RValue<Byte8> rhs) 2160894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2161894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs - rhs; 2162894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2163894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 216496d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens// RValue<Byte8> operator*=(Byte8 &lhs, RValue<Byte8> rhs) 216519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 216619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return lhs = lhs * rhs; 216719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 2168894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 216996d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens// RValue<Byte8> operator/=(Byte8 &lhs, RValue<Byte8> rhs) 217019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 217119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return lhs = lhs / rhs; 217219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 2173894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 217496d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens// RValue<Byte8> operator%=(Byte8 &lhs, RValue<Byte8> rhs) 217519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 217619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return lhs = lhs % rhs; 217719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 2178894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 217996d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Byte8> operator&=(Byte8 &lhs, RValue<Byte8> rhs) 2180894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2181894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs & rhs; 2182894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2183894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 218496d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Byte8> operator|=(Byte8 &lhs, RValue<Byte8> rhs) 2185894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2186894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs | rhs; 2187894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2188894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 218996d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Byte8> operator^=(Byte8 &lhs, RValue<Byte8> rhs) 2190894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2191894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs ^ rhs; 2192894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2193894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 219496d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens// RValue<Byte8> operator<<=(Byte8 &lhs, RValue<Byte8> rhs) 2195894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// { 2196894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// return lhs = lhs << rhs; 2197894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// } 2198894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 219996d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens// RValue<Byte8> operator>>=(Byte8 &lhs, RValue<Byte8> rhs) 2200894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// { 2201894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// return lhs = lhs >> rhs; 2202894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// } 2203894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 220419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// RValue<Byte8> operator+(RValue<Byte8> val) 220519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 220619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return val; 220719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 2208894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 220919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// RValue<Byte8> operator-(RValue<Byte8> val) 221019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 221119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return RValue<Byte8>(Nucleus::createNeg(val.value)); 221219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 2213894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 221419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Byte8> operator~(RValue<Byte8> val) 2215894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 221601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<Byte8>(Nucleus::createNot(val.value)); 2217894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2218894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 221919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Byte8> AddSat(RValue<Byte8> x, RValue<Byte8> y) 2220894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2221894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::paddusb(x, y); 2222894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 222366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 222419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Byte8> SubSat(RValue<Byte8> x, RValue<Byte8> y) 2225894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2226894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::psubusb(x, y); 2227894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2228894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 222919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short4> Unpack(RValue<Byte4> x) 2230894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 223101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens int shuffle[16] = {0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7}; // Real type is v16i8 223201a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<Short4>(Nucleus::createShuffleVector(x.value, x.value, shuffle)); 223319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 2234894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 2235411273e7b30258756011601a2c3035dd67721a55Nicolas Capens RValue<Short4> Unpack(RValue<Byte4> x, RValue<Byte4> y) 2236411273e7b30258756011601a2c3035dd67721a55Nicolas Capens { 223701a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return UnpackLow(As<Byte8>(x), As<Byte8>(y)); 2238411273e7b30258756011601a2c3035dd67721a55Nicolas Capens } 2239411273e7b30258756011601a2c3035dd67721a55Nicolas Capens 224019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short4> UnpackLow(RValue<Byte8> x, RValue<Byte8> y) 224119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 224201a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens int shuffle[16] = {0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23}; // Real type is v16i8 224301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<Short4>(Nucleus::createShuffleVector(x.value, y.value, shuffle)); 2244894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 224566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 224619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short4> UnpackHigh(RValue<Byte8> x, RValue<Byte8> y) 2247894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 224801a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens int shuffle[16] = {0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23}; // Real type is v16i8 224901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens auto lowHigh = RValue<Byte16>(Nucleus::createShuffleVector(x.value, y.value, shuffle)); 225001a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<Short4>(Swizzle(As<Int4>(lowHigh), 0xEE)); 2251894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2252894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 225319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int> SignMask(RValue<Byte8> x) 2254894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2255894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::pmovmskb(x); 2256894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2257894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 225819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// RValue<Byte8> CmpGT(RValue<Byte8> x, RValue<Byte8> y) 2259894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// { 2260894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// return x86::pcmpgtb(x, y); // FIXME: Signedness 2261894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// } 226266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 226319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Byte8> CmpEQ(RValue<Byte8> x, RValue<Byte8> y) 2264894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2265894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::pcmpeqb(x, y); 2266894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2267894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 226819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Type *Byte8::getType() 2269894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2270fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return T(Type_v8i8); 2271894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2272894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 22733bbc5e16af2975cf3903ef47a21ed7d75d0874d9Nicolas Capens 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) 2274894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 227513ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens int64_t constantVector[8] = {x0, x1, x2, x3, x4, x5, x6, x7}; 227601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens Value *vector = V(Nucleus::createConstantVector(constantVector, getType())); 2277894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 227866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(Nucleus::createBitCast(vector, getType())); 2279894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2280894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 228119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman SByte8::SByte8(RValue<SByte8> rhs) 2282894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 228366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 2284894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2285894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 2286894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SByte8::SByte8(const SByte8 &rhs) 2287894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 228866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 228966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 229066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 229166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 229266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman SByte8::SByte8(const Reference<SByte8> &rhs) 229366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 229466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 229566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 2296894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2297894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 229896d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<SByte8> SByte8::operator=(RValue<SByte8> rhs) 2299894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 230066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 2301894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 2302894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return rhs; 2303894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2304894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 230596d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<SByte8> SByte8::operator=(const SByte8 &rhs) 2306894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 230766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 230866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 230966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 231066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman return RValue<SByte8>(value); 231166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 231266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 231396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<SByte8> SByte8::operator=(const Reference<SByte8> &rhs) 231466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 231566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 231666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 2317894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 2318894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<SByte8>(value); 2319894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2320894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 232119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<SByte8> operator+(RValue<SByte8> lhs, RValue<SByte8> rhs) 2322894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 232301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<SByte8>(Nucleus::createAdd(lhs.value, rhs.value)); 2324894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2325894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 232619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<SByte8> operator-(RValue<SByte8> lhs, RValue<SByte8> rhs) 2327894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 232801a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<SByte8>(Nucleus::createSub(lhs.value, rhs.value)); 2329894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2330894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 233119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// RValue<SByte8> operator*(RValue<SByte8> lhs, RValue<SByte8> rhs) 233219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 233319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return RValue<SByte8>(Nucleus::createMul(lhs.value, rhs.value)); 233419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 2335894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 233619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// RValue<SByte8> operator/(RValue<SByte8> lhs, RValue<SByte8> rhs) 233719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 233819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return RValue<SByte8>(Nucleus::createSDiv(lhs.value, rhs.value)); 233919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 2340894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 234119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// RValue<SByte8> operator%(RValue<SByte8> lhs, RValue<SByte8> rhs) 234219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 234319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return RValue<SByte8>(Nucleus::createSRem(lhs.value, rhs.value)); 234419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 2345894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 234619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<SByte8> operator&(RValue<SByte8> lhs, RValue<SByte8> rhs) 2347894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2348894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<SByte8>(Nucleus::createAnd(lhs.value, rhs.value)); 2349894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2350894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 235119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<SByte8> operator|(RValue<SByte8> lhs, RValue<SByte8> rhs) 2352894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2353894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<SByte8>(Nucleus::createOr(lhs.value, rhs.value)); 2354894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2355894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 235619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<SByte8> operator^(RValue<SByte8> lhs, RValue<SByte8> rhs) 2357894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2358894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<SByte8>(Nucleus::createXor(lhs.value, rhs.value)); 2359894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2360894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 236119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// RValue<SByte8> operator<<(RValue<SByte8> lhs, unsigned char rhs) 2362894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// { 2363894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// return RValue<SByte8>(Nucleus::createShl(lhs.value, rhs.value)); 2364894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// } 2365894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 236619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// RValue<SByte8> operator>>(RValue<SByte8> lhs, unsigned char rhs) 2367894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// { 2368894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// return RValue<SByte8>(Nucleus::createAShr(lhs.value, rhs.value)); 2369894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// } 2370894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 237196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<SByte8> operator+=(SByte8 &lhs, RValue<SByte8> rhs) 2372894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2373894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs + rhs; 2374894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2375894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 237696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<SByte8> operator-=(SByte8 &lhs, RValue<SByte8> rhs) 2377894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2378894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs - rhs; 2379894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2380894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 238196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens// RValue<SByte8> operator*=(SByte8 &lhs, RValue<SByte8> rhs) 238219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 238319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return lhs = lhs * rhs; 238419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 2385894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 238696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens// RValue<SByte8> operator/=(SByte8 &lhs, RValue<SByte8> rhs) 238719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 238819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return lhs = lhs / rhs; 238919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 2390894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 239196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens// RValue<SByte8> operator%=(SByte8 &lhs, RValue<SByte8> rhs) 239219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 239319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return lhs = lhs % rhs; 239419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 2395894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 239696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<SByte8> operator&=(SByte8 &lhs, RValue<SByte8> rhs) 2397894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2398894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs & rhs; 2399894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2400894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 240196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<SByte8> operator|=(SByte8 &lhs, RValue<SByte8> rhs) 2402894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2403894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs | rhs; 2404894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2405894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 240696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<SByte8> operator^=(SByte8 &lhs, RValue<SByte8> rhs) 2407894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2408894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs ^ rhs; 2409894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2410894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 241196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens// RValue<SByte8> operator<<=(SByte8 &lhs, RValue<SByte8> rhs) 2412894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// { 2413894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// return lhs = lhs << rhs; 2414894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// } 2415894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 241696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens// RValue<SByte8> operator>>=(SByte8 &lhs, RValue<SByte8> rhs) 2417894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// { 2418894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// return lhs = lhs >> rhs; 2419894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// } 2420894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 242119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// RValue<SByte8> operator+(RValue<SByte8> val) 242219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 242319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return val; 242419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 2425894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 242619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// RValue<SByte8> operator-(RValue<SByte8> val) 242719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 242819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return RValue<SByte8>(Nucleus::createNeg(val.value)); 242919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 2430894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 243119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<SByte8> operator~(RValue<SByte8> val) 2432894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 243301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<SByte8>(Nucleus::createNot(val.value)); 2434894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2435894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 243619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<SByte8> AddSat(RValue<SByte8> x, RValue<SByte8> y) 2437894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2438894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::paddsb(x, y); 2439894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 244066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 244119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<SByte8> SubSat(RValue<SByte8> x, RValue<SByte8> y) 2442894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2443894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::psubsb(x, y); 2444894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2445894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 244619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short4> UnpackLow(RValue<SByte8> x, RValue<SByte8> y) 2447894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 244801a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens int shuffle[16] = {0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23}; // Real type is v16i8 244901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<Short4>(Nucleus::createShuffleVector(x.value, y.value, shuffle)); 2450894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 245166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 245219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short4> UnpackHigh(RValue<SByte8> x, RValue<SByte8> y) 2453894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 245401a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens int shuffle[16] = {0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23}; // Real type is v16i8 245501a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens auto lowHigh = RValue<Byte16>(Nucleus::createShuffleVector(x.value, y.value, shuffle)); 245601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<Short4>(Swizzle(As<Int4>(lowHigh), 0xEE)); 2457894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2458894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 245919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int> SignMask(RValue<SByte8> x) 2460894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2461894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::pmovmskb(As<Byte8>(x)); 2462894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2463894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 246419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Byte8> CmpGT(RValue<SByte8> x, RValue<SByte8> y) 2465894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2466894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::pcmpgtb(x, y); 2467894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 246866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 246919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Byte8> CmpEQ(RValue<SByte8> x, RValue<SByte8> y) 2470894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2471894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::pcmpeqb(As<Byte8>(x), As<Byte8>(y)); 2472894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2473894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 247419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Type *SByte8::getType() 2475894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2476fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return T(Type_v8i8); 2477894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2478894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 247919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Byte16::Byte16(RValue<Byte16> rhs) 2480894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 248166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 2482894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2483894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 2484894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Byte16::Byte16(const Byte16 &rhs) 2485894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 248666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 248766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 248866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 248966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 249066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Byte16::Byte16(const Reference<Byte16> &rhs) 249166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 249266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 249366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 2494894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2495894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 249696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Byte16> Byte16::operator=(RValue<Byte16> rhs) 2497894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 249866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 2499894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 2500894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return rhs; 2501894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2502894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 250396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Byte16> Byte16::operator=(const Byte16 &rhs) 2504894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 250566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 250666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 250766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 250866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman return RValue<Byte16>(value); 250966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 251066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 251196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Byte16> Byte16::operator=(const Reference<Byte16> &rhs) 251266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 251366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 251466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 2515894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 2516894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Byte16>(value); 2517894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2518894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 251919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Type *Byte16::getType() 2520894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2521fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return T(llvm::VectorType::get(T(Byte::getType()), 16)); 2522894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2523894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 252419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Type *SByte16::getType() 2525894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2526fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return T(llvm::VectorType::get(T(SByte::getType()), 16)); 2527894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2528894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 252916b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens Short2::Short2(RValue<Short4> cast) 253016b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens { 253101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens storeValue(Nucleus::createBitCast(cast.value, getType())); 253216b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens } 253316b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens 253416b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens Type *Short2::getType() 253516b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens { 2536fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return T(Type_v2i16); 253716b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens } 253816b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens 253916b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens UShort2::UShort2(RValue<UShort4> cast) 254016b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens { 254101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens storeValue(Nucleus::createBitCast(cast.value, getType())); 254216b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens } 254316b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens 254416b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens Type *UShort2::getType() 254516b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens { 2546fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return T(Type_v2i16); 254716b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens } 254816b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens 254919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Short4::Short4(RValue<Int> cast) 2550894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 255101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens Value *vector = loadValue(); 255201a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens Value *element = Nucleus::createTrunc(cast.value, Short::getType()); 255301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens Value *insert = Nucleus::createInsertElement(vector, element, 0); 255401a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens Value *swizzle = Swizzle(RValue<Short4>(insert), 0x00).value; 255566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 255666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(swizzle); 2557894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2558894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 255919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Short4::Short4(RValue<Int4> cast) 2560894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 256101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens int select[8] = {0, 2, 4, 6, 0, 2, 4, 6}; 2562894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *short8 = Nucleus::createBitCast(cast.value, Short8::getType()); 2563894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 256401a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens Value *packed = Nucleus::createShuffleVector(short8, short8, select); 256501a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens Value *short4 = As<Short4>(Int2(As<Int4>(packed))).value; 2566894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 256766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(short4); 2568894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2569894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 257019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// Short4::Short4(RValue<Float> cast) 2571894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// { 2572894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// } 2573894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 257419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Short4::Short4(RValue<Float4> cast) 2575894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2576894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Int4 v4i32 = Int4(cast); 2577894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman v4i32 = As<Int4>(x86::packssdw(v4i32, v4i32)); 257866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 257966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(As<Short4>(Int2(v4i32)).value); 2580894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2581894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 258219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Short4::Short4(short xyzw) 258319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 258413ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens int64_t constantVector[4] = {xyzw, xyzw, xyzw, xyzw}; 258501a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens storeValue(Nucleus::createConstantVector(constantVector, getType())); 258619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 258719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 2588894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Short4::Short4(short x, short y, short z, short w) 2589894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 259013ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens int64_t constantVector[4] = {x, y, z, w}; 259101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens storeValue(Nucleus::createConstantVector(constantVector, getType())); 2592894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2593894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 259419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Short4::Short4(RValue<Short4> rhs) 2595894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 259666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 2597894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2598894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 2599894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Short4::Short4(const Short4 &rhs) 2600894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 260166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 260266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 260366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 260466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 260566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Short4::Short4(const Reference<Short4> &rhs) 260666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 260766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 260866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 2609894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2610894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 261119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Short4::Short4(RValue<UShort4> rhs) 2612894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 261366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 2614894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2615894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 2616894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Short4::Short4(const UShort4 &rhs) 2617894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 261866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.loadValue()); 261966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 262066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 262166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Short4::Short4(const Reference<UShort4> &rhs) 262266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 262366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.loadValue()); 2624894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2625894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 262696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Short4> Short4::operator=(RValue<Short4> rhs) 2627894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 262866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 2629894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 2630894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return rhs; 2631894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2632894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 263396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Short4> Short4::operator=(const Short4 &rhs) 2634894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 263566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 263666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 263766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 263866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman return RValue<Short4>(value); 263966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 264066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 264196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Short4> Short4::operator=(const Reference<Short4> &rhs) 264266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 264366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 264466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 2645894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 2646894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Short4>(value); 2647894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2648894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 264996d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Short4> Short4::operator=(RValue<UShort4> rhs) 2650894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 265166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 2652894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 265366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman return RValue<Short4>(rhs); 2654894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2655894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 265696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Short4> Short4::operator=(const UShort4 &rhs) 2657894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 265866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 265966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 266066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 266166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman return RValue<Short4>(value); 266266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 266366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 266496d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Short4> Short4::operator=(const Reference<UShort4> &rhs) 266566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 266666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 266766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 2668894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 2669894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Short4>(value); 2670894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2671894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 267219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short4> operator+(RValue<Short4> lhs, RValue<Short4> rhs) 2673894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 267401a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<Short4>(Nucleus::createAdd(lhs.value, rhs.value)); 2675894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2676894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 267719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short4> operator-(RValue<Short4> lhs, RValue<Short4> rhs) 2678894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 267901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<Short4>(Nucleus::createSub(lhs.value, rhs.value)); 2680894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2681894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 268219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short4> operator*(RValue<Short4> lhs, RValue<Short4> rhs) 2683894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 268401a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<Short4>(Nucleus::createMul(lhs.value, rhs.value)); 2685894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2686894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 268719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// RValue<Short4> operator/(RValue<Short4> lhs, RValue<Short4> rhs) 268819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 268919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return RValue<Short4>(Nucleus::createSDiv(lhs.value, rhs.value)); 269019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 2691894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 269219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// RValue<Short4> operator%(RValue<Short4> lhs, RValue<Short4> rhs) 269319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 269419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return RValue<Short4>(Nucleus::createSRem(lhs.value, rhs.value)); 269519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 2696894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 269719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short4> operator&(RValue<Short4> lhs, RValue<Short4> rhs) 2698894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 269901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<Short4>(Nucleus::createAnd(lhs.value, rhs.value)); 2700894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2701894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 270219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short4> operator|(RValue<Short4> lhs, RValue<Short4> rhs) 2703894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 270401a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<Short4>(Nucleus::createOr(lhs.value, rhs.value)); 270519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 270619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 270719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short4> operator^(RValue<Short4> lhs, RValue<Short4> rhs) 2708894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 270901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<Short4>(Nucleus::createXor(lhs.value, rhs.value)); 2710894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2711894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 271219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short4> operator<<(RValue<Short4> lhs, unsigned char rhs) 2713894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2714894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // return RValue<Short4>(Nucleus::createShl(lhs.value, rhs.value)); 2715894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 2716894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::psllw(lhs, rhs); 2717894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2718894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 271919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short4> operator>>(RValue<Short4> lhs, unsigned char rhs) 2720894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2721894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // return RValue<Short4>(Nucleus::createAShr(lhs.value, rhs.value)); 2722894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 2723894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::psraw(lhs, rhs); 2724894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2725894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 272696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Short4> operator+=(Short4 &lhs, RValue<Short4> rhs) 2727894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2728894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs + rhs; 2729894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2730894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 273196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Short4> operator-=(Short4 &lhs, RValue<Short4> rhs) 2732894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2733894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs - rhs; 2734894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2735894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 273696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Short4> operator*=(Short4 &lhs, RValue<Short4> rhs) 2737894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2738894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs * rhs; 2739894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2740894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 274196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens// RValue<Short4> operator/=(Short4 &lhs, RValue<Short4> rhs) 274219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 274319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return lhs = lhs / rhs; 274419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 2745894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 274696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens// RValue<Short4> operator%=(Short4 &lhs, RValue<Short4> rhs) 274719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 274819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return lhs = lhs % rhs; 274919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 2750894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 275196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Short4> operator&=(Short4 &lhs, RValue<Short4> rhs) 2752894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2753894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs & rhs; 2754894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2755894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 275696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Short4> operator|=(Short4 &lhs, RValue<Short4> rhs) 2757894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2758894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs | rhs; 2759894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2760894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 276196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Short4> operator^=(Short4 &lhs, RValue<Short4> rhs) 2762894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2763894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs ^ rhs; 2764894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2765894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 276696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Short4> operator<<=(Short4 &lhs, unsigned char rhs) 2767894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2768894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs << rhs; 2769894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2770894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 277196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Short4> operator>>=(Short4 &lhs, unsigned char rhs) 2772894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2773894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs >> rhs; 2774894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2775894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 277619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// RValue<Short4> operator+(RValue<Short4> val) 277719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 277819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return val; 277919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 2780894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 278119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short4> operator-(RValue<Short4> val) 2782894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 278301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<Short4>(Nucleus::createNeg(val.value)); 2784894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2785894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 278619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short4> operator~(RValue<Short4> val) 2787894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 278801a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<Short4>(Nucleus::createNot(val.value)); 2789894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2790894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 279119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short4> RoundShort4(RValue<Float4> cast) 2792894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 279301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens RValue<Int4> int4 = RoundInt(cast); 279433438a6882d629139617d80cc7fdbc687b71a794Nicolas Capens return As<Short4>(PackSigned(int4, int4)); 2795894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2796894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 279719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short4> Max(RValue<Short4> x, RValue<Short4> y) 2798894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2799894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::pmaxsw(x, y); 2800894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2801894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 280219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short4> Min(RValue<Short4> x, RValue<Short4> y) 2803894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2804894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::pminsw(x, y); 2805894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2806894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 280719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short4> AddSat(RValue<Short4> x, RValue<Short4> y) 2808894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2809894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::paddsw(x, y); 2810894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2811894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 281219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short4> SubSat(RValue<Short4> x, RValue<Short4> y) 2813894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2814894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::psubsw(x, y); 2815894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2816894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 281719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short4> MulHigh(RValue<Short4> x, RValue<Short4> y) 2818894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2819894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::pmulhw(x, y); 2820894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2821894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 282219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int2> MulAdd(RValue<Short4> x, RValue<Short4> y) 2823894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2824894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::pmaddwd(x, y); 2825894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2826894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 282733438a6882d629139617d80cc7fdbc687b71a794Nicolas Capens RValue<SByte8> PackSigned(RValue<Short4> x, RValue<Short4> y) 2828894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 282901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens auto result = x86::packsswb(x, y); 283001a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens 283101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<SByte8>(Swizzle(As<Int4>(result), 0x88)); 2832894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2833894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 283433438a6882d629139617d80cc7fdbc687b71a794Nicolas Capens RValue<Byte8> PackUnsigned(RValue<Short4> x, RValue<Short4> y) 283533438a6882d629139617d80cc7fdbc687b71a794Nicolas Capens { 283633438a6882d629139617d80cc7fdbc687b71a794Nicolas Capens auto result = x86::packuswb(x, y); 283733438a6882d629139617d80cc7fdbc687b71a794Nicolas Capens 283833438a6882d629139617d80cc7fdbc687b71a794Nicolas Capens return As<Byte8>(Swizzle(As<Int4>(result), 0x88)); 283933438a6882d629139617d80cc7fdbc687b71a794Nicolas Capens } 284033438a6882d629139617d80cc7fdbc687b71a794Nicolas Capens 284119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int2> UnpackLow(RValue<Short4> x, RValue<Short4> y) 2842894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 284301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens int shuffle[8] = {0, 8, 1, 9, 2, 10, 3, 11}; // Real type is v8i16 284401a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<Int2>(Nucleus::createShuffleVector(x.value, y.value, shuffle)); 2845894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2846894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 284719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int2> UnpackHigh(RValue<Short4> x, RValue<Short4> y) 2848894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 284901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens int shuffle[8] = {0, 8, 1, 9, 2, 10, 3, 11}; // Real type is v8i16 285001a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens auto lowHigh = RValue<Short8>(Nucleus::createShuffleVector(x.value, y.value, shuffle)); 285101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<Int2>(Swizzle(As<Int4>(lowHigh), 0xEE)); 2852894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2853894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 285419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short4> Swizzle(RValue<Short4> x, unsigned char select) 2855894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 285601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens // Real type is v8i16 285701a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens int shuffle[8] = 285819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 285901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens (select >> 0) & 0x03, 286001a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens (select >> 2) & 0x03, 286101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens (select >> 4) & 0x03, 286201a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens (select >> 6) & 0x03, 286301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens (select >> 0) & 0x03, 286401a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens (select >> 2) & 0x03, 286501a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens (select >> 4) & 0x03, 286601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens (select >> 6) & 0x03, 286701a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens }; 286801a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens 286901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<Short4>(Nucleus::createShuffleVector(x.value, x.value, shuffle)); 2870894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2871894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 287219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short4> Insert(RValue<Short4> val, RValue<Short> element, int i) 2873894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 287401a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<Short4>(Nucleus::createInsertElement(val.value, element.value, i)); 2875894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2876894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 287719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short> Extract(RValue<Short4> val, int i) 2878894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 287901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<Short>(Nucleus::createExtractElement(val.value, Short::getType(), i)); 2880894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2881894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 288219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short4> CmpGT(RValue<Short4> x, RValue<Short4> y) 2883894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2884894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::pcmpgtw(x, y); 2885894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2886894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 288719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short4> CmpEQ(RValue<Short4> x, RValue<Short4> y) 2888894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2889894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::pcmpeqw(x, y); 2890894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2891894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 289219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Type *Short4::getType() 2893894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2894fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return T(Type_v4i16); 2895894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2896894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 289719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman UShort4::UShort4(RValue<Int4> cast) 2898894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2899894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *this = Short4(cast); 2900894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2901894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 290219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman UShort4::UShort4(RValue<Float4> cast, bool saturate) 2903894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2904894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(saturate) 2905894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2906894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(CPUID::supportsSSE4_1()) 2907894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 290801a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens Int4 int4(Min(cast, Float4(0xFFFF))); // packusdw takes care of 0x0000 saturation 290933438a6882d629139617d80cc7fdbc687b71a794Nicolas Capens *this = As<Short4>(PackUnsigned(int4, int4)); 2910894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2911894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman else 2912894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 291301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens *this = Short4(Int4(Max(Min(cast, Float4(0xFFFF)), Float4(0x0000)))); 2914894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2915894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2916894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman else 2917894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 291801a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens *this = Short4(Int4(cast)); 2919894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2920894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2921894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 292290c7ad6764b32c5c1784893316872282f791135aAlexis Hetu UShort4::UShort4(unsigned short xyzw) 292390c7ad6764b32c5c1784893316872282f791135aAlexis Hetu { 292413ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens int64_t constantVector[4] = {xyzw, xyzw, xyzw, xyzw}; 292501a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens storeValue(Nucleus::createConstantVector(constantVector, getType())); 292690c7ad6764b32c5c1784893316872282f791135aAlexis Hetu } 292790c7ad6764b32c5c1784893316872282f791135aAlexis Hetu 2928894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman UShort4::UShort4(unsigned short x, unsigned short y, unsigned short z, unsigned short w) 2929894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 293013ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens int64_t constantVector[4] = {x, y, z, w}; 293101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens storeValue(Nucleus::createConstantVector(constantVector, getType())); 2932894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2933894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 293419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman UShort4::UShort4(RValue<UShort4> rhs) 2935894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 293666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 2937894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2938894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 2939894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman UShort4::UShort4(const UShort4 &rhs) 2940894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 294166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 294266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 294366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 294466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 294566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman UShort4::UShort4(const Reference<UShort4> &rhs) 294666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 294766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 294866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 2949894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2950894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 295119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman UShort4::UShort4(RValue<Short4> rhs) 2952894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 295366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 2954894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2955894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 2956894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman UShort4::UShort4(const Short4 &rhs) 2957894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 295866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 295966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 296066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 296166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 296266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman UShort4::UShort4(const Reference<Short4> &rhs) 296366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 296466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 296566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 2966894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2967894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 296896d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UShort4> UShort4::operator=(RValue<UShort4> rhs) 2969894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 297066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 2971894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 2972894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return rhs; 2973894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2974894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 297596d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UShort4> UShort4::operator=(const UShort4 &rhs) 2976894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 297766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 297866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 297966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 298066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman return RValue<UShort4>(value); 298166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 298266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 298396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UShort4> UShort4::operator=(const Reference<UShort4> &rhs) 298466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 298566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 298666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 2987894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 2988894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UShort4>(value); 2989894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2990894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 299196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UShort4> UShort4::operator=(RValue<Short4> rhs) 2992894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 299366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 2994894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 299566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman return RValue<UShort4>(rhs); 2996894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2997894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 299896d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UShort4> UShort4::operator=(const Short4 &rhs) 2999894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 300066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 300166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 300266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 300366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman return RValue<UShort4>(value); 300466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 300566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 300696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UShort4> UShort4::operator=(const Reference<Short4> &rhs) 300766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 300866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 300966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 3010894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3011894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UShort4>(value); 3012894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3013894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 301419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort4> operator+(RValue<UShort4> lhs, RValue<UShort4> rhs) 3015894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 301601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<UShort4>(Nucleus::createAdd(lhs.value, rhs.value)); 3017894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3018894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 301919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort4> operator-(RValue<UShort4> lhs, RValue<UShort4> rhs) 3020894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 302101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<UShort4>(Nucleus::createSub(lhs.value, rhs.value)); 3022894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3023894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 302419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort4> operator*(RValue<UShort4> lhs, RValue<UShort4> rhs) 3025894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 302601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<UShort4>(Nucleus::createMul(lhs.value, rhs.value)); 3027894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3028894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 302916b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens RValue<UShort4> operator&(RValue<UShort4> lhs, RValue<UShort4> rhs) 303016b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens { 303101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<UShort4>(Nucleus::createAnd(lhs.value, rhs.value)); 303216b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens } 303316b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens 303416b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens RValue<UShort4> operator|(RValue<UShort4> lhs, RValue<UShort4> rhs) 303516b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens { 303601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<UShort4>(Nucleus::createOr(lhs.value, rhs.value)); 303716b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens } 303816b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens 303916b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens RValue<UShort4> operator^(RValue<UShort4> lhs, RValue<UShort4> rhs) 304016b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens { 304101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<UShort4>(Nucleus::createXor(lhs.value, rhs.value)); 304216b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens } 304316b5f15bbba60a7f89fc3c313588da86a4266869Nicolas Capens 304419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort4> operator<<(RValue<UShort4> lhs, unsigned char rhs) 3045894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3046894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // return RValue<Short4>(Nucleus::createShl(lhs.value, rhs.value)); 3047894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3048894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return As<UShort4>(x86::psllw(As<Short4>(lhs), rhs)); 3049894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3050894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 305119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort4> operator>>(RValue<UShort4> lhs, unsigned char rhs) 3052894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3053894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // return RValue<Short4>(Nucleus::createLShr(lhs.value, rhs.value)); 3054894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3055894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::psrlw(lhs, rhs); 3056894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3057894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 305896d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UShort4> operator<<=(UShort4 &lhs, unsigned char rhs) 3059894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3060894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs << rhs; 3061894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3062894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 306396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UShort4> operator>>=(UShort4 &lhs, unsigned char rhs) 3064894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3065894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs >> rhs; 3066894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3067894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 306819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort4> operator~(RValue<UShort4> val) 3069894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 307001a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<UShort4>(Nucleus::createNot(val.value)); 3071894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3072894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 307319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort4> Max(RValue<UShort4> x, RValue<UShort4> y) 3074894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 307566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman return RValue<UShort4>(Max(As<Short4>(x) - Short4(0x8000u, 0x8000u, 0x8000u, 0x8000u), As<Short4>(y) - Short4(0x8000u, 0x8000u, 0x8000u, 0x8000u)) + Short4(0x8000u, 0x8000u, 0x8000u, 0x8000u)); 3076894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3077894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 307819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort4> Min(RValue<UShort4> x, RValue<UShort4> y) 3079894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 308066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman return RValue<UShort4>(Min(As<Short4>(x) - Short4(0x8000u, 0x8000u, 0x8000u, 0x8000u), As<Short4>(y) - Short4(0x8000u, 0x8000u, 0x8000u, 0x8000u)) + Short4(0x8000u, 0x8000u, 0x8000u, 0x8000u)); 3081894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3082894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 308319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort4> AddSat(RValue<UShort4> x, RValue<UShort4> y) 3084894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3085894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::paddusw(x, y); 3086894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3087894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 308819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort4> SubSat(RValue<UShort4> x, RValue<UShort4> y) 3089894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3090894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::psubusw(x, y); 3091894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3092894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 309319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort4> MulHigh(RValue<UShort4> x, RValue<UShort4> y) 3094894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3095894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::pmulhuw(x, y); 3096894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3097894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 309819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort4> Average(RValue<UShort4> x, RValue<UShort4> y) 3099894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3100894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::pavgw(x, y); 3101894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3102894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 310319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Type *UShort4::getType() 3104894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3105fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return T(Type_v4i16); 3106894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3107894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 31083e7062b993c74700a403f46f01e0d55bfaed71dfNicolas Capens Short8::Short8(short c) 31093e7062b993c74700a403f46f01e0d55bfaed71dfNicolas Capens { 31103e7062b993c74700a403f46f01e0d55bfaed71dfNicolas Capens int64_t constantVector[8] = {c, c, c, c, c, c, c, c}; 31113e7062b993c74700a403f46f01e0d55bfaed71dfNicolas Capens storeValue(Nucleus::createConstantVector(constantVector, getType())); 31123e7062b993c74700a403f46f01e0d55bfaed71dfNicolas Capens } 31133e7062b993c74700a403f46f01e0d55bfaed71dfNicolas Capens 3114894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Short8::Short8(short c0, short c1, short c2, short c3, short c4, short c5, short c6, short c7) 3115894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 311613ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens int64_t constantVector[8] = {c0, c1, c2, c3, c4, c5, c6, c7}; 311713ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens storeValue(Nucleus::createConstantVector(constantVector, getType())); 3118894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3119894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 312019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Short8::Short8(RValue<Short8> rhs) 3121894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 312266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 3123894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3124894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3125ef8cd669357e73b6de0c11169f5b1089461a0807Nicolas Capens Short8::Short8(const Reference<Short8> &rhs) 3126ef8cd669357e73b6de0c11169f5b1089461a0807Nicolas Capens { 3127ef8cd669357e73b6de0c11169f5b1089461a0807Nicolas Capens Value *value = rhs.loadValue(); 3128ef8cd669357e73b6de0c11169f5b1089461a0807Nicolas Capens storeValue(value); 3129ef8cd669357e73b6de0c11169f5b1089461a0807Nicolas Capens } 3130ef8cd669357e73b6de0c11169f5b1089461a0807Nicolas Capens 313162abb5589758c3d3e32f5a7a2d7e0ad936d5c5f1Nicolas Capens Short8::Short8(RValue<Short4> lo, RValue<Short4> hi) 313262abb5589758c3d3e32f5a7a2d7e0ad936d5c5f1Nicolas Capens { 313301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens int shuffle[8] = {0, 1, 2, 3, 8, 9, 10, 11}; // Real type is v8i16 313401a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens Value *packed = Nucleus::createShuffleVector(lo.value, hi.value, shuffle); 313562abb5589758c3d3e32f5a7a2d7e0ad936d5c5f1Nicolas Capens 313601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens storeValue(packed); 313762abb5589758c3d3e32f5a7a2d7e0ad936d5c5f1Nicolas Capens } 313862abb5589758c3d3e32f5a7a2d7e0ad936d5c5f1Nicolas Capens 313919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short8> operator+(RValue<Short8> lhs, RValue<Short8> rhs) 3140894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3141894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Short8>(Nucleus::createAdd(lhs.value, rhs.value)); 3142894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3143894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 314419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short8> operator&(RValue<Short8> lhs, RValue<Short8> rhs) 3145894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3146894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Short8>(Nucleus::createAnd(lhs.value, rhs.value)); 3147894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3148894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 314919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short8> operator<<(RValue<Short8> lhs, unsigned char rhs) 3150894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3151894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::psllw(lhs, rhs); // FIXME: Fallback required 3152894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3153894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 315419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short8> operator>>(RValue<Short8> lhs, unsigned char rhs) 3155894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3156894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::psraw(lhs, rhs); // FIXME: Fallback required 3157894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3158894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 315919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> MulAdd(RValue<Short8> x, RValue<Short8> y) 3160894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3161894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::pmaddwd(x, y); // FIXME: Fallback required 3162894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3163894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 31640f4480780a2bfad69cece5fd9cabd1bf89f7393eAlexis Hetu RValue<Int4> Abs(RValue<Int4> x) 31650f4480780a2bfad69cece5fd9cabd1bf89f7393eAlexis Hetu { 316601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens auto negative = x >> 31; 316701a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return (x ^ negative) - negative; 31680f4480780a2bfad69cece5fd9cabd1bf89f7393eAlexis Hetu } 31690f4480780a2bfad69cece5fd9cabd1bf89f7393eAlexis Hetu 317019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short8> MulHigh(RValue<Short8> x, RValue<Short8> y) 3171894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3172894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::pmulhw(x, y); // FIXME: Fallback required 3173894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3174894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 317519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Type *Short8::getType() 3176894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3177fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return T(llvm::VectorType::get(T(Short::getType()), 8)); 3178894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3179894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 31803e7062b993c74700a403f46f01e0d55bfaed71dfNicolas Capens UShort8::UShort8(unsigned short c) 31813e7062b993c74700a403f46f01e0d55bfaed71dfNicolas Capens { 31823e7062b993c74700a403f46f01e0d55bfaed71dfNicolas Capens int64_t constantVector[8] = {c, c, c, c, c, c, c, c}; 31833e7062b993c74700a403f46f01e0d55bfaed71dfNicolas Capens storeValue(Nucleus::createConstantVector(constantVector, getType())); 31843e7062b993c74700a403f46f01e0d55bfaed71dfNicolas Capens } 31853e7062b993c74700a403f46f01e0d55bfaed71dfNicolas Capens 3186894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 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) 3187894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 318813ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens int64_t constantVector[8] = {c0, c1, c2, c3, c4, c5, c6, c7}; 318913ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens storeValue(Nucleus::createConstantVector(constantVector, getType())); 3190894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3191894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 319219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman UShort8::UShort8(RValue<UShort8> rhs) 3193894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 319466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 3195894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3196894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3197ef8cd669357e73b6de0c11169f5b1089461a0807Nicolas Capens UShort8::UShort8(const Reference<UShort8> &rhs) 3198ef8cd669357e73b6de0c11169f5b1089461a0807Nicolas Capens { 3199ef8cd669357e73b6de0c11169f5b1089461a0807Nicolas Capens Value *value = rhs.loadValue(); 3200ef8cd669357e73b6de0c11169f5b1089461a0807Nicolas Capens storeValue(value); 3201ef8cd669357e73b6de0c11169f5b1089461a0807Nicolas Capens } 3202ef8cd669357e73b6de0c11169f5b1089461a0807Nicolas Capens 320362abb5589758c3d3e32f5a7a2d7e0ad936d5c5f1Nicolas Capens UShort8::UShort8(RValue<UShort4> lo, RValue<UShort4> hi) 320462abb5589758c3d3e32f5a7a2d7e0ad936d5c5f1Nicolas Capens { 320501a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens int shuffle[8] = {0, 1, 2, 3, 8, 9, 10, 11}; // Real type is v8i16 320601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens Value *packed = Nucleus::createShuffleVector(lo.value, hi.value, shuffle); 320762abb5589758c3d3e32f5a7a2d7e0ad936d5c5f1Nicolas Capens 320801a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens storeValue(packed); 320962abb5589758c3d3e32f5a7a2d7e0ad936d5c5f1Nicolas Capens } 321062abb5589758c3d3e32f5a7a2d7e0ad936d5c5f1Nicolas Capens 321196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UShort8> UShort8::operator=(RValue<UShort8> rhs) 3212894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 321366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 3214894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3215894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return rhs; 3216894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3217894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 321896d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UShort8> UShort8::operator=(const UShort8 &rhs) 3219894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 322066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 322166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 322266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 322366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman return RValue<UShort8>(value); 322466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 322566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 322696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UShort8> UShort8::operator=(const Reference<UShort8> &rhs) 322766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 322866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 322966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 3230894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3231894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UShort8>(value); 3232894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3233894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 323419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort8> operator&(RValue<UShort8> lhs, RValue<UShort8> rhs) 3235894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3236894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UShort8>(Nucleus::createAnd(lhs.value, rhs.value)); 3237894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3238894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 323919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort8> operator<<(RValue<UShort8> lhs, unsigned char rhs) 3240894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3241894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return As<UShort8>(x86::psllw(As<Short8>(lhs), rhs)); // FIXME: Fallback required 3242894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3243894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 324419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort8> operator>>(RValue<UShort8> lhs, unsigned char rhs) 3245894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3246894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::psrlw(lhs, rhs); // FIXME: Fallback required 3247894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3248894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 324919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort8> operator+(RValue<UShort8> lhs, RValue<UShort8> rhs) 3250894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3251894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UShort8>(Nucleus::createAdd(lhs.value, rhs.value)); 3252894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3253894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 325419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort8> operator*(RValue<UShort8> lhs, RValue<UShort8> rhs) 3255894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3256894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UShort8>(Nucleus::createMul(lhs.value, rhs.value)); 3257894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3258894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 325996d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UShort8> operator+=(UShort8 &lhs, RValue<UShort8> rhs) 3260894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3261894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs + rhs; 3262894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3263894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 326419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort8> operator~(RValue<UShort8> val) 3265894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3266894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UShort8>(Nucleus::createNot(val.value)); 3267894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3268894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 326919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort8> Swizzle(RValue<UShort8> x, char select0, char select1, char select2, char select3, char select4, char select5, char select6, char select7) 3270894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3271e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens int pshufb[16] = 3272e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens { 3273e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens select0 + 0, 3274e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens select0 + 1, 3275e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens select1 + 0, 3276e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens select1 + 1, 3277e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens select2 + 0, 3278e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens select2 + 1, 3279e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens select3 + 0, 3280e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens select3 + 1, 3281e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens select4 + 0, 3282e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens select4 + 1, 3283e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens select5 + 0, 3284e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens select5 + 1, 3285e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens select6 + 0, 3286e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens select6 + 1, 3287e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens select7 + 0, 3288e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens select7 + 1, 3289e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens }; 3290894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3291894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *byte16 = Nucleus::createBitCast(x.value, Byte16::getType()); 3292e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens Value *shuffle = Nucleus::createShuffleVector(byte16, byte16, pshufb); 3293894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *short8 = Nucleus::createBitCast(shuffle, UShort8::getType()); 3294894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3295894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UShort8>(short8); 3296894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3297894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 329819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort8> MulHigh(RValue<UShort8> x, RValue<UShort8> y) 3299894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3300894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::pmulhuw(x, y); // FIXME: Fallback required 3301894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3302894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 330319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Type *UShort8::getType() 3304894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3305fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return T(llvm::VectorType::get(T(UShort::getType()), 8)); 3306894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3307894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 330881f1830d46482cd635f7e7a92c55aec8683c1e55Nicolas Capens Int::Int(Argument<Int> argument) 3309894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 331081f1830d46482cd635f7e7a92c55aec8683c1e55Nicolas Capens storeValue(argument.value); 3311894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3312894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 331319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Int::Int(RValue<Byte> cast) 3314894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3315894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *integer = Nucleus::createZExt(cast.value, Int::getType()); 3316894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 331766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(integer); 3318894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3319894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 332019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Int::Int(RValue<SByte> cast) 3321894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3322894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *integer = Nucleus::createSExt(cast.value, Int::getType()); 3323894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 332466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(integer); 3325894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3326894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 332719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Int::Int(RValue<Short> cast) 3328894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3329894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *integer = Nucleus::createSExt(cast.value, Int::getType()); 3330894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 333166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(integer); 3332894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3333894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 333419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Int::Int(RValue<UShort> cast) 3335894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3336894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *integer = Nucleus::createZExt(cast.value, Int::getType()); 3337894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 333866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(integer); 3339894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3340894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 334119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Int::Int(RValue<Int2> cast) 3342894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3343894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *this = Extract(cast, 0); 3344894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3345894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 334619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Int::Int(RValue<Long> cast) 3347894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3348894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *integer = Nucleus::createTrunc(cast.value, Int::getType()); 3349894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 335066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(integer); 3351894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3352894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 335319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Int::Int(RValue<Float> cast) 3354894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3355894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *integer = Nucleus::createFPToSI(cast.value, Int::getType()); 3356894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 335766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(integer); 3358894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3359894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3360894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Int::Int(int x) 3361894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 336266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(Nucleus::createConstantInt(x)); 3363894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3364894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 336519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Int::Int(RValue<Int> rhs) 3366894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 336766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 3368894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3369894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 337019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Int::Int(RValue<UInt> rhs) 3371894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 337266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 3373894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3374894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3375894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Int::Int(const Int &rhs) 3376894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 337766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 337866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 337966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 3380894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 338166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Int::Int(const Reference<Int> &rhs) 338266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 338366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 338466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 3385894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3386894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3387894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Int::Int(const UInt &rhs) 3388894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 338966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 339066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 339166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 3392894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 339366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Int::Int(const Reference<UInt> &rhs) 339466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 339566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 339666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 3397894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3398894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 339996d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int> Int::operator=(int rhs) 3400894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 340166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman return RValue<Int>(storeValue(Nucleus::createConstantInt(rhs))); 3402894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3403894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 340496d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int> Int::operator=(RValue<Int> rhs) 3405894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 340666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 3407894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3408894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return rhs; 3409894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3410894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 341196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int> Int::operator=(RValue<UInt> rhs) 3412894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 341366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 3414894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 341566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman return RValue<Int>(rhs); 3416894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3417894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 341896d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int> Int::operator=(const Int &rhs) 3419894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 342066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 342166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 342266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 342366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman return RValue<Int>(value); 342466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 342566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 342696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int> Int::operator=(const Reference<Int> &rhs) 342766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 342866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 342966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 3430894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3431894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Int>(value); 3432894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3433894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 343496d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int> Int::operator=(const UInt &rhs) 3435894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 343666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 343766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 3438894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3439894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Int>(value); 3440894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3441894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 344296d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int> Int::operator=(const Reference<UInt> &rhs) 3443894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 344466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 344566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 344666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 344766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman return RValue<Int>(value); 3448894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3449894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 345019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int> operator+(RValue<Int> lhs, RValue<Int> rhs) 3451894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3452894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Int>(Nucleus::createAdd(lhs.value, rhs.value)); 3453894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3454894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 345519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int> operator-(RValue<Int> lhs, RValue<Int> rhs) 3456894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3457894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Int>(Nucleus::createSub(lhs.value, rhs.value)); 3458894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3459894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 346019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int> operator*(RValue<Int> lhs, RValue<Int> rhs) 3461894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3462894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Int>(Nucleus::createMul(lhs.value, rhs.value)); 3463894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3464894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 346519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int> operator/(RValue<Int> lhs, RValue<Int> rhs) 3466894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3467894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Int>(Nucleus::createSDiv(lhs.value, rhs.value)); 3468894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3469894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 347019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int> operator%(RValue<Int> lhs, RValue<Int> rhs) 3471894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3472894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Int>(Nucleus::createSRem(lhs.value, rhs.value)); 3473894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3474894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 347519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int> operator&(RValue<Int> lhs, RValue<Int> rhs) 3476894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3477894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Int>(Nucleus::createAnd(lhs.value, rhs.value)); 3478894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3479894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 348019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int> operator|(RValue<Int> lhs, RValue<Int> rhs) 3481894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3482894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Int>(Nucleus::createOr(lhs.value, rhs.value)); 3483894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3484894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 348519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int> operator^(RValue<Int> lhs, RValue<Int> rhs) 3486894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3487894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Int>(Nucleus::createXor(lhs.value, rhs.value)); 3488894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3489894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 349019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int> operator<<(RValue<Int> lhs, RValue<Int> rhs) 3491894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3492894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Int>(Nucleus::createShl(lhs.value, rhs.value)); 3493894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3494894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 349519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int> operator>>(RValue<Int> lhs, RValue<Int> rhs) 3496894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3497894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Int>(Nucleus::createAShr(lhs.value, rhs.value)); 3498894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3499894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 350096d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int> operator+=(Int &lhs, RValue<Int> rhs) 3501894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3502894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs + rhs; 3503894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3504894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 350596d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int> operator-=(Int &lhs, RValue<Int> rhs) 3506894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3507894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs - rhs; 3508894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3509894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 351096d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int> operator*=(Int &lhs, RValue<Int> rhs) 3511894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3512894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs * rhs; 3513894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3514894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 351596d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int> operator/=(Int &lhs, RValue<Int> rhs) 3516894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3517894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs / rhs; 3518894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3519894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 352096d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int> operator%=(Int &lhs, RValue<Int> rhs) 3521894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3522894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs % rhs; 3523894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3524894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 352596d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int> operator&=(Int &lhs, RValue<Int> rhs) 3526894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3527894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs & rhs; 3528894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3529894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 353096d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int> operator|=(Int &lhs, RValue<Int> rhs) 3531894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3532894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs | rhs; 3533894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3534894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 353596d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int> operator^=(Int &lhs, RValue<Int> rhs) 3536894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3537894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs ^ rhs; 3538894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3539894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 354096d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int> operator<<=(Int &lhs, RValue<Int> rhs) 3541894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3542894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs << rhs; 3543894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3544894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 354596d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int> operator>>=(Int &lhs, RValue<Int> rhs) 3546894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3547894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs >> rhs; 3548894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3549894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 355019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int> operator+(RValue<Int> val) 3551894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3552894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return val; 3553894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3554894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 355519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int> operator-(RValue<Int> val) 3556894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3557894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Int>(Nucleus::createNeg(val.value)); 3558894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3559894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 356019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int> operator~(RValue<Int> val) 3561894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3562894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Int>(Nucleus::createNot(val.value)); 3563894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3564894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 356596d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int> operator++(Int &val, int) // Post-increment 3566894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3567894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman RValue<Int> res = val; 3568894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 35691933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *inc = Nucleus::createAdd(res.value, V(Nucleus::createConstantInt(1))); 357066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman val.storeValue(inc); 3571894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3572894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return res; 3573894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3574894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 357596d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens const Int &operator++(Int &val) // Pre-increment 3576894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 35771933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *inc = Nucleus::createAdd(val.loadValue(), V(Nucleus::createConstantInt(1))); 357866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman val.storeValue(inc); 3579894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3580894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return val; 3581894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3582894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 358396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int> operator--(Int &val, int) // Post-decrement 3584894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3585894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman RValue<Int> res = val; 3586894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 35871933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *inc = Nucleus::createSub(res.value, V(Nucleus::createConstantInt(1))); 358866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman val.storeValue(inc); 3589894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3590894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return res; 3591894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3592894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 359396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens const Int &operator--(Int &val) // Pre-decrement 3594894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 35951933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *inc = Nucleus::createSub(val.loadValue(), V(Nucleus::createConstantInt(1))); 359666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman val.storeValue(inc); 3597894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3598894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return val; 3599894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3600894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 360119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator<(RValue<Int> lhs, RValue<Int> rhs) 3602894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3603894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpSLT(lhs.value, rhs.value)); 3604894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3605894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 360619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator<=(RValue<Int> lhs, RValue<Int> rhs) 3607894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3608894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpSLE(lhs.value, rhs.value)); 3609894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3610894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 361119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator>(RValue<Int> lhs, RValue<Int> rhs) 3612894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3613894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpSGT(lhs.value, rhs.value)); 3614894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3615894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 361619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator>=(RValue<Int> lhs, RValue<Int> rhs) 3617894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3618894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpSGE(lhs.value, rhs.value)); 3619894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3620894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 362119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator!=(RValue<Int> lhs, RValue<Int> rhs) 3622894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3623894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value)); 3624894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3625894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 362619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator==(RValue<Int> lhs, RValue<Int> rhs) 3627894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3628894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value)); 3629894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3630894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 363119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int> Max(RValue<Int> x, RValue<Int> y) 3632894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 363319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman return IfThenElse(x > y, x, y); 363419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 3635894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 363619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int> Min(RValue<Int> x, RValue<Int> y) 363719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 363819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman return IfThenElse(x < y, x, y); 3639894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3640894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 364119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int> Clamp(RValue<Int> x, RValue<Int> min, RValue<Int> max) 3642894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 364319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman return Min(Max(x, min), max); 364419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 364519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 364619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int> RoundInt(RValue<Float> cast) 364719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 364819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman return x86::cvtss2si(cast); 364919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 365066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman // return IfThenElse(val > 0.0f, Int(val + 0.5f), Int(val - 0.5f)); 3651894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3652894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 365319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Type *Int::getType() 3654894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3655ac2301298a42723d2c88f8749cab434ddd64e82dNicolas Capens return T(llvm::Type::getInt32Ty(*::context)); 3656894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3657894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 365819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Long::Long(RValue<Int> cast) 3659894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3660894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *integer = Nucleus::createSExt(cast.value, Long::getType()); 3661894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 366266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(integer); 3663894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3664894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 366519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Long::Long(RValue<UInt> cast) 3666894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3667894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *integer = Nucleus::createZExt(cast.value, Long::getType()); 3668894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 366966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(integer); 3670894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3671894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 367219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Long::Long(RValue<Long> rhs) 3673894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 367466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 3675894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3676894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 367796d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Long> Long::operator=(int64_t rhs) 3678894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 367913ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens return RValue<Long>(storeValue(Nucleus::createConstantLong(rhs))); 3680894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3681894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 368296d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Long> Long::operator=(RValue<Long> rhs) 3683894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 368466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 3685894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3686894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return rhs; 3687894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3688894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 368996d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Long> Long::operator=(const Long &rhs) 3690894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 369166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 369266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 369366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 369466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman return RValue<Long>(value); 369566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 369666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 369796d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Long> Long::operator=(const Reference<Long> &rhs) 369866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 369966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 370066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 3701894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3702894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Long>(value); 3703894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3704894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 370519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Long> operator+(RValue<Long> lhs, RValue<Long> rhs) 3706894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3707894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Long>(Nucleus::createAdd(lhs.value, rhs.value)); 3708894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3709894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 371019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Long> operator-(RValue<Long> lhs, RValue<Long> rhs) 3711894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3712894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Long>(Nucleus::createSub(lhs.value, rhs.value)); 3713894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3714894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 371596d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Long> operator+=(Long &lhs, RValue<Long> rhs) 3716894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3717894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs + rhs; 3718894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3719894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 372096d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Long> operator-=(Long &lhs, RValue<Long> rhs) 3721894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3722894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs - rhs; 3723894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3724894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 372566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman RValue<Long> AddAtomic(RValue<Pointer<Long> > x, RValue<Long> y) 3726894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 372719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman return RValue<Long>(Nucleus::createAtomicAdd(x.value, y.value)); 3728894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3729894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 373019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Type *Long::getType() 3731894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3732ac2301298a42723d2c88f8749cab434ddd64e82dNicolas Capens return T(llvm::Type::getInt64Ty(*::context)); 3733894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3734894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 373581f1830d46482cd635f7e7a92c55aec8683c1e55Nicolas Capens UInt::UInt(Argument<UInt> argument) 3736894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 373781f1830d46482cd635f7e7a92c55aec8683c1e55Nicolas Capens storeValue(argument.value); 3738894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3739894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 374019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman UInt::UInt(RValue<UShort> cast) 3741894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3742894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *integer = Nucleus::createZExt(cast.value, UInt::getType()); 3743894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 374466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(integer); 3745894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3746894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 374719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman UInt::UInt(RValue<Long> cast) 3748894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3749894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *integer = Nucleus::createTrunc(cast.value, UInt::getType()); 3750894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 375166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(integer); 3752894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3753894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 375419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman UInt::UInt(RValue<Float> cast) 3755894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3756764d14268b9067fec1589fc7182d328410a94d52Alexis Hetu // Note: createFPToUI is broken, must perform conversion using createFPtoSI 3757764d14268b9067fec1589fc7182d328410a94d52Alexis Hetu // Value *integer = Nucleus::createFPToUI(cast.value, UInt::getType()); 3758894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3759764d14268b9067fec1589fc7182d328410a94d52Alexis Hetu // Smallest positive value representable in UInt, but not in Int 3760764d14268b9067fec1589fc7182d328410a94d52Alexis Hetu const unsigned int ustart = 0x80000000u; 3761764d14268b9067fec1589fc7182d328410a94d52Alexis Hetu const float ustartf = float(ustart); 3762764d14268b9067fec1589fc7182d328410a94d52Alexis Hetu 3763764d14268b9067fec1589fc7182d328410a94d52Alexis Hetu // If the value is negative, store 0, otherwise store the result of the conversion 3764764d14268b9067fec1589fc7182d328410a94d52Alexis Hetu storeValue((~(As<Int>(cast) >> 31) & 3765764d14268b9067fec1589fc7182d328410a94d52Alexis Hetu // Check if the value can be represented as an Int 3766764d14268b9067fec1589fc7182d328410a94d52Alexis Hetu IfThenElse(cast >= ustartf, 3767764d14268b9067fec1589fc7182d328410a94d52Alexis Hetu // If the value is too large, subtract ustart and re-add it after conversion. 3768764d14268b9067fec1589fc7182d328410a94d52Alexis Hetu As<Int>(As<UInt>(Int(cast - Float(ustartf))) + UInt(ustart)), 3769764d14268b9067fec1589fc7182d328410a94d52Alexis Hetu // Otherwise, just convert normally 3770764d14268b9067fec1589fc7182d328410a94d52Alexis Hetu Int(cast))).value); 3771894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3772894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3773894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman UInt::UInt(int x) 3774894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 377566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(Nucleus::createConstantInt(x)); 3776894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3777894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3778894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman UInt::UInt(unsigned int x) 3779894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 378066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(Nucleus::createConstantInt(x)); 3781894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3782894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 378319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman UInt::UInt(RValue<UInt> rhs) 3784894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 378566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 3786894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3787894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 378819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman UInt::UInt(RValue<Int> rhs) 3789894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 379066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 3791894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3792894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3793894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman UInt::UInt(const UInt &rhs) 3794894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 379566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 379666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 379766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 3798894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 379966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman UInt::UInt(const Reference<UInt> &rhs) 380066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 380166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 380266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 3803894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3804894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3805894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman UInt::UInt(const Int &rhs) 3806894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 380766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 380866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 380966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 3810894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 381166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman UInt::UInt(const Reference<Int> &rhs) 381266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 381366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 381466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 3815894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3816894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 381796d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt> UInt::operator=(unsigned int rhs) 3818894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 381966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman return RValue<UInt>(storeValue(Nucleus::createConstantInt(rhs))); 3820894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3821894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 382296d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt> UInt::operator=(RValue<UInt> rhs) 3823894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 382466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 3825894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3826894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return rhs; 3827894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3828894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 382996d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt> UInt::operator=(RValue<Int> rhs) 3830894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 383166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 3832894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 383366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman return RValue<UInt>(rhs); 3834894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3835894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 383696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt> UInt::operator=(const UInt &rhs) 3837894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 383866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 383966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 384066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 384166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman return RValue<UInt>(value); 384266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 384366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 384496d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt> UInt::operator=(const Reference<UInt> &rhs) 384566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 384666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 384766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 3848894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3849894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UInt>(value); 3850894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3851894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 385296d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt> UInt::operator=(const Int &rhs) 3853894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 385466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 385566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 3856894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3857894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UInt>(value); 3858894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3859894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 386096d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt> UInt::operator=(const Reference<Int> &rhs) 3861894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 386266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 386366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 386466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 386566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman return RValue<UInt>(value); 3866894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3867894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 386819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt> operator+(RValue<UInt> lhs, RValue<UInt> rhs) 3869894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3870894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UInt>(Nucleus::createAdd(lhs.value, rhs.value)); 3871894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3872894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 387319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt> operator-(RValue<UInt> lhs, RValue<UInt> rhs) 3874894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3875894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UInt>(Nucleus::createSub(lhs.value, rhs.value)); 3876894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3877894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 387819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt> operator*(RValue<UInt> lhs, RValue<UInt> rhs) 3879894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3880894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UInt>(Nucleus::createMul(lhs.value, rhs.value)); 3881894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3882894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 388319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt> operator/(RValue<UInt> lhs, RValue<UInt> rhs) 3884894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3885894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UInt>(Nucleus::createUDiv(lhs.value, rhs.value)); 3886894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3887894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 388819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt> operator%(RValue<UInt> lhs, RValue<UInt> rhs) 3889894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3890894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UInt>(Nucleus::createURem(lhs.value, rhs.value)); 3891894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3892894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 389319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt> operator&(RValue<UInt> lhs, RValue<UInt> rhs) 3894894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3895894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UInt>(Nucleus::createAnd(lhs.value, rhs.value)); 3896894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3897894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 389819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt> operator|(RValue<UInt> lhs, RValue<UInt> rhs) 3899894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3900894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UInt>(Nucleus::createOr(lhs.value, rhs.value)); 3901894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3902894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 390319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt> operator^(RValue<UInt> lhs, RValue<UInt> rhs) 3904894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3905894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UInt>(Nucleus::createXor(lhs.value, rhs.value)); 3906894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3907894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 390819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt> operator<<(RValue<UInt> lhs, RValue<UInt> rhs) 3909894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3910894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UInt>(Nucleus::createShl(lhs.value, rhs.value)); 3911894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3912894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 391319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt> operator>>(RValue<UInt> lhs, RValue<UInt> rhs) 3914894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3915894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UInt>(Nucleus::createLShr(lhs.value, rhs.value)); 3916894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3917894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 391896d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt> operator+=(UInt &lhs, RValue<UInt> rhs) 3919894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3920894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs + rhs; 3921894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3922894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 392396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt> operator-=(UInt &lhs, RValue<UInt> rhs) 3924894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3925894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs - rhs; 3926894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3927894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 392896d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt> operator*=(UInt &lhs, RValue<UInt> rhs) 3929894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3930894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs * rhs; 3931894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3932894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 393396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt> operator/=(UInt &lhs, RValue<UInt> rhs) 3934894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3935894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs / rhs; 3936894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3937894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 393896d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt> operator%=(UInt &lhs, RValue<UInt> rhs) 3939894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3940894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs % rhs; 3941894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3942894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 394396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt> operator&=(UInt &lhs, RValue<UInt> rhs) 3944894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3945894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs & rhs; 3946894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3947894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 394896d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt> operator|=(UInt &lhs, RValue<UInt> rhs) 3949894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3950894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs | rhs; 3951894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3952894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 395396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt> operator^=(UInt &lhs, RValue<UInt> rhs) 3954894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3955894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs ^ rhs; 3956894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3957894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 395896d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt> operator<<=(UInt &lhs, RValue<UInt> rhs) 3959894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3960894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs << rhs; 3961894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3962894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 396396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt> operator>>=(UInt &lhs, RValue<UInt> rhs) 3964894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3965894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs >> rhs; 3966894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3967894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 396819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt> operator+(RValue<UInt> val) 3969894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3970894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return val; 3971894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3972894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 397319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt> operator-(RValue<UInt> val) 3974894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3975894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UInt>(Nucleus::createNeg(val.value)); 3976894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3977894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 397819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt> operator~(RValue<UInt> val) 3979894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3980894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UInt>(Nucleus::createNot(val.value)); 3981894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3982894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 398396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt> operator++(UInt &val, int) // Post-increment 3984894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3985894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman RValue<UInt> res = val; 3986894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 39871933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *inc = Nucleus::createAdd(res.value, V(Nucleus::createConstantInt(1))); 398866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman val.storeValue(inc); 3989894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3990894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return res; 3991894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 3992894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 399396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens const UInt &operator++(UInt &val) // Pre-increment 3994894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 39951933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *inc = Nucleus::createAdd(val.loadValue(), V(Nucleus::createConstantInt(1))); 399666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman val.storeValue(inc); 3997894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3998894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return val; 3999894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4000894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 400196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt> operator--(UInt &val, int) // Post-decrement 4002894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4003894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman RValue<UInt> res = val; 4004894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 40051933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *inc = Nucleus::createSub(res.value, V(Nucleus::createConstantInt(1))); 400666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman val.storeValue(inc); 4007894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4008894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return res; 4009894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4010894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 401196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens const UInt &operator--(UInt &val) // Pre-decrement 4012894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 40131933654b62251805d4575b05b6829275b0fe6142Nicolas Capens Value *inc = Nucleus::createSub(val.loadValue(), V(Nucleus::createConstantInt(1))); 401466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman val.storeValue(inc); 4015894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4016894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return val; 4017894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4018894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 401919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt> Max(RValue<UInt> x, RValue<UInt> y) 402019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 402119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman return IfThenElse(x > y, x, y); 402219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 402319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 402419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt> Min(RValue<UInt> x, RValue<UInt> y) 402519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 402619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman return IfThenElse(x < y, x, y); 402719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 402819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 402919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt> Clamp(RValue<UInt> x, RValue<UInt> min, RValue<UInt> max) 403019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 403119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman return Min(Max(x, min), max); 403219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 403319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 403419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator<(RValue<UInt> lhs, RValue<UInt> rhs) 4035894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4036894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpULT(lhs.value, rhs.value)); 4037894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4038894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 403919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator<=(RValue<UInt> lhs, RValue<UInt> rhs) 4040894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4041894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpULE(lhs.value, rhs.value)); 4042894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4043894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 404419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator>(RValue<UInt> lhs, RValue<UInt> rhs) 4045894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4046894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpUGT(lhs.value, rhs.value)); 4047894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4048894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 404919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator>=(RValue<UInt> lhs, RValue<UInt> rhs) 4050894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4051894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpUGE(lhs.value, rhs.value)); 4052894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4053894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 405419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator!=(RValue<UInt> lhs, RValue<UInt> rhs) 4055894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4056894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value)); 4057894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4058894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 405919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator==(RValue<UInt> lhs, RValue<UInt> rhs) 4060894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4061894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value)); 4062894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4063894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 406419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// RValue<UInt> RoundUInt(RValue<Float> cast) 4065894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// { 4066894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// return x86::cvtss2si(val); // FIXME: Unsigned 4067894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// 406866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// // return IfThenElse(val > 0.0f, Int(val + 0.5f), Int(val - 0.5f)); 4069894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// } 4070894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 407119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Type *UInt::getType() 4072894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4073ac2301298a42723d2c88f8749cab434ddd64e82dNicolas Capens return T(llvm::Type::getInt32Ty(*::context)); 4074894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4075894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 407619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// Int2::Int2(RValue<Int> cast) 407719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 407819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// Value *extend = Nucleus::createZExt(cast.value, Long::getType()); 407919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// Value *vector = Nucleus::createBitCast(extend, Int2::getType()); 408066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// 4081e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens// int shuffle[2] = {0, 0}; 4082e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens// Value *replicate = Nucleus::createShuffleVector(vector, vector, shuffle); 408319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// 408466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// storeValue(replicate); 408519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 4086894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 408719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Int2::Int2(RValue<Int4> cast) 4088894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 408901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens storeValue(Nucleus::createBitCast(cast.value, getType())); 4090894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4091894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4092894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Int2::Int2(int x, int y) 4093894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 409413ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens int64_t constantVector[2] = {x, y}; 409501a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens storeValue(Nucleus::createConstantVector(constantVector, getType())); 4096894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4097894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 409819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Int2::Int2(RValue<Int2> rhs) 4099894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 410066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 4101894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4102894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4103894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Int2::Int2(const Int2 &rhs) 4104894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 410566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 410666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 410766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 410866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 410966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Int2::Int2(const Reference<Int2> &rhs) 411066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 411166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 411266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 4113894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4114894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 411562abb5589758c3d3e32f5a7a2d7e0ad936d5c5f1Nicolas Capens Int2::Int2(RValue<Int> lo, RValue<Int> hi) 411662abb5589758c3d3e32f5a7a2d7e0ad936d5c5f1Nicolas Capens { 411701a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens int shuffle[4] = {0, 4, 1, 5}; 411801a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens Value *packed = Nucleus::createShuffleVector(Int4(lo).loadValue(), Int4(hi).loadValue(), shuffle); 411905b3d665fd92cd11b8a6517dafe661a5398547b7Nicolas Capens 412001a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens storeValue(Nucleus::createBitCast(packed, Int2::getType())); 412162abb5589758c3d3e32f5a7a2d7e0ad936d5c5f1Nicolas Capens } 412262abb5589758c3d3e32f5a7a2d7e0ad936d5c5f1Nicolas Capens 412396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int2> Int2::operator=(RValue<Int2> rhs) 4124894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 412566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 4126894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4127894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return rhs; 4128894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4129894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 413096d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int2> Int2::operator=(const Int2 &rhs) 4131894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 413266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 413366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 413466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 413566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman return RValue<Int2>(value); 413666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 413766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 413896d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int2> Int2::operator=(const Reference<Int2> &rhs) 413966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 414066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 414166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 4142894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4143894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Int2>(value); 4144894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4145894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 414619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int2> operator+(RValue<Int2> lhs, RValue<Int2> rhs) 4147894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 414801a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<Int2>(Nucleus::createAdd(lhs.value, rhs.value)); 4149894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4150894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 415119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int2> operator-(RValue<Int2> lhs, RValue<Int2> rhs) 4152894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 415301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<Int2>(Nucleus::createSub(lhs.value, rhs.value)); 4154894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4155894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 415619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// RValue<Int2> operator*(RValue<Int2> lhs, RValue<Int2> rhs) 415719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 415819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return RValue<Int2>(Nucleus::createMul(lhs.value, rhs.value)); 415919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 4160894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 416119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// RValue<Int2> operator/(RValue<Int2> lhs, RValue<Int2> rhs) 416219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 416319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return RValue<Int2>(Nucleus::createSDiv(lhs.value, rhs.value)); 416419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 4165894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 416619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// RValue<Int2> operator%(RValue<Int2> lhs, RValue<Int2> rhs) 416719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 416819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return RValue<Int2>(Nucleus::createSRem(lhs.value, rhs.value)); 416919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 4170894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 417119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int2> operator&(RValue<Int2> lhs, RValue<Int2> rhs) 4172894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 417301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<Int2>(Nucleus::createAnd(lhs.value, rhs.value)); 4174894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4175894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 417619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int2> operator|(RValue<Int2> lhs, RValue<Int2> rhs) 4177894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 417801a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<Int2>(Nucleus::createOr(lhs.value, rhs.value)); 4179894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4180894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 418119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int2> operator^(RValue<Int2> lhs, RValue<Int2> rhs) 4182894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 418301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<Int2>(Nucleus::createXor(lhs.value, rhs.value)); 4184894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4185894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 418619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int2> operator<<(RValue<Int2> lhs, unsigned char rhs) 4187894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4188894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // return RValue<Int2>(Nucleus::createShl(lhs.value, rhs.value)); 4189894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4190894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::pslld(lhs, rhs); 4191894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4192894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 419319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int2> operator>>(RValue<Int2> lhs, unsigned char rhs) 4194894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4195894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // return RValue<Int2>(Nucleus::createAShr(lhs.value, rhs.value)); 4196894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4197894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::psrad(lhs, rhs); 4198894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4199894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 420096d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int2> operator+=(Int2 &lhs, RValue<Int2> rhs) 4201894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4202894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs + rhs; 4203894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4204894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 420596d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int2> operator-=(Int2 &lhs, RValue<Int2> rhs) 4206894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4207894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs - rhs; 4208894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4209894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 421096d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens// RValue<Int2> operator*=(Int2 &lhs, RValue<Int2> rhs) 421119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 421219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return lhs = lhs * rhs; 421319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 4214894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 421596d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens// RValue<Int2> operator/=(Int2 &lhs, RValue<Int2> rhs) 421619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 421719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return lhs = lhs / rhs; 421819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 4219894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 422096d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens// RValue<Int2> operator%=(Int2 &lhs, RValue<Int2> rhs) 422119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 422219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return lhs = lhs % rhs; 422319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 4224894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 422596d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int2> operator&=(Int2 &lhs, RValue<Int2> rhs) 4226894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4227894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs & rhs; 4228894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4229894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 423096d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int2> operator|=(Int2 &lhs, RValue<Int2> rhs) 4231894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4232894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs | rhs; 4233894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4234894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 423596d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int2> operator^=(Int2 &lhs, RValue<Int2> rhs) 4236894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4237894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs ^ rhs; 4238894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4239894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 424096d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int2> operator<<=(Int2 &lhs, unsigned char rhs) 4241894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4242894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs << rhs; 4243894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4244894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 424596d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int2> operator>>=(Int2 &lhs, unsigned char rhs) 4246894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4247894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs >> rhs; 4248894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4249894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 425019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// RValue<Int2> operator+(RValue<Int2> val) 425119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 425219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return val; 425319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 4254894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 425519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// RValue<Int2> operator-(RValue<Int2> val) 425619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 425719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return RValue<Int2>(Nucleus::createNeg(val.value)); 425819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 4259894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 426019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int2> operator~(RValue<Int2> val) 4261894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 426201a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<Int2>(Nucleus::createNot(val.value)); 4263894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4264894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 426545f187a368c383d2f44f369b965d361e1ce33e44Nicolas Capens RValue<Short4> UnpackLow(RValue<Int2> x, RValue<Int2> y) 4266894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 426701a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens int shuffle[4] = {0, 4, 1, 5}; // Real type is v4i32 426801a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<Short4>(Nucleus::createShuffleVector(x.value, y.value, shuffle)); 4269894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 427066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 427145f187a368c383d2f44f369b965d361e1ce33e44Nicolas Capens RValue<Short4> UnpackHigh(RValue<Int2> x, RValue<Int2> y) 4272894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 427301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens int shuffle[4] = {0, 4, 1, 5}; // Real type is v4i32 427401a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens auto lowHigh = RValue<Int4>(Nucleus::createShuffleVector(x.value, y.value, shuffle)); 427501a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<Short4>(Swizzle(lowHigh, 0xEE)); 4276894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4277894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 427819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int> Extract(RValue<Int2> val, int i) 4279894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 428001a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<Int>(Nucleus::createExtractElement(val.value, Int::getType(), i)); 4281894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4282894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4283fff3c9bc1a90b9dc34a423ba91fbf6952980c64cNicolas Capens RValue<Int2> Insert(RValue<Int2> val, RValue<Int> element, int i) 4284fff3c9bc1a90b9dc34a423ba91fbf6952980c64cNicolas Capens { 428501a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<Int2>(Nucleus::createInsertElement(val.value, element.value, i)); 4286fff3c9bc1a90b9dc34a423ba91fbf6952980c64cNicolas Capens } 4287894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 428819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Type *Int2::getType() 4289894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4290fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return T(Type_v2i32); 4291894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4292894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4293894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman UInt2::UInt2(unsigned int x, unsigned int y) 4294894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 429513ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens int64_t constantVector[2] = {x, y}; 429601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens storeValue(Nucleus::createConstantVector(constantVector, getType())); 4297894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4298894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 429919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman UInt2::UInt2(RValue<UInt2> rhs) 4300894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 430166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 4302894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4303894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4304894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman UInt2::UInt2(const UInt2 &rhs) 4305894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 430666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 430766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 430866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 430966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 431066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman UInt2::UInt2(const Reference<UInt2> &rhs) 431166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 431266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 431366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 4314894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4315894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 431696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt2> UInt2::operator=(RValue<UInt2> rhs) 4317894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 431866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 4319894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4320894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return rhs; 4321894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4322894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 432396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt2> UInt2::operator=(const UInt2 &rhs) 4324894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 432566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 432666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 432766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 432866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman return RValue<UInt2>(value); 432966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 433066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 433196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt2> UInt2::operator=(const Reference<UInt2> &rhs) 433266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 433366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 433466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 4335894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4336894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UInt2>(value); 4337894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4338894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 433919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt2> operator+(RValue<UInt2> lhs, RValue<UInt2> rhs) 4340894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 434101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<UInt2>(Nucleus::createAdd(lhs.value, rhs.value)); 4342894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4343894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 434419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt2> operator-(RValue<UInt2> lhs, RValue<UInt2> rhs) 4345894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 434601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<UInt2>(Nucleus::createSub(lhs.value, rhs.value)); 4347894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4348894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 434919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// RValue<UInt2> operator*(RValue<UInt2> lhs, RValue<UInt2> rhs) 435019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 435119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return RValue<UInt2>(Nucleus::createMul(lhs.value, rhs.value)); 435219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 4353894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 435419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// RValue<UInt2> operator/(RValue<UInt2> lhs, RValue<UInt2> rhs) 435519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 435619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return RValue<UInt2>(Nucleus::createUDiv(lhs.value, rhs.value)); 435719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 4358894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 435919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// RValue<UInt2> operator%(RValue<UInt2> lhs, RValue<UInt2> rhs) 436019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 436119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return RValue<UInt2>(Nucleus::createURem(lhs.value, rhs.value)); 436219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 4363894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 436419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt2> operator&(RValue<UInt2> lhs, RValue<UInt2> rhs) 4365894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 436601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<UInt2>(Nucleus::createAnd(lhs.value, rhs.value)); 4367894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4368894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 436919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt2> operator|(RValue<UInt2> lhs, RValue<UInt2> rhs) 4370894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 437101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<UInt2>(Nucleus::createOr(lhs.value, rhs.value)); 4372894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4373894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 437419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt2> operator^(RValue<UInt2> lhs, RValue<UInt2> rhs) 4375894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 437601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<UInt2>(Nucleus::createXor(lhs.value, rhs.value)); 4377894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4378894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 437919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt2> operator<<(RValue<UInt2> lhs, unsigned char rhs) 4380894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4381894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // return RValue<UInt2>(Nucleus::createShl(lhs.value, rhs.value)); 4382894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4383894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return As<UInt2>(x86::pslld(As<Int2>(lhs), rhs)); 4384894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4385894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 438619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt2> operator>>(RValue<UInt2> lhs, unsigned char rhs) 4387894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4388894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // return RValue<UInt2>(Nucleus::createLShr(lhs.value, rhs.value)); 4389894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4390894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::psrld(lhs, rhs); 4391894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4392894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 439396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt2> operator+=(UInt2 &lhs, RValue<UInt2> rhs) 4394894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4395894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs + rhs; 4396894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4397894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 439896d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt2> operator-=(UInt2 &lhs, RValue<UInt2> rhs) 4399894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4400894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs - rhs; 4401894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4402894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 440396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens// RValue<UInt2> operator*=(UInt2 &lhs, RValue<UInt2> rhs) 440419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 440519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return lhs = lhs * rhs; 440619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 4407894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 440896d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens// RValue<UInt2> operator/=(UInt2 &lhs, RValue<UInt2> rhs) 440919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 441019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return lhs = lhs / rhs; 441119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 4412894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 441396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens// RValue<UInt2> operator%=(UInt2 &lhs, RValue<UInt2> rhs) 441419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 441519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return lhs = lhs % rhs; 441619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 4417894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 441896d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt2> operator&=(UInt2 &lhs, RValue<UInt2> rhs) 4419894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4420894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs & rhs; 4421894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4422894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 442396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt2> operator|=(UInt2 &lhs, RValue<UInt2> rhs) 4424894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4425894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs | rhs; 4426894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4427894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 442896d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt2> operator^=(UInt2 &lhs, RValue<UInt2> rhs) 4429894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4430894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs ^ rhs; 4431894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4432894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 443396d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt2> operator<<=(UInt2 &lhs, unsigned char rhs) 4434894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4435894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs << rhs; 4436894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4437894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 443896d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt2> operator>>=(UInt2 &lhs, unsigned char rhs) 4439894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4440894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs >> rhs; 4441894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4442894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 444319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// RValue<UInt2> operator+(RValue<UInt2> val) 444419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 444519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return val; 444619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 4447894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 444819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// RValue<UInt2> operator-(RValue<UInt2> val) 444919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 445019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return RValue<UInt2>(Nucleus::createNeg(val.value)); 445119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 4452894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 445319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt2> operator~(RValue<UInt2> val) 4454894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 445501a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<UInt2>(Nucleus::createNot(val.value)); 4456894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4457894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 445819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Type *UInt2::getType() 4459894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4460fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return T(Type_v2i32); 4461894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4462894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4463cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Int4::Int4() : XYZW(this) 4464cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens { 4465cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens } 4466cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens 4467cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Int4::Int4(RValue<Byte4> cast) : XYZW(this) 4468601d00599dc6aba541c6fa158b31c3a8fe17a5b5Meng-Lin Wu { 446901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens if(CPUID::supportsSSE4_1()) 4470601d00599dc6aba541c6fa158b31c3a8fe17a5b5Meng-Lin Wu { 447101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens *this = x86::pmovzxbd(As<Byte16>(cast)); 4472601d00599dc6aba541c6fa158b31c3a8fe17a5b5Meng-Lin Wu } 4473601d00599dc6aba541c6fa158b31c3a8fe17a5b5Meng-Lin Wu else 4474601d00599dc6aba541c6fa158b31c3a8fe17a5b5Meng-Lin Wu { 4475e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens int swizzle[16] = {0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23}; 447601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens Value *a = Nucleus::createBitCast(cast.value, Byte16::getType()); 447701a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens Value *b = Nucleus::createShuffleVector(a, V(Nucleus::createNullValue(Byte16::getType())), swizzle); 4478601d00599dc6aba541c6fa158b31c3a8fe17a5b5Meng-Lin Wu 4479e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens int swizzle2[8] = {0, 8, 1, 9, 2, 10, 3, 11}; 448001a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens Value *c = Nucleus::createBitCast(b, Short8::getType()); 448101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens Value *d = Nucleus::createShuffleVector(c, V(Nucleus::createNullValue(Short8::getType())), swizzle2); 4482601d00599dc6aba541c6fa158b31c3a8fe17a5b5Meng-Lin Wu 448301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens *this = As<Int4>(d); 448401a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens } 4485601d00599dc6aba541c6fa158b31c3a8fe17a5b5Meng-Lin Wu } 4486601d00599dc6aba541c6fa158b31c3a8fe17a5b5Meng-Lin Wu 4487cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Int4::Int4(RValue<SByte4> cast) : XYZW(this) 4488601d00599dc6aba541c6fa158b31c3a8fe17a5b5Meng-Lin Wu { 448901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens if(CPUID::supportsSSE4_1()) 4490601d00599dc6aba541c6fa158b31c3a8fe17a5b5Meng-Lin Wu { 449101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens *this = x86::pmovsxbd(As<SByte16>(cast)); 4492601d00599dc6aba541c6fa158b31c3a8fe17a5b5Meng-Lin Wu } 4493601d00599dc6aba541c6fa158b31c3a8fe17a5b5Meng-Lin Wu else 4494601d00599dc6aba541c6fa158b31c3a8fe17a5b5Meng-Lin Wu { 449501a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens int swizzle[16] = {0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7}; 449601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens Value *a = Nucleus::createBitCast(cast.value, Byte16::getType()); 449701a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens Value *b = Nucleus::createShuffleVector(a, a, swizzle); 4498601d00599dc6aba541c6fa158b31c3a8fe17a5b5Meng-Lin Wu 4499e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens int swizzle2[8] = {0, 0, 1, 1, 2, 2, 3, 3}; 450001a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens Value *c = Nucleus::createBitCast(b, Short8::getType()); 450101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens Value *d = Nucleus::createShuffleVector(c, c, swizzle2); 4502601d00599dc6aba541c6fa158b31c3a8fe17a5b5Meng-Lin Wu 450301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens *this = As<Int4>(d) >> 24; 4504601d00599dc6aba541c6fa158b31c3a8fe17a5b5Meng-Lin Wu } 4505601d00599dc6aba541c6fa158b31c3a8fe17a5b5Meng-Lin Wu } 4506601d00599dc6aba541c6fa158b31c3a8fe17a5b5Meng-Lin Wu 4507cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Int4::Int4(RValue<Float4> cast) : XYZW(this) 4508894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4509894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *xyzw = Nucleus::createFPToSI(cast.value, Int4::getType()); 4510894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 451166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(xyzw); 4512894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4513894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4514cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Int4::Int4(RValue<Short4> cast) : XYZW(this) 45152aa852f4c1246ef8ab2a46d5d3f6a981c2ddda0aAlexis Hetu { 45162aa852f4c1246ef8ab2a46d5d3f6a981c2ddda0aAlexis Hetu if(CPUID::supportsSSE4_1()) 45172aa852f4c1246ef8ab2a46d5d3f6a981c2ddda0aAlexis Hetu { 451801a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens *this = x86::pmovsxwd(As<Short8>(cast)); 45192aa852f4c1246ef8ab2a46d5d3f6a981c2ddda0aAlexis Hetu } 45202aa852f4c1246ef8ab2a46d5d3f6a981c2ddda0aAlexis Hetu else 45212aa852f4c1246ef8ab2a46d5d3f6a981c2ddda0aAlexis Hetu { 4522e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens int swizzle[8] = {0, 0, 1, 1, 2, 2, 3, 3}; 452301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens Value *c = Nucleus::createShuffleVector(cast.value, cast.value, swizzle); 452401a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens *this = As<Int4>(c) >> 16; 45252aa852f4c1246ef8ab2a46d5d3f6a981c2ddda0aAlexis Hetu } 45262aa852f4c1246ef8ab2a46d5d3f6a981c2ddda0aAlexis Hetu } 45272aa852f4c1246ef8ab2a46d5d3f6a981c2ddda0aAlexis Hetu 4528cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Int4::Int4(RValue<UShort4> cast) : XYZW(this) 45292aa852f4c1246ef8ab2a46d5d3f6a981c2ddda0aAlexis Hetu { 45302aa852f4c1246ef8ab2a46d5d3f6a981c2ddda0aAlexis Hetu if(CPUID::supportsSSE4_1()) 45312aa852f4c1246ef8ab2a46d5d3f6a981c2ddda0aAlexis Hetu { 453201a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens *this = x86::pmovzxwd(As<UShort8>(cast)); 45332aa852f4c1246ef8ab2a46d5d3f6a981c2ddda0aAlexis Hetu } 45342aa852f4c1246ef8ab2a46d5d3f6a981c2ddda0aAlexis Hetu else 45352aa852f4c1246ef8ab2a46d5d3f6a981c2ddda0aAlexis Hetu { 4536e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens int swizzle[8] = {0, 8, 1, 9, 2, 10, 3, 11}; 453701a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens Value *c = Nucleus::createShuffleVector(cast.value, Short8(0, 0, 0, 0, 0, 0, 0, 0).loadValue(), swizzle); 453801a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens *this = As<Int4>(c); 45392aa852f4c1246ef8ab2a46d5d3f6a981c2ddda0aAlexis Hetu } 45402aa852f4c1246ef8ab2a46d5d3f6a981c2ddda0aAlexis Hetu } 45412aa852f4c1246ef8ab2a46d5d3f6a981c2ddda0aAlexis Hetu 4542cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Int4::Int4(int xyzw) : XYZW(this) 4543894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4544894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman constant(xyzw, xyzw, xyzw, xyzw); 4545894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4546894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4547cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Int4::Int4(int x, int yzw) : XYZW(this) 4548894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4549894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman constant(x, yzw, yzw, yzw); 4550894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4551894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4552cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Int4::Int4(int x, int y, int zw) : XYZW(this) 4553894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4554894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman constant(x, y, zw, zw); 4555894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4556894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4557cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Int4::Int4(int x, int y, int z, int w) : XYZW(this) 4558894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4559894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman constant(x, y, z, w); 4560894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4561894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4562894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman void Int4::constant(int x, int y, int z, int w) 4563894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 456413ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens int64_t constantVector[4] = {x, y, z, w}; 456513ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens storeValue(Nucleus::createConstantVector(constantVector, getType())); 4566894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4567894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4568cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Int4::Int4(RValue<Int4> rhs) : XYZW(this) 4569894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 457066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 4571894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4572894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4573cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Int4::Int4(const Int4 &rhs) : XYZW(this) 4574894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 457566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 457666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 457766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 457866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 4579cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Int4::Int4(const Reference<Int4> &rhs) : XYZW(this) 458066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 458166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 458266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 4583894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4584894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4585cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Int4::Int4(RValue<UInt4> rhs) : XYZW(this) 458619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 458766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 458819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 458919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 4590cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Int4::Int4(const UInt4 &rhs) : XYZW(this) 459119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 459266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 459366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 459466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 459566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 4596cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Int4::Int4(const Reference<UInt4> &rhs) : XYZW(this) 459766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 459866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 459966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 460019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 460119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 4602cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Int4::Int4(RValue<Int2> lo, RValue<Int2> hi) : XYZW(this) 460362abb5589758c3d3e32f5a7a2d7e0ad936d5c5f1Nicolas Capens { 460401a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens int shuffle[4] = {0, 1, 4, 5}; // Real type is v4i32 460501a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens Value *packed = Nucleus::createShuffleVector(lo.value, hi.value, shuffle); 460662abb5589758c3d3e32f5a7a2d7e0ad936d5c5f1Nicolas Capens 460701a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens storeValue(packed); 460862abb5589758c3d3e32f5a7a2d7e0ad936d5c5f1Nicolas Capens } 460962abb5589758c3d3e32f5a7a2d7e0ad936d5c5f1Nicolas Capens 4610cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Int4::Int4(RValue<Int> rhs) : XYZW(this) 461124c8cf096174ba6c37b719d9caf13933ea9b12c9Nicolas Capens { 461224c8cf096174ba6c37b719d9caf13933ea9b12c9Nicolas Capens Value *vector = loadValue(); 461324c8cf096174ba6c37b719d9caf13933ea9b12c9Nicolas Capens Value *insert = Nucleus::createInsertElement(vector, rhs.value, 0); 461424c8cf096174ba6c37b719d9caf13933ea9b12c9Nicolas Capens 4615e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens int swizzle[4] = {0, 0, 0, 0}; 4616e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens Value *replicate = Nucleus::createShuffleVector(insert, insert, swizzle); 461724c8cf096174ba6c37b719d9caf13933ea9b12c9Nicolas Capens 461824c8cf096174ba6c37b719d9caf13933ea9b12c9Nicolas Capens storeValue(replicate); 461924c8cf096174ba6c37b719d9caf13933ea9b12c9Nicolas Capens } 462024c8cf096174ba6c37b719d9caf13933ea9b12c9Nicolas Capens 4621cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Int4::Int4(const Int &rhs) : XYZW(this) 462224c8cf096174ba6c37b719d9caf13933ea9b12c9Nicolas Capens { 462324c8cf096174ba6c37b719d9caf13933ea9b12c9Nicolas Capens *this = RValue<Int>(rhs.loadValue()); 462424c8cf096174ba6c37b719d9caf13933ea9b12c9Nicolas Capens } 462524c8cf096174ba6c37b719d9caf13933ea9b12c9Nicolas Capens 4626cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Int4::Int4(const Reference<Int> &rhs) : XYZW(this) 462724c8cf096174ba6c37b719d9caf13933ea9b12c9Nicolas Capens { 462824c8cf096174ba6c37b719d9caf13933ea9b12c9Nicolas Capens *this = RValue<Int>(rhs.loadValue()); 462924c8cf096174ba6c37b719d9caf13933ea9b12c9Nicolas Capens } 463024c8cf096174ba6c37b719d9caf13933ea9b12c9Nicolas Capens 463196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int4> Int4::operator=(RValue<Int4> rhs) 4632894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 463366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 4634894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4635894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return rhs; 4636894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4637894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 463896d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int4> Int4::operator=(const Int4 &rhs) 4639894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 464066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 464166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 464266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 464366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman return RValue<Int4>(value); 464466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 464566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 464696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int4> Int4::operator=(const Reference<Int4> &rhs) 464766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 464866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 464966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 4650894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4651894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Int4>(value); 4652894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4653894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 465419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> operator+(RValue<Int4> lhs, RValue<Int4> rhs) 4655894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4656894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Int4>(Nucleus::createAdd(lhs.value, rhs.value)); 4657894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4658894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 465919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> operator-(RValue<Int4> lhs, RValue<Int4> rhs) 4660894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4661894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Int4>(Nucleus::createSub(lhs.value, rhs.value)); 4662894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4663894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 466419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> operator*(RValue<Int4> lhs, RValue<Int4> rhs) 4665894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4666894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Int4>(Nucleus::createMul(lhs.value, rhs.value)); 4667894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4668894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4669d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu RValue<Int4> operator/(RValue<Int4> lhs, RValue<Int4> rhs) 4670d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu { 4671d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu return RValue<Int4>(Nucleus::createSDiv(lhs.value, rhs.value)); 4672d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu } 4673894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4674d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu RValue<Int4> operator%(RValue<Int4> lhs, RValue<Int4> rhs) 4675d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu { 4676d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu return RValue<Int4>(Nucleus::createSRem(lhs.value, rhs.value)); 4677d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu } 4678894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 467919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> operator&(RValue<Int4> lhs, RValue<Int4> rhs) 4680894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4681894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Int4>(Nucleus::createAnd(lhs.value, rhs.value)); 4682894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4683894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 468419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> operator|(RValue<Int4> lhs, RValue<Int4> rhs) 4685894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4686894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Int4>(Nucleus::createOr(lhs.value, rhs.value)); 4687894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4688894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 468919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> operator^(RValue<Int4> lhs, RValue<Int4> rhs) 4690894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4691894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Int4>(Nucleus::createXor(lhs.value, rhs.value)); 4692894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4693894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 469419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> operator<<(RValue<Int4> lhs, unsigned char rhs) 4695894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4696894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::pslld(lhs, rhs); 4697894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4698894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 469919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> operator>>(RValue<Int4> lhs, unsigned char rhs) 4700894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4701894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::psrad(lhs, rhs); 4702894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4703894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4704d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu RValue<Int4> operator<<(RValue<Int4> lhs, RValue<Int4> rhs) 4705d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu { 4706d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu return RValue<Int4>(Nucleus::createShl(lhs.value, rhs.value)); 4707d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu } 4708d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu 4709d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu RValue<Int4> operator>>(RValue<Int4> lhs, RValue<Int4> rhs) 4710d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu { 4711d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu return RValue<Int4>(Nucleus::createAShr(lhs.value, rhs.value)); 4712d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu } 4713d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu 471496d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int4> operator+=(Int4 &lhs, RValue<Int4> rhs) 4715894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4716894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs + rhs; 4717894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4718894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 471996d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int4> operator-=(Int4 &lhs, RValue<Int4> rhs) 4720894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4721894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs - rhs; 4722894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4723894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 472496d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int4> operator*=(Int4 &lhs, RValue<Int4> rhs) 4725894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4726894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs * rhs; 4727894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4728894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 472996d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens// RValue<Int4> operator/=(Int4 &lhs, RValue<Int4> rhs) 473019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 473119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return lhs = lhs / rhs; 473219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 4733894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 473496d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens// RValue<Int4> operator%=(Int4 &lhs, RValue<Int4> rhs) 473519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 473619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return lhs = lhs % rhs; 473719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 4738894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 473996d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int4> operator&=(Int4 &lhs, RValue<Int4> rhs) 4740894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4741894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs & rhs; 4742894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4743894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 474496d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int4> operator|=(Int4 &lhs, RValue<Int4> rhs) 4745894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4746894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs | rhs; 4747894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4748894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 474996d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int4> operator^=(Int4 &lhs, RValue<Int4> rhs) 4750894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4751894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs ^ rhs; 4752894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4753894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 475496d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int4> operator<<=(Int4 &lhs, unsigned char rhs) 4755894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4756894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs << rhs; 4757894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4758894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 475996d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Int4> operator>>=(Int4 &lhs, unsigned char rhs) 4760894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4761894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs >> rhs; 4762894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4763894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 476419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> operator+(RValue<Int4> val) 4765894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4766894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return val; 4767894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4768894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 476919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> operator-(RValue<Int4> val) 4770894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4771894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Int4>(Nucleus::createNeg(val.value)); 4772894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4773894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 477419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> operator~(RValue<Int4> val) 4775894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4776894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Int4>(Nucleus::createNot(val.value)); 4777894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4778894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 477919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> CmpEQ(RValue<Int4> x, RValue<Int4> y) 478019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 4781197226a0e460200ad65a033fad60bb38c9c8a2edNicolas Capens // FIXME: An LLVM bug causes SExt(ICmpCC()) to produce 0 or 1 instead of 0 or ~0 4782fb60399746e6d03e28dbaa5f8b3b1c38935ff35eAlexis Hetu // Restore the following line when LLVM is updated to a version where this issue is fixed. 4783fb60399746e6d03e28dbaa5f8b3b1c38935ff35eAlexis Hetu // return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpEQ(x.value, y.value), Int4::getType())); 4784fb60399746e6d03e28dbaa5f8b3b1c38935ff35eAlexis Hetu return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpNE(x.value, y.value), Int4::getType())) ^ Int4(0xFFFFFFFF); 478519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 478619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 478719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> CmpLT(RValue<Int4> x, RValue<Int4> y) 478819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 47899ae6cfd7474303a699af8e98d9449d6a78fd02a8Nicolas Capens // FIXME: An LLVM bug causes SExt(ICmpCC()) to produce 0 or 1 instead of 0 or ~0 47909ae6cfd7474303a699af8e98d9449d6a78fd02a8Nicolas Capens // Restore the following line when LLVM is updated to a version where this issue is fixed. 47919ae6cfd7474303a699af8e98d9449d6a78fd02a8Nicolas Capens // return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSLT(x.value, y.value), Int4::getType())); 47929ae6cfd7474303a699af8e98d9449d6a78fd02a8Nicolas Capens return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSGE(x.value, y.value), Int4::getType())) ^ Int4(0xFFFFFFFF); 479319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 479419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 479519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> CmpLE(RValue<Int4> x, RValue<Int4> y) 479619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 4797197226a0e460200ad65a033fad60bb38c9c8a2edNicolas Capens // FIXME: An LLVM bug causes SExt(ICmpCC()) to produce 0 or 1 instead of 0 or ~0 4798197226a0e460200ad65a033fad60bb38c9c8a2edNicolas Capens // Restore the following line when LLVM is updated to a version where this issue is fixed. 4799197226a0e460200ad65a033fad60bb38c9c8a2edNicolas Capens // return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSLE(x.value, y.value), Int4::getType())); 4800197226a0e460200ad65a033fad60bb38c9c8a2edNicolas Capens return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSGT(x.value, y.value), Int4::getType())) ^ Int4(0xFFFFFFFF); 480119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 480219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 480319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> CmpNEQ(RValue<Int4> x, RValue<Int4> y) 480419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 48059ae6cfd7474303a699af8e98d9449d6a78fd02a8Nicolas Capens // FIXME: An LLVM bug causes SExt(ICmpCC()) to produce 0 or 1 instead of 0 or ~0 48069ae6cfd7474303a699af8e98d9449d6a78fd02a8Nicolas Capens // Restore the following line when LLVM is updated to a version where this issue is fixed. 48079ae6cfd7474303a699af8e98d9449d6a78fd02a8Nicolas Capens // return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpNE(x.value, y.value), Int4::getType())); 48089ae6cfd7474303a699af8e98d9449d6a78fd02a8Nicolas Capens return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpEQ(x.value, y.value), Int4::getType())) ^ Int4(0xFFFFFFFF); 480919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 481019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 481119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> CmpNLT(RValue<Int4> x, RValue<Int4> y) 481219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 4813197226a0e460200ad65a033fad60bb38c9c8a2edNicolas Capens // FIXME: An LLVM bug causes SExt(ICmpCC()) to produce 0 or 1 instead of 0 or ~0 4814197226a0e460200ad65a033fad60bb38c9c8a2edNicolas Capens // Restore the following line when LLVM is updated to a version where this issue is fixed. 4815197226a0e460200ad65a033fad60bb38c9c8a2edNicolas Capens // return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSGE(x.value, y.value), Int4::getType())); 4816197226a0e460200ad65a033fad60bb38c9c8a2edNicolas Capens return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSLT(x.value, y.value), Int4::getType())) ^ Int4(0xFFFFFFFF); 481719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 481819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 481919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> CmpNLE(RValue<Int4> x, RValue<Int4> y) 482019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 48219ae6cfd7474303a699af8e98d9449d6a78fd02a8Nicolas Capens // FIXME: An LLVM bug causes SExt(ICmpCC()) to produce 0 or 1 instead of 0 or ~0 48229ae6cfd7474303a699af8e98d9449d6a78fd02a8Nicolas Capens // Restore the following line when LLVM is updated to a version where this issue is fixed. 48239ae6cfd7474303a699af8e98d9449d6a78fd02a8Nicolas Capens // return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSGT(x.value, y.value), Int4::getType())); 48249ae6cfd7474303a699af8e98d9449d6a78fd02a8Nicolas Capens return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSLE(x.value, y.value), Int4::getType())) ^ Int4(0xFFFFFFFF); 482519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 482619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 482719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> Max(RValue<Int4> x, RValue<Int4> y) 482819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 482919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman if(CPUID::supportsSSE4_1()) 483019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 483119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman return x86::pmaxsd(x, y); 483219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 483319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman else 483419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 483519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> greater = CmpNLE(x, y); 483669bc6e8ac26d38aec85946dbf1bc60c32fb6e5d3Tom Anderson return (x & greater) | (y & ~greater); 483719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 483819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 483919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 484019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> Min(RValue<Int4> x, RValue<Int4> y) 484119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 484219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman if(CPUID::supportsSSE4_1()) 484319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 484419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman return x86::pminsd(x, y); 484519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 484619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman else 484719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 484819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> less = CmpLT(x, y); 484969bc6e8ac26d38aec85946dbf1bc60c32fb6e5d3Tom Anderson return (x & less) | (y & ~less); 485019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 485119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 485219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 485319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> RoundInt(RValue<Float4> cast) 4854894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4855894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::cvtps2dq(cast); 4856894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4857894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 485833438a6882d629139617d80cc7fdbc687b71a794Nicolas Capens RValue<Short8> PackSigned(RValue<Int4> x, RValue<Int4> y) 4859894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4860894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::packssdw(x, y); 4861894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4862894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 486333438a6882d629139617d80cc7fdbc687b71a794Nicolas Capens RValue<UShort8> PackUnsigned(RValue<Int4> x, RValue<Int4> y) 486433438a6882d629139617d80cc7fdbc687b71a794Nicolas Capens { 486533438a6882d629139617d80cc7fdbc687b71a794Nicolas Capens return x86::packusdw(x, y); 486633438a6882d629139617d80cc7fdbc687b71a794Nicolas Capens } 486733438a6882d629139617d80cc7fdbc687b71a794Nicolas Capens 486819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int> Extract(RValue<Int4> x, int i) 4869894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4870e95d534ac645273b3669ef62046d9aa612468e7eNicolas Capens return RValue<Int>(Nucleus::createExtractElement(x.value, Int::getType(), i)); 4871894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4872894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 487319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> Insert(RValue<Int4> x, RValue<Int> element, int i) 4874894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4875894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Int4>(Nucleus::createInsertElement(x.value, element.value, i)); 4876894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4877894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 487819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int> SignMask(RValue<Int4> x) 4879894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4880894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::movmskps(As<Float4>(x)); 4881894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4882894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 488319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> Swizzle(RValue<Int4> x, unsigned char select) 4884894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4885e95d534ac645273b3669ef62046d9aa612468e7eNicolas Capens return RValue<Int4>(createSwizzle4(x.value, select)); 4886894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4887894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 488819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Type *Int4::getType() 4889894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4890fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return T(llvm::VectorType::get(T(Int::getType()), 4)); 4891894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4892894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4893cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens UInt4::UInt4() : XYZW(this) 4894cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens { 4895cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens } 4896cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens 4897cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens UInt4::UInt4(RValue<Float4> cast) : XYZW(this) 4898894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 4899764d14268b9067fec1589fc7182d328410a94d52Alexis Hetu // Note: createFPToUI is broken, must perform conversion using createFPtoSI 4900764d14268b9067fec1589fc7182d328410a94d52Alexis Hetu // Value *xyzw = Nucleus::createFPToUI(cast.value, UInt4::getType()); 4901764d14268b9067fec1589fc7182d328410a94d52Alexis Hetu 4902764d14268b9067fec1589fc7182d328410a94d52Alexis Hetu // Smallest positive value representable in UInt, but not in Int 4903764d14268b9067fec1589fc7182d328410a94d52Alexis Hetu const unsigned int ustart = 0x80000000u; 4904764d14268b9067fec1589fc7182d328410a94d52Alexis Hetu const float ustartf = float(ustart); 4905764d14268b9067fec1589fc7182d328410a94d52Alexis Hetu 4906764d14268b9067fec1589fc7182d328410a94d52Alexis Hetu // Check if the value can be represented as an Int 4907764d14268b9067fec1589fc7182d328410a94d52Alexis Hetu Int4 uiValue = CmpNLT(cast, Float4(ustartf)); 4908764d14268b9067fec1589fc7182d328410a94d52Alexis Hetu // If the value is too large, subtract ustart and re-add it after conversion. 4909764d14268b9067fec1589fc7182d328410a94d52Alexis Hetu uiValue = (uiValue & As<Int4>(As<UInt4>(Int4(cast - Float4(ustartf))) + UInt4(ustart))) | 4910764d14268b9067fec1589fc7182d328410a94d52Alexis Hetu // Otherwise, just convert normally 4911764d14268b9067fec1589fc7182d328410a94d52Alexis Hetu (~uiValue & Int4(cast)); 4912764d14268b9067fec1589fc7182d328410a94d52Alexis Hetu // If the value is negative, store 0, otherwise store the result of the conversion 4913764d14268b9067fec1589fc7182d328410a94d52Alexis Hetu storeValue((~(As<Int4>(cast) >> 31) & uiValue).value); 4914894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4915894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4916cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens UInt4::UInt4(int xyzw) : XYZW(this) 491719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 491819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman constant(xyzw, xyzw, xyzw, xyzw); 491919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 492019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 4921cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens UInt4::UInt4(int x, int yzw) : XYZW(this) 492219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 492319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman constant(x, yzw, yzw, yzw); 492419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 492519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 4926cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens UInt4::UInt4(int x, int y, int zw) : XYZW(this) 492719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 492819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman constant(x, y, zw, zw); 492919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 493019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 4931cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens UInt4::UInt4(int x, int y, int z, int w) : XYZW(this) 493219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 493319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman constant(x, y, z, w); 493419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 493519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 493619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman void UInt4::constant(int x, int y, int z, int w) 4937894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 493813ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens int64_t constantVector[4] = {x, y, z, w}; 493913ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens storeValue(Nucleus::createConstantVector(constantVector, getType())); 4940894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4941894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4942cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens UInt4::UInt4(RValue<UInt4> rhs) : XYZW(this) 4943894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 494466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 4945894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4946894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4947cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens UInt4::UInt4(const UInt4 &rhs) : XYZW(this) 4948894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 494966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 495066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 495166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 495266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 4953cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens UInt4::UInt4(const Reference<UInt4> &rhs) : XYZW(this) 495466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 495566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 495666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 4957894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4958894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4959cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens UInt4::UInt4(RValue<Int4> rhs) : XYZW(this) 496019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 496166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 496219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 496319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 4964cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens UInt4::UInt4(const Int4 &rhs) : XYZW(this) 496519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 496666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 496766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 496866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 496966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 4970cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens UInt4::UInt4(const Reference<Int4> &rhs) : XYZW(this) 497166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 497266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 497366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 497419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 497519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 4976cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens UInt4::UInt4(RValue<UInt2> lo, RValue<UInt2> hi) : XYZW(this) 497762abb5589758c3d3e32f5a7a2d7e0ad936d5c5f1Nicolas Capens { 497801a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens int shuffle[4] = {0, 1, 4, 5}; // Real type is v4i32 497901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens Value *packed = Nucleus::createShuffleVector(lo.value, hi.value, shuffle); 498062abb5589758c3d3e32f5a7a2d7e0ad936d5c5f1Nicolas Capens 498101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens storeValue(packed); 498262abb5589758c3d3e32f5a7a2d7e0ad936d5c5f1Nicolas Capens } 498362abb5589758c3d3e32f5a7a2d7e0ad936d5c5f1Nicolas Capens 498496d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt4> UInt4::operator=(RValue<UInt4> rhs) 4985894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 498666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 4987894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4988894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return rhs; 4989894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4990894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 499196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt4> UInt4::operator=(const UInt4 &rhs) 4992894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 499366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 499466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 499566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 499666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman return RValue<UInt4>(value); 499766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 499866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 499996d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt4> UInt4::operator=(const Reference<UInt4> &rhs) 500066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 500166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 500266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 5003894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5004894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UInt4>(value); 5005894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5006894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 500719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt4> operator+(RValue<UInt4> lhs, RValue<UInt4> rhs) 5008894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5009894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UInt4>(Nucleus::createAdd(lhs.value, rhs.value)); 5010894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5011894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 501219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt4> operator-(RValue<UInt4> lhs, RValue<UInt4> rhs) 5013894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5014894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UInt4>(Nucleus::createSub(lhs.value, rhs.value)); 5015894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5016894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 501719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt4> operator*(RValue<UInt4> lhs, RValue<UInt4> rhs) 5018894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5019894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UInt4>(Nucleus::createMul(lhs.value, rhs.value)); 5020894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5021894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5022d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu RValue<UInt4> operator/(RValue<UInt4> lhs, RValue<UInt4> rhs) 5023d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu { 5024d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu return RValue<UInt4>(Nucleus::createUDiv(lhs.value, rhs.value)); 5025d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu } 5026894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5027d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu RValue<UInt4> operator%(RValue<UInt4> lhs, RValue<UInt4> rhs) 5028d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu { 5029d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu return RValue<UInt4>(Nucleus::createURem(lhs.value, rhs.value)); 5030d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu } 5031894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 503219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt4> operator&(RValue<UInt4> lhs, RValue<UInt4> rhs) 5033894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5034894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UInt4>(Nucleus::createAnd(lhs.value, rhs.value)); 5035894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5036894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 503719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt4> operator|(RValue<UInt4> lhs, RValue<UInt4> rhs) 5038894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5039894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UInt4>(Nucleus::createOr(lhs.value, rhs.value)); 5040894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5041894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 504219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt4> operator^(RValue<UInt4> lhs, RValue<UInt4> rhs) 5043894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5044894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UInt4>(Nucleus::createXor(lhs.value, rhs.value)); 5045894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5046894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 504719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt4> operator<<(RValue<UInt4> lhs, unsigned char rhs) 5048894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5049894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return As<UInt4>(x86::pslld(As<Int4>(lhs), rhs)); 5050894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5051894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 505219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt4> operator>>(RValue<UInt4> lhs, unsigned char rhs) 5053894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5054894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::psrld(lhs, rhs); 5055894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5056894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5057d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu RValue<UInt4> operator<<(RValue<UInt4> lhs, RValue<UInt4> rhs) 5058d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu { 5059d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu return RValue<UInt4>(Nucleus::createShl(lhs.value, rhs.value)); 5060d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu } 5061d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu 5062d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu RValue<UInt4> operator>>(RValue<UInt4> lhs, RValue<UInt4> rhs) 5063d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu { 5064d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu return RValue<UInt4>(Nucleus::createLShr(lhs.value, rhs.value)); 5065d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu } 5066d9d27bbe1ce0e866262f84395edbeb4108720684Alexis Hetu 506796d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt4> operator+=(UInt4 &lhs, RValue<UInt4> rhs) 5068894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5069894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs + rhs; 5070894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5071894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 507296d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt4> operator-=(UInt4 &lhs, RValue<UInt4> rhs) 5073894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5074894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs - rhs; 5075894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5076894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 507796d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt4> operator*=(UInt4 &lhs, RValue<UInt4> rhs) 5078894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5079894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs * rhs; 5080894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5081894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 508296d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens// RValue<UInt4> operator/=(UInt4 &lhs, RValue<UInt4> rhs) 508319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 508419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return lhs = lhs / rhs; 508519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 5086894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 508796d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens// RValue<UInt4> operator%=(UInt4 &lhs, RValue<UInt4> rhs) 508819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// { 508919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// return lhs = lhs % rhs; 509019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// } 5091894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 509296d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt4> operator&=(UInt4 &lhs, RValue<UInt4> rhs) 5093894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5094894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs & rhs; 5095894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5096894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 509796d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt4> operator|=(UInt4 &lhs, RValue<UInt4> rhs) 5098894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5099894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs | rhs; 5100894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5101894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 510296d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt4> operator^=(UInt4 &lhs, RValue<UInt4> rhs) 5103894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5104894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs ^ rhs; 5105894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5106894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 510796d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt4> operator<<=(UInt4 &lhs, unsigned char rhs) 5108894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5109894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs << rhs; 5110894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5111894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 511296d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<UInt4> operator>>=(UInt4 &lhs, unsigned char rhs) 5113894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5114894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs >> rhs; 5115894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5116894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 511719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt4> operator+(RValue<UInt4> val) 5118894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5119894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return val; 5120894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5121894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 512219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt4> operator-(RValue<UInt4> val) 5123894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5124894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UInt4>(Nucleus::createNeg(val.value)); 5125894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5126894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 512719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt4> operator~(RValue<UInt4> val) 5128894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5129894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<UInt4>(Nucleus::createNot(val.value)); 5130894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5131894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 513219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt4> CmpEQ(RValue<UInt4> x, RValue<UInt4> y) 513319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 5134197226a0e460200ad65a033fad60bb38c9c8a2edNicolas Capens // FIXME: An LLVM bug causes SExt(ICmpCC()) to produce 0 or 1 instead of 0 or ~0 5135fb60399746e6d03e28dbaa5f8b3b1c38935ff35eAlexis Hetu // Restore the following line when LLVM is updated to a version where this issue is fixed. 5136fb60399746e6d03e28dbaa5f8b3b1c38935ff35eAlexis Hetu // return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpEQ(x.value, y.value), Int4::getType())); 5137fb60399746e6d03e28dbaa5f8b3b1c38935ff35eAlexis Hetu return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpNE(x.value, y.value), Int4::getType())) ^ UInt4(0xFFFFFFFF); 513819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 513919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 514019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt4> CmpLT(RValue<UInt4> x, RValue<UInt4> y) 514119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 514219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpULT(x.value, y.value), Int4::getType())); 514319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 514419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 514519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt4> CmpLE(RValue<UInt4> x, RValue<UInt4> y) 514619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 5147197226a0e460200ad65a033fad60bb38c9c8a2edNicolas Capens // FIXME: An LLVM bug causes SExt(ICmpCC()) to produce 0 or 1 instead of 0 or ~0 5148197226a0e460200ad65a033fad60bb38c9c8a2edNicolas Capens // Restore the following line when LLVM is updated to a version where this issue is fixed. 5149197226a0e460200ad65a033fad60bb38c9c8a2edNicolas Capens // return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpULE(x.value, y.value), Int4::getType())); 5150197226a0e460200ad65a033fad60bb38c9c8a2edNicolas Capens return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpUGT(x.value, y.value), Int4::getType())) ^ UInt4(0xFFFFFFFF); 515119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 515219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 515319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt4> CmpNEQ(RValue<UInt4> x, RValue<UInt4> y) 515419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 515519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpNE(x.value, y.value), Int4::getType())); 515619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 515719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 515819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt4> CmpNLT(RValue<UInt4> x, RValue<UInt4> y) 515919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 5160197226a0e460200ad65a033fad60bb38c9c8a2edNicolas Capens // FIXME: An LLVM bug causes SExt(ICmpCC()) to produce 0 or 1 instead of 0 or ~0 5161197226a0e460200ad65a033fad60bb38c9c8a2edNicolas Capens // Restore the following line when LLVM is updated to a version where this issue is fixed. 5162197226a0e460200ad65a033fad60bb38c9c8a2edNicolas Capens // return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpUGE(x.value, y.value), Int4::getType())); 5163197226a0e460200ad65a033fad60bb38c9c8a2edNicolas Capens return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpULT(x.value, y.value), Int4::getType())) ^ UInt4(0xFFFFFFFF); 516419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 516519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 516619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt4> CmpNLE(RValue<UInt4> x, RValue<UInt4> y) 516719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 516819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpUGT(x.value, y.value), Int4::getType())); 516919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 517019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 517119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt4> Max(RValue<UInt4> x, RValue<UInt4> y) 517219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 517319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman if(CPUID::supportsSSE4_1()) 517419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 517519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman return x86::pmaxud(x, y); 517619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 517719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman else 517819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 517919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt4> greater = CmpNLE(x, y); 518069bc6e8ac26d38aec85946dbf1bc60c32fb6e5d3Tom Anderson return (x & greater) | (y & ~greater); 518119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 518219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 518319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 518419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt4> Min(RValue<UInt4> x, RValue<UInt4> y) 518519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 518619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman if(CPUID::supportsSSE4_1()) 518719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 518819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman return x86::pminud(x, y); 518919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 519019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman else 519119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 519219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt4> less = CmpLT(x, y); 519369bc6e8ac26d38aec85946dbf1bc60c32fb6e5d3Tom Anderson return (x & less) | (y & ~less); 519419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 519519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 519619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 519719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Type *UInt4::getType() 5198894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5199fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return T(llvm::VectorType::get(T(UInt::getType()), 4)); 5200894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5201894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 520219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Float::Float(RValue<Int> cast) 5203894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5204894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *integer = Nucleus::createSIToFP(cast.value, Float::getType()); 5205894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 520666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(integer); 5207894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5208894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5209cfd963201e004f8b9b5b631812960d6985f03e75Alexis Hetu Float::Float(RValue<UInt> cast) 5210cfd963201e004f8b9b5b631812960d6985f03e75Alexis Hetu { 5211cfd963201e004f8b9b5b631812960d6985f03e75Alexis Hetu RValue<Float> result = Float(Int(cast & UInt(0x7FFFFFFF))) + 5212cfd963201e004f8b9b5b631812960d6985f03e75Alexis Hetu As<Float>((As<Int>(cast) >> 31) & As<Int>(Float(0x80000000u))); 5213cfd963201e004f8b9b5b631812960d6985f03e75Alexis Hetu 5214cfd963201e004f8b9b5b631812960d6985f03e75Alexis Hetu storeValue(result.value); 5215cfd963201e004f8b9b5b631812960d6985f03e75Alexis Hetu } 5216cfd963201e004f8b9b5b631812960d6985f03e75Alexis Hetu 5217894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Float::Float(float x) 5218894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 521966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(Nucleus::createConstantFloat(x)); 5220894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5221894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 522219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Float::Float(RValue<Float> rhs) 5223894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 522466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 5225894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5226894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5227894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Float::Float(const Float &rhs) 5228894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 522966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 523066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 523166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 5232894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 523366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Float::Float(const Reference<Float> &rhs) 523466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 523566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 523666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 5237894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5238894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 523996d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Float> Float::operator=(RValue<Float> rhs) 5240894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 524166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 5242894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5243894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return rhs; 5244894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5245894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 524696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Float> Float::operator=(const Float &rhs) 5247894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 524866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 524966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 5250894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5251894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Float>(value); 5252894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5253894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 525496d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Float> Float::operator=(const Reference<Float> &rhs) 5255894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 525666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 525766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 525866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 525966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman return RValue<Float>(value); 5260894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5261894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 526219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float> operator+(RValue<Float> lhs, RValue<Float> rhs) 5263894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5264894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Float>(Nucleus::createFAdd(lhs.value, rhs.value)); 5265894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5266894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 526719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float> operator-(RValue<Float> lhs, RValue<Float> rhs) 5268894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5269894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Float>(Nucleus::createFSub(lhs.value, rhs.value)); 5270894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5271894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 527219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float> operator*(RValue<Float> lhs, RValue<Float> rhs) 5273894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5274894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Float>(Nucleus::createFMul(lhs.value, rhs.value)); 5275894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5276894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 527719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float> operator/(RValue<Float> lhs, RValue<Float> rhs) 5278894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5279894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Float>(Nucleus::createFDiv(lhs.value, rhs.value)); 5280894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5281894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 528296d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Float> operator+=(Float &lhs, RValue<Float> rhs) 5283894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5284894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs + rhs; 5285894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5286894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 528796d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Float> operator-=(Float &lhs, RValue<Float> rhs) 5288894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5289894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs - rhs; 5290894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5291894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 529296d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Float> operator*=(Float &lhs, RValue<Float> rhs) 5293894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5294894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs * rhs; 5295894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5296894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 529796d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Float> operator/=(Float &lhs, RValue<Float> rhs) 5298894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5299894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs / rhs; 5300894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5301894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 530219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float> operator+(RValue<Float> val) 5303894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5304894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return val; 5305894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5306894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 530719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float> operator-(RValue<Float> val) 5308894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5309894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Float>(Nucleus::createFNeg(val.value)); 5310894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5311894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 531219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator<(RValue<Float> lhs, RValue<Float> rhs) 5313894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5314894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createFCmpOLT(lhs.value, rhs.value)); 5315894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5316894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 531719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator<=(RValue<Float> lhs, RValue<Float> rhs) 5318894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5319894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createFCmpOLE(lhs.value, rhs.value)); 5320894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5321894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 532219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator>(RValue<Float> lhs, RValue<Float> rhs) 5323894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5324894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createFCmpOGT(lhs.value, rhs.value)); 5325894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5326894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 532719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator>=(RValue<Float> lhs, RValue<Float> rhs) 5328894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5329894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createFCmpOGE(lhs.value, rhs.value)); 5330894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5331894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 533219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator!=(RValue<Float> lhs, RValue<Float> rhs) 5333894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5334894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createFCmpONE(lhs.value, rhs.value)); 5335894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5336894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 533719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Bool> operator==(RValue<Float> lhs, RValue<Float> rhs) 5338894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5339894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Bool>(Nucleus::createFCmpOEQ(lhs.value, rhs.value)); 5340894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5341894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 534219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float> Abs(RValue<Float> x) 5343894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 534466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman return IfThenElse(x > 0.0f, x, -x); 5345894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5346894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 534719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float> Max(RValue<Float> x, RValue<Float> y) 5348894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5349894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return IfThenElse(x > y, x, y); 5350894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5351894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 535219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float> Min(RValue<Float> x, RValue<Float> y) 5353894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5354894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return IfThenElse(x < y, x, y); 5355894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5356894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 535705b3d665fd92cd11b8a6517dafe661a5398547b7Nicolas Capens RValue<Float> Rcp_pp(RValue<Float> x, bool exactAtPow2) 5358894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 535947dc8676fcff01274de3d3fe98e1de607ff076d3Nicolas Capens #if defined(__i386__) || defined(__x86_64__) 536047dc8676fcff01274de3d3fe98e1de607ff076d3Nicolas Capens if(exactAtPow2) 536147dc8676fcff01274de3d3fe98e1de607ff076d3Nicolas Capens { 536247dc8676fcff01274de3d3fe98e1de607ff076d3Nicolas Capens // rcpss uses a piecewise-linear approximation which minimizes the relative error 536347dc8676fcff01274de3d3fe98e1de607ff076d3Nicolas Capens // but is not exact at power-of-two values. Rectify by multiplying by the inverse. 536447dc8676fcff01274de3d3fe98e1de607ff076d3Nicolas Capens return x86::rcpss(x) * Float(1.0f / _mm_cvtss_f32(_mm_rcp_ss(_mm_set_ps1(1.0f)))); 536547dc8676fcff01274de3d3fe98e1de607ff076d3Nicolas Capens } 536647dc8676fcff01274de3d3fe98e1de607ff076d3Nicolas Capens #endif 536747dc8676fcff01274de3d3fe98e1de607ff076d3Nicolas Capens 536847dc8676fcff01274de3d3fe98e1de607ff076d3Nicolas Capens return x86::rcpss(x); 5369894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 537066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 537119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float> RcpSqrt_pp(RValue<Float> x) 5372894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5373894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::rsqrtss(x); 5374894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5375894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 537619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float> Sqrt(RValue<Float> x) 5377894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5378894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::sqrtss(x); 5379894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5380894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 538119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float> Round(RValue<Float> x) 538219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 538319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman if(CPUID::supportsSSE4_1()) 538419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 538519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman return x86::roundss(x, 0); 538619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 538719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman else 538819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 538919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman return Float4(Round(Float4(x))).x; 539019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 539119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 539219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 539319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float> Trunc(RValue<Float> x) 539419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 539519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman if(CPUID::supportsSSE4_1()) 539619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 539719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman return x86::roundss(x, 3); 539819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 539919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman else 540019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 540119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman return Float(Int(x)); // Rounded toward zero 540219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 540319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 540419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 540519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float> Frac(RValue<Float> x) 5406894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5407894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(CPUID::supportsSSE4_1()) 5408894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5409894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x - x86::floorss(x); 5410894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5411894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman else 5412894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 541319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman return Float4(Frac(Float4(x))).x; 5414894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5415894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5416894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 541719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float> Floor(RValue<Float> x) 5418894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5419894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(CPUID::supportsSSE4_1()) 5420894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5421894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::floorss(x); 5422894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5423894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman else 5424894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5425894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return Float4(Floor(Float4(x))).x; 5426894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5427894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5428894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 542919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float> Ceil(RValue<Float> x) 5430894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 543119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman if(CPUID::supportsSSE4_1()) 543219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 543319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman return x86::ceilss(x); 543419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 543519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman else 543619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 543719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman return Float4(Ceil(Float4(x))).x; 543819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 5439894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5440894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 544119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Type *Float::getType() 5442894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5443ac2301298a42723d2c88f8749cab434ddd64e82dNicolas Capens return T(llvm::Type::getFloatTy(*::context)); 5444894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5445894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 544619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Float2::Float2(RValue<Float4> cast) 5447894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 544801a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens storeValue(Nucleus::createBitCast(cast.value, getType())); 5449894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5450894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 545119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Type *Float2::getType() 5452894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5453fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return T(Type_v2f32); 5454894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5455894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5456cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Float4::Float4(RValue<Byte4> cast) : XYZW(this) 5457894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 54589e013d4624df365e002ee086486830cda78d2e98Nicolas Capens Value *a = Int4(cast).loadValue(); 54599e013d4624df365e002ee086486830cda78d2e98Nicolas Capens Value *xyzw = Nucleus::createSIToFP(a, Float4::getType()); 546066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 546166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(xyzw); 5462894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5463894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5464cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Float4::Float4(RValue<SByte4> cast) : XYZW(this) 5465894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 54669e013d4624df365e002ee086486830cda78d2e98Nicolas Capens Value *a = Int4(cast).loadValue(); 54679e013d4624df365e002ee086486830cda78d2e98Nicolas Capens Value *xyzw = Nucleus::createSIToFP(a, Float4::getType()); 546866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 546966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(xyzw); 5470894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5471894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5472cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Float4::Float4(RValue<Short4> cast) : XYZW(this) 5473894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 54742aa852f4c1246ef8ab2a46d5d3f6a981c2ddda0aAlexis Hetu Int4 c(cast); 54752aa852f4c1246ef8ab2a46d5d3f6a981c2ddda0aAlexis Hetu storeValue(Nucleus::createSIToFP(RValue<Int4>(c).value, Float4::getType())); 5476894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5477894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5478cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Float4::Float4(RValue<UShort4> cast) : XYZW(this) 5479894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 54802aa852f4c1246ef8ab2a46d5d3f6a981c2ddda0aAlexis Hetu Int4 c(cast); 54812aa852f4c1246ef8ab2a46d5d3f6a981c2ddda0aAlexis Hetu storeValue(Nucleus::createSIToFP(RValue<Int4>(c).value, Float4::getType())); 5482894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5483894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5484cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Float4::Float4(RValue<Int4> cast) : XYZW(this) 5485894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5486894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *xyzw = Nucleus::createSIToFP(cast.value, Float4::getType()); 5487894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 548866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(xyzw); 5489894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5490894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5491cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Float4::Float4(RValue<UInt4> cast) : XYZW(this) 5492894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 549396445fe36c80c3cb5443a29be673bedb7ad2fb2fNicolas Capens RValue<Float4> result = Float4(Int4(cast & UInt4(0x7FFFFFFF))) + 549496445fe36c80c3cb5443a29be673bedb7ad2fb2fNicolas Capens As<Float4>((As<Int4>(cast) >> 31) & As<Int4>(Float4(0x80000000u))); 5495894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 549696445fe36c80c3cb5443a29be673bedb7ad2fb2fNicolas Capens storeValue(result.value); 5497894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5498894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5499cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Float4::Float4() : XYZW(this) 5500894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5501894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 550266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 5503cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Float4::Float4(float xyzw) : XYZW(this) 5504894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5505894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman constant(xyzw, xyzw, xyzw, xyzw); 5506894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5507894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5508cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Float4::Float4(float x, float yzw) : XYZW(this) 5509894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5510894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman constant(x, yzw, yzw, yzw); 5511894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5512894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5513cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Float4::Float4(float x, float y, float zw) : XYZW(this) 5514894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5515894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman constant(x, y, zw, zw); 5516894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5517894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5518cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Float4::Float4(float x, float y, float z, float w) : XYZW(this) 5519894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5520894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman constant(x, y, z, w); 5521894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5522894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5523894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman void Float4::constant(float x, float y, float z, float w) 5524894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 552513ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens double constantVector[4] = {x, y, z, w}; 552613ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens storeValue(Nucleus::createConstantVector(constantVector, getType())); 5527894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5528894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5529cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Float4::Float4(RValue<Float4> rhs) : XYZW(this) 5530894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 553166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 5532894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5533894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5534cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Float4::Float4(const Float4 &rhs) : XYZW(this) 5535894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 553666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 553766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 553866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 553966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 5540cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Float4::Float4(const Reference<Float4> &rhs) : XYZW(this) 554166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 554266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 554366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 5544894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5545894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5546cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Float4::Float4(RValue<Float> rhs) : XYZW(this) 5547894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 554866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *vector = loadValue(); 5549894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *insert = Nucleus::createInsertElement(vector, rhs.value, 0); 5550894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5551e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens int swizzle[4] = {0, 0, 0, 0}; 5552e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens Value *replicate = Nucleus::createShuffleVector(insert, insert, swizzle); 5553894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 555466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(replicate); 5555894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5556894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5557cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Float4::Float4(const Float &rhs) : XYZW(this) 5558894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 555966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman *this = RValue<Float>(rhs.loadValue()); 556066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 5561894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5562cb98676127fd976d4fee1269f606ad0d949bd9b9Nicolas Capens Float4::Float4(const Reference<Float> &rhs) : XYZW(this) 556366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 556466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman *this = RValue<Float>(rhs.loadValue()); 5565894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5566894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 556796d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Float4> Float4::operator=(float x) 5568894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5569894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return *this = Float4(x, x, x, x); 5570894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5571894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 557296d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Float4> Float4::operator=(RValue<Float4> rhs) 5573894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 557466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(rhs.value); 5575894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5576894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return rhs; 5577894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5578894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 557996d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Float4> Float4::operator=(const Float4 &rhs) 5580894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 558166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 558266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 558366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 558466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman return RValue<Float4>(value); 558566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 558666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 558796d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Float4> Float4::operator=(const Reference<Float4> &rhs) 558866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 558966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *value = rhs.loadValue(); 559066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman storeValue(value); 5591894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5592894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Float4>(value); 5593894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5594894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 559596d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Float4> Float4::operator=(RValue<Float> rhs) 5596894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5597894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return *this = Float4(rhs); 5598894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5599894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 560096d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Float4> Float4::operator=(const Float &rhs) 5601894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5602894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return *this = Float4(rhs); 5603894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5604894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 560596d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Float4> Float4::operator=(const Reference<Float> &rhs) 5606894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 560766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman return *this = Float4(rhs); 5608894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5609894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 561019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float4> operator+(RValue<Float4> lhs, RValue<Float4> rhs) 5611894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5612894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Float4>(Nucleus::createFAdd(lhs.value, rhs.value)); 5613894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5614894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 561519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float4> operator-(RValue<Float4> lhs, RValue<Float4> rhs) 5616894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5617894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Float4>(Nucleus::createFSub(lhs.value, rhs.value)); 5618894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5619894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 562019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float4> operator*(RValue<Float4> lhs, RValue<Float4> rhs) 5621894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5622894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Float4>(Nucleus::createFMul(lhs.value, rhs.value)); 5623894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5624894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 562519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float4> operator/(RValue<Float4> lhs, RValue<Float4> rhs) 5626894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5627894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Float4>(Nucleus::createFDiv(lhs.value, rhs.value)); 5628894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5629894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 563019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float4> operator%(RValue<Float4> lhs, RValue<Float4> rhs) 5631894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5632894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Float4>(Nucleus::createFRem(lhs.value, rhs.value)); 5633894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5634894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 563596d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Float4> operator+=(Float4 &lhs, RValue<Float4> rhs) 5636894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5637894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs + rhs; 5638894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5639894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 564096d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Float4> operator-=(Float4 &lhs, RValue<Float4> rhs) 5641894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5642894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs - rhs; 5643894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5644894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 564596d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Float4> operator*=(Float4 &lhs, RValue<Float4> rhs) 5646894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5647894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs * rhs; 5648894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5649894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 565096d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Float4> operator/=(Float4 &lhs, RValue<Float4> rhs) 5651894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5652894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs / rhs; 5653894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5654894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 565596d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Float4> operator%=(Float4 &lhs, RValue<Float4> rhs) 5656894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5657894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs % rhs; 5658894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5659894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 566019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float4> operator+(RValue<Float4> val) 5661894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5662894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return val; 5663894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5664894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 566519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float4> operator-(RValue<Float4> val) 5666894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5667894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Float4>(Nucleus::createFNeg(val.value)); 5668894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5669894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 567019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float4> Abs(RValue<Float4> x) 5671894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5672894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *vector = Nucleus::createBitCast(x.value, Int4::getType()); 567313ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens int64_t constantVector[4] = {0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF}; 567413ac2327184133f5a69584ff2d69bc2cdeec1457Nicolas Capens Value *result = Nucleus::createAnd(vector, V(Nucleus::createConstantVector(constantVector, Int4::getType()))); 5675894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 567601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<Float4>(result); 5677894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5678894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 567919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float4> Max(RValue<Float4> x, RValue<Float4> y) 5680894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5681894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::maxps(x, y); 5682894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5683894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 568419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float4> Min(RValue<Float4> x, RValue<Float4> y) 5685894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5686894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::minps(x, y); 5687894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5688894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 568905b3d665fd92cd11b8a6517dafe661a5398547b7Nicolas Capens RValue<Float4> Rcp_pp(RValue<Float4> x, bool exactAtPow2) 5690894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 569147dc8676fcff01274de3d3fe98e1de607ff076d3Nicolas Capens #if defined(__i386__) || defined(__x86_64__) 569247dc8676fcff01274de3d3fe98e1de607ff076d3Nicolas Capens if(exactAtPow2) 569347dc8676fcff01274de3d3fe98e1de607ff076d3Nicolas Capens { 569447dc8676fcff01274de3d3fe98e1de607ff076d3Nicolas Capens // rcpps uses a piecewise-linear approximation which minimizes the relative error 569547dc8676fcff01274de3d3fe98e1de607ff076d3Nicolas Capens // but is not exact at power-of-two values. Rectify by multiplying by the inverse. 569647dc8676fcff01274de3d3fe98e1de607ff076d3Nicolas Capens return x86::rcpps(x) * Float4(1.0f / _mm_cvtss_f32(_mm_rcp_ss(_mm_set_ps1(1.0f)))); 569747dc8676fcff01274de3d3fe98e1de607ff076d3Nicolas Capens } 569847dc8676fcff01274de3d3fe98e1de607ff076d3Nicolas Capens #endif 569947dc8676fcff01274de3d3fe98e1de607ff076d3Nicolas Capens 570047dc8676fcff01274de3d3fe98e1de607ff076d3Nicolas Capens return x86::rcpps(x); 5701894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 570266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 570319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float4> RcpSqrt_pp(RValue<Float4> x) 5704894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5705894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::rsqrtps(x); 5706894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5707894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 570819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float4> Sqrt(RValue<Float4> x) 5709894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5710894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::sqrtps(x); 5711894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5712894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 571301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens RValue<Float4> Insert(RValue<Float4> x, RValue<Float> element, int i) 5714894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 571501a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<Float4>(Nucleus::createInsertElement(x.value, element.value, i)); 5716894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5717894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 571819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float> Extract(RValue<Float4> x, int i) 5719894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5720e95d534ac645273b3669ef62046d9aa612468e7eNicolas Capens return RValue<Float>(Nucleus::createExtractElement(x.value, Float::getType(), i)); 5721894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5722894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 572319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float4> Swizzle(RValue<Float4> x, unsigned char select) 5724894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5725e95d534ac645273b3669ef62046d9aa612468e7eNicolas Capens return RValue<Float4>(createSwizzle4(x.value, select)); 5726894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5727894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 572819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float4> ShuffleLowHigh(RValue<Float4> x, RValue<Float4> y, unsigned char imm) 5729894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5730e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens int shuffle[4] = 5731e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens { 5732e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens ((imm >> 0) & 0x03) + 0, 5733e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens ((imm >> 2) & 0x03) + 0, 5734e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens ((imm >> 4) & 0x03) + 4, 5735e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens ((imm >> 6) & 0x03) + 4, 5736e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens }; 5737894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5738e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens return RValue<Float4>(Nucleus::createShuffleVector(x.value, y.value, shuffle)); 5739894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5740894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 574119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float4> UnpackLow(RValue<Float4> x, RValue<Float4> y) 5742894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5743e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens int shuffle[4] = {0, 4, 1, 5}; 5744e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens return RValue<Float4>(Nucleus::createShuffleVector(x.value, y.value, shuffle)); 5745894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5746894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 574719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float4> UnpackHigh(RValue<Float4> x, RValue<Float4> y) 5748894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5749e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens int shuffle[4] = {2, 6, 3, 7}; 5750e89cd5805a9e9578821d9049671f5a345874eca3Nicolas Capens return RValue<Float4>(Nucleus::createShuffleVector(x.value, y.value, shuffle)); 5751894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 575266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 575319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float4> Mask(Float4 &lhs, RValue<Float4> rhs, unsigned char select) 5754894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 575566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Value *vector = lhs.loadValue(); 575601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens Value *result = createMask4(vector, rhs.value, select); 575701a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens lhs.storeValue(result); 5758894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 575901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<Float4>(result); 5760894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5761894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 576219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int> SignMask(RValue<Float4> x) 5763894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5764894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::movmskps(x); 5765894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5766894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 576719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> CmpEQ(RValue<Float4> x, RValue<Float4> y) 5768894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5769894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // return As<Int4>(x86::cmpeqps(x, y)); 5770894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOEQ(x.value, y.value), Int4::getType())); 5771894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5772894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 577319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> CmpLT(RValue<Float4> x, RValue<Float4> y) 5774894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5775894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // return As<Int4>(x86::cmpltps(x, y)); 5776894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOLT(x.value, y.value), Int4::getType())); 5777894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5778894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 577919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> CmpLE(RValue<Float4> x, RValue<Float4> y) 5780894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5781894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // return As<Int4>(x86::cmpleps(x, y)); 5782894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOLE(x.value, y.value), Int4::getType())); 5783894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5784894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 578519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> CmpNEQ(RValue<Float4> x, RValue<Float4> y) 5786894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5787894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // return As<Int4>(x86::cmpneqps(x, y)); 5788894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpONE(x.value, y.value), Int4::getType())); 5789894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5790894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 579119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> CmpNLT(RValue<Float4> x, RValue<Float4> y) 5792894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5793894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // return As<Int4>(x86::cmpnltps(x, y)); 5794894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOGE(x.value, y.value), Int4::getType())); 5795894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5796894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 579719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> CmpNLE(RValue<Float4> x, RValue<Float4> y) 5798894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5799894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // return As<Int4>(x86::cmpnleps(x, y)); 5800894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOGT(x.value, y.value), Int4::getType())); 5801894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5802894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 58038ef6d1097d9fe71a2461a5040bddb1893bdbed6cAlexis Hetu RValue<Int4> IsInf(RValue<Float4> x) 58048ef6d1097d9fe71a2461a5040bddb1893bdbed6cAlexis Hetu { 58058ef6d1097d9fe71a2461a5040bddb1893bdbed6cAlexis Hetu return CmpEQ(As<Int4>(x) & Int4(0x7FFFFFFF), Int4(0x7F800000)); 58068ef6d1097d9fe71a2461a5040bddb1893bdbed6cAlexis Hetu } 58078ef6d1097d9fe71a2461a5040bddb1893bdbed6cAlexis Hetu 58088ef6d1097d9fe71a2461a5040bddb1893bdbed6cAlexis Hetu RValue<Int4> IsNan(RValue<Float4> x) 58098ef6d1097d9fe71a2461a5040bddb1893bdbed6cAlexis Hetu { 58108ef6d1097d9fe71a2461a5040bddb1893bdbed6cAlexis Hetu return ~CmpEQ(x, x); 58118ef6d1097d9fe71a2461a5040bddb1893bdbed6cAlexis Hetu } 58128ef6d1097d9fe71a2461a5040bddb1893bdbed6cAlexis Hetu 581319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float4> Round(RValue<Float4> x) 581419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 581519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman if(CPUID::supportsSSE4_1()) 581619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 581719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman return x86::roundps(x, 0); 581819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 581919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman else 582019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 582119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman return Float4(RoundInt(x)); 582219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 582319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 582419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 582519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float4> Trunc(RValue<Float4> x) 582619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 582719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman if(CPUID::supportsSSE4_1()) 582819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 582919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman return x86::roundps(x, 3); 583019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 583119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman else 583219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 583301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return Float4(Int4(x)); 583419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 583519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 583619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 583719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float4> Frac(RValue<Float4> x) 5838894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5839b923042e7737fcde817b648b399f86506dff3565Nicolas Capens Float4 frc; 5840b923042e7737fcde817b648b399f86506dff3565Nicolas Capens 5841894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(CPUID::supportsSSE4_1()) 5842894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 584301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens frc = x - Floor(x); 5844894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5845894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman else 5846894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5847b923042e7737fcde817b648b399f86506dff3565Nicolas Capens frc = x - Float4(Int4(x)); // Signed fractional part. 5848894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5849b923042e7737fcde817b648b399f86506dff3565Nicolas Capens frc += As<Float4>(As<Int4>(CmpNLE(Float4(0.0f), frc)) & As<Int4>(Float4(1.0f))); // Add 1.0 if negative. 5850894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5851b923042e7737fcde817b648b399f86506dff3565Nicolas Capens 5852b923042e7737fcde817b648b399f86506dff3565Nicolas Capens // x - floor(x) can be 1.0 for very small negative x. 5853b923042e7737fcde817b648b399f86506dff3565Nicolas Capens // Clamp against the value just below 1.0. 5854b923042e7737fcde817b648b399f86506dff3565Nicolas Capens return Min(frc, As<Float4>(Int4(0x3F7FFFFF))); 5855894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5856894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 585719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float4> Floor(RValue<Float4> x) 5858894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5859894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(CPUID::supportsSSE4_1()) 5860894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5861894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x86::floorps(x); 5862894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5863894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman else 5864894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 586519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman return x - Frac(x); 5866894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5867894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5868894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 586919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float4> Ceil(RValue<Float4> x) 5870894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 587119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman if(CPUID::supportsSSE4_1()) 587219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 587319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman return x86::ceilps(x); 587419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 587519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman else 587619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 587719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman return -Floor(-x); 587819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 5879894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5880894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 588119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Type *Float4::getType() 5882894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5883fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens return T(llvm::VectorType::get(T(Float::getType()), 4)); 5884894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5885894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 588681f1830d46482cd635f7e7a92c55aec8683c1e55Nicolas Capens RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, int offset) 5887894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 588801a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return lhs + RValue<Int>(Nucleus::createConstantInt(offset)); 5889894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5890894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 589181f1830d46482cd635f7e7a92c55aec8683c1e55Nicolas Capens RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<Int> offset) 5892894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5893d294def5b421885b259403efb9b1abddaae3a82cNicolas Capens return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value, Byte::getType(), offset.value, false)); 5894894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5895894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 589681f1830d46482cd635f7e7a92c55aec8683c1e55Nicolas Capens RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<UInt> offset) 5897894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5898d294def5b421885b259403efb9b1abddaae3a82cNicolas Capens return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value, Byte::getType(), offset.value, true)); 5899894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5900894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 590196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Pointer<Byte>> operator+=(Pointer<Byte> &lhs, int offset) 5902894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5903894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs + offset; 5904894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5905894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 590696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Pointer<Byte>> operator+=(Pointer<Byte> &lhs, RValue<Int> offset) 5907894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5908894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs + offset; 5909894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5910894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 591196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Pointer<Byte>> operator+=(Pointer<Byte> &lhs, RValue<UInt> offset) 5912894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5913894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs + offset; 5914894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5915894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 591681f1830d46482cd635f7e7a92c55aec8683c1e55Nicolas Capens RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, int offset) 5917894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5918894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs + -offset; 5919894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5920894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 592181f1830d46482cd635f7e7a92c55aec8683c1e55Nicolas Capens RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, RValue<Int> offset) 5922894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5923894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs + -offset; 5924894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5925894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 592681f1830d46482cd635f7e7a92c55aec8683c1e55Nicolas Capens RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, RValue<UInt> offset) 5927894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5928894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs + -offset; 5929894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5930894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 593196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Pointer<Byte>> operator-=(Pointer<Byte> &lhs, int offset) 5932894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5933894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs - offset; 5934894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5935894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 593696d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Pointer<Byte>> operator-=(Pointer<Byte> &lhs, RValue<Int> offset) 5937894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5938894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs - offset; 5939894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5940894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 594196d4e09163d5979f9b695cea48975d8b89b3372bNicolas Capens RValue<Pointer<Byte>> operator-=(Pointer<Byte> &lhs, RValue<UInt> offset) 5942894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5943894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return lhs = lhs - offset; 5944894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5945894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5946894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman void Return() 5947894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5948894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Nucleus::createRetVoid(); 5949894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Nucleus::setInsertBlock(Nucleus::createBasicBlock()); 595019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Nucleus::createUnreachable(); 595119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 595219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 5953eb253d0b6c3d44e99804ad780d273008159246d8Nicolas Capens void Return(RValue<Int> ret) 595419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 5955eb253d0b6c3d44e99804ad780d273008159246d8Nicolas Capens Nucleus::createRet(ret.value); 5956894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Nucleus::setInsertBlock(Nucleus::createBasicBlock()); 595719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Nucleus::createUnreachable(); 5958894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5959894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5960f4eec2f957577bd5f97639863adf4da2e9a82c2bNicolas Capens void branch(RValue<Bool> cmp, BasicBlock *bodyBB, BasicBlock *endBB) 5961894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5962894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Nucleus::createCondBr(cmp.value, bodyBB, endBB); 596366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Nucleus::setInsertBlock(bodyBB); 5964894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5965894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5966894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman RValue<Long> Ticks() 5967894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5968fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::Function *rdtsc = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::readcyclecounter); 5969894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 59702ab69ee7346b5ecb708825ef00a127e1aac63152Nicolas Capens return RValue<Long>(V(::builder->CreateCall(rdtsc))); 5971894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5972894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman} 5973894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5974894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumannamespace sw 5975894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman{ 5976894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman namespace x86 5977894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 597819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int> cvtss2si(RValue<Float> val) 5979894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5980fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::Function *cvtss2si = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse_cvtss2si); 598166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 5982894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Float4 vector; 5983894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman vector.x = val; 5984894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 59852ab69ee7346b5ecb708825ef00a127e1aac63152Nicolas Capens return RValue<Int>(V(::builder->CreateCall(cvtss2si, RValue<Float4>(vector).value))); 5986894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5987894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 598819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> cvtps2dq(RValue<Float4> val) 5989894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 59909e013d4624df365e002ee086486830cda78d2e98Nicolas Capens llvm::Function *cvtps2dq = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_cvtps2dq); 5991894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 59929e013d4624df365e002ee086486830cda78d2e98Nicolas Capens return RValue<Int4>(V(::builder->CreateCall(cvtps2dq, val.value))); 5993894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 5994894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 599519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float> rcpss(RValue<Float> val) 5996894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 5997fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::Function *rcpss = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse_rcp_ss); 5998894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 5999fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens Value *vector = Nucleus::createInsertElement(V(llvm::UndefValue::get(T(Float4::getType()))), val.value, 0); 600066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 6001e95d534ac645273b3669ef62046d9aa612468e7eNicolas Capens return RValue<Float>(Nucleus::createExtractElement(V(::builder->CreateCall(rcpss, vector)), Float::getType(), 0)); 6002894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6003894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 600419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float> sqrtss(RValue<Float> val) 6005894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 6006fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::Function *sqrtss = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse_sqrt_ss); 6007894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 6008fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens Value *vector = Nucleus::createInsertElement(V(llvm::UndefValue::get(T(Float4::getType()))), val.value, 0); 600966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 6010e95d534ac645273b3669ef62046d9aa612468e7eNicolas Capens return RValue<Float>(Nucleus::createExtractElement(V(::builder->CreateCall(sqrtss, vector)), Float::getType(), 0)); 6011894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6012894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 601319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float> rsqrtss(RValue<Float> val) 6014894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 6015fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::Function *rsqrtss = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse_rsqrt_ss); 601666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 6017fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens Value *vector = Nucleus::createInsertElement(V(llvm::UndefValue::get(T(Float4::getType()))), val.value, 0); 6018894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 6019e95d534ac645273b3669ef62046d9aa612468e7eNicolas Capens return RValue<Float>(Nucleus::createExtractElement(V(::builder->CreateCall(rsqrtss, vector)), Float::getType(), 0)); 6020894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6021894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 602219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float4> rcpps(RValue<Float4> val) 6023894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 6024fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::Function *rcpps = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse_rcp_ps); 602566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 60262ab69ee7346b5ecb708825ef00a127e1aac63152Nicolas Capens return RValue<Float4>(V(::builder->CreateCall(rcpps, val.value))); 6027894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6028894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 602919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float4> sqrtps(RValue<Float4> val) 6030894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 6031fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::Function *sqrtps = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse_sqrt_ps); 603266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 60332ab69ee7346b5ecb708825ef00a127e1aac63152Nicolas Capens return RValue<Float4>(V(::builder->CreateCall(sqrtps, val.value))); 6034894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6035894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 603619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float4> rsqrtps(RValue<Float4> val) 6037894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 6038fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::Function *rsqrtps = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse_rsqrt_ps); 603966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 60402ab69ee7346b5ecb708825ef00a127e1aac63152Nicolas Capens return RValue<Float4>(V(::builder->CreateCall(rsqrtps, val.value))); 6041894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6042894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 604319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float4> maxps(RValue<Float4> x, RValue<Float4> y) 6044894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 6045fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::Function *maxps = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse_max_ps); 6046894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 60472ab69ee7346b5ecb708825ef00a127e1aac63152Nicolas Capens return RValue<Float4>(V(::builder->CreateCall2(maxps, x.value, y.value))); 6048894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6049894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 605019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float4> minps(RValue<Float4> x, RValue<Float4> y) 6051894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 6052fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::Function *minps = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse_min_ps); 6053894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 60542ab69ee7346b5ecb708825ef00a127e1aac63152Nicolas Capens return RValue<Float4>(V(::builder->CreateCall2(minps, x.value, y.value))); 6055894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6056894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 605719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float> roundss(RValue<Float> val, unsigned char imm) 6058894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 6059fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::Function *roundss = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse41_round_ss); 6060894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 6061fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens Value *undef = V(llvm::UndefValue::get(T(Float4::getType()))); 6062894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Value *vector = Nucleus::createInsertElement(undef, val.value, 0); 6063894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 6064e95d534ac645273b3669ef62046d9aa612468e7eNicolas Capens return RValue<Float>(Nucleus::createExtractElement(V(::builder->CreateCall3(roundss, undef, vector, V(Nucleus::createConstantInt(imm)))), Float::getType(), 0)); 6065894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6066894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 606719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float> floorss(RValue<Float> val) 6068894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 6069894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return roundss(val, 1); 6070894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6071894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 607219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float> ceilss(RValue<Float> val) 6073894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 6074894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return roundss(val, 2); 6075894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6076894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 607719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float4> roundps(RValue<Float4> val, unsigned char imm) 6078894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 6079fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::Function *roundps = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse41_round_ps); 6080894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 60812ab69ee7346b5ecb708825ef00a127e1aac63152Nicolas Capens return RValue<Float4>(V(::builder->CreateCall2(roundps, val.value, V(Nucleus::createConstantInt(imm))))); 6082894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6083894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 608419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float4> floorps(RValue<Float4> val) 6085894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 6086894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return roundps(val, 1); 6087894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6088894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 608919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Float4> ceilps(RValue<Float4> val) 6090894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 6091894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return roundps(val, 2); 6092894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6093894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 60940f4480780a2bfad69cece5fd9cabd1bf89f7393eAlexis Hetu RValue<Int4> pabsd(RValue<Int4> x) 6095894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 6096fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::Function *pabsd = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_ssse3_pabs_d_128); 6097894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 60982ab69ee7346b5ecb708825ef00a127e1aac63152Nicolas Capens return RValue<Int4>(V(::builder->CreateCall(pabsd, x.value))); 6099894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6100894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 610119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short4> paddsw(RValue<Short4> x, RValue<Short4> y) 6102894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 610301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens llvm::Function *paddsw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_padds_w); 6104894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 610501a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<Short4>(V(::builder->CreateCall2(paddsw, x.value, y.value))); 6106894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 610766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 610819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short4> psubsw(RValue<Short4> x, RValue<Short4> y) 6109894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 611001a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens llvm::Function *psubsw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_psubs_w); 6111894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 611201a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<Short4>(V(::builder->CreateCall2(psubsw, x.value, y.value))); 6113894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6114894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 611519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort4> paddusw(RValue<UShort4> x, RValue<UShort4> y) 6116894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 611701a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens llvm::Function *paddusw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_paddus_w); 6118894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 611901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<UShort4>(V(::builder->CreateCall2(paddusw, x.value, y.value))); 6120894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 612166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 612219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort4> psubusw(RValue<UShort4> x, RValue<UShort4> y) 6123894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 612401a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens llvm::Function *psubusw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_psubus_w); 6125894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 612601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<UShort4>(V(::builder->CreateCall2(psubusw, x.value, y.value))); 6127894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6128894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 612919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<SByte8> paddsb(RValue<SByte8> x, RValue<SByte8> y) 6130894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 613101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens llvm::Function *paddsb = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_padds_b); 6132894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 613301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<SByte8>(V(::builder->CreateCall2(paddsb, x.value, y.value))); 6134894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 613566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 613619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<SByte8> psubsb(RValue<SByte8> x, RValue<SByte8> y) 6137894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 613801a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens llvm::Function *psubsb = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_psubs_b); 6139894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 614001a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<SByte8>(V(::builder->CreateCall2(psubsb, x.value, y.value))); 6141894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 614266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 614319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Byte8> paddusb(RValue<Byte8> x, RValue<Byte8> y) 6144894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 614501a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens llvm::Function *paddusb = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_paddus_b); 6146894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 614701a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<Byte8>(V(::builder->CreateCall2(paddusb, x.value, y.value))); 6148894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 614966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 615019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Byte8> psubusb(RValue<Byte8> x, RValue<Byte8> y) 6151894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 615201a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens llvm::Function *psubusb = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_psubus_b); 6153894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 615401a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<Byte8>(V(::builder->CreateCall2(psubusb, x.value, y.value))); 6155894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6156894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 615719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort4> pavgw(RValue<UShort4> x, RValue<UShort4> y) 6158894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 615901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens llvm::Function *pavgw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_pavg_w); 6160894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 616101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<UShort4>(V(::builder->CreateCall2(pavgw, x.value, y.value))); 6162894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6163894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 616419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short4> pmaxsw(RValue<Short4> x, RValue<Short4> y) 6165894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 616601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens llvm::Function *pmaxsw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_pmaxs_w); 6167894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 616801a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<Short4>(V(::builder->CreateCall2(pmaxsw, x.value, y.value))); 6169894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6170894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 617119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short4> pminsw(RValue<Short4> x, RValue<Short4> y) 6172894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 617301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens llvm::Function *pminsw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_pmins_w); 6174894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 617501a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<Short4>(V(::builder->CreateCall2(pminsw, x.value, y.value))); 6176894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6177894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 617819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short4> pcmpgtw(RValue<Short4> x, RValue<Short4> y) 6179894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 618001a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens llvm::Function *pcmpgtw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_pcmpgt_w); 6181894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 618201a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<Short4>(V(::builder->CreateCall2(pcmpgtw, x.value, y.value))); 6183894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6184894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 618519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short4> pcmpeqw(RValue<Short4> x, RValue<Short4> y) 6186894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 618701a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens llvm::Function *pcmpeqw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_pcmpeq_w); 6188894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 618901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<Short4>(V(::builder->CreateCall2(pcmpeqw, x.value, y.value))); 6190894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6191894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 619219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Byte8> pcmpgtb(RValue<SByte8> x, RValue<SByte8> y) 6193894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 619401a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens llvm::Function *pcmpgtb = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_pcmpgt_b); 6195894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 619601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<Byte8>(V(::builder->CreateCall2(pcmpgtb, x.value, y.value))); 6197894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6198894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 619919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Byte8> pcmpeqb(RValue<Byte8> x, RValue<Byte8> y) 6200894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 620101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens llvm::Function *pcmpeqb = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_pcmpeq_b); 6202894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 620301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<Byte8>(V(::builder->CreateCall2(pcmpeqb, x.value, y.value))); 6204894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6205894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 620619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short4> packssdw(RValue<Int2> x, RValue<Int2> y) 6207894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 620801a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens llvm::Function *packssdw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_packssdw_128); 6209894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 621001a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<Short4>(V(::builder->CreateCall2(packssdw, x.value, y.value))); 6211894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6212894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 621319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short8> packssdw(RValue<Int4> x, RValue<Int4> y) 6214894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 62159e013d4624df365e002ee086486830cda78d2e98Nicolas Capens llvm::Function *packssdw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_packssdw_128); 6216894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 62179e013d4624df365e002ee086486830cda78d2e98Nicolas Capens return RValue<Short8>(V(::builder->CreateCall2(packssdw, x.value, y.value))); 6218894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6219894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 622019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<SByte8> packsswb(RValue<Short4> x, RValue<Short4> y) 6221894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 622201a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens llvm::Function *packsswb = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_packsswb_128); 6223894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 622401a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<SByte8>(V(::builder->CreateCall2(packsswb, x.value, y.value))); 6225894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6226894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 622733438a6882d629139617d80cc7fdbc687b71a794Nicolas Capens RValue<Byte8> packuswb(RValue<Short4> x, RValue<Short4> y) 6228894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 622901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens llvm::Function *packuswb = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_packuswb_128); 6230894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 623101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<Byte8>(V(::builder->CreateCall2(packuswb, x.value, y.value))); 6232894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6233894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 62343e7062b993c74700a403f46f01e0d55bfaed71dfNicolas Capens RValue<UShort8> packusdw(RValue<Int4> x, RValue<Int4> y) 6235894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 6236894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(CPUID::supportsSSE4_1()) 6237894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 6238fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::Function *packusdw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse41_packusdw); 623966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 62402ab69ee7346b5ecb708825ef00a127e1aac63152Nicolas Capens return RValue<UShort8>(V(::builder->CreateCall2(packusdw, x.value, y.value))); 6241894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6242894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman else 6243894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 62443e7062b993c74700a403f46f01e0d55bfaed71dfNicolas Capens RValue<Int4> bx = (x & ~(x >> 31)) - Int4(0x8000); 62453e7062b993c74700a403f46f01e0d55bfaed71dfNicolas Capens RValue<Int4> by = (y & ~(y >> 31)) - Int4(0x8000); 62463e7062b993c74700a403f46f01e0d55bfaed71dfNicolas Capens 62473e7062b993c74700a403f46f01e0d55bfaed71dfNicolas Capens return As<UShort8>(packssdw(bx, by) + Short8(0x8000u)); 6248894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6249894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6250894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 625119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort4> psrlw(RValue<UShort4> x, unsigned char y) 6252894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 625301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens llvm::Function *psrlw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_psrli_w); 6254894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 625501a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<UShort4>(V(::builder->CreateCall2(psrlw, x.value, V(Nucleus::createConstantInt(y))))); 6256894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6257894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 625819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort8> psrlw(RValue<UShort8> x, unsigned char y) 6259894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 6260fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::Function *psrlw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_psrli_w); 6261894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 62622ab69ee7346b5ecb708825ef00a127e1aac63152Nicolas Capens return RValue<UShort8>(V(::builder->CreateCall2(psrlw, x.value, V(Nucleus::createConstantInt(y))))); 6263894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6264894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 626519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short4> psraw(RValue<Short4> x, unsigned char y) 6266894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 626701a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens llvm::Function *psraw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_psrai_w); 6268894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 626901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<Short4>(V(::builder->CreateCall2(psraw, x.value, V(Nucleus::createConstantInt(y))))); 6270894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6271894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 627219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short8> psraw(RValue<Short8> x, unsigned char y) 6273894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 6274fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::Function *psraw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_psrai_w); 6275894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 62762ab69ee7346b5ecb708825ef00a127e1aac63152Nicolas Capens return RValue<Short8>(V(::builder->CreateCall2(psraw, x.value, V(Nucleus::createConstantInt(y))))); 6277894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6278894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 627919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short4> psllw(RValue<Short4> x, unsigned char y) 6280894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 628101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens llvm::Function *psllw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_pslli_w); 6282894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 628301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<Short4>(V(::builder->CreateCall2(psllw, x.value, V(Nucleus::createConstantInt(y))))); 6284894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6285894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 628619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short8> psllw(RValue<Short8> x, unsigned char y) 6287894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 6288fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::Function *psllw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_pslli_w); 6289894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 62902ab69ee7346b5ecb708825ef00a127e1aac63152Nicolas Capens return RValue<Short8>(V(::builder->CreateCall2(psllw, x.value, V(Nucleus::createConstantInt(y))))); 6291894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6292894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 629319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int2> pslld(RValue<Int2> x, unsigned char y) 6294894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 629501a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens llvm::Function *pslld = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_pslli_d); 6296894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 629701a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<Int2>(V(::builder->CreateCall2(pslld, x.value, V(Nucleus::createConstantInt(y))))); 6298894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6299894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 630019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> pslld(RValue<Int4> x, unsigned char y) 6301894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 63029e013d4624df365e002ee086486830cda78d2e98Nicolas Capens llvm::Function *pslld = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_pslli_d); 630366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 63049e013d4624df365e002ee086486830cda78d2e98Nicolas Capens return RValue<Int4>(V(::builder->CreateCall2(pslld, x.value, V(Nucleus::createConstantInt(y))))); 6305894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6306894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 630719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int2> psrad(RValue<Int2> x, unsigned char y) 6308894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 630901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens llvm::Function *psrad = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_psrai_d); 6310894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 631101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<Int2>(V(::builder->CreateCall2(psrad, x.value, V(Nucleus::createConstantInt(y))))); 6312894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6313894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 631419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> psrad(RValue<Int4> x, unsigned char y) 6315894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 63169e013d4624df365e002ee086486830cda78d2e98Nicolas Capens llvm::Function *psrad = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_psrai_d); 631766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 63189e013d4624df365e002ee086486830cda78d2e98Nicolas Capens return RValue<Int4>(V(::builder->CreateCall2(psrad, x.value, V(Nucleus::createConstantInt(y))))); 6319894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6320894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 632119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt2> psrld(RValue<UInt2> x, unsigned char y) 6322894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 632301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens llvm::Function *psrld = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_psrli_d); 6324894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 632501a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<UInt2>(V(::builder->CreateCall2(psrld, x.value, V(Nucleus::createConstantInt(y))))); 6326894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6327894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 632819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt4> psrld(RValue<UInt4> x, unsigned char y) 6329894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 63309e013d4624df365e002ee086486830cda78d2e98Nicolas Capens llvm::Function *psrld = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_psrli_d); 633166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 63329e013d4624df365e002ee086486830cda78d2e98Nicolas Capens return RValue<UInt4>(V(::builder->CreateCall2(psrld, x.value, V(Nucleus::createConstantInt(y))))); 6333894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6334894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 633519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> pmaxsd(RValue<Int4> x, RValue<Int4> y) 633619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 6337fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::Function *pmaxsd = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse41_pmaxsd); 633819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 63392ab69ee7346b5ecb708825ef00a127e1aac63152Nicolas Capens return RValue<Int4>(V(::builder->CreateCall2(pmaxsd, x.value, y.value))); 634019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 634119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 634219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> pminsd(RValue<Int4> x, RValue<Int4> y) 634319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 6344fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::Function *pminsd = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse41_pminsd); 634519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 63462ab69ee7346b5ecb708825ef00a127e1aac63152Nicolas Capens return RValue<Int4>(V(::builder->CreateCall2(pminsd, x.value, y.value))); 634719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 634819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 634919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt4> pmaxud(RValue<UInt4> x, RValue<UInt4> y) 635019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 6351fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::Function *pmaxud = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse41_pmaxud); 635219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 63532ab69ee7346b5ecb708825ef00a127e1aac63152Nicolas Capens return RValue<UInt4>(V(::builder->CreateCall2(pmaxud, x.value, y.value))); 635419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 635519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 635619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UInt4> pminud(RValue<UInt4> x, RValue<UInt4> y) 635719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 6358fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::Function *pminud = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse41_pminud); 635919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 63602ab69ee7346b5ecb708825ef00a127e1aac63152Nicolas Capens return RValue<UInt4>(V(::builder->CreateCall2(pminud, x.value, y.value))); 6361894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6362894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 636319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short4> pmulhw(RValue<Short4> x, RValue<Short4> y) 6364894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 636501a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens llvm::Function *pmulhw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_pmulh_w); 6366894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 636701a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<Short4>(V(::builder->CreateCall2(pmulhw, x.value, y.value))); 6368894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6369894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 637019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort4> pmulhuw(RValue<UShort4> x, RValue<UShort4> y) 6371894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 637201a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens llvm::Function *pmulhuw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_pmulhu_w); 6373894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 637401a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<UShort4>(V(::builder->CreateCall2(pmulhuw, x.value, y.value))); 6375894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6376894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 637719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int2> pmaddwd(RValue<Short4> x, RValue<Short4> y) 6378894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 637901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens llvm::Function *pmaddwd = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_pmadd_wd); 6380894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 638101a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return As<Int2>(V(::builder->CreateCall2(pmaddwd, x.value, y.value))); 6382894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6383894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 638419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Short8> pmulhw(RValue<Short8> x, RValue<Short8> y) 6385894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 6386fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::Function *pmulhw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_pmulh_w); 6387894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 63882ab69ee7346b5ecb708825ef00a127e1aac63152Nicolas Capens return RValue<Short8>(V(::builder->CreateCall2(pmulhw, x.value, y.value))); 6389894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6390894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 639119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<UShort8> pmulhuw(RValue<UShort8> x, RValue<UShort8> y) 6392894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 6393fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::Function *pmulhuw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_pmulhu_w); 6394894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 63952ab69ee7346b5ecb708825ef00a127e1aac63152Nicolas Capens return RValue<UShort8>(V(::builder->CreateCall2(pmulhuw, x.value, y.value))); 6396894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6397894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 639819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int4> pmaddwd(RValue<Short8> x, RValue<Short8> y) 6399894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 6400fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::Function *pmaddwd = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_pmadd_wd); 6401894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 64022ab69ee7346b5ecb708825ef00a127e1aac63152Nicolas Capens return RValue<Int4>(V(::builder->CreateCall2(pmaddwd, x.value, y.value))); 6403894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6404894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 640519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int> movmskps(RValue<Float4> x) 6406894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 6407fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::Function *movmskps = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse_movmsk_ps); 6408894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 64092ab69ee7346b5ecb708825ef00a127e1aac63152Nicolas Capens return RValue<Int>(V(::builder->CreateCall(movmskps, x.value))); 6410894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6411894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 641219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman RValue<Int> pmovmskb(RValue<Byte8> x) 6413894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 641401a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens llvm::Function *pmovmskb = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_pmovmskb_128); 6415894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 641601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<Int>(V(::builder->CreateCall(pmovmskb, x.value))) & 0xFF; 6417894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6418894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 641901a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens RValue<Int4> pmovzxbd(RValue<Byte16> x) 6420894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 6421fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::Function *pmovzxbd = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse41_pmovzxbd); 642266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 642301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<Int4>(V(::builder->CreateCall(pmovzxbd, x.value))); 6424894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6425894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 642601a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens RValue<Int4> pmovsxbd(RValue<SByte16> x) 6427894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 6428fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::Function *pmovsxbd = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse41_pmovsxbd); 642966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 643001a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<Int4>(V(::builder->CreateCall(pmovsxbd, x.value))); 6431894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6432894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 643301a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens RValue<Int4> pmovzxwd(RValue<UShort8> x) 6434894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 6435fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::Function *pmovzxwd = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse41_pmovzxwd); 643666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 643701a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<Int4>(V(::builder->CreateCall(pmovzxwd, x.value))); 6438894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6439894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 644001a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens RValue<Int4> pmovsxwd(RValue<Short8> x) 6441894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 6442fbf2bc536793bca43e28b07ce5059bbc8c377e01Nicolas Capens llvm::Function *pmovsxwd = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse41_pmovsxwd); 644366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 644401a9796a5e07f0319275e1c592b39544d6aa228aNicolas Capens return RValue<Int4>(V(::builder->CreateCall(pmovsxwd, x.value))); 6445894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6446894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 6447894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman} 6448