Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 1 | // Copyright 2016 The SwiftShader Authors. All Rights Reserved. |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2 | // |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6 | // |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 8 | // |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 14 | |
| 15 | #include "Nucleus.hpp" |
| 16 | |
| 17 | #include "llvm/Support/IRBuilder.h" |
| 18 | #include "llvm/Function.h" |
| 19 | #include "llvm/GlobalVariable.h" |
| 20 | #include "llvm/Module.h" |
| 21 | #include "llvm/LLVMContext.h" |
| 22 | #include "llvm/Constants.h" |
| 23 | #include "llvm/Intrinsics.h" |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 24 | #include "llvm/PassManager.h" |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 25 | #include "llvm/Analysis/LoopPass.h" |
| 26 | #include "llvm/Transforms/Scalar.h" |
| 27 | #include "llvm/Target/TargetData.h" |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 28 | #include "llvm/Target/TargetOptions.h" |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 29 | #include "llvm/Support/TargetSelect.h" |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 30 | #include "../lib/ExecutionEngine/JIT/JIT.h" |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 31 | |
Nicolas Capens | daa5d91 | 2016-09-28 16:56:36 -0400 | [diff] [blame] | 32 | #include "LLVMRoutine.hpp" |
| 33 | #include "LLVMRoutineManager.hpp" |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 34 | #include "x86.hpp" |
| 35 | #include "CPUID.hpp" |
| 36 | #include "Thread.hpp" |
| 37 | #include "Memory.hpp" |
Nicolas Capens | 3bbc5e1 | 2016-09-27 10:49:52 -0400 | [diff] [blame] | 38 | #include "MutexLock.hpp" |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 39 | |
Nicolas Capens | 05b3d66 | 2016-02-25 23:58:33 -0500 | [diff] [blame] | 40 | #include <xmmintrin.h> |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 41 | #include <fstream> |
| 42 | |
Nicolas Capens | cb12258 | 2014-05-06 23:34:44 -0400 | [diff] [blame] | 43 | #if defined(__x86_64__) && defined(_WIN32) |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 44 | extern "C" void X86CompilationCallback() |
| 45 | { |
| 46 | assert(false); // UNIMPLEMENTED |
| 47 | } |
| 48 | #endif |
| 49 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 50 | extern "C" |
| 51 | { |
| 52 | bool (*CodeAnalystInitialize)() = 0; |
| 53 | void (*CodeAnalystCompleteJITLog)() = 0; |
| 54 | bool (*CodeAnalystLogJITCode)(const void *jitCodeStartAddr, unsigned int jitCodeSize, const wchar_t *functionName) = 0; |
| 55 | } |
| 56 | |
| 57 | namespace llvm |
| 58 | { |
| 59 | extern bool JITEmitDebugInfo; |
| 60 | } |
| 61 | |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 62 | namespace |
| 63 | { |
Nicolas Capens | daa5d91 | 2016-09-28 16:56:36 -0400 | [diff] [blame] | 64 | sw::LLVMRoutineManager *routineManager = nullptr; |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 65 | llvm::ExecutionEngine *executionEngine = nullptr; |
| 66 | llvm::IRBuilder<> *builder = nullptr; |
| 67 | llvm::LLVMContext *context = nullptr; |
| 68 | llvm::Module *module = nullptr; |
| 69 | llvm::Function *function = nullptr; |
Nicolas Capens | 3bbc5e1 | 2016-09-27 10:49:52 -0400 | [diff] [blame] | 70 | |
| 71 | sw::BackoffLock codegenMutex; |
Nicolas Capens | 9ed1a18 | 2016-10-24 09:52:23 -0400 | [diff] [blame^] | 72 | |
| 73 | sw::BasicBlock *falseBB = nullptr; |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 74 | } |
| 75 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 76 | namespace sw |
| 77 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 78 | using namespace llvm; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 79 | |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 80 | Optimization optimization[10] = {InstructionCombining, Disabled}; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 81 | |
Nicolas Capens | c8b67a4 | 2016-09-25 15:02:52 -0400 | [diff] [blame] | 82 | class Type : public llvm::Type {}; |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 83 | class Value : public llvm::Value {}; |
Nicolas Capens | c8b67a4 | 2016-09-25 15:02:52 -0400 | [diff] [blame] | 84 | class BasicBlock : public llvm::BasicBlock {}; |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 85 | |
| 86 | inline Type *T(llvm::Type *t) |
| 87 | { |
| 88 | return reinterpret_cast<Type*>(t); |
| 89 | } |
| 90 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 91 | inline Value *V(llvm::Value *t) |
| 92 | { |
| 93 | return reinterpret_cast<Value*>(t); |
| 94 | } |
| 95 | |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 96 | inline std::vector<llvm::Type*> &T(std::vector<Type*> &t) |
| 97 | { |
| 98 | return reinterpret_cast<std::vector<llvm::Type*>&>(t); |
| 99 | } |
| 100 | |
Nicolas Capens | c8b67a4 | 2016-09-25 15:02:52 -0400 | [diff] [blame] | 101 | inline BasicBlock *B(llvm::BasicBlock *t) |
| 102 | { |
| 103 | return reinterpret_cast<BasicBlock*>(t); |
| 104 | } |
| 105 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 106 | Nucleus::Nucleus() |
| 107 | { |
Nicolas Capens | 3bbc5e1 | 2016-09-27 10:49:52 -0400 | [diff] [blame] | 108 | ::codegenMutex.lock(); // Reactor and LLVM are currently not thread safe |
Nicolas Capens | b7ea984 | 2015-04-01 10:54:59 -0400 | [diff] [blame] | 109 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 110 | InitializeNativeTarget(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 111 | JITEmitDebugInfo = false; |
| 112 | |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 113 | if(!::context) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 114 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 115 | ::context = new LLVMContext(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 116 | } |
| 117 | |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 118 | ::module = new Module("", *::context); |
Nicolas Capens | daa5d91 | 2016-09-28 16:56:36 -0400 | [diff] [blame] | 119 | ::routineManager = new LLVMRoutineManager(); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 120 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 121 | #if defined(__x86_64__) |
| 122 | const char *architecture = "x86-64"; |
| 123 | #else |
| 124 | const char *architecture = "x86"; |
| 125 | #endif |
| 126 | |
| 127 | SmallVector<std::string, 1> MAttrs; |
| 128 | MAttrs.push_back(CPUID::supportsMMX() ? "+mmx" : "-mmx"); |
| 129 | MAttrs.push_back(CPUID::supportsCMOV() ? "+cmov" : "-cmov"); |
| 130 | MAttrs.push_back(CPUID::supportsSSE() ? "+sse" : "-sse"); |
| 131 | MAttrs.push_back(CPUID::supportsSSE2() ? "+sse2" : "-sse2"); |
| 132 | MAttrs.push_back(CPUID::supportsSSE3() ? "+sse3" : "-sse3"); |
| 133 | MAttrs.push_back(CPUID::supportsSSSE3() ? "+ssse3" : "-ssse3"); |
| 134 | MAttrs.push_back(CPUID::supportsSSE4_1() ? "+sse41" : "-sse41"); |
| 135 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 136 | std::string error; |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 137 | TargetMachine *targetMachine = EngineBuilder::selectTarget(::module, architecture, "", MAttrs, Reloc::Default, CodeModel::JITDefault, &error); |
| 138 | ::executionEngine = JIT::createJIT(::module, 0, ::routineManager, CodeGenOpt::Aggressive, true, targetMachine); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 139 | |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 140 | if(!::builder) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 141 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 142 | ::builder = new IRBuilder<>(*::context); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 143 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 144 | #if defined(_WIN32) |
| 145 | HMODULE CodeAnalyst = LoadLibrary("CAJitNtfyLib.dll"); |
| 146 | if(CodeAnalyst) |
| 147 | { |
| 148 | CodeAnalystInitialize = (bool(*)())GetProcAddress(CodeAnalyst, "CAJIT_Initialize"); |
| 149 | CodeAnalystCompleteJITLog = (void(*)())GetProcAddress(CodeAnalyst, "CAJIT_CompleteJITLog"); |
| 150 | CodeAnalystLogJITCode = (bool(*)(const void*, unsigned int, const wchar_t*))GetProcAddress(CodeAnalyst, "CAJIT_LogJITCode"); |
| 151 | |
| 152 | CodeAnalystInitialize(); |
| 153 | } |
| 154 | #endif |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 155 | } |
| 156 | } |
| 157 | |
| 158 | Nucleus::~Nucleus() |
| 159 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 160 | delete ::executionEngine; |
| 161 | ::executionEngine = nullptr; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 162 | |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 163 | ::routineManager = nullptr; |
| 164 | ::function = nullptr; |
| 165 | ::module = nullptr; |
Nicolas Capens | b7ea984 | 2015-04-01 10:54:59 -0400 | [diff] [blame] | 166 | |
Nicolas Capens | 3bbc5e1 | 2016-09-27 10:49:52 -0400 | [diff] [blame] | 167 | ::codegenMutex.unlock(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | Routine *Nucleus::acquireRoutine(const wchar_t *name, bool runOptimizations) |
| 171 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 172 | if(::builder->GetInsertBlock()->empty() || !::builder->GetInsertBlock()->back().isTerminator()) |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 173 | { |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 174 | llvm::Type *type = ::function->getReturnType(); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 175 | |
| 176 | if(type->isVoidTy()) |
| 177 | { |
| 178 | createRetVoid(); |
| 179 | } |
| 180 | else |
| 181 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 182 | createRet(V(UndefValue::get(type))); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 183 | } |
| 184 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 185 | |
| 186 | if(false) |
| 187 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 188 | std::string error; |
| 189 | raw_fd_ostream file("llvm-dump-unopt.txt", error); |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 190 | ::module->print(file, 0); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 191 | } |
| 192 | |
| 193 | if(runOptimizations) |
| 194 | { |
| 195 | optimize(); |
| 196 | } |
| 197 | |
| 198 | if(false) |
| 199 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 200 | std::string error; |
| 201 | raw_fd_ostream file("llvm-dump-opt.txt", error); |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 202 | ::module->print(file, 0); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 203 | } |
| 204 | |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 205 | void *entry = ::executionEngine->getPointerToFunction(::function); |
Nicolas Capens | daa5d91 | 2016-09-28 16:56:36 -0400 | [diff] [blame] | 206 | LLVMRoutine *routine = ::routineManager->acquireRoutine(entry); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 207 | |
| 208 | if(CodeAnalystLogJITCode) |
| 209 | { |
Nicolas Capens | d946e0a | 2014-06-26 11:31:08 -0400 | [diff] [blame] | 210 | CodeAnalystLogJITCode(routine->getEntry(), routine->getCodeSize(), name); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 211 | } |
| 212 | |
| 213 | return routine; |
| 214 | } |
| 215 | |
| 216 | void Nucleus::optimize() |
| 217 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 218 | static PassManager *passManager = nullptr; |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 219 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 220 | if(!passManager) |
| 221 | { |
| 222 | passManager = new PassManager(); |
| 223 | |
| 224 | UnsafeFPMath = true; |
| 225 | // NoInfsFPMath = true; |
| 226 | // NoNaNsFPMath = true; |
| 227 | |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 228 | passManager->add(new TargetData(*::executionEngine->getTargetData())); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 229 | passManager->add(createScalarReplAggregatesPass()); |
| 230 | |
| 231 | for(int pass = 0; pass < 10 && optimization[pass] != Disabled; pass++) |
| 232 | { |
| 233 | switch(optimization[pass]) |
| 234 | { |
| 235 | case Disabled: break; |
| 236 | case CFGSimplification: passManager->add(createCFGSimplificationPass()); break; |
| 237 | case LICM: passManager->add(createLICMPass()); break; |
| 238 | case AggressiveDCE: passManager->add(createAggressiveDCEPass()); break; |
| 239 | case GVN: passManager->add(createGVNPass()); break; |
| 240 | case InstructionCombining: passManager->add(createInstructionCombiningPass()); break; |
| 241 | case Reassociate: passManager->add(createReassociatePass()); break; |
| 242 | case DeadStoreElimination: passManager->add(createDeadStoreEliminationPass()); break; |
| 243 | case SCCP: passManager->add(createSCCPPass()); break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 244 | case ScalarReplAggregates: passManager->add(createScalarReplAggregatesPass()); break; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 245 | default: |
| 246 | assert(false); |
| 247 | } |
| 248 | } |
| 249 | } |
| 250 | |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 251 | passManager->run(*::module); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 252 | } |
| 253 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 254 | Value *Nucleus::allocateStackVariable(Type *type, int arraySize) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 255 | { |
| 256 | // Need to allocate it in the entry block for mem2reg to work |
Nicolas Capens | c8b67a4 | 2016-09-25 15:02:52 -0400 | [diff] [blame] | 257 | llvm::BasicBlock &entryBlock = ::function->getEntryBlock(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 258 | |
| 259 | Instruction *declaration; |
| 260 | |
| 261 | if(arraySize) |
| 262 | { |
| 263 | declaration = new AllocaInst(type, Nucleus::createConstantInt(arraySize)); |
| 264 | } |
| 265 | else |
| 266 | { |
| 267 | declaration = new AllocaInst(type, (Value*)0); |
| 268 | } |
| 269 | |
| 270 | entryBlock.getInstList().push_front(declaration); |
| 271 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 272 | return V(declaration); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | BasicBlock *Nucleus::createBasicBlock() |
| 276 | { |
Nicolas Capens | c8b67a4 | 2016-09-25 15:02:52 -0400 | [diff] [blame] | 277 | return B(BasicBlock::Create(*::context, "", ::function)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | BasicBlock *Nucleus::getInsertBlock() |
| 281 | { |
Nicolas Capens | c8b67a4 | 2016-09-25 15:02:52 -0400 | [diff] [blame] | 282 | return B(::builder->GetInsertBlock()); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 283 | } |
| 284 | |
| 285 | void Nucleus::setInsertBlock(BasicBlock *basicBlock) |
| 286 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 287 | // assert(::builder->GetInsertBlock()->back().isTerminator()); |
| 288 | return ::builder->SetInsertPoint(basicBlock); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 289 | } |
| 290 | |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 291 | void Nucleus::createFunction(Type *ReturnType, std::vector<Type*> &Params) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 292 | { |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 293 | llvm::FunctionType *functionType = llvm::FunctionType::get(ReturnType, T(Params), false); |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 294 | ::function = llvm::Function::Create(functionType, llvm::GlobalValue::InternalLinkage, "", ::module); |
| 295 | ::function->setCallingConv(llvm::CallingConv::C); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 296 | |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 297 | ::builder->SetInsertPoint(BasicBlock::Create(*::context, "", ::function)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 298 | } |
| 299 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 300 | Value *Nucleus::getArgument(unsigned int index) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 301 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 302 | llvm::Function::arg_iterator args = ::function->arg_begin(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 303 | |
| 304 | while(index) |
| 305 | { |
| 306 | args++; |
| 307 | index--; |
| 308 | } |
| 309 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 310 | return V(&*args); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 311 | } |
| 312 | |
Nicolas Capens | 3d7c35f | 2016-09-28 10:36:57 -0400 | [diff] [blame] | 313 | void Nucleus::createRetVoid() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 314 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 315 | x86::emms(); |
| 316 | |
Nicolas Capens | 3d7c35f | 2016-09-28 10:36:57 -0400 | [diff] [blame] | 317 | ::builder->CreateRetVoid(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 318 | } |
| 319 | |
Nicolas Capens | 3d7c35f | 2016-09-28 10:36:57 -0400 | [diff] [blame] | 320 | void Nucleus::createRet(Value *v) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 321 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 322 | x86::emms(); |
| 323 | |
Nicolas Capens | 3d7c35f | 2016-09-28 10:36:57 -0400 | [diff] [blame] | 324 | ::builder->CreateRet(v); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 325 | } |
| 326 | |
Nicolas Capens | 3d7c35f | 2016-09-28 10:36:57 -0400 | [diff] [blame] | 327 | void Nucleus::createBr(BasicBlock *dest) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 328 | { |
Nicolas Capens | 3d7c35f | 2016-09-28 10:36:57 -0400 | [diff] [blame] | 329 | ::builder->CreateBr(dest); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 330 | } |
| 331 | |
Nicolas Capens | 3d7c35f | 2016-09-28 10:36:57 -0400 | [diff] [blame] | 332 | void Nucleus::createCondBr(Value *cond, BasicBlock *ifTrue, BasicBlock *ifFalse) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 333 | { |
Nicolas Capens | 3d7c35f | 2016-09-28 10:36:57 -0400 | [diff] [blame] | 334 | ::builder->CreateCondBr(cond, ifTrue, ifFalse); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 335 | } |
| 336 | |
| 337 | Value *Nucleus::createAdd(Value *lhs, Value *rhs) |
| 338 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 339 | return V(::builder->CreateAdd(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | Value *Nucleus::createSub(Value *lhs, Value *rhs) |
| 343 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 344 | return V(::builder->CreateSub(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 345 | } |
| 346 | |
| 347 | Value *Nucleus::createMul(Value *lhs, Value *rhs) |
| 348 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 349 | return V(::builder->CreateMul(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 350 | } |
| 351 | |
| 352 | Value *Nucleus::createUDiv(Value *lhs, Value *rhs) |
| 353 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 354 | return V(::builder->CreateUDiv(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 355 | } |
| 356 | |
| 357 | Value *Nucleus::createSDiv(Value *lhs, Value *rhs) |
| 358 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 359 | return V(::builder->CreateSDiv(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 360 | } |
| 361 | |
| 362 | Value *Nucleus::createFAdd(Value *lhs, Value *rhs) |
| 363 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 364 | return V(::builder->CreateFAdd(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | Value *Nucleus::createFSub(Value *lhs, Value *rhs) |
| 368 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 369 | return V(::builder->CreateFSub(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 370 | } |
| 371 | |
| 372 | Value *Nucleus::createFMul(Value *lhs, Value *rhs) |
| 373 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 374 | return V(::builder->CreateFMul(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 375 | } |
| 376 | |
| 377 | Value *Nucleus::createFDiv(Value *lhs, Value *rhs) |
| 378 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 379 | return V(::builder->CreateFDiv(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 380 | } |
| 381 | |
| 382 | Value *Nucleus::createURem(Value *lhs, Value *rhs) |
| 383 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 384 | return V(::builder->CreateURem(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 385 | } |
| 386 | |
| 387 | Value *Nucleus::createSRem(Value *lhs, Value *rhs) |
| 388 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 389 | return V(::builder->CreateSRem(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 390 | } |
| 391 | |
| 392 | Value *Nucleus::createFRem(Value *lhs, Value *rhs) |
| 393 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 394 | return V(::builder->CreateFRem(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 395 | } |
| 396 | |
| 397 | Value *Nucleus::createShl(Value *lhs, Value *rhs) |
| 398 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 399 | return V(::builder->CreateShl(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 400 | } |
| 401 | |
| 402 | Value *Nucleus::createLShr(Value *lhs, Value *rhs) |
| 403 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 404 | return V(::builder->CreateLShr(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 405 | } |
| 406 | |
| 407 | Value *Nucleus::createAShr(Value *lhs, Value *rhs) |
| 408 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 409 | return V(::builder->CreateAShr(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 410 | } |
| 411 | |
| 412 | Value *Nucleus::createAnd(Value *lhs, Value *rhs) |
| 413 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 414 | return V(::builder->CreateAnd(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 415 | } |
| 416 | |
| 417 | Value *Nucleus::createOr(Value *lhs, Value *rhs) |
| 418 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 419 | return V(::builder->CreateOr(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 420 | } |
| 421 | |
| 422 | Value *Nucleus::createXor(Value *lhs, Value *rhs) |
| 423 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 424 | return V(::builder->CreateXor(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 425 | } |
| 426 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 427 | Value *Nucleus::createNeg(Value *v) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 428 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 429 | return V(::builder->CreateNeg(v)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 430 | } |
| 431 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 432 | Value *Nucleus::createFNeg(Value *v) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 433 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 434 | return V(::builder->CreateFNeg(v)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 435 | } |
| 436 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 437 | Value *Nucleus::createNot(Value *v) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 438 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 439 | return V(::builder->CreateNot(v)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 440 | } |
| 441 | |
Nicolas Capens | e12780d | 2016-09-27 14:18:07 -0400 | [diff] [blame] | 442 | Value *Nucleus::createLoad(Value *ptr, Type *type, bool isVolatile, unsigned int align) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 443 | { |
Nicolas Capens | e12780d | 2016-09-27 14:18:07 -0400 | [diff] [blame] | 444 | assert(ptr->getType()->getContainedType(0) == type); |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 445 | return V(::builder->Insert(new LoadInst(ptr, "", isVolatile, align))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 446 | } |
| 447 | |
Nicolas Capens | 6d73871 | 2016-09-30 04:15:22 -0400 | [diff] [blame] | 448 | Value *Nucleus::createStore(Value *value, Value *ptr, Type *type, bool isVolatile, unsigned int align) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 449 | { |
Nicolas Capens | 6d73871 | 2016-09-30 04:15:22 -0400 | [diff] [blame] | 450 | assert(ptr->getType()->getContainedType(0) == type); |
Nicolas Capens | b955d5b | 2016-09-28 22:36:28 -0400 | [diff] [blame] | 451 | ::builder->Insert(new StoreInst(value, ptr, isVolatile, align)); |
| 452 | return value; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 453 | } |
| 454 | |
Nicolas Capens | 6d73871 | 2016-09-30 04:15:22 -0400 | [diff] [blame] | 455 | Value *Nucleus::createGEP(Value *ptr, Type *type, Value *index) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 456 | { |
Nicolas Capens | 6d73871 | 2016-09-30 04:15:22 -0400 | [diff] [blame] | 457 | assert(ptr->getType()->getContainedType(0) == type); |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 458 | return V(::builder->CreateGEP(ptr, index)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 459 | } |
| 460 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 461 | Value *Nucleus::createAtomicAdd(Value *ptr, Value *value) |
| 462 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 463 | return V(::builder->CreateAtomicRMW(AtomicRMWInst::Add, ptr, value, SequentiallyConsistent)); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 464 | } |
| 465 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 466 | Value *Nucleus::createTrunc(Value *v, Type *destType) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 467 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 468 | return V(::builder->CreateTrunc(v, destType)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 469 | } |
| 470 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 471 | Value *Nucleus::createZExt(Value *v, Type *destType) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 472 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 473 | return V(::builder->CreateZExt(v, destType)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 474 | } |
| 475 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 476 | Value *Nucleus::createSExt(Value *v, Type *destType) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 477 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 478 | return V(::builder->CreateSExt(v, destType)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 479 | } |
| 480 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 481 | Value *Nucleus::createFPToSI(Value *v, Type *destType) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 482 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 483 | return V(::builder->CreateFPToSI(v, destType)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 484 | } |
| 485 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 486 | Value *Nucleus::createUIToFP(Value *v, Type *destType) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 487 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 488 | return V(::builder->CreateUIToFP(v, destType)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 489 | } |
| 490 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 491 | Value *Nucleus::createSIToFP(Value *v, Type *destType) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 492 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 493 | return V(::builder->CreateSIToFP(v, destType)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 494 | } |
| 495 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 496 | Value *Nucleus::createFPTrunc(Value *v, Type *destType) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 497 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 498 | return V(::builder->CreateFPTrunc(v, destType)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 499 | } |
| 500 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 501 | Value *Nucleus::createFPExt(Value *v, Type *destType) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 502 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 503 | return V(::builder->CreateFPExt(v, destType)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 504 | } |
| 505 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 506 | Value *Nucleus::createBitCast(Value *v, Type *destType) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 507 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 508 | return V(::builder->CreateBitCast(v, destType)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 509 | } |
| 510 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 511 | Value *Nucleus::createIntCast(Value *v, Type *destType, bool isSigned) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 512 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 513 | return V(::builder->CreateIntCast(v, destType, isSigned)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 514 | } |
| 515 | |
| 516 | Value *Nucleus::createICmpEQ(Value *lhs, Value *rhs) |
| 517 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 518 | return V(::builder->CreateICmpEQ(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 519 | } |
| 520 | |
| 521 | Value *Nucleus::createICmpNE(Value *lhs, Value *rhs) |
| 522 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 523 | return V(::builder->CreateICmpNE(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 524 | } |
| 525 | |
| 526 | Value *Nucleus::createICmpUGT(Value *lhs, Value *rhs) |
| 527 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 528 | return V(::builder->CreateICmpUGT(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 529 | } |
| 530 | |
| 531 | Value *Nucleus::createICmpUGE(Value *lhs, Value *rhs) |
| 532 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 533 | return V(::builder->CreateICmpUGE(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 534 | } |
| 535 | |
| 536 | Value *Nucleus::createICmpULT(Value *lhs, Value *rhs) |
| 537 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 538 | return V(::builder->CreateICmpULT(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 539 | } |
| 540 | |
| 541 | Value *Nucleus::createICmpULE(Value *lhs, Value *rhs) |
| 542 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 543 | return V(::builder->CreateICmpULE(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 544 | } |
| 545 | |
| 546 | Value *Nucleus::createICmpSGT(Value *lhs, Value *rhs) |
| 547 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 548 | return V(::builder->CreateICmpSGT(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 549 | } |
| 550 | |
| 551 | Value *Nucleus::createICmpSGE(Value *lhs, Value *rhs) |
| 552 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 553 | return V(::builder->CreateICmpSGE(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 554 | } |
| 555 | |
| 556 | Value *Nucleus::createICmpSLT(Value *lhs, Value *rhs) |
| 557 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 558 | return V(::builder->CreateICmpSLT(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 559 | } |
| 560 | |
| 561 | Value *Nucleus::createICmpSLE(Value *lhs, Value *rhs) |
| 562 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 563 | return V(::builder->CreateICmpSLE(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 564 | } |
| 565 | |
| 566 | Value *Nucleus::createFCmpOEQ(Value *lhs, Value *rhs) |
| 567 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 568 | return V(::builder->CreateFCmpOEQ(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 569 | } |
| 570 | |
| 571 | Value *Nucleus::createFCmpOGT(Value *lhs, Value *rhs) |
| 572 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 573 | return V(::builder->CreateFCmpOGT(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 574 | } |
| 575 | |
| 576 | Value *Nucleus::createFCmpOGE(Value *lhs, Value *rhs) |
| 577 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 578 | return V(::builder->CreateFCmpOGE(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 579 | } |
| 580 | |
| 581 | Value *Nucleus::createFCmpOLT(Value *lhs, Value *rhs) |
| 582 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 583 | return V(::builder->CreateFCmpOLT(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 584 | } |
| 585 | |
| 586 | Value *Nucleus::createFCmpOLE(Value *lhs, Value *rhs) |
| 587 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 588 | return V(::builder->CreateFCmpOLE(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 589 | } |
| 590 | |
| 591 | Value *Nucleus::createFCmpONE(Value *lhs, Value *rhs) |
| 592 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 593 | return V(::builder->CreateFCmpONE(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 594 | } |
| 595 | |
| 596 | Value *Nucleus::createFCmpORD(Value *lhs, Value *rhs) |
| 597 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 598 | return V(::builder->CreateFCmpORD(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 599 | } |
| 600 | |
| 601 | Value *Nucleus::createFCmpUNO(Value *lhs, Value *rhs) |
| 602 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 603 | return V(::builder->CreateFCmpUNO(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 604 | } |
| 605 | |
| 606 | Value *Nucleus::createFCmpUEQ(Value *lhs, Value *rhs) |
| 607 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 608 | return V(::builder->CreateFCmpUEQ(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 609 | } |
| 610 | |
| 611 | Value *Nucleus::createFCmpUGT(Value *lhs, Value *rhs) |
| 612 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 613 | return V(::builder->CreateFCmpUGT(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 614 | } |
| 615 | |
| 616 | Value *Nucleus::createFCmpUGE(Value *lhs, Value *rhs) |
| 617 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 618 | return V(::builder->CreateFCmpUGE(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 619 | } |
| 620 | |
| 621 | Value *Nucleus::createFCmpULT(Value *lhs, Value *rhs) |
| 622 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 623 | return V(::builder->CreateFCmpULT(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 624 | } |
| 625 | |
| 626 | Value *Nucleus::createFCmpULE(Value *lhs, Value *rhs) |
| 627 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 628 | return V(::builder->CreateFCmpULE(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 629 | } |
| 630 | |
| 631 | Value *Nucleus::createFCmpUNE(Value *lhs, Value *rhs) |
| 632 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 633 | return V(::builder->CreateFCmpULE(lhs, rhs)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 634 | } |
| 635 | |
Nicolas Capens | e95d534 | 2016-09-30 11:37:28 -0400 | [diff] [blame] | 636 | Value *Nucleus::createExtractElement(Value *vector, Type *type, int index) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 637 | { |
Nicolas Capens | e95d534 | 2016-09-30 11:37:28 -0400 | [diff] [blame] | 638 | assert(vector->getType()->getContainedType(0) == type); |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 639 | return V(::builder->CreateExtractElement(vector, createConstantInt(index))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 640 | } |
| 641 | |
| 642 | Value *Nucleus::createInsertElement(Value *vector, Value *element, int index) |
| 643 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 644 | return V(::builder->CreateInsertElement(vector, element, createConstantInt(index))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 645 | } |
| 646 | |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 647 | Value *Nucleus::createShuffleVector(Value *V1, Value *V2, const int *select) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 648 | { |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 649 | int size = llvm::cast<llvm::VectorType>(V1->getType())->getNumElements(); |
| 650 | const int maxSize = 16; |
| 651 | llvm::Constant *swizzle[maxSize]; |
| 652 | assert(size <= maxSize); |
| 653 | |
| 654 | for(int i = 0; i < size; i++) |
| 655 | { |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 656 | swizzle[i] = llvm::ConstantInt::get(Type::getInt32Ty(*::context), select[i]); |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 657 | } |
| 658 | |
| 659 | llvm::Value *shuffle = llvm::ConstantVector::get(llvm::ArrayRef<llvm::Constant*>(swizzle, size)); |
| 660 | |
| 661 | return V(::builder->CreateShuffleVector(V1, V2, shuffle)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 662 | } |
| 663 | |
| 664 | Value *Nucleus::createSelect(Value *C, Value *ifTrue, Value *ifFalse) |
| 665 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 666 | return V(::builder->CreateSelect(C, ifTrue, ifFalse)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 667 | } |
| 668 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 669 | Value *Nucleus::createSwitch(Value *v, BasicBlock *Dest, unsigned NumCases) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 670 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 671 | return V(::builder->CreateSwitch(v, Dest, NumCases)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 672 | } |
| 673 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 674 | void Nucleus::addSwitchCase(Value *Switch, int Case, BasicBlock *Branch) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 675 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 676 | reinterpret_cast<SwitchInst*>(Switch)->addCase(llvm::ConstantInt::get(Type::getInt32Ty(*::context), Case, true), Branch); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 677 | } |
| 678 | |
Nicolas Capens | 3d7c35f | 2016-09-28 10:36:57 -0400 | [diff] [blame] | 679 | void Nucleus::createUnreachable() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 680 | { |
Nicolas Capens | 3d7c35f | 2016-09-28 10:36:57 -0400 | [diff] [blame] | 681 | ::builder->CreateUnreachable(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 682 | } |
| 683 | |
Nicolas Capens | e95d534 | 2016-09-30 11:37:28 -0400 | [diff] [blame] | 684 | static Value *createSwizzle4(Value *val, unsigned char select) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 685 | { |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 686 | int swizzle[4] = |
| 687 | { |
| 688 | (select >> 0) & 0x03, |
| 689 | (select >> 2) & 0x03, |
| 690 | (select >> 4) & 0x03, |
| 691 | (select >> 6) & 0x03, |
| 692 | }; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 693 | |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 694 | return Nucleus::createShuffleVector(val, val, swizzle); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 695 | } |
| 696 | |
Nicolas Capens | e95d534 | 2016-09-30 11:37:28 -0400 | [diff] [blame] | 697 | static Value *createMask4(Value *lhs, Value *rhs, unsigned char select) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 698 | { |
| 699 | bool mask[4] = {false, false, false, false}; |
| 700 | |
| 701 | mask[(select >> 0) & 0x03] = true; |
| 702 | mask[(select >> 2) & 0x03] = true; |
| 703 | mask[(select >> 4) & 0x03] = true; |
| 704 | mask[(select >> 6) & 0x03] = true; |
| 705 | |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 706 | int swizzle[4] = |
| 707 | { |
| 708 | mask[0] ? 4 : 0, |
| 709 | mask[1] ? 5 : 1, |
| 710 | mask[2] ? 6 : 2, |
| 711 | mask[3] ? 7 : 3, |
| 712 | }; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 713 | |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 714 | Value *shuffle = Nucleus::createShuffleVector(lhs, rhs, swizzle); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 715 | |
| 716 | return shuffle; |
| 717 | } |
| 718 | |
Nicolas Capens | 73dd7a2 | 2016-10-20 13:20:34 -0400 | [diff] [blame] | 719 | Value *Nucleus::createConstantPointer(const void *address, Type *Ty, unsigned int align) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 720 | { |
Nicolas Capens | 0e33ae3 | 2016-09-23 17:37:27 -0400 | [diff] [blame] | 721 | const GlobalValue *existingGlobal = ::executionEngine->getGlobalValueAtAddress(const_cast<void*>(address)); // FIXME: Const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 722 | |
Nicolas Capens | 0e33ae3 | 2016-09-23 17:37:27 -0400 | [diff] [blame] | 723 | if(existingGlobal) |
| 724 | { |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 725 | return (Value*)existingGlobal; |
Nicolas Capens | 0e33ae3 | 2016-09-23 17:37:27 -0400 | [diff] [blame] | 726 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 727 | |
Nicolas Capens | 73dd7a2 | 2016-10-20 13:20:34 -0400 | [diff] [blame] | 728 | llvm::GlobalValue *global = new llvm::GlobalVariable(*::module, Ty, true, llvm::GlobalValue::ExternalLinkage, 0, ""); |
| 729 | global->setAlignment(align); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 730 | |
Nicolas Capens | 0e33ae3 | 2016-09-23 17:37:27 -0400 | [diff] [blame] | 731 | ::executionEngine->addGlobalMapping(global, const_cast<void*>(address)); |
| 732 | |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 733 | return V(global); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 734 | } |
| 735 | |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 736 | Type *Nucleus::getPointerType(Type *ElementType) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 737 | { |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 738 | return T(llvm::PointerType::get(ElementType, 0)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 739 | } |
| 740 | |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 741 | Value *Nucleus::createNullValue(Type *Ty) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 742 | { |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 743 | return V(llvm::Constant::getNullValue(Ty)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 744 | } |
| 745 | |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 746 | Value *Nucleus::createConstantLong(int64_t i) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 747 | { |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 748 | return V(llvm::ConstantInt::get(Type::getInt64Ty(*::context), i, true)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 749 | } |
| 750 | |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 751 | Value *Nucleus::createConstantInt(int i) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 752 | { |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 753 | return V(llvm::ConstantInt::get(Type::getInt32Ty(*::context), i, true)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 754 | } |
| 755 | |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 756 | Value *Nucleus::createConstantInt(unsigned int i) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 757 | { |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 758 | return V(llvm::ConstantInt::get(Type::getInt32Ty(*::context), i, false)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 759 | } |
| 760 | |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 761 | Value *Nucleus::createConstantBool(bool b) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 762 | { |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 763 | return V(llvm::ConstantInt::get(Type::getInt1Ty(*::context), b)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 764 | } |
| 765 | |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 766 | Value *Nucleus::createConstantByte(signed char i) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 767 | { |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 768 | return V(llvm::ConstantInt::get(Type::getInt8Ty(*::context), i, true)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 769 | } |
| 770 | |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 771 | Value *Nucleus::createConstantByte(unsigned char i) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 772 | { |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 773 | return V(llvm::ConstantInt::get(Type::getInt8Ty(*::context), i, false)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 774 | } |
| 775 | |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 776 | Value *Nucleus::createConstantShort(short i) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 777 | { |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 778 | return V(llvm::ConstantInt::get(Type::getInt16Ty(*::context), i, true)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 779 | } |
| 780 | |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 781 | Value *Nucleus::createConstantShort(unsigned short i) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 782 | { |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 783 | return V(llvm::ConstantInt::get(Type::getInt16Ty(*::context), i, false)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 784 | } |
| 785 | |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 786 | Value *Nucleus::createConstantFloat(float x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 787 | { |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 788 | return V(llvm::ConstantFP::get(Float::getType(), x)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 789 | } |
| 790 | |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 791 | Value *Nucleus::createNullPointer(Type *Ty) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 792 | { |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 793 | return V(llvm::ConstantPointerNull::get(llvm::PointerType::get(Ty, 0))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 794 | } |
| 795 | |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 796 | Value *Nucleus::createConstantVector(const int64_t *constants, Type *type) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 797 | { |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 798 | assert(llvm::isa<VectorType>(type)); |
| 799 | const int numConstants = llvm::cast<VectorType>(type)->getNumElements(); |
| 800 | assert(numConstants <= 16); |
| 801 | llvm::Constant *constantVector[16]; |
| 802 | |
| 803 | for(int i = 0; i < numConstants; i++) |
| 804 | { |
| 805 | constantVector[i] = llvm::ConstantInt::get(type->getContainedType(0), constants[i]); |
| 806 | } |
| 807 | |
| 808 | return V(llvm::ConstantVector::get(llvm::ArrayRef<llvm::Constant*>(constantVector, numConstants))); |
| 809 | } |
| 810 | |
| 811 | Value *Nucleus::createConstantVector(const double *constants, Type *type) |
| 812 | { |
| 813 | assert(llvm::isa<VectorType>(type)); |
| 814 | const int numConstants = llvm::cast<VectorType>(type)->getNumElements(); |
| 815 | assert(numConstants <= 8); |
| 816 | llvm::Constant *constantVector[8]; |
| 817 | |
| 818 | for(int i = 0; i < numConstants; i++) |
| 819 | { |
| 820 | constantVector[i] = llvm::ConstantFP::get(type->getContainedType(0), constants[i]); |
| 821 | } |
| 822 | |
| 823 | return V(llvm::ConstantVector::get(llvm::ArrayRef<llvm::Constant*>(constantVector, numConstants))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 824 | } |
| 825 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 826 | Type *Void::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 827 | { |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 828 | return T(llvm::Type::getVoidTy(*::context)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 829 | } |
| 830 | |
Nicolas Capens | 4f738a1 | 2016-09-20 15:46:16 -0400 | [diff] [blame] | 831 | class MMX : public Variable<MMX> |
| 832 | { |
| 833 | public: |
| 834 | static Type *getType(); |
| 835 | }; |
| 836 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 837 | Type *MMX::getType() |
| 838 | { |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 839 | return T(llvm::Type::getX86_MMXTy(*::context)); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 840 | } |
| 841 | |
Nicolas Capens | 81f1830 | 2016-01-14 09:32:35 -0500 | [diff] [blame] | 842 | Bool::Bool(Argument<Bool> argument) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 843 | { |
Nicolas Capens | 81f1830 | 2016-01-14 09:32:35 -0500 | [diff] [blame] | 844 | storeValue(argument.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 845 | } |
| 846 | |
| 847 | Bool::Bool() |
| 848 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 849 | } |
| 850 | |
| 851 | Bool::Bool(bool x) |
| 852 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 853 | storeValue(Nucleus::createConstantBool(x)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 854 | } |
| 855 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 856 | Bool::Bool(RValue<Bool> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 857 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 858 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 859 | } |
| 860 | |
| 861 | Bool::Bool(const Bool &rhs) |
| 862 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 863 | Value *value = rhs.loadValue(); |
| 864 | storeValue(value); |
| 865 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 866 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 867 | Bool::Bool(const Reference<Bool> &rhs) |
| 868 | { |
| 869 | Value *value = rhs.loadValue(); |
| 870 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 871 | } |
| 872 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 873 | RValue<Bool> Bool::operator=(RValue<Bool> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 874 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 875 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 876 | |
| 877 | return rhs; |
| 878 | } |
| 879 | |
| 880 | RValue<Bool> Bool::operator=(const Bool &rhs) const |
| 881 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 882 | Value *value = rhs.loadValue(); |
| 883 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 884 | |
| 885 | return RValue<Bool>(value); |
| 886 | } |
| 887 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 888 | RValue<Bool> Bool::operator=(const Reference<Bool> &rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 889 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 890 | Value *value = rhs.loadValue(); |
| 891 | storeValue(value); |
| 892 | |
| 893 | return RValue<Bool>(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 894 | } |
| 895 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 896 | RValue<Bool> operator!(RValue<Bool> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 897 | { |
| 898 | return RValue<Bool>(Nucleus::createNot(val.value)); |
| 899 | } |
| 900 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 901 | RValue<Bool> operator&&(RValue<Bool> lhs, RValue<Bool> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 902 | { |
| 903 | return RValue<Bool>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 904 | } |
| 905 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 906 | RValue<Bool> operator||(RValue<Bool> lhs, RValue<Bool> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 907 | { |
| 908 | return RValue<Bool>(Nucleus::createOr(lhs.value, rhs.value)); |
| 909 | } |
| 910 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 911 | Type *Bool::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 912 | { |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 913 | return T(llvm::Type::getInt1Ty(*::context)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 914 | } |
| 915 | |
Nicolas Capens | 81f1830 | 2016-01-14 09:32:35 -0500 | [diff] [blame] | 916 | Byte::Byte(Argument<Byte> argument) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 917 | { |
Nicolas Capens | 81f1830 | 2016-01-14 09:32:35 -0500 | [diff] [blame] | 918 | storeValue(argument.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 919 | } |
| 920 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 921 | Byte::Byte(RValue<Int> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 922 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 923 | Value *integer = Nucleus::createTrunc(cast.value, Byte::getType()); |
| 924 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 925 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 926 | } |
| 927 | |
Alexis Hetu | 77dfab4 | 2015-11-23 13:31:22 -0500 | [diff] [blame] | 928 | Byte::Byte(RValue<UInt> cast) |
| 929 | { |
| 930 | Value *integer = Nucleus::createTrunc(cast.value, Byte::getType()); |
| 931 | |
| 932 | storeValue(integer); |
| 933 | } |
| 934 | |
| 935 | Byte::Byte(RValue<UShort> cast) |
| 936 | { |
| 937 | Value *integer = Nucleus::createTrunc(cast.value, Byte::getType()); |
| 938 | |
| 939 | storeValue(integer); |
| 940 | } |
| 941 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 942 | Byte::Byte() |
| 943 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 944 | } |
| 945 | |
| 946 | Byte::Byte(int x) |
| 947 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 948 | storeValue(Nucleus::createConstantByte((unsigned char)x)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 949 | } |
| 950 | |
| 951 | Byte::Byte(unsigned char x) |
| 952 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 953 | storeValue(Nucleus::createConstantByte(x)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 954 | } |
| 955 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 956 | Byte::Byte(RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 957 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 958 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 959 | } |
| 960 | |
| 961 | Byte::Byte(const Byte &rhs) |
| 962 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 963 | Value *value = rhs.loadValue(); |
| 964 | storeValue(value); |
| 965 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 966 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 967 | Byte::Byte(const Reference<Byte> &rhs) |
| 968 | { |
| 969 | Value *value = rhs.loadValue(); |
| 970 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 971 | } |
| 972 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 973 | RValue<Byte> Byte::operator=(RValue<Byte> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 974 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 975 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 976 | |
| 977 | return rhs; |
| 978 | } |
| 979 | |
| 980 | RValue<Byte> Byte::operator=(const Byte &rhs) const |
| 981 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 982 | Value *value = rhs.loadValue(); |
| 983 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 984 | |
| 985 | return RValue<Byte>(value); |
| 986 | } |
| 987 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 988 | RValue<Byte> Byte::operator=(const Reference<Byte> &rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 989 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 990 | Value *value = rhs.loadValue(); |
| 991 | storeValue(value); |
| 992 | |
| 993 | return RValue<Byte>(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 994 | } |
| 995 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 996 | RValue<Byte> operator+(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 997 | { |
| 998 | return RValue<Byte>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 999 | } |
| 1000 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1001 | RValue<Byte> operator-(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1002 | { |
| 1003 | return RValue<Byte>(Nucleus::createSub(lhs.value, rhs.value)); |
| 1004 | } |
| 1005 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1006 | RValue<Byte> operator*(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1007 | { |
| 1008 | return RValue<Byte>(Nucleus::createMul(lhs.value, rhs.value)); |
| 1009 | } |
| 1010 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1011 | RValue<Byte> operator/(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1012 | { |
| 1013 | return RValue<Byte>(Nucleus::createUDiv(lhs.value, rhs.value)); |
| 1014 | } |
| 1015 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1016 | RValue<Byte> operator%(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1017 | { |
| 1018 | return RValue<Byte>(Nucleus::createURem(lhs.value, rhs.value)); |
| 1019 | } |
| 1020 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1021 | RValue<Byte> operator&(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1022 | { |
| 1023 | return RValue<Byte>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 1024 | } |
| 1025 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1026 | RValue<Byte> operator|(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1027 | { |
| 1028 | return RValue<Byte>(Nucleus::createOr(lhs.value, rhs.value)); |
| 1029 | } |
| 1030 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1031 | RValue<Byte> operator^(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1032 | { |
| 1033 | return RValue<Byte>(Nucleus::createXor(lhs.value, rhs.value)); |
| 1034 | } |
| 1035 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1036 | RValue<Byte> operator<<(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1037 | { |
| 1038 | return RValue<Byte>(Nucleus::createShl(lhs.value, rhs.value)); |
| 1039 | } |
| 1040 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1041 | RValue<Byte> operator>>(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1042 | { |
| 1043 | return RValue<Byte>(Nucleus::createLShr(lhs.value, rhs.value)); |
| 1044 | } |
| 1045 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1046 | RValue<Byte> operator+=(const Byte &lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1047 | { |
| 1048 | return lhs = lhs + rhs; |
| 1049 | } |
| 1050 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1051 | RValue<Byte> operator-=(const Byte &lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1052 | { |
| 1053 | return lhs = lhs - rhs; |
| 1054 | } |
| 1055 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1056 | RValue<Byte> operator*=(const Byte &lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1057 | { |
| 1058 | return lhs = lhs * rhs; |
| 1059 | } |
| 1060 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1061 | RValue<Byte> operator/=(const Byte &lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1062 | { |
| 1063 | return lhs = lhs / rhs; |
| 1064 | } |
| 1065 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1066 | RValue<Byte> operator%=(const Byte &lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1067 | { |
| 1068 | return lhs = lhs % rhs; |
| 1069 | } |
| 1070 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1071 | RValue<Byte> operator&=(const Byte &lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1072 | { |
| 1073 | return lhs = lhs & rhs; |
| 1074 | } |
| 1075 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1076 | RValue<Byte> operator|=(const Byte &lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1077 | { |
| 1078 | return lhs = lhs | rhs; |
| 1079 | } |
| 1080 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1081 | RValue<Byte> operator^=(const Byte &lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1082 | { |
| 1083 | return lhs = lhs ^ rhs; |
| 1084 | } |
| 1085 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1086 | RValue<Byte> operator<<=(const Byte &lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1087 | { |
| 1088 | return lhs = lhs << rhs; |
| 1089 | } |
| 1090 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1091 | RValue<Byte> operator>>=(const Byte &lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1092 | { |
| 1093 | return lhs = lhs >> rhs; |
| 1094 | } |
| 1095 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1096 | RValue<Byte> operator+(RValue<Byte> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1097 | { |
| 1098 | return val; |
| 1099 | } |
| 1100 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1101 | RValue<Byte> operator-(RValue<Byte> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1102 | { |
| 1103 | return RValue<Byte>(Nucleus::createNeg(val.value)); |
| 1104 | } |
| 1105 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1106 | RValue<Byte> operator~(RValue<Byte> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1107 | { |
| 1108 | return RValue<Byte>(Nucleus::createNot(val.value)); |
| 1109 | } |
| 1110 | |
| 1111 | RValue<Byte> operator++(const Byte &val, int) // Post-increment |
| 1112 | { |
| 1113 | RValue<Byte> res = val; |
| 1114 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 1115 | Value *inc = Nucleus::createAdd(res.value, V(Nucleus::createConstantByte((unsigned char)1))); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1116 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1117 | |
| 1118 | return res; |
| 1119 | } |
| 1120 | |
| 1121 | const Byte &operator++(const Byte &val) // Pre-increment |
| 1122 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 1123 | Value *inc = Nucleus::createAdd(val.loadValue(), V(Nucleus::createConstantByte((unsigned char)1))); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1124 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1125 | |
| 1126 | return val; |
| 1127 | } |
| 1128 | |
| 1129 | RValue<Byte> operator--(const Byte &val, int) // Post-decrement |
| 1130 | { |
| 1131 | RValue<Byte> res = val; |
| 1132 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 1133 | Value *inc = Nucleus::createSub(res.value, V(Nucleus::createConstantByte((unsigned char)1))); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1134 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1135 | |
| 1136 | return res; |
| 1137 | } |
| 1138 | |
| 1139 | const Byte &operator--(const Byte &val) // Pre-decrement |
| 1140 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 1141 | Value *inc = Nucleus::createSub(val.loadValue(), V(Nucleus::createConstantByte((unsigned char)1))); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1142 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1143 | |
| 1144 | return val; |
| 1145 | } |
| 1146 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1147 | RValue<Bool> operator<(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1148 | { |
| 1149 | return RValue<Bool>(Nucleus::createICmpULT(lhs.value, rhs.value)); |
| 1150 | } |
| 1151 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1152 | RValue<Bool> operator<=(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1153 | { |
| 1154 | return RValue<Bool>(Nucleus::createICmpULE(lhs.value, rhs.value)); |
| 1155 | } |
| 1156 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1157 | RValue<Bool> operator>(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1158 | { |
| 1159 | return RValue<Bool>(Nucleus::createICmpUGT(lhs.value, rhs.value)); |
| 1160 | } |
| 1161 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1162 | RValue<Bool> operator>=(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1163 | { |
| 1164 | return RValue<Bool>(Nucleus::createICmpUGE(lhs.value, rhs.value)); |
| 1165 | } |
| 1166 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1167 | RValue<Bool> operator!=(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1168 | { |
| 1169 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value)); |
| 1170 | } |
| 1171 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1172 | RValue<Bool> operator==(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1173 | { |
| 1174 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value)); |
| 1175 | } |
| 1176 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1177 | Type *Byte::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1178 | { |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 1179 | return T(llvm::Type::getInt8Ty(*::context)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1180 | } |
| 1181 | |
Nicolas Capens | 81f1830 | 2016-01-14 09:32:35 -0500 | [diff] [blame] | 1182 | SByte::SByte(Argument<SByte> argument) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1183 | { |
Nicolas Capens | 81f1830 | 2016-01-14 09:32:35 -0500 | [diff] [blame] | 1184 | storeValue(argument.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1185 | } |
| 1186 | |
Alexis Hetu | 77dfab4 | 2015-11-23 13:31:22 -0500 | [diff] [blame] | 1187 | SByte::SByte(RValue<Int> cast) |
| 1188 | { |
| 1189 | Value *integer = Nucleus::createTrunc(cast.value, SByte::getType()); |
| 1190 | |
| 1191 | storeValue(integer); |
| 1192 | } |
| 1193 | |
| 1194 | SByte::SByte(RValue<Short> cast) |
| 1195 | { |
| 1196 | Value *integer = Nucleus::createTrunc(cast.value, SByte::getType()); |
| 1197 | |
| 1198 | storeValue(integer); |
| 1199 | } |
| 1200 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1201 | SByte::SByte() |
| 1202 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1203 | } |
| 1204 | |
| 1205 | SByte::SByte(signed char x) |
| 1206 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1207 | storeValue(Nucleus::createConstantByte(x)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1208 | } |
| 1209 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1210 | SByte::SByte(RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1211 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1212 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1213 | } |
| 1214 | |
| 1215 | SByte::SByte(const SByte &rhs) |
| 1216 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1217 | Value *value = rhs.loadValue(); |
| 1218 | storeValue(value); |
| 1219 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1220 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1221 | SByte::SByte(const Reference<SByte> &rhs) |
| 1222 | { |
| 1223 | Value *value = rhs.loadValue(); |
| 1224 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1225 | } |
| 1226 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1227 | RValue<SByte> SByte::operator=(RValue<SByte> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1228 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1229 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1230 | |
| 1231 | return rhs; |
| 1232 | } |
| 1233 | |
| 1234 | RValue<SByte> SByte::operator=(const SByte &rhs) const |
| 1235 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1236 | Value *value = rhs.loadValue(); |
| 1237 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1238 | |
| 1239 | return RValue<SByte>(value); |
| 1240 | } |
| 1241 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1242 | RValue<SByte> SByte::operator=(const Reference<SByte> &rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1243 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1244 | Value *value = rhs.loadValue(); |
| 1245 | storeValue(value); |
| 1246 | |
| 1247 | return RValue<SByte>(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1248 | } |
| 1249 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1250 | RValue<SByte> operator+(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1251 | { |
| 1252 | return RValue<SByte>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 1253 | } |
| 1254 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1255 | RValue<SByte> operator-(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1256 | { |
| 1257 | return RValue<SByte>(Nucleus::createSub(lhs.value, rhs.value)); |
| 1258 | } |
| 1259 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1260 | RValue<SByte> operator*(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1261 | { |
| 1262 | return RValue<SByte>(Nucleus::createMul(lhs.value, rhs.value)); |
| 1263 | } |
| 1264 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1265 | RValue<SByte> operator/(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1266 | { |
| 1267 | return RValue<SByte>(Nucleus::createSDiv(lhs.value, rhs.value)); |
| 1268 | } |
| 1269 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1270 | RValue<SByte> operator%(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1271 | { |
| 1272 | return RValue<SByte>(Nucleus::createSRem(lhs.value, rhs.value)); |
| 1273 | } |
| 1274 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1275 | RValue<SByte> operator&(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1276 | { |
| 1277 | return RValue<SByte>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 1278 | } |
| 1279 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1280 | RValue<SByte> operator|(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1281 | { |
| 1282 | return RValue<SByte>(Nucleus::createOr(lhs.value, rhs.value)); |
| 1283 | } |
| 1284 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1285 | RValue<SByte> operator^(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1286 | { |
| 1287 | return RValue<SByte>(Nucleus::createXor(lhs.value, rhs.value)); |
| 1288 | } |
| 1289 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1290 | RValue<SByte> operator<<(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1291 | { |
| 1292 | return RValue<SByte>(Nucleus::createShl(lhs.value, rhs.value)); |
| 1293 | } |
| 1294 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1295 | RValue<SByte> operator>>(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1296 | { |
| 1297 | return RValue<SByte>(Nucleus::createAShr(lhs.value, rhs.value)); |
| 1298 | } |
| 1299 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1300 | RValue<SByte> operator+=(const SByte &lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1301 | { |
| 1302 | return lhs = lhs + rhs; |
| 1303 | } |
| 1304 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1305 | RValue<SByte> operator-=(const SByte &lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1306 | { |
| 1307 | return lhs = lhs - rhs; |
| 1308 | } |
| 1309 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1310 | RValue<SByte> operator*=(const SByte &lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1311 | { |
| 1312 | return lhs = lhs * rhs; |
| 1313 | } |
| 1314 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1315 | RValue<SByte> operator/=(const SByte &lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1316 | { |
| 1317 | return lhs = lhs / rhs; |
| 1318 | } |
| 1319 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1320 | RValue<SByte> operator%=(const SByte &lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1321 | { |
| 1322 | return lhs = lhs % rhs; |
| 1323 | } |
| 1324 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1325 | RValue<SByte> operator&=(const SByte &lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1326 | { |
| 1327 | return lhs = lhs & rhs; |
| 1328 | } |
| 1329 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1330 | RValue<SByte> operator|=(const SByte &lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1331 | { |
| 1332 | return lhs = lhs | rhs; |
| 1333 | } |
| 1334 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1335 | RValue<SByte> operator^=(const SByte &lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1336 | { |
| 1337 | return lhs = lhs ^ rhs; |
| 1338 | } |
| 1339 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1340 | RValue<SByte> operator<<=(const SByte &lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1341 | { |
| 1342 | return lhs = lhs << rhs; |
| 1343 | } |
| 1344 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1345 | RValue<SByte> operator>>=(const SByte &lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1346 | { |
| 1347 | return lhs = lhs >> rhs; |
| 1348 | } |
| 1349 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1350 | RValue<SByte> operator+(RValue<SByte> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1351 | { |
| 1352 | return val; |
| 1353 | } |
| 1354 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1355 | RValue<SByte> operator-(RValue<SByte> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1356 | { |
| 1357 | return RValue<SByte>(Nucleus::createNeg(val.value)); |
| 1358 | } |
| 1359 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1360 | RValue<SByte> operator~(RValue<SByte> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1361 | { |
| 1362 | return RValue<SByte>(Nucleus::createNot(val.value)); |
| 1363 | } |
| 1364 | |
| 1365 | RValue<SByte> operator++(const SByte &val, int) // Post-increment |
| 1366 | { |
| 1367 | RValue<SByte> res = val; |
| 1368 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 1369 | Value *inc = Nucleus::createAdd(res.value, V(Nucleus::createConstantByte((signed char)1))); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1370 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1371 | |
| 1372 | return res; |
| 1373 | } |
| 1374 | |
| 1375 | const SByte &operator++(const SByte &val) // Pre-increment |
| 1376 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 1377 | Value *inc = Nucleus::createAdd(val.loadValue(), V(Nucleus::createConstantByte((signed char)1))); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1378 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1379 | |
| 1380 | return val; |
| 1381 | } |
| 1382 | |
| 1383 | RValue<SByte> operator--(const SByte &val, int) // Post-decrement |
| 1384 | { |
| 1385 | RValue<SByte> res = val; |
| 1386 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 1387 | Value *inc = Nucleus::createSub(res.value, V(Nucleus::createConstantByte((signed char)1))); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1388 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1389 | |
| 1390 | return res; |
| 1391 | } |
| 1392 | |
| 1393 | const SByte &operator--(const SByte &val) // Pre-decrement |
| 1394 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 1395 | Value *inc = Nucleus::createSub(val.loadValue(), V(Nucleus::createConstantByte((signed char)1))); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1396 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1397 | |
| 1398 | return val; |
| 1399 | } |
| 1400 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1401 | RValue<Bool> operator<(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1402 | { |
| 1403 | return RValue<Bool>(Nucleus::createICmpSLT(lhs.value, rhs.value)); |
| 1404 | } |
| 1405 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1406 | RValue<Bool> operator<=(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1407 | { |
| 1408 | return RValue<Bool>(Nucleus::createICmpSLE(lhs.value, rhs.value)); |
| 1409 | } |
| 1410 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1411 | RValue<Bool> operator>(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1412 | { |
| 1413 | return RValue<Bool>(Nucleus::createICmpSGT(lhs.value, rhs.value)); |
| 1414 | } |
| 1415 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1416 | RValue<Bool> operator>=(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1417 | { |
| 1418 | return RValue<Bool>(Nucleus::createICmpSGE(lhs.value, rhs.value)); |
| 1419 | } |
| 1420 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1421 | RValue<Bool> operator!=(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1422 | { |
| 1423 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value)); |
| 1424 | } |
| 1425 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1426 | RValue<Bool> operator==(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1427 | { |
| 1428 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value)); |
| 1429 | } |
| 1430 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1431 | Type *SByte::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1432 | { |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 1433 | return T(llvm::Type::getInt8Ty(*::context)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1434 | } |
| 1435 | |
Nicolas Capens | 81f1830 | 2016-01-14 09:32:35 -0500 | [diff] [blame] | 1436 | Short::Short(Argument<Short> argument) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1437 | { |
Nicolas Capens | 81f1830 | 2016-01-14 09:32:35 -0500 | [diff] [blame] | 1438 | storeValue(argument.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1439 | } |
| 1440 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1441 | Short::Short(RValue<Int> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1442 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1443 | Value *integer = Nucleus::createTrunc(cast.value, Short::getType()); |
| 1444 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1445 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1446 | } |
| 1447 | |
| 1448 | Short::Short() |
| 1449 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1450 | } |
| 1451 | |
| 1452 | Short::Short(short x) |
| 1453 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1454 | storeValue(Nucleus::createConstantShort(x)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1455 | } |
| 1456 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1457 | Short::Short(RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1458 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1459 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1460 | } |
| 1461 | |
| 1462 | Short::Short(const Short &rhs) |
| 1463 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1464 | Value *value = rhs.loadValue(); |
| 1465 | storeValue(value); |
| 1466 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1467 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1468 | Short::Short(const Reference<Short> &rhs) |
| 1469 | { |
| 1470 | Value *value = rhs.loadValue(); |
| 1471 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1472 | } |
| 1473 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1474 | RValue<Short> Short::operator=(RValue<Short> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1475 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1476 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1477 | |
| 1478 | return rhs; |
| 1479 | } |
| 1480 | |
| 1481 | RValue<Short> Short::operator=(const Short &rhs) const |
| 1482 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1483 | Value *value = rhs.loadValue(); |
| 1484 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1485 | |
| 1486 | return RValue<Short>(value); |
| 1487 | } |
| 1488 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1489 | RValue<Short> Short::operator=(const Reference<Short> &rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1490 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1491 | Value *value = rhs.loadValue(); |
| 1492 | storeValue(value); |
| 1493 | |
| 1494 | return RValue<Short>(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1495 | } |
| 1496 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1497 | RValue<Short> operator+(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1498 | { |
| 1499 | return RValue<Short>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 1500 | } |
| 1501 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1502 | RValue<Short> operator-(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1503 | { |
| 1504 | return RValue<Short>(Nucleus::createSub(lhs.value, rhs.value)); |
| 1505 | } |
| 1506 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1507 | RValue<Short> operator*(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1508 | { |
| 1509 | return RValue<Short>(Nucleus::createMul(lhs.value, rhs.value)); |
| 1510 | } |
| 1511 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1512 | RValue<Short> operator/(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1513 | { |
| 1514 | return RValue<Short>(Nucleus::createSDiv(lhs.value, rhs.value)); |
| 1515 | } |
| 1516 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1517 | RValue<Short> operator%(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1518 | { |
| 1519 | return RValue<Short>(Nucleus::createSRem(lhs.value, rhs.value)); |
| 1520 | } |
| 1521 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1522 | RValue<Short> operator&(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1523 | { |
| 1524 | return RValue<Short>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 1525 | } |
| 1526 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1527 | RValue<Short> operator|(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1528 | { |
| 1529 | return RValue<Short>(Nucleus::createOr(lhs.value, rhs.value)); |
| 1530 | } |
| 1531 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1532 | RValue<Short> operator^(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1533 | { |
| 1534 | return RValue<Short>(Nucleus::createXor(lhs.value, rhs.value)); |
| 1535 | } |
| 1536 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1537 | RValue<Short> operator<<(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1538 | { |
| 1539 | return RValue<Short>(Nucleus::createShl(lhs.value, rhs.value)); |
| 1540 | } |
| 1541 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1542 | RValue<Short> operator>>(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1543 | { |
| 1544 | return RValue<Short>(Nucleus::createAShr(lhs.value, rhs.value)); |
| 1545 | } |
| 1546 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1547 | RValue<Short> operator+=(const Short &lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1548 | { |
| 1549 | return lhs = lhs + rhs; |
| 1550 | } |
| 1551 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1552 | RValue<Short> operator-=(const Short &lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1553 | { |
| 1554 | return lhs = lhs - rhs; |
| 1555 | } |
| 1556 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1557 | RValue<Short> operator*=(const Short &lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1558 | { |
| 1559 | return lhs = lhs * rhs; |
| 1560 | } |
| 1561 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1562 | RValue<Short> operator/=(const Short &lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1563 | { |
| 1564 | return lhs = lhs / rhs; |
| 1565 | } |
| 1566 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1567 | RValue<Short> operator%=(const Short &lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1568 | { |
| 1569 | return lhs = lhs % rhs; |
| 1570 | } |
| 1571 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1572 | RValue<Short> operator&=(const Short &lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1573 | { |
| 1574 | return lhs = lhs & rhs; |
| 1575 | } |
| 1576 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1577 | RValue<Short> operator|=(const Short &lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1578 | { |
| 1579 | return lhs = lhs | rhs; |
| 1580 | } |
| 1581 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1582 | RValue<Short> operator^=(const Short &lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1583 | { |
| 1584 | return lhs = lhs ^ rhs; |
| 1585 | } |
| 1586 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1587 | RValue<Short> operator<<=(const Short &lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1588 | { |
| 1589 | return lhs = lhs << rhs; |
| 1590 | } |
| 1591 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1592 | RValue<Short> operator>>=(const Short &lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1593 | { |
| 1594 | return lhs = lhs >> rhs; |
| 1595 | } |
| 1596 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1597 | RValue<Short> operator+(RValue<Short> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1598 | { |
| 1599 | return val; |
| 1600 | } |
| 1601 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1602 | RValue<Short> operator-(RValue<Short> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1603 | { |
| 1604 | return RValue<Short>(Nucleus::createNeg(val.value)); |
| 1605 | } |
| 1606 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1607 | RValue<Short> operator~(RValue<Short> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1608 | { |
| 1609 | return RValue<Short>(Nucleus::createNot(val.value)); |
| 1610 | } |
| 1611 | |
| 1612 | RValue<Short> operator++(const Short &val, int) // Post-increment |
| 1613 | { |
| 1614 | RValue<Short> res = val; |
| 1615 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 1616 | Value *inc = Nucleus::createAdd(res.value, V(Nucleus::createConstantShort((short)1))); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1617 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1618 | |
| 1619 | return res; |
| 1620 | } |
| 1621 | |
| 1622 | const Short &operator++(const Short &val) // Pre-increment |
| 1623 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 1624 | Value *inc = Nucleus::createAdd(val.loadValue(), V(Nucleus::createConstantShort((short)1))); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1625 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1626 | |
| 1627 | return val; |
| 1628 | } |
| 1629 | |
| 1630 | RValue<Short> operator--(const Short &val, int) // Post-decrement |
| 1631 | { |
| 1632 | RValue<Short> res = val; |
| 1633 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 1634 | Value *inc = Nucleus::createSub(res.value, V(Nucleus::createConstantShort((short)1))); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1635 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1636 | |
| 1637 | return res; |
| 1638 | } |
| 1639 | |
| 1640 | const Short &operator--(const Short &val) // Pre-decrement |
| 1641 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 1642 | Value *inc = Nucleus::createSub(val.loadValue(), V(Nucleus::createConstantShort((short)1))); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1643 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1644 | |
| 1645 | return val; |
| 1646 | } |
| 1647 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1648 | RValue<Bool> operator<(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1649 | { |
| 1650 | return RValue<Bool>(Nucleus::createICmpSLT(lhs.value, rhs.value)); |
| 1651 | } |
| 1652 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1653 | RValue<Bool> operator<=(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1654 | { |
| 1655 | return RValue<Bool>(Nucleus::createICmpSLE(lhs.value, rhs.value)); |
| 1656 | } |
| 1657 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1658 | RValue<Bool> operator>(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1659 | { |
| 1660 | return RValue<Bool>(Nucleus::createICmpSGT(lhs.value, rhs.value)); |
| 1661 | } |
| 1662 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1663 | RValue<Bool> operator>=(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1664 | { |
| 1665 | return RValue<Bool>(Nucleus::createICmpSGE(lhs.value, rhs.value)); |
| 1666 | } |
| 1667 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1668 | RValue<Bool> operator!=(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1669 | { |
| 1670 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value)); |
| 1671 | } |
| 1672 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1673 | RValue<Bool> operator==(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1674 | { |
| 1675 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value)); |
| 1676 | } |
| 1677 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1678 | Type *Short::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1679 | { |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 1680 | return T(llvm::Type::getInt16Ty(*::context)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1681 | } |
| 1682 | |
Nicolas Capens | 81f1830 | 2016-01-14 09:32:35 -0500 | [diff] [blame] | 1683 | UShort::UShort(Argument<UShort> argument) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1684 | { |
Nicolas Capens | 81f1830 | 2016-01-14 09:32:35 -0500 | [diff] [blame] | 1685 | storeValue(argument.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1686 | } |
| 1687 | |
Alexis Hetu | 77dfab4 | 2015-11-23 13:31:22 -0500 | [diff] [blame] | 1688 | UShort::UShort(RValue<UInt> cast) |
| 1689 | { |
| 1690 | Value *integer = Nucleus::createTrunc(cast.value, UShort::getType()); |
| 1691 | |
| 1692 | storeValue(integer); |
| 1693 | } |
| 1694 | |
Alexis Hetu | 75b650f | 2015-11-19 17:40:15 -0500 | [diff] [blame] | 1695 | UShort::UShort(RValue<Int> cast) |
| 1696 | { |
| 1697 | Value *integer = Nucleus::createTrunc(cast.value, UShort::getType()); |
| 1698 | |
| 1699 | storeValue(integer); |
| 1700 | } |
| 1701 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1702 | UShort::UShort() |
| 1703 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1704 | } |
| 1705 | |
| 1706 | UShort::UShort(unsigned short x) |
| 1707 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1708 | storeValue(Nucleus::createConstantShort(x)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1709 | } |
| 1710 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1711 | UShort::UShort(RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1712 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1713 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1714 | } |
| 1715 | |
| 1716 | UShort::UShort(const UShort &rhs) |
| 1717 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1718 | Value *value = rhs.loadValue(); |
| 1719 | storeValue(value); |
| 1720 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1721 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1722 | UShort::UShort(const Reference<UShort> &rhs) |
| 1723 | { |
| 1724 | Value *value = rhs.loadValue(); |
| 1725 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1726 | } |
| 1727 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1728 | RValue<UShort> UShort::operator=(RValue<UShort> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1729 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1730 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1731 | |
| 1732 | return rhs; |
| 1733 | } |
| 1734 | |
| 1735 | RValue<UShort> UShort::operator=(const UShort &rhs) const |
| 1736 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1737 | Value *value = rhs.loadValue(); |
| 1738 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1739 | |
| 1740 | return RValue<UShort>(value); |
| 1741 | } |
| 1742 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1743 | RValue<UShort> UShort::operator=(const Reference<UShort> &rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1744 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1745 | Value *value = rhs.loadValue(); |
| 1746 | storeValue(value); |
| 1747 | |
| 1748 | return RValue<UShort>(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1749 | } |
| 1750 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1751 | RValue<UShort> operator+(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1752 | { |
| 1753 | return RValue<UShort>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 1754 | } |
| 1755 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1756 | RValue<UShort> operator-(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1757 | { |
| 1758 | return RValue<UShort>(Nucleus::createSub(lhs.value, rhs.value)); |
| 1759 | } |
| 1760 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1761 | RValue<UShort> operator*(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1762 | { |
| 1763 | return RValue<UShort>(Nucleus::createMul(lhs.value, rhs.value)); |
| 1764 | } |
| 1765 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1766 | RValue<UShort> operator/(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1767 | { |
| 1768 | return RValue<UShort>(Nucleus::createUDiv(lhs.value, rhs.value)); |
| 1769 | } |
| 1770 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1771 | RValue<UShort> operator%(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1772 | { |
| 1773 | return RValue<UShort>(Nucleus::createURem(lhs.value, rhs.value)); |
| 1774 | } |
| 1775 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1776 | RValue<UShort> operator&(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1777 | { |
| 1778 | return RValue<UShort>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 1779 | } |
| 1780 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1781 | RValue<UShort> operator|(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1782 | { |
| 1783 | return RValue<UShort>(Nucleus::createOr(lhs.value, rhs.value)); |
| 1784 | } |
| 1785 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1786 | RValue<UShort> operator^(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1787 | { |
| 1788 | return RValue<UShort>(Nucleus::createXor(lhs.value, rhs.value)); |
| 1789 | } |
| 1790 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1791 | RValue<UShort> operator<<(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1792 | { |
| 1793 | return RValue<UShort>(Nucleus::createShl(lhs.value, rhs.value)); |
| 1794 | } |
| 1795 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1796 | RValue<UShort> operator>>(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1797 | { |
| 1798 | return RValue<UShort>(Nucleus::createLShr(lhs.value, rhs.value)); |
| 1799 | } |
| 1800 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1801 | RValue<UShort> operator+=(const UShort &lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1802 | { |
| 1803 | return lhs = lhs + rhs; |
| 1804 | } |
| 1805 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1806 | RValue<UShort> operator-=(const UShort &lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1807 | { |
| 1808 | return lhs = lhs - rhs; |
| 1809 | } |
| 1810 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1811 | RValue<UShort> operator*=(const UShort &lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1812 | { |
| 1813 | return lhs = lhs * rhs; |
| 1814 | } |
| 1815 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1816 | RValue<UShort> operator/=(const UShort &lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1817 | { |
| 1818 | return lhs = lhs / rhs; |
| 1819 | } |
| 1820 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1821 | RValue<UShort> operator%=(const UShort &lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1822 | { |
| 1823 | return lhs = lhs % rhs; |
| 1824 | } |
| 1825 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1826 | RValue<UShort> operator&=(const UShort &lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1827 | { |
| 1828 | return lhs = lhs & rhs; |
| 1829 | } |
| 1830 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1831 | RValue<UShort> operator|=(const UShort &lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1832 | { |
| 1833 | return lhs = lhs | rhs; |
| 1834 | } |
| 1835 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1836 | RValue<UShort> operator^=(const UShort &lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1837 | { |
| 1838 | return lhs = lhs ^ rhs; |
| 1839 | } |
| 1840 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1841 | RValue<UShort> operator<<=(const UShort &lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1842 | { |
| 1843 | return lhs = lhs << rhs; |
| 1844 | } |
| 1845 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1846 | RValue<UShort> operator>>=(const UShort &lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1847 | { |
| 1848 | return lhs = lhs >> rhs; |
| 1849 | } |
| 1850 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1851 | RValue<UShort> operator+(RValue<UShort> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1852 | { |
| 1853 | return val; |
| 1854 | } |
| 1855 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1856 | RValue<UShort> operator-(RValue<UShort> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1857 | { |
| 1858 | return RValue<UShort>(Nucleus::createNeg(val.value)); |
| 1859 | } |
| 1860 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1861 | RValue<UShort> operator~(RValue<UShort> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1862 | { |
| 1863 | return RValue<UShort>(Nucleus::createNot(val.value)); |
| 1864 | } |
| 1865 | |
| 1866 | RValue<UShort> operator++(const UShort &val, int) // Post-increment |
| 1867 | { |
| 1868 | RValue<UShort> res = val; |
| 1869 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 1870 | Value *inc = Nucleus::createAdd(res.value, V(Nucleus::createConstantShort((unsigned short)1))); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1871 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1872 | |
| 1873 | return res; |
| 1874 | } |
| 1875 | |
| 1876 | const UShort &operator++(const UShort &val) // Pre-increment |
| 1877 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 1878 | Value *inc = Nucleus::createAdd(val.loadValue(), V(Nucleus::createConstantShort((unsigned short)1))); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1879 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1880 | |
| 1881 | return val; |
| 1882 | } |
| 1883 | |
| 1884 | RValue<UShort> operator--(const UShort &val, int) // Post-decrement |
| 1885 | { |
| 1886 | RValue<UShort> res = val; |
| 1887 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 1888 | Value *inc = Nucleus::createSub(res.value, V(Nucleus::createConstantShort((unsigned short)1))); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1889 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1890 | |
| 1891 | return res; |
| 1892 | } |
| 1893 | |
| 1894 | const UShort &operator--(const UShort &val) // Pre-decrement |
| 1895 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 1896 | Value *inc = Nucleus::createSub(val.loadValue(), V(Nucleus::createConstantShort((unsigned short)1))); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1897 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1898 | |
| 1899 | return val; |
| 1900 | } |
| 1901 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1902 | RValue<Bool> operator<(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1903 | { |
| 1904 | return RValue<Bool>(Nucleus::createICmpULT(lhs.value, rhs.value)); |
| 1905 | } |
| 1906 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1907 | RValue<Bool> operator<=(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1908 | { |
| 1909 | return RValue<Bool>(Nucleus::createICmpULE(lhs.value, rhs.value)); |
| 1910 | } |
| 1911 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1912 | RValue<Bool> operator>(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1913 | { |
| 1914 | return RValue<Bool>(Nucleus::createICmpUGT(lhs.value, rhs.value)); |
| 1915 | } |
| 1916 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1917 | RValue<Bool> operator>=(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1918 | { |
| 1919 | return RValue<Bool>(Nucleus::createICmpUGE(lhs.value, rhs.value)); |
| 1920 | } |
| 1921 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1922 | RValue<Bool> operator!=(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1923 | { |
| 1924 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value)); |
| 1925 | } |
| 1926 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1927 | RValue<Bool> operator==(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1928 | { |
| 1929 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value)); |
| 1930 | } |
| 1931 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1932 | Type *UShort::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1933 | { |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 1934 | return T(llvm::Type::getInt16Ty(*::context)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1935 | } |
| 1936 | |
Nicolas Capens | 16b5f15 | 2016-10-13 13:39:01 -0400 | [diff] [blame] | 1937 | Byte4::Byte4(RValue<Byte8> cast) |
| 1938 | { |
| 1939 | // xyzw.parent = this; |
| 1940 | |
| 1941 | storeValue(Nucleus::createTrunc(Nucleus::createBitCast(cast.value, Long::getType()), Int::getType())); |
| 1942 | } |
| 1943 | |
| 1944 | Byte4::Byte4(const Reference<Byte4> &rhs) |
| 1945 | { |
| 1946 | // xyzw.parent = this; |
| 1947 | |
| 1948 | Value *value = rhs.loadValue(); |
| 1949 | storeValue(value); |
| 1950 | } |
| 1951 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1952 | Type *Byte4::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1953 | { |
| 1954 | #if 0 |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 1955 | return T(VectorType::get(Byte::getType(), 4)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1956 | #else |
| 1957 | return UInt::getType(); // FIXME: LLVM doesn't manipulate it as one 32-bit block |
| 1958 | #endif |
| 1959 | } |
| 1960 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1961 | Type *SByte4::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1962 | { |
| 1963 | #if 0 |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 1964 | return T(VectorType::get(SByte::getType(), 4)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1965 | #else |
| 1966 | return Int::getType(); // FIXME: LLVM doesn't manipulate it as one 32-bit block |
| 1967 | #endif |
| 1968 | } |
| 1969 | |
| 1970 | Byte8::Byte8() |
| 1971 | { |
| 1972 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1973 | } |
| 1974 | |
Nicolas Capens | 3bbc5e1 | 2016-09-27 10:49:52 -0400 | [diff] [blame] | 1975 | 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) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1976 | { |
| 1977 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1978 | |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 1979 | int64_t constantVector[8] = {x0, x1, x2, x3, x4, x5, x6, x7}; |
| 1980 | Value *vector = V(Nucleus::createConstantVector(constantVector, T(VectorType::get(Byte::getType(), 8)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1981 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1982 | storeValue(Nucleus::createBitCast(vector, getType())); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1983 | } |
| 1984 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1985 | Byte8::Byte8(RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1986 | { |
| 1987 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1988 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1989 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1990 | } |
| 1991 | |
| 1992 | Byte8::Byte8(const Byte8 &rhs) |
| 1993 | { |
| 1994 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1995 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1996 | Value *value = rhs.loadValue(); |
| 1997 | storeValue(value); |
| 1998 | } |
| 1999 | |
| 2000 | Byte8::Byte8(const Reference<Byte8> &rhs) |
| 2001 | { |
| 2002 | // xyzw.parent = this; |
| 2003 | |
| 2004 | Value *value = rhs.loadValue(); |
| 2005 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2006 | } |
| 2007 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2008 | RValue<Byte8> Byte8::operator=(RValue<Byte8> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2009 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2010 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2011 | |
| 2012 | return rhs; |
| 2013 | } |
| 2014 | |
| 2015 | RValue<Byte8> Byte8::operator=(const Byte8 &rhs) const |
| 2016 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2017 | Value *value = rhs.loadValue(); |
| 2018 | storeValue(value); |
| 2019 | |
| 2020 | return RValue<Byte8>(value); |
| 2021 | } |
| 2022 | |
| 2023 | RValue<Byte8> Byte8::operator=(const Reference<Byte8> &rhs) const |
| 2024 | { |
| 2025 | Value *value = rhs.loadValue(); |
| 2026 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2027 | |
| 2028 | return RValue<Byte8>(value); |
| 2029 | } |
| 2030 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2031 | RValue<Byte8> operator+(RValue<Byte8> lhs, RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2032 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2033 | if(CPUID::supportsMMX2()) |
| 2034 | { |
| 2035 | return x86::paddb(lhs, rhs); |
| 2036 | } |
| 2037 | else |
| 2038 | { |
| 2039 | return RValue<Byte8>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 2040 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2041 | } |
| 2042 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2043 | RValue<Byte8> operator-(RValue<Byte8> lhs, RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2044 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2045 | if(CPUID::supportsMMX2()) |
| 2046 | { |
| 2047 | return x86::psubb(lhs, rhs); |
| 2048 | } |
| 2049 | else |
| 2050 | { |
| 2051 | return RValue<Byte8>(Nucleus::createSub(lhs.value, rhs.value)); |
| 2052 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2053 | } |
| 2054 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2055 | // RValue<Byte8> operator*(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 2056 | // { |
| 2057 | // return RValue<Byte8>(Nucleus::createMul(lhs.value, rhs.value)); |
| 2058 | // } |
| 2059 | |
| 2060 | // RValue<Byte8> operator/(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 2061 | // { |
| 2062 | // return RValue<Byte8>(Nucleus::createUDiv(lhs.value, rhs.value)); |
| 2063 | // } |
| 2064 | |
| 2065 | // RValue<Byte8> operator%(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 2066 | // { |
| 2067 | // return RValue<Byte8>(Nucleus::createURem(lhs.value, rhs.value)); |
| 2068 | // } |
| 2069 | |
| 2070 | RValue<Byte8> operator&(RValue<Byte8> lhs, RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2071 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2072 | if(CPUID::supportsMMX2()) |
| 2073 | { |
| 2074 | return As<Byte8>(x86::pand(As<Short4>(lhs), As<Short4>(rhs))); |
| 2075 | } |
| 2076 | else |
| 2077 | { |
| 2078 | return RValue<Byte8>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 2079 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2080 | } |
| 2081 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2082 | RValue<Byte8> operator|(RValue<Byte8> lhs, RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2083 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2084 | if(CPUID::supportsMMX2()) |
| 2085 | { |
| 2086 | return As<Byte8>(x86::por(As<Short4>(lhs), As<Short4>(rhs))); |
| 2087 | } |
| 2088 | else |
| 2089 | { |
| 2090 | return RValue<Byte8>(Nucleus::createOr(lhs.value, rhs.value)); |
| 2091 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2092 | } |
| 2093 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2094 | RValue<Byte8> operator^(RValue<Byte8> lhs, RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2095 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2096 | if(CPUID::supportsMMX2()) |
| 2097 | { |
| 2098 | return As<Byte8>(x86::pxor(As<Short4>(lhs), As<Short4>(rhs))); |
| 2099 | } |
| 2100 | else |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2101 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2102 | return RValue<Byte8>(Nucleus::createXor(lhs.value, rhs.value)); |
| 2103 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2104 | } |
| 2105 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2106 | // RValue<Byte8> operator<<(RValue<Byte8> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2107 | // { |
| 2108 | // return RValue<Byte8>(Nucleus::createShl(lhs.value, rhs.value)); |
| 2109 | // } |
| 2110 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2111 | // RValue<Byte8> operator>>(RValue<Byte8> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2112 | // { |
| 2113 | // return RValue<Byte8>(Nucleus::createLShr(lhs.value, rhs.value)); |
| 2114 | // } |
| 2115 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2116 | RValue<Byte8> operator+=(const Byte8 &lhs, RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2117 | { |
| 2118 | return lhs = lhs + rhs; |
| 2119 | } |
| 2120 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2121 | RValue<Byte8> operator-=(const Byte8 &lhs, RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2122 | { |
| 2123 | return lhs = lhs - rhs; |
| 2124 | } |
| 2125 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2126 | // RValue<Byte8> operator*=(const Byte8 &lhs, RValue<Byte8> rhs) |
| 2127 | // { |
| 2128 | // return lhs = lhs * rhs; |
| 2129 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2130 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2131 | // RValue<Byte8> operator/=(const Byte8 &lhs, RValue<Byte8> rhs) |
| 2132 | // { |
| 2133 | // return lhs = lhs / rhs; |
| 2134 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2135 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2136 | // RValue<Byte8> operator%=(const Byte8 &lhs, RValue<Byte8> rhs) |
| 2137 | // { |
| 2138 | // return lhs = lhs % rhs; |
| 2139 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2140 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2141 | RValue<Byte8> operator&=(const Byte8 &lhs, RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2142 | { |
| 2143 | return lhs = lhs & rhs; |
| 2144 | } |
| 2145 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2146 | RValue<Byte8> operator|=(const Byte8 &lhs, RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2147 | { |
| 2148 | return lhs = lhs | rhs; |
| 2149 | } |
| 2150 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2151 | RValue<Byte8> operator^=(const Byte8 &lhs, RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2152 | { |
| 2153 | return lhs = lhs ^ rhs; |
| 2154 | } |
| 2155 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2156 | // RValue<Byte8> operator<<=(const Byte8 &lhs, RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2157 | // { |
| 2158 | // return lhs = lhs << rhs; |
| 2159 | // } |
| 2160 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2161 | // RValue<Byte8> operator>>=(const Byte8 &lhs, RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2162 | // { |
| 2163 | // return lhs = lhs >> rhs; |
| 2164 | // } |
| 2165 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2166 | // RValue<Byte8> operator+(RValue<Byte8> val) |
| 2167 | // { |
| 2168 | // return val; |
| 2169 | // } |
| 2170 | |
| 2171 | // RValue<Byte8> operator-(RValue<Byte8> val) |
| 2172 | // { |
| 2173 | // return RValue<Byte8>(Nucleus::createNeg(val.value)); |
| 2174 | // } |
| 2175 | |
| 2176 | RValue<Byte8> operator~(RValue<Byte8> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2177 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2178 | if(CPUID::supportsMMX2()) |
| 2179 | { |
Nicolas Capens | 16b5f15 | 2016-10-13 13:39:01 -0400 | [diff] [blame] | 2180 | return val ^ Byte8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2181 | } |
| 2182 | else |
| 2183 | { |
| 2184 | return RValue<Byte8>(Nucleus::createNot(val.value)); |
| 2185 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2186 | } |
| 2187 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2188 | RValue<Byte8> AddSat(RValue<Byte8> x, RValue<Byte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2189 | { |
| 2190 | return x86::paddusb(x, y); |
| 2191 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2192 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2193 | RValue<Byte8> SubSat(RValue<Byte8> x, RValue<Byte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2194 | { |
| 2195 | return x86::psubusb(x, y); |
| 2196 | } |
| 2197 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2198 | RValue<Short4> Unpack(RValue<Byte4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2199 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 2200 | Value *int2 = Nucleus::createInsertElement(V(UndefValue::get(VectorType::get(Int::getType(), 2))), x.value, 0); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2201 | Value *byte8 = Nucleus::createBitCast(int2, Byte8::getType()); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2202 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2203 | return UnpackLow(RValue<Byte8>(byte8), RValue<Byte8>(byte8)); |
| 2204 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2205 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2206 | RValue<Short4> UnpackLow(RValue<Byte8> x, RValue<Byte8> y) |
| 2207 | { |
| 2208 | if(CPUID::supportsMMX2()) |
| 2209 | { |
| 2210 | return x86::punpcklbw(x, y); |
| 2211 | } |
| 2212 | else |
| 2213 | { |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 2214 | int shuffle[8] = {0, 8, 1, 9, 2, 10, 3, 11}; |
| 2215 | Value *packed = Nucleus::createShuffleVector(x.value, y.value, shuffle); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2216 | |
| 2217 | return RValue<Short4>(Nucleus::createBitCast(packed, Short4::getType())); |
| 2218 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2219 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2220 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2221 | RValue<Short4> UnpackHigh(RValue<Byte8> x, RValue<Byte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2222 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2223 | if(CPUID::supportsMMX2()) |
| 2224 | { |
| 2225 | return x86::punpckhbw(x, y); |
| 2226 | } |
| 2227 | else |
| 2228 | { |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 2229 | int shuffle[8] = {4, 12, 5, 13, 6, 14, 7, 15}; |
| 2230 | Value *packed = Nucleus::createShuffleVector(x.value, y.value, shuffle); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2231 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2232 | return RValue<Short4>(Nucleus::createBitCast(packed, Short4::getType())); |
| 2233 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2234 | } |
| 2235 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2236 | RValue<Int> SignMask(RValue<Byte8> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2237 | { |
| 2238 | return x86::pmovmskb(x); |
| 2239 | } |
| 2240 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2241 | // RValue<Byte8> CmpGT(RValue<Byte8> x, RValue<Byte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2242 | // { |
| 2243 | // return x86::pcmpgtb(x, y); // FIXME: Signedness |
| 2244 | // } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2245 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2246 | RValue<Byte8> CmpEQ(RValue<Byte8> x, RValue<Byte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2247 | { |
| 2248 | return x86::pcmpeqb(x, y); |
| 2249 | } |
| 2250 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2251 | Type *Byte8::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2252 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2253 | if(CPUID::supportsMMX2()) |
| 2254 | { |
| 2255 | return MMX::getType(); |
| 2256 | } |
| 2257 | else |
| 2258 | { |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 2259 | return T(VectorType::get(Byte::getType(), 8)); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2260 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2261 | } |
| 2262 | |
| 2263 | SByte8::SByte8() |
| 2264 | { |
| 2265 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2266 | } |
| 2267 | |
Nicolas Capens | 3bbc5e1 | 2016-09-27 10:49:52 -0400 | [diff] [blame] | 2268 | 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) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2269 | { |
| 2270 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2271 | |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 2272 | int64_t constantVector[8] = {x0, x1, x2, x3, x4, x5, x6, x7}; |
| 2273 | Value *vector = V(Nucleus::createConstantVector(constantVector, T(VectorType::get(SByte::getType(), 8)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2274 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2275 | storeValue(Nucleus::createBitCast(vector, getType())); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2276 | } |
| 2277 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2278 | SByte8::SByte8(RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2279 | { |
| 2280 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2281 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2282 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2283 | } |
| 2284 | |
| 2285 | SByte8::SByte8(const SByte8 &rhs) |
| 2286 | { |
| 2287 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2288 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2289 | Value *value = rhs.loadValue(); |
| 2290 | storeValue(value); |
| 2291 | } |
| 2292 | |
| 2293 | SByte8::SByte8(const Reference<SByte8> &rhs) |
| 2294 | { |
| 2295 | // xyzw.parent = this; |
| 2296 | |
| 2297 | Value *value = rhs.loadValue(); |
| 2298 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2299 | } |
| 2300 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2301 | RValue<SByte8> SByte8::operator=(RValue<SByte8> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2302 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2303 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2304 | |
| 2305 | return rhs; |
| 2306 | } |
| 2307 | |
| 2308 | RValue<SByte8> SByte8::operator=(const SByte8 &rhs) const |
| 2309 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2310 | Value *value = rhs.loadValue(); |
| 2311 | storeValue(value); |
| 2312 | |
| 2313 | return RValue<SByte8>(value); |
| 2314 | } |
| 2315 | |
| 2316 | RValue<SByte8> SByte8::operator=(const Reference<SByte8> &rhs) const |
| 2317 | { |
| 2318 | Value *value = rhs.loadValue(); |
| 2319 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2320 | |
| 2321 | return RValue<SByte8>(value); |
| 2322 | } |
| 2323 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2324 | RValue<SByte8> operator+(RValue<SByte8> lhs, RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2325 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2326 | if(CPUID::supportsMMX2()) |
| 2327 | { |
| 2328 | return As<SByte8>(x86::paddb(As<Byte8>(lhs), As<Byte8>(rhs))); |
| 2329 | } |
| 2330 | else |
| 2331 | { |
| 2332 | return RValue<SByte8>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 2333 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2334 | } |
| 2335 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2336 | RValue<SByte8> operator-(RValue<SByte8> lhs, RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2337 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2338 | if(CPUID::supportsMMX2()) |
| 2339 | { |
| 2340 | return As<SByte8>(x86::psubb(As<Byte8>(lhs), As<Byte8>(rhs))); |
| 2341 | } |
| 2342 | else |
| 2343 | { |
| 2344 | return RValue<SByte8>(Nucleus::createSub(lhs.value, rhs.value)); |
| 2345 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2346 | } |
| 2347 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2348 | // RValue<SByte8> operator*(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 2349 | // { |
| 2350 | // return RValue<SByte8>(Nucleus::createMul(lhs.value, rhs.value)); |
| 2351 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2352 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2353 | // RValue<SByte8> operator/(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 2354 | // { |
| 2355 | // return RValue<SByte8>(Nucleus::createSDiv(lhs.value, rhs.value)); |
| 2356 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2357 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2358 | // RValue<SByte8> operator%(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 2359 | // { |
| 2360 | // return RValue<SByte8>(Nucleus::createSRem(lhs.value, rhs.value)); |
| 2361 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2362 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2363 | RValue<SByte8> operator&(RValue<SByte8> lhs, RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2364 | { |
| 2365 | return RValue<SByte8>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 2366 | } |
| 2367 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2368 | RValue<SByte8> operator|(RValue<SByte8> lhs, RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2369 | { |
| 2370 | return RValue<SByte8>(Nucleus::createOr(lhs.value, rhs.value)); |
| 2371 | } |
| 2372 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2373 | RValue<SByte8> operator^(RValue<SByte8> lhs, RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2374 | { |
| 2375 | return RValue<SByte8>(Nucleus::createXor(lhs.value, rhs.value)); |
| 2376 | } |
| 2377 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2378 | // RValue<SByte8> operator<<(RValue<SByte8> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2379 | // { |
| 2380 | // return RValue<SByte8>(Nucleus::createShl(lhs.value, rhs.value)); |
| 2381 | // } |
| 2382 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2383 | // RValue<SByte8> operator>>(RValue<SByte8> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2384 | // { |
| 2385 | // return RValue<SByte8>(Nucleus::createAShr(lhs.value, rhs.value)); |
| 2386 | // } |
| 2387 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2388 | RValue<SByte8> operator+=(const SByte8 &lhs, RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2389 | { |
| 2390 | return lhs = lhs + rhs; |
| 2391 | } |
| 2392 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2393 | RValue<SByte8> operator-=(const SByte8 &lhs, RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2394 | { |
| 2395 | return lhs = lhs - rhs; |
| 2396 | } |
| 2397 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2398 | // RValue<SByte8> operator*=(const SByte8 &lhs, RValue<SByte8> rhs) |
| 2399 | // { |
| 2400 | // return lhs = lhs * rhs; |
| 2401 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2402 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2403 | // RValue<SByte8> operator/=(const SByte8 &lhs, RValue<SByte8> rhs) |
| 2404 | // { |
| 2405 | // return lhs = lhs / rhs; |
| 2406 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2407 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2408 | // RValue<SByte8> operator%=(const SByte8 &lhs, RValue<SByte8> rhs) |
| 2409 | // { |
| 2410 | // return lhs = lhs % rhs; |
| 2411 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2412 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2413 | RValue<SByte8> operator&=(const SByte8 &lhs, RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2414 | { |
| 2415 | return lhs = lhs & rhs; |
| 2416 | } |
| 2417 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2418 | RValue<SByte8> operator|=(const SByte8 &lhs, RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2419 | { |
| 2420 | return lhs = lhs | rhs; |
| 2421 | } |
| 2422 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2423 | RValue<SByte8> operator^=(const SByte8 &lhs, RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2424 | { |
| 2425 | return lhs = lhs ^ rhs; |
| 2426 | } |
| 2427 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2428 | // RValue<SByte8> operator<<=(const SByte8 &lhs, RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2429 | // { |
| 2430 | // return lhs = lhs << rhs; |
| 2431 | // } |
| 2432 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2433 | // RValue<SByte8> operator>>=(const SByte8 &lhs, RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2434 | // { |
| 2435 | // return lhs = lhs >> rhs; |
| 2436 | // } |
| 2437 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2438 | // RValue<SByte8> operator+(RValue<SByte8> val) |
| 2439 | // { |
| 2440 | // return val; |
| 2441 | // } |
| 2442 | |
| 2443 | // RValue<SByte8> operator-(RValue<SByte8> val) |
| 2444 | // { |
| 2445 | // return RValue<SByte8>(Nucleus::createNeg(val.value)); |
| 2446 | // } |
| 2447 | |
| 2448 | RValue<SByte8> operator~(RValue<SByte8> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2449 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2450 | if(CPUID::supportsMMX2()) |
| 2451 | { |
Nicolas Capens | 16b5f15 | 2016-10-13 13:39:01 -0400 | [diff] [blame] | 2452 | return val ^ SByte8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2453 | } |
| 2454 | else |
| 2455 | { |
| 2456 | return RValue<SByte8>(Nucleus::createNot(val.value)); |
| 2457 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2458 | } |
| 2459 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2460 | RValue<SByte8> AddSat(RValue<SByte8> x, RValue<SByte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2461 | { |
| 2462 | return x86::paddsb(x, y); |
| 2463 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2464 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2465 | RValue<SByte8> SubSat(RValue<SByte8> x, RValue<SByte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2466 | { |
| 2467 | return x86::psubsb(x, y); |
| 2468 | } |
| 2469 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2470 | RValue<Short4> UnpackLow(RValue<SByte8> x, RValue<SByte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2471 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2472 | if(CPUID::supportsMMX2()) |
| 2473 | { |
| 2474 | return As<Short4>(x86::punpcklbw(As<Byte8>(x), As<Byte8>(y))); |
| 2475 | } |
| 2476 | else |
| 2477 | { |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 2478 | int shuffle[8] = {0, 8, 1, 9, 2, 10, 3, 11}; |
| 2479 | Value *packed = Nucleus::createShuffleVector(x.value, y.value, shuffle); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2480 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2481 | return RValue<Short4>(Nucleus::createBitCast(packed, Short4::getType())); |
| 2482 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2483 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2484 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2485 | RValue<Short4> UnpackHigh(RValue<SByte8> x, RValue<SByte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2486 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2487 | if(CPUID::supportsMMX2()) |
| 2488 | { |
| 2489 | return As<Short4>(x86::punpckhbw(As<Byte8>(x), As<Byte8>(y))); |
| 2490 | } |
| 2491 | else |
| 2492 | { |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 2493 | int shuffle[8] = {4, 12, 5, 13, 6, 14, 7, 15}; |
| 2494 | Value *packed = Nucleus::createShuffleVector(x.value, y.value, shuffle); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2495 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2496 | return RValue<Short4>(Nucleus::createBitCast(packed, Short4::getType())); |
| 2497 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2498 | } |
| 2499 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2500 | RValue<Int> SignMask(RValue<SByte8> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2501 | { |
| 2502 | return x86::pmovmskb(As<Byte8>(x)); |
| 2503 | } |
| 2504 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2505 | RValue<Byte8> CmpGT(RValue<SByte8> x, RValue<SByte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2506 | { |
| 2507 | return x86::pcmpgtb(x, y); |
| 2508 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2509 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2510 | RValue<Byte8> CmpEQ(RValue<SByte8> x, RValue<SByte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2511 | { |
| 2512 | return x86::pcmpeqb(As<Byte8>(x), As<Byte8>(y)); |
| 2513 | } |
| 2514 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2515 | Type *SByte8::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2516 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2517 | if(CPUID::supportsMMX2()) |
| 2518 | { |
| 2519 | return MMX::getType(); |
| 2520 | } |
| 2521 | else |
| 2522 | { |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 2523 | return T(VectorType::get(SByte::getType(), 8)); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2524 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2525 | } |
| 2526 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2527 | Byte16::Byte16(RValue<Byte16> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2528 | { |
| 2529 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2530 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2531 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2532 | } |
| 2533 | |
| 2534 | Byte16::Byte16(const Byte16 &rhs) |
| 2535 | { |
| 2536 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2537 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2538 | Value *value = rhs.loadValue(); |
| 2539 | storeValue(value); |
| 2540 | } |
| 2541 | |
| 2542 | Byte16::Byte16(const Reference<Byte16> &rhs) |
| 2543 | { |
| 2544 | // xyzw.parent = this; |
| 2545 | |
| 2546 | Value *value = rhs.loadValue(); |
| 2547 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2548 | } |
| 2549 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2550 | RValue<Byte16> Byte16::operator=(RValue<Byte16> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2551 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2552 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2553 | |
| 2554 | return rhs; |
| 2555 | } |
| 2556 | |
| 2557 | RValue<Byte16> Byte16::operator=(const Byte16 &rhs) const |
| 2558 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2559 | Value *value = rhs.loadValue(); |
| 2560 | storeValue(value); |
| 2561 | |
| 2562 | return RValue<Byte16>(value); |
| 2563 | } |
| 2564 | |
| 2565 | RValue<Byte16> Byte16::operator=(const Reference<Byte16> &rhs) const |
| 2566 | { |
| 2567 | Value *value = rhs.loadValue(); |
| 2568 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2569 | |
| 2570 | return RValue<Byte16>(value); |
| 2571 | } |
| 2572 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2573 | Type *Byte16::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2574 | { |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 2575 | return T(VectorType::get(Byte::getType(), 16)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2576 | } |
| 2577 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2578 | Type *SByte16::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2579 | { |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 2580 | return T( VectorType::get(SByte::getType(), 16)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2581 | } |
| 2582 | |
Nicolas Capens | 16b5f15 | 2016-10-13 13:39:01 -0400 | [diff] [blame] | 2583 | Short2::Short2(RValue<Short4> cast) |
| 2584 | { |
| 2585 | storeValue(Nucleus::createTrunc(Nucleus::createBitCast(cast.value, Long::getType()), UInt::getType())); |
| 2586 | } |
| 2587 | |
| 2588 | Type *Short2::getType() |
| 2589 | { |
| 2590 | #if 0 |
| 2591 | return T(VectorType::get(Short::getType(), 2)); |
| 2592 | #else |
| 2593 | return UInt::getType(); // FIXME: LLVM doesn't manipulate it as one 32-bit block |
| 2594 | #endif |
| 2595 | } |
| 2596 | |
| 2597 | UShort2::UShort2(RValue<UShort4> cast) |
| 2598 | { |
| 2599 | storeValue(Nucleus::createTrunc(Nucleus::createBitCast(cast.value, Long::getType()), UInt::getType())); |
| 2600 | } |
| 2601 | |
| 2602 | Type *UShort2::getType() |
| 2603 | { |
| 2604 | #if 0 |
| 2605 | return T(VectorType::get(UShort::getType(), 2)); |
| 2606 | #else |
| 2607 | return UInt::getType(); // FIXME: LLVM doesn't manipulate it as one 32-bit block |
| 2608 | #endif |
| 2609 | } |
| 2610 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2611 | Short4::Short4(RValue<Int> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2612 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2613 | Value *extend = Nucleus::createZExt(cast.value, Long::getType()); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2614 | Value *swizzle = Swizzle(RValue<Short4>(extend), 0x00).value; |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2615 | |
| 2616 | storeValue(swizzle); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2617 | } |
| 2618 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2619 | Short4::Short4(RValue<Int4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2620 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2621 | Value *short8 = Nucleus::createBitCast(cast.value, Short8::getType()); |
| 2622 | |
| 2623 | #if 0 // FIXME: Check codegen (pshuflw phshufhw pshufd) |
| 2624 | Constant *pack[8]; |
| 2625 | pack[0] = Nucleus::createConstantInt(0); |
| 2626 | pack[1] = Nucleus::createConstantInt(2); |
| 2627 | pack[2] = Nucleus::createConstantInt(4); |
| 2628 | pack[3] = Nucleus::createConstantInt(6); |
| 2629 | |
| 2630 | Value *short4 = Nucleus::createShuffleVector(short8, short8, Nucleus::createConstantVector(pack, 4)); |
| 2631 | #else |
| 2632 | Value *packed; |
| 2633 | |
| 2634 | // FIXME: Use Swizzle<Short8> |
| 2635 | if(!CPUID::supportsSSSE3()) |
| 2636 | { |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 2637 | int pshuflw[8] = {0, 2, 0, 2, 4, 5, 6, 7}; |
| 2638 | int pshufhw[8] = {0, 1, 2, 3, 4, 6, 4, 6}; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2639 | |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 2640 | Value *shuffle1 = Nucleus::createShuffleVector(short8, short8, pshuflw); |
| 2641 | Value *shuffle2 = Nucleus::createShuffleVector(shuffle1, shuffle1, pshufhw); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2642 | Value *int4 = Nucleus::createBitCast(shuffle2, Int4::getType()); |
Nicolas Capens | e95d534 | 2016-09-30 11:37:28 -0400 | [diff] [blame] | 2643 | packed = createSwizzle4(int4, 0x88); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2644 | } |
| 2645 | else |
| 2646 | { |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 2647 | int pshufb[16] = {0, 1, 4, 5, 8, 9, 12, 13, 0, 1, 4, 5, 8, 9, 12, 13}; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2648 | Value *byte16 = Nucleus::createBitCast(cast.value, Byte16::getType()); |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 2649 | packed = Nucleus::createShuffleVector(byte16, byte16, pshufb); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2650 | } |
| 2651 | |
| 2652 | #if 0 // FIXME: No optimal instruction selection |
Nicolas Capens | 2200878 | 2016-10-20 01:11:47 -0400 | [diff] [blame] | 2653 | Value *qword2 = Nucleus::createBitCast(packed, T(VectorType::get(Long::getType(), 2))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2654 | Value *element = Nucleus::createExtractElement(qword2, 0); |
| 2655 | Value *short4 = Nucleus::createBitCast(element, Short4::getType()); |
| 2656 | #else // FIXME: Requires SSE |
| 2657 | Value *int2 = RValue<Int2>(Int2(RValue<Int4>(packed))).value; |
| 2658 | Value *short4 = Nucleus::createBitCast(int2, Short4::getType()); |
| 2659 | #endif |
| 2660 | #endif |
| 2661 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2662 | storeValue(short4); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2663 | } |
| 2664 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2665 | // Short4::Short4(RValue<Float> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2666 | // { |
| 2667 | // } |
| 2668 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2669 | Short4::Short4(RValue<Float4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2670 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2671 | Int4 v4i32 = Int4(cast); |
| 2672 | v4i32 = As<Int4>(x86::packssdw(v4i32, v4i32)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2673 | |
| 2674 | storeValue(As<Short4>(Int2(v4i32)).value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2675 | } |
| 2676 | |
| 2677 | Short4::Short4() |
| 2678 | { |
| 2679 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2680 | } |
| 2681 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2682 | Short4::Short4(short xyzw) |
| 2683 | { |
| 2684 | // xyzw.parent = this; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2685 | |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 2686 | int64_t constantVector[4] = {xyzw, xyzw, xyzw, xyzw}; |
| 2687 | Value *vector = V(Nucleus::createConstantVector(constantVector, T(VectorType::get(Short::getType(), 4)))); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2688 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2689 | storeValue(Nucleus::createBitCast(vector, getType())); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2690 | } |
| 2691 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2692 | Short4::Short4(short x, short y, short z, short w) |
| 2693 | { |
| 2694 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2695 | |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 2696 | int64_t constantVector[4] = {x, y, z, w}; |
| 2697 | Value *vector = V(Nucleus::createConstantVector(constantVector, T(VectorType::get(Short::getType(), 4)))); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2698 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2699 | storeValue(Nucleus::createBitCast(vector, getType())); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2700 | } |
| 2701 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2702 | Short4::Short4(RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2703 | { |
| 2704 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2705 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2706 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2707 | } |
| 2708 | |
| 2709 | Short4::Short4(const Short4 &rhs) |
| 2710 | { |
| 2711 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2712 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2713 | Value *value = rhs.loadValue(); |
| 2714 | storeValue(value); |
| 2715 | } |
| 2716 | |
| 2717 | Short4::Short4(const Reference<Short4> &rhs) |
| 2718 | { |
| 2719 | // xyzw.parent = this; |
| 2720 | |
| 2721 | Value *value = rhs.loadValue(); |
| 2722 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2723 | } |
| 2724 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2725 | Short4::Short4(RValue<UShort4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2726 | { |
| 2727 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2728 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2729 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2730 | } |
| 2731 | |
| 2732 | Short4::Short4(const UShort4 &rhs) |
| 2733 | { |
| 2734 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2735 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2736 | storeValue(rhs.loadValue()); |
| 2737 | } |
| 2738 | |
| 2739 | Short4::Short4(const Reference<UShort4> &rhs) |
| 2740 | { |
| 2741 | // xyzw.parent = this; |
| 2742 | |
| 2743 | storeValue(rhs.loadValue()); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2744 | } |
| 2745 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2746 | RValue<Short4> Short4::operator=(RValue<Short4> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2747 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2748 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2749 | |
| 2750 | return rhs; |
| 2751 | } |
| 2752 | |
| 2753 | RValue<Short4> Short4::operator=(const Short4 &rhs) const |
| 2754 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2755 | Value *value = rhs.loadValue(); |
| 2756 | storeValue(value); |
| 2757 | |
| 2758 | return RValue<Short4>(value); |
| 2759 | } |
| 2760 | |
| 2761 | RValue<Short4> Short4::operator=(const Reference<Short4> &rhs) const |
| 2762 | { |
| 2763 | Value *value = rhs.loadValue(); |
| 2764 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2765 | |
| 2766 | return RValue<Short4>(value); |
| 2767 | } |
| 2768 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2769 | RValue<Short4> Short4::operator=(RValue<UShort4> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2770 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2771 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2772 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2773 | return RValue<Short4>(rhs); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2774 | } |
| 2775 | |
| 2776 | RValue<Short4> Short4::operator=(const UShort4 &rhs) const |
| 2777 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2778 | Value *value = rhs.loadValue(); |
| 2779 | storeValue(value); |
| 2780 | |
| 2781 | return RValue<Short4>(value); |
| 2782 | } |
| 2783 | |
| 2784 | RValue<Short4> Short4::operator=(const Reference<UShort4> &rhs) const |
| 2785 | { |
| 2786 | Value *value = rhs.loadValue(); |
| 2787 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2788 | |
| 2789 | return RValue<Short4>(value); |
| 2790 | } |
| 2791 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2792 | RValue<Short4> operator+(RValue<Short4> lhs, RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2793 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2794 | if(CPUID::supportsMMX2()) |
| 2795 | { |
| 2796 | return x86::paddw(lhs, rhs); |
| 2797 | } |
| 2798 | else |
| 2799 | { |
| 2800 | return RValue<Short4>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 2801 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2802 | } |
| 2803 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2804 | RValue<Short4> operator-(RValue<Short4> lhs, RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2805 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2806 | if(CPUID::supportsMMX2()) |
| 2807 | { |
| 2808 | return x86::psubw(lhs, rhs); |
| 2809 | } |
| 2810 | else |
| 2811 | { |
| 2812 | return RValue<Short4>(Nucleus::createSub(lhs.value, rhs.value)); |
| 2813 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2814 | } |
| 2815 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2816 | RValue<Short4> operator*(RValue<Short4> lhs, RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2817 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2818 | if(CPUID::supportsMMX2()) |
| 2819 | { |
| 2820 | return x86::pmullw(lhs, rhs); |
| 2821 | } |
| 2822 | else |
| 2823 | { |
| 2824 | return RValue<Short4>(Nucleus::createMul(lhs.value, rhs.value)); |
| 2825 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2826 | } |
| 2827 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2828 | // RValue<Short4> operator/(RValue<Short4> lhs, RValue<Short4> rhs) |
| 2829 | // { |
| 2830 | // return RValue<Short4>(Nucleus::createSDiv(lhs.value, rhs.value)); |
| 2831 | // } |
| 2832 | |
| 2833 | // RValue<Short4> operator%(RValue<Short4> lhs, RValue<Short4> rhs) |
| 2834 | // { |
| 2835 | // return RValue<Short4>(Nucleus::createSRem(lhs.value, rhs.value)); |
| 2836 | // } |
| 2837 | |
| 2838 | RValue<Short4> operator&(RValue<Short4> lhs, RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2839 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2840 | if(CPUID::supportsMMX2()) |
| 2841 | { |
| 2842 | return x86::pand(lhs, rhs); |
| 2843 | } |
| 2844 | else |
| 2845 | { |
| 2846 | return RValue<Short4>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 2847 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2848 | } |
| 2849 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2850 | RValue<Short4> operator|(RValue<Short4> lhs, RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2851 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2852 | if(CPUID::supportsMMX2()) |
| 2853 | { |
| 2854 | return x86::por(lhs, rhs); |
| 2855 | } |
| 2856 | else |
| 2857 | { |
| 2858 | return RValue<Short4>(Nucleus::createOr(lhs.value, rhs.value)); |
| 2859 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2860 | } |
| 2861 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2862 | RValue<Short4> operator^(RValue<Short4> lhs, RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2863 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2864 | if(CPUID::supportsMMX2()) |
| 2865 | { |
| 2866 | return x86::pxor(lhs, rhs); |
| 2867 | } |
| 2868 | else |
| 2869 | { |
| 2870 | return RValue<Short4>(Nucleus::createXor(lhs.value, rhs.value)); |
| 2871 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2872 | } |
| 2873 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2874 | RValue<Short4> operator<<(RValue<Short4> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2875 | { |
| 2876 | // return RValue<Short4>(Nucleus::createShl(lhs.value, rhs.value)); |
| 2877 | |
| 2878 | return x86::psllw(lhs, rhs); |
| 2879 | } |
| 2880 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2881 | RValue<Short4> operator>>(RValue<Short4> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2882 | { |
| 2883 | // return RValue<Short4>(Nucleus::createAShr(lhs.value, rhs.value)); |
| 2884 | |
| 2885 | return x86::psraw(lhs, rhs); |
| 2886 | } |
| 2887 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2888 | RValue<Short4> operator<<(RValue<Short4> lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2889 | { |
| 2890 | // return RValue<Short4>(Nucleus::createShl(lhs.value, rhs.value)); |
| 2891 | |
| 2892 | return x86::psllw(lhs, rhs); |
| 2893 | } |
| 2894 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2895 | RValue<Short4> operator>>(RValue<Short4> lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2896 | { |
| 2897 | // return RValue<Short4>(Nucleus::createAShr(lhs.value, rhs.value)); |
| 2898 | |
| 2899 | return x86::psraw(lhs, rhs); |
| 2900 | } |
| 2901 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2902 | RValue<Short4> operator+=(const Short4 &lhs, RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2903 | { |
| 2904 | return lhs = lhs + rhs; |
| 2905 | } |
| 2906 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2907 | RValue<Short4> operator-=(const Short4 &lhs, RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2908 | { |
| 2909 | return lhs = lhs - rhs; |
| 2910 | } |
| 2911 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2912 | RValue<Short4> operator*=(const Short4 &lhs, RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2913 | { |
| 2914 | return lhs = lhs * rhs; |
| 2915 | } |
| 2916 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2917 | // RValue<Short4> operator/=(const Short4 &lhs, RValue<Short4> rhs) |
| 2918 | // { |
| 2919 | // return lhs = lhs / rhs; |
| 2920 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2921 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2922 | // RValue<Short4> operator%=(const Short4 &lhs, RValue<Short4> rhs) |
| 2923 | // { |
| 2924 | // return lhs = lhs % rhs; |
| 2925 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2926 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2927 | RValue<Short4> operator&=(const Short4 &lhs, RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2928 | { |
| 2929 | return lhs = lhs & rhs; |
| 2930 | } |
| 2931 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2932 | RValue<Short4> operator|=(const Short4 &lhs, RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2933 | { |
| 2934 | return lhs = lhs | rhs; |
| 2935 | } |
| 2936 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2937 | RValue<Short4> operator^=(const Short4 &lhs, RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2938 | { |
| 2939 | return lhs = lhs ^ rhs; |
| 2940 | } |
| 2941 | |
| 2942 | RValue<Short4> operator<<=(const Short4 &lhs, unsigned char rhs) |
| 2943 | { |
| 2944 | return lhs = lhs << rhs; |
| 2945 | } |
| 2946 | |
| 2947 | RValue<Short4> operator>>=(const Short4 &lhs, unsigned char rhs) |
| 2948 | { |
| 2949 | return lhs = lhs >> rhs; |
| 2950 | } |
| 2951 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2952 | RValue<Short4> operator<<=(const Short4 &lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2953 | { |
| 2954 | return lhs = lhs << rhs; |
| 2955 | } |
| 2956 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2957 | RValue<Short4> operator>>=(const Short4 &lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2958 | { |
| 2959 | return lhs = lhs >> rhs; |
| 2960 | } |
| 2961 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2962 | // RValue<Short4> operator+(RValue<Short4> val) |
| 2963 | // { |
| 2964 | // return val; |
| 2965 | // } |
| 2966 | |
| 2967 | RValue<Short4> operator-(RValue<Short4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2968 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2969 | if(CPUID::supportsMMX2()) |
| 2970 | { |
| 2971 | return Short4(0, 0, 0, 0) - val; |
| 2972 | } |
| 2973 | else |
| 2974 | { |
| 2975 | return RValue<Short4>(Nucleus::createNeg(val.value)); |
| 2976 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2977 | } |
| 2978 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2979 | RValue<Short4> operator~(RValue<Short4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2980 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2981 | if(CPUID::supportsMMX2()) |
| 2982 | { |
| 2983 | return val ^ Short4(0xFFFFu, 0xFFFFu, 0xFFFFu, 0xFFFFu); |
| 2984 | } |
| 2985 | else |
| 2986 | { |
| 2987 | return RValue<Short4>(Nucleus::createNot(val.value)); |
| 2988 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2989 | } |
| 2990 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2991 | RValue<Short4> RoundShort4(RValue<Float4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2992 | { |
| 2993 | RValue<Int4> v4i32 = x86::cvtps2dq(cast); |
Nicolas Capens | 698633a | 2015-02-04 00:16:13 -0500 | [diff] [blame] | 2994 | RValue<Short8> v8i16 = x86::packssdw(v4i32, v4i32); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2995 | |
Nicolas Capens | 698633a | 2015-02-04 00:16:13 -0500 | [diff] [blame] | 2996 | return As<Short4>(Int2(As<Int4>(v8i16))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2997 | } |
| 2998 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2999 | RValue<Short4> Max(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3000 | { |
| 3001 | return x86::pmaxsw(x, y); |
| 3002 | } |
| 3003 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3004 | RValue<Short4> Min(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3005 | { |
| 3006 | return x86::pminsw(x, y); |
| 3007 | } |
| 3008 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3009 | RValue<Short4> AddSat(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3010 | { |
| 3011 | return x86::paddsw(x, y); |
| 3012 | } |
| 3013 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3014 | RValue<Short4> SubSat(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3015 | { |
| 3016 | return x86::psubsw(x, y); |
| 3017 | } |
| 3018 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3019 | RValue<Short4> MulHigh(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3020 | { |
| 3021 | return x86::pmulhw(x, y); |
| 3022 | } |
| 3023 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3024 | RValue<Int2> MulAdd(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3025 | { |
| 3026 | return x86::pmaddwd(x, y); |
| 3027 | } |
| 3028 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3029 | RValue<SByte8> Pack(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3030 | { |
| 3031 | return x86::packsswb(x, y); |
| 3032 | } |
| 3033 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3034 | RValue<Int2> UnpackLow(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3035 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3036 | if(CPUID::supportsMMX2()) |
| 3037 | { |
| 3038 | return x86::punpcklwd(x, y); |
| 3039 | } |
| 3040 | else |
| 3041 | { |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 3042 | int shuffle[4] = {0, 4, 1, 5}; |
| 3043 | Value *packed = Nucleus::createShuffleVector(x.value, y.value, shuffle); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3044 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3045 | return RValue<Int2>(Nucleus::createBitCast(packed, Int2::getType())); |
| 3046 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3047 | } |
| 3048 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3049 | RValue<Int2> UnpackHigh(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3050 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3051 | if(CPUID::supportsMMX2()) |
| 3052 | { |
| 3053 | return x86::punpckhwd(x, y); |
| 3054 | } |
| 3055 | else |
| 3056 | { |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 3057 | int shuffle[4] = {2, 6, 3, 7}; |
| 3058 | Value *packed = Nucleus::createShuffleVector(x.value, y.value, shuffle); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3059 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3060 | return RValue<Int2>(Nucleus::createBitCast(packed, Int2::getType())); |
| 3061 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3062 | } |
| 3063 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3064 | RValue<Short4> Swizzle(RValue<Short4> x, unsigned char select) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3065 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3066 | if(CPUID::supportsMMX2()) |
| 3067 | { |
| 3068 | return x86::pshufw(x, select); |
| 3069 | } |
| 3070 | else |
| 3071 | { |
Nicolas Capens | e95d534 | 2016-09-30 11:37:28 -0400 | [diff] [blame] | 3072 | return RValue<Short4>(createSwizzle4(x.value, select)); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3073 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3074 | } |
| 3075 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3076 | RValue<Short4> Insert(RValue<Short4> val, RValue<Short> element, int i) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3077 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3078 | if(CPUID::supportsMMX2()) |
| 3079 | { |
| 3080 | return x86::pinsrw(val, Int(element), i); |
| 3081 | } |
| 3082 | else |
| 3083 | { |
| 3084 | return RValue<Short4>(Nucleus::createInsertElement(val.value, element.value, i)); |
| 3085 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3086 | } |
| 3087 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3088 | RValue<Short> Extract(RValue<Short4> val, int i) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3089 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3090 | if(CPUID::supportsMMX2()) |
| 3091 | { |
| 3092 | return Short(x86::pextrw(val, i)); |
| 3093 | } |
| 3094 | else |
| 3095 | { |
Nicolas Capens | e95d534 | 2016-09-30 11:37:28 -0400 | [diff] [blame] | 3096 | return RValue<Short>(Nucleus::createExtractElement(val.value, Short::getType(), i)); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3097 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3098 | } |
| 3099 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3100 | RValue<Short4> CmpGT(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3101 | { |
| 3102 | return x86::pcmpgtw(x, y); |
| 3103 | } |
| 3104 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3105 | RValue<Short4> CmpEQ(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3106 | { |
| 3107 | return x86::pcmpeqw(x, y); |
| 3108 | } |
| 3109 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3110 | Type *Short4::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3111 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3112 | if(CPUID::supportsMMX2()) |
| 3113 | { |
| 3114 | return MMX::getType(); |
| 3115 | } |
| 3116 | else |
| 3117 | { |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 3118 | return T(VectorType::get(Short::getType(), 4)); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3119 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3120 | } |
| 3121 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3122 | UShort4::UShort4(RValue<Int4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3123 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3124 | *this = Short4(cast); |
| 3125 | } |
| 3126 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3127 | UShort4::UShort4(RValue<Float4> cast, bool saturate) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3128 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3129 | Float4 sat; |
| 3130 | |
| 3131 | if(saturate) |
| 3132 | { |
| 3133 | if(CPUID::supportsSSE4_1()) |
| 3134 | { |
| 3135 | sat = Min(cast, Float4(0xFFFF)); // packusdw takes care of 0x0000 saturation |
| 3136 | } |
| 3137 | else |
| 3138 | { |
| 3139 | sat = Max(Min(cast, Float4(0xFFFF)), Float4(0x0000)); |
| 3140 | } |
| 3141 | } |
| 3142 | else |
| 3143 | { |
| 3144 | sat = cast; |
| 3145 | } |
| 3146 | |
| 3147 | Int4 int4(sat); |
| 3148 | |
| 3149 | if(!saturate || !CPUID::supportsSSE4_1()) |
| 3150 | { |
| 3151 | *this = Short4(Int4(int4)); |
| 3152 | } |
| 3153 | else |
| 3154 | { |
| 3155 | *this = As<Short4>(Int2(As<Int4>(x86::packusdw(As<UInt4>(int4), As<UInt4>(int4))))); |
| 3156 | } |
| 3157 | } |
| 3158 | |
| 3159 | UShort4::UShort4() |
| 3160 | { |
| 3161 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3162 | } |
| 3163 | |
Alexis Hetu | 90c7ad6 | 2016-06-27 11:50:40 -0400 | [diff] [blame] | 3164 | UShort4::UShort4(unsigned short xyzw) |
| 3165 | { |
| 3166 | // xyzw.parent = this; |
| 3167 | |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 3168 | int64_t constantVector[4] = {xyzw, xyzw, xyzw, xyzw}; |
| 3169 | Value *vector = V(Nucleus::createConstantVector(constantVector, T(VectorType::get(UShort::getType(), 4)))); |
Alexis Hetu | 90c7ad6 | 2016-06-27 11:50:40 -0400 | [diff] [blame] | 3170 | |
| 3171 | storeValue(Nucleus::createBitCast(vector, getType())); |
| 3172 | } |
| 3173 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3174 | UShort4::UShort4(unsigned short x, unsigned short y, unsigned short z, unsigned short w) |
| 3175 | { |
| 3176 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3177 | |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 3178 | int64_t constantVector[4] = {x, y, z, w}; |
| 3179 | Value *vector = V(Nucleus::createConstantVector(constantVector, T(VectorType::get(UShort::getType(), 4)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3180 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3181 | storeValue(Nucleus::createBitCast(vector, getType())); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3182 | } |
| 3183 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3184 | UShort4::UShort4(RValue<UShort4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3185 | { |
| 3186 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3187 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3188 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3189 | } |
| 3190 | |
| 3191 | UShort4::UShort4(const UShort4 &rhs) |
| 3192 | { |
| 3193 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3194 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3195 | Value *value = rhs.loadValue(); |
| 3196 | storeValue(value); |
| 3197 | } |
| 3198 | |
| 3199 | UShort4::UShort4(const Reference<UShort4> &rhs) |
| 3200 | { |
| 3201 | // xyzw.parent = this; |
| 3202 | |
| 3203 | Value *value = rhs.loadValue(); |
| 3204 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3205 | } |
| 3206 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3207 | UShort4::UShort4(RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3208 | { |
| 3209 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3210 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3211 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3212 | } |
| 3213 | |
| 3214 | UShort4::UShort4(const Short4 &rhs) |
| 3215 | { |
| 3216 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3217 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3218 | Value *value = rhs.loadValue(); |
| 3219 | storeValue(value); |
| 3220 | } |
| 3221 | |
| 3222 | UShort4::UShort4(const Reference<Short4> &rhs) |
| 3223 | { |
| 3224 | // xyzw.parent = this; |
| 3225 | |
| 3226 | Value *value = rhs.loadValue(); |
| 3227 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3228 | } |
| 3229 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3230 | RValue<UShort4> UShort4::operator=(RValue<UShort4> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3231 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3232 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3233 | |
| 3234 | return rhs; |
| 3235 | } |
| 3236 | |
| 3237 | RValue<UShort4> UShort4::operator=(const UShort4 &rhs) const |
| 3238 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3239 | Value *value = rhs.loadValue(); |
| 3240 | storeValue(value); |
| 3241 | |
| 3242 | return RValue<UShort4>(value); |
| 3243 | } |
| 3244 | |
| 3245 | RValue<UShort4> UShort4::operator=(const Reference<UShort4> &rhs) const |
| 3246 | { |
| 3247 | Value *value = rhs.loadValue(); |
| 3248 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3249 | |
| 3250 | return RValue<UShort4>(value); |
| 3251 | } |
| 3252 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3253 | RValue<UShort4> UShort4::operator=(RValue<Short4> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3254 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3255 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3256 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3257 | return RValue<UShort4>(rhs); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3258 | } |
| 3259 | |
| 3260 | RValue<UShort4> UShort4::operator=(const Short4 &rhs) const |
| 3261 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3262 | Value *value = rhs.loadValue(); |
| 3263 | storeValue(value); |
| 3264 | |
| 3265 | return RValue<UShort4>(value); |
| 3266 | } |
| 3267 | |
| 3268 | RValue<UShort4> UShort4::operator=(const Reference<Short4> &rhs) const |
| 3269 | { |
| 3270 | Value *value = rhs.loadValue(); |
| 3271 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3272 | |
| 3273 | return RValue<UShort4>(value); |
| 3274 | } |
| 3275 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3276 | RValue<UShort4> operator+(RValue<UShort4> lhs, RValue<UShort4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3277 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3278 | if(CPUID::supportsMMX2()) |
| 3279 | { |
| 3280 | return As<UShort4>(x86::paddw(As<Short4>(lhs), As<Short4>(rhs))); |
| 3281 | } |
| 3282 | else |
| 3283 | { |
| 3284 | return RValue<UShort4>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 3285 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3286 | } |
| 3287 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3288 | RValue<UShort4> operator-(RValue<UShort4> lhs, RValue<UShort4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3289 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3290 | if(CPUID::supportsMMX2()) |
| 3291 | { |
| 3292 | return As<UShort4>(x86::psubw(As<Short4>(lhs), As<Short4>(rhs))); |
| 3293 | } |
| 3294 | else |
| 3295 | { |
| 3296 | return RValue<UShort4>(Nucleus::createSub(lhs.value, rhs.value)); |
| 3297 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3298 | } |
| 3299 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3300 | RValue<UShort4> operator*(RValue<UShort4> lhs, RValue<UShort4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3301 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3302 | if(CPUID::supportsMMX2()) |
| 3303 | { |
| 3304 | return As<UShort4>(x86::pmullw(As<Short4>(lhs), As<Short4>(rhs))); |
| 3305 | } |
| 3306 | else |
| 3307 | { |
| 3308 | return RValue<UShort4>(Nucleus::createMul(lhs.value, rhs.value)); |
| 3309 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3310 | } |
| 3311 | |
Nicolas Capens | 16b5f15 | 2016-10-13 13:39:01 -0400 | [diff] [blame] | 3312 | RValue<UShort4> operator&(RValue<UShort4> lhs, RValue<UShort4> rhs) |
| 3313 | { |
| 3314 | if(CPUID::supportsMMX2()) |
| 3315 | { |
| 3316 | return As<UShort4>(x86::pand(As<Short4>(lhs), As<Short4>(rhs))); |
| 3317 | } |
| 3318 | else |
| 3319 | { |
| 3320 | return RValue<UShort4>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 3321 | } |
| 3322 | } |
| 3323 | |
| 3324 | RValue<UShort4> operator|(RValue<UShort4> lhs, RValue<UShort4> rhs) |
| 3325 | { |
| 3326 | if(CPUID::supportsMMX2()) |
| 3327 | { |
| 3328 | return As<UShort4>(x86::por(As<Short4>(lhs), As<Short4>(rhs))); |
| 3329 | } |
| 3330 | else |
| 3331 | { |
| 3332 | return RValue<UShort4>(Nucleus::createOr(lhs.value, rhs.value)); |
| 3333 | } |
| 3334 | } |
| 3335 | |
| 3336 | RValue<UShort4> operator^(RValue<UShort4> lhs, RValue<UShort4> rhs) |
| 3337 | { |
| 3338 | if(CPUID::supportsMMX2()) |
| 3339 | { |
| 3340 | return As<UShort4>(x86::pxor(As<Short4>(lhs), As<Short4>(rhs))); |
| 3341 | } |
| 3342 | else |
| 3343 | { |
| 3344 | return RValue<UShort4>(Nucleus::createXor(lhs.value, rhs.value)); |
| 3345 | } |
| 3346 | } |
| 3347 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3348 | RValue<UShort4> operator<<(RValue<UShort4> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3349 | { |
| 3350 | // return RValue<Short4>(Nucleus::createShl(lhs.value, rhs.value)); |
| 3351 | |
| 3352 | return As<UShort4>(x86::psllw(As<Short4>(lhs), rhs)); |
| 3353 | } |
| 3354 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3355 | RValue<UShort4> operator>>(RValue<UShort4> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3356 | { |
| 3357 | // return RValue<Short4>(Nucleus::createLShr(lhs.value, rhs.value)); |
| 3358 | |
| 3359 | return x86::psrlw(lhs, rhs); |
| 3360 | } |
| 3361 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3362 | RValue<UShort4> operator<<(RValue<UShort4> lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3363 | { |
| 3364 | // return RValue<Short4>(Nucleus::createShl(lhs.value, rhs.value)); |
| 3365 | |
| 3366 | return As<UShort4>(x86::psllw(As<Short4>(lhs), rhs)); |
| 3367 | } |
| 3368 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3369 | RValue<UShort4> operator>>(RValue<UShort4> lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3370 | { |
| 3371 | // return RValue<Short4>(Nucleus::createLShr(lhs.value, rhs.value)); |
| 3372 | |
| 3373 | return x86::psrlw(lhs, rhs); |
| 3374 | } |
| 3375 | |
| 3376 | RValue<UShort4> operator<<=(const UShort4 &lhs, unsigned char rhs) |
| 3377 | { |
| 3378 | return lhs = lhs << rhs; |
| 3379 | } |
| 3380 | |
| 3381 | RValue<UShort4> operator>>=(const UShort4 &lhs, unsigned char rhs) |
| 3382 | { |
| 3383 | return lhs = lhs >> rhs; |
| 3384 | } |
| 3385 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3386 | RValue<UShort4> operator<<=(const UShort4 &lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3387 | { |
| 3388 | return lhs = lhs << rhs; |
| 3389 | } |
| 3390 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3391 | RValue<UShort4> operator>>=(const UShort4 &lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3392 | { |
| 3393 | return lhs = lhs >> rhs; |
| 3394 | } |
| 3395 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3396 | RValue<UShort4> operator~(RValue<UShort4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3397 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3398 | if(CPUID::supportsMMX2()) |
| 3399 | { |
| 3400 | return As<UShort4>(As<Short4>(val) ^ Short4(0xFFFFu, 0xFFFFu, 0xFFFFu, 0xFFFFu)); |
| 3401 | } |
| 3402 | else |
| 3403 | { |
| 3404 | return RValue<UShort4>(Nucleus::createNot(val.value)); |
| 3405 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3406 | } |
| 3407 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3408 | RValue<UShort4> Max(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3409 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3410 | 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)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3411 | } |
| 3412 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3413 | RValue<UShort4> Min(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3414 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3415 | 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)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3416 | } |
| 3417 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3418 | RValue<UShort4> AddSat(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3419 | { |
| 3420 | return x86::paddusw(x, y); |
| 3421 | } |
| 3422 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3423 | RValue<UShort4> SubSat(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3424 | { |
| 3425 | return x86::psubusw(x, y); |
| 3426 | } |
| 3427 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3428 | RValue<UShort4> MulHigh(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3429 | { |
| 3430 | return x86::pmulhuw(x, y); |
| 3431 | } |
| 3432 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3433 | RValue<UShort4> Average(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3434 | { |
| 3435 | return x86::pavgw(x, y); |
| 3436 | } |
| 3437 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3438 | RValue<Byte8> Pack(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3439 | { |
| 3440 | return x86::packuswb(x, y); |
| 3441 | } |
| 3442 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3443 | Type *UShort4::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3444 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3445 | if(CPUID::supportsMMX2()) |
| 3446 | { |
| 3447 | return MMX::getType(); |
| 3448 | } |
| 3449 | else |
| 3450 | { |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 3451 | return T(VectorType::get(UShort::getType(), 4)); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3452 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3453 | } |
| 3454 | |
| 3455 | Short8::Short8(short c0, short c1, short c2, short c3, short c4, short c5, short c6, short c7) |
| 3456 | { |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 3457 | int64_t constantVector[8] = {c0, c1, c2, c3, c4, c5, c6, c7}; |
| 3458 | storeValue(Nucleus::createConstantVector(constantVector, getType())); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3459 | } |
| 3460 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3461 | Short8::Short8(RValue<Short8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3462 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3463 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3464 | } |
| 3465 | |
Nicolas Capens | ef8cd66 | 2016-06-30 15:34:40 -0400 | [diff] [blame] | 3466 | Short8::Short8(const Reference<Short8> &rhs) |
| 3467 | { |
Nicolas Capens | ef8cd66 | 2016-06-30 15:34:40 -0400 | [diff] [blame] | 3468 | Value *value = rhs.loadValue(); |
| 3469 | storeValue(value); |
| 3470 | } |
| 3471 | |
Nicolas Capens | 62abb55 | 2016-01-05 12:03:47 -0500 | [diff] [blame] | 3472 | Short8::Short8(RValue<Short4> lo, RValue<Short4> hi) |
| 3473 | { |
| 3474 | Value *loLong = Nucleus::createBitCast(lo.value, Long::getType()); |
| 3475 | Value *hiLong = Nucleus::createBitCast(hi.value, Long::getType()); |
| 3476 | |
Nicolas Capens | 2200878 | 2016-10-20 01:11:47 -0400 | [diff] [blame] | 3477 | Value *long2 = V(UndefValue::get(VectorType::get(Long::getType(), 2))); |
Nicolas Capens | 62abb55 | 2016-01-05 12:03:47 -0500 | [diff] [blame] | 3478 | long2 = Nucleus::createInsertElement(long2, loLong, 0); |
| 3479 | long2 = Nucleus::createInsertElement(long2, hiLong, 1); |
| 3480 | Value *short8 = Nucleus::createBitCast(long2, Short8::getType()); |
| 3481 | |
| 3482 | storeValue(short8); |
| 3483 | } |
| 3484 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3485 | RValue<Short8> operator+(RValue<Short8> lhs, RValue<Short8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3486 | { |
| 3487 | return RValue<Short8>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 3488 | } |
| 3489 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3490 | RValue<Short8> operator&(RValue<Short8> lhs, RValue<Short8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3491 | { |
| 3492 | return RValue<Short8>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 3493 | } |
| 3494 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3495 | RValue<Short8> operator<<(RValue<Short8> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3496 | { |
| 3497 | return x86::psllw(lhs, rhs); // FIXME: Fallback required |
| 3498 | } |
| 3499 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3500 | RValue<Short8> operator>>(RValue<Short8> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3501 | { |
| 3502 | return x86::psraw(lhs, rhs); // FIXME: Fallback required |
| 3503 | } |
| 3504 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3505 | RValue<Int4> MulAdd(RValue<Short8> x, RValue<Short8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3506 | { |
| 3507 | return x86::pmaddwd(x, y); // FIXME: Fallback required |
| 3508 | } |
| 3509 | |
Alexis Hetu | 0f44807 | 2016-03-18 10:56:08 -0400 | [diff] [blame] | 3510 | RValue<Int4> Abs(RValue<Int4> x) |
| 3511 | { |
| 3512 | if(CPUID::supportsSSSE3()) |
| 3513 | { |
| 3514 | return x86::pabsd(x); |
| 3515 | } |
| 3516 | else |
| 3517 | { |
| 3518 | Int4 mask = (x >> 31); |
| 3519 | return (mask ^ x) - mask; |
| 3520 | } |
| 3521 | } |
| 3522 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3523 | RValue<Short8> MulHigh(RValue<Short8> x, RValue<Short8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3524 | { |
| 3525 | return x86::pmulhw(x, y); // FIXME: Fallback required |
| 3526 | } |
| 3527 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3528 | Type *Short8::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3529 | { |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 3530 | return T(VectorType::get(Short::getType(), 8)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3531 | } |
| 3532 | |
| 3533 | 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) |
| 3534 | { |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 3535 | int64_t constantVector[8] = {c0, c1, c2, c3, c4, c5, c6, c7}; |
| 3536 | storeValue(Nucleus::createConstantVector(constantVector, getType())); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3537 | } |
| 3538 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3539 | UShort8::UShort8(RValue<UShort8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3540 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3541 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3542 | } |
| 3543 | |
Nicolas Capens | ef8cd66 | 2016-06-30 15:34:40 -0400 | [diff] [blame] | 3544 | UShort8::UShort8(const Reference<UShort8> &rhs) |
| 3545 | { |
Nicolas Capens | ef8cd66 | 2016-06-30 15:34:40 -0400 | [diff] [blame] | 3546 | Value *value = rhs.loadValue(); |
| 3547 | storeValue(value); |
| 3548 | } |
| 3549 | |
Nicolas Capens | 62abb55 | 2016-01-05 12:03:47 -0500 | [diff] [blame] | 3550 | UShort8::UShort8(RValue<UShort4> lo, RValue<UShort4> hi) |
| 3551 | { |
| 3552 | Value *loLong = Nucleus::createBitCast(lo.value, Long::getType()); |
| 3553 | Value *hiLong = Nucleus::createBitCast(hi.value, Long::getType()); |
| 3554 | |
Nicolas Capens | 2200878 | 2016-10-20 01:11:47 -0400 | [diff] [blame] | 3555 | Value *long2 = V(UndefValue::get(VectorType::get(Long::getType(), 2))); |
Nicolas Capens | 62abb55 | 2016-01-05 12:03:47 -0500 | [diff] [blame] | 3556 | long2 = Nucleus::createInsertElement(long2, loLong, 0); |
| 3557 | long2 = Nucleus::createInsertElement(long2, hiLong, 1); |
| 3558 | Value *short8 = Nucleus::createBitCast(long2, Short8::getType()); |
| 3559 | |
| 3560 | storeValue(short8); |
| 3561 | } |
| 3562 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3563 | RValue<UShort8> UShort8::operator=(RValue<UShort8> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3564 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3565 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3566 | |
| 3567 | return rhs; |
| 3568 | } |
| 3569 | |
| 3570 | RValue<UShort8> UShort8::operator=(const UShort8 &rhs) const |
| 3571 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3572 | Value *value = rhs.loadValue(); |
| 3573 | storeValue(value); |
| 3574 | |
| 3575 | return RValue<UShort8>(value); |
| 3576 | } |
| 3577 | |
| 3578 | RValue<UShort8> UShort8::operator=(const Reference<UShort8> &rhs) const |
| 3579 | { |
| 3580 | Value *value = rhs.loadValue(); |
| 3581 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3582 | |
| 3583 | return RValue<UShort8>(value); |
| 3584 | } |
| 3585 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3586 | RValue<UShort8> operator&(RValue<UShort8> lhs, RValue<UShort8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3587 | { |
| 3588 | return RValue<UShort8>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 3589 | } |
| 3590 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3591 | RValue<UShort8> operator<<(RValue<UShort8> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3592 | { |
| 3593 | return As<UShort8>(x86::psllw(As<Short8>(lhs), rhs)); // FIXME: Fallback required |
| 3594 | } |
| 3595 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3596 | RValue<UShort8> operator>>(RValue<UShort8> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3597 | { |
| 3598 | return x86::psrlw(lhs, rhs); // FIXME: Fallback required |
| 3599 | } |
| 3600 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3601 | RValue<UShort8> operator+(RValue<UShort8> lhs, RValue<UShort8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3602 | { |
| 3603 | return RValue<UShort8>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 3604 | } |
| 3605 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3606 | RValue<UShort8> operator*(RValue<UShort8> lhs, RValue<UShort8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3607 | { |
| 3608 | return RValue<UShort8>(Nucleus::createMul(lhs.value, rhs.value)); |
| 3609 | } |
| 3610 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3611 | RValue<UShort8> operator+=(const UShort8 &lhs, RValue<UShort8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3612 | { |
| 3613 | return lhs = lhs + rhs; |
| 3614 | } |
| 3615 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3616 | RValue<UShort8> operator~(RValue<UShort8> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3617 | { |
| 3618 | return RValue<UShort8>(Nucleus::createNot(val.value)); |
| 3619 | } |
| 3620 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3621 | RValue<UShort8> Swizzle(RValue<UShort8> x, char select0, char select1, char select2, char select3, char select4, char select5, char select6, char select7) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3622 | { |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 3623 | int pshufb[16] = |
| 3624 | { |
| 3625 | select0 + 0, |
| 3626 | select0 + 1, |
| 3627 | select1 + 0, |
| 3628 | select1 + 1, |
| 3629 | select2 + 0, |
| 3630 | select2 + 1, |
| 3631 | select3 + 0, |
| 3632 | select3 + 1, |
| 3633 | select4 + 0, |
| 3634 | select4 + 1, |
| 3635 | select5 + 0, |
| 3636 | select5 + 1, |
| 3637 | select6 + 0, |
| 3638 | select6 + 1, |
| 3639 | select7 + 0, |
| 3640 | select7 + 1, |
| 3641 | }; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3642 | |
| 3643 | Value *byte16 = Nucleus::createBitCast(x.value, Byte16::getType()); |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 3644 | Value *shuffle = Nucleus::createShuffleVector(byte16, byte16, pshufb); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3645 | Value *short8 = Nucleus::createBitCast(shuffle, UShort8::getType()); |
| 3646 | |
| 3647 | return RValue<UShort8>(short8); |
| 3648 | } |
| 3649 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3650 | RValue<UShort8> MulHigh(RValue<UShort8> x, RValue<UShort8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3651 | { |
| 3652 | return x86::pmulhuw(x, y); // FIXME: Fallback required |
| 3653 | } |
| 3654 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3655 | Type *UShort8::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3656 | { |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 3657 | return T(VectorType::get(UShort::getType(), 8)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3658 | } |
| 3659 | |
Nicolas Capens | 81f1830 | 2016-01-14 09:32:35 -0500 | [diff] [blame] | 3660 | Int::Int(Argument<Int> argument) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3661 | { |
Nicolas Capens | 81f1830 | 2016-01-14 09:32:35 -0500 | [diff] [blame] | 3662 | storeValue(argument.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3663 | } |
| 3664 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3665 | Int::Int(RValue<Byte> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3666 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3667 | Value *integer = Nucleus::createZExt(cast.value, Int::getType()); |
| 3668 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3669 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3670 | } |
| 3671 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3672 | Int::Int(RValue<SByte> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3673 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3674 | Value *integer = Nucleus::createSExt(cast.value, Int::getType()); |
| 3675 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3676 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3677 | } |
| 3678 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3679 | Int::Int(RValue<Short> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3680 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3681 | Value *integer = Nucleus::createSExt(cast.value, Int::getType()); |
| 3682 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3683 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3684 | } |
| 3685 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3686 | Int::Int(RValue<UShort> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3687 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3688 | Value *integer = Nucleus::createZExt(cast.value, Int::getType()); |
| 3689 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3690 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3691 | } |
| 3692 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3693 | Int::Int(RValue<Int2> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3694 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3695 | *this = Extract(cast, 0); |
| 3696 | } |
| 3697 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3698 | Int::Int(RValue<Long> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3699 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3700 | Value *integer = Nucleus::createTrunc(cast.value, Int::getType()); |
| 3701 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3702 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3703 | } |
| 3704 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3705 | Int::Int(RValue<Float> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3706 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3707 | Value *integer = Nucleus::createFPToSI(cast.value, Int::getType()); |
| 3708 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3709 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3710 | } |
| 3711 | |
| 3712 | Int::Int() |
| 3713 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3714 | } |
| 3715 | |
| 3716 | Int::Int(int x) |
| 3717 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3718 | storeValue(Nucleus::createConstantInt(x)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3719 | } |
| 3720 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3721 | Int::Int(RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3722 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3723 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3724 | } |
| 3725 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3726 | Int::Int(RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3727 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3728 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3729 | } |
| 3730 | |
| 3731 | Int::Int(const Int &rhs) |
| 3732 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3733 | Value *value = rhs.loadValue(); |
| 3734 | storeValue(value); |
| 3735 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3736 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3737 | Int::Int(const Reference<Int> &rhs) |
| 3738 | { |
| 3739 | Value *value = rhs.loadValue(); |
| 3740 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3741 | } |
| 3742 | |
| 3743 | Int::Int(const UInt &rhs) |
| 3744 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3745 | Value *value = rhs.loadValue(); |
| 3746 | storeValue(value); |
| 3747 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3748 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3749 | Int::Int(const Reference<UInt> &rhs) |
| 3750 | { |
| 3751 | Value *value = rhs.loadValue(); |
| 3752 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3753 | } |
| 3754 | |
| 3755 | RValue<Int> Int::operator=(int rhs) const |
| 3756 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3757 | return RValue<Int>(storeValue(Nucleus::createConstantInt(rhs))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3758 | } |
| 3759 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3760 | RValue<Int> Int::operator=(RValue<Int> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3761 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3762 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3763 | |
| 3764 | return rhs; |
| 3765 | } |
| 3766 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3767 | RValue<Int> Int::operator=(RValue<UInt> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3768 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3769 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3770 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3771 | return RValue<Int>(rhs); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3772 | } |
| 3773 | |
| 3774 | RValue<Int> Int::operator=(const Int &rhs) const |
| 3775 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3776 | Value *value = rhs.loadValue(); |
| 3777 | storeValue(value); |
| 3778 | |
| 3779 | return RValue<Int>(value); |
| 3780 | } |
| 3781 | |
| 3782 | RValue<Int> Int::operator=(const Reference<Int> &rhs) const |
| 3783 | { |
| 3784 | Value *value = rhs.loadValue(); |
| 3785 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3786 | |
| 3787 | return RValue<Int>(value); |
| 3788 | } |
| 3789 | |
| 3790 | RValue<Int> Int::operator=(const UInt &rhs) const |
| 3791 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3792 | Value *value = rhs.loadValue(); |
| 3793 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3794 | |
| 3795 | return RValue<Int>(value); |
| 3796 | } |
| 3797 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3798 | RValue<Int> Int::operator=(const Reference<UInt> &rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3799 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3800 | Value *value = rhs.loadValue(); |
| 3801 | storeValue(value); |
| 3802 | |
| 3803 | return RValue<Int>(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3804 | } |
| 3805 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3806 | RValue<Int> operator+(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3807 | { |
| 3808 | return RValue<Int>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 3809 | } |
| 3810 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3811 | RValue<Int> operator-(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3812 | { |
| 3813 | return RValue<Int>(Nucleus::createSub(lhs.value, rhs.value)); |
| 3814 | } |
| 3815 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3816 | RValue<Int> operator*(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3817 | { |
| 3818 | return RValue<Int>(Nucleus::createMul(lhs.value, rhs.value)); |
| 3819 | } |
| 3820 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3821 | RValue<Int> operator/(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3822 | { |
| 3823 | return RValue<Int>(Nucleus::createSDiv(lhs.value, rhs.value)); |
| 3824 | } |
| 3825 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3826 | RValue<Int> operator%(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3827 | { |
| 3828 | return RValue<Int>(Nucleus::createSRem(lhs.value, rhs.value)); |
| 3829 | } |
| 3830 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3831 | RValue<Int> operator&(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3832 | { |
| 3833 | return RValue<Int>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 3834 | } |
| 3835 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3836 | RValue<Int> operator|(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3837 | { |
| 3838 | return RValue<Int>(Nucleus::createOr(lhs.value, rhs.value)); |
| 3839 | } |
| 3840 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3841 | RValue<Int> operator^(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3842 | { |
| 3843 | return RValue<Int>(Nucleus::createXor(lhs.value, rhs.value)); |
| 3844 | } |
| 3845 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3846 | RValue<Int> operator<<(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3847 | { |
| 3848 | return RValue<Int>(Nucleus::createShl(lhs.value, rhs.value)); |
| 3849 | } |
| 3850 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3851 | RValue<Int> operator>>(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3852 | { |
| 3853 | return RValue<Int>(Nucleus::createAShr(lhs.value, rhs.value)); |
| 3854 | } |
| 3855 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3856 | RValue<Int> operator+=(const Int &lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3857 | { |
| 3858 | return lhs = lhs + rhs; |
| 3859 | } |
| 3860 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3861 | RValue<Int> operator-=(const Int &lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3862 | { |
| 3863 | return lhs = lhs - rhs; |
| 3864 | } |
| 3865 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3866 | RValue<Int> operator*=(const Int &lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3867 | { |
| 3868 | return lhs = lhs * rhs; |
| 3869 | } |
| 3870 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3871 | RValue<Int> operator/=(const Int &lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3872 | { |
| 3873 | return lhs = lhs / rhs; |
| 3874 | } |
| 3875 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3876 | RValue<Int> operator%=(const Int &lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3877 | { |
| 3878 | return lhs = lhs % rhs; |
| 3879 | } |
| 3880 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3881 | RValue<Int> operator&=(const Int &lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3882 | { |
| 3883 | return lhs = lhs & rhs; |
| 3884 | } |
| 3885 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3886 | RValue<Int> operator|=(const Int &lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3887 | { |
| 3888 | return lhs = lhs | rhs; |
| 3889 | } |
| 3890 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3891 | RValue<Int> operator^=(const Int &lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3892 | { |
| 3893 | return lhs = lhs ^ rhs; |
| 3894 | } |
| 3895 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3896 | RValue<Int> operator<<=(const Int &lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3897 | { |
| 3898 | return lhs = lhs << rhs; |
| 3899 | } |
| 3900 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3901 | RValue<Int> operator>>=(const Int &lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3902 | { |
| 3903 | return lhs = lhs >> rhs; |
| 3904 | } |
| 3905 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3906 | RValue<Int> operator+(RValue<Int> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3907 | { |
| 3908 | return val; |
| 3909 | } |
| 3910 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3911 | RValue<Int> operator-(RValue<Int> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3912 | { |
| 3913 | return RValue<Int>(Nucleus::createNeg(val.value)); |
| 3914 | } |
| 3915 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3916 | RValue<Int> operator~(RValue<Int> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3917 | { |
| 3918 | return RValue<Int>(Nucleus::createNot(val.value)); |
| 3919 | } |
| 3920 | |
| 3921 | RValue<Int> operator++(const Int &val, int) // Post-increment |
| 3922 | { |
| 3923 | RValue<Int> res = val; |
| 3924 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 3925 | Value *inc = Nucleus::createAdd(res.value, V(Nucleus::createConstantInt(1))); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3926 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3927 | |
| 3928 | return res; |
| 3929 | } |
| 3930 | |
| 3931 | const Int &operator++(const Int &val) // Pre-increment |
| 3932 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 3933 | Value *inc = Nucleus::createAdd(val.loadValue(), V(Nucleus::createConstantInt(1))); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3934 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3935 | |
| 3936 | return val; |
| 3937 | } |
| 3938 | |
| 3939 | RValue<Int> operator--(const Int &val, int) // Post-decrement |
| 3940 | { |
| 3941 | RValue<Int> res = val; |
| 3942 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 3943 | Value *inc = Nucleus::createSub(res.value, V(Nucleus::createConstantInt(1))); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3944 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3945 | |
| 3946 | return res; |
| 3947 | } |
| 3948 | |
| 3949 | const Int &operator--(const Int &val) // Pre-decrement |
| 3950 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 3951 | Value *inc = Nucleus::createSub(val.loadValue(), V(Nucleus::createConstantInt(1))); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3952 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3953 | |
| 3954 | return val; |
| 3955 | } |
| 3956 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3957 | RValue<Bool> operator<(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3958 | { |
| 3959 | return RValue<Bool>(Nucleus::createICmpSLT(lhs.value, rhs.value)); |
| 3960 | } |
| 3961 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3962 | RValue<Bool> operator<=(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3963 | { |
| 3964 | return RValue<Bool>(Nucleus::createICmpSLE(lhs.value, rhs.value)); |
| 3965 | } |
| 3966 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3967 | RValue<Bool> operator>(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3968 | { |
| 3969 | return RValue<Bool>(Nucleus::createICmpSGT(lhs.value, rhs.value)); |
| 3970 | } |
| 3971 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3972 | RValue<Bool> operator>=(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3973 | { |
| 3974 | return RValue<Bool>(Nucleus::createICmpSGE(lhs.value, rhs.value)); |
| 3975 | } |
| 3976 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3977 | RValue<Bool> operator!=(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3978 | { |
| 3979 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value)); |
| 3980 | } |
| 3981 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3982 | RValue<Bool> operator==(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3983 | { |
| 3984 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value)); |
| 3985 | } |
| 3986 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3987 | RValue<Int> Max(RValue<Int> x, RValue<Int> y) |
| 3988 | { |
| 3989 | return IfThenElse(x > y, x, y); |
| 3990 | } |
| 3991 | |
| 3992 | RValue<Int> Min(RValue<Int> x, RValue<Int> y) |
| 3993 | { |
| 3994 | return IfThenElse(x < y, x, y); |
| 3995 | } |
| 3996 | |
| 3997 | RValue<Int> Clamp(RValue<Int> x, RValue<Int> min, RValue<Int> max) |
| 3998 | { |
| 3999 | return Min(Max(x, min), max); |
| 4000 | } |
| 4001 | |
| 4002 | RValue<Int> RoundInt(RValue<Float> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4003 | { |
| 4004 | return x86::cvtss2si(cast); |
| 4005 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4006 | // return IfThenElse(val > 0.0f, Int(val + 0.5f), Int(val - 0.5f)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4007 | } |
| 4008 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4009 | Type *Int::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4010 | { |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 4011 | return T(llvm::Type::getInt32Ty(*::context)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4012 | } |
| 4013 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4014 | Long::Long(RValue<Int> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4015 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4016 | Value *integer = Nucleus::createSExt(cast.value, Long::getType()); |
| 4017 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4018 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4019 | } |
| 4020 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4021 | Long::Long(RValue<UInt> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4022 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4023 | Value *integer = Nucleus::createZExt(cast.value, Long::getType()); |
| 4024 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4025 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4026 | } |
| 4027 | |
| 4028 | Long::Long() |
| 4029 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4030 | } |
| 4031 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4032 | Long::Long(RValue<Long> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4033 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4034 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4035 | } |
| 4036 | |
| 4037 | RValue<Long> Long::operator=(int64_t rhs) const |
| 4038 | { |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 4039 | return RValue<Long>(storeValue(Nucleus::createConstantLong(rhs))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4040 | } |
| 4041 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4042 | RValue<Long> Long::operator=(RValue<Long> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4043 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4044 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4045 | |
| 4046 | return rhs; |
| 4047 | } |
| 4048 | |
| 4049 | RValue<Long> Long::operator=(const Long &rhs) const |
| 4050 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4051 | Value *value = rhs.loadValue(); |
| 4052 | storeValue(value); |
| 4053 | |
| 4054 | return RValue<Long>(value); |
| 4055 | } |
| 4056 | |
| 4057 | RValue<Long> Long::operator=(const Reference<Long> &rhs) const |
| 4058 | { |
| 4059 | Value *value = rhs.loadValue(); |
| 4060 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4061 | |
| 4062 | return RValue<Long>(value); |
| 4063 | } |
| 4064 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4065 | RValue<Long> operator+(RValue<Long> lhs, RValue<Long> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4066 | { |
| 4067 | return RValue<Long>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 4068 | } |
| 4069 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4070 | RValue<Long> operator-(RValue<Long> lhs, RValue<Long> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4071 | { |
| 4072 | return RValue<Long>(Nucleus::createSub(lhs.value, rhs.value)); |
| 4073 | } |
| 4074 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4075 | RValue<Long> operator+=(const Long &lhs, RValue<Long> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4076 | { |
| 4077 | return lhs = lhs + rhs; |
| 4078 | } |
| 4079 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4080 | RValue<Long> operator-=(const Long &lhs, RValue<Long> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4081 | { |
| 4082 | return lhs = lhs - rhs; |
| 4083 | } |
| 4084 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4085 | RValue<Long> AddAtomic(RValue<Pointer<Long> > x, RValue<Long> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4086 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4087 | return RValue<Long>(Nucleus::createAtomicAdd(x.value, y.value)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4088 | } |
| 4089 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4090 | Type *Long::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4091 | { |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 4092 | return T(llvm::Type::getInt64Ty(*::context)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4093 | } |
| 4094 | |
Nicolas Capens | 50c9636 | 2016-01-04 23:03:59 -0500 | [diff] [blame] | 4095 | Long1::Long1(const RValue<UInt> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4096 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 4097 | Value *undefCast = Nucleus::createInsertElement(V(UndefValue::get(VectorType::get(Int::getType(), 2))), cast.value, 0); |
| 4098 | Value *zeroCast = Nucleus::createInsertElement(undefCast, V(Nucleus::createConstantInt(0)), 1); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4099 | |
Nicolas Capens | 50c9636 | 2016-01-04 23:03:59 -0500 | [diff] [blame] | 4100 | storeValue(Nucleus::createBitCast(zeroCast, Long1::getType())); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4101 | } |
| 4102 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4103 | Long1::Long1(RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4104 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4105 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4106 | } |
| 4107 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4108 | Type *Long1::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4109 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4110 | if(CPUID::supportsMMX2()) |
| 4111 | { |
| 4112 | return MMX::getType(); |
| 4113 | } |
| 4114 | else |
| 4115 | { |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 4116 | return T(VectorType::get(Long::getType(), 1)); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4117 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4118 | } |
| 4119 | |
Nicolas Capens | 81f1830 | 2016-01-14 09:32:35 -0500 | [diff] [blame] | 4120 | UInt::UInt(Argument<UInt> argument) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4121 | { |
Nicolas Capens | 81f1830 | 2016-01-14 09:32:35 -0500 | [diff] [blame] | 4122 | storeValue(argument.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4123 | } |
| 4124 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4125 | UInt::UInt(RValue<UShort> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4126 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4127 | Value *integer = Nucleus::createZExt(cast.value, UInt::getType()); |
| 4128 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4129 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4130 | } |
| 4131 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4132 | UInt::UInt(RValue<Long> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4133 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4134 | Value *integer = Nucleus::createTrunc(cast.value, UInt::getType()); |
| 4135 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4136 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4137 | } |
| 4138 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4139 | UInt::UInt(RValue<Float> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4140 | { |
Alexis Hetu | 764d142 | 2016-09-28 08:44:22 -0400 | [diff] [blame] | 4141 | // Note: createFPToUI is broken, must perform conversion using createFPtoSI |
| 4142 | // Value *integer = Nucleus::createFPToUI(cast.value, UInt::getType()); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4143 | |
Alexis Hetu | 764d142 | 2016-09-28 08:44:22 -0400 | [diff] [blame] | 4144 | // Smallest positive value representable in UInt, but not in Int |
| 4145 | const unsigned int ustart = 0x80000000u; |
| 4146 | const float ustartf = float(ustart); |
| 4147 | |
| 4148 | // If the value is negative, store 0, otherwise store the result of the conversion |
| 4149 | storeValue((~(As<Int>(cast) >> 31) & |
| 4150 | // Check if the value can be represented as an Int |
| 4151 | IfThenElse(cast >= ustartf, |
| 4152 | // If the value is too large, subtract ustart and re-add it after conversion. |
| 4153 | As<Int>(As<UInt>(Int(cast - Float(ustartf))) + UInt(ustart)), |
| 4154 | // Otherwise, just convert normally |
| 4155 | Int(cast))).value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4156 | } |
| 4157 | |
| 4158 | UInt::UInt() |
| 4159 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4160 | } |
| 4161 | |
| 4162 | UInt::UInt(int x) |
| 4163 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4164 | storeValue(Nucleus::createConstantInt(x)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4165 | } |
| 4166 | |
| 4167 | UInt::UInt(unsigned int x) |
| 4168 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4169 | storeValue(Nucleus::createConstantInt(x)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4170 | } |
| 4171 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4172 | UInt::UInt(RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4173 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4174 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4175 | } |
| 4176 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4177 | UInt::UInt(RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4178 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4179 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4180 | } |
| 4181 | |
| 4182 | UInt::UInt(const UInt &rhs) |
| 4183 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4184 | Value *value = rhs.loadValue(); |
| 4185 | storeValue(value); |
| 4186 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4187 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4188 | UInt::UInt(const Reference<UInt> &rhs) |
| 4189 | { |
| 4190 | Value *value = rhs.loadValue(); |
| 4191 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4192 | } |
| 4193 | |
| 4194 | UInt::UInt(const Int &rhs) |
| 4195 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4196 | Value *value = rhs.loadValue(); |
| 4197 | storeValue(value); |
| 4198 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4199 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4200 | UInt::UInt(const Reference<Int> &rhs) |
| 4201 | { |
| 4202 | Value *value = rhs.loadValue(); |
| 4203 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4204 | } |
| 4205 | |
| 4206 | RValue<UInt> UInt::operator=(unsigned int rhs) const |
| 4207 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4208 | return RValue<UInt>(storeValue(Nucleus::createConstantInt(rhs))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4209 | } |
| 4210 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4211 | RValue<UInt> UInt::operator=(RValue<UInt> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4212 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4213 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4214 | |
| 4215 | return rhs; |
| 4216 | } |
| 4217 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4218 | RValue<UInt> UInt::operator=(RValue<Int> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4219 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4220 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4221 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4222 | return RValue<UInt>(rhs); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4223 | } |
| 4224 | |
| 4225 | RValue<UInt> UInt::operator=(const UInt &rhs) const |
| 4226 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4227 | Value *value = rhs.loadValue(); |
| 4228 | storeValue(value); |
| 4229 | |
| 4230 | return RValue<UInt>(value); |
| 4231 | } |
| 4232 | |
| 4233 | RValue<UInt> UInt::operator=(const Reference<UInt> &rhs) const |
| 4234 | { |
| 4235 | Value *value = rhs.loadValue(); |
| 4236 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4237 | |
| 4238 | return RValue<UInt>(value); |
| 4239 | } |
| 4240 | |
| 4241 | RValue<UInt> UInt::operator=(const Int &rhs) const |
| 4242 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4243 | Value *value = rhs.loadValue(); |
| 4244 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4245 | |
| 4246 | return RValue<UInt>(value); |
| 4247 | } |
| 4248 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4249 | RValue<UInt> UInt::operator=(const Reference<Int> &rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4250 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4251 | Value *value = rhs.loadValue(); |
| 4252 | storeValue(value); |
| 4253 | |
| 4254 | return RValue<UInt>(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4255 | } |
| 4256 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4257 | RValue<UInt> operator+(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4258 | { |
| 4259 | return RValue<UInt>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 4260 | } |
| 4261 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4262 | RValue<UInt> operator-(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4263 | { |
| 4264 | return RValue<UInt>(Nucleus::createSub(lhs.value, rhs.value)); |
| 4265 | } |
| 4266 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4267 | RValue<UInt> operator*(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4268 | { |
| 4269 | return RValue<UInt>(Nucleus::createMul(lhs.value, rhs.value)); |
| 4270 | } |
| 4271 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4272 | RValue<UInt> operator/(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4273 | { |
| 4274 | return RValue<UInt>(Nucleus::createUDiv(lhs.value, rhs.value)); |
| 4275 | } |
| 4276 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4277 | RValue<UInt> operator%(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4278 | { |
| 4279 | return RValue<UInt>(Nucleus::createURem(lhs.value, rhs.value)); |
| 4280 | } |
| 4281 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4282 | RValue<UInt> operator&(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4283 | { |
| 4284 | return RValue<UInt>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 4285 | } |
| 4286 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4287 | RValue<UInt> operator|(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4288 | { |
| 4289 | return RValue<UInt>(Nucleus::createOr(lhs.value, rhs.value)); |
| 4290 | } |
| 4291 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4292 | RValue<UInt> operator^(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4293 | { |
| 4294 | return RValue<UInt>(Nucleus::createXor(lhs.value, rhs.value)); |
| 4295 | } |
| 4296 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4297 | RValue<UInt> operator<<(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4298 | { |
| 4299 | return RValue<UInt>(Nucleus::createShl(lhs.value, rhs.value)); |
| 4300 | } |
| 4301 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4302 | RValue<UInt> operator>>(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4303 | { |
| 4304 | return RValue<UInt>(Nucleus::createLShr(lhs.value, rhs.value)); |
| 4305 | } |
| 4306 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4307 | RValue<UInt> operator+=(const UInt &lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4308 | { |
| 4309 | return lhs = lhs + rhs; |
| 4310 | } |
| 4311 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4312 | RValue<UInt> operator-=(const UInt &lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4313 | { |
| 4314 | return lhs = lhs - rhs; |
| 4315 | } |
| 4316 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4317 | RValue<UInt> operator*=(const UInt &lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4318 | { |
| 4319 | return lhs = lhs * rhs; |
| 4320 | } |
| 4321 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4322 | RValue<UInt> operator/=(const UInt &lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4323 | { |
| 4324 | return lhs = lhs / rhs; |
| 4325 | } |
| 4326 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4327 | RValue<UInt> operator%=(const UInt &lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4328 | { |
| 4329 | return lhs = lhs % rhs; |
| 4330 | } |
| 4331 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4332 | RValue<UInt> operator&=(const UInt &lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4333 | { |
| 4334 | return lhs = lhs & rhs; |
| 4335 | } |
| 4336 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4337 | RValue<UInt> operator|=(const UInt &lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4338 | { |
| 4339 | return lhs = lhs | rhs; |
| 4340 | } |
| 4341 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4342 | RValue<UInt> operator^=(const UInt &lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4343 | { |
| 4344 | return lhs = lhs ^ rhs; |
| 4345 | } |
| 4346 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4347 | RValue<UInt> operator<<=(const UInt &lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4348 | { |
| 4349 | return lhs = lhs << rhs; |
| 4350 | } |
| 4351 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4352 | RValue<UInt> operator>>=(const UInt &lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4353 | { |
| 4354 | return lhs = lhs >> rhs; |
| 4355 | } |
| 4356 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4357 | RValue<UInt> operator+(RValue<UInt> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4358 | { |
| 4359 | return val; |
| 4360 | } |
| 4361 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4362 | RValue<UInt> operator-(RValue<UInt> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4363 | { |
| 4364 | return RValue<UInt>(Nucleus::createNeg(val.value)); |
| 4365 | } |
| 4366 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4367 | RValue<UInt> operator~(RValue<UInt> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4368 | { |
| 4369 | return RValue<UInt>(Nucleus::createNot(val.value)); |
| 4370 | } |
| 4371 | |
| 4372 | RValue<UInt> operator++(const UInt &val, int) // Post-increment |
| 4373 | { |
| 4374 | RValue<UInt> res = val; |
| 4375 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 4376 | Value *inc = Nucleus::createAdd(res.value, V(Nucleus::createConstantInt(1))); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4377 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4378 | |
| 4379 | return res; |
| 4380 | } |
| 4381 | |
| 4382 | const UInt &operator++(const UInt &val) // Pre-increment |
| 4383 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 4384 | Value *inc = Nucleus::createAdd(val.loadValue(), V(Nucleus::createConstantInt(1))); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4385 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4386 | |
| 4387 | return val; |
| 4388 | } |
| 4389 | |
| 4390 | RValue<UInt> operator--(const UInt &val, int) // Post-decrement |
| 4391 | { |
| 4392 | RValue<UInt> res = val; |
| 4393 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 4394 | Value *inc = Nucleus::createSub(res.value, V(Nucleus::createConstantInt(1))); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4395 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4396 | |
| 4397 | return res; |
| 4398 | } |
| 4399 | |
| 4400 | const UInt &operator--(const UInt &val) // Pre-decrement |
| 4401 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 4402 | Value *inc = Nucleus::createSub(val.loadValue(), V(Nucleus::createConstantInt(1))); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4403 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4404 | |
| 4405 | return val; |
| 4406 | } |
| 4407 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4408 | RValue<UInt> Max(RValue<UInt> x, RValue<UInt> y) |
| 4409 | { |
| 4410 | return IfThenElse(x > y, x, y); |
| 4411 | } |
| 4412 | |
| 4413 | RValue<UInt> Min(RValue<UInt> x, RValue<UInt> y) |
| 4414 | { |
| 4415 | return IfThenElse(x < y, x, y); |
| 4416 | } |
| 4417 | |
| 4418 | RValue<UInt> Clamp(RValue<UInt> x, RValue<UInt> min, RValue<UInt> max) |
| 4419 | { |
| 4420 | return Min(Max(x, min), max); |
| 4421 | } |
| 4422 | |
| 4423 | RValue<Bool> operator<(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4424 | { |
| 4425 | return RValue<Bool>(Nucleus::createICmpULT(lhs.value, rhs.value)); |
| 4426 | } |
| 4427 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4428 | RValue<Bool> operator<=(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4429 | { |
| 4430 | return RValue<Bool>(Nucleus::createICmpULE(lhs.value, rhs.value)); |
| 4431 | } |
| 4432 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4433 | RValue<Bool> operator>(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4434 | { |
| 4435 | return RValue<Bool>(Nucleus::createICmpUGT(lhs.value, rhs.value)); |
| 4436 | } |
| 4437 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4438 | RValue<Bool> operator>=(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4439 | { |
| 4440 | return RValue<Bool>(Nucleus::createICmpUGE(lhs.value, rhs.value)); |
| 4441 | } |
| 4442 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4443 | RValue<Bool> operator!=(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4444 | { |
| 4445 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value)); |
| 4446 | } |
| 4447 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4448 | RValue<Bool> operator==(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4449 | { |
| 4450 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value)); |
| 4451 | } |
| 4452 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4453 | // RValue<UInt> RoundUInt(RValue<Float> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4454 | // { |
| 4455 | // return x86::cvtss2si(val); // FIXME: Unsigned |
| 4456 | // |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4457 | // // return IfThenElse(val > 0.0f, Int(val + 0.5f), Int(val - 0.5f)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4458 | // } |
| 4459 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4460 | Type *UInt::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4461 | { |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 4462 | return T(llvm::Type::getInt32Ty(*::context)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4463 | } |
| 4464 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4465 | // Int2::Int2(RValue<Int> cast) |
| 4466 | // { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4467 | // Value *extend = Nucleus::createZExt(cast.value, Long::getType()); |
| 4468 | // Value *vector = Nucleus::createBitCast(extend, Int2::getType()); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4469 | // |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 4470 | // int shuffle[2] = {0, 0}; |
| 4471 | // Value *replicate = Nucleus::createShuffleVector(vector, vector, shuffle); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4472 | // |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4473 | // storeValue(replicate); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4474 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4475 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4476 | Int2::Int2(RValue<Int4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4477 | { |
Nicolas Capens | 2200878 | 2016-10-20 01:11:47 -0400 | [diff] [blame] | 4478 | Value *long2 = Nucleus::createBitCast(cast.value, T(VectorType::get(Long::getType(), 2))); |
Nicolas Capens | e95d534 | 2016-09-30 11:37:28 -0400 | [diff] [blame] | 4479 | Value *element = Nucleus::createExtractElement(long2, Long::getType(), 0); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4480 | Value *int2 = Nucleus::createBitCast(element, Int2::getType()); |
| 4481 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4482 | storeValue(int2); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4483 | } |
| 4484 | |
| 4485 | Int2::Int2() |
| 4486 | { |
| 4487 | // xy.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4488 | } |
| 4489 | |
| 4490 | Int2::Int2(int x, int y) |
| 4491 | { |
| 4492 | // xy.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4493 | |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 4494 | int64_t constantVector[2] = {x, y}; |
| 4495 | Value *vector = V(Nucleus::createConstantVector(constantVector, T(VectorType::get(Int::getType(), 2)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4496 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4497 | storeValue(Nucleus::createBitCast(vector, getType())); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4498 | } |
| 4499 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4500 | Int2::Int2(RValue<Int2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4501 | { |
| 4502 | // xy.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4503 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4504 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4505 | } |
| 4506 | |
| 4507 | Int2::Int2(const Int2 &rhs) |
| 4508 | { |
| 4509 | // xy.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4510 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4511 | Value *value = rhs.loadValue(); |
| 4512 | storeValue(value); |
| 4513 | } |
| 4514 | |
| 4515 | Int2::Int2(const Reference<Int2> &rhs) |
| 4516 | { |
| 4517 | // xy.parent = this; |
| 4518 | |
| 4519 | Value *value = rhs.loadValue(); |
| 4520 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4521 | } |
| 4522 | |
Nicolas Capens | 62abb55 | 2016-01-05 12:03:47 -0500 | [diff] [blame] | 4523 | Int2::Int2(RValue<Int> lo, RValue<Int> hi) |
| 4524 | { |
Nicolas Capens | b40a256 | 2016-01-05 00:08:45 -0500 | [diff] [blame] | 4525 | if(CPUID::supportsMMX2()) |
| 4526 | { |
| 4527 | // movd mm0, lo |
| 4528 | // movd mm1, hi |
| 4529 | // punpckldq mm0, mm1 |
| 4530 | storeValue(As<Int2>(UnpackLow(As<Int2>(Long1(RValue<UInt>(lo))), As<Int2>(Long1(RValue<UInt>(hi))))).value); |
| 4531 | } |
| 4532 | else |
| 4533 | { |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 4534 | int shuffle[2] = {0, 1}; |
| 4535 | Value *packed = Nucleus::createShuffleVector(Nucleus::createBitCast(lo.value, T(VectorType::get(Int::getType(), 1))), Nucleus::createBitCast(hi.value, T(VectorType::get(Int::getType(), 1))), shuffle); |
Nicolas Capens | 05b3d66 | 2016-02-25 23:58:33 -0500 | [diff] [blame] | 4536 | |
Nicolas Capens | b40a256 | 2016-01-05 00:08:45 -0500 | [diff] [blame] | 4537 | storeValue(Nucleus::createBitCast(packed, Int2::getType())); |
| 4538 | } |
Nicolas Capens | 62abb55 | 2016-01-05 12:03:47 -0500 | [diff] [blame] | 4539 | } |
| 4540 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4541 | RValue<Int2> Int2::operator=(RValue<Int2> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4542 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4543 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4544 | |
| 4545 | return rhs; |
| 4546 | } |
| 4547 | |
| 4548 | RValue<Int2> Int2::operator=(const Int2 &rhs) const |
| 4549 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4550 | Value *value = rhs.loadValue(); |
| 4551 | storeValue(value); |
| 4552 | |
| 4553 | return RValue<Int2>(value); |
| 4554 | } |
| 4555 | |
| 4556 | RValue<Int2> Int2::operator=(const Reference<Int2> &rhs) const |
| 4557 | { |
| 4558 | Value *value = rhs.loadValue(); |
| 4559 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4560 | |
| 4561 | return RValue<Int2>(value); |
| 4562 | } |
| 4563 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4564 | RValue<Int2> operator+(RValue<Int2> lhs, RValue<Int2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4565 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4566 | if(CPUID::supportsMMX2()) |
| 4567 | { |
| 4568 | return x86::paddd(lhs, rhs); |
| 4569 | } |
| 4570 | else |
| 4571 | { |
| 4572 | return RValue<Int2>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 4573 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4574 | } |
| 4575 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4576 | RValue<Int2> operator-(RValue<Int2> lhs, RValue<Int2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4577 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4578 | if(CPUID::supportsMMX2()) |
| 4579 | { |
| 4580 | return x86::psubd(lhs, rhs); |
| 4581 | } |
| 4582 | else |
| 4583 | { |
| 4584 | return RValue<Int2>(Nucleus::createSub(lhs.value, rhs.value)); |
| 4585 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4586 | } |
| 4587 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4588 | // RValue<Int2> operator*(RValue<Int2> lhs, RValue<Int2> rhs) |
| 4589 | // { |
| 4590 | // return RValue<Int2>(Nucleus::createMul(lhs.value, rhs.value)); |
| 4591 | // } |
| 4592 | |
| 4593 | // RValue<Int2> operator/(RValue<Int2> lhs, RValue<Int2> rhs) |
| 4594 | // { |
| 4595 | // return RValue<Int2>(Nucleus::createSDiv(lhs.value, rhs.value)); |
| 4596 | // } |
| 4597 | |
| 4598 | // RValue<Int2> operator%(RValue<Int2> lhs, RValue<Int2> rhs) |
| 4599 | // { |
| 4600 | // return RValue<Int2>(Nucleus::createSRem(lhs.value, rhs.value)); |
| 4601 | // } |
| 4602 | |
| 4603 | RValue<Int2> operator&(RValue<Int2> lhs, RValue<Int2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4604 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4605 | if(CPUID::supportsMMX2()) |
| 4606 | { |
| 4607 | return As<Int2>(x86::pand(As<Short4>(lhs), As<Short4>(rhs))); |
| 4608 | } |
| 4609 | else |
| 4610 | { |
| 4611 | return RValue<Int2>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 4612 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4613 | } |
| 4614 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4615 | RValue<Int2> operator|(RValue<Int2> lhs, RValue<Int2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4616 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4617 | if(CPUID::supportsMMX2()) |
| 4618 | { |
| 4619 | return As<Int2>(x86::por(As<Short4>(lhs), As<Short4>(rhs))); |
| 4620 | } |
| 4621 | else |
| 4622 | { |
| 4623 | return RValue<Int2>(Nucleus::createOr(lhs.value, rhs.value)); |
| 4624 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4625 | } |
| 4626 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4627 | RValue<Int2> operator^(RValue<Int2> lhs, RValue<Int2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4628 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4629 | if(CPUID::supportsMMX2()) |
| 4630 | { |
| 4631 | return As<Int2>(x86::pxor(As<Short4>(lhs), As<Short4>(rhs))); |
| 4632 | } |
| 4633 | else |
| 4634 | { |
| 4635 | return RValue<Int2>(Nucleus::createXor(lhs.value, rhs.value)); |
| 4636 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4637 | } |
| 4638 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4639 | RValue<Int2> operator<<(RValue<Int2> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4640 | { |
| 4641 | // return RValue<Int2>(Nucleus::createShl(lhs.value, rhs.value)); |
| 4642 | |
| 4643 | return x86::pslld(lhs, rhs); |
| 4644 | } |
| 4645 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4646 | RValue<Int2> operator>>(RValue<Int2> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4647 | { |
| 4648 | // return RValue<Int2>(Nucleus::createAShr(lhs.value, rhs.value)); |
| 4649 | |
| 4650 | return x86::psrad(lhs, rhs); |
| 4651 | } |
| 4652 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4653 | RValue<Int2> operator<<(RValue<Int2> lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4654 | { |
| 4655 | // return RValue<Int2>(Nucleus::createShl(lhs.value, rhs.value)); |
| 4656 | |
| 4657 | return x86::pslld(lhs, rhs); |
| 4658 | } |
| 4659 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4660 | RValue<Int2> operator>>(RValue<Int2> lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4661 | { |
| 4662 | // return RValue<Int2>(Nucleus::createAShr(lhs.value, rhs.value)); |
| 4663 | |
| 4664 | return x86::psrad(lhs, rhs); |
| 4665 | } |
| 4666 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4667 | RValue<Int2> operator+=(const Int2 &lhs, RValue<Int2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4668 | { |
| 4669 | return lhs = lhs + rhs; |
| 4670 | } |
| 4671 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4672 | RValue<Int2> operator-=(const Int2 &lhs, RValue<Int2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4673 | { |
| 4674 | return lhs = lhs - rhs; |
| 4675 | } |
| 4676 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4677 | // RValue<Int2> operator*=(const Int2 &lhs, RValue<Int2> rhs) |
| 4678 | // { |
| 4679 | // return lhs = lhs * rhs; |
| 4680 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4681 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4682 | // RValue<Int2> operator/=(const Int2 &lhs, RValue<Int2> rhs) |
| 4683 | // { |
| 4684 | // return lhs = lhs / rhs; |
| 4685 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4686 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4687 | // RValue<Int2> operator%=(const Int2 &lhs, RValue<Int2> rhs) |
| 4688 | // { |
| 4689 | // return lhs = lhs % rhs; |
| 4690 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4691 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4692 | RValue<Int2> operator&=(const Int2 &lhs, RValue<Int2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4693 | { |
| 4694 | return lhs = lhs & rhs; |
| 4695 | } |
| 4696 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4697 | RValue<Int2> operator|=(const Int2 &lhs, RValue<Int2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4698 | { |
| 4699 | return lhs = lhs | rhs; |
| 4700 | } |
| 4701 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4702 | RValue<Int2> operator^=(const Int2 &lhs, RValue<Int2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4703 | { |
| 4704 | return lhs = lhs ^ rhs; |
| 4705 | } |
| 4706 | |
| 4707 | RValue<Int2> operator<<=(const Int2 &lhs, unsigned char rhs) |
| 4708 | { |
| 4709 | return lhs = lhs << rhs; |
| 4710 | } |
| 4711 | |
| 4712 | RValue<Int2> operator>>=(const Int2 &lhs, unsigned char rhs) |
| 4713 | { |
| 4714 | return lhs = lhs >> rhs; |
| 4715 | } |
| 4716 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4717 | RValue<Int2> operator<<=(const Int2 &lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4718 | { |
| 4719 | return lhs = lhs << rhs; |
| 4720 | } |
| 4721 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4722 | RValue<Int2> operator>>=(const Int2 &lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4723 | { |
| 4724 | return lhs = lhs >> rhs; |
| 4725 | } |
| 4726 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4727 | // RValue<Int2> operator+(RValue<Int2> val) |
| 4728 | // { |
| 4729 | // return val; |
| 4730 | // } |
| 4731 | |
| 4732 | // RValue<Int2> operator-(RValue<Int2> val) |
| 4733 | // { |
| 4734 | // return RValue<Int2>(Nucleus::createNeg(val.value)); |
| 4735 | // } |
| 4736 | |
| 4737 | RValue<Int2> operator~(RValue<Int2> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4738 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4739 | if(CPUID::supportsMMX2()) |
| 4740 | { |
| 4741 | return val ^ Int2(0xFFFFFFFF, 0xFFFFFFFF); |
| 4742 | } |
| 4743 | else |
| 4744 | { |
| 4745 | return RValue<Int2>(Nucleus::createNot(val.value)); |
| 4746 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4747 | } |
| 4748 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4749 | RValue<Long1> UnpackLow(RValue<Int2> x, RValue<Int2> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4750 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4751 | if(CPUID::supportsMMX2()) |
| 4752 | { |
| 4753 | return x86::punpckldq(x, y); |
| 4754 | } |
| 4755 | else |
| 4756 | { |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 4757 | int shuffle[2] = {0, 2}; |
| 4758 | Value *packed = Nucleus::createShuffleVector(x.value, y.value, shuffle); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4759 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4760 | return RValue<Long1>(Nucleus::createBitCast(packed, Long1::getType())); |
| 4761 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4762 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4763 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4764 | RValue<Long1> UnpackHigh(RValue<Int2> x, RValue<Int2> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4765 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4766 | if(CPUID::supportsMMX2()) |
| 4767 | { |
| 4768 | return x86::punpckhdq(x, y); |
| 4769 | } |
| 4770 | else |
| 4771 | { |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 4772 | int shuffle[2] = {1, 3}; |
| 4773 | Value *packed = Nucleus::createShuffleVector(x.value, y.value, shuffle); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4774 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4775 | return RValue<Long1>(Nucleus::createBitCast(packed, Long1::getType())); |
| 4776 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4777 | } |
| 4778 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4779 | RValue<Int> Extract(RValue<Int2> val, int i) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4780 | { |
| 4781 | if(false) // FIXME: LLVM does not generate optimal code |
| 4782 | { |
Nicolas Capens | e95d534 | 2016-09-30 11:37:28 -0400 | [diff] [blame] | 4783 | return RValue<Int>(Nucleus::createExtractElement(val.value, Int::getType(), i)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4784 | } |
| 4785 | else |
| 4786 | { |
| 4787 | if(i == 0) |
| 4788 | { |
Nicolas Capens | e95d534 | 2016-09-30 11:37:28 -0400 | [diff] [blame] | 4789 | return RValue<Int>(Nucleus::createExtractElement(Nucleus::createBitCast(val.value, T(VectorType::get(Int::getType(), 2))), Int::getType(), 0)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4790 | } |
| 4791 | else |
| 4792 | { |
| 4793 | Int2 val2 = As<Int2>(UnpackHigh(val, val)); |
| 4794 | |
| 4795 | return Extract(val2, 0); |
| 4796 | } |
| 4797 | } |
| 4798 | } |
| 4799 | |
Nicolas Capens | fff3c9b | 2015-05-13 23:40:44 -0400 | [diff] [blame] | 4800 | RValue<Int2> Insert(RValue<Int2> val, RValue<Int> element, int i) |
| 4801 | { |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 4802 | return RValue<Int2>(Nucleus::createBitCast(Nucleus::createInsertElement(Nucleus::createBitCast(val.value, T(VectorType::get(Int::getType(), 2))), element.value, i), Int2::getType())); |
Nicolas Capens | fff3c9b | 2015-05-13 23:40:44 -0400 | [diff] [blame] | 4803 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4804 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4805 | Type *Int2::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4806 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4807 | if(CPUID::supportsMMX2()) |
| 4808 | { |
| 4809 | return MMX::getType(); |
| 4810 | } |
| 4811 | else |
| 4812 | { |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 4813 | return T(VectorType::get(Int::getType(), 2)); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4814 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4815 | } |
| 4816 | |
| 4817 | UInt2::UInt2() |
| 4818 | { |
| 4819 | // xy.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4820 | } |
| 4821 | |
| 4822 | UInt2::UInt2(unsigned int x, unsigned int y) |
| 4823 | { |
| 4824 | // xy.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4825 | |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 4826 | int64_t constantVector[2] = {x, y}; |
| 4827 | Value *vector = V(Nucleus::createConstantVector(constantVector, T(VectorType::get(UInt::getType(), 2)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4828 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4829 | storeValue(Nucleus::createBitCast(vector, getType())); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4830 | } |
| 4831 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4832 | UInt2::UInt2(RValue<UInt2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4833 | { |
| 4834 | // xy.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4835 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4836 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4837 | } |
| 4838 | |
| 4839 | UInt2::UInt2(const UInt2 &rhs) |
| 4840 | { |
| 4841 | // xy.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4842 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4843 | Value *value = rhs.loadValue(); |
| 4844 | storeValue(value); |
| 4845 | } |
| 4846 | |
| 4847 | UInt2::UInt2(const Reference<UInt2> &rhs) |
| 4848 | { |
| 4849 | // xy.parent = this; |
| 4850 | |
| 4851 | Value *value = rhs.loadValue(); |
| 4852 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4853 | } |
| 4854 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4855 | RValue<UInt2> UInt2::operator=(RValue<UInt2> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4856 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4857 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4858 | |
| 4859 | return rhs; |
| 4860 | } |
| 4861 | |
| 4862 | RValue<UInt2> UInt2::operator=(const UInt2 &rhs) const |
| 4863 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4864 | Value *value = rhs.loadValue(); |
| 4865 | storeValue(value); |
| 4866 | |
| 4867 | return RValue<UInt2>(value); |
| 4868 | } |
| 4869 | |
| 4870 | RValue<UInt2> UInt2::operator=(const Reference<UInt2> &rhs) const |
| 4871 | { |
| 4872 | Value *value = rhs.loadValue(); |
| 4873 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4874 | |
| 4875 | return RValue<UInt2>(value); |
| 4876 | } |
| 4877 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4878 | RValue<UInt2> operator+(RValue<UInt2> lhs, RValue<UInt2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4879 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4880 | if(CPUID::supportsMMX2()) |
| 4881 | { |
| 4882 | return As<UInt2>(x86::paddd(As<Int2>(lhs), As<Int2>(rhs))); |
| 4883 | } |
| 4884 | else |
| 4885 | { |
| 4886 | return RValue<UInt2>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 4887 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4888 | } |
| 4889 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4890 | RValue<UInt2> operator-(RValue<UInt2> lhs, RValue<UInt2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4891 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4892 | if(CPUID::supportsMMX2()) |
| 4893 | { |
| 4894 | return As<UInt2>(x86::psubd(As<Int2>(lhs), As<Int2>(rhs))); |
| 4895 | } |
| 4896 | else |
| 4897 | { |
| 4898 | return RValue<UInt2>(Nucleus::createSub(lhs.value, rhs.value)); |
| 4899 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4900 | } |
| 4901 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4902 | // RValue<UInt2> operator*(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 4903 | // { |
| 4904 | // return RValue<UInt2>(Nucleus::createMul(lhs.value, rhs.value)); |
| 4905 | // } |
| 4906 | |
| 4907 | // RValue<UInt2> operator/(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 4908 | // { |
| 4909 | // return RValue<UInt2>(Nucleus::createUDiv(lhs.value, rhs.value)); |
| 4910 | // } |
| 4911 | |
| 4912 | // RValue<UInt2> operator%(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 4913 | // { |
| 4914 | // return RValue<UInt2>(Nucleus::createURem(lhs.value, rhs.value)); |
| 4915 | // } |
| 4916 | |
| 4917 | RValue<UInt2> operator&(RValue<UInt2> lhs, RValue<UInt2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4918 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4919 | if(CPUID::supportsMMX2()) |
| 4920 | { |
| 4921 | return As<UInt2>(x86::pand(As<Short4>(lhs), As<Short4>(rhs))); |
| 4922 | } |
| 4923 | else |
| 4924 | { |
| 4925 | return RValue<UInt2>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 4926 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4927 | } |
| 4928 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4929 | RValue<UInt2> operator|(RValue<UInt2> lhs, RValue<UInt2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4930 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4931 | if(CPUID::supportsMMX2()) |
| 4932 | { |
| 4933 | return As<UInt2>(x86::por(As<Short4>(lhs), As<Short4>(rhs))); |
| 4934 | } |
| 4935 | else |
| 4936 | { |
| 4937 | return RValue<UInt2>(Nucleus::createOr(lhs.value, rhs.value)); |
| 4938 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4939 | } |
| 4940 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4941 | RValue<UInt2> operator^(RValue<UInt2> lhs, RValue<UInt2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4942 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4943 | if(CPUID::supportsMMX2()) |
| 4944 | { |
| 4945 | return As<UInt2>(x86::pxor(As<Short4>(lhs), As<Short4>(rhs))); |
| 4946 | } |
| 4947 | else |
| 4948 | { |
| 4949 | return RValue<UInt2>(Nucleus::createXor(lhs.value, rhs.value)); |
| 4950 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4951 | } |
| 4952 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4953 | RValue<UInt2> operator<<(RValue<UInt2> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4954 | { |
| 4955 | // return RValue<UInt2>(Nucleus::createShl(lhs.value, rhs.value)); |
| 4956 | |
| 4957 | return As<UInt2>(x86::pslld(As<Int2>(lhs), rhs)); |
| 4958 | } |
| 4959 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4960 | RValue<UInt2> operator>>(RValue<UInt2> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4961 | { |
| 4962 | // return RValue<UInt2>(Nucleus::createLShr(lhs.value, rhs.value)); |
| 4963 | |
| 4964 | return x86::psrld(lhs, rhs); |
| 4965 | } |
| 4966 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4967 | RValue<UInt2> operator<<(RValue<UInt2> lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4968 | { |
| 4969 | // return RValue<UInt2>(Nucleus::createShl(lhs.value, rhs.value)); |
| 4970 | |
| 4971 | return As<UInt2>(x86::pslld(As<Int2>(lhs), rhs)); |
| 4972 | } |
| 4973 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4974 | RValue<UInt2> operator>>(RValue<UInt2> lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4975 | { |
| 4976 | // return RValue<UInt2>(Nucleus::createLShr(lhs.value, rhs.value)); |
| 4977 | |
| 4978 | return x86::psrld(lhs, rhs); |
| 4979 | } |
| 4980 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4981 | RValue<UInt2> operator+=(const UInt2 &lhs, RValue<UInt2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4982 | { |
| 4983 | return lhs = lhs + rhs; |
| 4984 | } |
| 4985 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4986 | RValue<UInt2> operator-=(const UInt2 &lhs, RValue<UInt2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4987 | { |
| 4988 | return lhs = lhs - rhs; |
| 4989 | } |
| 4990 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4991 | // RValue<UInt2> operator*=(const UInt2 &lhs, RValue<UInt2> rhs) |
| 4992 | // { |
| 4993 | // return lhs = lhs * rhs; |
| 4994 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4995 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4996 | // RValue<UInt2> operator/=(const UInt2 &lhs, RValue<UInt2> rhs) |
| 4997 | // { |
| 4998 | // return lhs = lhs / rhs; |
| 4999 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5000 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5001 | // RValue<UInt2> operator%=(const UInt2 &lhs, RValue<UInt2> rhs) |
| 5002 | // { |
| 5003 | // return lhs = lhs % rhs; |
| 5004 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5005 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5006 | RValue<UInt2> operator&=(const UInt2 &lhs, RValue<UInt2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5007 | { |
| 5008 | return lhs = lhs & rhs; |
| 5009 | } |
| 5010 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5011 | RValue<UInt2> operator|=(const UInt2 &lhs, RValue<UInt2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5012 | { |
| 5013 | return lhs = lhs | rhs; |
| 5014 | } |
| 5015 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5016 | RValue<UInt2> operator^=(const UInt2 &lhs, RValue<UInt2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5017 | { |
| 5018 | return lhs = lhs ^ rhs; |
| 5019 | } |
| 5020 | |
| 5021 | RValue<UInt2> operator<<=(const UInt2 &lhs, unsigned char rhs) |
| 5022 | { |
| 5023 | return lhs = lhs << rhs; |
| 5024 | } |
| 5025 | |
| 5026 | RValue<UInt2> operator>>=(const UInt2 &lhs, unsigned char rhs) |
| 5027 | { |
| 5028 | return lhs = lhs >> rhs; |
| 5029 | } |
| 5030 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5031 | RValue<UInt2> operator<<=(const UInt2 &lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5032 | { |
| 5033 | return lhs = lhs << rhs; |
| 5034 | } |
| 5035 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5036 | RValue<UInt2> operator>>=(const UInt2 &lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5037 | { |
| 5038 | return lhs = lhs >> rhs; |
| 5039 | } |
| 5040 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5041 | // RValue<UInt2> operator+(RValue<UInt2> val) |
| 5042 | // { |
| 5043 | // return val; |
| 5044 | // } |
| 5045 | |
| 5046 | // RValue<UInt2> operator-(RValue<UInt2> val) |
| 5047 | // { |
| 5048 | // return RValue<UInt2>(Nucleus::createNeg(val.value)); |
| 5049 | // } |
| 5050 | |
| 5051 | RValue<UInt2> operator~(RValue<UInt2> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5052 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5053 | if(CPUID::supportsMMX2()) |
| 5054 | { |
| 5055 | return val ^ UInt2(0xFFFFFFFF, 0xFFFFFFFF); |
| 5056 | } |
| 5057 | else |
| 5058 | { |
| 5059 | return RValue<UInt2>(Nucleus::createNot(val.value)); |
| 5060 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5061 | } |
| 5062 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5063 | Type *UInt2::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5064 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5065 | if(CPUID::supportsMMX2()) |
| 5066 | { |
| 5067 | return MMX::getType(); |
| 5068 | } |
| 5069 | else |
| 5070 | { |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 5071 | return T(VectorType::get(UInt::getType(), 2)); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5072 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5073 | } |
| 5074 | |
Meng-Lin Wu | 601d005 | 2016-06-10 14:18:41 -0400 | [diff] [blame] | 5075 | Int4::Int4(RValue<Byte4> cast) |
| 5076 | { |
| 5077 | Value *x = Nucleus::createBitCast(cast.value, Int::getType()); |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 5078 | Value *a = Nucleus::createInsertElement(V(UndefValue::get(Int4::getType())), x, 0); |
Meng-Lin Wu | 601d005 | 2016-06-10 14:18:41 -0400 | [diff] [blame] | 5079 | |
| 5080 | Value *e; |
| 5081 | |
| 5082 | if (CPUID::supportsSSE4_1()) |
| 5083 | { |
| 5084 | e = x86::pmovzxbd(RValue<Int4>(a)).value; |
| 5085 | } |
| 5086 | else |
| 5087 | { |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 5088 | int swizzle[16] = {0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23}; |
Meng-Lin Wu | 601d005 | 2016-06-10 14:18:41 -0400 | [diff] [blame] | 5089 | Value *b = Nucleus::createBitCast(a, Byte16::getType()); |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 5090 | Value *c = Nucleus::createShuffleVector(b, V(Nucleus::createNullValue(Byte16::getType())), swizzle); |
Meng-Lin Wu | 601d005 | 2016-06-10 14:18:41 -0400 | [diff] [blame] | 5091 | |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 5092 | int swizzle2[8] = {0, 8, 1, 9, 2, 10, 3, 11}; |
Meng-Lin Wu | 601d005 | 2016-06-10 14:18:41 -0400 | [diff] [blame] | 5093 | Value *d = Nucleus::createBitCast(c, Short8::getType()); |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 5094 | e = Nucleus::createShuffleVector(d, V(Nucleus::createNullValue(Short8::getType())), swizzle2); |
Meng-Lin Wu | 601d005 | 2016-06-10 14:18:41 -0400 | [diff] [blame] | 5095 | } |
| 5096 | |
| 5097 | Value *f = Nucleus::createBitCast(e, Int4::getType()); |
| 5098 | storeValue(f); |
| 5099 | } |
| 5100 | |
| 5101 | Int4::Int4(RValue<SByte4> cast) |
| 5102 | { |
| 5103 | Value *x = Nucleus::createBitCast(cast.value, Int::getType()); |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 5104 | Value *a = Nucleus::createInsertElement(V(UndefValue::get(Int4::getType())), x, 0); |
Meng-Lin Wu | 601d005 | 2016-06-10 14:18:41 -0400 | [diff] [blame] | 5105 | |
| 5106 | Value *g; |
| 5107 | |
| 5108 | if (CPUID::supportsSSE4_1()) |
| 5109 | { |
| 5110 | g = x86::pmovsxbd(RValue<Int4>(a)).value; |
| 5111 | } |
| 5112 | else |
| 5113 | { |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 5114 | int swizzle[16] = {0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7}; |
Meng-Lin Wu | 601d005 | 2016-06-10 14:18:41 -0400 | [diff] [blame] | 5115 | Value *b = Nucleus::createBitCast(a, Byte16::getType()); |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 5116 | Value *c = Nucleus::createShuffleVector(b, b, swizzle); |
Meng-Lin Wu | 601d005 | 2016-06-10 14:18:41 -0400 | [diff] [blame] | 5117 | |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 5118 | int swizzle2[8] = {0, 0, 1, 1, 2, 2, 3, 3}; |
Meng-Lin Wu | 601d005 | 2016-06-10 14:18:41 -0400 | [diff] [blame] | 5119 | Value *d = Nucleus::createBitCast(c, Short8::getType()); |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 5120 | Value *e = Nucleus::createShuffleVector(d, d, swizzle2); |
Meng-Lin Wu | 601d005 | 2016-06-10 14:18:41 -0400 | [diff] [blame] | 5121 | |
| 5122 | Value *f = Nucleus::createBitCast(e, Int4::getType()); |
| 5123 | // g = Nucleus::createAShr(f, Nucleus::createConstantInt(24)); |
| 5124 | g = x86::psrad(RValue<Int4>(f), 24).value; |
| 5125 | } |
| 5126 | |
| 5127 | storeValue(g); |
| 5128 | } |
| 5129 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5130 | Int4::Int4(RValue<Float4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5131 | { |
| 5132 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5133 | |
| 5134 | Value *xyzw = Nucleus::createFPToSI(cast.value, Int4::getType()); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5135 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5136 | storeValue(xyzw); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5137 | } |
| 5138 | |
Alexis Hetu | 2aa852f | 2015-10-14 16:32:39 -0400 | [diff] [blame] | 5139 | Int4::Int4(RValue<Short4> cast) |
| 5140 | { |
Nicolas Capens | 2200878 | 2016-10-20 01:11:47 -0400 | [diff] [blame] | 5141 | Value *long2 = V(UndefValue::get(VectorType::get(Long::getType(), 2))); |
Alexis Hetu | 2aa852f | 2015-10-14 16:32:39 -0400 | [diff] [blame] | 5142 | Value *element = Nucleus::createBitCast(cast.value, Long::getType()); |
| 5143 | long2 = Nucleus::createInsertElement(long2, element, 0); |
| 5144 | RValue<Int4> vector = RValue<Int4>(Nucleus::createBitCast(long2, Int4::getType())); |
Nicolas Capens | 05b3d66 | 2016-02-25 23:58:33 -0500 | [diff] [blame] | 5145 | |
Alexis Hetu | 2aa852f | 2015-10-14 16:32:39 -0400 | [diff] [blame] | 5146 | if(CPUID::supportsSSE4_1()) |
| 5147 | { |
| 5148 | storeValue(x86::pmovsxwd(vector).value); |
| 5149 | } |
| 5150 | else |
| 5151 | { |
| 5152 | Value *b = Nucleus::createBitCast(vector.value, Short8::getType()); |
| 5153 | |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 5154 | int swizzle[8] = {0, 0, 1, 1, 2, 2, 3, 3}; |
| 5155 | Value *c = Nucleus::createShuffleVector(b, b, swizzle); |
Nicolas Capens | 6ce5c33 | 2015-10-28 01:58:18 -0400 | [diff] [blame] | 5156 | Value *d = Nucleus::createBitCast(c, Int4::getType()); |
| 5157 | storeValue(d); |
Alexis Hetu | 2aa852f | 2015-10-14 16:32:39 -0400 | [diff] [blame] | 5158 | |
| 5159 | // Each Short is packed into each Int in the (Short | Short) format. |
| 5160 | // Shifting by 16 will retrieve the original Short value. |
| 5161 | // Shitfing an Int will propagate the sign bit, which will work |
| 5162 | // for both positive and negative values of a Short. |
| 5163 | *this >>= 16; |
| 5164 | } |
| 5165 | } |
| 5166 | |
| 5167 | Int4::Int4(RValue<UShort4> cast) |
| 5168 | { |
Nicolas Capens | 2200878 | 2016-10-20 01:11:47 -0400 | [diff] [blame] | 5169 | Value *long2 = V(UndefValue::get(VectorType::get(Long::getType(), 2))); |
Alexis Hetu | 2aa852f | 2015-10-14 16:32:39 -0400 | [diff] [blame] | 5170 | Value *element = Nucleus::createBitCast(cast.value, Long::getType()); |
| 5171 | long2 = Nucleus::createInsertElement(long2, element, 0); |
| 5172 | RValue<Int4> vector = RValue<Int4>(Nucleus::createBitCast(long2, Int4::getType())); |
| 5173 | |
| 5174 | if(CPUID::supportsSSE4_1()) |
| 5175 | { |
| 5176 | storeValue(x86::pmovzxwd(RValue<Int4>(vector)).value); |
| 5177 | } |
| 5178 | else |
| 5179 | { |
| 5180 | Value *b = Nucleus::createBitCast(vector.value, Short8::getType()); |
| 5181 | |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 5182 | int swizzle[8] = {0, 8, 1, 9, 2, 10, 3, 11}; |
| 5183 | Value *c = Nucleus::createShuffleVector(b, V(Nucleus::createNullValue(Short8::getType())), swizzle); |
Nicolas Capens | 6ce5c33 | 2015-10-28 01:58:18 -0400 | [diff] [blame] | 5184 | Value *d = Nucleus::createBitCast(c, Int4::getType()); |
| 5185 | storeValue(d); |
Alexis Hetu | 2aa852f | 2015-10-14 16:32:39 -0400 | [diff] [blame] | 5186 | } |
| 5187 | } |
| 5188 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5189 | Int4::Int4() |
| 5190 | { |
| 5191 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5192 | } |
| 5193 | |
| 5194 | Int4::Int4(int xyzw) |
| 5195 | { |
| 5196 | constant(xyzw, xyzw, xyzw, xyzw); |
| 5197 | } |
| 5198 | |
| 5199 | Int4::Int4(int x, int yzw) |
| 5200 | { |
| 5201 | constant(x, yzw, yzw, yzw); |
| 5202 | } |
| 5203 | |
| 5204 | Int4::Int4(int x, int y, int zw) |
| 5205 | { |
| 5206 | constant(x, y, zw, zw); |
| 5207 | } |
| 5208 | |
| 5209 | Int4::Int4(int x, int y, int z, int w) |
| 5210 | { |
| 5211 | constant(x, y, z, w); |
| 5212 | } |
| 5213 | |
| 5214 | void Int4::constant(int x, int y, int z, int w) |
| 5215 | { |
| 5216 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5217 | |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 5218 | int64_t constantVector[4] = {x, y, z, w}; |
| 5219 | storeValue(Nucleus::createConstantVector(constantVector, getType())); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5220 | } |
| 5221 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5222 | Int4::Int4(RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5223 | { |
| 5224 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5225 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5226 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5227 | } |
| 5228 | |
| 5229 | Int4::Int4(const Int4 &rhs) |
| 5230 | { |
| 5231 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5232 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5233 | Value *value = rhs.loadValue(); |
| 5234 | storeValue(value); |
| 5235 | } |
| 5236 | |
| 5237 | Int4::Int4(const Reference<Int4> &rhs) |
| 5238 | { |
| 5239 | // xyzw.parent = this; |
| 5240 | |
| 5241 | Value *value = rhs.loadValue(); |
| 5242 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5243 | } |
| 5244 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5245 | Int4::Int4(RValue<UInt4> rhs) |
| 5246 | { |
| 5247 | // xyzw.parent = this; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5248 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5249 | storeValue(rhs.value); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5250 | } |
| 5251 | |
| 5252 | Int4::Int4(const UInt4 &rhs) |
| 5253 | { |
| 5254 | // xyzw.parent = this; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5255 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5256 | Value *value = rhs.loadValue(); |
| 5257 | storeValue(value); |
| 5258 | } |
| 5259 | |
| 5260 | Int4::Int4(const Reference<UInt4> &rhs) |
| 5261 | { |
| 5262 | // xyzw.parent = this; |
| 5263 | |
| 5264 | Value *value = rhs.loadValue(); |
| 5265 | storeValue(value); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5266 | } |
| 5267 | |
Nicolas Capens | 62abb55 | 2016-01-05 12:03:47 -0500 | [diff] [blame] | 5268 | Int4::Int4(RValue<Int2> lo, RValue<Int2> hi) |
| 5269 | { |
Nicolas Capens | 24c8cf0 | 2016-08-15 15:33:14 -0400 | [diff] [blame] | 5270 | // xyzw.parent = this; |
| 5271 | |
Nicolas Capens | 62abb55 | 2016-01-05 12:03:47 -0500 | [diff] [blame] | 5272 | Value *loLong = Nucleus::createBitCast(lo.value, Long::getType()); |
| 5273 | Value *hiLong = Nucleus::createBitCast(hi.value, Long::getType()); |
| 5274 | |
Nicolas Capens | 2200878 | 2016-10-20 01:11:47 -0400 | [diff] [blame] | 5275 | Value *long2 = V(UndefValue::get(VectorType::get(Long::getType(), 2))); |
Nicolas Capens | 62abb55 | 2016-01-05 12:03:47 -0500 | [diff] [blame] | 5276 | long2 = Nucleus::createInsertElement(long2, loLong, 0); |
| 5277 | long2 = Nucleus::createInsertElement(long2, hiLong, 1); |
| 5278 | Value *int4 = Nucleus::createBitCast(long2, Int4::getType()); |
| 5279 | |
| 5280 | storeValue(int4); |
| 5281 | } |
| 5282 | |
Nicolas Capens | 24c8cf0 | 2016-08-15 15:33:14 -0400 | [diff] [blame] | 5283 | Int4::Int4(RValue<Int> rhs) |
| 5284 | { |
| 5285 | // xyzw.parent = this; |
| 5286 | |
| 5287 | Value *vector = loadValue(); |
| 5288 | Value *insert = Nucleus::createInsertElement(vector, rhs.value, 0); |
| 5289 | |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 5290 | int swizzle[4] = {0, 0, 0, 0}; |
| 5291 | Value *replicate = Nucleus::createShuffleVector(insert, insert, swizzle); |
Nicolas Capens | 24c8cf0 | 2016-08-15 15:33:14 -0400 | [diff] [blame] | 5292 | |
| 5293 | storeValue(replicate); |
| 5294 | } |
| 5295 | |
| 5296 | Int4::Int4(const Int &rhs) |
| 5297 | { |
| 5298 | // xyzw.parent = this; |
| 5299 | |
| 5300 | *this = RValue<Int>(rhs.loadValue()); |
| 5301 | } |
| 5302 | |
| 5303 | Int4::Int4(const Reference<Int> &rhs) |
| 5304 | { |
| 5305 | // xyzw.parent = this; |
| 5306 | |
| 5307 | *this = RValue<Int>(rhs.loadValue()); |
| 5308 | } |
| 5309 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5310 | RValue<Int4> Int4::operator=(RValue<Int4> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5311 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5312 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5313 | |
| 5314 | return rhs; |
| 5315 | } |
| 5316 | |
| 5317 | RValue<Int4> Int4::operator=(const Int4 &rhs) const |
| 5318 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5319 | Value *value = rhs.loadValue(); |
| 5320 | storeValue(value); |
| 5321 | |
| 5322 | return RValue<Int4>(value); |
| 5323 | } |
| 5324 | |
| 5325 | RValue<Int4> Int4::operator=(const Reference<Int4> &rhs) const |
| 5326 | { |
| 5327 | Value *value = rhs.loadValue(); |
| 5328 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5329 | |
| 5330 | return RValue<Int4>(value); |
| 5331 | } |
| 5332 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5333 | RValue<Int4> operator+(RValue<Int4> lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5334 | { |
| 5335 | return RValue<Int4>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 5336 | } |
| 5337 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5338 | RValue<Int4> operator-(RValue<Int4> lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5339 | { |
| 5340 | return RValue<Int4>(Nucleus::createSub(lhs.value, rhs.value)); |
| 5341 | } |
| 5342 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5343 | RValue<Int4> operator*(RValue<Int4> lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5344 | { |
| 5345 | return RValue<Int4>(Nucleus::createMul(lhs.value, rhs.value)); |
| 5346 | } |
| 5347 | |
Alexis Hetu | d9d27bb | 2015-08-18 15:22:15 -0400 | [diff] [blame] | 5348 | RValue<Int4> operator/(RValue<Int4> lhs, RValue<Int4> rhs) |
| 5349 | { |
| 5350 | return RValue<Int4>(Nucleus::createSDiv(lhs.value, rhs.value)); |
| 5351 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5352 | |
Alexis Hetu | d9d27bb | 2015-08-18 15:22:15 -0400 | [diff] [blame] | 5353 | RValue<Int4> operator%(RValue<Int4> lhs, RValue<Int4> rhs) |
| 5354 | { |
| 5355 | return RValue<Int4>(Nucleus::createSRem(lhs.value, rhs.value)); |
| 5356 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5357 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5358 | RValue<Int4> operator&(RValue<Int4> lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5359 | { |
| 5360 | return RValue<Int4>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 5361 | } |
| 5362 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5363 | RValue<Int4> operator|(RValue<Int4> lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5364 | { |
| 5365 | return RValue<Int4>(Nucleus::createOr(lhs.value, rhs.value)); |
| 5366 | } |
| 5367 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5368 | RValue<Int4> operator^(RValue<Int4> lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5369 | { |
| 5370 | return RValue<Int4>(Nucleus::createXor(lhs.value, rhs.value)); |
| 5371 | } |
| 5372 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5373 | RValue<Int4> operator<<(RValue<Int4> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5374 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5375 | return x86::pslld(lhs, rhs); |
| 5376 | } |
| 5377 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5378 | RValue<Int4> operator>>(RValue<Int4> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5379 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5380 | return x86::psrad(lhs, rhs); |
| 5381 | } |
| 5382 | |
Alexis Hetu | d9d27bb | 2015-08-18 15:22:15 -0400 | [diff] [blame] | 5383 | RValue<Int4> operator<<(RValue<Int4> lhs, RValue<Int4> rhs) |
| 5384 | { |
| 5385 | return RValue<Int4>(Nucleus::createShl(lhs.value, rhs.value)); |
| 5386 | } |
| 5387 | |
| 5388 | RValue<Int4> operator>>(RValue<Int4> lhs, RValue<Int4> rhs) |
| 5389 | { |
| 5390 | return RValue<Int4>(Nucleus::createAShr(lhs.value, rhs.value)); |
| 5391 | } |
| 5392 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5393 | RValue<Int4> operator+=(const Int4 &lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5394 | { |
| 5395 | return lhs = lhs + rhs; |
| 5396 | } |
| 5397 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5398 | RValue<Int4> operator-=(const Int4 &lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5399 | { |
| 5400 | return lhs = lhs - rhs; |
| 5401 | } |
| 5402 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5403 | RValue<Int4> operator*=(const Int4 &lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5404 | { |
| 5405 | return lhs = lhs * rhs; |
| 5406 | } |
| 5407 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5408 | // RValue<Int4> operator/=(const Int4 &lhs, RValue<Int4> rhs) |
| 5409 | // { |
| 5410 | // return lhs = lhs / rhs; |
| 5411 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5412 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5413 | // RValue<Int4> operator%=(const Int4 &lhs, RValue<Int4> rhs) |
| 5414 | // { |
| 5415 | // return lhs = lhs % rhs; |
| 5416 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5417 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5418 | RValue<Int4> operator&=(const Int4 &lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5419 | { |
| 5420 | return lhs = lhs & rhs; |
| 5421 | } |
| 5422 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5423 | RValue<Int4> operator|=(const Int4 &lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5424 | { |
| 5425 | return lhs = lhs | rhs; |
| 5426 | } |
| 5427 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5428 | RValue<Int4> operator^=(const Int4 &lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5429 | { |
| 5430 | return lhs = lhs ^ rhs; |
| 5431 | } |
| 5432 | |
| 5433 | RValue<Int4> operator<<=(const Int4 &lhs, unsigned char rhs) |
| 5434 | { |
| 5435 | return lhs = lhs << rhs; |
| 5436 | } |
| 5437 | |
| 5438 | RValue<Int4> operator>>=(const Int4 &lhs, unsigned char rhs) |
| 5439 | { |
| 5440 | return lhs = lhs >> rhs; |
| 5441 | } |
| 5442 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5443 | RValue<Int4> operator+(RValue<Int4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5444 | { |
| 5445 | return val; |
| 5446 | } |
| 5447 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5448 | RValue<Int4> operator-(RValue<Int4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5449 | { |
| 5450 | return RValue<Int4>(Nucleus::createNeg(val.value)); |
| 5451 | } |
| 5452 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5453 | RValue<Int4> operator~(RValue<Int4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5454 | { |
| 5455 | return RValue<Int4>(Nucleus::createNot(val.value)); |
| 5456 | } |
| 5457 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5458 | RValue<Int4> CmpEQ(RValue<Int4> x, RValue<Int4> y) |
| 5459 | { |
Nicolas Capens | 197226a | 2016-04-27 23:08:50 -0400 | [diff] [blame] | 5460 | // FIXME: An LLVM bug causes SExt(ICmpCC()) to produce 0 or 1 instead of 0 or ~0 |
Alexis Hetu | fb60399 | 2016-04-26 11:50:40 -0400 | [diff] [blame] | 5461 | // Restore the following line when LLVM is updated to a version where this issue is fixed. |
| 5462 | // return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpEQ(x.value, y.value), Int4::getType())); |
| 5463 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpNE(x.value, y.value), Int4::getType())) ^ Int4(0xFFFFFFFF); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5464 | } |
| 5465 | |
| 5466 | RValue<Int4> CmpLT(RValue<Int4> x, RValue<Int4> y) |
| 5467 | { |
| 5468 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSLT(x.value, y.value), Int4::getType())); |
| 5469 | } |
| 5470 | |
| 5471 | RValue<Int4> CmpLE(RValue<Int4> x, RValue<Int4> y) |
| 5472 | { |
Nicolas Capens | 197226a | 2016-04-27 23:08:50 -0400 | [diff] [blame] | 5473 | // FIXME: An LLVM bug causes SExt(ICmpCC()) to produce 0 or 1 instead of 0 or ~0 |
| 5474 | // Restore the following line when LLVM is updated to a version where this issue is fixed. |
| 5475 | // return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSLE(x.value, y.value), Int4::getType())); |
| 5476 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSGT(x.value, y.value), Int4::getType())) ^ Int4(0xFFFFFFFF); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5477 | } |
| 5478 | |
| 5479 | RValue<Int4> CmpNEQ(RValue<Int4> x, RValue<Int4> y) |
| 5480 | { |
| 5481 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpNE(x.value, y.value), Int4::getType())); |
| 5482 | } |
| 5483 | |
| 5484 | RValue<Int4> CmpNLT(RValue<Int4> x, RValue<Int4> y) |
| 5485 | { |
Nicolas Capens | 197226a | 2016-04-27 23:08:50 -0400 | [diff] [blame] | 5486 | // FIXME: An LLVM bug causes SExt(ICmpCC()) to produce 0 or 1 instead of 0 or ~0 |
| 5487 | // Restore the following line when LLVM is updated to a version where this issue is fixed. |
| 5488 | // return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSGE(x.value, y.value), Int4::getType())); |
| 5489 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSLT(x.value, y.value), Int4::getType())) ^ Int4(0xFFFFFFFF); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5490 | } |
| 5491 | |
| 5492 | RValue<Int4> CmpNLE(RValue<Int4> x, RValue<Int4> y) |
| 5493 | { |
| 5494 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSGT(x.value, y.value), Int4::getType())); |
| 5495 | } |
| 5496 | |
| 5497 | RValue<Int4> Max(RValue<Int4> x, RValue<Int4> y) |
| 5498 | { |
| 5499 | if(CPUID::supportsSSE4_1()) |
| 5500 | { |
| 5501 | return x86::pmaxsd(x, y); |
| 5502 | } |
| 5503 | else |
| 5504 | { |
| 5505 | RValue<Int4> greater = CmpNLE(x, y); |
| 5506 | return x & greater | y & ~greater; |
| 5507 | } |
| 5508 | } |
| 5509 | |
| 5510 | RValue<Int4> Min(RValue<Int4> x, RValue<Int4> y) |
| 5511 | { |
| 5512 | if(CPUID::supportsSSE4_1()) |
| 5513 | { |
| 5514 | return x86::pminsd(x, y); |
| 5515 | } |
| 5516 | else |
| 5517 | { |
| 5518 | RValue<Int4> less = CmpLT(x, y); |
| 5519 | return x & less | y & ~less; |
| 5520 | } |
| 5521 | } |
| 5522 | |
| 5523 | RValue<Int4> RoundInt(RValue<Float4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5524 | { |
| 5525 | return x86::cvtps2dq(cast); |
| 5526 | } |
| 5527 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5528 | RValue<Short8> Pack(RValue<Int4> x, RValue<Int4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5529 | { |
| 5530 | return x86::packssdw(x, y); |
| 5531 | } |
| 5532 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5533 | RValue<Int> Extract(RValue<Int4> x, int i) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5534 | { |
Nicolas Capens | e95d534 | 2016-09-30 11:37:28 -0400 | [diff] [blame] | 5535 | return RValue<Int>(Nucleus::createExtractElement(x.value, Int::getType(), i)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5536 | } |
| 5537 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5538 | RValue<Int4> Insert(RValue<Int4> x, RValue<Int> element, int i) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5539 | { |
| 5540 | return RValue<Int4>(Nucleus::createInsertElement(x.value, element.value, i)); |
| 5541 | } |
| 5542 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5543 | RValue<Int> SignMask(RValue<Int4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5544 | { |
| 5545 | return x86::movmskps(As<Float4>(x)); |
| 5546 | } |
| 5547 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5548 | RValue<Int4> Swizzle(RValue<Int4> x, unsigned char select) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5549 | { |
Nicolas Capens | e95d534 | 2016-09-30 11:37:28 -0400 | [diff] [blame] | 5550 | return RValue<Int4>(createSwizzle4(x.value, select)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5551 | } |
| 5552 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5553 | Type *Int4::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5554 | { |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 5555 | return T(VectorType::get(Int::getType(), 4)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5556 | } |
| 5557 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5558 | UInt4::UInt4(RValue<Float4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5559 | { |
| 5560 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5561 | |
Alexis Hetu | 764d142 | 2016-09-28 08:44:22 -0400 | [diff] [blame] | 5562 | // Note: createFPToUI is broken, must perform conversion using createFPtoSI |
| 5563 | // Value *xyzw = Nucleus::createFPToUI(cast.value, UInt4::getType()); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5564 | |
Alexis Hetu | 764d142 | 2016-09-28 08:44:22 -0400 | [diff] [blame] | 5565 | // Smallest positive value representable in UInt, but not in Int |
| 5566 | const unsigned int ustart = 0x80000000u; |
| 5567 | const float ustartf = float(ustart); |
| 5568 | |
| 5569 | // Check if the value can be represented as an Int |
| 5570 | Int4 uiValue = CmpNLT(cast, Float4(ustartf)); |
| 5571 | // If the value is too large, subtract ustart and re-add it after conversion. |
| 5572 | uiValue = (uiValue & As<Int4>(As<UInt4>(Int4(cast - Float4(ustartf))) + UInt4(ustart))) | |
| 5573 | // Otherwise, just convert normally |
| 5574 | (~uiValue & Int4(cast)); |
| 5575 | // If the value is negative, store 0, otherwise store the result of the conversion |
| 5576 | storeValue((~(As<Int4>(cast) >> 31) & uiValue).value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5577 | } |
| 5578 | |
| 5579 | UInt4::UInt4() |
| 5580 | { |
| 5581 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5582 | } |
| 5583 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5584 | UInt4::UInt4(int xyzw) |
| 5585 | { |
| 5586 | constant(xyzw, xyzw, xyzw, xyzw); |
| 5587 | } |
| 5588 | |
| 5589 | UInt4::UInt4(int x, int yzw) |
| 5590 | { |
| 5591 | constant(x, yzw, yzw, yzw); |
| 5592 | } |
| 5593 | |
| 5594 | UInt4::UInt4(int x, int y, int zw) |
| 5595 | { |
| 5596 | constant(x, y, zw, zw); |
| 5597 | } |
| 5598 | |
| 5599 | UInt4::UInt4(int x, int y, int z, int w) |
| 5600 | { |
| 5601 | constant(x, y, z, w); |
| 5602 | } |
| 5603 | |
| 5604 | void UInt4::constant(int x, int y, int z, int w) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5605 | { |
| 5606 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5607 | |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 5608 | int64_t constantVector[4] = {x, y, z, w}; |
| 5609 | storeValue(Nucleus::createConstantVector(constantVector, getType())); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5610 | } |
| 5611 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5612 | UInt4::UInt4(RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5613 | { |
| 5614 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5615 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5616 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5617 | } |
| 5618 | |
| 5619 | UInt4::UInt4(const UInt4 &rhs) |
| 5620 | { |
| 5621 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5622 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5623 | Value *value = rhs.loadValue(); |
| 5624 | storeValue(value); |
| 5625 | } |
| 5626 | |
| 5627 | UInt4::UInt4(const Reference<UInt4> &rhs) |
| 5628 | { |
| 5629 | // xyzw.parent = this; |
| 5630 | |
| 5631 | Value *value = rhs.loadValue(); |
| 5632 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5633 | } |
| 5634 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5635 | UInt4::UInt4(RValue<Int4> rhs) |
| 5636 | { |
| 5637 | // xyzw.parent = this; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5638 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5639 | storeValue(rhs.value); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5640 | } |
| 5641 | |
| 5642 | UInt4::UInt4(const Int4 &rhs) |
| 5643 | { |
| 5644 | // xyzw.parent = this; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5645 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5646 | Value *value = rhs.loadValue(); |
| 5647 | storeValue(value); |
| 5648 | } |
| 5649 | |
| 5650 | UInt4::UInt4(const Reference<Int4> &rhs) |
| 5651 | { |
| 5652 | // xyzw.parent = this; |
| 5653 | |
| 5654 | Value *value = rhs.loadValue(); |
| 5655 | storeValue(value); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5656 | } |
| 5657 | |
Nicolas Capens | 62abb55 | 2016-01-05 12:03:47 -0500 | [diff] [blame] | 5658 | UInt4::UInt4(RValue<UInt2> lo, RValue<UInt2> hi) |
| 5659 | { |
| 5660 | Value *loLong = Nucleus::createBitCast(lo.value, Long::getType()); |
| 5661 | Value *hiLong = Nucleus::createBitCast(hi.value, Long::getType()); |
| 5662 | |
Nicolas Capens | 2200878 | 2016-10-20 01:11:47 -0400 | [diff] [blame] | 5663 | Value *long2 = V(UndefValue::get(VectorType::get(Long::getType(), 2))); |
Nicolas Capens | 62abb55 | 2016-01-05 12:03:47 -0500 | [diff] [blame] | 5664 | long2 = Nucleus::createInsertElement(long2, loLong, 0); |
| 5665 | long2 = Nucleus::createInsertElement(long2, hiLong, 1); |
| 5666 | Value *uint4 = Nucleus::createBitCast(long2, Int4::getType()); |
| 5667 | |
| 5668 | storeValue(uint4); |
| 5669 | } |
| 5670 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5671 | RValue<UInt4> UInt4::operator=(RValue<UInt4> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5672 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5673 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5674 | |
| 5675 | return rhs; |
| 5676 | } |
| 5677 | |
| 5678 | RValue<UInt4> UInt4::operator=(const UInt4 &rhs) const |
| 5679 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5680 | Value *value = rhs.loadValue(); |
| 5681 | storeValue(value); |
| 5682 | |
| 5683 | return RValue<UInt4>(value); |
| 5684 | } |
| 5685 | |
| 5686 | RValue<UInt4> UInt4::operator=(const Reference<UInt4> &rhs) const |
| 5687 | { |
| 5688 | Value *value = rhs.loadValue(); |
| 5689 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5690 | |
| 5691 | return RValue<UInt4>(value); |
| 5692 | } |
| 5693 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5694 | RValue<UInt4> operator+(RValue<UInt4> lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5695 | { |
| 5696 | return RValue<UInt4>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 5697 | } |
| 5698 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5699 | RValue<UInt4> operator-(RValue<UInt4> lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5700 | { |
| 5701 | return RValue<UInt4>(Nucleus::createSub(lhs.value, rhs.value)); |
| 5702 | } |
| 5703 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5704 | RValue<UInt4> operator*(RValue<UInt4> lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5705 | { |
| 5706 | return RValue<UInt4>(Nucleus::createMul(lhs.value, rhs.value)); |
| 5707 | } |
| 5708 | |
Alexis Hetu | d9d27bb | 2015-08-18 15:22:15 -0400 | [diff] [blame] | 5709 | RValue<UInt4> operator/(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 5710 | { |
| 5711 | return RValue<UInt4>(Nucleus::createUDiv(lhs.value, rhs.value)); |
| 5712 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5713 | |
Alexis Hetu | d9d27bb | 2015-08-18 15:22:15 -0400 | [diff] [blame] | 5714 | RValue<UInt4> operator%(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 5715 | { |
| 5716 | return RValue<UInt4>(Nucleus::createURem(lhs.value, rhs.value)); |
| 5717 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5718 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5719 | RValue<UInt4> operator&(RValue<UInt4> lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5720 | { |
| 5721 | return RValue<UInt4>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 5722 | } |
| 5723 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5724 | RValue<UInt4> operator|(RValue<UInt4> lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5725 | { |
| 5726 | return RValue<UInt4>(Nucleus::createOr(lhs.value, rhs.value)); |
| 5727 | } |
| 5728 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5729 | RValue<UInt4> operator^(RValue<UInt4> lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5730 | { |
| 5731 | return RValue<UInt4>(Nucleus::createXor(lhs.value, rhs.value)); |
| 5732 | } |
| 5733 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5734 | RValue<UInt4> operator<<(RValue<UInt4> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5735 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5736 | return As<UInt4>(x86::pslld(As<Int4>(lhs), rhs)); |
| 5737 | } |
| 5738 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5739 | RValue<UInt4> operator>>(RValue<UInt4> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5740 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5741 | return x86::psrld(lhs, rhs); |
| 5742 | } |
| 5743 | |
Alexis Hetu | d9d27bb | 2015-08-18 15:22:15 -0400 | [diff] [blame] | 5744 | RValue<UInt4> operator<<(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 5745 | { |
| 5746 | return RValue<UInt4>(Nucleus::createShl(lhs.value, rhs.value)); |
| 5747 | } |
| 5748 | |
| 5749 | RValue<UInt4> operator>>(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 5750 | { |
| 5751 | return RValue<UInt4>(Nucleus::createLShr(lhs.value, rhs.value)); |
| 5752 | } |
| 5753 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5754 | RValue<UInt4> operator+=(const UInt4 &lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5755 | { |
| 5756 | return lhs = lhs + rhs; |
| 5757 | } |
| 5758 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5759 | RValue<UInt4> operator-=(const UInt4 &lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5760 | { |
| 5761 | return lhs = lhs - rhs; |
| 5762 | } |
| 5763 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5764 | RValue<UInt4> operator*=(const UInt4 &lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5765 | { |
| 5766 | return lhs = lhs * rhs; |
| 5767 | } |
| 5768 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5769 | // RValue<UInt4> operator/=(const UInt4 &lhs, RValue<UInt4> rhs) |
| 5770 | // { |
| 5771 | // return lhs = lhs / rhs; |
| 5772 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5773 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5774 | // RValue<UInt4> operator%=(const UInt4 &lhs, RValue<UInt4> rhs) |
| 5775 | // { |
| 5776 | // return lhs = lhs % rhs; |
| 5777 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5778 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5779 | RValue<UInt4> operator&=(const UInt4 &lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5780 | { |
| 5781 | return lhs = lhs & rhs; |
| 5782 | } |
| 5783 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5784 | RValue<UInt4> operator|=(const UInt4 &lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5785 | { |
| 5786 | return lhs = lhs | rhs; |
| 5787 | } |
| 5788 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5789 | RValue<UInt4> operator^=(const UInt4 &lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5790 | { |
| 5791 | return lhs = lhs ^ rhs; |
| 5792 | } |
| 5793 | |
| 5794 | RValue<UInt4> operator<<=(const UInt4 &lhs, unsigned char rhs) |
| 5795 | { |
| 5796 | return lhs = lhs << rhs; |
| 5797 | } |
| 5798 | |
| 5799 | RValue<UInt4> operator>>=(const UInt4 &lhs, unsigned char rhs) |
| 5800 | { |
| 5801 | return lhs = lhs >> rhs; |
| 5802 | } |
| 5803 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5804 | RValue<UInt4> operator+(RValue<UInt4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5805 | { |
| 5806 | return val; |
| 5807 | } |
| 5808 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5809 | RValue<UInt4> operator-(RValue<UInt4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5810 | { |
| 5811 | return RValue<UInt4>(Nucleus::createNeg(val.value)); |
| 5812 | } |
| 5813 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5814 | RValue<UInt4> operator~(RValue<UInt4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5815 | { |
| 5816 | return RValue<UInt4>(Nucleus::createNot(val.value)); |
| 5817 | } |
| 5818 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5819 | RValue<UInt4> CmpEQ(RValue<UInt4> x, RValue<UInt4> y) |
| 5820 | { |
Nicolas Capens | 197226a | 2016-04-27 23:08:50 -0400 | [diff] [blame] | 5821 | // FIXME: An LLVM bug causes SExt(ICmpCC()) to produce 0 or 1 instead of 0 or ~0 |
Alexis Hetu | fb60399 | 2016-04-26 11:50:40 -0400 | [diff] [blame] | 5822 | // Restore the following line when LLVM is updated to a version where this issue is fixed. |
| 5823 | // return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpEQ(x.value, y.value), Int4::getType())); |
| 5824 | return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpNE(x.value, y.value), Int4::getType())) ^ UInt4(0xFFFFFFFF); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5825 | } |
| 5826 | |
| 5827 | RValue<UInt4> CmpLT(RValue<UInt4> x, RValue<UInt4> y) |
| 5828 | { |
| 5829 | return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpULT(x.value, y.value), Int4::getType())); |
| 5830 | } |
| 5831 | |
| 5832 | RValue<UInt4> CmpLE(RValue<UInt4> x, RValue<UInt4> y) |
| 5833 | { |
Nicolas Capens | 197226a | 2016-04-27 23:08:50 -0400 | [diff] [blame] | 5834 | // FIXME: An LLVM bug causes SExt(ICmpCC()) to produce 0 or 1 instead of 0 or ~0 |
| 5835 | // Restore the following line when LLVM is updated to a version where this issue is fixed. |
| 5836 | // return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpULE(x.value, y.value), Int4::getType())); |
| 5837 | return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpUGT(x.value, y.value), Int4::getType())) ^ UInt4(0xFFFFFFFF); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5838 | } |
| 5839 | |
| 5840 | RValue<UInt4> CmpNEQ(RValue<UInt4> x, RValue<UInt4> y) |
| 5841 | { |
| 5842 | return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpNE(x.value, y.value), Int4::getType())); |
| 5843 | } |
| 5844 | |
| 5845 | RValue<UInt4> CmpNLT(RValue<UInt4> x, RValue<UInt4> y) |
| 5846 | { |
Nicolas Capens | 197226a | 2016-04-27 23:08:50 -0400 | [diff] [blame] | 5847 | // FIXME: An LLVM bug causes SExt(ICmpCC()) to produce 0 or 1 instead of 0 or ~0 |
| 5848 | // Restore the following line when LLVM is updated to a version where this issue is fixed. |
| 5849 | // return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpUGE(x.value, y.value), Int4::getType())); |
| 5850 | return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpULT(x.value, y.value), Int4::getType())) ^ UInt4(0xFFFFFFFF); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5851 | } |
| 5852 | |
| 5853 | RValue<UInt4> CmpNLE(RValue<UInt4> x, RValue<UInt4> y) |
| 5854 | { |
| 5855 | return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpUGT(x.value, y.value), Int4::getType())); |
| 5856 | } |
| 5857 | |
| 5858 | RValue<UInt4> Max(RValue<UInt4> x, RValue<UInt4> y) |
| 5859 | { |
| 5860 | if(CPUID::supportsSSE4_1()) |
| 5861 | { |
| 5862 | return x86::pmaxud(x, y); |
| 5863 | } |
| 5864 | else |
| 5865 | { |
| 5866 | RValue<UInt4> greater = CmpNLE(x, y); |
| 5867 | return x & greater | y & ~greater; |
| 5868 | } |
| 5869 | } |
| 5870 | |
| 5871 | RValue<UInt4> Min(RValue<UInt4> x, RValue<UInt4> y) |
| 5872 | { |
| 5873 | if(CPUID::supportsSSE4_1()) |
| 5874 | { |
| 5875 | return x86::pminud(x, y); |
| 5876 | } |
| 5877 | else |
| 5878 | { |
| 5879 | RValue<UInt4> less = CmpLT(x, y); |
| 5880 | return x & less | y & ~less; |
| 5881 | } |
| 5882 | } |
| 5883 | |
| 5884 | RValue<UShort8> Pack(RValue<UInt4> x, RValue<UInt4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5885 | { |
| 5886 | return x86::packusdw(x, y); // FIXME: Fallback required |
| 5887 | } |
| 5888 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5889 | Type *UInt4::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5890 | { |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 5891 | return T(VectorType::get(UInt::getType(), 4)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5892 | } |
| 5893 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5894 | Float::Float(RValue<Int> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5895 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5896 | Value *integer = Nucleus::createSIToFP(cast.value, Float::getType()); |
| 5897 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5898 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5899 | } |
| 5900 | |
| 5901 | Float::Float() |
| 5902 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5903 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5904 | } |
| 5905 | |
| 5906 | Float::Float(float x) |
| 5907 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5908 | storeValue(Nucleus::createConstantFloat(x)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5909 | } |
| 5910 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5911 | Float::Float(RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5912 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5913 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5914 | } |
| 5915 | |
| 5916 | Float::Float(const Float &rhs) |
| 5917 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5918 | Value *value = rhs.loadValue(); |
| 5919 | storeValue(value); |
| 5920 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5921 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5922 | Float::Float(const Reference<Float> &rhs) |
| 5923 | { |
| 5924 | Value *value = rhs.loadValue(); |
| 5925 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5926 | } |
| 5927 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5928 | RValue<Float> Float::operator=(RValue<Float> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5929 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5930 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5931 | |
| 5932 | return rhs; |
| 5933 | } |
| 5934 | |
| 5935 | RValue<Float> Float::operator=(const Float &rhs) const |
| 5936 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5937 | Value *value = rhs.loadValue(); |
| 5938 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5939 | |
| 5940 | return RValue<Float>(value); |
| 5941 | } |
| 5942 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5943 | RValue<Float> Float::operator=(const Reference<Float> &rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5944 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5945 | Value *value = rhs.loadValue(); |
| 5946 | storeValue(value); |
| 5947 | |
| 5948 | return RValue<Float>(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5949 | } |
| 5950 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5951 | RValue<Float> operator+(RValue<Float> lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5952 | { |
| 5953 | return RValue<Float>(Nucleus::createFAdd(lhs.value, rhs.value)); |
| 5954 | } |
| 5955 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5956 | RValue<Float> operator-(RValue<Float> lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5957 | { |
| 5958 | return RValue<Float>(Nucleus::createFSub(lhs.value, rhs.value)); |
| 5959 | } |
| 5960 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5961 | RValue<Float> operator*(RValue<Float> lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5962 | { |
| 5963 | return RValue<Float>(Nucleus::createFMul(lhs.value, rhs.value)); |
| 5964 | } |
| 5965 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5966 | RValue<Float> operator/(RValue<Float> lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5967 | { |
| 5968 | return RValue<Float>(Nucleus::createFDiv(lhs.value, rhs.value)); |
| 5969 | } |
| 5970 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5971 | RValue<Float> operator+=(const Float &lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5972 | { |
| 5973 | return lhs = lhs + rhs; |
| 5974 | } |
| 5975 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5976 | RValue<Float> operator-=(const Float &lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5977 | { |
| 5978 | return lhs = lhs - rhs; |
| 5979 | } |
| 5980 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5981 | RValue<Float> operator*=(const Float &lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5982 | { |
| 5983 | return lhs = lhs * rhs; |
| 5984 | } |
| 5985 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5986 | RValue<Float> operator/=(const Float &lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5987 | { |
| 5988 | return lhs = lhs / rhs; |
| 5989 | } |
| 5990 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5991 | RValue<Float> operator+(RValue<Float> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5992 | { |
| 5993 | return val; |
| 5994 | } |
| 5995 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5996 | RValue<Float> operator-(RValue<Float> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5997 | { |
| 5998 | return RValue<Float>(Nucleus::createFNeg(val.value)); |
| 5999 | } |
| 6000 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6001 | RValue<Bool> operator<(RValue<Float> lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6002 | { |
| 6003 | return RValue<Bool>(Nucleus::createFCmpOLT(lhs.value, rhs.value)); |
| 6004 | } |
| 6005 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6006 | RValue<Bool> operator<=(RValue<Float> lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6007 | { |
| 6008 | return RValue<Bool>(Nucleus::createFCmpOLE(lhs.value, rhs.value)); |
| 6009 | } |
| 6010 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6011 | RValue<Bool> operator>(RValue<Float> lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6012 | { |
| 6013 | return RValue<Bool>(Nucleus::createFCmpOGT(lhs.value, rhs.value)); |
| 6014 | } |
| 6015 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6016 | RValue<Bool> operator>=(RValue<Float> lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6017 | { |
| 6018 | return RValue<Bool>(Nucleus::createFCmpOGE(lhs.value, rhs.value)); |
| 6019 | } |
| 6020 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6021 | RValue<Bool> operator!=(RValue<Float> lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6022 | { |
| 6023 | return RValue<Bool>(Nucleus::createFCmpONE(lhs.value, rhs.value)); |
| 6024 | } |
| 6025 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6026 | RValue<Bool> operator==(RValue<Float> lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6027 | { |
| 6028 | return RValue<Bool>(Nucleus::createFCmpOEQ(lhs.value, rhs.value)); |
| 6029 | } |
| 6030 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6031 | RValue<Float> Abs(RValue<Float> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6032 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6033 | return IfThenElse(x > 0.0f, x, -x); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6034 | } |
| 6035 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6036 | RValue<Float> Max(RValue<Float> x, RValue<Float> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6037 | { |
| 6038 | return IfThenElse(x > y, x, y); |
| 6039 | } |
| 6040 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6041 | RValue<Float> Min(RValue<Float> x, RValue<Float> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6042 | { |
| 6043 | return IfThenElse(x < y, x, y); |
| 6044 | } |
| 6045 | |
Nicolas Capens | 05b3d66 | 2016-02-25 23:58:33 -0500 | [diff] [blame] | 6046 | RValue<Float> Rcp_pp(RValue<Float> x, bool exactAtPow2) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6047 | { |
Nicolas Capens | 05b3d66 | 2016-02-25 23:58:33 -0500 | [diff] [blame] | 6048 | if(exactAtPow2) |
| 6049 | { |
| 6050 | // rcpss uses a piecewise-linear approximation which minimizes the relative error |
| 6051 | // but is not exact at power-of-two values. Rectify by multiplying by the inverse. |
| 6052 | return x86::rcpss(x) * Float(1.0f / _mm_cvtss_f32(_mm_rcp_ss(_mm_set_ps1(1.0f)))); |
| 6053 | } |
| 6054 | else |
| 6055 | { |
| 6056 | return x86::rcpss(x); |
| 6057 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6058 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6059 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6060 | RValue<Float> RcpSqrt_pp(RValue<Float> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6061 | { |
| 6062 | return x86::rsqrtss(x); |
| 6063 | } |
| 6064 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6065 | RValue<Float> Sqrt(RValue<Float> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6066 | { |
| 6067 | return x86::sqrtss(x); |
| 6068 | } |
| 6069 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6070 | RValue<Float> Round(RValue<Float> x) |
| 6071 | { |
| 6072 | if(CPUID::supportsSSE4_1()) |
| 6073 | { |
| 6074 | return x86::roundss(x, 0); |
| 6075 | } |
| 6076 | else |
| 6077 | { |
| 6078 | return Float4(Round(Float4(x))).x; |
| 6079 | } |
| 6080 | } |
| 6081 | |
| 6082 | RValue<Float> Trunc(RValue<Float> x) |
| 6083 | { |
| 6084 | if(CPUID::supportsSSE4_1()) |
| 6085 | { |
| 6086 | return x86::roundss(x, 3); |
| 6087 | } |
| 6088 | else |
| 6089 | { |
| 6090 | return Float(Int(x)); // Rounded toward zero |
| 6091 | } |
| 6092 | } |
| 6093 | |
| 6094 | RValue<Float> Frac(RValue<Float> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6095 | { |
| 6096 | if(CPUID::supportsSSE4_1()) |
| 6097 | { |
| 6098 | return x - x86::floorss(x); |
| 6099 | } |
| 6100 | else |
| 6101 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6102 | return Float4(Frac(Float4(x))).x; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6103 | } |
| 6104 | } |
| 6105 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6106 | RValue<Float> Floor(RValue<Float> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6107 | { |
| 6108 | if(CPUID::supportsSSE4_1()) |
| 6109 | { |
| 6110 | return x86::floorss(x); |
| 6111 | } |
| 6112 | else |
| 6113 | { |
| 6114 | return Float4(Floor(Float4(x))).x; |
| 6115 | } |
| 6116 | } |
| 6117 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6118 | RValue<Float> Ceil(RValue<Float> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6119 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6120 | if(CPUID::supportsSSE4_1()) |
| 6121 | { |
| 6122 | return x86::ceilss(x); |
| 6123 | } |
| 6124 | else |
| 6125 | { |
| 6126 | return Float4(Ceil(Float4(x))).x; |
| 6127 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6128 | } |
| 6129 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6130 | Type *Float::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6131 | { |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 6132 | return T(llvm::Type::getFloatTy(*::context)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6133 | } |
| 6134 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6135 | Float2::Float2(RValue<Float4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6136 | { |
| 6137 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6138 | |
Nicolas Capens | 2200878 | 2016-10-20 01:11:47 -0400 | [diff] [blame] | 6139 | Value *int64x2 = Nucleus::createBitCast(cast.value, T(VectorType::get(Long::getType(), 2))); |
Nicolas Capens | e95d534 | 2016-09-30 11:37:28 -0400 | [diff] [blame] | 6140 | Value *int64 = Nucleus::createExtractElement(int64x2, Long::getType(), 0); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6141 | Value *float2 = Nucleus::createBitCast(int64, Float2::getType()); |
| 6142 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6143 | storeValue(float2); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6144 | } |
| 6145 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6146 | Type *Float2::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6147 | { |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 6148 | return T(VectorType::get(Float::getType(), 2)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6149 | } |
| 6150 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6151 | Float4::Float4(RValue<Byte4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6152 | { |
| 6153 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6154 | |
| 6155 | #if 0 |
| 6156 | Value *xyzw = Nucleus::createUIToFP(cast.value, Float4::getType()); // FIXME: Crashes |
| 6157 | #elif 0 |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6158 | Value *vector = loadValue(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6159 | |
| 6160 | Value *i8x = Nucleus::createExtractElement(cast.value, 0); |
| 6161 | Value *f32x = Nucleus::createUIToFP(i8x, Float::getType()); |
| 6162 | Value *x = Nucleus::createInsertElement(vector, f32x, 0); |
| 6163 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 6164 | Value *i8y = Nucleus::createExtractElement(cast.value, V(Nucleus::createConstantInt(1))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6165 | Value *f32y = Nucleus::createUIToFP(i8y, Float::getType()); |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 6166 | Value *xy = Nucleus::createInsertElement(x, f32y, V(Nucleus::createConstantInt(1))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6167 | |
| 6168 | Value *i8z = Nucleus::createExtractElement(cast.value, Nucleus::createConstantInt(2)); |
| 6169 | Value *f32z = Nucleus::createUIToFP(i8z, Float::getType()); |
| 6170 | Value *xyz = Nucleus::createInsertElement(xy, f32z, Nucleus::createConstantInt(2)); |
| 6171 | |
| 6172 | Value *i8w = Nucleus::createExtractElement(cast.value, Nucleus::createConstantInt(3)); |
| 6173 | Value *f32w = Nucleus::createUIToFP(i8w, Float::getType()); |
| 6174 | Value *xyzw = Nucleus::createInsertElement(xyz, f32w, Nucleus::createConstantInt(3)); |
| 6175 | #else |
Meng-Lin Wu | 601d005 | 2016-06-10 14:18:41 -0400 | [diff] [blame] | 6176 | Value *a = Int4(cast).loadValue(); |
| 6177 | Value *xyzw = Nucleus::createSIToFP(a, Float4::getType()); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6178 | #endif |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6179 | |
| 6180 | storeValue(xyzw); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6181 | } |
| 6182 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6183 | Float4::Float4(RValue<SByte4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6184 | { |
| 6185 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6186 | |
| 6187 | #if 0 |
| 6188 | Value *xyzw = Nucleus::createSIToFP(cast.value, Float4::getType()); // FIXME: Crashes |
| 6189 | #elif 0 |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6190 | Value *vector = loadValue(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6191 | |
| 6192 | Value *i8x = Nucleus::createExtractElement(cast.value, 0); |
| 6193 | Value *f32x = Nucleus::createSIToFP(i8x, Float::getType()); |
| 6194 | Value *x = Nucleus::createInsertElement(vector, f32x, 0); |
| 6195 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 6196 | Value *i8y = Nucleus::createExtractElement(cast.value, V(Nucleus::createConstantInt(1))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6197 | Value *f32y = Nucleus::createSIToFP(i8y, Float::getType()); |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 6198 | Value *xy = Nucleus::createInsertElement(x, f32y, V(Nucleus::createConstantInt(1))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6199 | |
| 6200 | Value *i8z = Nucleus::createExtractElement(cast.value, Nucleus::createConstantInt(2)); |
| 6201 | Value *f32z = Nucleus::createSIToFP(i8z, Float::getType()); |
| 6202 | Value *xyz = Nucleus::createInsertElement(xy, f32z, Nucleus::createConstantInt(2)); |
| 6203 | |
| 6204 | Value *i8w = Nucleus::createExtractElement(cast.value, Nucleus::createConstantInt(3)); |
| 6205 | Value *f32w = Nucleus::createSIToFP(i8w, Float::getType()); |
| 6206 | Value *xyzw = Nucleus::createInsertElement(xyz, f32w, Nucleus::createConstantInt(3)); |
| 6207 | #else |
Meng-Lin Wu | 601d005 | 2016-06-10 14:18:41 -0400 | [diff] [blame] | 6208 | Value *a = Int4(cast).loadValue(); |
| 6209 | Value *xyzw = Nucleus::createSIToFP(a, Float4::getType()); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6210 | #endif |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6211 | |
| 6212 | storeValue(xyzw); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6213 | } |
| 6214 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6215 | Float4::Float4(RValue<Short4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6216 | { |
| 6217 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6218 | |
Alexis Hetu | 2aa852f | 2015-10-14 16:32:39 -0400 | [diff] [blame] | 6219 | Int4 c(cast); |
| 6220 | storeValue(Nucleus::createSIToFP(RValue<Int4>(c).value, Float4::getType())); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6221 | } |
| 6222 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6223 | Float4::Float4(RValue<UShort4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6224 | { |
| 6225 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6226 | |
Alexis Hetu | 2aa852f | 2015-10-14 16:32:39 -0400 | [diff] [blame] | 6227 | Int4 c(cast); |
| 6228 | storeValue(Nucleus::createSIToFP(RValue<Int4>(c).value, Float4::getType())); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6229 | } |
| 6230 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6231 | Float4::Float4(RValue<Int4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6232 | { |
| 6233 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6234 | |
| 6235 | Value *xyzw = Nucleus::createSIToFP(cast.value, Float4::getType()); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6236 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6237 | storeValue(xyzw); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6238 | } |
| 6239 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6240 | Float4::Float4(RValue<UInt4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6241 | { |
| 6242 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6243 | |
| 6244 | Value *xyzw = Nucleus::createUIToFP(cast.value, Float4::getType()); |
| 6245 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6246 | storeValue(xyzw); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6247 | } |
| 6248 | |
| 6249 | Float4::Float4() |
| 6250 | { |
| 6251 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6252 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6253 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6254 | Float4::Float4(float xyzw) |
| 6255 | { |
| 6256 | constant(xyzw, xyzw, xyzw, xyzw); |
| 6257 | } |
| 6258 | |
| 6259 | Float4::Float4(float x, float yzw) |
| 6260 | { |
| 6261 | constant(x, yzw, yzw, yzw); |
| 6262 | } |
| 6263 | |
| 6264 | Float4::Float4(float x, float y, float zw) |
| 6265 | { |
| 6266 | constant(x, y, zw, zw); |
| 6267 | } |
| 6268 | |
| 6269 | Float4::Float4(float x, float y, float z, float w) |
| 6270 | { |
| 6271 | constant(x, y, z, w); |
| 6272 | } |
| 6273 | |
| 6274 | void Float4::constant(float x, float y, float z, float w) |
| 6275 | { |
| 6276 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6277 | |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 6278 | double constantVector[4] = {x, y, z, w}; |
| 6279 | storeValue(Nucleus::createConstantVector(constantVector, getType())); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6280 | } |
| 6281 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6282 | Float4::Float4(RValue<Float4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6283 | { |
| 6284 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6285 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6286 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6287 | } |
| 6288 | |
| 6289 | Float4::Float4(const Float4 &rhs) |
| 6290 | { |
| 6291 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6292 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6293 | Value *value = rhs.loadValue(); |
| 6294 | storeValue(value); |
| 6295 | } |
| 6296 | |
| 6297 | Float4::Float4(const Reference<Float4> &rhs) |
| 6298 | { |
| 6299 | xyzw.parent = this; |
| 6300 | |
| 6301 | Value *value = rhs.loadValue(); |
| 6302 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6303 | } |
| 6304 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6305 | Float4::Float4(RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6306 | { |
| 6307 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6308 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6309 | Value *vector = loadValue(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6310 | Value *insert = Nucleus::createInsertElement(vector, rhs.value, 0); |
| 6311 | |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 6312 | int swizzle[4] = {0, 0, 0, 0}; |
| 6313 | Value *replicate = Nucleus::createShuffleVector(insert, insert, swizzle); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6314 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6315 | storeValue(replicate); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6316 | } |
| 6317 | |
| 6318 | Float4::Float4(const Float &rhs) |
| 6319 | { |
| 6320 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6321 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6322 | *this = RValue<Float>(rhs.loadValue()); |
| 6323 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6324 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6325 | Float4::Float4(const Reference<Float> &rhs) |
| 6326 | { |
| 6327 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6328 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6329 | *this = RValue<Float>(rhs.loadValue()); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6330 | } |
| 6331 | |
| 6332 | RValue<Float4> Float4::operator=(float x) const |
| 6333 | { |
| 6334 | return *this = Float4(x, x, x, x); |
| 6335 | } |
| 6336 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6337 | RValue<Float4> Float4::operator=(RValue<Float4> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6338 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6339 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6340 | |
| 6341 | return rhs; |
| 6342 | } |
| 6343 | |
| 6344 | RValue<Float4> Float4::operator=(const Float4 &rhs) const |
| 6345 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6346 | Value *value = rhs.loadValue(); |
| 6347 | storeValue(value); |
| 6348 | |
| 6349 | return RValue<Float4>(value); |
| 6350 | } |
| 6351 | |
| 6352 | RValue<Float4> Float4::operator=(const Reference<Float4> &rhs) const |
| 6353 | { |
| 6354 | Value *value = rhs.loadValue(); |
| 6355 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6356 | |
| 6357 | return RValue<Float4>(value); |
| 6358 | } |
| 6359 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6360 | RValue<Float4> Float4::operator=(RValue<Float> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6361 | { |
| 6362 | return *this = Float4(rhs); |
| 6363 | } |
| 6364 | |
| 6365 | RValue<Float4> Float4::operator=(const Float &rhs) const |
| 6366 | { |
| 6367 | return *this = Float4(rhs); |
| 6368 | } |
| 6369 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6370 | RValue<Float4> Float4::operator=(const Reference<Float> &rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6371 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6372 | return *this = Float4(rhs); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6373 | } |
| 6374 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6375 | RValue<Float4> operator+(RValue<Float4> lhs, RValue<Float4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6376 | { |
| 6377 | return RValue<Float4>(Nucleus::createFAdd(lhs.value, rhs.value)); |
| 6378 | } |
| 6379 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6380 | RValue<Float4> operator-(RValue<Float4> lhs, RValue<Float4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6381 | { |
| 6382 | return RValue<Float4>(Nucleus::createFSub(lhs.value, rhs.value)); |
| 6383 | } |
| 6384 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6385 | RValue<Float4> operator*(RValue<Float4> lhs, RValue<Float4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6386 | { |
| 6387 | return RValue<Float4>(Nucleus::createFMul(lhs.value, rhs.value)); |
| 6388 | } |
| 6389 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6390 | RValue<Float4> operator/(RValue<Float4> lhs, RValue<Float4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6391 | { |
| 6392 | return RValue<Float4>(Nucleus::createFDiv(lhs.value, rhs.value)); |
| 6393 | } |
| 6394 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6395 | RValue<Float4> operator%(RValue<Float4> lhs, RValue<Float4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6396 | { |
| 6397 | return RValue<Float4>(Nucleus::createFRem(lhs.value, rhs.value)); |
| 6398 | } |
| 6399 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6400 | RValue<Float4> operator+=(const Float4 &lhs, RValue<Float4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6401 | { |
| 6402 | return lhs = lhs + rhs; |
| 6403 | } |
| 6404 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6405 | RValue<Float4> operator-=(const Float4 &lhs, RValue<Float4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6406 | { |
| 6407 | return lhs = lhs - rhs; |
| 6408 | } |
| 6409 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6410 | RValue<Float4> operator*=(const Float4 &lhs, RValue<Float4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6411 | { |
| 6412 | return lhs = lhs * rhs; |
| 6413 | } |
| 6414 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6415 | RValue<Float4> operator/=(const Float4 &lhs, RValue<Float4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6416 | { |
| 6417 | return lhs = lhs / rhs; |
| 6418 | } |
| 6419 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6420 | RValue<Float4> operator%=(const Float4 &lhs, RValue<Float4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6421 | { |
| 6422 | return lhs = lhs % rhs; |
| 6423 | } |
| 6424 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6425 | RValue<Float4> operator+(RValue<Float4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6426 | { |
| 6427 | return val; |
| 6428 | } |
| 6429 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6430 | RValue<Float4> operator-(RValue<Float4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6431 | { |
| 6432 | return RValue<Float4>(Nucleus::createFNeg(val.value)); |
| 6433 | } |
| 6434 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6435 | RValue<Float4> Abs(RValue<Float4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6436 | { |
| 6437 | Value *vector = Nucleus::createBitCast(x.value, Int4::getType()); |
Nicolas Capens | 13ac232 | 2016-10-13 14:52:12 -0400 | [diff] [blame] | 6438 | int64_t constantVector[4] = {0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF}; |
| 6439 | Value *result = Nucleus::createAnd(vector, V(Nucleus::createConstantVector(constantVector, Int4::getType()))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6440 | |
| 6441 | return RValue<Float4>(Nucleus::createBitCast(result, Float4::getType())); |
| 6442 | } |
| 6443 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6444 | RValue<Float4> Max(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6445 | { |
| 6446 | return x86::maxps(x, y); |
| 6447 | } |
| 6448 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6449 | RValue<Float4> Min(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6450 | { |
| 6451 | return x86::minps(x, y); |
| 6452 | } |
| 6453 | |
Nicolas Capens | 05b3d66 | 2016-02-25 23:58:33 -0500 | [diff] [blame] | 6454 | RValue<Float4> Rcp_pp(RValue<Float4> x, bool exactAtPow2) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6455 | { |
Nicolas Capens | 05b3d66 | 2016-02-25 23:58:33 -0500 | [diff] [blame] | 6456 | if(exactAtPow2) |
| 6457 | { |
| 6458 | // rcpps uses a piecewise-linear approximation which minimizes the relative error |
| 6459 | // but is not exact at power-of-two values. Rectify by multiplying by the inverse. |
| 6460 | return x86::rcpps(x) * Float4(1.0f / _mm_cvtss_f32(_mm_rcp_ss(_mm_set_ps1(1.0f)))); |
| 6461 | } |
| 6462 | else |
| 6463 | { |
| 6464 | return x86::rcpps(x); |
| 6465 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6466 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6467 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6468 | RValue<Float4> RcpSqrt_pp(RValue<Float4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6469 | { |
| 6470 | return x86::rsqrtps(x); |
| 6471 | } |
| 6472 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6473 | RValue<Float4> Sqrt(RValue<Float4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6474 | { |
| 6475 | return x86::sqrtps(x); |
| 6476 | } |
| 6477 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6478 | RValue<Float4> Insert(const Float4 &val, RValue<Float> element, int i) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6479 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 6480 | Value *value = val.loadValue(); |
| 6481 | Value *insert = Nucleus::createInsertElement(value, element.value, i); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6482 | |
| 6483 | val = RValue<Float4>(insert); |
| 6484 | |
| 6485 | return val; |
| 6486 | } |
| 6487 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6488 | RValue<Float> Extract(RValue<Float4> x, int i) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6489 | { |
Nicolas Capens | e95d534 | 2016-09-30 11:37:28 -0400 | [diff] [blame] | 6490 | return RValue<Float>(Nucleus::createExtractElement(x.value, Float::getType(), i)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6491 | } |
| 6492 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6493 | RValue<Float4> Swizzle(RValue<Float4> x, unsigned char select) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6494 | { |
Nicolas Capens | e95d534 | 2016-09-30 11:37:28 -0400 | [diff] [blame] | 6495 | return RValue<Float4>(createSwizzle4(x.value, select)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6496 | } |
| 6497 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6498 | RValue<Float4> ShuffleLowHigh(RValue<Float4> x, RValue<Float4> y, unsigned char imm) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6499 | { |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 6500 | int shuffle[4] = |
| 6501 | { |
| 6502 | ((imm >> 0) & 0x03) + 0, |
| 6503 | ((imm >> 2) & 0x03) + 0, |
| 6504 | ((imm >> 4) & 0x03) + 4, |
| 6505 | ((imm >> 6) & 0x03) + 4, |
| 6506 | }; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6507 | |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 6508 | return RValue<Float4>(Nucleus::createShuffleVector(x.value, y.value, shuffle)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6509 | } |
| 6510 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6511 | RValue<Float4> UnpackLow(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6512 | { |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 6513 | int shuffle[4] = {0, 4, 1, 5}; |
| 6514 | return RValue<Float4>(Nucleus::createShuffleVector(x.value, y.value, shuffle)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6515 | } |
| 6516 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6517 | RValue<Float4> UnpackHigh(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6518 | { |
Nicolas Capens | e89cd58 | 2016-09-30 14:23:47 -0400 | [diff] [blame] | 6519 | int shuffle[4] = {2, 6, 3, 7}; |
| 6520 | return RValue<Float4>(Nucleus::createShuffleVector(x.value, y.value, shuffle)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6521 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6522 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6523 | RValue<Float4> Mask(Float4 &lhs, RValue<Float4> rhs, unsigned char select) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6524 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6525 | Value *vector = lhs.loadValue(); |
Nicolas Capens | e95d534 | 2016-09-30 11:37:28 -0400 | [diff] [blame] | 6526 | Value *shuffle = createMask4(vector, rhs.value, select); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6527 | lhs.storeValue(shuffle); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6528 | |
| 6529 | return RValue<Float4>(shuffle); |
| 6530 | } |
| 6531 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6532 | RValue<Int> SignMask(RValue<Float4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6533 | { |
| 6534 | return x86::movmskps(x); |
| 6535 | } |
| 6536 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6537 | RValue<Int4> CmpEQ(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6538 | { |
| 6539 | // return As<Int4>(x86::cmpeqps(x, y)); |
| 6540 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOEQ(x.value, y.value), Int4::getType())); |
| 6541 | } |
| 6542 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6543 | RValue<Int4> CmpLT(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6544 | { |
| 6545 | // return As<Int4>(x86::cmpltps(x, y)); |
| 6546 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOLT(x.value, y.value), Int4::getType())); |
| 6547 | } |
| 6548 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6549 | RValue<Int4> CmpLE(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6550 | { |
| 6551 | // return As<Int4>(x86::cmpleps(x, y)); |
| 6552 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOLE(x.value, y.value), Int4::getType())); |
| 6553 | } |
| 6554 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6555 | RValue<Int4> CmpNEQ(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6556 | { |
| 6557 | // return As<Int4>(x86::cmpneqps(x, y)); |
| 6558 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpONE(x.value, y.value), Int4::getType())); |
| 6559 | } |
| 6560 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6561 | RValue<Int4> CmpNLT(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6562 | { |
| 6563 | // return As<Int4>(x86::cmpnltps(x, y)); |
| 6564 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOGE(x.value, y.value), Int4::getType())); |
| 6565 | } |
| 6566 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6567 | RValue<Int4> CmpNLE(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6568 | { |
| 6569 | // return As<Int4>(x86::cmpnleps(x, y)); |
| 6570 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOGT(x.value, y.value), Int4::getType())); |
| 6571 | } |
| 6572 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6573 | RValue<Float4> Round(RValue<Float4> x) |
| 6574 | { |
| 6575 | if(CPUID::supportsSSE4_1()) |
| 6576 | { |
| 6577 | return x86::roundps(x, 0); |
| 6578 | } |
| 6579 | else |
| 6580 | { |
| 6581 | return Float4(RoundInt(x)); |
| 6582 | } |
| 6583 | } |
| 6584 | |
| 6585 | RValue<Float4> Trunc(RValue<Float4> x) |
| 6586 | { |
| 6587 | if(CPUID::supportsSSE4_1()) |
| 6588 | { |
| 6589 | return x86::roundps(x, 3); |
| 6590 | } |
| 6591 | else |
| 6592 | { |
| 6593 | return Float4(Int4(x)); // Rounded toward zero |
| 6594 | } |
| 6595 | } |
| 6596 | |
| 6597 | RValue<Float4> Frac(RValue<Float4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6598 | { |
| 6599 | if(CPUID::supportsSSE4_1()) |
| 6600 | { |
| 6601 | return x - x86::floorps(x); |
| 6602 | } |
| 6603 | else |
| 6604 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6605 | Float4 frc = x - Float4(Int4(x)); // Signed fractional part |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6606 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6607 | return frc + As<Float4>(As<Int4>(CmpNLE(Float4(0.0f), frc)) & As<Int4>(Float4(1, 1, 1, 1))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6608 | } |
| 6609 | } |
| 6610 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6611 | RValue<Float4> Floor(RValue<Float4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6612 | { |
| 6613 | if(CPUID::supportsSSE4_1()) |
| 6614 | { |
| 6615 | return x86::floorps(x); |
| 6616 | } |
| 6617 | else |
| 6618 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6619 | return x - Frac(x); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6620 | } |
| 6621 | } |
| 6622 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6623 | RValue<Float4> Ceil(RValue<Float4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6624 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6625 | if(CPUID::supportsSSE4_1()) |
| 6626 | { |
| 6627 | return x86::ceilps(x); |
| 6628 | } |
| 6629 | else |
| 6630 | { |
| 6631 | return -Floor(-x); |
| 6632 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6633 | } |
| 6634 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6635 | Type *Float4::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6636 | { |
Nicolas Capens | ac23012 | 2016-09-20 14:30:06 -0400 | [diff] [blame] | 6637 | return T(VectorType::get(Float::getType(), 4)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6638 | } |
| 6639 | |
Nicolas Capens | 81f1830 | 2016-01-14 09:32:35 -0500 | [diff] [blame] | 6640 | RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, int offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6641 | { |
Nicolas Capens | 6d73871 | 2016-09-30 04:15:22 -0400 | [diff] [blame] | 6642 | return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value, Byte::getType(), V(Nucleus::createConstantInt(offset)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6643 | } |
| 6644 | |
Nicolas Capens | 81f1830 | 2016-01-14 09:32:35 -0500 | [diff] [blame] | 6645 | RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<Int> offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6646 | { |
Nicolas Capens | 6d73871 | 2016-09-30 04:15:22 -0400 | [diff] [blame] | 6647 | return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value, Byte::getType(), offset.value)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6648 | } |
| 6649 | |
Nicolas Capens | 81f1830 | 2016-01-14 09:32:35 -0500 | [diff] [blame] | 6650 | RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<UInt> offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6651 | { |
Nicolas Capens | 6d73871 | 2016-09-30 04:15:22 -0400 | [diff] [blame] | 6652 | return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value, Byte::getType(), offset.value)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6653 | } |
| 6654 | |
Nicolas Capens | 81f1830 | 2016-01-14 09:32:35 -0500 | [diff] [blame] | 6655 | RValue<Pointer<Byte>> operator+=(const Pointer<Byte> &lhs, int offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6656 | { |
| 6657 | return lhs = lhs + offset; |
| 6658 | } |
| 6659 | |
Nicolas Capens | 81f1830 | 2016-01-14 09:32:35 -0500 | [diff] [blame] | 6660 | RValue<Pointer<Byte>> operator+=(const Pointer<Byte> &lhs, RValue<Int> offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6661 | { |
| 6662 | return lhs = lhs + offset; |
| 6663 | } |
| 6664 | |
Nicolas Capens | 81f1830 | 2016-01-14 09:32:35 -0500 | [diff] [blame] | 6665 | RValue<Pointer<Byte>> operator+=(const Pointer<Byte> &lhs, RValue<UInt> offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6666 | { |
| 6667 | return lhs = lhs + offset; |
| 6668 | } |
| 6669 | |
Nicolas Capens | 81f1830 | 2016-01-14 09:32:35 -0500 | [diff] [blame] | 6670 | RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, int offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6671 | { |
| 6672 | return lhs + -offset; |
| 6673 | } |
| 6674 | |
Nicolas Capens | 81f1830 | 2016-01-14 09:32:35 -0500 | [diff] [blame] | 6675 | RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, RValue<Int> offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6676 | { |
| 6677 | return lhs + -offset; |
| 6678 | } |
| 6679 | |
Nicolas Capens | 81f1830 | 2016-01-14 09:32:35 -0500 | [diff] [blame] | 6680 | RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, RValue<UInt> offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6681 | { |
| 6682 | return lhs + -offset; |
| 6683 | } |
| 6684 | |
Nicolas Capens | 81f1830 | 2016-01-14 09:32:35 -0500 | [diff] [blame] | 6685 | RValue<Pointer<Byte>> operator-=(const Pointer<Byte> &lhs, int offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6686 | { |
| 6687 | return lhs = lhs - offset; |
| 6688 | } |
| 6689 | |
Nicolas Capens | 81f1830 | 2016-01-14 09:32:35 -0500 | [diff] [blame] | 6690 | RValue<Pointer<Byte>> operator-=(const Pointer<Byte> &lhs, RValue<Int> offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6691 | { |
| 6692 | return lhs = lhs - offset; |
| 6693 | } |
| 6694 | |
Nicolas Capens | 81f1830 | 2016-01-14 09:32:35 -0500 | [diff] [blame] | 6695 | RValue<Pointer<Byte>> operator-=(const Pointer<Byte> &lhs, RValue<UInt> offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6696 | { |
| 6697 | return lhs = lhs - offset; |
| 6698 | } |
| 6699 | |
| 6700 | void Return() |
| 6701 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6702 | Nucleus::createRetVoid(); |
| 6703 | Nucleus::setInsertBlock(Nucleus::createBasicBlock()); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6704 | Nucleus::createUnreachable(); |
| 6705 | } |
| 6706 | |
| 6707 | void Return(bool ret) |
| 6708 | { |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 6709 | Nucleus::createRet(V(Nucleus::createConstantBool(ret))); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6710 | Nucleus::setInsertBlock(Nucleus::createBasicBlock()); |
| 6711 | Nucleus::createUnreachable(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6712 | } |
| 6713 | |
| 6714 | void Return(const Int &ret) |
| 6715 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6716 | Nucleus::createRet(ret.loadValue()); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6717 | Nucleus::setInsertBlock(Nucleus::createBasicBlock()); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6718 | Nucleus::createUnreachable(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6719 | } |
| 6720 | |
| 6721 | BasicBlock *beginLoop() |
| 6722 | { |
| 6723 | BasicBlock *loopBB = Nucleus::createBasicBlock(); |
| 6724 | |
| 6725 | Nucleus::createBr(loopBB); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6726 | Nucleus::setInsertBlock(loopBB); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6727 | |
| 6728 | return loopBB; |
| 6729 | } |
| 6730 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6731 | bool branch(RValue<Bool> cmp, BasicBlock *bodyBB, BasicBlock *endBB) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6732 | { |
| 6733 | Nucleus::createCondBr(cmp.value, bodyBB, endBB); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6734 | Nucleus::setInsertBlock(bodyBB); |
| 6735 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6736 | return true; |
| 6737 | } |
| 6738 | |
Nicolas Capens | 9ed1a18 | 2016-10-24 09:52:23 -0400 | [diff] [blame^] | 6739 | void endIf(BasicBlock *falseBB) |
| 6740 | { |
| 6741 | ::falseBB = falseBB; |
| 6742 | } |
| 6743 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6744 | bool elseBlock(BasicBlock *falseBB) |
| 6745 | { |
Nicolas Capens | 9ed1a18 | 2016-10-24 09:52:23 -0400 | [diff] [blame^] | 6746 | assert(falseBB && "Else not preceded by If"); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6747 | falseBB->back().eraseFromParent(); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6748 | Nucleus::setInsertBlock(falseBB); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6749 | |
| 6750 | return true; |
| 6751 | } |
| 6752 | |
Nicolas Capens | 9ed1a18 | 2016-10-24 09:52:23 -0400 | [diff] [blame^] | 6753 | BasicBlock *beginElse() |
| 6754 | { |
| 6755 | BasicBlock *falseBB = ::falseBB; |
| 6756 | ::falseBB = nullptr; |
| 6757 | |
| 6758 | return falseBB; |
| 6759 | } |
| 6760 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6761 | RValue<Long> Ticks() |
| 6762 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 6763 | llvm::Function *rdtsc = Intrinsic::getDeclaration(::module, Intrinsic::readcyclecounter); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6764 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 6765 | return RValue<Long>(V(::builder->CreateCall(rdtsc))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6766 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6767 | } |
| 6768 | |
| 6769 | namespace sw |
| 6770 | { |
| 6771 | namespace x86 |
| 6772 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6773 | RValue<Int> cvtss2si(RValue<Float> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6774 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 6775 | llvm::Function *cvtss2si = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse_cvtss2si); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6776 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6777 | Float4 vector; |
| 6778 | vector.x = val; |
| 6779 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 6780 | return RValue<Int>(V(::builder->CreateCall(cvtss2si, RValue<Float4>(vector).value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6781 | } |
| 6782 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6783 | RValue<Int2> cvtps2pi(RValue<Float4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6784 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 6785 | llvm::Function *cvtps2pi = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse_cvtps2pi); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6786 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 6787 | return RValue<Int2>(V(::builder->CreateCall(cvtps2pi, val.value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6788 | } |
| 6789 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6790 | RValue<Int2> cvttps2pi(RValue<Float4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6791 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 6792 | llvm::Function *cvttps2pi = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse_cvttps2pi); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6793 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 6794 | return RValue<Int2>(V(::builder->CreateCall(cvttps2pi, val.value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6795 | } |
| 6796 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6797 | RValue<Int4> cvtps2dq(RValue<Float4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6798 | { |
| 6799 | if(CPUID::supportsSSE2()) |
| 6800 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 6801 | llvm::Function *cvtps2dq = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse2_cvtps2dq); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6802 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 6803 | return RValue<Int4>(V(::builder->CreateCall(cvtps2dq, val.value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6804 | } |
| 6805 | else |
| 6806 | { |
| 6807 | Int2 lo = x86::cvtps2pi(val); |
| 6808 | Int2 hi = x86::cvtps2pi(Swizzle(val, 0xEE)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6809 | |
Nicolas Capens | 62abb55 | 2016-01-05 12:03:47 -0500 | [diff] [blame] | 6810 | return Int4(lo, hi); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6811 | } |
| 6812 | } |
| 6813 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6814 | RValue<Float> rcpss(RValue<Float> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6815 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 6816 | llvm::Function *rcpss = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse_rcp_ss); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6817 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 6818 | Value *vector = Nucleus::createInsertElement(V(UndefValue::get(Float4::getType())), val.value, 0); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6819 | |
Nicolas Capens | e95d534 | 2016-09-30 11:37:28 -0400 | [diff] [blame] | 6820 | return RValue<Float>(Nucleus::createExtractElement(V(::builder->CreateCall(rcpss, vector)), Float::getType(), 0)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6821 | } |
| 6822 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6823 | RValue<Float> sqrtss(RValue<Float> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6824 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 6825 | llvm::Function *sqrtss = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse_sqrt_ss); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6826 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 6827 | Value *vector = Nucleus::createInsertElement(V(UndefValue::get(Float4::getType())), val.value, 0); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6828 | |
Nicolas Capens | e95d534 | 2016-09-30 11:37:28 -0400 | [diff] [blame] | 6829 | return RValue<Float>(Nucleus::createExtractElement(V(::builder->CreateCall(sqrtss, vector)), Float::getType(), 0)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6830 | } |
| 6831 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6832 | RValue<Float> rsqrtss(RValue<Float> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6833 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 6834 | llvm::Function *rsqrtss = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse_rsqrt_ss); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6835 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 6836 | Value *vector = Nucleus::createInsertElement(V(UndefValue::get(Float4::getType())), val.value, 0); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6837 | |
Nicolas Capens | e95d534 | 2016-09-30 11:37:28 -0400 | [diff] [blame] | 6838 | return RValue<Float>(Nucleus::createExtractElement(V(::builder->CreateCall(rsqrtss, vector)), Float::getType(), 0)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6839 | } |
| 6840 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6841 | RValue<Float4> rcpps(RValue<Float4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6842 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 6843 | llvm::Function *rcpps = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse_rcp_ps); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6844 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 6845 | return RValue<Float4>(V(::builder->CreateCall(rcpps, val.value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6846 | } |
| 6847 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6848 | RValue<Float4> sqrtps(RValue<Float4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6849 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 6850 | llvm::Function *sqrtps = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse_sqrt_ps); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6851 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 6852 | return RValue<Float4>(V(::builder->CreateCall(sqrtps, val.value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6853 | } |
| 6854 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6855 | RValue<Float4> rsqrtps(RValue<Float4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6856 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 6857 | llvm::Function *rsqrtps = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse_rsqrt_ps); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6858 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 6859 | return RValue<Float4>(V(::builder->CreateCall(rsqrtps, val.value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6860 | } |
| 6861 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6862 | RValue<Float4> maxps(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6863 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 6864 | llvm::Function *maxps = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse_max_ps); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6865 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 6866 | return RValue<Float4>(V(::builder->CreateCall2(maxps, x.value, y.value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6867 | } |
| 6868 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6869 | RValue<Float4> minps(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6870 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 6871 | llvm::Function *minps = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse_min_ps); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6872 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 6873 | return RValue<Float4>(V(::builder->CreateCall2(minps, x.value, y.value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6874 | } |
| 6875 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6876 | RValue<Float> roundss(RValue<Float> val, unsigned char imm) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6877 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 6878 | llvm::Function *roundss = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse41_round_ss); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6879 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 6880 | Value *undef = V(UndefValue::get(Float4::getType())); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6881 | Value *vector = Nucleus::createInsertElement(undef, val.value, 0); |
| 6882 | |
Nicolas Capens | e95d534 | 2016-09-30 11:37:28 -0400 | [diff] [blame] | 6883 | return RValue<Float>(Nucleus::createExtractElement(V(::builder->CreateCall3(roundss, undef, vector, V(Nucleus::createConstantInt(imm)))), Float::getType(), 0)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6884 | } |
| 6885 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6886 | RValue<Float> floorss(RValue<Float> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6887 | { |
| 6888 | return roundss(val, 1); |
| 6889 | } |
| 6890 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6891 | RValue<Float> ceilss(RValue<Float> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6892 | { |
| 6893 | return roundss(val, 2); |
| 6894 | } |
| 6895 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6896 | RValue<Float4> roundps(RValue<Float4> val, unsigned char imm) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6897 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 6898 | llvm::Function *roundps = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse41_round_ps); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6899 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 6900 | return RValue<Float4>(V(::builder->CreateCall2(roundps, val.value, V(Nucleus::createConstantInt(imm))))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6901 | } |
| 6902 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6903 | RValue<Float4> floorps(RValue<Float4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6904 | { |
| 6905 | return roundps(val, 1); |
| 6906 | } |
| 6907 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6908 | RValue<Float4> ceilps(RValue<Float4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6909 | { |
| 6910 | return roundps(val, 2); |
| 6911 | } |
| 6912 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6913 | RValue<Float4> cmpps(RValue<Float4> x, RValue<Float4> y, unsigned char imm) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6914 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 6915 | llvm::Function *cmpps = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse_cmp_ps); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6916 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 6917 | return RValue<Float4>(V(::builder->CreateCall3(cmpps, x.value, y.value, V(Nucleus::createConstantByte(imm))))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6918 | } |
| 6919 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6920 | RValue<Float4> cmpeqps(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6921 | { |
| 6922 | return cmpps(x, y, 0); |
| 6923 | } |
| 6924 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6925 | RValue<Float4> cmpltps(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6926 | { |
| 6927 | return cmpps(x, y, 1); |
| 6928 | } |
| 6929 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6930 | RValue<Float4> cmpleps(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6931 | { |
| 6932 | return cmpps(x, y, 2); |
| 6933 | } |
| 6934 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6935 | RValue<Float4> cmpunordps(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6936 | { |
| 6937 | return cmpps(x, y, 3); |
| 6938 | } |
| 6939 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6940 | RValue<Float4> cmpneqps(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6941 | { |
| 6942 | return cmpps(x, y, 4); |
| 6943 | } |
| 6944 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6945 | RValue<Float4> cmpnltps(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6946 | { |
| 6947 | return cmpps(x, y, 5); |
| 6948 | } |
| 6949 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6950 | RValue<Float4> cmpnleps(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6951 | { |
| 6952 | return cmpps(x, y, 6); |
| 6953 | } |
| 6954 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6955 | RValue<Float4> cmpordps(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6956 | { |
| 6957 | return cmpps(x, y, 7); |
| 6958 | } |
| 6959 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6960 | RValue<Float> cmpss(RValue<Float> x, RValue<Float> y, unsigned char imm) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6961 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 6962 | llvm::Function *cmpss = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse_cmp_ss); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6963 | |
Nicolas Capens | 1933654 | 2016-09-26 10:32:29 -0400 | [diff] [blame] | 6964 | Value *vector1 = Nucleus::createInsertElement(V(UndefValue::get(Float4::getType())), x.value, 0); |
| 6965 | Value *vector2 = Nucleus::createInsertElement(V(UndefValue::get(Float4::getType())), y.value, 0); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6966 | |
Nicolas Capens | e95d534 | 2016-09-30 11:37:28 -0400 | [diff] [blame] | 6967 | return RValue<Float>(Nucleus::createExtractElement(V(::builder->CreateCall3(cmpss, vector1, vector2, V(Nucleus::createConstantByte(imm)))), Float::getType(), 0)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6968 | } |
| 6969 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6970 | RValue<Float> cmpeqss(RValue<Float> x, RValue<Float> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6971 | { |
| 6972 | return cmpss(x, y, 0); |
| 6973 | } |
| 6974 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6975 | RValue<Float> cmpltss(RValue<Float> x, RValue<Float> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6976 | { |
| 6977 | return cmpss(x, y, 1); |
| 6978 | } |
| 6979 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6980 | RValue<Float> cmpless(RValue<Float> x, RValue<Float> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6981 | { |
| 6982 | return cmpss(x, y, 2); |
| 6983 | } |
| 6984 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6985 | RValue<Float> cmpunordss(RValue<Float> x, RValue<Float> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6986 | { |
| 6987 | return cmpss(x, y, 3); |
| 6988 | } |
| 6989 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6990 | RValue<Float> cmpneqss(RValue<Float> x, RValue<Float> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6991 | { |
| 6992 | return cmpss(x, y, 4); |
| 6993 | } |
| 6994 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6995 | RValue<Float> cmpnltss(RValue<Float> x, RValue<Float> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6996 | { |
| 6997 | return cmpss(x, y, 5); |
| 6998 | } |
| 6999 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7000 | RValue<Float> cmpnless(RValue<Float> x, RValue<Float> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7001 | { |
| 7002 | return cmpss(x, y, 6); |
| 7003 | } |
| 7004 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7005 | RValue<Float> cmpordss(RValue<Float> x, RValue<Float> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7006 | { |
| 7007 | return cmpss(x, y, 7); |
| 7008 | } |
| 7009 | |
Alexis Hetu | 0f44807 | 2016-03-18 10:56:08 -0400 | [diff] [blame] | 7010 | RValue<Int4> pabsd(RValue<Int4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7011 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7012 | llvm::Function *pabsd = Intrinsic::getDeclaration(::module, Intrinsic::x86_ssse3_pabs_d_128); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7013 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7014 | return RValue<Int4>(V(::builder->CreateCall(pabsd, x.value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7015 | } |
| 7016 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7017 | RValue<Short4> paddsw(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7018 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7019 | llvm::Function *paddsw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_padds_w); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7020 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7021 | return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(paddsw, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7022 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7023 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7024 | RValue<Short4> psubsw(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7025 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7026 | llvm::Function *psubsw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psubs_w); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7027 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7028 | return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(psubsw, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7029 | } |
| 7030 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7031 | RValue<UShort4> paddusw(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7032 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7033 | llvm::Function *paddusw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_paddus_w); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7034 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7035 | return As<UShort4>(RValue<MMX>(V(::builder->CreateCall2(paddusw, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7036 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7037 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7038 | RValue<UShort4> psubusw(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7039 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7040 | llvm::Function *psubusw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psubus_w); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7041 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7042 | return As<UShort4>(RValue<MMX>(V(::builder->CreateCall2(psubusw, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7043 | } |
| 7044 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7045 | RValue<SByte8> paddsb(RValue<SByte8> x, RValue<SByte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7046 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7047 | llvm::Function *paddsb = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_padds_b); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7048 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7049 | return As<SByte8>(RValue<MMX>(V(::builder->CreateCall2(paddsb, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7050 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7051 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7052 | RValue<SByte8> psubsb(RValue<SByte8> x, RValue<SByte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7053 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7054 | llvm::Function *psubsb = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psubs_b); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7055 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7056 | return As<SByte8>(RValue<MMX>(V(::builder->CreateCall2(psubsb, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7057 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7058 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7059 | RValue<Byte8> paddusb(RValue<Byte8> x, RValue<Byte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7060 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7061 | llvm::Function *paddusb = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_paddus_b); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7062 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7063 | return As<Byte8>(RValue<MMX>(V(::builder->CreateCall2(paddusb, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7064 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7065 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7066 | RValue<Byte8> psubusb(RValue<Byte8> x, RValue<Byte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7067 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7068 | llvm::Function *psubusb = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psubus_b); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7069 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7070 | return As<Byte8>(RValue<MMX>(V(::builder->CreateCall2(psubusb, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7071 | } |
| 7072 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7073 | RValue<Short4> paddw(RValue<Short4> x, RValue<Short4> y) |
| 7074 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7075 | llvm::Function *paddw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_padd_w); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7076 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7077 | return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(paddw, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7078 | } |
| 7079 | |
| 7080 | RValue<Short4> psubw(RValue<Short4> x, RValue<Short4> y) |
| 7081 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7082 | llvm::Function *psubw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psub_w); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7083 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7084 | return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(psubw, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7085 | } |
| 7086 | |
| 7087 | RValue<Short4> pmullw(RValue<Short4> x, RValue<Short4> y) |
| 7088 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7089 | llvm::Function *pmullw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pmull_w); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7090 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7091 | return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(pmullw, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7092 | } |
| 7093 | |
| 7094 | RValue<Short4> pand(RValue<Short4> x, RValue<Short4> y) |
| 7095 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7096 | llvm::Function *pand = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pand); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7097 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7098 | return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(pand, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7099 | } |
| 7100 | |
| 7101 | RValue<Short4> por(RValue<Short4> x, RValue<Short4> y) |
| 7102 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7103 | llvm::Function *por = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_por); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7104 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7105 | return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(por, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7106 | } |
| 7107 | |
| 7108 | RValue<Short4> pxor(RValue<Short4> x, RValue<Short4> y) |
| 7109 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7110 | llvm::Function *pxor = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pxor); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7111 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7112 | return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(pxor, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7113 | } |
| 7114 | |
| 7115 | RValue<Short4> pshufw(RValue<Short4> x, unsigned char y) |
| 7116 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7117 | llvm::Function *pshufw = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse_pshuf_w); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7118 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7119 | return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(pshufw, As<MMX>(x).value, V(Nucleus::createConstantByte(y)))))); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7120 | } |
| 7121 | |
| 7122 | RValue<Int2> punpcklwd(RValue<Short4> x, RValue<Short4> y) |
| 7123 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7124 | llvm::Function *punpcklwd = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_punpcklwd); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7125 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7126 | return As<Int2>(RValue<MMX>(V(::builder->CreateCall2(punpcklwd, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7127 | } |
| 7128 | |
| 7129 | RValue<Int2> punpckhwd(RValue<Short4> x, RValue<Short4> y) |
| 7130 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7131 | llvm::Function *punpckhwd = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_punpckhwd); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7132 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7133 | return As<Int2>(RValue<MMX>(V(::builder->CreateCall2(punpckhwd, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7134 | } |
| 7135 | |
| 7136 | RValue<Short4> pinsrw(RValue<Short4> x, RValue<Int> y, unsigned int i) |
| 7137 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7138 | llvm::Function *pinsrw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pinsr_w); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7139 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7140 | return As<Short4>(RValue<MMX>(V(::builder->CreateCall3(pinsrw, As<MMX>(x).value, y.value, V(Nucleus::createConstantInt(i)))))); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7141 | } |
| 7142 | |
| 7143 | RValue<Int> pextrw(RValue<Short4> x, unsigned int i) |
| 7144 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7145 | llvm::Function *pextrw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pextr_w); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7146 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7147 | return RValue<Int>(V(::builder->CreateCall2(pextrw, As<MMX>(x).value, V(Nucleus::createConstantInt(i))))); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7148 | } |
| 7149 | |
| 7150 | RValue<Long1> punpckldq(RValue<Int2> x, RValue<Int2> y) |
| 7151 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7152 | llvm::Function *punpckldq = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_punpckldq); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7153 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7154 | return As<Long1>(RValue<MMX>(V(::builder->CreateCall2(punpckldq, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7155 | } |
| 7156 | |
| 7157 | RValue<Long1> punpckhdq(RValue<Int2> x, RValue<Int2> y) |
| 7158 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7159 | llvm::Function *punpckhdq = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_punpckhdq); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7160 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7161 | return As<Long1>(RValue<MMX>(V(::builder->CreateCall2(punpckhdq, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7162 | } |
| 7163 | |
| 7164 | RValue<Short4> punpcklbw(RValue<Byte8> x, RValue<Byte8> y) |
| 7165 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7166 | llvm::Function *punpcklbw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_punpcklbw); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7167 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7168 | return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(punpcklbw, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7169 | } |
| 7170 | |
| 7171 | RValue<Short4> punpckhbw(RValue<Byte8> x, RValue<Byte8> y) |
| 7172 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7173 | llvm::Function *punpckhbw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_punpckhbw); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7174 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7175 | return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(punpckhbw, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7176 | } |
| 7177 | |
| 7178 | RValue<Byte8> paddb(RValue<Byte8> x, RValue<Byte8> y) |
| 7179 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7180 | llvm::Function *paddb = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_padd_b); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7181 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7182 | return As<Byte8>(RValue<MMX>(V(::builder->CreateCall2(paddb, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7183 | } |
| 7184 | |
| 7185 | RValue<Byte8> psubb(RValue<Byte8> x, RValue<Byte8> y) |
| 7186 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7187 | llvm::Function *psubb = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psub_b); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7188 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7189 | return As<Byte8>(RValue<MMX>(V(::builder->CreateCall2(psubb, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7190 | } |
| 7191 | |
| 7192 | RValue<Int2> paddd(RValue<Int2> x, RValue<Int2> y) |
| 7193 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7194 | llvm::Function *paddd = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_padd_d); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7195 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7196 | return As<Int2>(RValue<MMX>(V(::builder->CreateCall2(paddd, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7197 | } |
| 7198 | |
| 7199 | RValue<Int2> psubd(RValue<Int2> x, RValue<Int2> y) |
| 7200 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7201 | llvm::Function *psubd = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psub_d); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7202 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7203 | return As<Int2>(RValue<MMX>(V(::builder->CreateCall2(psubd, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7204 | } |
| 7205 | |
| 7206 | RValue<UShort4> pavgw(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7207 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7208 | llvm::Function *pavgw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pavg_w); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7209 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7210 | return As<UShort4>(RValue<MMX>(V(::builder->CreateCall2(pavgw, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7211 | } |
| 7212 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7213 | RValue<Short4> pmaxsw(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7214 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7215 | llvm::Function *pmaxsw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pmaxs_w); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7216 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7217 | return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(pmaxsw, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7218 | } |
| 7219 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7220 | RValue<Short4> pminsw(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7221 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7222 | llvm::Function *pminsw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pmins_w); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7223 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7224 | return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(pminsw, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7225 | } |
| 7226 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7227 | RValue<Short4> pcmpgtw(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7228 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7229 | llvm::Function *pcmpgtw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pcmpgt_w); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7230 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7231 | return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(pcmpgtw, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7232 | } |
| 7233 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7234 | RValue<Short4> pcmpeqw(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7235 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7236 | llvm::Function *pcmpeqw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pcmpeq_w); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7237 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7238 | return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(pcmpeqw, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7239 | } |
| 7240 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7241 | RValue<Byte8> pcmpgtb(RValue<SByte8> x, RValue<SByte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7242 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7243 | llvm::Function *pcmpgtb = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pcmpgt_b); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7244 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7245 | return As<Byte8>(RValue<MMX>(V(::builder->CreateCall2(pcmpgtb, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7246 | } |
| 7247 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7248 | RValue<Byte8> pcmpeqb(RValue<Byte8> x, RValue<Byte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7249 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7250 | llvm::Function *pcmpeqb = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pcmpeq_b); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7251 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7252 | return As<Byte8>(RValue<MMX>(V(::builder->CreateCall2(pcmpeqb, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7253 | } |
| 7254 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7255 | RValue<Short4> packssdw(RValue<Int2> x, RValue<Int2> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7256 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7257 | llvm::Function *packssdw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_packssdw); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7258 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7259 | return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(packssdw, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7260 | } |
| 7261 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7262 | RValue<Short8> packssdw(RValue<Int4> x, RValue<Int4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7263 | { |
| 7264 | if(CPUID::supportsSSE2()) |
| 7265 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7266 | llvm::Function *packssdw = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse2_packssdw_128); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7267 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7268 | return RValue<Short8>(V(::builder->CreateCall2(packssdw, x.value, y.value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7269 | } |
| 7270 | else |
| 7271 | { |
| 7272 | Int2 loX = Int2(x); |
| 7273 | Int2 hiX = Int2(Swizzle(x, 0xEE)); |
| 7274 | |
| 7275 | Int2 loY = Int2(y); |
| 7276 | Int2 hiY = Int2(Swizzle(y, 0xEE)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7277 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7278 | Short4 lo = x86::packssdw(loX, hiX); |
| 7279 | Short4 hi = x86::packssdw(loY, hiY); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7280 | |
Nicolas Capens | 62abb55 | 2016-01-05 12:03:47 -0500 | [diff] [blame] | 7281 | return Short8(lo, hi); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7282 | } |
| 7283 | } |
| 7284 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7285 | RValue<SByte8> packsswb(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7286 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7287 | llvm::Function *packsswb = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_packsswb); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7288 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7289 | return As<SByte8>(RValue<MMX>(V(::builder->CreateCall2(packsswb, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7290 | } |
| 7291 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7292 | RValue<Byte8> packuswb(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7293 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7294 | llvm::Function *packuswb = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_packuswb); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7295 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7296 | return As<Byte8>(RValue<MMX>(V(::builder->CreateCall2(packuswb, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7297 | } |
| 7298 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7299 | RValue<UShort8> packusdw(RValue<UInt4> x, RValue<UInt4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7300 | { |
| 7301 | if(CPUID::supportsSSE4_1()) |
| 7302 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7303 | llvm::Function *packusdw = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse41_packusdw); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7304 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7305 | return RValue<UShort8>(V(::builder->CreateCall2(packusdw, x.value, y.value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7306 | } |
| 7307 | else |
| 7308 | { |
| 7309 | // FIXME: Not an exact replacement! |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7310 | return As<UShort8>(packssdw(As<Int4>(x - UInt4(0x00008000, 0x00008000, 0x00008000, 0x00008000)), As<Int4>(y - UInt4(0x00008000, 0x00008000, 0x00008000, 0x00008000))) + Short8(0x8000u, 0x8000u, 0x8000u, 0x8000u, 0x8000u, 0x8000u, 0x8000u, 0x8000u)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7311 | } |
| 7312 | } |
| 7313 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7314 | RValue<UShort4> psrlw(RValue<UShort4> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7315 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7316 | llvm::Function *psrlw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psrli_w); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7317 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7318 | return As<UShort4>(RValue<MMX>(V(::builder->CreateCall2(psrlw, As<MMX>(x).value, V(Nucleus::createConstantInt(y)))))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7319 | } |
| 7320 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7321 | RValue<UShort8> psrlw(RValue<UShort8> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7322 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7323 | llvm::Function *psrlw = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse2_psrli_w); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7324 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7325 | return RValue<UShort8>(V(::builder->CreateCall2(psrlw, x.value, V(Nucleus::createConstantInt(y))))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7326 | } |
| 7327 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7328 | RValue<Short4> psraw(RValue<Short4> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7329 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7330 | llvm::Function *psraw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psrai_w); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7331 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7332 | return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(psraw, As<MMX>(x).value, V(Nucleus::createConstantInt(y)))))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7333 | } |
| 7334 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7335 | RValue<Short8> psraw(RValue<Short8> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7336 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7337 | llvm::Function *psraw = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse2_psrai_w); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7338 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7339 | return RValue<Short8>(V(::builder->CreateCall2(psraw, x.value, V(Nucleus::createConstantInt(y))))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7340 | } |
| 7341 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7342 | RValue<Short4> psllw(RValue<Short4> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7343 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7344 | llvm::Function *psllw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pslli_w); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7345 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7346 | return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(psllw, As<MMX>(x).value, V(Nucleus::createConstantInt(y)))))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7347 | } |
| 7348 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7349 | RValue<Short8> psllw(RValue<Short8> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7350 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7351 | llvm::Function *psllw = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse2_pslli_w); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7352 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7353 | return RValue<Short8>(V(::builder->CreateCall2(psllw, x.value, V(Nucleus::createConstantInt(y))))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7354 | } |
| 7355 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7356 | RValue<Int2> pslld(RValue<Int2> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7357 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7358 | llvm::Function *pslld = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pslli_d); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7359 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7360 | return As<Int2>(RValue<MMX>(V(::builder->CreateCall2(pslld, As<MMX>(x).value, V(Nucleus::createConstantInt(y)))))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7361 | } |
| 7362 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7363 | RValue<Int4> pslld(RValue<Int4> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7364 | { |
| 7365 | if(CPUID::supportsSSE2()) |
| 7366 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7367 | llvm::Function *pslld = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse2_pslli_d); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7368 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7369 | return RValue<Int4>(V(::builder->CreateCall2(pslld, x.value, V(Nucleus::createConstantInt(y))))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7370 | } |
| 7371 | else |
| 7372 | { |
| 7373 | Int2 lo = Int2(x); |
| 7374 | Int2 hi = Int2(Swizzle(x, 0xEE)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7375 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7376 | lo = x86::pslld(lo, y); |
| 7377 | hi = x86::pslld(hi, y); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7378 | |
Nicolas Capens | 62abb55 | 2016-01-05 12:03:47 -0500 | [diff] [blame] | 7379 | return Int4(lo, hi); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7380 | } |
| 7381 | } |
| 7382 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7383 | RValue<Int2> psrad(RValue<Int2> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7384 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7385 | llvm::Function *psrad = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psrai_d); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7386 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7387 | return As<Int2>(RValue<MMX>(V(::builder->CreateCall2(psrad, As<MMX>(x).value, V(Nucleus::createConstantInt(y)))))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7388 | } |
| 7389 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7390 | RValue<Int4> psrad(RValue<Int4> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7391 | { |
| 7392 | if(CPUID::supportsSSE2()) |
| 7393 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7394 | llvm::Function *psrad = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse2_psrai_d); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7395 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7396 | return RValue<Int4>(V(::builder->CreateCall2(psrad, x.value, V(Nucleus::createConstantInt(y))))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7397 | } |
| 7398 | else |
| 7399 | { |
| 7400 | Int2 lo = Int2(x); |
| 7401 | Int2 hi = Int2(Swizzle(x, 0xEE)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7402 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7403 | lo = x86::psrad(lo, y); |
| 7404 | hi = x86::psrad(hi, y); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7405 | |
Nicolas Capens | 62abb55 | 2016-01-05 12:03:47 -0500 | [diff] [blame] | 7406 | return Int4(lo, hi); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7407 | } |
| 7408 | } |
| 7409 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7410 | RValue<UInt2> psrld(RValue<UInt2> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7411 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7412 | llvm::Function *psrld = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psrli_d); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7413 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7414 | return As<UInt2>(RValue<MMX>(V(::builder->CreateCall2(psrld, As<MMX>(x).value, V(Nucleus::createConstantInt(y)))))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7415 | } |
| 7416 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7417 | RValue<UInt4> psrld(RValue<UInt4> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7418 | { |
| 7419 | if(CPUID::supportsSSE2()) |
| 7420 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7421 | llvm::Function *psrld = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse2_psrli_d); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7422 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7423 | return RValue<UInt4>(V(::builder->CreateCall2(psrld, x.value, V(Nucleus::createConstantInt(y))))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7424 | } |
| 7425 | else |
| 7426 | { |
| 7427 | UInt2 lo = As<UInt2>(Int2(As<Int4>(x))); |
| 7428 | UInt2 hi = As<UInt2>(Int2(Swizzle(As<Int4>(x), 0xEE))); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7429 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7430 | lo = x86::psrld(lo, y); |
| 7431 | hi = x86::psrld(hi, y); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7432 | |
Nicolas Capens | 62abb55 | 2016-01-05 12:03:47 -0500 | [diff] [blame] | 7433 | return UInt4(lo, hi); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7434 | } |
| 7435 | } |
| 7436 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7437 | RValue<UShort4> psrlw(RValue<UShort4> x, RValue<Long1> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7438 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7439 | llvm::Function *psrlw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psrl_w); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7440 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7441 | return As<UShort4>(RValue<MMX>(V(::builder->CreateCall2(psrlw, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7442 | } |
| 7443 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7444 | RValue<Short4> psraw(RValue<Short4> x, RValue<Long1> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7445 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7446 | llvm::Function *psraw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psra_w); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7447 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7448 | return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(psraw, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7449 | } |
| 7450 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7451 | RValue<Short4> psllw(RValue<Short4> x, RValue<Long1> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7452 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7453 | llvm::Function *psllw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psll_w); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7454 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7455 | return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(psllw, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7456 | } |
| 7457 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7458 | RValue<Int2> pslld(RValue<Int2> x, RValue<Long1> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7459 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7460 | llvm::Function *pslld = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psll_d); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7461 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7462 | return As<Int2>(RValue<MMX>(V(::builder->CreateCall2(pslld, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7463 | } |
| 7464 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7465 | RValue<UInt2> psrld(RValue<UInt2> x, RValue<Long1> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7466 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7467 | llvm::Function *psrld = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psrl_d); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7468 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7469 | return As<UInt2>(RValue<MMX>(V(::builder->CreateCall2(psrld, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7470 | } |
| 7471 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7472 | RValue<Int2> psrad(RValue<Int2> x, RValue<Long1> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7473 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7474 | llvm::Function *psrld = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psra_d); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7475 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7476 | return As<Int2>(RValue<MMX>(V(::builder->CreateCall2(psrld, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7477 | } |
| 7478 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7479 | RValue<Int4> pmaxsd(RValue<Int4> x, RValue<Int4> y) |
| 7480 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7481 | llvm::Function *pmaxsd = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse41_pmaxsd); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7482 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7483 | return RValue<Int4>(V(::builder->CreateCall2(pmaxsd, x.value, y.value))); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7484 | } |
| 7485 | |
| 7486 | RValue<Int4> pminsd(RValue<Int4> x, RValue<Int4> y) |
| 7487 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7488 | llvm::Function *pminsd = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse41_pminsd); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7489 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7490 | return RValue<Int4>(V(::builder->CreateCall2(pminsd, x.value, y.value))); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7491 | } |
| 7492 | |
| 7493 | RValue<UInt4> pmaxud(RValue<UInt4> x, RValue<UInt4> y) |
| 7494 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7495 | llvm::Function *pmaxud = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse41_pmaxud); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7496 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7497 | return RValue<UInt4>(V(::builder->CreateCall2(pmaxud, x.value, y.value))); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7498 | } |
| 7499 | |
| 7500 | RValue<UInt4> pminud(RValue<UInt4> x, RValue<UInt4> y) |
| 7501 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7502 | llvm::Function *pminud = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse41_pminud); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7503 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7504 | return RValue<UInt4>(V(::builder->CreateCall2(pminud, x.value, y.value))); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7505 | } |
| 7506 | |
| 7507 | RValue<Short4> pmulhw(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7508 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7509 | llvm::Function *pmulhw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pmulh_w); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7510 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7511 | return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(pmulhw, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7512 | } |
| 7513 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7514 | RValue<UShort4> pmulhuw(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7515 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7516 | llvm::Function *pmulhuw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pmulhu_w); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7517 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7518 | return As<UShort4>(RValue<MMX>(V(::builder->CreateCall2(pmulhuw, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7519 | } |
| 7520 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7521 | RValue<Int2> pmaddwd(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7522 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7523 | llvm::Function *pmaddwd = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pmadd_wd); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7524 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7525 | return As<Int2>(RValue<MMX>(V(::builder->CreateCall2(pmaddwd, As<MMX>(x).value, As<MMX>(y).value)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7526 | } |
| 7527 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7528 | RValue<Short8> pmulhw(RValue<Short8> x, RValue<Short8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7529 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7530 | llvm::Function *pmulhw = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse2_pmulh_w); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7531 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7532 | return RValue<Short8>(V(::builder->CreateCall2(pmulhw, x.value, y.value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7533 | } |
| 7534 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7535 | RValue<UShort8> pmulhuw(RValue<UShort8> x, RValue<UShort8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7536 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7537 | llvm::Function *pmulhuw = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse2_pmulhu_w); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7538 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7539 | return RValue<UShort8>(V(::builder->CreateCall2(pmulhuw, x.value, y.value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7540 | } |
| 7541 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7542 | RValue<Int4> pmaddwd(RValue<Short8> x, RValue<Short8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7543 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7544 | llvm::Function *pmaddwd = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse2_pmadd_wd); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7545 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7546 | return RValue<Int4>(V(::builder->CreateCall2(pmaddwd, x.value, y.value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7547 | } |
| 7548 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7549 | RValue<Int> movmskps(RValue<Float4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7550 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7551 | llvm::Function *movmskps = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse_movmsk_ps); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7552 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7553 | return RValue<Int>(V(::builder->CreateCall(movmskps, x.value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7554 | } |
| 7555 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7556 | RValue<Int> pmovmskb(RValue<Byte8> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7557 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7558 | llvm::Function *pmovmskb = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pmovmskb); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7559 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7560 | return RValue<Int>(V(::builder->CreateCall(pmovmskb, As<MMX>(x).value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7561 | } |
| 7562 | |
Nicolas Capens | 81f1830 | 2016-01-14 09:32:35 -0500 | [diff] [blame] | 7563 | //RValue<Int2> movd(RValue<Pointer<Int>> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7564 | //{ |
| 7565 | // Value *element = Nucleus::createLoad(x.value); |
| 7566 | |
| 7567 | //// Value *int2 = UndefValue::get(Int2::getType()); |
| 7568 | //// int2 = Nucleus::createInsertElement(int2, element, ConstantInt::get(Int::getType(), 0)); |
| 7569 | |
| 7570 | // Value *int2 = Nucleus::createBitCast(Nucleus::createZExt(element, Long::getType()), Int2::getType()); |
| 7571 | |
| 7572 | // return RValue<Int2>(int2); |
| 7573 | //} |
| 7574 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7575 | //RValue<Int2> movdq2q(RValue<Int4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7576 | //{ |
Nicolas Capens | 2200878 | 2016-10-20 01:11:47 -0400 | [diff] [blame] | 7577 | // Value *long2 = Nucleus::createBitCast(x.value, T(VectorType::get(Long::getType(), 2))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7578 | // Value *element = Nucleus::createExtractElement(long2, ConstantInt::get(Int::getType(), 0)); |
| 7579 | |
| 7580 | // return RValue<Int2>(Nucleus::createBitCast(element, Int2::getType())); |
| 7581 | //} |
| 7582 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7583 | RValue<Int4> pmovzxbd(RValue<Int4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7584 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7585 | llvm::Function *pmovzxbd = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse41_pmovzxbd); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7586 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7587 | return RValue<Int4>(V(::builder->CreateCall(pmovzxbd, Nucleus::createBitCast(x.value, Byte16::getType())))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7588 | } |
| 7589 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7590 | RValue<Int4> pmovsxbd(RValue<Int4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7591 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7592 | llvm::Function *pmovsxbd = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse41_pmovsxbd); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7593 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7594 | return RValue<Int4>(V(::builder->CreateCall(pmovsxbd, Nucleus::createBitCast(x.value, SByte16::getType())))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7595 | } |
| 7596 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7597 | RValue<Int4> pmovzxwd(RValue<Int4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7598 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7599 | llvm::Function *pmovzxwd = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse41_pmovzxwd); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7600 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7601 | return RValue<Int4>(V(::builder->CreateCall(pmovzxwd, Nucleus::createBitCast(x.value, UShort8::getType())))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7602 | } |
| 7603 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7604 | RValue<Int4> pmovsxwd(RValue<Int4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7605 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7606 | llvm::Function *pmovsxwd = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse41_pmovsxwd); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7607 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7608 | return RValue<Int4>(V(::builder->CreateCall(pmovsxwd, Nucleus::createBitCast(x.value, Short8::getType())))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7609 | } |
| 7610 | |
| 7611 | void emms() |
| 7612 | { |
Nicolas Capens | 5c1f5cc | 2016-09-23 16:45:13 -0400 | [diff] [blame] | 7613 | llvm::Function *emms = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_emms); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7614 | |
Nicolas Capens | 2ab69ee | 2016-09-26 11:45:17 -0400 | [diff] [blame] | 7615 | V(::builder->CreateCall(emms)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7616 | } |
| 7617 | } |
| 7618 | } |