John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1 | // SwiftShader Software Renderer |
| 2 | // |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3 | // Copyright(c) 2005-2012 TransGaming Inc. |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4 | // |
| 5 | // All rights reserved. No part of this software may be copied, distributed, transmitted, |
| 6 | // transcribed, stored in a retrieval system, translated into any human or computer |
| 7 | // language by any means, or disclosed to third parties without the explicit written |
| 8 | // agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express |
| 9 | // or implied, including but not limited to any patent rights, are granted to you. |
| 10 | // |
| 11 | |
| 12 | #include "Nucleus.hpp" |
| 13 | |
| 14 | #include "llvm/Support/IRBuilder.h" |
| 15 | #include "llvm/Function.h" |
| 16 | #include "llvm/GlobalVariable.h" |
| 17 | #include "llvm/Module.h" |
| 18 | #include "llvm/LLVMContext.h" |
| 19 | #include "llvm/Constants.h" |
| 20 | #include "llvm/Intrinsics.h" |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 21 | #include "llvm/PassManager.h" |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 22 | #include "llvm/Analysis/LoopPass.h" |
| 23 | #include "llvm/Transforms/Scalar.h" |
| 24 | #include "llvm/Target/TargetData.h" |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 25 | #include "llvm/Target/TargetOptions.h" |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 26 | #include "llvm/Support/TargetSelect.h" |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 27 | #include "../lib/ExecutionEngine/JIT/JIT.h" |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 28 | |
Nicolas Capens | d946e0a | 2014-06-26 11:31:08 -0400 | [diff] [blame] | 29 | #include "Routine.hpp" |
Nicolas Capens | 2fb4110 | 2014-06-26 10:11:50 -0400 | [diff] [blame] | 30 | #include "RoutineManager.hpp" |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 31 | #include "x86.hpp" |
| 32 | #include "CPUID.hpp" |
| 33 | #include "Thread.hpp" |
| 34 | #include "Memory.hpp" |
| 35 | |
| 36 | #include <fstream> |
| 37 | |
Nicolas Capens | cb12258 | 2014-05-06 23:34:44 -0400 | [diff] [blame] | 38 | #if defined(__x86_64__) && defined(_WIN32) |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 39 | extern "C" void X86CompilationCallback() |
| 40 | { |
| 41 | assert(false); // UNIMPLEMENTED |
| 42 | } |
| 43 | #endif |
| 44 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 45 | extern "C" |
| 46 | { |
| 47 | bool (*CodeAnalystInitialize)() = 0; |
| 48 | void (*CodeAnalystCompleteJITLog)() = 0; |
| 49 | bool (*CodeAnalystLogJITCode)(const void *jitCodeStartAddr, unsigned int jitCodeSize, const wchar_t *functionName) = 0; |
| 50 | } |
| 51 | |
| 52 | namespace llvm |
| 53 | { |
| 54 | extern bool JITEmitDebugInfo; |
| 55 | } |
| 56 | |
| 57 | namespace sw |
| 58 | { |
| 59 | Optimization optimization[10] = {InstructionCombining, Disabled}; |
| 60 | |
| 61 | using namespace llvm; |
| 62 | |
Nicolas Capens | 2fb4110 | 2014-06-26 10:11:50 -0400 | [diff] [blame] | 63 | RoutineManager *Nucleus::routineManager = 0; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 64 | ExecutionEngine *Nucleus::executionEngine = 0; |
| 65 | Builder *Nucleus::builder = 0; |
| 66 | LLVMContext *Nucleus::context = 0; |
| 67 | Module *Nucleus::module = 0; |
| 68 | llvm::Function *Nucleus::function = 0; |
Nicolas Capens | b7ea984 | 2015-04-01 10:54:59 -0400 | [diff] [blame^] | 69 | BackoffLock Nucleus::codegenMutex; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 70 | |
| 71 | class Builder : public IRBuilder<> |
| 72 | { |
| 73 | }; |
| 74 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 75 | Nucleus::Nucleus() |
| 76 | { |
Nicolas Capens | b7ea984 | 2015-04-01 10:54:59 -0400 | [diff] [blame^] | 77 | codegenMutex.lock(); // Reactor and LLVM are currently not thread safe |
| 78 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 79 | InitializeNativeTarget(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 80 | JITEmitDebugInfo = false; |
| 81 | |
| 82 | if(!context) |
| 83 | { |
| 84 | context = new LLVMContext(); |
| 85 | } |
| 86 | |
| 87 | module = new Module("", *context); |
Nicolas Capens | 2fb4110 | 2014-06-26 10:11:50 -0400 | [diff] [blame] | 88 | routineManager = new RoutineManager(); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 89 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 90 | #if defined(__x86_64__) |
| 91 | const char *architecture = "x86-64"; |
| 92 | #else |
| 93 | const char *architecture = "x86"; |
| 94 | #endif |
| 95 | |
| 96 | SmallVector<std::string, 1> MAttrs; |
| 97 | MAttrs.push_back(CPUID::supportsMMX() ? "+mmx" : "-mmx"); |
| 98 | MAttrs.push_back(CPUID::supportsCMOV() ? "+cmov" : "-cmov"); |
| 99 | MAttrs.push_back(CPUID::supportsSSE() ? "+sse" : "-sse"); |
| 100 | MAttrs.push_back(CPUID::supportsSSE2() ? "+sse2" : "-sse2"); |
| 101 | MAttrs.push_back(CPUID::supportsSSE3() ? "+sse3" : "-sse3"); |
| 102 | MAttrs.push_back(CPUID::supportsSSSE3() ? "+ssse3" : "-ssse3"); |
| 103 | MAttrs.push_back(CPUID::supportsSSE4_1() ? "+sse41" : "-sse41"); |
| 104 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 105 | std::string error; |
| 106 | TargetMachine *targetMachine = EngineBuilder::selectTarget(module, architecture, "", MAttrs, Reloc::Default, CodeModel::JITDefault, &error); |
Nicolas Capens | 2fb4110 | 2014-06-26 10:11:50 -0400 | [diff] [blame] | 107 | executionEngine = JIT::createJIT(module, 0, routineManager, CodeGenOpt::Aggressive, true, targetMachine); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 108 | |
| 109 | if(!builder) |
| 110 | { |
| 111 | builder = static_cast<Builder*>(new IRBuilder<>(*context)); |
| 112 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 113 | #if defined(_WIN32) |
| 114 | HMODULE CodeAnalyst = LoadLibrary("CAJitNtfyLib.dll"); |
| 115 | if(CodeAnalyst) |
| 116 | { |
| 117 | CodeAnalystInitialize = (bool(*)())GetProcAddress(CodeAnalyst, "CAJIT_Initialize"); |
| 118 | CodeAnalystCompleteJITLog = (void(*)())GetProcAddress(CodeAnalyst, "CAJIT_CompleteJITLog"); |
| 119 | CodeAnalystLogJITCode = (bool(*)(const void*, unsigned int, const wchar_t*))GetProcAddress(CodeAnalyst, "CAJIT_LogJITCode"); |
| 120 | |
| 121 | CodeAnalystInitialize(); |
| 122 | } |
| 123 | #endif |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 124 | } |
| 125 | } |
| 126 | |
| 127 | Nucleus::~Nucleus() |
| 128 | { |
| 129 | delete executionEngine; |
| 130 | executionEngine = 0; |
| 131 | |
Nicolas Capens | 2fb4110 | 2014-06-26 10:11:50 -0400 | [diff] [blame] | 132 | routineManager = 0; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 133 | function = 0; |
| 134 | module = 0; |
Nicolas Capens | b7ea984 | 2015-04-01 10:54:59 -0400 | [diff] [blame^] | 135 | |
| 136 | codegenMutex.unlock(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | Routine *Nucleus::acquireRoutine(const wchar_t *name, bool runOptimizations) |
| 140 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 141 | if(builder->GetInsertBlock()->empty() || !builder->GetInsertBlock()->back().isTerminator()) |
| 142 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 143 | Type *type = function->getReturnType(); |
| 144 | |
| 145 | if(type->isVoidTy()) |
| 146 | { |
| 147 | createRetVoid(); |
| 148 | } |
| 149 | else |
| 150 | { |
| 151 | createRet(UndefValue::get(type)); |
| 152 | } |
| 153 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 154 | |
| 155 | if(false) |
| 156 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 157 | std::string error; |
| 158 | raw_fd_ostream file("llvm-dump-unopt.txt", error); |
| 159 | module->print(file, 0); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | if(runOptimizations) |
| 163 | { |
| 164 | optimize(); |
| 165 | } |
| 166 | |
| 167 | if(false) |
| 168 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 169 | std::string error; |
| 170 | raw_fd_ostream file("llvm-dump-opt.txt", error); |
| 171 | module->print(file, 0); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | void *entry = executionEngine->getPointerToFunction(function); |
Nicolas Capens | d946e0a | 2014-06-26 11:31:08 -0400 | [diff] [blame] | 175 | Routine *routine = routineManager->acquireRoutine(entry); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 176 | |
| 177 | if(CodeAnalystLogJITCode) |
| 178 | { |
Nicolas Capens | d946e0a | 2014-06-26 11:31:08 -0400 | [diff] [blame] | 179 | CodeAnalystLogJITCode(routine->getEntry(), routine->getCodeSize(), name); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | return routine; |
| 183 | } |
| 184 | |
| 185 | void Nucleus::optimize() |
| 186 | { |
| 187 | static PassManager *passManager = 0; |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 188 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 189 | if(!passManager) |
| 190 | { |
| 191 | passManager = new PassManager(); |
| 192 | |
| 193 | UnsafeFPMath = true; |
| 194 | // NoInfsFPMath = true; |
| 195 | // NoNaNsFPMath = true; |
| 196 | |
| 197 | passManager->add(new TargetData(*executionEngine->getTargetData())); |
| 198 | passManager->add(createScalarReplAggregatesPass()); |
| 199 | |
| 200 | for(int pass = 0; pass < 10 && optimization[pass] != Disabled; pass++) |
| 201 | { |
| 202 | switch(optimization[pass]) |
| 203 | { |
| 204 | case Disabled: break; |
| 205 | case CFGSimplification: passManager->add(createCFGSimplificationPass()); break; |
| 206 | case LICM: passManager->add(createLICMPass()); break; |
| 207 | case AggressiveDCE: passManager->add(createAggressiveDCEPass()); break; |
| 208 | case GVN: passManager->add(createGVNPass()); break; |
| 209 | case InstructionCombining: passManager->add(createInstructionCombiningPass()); break; |
| 210 | case Reassociate: passManager->add(createReassociatePass()); break; |
| 211 | case DeadStoreElimination: passManager->add(createDeadStoreEliminationPass()); break; |
| 212 | case SCCP: passManager->add(createSCCPPass()); break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 213 | case ScalarReplAggregates: passManager->add(createScalarReplAggregatesPass()); break; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 214 | default: |
| 215 | assert(false); |
| 216 | } |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | passManager->run(*module); |
| 221 | } |
| 222 | |
| 223 | void Nucleus::setFunction(llvm::Function *function) |
| 224 | { |
| 225 | Nucleus::function = function; |
| 226 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 227 | builder->SetInsertPoint(BasicBlock::Create(*context, "", function)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | Module *Nucleus::getModule() |
| 231 | { |
| 232 | return module; |
| 233 | } |
| 234 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 235 | llvm::Function *Nucleus::getFunction() |
| 236 | { |
| 237 | return function; |
| 238 | } |
| 239 | |
| 240 | llvm::LLVMContext *Nucleus::getContext() |
| 241 | { |
| 242 | return context; |
| 243 | } |
| 244 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 245 | Value *Nucleus::allocateStackVariable(Type *type, int arraySize) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 246 | { |
| 247 | // Need to allocate it in the entry block for mem2reg to work |
| 248 | llvm::Function *function = getFunction(); |
| 249 | BasicBlock &entryBlock = function->getEntryBlock(); |
| 250 | |
| 251 | Instruction *declaration; |
| 252 | |
| 253 | if(arraySize) |
| 254 | { |
| 255 | declaration = new AllocaInst(type, Nucleus::createConstantInt(arraySize)); |
| 256 | } |
| 257 | else |
| 258 | { |
| 259 | declaration = new AllocaInst(type, (Value*)0); |
| 260 | } |
| 261 | |
| 262 | entryBlock.getInstList().push_front(declaration); |
| 263 | |
| 264 | return declaration; |
| 265 | } |
| 266 | |
| 267 | BasicBlock *Nucleus::createBasicBlock() |
| 268 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 269 | return BasicBlock::Create(*context, "", Nucleus::getFunction()); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 270 | } |
| 271 | |
| 272 | BasicBlock *Nucleus::getInsertBlock() |
| 273 | { |
| 274 | return builder->GetInsertBlock(); |
| 275 | } |
| 276 | |
| 277 | void Nucleus::setInsertBlock(BasicBlock *basicBlock) |
| 278 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 279 | // assert(builder->GetInsertBlock()->back().isTerminator()); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 280 | return builder->SetInsertPoint(basicBlock); |
| 281 | } |
| 282 | |
| 283 | BasicBlock *Nucleus::getPredecessor(BasicBlock *basicBlock) |
| 284 | { |
| 285 | return *pred_begin(basicBlock); |
| 286 | } |
| 287 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 288 | llvm::Function *Nucleus::createFunction(llvm::Type *ReturnType, std::vector<llvm::Type*> &Params) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 289 | { |
| 290 | llvm::FunctionType *functionType = llvm::FunctionType::get(ReturnType, Params, false); |
| 291 | llvm::Function *function = llvm::Function::Create(functionType, llvm::GlobalValue::InternalLinkage, "", Nucleus::getModule()); |
| 292 | function->setCallingConv(llvm::CallingConv::C); |
| 293 | |
| 294 | return function; |
| 295 | } |
| 296 | |
| 297 | llvm::Argument *Nucleus::getArgument(llvm::Function *function, unsigned int index) |
| 298 | { |
| 299 | llvm::Function::arg_iterator args = function->arg_begin(); |
| 300 | |
| 301 | while(index) |
| 302 | { |
| 303 | args++; |
| 304 | index--; |
| 305 | } |
| 306 | |
| 307 | return &*args; |
| 308 | } |
| 309 | |
| 310 | Value *Nucleus::createRetVoid() |
| 311 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 312 | x86::emms(); |
| 313 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 314 | return builder->CreateRetVoid(); |
| 315 | } |
| 316 | |
| 317 | Value *Nucleus::createRet(Value *V) |
| 318 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 319 | x86::emms(); |
| 320 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 321 | return builder->CreateRet(V); |
| 322 | } |
| 323 | |
| 324 | Value *Nucleus::createBr(BasicBlock *dest) |
| 325 | { |
| 326 | return builder->CreateBr(dest); |
| 327 | } |
| 328 | |
| 329 | Value *Nucleus::createCondBr(Value *cond, BasicBlock *ifTrue, BasicBlock *ifFalse) |
| 330 | { |
| 331 | return builder->CreateCondBr(cond, ifTrue, ifFalse); |
| 332 | } |
| 333 | |
| 334 | Value *Nucleus::createAdd(Value *lhs, Value *rhs) |
| 335 | { |
| 336 | return builder->CreateAdd(lhs, rhs); |
| 337 | } |
| 338 | |
| 339 | Value *Nucleus::createSub(Value *lhs, Value *rhs) |
| 340 | { |
| 341 | return builder->CreateSub(lhs, rhs); |
| 342 | } |
| 343 | |
| 344 | Value *Nucleus::createMul(Value *lhs, Value *rhs) |
| 345 | { |
| 346 | return builder->CreateMul(lhs, rhs); |
| 347 | } |
| 348 | |
| 349 | Value *Nucleus::createUDiv(Value *lhs, Value *rhs) |
| 350 | { |
| 351 | return builder->CreateUDiv(lhs, rhs); |
| 352 | } |
| 353 | |
| 354 | Value *Nucleus::createSDiv(Value *lhs, Value *rhs) |
| 355 | { |
| 356 | return builder->CreateSDiv(lhs, rhs); |
| 357 | } |
| 358 | |
| 359 | Value *Nucleus::createFAdd(Value *lhs, Value *rhs) |
| 360 | { |
| 361 | return builder->CreateFAdd(lhs, rhs); |
| 362 | } |
| 363 | |
| 364 | Value *Nucleus::createFSub(Value *lhs, Value *rhs) |
| 365 | { |
| 366 | return builder->CreateFSub(lhs, rhs); |
| 367 | } |
| 368 | |
| 369 | Value *Nucleus::createFMul(Value *lhs, Value *rhs) |
| 370 | { |
| 371 | return builder->CreateFMul(lhs, rhs); |
| 372 | } |
| 373 | |
| 374 | Value *Nucleus::createFDiv(Value *lhs, Value *rhs) |
| 375 | { |
| 376 | return builder->CreateFDiv(lhs, rhs); |
| 377 | } |
| 378 | |
| 379 | Value *Nucleus::createURem(Value *lhs, Value *rhs) |
| 380 | { |
| 381 | return builder->CreateURem(lhs, rhs); |
| 382 | } |
| 383 | |
| 384 | Value *Nucleus::createSRem(Value *lhs, Value *rhs) |
| 385 | { |
| 386 | return builder->CreateSRem(lhs, rhs); |
| 387 | } |
| 388 | |
| 389 | Value *Nucleus::createFRem(Value *lhs, Value *rhs) |
| 390 | { |
| 391 | return builder->CreateFRem(lhs, rhs); |
| 392 | } |
| 393 | |
| 394 | Value *Nucleus::createShl(Value *lhs, Value *rhs) |
| 395 | { |
| 396 | return builder->CreateShl(lhs, rhs); |
| 397 | } |
| 398 | |
| 399 | Value *Nucleus::createLShr(Value *lhs, Value *rhs) |
| 400 | { |
| 401 | return builder->CreateLShr(lhs, rhs); |
| 402 | } |
| 403 | |
| 404 | Value *Nucleus::createAShr(Value *lhs, Value *rhs) |
| 405 | { |
| 406 | return builder->CreateAShr(lhs, rhs); |
| 407 | } |
| 408 | |
| 409 | Value *Nucleus::createAnd(Value *lhs, Value *rhs) |
| 410 | { |
| 411 | return builder->CreateAnd(lhs, rhs); |
| 412 | } |
| 413 | |
| 414 | Value *Nucleus::createOr(Value *lhs, Value *rhs) |
| 415 | { |
| 416 | return builder->CreateOr(lhs, rhs); |
| 417 | } |
| 418 | |
| 419 | Value *Nucleus::createXor(Value *lhs, Value *rhs) |
| 420 | { |
| 421 | return builder->CreateXor(lhs, rhs); |
| 422 | } |
| 423 | |
| 424 | Value *Nucleus::createNeg(Value *V) |
| 425 | { |
| 426 | return builder->CreateNeg(V); |
| 427 | } |
| 428 | |
| 429 | Value *Nucleus::createFNeg(Value *V) |
| 430 | { |
| 431 | return builder->CreateFNeg(V); |
| 432 | } |
| 433 | |
| 434 | Value *Nucleus::createNot(Value *V) |
| 435 | { |
| 436 | return builder->CreateNot(V); |
| 437 | } |
| 438 | |
| 439 | Value *Nucleus::createLoad(Value *ptr, bool isVolatile, unsigned int align) |
| 440 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 441 | return builder->Insert(new LoadInst(ptr, "", isVolatile, align)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 442 | } |
| 443 | |
| 444 | Value *Nucleus::createStore(Value *value, Value *ptr, bool isVolatile, unsigned int align) |
| 445 | { |
| 446 | return builder->Insert(new StoreInst(value, ptr, isVolatile, align)); |
| 447 | } |
| 448 | |
| 449 | Value *Nucleus::createGEP(Value *ptr, Value *index) |
| 450 | { |
| 451 | return builder->CreateGEP(ptr, index); |
| 452 | } |
| 453 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 454 | Value *Nucleus::createAtomicAdd(Value *ptr, Value *value) |
| 455 | { |
| 456 | return builder->CreateAtomicRMW(AtomicRMWInst::Add, ptr, value, SequentiallyConsistent); |
| 457 | } |
| 458 | |
| 459 | Value *Nucleus::createTrunc(Value *V, Type *destType) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 460 | { |
| 461 | return builder->CreateTrunc(V, destType); |
| 462 | } |
| 463 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 464 | Value *Nucleus::createZExt(Value *V, Type *destType) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 465 | { |
| 466 | return builder->CreateZExt(V, destType); |
| 467 | } |
| 468 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 469 | Value *Nucleus::createSExt(Value *V, Type *destType) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 470 | { |
| 471 | return builder->CreateSExt(V, destType); |
| 472 | } |
| 473 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 474 | Value *Nucleus::createFPToUI(Value *V, Type *destType) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 475 | { |
| 476 | return builder->CreateFPToUI(V, destType); |
| 477 | } |
| 478 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 479 | Value *Nucleus::createFPToSI(Value *V, Type *destType) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 480 | { |
| 481 | return builder->CreateFPToSI(V, destType); |
| 482 | } |
| 483 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 484 | Value *Nucleus::createUIToFP(Value *V, Type *destType) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 485 | { |
| 486 | return builder->CreateUIToFP(V, destType); |
| 487 | } |
| 488 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 489 | Value *Nucleus::createSIToFP(Value *V, Type *destType) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 490 | { |
| 491 | return builder->CreateSIToFP(V, destType); |
| 492 | } |
| 493 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 494 | Value *Nucleus::createFPTrunc(Value *V, Type *destType) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 495 | { |
| 496 | return builder->CreateFPTrunc(V, destType); |
| 497 | } |
| 498 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 499 | Value *Nucleus::createFPExt(Value *V, Type *destType) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 500 | { |
| 501 | return builder->CreateFPExt(V, destType); |
| 502 | } |
| 503 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 504 | Value *Nucleus::createPtrToInt(Value *V, Type *destType) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 505 | { |
| 506 | return builder->CreatePtrToInt(V, destType); |
| 507 | } |
| 508 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 509 | Value *Nucleus::createIntToPtr(Value *V, Type *destType) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 510 | { |
| 511 | return builder->CreateIntToPtr(V, destType); |
| 512 | } |
| 513 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 514 | Value *Nucleus::createBitCast(Value *V, Type *destType) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 515 | { |
| 516 | return builder->CreateBitCast(V, destType); |
| 517 | } |
| 518 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 519 | Value *Nucleus::createIntCast(Value *V, Type *destType, bool isSigned) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 520 | { |
| 521 | return builder->CreateIntCast(V, destType, isSigned); |
| 522 | } |
| 523 | |
| 524 | Value *Nucleus::createICmpEQ(Value *lhs, Value *rhs) |
| 525 | { |
| 526 | return builder->CreateICmpEQ(lhs, rhs); |
| 527 | } |
| 528 | |
| 529 | Value *Nucleus::createICmpNE(Value *lhs, Value *rhs) |
| 530 | { |
| 531 | return builder->CreateICmpNE(lhs, rhs); |
| 532 | } |
| 533 | |
| 534 | Value *Nucleus::createICmpUGT(Value *lhs, Value *rhs) |
| 535 | { |
| 536 | return builder->CreateICmpUGT(lhs, rhs); |
| 537 | } |
| 538 | |
| 539 | Value *Nucleus::createICmpUGE(Value *lhs, Value *rhs) |
| 540 | { |
| 541 | return builder->CreateICmpUGE(lhs, rhs); |
| 542 | } |
| 543 | |
| 544 | Value *Nucleus::createICmpULT(Value *lhs, Value *rhs) |
| 545 | { |
| 546 | return builder->CreateICmpULT(lhs, rhs); |
| 547 | } |
| 548 | |
| 549 | Value *Nucleus::createICmpULE(Value *lhs, Value *rhs) |
| 550 | { |
| 551 | return builder->CreateICmpULE(lhs, rhs); |
| 552 | } |
| 553 | |
| 554 | Value *Nucleus::createICmpSGT(Value *lhs, Value *rhs) |
| 555 | { |
| 556 | return builder->CreateICmpSGT(lhs, rhs); |
| 557 | } |
| 558 | |
| 559 | Value *Nucleus::createICmpSGE(Value *lhs, Value *rhs) |
| 560 | { |
| 561 | return builder->CreateICmpSGE(lhs, rhs); |
| 562 | } |
| 563 | |
| 564 | Value *Nucleus::createICmpSLT(Value *lhs, Value *rhs) |
| 565 | { |
| 566 | return builder->CreateICmpSLT(lhs, rhs); |
| 567 | } |
| 568 | |
| 569 | Value *Nucleus::createICmpSLE(Value *lhs, Value *rhs) |
| 570 | { |
| 571 | return builder->CreateICmpSLE(lhs, rhs); |
| 572 | } |
| 573 | |
| 574 | Value *Nucleus::createFCmpOEQ(Value *lhs, Value *rhs) |
| 575 | { |
| 576 | return builder->CreateFCmpOEQ(lhs, rhs); |
| 577 | } |
| 578 | |
| 579 | Value *Nucleus::createFCmpOGT(Value *lhs, Value *rhs) |
| 580 | { |
| 581 | return builder->CreateFCmpOGT(lhs, rhs); |
| 582 | } |
| 583 | |
| 584 | Value *Nucleus::createFCmpOGE(Value *lhs, Value *rhs) |
| 585 | { |
| 586 | return builder->CreateFCmpOGE(lhs, rhs); |
| 587 | } |
| 588 | |
| 589 | Value *Nucleus::createFCmpOLT(Value *lhs, Value *rhs) |
| 590 | { |
| 591 | return builder->CreateFCmpOLT(lhs, rhs); |
| 592 | } |
| 593 | |
| 594 | Value *Nucleus::createFCmpOLE(Value *lhs, Value *rhs) |
| 595 | { |
| 596 | return builder->CreateFCmpOLE(lhs, rhs); |
| 597 | } |
| 598 | |
| 599 | Value *Nucleus::createFCmpONE(Value *lhs, Value *rhs) |
| 600 | { |
| 601 | return builder->CreateFCmpONE(lhs, rhs); |
| 602 | } |
| 603 | |
| 604 | Value *Nucleus::createFCmpORD(Value *lhs, Value *rhs) |
| 605 | { |
| 606 | return builder->CreateFCmpORD(lhs, rhs); |
| 607 | } |
| 608 | |
| 609 | Value *Nucleus::createFCmpUNO(Value *lhs, Value *rhs) |
| 610 | { |
| 611 | return builder->CreateFCmpUNO(lhs, rhs); |
| 612 | } |
| 613 | |
| 614 | Value *Nucleus::createFCmpUEQ(Value *lhs, Value *rhs) |
| 615 | { |
| 616 | return builder->CreateFCmpUEQ(lhs, rhs); |
| 617 | } |
| 618 | |
| 619 | Value *Nucleus::createFCmpUGT(Value *lhs, Value *rhs) |
| 620 | { |
| 621 | return builder->CreateFCmpUGT(lhs, rhs); |
| 622 | } |
| 623 | |
| 624 | Value *Nucleus::createFCmpUGE(Value *lhs, Value *rhs) |
| 625 | { |
| 626 | return builder->CreateFCmpUGE(lhs, rhs); |
| 627 | } |
| 628 | |
| 629 | Value *Nucleus::createFCmpULT(Value *lhs, Value *rhs) |
| 630 | { |
| 631 | return builder->CreateFCmpULT(lhs, rhs); |
| 632 | } |
| 633 | |
| 634 | Value *Nucleus::createFCmpULE(Value *lhs, Value *rhs) |
| 635 | { |
| 636 | return builder->CreateFCmpULE(lhs, rhs); |
| 637 | } |
| 638 | |
| 639 | Value *Nucleus::createFCmpUNE(Value *lhs, Value *rhs) |
| 640 | { |
| 641 | return builder->CreateFCmpULE(lhs, rhs); |
| 642 | } |
| 643 | |
| 644 | Value *Nucleus::createCall(Value *callee) |
| 645 | { |
| 646 | return builder->CreateCall(callee); |
| 647 | } |
| 648 | |
| 649 | Value *Nucleus::createCall(Value *callee, Value *arg) |
| 650 | { |
| 651 | return builder->CreateCall(callee, arg); |
| 652 | } |
| 653 | |
| 654 | Value *Nucleus::createCall(Value *callee, Value *arg1, Value *arg2) |
| 655 | { |
| 656 | return builder->CreateCall2(callee, arg1, arg2); |
| 657 | } |
| 658 | |
| 659 | Value *Nucleus::createCall(Value *callee, Value *arg1, Value *arg2, Value *arg3) |
| 660 | { |
| 661 | return builder->CreateCall3(callee, arg1, arg2, arg3); |
| 662 | } |
| 663 | |
| 664 | Value *Nucleus::createCall(Value *callee, Value *arg1, Value *arg2, Value *arg3, Value *arg4) |
| 665 | { |
| 666 | return builder->CreateCall4(callee, arg1, arg2, arg3, arg4); |
| 667 | } |
| 668 | |
| 669 | Value *Nucleus::createExtractElement(Value *vector, int index) |
| 670 | { |
| 671 | return builder->CreateExtractElement(vector, createConstantInt(index)); |
| 672 | } |
| 673 | |
| 674 | Value *Nucleus::createInsertElement(Value *vector, Value *element, int index) |
| 675 | { |
| 676 | return builder->CreateInsertElement(vector, element, createConstantInt(index)); |
| 677 | } |
| 678 | |
| 679 | Value *Nucleus::createShuffleVector(Value *V1, Value *V2, Value *mask) |
| 680 | { |
| 681 | return builder->CreateShuffleVector(V1, V2, mask); |
| 682 | } |
| 683 | |
| 684 | Value *Nucleus::createSelect(Value *C, Value *ifTrue, Value *ifFalse) |
| 685 | { |
| 686 | return builder->CreateSelect(C, ifTrue, ifFalse); |
| 687 | } |
| 688 | |
| 689 | Value *Nucleus::createSwitch(llvm::Value *V, llvm::BasicBlock *Dest, unsigned NumCases) |
| 690 | { |
| 691 | return builder->CreateSwitch(V, Dest, NumCases); |
| 692 | } |
| 693 | |
| 694 | void Nucleus::addSwitchCase(llvm::Value *Switch, int Case, llvm::BasicBlock *Branch) |
| 695 | { |
| 696 | static_cast<SwitchInst*>(Switch)->addCase(Nucleus::createConstantInt(Case), Branch); |
| 697 | } |
| 698 | |
| 699 | Value *Nucleus::createUnreachable() |
| 700 | { |
| 701 | return builder->CreateUnreachable(); |
| 702 | } |
| 703 | |
| 704 | Value *Nucleus::createSwizzle(Value *val, unsigned char select) |
| 705 | { |
| 706 | Constant *swizzle[4]; |
| 707 | swizzle[0] = Nucleus::createConstantInt((select >> 0) & 0x03); |
| 708 | swizzle[1] = Nucleus::createConstantInt((select >> 2) & 0x03); |
| 709 | swizzle[2] = Nucleus::createConstantInt((select >> 4) & 0x03); |
| 710 | swizzle[3] = Nucleus::createConstantInt((select >> 6) & 0x03); |
| 711 | |
| 712 | Value *shuffle = Nucleus::createShuffleVector(val, UndefValue::get(val->getType()), Nucleus::createConstantVector(swizzle, 4)); |
| 713 | |
| 714 | return shuffle; |
| 715 | } |
| 716 | |
| 717 | Value *Nucleus::createMask(Value *lhs, Value *rhs, unsigned char select) |
| 718 | { |
| 719 | bool mask[4] = {false, false, false, false}; |
| 720 | |
| 721 | mask[(select >> 0) & 0x03] = true; |
| 722 | mask[(select >> 2) & 0x03] = true; |
| 723 | mask[(select >> 4) & 0x03] = true; |
| 724 | mask[(select >> 6) & 0x03] = true; |
| 725 | |
| 726 | Constant *swizzle[4]; |
| 727 | swizzle[0] = Nucleus::createConstantInt(mask[0] ? 4 : 0); |
| 728 | swizzle[1] = Nucleus::createConstantInt(mask[1] ? 5 : 1); |
| 729 | swizzle[2] = Nucleus::createConstantInt(mask[2] ? 6 : 2); |
| 730 | swizzle[3] = Nucleus::createConstantInt(mask[3] ? 7 : 3); |
| 731 | |
| 732 | Value *shuffle = Nucleus::createShuffleVector(lhs, rhs, Nucleus::createConstantVector(swizzle, 4)); |
| 733 | |
| 734 | return shuffle; |
| 735 | } |
| 736 | |
| 737 | const llvm::GlobalValue *Nucleus::getGlobalValueAtAddress(void *Addr) |
| 738 | { |
| 739 | return executionEngine->getGlobalValueAtAddress(Addr); |
| 740 | } |
| 741 | |
| 742 | void Nucleus::addGlobalMapping(const llvm::GlobalValue *GV, void *Addr) |
| 743 | { |
| 744 | executionEngine->addGlobalMapping(GV, Addr); |
| 745 | } |
| 746 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 747 | llvm::GlobalValue *Nucleus::createGlobalValue(llvm::Type *Ty, bool isConstant, unsigned int Align) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 748 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 749 | llvm::GlobalValue *global = new llvm::GlobalVariable(*Nucleus::getModule(), Ty, isConstant, llvm::GlobalValue::ExternalLinkage, 0, ""); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 750 | global->setAlignment(Align); |
| 751 | |
| 752 | return global; |
| 753 | } |
| 754 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 755 | llvm::Type *Nucleus::getPointerType(llvm::Type *ElementType) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 756 | { |
| 757 | return llvm::PointerType::get(ElementType, 0); |
| 758 | } |
| 759 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 760 | llvm::Constant *Nucleus::createNullValue(llvm::Type *Ty) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 761 | { |
| 762 | return llvm::Constant::getNullValue(Ty); |
| 763 | } |
| 764 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 765 | llvm::ConstantInt *Nucleus::createConstantInt(int64_t i) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 766 | { |
| 767 | return llvm::ConstantInt::get(Type::getInt64Ty(*context), i, true); |
| 768 | } |
| 769 | |
| 770 | llvm::ConstantInt *Nucleus::createConstantInt(int i) |
| 771 | { |
| 772 | return llvm::ConstantInt::get(Type::getInt32Ty(*context), i, true); |
| 773 | } |
| 774 | |
| 775 | llvm::ConstantInt *Nucleus::createConstantInt(unsigned int i) |
| 776 | { |
| 777 | return llvm::ConstantInt::get(Type::getInt32Ty(*context), i, false); |
| 778 | } |
| 779 | |
| 780 | llvm::ConstantInt *Nucleus::createConstantBool(bool b) |
| 781 | { |
| 782 | return llvm::ConstantInt::get(Type::getInt1Ty(*context), b); |
| 783 | } |
| 784 | |
| 785 | llvm::ConstantInt *Nucleus::createConstantByte(signed char i) |
| 786 | { |
| 787 | return llvm::ConstantInt::get(Type::getInt8Ty(*context), i, true); |
| 788 | } |
| 789 | |
| 790 | llvm::ConstantInt *Nucleus::createConstantByte(unsigned char i) |
| 791 | { |
| 792 | return llvm::ConstantInt::get(Type::getInt8Ty(*context), i, false); |
| 793 | } |
| 794 | |
| 795 | llvm::ConstantInt *Nucleus::createConstantShort(short i) |
| 796 | { |
| 797 | return llvm::ConstantInt::get(Type::getInt16Ty(*context), i, true); |
| 798 | } |
| 799 | |
| 800 | llvm::ConstantInt *Nucleus::createConstantShort(unsigned short i) |
| 801 | { |
| 802 | return llvm::ConstantInt::get(Type::getInt16Ty(*context), i, false); |
| 803 | } |
| 804 | |
| 805 | llvm::Constant *Nucleus::createConstantFloat(float x) |
| 806 | { |
| 807 | return ConstantFP::get(Float::getType(), x); |
| 808 | } |
| 809 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 810 | llvm::Value *Nucleus::createNullPointer(llvm::Type *Ty) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 811 | { |
| 812 | return llvm::ConstantPointerNull::get(llvm::PointerType::get(Ty, 0)); |
| 813 | } |
| 814 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 815 | llvm::Value *Nucleus::createConstantVector(llvm::Constant *const *Vals, unsigned NumVals) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 816 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 817 | return llvm::ConstantVector::get(llvm::ArrayRef<llvm::Constant*>(Vals, NumVals)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 818 | } |
| 819 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 820 | Type *Void::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 821 | { |
| 822 | return Type::getVoidTy(*Nucleus::getContext()); |
| 823 | } |
| 824 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 825 | LValue::LValue(llvm::Type *type, int arraySize) |
| 826 | { |
| 827 | address = Nucleus::allocateStackVariable(type, arraySize); |
| 828 | } |
| 829 | |
| 830 | llvm::Value *LValue::loadValue(unsigned int alignment) const |
| 831 | { |
| 832 | return Nucleus::createLoad(address, false, alignment); |
| 833 | } |
| 834 | |
| 835 | llvm::Value *LValue::storeValue(llvm::Value *value, unsigned int alignment) const |
| 836 | { |
| 837 | return Nucleus::createStore(value, address, false, alignment); |
| 838 | } |
| 839 | |
| 840 | llvm::Value *LValue::getAddress(llvm::Value *index) const |
| 841 | { |
| 842 | return Nucleus::createGEP(address, index); |
| 843 | } |
| 844 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 845 | Type *MMX::getType() |
| 846 | { |
| 847 | return Type::getX86_MMXTy(*Nucleus::getContext()); |
| 848 | } |
| 849 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 850 | Bool::Bool(Argument *argument) |
| 851 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 852 | storeValue(argument); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 853 | } |
| 854 | |
| 855 | Bool::Bool() |
| 856 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 857 | } |
| 858 | |
| 859 | Bool::Bool(bool x) |
| 860 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 861 | storeValue(Nucleus::createConstantBool(x)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 862 | } |
| 863 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 864 | Bool::Bool(RValue<Bool> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 865 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 866 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 867 | } |
| 868 | |
| 869 | Bool::Bool(const Bool &rhs) |
| 870 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 871 | Value *value = rhs.loadValue(); |
| 872 | storeValue(value); |
| 873 | } |
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 | Bool::Bool(const Reference<Bool> &rhs) |
| 876 | { |
| 877 | Value *value = rhs.loadValue(); |
| 878 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 879 | } |
| 880 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 881 | RValue<Bool> Bool::operator=(RValue<Bool> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 882 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 883 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 884 | |
| 885 | return rhs; |
| 886 | } |
| 887 | |
| 888 | RValue<Bool> Bool::operator=(const Bool &rhs) const |
| 889 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 890 | Value *value = rhs.loadValue(); |
| 891 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 892 | |
| 893 | return RValue<Bool>(value); |
| 894 | } |
| 895 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 896 | RValue<Bool> Bool::operator=(const Reference<Bool> &rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 897 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 898 | Value *value = rhs.loadValue(); |
| 899 | storeValue(value); |
| 900 | |
| 901 | return RValue<Bool>(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 902 | } |
| 903 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 904 | RValue<Bool> operator!(RValue<Bool> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 905 | { |
| 906 | return RValue<Bool>(Nucleus::createNot(val.value)); |
| 907 | } |
| 908 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 909 | RValue<Bool> operator&&(RValue<Bool> lhs, RValue<Bool> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 910 | { |
| 911 | return RValue<Bool>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 912 | } |
| 913 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 914 | RValue<Bool> operator||(RValue<Bool> lhs, RValue<Bool> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 915 | { |
| 916 | return RValue<Bool>(Nucleus::createOr(lhs.value, rhs.value)); |
| 917 | } |
| 918 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 919 | Type *Bool::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 920 | { |
| 921 | return Type::getInt1Ty(*Nucleus::getContext()); |
| 922 | } |
| 923 | |
| 924 | Byte::Byte(Argument *argument) |
| 925 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 926 | storeValue(argument); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 927 | } |
| 928 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 929 | Byte::Byte(RValue<Int> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 930 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 931 | Value *integer = Nucleus::createTrunc(cast.value, Byte::getType()); |
| 932 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 933 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 934 | } |
| 935 | |
| 936 | Byte::Byte() |
| 937 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 938 | } |
| 939 | |
| 940 | Byte::Byte(int x) |
| 941 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 942 | storeValue(Nucleus::createConstantByte((unsigned char)x)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 943 | } |
| 944 | |
| 945 | Byte::Byte(unsigned char x) |
| 946 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 947 | storeValue(Nucleus::createConstantByte(x)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 948 | } |
| 949 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 950 | Byte::Byte(RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 951 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 952 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 953 | } |
| 954 | |
| 955 | Byte::Byte(const Byte &rhs) |
| 956 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 957 | Value *value = rhs.loadValue(); |
| 958 | storeValue(value); |
| 959 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 960 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 961 | Byte::Byte(const Reference<Byte> &rhs) |
| 962 | { |
| 963 | Value *value = rhs.loadValue(); |
| 964 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 965 | } |
| 966 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 967 | RValue<Byte> Byte::operator=(RValue<Byte> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 968 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 969 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 970 | |
| 971 | return rhs; |
| 972 | } |
| 973 | |
| 974 | RValue<Byte> Byte::operator=(const Byte &rhs) const |
| 975 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 976 | Value *value = rhs.loadValue(); |
| 977 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 978 | |
| 979 | return RValue<Byte>(value); |
| 980 | } |
| 981 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 982 | RValue<Byte> Byte::operator=(const Reference<Byte> &rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 983 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 984 | Value *value = rhs.loadValue(); |
| 985 | storeValue(value); |
| 986 | |
| 987 | return RValue<Byte>(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 988 | } |
| 989 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 990 | RValue<Byte> operator+(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 991 | { |
| 992 | return RValue<Byte>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 993 | } |
| 994 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 995 | RValue<Byte> operator-(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 996 | { |
| 997 | return RValue<Byte>(Nucleus::createSub(lhs.value, rhs.value)); |
| 998 | } |
| 999 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1000 | RValue<Byte> operator*(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1001 | { |
| 1002 | return RValue<Byte>(Nucleus::createMul(lhs.value, rhs.value)); |
| 1003 | } |
| 1004 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1005 | RValue<Byte> operator/(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1006 | { |
| 1007 | return RValue<Byte>(Nucleus::createUDiv(lhs.value, rhs.value)); |
| 1008 | } |
| 1009 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1010 | RValue<Byte> operator%(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1011 | { |
| 1012 | return RValue<Byte>(Nucleus::createURem(lhs.value, rhs.value)); |
| 1013 | } |
| 1014 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1015 | RValue<Byte> operator&(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1016 | { |
| 1017 | return RValue<Byte>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 1018 | } |
| 1019 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1020 | RValue<Byte> operator|(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1021 | { |
| 1022 | return RValue<Byte>(Nucleus::createOr(lhs.value, rhs.value)); |
| 1023 | } |
| 1024 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1025 | RValue<Byte> operator^(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1026 | { |
| 1027 | return RValue<Byte>(Nucleus::createXor(lhs.value, rhs.value)); |
| 1028 | } |
| 1029 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1030 | RValue<Byte> operator<<(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1031 | { |
| 1032 | return RValue<Byte>(Nucleus::createShl(lhs.value, rhs.value)); |
| 1033 | } |
| 1034 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1035 | RValue<Byte> operator>>(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1036 | { |
| 1037 | return RValue<Byte>(Nucleus::createLShr(lhs.value, rhs.value)); |
| 1038 | } |
| 1039 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1040 | RValue<Byte> operator+=(const Byte &lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1041 | { |
| 1042 | return lhs = lhs + rhs; |
| 1043 | } |
| 1044 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1045 | RValue<Byte> operator-=(const Byte &lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1046 | { |
| 1047 | return lhs = lhs - rhs; |
| 1048 | } |
| 1049 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1050 | RValue<Byte> operator*=(const Byte &lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1051 | { |
| 1052 | return lhs = lhs * rhs; |
| 1053 | } |
| 1054 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1055 | RValue<Byte> operator/=(const Byte &lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1056 | { |
| 1057 | return lhs = lhs / rhs; |
| 1058 | } |
| 1059 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1060 | RValue<Byte> operator%=(const Byte &lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1061 | { |
| 1062 | return lhs = lhs % rhs; |
| 1063 | } |
| 1064 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1065 | RValue<Byte> operator&=(const Byte &lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1066 | { |
| 1067 | return lhs = lhs & rhs; |
| 1068 | } |
| 1069 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1070 | RValue<Byte> operator|=(const Byte &lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1071 | { |
| 1072 | return lhs = lhs | rhs; |
| 1073 | } |
| 1074 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1075 | RValue<Byte> operator^=(const Byte &lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1076 | { |
| 1077 | return lhs = lhs ^ rhs; |
| 1078 | } |
| 1079 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1080 | RValue<Byte> operator<<=(const Byte &lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1081 | { |
| 1082 | return lhs = lhs << rhs; |
| 1083 | } |
| 1084 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1085 | RValue<Byte> operator>>=(const Byte &lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1086 | { |
| 1087 | return lhs = lhs >> rhs; |
| 1088 | } |
| 1089 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1090 | RValue<Byte> operator+(RValue<Byte> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1091 | { |
| 1092 | return val; |
| 1093 | } |
| 1094 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1095 | RValue<Byte> operator-(RValue<Byte> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1096 | { |
| 1097 | return RValue<Byte>(Nucleus::createNeg(val.value)); |
| 1098 | } |
| 1099 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1100 | RValue<Byte> operator~(RValue<Byte> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1101 | { |
| 1102 | return RValue<Byte>(Nucleus::createNot(val.value)); |
| 1103 | } |
| 1104 | |
| 1105 | RValue<Byte> operator++(const Byte &val, int) // Post-increment |
| 1106 | { |
| 1107 | RValue<Byte> res = val; |
| 1108 | |
| 1109 | Value *inc = Nucleus::createAdd(res.value, Nucleus::createConstantByte((unsigned char)1)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1110 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1111 | |
| 1112 | return res; |
| 1113 | } |
| 1114 | |
| 1115 | const Byte &operator++(const Byte &val) // Pre-increment |
| 1116 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1117 | Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantByte((unsigned char)1)); |
| 1118 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1119 | |
| 1120 | return val; |
| 1121 | } |
| 1122 | |
| 1123 | RValue<Byte> operator--(const Byte &val, int) // Post-decrement |
| 1124 | { |
| 1125 | RValue<Byte> res = val; |
| 1126 | |
| 1127 | Value *inc = Nucleus::createSub(res.value, Nucleus::createConstantByte((unsigned char)1)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1128 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1129 | |
| 1130 | return res; |
| 1131 | } |
| 1132 | |
| 1133 | const Byte &operator--(const Byte &val) // Pre-decrement |
| 1134 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1135 | Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantByte((unsigned char)1)); |
| 1136 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1137 | |
| 1138 | return val; |
| 1139 | } |
| 1140 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1141 | RValue<Bool> operator<(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1142 | { |
| 1143 | return RValue<Bool>(Nucleus::createICmpULT(lhs.value, rhs.value)); |
| 1144 | } |
| 1145 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1146 | RValue<Bool> operator<=(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1147 | { |
| 1148 | return RValue<Bool>(Nucleus::createICmpULE(lhs.value, rhs.value)); |
| 1149 | } |
| 1150 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1151 | RValue<Bool> operator>(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1152 | { |
| 1153 | return RValue<Bool>(Nucleus::createICmpUGT(lhs.value, rhs.value)); |
| 1154 | } |
| 1155 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1156 | RValue<Bool> operator>=(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1157 | { |
| 1158 | return RValue<Bool>(Nucleus::createICmpUGE(lhs.value, rhs.value)); |
| 1159 | } |
| 1160 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1161 | RValue<Bool> operator!=(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1162 | { |
| 1163 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value)); |
| 1164 | } |
| 1165 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1166 | RValue<Bool> operator==(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1167 | { |
| 1168 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value)); |
| 1169 | } |
| 1170 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1171 | Type *Byte::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1172 | { |
| 1173 | return Type::getInt8Ty(*Nucleus::getContext()); |
| 1174 | } |
| 1175 | |
| 1176 | SByte::SByte(Argument *argument) |
| 1177 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1178 | storeValue(argument); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1179 | } |
| 1180 | |
| 1181 | SByte::SByte() |
| 1182 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1183 | } |
| 1184 | |
| 1185 | SByte::SByte(signed char x) |
| 1186 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1187 | storeValue(Nucleus::createConstantByte(x)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1188 | } |
| 1189 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1190 | SByte::SByte(RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1191 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1192 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1193 | } |
| 1194 | |
| 1195 | SByte::SByte(const SByte &rhs) |
| 1196 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1197 | Value *value = rhs.loadValue(); |
| 1198 | storeValue(value); |
| 1199 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1200 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1201 | SByte::SByte(const Reference<SByte> &rhs) |
| 1202 | { |
| 1203 | Value *value = rhs.loadValue(); |
| 1204 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1205 | } |
| 1206 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1207 | RValue<SByte> SByte::operator=(RValue<SByte> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1208 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1209 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1210 | |
| 1211 | return rhs; |
| 1212 | } |
| 1213 | |
| 1214 | RValue<SByte> SByte::operator=(const SByte &rhs) const |
| 1215 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1216 | Value *value = rhs.loadValue(); |
| 1217 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1218 | |
| 1219 | return RValue<SByte>(value); |
| 1220 | } |
| 1221 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1222 | RValue<SByte> SByte::operator=(const Reference<SByte> &rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1223 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1224 | Value *value = rhs.loadValue(); |
| 1225 | storeValue(value); |
| 1226 | |
| 1227 | return RValue<SByte>(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1228 | } |
| 1229 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1230 | RValue<SByte> operator+(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1231 | { |
| 1232 | return RValue<SByte>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 1233 | } |
| 1234 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1235 | RValue<SByte> operator-(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1236 | { |
| 1237 | return RValue<SByte>(Nucleus::createSub(lhs.value, rhs.value)); |
| 1238 | } |
| 1239 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1240 | RValue<SByte> operator*(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1241 | { |
| 1242 | return RValue<SByte>(Nucleus::createMul(lhs.value, rhs.value)); |
| 1243 | } |
| 1244 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1245 | RValue<SByte> operator/(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1246 | { |
| 1247 | return RValue<SByte>(Nucleus::createSDiv(lhs.value, rhs.value)); |
| 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::createSRem(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::createAnd(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::createOr(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::createXor(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::createShl(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::createAShr(lhs.value, rhs.value)); |
| 1278 | } |
| 1279 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1280 | RValue<SByte> operator+=(const SByte &lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1281 | { |
| 1282 | return lhs = lhs + rhs; |
| 1283 | } |
| 1284 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1285 | RValue<SByte> operator-=(const SByte &lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1286 | { |
| 1287 | return lhs = lhs - rhs; |
| 1288 | } |
| 1289 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1290 | RValue<SByte> operator*=(const SByte &lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1291 | { |
| 1292 | return lhs = lhs * rhs; |
| 1293 | } |
| 1294 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1295 | RValue<SByte> operator/=(const SByte &lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1296 | { |
| 1297 | return lhs = lhs / rhs; |
| 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+(RValue<SByte> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1331 | { |
| 1332 | return val; |
| 1333 | } |
| 1334 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1335 | RValue<SByte> operator-(RValue<SByte> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1336 | { |
| 1337 | return RValue<SByte>(Nucleus::createNeg(val.value)); |
| 1338 | } |
| 1339 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1340 | RValue<SByte> operator~(RValue<SByte> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1341 | { |
| 1342 | return RValue<SByte>(Nucleus::createNot(val.value)); |
| 1343 | } |
| 1344 | |
| 1345 | RValue<SByte> operator++(const SByte &val, int) // Post-increment |
| 1346 | { |
| 1347 | RValue<SByte> res = val; |
| 1348 | |
| 1349 | Value *inc = Nucleus::createAdd(res.value, Nucleus::createConstantByte((signed char)1)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1350 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1351 | |
| 1352 | return res; |
| 1353 | } |
| 1354 | |
| 1355 | const SByte &operator++(const SByte &val) // Pre-increment |
| 1356 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1357 | Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantByte((signed char)1)); |
| 1358 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1359 | |
| 1360 | return val; |
| 1361 | } |
| 1362 | |
| 1363 | RValue<SByte> operator--(const SByte &val, int) // Post-decrement |
| 1364 | { |
| 1365 | RValue<SByte> res = val; |
| 1366 | |
| 1367 | Value *inc = Nucleus::createSub(res.value, Nucleus::createConstantByte((signed char)1)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1368 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1369 | |
| 1370 | return res; |
| 1371 | } |
| 1372 | |
| 1373 | const SByte &operator--(const SByte &val) // Pre-decrement |
| 1374 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1375 | Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantByte((signed char)1)); |
| 1376 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1377 | |
| 1378 | return val; |
| 1379 | } |
| 1380 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1381 | RValue<Bool> operator<(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1382 | { |
| 1383 | return RValue<Bool>(Nucleus::createICmpSLT(lhs.value, rhs.value)); |
| 1384 | } |
| 1385 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1386 | RValue<Bool> operator<=(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1387 | { |
| 1388 | return RValue<Bool>(Nucleus::createICmpSLE(lhs.value, rhs.value)); |
| 1389 | } |
| 1390 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1391 | RValue<Bool> operator>(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1392 | { |
| 1393 | return RValue<Bool>(Nucleus::createICmpSGT(lhs.value, rhs.value)); |
| 1394 | } |
| 1395 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1396 | RValue<Bool> operator>=(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1397 | { |
| 1398 | return RValue<Bool>(Nucleus::createICmpSGE(lhs.value, rhs.value)); |
| 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::createICmpNE(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::createICmpEQ(lhs.value, rhs.value)); |
| 1409 | } |
| 1410 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1411 | Type *SByte::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1412 | { |
| 1413 | return Type::getInt8Ty(*Nucleus::getContext()); |
| 1414 | } |
| 1415 | |
| 1416 | Short::Short(Argument *argument) |
| 1417 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1418 | storeValue(argument); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1419 | } |
| 1420 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1421 | Short::Short(RValue<Int> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1422 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1423 | Value *integer = Nucleus::createTrunc(cast.value, Short::getType()); |
| 1424 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1425 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1426 | } |
| 1427 | |
| 1428 | Short::Short() |
| 1429 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1430 | } |
| 1431 | |
| 1432 | Short::Short(short x) |
| 1433 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1434 | storeValue(Nucleus::createConstantShort(x)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1435 | } |
| 1436 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1437 | Short::Short(RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1438 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1439 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1440 | } |
| 1441 | |
| 1442 | Short::Short(const Short &rhs) |
| 1443 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1444 | Value *value = rhs.loadValue(); |
| 1445 | storeValue(value); |
| 1446 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1447 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1448 | Short::Short(const Reference<Short> &rhs) |
| 1449 | { |
| 1450 | Value *value = rhs.loadValue(); |
| 1451 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1452 | } |
| 1453 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1454 | RValue<Short> Short::operator=(RValue<Short> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1455 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1456 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1457 | |
| 1458 | return rhs; |
| 1459 | } |
| 1460 | |
| 1461 | RValue<Short> Short::operator=(const Short &rhs) const |
| 1462 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1463 | Value *value = rhs.loadValue(); |
| 1464 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1465 | |
| 1466 | return RValue<Short>(value); |
| 1467 | } |
| 1468 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1469 | RValue<Short> Short::operator=(const Reference<Short> &rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1470 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1471 | Value *value = rhs.loadValue(); |
| 1472 | storeValue(value); |
| 1473 | |
| 1474 | return RValue<Short>(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1475 | } |
| 1476 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1477 | RValue<Short> operator+(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1478 | { |
| 1479 | return RValue<Short>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 1480 | } |
| 1481 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1482 | RValue<Short> operator-(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1483 | { |
| 1484 | return RValue<Short>(Nucleus::createSub(lhs.value, rhs.value)); |
| 1485 | } |
| 1486 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1487 | RValue<Short> operator*(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1488 | { |
| 1489 | return RValue<Short>(Nucleus::createMul(lhs.value, rhs.value)); |
| 1490 | } |
| 1491 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1492 | RValue<Short> operator/(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1493 | { |
| 1494 | return RValue<Short>(Nucleus::createSDiv(lhs.value, rhs.value)); |
| 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::createSRem(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::createAnd(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::createOr(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::createXor(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::createShl(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::createAShr(lhs.value, rhs.value)); |
| 1525 | } |
| 1526 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1527 | RValue<Short> operator+=(const Short &lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1528 | { |
| 1529 | return lhs = lhs + rhs; |
| 1530 | } |
| 1531 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1532 | RValue<Short> operator-=(const Short &lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1533 | { |
| 1534 | return lhs = lhs - rhs; |
| 1535 | } |
| 1536 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1537 | RValue<Short> operator*=(const Short &lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1538 | { |
| 1539 | return lhs = lhs * rhs; |
| 1540 | } |
| 1541 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1542 | RValue<Short> operator/=(const Short &lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1543 | { |
| 1544 | return lhs = lhs / rhs; |
| 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+(RValue<Short> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1578 | { |
| 1579 | return val; |
| 1580 | } |
| 1581 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1582 | RValue<Short> operator-(RValue<Short> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1583 | { |
| 1584 | return RValue<Short>(Nucleus::createNeg(val.value)); |
| 1585 | } |
| 1586 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1587 | RValue<Short> operator~(RValue<Short> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1588 | { |
| 1589 | return RValue<Short>(Nucleus::createNot(val.value)); |
| 1590 | } |
| 1591 | |
| 1592 | RValue<Short> operator++(const Short &val, int) // Post-increment |
| 1593 | { |
| 1594 | RValue<Short> res = val; |
| 1595 | |
| 1596 | Value *inc = Nucleus::createAdd(res.value, Nucleus::createConstantShort((short)1)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1597 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1598 | |
| 1599 | return res; |
| 1600 | } |
| 1601 | |
| 1602 | const Short &operator++(const Short &val) // Pre-increment |
| 1603 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1604 | Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantShort((short)1)); |
| 1605 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1606 | |
| 1607 | return val; |
| 1608 | } |
| 1609 | |
| 1610 | RValue<Short> operator--(const Short &val, int) // Post-decrement |
| 1611 | { |
| 1612 | RValue<Short> res = val; |
| 1613 | |
| 1614 | Value *inc = Nucleus::createSub(res.value, Nucleus::createConstantShort((short)1)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1615 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1616 | |
| 1617 | return res; |
| 1618 | } |
| 1619 | |
| 1620 | const Short &operator--(const Short &val) // Pre-decrement |
| 1621 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1622 | Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantShort((short)1)); |
| 1623 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1624 | |
| 1625 | return val; |
| 1626 | } |
| 1627 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1628 | RValue<Bool> operator<(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1629 | { |
| 1630 | return RValue<Bool>(Nucleus::createICmpSLT(lhs.value, rhs.value)); |
| 1631 | } |
| 1632 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1633 | RValue<Bool> operator<=(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1634 | { |
| 1635 | return RValue<Bool>(Nucleus::createICmpSLE(lhs.value, rhs.value)); |
| 1636 | } |
| 1637 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1638 | RValue<Bool> operator>(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1639 | { |
| 1640 | return RValue<Bool>(Nucleus::createICmpSGT(lhs.value, rhs.value)); |
| 1641 | } |
| 1642 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1643 | RValue<Bool> operator>=(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1644 | { |
| 1645 | return RValue<Bool>(Nucleus::createICmpSGE(lhs.value, rhs.value)); |
| 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::createICmpNE(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::createICmpEQ(lhs.value, rhs.value)); |
| 1656 | } |
| 1657 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1658 | Type *Short::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1659 | { |
| 1660 | return Type::getInt16Ty(*Nucleus::getContext()); |
| 1661 | } |
| 1662 | |
| 1663 | UShort::UShort(Argument *argument) |
| 1664 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1665 | storeValue(argument); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1666 | } |
| 1667 | |
| 1668 | UShort::UShort() |
| 1669 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1670 | } |
| 1671 | |
| 1672 | UShort::UShort(unsigned short x) |
| 1673 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1674 | storeValue(Nucleus::createConstantShort(x)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1675 | } |
| 1676 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1677 | UShort::UShort(RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1678 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1679 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1680 | } |
| 1681 | |
| 1682 | UShort::UShort(const UShort &rhs) |
| 1683 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1684 | Value *value = rhs.loadValue(); |
| 1685 | storeValue(value); |
| 1686 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1687 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1688 | UShort::UShort(const Reference<UShort> &rhs) |
| 1689 | { |
| 1690 | Value *value = rhs.loadValue(); |
| 1691 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1692 | } |
| 1693 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1694 | RValue<UShort> UShort::operator=(RValue<UShort> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1695 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1696 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1697 | |
| 1698 | return rhs; |
| 1699 | } |
| 1700 | |
| 1701 | RValue<UShort> UShort::operator=(const UShort &rhs) const |
| 1702 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1703 | Value *value = rhs.loadValue(); |
| 1704 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1705 | |
| 1706 | return RValue<UShort>(value); |
| 1707 | } |
| 1708 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1709 | RValue<UShort> UShort::operator=(const Reference<UShort> &rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1710 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1711 | Value *value = rhs.loadValue(); |
| 1712 | storeValue(value); |
| 1713 | |
| 1714 | return RValue<UShort>(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1715 | } |
| 1716 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1717 | RValue<UShort> operator+(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1718 | { |
| 1719 | return RValue<UShort>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 1720 | } |
| 1721 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1722 | RValue<UShort> operator-(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1723 | { |
| 1724 | return RValue<UShort>(Nucleus::createSub(lhs.value, rhs.value)); |
| 1725 | } |
| 1726 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1727 | RValue<UShort> operator*(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1728 | { |
| 1729 | return RValue<UShort>(Nucleus::createMul(lhs.value, rhs.value)); |
| 1730 | } |
| 1731 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1732 | RValue<UShort> operator/(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1733 | { |
| 1734 | return RValue<UShort>(Nucleus::createUDiv(lhs.value, rhs.value)); |
| 1735 | } |
| 1736 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1737 | RValue<UShort> operator%(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1738 | { |
| 1739 | return RValue<UShort>(Nucleus::createURem(lhs.value, rhs.value)); |
| 1740 | } |
| 1741 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1742 | RValue<UShort> operator&(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1743 | { |
| 1744 | return RValue<UShort>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 1745 | } |
| 1746 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1747 | RValue<UShort> operator|(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1748 | { |
| 1749 | return RValue<UShort>(Nucleus::createOr(lhs.value, rhs.value)); |
| 1750 | } |
| 1751 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1752 | RValue<UShort> operator^(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1753 | { |
| 1754 | return RValue<UShort>(Nucleus::createXor(lhs.value, rhs.value)); |
| 1755 | } |
| 1756 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1757 | RValue<UShort> operator<<(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1758 | { |
| 1759 | return RValue<UShort>(Nucleus::createShl(lhs.value, rhs.value)); |
| 1760 | } |
| 1761 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1762 | RValue<UShort> operator>>(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1763 | { |
| 1764 | return RValue<UShort>(Nucleus::createLShr(lhs.value, rhs.value)); |
| 1765 | } |
| 1766 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1767 | RValue<UShort> operator+=(const UShort &lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1768 | { |
| 1769 | return lhs = lhs + rhs; |
| 1770 | } |
| 1771 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1772 | RValue<UShort> operator-=(const UShort &lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1773 | { |
| 1774 | return lhs = lhs - rhs; |
| 1775 | } |
| 1776 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1777 | RValue<UShort> operator*=(const UShort &lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1778 | { |
| 1779 | return lhs = lhs * rhs; |
| 1780 | } |
| 1781 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1782 | RValue<UShort> operator/=(const UShort &lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1783 | { |
| 1784 | return lhs = lhs / rhs; |
| 1785 | } |
| 1786 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1787 | RValue<UShort> operator%=(const UShort &lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1788 | { |
| 1789 | return lhs = lhs % rhs; |
| 1790 | } |
| 1791 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1792 | RValue<UShort> operator&=(const UShort &lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1793 | { |
| 1794 | return lhs = lhs & rhs; |
| 1795 | } |
| 1796 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1797 | RValue<UShort> operator|=(const UShort &lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1798 | { |
| 1799 | return lhs = lhs | rhs; |
| 1800 | } |
| 1801 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1802 | RValue<UShort> operator^=(const UShort &lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1803 | { |
| 1804 | return lhs = lhs ^ rhs; |
| 1805 | } |
| 1806 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1807 | RValue<UShort> operator<<=(const UShort &lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1808 | { |
| 1809 | return lhs = lhs << rhs; |
| 1810 | } |
| 1811 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1812 | RValue<UShort> operator>>=(const UShort &lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1813 | { |
| 1814 | return lhs = lhs >> rhs; |
| 1815 | } |
| 1816 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1817 | RValue<UShort> operator+(RValue<UShort> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1818 | { |
| 1819 | return val; |
| 1820 | } |
| 1821 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1822 | RValue<UShort> operator-(RValue<UShort> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1823 | { |
| 1824 | return RValue<UShort>(Nucleus::createNeg(val.value)); |
| 1825 | } |
| 1826 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1827 | RValue<UShort> operator~(RValue<UShort> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1828 | { |
| 1829 | return RValue<UShort>(Nucleus::createNot(val.value)); |
| 1830 | } |
| 1831 | |
| 1832 | RValue<UShort> operator++(const UShort &val, int) // Post-increment |
| 1833 | { |
| 1834 | RValue<UShort> res = val; |
| 1835 | |
| 1836 | Value *inc = Nucleus::createAdd(res.value, Nucleus::createConstantShort((unsigned short)1)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1837 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1838 | |
| 1839 | return res; |
| 1840 | } |
| 1841 | |
| 1842 | const UShort &operator++(const UShort &val) // Pre-increment |
| 1843 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1844 | Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantShort((unsigned short)1)); |
| 1845 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1846 | |
| 1847 | return val; |
| 1848 | } |
| 1849 | |
| 1850 | RValue<UShort> operator--(const UShort &val, int) // Post-decrement |
| 1851 | { |
| 1852 | RValue<UShort> res = val; |
| 1853 | |
| 1854 | Value *inc = Nucleus::createSub(res.value, Nucleus::createConstantShort((unsigned short)1)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1855 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1856 | |
| 1857 | return res; |
| 1858 | } |
| 1859 | |
| 1860 | const UShort &operator--(const UShort &val) // Pre-decrement |
| 1861 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1862 | Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantShort((unsigned short)1)); |
| 1863 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1864 | |
| 1865 | return val; |
| 1866 | } |
| 1867 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1868 | RValue<Bool> operator<(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1869 | { |
| 1870 | return RValue<Bool>(Nucleus::createICmpULT(lhs.value, rhs.value)); |
| 1871 | } |
| 1872 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1873 | RValue<Bool> operator<=(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1874 | { |
| 1875 | return RValue<Bool>(Nucleus::createICmpULE(lhs.value, rhs.value)); |
| 1876 | } |
| 1877 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1878 | RValue<Bool> operator>(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1879 | { |
| 1880 | return RValue<Bool>(Nucleus::createICmpUGT(lhs.value, rhs.value)); |
| 1881 | } |
| 1882 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1883 | RValue<Bool> operator>=(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1884 | { |
| 1885 | return RValue<Bool>(Nucleus::createICmpUGE(lhs.value, rhs.value)); |
| 1886 | } |
| 1887 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1888 | RValue<Bool> operator!=(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1889 | { |
| 1890 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value)); |
| 1891 | } |
| 1892 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1893 | RValue<Bool> operator==(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1894 | { |
| 1895 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value)); |
| 1896 | } |
| 1897 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1898 | Type *UShort::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1899 | { |
| 1900 | return Type::getInt16Ty(*Nucleus::getContext()); |
| 1901 | } |
| 1902 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1903 | Type *Byte4::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1904 | { |
| 1905 | #if 0 |
| 1906 | return VectorType::get(Byte::getType(), 4); |
| 1907 | #else |
| 1908 | return UInt::getType(); // FIXME: LLVM doesn't manipulate it as one 32-bit block |
| 1909 | #endif |
| 1910 | } |
| 1911 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1912 | Type *SByte4::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1913 | { |
| 1914 | #if 0 |
| 1915 | return VectorType::get(SByte::getType(), 4); |
| 1916 | #else |
| 1917 | return Int::getType(); // FIXME: LLVM doesn't manipulate it as one 32-bit block |
| 1918 | #endif |
| 1919 | } |
| 1920 | |
| 1921 | Byte8::Byte8() |
| 1922 | { |
| 1923 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1924 | } |
| 1925 | |
| 1926 | Byte8::Byte8(byte x0, byte x1, byte x2, byte x3, byte x4, byte x5, byte x6, byte x7) |
| 1927 | { |
| 1928 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1929 | |
| 1930 | Constant *constantVector[8]; |
| 1931 | constantVector[0] = Nucleus::createConstantByte(x0); |
| 1932 | constantVector[1] = Nucleus::createConstantByte(x1); |
| 1933 | constantVector[2] = Nucleus::createConstantByte(x2); |
| 1934 | constantVector[3] = Nucleus::createConstantByte(x3); |
| 1935 | constantVector[4] = Nucleus::createConstantByte(x4); |
| 1936 | constantVector[5] = Nucleus::createConstantByte(x5); |
| 1937 | constantVector[6] = Nucleus::createConstantByte(x6); |
| 1938 | constantVector[7] = Nucleus::createConstantByte(x7); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1939 | Value *vector = Nucleus::createConstantVector(constantVector, 8); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1940 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1941 | storeValue(Nucleus::createBitCast(vector, getType())); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1942 | } |
| 1943 | |
| 1944 | Byte8::Byte8(int64_t x) |
| 1945 | { |
| 1946 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1947 | |
| 1948 | Constant *constantVector[8]; |
| 1949 | constantVector[0] = Nucleus::createConstantByte((unsigned char)(x >> 0)); |
| 1950 | constantVector[1] = Nucleus::createConstantByte((unsigned char)(x >> 8)); |
| 1951 | constantVector[2] = Nucleus::createConstantByte((unsigned char)(x >> 16)); |
| 1952 | constantVector[3] = Nucleus::createConstantByte((unsigned char)(x >> 24)); |
| 1953 | constantVector[4] = Nucleus::createConstantByte((unsigned char)(x >> 32)); |
| 1954 | constantVector[5] = Nucleus::createConstantByte((unsigned char)(x >> 40)); |
| 1955 | constantVector[6] = Nucleus::createConstantByte((unsigned char)(x >> 48)); |
| 1956 | constantVector[7] = Nucleus::createConstantByte((unsigned char)(x >> 56)); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1957 | Value *vector = Nucleus::createConstantVector(constantVector, 8); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1958 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1959 | storeValue(Nucleus::createBitCast(vector, getType())); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1960 | } |
| 1961 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1962 | Byte8::Byte8(RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1963 | { |
| 1964 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1965 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1966 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1967 | } |
| 1968 | |
| 1969 | Byte8::Byte8(const Byte8 &rhs) |
| 1970 | { |
| 1971 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1972 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1973 | Value *value = rhs.loadValue(); |
| 1974 | storeValue(value); |
| 1975 | } |
| 1976 | |
| 1977 | Byte8::Byte8(const Reference<Byte8> &rhs) |
| 1978 | { |
| 1979 | // xyzw.parent = this; |
| 1980 | |
| 1981 | Value *value = rhs.loadValue(); |
| 1982 | storeValue(value); |
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 | RValue<Byte8> Byte8::operator=(RValue<Byte8> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1986 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1987 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1988 | |
| 1989 | return rhs; |
| 1990 | } |
| 1991 | |
| 1992 | RValue<Byte8> Byte8::operator=(const Byte8 &rhs) const |
| 1993 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1994 | Value *value = rhs.loadValue(); |
| 1995 | storeValue(value); |
| 1996 | |
| 1997 | return RValue<Byte8>(value); |
| 1998 | } |
| 1999 | |
| 2000 | RValue<Byte8> Byte8::operator=(const Reference<Byte8> &rhs) const |
| 2001 | { |
| 2002 | Value *value = rhs.loadValue(); |
| 2003 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2004 | |
| 2005 | return RValue<Byte8>(value); |
| 2006 | } |
| 2007 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2008 | RValue<Byte8> operator+(RValue<Byte8> lhs, RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2009 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2010 | if(CPUID::supportsMMX2()) |
| 2011 | { |
| 2012 | return x86::paddb(lhs, rhs); |
| 2013 | } |
| 2014 | else |
| 2015 | { |
| 2016 | return RValue<Byte8>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 2017 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2018 | } |
| 2019 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2020 | RValue<Byte8> operator-(RValue<Byte8> lhs, RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2021 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2022 | if(CPUID::supportsMMX2()) |
| 2023 | { |
| 2024 | return x86::psubb(lhs, rhs); |
| 2025 | } |
| 2026 | else |
| 2027 | { |
| 2028 | return RValue<Byte8>(Nucleus::createSub(lhs.value, rhs.value)); |
| 2029 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2030 | } |
| 2031 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2032 | // RValue<Byte8> operator*(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 2033 | // { |
| 2034 | // return RValue<Byte8>(Nucleus::createMul(lhs.value, rhs.value)); |
| 2035 | // } |
| 2036 | |
| 2037 | // RValue<Byte8> operator/(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 2038 | // { |
| 2039 | // return RValue<Byte8>(Nucleus::createUDiv(lhs.value, rhs.value)); |
| 2040 | // } |
| 2041 | |
| 2042 | // RValue<Byte8> operator%(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 2043 | // { |
| 2044 | // return RValue<Byte8>(Nucleus::createURem(lhs.value, rhs.value)); |
| 2045 | // } |
| 2046 | |
| 2047 | RValue<Byte8> operator&(RValue<Byte8> lhs, RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2048 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2049 | if(CPUID::supportsMMX2()) |
| 2050 | { |
| 2051 | return As<Byte8>(x86::pand(As<Short4>(lhs), As<Short4>(rhs))); |
| 2052 | } |
| 2053 | else |
| 2054 | { |
| 2055 | return RValue<Byte8>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 2056 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2057 | } |
| 2058 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2059 | RValue<Byte8> operator|(RValue<Byte8> lhs, RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2060 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2061 | if(CPUID::supportsMMX2()) |
| 2062 | { |
| 2063 | return As<Byte8>(x86::por(As<Short4>(lhs), As<Short4>(rhs))); |
| 2064 | } |
| 2065 | else |
| 2066 | { |
| 2067 | return RValue<Byte8>(Nucleus::createOr(lhs.value, rhs.value)); |
| 2068 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2069 | } |
| 2070 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2071 | RValue<Byte8> operator^(RValue<Byte8> lhs, RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2072 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2073 | if(CPUID::supportsMMX2()) |
| 2074 | { |
| 2075 | return As<Byte8>(x86::pxor(As<Short4>(lhs), As<Short4>(rhs))); |
| 2076 | } |
| 2077 | else |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2078 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2079 | return RValue<Byte8>(Nucleus::createXor(lhs.value, rhs.value)); |
| 2080 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2081 | } |
| 2082 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2083 | // RValue<Byte8> operator<<(RValue<Byte8> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2084 | // { |
| 2085 | // return RValue<Byte8>(Nucleus::createShl(lhs.value, rhs.value)); |
| 2086 | // } |
| 2087 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2088 | // RValue<Byte8> operator>>(RValue<Byte8> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2089 | // { |
| 2090 | // return RValue<Byte8>(Nucleus::createLShr(lhs.value, rhs.value)); |
| 2091 | // } |
| 2092 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2093 | RValue<Byte8> operator+=(const Byte8 &lhs, RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2094 | { |
| 2095 | return lhs = lhs + rhs; |
| 2096 | } |
| 2097 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2098 | RValue<Byte8> operator-=(const Byte8 &lhs, RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2099 | { |
| 2100 | return lhs = lhs - rhs; |
| 2101 | } |
| 2102 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2103 | // RValue<Byte8> operator*=(const Byte8 &lhs, RValue<Byte8> rhs) |
| 2104 | // { |
| 2105 | // return lhs = lhs * rhs; |
| 2106 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2107 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2108 | // RValue<Byte8> operator/=(const Byte8 &lhs, RValue<Byte8> rhs) |
| 2109 | // { |
| 2110 | // return lhs = lhs / rhs; |
| 2111 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2112 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2113 | // RValue<Byte8> operator%=(const Byte8 &lhs, RValue<Byte8> rhs) |
| 2114 | // { |
| 2115 | // return lhs = lhs % rhs; |
| 2116 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2117 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2118 | RValue<Byte8> operator&=(const Byte8 &lhs, RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2119 | { |
| 2120 | return lhs = lhs & rhs; |
| 2121 | } |
| 2122 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2123 | RValue<Byte8> operator|=(const Byte8 &lhs, RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2124 | { |
| 2125 | return lhs = lhs | rhs; |
| 2126 | } |
| 2127 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2128 | RValue<Byte8> operator^=(const Byte8 &lhs, RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2129 | { |
| 2130 | return lhs = lhs ^ rhs; |
| 2131 | } |
| 2132 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2133 | // RValue<Byte8> operator<<=(const Byte8 &lhs, RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2134 | // { |
| 2135 | // return lhs = lhs << rhs; |
| 2136 | // } |
| 2137 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2138 | // RValue<Byte8> operator>>=(const Byte8 &lhs, RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2139 | // { |
| 2140 | // return lhs = lhs >> rhs; |
| 2141 | // } |
| 2142 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2143 | // RValue<Byte8> operator+(RValue<Byte8> val) |
| 2144 | // { |
| 2145 | // return val; |
| 2146 | // } |
| 2147 | |
| 2148 | // RValue<Byte8> operator-(RValue<Byte8> val) |
| 2149 | // { |
| 2150 | // return RValue<Byte8>(Nucleus::createNeg(val.value)); |
| 2151 | // } |
| 2152 | |
| 2153 | RValue<Byte8> operator~(RValue<Byte8> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2154 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2155 | if(CPUID::supportsMMX2()) |
| 2156 | { |
| 2157 | return val ^ Byte8(0xFFFFFFFFFFFFFFFF); |
| 2158 | } |
| 2159 | else |
| 2160 | { |
| 2161 | return RValue<Byte8>(Nucleus::createNot(val.value)); |
| 2162 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2163 | } |
| 2164 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2165 | RValue<Byte8> AddSat(RValue<Byte8> x, RValue<Byte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2166 | { |
| 2167 | return x86::paddusb(x, y); |
| 2168 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2169 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2170 | RValue<Byte8> SubSat(RValue<Byte8> x, RValue<Byte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2171 | { |
| 2172 | return x86::psubusb(x, y); |
| 2173 | } |
| 2174 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2175 | RValue<Short4> Unpack(RValue<Byte4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2176 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2177 | Value *int2 = Nucleus::createInsertElement(UndefValue::get(VectorType::get(Int::getType(), 2)), x.value, 0); |
| 2178 | Value *byte8 = Nucleus::createBitCast(int2, Byte8::getType()); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2179 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2180 | return UnpackLow(RValue<Byte8>(byte8), RValue<Byte8>(byte8)); |
| 2181 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2182 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2183 | RValue<Short4> UnpackLow(RValue<Byte8> x, RValue<Byte8> y) |
| 2184 | { |
| 2185 | if(CPUID::supportsMMX2()) |
| 2186 | { |
| 2187 | return x86::punpcklbw(x, y); |
| 2188 | } |
| 2189 | else |
| 2190 | { |
| 2191 | Constant *shuffle[8]; |
| 2192 | shuffle[0] = Nucleus::createConstantInt(0); |
| 2193 | shuffle[1] = Nucleus::createConstantInt(8); |
| 2194 | shuffle[2] = Nucleus::createConstantInt(1); |
| 2195 | shuffle[3] = Nucleus::createConstantInt(9); |
| 2196 | shuffle[4] = Nucleus::createConstantInt(2); |
| 2197 | shuffle[5] = Nucleus::createConstantInt(10); |
| 2198 | shuffle[6] = Nucleus::createConstantInt(3); |
| 2199 | shuffle[7] = Nucleus::createConstantInt(11); |
| 2200 | |
| 2201 | Value *packed = Nucleus::createShuffleVector(x.value, y.value, Nucleus::createConstantVector(shuffle, 8)); |
| 2202 | |
| 2203 | return RValue<Short4>(Nucleus::createBitCast(packed, Short4::getType())); |
| 2204 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2205 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2206 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2207 | RValue<Short4> UnpackHigh(RValue<Byte8> x, RValue<Byte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2208 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2209 | if(CPUID::supportsMMX2()) |
| 2210 | { |
| 2211 | return x86::punpckhbw(x, y); |
| 2212 | } |
| 2213 | else |
| 2214 | { |
| 2215 | Constant *shuffle[8]; |
| 2216 | shuffle[0] = Nucleus::createConstantInt(4); |
| 2217 | shuffle[1] = Nucleus::createConstantInt(12); |
| 2218 | shuffle[2] = Nucleus::createConstantInt(5); |
| 2219 | shuffle[3] = Nucleus::createConstantInt(13); |
| 2220 | shuffle[4] = Nucleus::createConstantInt(6); |
| 2221 | shuffle[5] = Nucleus::createConstantInt(14); |
| 2222 | shuffle[6] = Nucleus::createConstantInt(7); |
| 2223 | shuffle[7] = Nucleus::createConstantInt(15); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2224 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2225 | Value *packed = Nucleus::createShuffleVector(x.value, y.value, Nucleus::createConstantVector(shuffle, 8)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2226 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2227 | return RValue<Short4>(Nucleus::createBitCast(packed, Short4::getType())); |
| 2228 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2229 | } |
| 2230 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2231 | RValue<Int> SignMask(RValue<Byte8> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2232 | { |
| 2233 | return x86::pmovmskb(x); |
| 2234 | } |
| 2235 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2236 | // RValue<Byte8> CmpGT(RValue<Byte8> x, RValue<Byte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2237 | // { |
| 2238 | // return x86::pcmpgtb(x, y); // FIXME: Signedness |
| 2239 | // } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2240 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2241 | RValue<Byte8> CmpEQ(RValue<Byte8> x, RValue<Byte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2242 | { |
| 2243 | return x86::pcmpeqb(x, y); |
| 2244 | } |
| 2245 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2246 | Type *Byte8::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2247 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2248 | if(CPUID::supportsMMX2()) |
| 2249 | { |
| 2250 | return MMX::getType(); |
| 2251 | } |
| 2252 | else |
| 2253 | { |
| 2254 | return VectorType::get(Byte::getType(), 8); |
| 2255 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2256 | } |
| 2257 | |
| 2258 | SByte8::SByte8() |
| 2259 | { |
| 2260 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2261 | } |
| 2262 | |
| 2263 | SByte8::SByte8(byte x0, byte x1, byte x2, byte x3, byte x4, byte x5, byte x6, byte x7) |
| 2264 | { |
| 2265 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2266 | |
| 2267 | Constant *constantVector[8]; |
| 2268 | constantVector[0] = Nucleus::createConstantByte(x0); |
| 2269 | constantVector[1] = Nucleus::createConstantByte(x1); |
| 2270 | constantVector[2] = Nucleus::createConstantByte(x2); |
| 2271 | constantVector[3] = Nucleus::createConstantByte(x3); |
| 2272 | constantVector[4] = Nucleus::createConstantByte(x4); |
| 2273 | constantVector[5] = Nucleus::createConstantByte(x5); |
| 2274 | constantVector[6] = Nucleus::createConstantByte(x6); |
| 2275 | constantVector[7] = Nucleus::createConstantByte(x7); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2276 | Value *vector = Nucleus::createConstantVector(constantVector, 8); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2277 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2278 | storeValue(Nucleus::createBitCast(vector, getType())); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2279 | } |
| 2280 | |
| 2281 | SByte8::SByte8(int64_t x) |
| 2282 | { |
| 2283 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2284 | |
| 2285 | Constant *constantVector[8]; |
| 2286 | constantVector[0] = Nucleus::createConstantByte((unsigned char)(x >> 0)); |
| 2287 | constantVector[1] = Nucleus::createConstantByte((unsigned char)(x >> 8)); |
| 2288 | constantVector[2] = Nucleus::createConstantByte((unsigned char)(x >> 16)); |
| 2289 | constantVector[3] = Nucleus::createConstantByte((unsigned char)(x >> 24)); |
| 2290 | constantVector[4] = Nucleus::createConstantByte((unsigned char)(x >> 32)); |
| 2291 | constantVector[5] = Nucleus::createConstantByte((unsigned char)(x >> 40)); |
| 2292 | constantVector[6] = Nucleus::createConstantByte((unsigned char)(x >> 48)); |
| 2293 | constantVector[7] = Nucleus::createConstantByte((unsigned char)(x >> 56)); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2294 | Value *vector = Nucleus::createConstantVector(constantVector, 8); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2295 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2296 | storeValue(Nucleus::createBitCast(vector, getType())); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2297 | } |
| 2298 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2299 | SByte8::SByte8(RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2300 | { |
| 2301 | // xyzw.parent = this; |
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 | |
| 2306 | SByte8::SByte8(const SByte8 &rhs) |
| 2307 | { |
| 2308 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2309 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2310 | Value *value = rhs.loadValue(); |
| 2311 | storeValue(value); |
| 2312 | } |
| 2313 | |
| 2314 | SByte8::SByte8(const Reference<SByte8> &rhs) |
| 2315 | { |
| 2316 | // xyzw.parent = this; |
| 2317 | |
| 2318 | Value *value = rhs.loadValue(); |
| 2319 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2320 | } |
| 2321 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2322 | RValue<SByte8> SByte8::operator=(RValue<SByte8> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2323 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2324 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2325 | |
| 2326 | return rhs; |
| 2327 | } |
| 2328 | |
| 2329 | RValue<SByte8> SByte8::operator=(const SByte8 &rhs) const |
| 2330 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2331 | Value *value = rhs.loadValue(); |
| 2332 | storeValue(value); |
| 2333 | |
| 2334 | return RValue<SByte8>(value); |
| 2335 | } |
| 2336 | |
| 2337 | RValue<SByte8> SByte8::operator=(const Reference<SByte8> &rhs) const |
| 2338 | { |
| 2339 | Value *value = rhs.loadValue(); |
| 2340 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2341 | |
| 2342 | return RValue<SByte8>(value); |
| 2343 | } |
| 2344 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2345 | RValue<SByte8> operator+(RValue<SByte8> lhs, RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2346 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2347 | if(CPUID::supportsMMX2()) |
| 2348 | { |
| 2349 | return As<SByte8>(x86::paddb(As<Byte8>(lhs), As<Byte8>(rhs))); |
| 2350 | } |
| 2351 | else |
| 2352 | { |
| 2353 | return RValue<SByte8>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 2354 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2355 | } |
| 2356 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2357 | RValue<SByte8> operator-(RValue<SByte8> lhs, RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2358 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2359 | if(CPUID::supportsMMX2()) |
| 2360 | { |
| 2361 | return As<SByte8>(x86::psubb(As<Byte8>(lhs), As<Byte8>(rhs))); |
| 2362 | } |
| 2363 | else |
| 2364 | { |
| 2365 | return RValue<SByte8>(Nucleus::createSub(lhs.value, rhs.value)); |
| 2366 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2367 | } |
| 2368 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2369 | // RValue<SByte8> operator*(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 2370 | // { |
| 2371 | // return RValue<SByte8>(Nucleus::createMul(lhs.value, rhs.value)); |
| 2372 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2373 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2374 | // RValue<SByte8> operator/(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 2375 | // { |
| 2376 | // return RValue<SByte8>(Nucleus::createSDiv(lhs.value, rhs.value)); |
| 2377 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2378 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2379 | // RValue<SByte8> operator%(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 2380 | // { |
| 2381 | // return RValue<SByte8>(Nucleus::createSRem(lhs.value, rhs.value)); |
| 2382 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2383 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2384 | RValue<SByte8> operator&(RValue<SByte8> lhs, RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2385 | { |
| 2386 | return RValue<SByte8>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 2387 | } |
| 2388 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2389 | RValue<SByte8> operator|(RValue<SByte8> lhs, RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2390 | { |
| 2391 | return RValue<SByte8>(Nucleus::createOr(lhs.value, rhs.value)); |
| 2392 | } |
| 2393 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2394 | RValue<SByte8> operator^(RValue<SByte8> lhs, RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2395 | { |
| 2396 | return RValue<SByte8>(Nucleus::createXor(lhs.value, rhs.value)); |
| 2397 | } |
| 2398 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2399 | // RValue<SByte8> operator<<(RValue<SByte8> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2400 | // { |
| 2401 | // return RValue<SByte8>(Nucleus::createShl(lhs.value, rhs.value)); |
| 2402 | // } |
| 2403 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2404 | // RValue<SByte8> operator>>(RValue<SByte8> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2405 | // { |
| 2406 | // return RValue<SByte8>(Nucleus::createAShr(lhs.value, rhs.value)); |
| 2407 | // } |
| 2408 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2409 | RValue<SByte8> operator+=(const SByte8 &lhs, RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2410 | { |
| 2411 | return lhs = lhs + rhs; |
| 2412 | } |
| 2413 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2414 | RValue<SByte8> operator-=(const SByte8 &lhs, RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2415 | { |
| 2416 | return lhs = lhs - rhs; |
| 2417 | } |
| 2418 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2419 | // RValue<SByte8> operator*=(const SByte8 &lhs, RValue<SByte8> rhs) |
| 2420 | // { |
| 2421 | // return lhs = lhs * rhs; |
| 2422 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2423 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2424 | // RValue<SByte8> operator/=(const SByte8 &lhs, RValue<SByte8> rhs) |
| 2425 | // { |
| 2426 | // return lhs = lhs / rhs; |
| 2427 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2428 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2429 | // RValue<SByte8> operator%=(const SByte8 &lhs, RValue<SByte8> rhs) |
| 2430 | // { |
| 2431 | // return lhs = lhs % rhs; |
| 2432 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2433 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2434 | RValue<SByte8> operator&=(const SByte8 &lhs, RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2435 | { |
| 2436 | return lhs = lhs & rhs; |
| 2437 | } |
| 2438 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2439 | RValue<SByte8> operator|=(const SByte8 &lhs, RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2440 | { |
| 2441 | return lhs = lhs | rhs; |
| 2442 | } |
| 2443 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2444 | RValue<SByte8> operator^=(const SByte8 &lhs, RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2445 | { |
| 2446 | return lhs = lhs ^ rhs; |
| 2447 | } |
| 2448 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2449 | // RValue<SByte8> operator<<=(const SByte8 &lhs, RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2450 | // { |
| 2451 | // return lhs = lhs << rhs; |
| 2452 | // } |
| 2453 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2454 | // RValue<SByte8> operator>>=(const SByte8 &lhs, RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2455 | // { |
| 2456 | // return lhs = lhs >> rhs; |
| 2457 | // } |
| 2458 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2459 | // RValue<SByte8> operator+(RValue<SByte8> val) |
| 2460 | // { |
| 2461 | // return val; |
| 2462 | // } |
| 2463 | |
| 2464 | // RValue<SByte8> operator-(RValue<SByte8> val) |
| 2465 | // { |
| 2466 | // return RValue<SByte8>(Nucleus::createNeg(val.value)); |
| 2467 | // } |
| 2468 | |
| 2469 | RValue<SByte8> operator~(RValue<SByte8> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2470 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2471 | if(CPUID::supportsMMX2()) |
| 2472 | { |
| 2473 | return val ^ SByte8(0xFFFFFFFFFFFFFFFF); |
| 2474 | } |
| 2475 | else |
| 2476 | { |
| 2477 | return RValue<SByte8>(Nucleus::createNot(val.value)); |
| 2478 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2479 | } |
| 2480 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2481 | RValue<SByte8> AddSat(RValue<SByte8> x, RValue<SByte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2482 | { |
| 2483 | return x86::paddsb(x, y); |
| 2484 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2485 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2486 | RValue<SByte8> SubSat(RValue<SByte8> x, RValue<SByte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2487 | { |
| 2488 | return x86::psubsb(x, y); |
| 2489 | } |
| 2490 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2491 | RValue<Short4> UnpackLow(RValue<SByte8> x, RValue<SByte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2492 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2493 | if(CPUID::supportsMMX2()) |
| 2494 | { |
| 2495 | return As<Short4>(x86::punpcklbw(As<Byte8>(x), As<Byte8>(y))); |
| 2496 | } |
| 2497 | else |
| 2498 | { |
| 2499 | Constant *shuffle[8]; |
| 2500 | shuffle[0] = Nucleus::createConstantInt(0); |
| 2501 | shuffle[1] = Nucleus::createConstantInt(8); |
| 2502 | shuffle[2] = Nucleus::createConstantInt(1); |
| 2503 | shuffle[3] = Nucleus::createConstantInt(9); |
| 2504 | shuffle[4] = Nucleus::createConstantInt(2); |
| 2505 | shuffle[5] = Nucleus::createConstantInt(10); |
| 2506 | shuffle[6] = Nucleus::createConstantInt(3); |
| 2507 | shuffle[7] = Nucleus::createConstantInt(11); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2508 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2509 | Value *packed = Nucleus::createShuffleVector(x.value, y.value, Nucleus::createConstantVector(shuffle, 8)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2510 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2511 | return RValue<Short4>(Nucleus::createBitCast(packed, Short4::getType())); |
| 2512 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2513 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2514 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2515 | RValue<Short4> UnpackHigh(RValue<SByte8> x, RValue<SByte8> y) |
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 As<Short4>(x86::punpckhbw(As<Byte8>(x), As<Byte8>(y))); |
| 2520 | } |
| 2521 | else |
| 2522 | { |
| 2523 | Constant *shuffle[8]; |
| 2524 | shuffle[0] = Nucleus::createConstantInt(4); |
| 2525 | shuffle[1] = Nucleus::createConstantInt(12); |
| 2526 | shuffle[2] = Nucleus::createConstantInt(5); |
| 2527 | shuffle[3] = Nucleus::createConstantInt(13); |
| 2528 | shuffle[4] = Nucleus::createConstantInt(6); |
| 2529 | shuffle[5] = Nucleus::createConstantInt(14); |
| 2530 | shuffle[6] = Nucleus::createConstantInt(7); |
| 2531 | shuffle[7] = Nucleus::createConstantInt(15); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2532 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2533 | Value *packed = Nucleus::createShuffleVector(x.value, y.value, Nucleus::createConstantVector(shuffle, 8)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2534 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2535 | return RValue<Short4>(Nucleus::createBitCast(packed, Short4::getType())); |
| 2536 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2537 | } |
| 2538 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2539 | RValue<Int> SignMask(RValue<SByte8> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2540 | { |
| 2541 | return x86::pmovmskb(As<Byte8>(x)); |
| 2542 | } |
| 2543 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2544 | RValue<Byte8> CmpGT(RValue<SByte8> x, RValue<SByte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2545 | { |
| 2546 | return x86::pcmpgtb(x, y); |
| 2547 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2548 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2549 | RValue<Byte8> CmpEQ(RValue<SByte8> x, RValue<SByte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2550 | { |
| 2551 | return x86::pcmpeqb(As<Byte8>(x), As<Byte8>(y)); |
| 2552 | } |
| 2553 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2554 | Type *SByte8::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2555 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2556 | if(CPUID::supportsMMX2()) |
| 2557 | { |
| 2558 | return MMX::getType(); |
| 2559 | } |
| 2560 | else |
| 2561 | { |
| 2562 | return VectorType::get(SByte::getType(), 8); |
| 2563 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2564 | } |
| 2565 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2566 | Byte16::Byte16(RValue<Byte16> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2567 | { |
| 2568 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2569 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2570 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2571 | } |
| 2572 | |
| 2573 | Byte16::Byte16(const Byte16 &rhs) |
| 2574 | { |
| 2575 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2576 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2577 | Value *value = rhs.loadValue(); |
| 2578 | storeValue(value); |
| 2579 | } |
| 2580 | |
| 2581 | Byte16::Byte16(const Reference<Byte16> &rhs) |
| 2582 | { |
| 2583 | // xyzw.parent = this; |
| 2584 | |
| 2585 | Value *value = rhs.loadValue(); |
| 2586 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2587 | } |
| 2588 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2589 | RValue<Byte16> Byte16::operator=(RValue<Byte16> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2590 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2591 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2592 | |
| 2593 | return rhs; |
| 2594 | } |
| 2595 | |
| 2596 | RValue<Byte16> Byte16::operator=(const Byte16 &rhs) const |
| 2597 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2598 | Value *value = rhs.loadValue(); |
| 2599 | storeValue(value); |
| 2600 | |
| 2601 | return RValue<Byte16>(value); |
| 2602 | } |
| 2603 | |
| 2604 | RValue<Byte16> Byte16::operator=(const Reference<Byte16> &rhs) const |
| 2605 | { |
| 2606 | Value *value = rhs.loadValue(); |
| 2607 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2608 | |
| 2609 | return RValue<Byte16>(value); |
| 2610 | } |
| 2611 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2612 | Type *Byte16::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2613 | { |
| 2614 | return VectorType::get(Byte::getType(), 16); |
| 2615 | } |
| 2616 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2617 | Type *SByte16::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2618 | { |
| 2619 | return VectorType::get(SByte::getType(), 16); |
| 2620 | } |
| 2621 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2622 | Short4::Short4(RValue<Int> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2623 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2624 | Value *extend = Nucleus::createZExt(cast.value, Long::getType()); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2625 | Value *swizzle = Swizzle(RValue<Short4>(extend), 0x00).value; |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2626 | |
| 2627 | storeValue(swizzle); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2628 | } |
| 2629 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2630 | Short4::Short4(RValue<Int4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2631 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2632 | Value *short8 = Nucleus::createBitCast(cast.value, Short8::getType()); |
| 2633 | |
| 2634 | #if 0 // FIXME: Check codegen (pshuflw phshufhw pshufd) |
| 2635 | Constant *pack[8]; |
| 2636 | pack[0] = Nucleus::createConstantInt(0); |
| 2637 | pack[1] = Nucleus::createConstantInt(2); |
| 2638 | pack[2] = Nucleus::createConstantInt(4); |
| 2639 | pack[3] = Nucleus::createConstantInt(6); |
| 2640 | |
| 2641 | Value *short4 = Nucleus::createShuffleVector(short8, short8, Nucleus::createConstantVector(pack, 4)); |
| 2642 | #else |
| 2643 | Value *packed; |
| 2644 | |
| 2645 | // FIXME: Use Swizzle<Short8> |
| 2646 | if(!CPUID::supportsSSSE3()) |
| 2647 | { |
| 2648 | Constant *pshuflw[8]; |
| 2649 | pshuflw[0] = Nucleus::createConstantInt(0); |
| 2650 | pshuflw[1] = Nucleus::createConstantInt(2); |
| 2651 | pshuflw[2] = Nucleus::createConstantInt(0); |
| 2652 | pshuflw[3] = Nucleus::createConstantInt(2); |
| 2653 | pshuflw[4] = Nucleus::createConstantInt(4); |
| 2654 | pshuflw[5] = Nucleus::createConstantInt(5); |
| 2655 | pshuflw[6] = Nucleus::createConstantInt(6); |
| 2656 | pshuflw[7] = Nucleus::createConstantInt(7); |
| 2657 | |
| 2658 | Constant *pshufhw[8]; |
| 2659 | pshufhw[0] = Nucleus::createConstantInt(0); |
| 2660 | pshufhw[1] = Nucleus::createConstantInt(1); |
| 2661 | pshufhw[2] = Nucleus::createConstantInt(2); |
| 2662 | pshufhw[3] = Nucleus::createConstantInt(3); |
| 2663 | pshufhw[4] = Nucleus::createConstantInt(4); |
| 2664 | pshufhw[5] = Nucleus::createConstantInt(6); |
| 2665 | pshufhw[6] = Nucleus::createConstantInt(4); |
| 2666 | pshufhw[7] = Nucleus::createConstantInt(6); |
| 2667 | |
| 2668 | Value *shuffle1 = Nucleus::createShuffleVector(short8, UndefValue::get(Short8::getType()), Nucleus::createConstantVector(pshuflw, 8)); |
| 2669 | Value *shuffle2 = Nucleus::createShuffleVector(shuffle1, UndefValue::get(Short8::getType()), Nucleus::createConstantVector(pshufhw, 8)); |
| 2670 | Value *int4 = Nucleus::createBitCast(shuffle2, Int4::getType()); |
| 2671 | packed = Nucleus::createSwizzle(int4, 0x88); |
| 2672 | } |
| 2673 | else |
| 2674 | { |
| 2675 | Constant *pshufb[16]; |
| 2676 | pshufb[0] = Nucleus::createConstantInt(0); |
| 2677 | pshufb[1] = Nucleus::createConstantInt(1); |
| 2678 | pshufb[2] = Nucleus::createConstantInt(4); |
| 2679 | pshufb[3] = Nucleus::createConstantInt(5); |
| 2680 | pshufb[4] = Nucleus::createConstantInt(8); |
| 2681 | pshufb[5] = Nucleus::createConstantInt(9); |
| 2682 | pshufb[6] = Nucleus::createConstantInt(12); |
| 2683 | pshufb[7] = Nucleus::createConstantInt(13); |
| 2684 | pshufb[8] = Nucleus::createConstantInt(0); |
| 2685 | pshufb[9] = Nucleus::createConstantInt(1); |
| 2686 | pshufb[10] = Nucleus::createConstantInt(4); |
| 2687 | pshufb[11] = Nucleus::createConstantInt(5); |
| 2688 | pshufb[12] = Nucleus::createConstantInt(8); |
| 2689 | pshufb[13] = Nucleus::createConstantInt(9); |
| 2690 | pshufb[14] = Nucleus::createConstantInt(12); |
| 2691 | pshufb[15] = Nucleus::createConstantInt(13); |
| 2692 | |
| 2693 | Value *byte16 = Nucleus::createBitCast(cast.value, Byte16::getType()); |
| 2694 | packed = Nucleus::createShuffleVector(byte16, UndefValue::get(Byte16::getType()), Nucleus::createConstantVector(pshufb, 16)); |
| 2695 | } |
| 2696 | |
| 2697 | #if 0 // FIXME: No optimal instruction selection |
| 2698 | Value *qword2 = Nucleus::createBitCast(packed, Long2::getType()); |
| 2699 | Value *element = Nucleus::createExtractElement(qword2, 0); |
| 2700 | Value *short4 = Nucleus::createBitCast(element, Short4::getType()); |
| 2701 | #else // FIXME: Requires SSE |
| 2702 | Value *int2 = RValue<Int2>(Int2(RValue<Int4>(packed))).value; |
| 2703 | Value *short4 = Nucleus::createBitCast(int2, Short4::getType()); |
| 2704 | #endif |
| 2705 | #endif |
| 2706 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2707 | storeValue(short4); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2708 | } |
| 2709 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2710 | // Short4::Short4(RValue<Float> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2711 | // { |
| 2712 | // } |
| 2713 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2714 | Short4::Short4(RValue<Float4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2715 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2716 | Int4 v4i32 = Int4(cast); |
| 2717 | v4i32 = As<Int4>(x86::packssdw(v4i32, v4i32)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2718 | |
| 2719 | storeValue(As<Short4>(Int2(v4i32)).value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2720 | } |
| 2721 | |
| 2722 | Short4::Short4() |
| 2723 | { |
| 2724 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2725 | } |
| 2726 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2727 | Short4::Short4(short xyzw) |
| 2728 | { |
| 2729 | // xyzw.parent = this; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2730 | |
| 2731 | Constant *constantVector[4]; |
| 2732 | constantVector[0] = Nucleus::createConstantShort(xyzw); |
| 2733 | constantVector[1] = Nucleus::createConstantShort(xyzw); |
| 2734 | constantVector[2] = Nucleus::createConstantShort(xyzw); |
| 2735 | constantVector[3] = Nucleus::createConstantShort(xyzw); |
| 2736 | Value *vector = Nucleus::createConstantVector(constantVector, 4); |
| 2737 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2738 | storeValue(Nucleus::createBitCast(vector, getType())); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2739 | } |
| 2740 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2741 | Short4::Short4(short x, short y, short z, short w) |
| 2742 | { |
| 2743 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2744 | |
| 2745 | Constant *constantVector[4]; |
| 2746 | constantVector[0] = Nucleus::createConstantShort(x); |
| 2747 | constantVector[1] = Nucleus::createConstantShort(y); |
| 2748 | constantVector[2] = Nucleus::createConstantShort(z); |
| 2749 | constantVector[3] = Nucleus::createConstantShort(w); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2750 | Value *vector = Nucleus::createConstantVector(constantVector, 4); |
| 2751 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2752 | storeValue(Nucleus::createBitCast(vector, getType())); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2753 | } |
| 2754 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2755 | Short4::Short4(RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2756 | { |
| 2757 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2758 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2759 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2760 | } |
| 2761 | |
| 2762 | Short4::Short4(const Short4 &rhs) |
| 2763 | { |
| 2764 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2765 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2766 | Value *value = rhs.loadValue(); |
| 2767 | storeValue(value); |
| 2768 | } |
| 2769 | |
| 2770 | Short4::Short4(const Reference<Short4> &rhs) |
| 2771 | { |
| 2772 | // xyzw.parent = this; |
| 2773 | |
| 2774 | Value *value = rhs.loadValue(); |
| 2775 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2776 | } |
| 2777 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2778 | Short4::Short4(RValue<UShort4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2779 | { |
| 2780 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2781 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2782 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2783 | } |
| 2784 | |
| 2785 | Short4::Short4(const UShort4 &rhs) |
| 2786 | { |
| 2787 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2788 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2789 | storeValue(rhs.loadValue()); |
| 2790 | } |
| 2791 | |
| 2792 | Short4::Short4(const Reference<UShort4> &rhs) |
| 2793 | { |
| 2794 | // xyzw.parent = this; |
| 2795 | |
| 2796 | storeValue(rhs.loadValue()); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2797 | } |
| 2798 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2799 | RValue<Short4> Short4::operator=(RValue<Short4> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2800 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2801 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2802 | |
| 2803 | return rhs; |
| 2804 | } |
| 2805 | |
| 2806 | RValue<Short4> Short4::operator=(const Short4 &rhs) const |
| 2807 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2808 | Value *value = rhs.loadValue(); |
| 2809 | storeValue(value); |
| 2810 | |
| 2811 | return RValue<Short4>(value); |
| 2812 | } |
| 2813 | |
| 2814 | RValue<Short4> Short4::operator=(const Reference<Short4> &rhs) const |
| 2815 | { |
| 2816 | Value *value = rhs.loadValue(); |
| 2817 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2818 | |
| 2819 | return RValue<Short4>(value); |
| 2820 | } |
| 2821 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2822 | RValue<Short4> Short4::operator=(RValue<UShort4> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2823 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2824 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2825 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2826 | return RValue<Short4>(rhs); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2827 | } |
| 2828 | |
| 2829 | RValue<Short4> Short4::operator=(const UShort4 &rhs) const |
| 2830 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2831 | Value *value = rhs.loadValue(); |
| 2832 | storeValue(value); |
| 2833 | |
| 2834 | return RValue<Short4>(value); |
| 2835 | } |
| 2836 | |
| 2837 | RValue<Short4> Short4::operator=(const Reference<UShort4> &rhs) const |
| 2838 | { |
| 2839 | Value *value = rhs.loadValue(); |
| 2840 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2841 | |
| 2842 | return RValue<Short4>(value); |
| 2843 | } |
| 2844 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2845 | RValue<Short4> operator+(RValue<Short4> lhs, RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2846 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2847 | if(CPUID::supportsMMX2()) |
| 2848 | { |
| 2849 | return x86::paddw(lhs, rhs); |
| 2850 | } |
| 2851 | else |
| 2852 | { |
| 2853 | return RValue<Short4>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 2854 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2855 | } |
| 2856 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2857 | RValue<Short4> operator-(RValue<Short4> lhs, RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2858 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2859 | if(CPUID::supportsMMX2()) |
| 2860 | { |
| 2861 | return x86::psubw(lhs, rhs); |
| 2862 | } |
| 2863 | else |
| 2864 | { |
| 2865 | return RValue<Short4>(Nucleus::createSub(lhs.value, rhs.value)); |
| 2866 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2867 | } |
| 2868 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2869 | RValue<Short4> operator*(RValue<Short4> lhs, RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2870 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2871 | if(CPUID::supportsMMX2()) |
| 2872 | { |
| 2873 | return x86::pmullw(lhs, rhs); |
| 2874 | } |
| 2875 | else |
| 2876 | { |
| 2877 | return RValue<Short4>(Nucleus::createMul(lhs.value, rhs.value)); |
| 2878 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2879 | } |
| 2880 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2881 | // RValue<Short4> operator/(RValue<Short4> lhs, RValue<Short4> rhs) |
| 2882 | // { |
| 2883 | // return RValue<Short4>(Nucleus::createSDiv(lhs.value, rhs.value)); |
| 2884 | // } |
| 2885 | |
| 2886 | // RValue<Short4> operator%(RValue<Short4> lhs, RValue<Short4> rhs) |
| 2887 | // { |
| 2888 | // return RValue<Short4>(Nucleus::createSRem(lhs.value, rhs.value)); |
| 2889 | // } |
| 2890 | |
| 2891 | RValue<Short4> operator&(RValue<Short4> lhs, RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2892 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2893 | if(CPUID::supportsMMX2()) |
| 2894 | { |
| 2895 | return x86::pand(lhs, rhs); |
| 2896 | } |
| 2897 | else |
| 2898 | { |
| 2899 | return RValue<Short4>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 2900 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2901 | } |
| 2902 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2903 | RValue<Short4> operator|(RValue<Short4> lhs, RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2904 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2905 | if(CPUID::supportsMMX2()) |
| 2906 | { |
| 2907 | return x86::por(lhs, rhs); |
| 2908 | } |
| 2909 | else |
| 2910 | { |
| 2911 | return RValue<Short4>(Nucleus::createOr(lhs.value, rhs.value)); |
| 2912 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2913 | } |
| 2914 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2915 | RValue<Short4> operator^(RValue<Short4> lhs, RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2916 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2917 | if(CPUID::supportsMMX2()) |
| 2918 | { |
| 2919 | return x86::pxor(lhs, rhs); |
| 2920 | } |
| 2921 | else |
| 2922 | { |
| 2923 | return RValue<Short4>(Nucleus::createXor(lhs.value, rhs.value)); |
| 2924 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2925 | } |
| 2926 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2927 | RValue<Short4> operator<<(RValue<Short4> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2928 | { |
| 2929 | // return RValue<Short4>(Nucleus::createShl(lhs.value, rhs.value)); |
| 2930 | |
| 2931 | return x86::psllw(lhs, rhs); |
| 2932 | } |
| 2933 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2934 | RValue<Short4> operator>>(RValue<Short4> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2935 | { |
| 2936 | // return RValue<Short4>(Nucleus::createAShr(lhs.value, rhs.value)); |
| 2937 | |
| 2938 | return x86::psraw(lhs, rhs); |
| 2939 | } |
| 2940 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2941 | RValue<Short4> operator<<(RValue<Short4> lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2942 | { |
| 2943 | // return RValue<Short4>(Nucleus::createShl(lhs.value, rhs.value)); |
| 2944 | |
| 2945 | return x86::psllw(lhs, rhs); |
| 2946 | } |
| 2947 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2948 | RValue<Short4> operator>>(RValue<Short4> lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2949 | { |
| 2950 | // return RValue<Short4>(Nucleus::createAShr(lhs.value, rhs.value)); |
| 2951 | |
| 2952 | return x86::psraw(lhs, rhs); |
| 2953 | } |
| 2954 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2955 | RValue<Short4> operator+=(const Short4 &lhs, RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2956 | { |
| 2957 | return lhs = lhs + rhs; |
| 2958 | } |
| 2959 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2960 | RValue<Short4> operator-=(const Short4 &lhs, RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2961 | { |
| 2962 | return lhs = lhs - rhs; |
| 2963 | } |
| 2964 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2965 | RValue<Short4> operator*=(const Short4 &lhs, RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2966 | { |
| 2967 | return lhs = lhs * rhs; |
| 2968 | } |
| 2969 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2970 | // RValue<Short4> operator/=(const Short4 &lhs, RValue<Short4> rhs) |
| 2971 | // { |
| 2972 | // return lhs = lhs / rhs; |
| 2973 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2974 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2975 | // RValue<Short4> operator%=(const Short4 &lhs, RValue<Short4> rhs) |
| 2976 | // { |
| 2977 | // return lhs = lhs % rhs; |
| 2978 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2979 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2980 | RValue<Short4> operator&=(const Short4 &lhs, RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2981 | { |
| 2982 | return lhs = lhs & rhs; |
| 2983 | } |
| 2984 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2985 | RValue<Short4> operator|=(const Short4 &lhs, RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2986 | { |
| 2987 | return lhs = lhs | rhs; |
| 2988 | } |
| 2989 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2990 | RValue<Short4> operator^=(const Short4 &lhs, RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2991 | { |
| 2992 | return lhs = lhs ^ rhs; |
| 2993 | } |
| 2994 | |
| 2995 | RValue<Short4> operator<<=(const Short4 &lhs, unsigned char rhs) |
| 2996 | { |
| 2997 | return lhs = lhs << rhs; |
| 2998 | } |
| 2999 | |
| 3000 | RValue<Short4> operator>>=(const Short4 &lhs, unsigned char rhs) |
| 3001 | { |
| 3002 | return lhs = lhs >> rhs; |
| 3003 | } |
| 3004 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3005 | RValue<Short4> operator<<=(const Short4 &lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3006 | { |
| 3007 | return lhs = lhs << rhs; |
| 3008 | } |
| 3009 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3010 | RValue<Short4> operator>>=(const Short4 &lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3011 | { |
| 3012 | return lhs = lhs >> rhs; |
| 3013 | } |
| 3014 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3015 | // RValue<Short4> operator+(RValue<Short4> val) |
| 3016 | // { |
| 3017 | // return val; |
| 3018 | // } |
| 3019 | |
| 3020 | RValue<Short4> operator-(RValue<Short4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3021 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3022 | if(CPUID::supportsMMX2()) |
| 3023 | { |
| 3024 | return Short4(0, 0, 0, 0) - val; |
| 3025 | } |
| 3026 | else |
| 3027 | { |
| 3028 | return RValue<Short4>(Nucleus::createNeg(val.value)); |
| 3029 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3030 | } |
| 3031 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3032 | RValue<Short4> operator~(RValue<Short4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3033 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3034 | if(CPUID::supportsMMX2()) |
| 3035 | { |
| 3036 | return val ^ Short4(0xFFFFu, 0xFFFFu, 0xFFFFu, 0xFFFFu); |
| 3037 | } |
| 3038 | else |
| 3039 | { |
| 3040 | return RValue<Short4>(Nucleus::createNot(val.value)); |
| 3041 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3042 | } |
| 3043 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3044 | RValue<Short4> RoundShort4(RValue<Float4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3045 | { |
| 3046 | RValue<Int4> v4i32 = x86::cvtps2dq(cast); |
| 3047 | v4i32 = As<Int4>(x86::packssdw(v4i32, v4i32)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3048 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3049 | return As<Short4>(Int2(v4i32)); |
| 3050 | } |
| 3051 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3052 | RValue<Short4> Max(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3053 | { |
| 3054 | return x86::pmaxsw(x, y); |
| 3055 | } |
| 3056 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3057 | RValue<Short4> Min(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3058 | { |
| 3059 | return x86::pminsw(x, y); |
| 3060 | } |
| 3061 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3062 | RValue<Short4> AddSat(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3063 | { |
| 3064 | return x86::paddsw(x, y); |
| 3065 | } |
| 3066 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3067 | RValue<Short4> SubSat(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3068 | { |
| 3069 | return x86::psubsw(x, y); |
| 3070 | } |
| 3071 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3072 | RValue<Short4> MulHigh(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3073 | { |
| 3074 | return x86::pmulhw(x, y); |
| 3075 | } |
| 3076 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3077 | RValue<Int2> MulAdd(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3078 | { |
| 3079 | return x86::pmaddwd(x, y); |
| 3080 | } |
| 3081 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3082 | RValue<SByte8> Pack(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3083 | { |
| 3084 | return x86::packsswb(x, y); |
| 3085 | } |
| 3086 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3087 | RValue<Int2> UnpackLow(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3088 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3089 | if(CPUID::supportsMMX2()) |
| 3090 | { |
| 3091 | return x86::punpcklwd(x, y); |
| 3092 | } |
| 3093 | else |
| 3094 | { |
| 3095 | Constant *shuffle[4]; |
| 3096 | shuffle[0] = Nucleus::createConstantInt(0); |
| 3097 | shuffle[1] = Nucleus::createConstantInt(4); |
| 3098 | shuffle[2] = Nucleus::createConstantInt(1); |
| 3099 | shuffle[3] = Nucleus::createConstantInt(5); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3100 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3101 | Value *packed = Nucleus::createShuffleVector(x.value, y.value, Nucleus::createConstantVector(shuffle, 4)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3102 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3103 | return RValue<Int2>(Nucleus::createBitCast(packed, Int2::getType())); |
| 3104 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3105 | } |
| 3106 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3107 | RValue<Int2> UnpackHigh(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3108 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3109 | if(CPUID::supportsMMX2()) |
| 3110 | { |
| 3111 | return x86::punpckhwd(x, y); |
| 3112 | } |
| 3113 | else |
| 3114 | { |
| 3115 | Constant *shuffle[4]; |
| 3116 | shuffle[0] = Nucleus::createConstantInt(2); |
| 3117 | shuffle[1] = Nucleus::createConstantInt(6); |
| 3118 | shuffle[2] = Nucleus::createConstantInt(3); |
| 3119 | shuffle[3] = Nucleus::createConstantInt(7); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3120 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3121 | Value *packed = Nucleus::createShuffleVector(x.value, y.value, Nucleus::createConstantVector(shuffle, 4)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3122 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3123 | return RValue<Int2>(Nucleus::createBitCast(packed, Int2::getType())); |
| 3124 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3125 | } |
| 3126 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3127 | RValue<Short4> Swizzle(RValue<Short4> x, unsigned char select) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3128 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3129 | if(CPUID::supportsMMX2()) |
| 3130 | { |
| 3131 | return x86::pshufw(x, select); |
| 3132 | } |
| 3133 | else |
| 3134 | { |
| 3135 | return RValue<Short4>(Nucleus::createSwizzle(x.value, select)); |
| 3136 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3137 | } |
| 3138 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3139 | RValue<Short4> Insert(RValue<Short4> val, RValue<Short> element, int i) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3140 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3141 | if(CPUID::supportsMMX2()) |
| 3142 | { |
| 3143 | return x86::pinsrw(val, Int(element), i); |
| 3144 | } |
| 3145 | else |
| 3146 | { |
| 3147 | return RValue<Short4>(Nucleus::createInsertElement(val.value, element.value, i)); |
| 3148 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3149 | } |
| 3150 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3151 | RValue<Short> Extract(RValue<Short4> val, int i) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3152 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3153 | if(CPUID::supportsMMX2()) |
| 3154 | { |
| 3155 | return Short(x86::pextrw(val, i)); |
| 3156 | } |
| 3157 | else |
| 3158 | { |
| 3159 | return RValue<Short>(Nucleus::createExtractElement(val.value, i)); |
| 3160 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3161 | } |
| 3162 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3163 | RValue<Short4> CmpGT(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3164 | { |
| 3165 | return x86::pcmpgtw(x, y); |
| 3166 | } |
| 3167 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3168 | RValue<Short4> CmpEQ(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3169 | { |
| 3170 | return x86::pcmpeqw(x, y); |
| 3171 | } |
| 3172 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3173 | Type *Short4::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3174 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3175 | if(CPUID::supportsMMX2()) |
| 3176 | { |
| 3177 | return MMX::getType(); |
| 3178 | } |
| 3179 | else |
| 3180 | { |
| 3181 | return VectorType::get(Short::getType(), 4); |
| 3182 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3183 | } |
| 3184 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3185 | UShort4::UShort4(RValue<Int4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3186 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3187 | *this = Short4(cast); |
| 3188 | } |
| 3189 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3190 | UShort4::UShort4(RValue<Float4> cast, bool saturate) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3191 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3192 | Float4 sat; |
| 3193 | |
| 3194 | if(saturate) |
| 3195 | { |
| 3196 | if(CPUID::supportsSSE4_1()) |
| 3197 | { |
| 3198 | sat = Min(cast, Float4(0xFFFF)); // packusdw takes care of 0x0000 saturation |
| 3199 | } |
| 3200 | else |
| 3201 | { |
| 3202 | sat = Max(Min(cast, Float4(0xFFFF)), Float4(0x0000)); |
| 3203 | } |
| 3204 | } |
| 3205 | else |
| 3206 | { |
| 3207 | sat = cast; |
| 3208 | } |
| 3209 | |
| 3210 | Int4 int4(sat); |
| 3211 | |
| 3212 | if(!saturate || !CPUID::supportsSSE4_1()) |
| 3213 | { |
| 3214 | *this = Short4(Int4(int4)); |
| 3215 | } |
| 3216 | else |
| 3217 | { |
| 3218 | *this = As<Short4>(Int2(As<Int4>(x86::packusdw(As<UInt4>(int4), As<UInt4>(int4))))); |
| 3219 | } |
| 3220 | } |
| 3221 | |
| 3222 | UShort4::UShort4() |
| 3223 | { |
| 3224 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3225 | } |
| 3226 | |
| 3227 | UShort4::UShort4(unsigned short x, unsigned short y, unsigned short z, unsigned short w) |
| 3228 | { |
| 3229 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3230 | |
| 3231 | Constant *constantVector[4]; |
| 3232 | constantVector[0] = Nucleus::createConstantShort(x); |
| 3233 | constantVector[1] = Nucleus::createConstantShort(y); |
| 3234 | constantVector[2] = Nucleus::createConstantShort(z); |
| 3235 | constantVector[3] = Nucleus::createConstantShort(w); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3236 | Value *vector = Nucleus::createConstantVector(constantVector, 4); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3237 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3238 | storeValue(Nucleus::createBitCast(vector, getType())); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3239 | } |
| 3240 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3241 | UShort4::UShort4(RValue<UShort4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3242 | { |
| 3243 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3244 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3245 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3246 | } |
| 3247 | |
| 3248 | UShort4::UShort4(const UShort4 &rhs) |
| 3249 | { |
| 3250 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3251 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3252 | Value *value = rhs.loadValue(); |
| 3253 | storeValue(value); |
| 3254 | } |
| 3255 | |
| 3256 | UShort4::UShort4(const Reference<UShort4> &rhs) |
| 3257 | { |
| 3258 | // xyzw.parent = this; |
| 3259 | |
| 3260 | Value *value = rhs.loadValue(); |
| 3261 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3262 | } |
| 3263 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3264 | UShort4::UShort4(RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3265 | { |
| 3266 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3267 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3268 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3269 | } |
| 3270 | |
| 3271 | UShort4::UShort4(const Short4 &rhs) |
| 3272 | { |
| 3273 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3274 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3275 | Value *value = rhs.loadValue(); |
| 3276 | storeValue(value); |
| 3277 | } |
| 3278 | |
| 3279 | UShort4::UShort4(const Reference<Short4> &rhs) |
| 3280 | { |
| 3281 | // xyzw.parent = this; |
| 3282 | |
| 3283 | Value *value = rhs.loadValue(); |
| 3284 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3285 | } |
| 3286 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3287 | RValue<UShort4> UShort4::operator=(RValue<UShort4> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3288 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3289 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3290 | |
| 3291 | return rhs; |
| 3292 | } |
| 3293 | |
| 3294 | RValue<UShort4> UShort4::operator=(const UShort4 &rhs) const |
| 3295 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3296 | Value *value = rhs.loadValue(); |
| 3297 | storeValue(value); |
| 3298 | |
| 3299 | return RValue<UShort4>(value); |
| 3300 | } |
| 3301 | |
| 3302 | RValue<UShort4> UShort4::operator=(const Reference<UShort4> &rhs) const |
| 3303 | { |
| 3304 | Value *value = rhs.loadValue(); |
| 3305 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3306 | |
| 3307 | return RValue<UShort4>(value); |
| 3308 | } |
| 3309 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3310 | RValue<UShort4> UShort4::operator=(RValue<Short4> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3311 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3312 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3313 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3314 | return RValue<UShort4>(rhs); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3315 | } |
| 3316 | |
| 3317 | RValue<UShort4> UShort4::operator=(const Short4 &rhs) const |
| 3318 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3319 | Value *value = rhs.loadValue(); |
| 3320 | storeValue(value); |
| 3321 | |
| 3322 | return RValue<UShort4>(value); |
| 3323 | } |
| 3324 | |
| 3325 | RValue<UShort4> UShort4::operator=(const Reference<Short4> &rhs) const |
| 3326 | { |
| 3327 | Value *value = rhs.loadValue(); |
| 3328 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3329 | |
| 3330 | return RValue<UShort4>(value); |
| 3331 | } |
| 3332 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3333 | RValue<UShort4> operator+(RValue<UShort4> lhs, RValue<UShort4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3334 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3335 | if(CPUID::supportsMMX2()) |
| 3336 | { |
| 3337 | return As<UShort4>(x86::paddw(As<Short4>(lhs), As<Short4>(rhs))); |
| 3338 | } |
| 3339 | else |
| 3340 | { |
| 3341 | return RValue<UShort4>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 3342 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3343 | } |
| 3344 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3345 | RValue<UShort4> operator-(RValue<UShort4> lhs, RValue<UShort4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3346 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3347 | if(CPUID::supportsMMX2()) |
| 3348 | { |
| 3349 | return As<UShort4>(x86::psubw(As<Short4>(lhs), As<Short4>(rhs))); |
| 3350 | } |
| 3351 | else |
| 3352 | { |
| 3353 | return RValue<UShort4>(Nucleus::createSub(lhs.value, rhs.value)); |
| 3354 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3355 | } |
| 3356 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3357 | |
| 3358 | RValue<UShort4> operator*(RValue<UShort4> lhs, RValue<UShort4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3359 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3360 | if(CPUID::supportsMMX2()) |
| 3361 | { |
| 3362 | return As<UShort4>(x86::pmullw(As<Short4>(lhs), As<Short4>(rhs))); |
| 3363 | } |
| 3364 | else |
| 3365 | { |
| 3366 | return RValue<UShort4>(Nucleus::createMul(lhs.value, rhs.value)); |
| 3367 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3368 | } |
| 3369 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3370 | RValue<UShort4> operator<<(RValue<UShort4> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3371 | { |
| 3372 | // return RValue<Short4>(Nucleus::createShl(lhs.value, rhs.value)); |
| 3373 | |
| 3374 | return As<UShort4>(x86::psllw(As<Short4>(lhs), rhs)); |
| 3375 | } |
| 3376 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3377 | RValue<UShort4> operator>>(RValue<UShort4> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3378 | { |
| 3379 | // return RValue<Short4>(Nucleus::createLShr(lhs.value, rhs.value)); |
| 3380 | |
| 3381 | return x86::psrlw(lhs, rhs); |
| 3382 | } |
| 3383 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3384 | RValue<UShort4> operator<<(RValue<UShort4> lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3385 | { |
| 3386 | // return RValue<Short4>(Nucleus::createShl(lhs.value, rhs.value)); |
| 3387 | |
| 3388 | return As<UShort4>(x86::psllw(As<Short4>(lhs), rhs)); |
| 3389 | } |
| 3390 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3391 | RValue<UShort4> operator>>(RValue<UShort4> lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3392 | { |
| 3393 | // return RValue<Short4>(Nucleus::createLShr(lhs.value, rhs.value)); |
| 3394 | |
| 3395 | return x86::psrlw(lhs, rhs); |
| 3396 | } |
| 3397 | |
| 3398 | RValue<UShort4> operator<<=(const UShort4 &lhs, unsigned char rhs) |
| 3399 | { |
| 3400 | return lhs = lhs << rhs; |
| 3401 | } |
| 3402 | |
| 3403 | RValue<UShort4> operator>>=(const UShort4 &lhs, unsigned char rhs) |
| 3404 | { |
| 3405 | return lhs = lhs >> rhs; |
| 3406 | } |
| 3407 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3408 | RValue<UShort4> operator<<=(const UShort4 &lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3409 | { |
| 3410 | return lhs = lhs << rhs; |
| 3411 | } |
| 3412 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3413 | RValue<UShort4> operator>>=(const UShort4 &lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3414 | { |
| 3415 | return lhs = lhs >> rhs; |
| 3416 | } |
| 3417 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3418 | RValue<UShort4> operator~(RValue<UShort4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3419 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3420 | if(CPUID::supportsMMX2()) |
| 3421 | { |
| 3422 | return As<UShort4>(As<Short4>(val) ^ Short4(0xFFFFu, 0xFFFFu, 0xFFFFu, 0xFFFFu)); |
| 3423 | } |
| 3424 | else |
| 3425 | { |
| 3426 | return RValue<UShort4>(Nucleus::createNot(val.value)); |
| 3427 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3428 | } |
| 3429 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3430 | RValue<UShort4> Max(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3431 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3432 | 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] | 3433 | } |
| 3434 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3435 | RValue<UShort4> Min(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3436 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3437 | 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] | 3438 | } |
| 3439 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3440 | RValue<UShort4> AddSat(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3441 | { |
| 3442 | return x86::paddusw(x, y); |
| 3443 | } |
| 3444 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3445 | RValue<UShort4> SubSat(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3446 | { |
| 3447 | return x86::psubusw(x, y); |
| 3448 | } |
| 3449 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3450 | RValue<UShort4> MulHigh(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3451 | { |
| 3452 | return x86::pmulhuw(x, y); |
| 3453 | } |
| 3454 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3455 | RValue<UShort4> Average(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3456 | { |
| 3457 | return x86::pavgw(x, y); |
| 3458 | } |
| 3459 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3460 | RValue<Byte8> Pack(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3461 | { |
| 3462 | return x86::packuswb(x, y); |
| 3463 | } |
| 3464 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3465 | Type *UShort4::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3466 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3467 | if(CPUID::supportsMMX2()) |
| 3468 | { |
| 3469 | return MMX::getType(); |
| 3470 | } |
| 3471 | else |
| 3472 | { |
| 3473 | return VectorType::get(UShort::getType(), 4); |
| 3474 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3475 | } |
| 3476 | |
| 3477 | Short8::Short8(short c0, short c1, short c2, short c3, short c4, short c5, short c6, short c7) |
| 3478 | { |
| 3479 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3480 | |
| 3481 | Constant *constantVector[8]; |
| 3482 | constantVector[0] = Nucleus::createConstantShort(c0); |
| 3483 | constantVector[1] = Nucleus::createConstantShort(c1); |
| 3484 | constantVector[2] = Nucleus::createConstantShort(c2); |
| 3485 | constantVector[3] = Nucleus::createConstantShort(c3); |
| 3486 | constantVector[4] = Nucleus::createConstantShort(c4); |
| 3487 | constantVector[5] = Nucleus::createConstantShort(c5); |
| 3488 | constantVector[6] = Nucleus::createConstantShort(c6); |
| 3489 | constantVector[7] = Nucleus::createConstantShort(c7); |
| 3490 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3491 | storeValue(Nucleus::createConstantVector(constantVector, 8)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3492 | } |
| 3493 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3494 | Short8::Short8(RValue<Short8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3495 | { |
| 3496 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3497 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3498 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3499 | } |
| 3500 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3501 | RValue<Short8> operator+(RValue<Short8> lhs, RValue<Short8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3502 | { |
| 3503 | return RValue<Short8>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 3504 | } |
| 3505 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3506 | RValue<Short8> operator&(RValue<Short8> lhs, RValue<Short8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3507 | { |
| 3508 | return RValue<Short8>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 3509 | } |
| 3510 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3511 | RValue<Short8> operator<<(RValue<Short8> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3512 | { |
| 3513 | return x86::psllw(lhs, rhs); // FIXME: Fallback required |
| 3514 | } |
| 3515 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3516 | RValue<Short8> operator>>(RValue<Short8> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3517 | { |
| 3518 | return x86::psraw(lhs, rhs); // FIXME: Fallback required |
| 3519 | } |
| 3520 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3521 | RValue<Short8> Concatenate(RValue<Short4> lo, RValue<Short4> hi) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3522 | { |
| 3523 | Value *loLong = Nucleus::createBitCast(lo.value, Long::getType()); |
| 3524 | Value *hiLong = Nucleus::createBitCast(hi.value, Long::getType()); |
| 3525 | |
| 3526 | Value *long2 = UndefValue::get(Long2::getType()); |
| 3527 | long2 = Nucleus::createInsertElement(long2, loLong, 0); |
| 3528 | long2 = Nucleus::createInsertElement(long2, hiLong, 1); |
| 3529 | Value *short8 = Nucleus::createBitCast(long2, Short8::getType()); |
| 3530 | |
| 3531 | return RValue<Short8>(short8); |
| 3532 | } |
| 3533 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3534 | RValue<Int4> MulAdd(RValue<Short8> x, RValue<Short8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3535 | { |
| 3536 | return x86::pmaddwd(x, y); // FIXME: Fallback required |
| 3537 | } |
| 3538 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3539 | RValue<Short8> MulHigh(RValue<Short8> x, RValue<Short8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3540 | { |
| 3541 | return x86::pmulhw(x, y); // FIXME: Fallback required |
| 3542 | } |
| 3543 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3544 | Type *Short8::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3545 | { |
| 3546 | return VectorType::get(Short::getType(), 8); |
| 3547 | } |
| 3548 | |
| 3549 | 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) |
| 3550 | { |
| 3551 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3552 | |
| 3553 | Constant *constantVector[8]; |
| 3554 | constantVector[0] = Nucleus::createConstantShort(c0); |
| 3555 | constantVector[1] = Nucleus::createConstantShort(c1); |
| 3556 | constantVector[2] = Nucleus::createConstantShort(c2); |
| 3557 | constantVector[3] = Nucleus::createConstantShort(c3); |
| 3558 | constantVector[4] = Nucleus::createConstantShort(c4); |
| 3559 | constantVector[5] = Nucleus::createConstantShort(c5); |
| 3560 | constantVector[6] = Nucleus::createConstantShort(c6); |
| 3561 | constantVector[7] = Nucleus::createConstantShort(c7); |
| 3562 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3563 | storeValue(Nucleus::createConstantVector(constantVector, 8)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3564 | } |
| 3565 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3566 | UShort8::UShort8(RValue<UShort8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3567 | { |
| 3568 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3569 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3570 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3571 | } |
| 3572 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3573 | RValue<UShort8> UShort8::operator=(RValue<UShort8> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3574 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3575 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3576 | |
| 3577 | return rhs; |
| 3578 | } |
| 3579 | |
| 3580 | RValue<UShort8> UShort8::operator=(const UShort8 &rhs) const |
| 3581 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3582 | Value *value = rhs.loadValue(); |
| 3583 | storeValue(value); |
| 3584 | |
| 3585 | return RValue<UShort8>(value); |
| 3586 | } |
| 3587 | |
| 3588 | RValue<UShort8> UShort8::operator=(const Reference<UShort8> &rhs) const |
| 3589 | { |
| 3590 | Value *value = rhs.loadValue(); |
| 3591 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3592 | |
| 3593 | return RValue<UShort8>(value); |
| 3594 | } |
| 3595 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3596 | RValue<UShort8> operator&(RValue<UShort8> lhs, RValue<UShort8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3597 | { |
| 3598 | return RValue<UShort8>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 3599 | } |
| 3600 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3601 | RValue<UShort8> operator<<(RValue<UShort8> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3602 | { |
| 3603 | return As<UShort8>(x86::psllw(As<Short8>(lhs), rhs)); // FIXME: Fallback required |
| 3604 | } |
| 3605 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3606 | RValue<UShort8> operator>>(RValue<UShort8> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3607 | { |
| 3608 | return x86::psrlw(lhs, rhs); // FIXME: Fallback required |
| 3609 | } |
| 3610 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3611 | RValue<UShort8> operator+(RValue<UShort8> lhs, RValue<UShort8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3612 | { |
| 3613 | return RValue<UShort8>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 3614 | } |
| 3615 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3616 | RValue<UShort8> operator*(RValue<UShort8> lhs, RValue<UShort8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3617 | { |
| 3618 | return RValue<UShort8>(Nucleus::createMul(lhs.value, rhs.value)); |
| 3619 | } |
| 3620 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3621 | RValue<UShort8> operator+=(const UShort8 &lhs, RValue<UShort8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3622 | { |
| 3623 | return lhs = lhs + rhs; |
| 3624 | } |
| 3625 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3626 | RValue<UShort8> operator~(RValue<UShort8> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3627 | { |
| 3628 | return RValue<UShort8>(Nucleus::createNot(val.value)); |
| 3629 | } |
| 3630 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3631 | 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] | 3632 | { |
| 3633 | Constant *pshufb[16]; |
| 3634 | pshufb[0] = Nucleus::createConstantInt(select0 + 0); |
| 3635 | pshufb[1] = Nucleus::createConstantInt(select0 + 1); |
| 3636 | pshufb[2] = Nucleus::createConstantInt(select1 + 0); |
| 3637 | pshufb[3] = Nucleus::createConstantInt(select1 + 1); |
| 3638 | pshufb[4] = Nucleus::createConstantInt(select2 + 0); |
| 3639 | pshufb[5] = Nucleus::createConstantInt(select2 + 1); |
| 3640 | pshufb[6] = Nucleus::createConstantInt(select3 + 0); |
| 3641 | pshufb[7] = Nucleus::createConstantInt(select3 + 1); |
| 3642 | pshufb[8] = Nucleus::createConstantInt(select4 + 0); |
| 3643 | pshufb[9] = Nucleus::createConstantInt(select4 + 1); |
| 3644 | pshufb[10] = Nucleus::createConstantInt(select5 + 0); |
| 3645 | pshufb[11] = Nucleus::createConstantInt(select5 + 1); |
| 3646 | pshufb[12] = Nucleus::createConstantInt(select6 + 0); |
| 3647 | pshufb[13] = Nucleus::createConstantInt(select6 + 1); |
| 3648 | pshufb[14] = Nucleus::createConstantInt(select7 + 0); |
| 3649 | pshufb[15] = Nucleus::createConstantInt(select7 + 1); |
| 3650 | |
| 3651 | Value *byte16 = Nucleus::createBitCast(x.value, Byte16::getType()); |
| 3652 | Value *shuffle = Nucleus::createShuffleVector(byte16, UndefValue::get(Byte16::getType()), Nucleus::createConstantVector(pshufb, 16)); |
| 3653 | Value *short8 = Nucleus::createBitCast(shuffle, UShort8::getType()); |
| 3654 | |
| 3655 | return RValue<UShort8>(short8); |
| 3656 | } |
| 3657 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3658 | RValue<UShort8> Concatenate(RValue<UShort4> lo, RValue<UShort4> hi) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3659 | { |
| 3660 | Value *loLong = Nucleus::createBitCast(lo.value, Long::getType()); |
| 3661 | Value *hiLong = Nucleus::createBitCast(hi.value, Long::getType()); |
| 3662 | |
| 3663 | Value *long2 = UndefValue::get(Long2::getType()); |
| 3664 | long2 = Nucleus::createInsertElement(long2, loLong, 0); |
| 3665 | long2 = Nucleus::createInsertElement(long2, hiLong, 1); |
| 3666 | Value *short8 = Nucleus::createBitCast(long2, Short8::getType()); |
| 3667 | |
| 3668 | return RValue<UShort8>(short8); |
| 3669 | } |
| 3670 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3671 | RValue<UShort8> MulHigh(RValue<UShort8> x, RValue<UShort8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3672 | { |
| 3673 | return x86::pmulhuw(x, y); // FIXME: Fallback required |
| 3674 | } |
| 3675 | |
| 3676 | // FIXME: Implement as Shuffle(x, y, Select(i0, ..., i16)) and Shuffle(x, y, SELECT_PACK_REPEAT(element)) |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3677 | // RValue<UShort8> PackRepeat(RValue<Byte16> x, RValue<Byte16> y, int element) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3678 | // { |
| 3679 | // Constant *pshufb[16]; |
| 3680 | // pshufb[0] = Nucleus::createConstantInt(element + 0); |
| 3681 | // pshufb[1] = Nucleus::createConstantInt(element + 0); |
| 3682 | // pshufb[2] = Nucleus::createConstantInt(element + 4); |
| 3683 | // pshufb[3] = Nucleus::createConstantInt(element + 4); |
| 3684 | // pshufb[4] = Nucleus::createConstantInt(element + 8); |
| 3685 | // pshufb[5] = Nucleus::createConstantInt(element + 8); |
| 3686 | // pshufb[6] = Nucleus::createConstantInt(element + 12); |
| 3687 | // pshufb[7] = Nucleus::createConstantInt(element + 12); |
| 3688 | // pshufb[8] = Nucleus::createConstantInt(element + 16); |
| 3689 | // pshufb[9] = Nucleus::createConstantInt(element + 16); |
| 3690 | // pshufb[10] = Nucleus::createConstantInt(element + 20); |
| 3691 | // pshufb[11] = Nucleus::createConstantInt(element + 20); |
| 3692 | // pshufb[12] = Nucleus::createConstantInt(element + 24); |
| 3693 | // pshufb[13] = Nucleus::createConstantInt(element + 24); |
| 3694 | // pshufb[14] = Nucleus::createConstantInt(element + 28); |
| 3695 | // pshufb[15] = Nucleus::createConstantInt(element + 28); |
| 3696 | // |
| 3697 | // Value *shuffle = Nucleus::createShuffleVector(x.value, y.value, Nucleus::createConstantVector(pshufb, 16)); |
| 3698 | // Value *short8 = Nucleus::createBitCast(shuffle, UShort8::getType()); |
| 3699 | // |
| 3700 | // return RValue<UShort8>(short8); |
| 3701 | // } |
| 3702 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3703 | Type *UShort8::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3704 | { |
| 3705 | return VectorType::get(UShort::getType(), 8); |
| 3706 | } |
| 3707 | |
| 3708 | Int::Int(Argument *argument) |
| 3709 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3710 | storeValue(argument); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3711 | } |
| 3712 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3713 | Int::Int(RValue<Byte> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3714 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3715 | Value *integer = Nucleus::createZExt(cast.value, Int::getType()); |
| 3716 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3717 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3718 | } |
| 3719 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3720 | Int::Int(RValue<SByte> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3721 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3722 | Value *integer = Nucleus::createSExt(cast.value, Int::getType()); |
| 3723 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3724 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3725 | } |
| 3726 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3727 | Int::Int(RValue<Short> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3728 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3729 | Value *integer = Nucleus::createSExt(cast.value, Int::getType()); |
| 3730 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3731 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3732 | } |
| 3733 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3734 | Int::Int(RValue<UShort> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3735 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3736 | Value *integer = Nucleus::createZExt(cast.value, Int::getType()); |
| 3737 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3738 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3739 | } |
| 3740 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3741 | Int::Int(RValue<Int2> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3742 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3743 | *this = Extract(cast, 0); |
| 3744 | } |
| 3745 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3746 | Int::Int(RValue<Long> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3747 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3748 | Value *integer = Nucleus::createTrunc(cast.value, Int::getType()); |
| 3749 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3750 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3751 | } |
| 3752 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3753 | Int::Int(RValue<Float> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3754 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3755 | Value *integer = Nucleus::createFPToSI(cast.value, Int::getType()); |
| 3756 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3757 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3758 | } |
| 3759 | |
| 3760 | Int::Int() |
| 3761 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3762 | } |
| 3763 | |
| 3764 | Int::Int(int x) |
| 3765 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3766 | storeValue(Nucleus::createConstantInt(x)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3767 | } |
| 3768 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3769 | Int::Int(RValue<Int> rhs) |
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 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3772 | } |
| 3773 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3774 | Int::Int(RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3775 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3776 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3777 | } |
| 3778 | |
| 3779 | Int::Int(const Int &rhs) |
| 3780 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3781 | Value *value = rhs.loadValue(); |
| 3782 | storeValue(value); |
| 3783 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3784 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3785 | Int::Int(const Reference<Int> &rhs) |
| 3786 | { |
| 3787 | Value *value = rhs.loadValue(); |
| 3788 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3789 | } |
| 3790 | |
| 3791 | Int::Int(const UInt &rhs) |
| 3792 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3793 | Value *value = rhs.loadValue(); |
| 3794 | storeValue(value); |
| 3795 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3796 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3797 | Int::Int(const Reference<UInt> &rhs) |
| 3798 | { |
| 3799 | Value *value = rhs.loadValue(); |
| 3800 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3801 | } |
| 3802 | |
| 3803 | RValue<Int> Int::operator=(int rhs) const |
| 3804 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3805 | return RValue<Int>(storeValue(Nucleus::createConstantInt(rhs))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3806 | } |
| 3807 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3808 | RValue<Int> Int::operator=(RValue<Int> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3809 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3810 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3811 | |
| 3812 | return rhs; |
| 3813 | } |
| 3814 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3815 | RValue<Int> Int::operator=(RValue<UInt> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3816 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3817 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3818 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3819 | return RValue<Int>(rhs); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3820 | } |
| 3821 | |
| 3822 | RValue<Int> Int::operator=(const Int &rhs) const |
| 3823 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3824 | Value *value = rhs.loadValue(); |
| 3825 | storeValue(value); |
| 3826 | |
| 3827 | return RValue<Int>(value); |
| 3828 | } |
| 3829 | |
| 3830 | RValue<Int> Int::operator=(const Reference<Int> &rhs) const |
| 3831 | { |
| 3832 | Value *value = rhs.loadValue(); |
| 3833 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3834 | |
| 3835 | return RValue<Int>(value); |
| 3836 | } |
| 3837 | |
| 3838 | RValue<Int> Int::operator=(const UInt &rhs) const |
| 3839 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3840 | Value *value = rhs.loadValue(); |
| 3841 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3842 | |
| 3843 | return RValue<Int>(value); |
| 3844 | } |
| 3845 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3846 | RValue<Int> Int::operator=(const Reference<UInt> &rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3847 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3848 | Value *value = rhs.loadValue(); |
| 3849 | storeValue(value); |
| 3850 | |
| 3851 | return RValue<Int>(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3852 | } |
| 3853 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3854 | RValue<Int> operator+(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3855 | { |
| 3856 | return RValue<Int>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 3857 | } |
| 3858 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3859 | RValue<Int> operator-(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3860 | { |
| 3861 | return RValue<Int>(Nucleus::createSub(lhs.value, rhs.value)); |
| 3862 | } |
| 3863 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3864 | RValue<Int> operator*(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3865 | { |
| 3866 | return RValue<Int>(Nucleus::createMul(lhs.value, rhs.value)); |
| 3867 | } |
| 3868 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3869 | RValue<Int> operator/(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3870 | { |
| 3871 | return RValue<Int>(Nucleus::createSDiv(lhs.value, rhs.value)); |
| 3872 | } |
| 3873 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3874 | RValue<Int> operator%(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3875 | { |
| 3876 | return RValue<Int>(Nucleus::createSRem(lhs.value, rhs.value)); |
| 3877 | } |
| 3878 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3879 | RValue<Int> operator&(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3880 | { |
| 3881 | return RValue<Int>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 3882 | } |
| 3883 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3884 | RValue<Int> operator|(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3885 | { |
| 3886 | return RValue<Int>(Nucleus::createOr(lhs.value, rhs.value)); |
| 3887 | } |
| 3888 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3889 | RValue<Int> operator^(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3890 | { |
| 3891 | return RValue<Int>(Nucleus::createXor(lhs.value, rhs.value)); |
| 3892 | } |
| 3893 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3894 | RValue<Int> operator<<(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3895 | { |
| 3896 | return RValue<Int>(Nucleus::createShl(lhs.value, rhs.value)); |
| 3897 | } |
| 3898 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3899 | RValue<Int> operator>>(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3900 | { |
| 3901 | return RValue<Int>(Nucleus::createAShr(lhs.value, rhs.value)); |
| 3902 | } |
| 3903 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3904 | RValue<Int> operator+=(const Int &lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3905 | { |
| 3906 | return lhs = lhs + rhs; |
| 3907 | } |
| 3908 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3909 | RValue<Int> operator-=(const Int &lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3910 | { |
| 3911 | return lhs = lhs - rhs; |
| 3912 | } |
| 3913 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3914 | RValue<Int> operator*=(const Int &lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3915 | { |
| 3916 | return lhs = lhs * rhs; |
| 3917 | } |
| 3918 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3919 | RValue<Int> operator/=(const Int &lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3920 | { |
| 3921 | return lhs = lhs / rhs; |
| 3922 | } |
| 3923 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3924 | RValue<Int> operator%=(const Int &lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3925 | { |
| 3926 | return lhs = lhs % rhs; |
| 3927 | } |
| 3928 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3929 | RValue<Int> operator&=(const Int &lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3930 | { |
| 3931 | return lhs = lhs & rhs; |
| 3932 | } |
| 3933 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3934 | RValue<Int> operator|=(const Int &lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3935 | { |
| 3936 | return lhs = lhs | rhs; |
| 3937 | } |
| 3938 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3939 | RValue<Int> operator^=(const Int &lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3940 | { |
| 3941 | return lhs = lhs ^ rhs; |
| 3942 | } |
| 3943 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3944 | RValue<Int> operator<<=(const Int &lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3945 | { |
| 3946 | return lhs = lhs << rhs; |
| 3947 | } |
| 3948 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3949 | RValue<Int> operator>>=(const Int &lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3950 | { |
| 3951 | return lhs = lhs >> rhs; |
| 3952 | } |
| 3953 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3954 | RValue<Int> operator+(RValue<Int> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3955 | { |
| 3956 | return val; |
| 3957 | } |
| 3958 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3959 | RValue<Int> operator-(RValue<Int> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3960 | { |
| 3961 | return RValue<Int>(Nucleus::createNeg(val.value)); |
| 3962 | } |
| 3963 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3964 | RValue<Int> operator~(RValue<Int> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3965 | { |
| 3966 | return RValue<Int>(Nucleus::createNot(val.value)); |
| 3967 | } |
| 3968 | |
| 3969 | RValue<Int> operator++(const Int &val, int) // Post-increment |
| 3970 | { |
| 3971 | RValue<Int> res = val; |
| 3972 | |
| 3973 | Value *inc = Nucleus::createAdd(res.value, Nucleus::createConstantInt(1)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3974 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3975 | |
| 3976 | return res; |
| 3977 | } |
| 3978 | |
| 3979 | const Int &operator++(const Int &val) // Pre-increment |
| 3980 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3981 | Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantInt(1)); |
| 3982 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3983 | |
| 3984 | return val; |
| 3985 | } |
| 3986 | |
| 3987 | RValue<Int> operator--(const Int &val, int) // Post-decrement |
| 3988 | { |
| 3989 | RValue<Int> res = val; |
| 3990 | |
| 3991 | Value *inc = Nucleus::createSub(res.value, Nucleus::createConstantInt(1)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3992 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3993 | |
| 3994 | return res; |
| 3995 | } |
| 3996 | |
| 3997 | const Int &operator--(const Int &val) // Pre-decrement |
| 3998 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3999 | Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantInt(1)); |
| 4000 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4001 | |
| 4002 | return val; |
| 4003 | } |
| 4004 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4005 | RValue<Bool> operator<(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4006 | { |
| 4007 | return RValue<Bool>(Nucleus::createICmpSLT(lhs.value, rhs.value)); |
| 4008 | } |
| 4009 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4010 | RValue<Bool> operator<=(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4011 | { |
| 4012 | return RValue<Bool>(Nucleus::createICmpSLE(lhs.value, rhs.value)); |
| 4013 | } |
| 4014 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4015 | RValue<Bool> operator>(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4016 | { |
| 4017 | return RValue<Bool>(Nucleus::createICmpSGT(lhs.value, rhs.value)); |
| 4018 | } |
| 4019 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4020 | RValue<Bool> operator>=(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4021 | { |
| 4022 | return RValue<Bool>(Nucleus::createICmpSGE(lhs.value, rhs.value)); |
| 4023 | } |
| 4024 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4025 | RValue<Bool> operator!=(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4026 | { |
| 4027 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value)); |
| 4028 | } |
| 4029 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4030 | RValue<Bool> operator==(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4031 | { |
| 4032 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value)); |
| 4033 | } |
| 4034 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4035 | RValue<Int> Max(RValue<Int> x, RValue<Int> y) |
| 4036 | { |
| 4037 | return IfThenElse(x > y, x, y); |
| 4038 | } |
| 4039 | |
| 4040 | RValue<Int> Min(RValue<Int> x, RValue<Int> y) |
| 4041 | { |
| 4042 | return IfThenElse(x < y, x, y); |
| 4043 | } |
| 4044 | |
| 4045 | RValue<Int> Clamp(RValue<Int> x, RValue<Int> min, RValue<Int> max) |
| 4046 | { |
| 4047 | return Min(Max(x, min), max); |
| 4048 | } |
| 4049 | |
| 4050 | RValue<Int> RoundInt(RValue<Float> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4051 | { |
| 4052 | return x86::cvtss2si(cast); |
| 4053 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4054 | // 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] | 4055 | } |
| 4056 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4057 | Type *Int::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4058 | { |
| 4059 | return Type::getInt32Ty(*Nucleus::getContext()); |
| 4060 | } |
| 4061 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4062 | Long::Long(RValue<Int> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4063 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4064 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4065 | |
| 4066 | Value *integer = Nucleus::createSExt(cast.value, Long::getType()); |
| 4067 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4068 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4069 | } |
| 4070 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4071 | Long::Long(RValue<UInt> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4072 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4073 | Value *integer = Nucleus::createZExt(cast.value, Long::getType()); |
| 4074 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4075 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4076 | } |
| 4077 | |
| 4078 | Long::Long() |
| 4079 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4080 | } |
| 4081 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4082 | Long::Long(RValue<Long> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4083 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4084 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4085 | } |
| 4086 | |
| 4087 | RValue<Long> Long::operator=(int64_t rhs) const |
| 4088 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4089 | return RValue<Long>(storeValue(Nucleus::createConstantInt(rhs))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4090 | } |
| 4091 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4092 | RValue<Long> Long::operator=(RValue<Long> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4093 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4094 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4095 | |
| 4096 | return rhs; |
| 4097 | } |
| 4098 | |
| 4099 | RValue<Long> Long::operator=(const Long &rhs) const |
| 4100 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4101 | Value *value = rhs.loadValue(); |
| 4102 | storeValue(value); |
| 4103 | |
| 4104 | return RValue<Long>(value); |
| 4105 | } |
| 4106 | |
| 4107 | RValue<Long> Long::operator=(const Reference<Long> &rhs) const |
| 4108 | { |
| 4109 | Value *value = rhs.loadValue(); |
| 4110 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4111 | |
| 4112 | return RValue<Long>(value); |
| 4113 | } |
| 4114 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4115 | RValue<Long> operator+(RValue<Long> lhs, RValue<Long> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4116 | { |
| 4117 | return RValue<Long>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 4118 | } |
| 4119 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4120 | RValue<Long> operator-(RValue<Long> lhs, RValue<Long> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4121 | { |
| 4122 | return RValue<Long>(Nucleus::createSub(lhs.value, rhs.value)); |
| 4123 | } |
| 4124 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4125 | RValue<Long> operator+=(const Long &lhs, RValue<Long> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4126 | { |
| 4127 | return lhs = lhs + rhs; |
| 4128 | } |
| 4129 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4130 | RValue<Long> operator-=(const Long &lhs, RValue<Long> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4131 | { |
| 4132 | return lhs = lhs - rhs; |
| 4133 | } |
| 4134 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4135 | RValue<Long> AddAtomic(RValue<Pointer<Long> > x, RValue<Long> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4136 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4137 | return RValue<Long>(Nucleus::createAtomicAdd(x.value, y.value)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4138 | } |
| 4139 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4140 | Type *Long::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4141 | { |
| 4142 | return Type::getInt64Ty(*Nucleus::getContext()); |
| 4143 | } |
| 4144 | |
| 4145 | Long1::Long1(const Reference<UInt> &cast) |
| 4146 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4147 | Value *uint = cast.loadValue(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4148 | Value *int64 = Nucleus::createZExt(uint, Long::getType()); |
| 4149 | Value *long1 = Nucleus::createBitCast(int64, Long1::getType()); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4150 | |
| 4151 | storeValue(long1); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4152 | } |
| 4153 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4154 | Long1::Long1(RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4155 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4156 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4157 | } |
| 4158 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4159 | Type *Long1::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4160 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4161 | if(CPUID::supportsMMX2()) |
| 4162 | { |
| 4163 | return MMX::getType(); |
| 4164 | } |
| 4165 | else |
| 4166 | { |
| 4167 | return VectorType::get(Long::getType(), 1); |
| 4168 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4169 | } |
| 4170 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4171 | RValue<Long2> UnpackHigh(RValue<Long2> x, RValue<Long2> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4172 | { |
| 4173 | Constant *shuffle[2]; |
| 4174 | shuffle[0] = Nucleus::createConstantInt(1); |
| 4175 | shuffle[1] = Nucleus::createConstantInt(3); |
| 4176 | |
| 4177 | Value *packed = Nucleus::createShuffleVector(x.value, y.value, Nucleus::createConstantVector(shuffle, 2)); |
| 4178 | |
| 4179 | return RValue<Long2>(packed); |
| 4180 | } |
| 4181 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4182 | Type *Long2::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4183 | { |
| 4184 | return VectorType::get(Long::getType(), 2); |
| 4185 | } |
| 4186 | |
| 4187 | UInt::UInt(Argument *argument) |
| 4188 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4189 | storeValue(argument); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4190 | } |
| 4191 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4192 | UInt::UInt(RValue<UShort> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4193 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4194 | Value *integer = Nucleus::createZExt(cast.value, UInt::getType()); |
| 4195 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4196 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4197 | } |
| 4198 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4199 | UInt::UInt(RValue<Long> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4200 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4201 | Value *integer = Nucleus::createTrunc(cast.value, UInt::getType()); |
| 4202 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4203 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4204 | } |
| 4205 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4206 | UInt::UInt(RValue<Float> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4207 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4208 | Value *integer = Nucleus::createFPToSI(cast.value, UInt::getType()); |
| 4209 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4210 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4211 | } |
| 4212 | |
| 4213 | UInt::UInt() |
| 4214 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4215 | } |
| 4216 | |
| 4217 | UInt::UInt(int x) |
| 4218 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4219 | storeValue(Nucleus::createConstantInt(x)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4220 | } |
| 4221 | |
| 4222 | UInt::UInt(unsigned int x) |
| 4223 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4224 | storeValue(Nucleus::createConstantInt(x)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4225 | } |
| 4226 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4227 | UInt::UInt(RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4228 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4229 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4230 | } |
| 4231 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4232 | UInt::UInt(RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4233 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4234 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4235 | } |
| 4236 | |
| 4237 | UInt::UInt(const UInt &rhs) |
| 4238 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4239 | Value *value = rhs.loadValue(); |
| 4240 | storeValue(value); |
| 4241 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4242 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4243 | UInt::UInt(const Reference<UInt> &rhs) |
| 4244 | { |
| 4245 | Value *value = rhs.loadValue(); |
| 4246 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4247 | } |
| 4248 | |
| 4249 | UInt::UInt(const Int &rhs) |
| 4250 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4251 | Value *value = rhs.loadValue(); |
| 4252 | storeValue(value); |
| 4253 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4254 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4255 | UInt::UInt(const Reference<Int> &rhs) |
| 4256 | { |
| 4257 | Value *value = rhs.loadValue(); |
| 4258 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4259 | } |
| 4260 | |
| 4261 | RValue<UInt> UInt::operator=(unsigned int rhs) const |
| 4262 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4263 | return RValue<UInt>(storeValue(Nucleus::createConstantInt(rhs))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4264 | } |
| 4265 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4266 | RValue<UInt> UInt::operator=(RValue<UInt> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4267 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4268 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4269 | |
| 4270 | return rhs; |
| 4271 | } |
| 4272 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4273 | RValue<UInt> UInt::operator=(RValue<Int> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4274 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4275 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4276 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4277 | return RValue<UInt>(rhs); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4278 | } |
| 4279 | |
| 4280 | RValue<UInt> UInt::operator=(const UInt &rhs) const |
| 4281 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4282 | Value *value = rhs.loadValue(); |
| 4283 | storeValue(value); |
| 4284 | |
| 4285 | return RValue<UInt>(value); |
| 4286 | } |
| 4287 | |
| 4288 | RValue<UInt> UInt::operator=(const Reference<UInt> &rhs) const |
| 4289 | { |
| 4290 | Value *value = rhs.loadValue(); |
| 4291 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4292 | |
| 4293 | return RValue<UInt>(value); |
| 4294 | } |
| 4295 | |
| 4296 | RValue<UInt> UInt::operator=(const Int &rhs) const |
| 4297 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4298 | Value *value = rhs.loadValue(); |
| 4299 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4300 | |
| 4301 | return RValue<UInt>(value); |
| 4302 | } |
| 4303 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4304 | RValue<UInt> UInt::operator=(const Reference<Int> &rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4305 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4306 | Value *value = rhs.loadValue(); |
| 4307 | storeValue(value); |
| 4308 | |
| 4309 | return RValue<UInt>(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4310 | } |
| 4311 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4312 | RValue<UInt> operator+(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4313 | { |
| 4314 | return RValue<UInt>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 4315 | } |
| 4316 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4317 | RValue<UInt> operator-(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4318 | { |
| 4319 | return RValue<UInt>(Nucleus::createSub(lhs.value, rhs.value)); |
| 4320 | } |
| 4321 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4322 | RValue<UInt> operator*(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4323 | { |
| 4324 | return RValue<UInt>(Nucleus::createMul(lhs.value, rhs.value)); |
| 4325 | } |
| 4326 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4327 | RValue<UInt> operator/(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4328 | { |
| 4329 | return RValue<UInt>(Nucleus::createUDiv(lhs.value, rhs.value)); |
| 4330 | } |
| 4331 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4332 | RValue<UInt> operator%(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4333 | { |
| 4334 | return RValue<UInt>(Nucleus::createURem(lhs.value, rhs.value)); |
| 4335 | } |
| 4336 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4337 | RValue<UInt> operator&(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4338 | { |
| 4339 | return RValue<UInt>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 4340 | } |
| 4341 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4342 | RValue<UInt> operator|(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4343 | { |
| 4344 | return RValue<UInt>(Nucleus::createOr(lhs.value, rhs.value)); |
| 4345 | } |
| 4346 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4347 | RValue<UInt> operator^(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4348 | { |
| 4349 | return RValue<UInt>(Nucleus::createXor(lhs.value, rhs.value)); |
| 4350 | } |
| 4351 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4352 | RValue<UInt> operator<<(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4353 | { |
| 4354 | return RValue<UInt>(Nucleus::createShl(lhs.value, rhs.value)); |
| 4355 | } |
| 4356 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4357 | RValue<UInt> operator>>(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4358 | { |
| 4359 | return RValue<UInt>(Nucleus::createLShr(lhs.value, rhs.value)); |
| 4360 | } |
| 4361 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4362 | RValue<UInt> operator+=(const UInt &lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4363 | { |
| 4364 | return lhs = lhs + rhs; |
| 4365 | } |
| 4366 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4367 | RValue<UInt> operator-=(const UInt &lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4368 | { |
| 4369 | return lhs = lhs - rhs; |
| 4370 | } |
| 4371 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4372 | RValue<UInt> operator*=(const UInt &lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4373 | { |
| 4374 | return lhs = lhs * rhs; |
| 4375 | } |
| 4376 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4377 | RValue<UInt> operator/=(const UInt &lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4378 | { |
| 4379 | return lhs = lhs / rhs; |
| 4380 | } |
| 4381 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4382 | RValue<UInt> operator%=(const UInt &lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4383 | { |
| 4384 | return lhs = lhs % rhs; |
| 4385 | } |
| 4386 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4387 | RValue<UInt> operator&=(const UInt &lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4388 | { |
| 4389 | return lhs = lhs & rhs; |
| 4390 | } |
| 4391 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4392 | RValue<UInt> operator|=(const UInt &lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4393 | { |
| 4394 | return lhs = lhs | rhs; |
| 4395 | } |
| 4396 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4397 | RValue<UInt> operator^=(const UInt &lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4398 | { |
| 4399 | return lhs = lhs ^ rhs; |
| 4400 | } |
| 4401 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4402 | RValue<UInt> operator<<=(const UInt &lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4403 | { |
| 4404 | return lhs = lhs << rhs; |
| 4405 | } |
| 4406 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4407 | RValue<UInt> operator>>=(const UInt &lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4408 | { |
| 4409 | return lhs = lhs >> rhs; |
| 4410 | } |
| 4411 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4412 | RValue<UInt> operator+(RValue<UInt> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4413 | { |
| 4414 | return val; |
| 4415 | } |
| 4416 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4417 | RValue<UInt> operator-(RValue<UInt> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4418 | { |
| 4419 | return RValue<UInt>(Nucleus::createNeg(val.value)); |
| 4420 | } |
| 4421 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4422 | RValue<UInt> operator~(RValue<UInt> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4423 | { |
| 4424 | return RValue<UInt>(Nucleus::createNot(val.value)); |
| 4425 | } |
| 4426 | |
| 4427 | RValue<UInt> operator++(const UInt &val, int) // Post-increment |
| 4428 | { |
| 4429 | RValue<UInt> res = val; |
| 4430 | |
| 4431 | Value *inc = Nucleus::createAdd(res.value, Nucleus::createConstantInt(1)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4432 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4433 | |
| 4434 | return res; |
| 4435 | } |
| 4436 | |
| 4437 | const UInt &operator++(const UInt &val) // Pre-increment |
| 4438 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4439 | Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantInt(1)); |
| 4440 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4441 | |
| 4442 | return val; |
| 4443 | } |
| 4444 | |
| 4445 | RValue<UInt> operator--(const UInt &val, int) // Post-decrement |
| 4446 | { |
| 4447 | RValue<UInt> res = val; |
| 4448 | |
| 4449 | Value *inc = Nucleus::createSub(res.value, Nucleus::createConstantInt(1)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4450 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4451 | |
| 4452 | return res; |
| 4453 | } |
| 4454 | |
| 4455 | const UInt &operator--(const UInt &val) // Pre-decrement |
| 4456 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4457 | Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantInt(1)); |
| 4458 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4459 | |
| 4460 | return val; |
| 4461 | } |
| 4462 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4463 | RValue<UInt> Max(RValue<UInt> x, RValue<UInt> y) |
| 4464 | { |
| 4465 | return IfThenElse(x > y, x, y); |
| 4466 | } |
| 4467 | |
| 4468 | RValue<UInt> Min(RValue<UInt> x, RValue<UInt> y) |
| 4469 | { |
| 4470 | return IfThenElse(x < y, x, y); |
| 4471 | } |
| 4472 | |
| 4473 | RValue<UInt> Clamp(RValue<UInt> x, RValue<UInt> min, RValue<UInt> max) |
| 4474 | { |
| 4475 | return Min(Max(x, min), max); |
| 4476 | } |
| 4477 | |
| 4478 | RValue<Bool> operator<(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4479 | { |
| 4480 | return RValue<Bool>(Nucleus::createICmpULT(lhs.value, rhs.value)); |
| 4481 | } |
| 4482 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4483 | RValue<Bool> operator<=(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4484 | { |
| 4485 | return RValue<Bool>(Nucleus::createICmpULE(lhs.value, rhs.value)); |
| 4486 | } |
| 4487 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4488 | RValue<Bool> operator>(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4489 | { |
| 4490 | return RValue<Bool>(Nucleus::createICmpUGT(lhs.value, rhs.value)); |
| 4491 | } |
| 4492 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4493 | RValue<Bool> operator>=(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4494 | { |
| 4495 | return RValue<Bool>(Nucleus::createICmpUGE(lhs.value, rhs.value)); |
| 4496 | } |
| 4497 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4498 | RValue<Bool> operator!=(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4499 | { |
| 4500 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value)); |
| 4501 | } |
| 4502 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4503 | RValue<Bool> operator==(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4504 | { |
| 4505 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value)); |
| 4506 | } |
| 4507 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4508 | // RValue<UInt> RoundUInt(RValue<Float> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4509 | // { |
| 4510 | // return x86::cvtss2si(val); // FIXME: Unsigned |
| 4511 | // |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4512 | // // 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] | 4513 | // } |
| 4514 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4515 | Type *UInt::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4516 | { |
| 4517 | return Type::getInt32Ty(*Nucleus::getContext()); |
| 4518 | } |
| 4519 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4520 | // Int2::Int2(RValue<Int> cast) |
| 4521 | // { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4522 | // Value *extend = Nucleus::createZExt(cast.value, Long::getType()); |
| 4523 | // Value *vector = Nucleus::createBitCast(extend, Int2::getType()); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4524 | // |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4525 | // Constant *shuffle[2]; |
| 4526 | // shuffle[0] = Nucleus::createConstantInt(0); |
| 4527 | // shuffle[1] = Nucleus::createConstantInt(0); |
| 4528 | // |
| 4529 | // Value *replicate = Nucleus::createShuffleVector(vector, UndefValue::get(Int2::getType()), Nucleus::createConstantVector(shuffle, 2)); |
| 4530 | // |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4531 | // storeValue(replicate); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4532 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4533 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4534 | Int2::Int2(RValue<Int4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4535 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4536 | Value *long2 = Nucleus::createBitCast(cast.value, Long2::getType()); |
| 4537 | Value *element = Nucleus::createExtractElement(long2, 0); |
| 4538 | Value *int2 = Nucleus::createBitCast(element, Int2::getType()); |
| 4539 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4540 | storeValue(int2); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4541 | } |
| 4542 | |
| 4543 | Int2::Int2() |
| 4544 | { |
| 4545 | // xy.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4546 | } |
| 4547 | |
| 4548 | Int2::Int2(int x, int y) |
| 4549 | { |
| 4550 | // xy.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4551 | |
| 4552 | Constant *constantVector[2]; |
| 4553 | constantVector[0] = Nucleus::createConstantInt(x); |
| 4554 | constantVector[1] = Nucleus::createConstantInt(y); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4555 | Value *vector = Nucleus::createConstantVector(constantVector, 2); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4556 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4557 | storeValue(Nucleus::createBitCast(vector, getType())); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4558 | } |
| 4559 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4560 | Int2::Int2(RValue<Int2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4561 | { |
| 4562 | // xy.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4563 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4564 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4565 | } |
| 4566 | |
| 4567 | Int2::Int2(const Int2 &rhs) |
| 4568 | { |
| 4569 | // xy.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4570 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4571 | Value *value = rhs.loadValue(); |
| 4572 | storeValue(value); |
| 4573 | } |
| 4574 | |
| 4575 | Int2::Int2(const Reference<Int2> &rhs) |
| 4576 | { |
| 4577 | // xy.parent = this; |
| 4578 | |
| 4579 | Value *value = rhs.loadValue(); |
| 4580 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4581 | } |
| 4582 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4583 | RValue<Int2> Int2::operator=(RValue<Int2> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4584 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4585 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4586 | |
| 4587 | return rhs; |
| 4588 | } |
| 4589 | |
| 4590 | RValue<Int2> Int2::operator=(const Int2 &rhs) const |
| 4591 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4592 | Value *value = rhs.loadValue(); |
| 4593 | storeValue(value); |
| 4594 | |
| 4595 | return RValue<Int2>(value); |
| 4596 | } |
| 4597 | |
| 4598 | RValue<Int2> Int2::operator=(const Reference<Int2> &rhs) const |
| 4599 | { |
| 4600 | Value *value = rhs.loadValue(); |
| 4601 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4602 | |
| 4603 | return RValue<Int2>(value); |
| 4604 | } |
| 4605 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4606 | RValue<Int2> operator+(RValue<Int2> lhs, RValue<Int2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4607 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4608 | if(CPUID::supportsMMX2()) |
| 4609 | { |
| 4610 | return x86::paddd(lhs, rhs); |
| 4611 | } |
| 4612 | else |
| 4613 | { |
| 4614 | return RValue<Int2>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 4615 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4616 | } |
| 4617 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4618 | RValue<Int2> operator-(RValue<Int2> lhs, RValue<Int2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4619 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4620 | if(CPUID::supportsMMX2()) |
| 4621 | { |
| 4622 | return x86::psubd(lhs, rhs); |
| 4623 | } |
| 4624 | else |
| 4625 | { |
| 4626 | return RValue<Int2>(Nucleus::createSub(lhs.value, rhs.value)); |
| 4627 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4628 | } |
| 4629 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4630 | // RValue<Int2> operator*(RValue<Int2> lhs, RValue<Int2> rhs) |
| 4631 | // { |
| 4632 | // return RValue<Int2>(Nucleus::createMul(lhs.value, rhs.value)); |
| 4633 | // } |
| 4634 | |
| 4635 | // RValue<Int2> operator/(RValue<Int2> lhs, RValue<Int2> rhs) |
| 4636 | // { |
| 4637 | // return RValue<Int2>(Nucleus::createSDiv(lhs.value, rhs.value)); |
| 4638 | // } |
| 4639 | |
| 4640 | // RValue<Int2> operator%(RValue<Int2> lhs, RValue<Int2> rhs) |
| 4641 | // { |
| 4642 | // return RValue<Int2>(Nucleus::createSRem(lhs.value, rhs.value)); |
| 4643 | // } |
| 4644 | |
| 4645 | RValue<Int2> operator&(RValue<Int2> lhs, RValue<Int2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4646 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4647 | if(CPUID::supportsMMX2()) |
| 4648 | { |
| 4649 | return As<Int2>(x86::pand(As<Short4>(lhs), As<Short4>(rhs))); |
| 4650 | } |
| 4651 | else |
| 4652 | { |
| 4653 | return RValue<Int2>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 4654 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4655 | } |
| 4656 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4657 | RValue<Int2> operator|(RValue<Int2> lhs, RValue<Int2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4658 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4659 | if(CPUID::supportsMMX2()) |
| 4660 | { |
| 4661 | return As<Int2>(x86::por(As<Short4>(lhs), As<Short4>(rhs))); |
| 4662 | } |
| 4663 | else |
| 4664 | { |
| 4665 | return RValue<Int2>(Nucleus::createOr(lhs.value, rhs.value)); |
| 4666 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4667 | } |
| 4668 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4669 | RValue<Int2> operator^(RValue<Int2> lhs, RValue<Int2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4670 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4671 | if(CPUID::supportsMMX2()) |
| 4672 | { |
| 4673 | return As<Int2>(x86::pxor(As<Short4>(lhs), As<Short4>(rhs))); |
| 4674 | } |
| 4675 | else |
| 4676 | { |
| 4677 | return RValue<Int2>(Nucleus::createXor(lhs.value, rhs.value)); |
| 4678 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4679 | } |
| 4680 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4681 | RValue<Int2> operator<<(RValue<Int2> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4682 | { |
| 4683 | // return RValue<Int2>(Nucleus::createShl(lhs.value, rhs.value)); |
| 4684 | |
| 4685 | return x86::pslld(lhs, rhs); |
| 4686 | } |
| 4687 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4688 | RValue<Int2> operator>>(RValue<Int2> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4689 | { |
| 4690 | // return RValue<Int2>(Nucleus::createAShr(lhs.value, rhs.value)); |
| 4691 | |
| 4692 | return x86::psrad(lhs, rhs); |
| 4693 | } |
| 4694 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4695 | RValue<Int2> operator<<(RValue<Int2> lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4696 | { |
| 4697 | // return RValue<Int2>(Nucleus::createShl(lhs.value, rhs.value)); |
| 4698 | |
| 4699 | return x86::pslld(lhs, rhs); |
| 4700 | } |
| 4701 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4702 | RValue<Int2> operator>>(RValue<Int2> lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4703 | { |
| 4704 | // return RValue<Int2>(Nucleus::createAShr(lhs.value, rhs.value)); |
| 4705 | |
| 4706 | return x86::psrad(lhs, rhs); |
| 4707 | } |
| 4708 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4709 | RValue<Int2> operator+=(const Int2 &lhs, RValue<Int2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4710 | { |
| 4711 | return lhs = lhs + rhs; |
| 4712 | } |
| 4713 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4714 | RValue<Int2> operator-=(const Int2 &lhs, RValue<Int2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4715 | { |
| 4716 | return lhs = lhs - rhs; |
| 4717 | } |
| 4718 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4719 | // RValue<Int2> operator*=(const Int2 &lhs, RValue<Int2> rhs) |
| 4720 | // { |
| 4721 | // return lhs = lhs * rhs; |
| 4722 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4723 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4724 | // RValue<Int2> operator/=(const Int2 &lhs, RValue<Int2> rhs) |
| 4725 | // { |
| 4726 | // return lhs = lhs / rhs; |
| 4727 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4728 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4729 | // RValue<Int2> operator%=(const Int2 &lhs, RValue<Int2> rhs) |
| 4730 | // { |
| 4731 | // return lhs = lhs % rhs; |
| 4732 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4733 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4734 | RValue<Int2> operator&=(const Int2 &lhs, RValue<Int2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4735 | { |
| 4736 | return lhs = lhs & rhs; |
| 4737 | } |
| 4738 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4739 | RValue<Int2> operator|=(const Int2 &lhs, RValue<Int2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4740 | { |
| 4741 | return lhs = lhs | rhs; |
| 4742 | } |
| 4743 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4744 | RValue<Int2> operator^=(const Int2 &lhs, RValue<Int2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4745 | { |
| 4746 | return lhs = lhs ^ rhs; |
| 4747 | } |
| 4748 | |
| 4749 | RValue<Int2> operator<<=(const Int2 &lhs, unsigned char rhs) |
| 4750 | { |
| 4751 | return lhs = lhs << rhs; |
| 4752 | } |
| 4753 | |
| 4754 | RValue<Int2> operator>>=(const Int2 &lhs, unsigned char rhs) |
| 4755 | { |
| 4756 | return lhs = lhs >> rhs; |
| 4757 | } |
| 4758 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4759 | RValue<Int2> operator<<=(const Int2 &lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4760 | { |
| 4761 | return lhs = lhs << rhs; |
| 4762 | } |
| 4763 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4764 | RValue<Int2> operator>>=(const Int2 &lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4765 | { |
| 4766 | return lhs = lhs >> rhs; |
| 4767 | } |
| 4768 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4769 | // RValue<Int2> operator+(RValue<Int2> val) |
| 4770 | // { |
| 4771 | // return val; |
| 4772 | // } |
| 4773 | |
| 4774 | // RValue<Int2> operator-(RValue<Int2> val) |
| 4775 | // { |
| 4776 | // return RValue<Int2>(Nucleus::createNeg(val.value)); |
| 4777 | // } |
| 4778 | |
| 4779 | RValue<Int2> operator~(RValue<Int2> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4780 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4781 | if(CPUID::supportsMMX2()) |
| 4782 | { |
| 4783 | return val ^ Int2(0xFFFFFFFF, 0xFFFFFFFF); |
| 4784 | } |
| 4785 | else |
| 4786 | { |
| 4787 | return RValue<Int2>(Nucleus::createNot(val.value)); |
| 4788 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4789 | } |
| 4790 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4791 | RValue<Long1> UnpackLow(RValue<Int2> x, RValue<Int2> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4792 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4793 | if(CPUID::supportsMMX2()) |
| 4794 | { |
| 4795 | return x86::punpckldq(x, y); |
| 4796 | } |
| 4797 | else |
| 4798 | { |
| 4799 | Constant *shuffle[2]; |
| 4800 | shuffle[0] = Nucleus::createConstantInt(0); |
| 4801 | shuffle[1] = Nucleus::createConstantInt(2); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4802 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4803 | Value *packed = Nucleus::createShuffleVector(x.value, y.value, Nucleus::createConstantVector(shuffle, 2)); |
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 | return RValue<Long1>(Nucleus::createBitCast(packed, Long1::getType())); |
| 4806 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4807 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4808 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4809 | RValue<Long1> UnpackHigh(RValue<Int2> x, RValue<Int2> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4810 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4811 | if(CPUID::supportsMMX2()) |
| 4812 | { |
| 4813 | return x86::punpckhdq(x, y); |
| 4814 | } |
| 4815 | else |
| 4816 | { |
| 4817 | Constant *shuffle[2]; |
| 4818 | shuffle[0] = Nucleus::createConstantInt(1); |
| 4819 | shuffle[1] = Nucleus::createConstantInt(3); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4820 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4821 | Value *packed = Nucleus::createShuffleVector(x.value, y.value, Nucleus::createConstantVector(shuffle, 2)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4822 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4823 | return RValue<Long1>(Nucleus::createBitCast(packed, Long1::getType())); |
| 4824 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4825 | } |
| 4826 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4827 | RValue<Int> Extract(RValue<Int2> val, int i) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4828 | { |
| 4829 | if(false) // FIXME: LLVM does not generate optimal code |
| 4830 | { |
| 4831 | return RValue<Int>(Nucleus::createExtractElement(val.value, i)); |
| 4832 | } |
| 4833 | else |
| 4834 | { |
| 4835 | if(i == 0) |
| 4836 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4837 | return RValue<Int>(Nucleus::createExtractElement(Nucleus::createBitCast(val.value, VectorType::get(Int::getType(), 2)), 0)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4838 | } |
| 4839 | else |
| 4840 | { |
| 4841 | Int2 val2 = As<Int2>(UnpackHigh(val, val)); |
| 4842 | |
| 4843 | return Extract(val2, 0); |
| 4844 | } |
| 4845 | } |
| 4846 | } |
| 4847 | |
| 4848 | // FIXME: Crashes LLVM |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4849 | // RValue<Int2> Insert(RValue<Int2> val, RValue<Int> element, int i) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4850 | // { |
| 4851 | // return RValue<Int2>(Nucleus::createInsertElement(val.value, element.value, Nucleus::createConstantInt(i))); |
| 4852 | // } |
| 4853 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4854 | Type *Int2::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4855 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4856 | if(CPUID::supportsMMX2()) |
| 4857 | { |
| 4858 | return MMX::getType(); |
| 4859 | } |
| 4860 | else |
| 4861 | { |
| 4862 | return VectorType::get(Int::getType(), 2); |
| 4863 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4864 | } |
| 4865 | |
| 4866 | UInt2::UInt2() |
| 4867 | { |
| 4868 | // xy.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4869 | } |
| 4870 | |
| 4871 | UInt2::UInt2(unsigned int x, unsigned int y) |
| 4872 | { |
| 4873 | // xy.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4874 | |
| 4875 | Constant *constantVector[2]; |
| 4876 | constantVector[0] = Nucleus::createConstantInt(x); |
| 4877 | constantVector[1] = Nucleus::createConstantInt(y); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4878 | Value *vector = Nucleus::createConstantVector(constantVector, 2); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4879 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4880 | storeValue(Nucleus::createBitCast(vector, getType())); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4881 | } |
| 4882 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4883 | UInt2::UInt2(RValue<UInt2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4884 | { |
| 4885 | // xy.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4886 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4887 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4888 | } |
| 4889 | |
| 4890 | UInt2::UInt2(const UInt2 &rhs) |
| 4891 | { |
| 4892 | // xy.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4893 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4894 | Value *value = rhs.loadValue(); |
| 4895 | storeValue(value); |
| 4896 | } |
| 4897 | |
| 4898 | UInt2::UInt2(const Reference<UInt2> &rhs) |
| 4899 | { |
| 4900 | // xy.parent = this; |
| 4901 | |
| 4902 | Value *value = rhs.loadValue(); |
| 4903 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4904 | } |
| 4905 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4906 | RValue<UInt2> UInt2::operator=(RValue<UInt2> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4907 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4908 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4909 | |
| 4910 | return rhs; |
| 4911 | } |
| 4912 | |
| 4913 | RValue<UInt2> UInt2::operator=(const UInt2 &rhs) const |
| 4914 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4915 | Value *value = rhs.loadValue(); |
| 4916 | storeValue(value); |
| 4917 | |
| 4918 | return RValue<UInt2>(value); |
| 4919 | } |
| 4920 | |
| 4921 | RValue<UInt2> UInt2::operator=(const Reference<UInt2> &rhs) const |
| 4922 | { |
| 4923 | Value *value = rhs.loadValue(); |
| 4924 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4925 | |
| 4926 | return RValue<UInt2>(value); |
| 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::paddd(As<Int2>(lhs), As<Int2>(rhs))); |
| 4934 | } |
| 4935 | else |
| 4936 | { |
| 4937 | return RValue<UInt2>(Nucleus::createAdd(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::psubd(As<Int2>(lhs), As<Int2>(rhs))); |
| 4946 | } |
| 4947 | else |
| 4948 | { |
| 4949 | return RValue<UInt2>(Nucleus::createSub(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, RValue<UInt2> rhs) |
| 4954 | // { |
| 4955 | // return RValue<UInt2>(Nucleus::createMul(lhs.value, rhs.value)); |
| 4956 | // } |
| 4957 | |
| 4958 | // RValue<UInt2> operator/(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 4959 | // { |
| 4960 | // return RValue<UInt2>(Nucleus::createUDiv(lhs.value, rhs.value)); |
| 4961 | // } |
| 4962 | |
| 4963 | // RValue<UInt2> operator%(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 4964 | // { |
| 4965 | // return RValue<UInt2>(Nucleus::createURem(lhs.value, rhs.value)); |
| 4966 | // } |
| 4967 | |
| 4968 | RValue<UInt2> operator&(RValue<UInt2> lhs, RValue<UInt2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4969 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4970 | if(CPUID::supportsMMX2()) |
| 4971 | { |
| 4972 | return As<UInt2>(x86::pand(As<Short4>(lhs), As<Short4>(rhs))); |
| 4973 | } |
| 4974 | else |
| 4975 | { |
| 4976 | return RValue<UInt2>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 4977 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4978 | } |
| 4979 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4980 | RValue<UInt2> operator|(RValue<UInt2> lhs, RValue<UInt2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4981 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4982 | if(CPUID::supportsMMX2()) |
| 4983 | { |
| 4984 | return As<UInt2>(x86::por(As<Short4>(lhs), As<Short4>(rhs))); |
| 4985 | } |
| 4986 | else |
| 4987 | { |
| 4988 | return RValue<UInt2>(Nucleus::createOr(lhs.value, rhs.value)); |
| 4989 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4990 | } |
| 4991 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4992 | RValue<UInt2> operator^(RValue<UInt2> lhs, RValue<UInt2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4993 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4994 | if(CPUID::supportsMMX2()) |
| 4995 | { |
| 4996 | return As<UInt2>(x86::pxor(As<Short4>(lhs), As<Short4>(rhs))); |
| 4997 | } |
| 4998 | else |
| 4999 | { |
| 5000 | return RValue<UInt2>(Nucleus::createXor(lhs.value, rhs.value)); |
| 5001 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5002 | } |
| 5003 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5004 | RValue<UInt2> operator<<(RValue<UInt2> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5005 | { |
| 5006 | // return RValue<UInt2>(Nucleus::createShl(lhs.value, rhs.value)); |
| 5007 | |
| 5008 | return As<UInt2>(x86::pslld(As<Int2>(lhs), rhs)); |
| 5009 | } |
| 5010 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5011 | RValue<UInt2> operator>>(RValue<UInt2> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5012 | { |
| 5013 | // return RValue<UInt2>(Nucleus::createLShr(lhs.value, rhs.value)); |
| 5014 | |
| 5015 | return x86::psrld(lhs, rhs); |
| 5016 | } |
| 5017 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5018 | RValue<UInt2> operator<<(RValue<UInt2> lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5019 | { |
| 5020 | // return RValue<UInt2>(Nucleus::createShl(lhs.value, rhs.value)); |
| 5021 | |
| 5022 | return As<UInt2>(x86::pslld(As<Int2>(lhs), rhs)); |
| 5023 | } |
| 5024 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5025 | RValue<UInt2> operator>>(RValue<UInt2> lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5026 | { |
| 5027 | // return RValue<UInt2>(Nucleus::createLShr(lhs.value, rhs.value)); |
| 5028 | |
| 5029 | return x86::psrld(lhs, rhs); |
| 5030 | } |
| 5031 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5032 | RValue<UInt2> operator+=(const UInt2 &lhs, RValue<UInt2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5033 | { |
| 5034 | return lhs = lhs + rhs; |
| 5035 | } |
| 5036 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5037 | RValue<UInt2> operator-=(const UInt2 &lhs, RValue<UInt2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5038 | { |
| 5039 | return lhs = lhs - rhs; |
| 5040 | } |
| 5041 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5042 | // RValue<UInt2> operator*=(const UInt2 &lhs, RValue<UInt2> rhs) |
| 5043 | // { |
| 5044 | // return lhs = lhs * rhs; |
| 5045 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5046 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5047 | // RValue<UInt2> operator/=(const UInt2 &lhs, RValue<UInt2> rhs) |
| 5048 | // { |
| 5049 | // return lhs = lhs / rhs; |
| 5050 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5051 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5052 | // RValue<UInt2> operator%=(const UInt2 &lhs, RValue<UInt2> rhs) |
| 5053 | // { |
| 5054 | // return lhs = lhs % rhs; |
| 5055 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5056 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5057 | RValue<UInt2> operator&=(const UInt2 &lhs, RValue<UInt2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5058 | { |
| 5059 | return lhs = lhs & rhs; |
| 5060 | } |
| 5061 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5062 | RValue<UInt2> operator|=(const UInt2 &lhs, RValue<UInt2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5063 | { |
| 5064 | return lhs = lhs | rhs; |
| 5065 | } |
| 5066 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5067 | RValue<UInt2> operator^=(const UInt2 &lhs, RValue<UInt2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5068 | { |
| 5069 | return lhs = lhs ^ rhs; |
| 5070 | } |
| 5071 | |
| 5072 | RValue<UInt2> operator<<=(const UInt2 &lhs, unsigned char rhs) |
| 5073 | { |
| 5074 | return lhs = lhs << rhs; |
| 5075 | } |
| 5076 | |
| 5077 | RValue<UInt2> operator>>=(const UInt2 &lhs, unsigned char rhs) |
| 5078 | { |
| 5079 | return lhs = lhs >> rhs; |
| 5080 | } |
| 5081 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5082 | RValue<UInt2> operator<<=(const UInt2 &lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5083 | { |
| 5084 | return lhs = lhs << rhs; |
| 5085 | } |
| 5086 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5087 | RValue<UInt2> operator>>=(const UInt2 &lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5088 | { |
| 5089 | return lhs = lhs >> rhs; |
| 5090 | } |
| 5091 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5092 | // RValue<UInt2> operator+(RValue<UInt2> val) |
| 5093 | // { |
| 5094 | // return val; |
| 5095 | // } |
| 5096 | |
| 5097 | // RValue<UInt2> operator-(RValue<UInt2> val) |
| 5098 | // { |
| 5099 | // return RValue<UInt2>(Nucleus::createNeg(val.value)); |
| 5100 | // } |
| 5101 | |
| 5102 | RValue<UInt2> operator~(RValue<UInt2> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5103 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5104 | if(CPUID::supportsMMX2()) |
| 5105 | { |
| 5106 | return val ^ UInt2(0xFFFFFFFF, 0xFFFFFFFF); |
| 5107 | } |
| 5108 | else |
| 5109 | { |
| 5110 | return RValue<UInt2>(Nucleus::createNot(val.value)); |
| 5111 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5112 | } |
| 5113 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5114 | Type *UInt2::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5115 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5116 | if(CPUID::supportsMMX2()) |
| 5117 | { |
| 5118 | return MMX::getType(); |
| 5119 | } |
| 5120 | else |
| 5121 | { |
| 5122 | return VectorType::get(UInt::getType(), 2); |
| 5123 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5124 | } |
| 5125 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5126 | Int4::Int4(RValue<Float4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5127 | { |
| 5128 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5129 | |
| 5130 | Value *xyzw = Nucleus::createFPToSI(cast.value, Int4::getType()); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5131 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5132 | storeValue(xyzw); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5133 | } |
| 5134 | |
| 5135 | Int4::Int4() |
| 5136 | { |
| 5137 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5138 | } |
| 5139 | |
| 5140 | Int4::Int4(int xyzw) |
| 5141 | { |
| 5142 | constant(xyzw, xyzw, xyzw, xyzw); |
| 5143 | } |
| 5144 | |
| 5145 | Int4::Int4(int x, int yzw) |
| 5146 | { |
| 5147 | constant(x, yzw, yzw, yzw); |
| 5148 | } |
| 5149 | |
| 5150 | Int4::Int4(int x, int y, int zw) |
| 5151 | { |
| 5152 | constant(x, y, zw, zw); |
| 5153 | } |
| 5154 | |
| 5155 | Int4::Int4(int x, int y, int z, int w) |
| 5156 | { |
| 5157 | constant(x, y, z, w); |
| 5158 | } |
| 5159 | |
| 5160 | void Int4::constant(int x, int y, int z, int w) |
| 5161 | { |
| 5162 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5163 | |
| 5164 | Constant *constantVector[4]; |
| 5165 | constantVector[0] = Nucleus::createConstantInt(x); |
| 5166 | constantVector[1] = Nucleus::createConstantInt(y); |
| 5167 | constantVector[2] = Nucleus::createConstantInt(z); |
| 5168 | constantVector[3] = Nucleus::createConstantInt(w); |
| 5169 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5170 | storeValue(Nucleus::createConstantVector(constantVector, 4)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5171 | } |
| 5172 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5173 | Int4::Int4(RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5174 | { |
| 5175 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5176 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5177 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5178 | } |
| 5179 | |
| 5180 | Int4::Int4(const Int4 &rhs) |
| 5181 | { |
| 5182 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5183 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5184 | Value *value = rhs.loadValue(); |
| 5185 | storeValue(value); |
| 5186 | } |
| 5187 | |
| 5188 | Int4::Int4(const Reference<Int4> &rhs) |
| 5189 | { |
| 5190 | // xyzw.parent = this; |
| 5191 | |
| 5192 | Value *value = rhs.loadValue(); |
| 5193 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5194 | } |
| 5195 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5196 | Int4::Int4(RValue<UInt4> rhs) |
| 5197 | { |
| 5198 | // xyzw.parent = this; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5199 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5200 | storeValue(rhs.value); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5201 | } |
| 5202 | |
| 5203 | Int4::Int4(const UInt4 &rhs) |
| 5204 | { |
| 5205 | // xyzw.parent = this; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5206 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5207 | Value *value = rhs.loadValue(); |
| 5208 | storeValue(value); |
| 5209 | } |
| 5210 | |
| 5211 | Int4::Int4(const Reference<UInt4> &rhs) |
| 5212 | { |
| 5213 | // xyzw.parent = this; |
| 5214 | |
| 5215 | Value *value = rhs.loadValue(); |
| 5216 | storeValue(value); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5217 | } |
| 5218 | |
| 5219 | RValue<Int4> Int4::operator=(RValue<Int4> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5220 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5221 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5222 | |
| 5223 | return rhs; |
| 5224 | } |
| 5225 | |
| 5226 | RValue<Int4> Int4::operator=(const Int4 &rhs) const |
| 5227 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5228 | Value *value = rhs.loadValue(); |
| 5229 | storeValue(value); |
| 5230 | |
| 5231 | return RValue<Int4>(value); |
| 5232 | } |
| 5233 | |
| 5234 | RValue<Int4> Int4::operator=(const Reference<Int4> &rhs) const |
| 5235 | { |
| 5236 | Value *value = rhs.loadValue(); |
| 5237 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5238 | |
| 5239 | return RValue<Int4>(value); |
| 5240 | } |
| 5241 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5242 | RValue<Int4> operator+(RValue<Int4> lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5243 | { |
| 5244 | return RValue<Int4>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 5245 | } |
| 5246 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5247 | RValue<Int4> operator-(RValue<Int4> lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5248 | { |
| 5249 | return RValue<Int4>(Nucleus::createSub(lhs.value, rhs.value)); |
| 5250 | } |
| 5251 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5252 | RValue<Int4> operator*(RValue<Int4> lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5253 | { |
| 5254 | return RValue<Int4>(Nucleus::createMul(lhs.value, rhs.value)); |
| 5255 | } |
| 5256 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5257 | // RValue<Int4> operator/(RValue<Int4> lhs, RValue<Int4> rhs) |
| 5258 | // { |
| 5259 | // return RValue<Int4>(Nucleus::createSDiv(lhs.value, rhs.value)); |
| 5260 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5261 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5262 | // RValue<Int4> operator%(RValue<Int4> lhs, RValue<Int4> rhs) |
| 5263 | // { |
| 5264 | // return RValue<Int4>(Nucleus::createSRem(lhs.value, rhs.value)); |
| 5265 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5266 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5267 | RValue<Int4> operator&(RValue<Int4> lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5268 | { |
| 5269 | return RValue<Int4>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 5270 | } |
| 5271 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5272 | RValue<Int4> operator|(RValue<Int4> lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5273 | { |
| 5274 | return RValue<Int4>(Nucleus::createOr(lhs.value, rhs.value)); |
| 5275 | } |
| 5276 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5277 | RValue<Int4> operator^(RValue<Int4> lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5278 | { |
| 5279 | return RValue<Int4>(Nucleus::createXor(lhs.value, rhs.value)); |
| 5280 | } |
| 5281 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5282 | RValue<Int4> operator<<(RValue<Int4> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5283 | { |
| 5284 | // return RValue<Int4>(Nucleus::createShl(lhs.value, rhs.value)); |
| 5285 | |
| 5286 | return x86::pslld(lhs, rhs); |
| 5287 | } |
| 5288 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5289 | RValue<Int4> operator>>(RValue<Int4> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5290 | { |
| 5291 | // return RValue<Int4>(Nucleus::createAShr(lhs.value, rhs.value)); |
| 5292 | |
| 5293 | return x86::psrad(lhs, rhs); |
| 5294 | } |
| 5295 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5296 | RValue<Int4> operator+=(const Int4 &lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5297 | { |
| 5298 | return lhs = lhs + rhs; |
| 5299 | } |
| 5300 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5301 | RValue<Int4> operator-=(const Int4 &lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5302 | { |
| 5303 | return lhs = lhs - rhs; |
| 5304 | } |
| 5305 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5306 | RValue<Int4> operator*=(const Int4 &lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5307 | { |
| 5308 | return lhs = lhs * rhs; |
| 5309 | } |
| 5310 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5311 | // RValue<Int4> operator/=(const Int4 &lhs, RValue<Int4> rhs) |
| 5312 | // { |
| 5313 | // return lhs = lhs / rhs; |
| 5314 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5315 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5316 | // RValue<Int4> operator%=(const Int4 &lhs, RValue<Int4> rhs) |
| 5317 | // { |
| 5318 | // return lhs = lhs % rhs; |
| 5319 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5320 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5321 | RValue<Int4> operator&=(const Int4 &lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5322 | { |
| 5323 | return lhs = lhs & rhs; |
| 5324 | } |
| 5325 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5326 | RValue<Int4> operator|=(const Int4 &lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5327 | { |
| 5328 | return lhs = lhs | rhs; |
| 5329 | } |
| 5330 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5331 | RValue<Int4> operator^=(const Int4 &lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5332 | { |
| 5333 | return lhs = lhs ^ rhs; |
| 5334 | } |
| 5335 | |
| 5336 | RValue<Int4> operator<<=(const Int4 &lhs, unsigned char rhs) |
| 5337 | { |
| 5338 | return lhs = lhs << rhs; |
| 5339 | } |
| 5340 | |
| 5341 | RValue<Int4> operator>>=(const Int4 &lhs, unsigned char rhs) |
| 5342 | { |
| 5343 | return lhs = lhs >> rhs; |
| 5344 | } |
| 5345 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5346 | RValue<Int4> operator+(RValue<Int4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5347 | { |
| 5348 | return val; |
| 5349 | } |
| 5350 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5351 | RValue<Int4> operator-(RValue<Int4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5352 | { |
| 5353 | return RValue<Int4>(Nucleus::createNeg(val.value)); |
| 5354 | } |
| 5355 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5356 | RValue<Int4> operator~(RValue<Int4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5357 | { |
| 5358 | return RValue<Int4>(Nucleus::createNot(val.value)); |
| 5359 | } |
| 5360 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5361 | RValue<Int4> CmpEQ(RValue<Int4> x, RValue<Int4> y) |
| 5362 | { |
| 5363 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpEQ(x.value, y.value), Int4::getType())); |
| 5364 | } |
| 5365 | |
| 5366 | RValue<Int4> CmpLT(RValue<Int4> x, RValue<Int4> y) |
| 5367 | { |
| 5368 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSLT(x.value, y.value), Int4::getType())); |
| 5369 | } |
| 5370 | |
| 5371 | RValue<Int4> CmpLE(RValue<Int4> x, RValue<Int4> y) |
| 5372 | { |
| 5373 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSLE(x.value, y.value), Int4::getType())); |
| 5374 | } |
| 5375 | |
| 5376 | RValue<Int4> CmpNEQ(RValue<Int4> x, RValue<Int4> y) |
| 5377 | { |
| 5378 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpNE(x.value, y.value), Int4::getType())); |
| 5379 | } |
| 5380 | |
| 5381 | RValue<Int4> CmpNLT(RValue<Int4> x, RValue<Int4> y) |
| 5382 | { |
| 5383 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSGE(x.value, y.value), Int4::getType())); |
| 5384 | } |
| 5385 | |
| 5386 | RValue<Int4> CmpNLE(RValue<Int4> x, RValue<Int4> y) |
| 5387 | { |
| 5388 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSGT(x.value, y.value), Int4::getType())); |
| 5389 | } |
| 5390 | |
| 5391 | RValue<Int4> Max(RValue<Int4> x, RValue<Int4> y) |
| 5392 | { |
| 5393 | if(CPUID::supportsSSE4_1()) |
| 5394 | { |
| 5395 | return x86::pmaxsd(x, y); |
| 5396 | } |
| 5397 | else |
| 5398 | { |
| 5399 | RValue<Int4> greater = CmpNLE(x, y); |
| 5400 | return x & greater | y & ~greater; |
| 5401 | } |
| 5402 | } |
| 5403 | |
| 5404 | RValue<Int4> Min(RValue<Int4> x, RValue<Int4> y) |
| 5405 | { |
| 5406 | if(CPUID::supportsSSE4_1()) |
| 5407 | { |
| 5408 | return x86::pminsd(x, y); |
| 5409 | } |
| 5410 | else |
| 5411 | { |
| 5412 | RValue<Int4> less = CmpLT(x, y); |
| 5413 | return x & less | y & ~less; |
| 5414 | } |
| 5415 | } |
| 5416 | |
| 5417 | RValue<Int4> RoundInt(RValue<Float4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5418 | { |
| 5419 | return x86::cvtps2dq(cast); |
| 5420 | } |
| 5421 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5422 | RValue<Short8> Pack(RValue<Int4> x, RValue<Int4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5423 | { |
| 5424 | return x86::packssdw(x, y); |
| 5425 | } |
| 5426 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5427 | RValue<Int4> Concatenate(RValue<Int2> lo, RValue<Int2> hi) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5428 | { |
| 5429 | Value *loLong = Nucleus::createBitCast(lo.value, Long::getType()); |
| 5430 | Value *hiLong = Nucleus::createBitCast(hi.value, Long::getType()); |
| 5431 | |
| 5432 | Value *long2 = UndefValue::get(Long2::getType()); |
| 5433 | long2 = Nucleus::createInsertElement(long2, loLong, 0); |
| 5434 | long2 = Nucleus::createInsertElement(long2, hiLong, 1); |
| 5435 | Value *int4 = Nucleus::createBitCast(long2, Int4::getType()); |
| 5436 | |
| 5437 | return RValue<Int4>(int4); |
| 5438 | } |
| 5439 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5440 | RValue<Int> Extract(RValue<Int4> x, int i) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5441 | { |
| 5442 | return RValue<Int>(Nucleus::createExtractElement(x.value, i)); |
| 5443 | } |
| 5444 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5445 | RValue<Int4> Insert(RValue<Int4> x, RValue<Int> element, int i) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5446 | { |
| 5447 | return RValue<Int4>(Nucleus::createInsertElement(x.value, element.value, i)); |
| 5448 | } |
| 5449 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5450 | RValue<Int> SignMask(RValue<Int4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5451 | { |
| 5452 | return x86::movmskps(As<Float4>(x)); |
| 5453 | } |
| 5454 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5455 | RValue<Int4> Swizzle(RValue<Int4> x, unsigned char select) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5456 | { |
| 5457 | return RValue<Int4>(Nucleus::createSwizzle(x.value, select)); |
| 5458 | } |
| 5459 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5460 | Type *Int4::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5461 | { |
| 5462 | return VectorType::get(Int::getType(), 4); |
| 5463 | } |
| 5464 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5465 | UInt4::UInt4(RValue<Float4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5466 | { |
| 5467 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5468 | |
| 5469 | Value *xyzw = Nucleus::createFPToUI(cast.value, UInt4::getType()); |
| 5470 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5471 | storeValue(xyzw); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5472 | } |
| 5473 | |
| 5474 | UInt4::UInt4() |
| 5475 | { |
| 5476 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5477 | } |
| 5478 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5479 | UInt4::UInt4(int xyzw) |
| 5480 | { |
| 5481 | constant(xyzw, xyzw, xyzw, xyzw); |
| 5482 | } |
| 5483 | |
| 5484 | UInt4::UInt4(int x, int yzw) |
| 5485 | { |
| 5486 | constant(x, yzw, yzw, yzw); |
| 5487 | } |
| 5488 | |
| 5489 | UInt4::UInt4(int x, int y, int zw) |
| 5490 | { |
| 5491 | constant(x, y, zw, zw); |
| 5492 | } |
| 5493 | |
| 5494 | UInt4::UInt4(int x, int y, int z, int w) |
| 5495 | { |
| 5496 | constant(x, y, z, w); |
| 5497 | } |
| 5498 | |
| 5499 | void UInt4::constant(int x, int y, int z, int w) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5500 | { |
| 5501 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5502 | |
| 5503 | Constant *constantVector[4]; |
| 5504 | constantVector[0] = Nucleus::createConstantInt(x); |
| 5505 | constantVector[1] = Nucleus::createConstantInt(y); |
| 5506 | constantVector[2] = Nucleus::createConstantInt(z); |
| 5507 | constantVector[3] = Nucleus::createConstantInt(w); |
| 5508 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5509 | storeValue(Nucleus::createConstantVector(constantVector, 4)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5510 | } |
| 5511 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5512 | UInt4::UInt4(RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5513 | { |
| 5514 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5515 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5516 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5517 | } |
| 5518 | |
| 5519 | UInt4::UInt4(const UInt4 &rhs) |
| 5520 | { |
| 5521 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5522 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5523 | Value *value = rhs.loadValue(); |
| 5524 | storeValue(value); |
| 5525 | } |
| 5526 | |
| 5527 | UInt4::UInt4(const Reference<UInt4> &rhs) |
| 5528 | { |
| 5529 | // xyzw.parent = this; |
| 5530 | |
| 5531 | Value *value = rhs.loadValue(); |
| 5532 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5533 | } |
| 5534 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5535 | UInt4::UInt4(RValue<Int4> rhs) |
| 5536 | { |
| 5537 | // xyzw.parent = this; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5538 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5539 | storeValue(rhs.value); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5540 | } |
| 5541 | |
| 5542 | UInt4::UInt4(const Int4 &rhs) |
| 5543 | { |
| 5544 | // xyzw.parent = this; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5545 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5546 | Value *value = rhs.loadValue(); |
| 5547 | storeValue(value); |
| 5548 | } |
| 5549 | |
| 5550 | UInt4::UInt4(const Reference<Int4> &rhs) |
| 5551 | { |
| 5552 | // xyzw.parent = this; |
| 5553 | |
| 5554 | Value *value = rhs.loadValue(); |
| 5555 | storeValue(value); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5556 | } |
| 5557 | |
| 5558 | RValue<UInt4> UInt4::operator=(RValue<UInt4> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5559 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5560 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5561 | |
| 5562 | return rhs; |
| 5563 | } |
| 5564 | |
| 5565 | RValue<UInt4> UInt4::operator=(const UInt4 &rhs) const |
| 5566 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5567 | Value *value = rhs.loadValue(); |
| 5568 | storeValue(value); |
| 5569 | |
| 5570 | return RValue<UInt4>(value); |
| 5571 | } |
| 5572 | |
| 5573 | RValue<UInt4> UInt4::operator=(const Reference<UInt4> &rhs) const |
| 5574 | { |
| 5575 | Value *value = rhs.loadValue(); |
| 5576 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5577 | |
| 5578 | return RValue<UInt4>(value); |
| 5579 | } |
| 5580 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5581 | RValue<UInt4> operator+(RValue<UInt4> lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5582 | { |
| 5583 | return RValue<UInt4>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 5584 | } |
| 5585 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5586 | RValue<UInt4> operator-(RValue<UInt4> lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5587 | { |
| 5588 | return RValue<UInt4>(Nucleus::createSub(lhs.value, rhs.value)); |
| 5589 | } |
| 5590 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5591 | RValue<UInt4> operator*(RValue<UInt4> lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5592 | { |
| 5593 | return RValue<UInt4>(Nucleus::createMul(lhs.value, rhs.value)); |
| 5594 | } |
| 5595 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5596 | // RValue<UInt4> operator/(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 5597 | // { |
| 5598 | // return RValue<UInt4>(Nucleus::createUDiv(lhs.value, rhs.value)); |
| 5599 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5600 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5601 | // RValue<UInt4> operator%(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 5602 | // { |
| 5603 | // return RValue<UInt4>(Nucleus::createURem(lhs.value, rhs.value)); |
| 5604 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5605 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5606 | RValue<UInt4> operator&(RValue<UInt4> lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5607 | { |
| 5608 | return RValue<UInt4>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 5609 | } |
| 5610 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5611 | RValue<UInt4> operator|(RValue<UInt4> lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5612 | { |
| 5613 | return RValue<UInt4>(Nucleus::createOr(lhs.value, rhs.value)); |
| 5614 | } |
| 5615 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5616 | RValue<UInt4> operator^(RValue<UInt4> lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5617 | { |
| 5618 | return RValue<UInt4>(Nucleus::createXor(lhs.value, rhs.value)); |
| 5619 | } |
| 5620 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5621 | RValue<UInt4> operator<<(RValue<UInt4> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5622 | { |
| 5623 | // return RValue<UInt4>(Nucleus::createShl(lhs.value, rhs.value)); |
| 5624 | |
| 5625 | return As<UInt4>(x86::pslld(As<Int4>(lhs), rhs)); |
| 5626 | } |
| 5627 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5628 | RValue<UInt4> operator>>(RValue<UInt4> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5629 | { |
| 5630 | // return RValue<UInt4>(Nucleus::createLShr(lhs.value, rhs.value)); |
| 5631 | |
| 5632 | return x86::psrld(lhs, rhs); |
| 5633 | } |
| 5634 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5635 | RValue<UInt4> operator+=(const UInt4 &lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5636 | { |
| 5637 | return lhs = lhs + rhs; |
| 5638 | } |
| 5639 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5640 | RValue<UInt4> operator-=(const UInt4 &lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5641 | { |
| 5642 | return lhs = lhs - rhs; |
| 5643 | } |
| 5644 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5645 | RValue<UInt4> operator*=(const UInt4 &lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5646 | { |
| 5647 | return lhs = lhs * rhs; |
| 5648 | } |
| 5649 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5650 | // RValue<UInt4> operator/=(const UInt4 &lhs, RValue<UInt4> rhs) |
| 5651 | // { |
| 5652 | // return lhs = lhs / rhs; |
| 5653 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5654 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5655 | // RValue<UInt4> operator%=(const UInt4 &lhs, RValue<UInt4> rhs) |
| 5656 | // { |
| 5657 | // return lhs = lhs % rhs; |
| 5658 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5659 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5660 | RValue<UInt4> operator&=(const UInt4 &lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5661 | { |
| 5662 | return lhs = lhs & rhs; |
| 5663 | } |
| 5664 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5665 | RValue<UInt4> operator|=(const UInt4 &lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5666 | { |
| 5667 | return lhs = lhs | rhs; |
| 5668 | } |
| 5669 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5670 | RValue<UInt4> operator^=(const UInt4 &lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5671 | { |
| 5672 | return lhs = lhs ^ rhs; |
| 5673 | } |
| 5674 | |
| 5675 | RValue<UInt4> operator<<=(const UInt4 &lhs, unsigned char rhs) |
| 5676 | { |
| 5677 | return lhs = lhs << rhs; |
| 5678 | } |
| 5679 | |
| 5680 | RValue<UInt4> operator>>=(const UInt4 &lhs, unsigned char rhs) |
| 5681 | { |
| 5682 | return lhs = lhs >> rhs; |
| 5683 | } |
| 5684 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5685 | RValue<UInt4> operator+(RValue<UInt4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5686 | { |
| 5687 | return val; |
| 5688 | } |
| 5689 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5690 | RValue<UInt4> operator-(RValue<UInt4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5691 | { |
| 5692 | return RValue<UInt4>(Nucleus::createNeg(val.value)); |
| 5693 | } |
| 5694 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5695 | RValue<UInt4> operator~(RValue<UInt4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5696 | { |
| 5697 | return RValue<UInt4>(Nucleus::createNot(val.value)); |
| 5698 | } |
| 5699 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5700 | RValue<UInt4> CmpEQ(RValue<UInt4> x, RValue<UInt4> y) |
| 5701 | { |
| 5702 | return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpEQ(x.value, y.value), Int4::getType())); |
| 5703 | } |
| 5704 | |
| 5705 | RValue<UInt4> CmpLT(RValue<UInt4> x, RValue<UInt4> y) |
| 5706 | { |
| 5707 | return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpULT(x.value, y.value), Int4::getType())); |
| 5708 | } |
| 5709 | |
| 5710 | RValue<UInt4> CmpLE(RValue<UInt4> x, RValue<UInt4> y) |
| 5711 | { |
| 5712 | return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpULE(x.value, y.value), Int4::getType())); |
| 5713 | } |
| 5714 | |
| 5715 | RValue<UInt4> CmpNEQ(RValue<UInt4> x, RValue<UInt4> y) |
| 5716 | { |
| 5717 | return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpNE(x.value, y.value), Int4::getType())); |
| 5718 | } |
| 5719 | |
| 5720 | RValue<UInt4> CmpNLT(RValue<UInt4> x, RValue<UInt4> y) |
| 5721 | { |
| 5722 | return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpUGE(x.value, y.value), Int4::getType())); |
| 5723 | } |
| 5724 | |
| 5725 | RValue<UInt4> CmpNLE(RValue<UInt4> x, RValue<UInt4> y) |
| 5726 | { |
| 5727 | return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpUGT(x.value, y.value), Int4::getType())); |
| 5728 | } |
| 5729 | |
| 5730 | RValue<UInt4> Max(RValue<UInt4> x, RValue<UInt4> y) |
| 5731 | { |
| 5732 | if(CPUID::supportsSSE4_1()) |
| 5733 | { |
| 5734 | return x86::pmaxud(x, y); |
| 5735 | } |
| 5736 | else |
| 5737 | { |
| 5738 | RValue<UInt4> greater = CmpNLE(x, y); |
| 5739 | return x & greater | y & ~greater; |
| 5740 | } |
| 5741 | } |
| 5742 | |
| 5743 | RValue<UInt4> Min(RValue<UInt4> x, RValue<UInt4> y) |
| 5744 | { |
| 5745 | if(CPUID::supportsSSE4_1()) |
| 5746 | { |
| 5747 | return x86::pminud(x, y); |
| 5748 | } |
| 5749 | else |
| 5750 | { |
| 5751 | RValue<UInt4> less = CmpLT(x, y); |
| 5752 | return x & less | y & ~less; |
| 5753 | } |
| 5754 | } |
| 5755 | |
| 5756 | RValue<UShort8> Pack(RValue<UInt4> x, RValue<UInt4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5757 | { |
| 5758 | return x86::packusdw(x, y); // FIXME: Fallback required |
| 5759 | } |
| 5760 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5761 | RValue<UInt4> Concatenate(RValue<UInt2> lo, RValue<UInt2> hi) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5762 | { |
| 5763 | Value *loLong = Nucleus::createBitCast(lo.value, Long::getType()); |
| 5764 | Value *hiLong = Nucleus::createBitCast(hi.value, Long::getType()); |
| 5765 | |
| 5766 | Value *long2 = UndefValue::get(Long2::getType()); |
| 5767 | long2 = Nucleus::createInsertElement(long2, loLong, 0); |
| 5768 | long2 = Nucleus::createInsertElement(long2, hiLong, 1); |
| 5769 | Value *uint4 = Nucleus::createBitCast(long2, Int4::getType()); |
| 5770 | |
| 5771 | return RValue<UInt4>(uint4); |
| 5772 | } |
| 5773 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5774 | Type *UInt4::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5775 | { |
| 5776 | return VectorType::get(UInt::getType(), 4); |
| 5777 | } |
| 5778 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5779 | Float::Float(RValue<Int> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5780 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5781 | Value *integer = Nucleus::createSIToFP(cast.value, Float::getType()); |
| 5782 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5783 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5784 | } |
| 5785 | |
| 5786 | Float::Float() |
| 5787 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5788 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5789 | } |
| 5790 | |
| 5791 | Float::Float(float x) |
| 5792 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5793 | storeValue(Nucleus::createConstantFloat(x)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5794 | } |
| 5795 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5796 | Float::Float(RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5797 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5798 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5799 | } |
| 5800 | |
| 5801 | Float::Float(const Float &rhs) |
| 5802 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5803 | Value *value = rhs.loadValue(); |
| 5804 | storeValue(value); |
| 5805 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5806 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5807 | Float::Float(const Reference<Float> &rhs) |
| 5808 | { |
| 5809 | Value *value = rhs.loadValue(); |
| 5810 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5811 | } |
| 5812 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5813 | RValue<Float> Float::operator=(RValue<Float> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5814 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5815 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5816 | |
| 5817 | return rhs; |
| 5818 | } |
| 5819 | |
| 5820 | RValue<Float> Float::operator=(const Float &rhs) const |
| 5821 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5822 | Value *value = rhs.loadValue(); |
| 5823 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5824 | |
| 5825 | return RValue<Float>(value); |
| 5826 | } |
| 5827 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5828 | RValue<Float> Float::operator=(const Reference<Float> &rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5829 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5830 | Value *value = rhs.loadValue(); |
| 5831 | storeValue(value); |
| 5832 | |
| 5833 | return RValue<Float>(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5834 | } |
| 5835 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5836 | RValue<Float> operator+(RValue<Float> lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5837 | { |
| 5838 | return RValue<Float>(Nucleus::createFAdd(lhs.value, rhs.value)); |
| 5839 | } |
| 5840 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5841 | RValue<Float> operator-(RValue<Float> lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5842 | { |
| 5843 | return RValue<Float>(Nucleus::createFSub(lhs.value, rhs.value)); |
| 5844 | } |
| 5845 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5846 | RValue<Float> operator*(RValue<Float> lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5847 | { |
| 5848 | return RValue<Float>(Nucleus::createFMul(lhs.value, rhs.value)); |
| 5849 | } |
| 5850 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5851 | RValue<Float> operator/(RValue<Float> lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5852 | { |
| 5853 | return RValue<Float>(Nucleus::createFDiv(lhs.value, rhs.value)); |
| 5854 | } |
| 5855 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5856 | RValue<Float> operator+=(const Float &lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5857 | { |
| 5858 | return lhs = lhs + rhs; |
| 5859 | } |
| 5860 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5861 | RValue<Float> operator-=(const Float &lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5862 | { |
| 5863 | return lhs = lhs - rhs; |
| 5864 | } |
| 5865 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5866 | RValue<Float> operator*=(const Float &lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5867 | { |
| 5868 | return lhs = lhs * rhs; |
| 5869 | } |
| 5870 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5871 | RValue<Float> operator/=(const Float &lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5872 | { |
| 5873 | return lhs = lhs / rhs; |
| 5874 | } |
| 5875 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5876 | RValue<Float> operator+(RValue<Float> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5877 | { |
| 5878 | return val; |
| 5879 | } |
| 5880 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5881 | RValue<Float> operator-(RValue<Float> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5882 | { |
| 5883 | return RValue<Float>(Nucleus::createFNeg(val.value)); |
| 5884 | } |
| 5885 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5886 | RValue<Bool> operator<(RValue<Float> lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5887 | { |
| 5888 | return RValue<Bool>(Nucleus::createFCmpOLT(lhs.value, rhs.value)); |
| 5889 | } |
| 5890 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5891 | RValue<Bool> operator<=(RValue<Float> lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5892 | { |
| 5893 | return RValue<Bool>(Nucleus::createFCmpOLE(lhs.value, rhs.value)); |
| 5894 | } |
| 5895 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5896 | RValue<Bool> operator>(RValue<Float> lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5897 | { |
| 5898 | return RValue<Bool>(Nucleus::createFCmpOGT(lhs.value, rhs.value)); |
| 5899 | } |
| 5900 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5901 | RValue<Bool> operator>=(RValue<Float> lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5902 | { |
| 5903 | return RValue<Bool>(Nucleus::createFCmpOGE(lhs.value, rhs.value)); |
| 5904 | } |
| 5905 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5906 | RValue<Bool> operator!=(RValue<Float> lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5907 | { |
| 5908 | return RValue<Bool>(Nucleus::createFCmpONE(lhs.value, rhs.value)); |
| 5909 | } |
| 5910 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5911 | RValue<Bool> operator==(RValue<Float> lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5912 | { |
| 5913 | return RValue<Bool>(Nucleus::createFCmpOEQ(lhs.value, rhs.value)); |
| 5914 | } |
| 5915 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5916 | RValue<Float> Abs(RValue<Float> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5917 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5918 | return IfThenElse(x > 0.0f, x, -x); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5919 | } |
| 5920 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5921 | RValue<Float> Max(RValue<Float> x, RValue<Float> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5922 | { |
| 5923 | return IfThenElse(x > y, x, y); |
| 5924 | } |
| 5925 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5926 | RValue<Float> Min(RValue<Float> x, RValue<Float> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5927 | { |
| 5928 | return IfThenElse(x < y, x, y); |
| 5929 | } |
| 5930 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5931 | RValue<Float> Rcp_pp(RValue<Float> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5932 | { |
| 5933 | return x86::rcpss(x); |
| 5934 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5935 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5936 | RValue<Float> RcpSqrt_pp(RValue<Float> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5937 | { |
| 5938 | return x86::rsqrtss(x); |
| 5939 | } |
| 5940 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5941 | RValue<Float> Sqrt(RValue<Float> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5942 | { |
| 5943 | return x86::sqrtss(x); |
| 5944 | } |
| 5945 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5946 | RValue<Float> Round(RValue<Float> x) |
| 5947 | { |
| 5948 | if(CPUID::supportsSSE4_1()) |
| 5949 | { |
| 5950 | return x86::roundss(x, 0); |
| 5951 | } |
| 5952 | else |
| 5953 | { |
| 5954 | return Float4(Round(Float4(x))).x; |
| 5955 | } |
| 5956 | } |
| 5957 | |
| 5958 | RValue<Float> Trunc(RValue<Float> x) |
| 5959 | { |
| 5960 | if(CPUID::supportsSSE4_1()) |
| 5961 | { |
| 5962 | return x86::roundss(x, 3); |
| 5963 | } |
| 5964 | else |
| 5965 | { |
| 5966 | return Float(Int(x)); // Rounded toward zero |
| 5967 | } |
| 5968 | } |
| 5969 | |
| 5970 | RValue<Float> Frac(RValue<Float> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5971 | { |
| 5972 | if(CPUID::supportsSSE4_1()) |
| 5973 | { |
| 5974 | return x - x86::floorss(x); |
| 5975 | } |
| 5976 | else |
| 5977 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5978 | return Float4(Frac(Float4(x))).x; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5979 | } |
| 5980 | } |
| 5981 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5982 | RValue<Float> Floor(RValue<Float> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5983 | { |
| 5984 | if(CPUID::supportsSSE4_1()) |
| 5985 | { |
| 5986 | return x86::floorss(x); |
| 5987 | } |
| 5988 | else |
| 5989 | { |
| 5990 | return Float4(Floor(Float4(x))).x; |
| 5991 | } |
| 5992 | } |
| 5993 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5994 | RValue<Float> Ceil(RValue<Float> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5995 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5996 | if(CPUID::supportsSSE4_1()) |
| 5997 | { |
| 5998 | return x86::ceilss(x); |
| 5999 | } |
| 6000 | else |
| 6001 | { |
| 6002 | return Float4(Ceil(Float4(x))).x; |
| 6003 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6004 | } |
| 6005 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6006 | Type *Float::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6007 | { |
| 6008 | return Type::getFloatTy(*Nucleus::getContext()); |
| 6009 | } |
| 6010 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6011 | Float2::Float2(RValue<Float4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6012 | { |
| 6013 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6014 | |
| 6015 | Value *int64x2 = Nucleus::createBitCast(cast.value, Long2::getType()); |
| 6016 | Value *int64 = Nucleus::createExtractElement(int64x2, 0); |
| 6017 | Value *float2 = Nucleus::createBitCast(int64, Float2::getType()); |
| 6018 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6019 | storeValue(float2); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6020 | } |
| 6021 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6022 | Type *Float2::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6023 | { |
| 6024 | return VectorType::get(Float::getType(), 2); |
| 6025 | } |
| 6026 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6027 | Float4::Float4(RValue<Byte4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6028 | { |
| 6029 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6030 | |
| 6031 | #if 0 |
| 6032 | Value *xyzw = Nucleus::createUIToFP(cast.value, Float4::getType()); // FIXME: Crashes |
| 6033 | #elif 0 |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6034 | Value *vector = loadValue(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6035 | |
| 6036 | Value *i8x = Nucleus::createExtractElement(cast.value, 0); |
| 6037 | Value *f32x = Nucleus::createUIToFP(i8x, Float::getType()); |
| 6038 | Value *x = Nucleus::createInsertElement(vector, f32x, 0); |
| 6039 | |
| 6040 | Value *i8y = Nucleus::createExtractElement(cast.value, Nucleus::createConstantInt(1)); |
| 6041 | Value *f32y = Nucleus::createUIToFP(i8y, Float::getType()); |
| 6042 | Value *xy = Nucleus::createInsertElement(x, f32y, Nucleus::createConstantInt(1)); |
| 6043 | |
| 6044 | Value *i8z = Nucleus::createExtractElement(cast.value, Nucleus::createConstantInt(2)); |
| 6045 | Value *f32z = Nucleus::createUIToFP(i8z, Float::getType()); |
| 6046 | Value *xyz = Nucleus::createInsertElement(xy, f32z, Nucleus::createConstantInt(2)); |
| 6047 | |
| 6048 | Value *i8w = Nucleus::createExtractElement(cast.value, Nucleus::createConstantInt(3)); |
| 6049 | Value *f32w = Nucleus::createUIToFP(i8w, Float::getType()); |
| 6050 | Value *xyzw = Nucleus::createInsertElement(xyz, f32w, Nucleus::createConstantInt(3)); |
| 6051 | #else |
| 6052 | Value *x = Nucleus::createBitCast(cast.value, Int::getType()); |
| 6053 | Value *a = Nucleus::createInsertElement(UndefValue::get(Int4::getType()), x, 0); |
| 6054 | |
| 6055 | Value *e; |
| 6056 | |
| 6057 | if(CPUID::supportsSSE4_1()) |
| 6058 | { |
| 6059 | e = x86::pmovzxbd(RValue<Int4>(a)).value; |
| 6060 | } |
| 6061 | else |
| 6062 | { |
| 6063 | Constant *swizzle[16]; |
| 6064 | swizzle[0] = Nucleus::createConstantInt(0); |
| 6065 | swizzle[1] = Nucleus::createConstantInt(16); |
| 6066 | swizzle[2] = Nucleus::createConstantInt(1); |
| 6067 | swizzle[3] = Nucleus::createConstantInt(17); |
| 6068 | swizzle[4] = Nucleus::createConstantInt(2); |
| 6069 | swizzle[5] = Nucleus::createConstantInt(18); |
| 6070 | swizzle[6] = Nucleus::createConstantInt(3); |
| 6071 | swizzle[7] = Nucleus::createConstantInt(19); |
| 6072 | swizzle[8] = Nucleus::createConstantInt(4); |
| 6073 | swizzle[9] = Nucleus::createConstantInt(20); |
| 6074 | swizzle[10] = Nucleus::createConstantInt(5); |
| 6075 | swizzle[11] = Nucleus::createConstantInt(21); |
| 6076 | swizzle[12] = Nucleus::createConstantInt(6); |
| 6077 | swizzle[13] = Nucleus::createConstantInt(22); |
| 6078 | swizzle[14] = Nucleus::createConstantInt(7); |
| 6079 | swizzle[15] = Nucleus::createConstantInt(23); |
| 6080 | |
| 6081 | Value *b = Nucleus::createBitCast(a, Byte16::getType()); |
| 6082 | Value *c = Nucleus::createShuffleVector(b, Nucleus::createNullValue(Byte16::getType()), Nucleus::createConstantVector(swizzle, 16)); |
| 6083 | |
| 6084 | Constant *swizzle2[8]; |
| 6085 | swizzle2[0] = Nucleus::createConstantInt(0); |
| 6086 | swizzle2[1] = Nucleus::createConstantInt(8); |
| 6087 | swizzle2[2] = Nucleus::createConstantInt(1); |
| 6088 | swizzle2[3] = Nucleus::createConstantInt(9); |
| 6089 | swizzle2[4] = Nucleus::createConstantInt(2); |
| 6090 | swizzle2[5] = Nucleus::createConstantInt(10); |
| 6091 | swizzle2[6] = Nucleus::createConstantInt(3); |
| 6092 | swizzle2[7] = Nucleus::createConstantInt(11); |
| 6093 | |
| 6094 | Value *d = Nucleus::createBitCast(c, Short8::getType()); |
| 6095 | e = Nucleus::createShuffleVector(d, Nucleus::createNullValue(Short8::getType()), Nucleus::createConstantVector(swizzle2, 8)); |
| 6096 | } |
| 6097 | |
| 6098 | Value *f = Nucleus::createBitCast(e, Int4::getType()); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6099 | Value *g = Nucleus::createSIToFP(f, Float4::getType()); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6100 | Value *xyzw = g; |
| 6101 | #endif |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6102 | |
| 6103 | storeValue(xyzw); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6104 | } |
| 6105 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6106 | Float4::Float4(RValue<SByte4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6107 | { |
| 6108 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6109 | |
| 6110 | #if 0 |
| 6111 | Value *xyzw = Nucleus::createSIToFP(cast.value, Float4::getType()); // FIXME: Crashes |
| 6112 | #elif 0 |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6113 | Value *vector = loadValue(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6114 | |
| 6115 | Value *i8x = Nucleus::createExtractElement(cast.value, 0); |
| 6116 | Value *f32x = Nucleus::createSIToFP(i8x, Float::getType()); |
| 6117 | Value *x = Nucleus::createInsertElement(vector, f32x, 0); |
| 6118 | |
| 6119 | Value *i8y = Nucleus::createExtractElement(cast.value, Nucleus::createConstantInt(1)); |
| 6120 | Value *f32y = Nucleus::createSIToFP(i8y, Float::getType()); |
| 6121 | Value *xy = Nucleus::createInsertElement(x, f32y, Nucleus::createConstantInt(1)); |
| 6122 | |
| 6123 | Value *i8z = Nucleus::createExtractElement(cast.value, Nucleus::createConstantInt(2)); |
| 6124 | Value *f32z = Nucleus::createSIToFP(i8z, Float::getType()); |
| 6125 | Value *xyz = Nucleus::createInsertElement(xy, f32z, Nucleus::createConstantInt(2)); |
| 6126 | |
| 6127 | Value *i8w = Nucleus::createExtractElement(cast.value, Nucleus::createConstantInt(3)); |
| 6128 | Value *f32w = Nucleus::createSIToFP(i8w, Float::getType()); |
| 6129 | Value *xyzw = Nucleus::createInsertElement(xyz, f32w, Nucleus::createConstantInt(3)); |
| 6130 | #else |
| 6131 | Value *x = Nucleus::createBitCast(cast.value, Int::getType()); |
| 6132 | Value *a = Nucleus::createInsertElement(UndefValue::get(Int4::getType()), x, 0); |
| 6133 | |
| 6134 | Value *g; |
| 6135 | |
| 6136 | if(CPUID::supportsSSE4_1()) |
| 6137 | { |
| 6138 | g = x86::pmovsxbd(RValue<Int4>(a)).value; |
| 6139 | } |
| 6140 | else |
| 6141 | { |
| 6142 | Constant *swizzle[16]; |
| 6143 | swizzle[0] = Nucleus::createConstantInt(0); |
| 6144 | swizzle[1] = Nucleus::createConstantInt(0); |
| 6145 | swizzle[2] = Nucleus::createConstantInt(1); |
| 6146 | swizzle[3] = Nucleus::createConstantInt(1); |
| 6147 | swizzle[4] = Nucleus::createConstantInt(2); |
| 6148 | swizzle[5] = Nucleus::createConstantInt(2); |
| 6149 | swizzle[6] = Nucleus::createConstantInt(3); |
| 6150 | swizzle[7] = Nucleus::createConstantInt(3); |
| 6151 | swizzle[8] = Nucleus::createConstantInt(4); |
| 6152 | swizzle[9] = Nucleus::createConstantInt(4); |
| 6153 | swizzle[10] = Nucleus::createConstantInt(5); |
| 6154 | swizzle[11] = Nucleus::createConstantInt(5); |
| 6155 | swizzle[12] = Nucleus::createConstantInt(6); |
| 6156 | swizzle[13] = Nucleus::createConstantInt(6); |
| 6157 | swizzle[14] = Nucleus::createConstantInt(7); |
| 6158 | swizzle[15] = Nucleus::createConstantInt(7); |
| 6159 | |
| 6160 | Value *b = Nucleus::createBitCast(a, Byte16::getType()); |
| 6161 | Value *c = Nucleus::createShuffleVector(b, b, Nucleus::createConstantVector(swizzle, 16)); |
| 6162 | |
| 6163 | Constant *swizzle2[8]; |
| 6164 | swizzle2[0] = Nucleus::createConstantInt(0); |
| 6165 | swizzle2[1] = Nucleus::createConstantInt(0); |
| 6166 | swizzle2[2] = Nucleus::createConstantInt(1); |
| 6167 | swizzle2[3] = Nucleus::createConstantInt(1); |
| 6168 | swizzle2[4] = Nucleus::createConstantInt(2); |
| 6169 | swizzle2[5] = Nucleus::createConstantInt(2); |
| 6170 | swizzle2[6] = Nucleus::createConstantInt(3); |
| 6171 | swizzle2[7] = Nucleus::createConstantInt(3); |
| 6172 | |
| 6173 | Value *d = Nucleus::createBitCast(c, Short8::getType()); |
| 6174 | Value *e = Nucleus::createShuffleVector(d, d, Nucleus::createConstantVector(swizzle2, 8)); |
| 6175 | |
| 6176 | Value *f = Nucleus::createBitCast(e, Int4::getType()); |
| 6177 | // g = Nucleus::createAShr(f, Nucleus::createConstantInt(24)); |
| 6178 | g = x86::psrad(RValue<Int4>(f), 24).value; |
| 6179 | } |
| 6180 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6181 | Value *xyzw = Nucleus::createSIToFP(g, Float4::getType()); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6182 | #endif |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6183 | |
| 6184 | storeValue(xyzw); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6185 | } |
| 6186 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6187 | Float4::Float4(RValue<Short4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6188 | { |
| 6189 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6190 | |
| 6191 | #if 0 |
| 6192 | Value *xyzw = Nucleus::createSIToFP(cast.value, Float4::getType()); // FIXME: Crashes |
| 6193 | #elif 0 |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6194 | Value *vector = loadValue(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6195 | |
| 6196 | Value *i16x = Nucleus::createExtractElement(cast.value, 0); |
| 6197 | Value *f32x = Nucleus::createSIToFP(i16x, Float::getType()); |
| 6198 | Value *x = Nucleus::createInsertElement(vector, f32x, 0); |
| 6199 | |
| 6200 | Value *i16y = Nucleus::createExtractElement(cast.value, Nucleus::createConstantInt(1)); |
| 6201 | Value *f32y = Nucleus::createSIToFP(i16y, Float::getType()); |
| 6202 | Value *xy = Nucleus::createInsertElement(x, f32y, Nucleus::createConstantInt(1)); |
| 6203 | |
| 6204 | Value *i16z = Nucleus::createExtractElement(cast.value, Nucleus::createConstantInt(2)); |
| 6205 | Value *f32z = Nucleus::createSIToFP(i16z, Float::getType()); |
| 6206 | Value *xyz = Nucleus::createInsertElement(xy, f32z, Nucleus::createConstantInt(2)); |
| 6207 | |
| 6208 | Value *i16w = Nucleus::createExtractElement(cast.value, Nucleus::createConstantInt(3)); |
| 6209 | Value *f32w = Nucleus::createSIToFP(i16w, Float::getType()); |
| 6210 | Value *xyzw = Nucleus::createInsertElement(xyz, f32w, Nucleus::createConstantInt(3)); |
| 6211 | #else |
| 6212 | Value *long2 = UndefValue::get(Long2::getType()); |
| 6213 | Value *element = Nucleus::createBitCast(cast.value, Long::getType()); |
| 6214 | long2 = Nucleus::createInsertElement(long2, element, 0); |
| 6215 | RValue<Int4> vector = RValue<Int4>(Nucleus::createBitCast(long2, Int4::getType())); |
| 6216 | |
| 6217 | Value *xyzw; |
| 6218 | |
| 6219 | if(CPUID::supportsSSE4_1()) |
| 6220 | { |
| 6221 | Value *c = x86::pmovsxwd(vector).value; |
| 6222 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6223 | xyzw = Nucleus::createSIToFP(c, Float4::getType()); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6224 | } |
| 6225 | else |
| 6226 | { |
| 6227 | Value *b = Nucleus::createBitCast(vector.value, Short8::getType()); |
| 6228 | |
| 6229 | Constant *swizzle[8]; |
| 6230 | swizzle[0] = Nucleus::createConstantInt(0); |
| 6231 | swizzle[1] = Nucleus::createConstantInt(0); |
| 6232 | swizzle[2] = Nucleus::createConstantInt(1); |
| 6233 | swizzle[3] = Nucleus::createConstantInt(1); |
| 6234 | swizzle[4] = Nucleus::createConstantInt(2); |
| 6235 | swizzle[5] = Nucleus::createConstantInt(2); |
| 6236 | swizzle[6] = Nucleus::createConstantInt(3); |
| 6237 | swizzle[7] = Nucleus::createConstantInt(3); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6238 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6239 | Value *c = Nucleus::createShuffleVector(b, b, Nucleus::createConstantVector(swizzle, 8)); |
| 6240 | Value *d = Nucleus::createBitCast(c, Int4::getType()); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6241 | Value *e = Nucleus::createSIToFP(d, Float4::getType()); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6242 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6243 | Constant *constantVector[4]; |
| 6244 | constantVector[0] = Nucleus::createConstantFloat(1.0f / (1 << 16)); |
| 6245 | constantVector[1] = Nucleus::createConstantFloat(1.0f / (1 << 16)); |
| 6246 | constantVector[2] = Nucleus::createConstantFloat(1.0f / (1 << 16)); |
| 6247 | constantVector[3] = Nucleus::createConstantFloat(1.0f / (1 << 16)); |
| 6248 | |
| 6249 | xyzw = Nucleus::createFMul(e, Nucleus::createConstantVector(constantVector, 4)); |
| 6250 | } |
| 6251 | #endif |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6252 | |
| 6253 | storeValue(xyzw); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6254 | } |
| 6255 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6256 | Float4::Float4(RValue<UShort4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6257 | { |
| 6258 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6259 | |
| 6260 | #if 0 |
| 6261 | Value *xyzw = Nucleus::createUIToFP(cast.value, Float4::getType()); // FIXME: Crashes |
| 6262 | #elif 0 |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6263 | Value *vector = loadValue(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6264 | |
| 6265 | Value *i16x = Nucleus::createExtractElement(cast.value, 0); |
| 6266 | Value *f32x = Nucleus::createUIToFP(i16x, Float::getType()); |
| 6267 | Value *x = Nucleus::createInsertElement(vector, f32x, 0); |
| 6268 | |
| 6269 | Value *i16y = Nucleus::createExtractElement(cast.value, Nucleus::createConstantInt(1)); |
| 6270 | Value *f32y = Nucleus::createUIToFP(i16y, Float::getType()); |
| 6271 | Value *xy = Nucleus::createInsertElement(x, f32y, Nucleus::createConstantInt(1)); |
| 6272 | |
| 6273 | Value *i16z = Nucleus::createExtractElement(cast.value, Nucleus::createConstantInt(2)); |
| 6274 | Value *f32z = Nucleus::createUIToFP(i16z, Float::getType()); |
| 6275 | Value *xyz = Nucleus::createInsertElement(xy, f32z, Nucleus::createConstantInt(2)); |
| 6276 | |
| 6277 | Value *i16w = Nucleus::createExtractElement(cast.value, Nucleus::createConstantInt(3)); |
| 6278 | Value *f32w = Nucleus::createUIToFP(i16w, Float::getType()); |
| 6279 | Value *xyzw = Nucleus::createInsertElement(xyz, f32w, Nucleus::createConstantInt(3)); |
| 6280 | #else |
| 6281 | Value *long2 = UndefValue::get(Long2::getType()); |
| 6282 | Value *element = Nucleus::createBitCast(cast.value, Long::getType()); |
| 6283 | long2 = Nucleus::createInsertElement(long2, element, 0); |
| 6284 | RValue<Int4> vector = RValue<Int4>(Nucleus::createBitCast(long2, Int4::getType())); |
| 6285 | |
| 6286 | Value *c; |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6287 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6288 | if(CPUID::supportsSSE4_1()) |
| 6289 | { |
| 6290 | c = x86::pmovzxwd(RValue<Int4>(vector)).value; |
| 6291 | } |
| 6292 | else |
| 6293 | { |
| 6294 | Value *b = Nucleus::createBitCast(vector.value, Short8::getType()); |
| 6295 | |
| 6296 | Constant *swizzle[8]; |
| 6297 | swizzle[0] = Nucleus::createConstantInt(0); |
| 6298 | swizzle[1] = Nucleus::createConstantInt(8); |
| 6299 | swizzle[2] = Nucleus::createConstantInt(1); |
| 6300 | swizzle[3] = Nucleus::createConstantInt(9); |
| 6301 | swizzle[4] = Nucleus::createConstantInt(2); |
| 6302 | swizzle[5] = Nucleus::createConstantInt(10); |
| 6303 | swizzle[6] = Nucleus::createConstantInt(3); |
| 6304 | swizzle[7] = Nucleus::createConstantInt(11); |
| 6305 | |
| 6306 | c = Nucleus::createShuffleVector(b, Nucleus::createNullValue(Short8::getType()), Nucleus::createConstantVector(swizzle, 8)); |
| 6307 | } |
| 6308 | |
| 6309 | Value *d = Nucleus::createBitCast(c, Int4::getType()); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6310 | Value *e = Nucleus::createSIToFP(d, Float4::getType()); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6311 | Value *xyzw = e; |
| 6312 | #endif |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6313 | |
| 6314 | storeValue(xyzw); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6315 | } |
| 6316 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6317 | Float4::Float4(RValue<Int4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6318 | { |
| 6319 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6320 | |
| 6321 | Value *xyzw = Nucleus::createSIToFP(cast.value, Float4::getType()); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6322 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6323 | storeValue(xyzw); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6324 | } |
| 6325 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6326 | Float4::Float4(RValue<UInt4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6327 | { |
| 6328 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6329 | |
| 6330 | Value *xyzw = Nucleus::createUIToFP(cast.value, Float4::getType()); |
| 6331 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6332 | storeValue(xyzw); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6333 | } |
| 6334 | |
| 6335 | Float4::Float4() |
| 6336 | { |
| 6337 | xyzw.parent = this; |
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 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6340 | Float4::Float4(float xyzw) |
| 6341 | { |
| 6342 | constant(xyzw, xyzw, xyzw, xyzw); |
| 6343 | } |
| 6344 | |
| 6345 | Float4::Float4(float x, float yzw) |
| 6346 | { |
| 6347 | constant(x, yzw, yzw, yzw); |
| 6348 | } |
| 6349 | |
| 6350 | Float4::Float4(float x, float y, float zw) |
| 6351 | { |
| 6352 | constant(x, y, zw, zw); |
| 6353 | } |
| 6354 | |
| 6355 | Float4::Float4(float x, float y, float z, float w) |
| 6356 | { |
| 6357 | constant(x, y, z, w); |
| 6358 | } |
| 6359 | |
| 6360 | void Float4::constant(float x, float y, float z, float w) |
| 6361 | { |
| 6362 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6363 | |
| 6364 | Constant *constantVector[4]; |
| 6365 | constantVector[0] = Nucleus::createConstantFloat(x); |
| 6366 | constantVector[1] = Nucleus::createConstantFloat(y); |
| 6367 | constantVector[2] = Nucleus::createConstantFloat(z); |
| 6368 | constantVector[3] = Nucleus::createConstantFloat(w); |
| 6369 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6370 | storeValue(Nucleus::createConstantVector(constantVector, 4)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6371 | } |
| 6372 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6373 | Float4::Float4(RValue<Float4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6374 | { |
| 6375 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6376 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6377 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6378 | } |
| 6379 | |
| 6380 | Float4::Float4(const Float4 &rhs) |
| 6381 | { |
| 6382 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6383 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6384 | Value *value = rhs.loadValue(); |
| 6385 | storeValue(value); |
| 6386 | } |
| 6387 | |
| 6388 | Float4::Float4(const Reference<Float4> &rhs) |
| 6389 | { |
| 6390 | xyzw.parent = this; |
| 6391 | |
| 6392 | Value *value = rhs.loadValue(); |
| 6393 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6394 | } |
| 6395 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6396 | Float4::Float4(RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6397 | { |
| 6398 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6399 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6400 | Value *vector = loadValue(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6401 | Value *insert = Nucleus::createInsertElement(vector, rhs.value, 0); |
| 6402 | |
| 6403 | Constant *swizzle[4]; |
| 6404 | swizzle[0] = Nucleus::createConstantInt(0); |
| 6405 | swizzle[1] = Nucleus::createConstantInt(0); |
| 6406 | swizzle[2] = Nucleus::createConstantInt(0); |
| 6407 | swizzle[3] = Nucleus::createConstantInt(0); |
| 6408 | |
| 6409 | Value *replicate = Nucleus::createShuffleVector(insert, UndefValue::get(Float4::getType()), Nucleus::createConstantVector(swizzle, 4)); |
| 6410 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6411 | storeValue(replicate); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6412 | } |
| 6413 | |
| 6414 | Float4::Float4(const Float &rhs) |
| 6415 | { |
| 6416 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6417 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6418 | *this = RValue<Float>(rhs.loadValue()); |
| 6419 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6420 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6421 | Float4::Float4(const Reference<Float> &rhs) |
| 6422 | { |
| 6423 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6424 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6425 | *this = RValue<Float>(rhs.loadValue()); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6426 | } |
| 6427 | |
| 6428 | RValue<Float4> Float4::operator=(float x) const |
| 6429 | { |
| 6430 | return *this = Float4(x, x, x, x); |
| 6431 | } |
| 6432 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6433 | RValue<Float4> Float4::operator=(RValue<Float4> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6434 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6435 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6436 | |
| 6437 | return rhs; |
| 6438 | } |
| 6439 | |
| 6440 | RValue<Float4> Float4::operator=(const Float4 &rhs) const |
| 6441 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6442 | Value *value = rhs.loadValue(); |
| 6443 | storeValue(value); |
| 6444 | |
| 6445 | return RValue<Float4>(value); |
| 6446 | } |
| 6447 | |
| 6448 | RValue<Float4> Float4::operator=(const Reference<Float4> &rhs) const |
| 6449 | { |
| 6450 | Value *value = rhs.loadValue(); |
| 6451 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6452 | |
| 6453 | return RValue<Float4>(value); |
| 6454 | } |
| 6455 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6456 | RValue<Float4> Float4::operator=(RValue<Float> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6457 | { |
| 6458 | return *this = Float4(rhs); |
| 6459 | } |
| 6460 | |
| 6461 | RValue<Float4> Float4::operator=(const Float &rhs) const |
| 6462 | { |
| 6463 | return *this = Float4(rhs); |
| 6464 | } |
| 6465 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6466 | RValue<Float4> Float4::operator=(const Reference<Float> &rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6467 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6468 | return *this = Float4(rhs); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6469 | } |
| 6470 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6471 | RValue<Float4> operator+(RValue<Float4> lhs, RValue<Float4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6472 | { |
| 6473 | return RValue<Float4>(Nucleus::createFAdd(lhs.value, rhs.value)); |
| 6474 | } |
| 6475 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6476 | RValue<Float4> operator-(RValue<Float4> lhs, RValue<Float4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6477 | { |
| 6478 | return RValue<Float4>(Nucleus::createFSub(lhs.value, rhs.value)); |
| 6479 | } |
| 6480 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6481 | RValue<Float4> operator*(RValue<Float4> lhs, RValue<Float4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6482 | { |
| 6483 | return RValue<Float4>(Nucleus::createFMul(lhs.value, rhs.value)); |
| 6484 | } |
| 6485 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6486 | RValue<Float4> operator/(RValue<Float4> lhs, RValue<Float4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6487 | { |
| 6488 | return RValue<Float4>(Nucleus::createFDiv(lhs.value, rhs.value)); |
| 6489 | } |
| 6490 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6491 | RValue<Float4> operator%(RValue<Float4> lhs, RValue<Float4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6492 | { |
| 6493 | return RValue<Float4>(Nucleus::createFRem(lhs.value, rhs.value)); |
| 6494 | } |
| 6495 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6496 | RValue<Float4> operator+=(const Float4 &lhs, RValue<Float4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6497 | { |
| 6498 | return lhs = lhs + rhs; |
| 6499 | } |
| 6500 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6501 | RValue<Float4> operator-=(const Float4 &lhs, RValue<Float4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6502 | { |
| 6503 | return lhs = lhs - rhs; |
| 6504 | } |
| 6505 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6506 | RValue<Float4> operator*=(const Float4 &lhs, RValue<Float4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6507 | { |
| 6508 | return lhs = lhs * rhs; |
| 6509 | } |
| 6510 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6511 | RValue<Float4> operator/=(const Float4 &lhs, RValue<Float4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6512 | { |
| 6513 | return lhs = lhs / rhs; |
| 6514 | } |
| 6515 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6516 | RValue<Float4> operator%=(const Float4 &lhs, RValue<Float4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6517 | { |
| 6518 | return lhs = lhs % rhs; |
| 6519 | } |
| 6520 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6521 | RValue<Float4> operator+(RValue<Float4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6522 | { |
| 6523 | return val; |
| 6524 | } |
| 6525 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6526 | RValue<Float4> operator-(RValue<Float4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6527 | { |
| 6528 | return RValue<Float4>(Nucleus::createFNeg(val.value)); |
| 6529 | } |
| 6530 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6531 | RValue<Float4> Abs(RValue<Float4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6532 | { |
| 6533 | Value *vector = Nucleus::createBitCast(x.value, Int4::getType()); |
| 6534 | |
| 6535 | Constant *constantVector[4]; |
| 6536 | constantVector[0] = Nucleus::createConstantInt(0x7FFFFFFF); |
| 6537 | constantVector[1] = Nucleus::createConstantInt(0x7FFFFFFF); |
| 6538 | constantVector[2] = Nucleus::createConstantInt(0x7FFFFFFF); |
| 6539 | constantVector[3] = Nucleus::createConstantInt(0x7FFFFFFF); |
| 6540 | |
| 6541 | Value *result = Nucleus::createAnd(vector, Nucleus::createConstantVector(constantVector, 4)); |
| 6542 | |
| 6543 | return RValue<Float4>(Nucleus::createBitCast(result, Float4::getType())); |
| 6544 | } |
| 6545 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6546 | RValue<Float4> Max(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6547 | { |
| 6548 | return x86::maxps(x, y); |
| 6549 | } |
| 6550 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6551 | RValue<Float4> Min(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6552 | { |
| 6553 | return x86::minps(x, y); |
| 6554 | } |
| 6555 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6556 | RValue<Float4> Rcp_pp(RValue<Float4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6557 | { |
| 6558 | return x86::rcpps(x); |
| 6559 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6560 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6561 | RValue<Float4> RcpSqrt_pp(RValue<Float4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6562 | { |
| 6563 | return x86::rsqrtps(x); |
| 6564 | } |
| 6565 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6566 | RValue<Float4> Sqrt(RValue<Float4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6567 | { |
| 6568 | return x86::sqrtps(x); |
| 6569 | } |
| 6570 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6571 | RValue<Float4> Insert(const Float4 &val, RValue<Float> element, int i) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6572 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6573 | llvm::Value *value = val.loadValue(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6574 | llvm::Value *insert = Nucleus::createInsertElement(value, element.value, i); |
| 6575 | |
| 6576 | val = RValue<Float4>(insert); |
| 6577 | |
| 6578 | return val; |
| 6579 | } |
| 6580 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6581 | RValue<Float> Extract(RValue<Float4> x, int i) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6582 | { |
| 6583 | return RValue<Float>(Nucleus::createExtractElement(x.value, i)); |
| 6584 | } |
| 6585 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6586 | RValue<Float4> Swizzle(RValue<Float4> x, unsigned char select) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6587 | { |
| 6588 | return RValue<Float4>(Nucleus::createSwizzle(x.value, select)); |
| 6589 | } |
| 6590 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6591 | RValue<Float4> ShuffleLowHigh(RValue<Float4> x, RValue<Float4> y, unsigned char imm) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6592 | { |
| 6593 | Constant *shuffle[4]; |
| 6594 | shuffle[0] = Nucleus::createConstantInt(((imm >> 0) & 0x03) + 0); |
| 6595 | shuffle[1] = Nucleus::createConstantInt(((imm >> 2) & 0x03) + 0); |
| 6596 | shuffle[2] = Nucleus::createConstantInt(((imm >> 4) & 0x03) + 4); |
| 6597 | shuffle[3] = Nucleus::createConstantInt(((imm >> 6) & 0x03) + 4); |
| 6598 | |
| 6599 | return RValue<Float4>(Nucleus::createShuffleVector(x.value, y.value, Nucleus::createConstantVector(shuffle, 4))); |
| 6600 | } |
| 6601 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6602 | RValue<Float4> UnpackLow(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6603 | { |
| 6604 | Constant *shuffle[4]; |
| 6605 | shuffle[0] = Nucleus::createConstantInt(0); |
| 6606 | shuffle[1] = Nucleus::createConstantInt(4); |
| 6607 | shuffle[2] = Nucleus::createConstantInt(1); |
| 6608 | shuffle[3] = Nucleus::createConstantInt(5); |
| 6609 | |
| 6610 | return RValue<Float4>(Nucleus::createShuffleVector(x.value, y.value, Nucleus::createConstantVector(shuffle, 4))); |
| 6611 | } |
| 6612 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6613 | RValue<Float4> UnpackHigh(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6614 | { |
| 6615 | Constant *shuffle[4]; |
| 6616 | shuffle[0] = Nucleus::createConstantInt(2); |
| 6617 | shuffle[1] = Nucleus::createConstantInt(6); |
| 6618 | shuffle[2] = Nucleus::createConstantInt(3); |
| 6619 | shuffle[3] = Nucleus::createConstantInt(7); |
| 6620 | |
| 6621 | return RValue<Float4>(Nucleus::createShuffleVector(x.value, y.value, Nucleus::createConstantVector(shuffle, 4))); |
| 6622 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6623 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6624 | RValue<Float4> Mask(Float4 &lhs, RValue<Float4> rhs, unsigned char select) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6625 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6626 | Value *vector = lhs.loadValue(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6627 | Value *shuffle = Nucleus::createMask(vector, rhs.value, select); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6628 | lhs.storeValue(shuffle); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6629 | |
| 6630 | return RValue<Float4>(shuffle); |
| 6631 | } |
| 6632 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6633 | RValue<Int> SignMask(RValue<Float4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6634 | { |
| 6635 | return x86::movmskps(x); |
| 6636 | } |
| 6637 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6638 | RValue<Int4> CmpEQ(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6639 | { |
| 6640 | // return As<Int4>(x86::cmpeqps(x, y)); |
| 6641 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOEQ(x.value, y.value), Int4::getType())); |
| 6642 | } |
| 6643 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6644 | RValue<Int4> CmpLT(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6645 | { |
| 6646 | // return As<Int4>(x86::cmpltps(x, y)); |
| 6647 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOLT(x.value, y.value), Int4::getType())); |
| 6648 | } |
| 6649 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6650 | RValue<Int4> CmpLE(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6651 | { |
| 6652 | // return As<Int4>(x86::cmpleps(x, y)); |
| 6653 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOLE(x.value, y.value), Int4::getType())); |
| 6654 | } |
| 6655 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6656 | RValue<Int4> CmpNEQ(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6657 | { |
| 6658 | // return As<Int4>(x86::cmpneqps(x, y)); |
| 6659 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpONE(x.value, y.value), Int4::getType())); |
| 6660 | } |
| 6661 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6662 | RValue<Int4> CmpNLT(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6663 | { |
| 6664 | // return As<Int4>(x86::cmpnltps(x, y)); |
| 6665 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOGE(x.value, y.value), Int4::getType())); |
| 6666 | } |
| 6667 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6668 | RValue<Int4> CmpNLE(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6669 | { |
| 6670 | // return As<Int4>(x86::cmpnleps(x, y)); |
| 6671 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOGT(x.value, y.value), Int4::getType())); |
| 6672 | } |
| 6673 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6674 | RValue<Float4> Round(RValue<Float4> x) |
| 6675 | { |
| 6676 | if(CPUID::supportsSSE4_1()) |
| 6677 | { |
| 6678 | return x86::roundps(x, 0); |
| 6679 | } |
| 6680 | else |
| 6681 | { |
| 6682 | return Float4(RoundInt(x)); |
| 6683 | } |
| 6684 | } |
| 6685 | |
| 6686 | RValue<Float4> Trunc(RValue<Float4> x) |
| 6687 | { |
| 6688 | if(CPUID::supportsSSE4_1()) |
| 6689 | { |
| 6690 | return x86::roundps(x, 3); |
| 6691 | } |
| 6692 | else |
| 6693 | { |
| 6694 | return Float4(Int4(x)); // Rounded toward zero |
| 6695 | } |
| 6696 | } |
| 6697 | |
| 6698 | RValue<Float4> Frac(RValue<Float4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6699 | { |
| 6700 | if(CPUID::supportsSSE4_1()) |
| 6701 | { |
| 6702 | return x - x86::floorps(x); |
| 6703 | } |
| 6704 | else |
| 6705 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6706 | Float4 frc = x - Float4(Int4(x)); // Signed fractional part |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6707 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6708 | 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] | 6709 | } |
| 6710 | } |
| 6711 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6712 | RValue<Float4> Floor(RValue<Float4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6713 | { |
| 6714 | if(CPUID::supportsSSE4_1()) |
| 6715 | { |
| 6716 | return x86::floorps(x); |
| 6717 | } |
| 6718 | else |
| 6719 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6720 | return x - Frac(x); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6721 | } |
| 6722 | } |
| 6723 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6724 | RValue<Float4> Ceil(RValue<Float4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6725 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6726 | if(CPUID::supportsSSE4_1()) |
| 6727 | { |
| 6728 | return x86::ceilps(x); |
| 6729 | } |
| 6730 | else |
| 6731 | { |
| 6732 | return -Floor(-x); |
| 6733 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6734 | } |
| 6735 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6736 | Type *Float4::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6737 | { |
| 6738 | return VectorType::get(Float::getType(), 4); |
| 6739 | } |
| 6740 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6741 | RValue<Pointer<Byte> > operator+(RValue<Pointer<Byte> > lhs, int offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6742 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6743 | return RValue<Pointer<Byte> >(Nucleus::createGEP(lhs.value, Nucleus::createConstantInt(offset))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6744 | } |
| 6745 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6746 | RValue<Pointer<Byte> > operator+(RValue<Pointer<Byte> > lhs, RValue<Int> offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6747 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6748 | return RValue<Pointer<Byte> >(Nucleus::createGEP(lhs.value, offset.value)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6749 | } |
| 6750 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6751 | RValue<Pointer<Byte> > operator+(RValue<Pointer<Byte> > lhs, RValue<UInt> offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6752 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6753 | return RValue<Pointer<Byte> >(Nucleus::createGEP(lhs.value, offset.value)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6754 | } |
| 6755 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6756 | RValue<Pointer<Byte> > operator+=(const Pointer<Byte> &lhs, int offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6757 | { |
| 6758 | return lhs = lhs + offset; |
| 6759 | } |
| 6760 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6761 | RValue<Pointer<Byte> > operator+=(const Pointer<Byte> &lhs, RValue<Int> offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6762 | { |
| 6763 | return lhs = lhs + offset; |
| 6764 | } |
| 6765 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6766 | RValue<Pointer<Byte> > operator+=(const Pointer<Byte> &lhs, RValue<UInt> offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6767 | { |
| 6768 | return lhs = lhs + offset; |
| 6769 | } |
| 6770 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6771 | RValue<Pointer<Byte> > operator-(RValue<Pointer<Byte> > lhs, int offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6772 | { |
| 6773 | return lhs + -offset; |
| 6774 | } |
| 6775 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6776 | RValue<Pointer<Byte> > operator-(RValue<Pointer<Byte> > lhs, RValue<Int> offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6777 | { |
| 6778 | return lhs + -offset; |
| 6779 | } |
| 6780 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6781 | RValue<Pointer<Byte> > operator-(RValue<Pointer<Byte> > lhs, RValue<UInt> offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6782 | { |
| 6783 | return lhs + -offset; |
| 6784 | } |
| 6785 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6786 | RValue<Pointer<Byte> > operator-=(const Pointer<Byte> &lhs, int offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6787 | { |
| 6788 | return lhs = lhs - offset; |
| 6789 | } |
| 6790 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6791 | RValue<Pointer<Byte> > operator-=(const Pointer<Byte> &lhs, RValue<Int> offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6792 | { |
| 6793 | return lhs = lhs - offset; |
| 6794 | } |
| 6795 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6796 | RValue<Pointer<Byte> > operator-=(const Pointer<Byte> &lhs, RValue<UInt> offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6797 | { |
| 6798 | return lhs = lhs - offset; |
| 6799 | } |
| 6800 | |
| 6801 | void Return() |
| 6802 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6803 | Nucleus::createRetVoid(); |
| 6804 | Nucleus::setInsertBlock(Nucleus::createBasicBlock()); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6805 | Nucleus::createUnreachable(); |
| 6806 | } |
| 6807 | |
| 6808 | void Return(bool ret) |
| 6809 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6810 | Nucleus::createRet(Nucleus::createConstantBool(ret)); |
| 6811 | Nucleus::setInsertBlock(Nucleus::createBasicBlock()); |
| 6812 | Nucleus::createUnreachable(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6813 | } |
| 6814 | |
| 6815 | void Return(const Int &ret) |
| 6816 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6817 | Nucleus::createRet(ret.loadValue()); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6818 | Nucleus::setInsertBlock(Nucleus::createBasicBlock()); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6819 | Nucleus::createUnreachable(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6820 | } |
| 6821 | |
| 6822 | BasicBlock *beginLoop() |
| 6823 | { |
| 6824 | BasicBlock *loopBB = Nucleus::createBasicBlock(); |
| 6825 | |
| 6826 | Nucleus::createBr(loopBB); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6827 | Nucleus::setInsertBlock(loopBB); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6828 | |
| 6829 | return loopBB; |
| 6830 | } |
| 6831 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6832 | bool branch(RValue<Bool> cmp, BasicBlock *bodyBB, BasicBlock *endBB) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6833 | { |
| 6834 | Nucleus::createCondBr(cmp.value, bodyBB, endBB); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6835 | Nucleus::setInsertBlock(bodyBB); |
| 6836 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6837 | return true; |
| 6838 | } |
| 6839 | |
| 6840 | bool elseBlock(BasicBlock *falseBB) |
| 6841 | { |
| 6842 | falseBB->back().eraseFromParent(); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6843 | Nucleus::setInsertBlock(falseBB); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6844 | |
| 6845 | return true; |
| 6846 | } |
| 6847 | |
| 6848 | RValue<Long> Ticks() |
| 6849 | { |
| 6850 | Module *module = Nucleus::getModule(); |
| 6851 | llvm::Function *rdtsc = Intrinsic::getDeclaration(module, Intrinsic::readcyclecounter); |
| 6852 | |
| 6853 | return RValue<Long>(Nucleus::createCall(rdtsc)); |
| 6854 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6855 | } |
| 6856 | |
| 6857 | namespace sw |
| 6858 | { |
| 6859 | namespace x86 |
| 6860 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6861 | RValue<Int> cvtss2si(RValue<Float> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6862 | { |
| 6863 | Module *module = Nucleus::getModule(); |
| 6864 | llvm::Function *cvtss2si = Intrinsic::getDeclaration(module, Intrinsic::x86_sse_cvtss2si); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6865 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6866 | Float4 vector; |
| 6867 | vector.x = val; |
| 6868 | |
| 6869 | return RValue<Int>(Nucleus::createCall(cvtss2si, RValue<Float4>(vector).value)); |
| 6870 | } |
| 6871 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6872 | RValue<Int2> cvtps2pi(RValue<Float4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6873 | { |
| 6874 | Module *module = Nucleus::getModule(); |
| 6875 | llvm::Function *cvtps2pi = Intrinsic::getDeclaration(module, Intrinsic::x86_sse_cvtps2pi); |
| 6876 | |
| 6877 | return RValue<Int2>(Nucleus::createCall(cvtps2pi, val.value)); |
| 6878 | } |
| 6879 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6880 | RValue<Int2> cvttps2pi(RValue<Float4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6881 | { |
| 6882 | Module *module = Nucleus::getModule(); |
| 6883 | llvm::Function *cvttps2pi = Intrinsic::getDeclaration(module, Intrinsic::x86_sse_cvttps2pi); |
| 6884 | |
| 6885 | return RValue<Int2>(Nucleus::createCall(cvttps2pi, val.value)); |
| 6886 | } |
| 6887 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6888 | RValue<Int4> cvtps2dq(RValue<Float4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6889 | { |
| 6890 | if(CPUID::supportsSSE2()) |
| 6891 | { |
| 6892 | Module *module = Nucleus::getModule(); |
| 6893 | llvm::Function *cvtps2dq = Intrinsic::getDeclaration(module, Intrinsic::x86_sse2_cvtps2dq); |
| 6894 | |
| 6895 | return RValue<Int4>(Nucleus::createCall(cvtps2dq, val.value)); |
| 6896 | } |
| 6897 | else |
| 6898 | { |
| 6899 | Int2 lo = x86::cvtps2pi(val); |
| 6900 | Int2 hi = x86::cvtps2pi(Swizzle(val, 0xEE)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6901 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6902 | return Concatenate(lo, hi); |
| 6903 | } |
| 6904 | } |
| 6905 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6906 | RValue<Float> rcpss(RValue<Float> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6907 | { |
| 6908 | Module *module = Nucleus::getModule(); |
| 6909 | llvm::Function *rcpss = Intrinsic::getDeclaration(module, Intrinsic::x86_sse_rcp_ss); |
| 6910 | |
| 6911 | Value *vector = Nucleus::createInsertElement(UndefValue::get(Float4::getType()), val.value, 0); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6912 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6913 | return RValue<Float>(Nucleus::createExtractElement(Nucleus::createCall(rcpss, vector), 0)); |
| 6914 | } |
| 6915 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6916 | RValue<Float> sqrtss(RValue<Float> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6917 | { |
| 6918 | Module *module = Nucleus::getModule(); |
| 6919 | llvm::Function *sqrtss = Intrinsic::getDeclaration(module, Intrinsic::x86_sse_sqrt_ss); |
| 6920 | |
| 6921 | Value *vector = Nucleus::createInsertElement(UndefValue::get(Float4::getType()), val.value, 0); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6922 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6923 | return RValue<Float>(Nucleus::createExtractElement(Nucleus::createCall(sqrtss, vector), 0)); |
| 6924 | } |
| 6925 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6926 | RValue<Float> rsqrtss(RValue<Float> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6927 | { |
| 6928 | Module *module = Nucleus::getModule(); |
| 6929 | llvm::Function *rsqrtss = Intrinsic::getDeclaration(module, Intrinsic::x86_sse_rsqrt_ss); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6930 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6931 | Value *vector = Nucleus::createInsertElement(UndefValue::get(Float4::getType()), val.value, 0); |
| 6932 | |
| 6933 | return RValue<Float>(Nucleus::createExtractElement(Nucleus::createCall(rsqrtss, vector), 0)); |
| 6934 | } |
| 6935 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6936 | RValue<Float4> rcpps(RValue<Float4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6937 | { |
| 6938 | Module *module = Nucleus::getModule(); |
| 6939 | llvm::Function *rcpps = Intrinsic::getDeclaration(module, Intrinsic::x86_sse_rcp_ps); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6940 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6941 | return RValue<Float4>(Nucleus::createCall(rcpps, val.value)); |
| 6942 | } |
| 6943 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6944 | RValue<Float4> sqrtps(RValue<Float4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6945 | { |
| 6946 | Module *module = Nucleus::getModule(); |
| 6947 | llvm::Function *sqrtps = Intrinsic::getDeclaration(module, Intrinsic::x86_sse_sqrt_ps); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6948 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6949 | return RValue<Float4>(Nucleus::createCall(sqrtps, val.value)); |
| 6950 | } |
| 6951 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6952 | RValue<Float4> rsqrtps(RValue<Float4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6953 | { |
| 6954 | Module *module = Nucleus::getModule(); |
| 6955 | llvm::Function *rsqrtps = Intrinsic::getDeclaration(module, Intrinsic::x86_sse_rsqrt_ps); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6956 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6957 | return RValue<Float4>(Nucleus::createCall(rsqrtps, val.value)); |
| 6958 | } |
| 6959 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6960 | RValue<Float4> maxps(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6961 | { |
| 6962 | Module *module = Nucleus::getModule(); |
| 6963 | llvm::Function *maxps = Intrinsic::getDeclaration(module, Intrinsic::x86_sse_max_ps); |
| 6964 | |
| 6965 | return RValue<Float4>(Nucleus::createCall(maxps, x.value, y.value)); |
| 6966 | } |
| 6967 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6968 | RValue<Float4> minps(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6969 | { |
| 6970 | Module *module = Nucleus::getModule(); |
| 6971 | llvm::Function *minps = Intrinsic::getDeclaration(module, Intrinsic::x86_sse_min_ps); |
| 6972 | |
| 6973 | return RValue<Float4>(Nucleus::createCall(minps, x.value, y.value)); |
| 6974 | } |
| 6975 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6976 | RValue<Float> roundss(RValue<Float> val, unsigned char imm) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6977 | { |
| 6978 | Module *module = Nucleus::getModule(); |
| 6979 | llvm::Function *roundss = Intrinsic::getDeclaration(module, Intrinsic::x86_sse41_round_ss); |
| 6980 | |
| 6981 | Value *undef = UndefValue::get(Float4::getType()); |
| 6982 | Value *vector = Nucleus::createInsertElement(undef, val.value, 0); |
| 6983 | |
| 6984 | return RValue<Float>(Nucleus::createExtractElement(Nucleus::createCall(roundss, undef, vector, Nucleus::createConstantInt(imm)), 0)); |
| 6985 | } |
| 6986 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6987 | RValue<Float> floorss(RValue<Float> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6988 | { |
| 6989 | return roundss(val, 1); |
| 6990 | } |
| 6991 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6992 | RValue<Float> ceilss(RValue<Float> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6993 | { |
| 6994 | return roundss(val, 2); |
| 6995 | } |
| 6996 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6997 | RValue<Float4> roundps(RValue<Float4> val, unsigned char imm) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6998 | { |
| 6999 | Module *module = Nucleus::getModule(); |
| 7000 | llvm::Function *roundps = Intrinsic::getDeclaration(module, Intrinsic::x86_sse41_round_ps); |
| 7001 | |
| 7002 | return RValue<Float4>(Nucleus::createCall(roundps, val.value, Nucleus::createConstantInt(imm))); |
| 7003 | } |
| 7004 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7005 | RValue<Float4> floorps(RValue<Float4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7006 | { |
| 7007 | return roundps(val, 1); |
| 7008 | } |
| 7009 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7010 | RValue<Float4> ceilps(RValue<Float4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7011 | { |
| 7012 | return roundps(val, 2); |
| 7013 | } |
| 7014 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7015 | RValue<Float4> cmpps(RValue<Float4> x, RValue<Float4> y, unsigned char imm) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7016 | { |
| 7017 | Module *module = Nucleus::getModule(); |
| 7018 | llvm::Function *cmpps = Intrinsic::getDeclaration(module, Intrinsic::x86_sse_cmp_ps); |
| 7019 | |
| 7020 | return RValue<Float4>(Nucleus::createCall(cmpps, x.value, y.value, Nucleus::createConstantByte(imm))); |
| 7021 | } |
| 7022 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7023 | RValue<Float4> cmpeqps(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7024 | { |
| 7025 | return cmpps(x, y, 0); |
| 7026 | } |
| 7027 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7028 | RValue<Float4> cmpltps(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7029 | { |
| 7030 | return cmpps(x, y, 1); |
| 7031 | } |
| 7032 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7033 | RValue<Float4> cmpleps(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7034 | { |
| 7035 | return cmpps(x, y, 2); |
| 7036 | } |
| 7037 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7038 | RValue<Float4> cmpunordps(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7039 | { |
| 7040 | return cmpps(x, y, 3); |
| 7041 | } |
| 7042 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7043 | RValue<Float4> cmpneqps(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7044 | { |
| 7045 | return cmpps(x, y, 4); |
| 7046 | } |
| 7047 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7048 | RValue<Float4> cmpnltps(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7049 | { |
| 7050 | return cmpps(x, y, 5); |
| 7051 | } |
| 7052 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7053 | RValue<Float4> cmpnleps(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7054 | { |
| 7055 | return cmpps(x, y, 6); |
| 7056 | } |
| 7057 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7058 | RValue<Float4> cmpordps(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7059 | { |
| 7060 | return cmpps(x, y, 7); |
| 7061 | } |
| 7062 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7063 | RValue<Float> cmpss(RValue<Float> x, RValue<Float> y, unsigned char imm) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7064 | { |
| 7065 | Module *module = Nucleus::getModule(); |
| 7066 | llvm::Function *cmpss = Intrinsic::getDeclaration(module, Intrinsic::x86_sse_cmp_ss); |
| 7067 | |
| 7068 | Value *vector1 = Nucleus::createInsertElement(UndefValue::get(Float4::getType()), x.value, 0); |
| 7069 | Value *vector2 = Nucleus::createInsertElement(UndefValue::get(Float4::getType()), y.value, 0); |
| 7070 | |
| 7071 | return RValue<Float>(Nucleus::createExtractElement(Nucleus::createCall(cmpss, vector1, vector2, Nucleus::createConstantByte(imm)), 0)); |
| 7072 | } |
| 7073 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7074 | RValue<Float> cmpeqss(RValue<Float> x, RValue<Float> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7075 | { |
| 7076 | return cmpss(x, y, 0); |
| 7077 | } |
| 7078 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7079 | RValue<Float> cmpltss(RValue<Float> x, RValue<Float> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7080 | { |
| 7081 | return cmpss(x, y, 1); |
| 7082 | } |
| 7083 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7084 | RValue<Float> cmpless(RValue<Float> x, RValue<Float> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7085 | { |
| 7086 | return cmpss(x, y, 2); |
| 7087 | } |
| 7088 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7089 | RValue<Float> cmpunordss(RValue<Float> x, RValue<Float> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7090 | { |
| 7091 | return cmpss(x, y, 3); |
| 7092 | } |
| 7093 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7094 | RValue<Float> cmpneqss(RValue<Float> x, RValue<Float> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7095 | { |
| 7096 | return cmpss(x, y, 4); |
| 7097 | } |
| 7098 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7099 | RValue<Float> cmpnltss(RValue<Float> x, RValue<Float> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7100 | { |
| 7101 | return cmpss(x, y, 5); |
| 7102 | } |
| 7103 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7104 | RValue<Float> cmpnless(RValue<Float> x, RValue<Float> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7105 | { |
| 7106 | return cmpss(x, y, 6); |
| 7107 | } |
| 7108 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7109 | RValue<Float> cmpordss(RValue<Float> x, RValue<Float> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7110 | { |
| 7111 | return cmpss(x, y, 7); |
| 7112 | } |
| 7113 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7114 | RValue<Int4> pabsd(RValue<Int4> x, RValue<Int4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7115 | { |
| 7116 | Module *module = Nucleus::getModule(); |
| 7117 | llvm::Function *pabsd = Intrinsic::getDeclaration(module, Intrinsic::x86_ssse3_pabs_d_128); |
| 7118 | |
| 7119 | return RValue<Int4>(Nucleus::createCall(pabsd, x.value, y.value)); |
| 7120 | } |
| 7121 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7122 | RValue<Short4> paddsw(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7123 | { |
| 7124 | Module *module = Nucleus::getModule(); |
| 7125 | llvm::Function *paddsw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_padds_w); |
| 7126 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7127 | return As<Short4>(RValue<MMX>(Nucleus::createCall(paddsw, As<MMX>(x).value, As<MMX>(y).value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7128 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7129 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7130 | RValue<Short4> psubsw(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7131 | { |
| 7132 | Module *module = Nucleus::getModule(); |
| 7133 | llvm::Function *psubsw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_psubs_w); |
| 7134 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7135 | return As<Short4>(RValue<MMX>(Nucleus::createCall(psubsw, As<MMX>(x).value, As<MMX>(y).value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7136 | } |
| 7137 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7138 | RValue<UShort4> paddusw(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7139 | { |
| 7140 | Module *module = Nucleus::getModule(); |
| 7141 | llvm::Function *paddusw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_paddus_w); |
| 7142 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7143 | return As<UShort4>(RValue<MMX>(Nucleus::createCall(paddusw, As<MMX>(x).value, As<MMX>(y).value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7144 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7145 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7146 | RValue<UShort4> psubusw(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7147 | { |
| 7148 | Module *module = Nucleus::getModule(); |
| 7149 | llvm::Function *psubusw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_psubus_w); |
| 7150 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7151 | return As<UShort4>(RValue<MMX>(Nucleus::createCall(psubusw, As<MMX>(x).value, As<MMX>(y).value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7152 | } |
| 7153 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7154 | RValue<SByte8> paddsb(RValue<SByte8> x, RValue<SByte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7155 | { |
| 7156 | Module *module = Nucleus::getModule(); |
| 7157 | llvm::Function *paddsb = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_padds_b); |
| 7158 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7159 | return As<SByte8>(RValue<MMX>(Nucleus::createCall(paddsb, As<MMX>(x).value, As<MMX>(y).value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7160 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7161 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7162 | RValue<SByte8> psubsb(RValue<SByte8> x, RValue<SByte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7163 | { |
| 7164 | Module *module = Nucleus::getModule(); |
| 7165 | llvm::Function *psubsb = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_psubs_b); |
| 7166 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7167 | return As<SByte8>(RValue<MMX>(Nucleus::createCall(psubsb, As<MMX>(x).value, As<MMX>(y).value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7168 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7169 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7170 | RValue<Byte8> paddusb(RValue<Byte8> x, RValue<Byte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7171 | { |
| 7172 | Module *module = Nucleus::getModule(); |
| 7173 | llvm::Function *paddusb = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_paddus_b); |
| 7174 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7175 | return As<Byte8>(RValue<MMX>(Nucleus::createCall(paddusb, As<MMX>(x).value, As<MMX>(y).value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7176 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7177 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7178 | RValue<Byte8> psubusb(RValue<Byte8> x, RValue<Byte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7179 | { |
| 7180 | Module *module = Nucleus::getModule(); |
| 7181 | llvm::Function *psubusb = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_psubus_b); |
| 7182 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7183 | return As<Byte8>(RValue<MMX>(Nucleus::createCall(psubusb, As<MMX>(x).value, As<MMX>(y).value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7184 | } |
| 7185 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7186 | RValue<Short4> paddw(RValue<Short4> x, RValue<Short4> y) |
| 7187 | { |
| 7188 | Module *module = Nucleus::getModule(); |
| 7189 | llvm::Function *paddw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_padd_w); |
| 7190 | |
| 7191 | return As<Short4>(RValue<MMX>(Nucleus::createCall(paddw, As<MMX>(x).value, As<MMX>(y).value))); |
| 7192 | } |
| 7193 | |
| 7194 | RValue<Short4> psubw(RValue<Short4> x, RValue<Short4> y) |
| 7195 | { |
| 7196 | Module *module = Nucleus::getModule(); |
| 7197 | llvm::Function *psubw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_psub_w); |
| 7198 | |
| 7199 | return As<Short4>(RValue<MMX>(Nucleus::createCall(psubw, As<MMX>(x).value, As<MMX>(y).value))); |
| 7200 | } |
| 7201 | |
| 7202 | RValue<Short4> pmullw(RValue<Short4> x, RValue<Short4> y) |
| 7203 | { |
| 7204 | Module *module = Nucleus::getModule(); |
| 7205 | llvm::Function *pmullw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pmull_w); |
| 7206 | |
| 7207 | return As<Short4>(RValue<MMX>(Nucleus::createCall(pmullw, As<MMX>(x).value, As<MMX>(y).value))); |
| 7208 | } |
| 7209 | |
| 7210 | RValue<Short4> pand(RValue<Short4> x, RValue<Short4> y) |
| 7211 | { |
| 7212 | Module *module = Nucleus::getModule(); |
| 7213 | llvm::Function *pand = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pand); |
| 7214 | |
| 7215 | return As<Short4>(RValue<MMX>(Nucleus::createCall(pand, As<MMX>(x).value, As<MMX>(y).value))); |
| 7216 | } |
| 7217 | |
| 7218 | RValue<Short4> por(RValue<Short4> x, RValue<Short4> y) |
| 7219 | { |
| 7220 | Module *module = Nucleus::getModule(); |
| 7221 | llvm::Function *por = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_por); |
| 7222 | |
| 7223 | return As<Short4>(RValue<MMX>(Nucleus::createCall(por, As<MMX>(x).value, As<MMX>(y).value))); |
| 7224 | } |
| 7225 | |
| 7226 | RValue<Short4> pxor(RValue<Short4> x, RValue<Short4> y) |
| 7227 | { |
| 7228 | Module *module = Nucleus::getModule(); |
| 7229 | llvm::Function *pxor = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pxor); |
| 7230 | |
| 7231 | return As<Short4>(RValue<MMX>(Nucleus::createCall(pxor, As<MMX>(x).value, As<MMX>(y).value))); |
| 7232 | } |
| 7233 | |
| 7234 | RValue<Short4> pshufw(RValue<Short4> x, unsigned char y) |
| 7235 | { |
| 7236 | Module *module = Nucleus::getModule(); |
| 7237 | llvm::Function *pshufw = Intrinsic::getDeclaration(module, Intrinsic::x86_sse_pshuf_w); |
| 7238 | |
| 7239 | return As<Short4>(RValue<MMX>(Nucleus::createCall(pshufw, As<MMX>(x).value, Nucleus::createConstantByte(y)))); |
| 7240 | } |
| 7241 | |
| 7242 | RValue<Int2> punpcklwd(RValue<Short4> x, RValue<Short4> y) |
| 7243 | { |
| 7244 | Module *module = Nucleus::getModule(); |
| 7245 | llvm::Function *punpcklwd = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_punpcklwd); |
| 7246 | |
| 7247 | return As<Int2>(RValue<MMX>(Nucleus::createCall(punpcklwd, As<MMX>(x).value, As<MMX>(y).value))); |
| 7248 | } |
| 7249 | |
| 7250 | RValue<Int2> punpckhwd(RValue<Short4> x, RValue<Short4> y) |
| 7251 | { |
| 7252 | Module *module = Nucleus::getModule(); |
| 7253 | llvm::Function *punpckhwd = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_punpckhwd); |
| 7254 | |
| 7255 | return As<Int2>(RValue<MMX>(Nucleus::createCall(punpckhwd, As<MMX>(x).value, As<MMX>(y).value))); |
| 7256 | } |
| 7257 | |
| 7258 | RValue<Short4> pinsrw(RValue<Short4> x, RValue<Int> y, unsigned int i) |
| 7259 | { |
| 7260 | Module *module = Nucleus::getModule(); |
| 7261 | llvm::Function *pinsrw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pinsr_w); |
| 7262 | |
| 7263 | return As<Short4>(RValue<MMX>(Nucleus::createCall(pinsrw, As<MMX>(x).value, y.value, Nucleus::createConstantInt(i)))); |
| 7264 | } |
| 7265 | |
| 7266 | RValue<Int> pextrw(RValue<Short4> x, unsigned int i) |
| 7267 | { |
| 7268 | Module *module = Nucleus::getModule(); |
| 7269 | llvm::Function *pextrw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pextr_w); |
| 7270 | |
| 7271 | return RValue<Int>(Nucleus::createCall(pextrw, As<MMX>(x).value, Nucleus::createConstantInt(i))); |
| 7272 | } |
| 7273 | |
| 7274 | RValue<Long1> punpckldq(RValue<Int2> x, RValue<Int2> y) |
| 7275 | { |
| 7276 | Module *module = Nucleus::getModule(); |
| 7277 | llvm::Function *punpckldq = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_punpckldq); |
| 7278 | |
| 7279 | return As<Long1>(RValue<MMX>(Nucleus::createCall(punpckldq, As<MMX>(x).value, As<MMX>(y).value))); |
| 7280 | } |
| 7281 | |
| 7282 | RValue<Long1> punpckhdq(RValue<Int2> x, RValue<Int2> y) |
| 7283 | { |
| 7284 | Module *module = Nucleus::getModule(); |
| 7285 | llvm::Function *punpckhdq = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_punpckhdq); |
| 7286 | |
| 7287 | return As<Long1>(RValue<MMX>(Nucleus::createCall(punpckhdq, As<MMX>(x).value, As<MMX>(y).value))); |
| 7288 | } |
| 7289 | |
| 7290 | RValue<Short4> punpcklbw(RValue<Byte8> x, RValue<Byte8> y) |
| 7291 | { |
| 7292 | Module *module = Nucleus::getModule(); |
| 7293 | llvm::Function *punpcklbw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_punpcklbw); |
| 7294 | |
| 7295 | return As<Short4>(RValue<MMX>(Nucleus::createCall(punpcklbw, As<MMX>(x).value, As<MMX>(y).value))); |
| 7296 | } |
| 7297 | |
| 7298 | RValue<Short4> punpckhbw(RValue<Byte8> x, RValue<Byte8> y) |
| 7299 | { |
| 7300 | Module *module = Nucleus::getModule(); |
| 7301 | llvm::Function *punpckhbw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_punpckhbw); |
| 7302 | |
| 7303 | return As<Short4>(RValue<MMX>(Nucleus::createCall(punpckhbw, As<MMX>(x).value, As<MMX>(y).value))); |
| 7304 | } |
| 7305 | |
| 7306 | RValue<Byte8> paddb(RValue<Byte8> x, RValue<Byte8> y) |
| 7307 | { |
| 7308 | Module *module = Nucleus::getModule(); |
| 7309 | llvm::Function *paddb = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_padd_b); |
| 7310 | |
| 7311 | return As<Byte8>(RValue<MMX>(Nucleus::createCall(paddb, As<MMX>(x).value, As<MMX>(y).value))); |
| 7312 | } |
| 7313 | |
| 7314 | RValue<Byte8> psubb(RValue<Byte8> x, RValue<Byte8> y) |
| 7315 | { |
| 7316 | Module *module = Nucleus::getModule(); |
| 7317 | llvm::Function *psubb = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_psub_b); |
| 7318 | |
| 7319 | return As<Byte8>(RValue<MMX>(Nucleus::createCall(psubb, As<MMX>(x).value, As<MMX>(y).value))); |
| 7320 | } |
| 7321 | |
| 7322 | RValue<Int2> paddd(RValue<Int2> x, RValue<Int2> y) |
| 7323 | { |
| 7324 | Module *module = Nucleus::getModule(); |
| 7325 | llvm::Function *paddd = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_padd_d); |
| 7326 | |
| 7327 | return As<Int2>(RValue<MMX>(Nucleus::createCall(paddd, As<MMX>(x).value, As<MMX>(y).value))); |
| 7328 | } |
| 7329 | |
| 7330 | RValue<Int2> psubd(RValue<Int2> x, RValue<Int2> y) |
| 7331 | { |
| 7332 | Module *module = Nucleus::getModule(); |
| 7333 | llvm::Function *psubd = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_psub_d); |
| 7334 | |
| 7335 | return As<Int2>(RValue<MMX>(Nucleus::createCall(psubd, As<MMX>(x).value, As<MMX>(y).value))); |
| 7336 | } |
| 7337 | |
| 7338 | RValue<UShort4> pavgw(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7339 | { |
| 7340 | Module *module = Nucleus::getModule(); |
| 7341 | llvm::Function *pavgw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pavg_w); |
| 7342 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7343 | return As<UShort4>(RValue<MMX>(Nucleus::createCall(pavgw, As<MMX>(x).value, As<MMX>(y).value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7344 | } |
| 7345 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7346 | RValue<Short4> pmaxsw(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7347 | { |
| 7348 | Module *module = Nucleus::getModule(); |
| 7349 | llvm::Function *pmaxsw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pmaxs_w); |
| 7350 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7351 | return As<Short4>(RValue<MMX>(Nucleus::createCall(pmaxsw, As<MMX>(x).value, As<MMX>(y).value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7352 | } |
| 7353 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7354 | RValue<Short4> pminsw(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7355 | { |
| 7356 | Module *module = Nucleus::getModule(); |
| 7357 | llvm::Function *pminsw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pmins_w); |
| 7358 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7359 | return As<Short4>(RValue<MMX>(Nucleus::createCall(pminsw, As<MMX>(x).value, As<MMX>(y).value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7360 | } |
| 7361 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7362 | RValue<Short4> pcmpgtw(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7363 | { |
| 7364 | Module *module = Nucleus::getModule(); |
| 7365 | llvm::Function *pcmpgtw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pcmpgt_w); |
| 7366 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7367 | return As<Short4>(RValue<MMX>(Nucleus::createCall(pcmpgtw, As<MMX>(x).value, As<MMX>(y).value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7368 | } |
| 7369 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7370 | RValue<Short4> pcmpeqw(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7371 | { |
| 7372 | Module *module = Nucleus::getModule(); |
| 7373 | llvm::Function *pcmpeqw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pcmpeq_w); |
| 7374 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7375 | return As<Short4>(RValue<MMX>(Nucleus::createCall(pcmpeqw, As<MMX>(x).value, As<MMX>(y).value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7376 | } |
| 7377 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7378 | RValue<Byte8> pcmpgtb(RValue<SByte8> x, RValue<SByte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7379 | { |
| 7380 | Module *module = Nucleus::getModule(); |
| 7381 | llvm::Function *pcmpgtb = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pcmpgt_b); |
| 7382 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7383 | return As<Byte8>(RValue<MMX>(Nucleus::createCall(pcmpgtb, As<MMX>(x).value, As<MMX>(y).value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7384 | } |
| 7385 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7386 | RValue<Byte8> pcmpeqb(RValue<Byte8> x, RValue<Byte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7387 | { |
| 7388 | Module *module = Nucleus::getModule(); |
| 7389 | llvm::Function *pcmpeqb = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pcmpeq_b); |
| 7390 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7391 | return As<Byte8>(RValue<MMX>(Nucleus::createCall(pcmpeqb, As<MMX>(x).value, As<MMX>(y).value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7392 | } |
| 7393 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7394 | RValue<Short4> packssdw(RValue<Int2> x, RValue<Int2> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7395 | { |
| 7396 | Module *module = Nucleus::getModule(); |
| 7397 | llvm::Function *packssdw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_packssdw); |
| 7398 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7399 | return As<Short4>(RValue<MMX>(Nucleus::createCall(packssdw, As<MMX>(x).value, As<MMX>(y).value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7400 | } |
| 7401 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7402 | RValue<Short8> packssdw(RValue<Int4> x, RValue<Int4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7403 | { |
| 7404 | if(CPUID::supportsSSE2()) |
| 7405 | { |
| 7406 | Module *module = Nucleus::getModule(); |
| 7407 | llvm::Function *packssdw = Intrinsic::getDeclaration(module, Intrinsic::x86_sse2_packssdw_128); |
| 7408 | |
| 7409 | return RValue<Short8>(Nucleus::createCall(packssdw, x.value, y.value)); |
| 7410 | } |
| 7411 | else |
| 7412 | { |
| 7413 | Int2 loX = Int2(x); |
| 7414 | Int2 hiX = Int2(Swizzle(x, 0xEE)); |
| 7415 | |
| 7416 | Int2 loY = Int2(y); |
| 7417 | Int2 hiY = Int2(Swizzle(y, 0xEE)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7418 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7419 | Short4 lo = x86::packssdw(loX, hiX); |
| 7420 | Short4 hi = x86::packssdw(loY, hiY); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7421 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7422 | return Concatenate(lo, hi); |
| 7423 | } |
| 7424 | } |
| 7425 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7426 | RValue<SByte8> packsswb(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7427 | { |
| 7428 | Module *module = Nucleus::getModule(); |
| 7429 | llvm::Function *packsswb = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_packsswb); |
| 7430 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7431 | return As<SByte8>(RValue<MMX>(Nucleus::createCall(packsswb, As<MMX>(x).value, As<MMX>(y).value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7432 | } |
| 7433 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7434 | RValue<Byte8> packuswb(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7435 | { |
| 7436 | Module *module = Nucleus::getModule(); |
| 7437 | llvm::Function *packuswb = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_packuswb); |
| 7438 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7439 | return As<Byte8>(RValue<MMX>(Nucleus::createCall(packuswb, As<MMX>(x).value, As<MMX>(y).value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7440 | } |
| 7441 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7442 | RValue<UShort8> packusdw(RValue<UInt4> x, RValue<UInt4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7443 | { |
| 7444 | if(CPUID::supportsSSE4_1()) |
| 7445 | { |
| 7446 | Module *module = Nucleus::getModule(); |
| 7447 | llvm::Function *packusdw = Intrinsic::getDeclaration(module, Intrinsic::x86_sse41_packusdw); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7448 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7449 | return RValue<UShort8>(Nucleus::createCall(packusdw, x.value, y.value)); |
| 7450 | } |
| 7451 | else |
| 7452 | { |
| 7453 | // FIXME: Not an exact replacement! |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7454 | 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] | 7455 | } |
| 7456 | } |
| 7457 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7458 | RValue<UShort4> psrlw(RValue<UShort4> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7459 | { |
| 7460 | Module *module = Nucleus::getModule(); |
| 7461 | llvm::Function *psrlw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_psrli_w); |
| 7462 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7463 | return As<UShort4>(RValue<MMX>(Nucleus::createCall(psrlw, As<MMX>(x).value, Nucleus::createConstantInt(y)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7464 | } |
| 7465 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7466 | RValue<UShort8> psrlw(RValue<UShort8> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7467 | { |
| 7468 | Module *module = Nucleus::getModule(); |
| 7469 | llvm::Function *psrlw = Intrinsic::getDeclaration(module, Intrinsic::x86_sse2_psrli_w); |
| 7470 | |
| 7471 | return RValue<UShort8>(Nucleus::createCall(psrlw, x.value, Nucleus::createConstantInt(y))); |
| 7472 | } |
| 7473 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7474 | RValue<Short4> psraw(RValue<Short4> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7475 | { |
| 7476 | Module *module = Nucleus::getModule(); |
| 7477 | llvm::Function *psraw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_psrai_w); |
| 7478 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7479 | return As<Short4>(RValue<MMX>(Nucleus::createCall(psraw, As<MMX>(x).value, Nucleus::createConstantInt(y)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7480 | } |
| 7481 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7482 | RValue<Short8> psraw(RValue<Short8> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7483 | { |
| 7484 | Module *module = Nucleus::getModule(); |
| 7485 | llvm::Function *psraw = Intrinsic::getDeclaration(module, Intrinsic::x86_sse2_psrai_w); |
| 7486 | |
| 7487 | return RValue<Short8>(Nucleus::createCall(psraw, x.value, Nucleus::createConstantInt(y))); |
| 7488 | } |
| 7489 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7490 | RValue<Short4> psllw(RValue<Short4> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7491 | { |
| 7492 | Module *module = Nucleus::getModule(); |
| 7493 | llvm::Function *psllw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pslli_w); |
| 7494 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7495 | return As<Short4>(RValue<MMX>(Nucleus::createCall(psllw, As<MMX>(x).value, Nucleus::createConstantInt(y)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7496 | } |
| 7497 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7498 | RValue<Short8> psllw(RValue<Short8> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7499 | { |
| 7500 | Module *module = Nucleus::getModule(); |
| 7501 | llvm::Function *psllw = Intrinsic::getDeclaration(module, Intrinsic::x86_sse2_pslli_w); |
| 7502 | |
| 7503 | return RValue<Short8>(Nucleus::createCall(psllw, x.value, Nucleus::createConstantInt(y))); |
| 7504 | } |
| 7505 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7506 | RValue<Int2> pslld(RValue<Int2> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7507 | { |
| 7508 | Module *module = Nucleus::getModule(); |
| 7509 | llvm::Function *pslld = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pslli_d); |
| 7510 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7511 | return As<Int2>(RValue<MMX>(Nucleus::createCall(pslld, As<MMX>(x).value, Nucleus::createConstantInt(y)))); |
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<Int4> pslld(RValue<Int4> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7515 | { |
| 7516 | if(CPUID::supportsSSE2()) |
| 7517 | { |
| 7518 | Module *module = Nucleus::getModule(); |
| 7519 | llvm::Function *pslld = Intrinsic::getDeclaration(module, Intrinsic::x86_sse2_pslli_d); |
| 7520 | |
| 7521 | return RValue<Int4>(Nucleus::createCall(pslld, x.value, Nucleus::createConstantInt(y))); |
| 7522 | } |
| 7523 | else |
| 7524 | { |
| 7525 | Int2 lo = Int2(x); |
| 7526 | Int2 hi = Int2(Swizzle(x, 0xEE)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7527 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7528 | lo = x86::pslld(lo, y); |
| 7529 | hi = x86::pslld(hi, y); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7530 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7531 | return Concatenate(lo, hi); |
| 7532 | } |
| 7533 | } |
| 7534 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7535 | RValue<Int2> psrad(RValue<Int2> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7536 | { |
| 7537 | Module *module = Nucleus::getModule(); |
| 7538 | llvm::Function *psrad = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_psrai_d); |
| 7539 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7540 | return As<Int2>(RValue<MMX>(Nucleus::createCall(psrad, As<MMX>(x).value, Nucleus::createConstantInt(y)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7541 | } |
| 7542 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7543 | RValue<Int4> psrad(RValue<Int4> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7544 | { |
| 7545 | if(CPUID::supportsSSE2()) |
| 7546 | { |
| 7547 | Module *module = Nucleus::getModule(); |
| 7548 | llvm::Function *psrad = Intrinsic::getDeclaration(module, Intrinsic::x86_sse2_psrai_d); |
| 7549 | |
| 7550 | return RValue<Int4>(Nucleus::createCall(psrad, x.value, Nucleus::createConstantInt(y))); |
| 7551 | } |
| 7552 | else |
| 7553 | { |
| 7554 | Int2 lo = Int2(x); |
| 7555 | Int2 hi = Int2(Swizzle(x, 0xEE)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7556 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7557 | lo = x86::psrad(lo, y); |
| 7558 | hi = x86::psrad(hi, y); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7559 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7560 | return Concatenate(lo, hi); |
| 7561 | } |
| 7562 | } |
| 7563 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7564 | RValue<UInt2> psrld(RValue<UInt2> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7565 | { |
| 7566 | Module *module = Nucleus::getModule(); |
| 7567 | llvm::Function *psrld = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_psrli_d); |
| 7568 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7569 | return As<UInt2>(RValue<MMX>(Nucleus::createCall(psrld, As<MMX>(x).value, Nucleus::createConstantInt(y)))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7570 | } |
| 7571 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7572 | RValue<UInt4> psrld(RValue<UInt4> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7573 | { |
| 7574 | if(CPUID::supportsSSE2()) |
| 7575 | { |
| 7576 | Module *module = Nucleus::getModule(); |
| 7577 | llvm::Function *psrld = Intrinsic::getDeclaration(module, Intrinsic::x86_sse2_psrli_d); |
| 7578 | |
| 7579 | return RValue<UInt4>(Nucleus::createCall(psrld, x.value, Nucleus::createConstantInt(y))); |
| 7580 | } |
| 7581 | else |
| 7582 | { |
| 7583 | UInt2 lo = As<UInt2>(Int2(As<Int4>(x))); |
| 7584 | UInt2 hi = As<UInt2>(Int2(Swizzle(As<Int4>(x), 0xEE))); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7585 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7586 | lo = x86::psrld(lo, y); |
| 7587 | hi = x86::psrld(hi, y); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7588 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7589 | return Concatenate(lo, hi); |
| 7590 | } |
| 7591 | } |
| 7592 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7593 | RValue<UShort4> psrlw(RValue<UShort4> x, RValue<Long1> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7594 | { |
| 7595 | Module *module = Nucleus::getModule(); |
| 7596 | llvm::Function *psrlw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_psrl_w); |
| 7597 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7598 | return As<UShort4>(RValue<MMX>(Nucleus::createCall(psrlw, As<MMX>(x).value, As<MMX>(y).value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7599 | } |
| 7600 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7601 | RValue<Short4> psraw(RValue<Short4> x, RValue<Long1> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7602 | { |
| 7603 | Module *module = Nucleus::getModule(); |
| 7604 | llvm::Function *psraw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_psra_w); |
| 7605 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7606 | return As<Short4>(RValue<MMX>(Nucleus::createCall(psraw, As<MMX>(x).value, As<MMX>(y).value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7607 | } |
| 7608 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7609 | RValue<Short4> psllw(RValue<Short4> x, RValue<Long1> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7610 | { |
| 7611 | Module *module = Nucleus::getModule(); |
| 7612 | llvm::Function *psllw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_psll_w); |
| 7613 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7614 | return As<Short4>(RValue<MMX>(Nucleus::createCall(psllw, As<MMX>(x).value, As<MMX>(y).value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7615 | } |
| 7616 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7617 | RValue<Int2> pslld(RValue<Int2> x, RValue<Long1> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7618 | { |
| 7619 | Module *module = Nucleus::getModule(); |
| 7620 | llvm::Function *pslld = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_psll_d); |
| 7621 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7622 | return As<Int2>(RValue<MMX>(Nucleus::createCall(pslld, As<MMX>(x).value, As<MMX>(y).value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7623 | } |
| 7624 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7625 | RValue<UInt2> psrld(RValue<UInt2> x, RValue<Long1> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7626 | { |
| 7627 | Module *module = Nucleus::getModule(); |
| 7628 | llvm::Function *psrld = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_psrl_d); |
| 7629 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7630 | return As<UInt2>(RValue<MMX>(Nucleus::createCall(psrld, As<MMX>(x).value, As<MMX>(y).value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7631 | } |
| 7632 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7633 | RValue<Int2> psrad(RValue<Int2> x, RValue<Long1> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7634 | { |
| 7635 | Module *module = Nucleus::getModule(); |
| 7636 | llvm::Function *psrld = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_psra_d); |
| 7637 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7638 | return As<Int2>(RValue<MMX>(Nucleus::createCall(psrld, As<MMX>(x).value, As<MMX>(y).value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7639 | } |
| 7640 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7641 | RValue<Int4> pmaxsd(RValue<Int4> x, RValue<Int4> y) |
| 7642 | { |
| 7643 | Module *module = Nucleus::getModule(); |
| 7644 | llvm::Function *pmaxsd = Intrinsic::getDeclaration(module, Intrinsic::x86_sse41_pmaxsd); |
| 7645 | |
| 7646 | return RValue<Int4>(Nucleus::createCall(pmaxsd, x.value, y.value)); |
| 7647 | } |
| 7648 | |
| 7649 | RValue<Int4> pminsd(RValue<Int4> x, RValue<Int4> y) |
| 7650 | { |
| 7651 | Module *module = Nucleus::getModule(); |
| 7652 | llvm::Function *pminsd = Intrinsic::getDeclaration(module, Intrinsic::x86_sse41_pminsd); |
| 7653 | |
| 7654 | return RValue<Int4>(Nucleus::createCall(pminsd, x.value, y.value)); |
| 7655 | } |
| 7656 | |
| 7657 | RValue<UInt4> pmaxud(RValue<UInt4> x, RValue<UInt4> y) |
| 7658 | { |
| 7659 | Module *module = Nucleus::getModule(); |
| 7660 | llvm::Function *pmaxud = Intrinsic::getDeclaration(module, Intrinsic::x86_sse41_pmaxud); |
| 7661 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7662 | return RValue<UInt4>(Nucleus::createCall(pmaxud, x.value, y.value)); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7663 | } |
| 7664 | |
| 7665 | RValue<UInt4> pminud(RValue<UInt4> x, RValue<UInt4> y) |
| 7666 | { |
| 7667 | Module *module = Nucleus::getModule(); |
| 7668 | llvm::Function *pminud = Intrinsic::getDeclaration(module, Intrinsic::x86_sse41_pminud); |
| 7669 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7670 | return RValue<UInt4>(Nucleus::createCall(pminud, x.value, y.value)); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7671 | } |
| 7672 | |
| 7673 | RValue<Short4> pmulhw(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7674 | { |
| 7675 | Module *module = Nucleus::getModule(); |
| 7676 | llvm::Function *pmulhw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pmulh_w); |
| 7677 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7678 | return As<Short4>(RValue<MMX>(Nucleus::createCall(pmulhw, As<MMX>(x).value, As<MMX>(y).value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7679 | } |
| 7680 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7681 | RValue<UShort4> pmulhuw(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7682 | { |
| 7683 | Module *module = Nucleus::getModule(); |
| 7684 | llvm::Function *pmulhuw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pmulhu_w); |
| 7685 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7686 | return As<UShort4>(RValue<MMX>(Nucleus::createCall(pmulhuw, As<MMX>(x).value, As<MMX>(y).value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7687 | } |
| 7688 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7689 | RValue<Int2> pmaddwd(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7690 | { |
| 7691 | Module *module = Nucleus::getModule(); |
| 7692 | llvm::Function *pmaddwd = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pmadd_wd); |
| 7693 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7694 | return As<Int2>(RValue<MMX>(Nucleus::createCall(pmaddwd, As<MMX>(x).value, As<MMX>(y).value))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7695 | } |
| 7696 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7697 | RValue<Short8> pmulhw(RValue<Short8> x, RValue<Short8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7698 | { |
| 7699 | Module *module = Nucleus::getModule(); |
| 7700 | llvm::Function *pmulhw = Intrinsic::getDeclaration(module, Intrinsic::x86_sse2_pmulh_w); |
| 7701 | |
| 7702 | return RValue<Short8>(Nucleus::createCall(pmulhw, x.value, y.value)); |
| 7703 | } |
| 7704 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7705 | RValue<UShort8> pmulhuw(RValue<UShort8> x, RValue<UShort8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7706 | { |
| 7707 | Module *module = Nucleus::getModule(); |
| 7708 | llvm::Function *pmulhuw = Intrinsic::getDeclaration(module, Intrinsic::x86_sse2_pmulhu_w); |
| 7709 | |
| 7710 | return RValue<UShort8>(Nucleus::createCall(pmulhuw, x.value, y.value)); |
| 7711 | } |
| 7712 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7713 | RValue<Int4> pmaddwd(RValue<Short8> x, RValue<Short8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7714 | { |
| 7715 | Module *module = Nucleus::getModule(); |
| 7716 | llvm::Function *pmaddwd = Intrinsic::getDeclaration(module, Intrinsic::x86_sse2_pmadd_wd); |
| 7717 | |
| 7718 | return RValue<Int4>(Nucleus::createCall(pmaddwd, x.value, y.value)); |
| 7719 | } |
| 7720 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7721 | RValue<Int> movmskps(RValue<Float4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7722 | { |
| 7723 | Module *module = Nucleus::getModule(); |
| 7724 | llvm::Function *movmskps = Intrinsic::getDeclaration(module, Intrinsic::x86_sse_movmsk_ps); |
| 7725 | |
| 7726 | return RValue<Int>(Nucleus::createCall(movmskps, x.value)); |
| 7727 | } |
| 7728 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7729 | RValue<Int> pmovmskb(RValue<Byte8> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7730 | { |
| 7731 | Module *module = Nucleus::getModule(); |
| 7732 | llvm::Function *pmovmskb = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pmovmskb); |
| 7733 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7734 | return RValue<Int>(Nucleus::createCall(pmovmskb, As<MMX>(x).value)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7735 | } |
| 7736 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7737 | //RValue<Int2> movd(RValue<Pointer<Int> > x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7738 | //{ |
| 7739 | // Value *element = Nucleus::createLoad(x.value); |
| 7740 | |
| 7741 | //// Value *int2 = UndefValue::get(Int2::getType()); |
| 7742 | //// int2 = Nucleus::createInsertElement(int2, element, ConstantInt::get(Int::getType(), 0)); |
| 7743 | |
| 7744 | // Value *int2 = Nucleus::createBitCast(Nucleus::createZExt(element, Long::getType()), Int2::getType()); |
| 7745 | |
| 7746 | // return RValue<Int2>(int2); |
| 7747 | //} |
| 7748 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7749 | //RValue<Int2> movdq2q(RValue<Int4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7750 | //{ |
| 7751 | // Value *long2 = Nucleus::createBitCast(x.value, Long2::getType()); |
| 7752 | // Value *element = Nucleus::createExtractElement(long2, ConstantInt::get(Int::getType(), 0)); |
| 7753 | |
| 7754 | // return RValue<Int2>(Nucleus::createBitCast(element, Int2::getType())); |
| 7755 | //} |
| 7756 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7757 | RValue<Int4> pmovzxbd(RValue<Int4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7758 | { |
| 7759 | Module *module = Nucleus::getModule(); |
| 7760 | llvm::Function *pmovzxbd = Intrinsic::getDeclaration(module, Intrinsic::x86_sse41_pmovzxbd); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7761 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7762 | return RValue<Int4>(Nucleus::createCall(pmovzxbd, Nucleus::createBitCast(x.value, Byte16::getType()))); |
| 7763 | } |
| 7764 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7765 | RValue<Int4> pmovsxbd(RValue<Int4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7766 | { |
| 7767 | Module *module = Nucleus::getModule(); |
| 7768 | llvm::Function *pmovsxbd = Intrinsic::getDeclaration(module, Intrinsic::x86_sse41_pmovsxbd); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7769 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7770 | return RValue<Int4>(Nucleus::createCall(pmovsxbd, Nucleus::createBitCast(x.value, SByte16::getType()))); |
| 7771 | } |
| 7772 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7773 | RValue<Int4> pmovzxwd(RValue<Int4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7774 | { |
| 7775 | Module *module = Nucleus::getModule(); |
| 7776 | llvm::Function *pmovzxwd = Intrinsic::getDeclaration(module, Intrinsic::x86_sse41_pmovzxwd); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7777 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7778 | return RValue<Int4>(Nucleus::createCall(pmovzxwd, Nucleus::createBitCast(x.value, UShort8::getType()))); |
| 7779 | } |
| 7780 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7781 | RValue<Int4> pmovsxwd(RValue<Int4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7782 | { |
| 7783 | Module *module = Nucleus::getModule(); |
| 7784 | llvm::Function *pmovsxwd = Intrinsic::getDeclaration(module, Intrinsic::x86_sse41_pmovsxwd); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7785 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7786 | return RValue<Int4>(Nucleus::createCall(pmovsxwd, Nucleus::createBitCast(x.value, Short8::getType()))); |
| 7787 | } |
| 7788 | |
| 7789 | void emms() |
| 7790 | { |
| 7791 | Module *module = Nucleus::getModule(); |
| 7792 | llvm::Function *emms = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_emms); |
| 7793 | |
| 7794 | Nucleus::createCall(emms); |
| 7795 | } |
| 7796 | } |
| 7797 | } |