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 | |
Alexis Hetu | 77dfab4 | 2015-11-23 13:31:22 -0500 | [diff] [blame^] | 936 | Byte::Byte(RValue<UInt> cast) |
| 937 | { |
| 938 | Value *integer = Nucleus::createTrunc(cast.value, Byte::getType()); |
| 939 | |
| 940 | storeValue(integer); |
| 941 | } |
| 942 | |
| 943 | Byte::Byte(RValue<UShort> cast) |
| 944 | { |
| 945 | Value *integer = Nucleus::createTrunc(cast.value, Byte::getType()); |
| 946 | |
| 947 | storeValue(integer); |
| 948 | } |
| 949 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 950 | Byte::Byte() |
| 951 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 952 | } |
| 953 | |
| 954 | Byte::Byte(int x) |
| 955 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 956 | storeValue(Nucleus::createConstantByte((unsigned char)x)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 957 | } |
| 958 | |
| 959 | Byte::Byte(unsigned char x) |
| 960 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 961 | storeValue(Nucleus::createConstantByte(x)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 962 | } |
| 963 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 964 | Byte::Byte(RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 965 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 966 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 967 | } |
| 968 | |
| 969 | Byte::Byte(const Byte &rhs) |
| 970 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 971 | Value *value = rhs.loadValue(); |
| 972 | storeValue(value); |
| 973 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 974 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 975 | Byte::Byte(const Reference<Byte> &rhs) |
| 976 | { |
| 977 | Value *value = rhs.loadValue(); |
| 978 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 979 | } |
| 980 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 981 | RValue<Byte> Byte::operator=(RValue<Byte> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 982 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 983 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 984 | |
| 985 | return rhs; |
| 986 | } |
| 987 | |
| 988 | RValue<Byte> Byte::operator=(const Byte &rhs) const |
| 989 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 990 | Value *value = rhs.loadValue(); |
| 991 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 992 | |
| 993 | return RValue<Byte>(value); |
| 994 | } |
| 995 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 996 | RValue<Byte> Byte::operator=(const Reference<Byte> &rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 997 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 998 | Value *value = rhs.loadValue(); |
| 999 | storeValue(value); |
| 1000 | |
| 1001 | return RValue<Byte>(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1002 | } |
| 1003 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1004 | RValue<Byte> operator+(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1005 | { |
| 1006 | return RValue<Byte>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 1007 | } |
| 1008 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1009 | RValue<Byte> operator-(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1010 | { |
| 1011 | return RValue<Byte>(Nucleus::createSub(lhs.value, rhs.value)); |
| 1012 | } |
| 1013 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1014 | RValue<Byte> operator*(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1015 | { |
| 1016 | return RValue<Byte>(Nucleus::createMul(lhs.value, rhs.value)); |
| 1017 | } |
| 1018 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1019 | RValue<Byte> operator/(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1020 | { |
| 1021 | return RValue<Byte>(Nucleus::createUDiv(lhs.value, rhs.value)); |
| 1022 | } |
| 1023 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1024 | RValue<Byte> operator%(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1025 | { |
| 1026 | return RValue<Byte>(Nucleus::createURem(lhs.value, rhs.value)); |
| 1027 | } |
| 1028 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1029 | RValue<Byte> operator&(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1030 | { |
| 1031 | return RValue<Byte>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 1032 | } |
| 1033 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1034 | RValue<Byte> operator|(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1035 | { |
| 1036 | return RValue<Byte>(Nucleus::createOr(lhs.value, rhs.value)); |
| 1037 | } |
| 1038 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1039 | RValue<Byte> operator^(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1040 | { |
| 1041 | return RValue<Byte>(Nucleus::createXor(lhs.value, rhs.value)); |
| 1042 | } |
| 1043 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1044 | RValue<Byte> operator<<(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1045 | { |
| 1046 | return RValue<Byte>(Nucleus::createShl(lhs.value, rhs.value)); |
| 1047 | } |
| 1048 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1049 | RValue<Byte> operator>>(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1050 | { |
| 1051 | return RValue<Byte>(Nucleus::createLShr(lhs.value, rhs.value)); |
| 1052 | } |
| 1053 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1054 | RValue<Byte> operator+=(const Byte &lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1055 | { |
| 1056 | return lhs = lhs + rhs; |
| 1057 | } |
| 1058 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1059 | RValue<Byte> operator-=(const Byte &lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1060 | { |
| 1061 | return lhs = lhs - rhs; |
| 1062 | } |
| 1063 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1064 | RValue<Byte> operator*=(const Byte &lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1065 | { |
| 1066 | return lhs = lhs * rhs; |
| 1067 | } |
| 1068 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1069 | RValue<Byte> operator/=(const Byte &lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1070 | { |
| 1071 | return lhs = lhs / rhs; |
| 1072 | } |
| 1073 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1074 | RValue<Byte> operator%=(const Byte &lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1075 | { |
| 1076 | return lhs = lhs % rhs; |
| 1077 | } |
| 1078 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1079 | RValue<Byte> operator&=(const Byte &lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1080 | { |
| 1081 | return lhs = lhs & rhs; |
| 1082 | } |
| 1083 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1084 | RValue<Byte> operator|=(const Byte &lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1085 | { |
| 1086 | return lhs = lhs | rhs; |
| 1087 | } |
| 1088 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1089 | RValue<Byte> operator^=(const Byte &lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1090 | { |
| 1091 | return lhs = lhs ^ rhs; |
| 1092 | } |
| 1093 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1094 | RValue<Byte> operator<<=(const Byte &lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1095 | { |
| 1096 | return lhs = lhs << rhs; |
| 1097 | } |
| 1098 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1099 | RValue<Byte> operator>>=(const Byte &lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1100 | { |
| 1101 | return lhs = lhs >> rhs; |
| 1102 | } |
| 1103 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1104 | RValue<Byte> operator+(RValue<Byte> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1105 | { |
| 1106 | return val; |
| 1107 | } |
| 1108 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1109 | RValue<Byte> operator-(RValue<Byte> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1110 | { |
| 1111 | return RValue<Byte>(Nucleus::createNeg(val.value)); |
| 1112 | } |
| 1113 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1114 | RValue<Byte> operator~(RValue<Byte> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1115 | { |
| 1116 | return RValue<Byte>(Nucleus::createNot(val.value)); |
| 1117 | } |
| 1118 | |
| 1119 | RValue<Byte> operator++(const Byte &val, int) // Post-increment |
| 1120 | { |
| 1121 | RValue<Byte> res = val; |
| 1122 | |
| 1123 | Value *inc = Nucleus::createAdd(res.value, Nucleus::createConstantByte((unsigned char)1)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1124 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1125 | |
| 1126 | return res; |
| 1127 | } |
| 1128 | |
| 1129 | const Byte &operator++(const Byte &val) // Pre-increment |
| 1130 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1131 | Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantByte((unsigned char)1)); |
| 1132 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1133 | |
| 1134 | return val; |
| 1135 | } |
| 1136 | |
| 1137 | RValue<Byte> operator--(const Byte &val, int) // Post-decrement |
| 1138 | { |
| 1139 | RValue<Byte> res = val; |
| 1140 | |
| 1141 | Value *inc = Nucleus::createSub(res.value, Nucleus::createConstantByte((unsigned char)1)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1142 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1143 | |
| 1144 | return res; |
| 1145 | } |
| 1146 | |
| 1147 | const Byte &operator--(const Byte &val) // Pre-decrement |
| 1148 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1149 | Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantByte((unsigned char)1)); |
| 1150 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1151 | |
| 1152 | return val; |
| 1153 | } |
| 1154 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1155 | RValue<Bool> operator<(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1156 | { |
| 1157 | return RValue<Bool>(Nucleus::createICmpULT(lhs.value, rhs.value)); |
| 1158 | } |
| 1159 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1160 | RValue<Bool> operator<=(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1161 | { |
| 1162 | return RValue<Bool>(Nucleus::createICmpULE(lhs.value, rhs.value)); |
| 1163 | } |
| 1164 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1165 | RValue<Bool> operator>(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1166 | { |
| 1167 | return RValue<Bool>(Nucleus::createICmpUGT(lhs.value, rhs.value)); |
| 1168 | } |
| 1169 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1170 | RValue<Bool> operator>=(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1171 | { |
| 1172 | return RValue<Bool>(Nucleus::createICmpUGE(lhs.value, rhs.value)); |
| 1173 | } |
| 1174 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1175 | RValue<Bool> operator!=(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1176 | { |
| 1177 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value)); |
| 1178 | } |
| 1179 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1180 | RValue<Bool> operator==(RValue<Byte> lhs, RValue<Byte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1181 | { |
| 1182 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value)); |
| 1183 | } |
| 1184 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1185 | Type *Byte::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1186 | { |
| 1187 | return Type::getInt8Ty(*Nucleus::getContext()); |
| 1188 | } |
| 1189 | |
| 1190 | SByte::SByte(Argument *argument) |
| 1191 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1192 | storeValue(argument); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1193 | } |
| 1194 | |
Alexis Hetu | 77dfab4 | 2015-11-23 13:31:22 -0500 | [diff] [blame^] | 1195 | SByte::SByte(RValue<Int> cast) |
| 1196 | { |
| 1197 | Value *integer = Nucleus::createTrunc(cast.value, SByte::getType()); |
| 1198 | |
| 1199 | storeValue(integer); |
| 1200 | } |
| 1201 | |
| 1202 | SByte::SByte(RValue<Short> cast) |
| 1203 | { |
| 1204 | Value *integer = Nucleus::createTrunc(cast.value, SByte::getType()); |
| 1205 | |
| 1206 | storeValue(integer); |
| 1207 | } |
| 1208 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1209 | SByte::SByte() |
| 1210 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1211 | } |
| 1212 | |
| 1213 | SByte::SByte(signed char x) |
| 1214 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1215 | storeValue(Nucleus::createConstantByte(x)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1216 | } |
| 1217 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1218 | SByte::SByte(RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1219 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1220 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1221 | } |
| 1222 | |
| 1223 | SByte::SByte(const SByte &rhs) |
| 1224 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1225 | Value *value = rhs.loadValue(); |
| 1226 | storeValue(value); |
| 1227 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1228 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1229 | SByte::SByte(const Reference<SByte> &rhs) |
| 1230 | { |
| 1231 | Value *value = rhs.loadValue(); |
| 1232 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1233 | } |
| 1234 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1235 | RValue<SByte> SByte::operator=(RValue<SByte> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1236 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1237 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1238 | |
| 1239 | return rhs; |
| 1240 | } |
| 1241 | |
| 1242 | RValue<SByte> SByte::operator=(const SByte &rhs) const |
| 1243 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1244 | Value *value = rhs.loadValue(); |
| 1245 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1246 | |
| 1247 | return RValue<SByte>(value); |
| 1248 | } |
| 1249 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1250 | RValue<SByte> SByte::operator=(const Reference<SByte> &rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1251 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1252 | Value *value = rhs.loadValue(); |
| 1253 | storeValue(value); |
| 1254 | |
| 1255 | return RValue<SByte>(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1256 | } |
| 1257 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1258 | RValue<SByte> operator+(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1259 | { |
| 1260 | return RValue<SByte>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 1261 | } |
| 1262 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1263 | RValue<SByte> operator-(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1264 | { |
| 1265 | return RValue<SByte>(Nucleus::createSub(lhs.value, rhs.value)); |
| 1266 | } |
| 1267 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1268 | RValue<SByte> operator*(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1269 | { |
| 1270 | return RValue<SByte>(Nucleus::createMul(lhs.value, rhs.value)); |
| 1271 | } |
| 1272 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1273 | RValue<SByte> operator/(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1274 | { |
| 1275 | return RValue<SByte>(Nucleus::createSDiv(lhs.value, rhs.value)); |
| 1276 | } |
| 1277 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1278 | RValue<SByte> operator%(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1279 | { |
| 1280 | return RValue<SByte>(Nucleus::createSRem(lhs.value, rhs.value)); |
| 1281 | } |
| 1282 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1283 | RValue<SByte> operator&(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1284 | { |
| 1285 | return RValue<SByte>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 1286 | } |
| 1287 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1288 | RValue<SByte> operator|(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1289 | { |
| 1290 | return RValue<SByte>(Nucleus::createOr(lhs.value, rhs.value)); |
| 1291 | } |
| 1292 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1293 | RValue<SByte> operator^(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1294 | { |
| 1295 | return RValue<SByte>(Nucleus::createXor(lhs.value, rhs.value)); |
| 1296 | } |
| 1297 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1298 | RValue<SByte> operator<<(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1299 | { |
| 1300 | return RValue<SByte>(Nucleus::createShl(lhs.value, rhs.value)); |
| 1301 | } |
| 1302 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1303 | RValue<SByte> operator>>(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1304 | { |
| 1305 | return RValue<SByte>(Nucleus::createAShr(lhs.value, rhs.value)); |
| 1306 | } |
| 1307 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1308 | RValue<SByte> operator+=(const SByte &lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1309 | { |
| 1310 | return lhs = lhs + rhs; |
| 1311 | } |
| 1312 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1313 | RValue<SByte> operator-=(const SByte &lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1314 | { |
| 1315 | return lhs = lhs - rhs; |
| 1316 | } |
| 1317 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1318 | RValue<SByte> operator*=(const SByte &lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1319 | { |
| 1320 | return lhs = lhs * rhs; |
| 1321 | } |
| 1322 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1323 | RValue<SByte> operator/=(const SByte &lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1324 | { |
| 1325 | return lhs = lhs / rhs; |
| 1326 | } |
| 1327 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1328 | RValue<SByte> operator%=(const SByte &lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1329 | { |
| 1330 | return lhs = lhs % rhs; |
| 1331 | } |
| 1332 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1333 | RValue<SByte> operator&=(const SByte &lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1334 | { |
| 1335 | return lhs = lhs & rhs; |
| 1336 | } |
| 1337 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1338 | RValue<SByte> operator|=(const SByte &lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1339 | { |
| 1340 | return lhs = lhs | rhs; |
| 1341 | } |
| 1342 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1343 | RValue<SByte> operator^=(const SByte &lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1344 | { |
| 1345 | return lhs = lhs ^ rhs; |
| 1346 | } |
| 1347 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1348 | RValue<SByte> operator<<=(const SByte &lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1349 | { |
| 1350 | return lhs = lhs << rhs; |
| 1351 | } |
| 1352 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1353 | RValue<SByte> operator>>=(const SByte &lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1354 | { |
| 1355 | return lhs = lhs >> rhs; |
| 1356 | } |
| 1357 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1358 | RValue<SByte> operator+(RValue<SByte> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1359 | { |
| 1360 | return val; |
| 1361 | } |
| 1362 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1363 | RValue<SByte> operator-(RValue<SByte> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1364 | { |
| 1365 | return RValue<SByte>(Nucleus::createNeg(val.value)); |
| 1366 | } |
| 1367 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1368 | RValue<SByte> operator~(RValue<SByte> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1369 | { |
| 1370 | return RValue<SByte>(Nucleus::createNot(val.value)); |
| 1371 | } |
| 1372 | |
| 1373 | RValue<SByte> operator++(const SByte &val, int) // Post-increment |
| 1374 | { |
| 1375 | RValue<SByte> res = val; |
| 1376 | |
| 1377 | Value *inc = Nucleus::createAdd(res.value, Nucleus::createConstantByte((signed char)1)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1378 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1379 | |
| 1380 | return res; |
| 1381 | } |
| 1382 | |
| 1383 | const SByte &operator++(const SByte &val) // Pre-increment |
| 1384 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1385 | Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantByte((signed char)1)); |
| 1386 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1387 | |
| 1388 | return val; |
| 1389 | } |
| 1390 | |
| 1391 | RValue<SByte> operator--(const SByte &val, int) // Post-decrement |
| 1392 | { |
| 1393 | RValue<SByte> res = val; |
| 1394 | |
| 1395 | Value *inc = Nucleus::createSub(res.value, Nucleus::createConstantByte((signed char)1)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1396 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1397 | |
| 1398 | return res; |
| 1399 | } |
| 1400 | |
| 1401 | const SByte &operator--(const SByte &val) // Pre-decrement |
| 1402 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1403 | Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantByte((signed char)1)); |
| 1404 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1405 | |
| 1406 | return val; |
| 1407 | } |
| 1408 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1409 | RValue<Bool> operator<(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1410 | { |
| 1411 | return RValue<Bool>(Nucleus::createICmpSLT(lhs.value, rhs.value)); |
| 1412 | } |
| 1413 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1414 | RValue<Bool> operator<=(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1415 | { |
| 1416 | return RValue<Bool>(Nucleus::createICmpSLE(lhs.value, rhs.value)); |
| 1417 | } |
| 1418 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1419 | RValue<Bool> operator>(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1420 | { |
| 1421 | return RValue<Bool>(Nucleus::createICmpSGT(lhs.value, rhs.value)); |
| 1422 | } |
| 1423 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1424 | RValue<Bool> operator>=(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1425 | { |
| 1426 | return RValue<Bool>(Nucleus::createICmpSGE(lhs.value, rhs.value)); |
| 1427 | } |
| 1428 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1429 | RValue<Bool> operator!=(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1430 | { |
| 1431 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value)); |
| 1432 | } |
| 1433 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1434 | RValue<Bool> operator==(RValue<SByte> lhs, RValue<SByte> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1435 | { |
| 1436 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value)); |
| 1437 | } |
| 1438 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1439 | Type *SByte::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1440 | { |
| 1441 | return Type::getInt8Ty(*Nucleus::getContext()); |
| 1442 | } |
| 1443 | |
| 1444 | Short::Short(Argument *argument) |
| 1445 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1446 | storeValue(argument); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1447 | } |
| 1448 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1449 | Short::Short(RValue<Int> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1450 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1451 | Value *integer = Nucleus::createTrunc(cast.value, Short::getType()); |
| 1452 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1453 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1454 | } |
| 1455 | |
| 1456 | Short::Short() |
| 1457 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1458 | } |
| 1459 | |
| 1460 | Short::Short(short x) |
| 1461 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1462 | storeValue(Nucleus::createConstantShort(x)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1463 | } |
| 1464 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1465 | Short::Short(RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1466 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1467 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1468 | } |
| 1469 | |
| 1470 | Short::Short(const Short &rhs) |
| 1471 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1472 | Value *value = rhs.loadValue(); |
| 1473 | storeValue(value); |
| 1474 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1475 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1476 | Short::Short(const Reference<Short> &rhs) |
| 1477 | { |
| 1478 | Value *value = rhs.loadValue(); |
| 1479 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1480 | } |
| 1481 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1482 | RValue<Short> Short::operator=(RValue<Short> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1483 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1484 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1485 | |
| 1486 | return rhs; |
| 1487 | } |
| 1488 | |
| 1489 | RValue<Short> Short::operator=(const Short &rhs) const |
| 1490 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1491 | Value *value = rhs.loadValue(); |
| 1492 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1493 | |
| 1494 | return RValue<Short>(value); |
| 1495 | } |
| 1496 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1497 | RValue<Short> Short::operator=(const Reference<Short> &rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1498 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1499 | Value *value = rhs.loadValue(); |
| 1500 | storeValue(value); |
| 1501 | |
| 1502 | return RValue<Short>(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1503 | } |
| 1504 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1505 | RValue<Short> operator+(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1506 | { |
| 1507 | return RValue<Short>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 1508 | } |
| 1509 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1510 | RValue<Short> operator-(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1511 | { |
| 1512 | return RValue<Short>(Nucleus::createSub(lhs.value, rhs.value)); |
| 1513 | } |
| 1514 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1515 | RValue<Short> operator*(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1516 | { |
| 1517 | return RValue<Short>(Nucleus::createMul(lhs.value, rhs.value)); |
| 1518 | } |
| 1519 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1520 | RValue<Short> operator/(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1521 | { |
| 1522 | return RValue<Short>(Nucleus::createSDiv(lhs.value, rhs.value)); |
| 1523 | } |
| 1524 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1525 | RValue<Short> operator%(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1526 | { |
| 1527 | return RValue<Short>(Nucleus::createSRem(lhs.value, rhs.value)); |
| 1528 | } |
| 1529 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1530 | RValue<Short> operator&(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1531 | { |
| 1532 | return RValue<Short>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 1533 | } |
| 1534 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1535 | RValue<Short> operator|(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1536 | { |
| 1537 | return RValue<Short>(Nucleus::createOr(lhs.value, rhs.value)); |
| 1538 | } |
| 1539 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1540 | RValue<Short> operator^(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1541 | { |
| 1542 | return RValue<Short>(Nucleus::createXor(lhs.value, rhs.value)); |
| 1543 | } |
| 1544 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1545 | RValue<Short> operator<<(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1546 | { |
| 1547 | return RValue<Short>(Nucleus::createShl(lhs.value, rhs.value)); |
| 1548 | } |
| 1549 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1550 | RValue<Short> operator>>(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1551 | { |
| 1552 | return RValue<Short>(Nucleus::createAShr(lhs.value, rhs.value)); |
| 1553 | } |
| 1554 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1555 | RValue<Short> operator+=(const Short &lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1556 | { |
| 1557 | return lhs = lhs + rhs; |
| 1558 | } |
| 1559 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1560 | RValue<Short> operator-=(const Short &lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1561 | { |
| 1562 | return lhs = lhs - rhs; |
| 1563 | } |
| 1564 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1565 | RValue<Short> operator*=(const Short &lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1566 | { |
| 1567 | return lhs = lhs * rhs; |
| 1568 | } |
| 1569 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1570 | RValue<Short> operator/=(const Short &lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1571 | { |
| 1572 | return lhs = lhs / rhs; |
| 1573 | } |
| 1574 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1575 | RValue<Short> operator%=(const Short &lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1576 | { |
| 1577 | return lhs = lhs % rhs; |
| 1578 | } |
| 1579 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1580 | RValue<Short> operator&=(const Short &lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1581 | { |
| 1582 | return lhs = lhs & rhs; |
| 1583 | } |
| 1584 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1585 | RValue<Short> operator|=(const Short &lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1586 | { |
| 1587 | return lhs = lhs | rhs; |
| 1588 | } |
| 1589 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1590 | RValue<Short> operator^=(const Short &lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1591 | { |
| 1592 | return lhs = lhs ^ rhs; |
| 1593 | } |
| 1594 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1595 | RValue<Short> operator<<=(const Short &lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1596 | { |
| 1597 | return lhs = lhs << rhs; |
| 1598 | } |
| 1599 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1600 | RValue<Short> operator>>=(const Short &lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1601 | { |
| 1602 | return lhs = lhs >> rhs; |
| 1603 | } |
| 1604 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1605 | RValue<Short> operator+(RValue<Short> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1606 | { |
| 1607 | return val; |
| 1608 | } |
| 1609 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1610 | RValue<Short> operator-(RValue<Short> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1611 | { |
| 1612 | return RValue<Short>(Nucleus::createNeg(val.value)); |
| 1613 | } |
| 1614 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1615 | RValue<Short> operator~(RValue<Short> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1616 | { |
| 1617 | return RValue<Short>(Nucleus::createNot(val.value)); |
| 1618 | } |
| 1619 | |
| 1620 | RValue<Short> operator++(const Short &val, int) // Post-increment |
| 1621 | { |
| 1622 | RValue<Short> res = val; |
| 1623 | |
| 1624 | Value *inc = Nucleus::createAdd(res.value, Nucleus::createConstantShort((short)1)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1625 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1626 | |
| 1627 | return res; |
| 1628 | } |
| 1629 | |
| 1630 | const Short &operator++(const Short &val) // Pre-increment |
| 1631 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1632 | Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantShort((short)1)); |
| 1633 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1634 | |
| 1635 | return val; |
| 1636 | } |
| 1637 | |
| 1638 | RValue<Short> operator--(const Short &val, int) // Post-decrement |
| 1639 | { |
| 1640 | RValue<Short> res = val; |
| 1641 | |
| 1642 | Value *inc = Nucleus::createSub(res.value, Nucleus::createConstantShort((short)1)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1643 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1644 | |
| 1645 | return res; |
| 1646 | } |
| 1647 | |
| 1648 | const Short &operator--(const Short &val) // Pre-decrement |
| 1649 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1650 | Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantShort((short)1)); |
| 1651 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1652 | |
| 1653 | return val; |
| 1654 | } |
| 1655 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1656 | RValue<Bool> operator<(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1657 | { |
| 1658 | return RValue<Bool>(Nucleus::createICmpSLT(lhs.value, rhs.value)); |
| 1659 | } |
| 1660 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1661 | RValue<Bool> operator<=(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1662 | { |
| 1663 | return RValue<Bool>(Nucleus::createICmpSLE(lhs.value, rhs.value)); |
| 1664 | } |
| 1665 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1666 | RValue<Bool> operator>(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1667 | { |
| 1668 | return RValue<Bool>(Nucleus::createICmpSGT(lhs.value, rhs.value)); |
| 1669 | } |
| 1670 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1671 | RValue<Bool> operator>=(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1672 | { |
| 1673 | return RValue<Bool>(Nucleus::createICmpSGE(lhs.value, rhs.value)); |
| 1674 | } |
| 1675 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1676 | RValue<Bool> operator!=(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1677 | { |
| 1678 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value)); |
| 1679 | } |
| 1680 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1681 | RValue<Bool> operator==(RValue<Short> lhs, RValue<Short> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1682 | { |
| 1683 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value)); |
| 1684 | } |
| 1685 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1686 | Type *Short::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1687 | { |
| 1688 | return Type::getInt16Ty(*Nucleus::getContext()); |
| 1689 | } |
| 1690 | |
| 1691 | UShort::UShort(Argument *argument) |
| 1692 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1693 | storeValue(argument); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1694 | } |
| 1695 | |
Alexis Hetu | 77dfab4 | 2015-11-23 13:31:22 -0500 | [diff] [blame^] | 1696 | UShort::UShort(RValue<UInt> cast) |
| 1697 | { |
| 1698 | Value *integer = Nucleus::createTrunc(cast.value, UShort::getType()); |
| 1699 | |
| 1700 | storeValue(integer); |
| 1701 | } |
| 1702 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1703 | UShort::UShort() |
| 1704 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1705 | } |
| 1706 | |
| 1707 | UShort::UShort(unsigned short x) |
| 1708 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1709 | storeValue(Nucleus::createConstantShort(x)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1710 | } |
| 1711 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1712 | UShort::UShort(RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1713 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1714 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1715 | } |
| 1716 | |
| 1717 | UShort::UShort(const UShort &rhs) |
| 1718 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1719 | Value *value = rhs.loadValue(); |
| 1720 | storeValue(value); |
| 1721 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1722 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1723 | UShort::UShort(const Reference<UShort> &rhs) |
| 1724 | { |
| 1725 | Value *value = rhs.loadValue(); |
| 1726 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1727 | } |
| 1728 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1729 | RValue<UShort> UShort::operator=(RValue<UShort> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1730 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1731 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1732 | |
| 1733 | return rhs; |
| 1734 | } |
| 1735 | |
| 1736 | RValue<UShort> UShort::operator=(const UShort &rhs) const |
| 1737 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1738 | Value *value = rhs.loadValue(); |
| 1739 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1740 | |
| 1741 | return RValue<UShort>(value); |
| 1742 | } |
| 1743 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1744 | RValue<UShort> UShort::operator=(const Reference<UShort> &rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1745 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1746 | Value *value = rhs.loadValue(); |
| 1747 | storeValue(value); |
| 1748 | |
| 1749 | return RValue<UShort>(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 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::createAdd(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::createSub(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::createMul(lhs.value, rhs.value)); |
| 1765 | } |
| 1766 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1767 | RValue<UShort> operator/(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1768 | { |
| 1769 | return RValue<UShort>(Nucleus::createUDiv(lhs.value, rhs.value)); |
| 1770 | } |
| 1771 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1772 | RValue<UShort> operator%(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1773 | { |
| 1774 | return RValue<UShort>(Nucleus::createURem(lhs.value, rhs.value)); |
| 1775 | } |
| 1776 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1777 | RValue<UShort> operator&(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1778 | { |
| 1779 | return RValue<UShort>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 1780 | } |
| 1781 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1782 | RValue<UShort> operator|(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1783 | { |
| 1784 | return RValue<UShort>(Nucleus::createOr(lhs.value, rhs.value)); |
| 1785 | } |
| 1786 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1787 | RValue<UShort> operator^(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1788 | { |
| 1789 | return RValue<UShort>(Nucleus::createXor(lhs.value, rhs.value)); |
| 1790 | } |
| 1791 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1792 | RValue<UShort> operator<<(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1793 | { |
| 1794 | return RValue<UShort>(Nucleus::createShl(lhs.value, rhs.value)); |
| 1795 | } |
| 1796 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1797 | RValue<UShort> operator>>(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1798 | { |
| 1799 | return RValue<UShort>(Nucleus::createLShr(lhs.value, rhs.value)); |
| 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/=(const UShort &lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1818 | { |
| 1819 | return lhs = lhs / rhs; |
| 1820 | } |
| 1821 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1822 | RValue<UShort> operator%=(const UShort &lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1823 | { |
| 1824 | return lhs = lhs % rhs; |
| 1825 | } |
| 1826 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1827 | RValue<UShort> operator&=(const UShort &lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1828 | { |
| 1829 | return lhs = lhs & rhs; |
| 1830 | } |
| 1831 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1832 | RValue<UShort> operator|=(const UShort &lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1833 | { |
| 1834 | return lhs = lhs | rhs; |
| 1835 | } |
| 1836 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1837 | RValue<UShort> operator^=(const UShort &lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1838 | { |
| 1839 | return lhs = lhs ^ rhs; |
| 1840 | } |
| 1841 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1842 | RValue<UShort> operator<<=(const UShort &lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1843 | { |
| 1844 | return lhs = lhs << rhs; |
| 1845 | } |
| 1846 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1847 | RValue<UShort> operator>>=(const UShort &lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1848 | { |
| 1849 | return lhs = lhs >> rhs; |
| 1850 | } |
| 1851 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1852 | RValue<UShort> operator+(RValue<UShort> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1853 | { |
| 1854 | return val; |
| 1855 | } |
| 1856 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1857 | RValue<UShort> operator-(RValue<UShort> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1858 | { |
| 1859 | return RValue<UShort>(Nucleus::createNeg(val.value)); |
| 1860 | } |
| 1861 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1862 | RValue<UShort> operator~(RValue<UShort> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1863 | { |
| 1864 | return RValue<UShort>(Nucleus::createNot(val.value)); |
| 1865 | } |
| 1866 | |
| 1867 | RValue<UShort> operator++(const UShort &val, int) // Post-increment |
| 1868 | { |
| 1869 | RValue<UShort> res = val; |
| 1870 | |
| 1871 | Value *inc = Nucleus::createAdd(res.value, Nucleus::createConstantShort((unsigned short)1)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1872 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1873 | |
| 1874 | return res; |
| 1875 | } |
| 1876 | |
| 1877 | const UShort &operator++(const UShort &val) // Pre-increment |
| 1878 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1879 | Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantShort((unsigned short)1)); |
| 1880 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1881 | |
| 1882 | return val; |
| 1883 | } |
| 1884 | |
| 1885 | RValue<UShort> operator--(const UShort &val, int) // Post-decrement |
| 1886 | { |
| 1887 | RValue<UShort> res = val; |
| 1888 | |
| 1889 | Value *inc = Nucleus::createSub(res.value, Nucleus::createConstantShort((unsigned short)1)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1890 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1891 | |
| 1892 | return res; |
| 1893 | } |
| 1894 | |
| 1895 | const UShort &operator--(const UShort &val) // Pre-decrement |
| 1896 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1897 | Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantShort((unsigned short)1)); |
| 1898 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1899 | |
| 1900 | return val; |
| 1901 | } |
| 1902 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1903 | RValue<Bool> operator<(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1904 | { |
| 1905 | return RValue<Bool>(Nucleus::createICmpULT(lhs.value, rhs.value)); |
| 1906 | } |
| 1907 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1908 | RValue<Bool> operator<=(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1909 | { |
| 1910 | return RValue<Bool>(Nucleus::createICmpULE(lhs.value, rhs.value)); |
| 1911 | } |
| 1912 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1913 | RValue<Bool> operator>(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1914 | { |
| 1915 | return RValue<Bool>(Nucleus::createICmpUGT(lhs.value, rhs.value)); |
| 1916 | } |
| 1917 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1918 | RValue<Bool> operator>=(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1919 | { |
| 1920 | return RValue<Bool>(Nucleus::createICmpUGE(lhs.value, rhs.value)); |
| 1921 | } |
| 1922 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1923 | RValue<Bool> operator!=(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1924 | { |
| 1925 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value)); |
| 1926 | } |
| 1927 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1928 | RValue<Bool> operator==(RValue<UShort> lhs, RValue<UShort> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1929 | { |
| 1930 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value)); |
| 1931 | } |
| 1932 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1933 | Type *UShort::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1934 | { |
| 1935 | return Type::getInt16Ty(*Nucleus::getContext()); |
| 1936 | } |
| 1937 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1938 | Type *Byte4::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1939 | { |
| 1940 | #if 0 |
| 1941 | return VectorType::get(Byte::getType(), 4); |
| 1942 | #else |
| 1943 | return UInt::getType(); // FIXME: LLVM doesn't manipulate it as one 32-bit block |
| 1944 | #endif |
| 1945 | } |
| 1946 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1947 | Type *SByte4::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1948 | { |
| 1949 | #if 0 |
| 1950 | return VectorType::get(SByte::getType(), 4); |
| 1951 | #else |
| 1952 | return Int::getType(); // FIXME: LLVM doesn't manipulate it as one 32-bit block |
| 1953 | #endif |
| 1954 | } |
| 1955 | |
| 1956 | Byte8::Byte8() |
| 1957 | { |
| 1958 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1959 | } |
| 1960 | |
| 1961 | Byte8::Byte8(byte x0, byte x1, byte x2, byte x3, byte x4, byte x5, byte x6, byte x7) |
| 1962 | { |
| 1963 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1964 | |
| 1965 | Constant *constantVector[8]; |
| 1966 | constantVector[0] = Nucleus::createConstantByte(x0); |
| 1967 | constantVector[1] = Nucleus::createConstantByte(x1); |
| 1968 | constantVector[2] = Nucleus::createConstantByte(x2); |
| 1969 | constantVector[3] = Nucleus::createConstantByte(x3); |
| 1970 | constantVector[4] = Nucleus::createConstantByte(x4); |
| 1971 | constantVector[5] = Nucleus::createConstantByte(x5); |
| 1972 | constantVector[6] = Nucleus::createConstantByte(x6); |
| 1973 | constantVector[7] = Nucleus::createConstantByte(x7); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1974 | Value *vector = Nucleus::createConstantVector(constantVector, 8); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1975 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1976 | storeValue(Nucleus::createBitCast(vector, getType())); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1977 | } |
| 1978 | |
| 1979 | Byte8::Byte8(int64_t x) |
| 1980 | { |
| 1981 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1982 | |
| 1983 | Constant *constantVector[8]; |
| 1984 | constantVector[0] = Nucleus::createConstantByte((unsigned char)(x >> 0)); |
| 1985 | constantVector[1] = Nucleus::createConstantByte((unsigned char)(x >> 8)); |
| 1986 | constantVector[2] = Nucleus::createConstantByte((unsigned char)(x >> 16)); |
| 1987 | constantVector[3] = Nucleus::createConstantByte((unsigned char)(x >> 24)); |
| 1988 | constantVector[4] = Nucleus::createConstantByte((unsigned char)(x >> 32)); |
| 1989 | constantVector[5] = Nucleus::createConstantByte((unsigned char)(x >> 40)); |
| 1990 | constantVector[6] = Nucleus::createConstantByte((unsigned char)(x >> 48)); |
| 1991 | constantVector[7] = Nucleus::createConstantByte((unsigned char)(x >> 56)); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1992 | Value *vector = Nucleus::createConstantVector(constantVector, 8); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1993 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1994 | storeValue(Nucleus::createBitCast(vector, getType())); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1995 | } |
| 1996 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1997 | Byte8::Byte8(RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1998 | { |
| 1999 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2000 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2001 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2002 | } |
| 2003 | |
| 2004 | Byte8::Byte8(const Byte8 &rhs) |
| 2005 | { |
| 2006 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2007 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2008 | Value *value = rhs.loadValue(); |
| 2009 | storeValue(value); |
| 2010 | } |
| 2011 | |
| 2012 | Byte8::Byte8(const Reference<Byte8> &rhs) |
| 2013 | { |
| 2014 | // xyzw.parent = this; |
| 2015 | |
| 2016 | Value *value = rhs.loadValue(); |
| 2017 | storeValue(value); |
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> Byte8::operator=(RValue<Byte8> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2021 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2022 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2023 | |
| 2024 | return rhs; |
| 2025 | } |
| 2026 | |
| 2027 | RValue<Byte8> Byte8::operator=(const Byte8 &rhs) const |
| 2028 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2029 | Value *value = rhs.loadValue(); |
| 2030 | storeValue(value); |
| 2031 | |
| 2032 | return RValue<Byte8>(value); |
| 2033 | } |
| 2034 | |
| 2035 | RValue<Byte8> Byte8::operator=(const Reference<Byte8> &rhs) const |
| 2036 | { |
| 2037 | Value *value = rhs.loadValue(); |
| 2038 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2039 | |
| 2040 | return RValue<Byte8>(value); |
| 2041 | } |
| 2042 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2043 | RValue<Byte8> operator+(RValue<Byte8> lhs, RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2044 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2045 | if(CPUID::supportsMMX2()) |
| 2046 | { |
| 2047 | return x86::paddb(lhs, rhs); |
| 2048 | } |
| 2049 | else |
| 2050 | { |
| 2051 | return RValue<Byte8>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 2052 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2053 | } |
| 2054 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2055 | RValue<Byte8> operator-(RValue<Byte8> lhs, RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2056 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2057 | if(CPUID::supportsMMX2()) |
| 2058 | { |
| 2059 | return x86::psubb(lhs, rhs); |
| 2060 | } |
| 2061 | else |
| 2062 | { |
| 2063 | return RValue<Byte8>(Nucleus::createSub(lhs.value, rhs.value)); |
| 2064 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2065 | } |
| 2066 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2067 | // RValue<Byte8> operator*(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 2068 | // { |
| 2069 | // return RValue<Byte8>(Nucleus::createMul(lhs.value, rhs.value)); |
| 2070 | // } |
| 2071 | |
| 2072 | // RValue<Byte8> operator/(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 2073 | // { |
| 2074 | // return RValue<Byte8>(Nucleus::createUDiv(lhs.value, rhs.value)); |
| 2075 | // } |
| 2076 | |
| 2077 | // RValue<Byte8> operator%(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 2078 | // { |
| 2079 | // return RValue<Byte8>(Nucleus::createURem(lhs.value, rhs.value)); |
| 2080 | // } |
| 2081 | |
| 2082 | RValue<Byte8> operator&(RValue<Byte8> lhs, RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2083 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2084 | if(CPUID::supportsMMX2()) |
| 2085 | { |
| 2086 | return As<Byte8>(x86::pand(As<Short4>(lhs), As<Short4>(rhs))); |
| 2087 | } |
| 2088 | else |
| 2089 | { |
| 2090 | return RValue<Byte8>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 2091 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2092 | } |
| 2093 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2094 | RValue<Byte8> operator|(RValue<Byte8> lhs, RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2095 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2096 | if(CPUID::supportsMMX2()) |
| 2097 | { |
| 2098 | return As<Byte8>(x86::por(As<Short4>(lhs), As<Short4>(rhs))); |
| 2099 | } |
| 2100 | else |
| 2101 | { |
| 2102 | return RValue<Byte8>(Nucleus::createOr(lhs.value, rhs.value)); |
| 2103 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2104 | } |
| 2105 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2106 | RValue<Byte8> operator^(RValue<Byte8> lhs, RValue<Byte8> rhs) |
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 | if(CPUID::supportsMMX2()) |
| 2109 | { |
| 2110 | return As<Byte8>(x86::pxor(As<Short4>(lhs), As<Short4>(rhs))); |
| 2111 | } |
| 2112 | else |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2113 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2114 | return RValue<Byte8>(Nucleus::createXor(lhs.value, rhs.value)); |
| 2115 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2116 | } |
| 2117 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2118 | // RValue<Byte8> operator<<(RValue<Byte8> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2119 | // { |
| 2120 | // return RValue<Byte8>(Nucleus::createShl(lhs.value, rhs.value)); |
| 2121 | // } |
| 2122 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2123 | // RValue<Byte8> operator>>(RValue<Byte8> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2124 | // { |
| 2125 | // return RValue<Byte8>(Nucleus::createLShr(lhs.value, rhs.value)); |
| 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) |
| 2139 | // { |
| 2140 | // return lhs = lhs * rhs; |
| 2141 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2142 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2143 | // RValue<Byte8> operator/=(const Byte8 &lhs, RValue<Byte8> rhs) |
| 2144 | // { |
| 2145 | // return lhs = lhs / rhs; |
| 2146 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2147 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2148 | // RValue<Byte8> operator%=(const Byte8 &lhs, RValue<Byte8> rhs) |
| 2149 | // { |
| 2150 | // return lhs = lhs % rhs; |
| 2151 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2152 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2153 | RValue<Byte8> operator&=(const Byte8 &lhs, RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2154 | { |
| 2155 | return lhs = lhs & rhs; |
| 2156 | } |
| 2157 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2158 | RValue<Byte8> operator|=(const Byte8 &lhs, RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2159 | { |
| 2160 | return lhs = lhs | rhs; |
| 2161 | } |
| 2162 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2163 | RValue<Byte8> operator^=(const Byte8 &lhs, RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2164 | { |
| 2165 | return lhs = lhs ^ rhs; |
| 2166 | } |
| 2167 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2168 | // RValue<Byte8> operator<<=(const Byte8 &lhs, RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2169 | // { |
| 2170 | // return lhs = lhs << rhs; |
| 2171 | // } |
| 2172 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2173 | // RValue<Byte8> operator>>=(const Byte8 &lhs, RValue<Byte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2174 | // { |
| 2175 | // return lhs = lhs >> rhs; |
| 2176 | // } |
| 2177 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2178 | // RValue<Byte8> operator+(RValue<Byte8> val) |
| 2179 | // { |
| 2180 | // return val; |
| 2181 | // } |
| 2182 | |
| 2183 | // RValue<Byte8> operator-(RValue<Byte8> val) |
| 2184 | // { |
| 2185 | // return RValue<Byte8>(Nucleus::createNeg(val.value)); |
| 2186 | // } |
| 2187 | |
| 2188 | RValue<Byte8> operator~(RValue<Byte8> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2189 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2190 | if(CPUID::supportsMMX2()) |
| 2191 | { |
| 2192 | return val ^ Byte8(0xFFFFFFFFFFFFFFFF); |
| 2193 | } |
| 2194 | else |
| 2195 | { |
| 2196 | return RValue<Byte8>(Nucleus::createNot(val.value)); |
| 2197 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2198 | } |
| 2199 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2200 | RValue<Byte8> AddSat(RValue<Byte8> x, RValue<Byte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2201 | { |
| 2202 | return x86::paddusb(x, y); |
| 2203 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2204 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2205 | RValue<Byte8> SubSat(RValue<Byte8> x, RValue<Byte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2206 | { |
| 2207 | return x86::psubusb(x, y); |
| 2208 | } |
| 2209 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2210 | RValue<Short4> Unpack(RValue<Byte4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2211 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2212 | Value *int2 = Nucleus::createInsertElement(UndefValue::get(VectorType::get(Int::getType(), 2)), x.value, 0); |
| 2213 | Value *byte8 = Nucleus::createBitCast(int2, Byte8::getType()); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2214 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2215 | return UnpackLow(RValue<Byte8>(byte8), RValue<Byte8>(byte8)); |
| 2216 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2217 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2218 | RValue<Short4> UnpackLow(RValue<Byte8> x, RValue<Byte8> y) |
| 2219 | { |
| 2220 | if(CPUID::supportsMMX2()) |
| 2221 | { |
| 2222 | return x86::punpcklbw(x, y); |
| 2223 | } |
| 2224 | else |
| 2225 | { |
| 2226 | Constant *shuffle[8]; |
| 2227 | shuffle[0] = Nucleus::createConstantInt(0); |
| 2228 | shuffle[1] = Nucleus::createConstantInt(8); |
| 2229 | shuffle[2] = Nucleus::createConstantInt(1); |
| 2230 | shuffle[3] = Nucleus::createConstantInt(9); |
| 2231 | shuffle[4] = Nucleus::createConstantInt(2); |
| 2232 | shuffle[5] = Nucleus::createConstantInt(10); |
| 2233 | shuffle[6] = Nucleus::createConstantInt(3); |
| 2234 | shuffle[7] = Nucleus::createConstantInt(11); |
| 2235 | |
| 2236 | Value *packed = Nucleus::createShuffleVector(x.value, y.value, Nucleus::createConstantVector(shuffle, 8)); |
| 2237 | |
| 2238 | return RValue<Short4>(Nucleus::createBitCast(packed, Short4::getType())); |
| 2239 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2240 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2241 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2242 | RValue<Short4> UnpackHigh(RValue<Byte8> x, RValue<Byte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2243 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2244 | if(CPUID::supportsMMX2()) |
| 2245 | { |
| 2246 | return x86::punpckhbw(x, y); |
| 2247 | } |
| 2248 | else |
| 2249 | { |
| 2250 | Constant *shuffle[8]; |
| 2251 | shuffle[0] = Nucleus::createConstantInt(4); |
| 2252 | shuffle[1] = Nucleus::createConstantInt(12); |
| 2253 | shuffle[2] = Nucleus::createConstantInt(5); |
| 2254 | shuffle[3] = Nucleus::createConstantInt(13); |
| 2255 | shuffle[4] = Nucleus::createConstantInt(6); |
| 2256 | shuffle[5] = Nucleus::createConstantInt(14); |
| 2257 | shuffle[6] = Nucleus::createConstantInt(7); |
| 2258 | shuffle[7] = Nucleus::createConstantInt(15); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2259 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2260 | Value *packed = Nucleus::createShuffleVector(x.value, y.value, Nucleus::createConstantVector(shuffle, 8)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2261 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2262 | return RValue<Short4>(Nucleus::createBitCast(packed, Short4::getType())); |
| 2263 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2264 | } |
| 2265 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2266 | RValue<Int> SignMask(RValue<Byte8> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2267 | { |
| 2268 | return x86::pmovmskb(x); |
| 2269 | } |
| 2270 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2271 | // RValue<Byte8> CmpGT(RValue<Byte8> x, RValue<Byte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2272 | // { |
| 2273 | // return x86::pcmpgtb(x, y); // FIXME: Signedness |
| 2274 | // } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2275 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2276 | RValue<Byte8> CmpEQ(RValue<Byte8> x, RValue<Byte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2277 | { |
| 2278 | return x86::pcmpeqb(x, y); |
| 2279 | } |
| 2280 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2281 | Type *Byte8::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2282 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2283 | if(CPUID::supportsMMX2()) |
| 2284 | { |
| 2285 | return MMX::getType(); |
| 2286 | } |
| 2287 | else |
| 2288 | { |
| 2289 | return VectorType::get(Byte::getType(), 8); |
| 2290 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2291 | } |
| 2292 | |
| 2293 | SByte8::SByte8() |
| 2294 | { |
| 2295 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2296 | } |
| 2297 | |
| 2298 | SByte8::SByte8(byte x0, byte x1, byte x2, byte x3, byte x4, byte x5, byte x6, byte x7) |
| 2299 | { |
| 2300 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2301 | |
| 2302 | Constant *constantVector[8]; |
| 2303 | constantVector[0] = Nucleus::createConstantByte(x0); |
| 2304 | constantVector[1] = Nucleus::createConstantByte(x1); |
| 2305 | constantVector[2] = Nucleus::createConstantByte(x2); |
| 2306 | constantVector[3] = Nucleus::createConstantByte(x3); |
| 2307 | constantVector[4] = Nucleus::createConstantByte(x4); |
| 2308 | constantVector[5] = Nucleus::createConstantByte(x5); |
| 2309 | constantVector[6] = Nucleus::createConstantByte(x6); |
| 2310 | constantVector[7] = Nucleus::createConstantByte(x7); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2311 | Value *vector = Nucleus::createConstantVector(constantVector, 8); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2312 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2313 | storeValue(Nucleus::createBitCast(vector, getType())); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2314 | } |
| 2315 | |
| 2316 | SByte8::SByte8(int64_t x) |
| 2317 | { |
| 2318 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2319 | |
| 2320 | Constant *constantVector[8]; |
| 2321 | constantVector[0] = Nucleus::createConstantByte((unsigned char)(x >> 0)); |
| 2322 | constantVector[1] = Nucleus::createConstantByte((unsigned char)(x >> 8)); |
| 2323 | constantVector[2] = Nucleus::createConstantByte((unsigned char)(x >> 16)); |
| 2324 | constantVector[3] = Nucleus::createConstantByte((unsigned char)(x >> 24)); |
| 2325 | constantVector[4] = Nucleus::createConstantByte((unsigned char)(x >> 32)); |
| 2326 | constantVector[5] = Nucleus::createConstantByte((unsigned char)(x >> 40)); |
| 2327 | constantVector[6] = Nucleus::createConstantByte((unsigned char)(x >> 48)); |
| 2328 | constantVector[7] = Nucleus::createConstantByte((unsigned char)(x >> 56)); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2329 | Value *vector = Nucleus::createConstantVector(constantVector, 8); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2330 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2331 | storeValue(Nucleus::createBitCast(vector, getType())); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2332 | } |
| 2333 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2334 | SByte8::SByte8(RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2335 | { |
| 2336 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2337 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2338 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2339 | } |
| 2340 | |
| 2341 | SByte8::SByte8(const SByte8 &rhs) |
| 2342 | { |
| 2343 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2344 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2345 | Value *value = rhs.loadValue(); |
| 2346 | storeValue(value); |
| 2347 | } |
| 2348 | |
| 2349 | SByte8::SByte8(const Reference<SByte8> &rhs) |
| 2350 | { |
| 2351 | // xyzw.parent = this; |
| 2352 | |
| 2353 | Value *value = rhs.loadValue(); |
| 2354 | storeValue(value); |
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> SByte8::operator=(RValue<SByte8> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2358 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2359 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2360 | |
| 2361 | return rhs; |
| 2362 | } |
| 2363 | |
| 2364 | RValue<SByte8> SByte8::operator=(const SByte8 &rhs) const |
| 2365 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2366 | Value *value = rhs.loadValue(); |
| 2367 | storeValue(value); |
| 2368 | |
| 2369 | return RValue<SByte8>(value); |
| 2370 | } |
| 2371 | |
| 2372 | RValue<SByte8> SByte8::operator=(const Reference<SByte8> &rhs) const |
| 2373 | { |
| 2374 | Value *value = rhs.loadValue(); |
| 2375 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2376 | |
| 2377 | return RValue<SByte8>(value); |
| 2378 | } |
| 2379 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2380 | RValue<SByte8> operator+(RValue<SByte8> lhs, RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2381 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2382 | if(CPUID::supportsMMX2()) |
| 2383 | { |
| 2384 | return As<SByte8>(x86::paddb(As<Byte8>(lhs), As<Byte8>(rhs))); |
| 2385 | } |
| 2386 | else |
| 2387 | { |
| 2388 | return RValue<SByte8>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 2389 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2390 | } |
| 2391 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2392 | RValue<SByte8> operator-(RValue<SByte8> lhs, RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2393 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2394 | if(CPUID::supportsMMX2()) |
| 2395 | { |
| 2396 | return As<SByte8>(x86::psubb(As<Byte8>(lhs), As<Byte8>(rhs))); |
| 2397 | } |
| 2398 | else |
| 2399 | { |
| 2400 | return RValue<SByte8>(Nucleus::createSub(lhs.value, rhs.value)); |
| 2401 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2402 | } |
| 2403 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2404 | // RValue<SByte8> operator*(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 2405 | // { |
| 2406 | // return RValue<SByte8>(Nucleus::createMul(lhs.value, rhs.value)); |
| 2407 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2408 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2409 | // RValue<SByte8> operator/(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 2410 | // { |
| 2411 | // return RValue<SByte8>(Nucleus::createSDiv(lhs.value, rhs.value)); |
| 2412 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2413 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2414 | // RValue<SByte8> operator%(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 2415 | // { |
| 2416 | // return RValue<SByte8>(Nucleus::createSRem(lhs.value, rhs.value)); |
| 2417 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2418 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2419 | RValue<SByte8> operator&(RValue<SByte8> lhs, RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2420 | { |
| 2421 | return RValue<SByte8>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 2422 | } |
| 2423 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2424 | RValue<SByte8> operator|(RValue<SByte8> lhs, RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2425 | { |
| 2426 | return RValue<SByte8>(Nucleus::createOr(lhs.value, rhs.value)); |
| 2427 | } |
| 2428 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2429 | RValue<SByte8> operator^(RValue<SByte8> lhs, RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2430 | { |
| 2431 | return RValue<SByte8>(Nucleus::createXor(lhs.value, rhs.value)); |
| 2432 | } |
| 2433 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2434 | // RValue<SByte8> operator<<(RValue<SByte8> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2435 | // { |
| 2436 | // return RValue<SByte8>(Nucleus::createShl(lhs.value, rhs.value)); |
| 2437 | // } |
| 2438 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2439 | // RValue<SByte8> operator>>(RValue<SByte8> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2440 | // { |
| 2441 | // return RValue<SByte8>(Nucleus::createAShr(lhs.value, rhs.value)); |
| 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) |
| 2455 | // { |
| 2456 | // return lhs = lhs * rhs; |
| 2457 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2458 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2459 | // RValue<SByte8> operator/=(const SByte8 &lhs, RValue<SByte8> rhs) |
| 2460 | // { |
| 2461 | // return lhs = lhs / rhs; |
| 2462 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2463 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2464 | // RValue<SByte8> operator%=(const SByte8 &lhs, RValue<SByte8> rhs) |
| 2465 | // { |
| 2466 | // return lhs = lhs % rhs; |
| 2467 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2468 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2469 | RValue<SByte8> operator&=(const SByte8 &lhs, RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2470 | { |
| 2471 | return lhs = lhs & rhs; |
| 2472 | } |
| 2473 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2474 | RValue<SByte8> operator|=(const SByte8 &lhs, RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2475 | { |
| 2476 | return lhs = lhs | rhs; |
| 2477 | } |
| 2478 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2479 | RValue<SByte8> operator^=(const SByte8 &lhs, RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2480 | { |
| 2481 | return lhs = lhs ^ rhs; |
| 2482 | } |
| 2483 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2484 | // RValue<SByte8> operator<<=(const SByte8 &lhs, RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2485 | // { |
| 2486 | // return lhs = lhs << rhs; |
| 2487 | // } |
| 2488 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2489 | // RValue<SByte8> operator>>=(const SByte8 &lhs, RValue<SByte8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2490 | // { |
| 2491 | // return lhs = lhs >> rhs; |
| 2492 | // } |
| 2493 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2494 | // RValue<SByte8> operator+(RValue<SByte8> val) |
| 2495 | // { |
| 2496 | // return val; |
| 2497 | // } |
| 2498 | |
| 2499 | // RValue<SByte8> operator-(RValue<SByte8> val) |
| 2500 | // { |
| 2501 | // return RValue<SByte8>(Nucleus::createNeg(val.value)); |
| 2502 | // } |
| 2503 | |
| 2504 | RValue<SByte8> operator~(RValue<SByte8> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2505 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2506 | if(CPUID::supportsMMX2()) |
| 2507 | { |
| 2508 | return val ^ SByte8(0xFFFFFFFFFFFFFFFF); |
| 2509 | } |
| 2510 | else |
| 2511 | { |
| 2512 | return RValue<SByte8>(Nucleus::createNot(val.value)); |
| 2513 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2514 | } |
| 2515 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2516 | RValue<SByte8> AddSat(RValue<SByte8> x, RValue<SByte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2517 | { |
| 2518 | return x86::paddsb(x, y); |
| 2519 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2520 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2521 | RValue<SByte8> SubSat(RValue<SByte8> x, RValue<SByte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2522 | { |
| 2523 | return x86::psubsb(x, y); |
| 2524 | } |
| 2525 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2526 | RValue<Short4> UnpackLow(RValue<SByte8> x, RValue<SByte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2527 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2528 | if(CPUID::supportsMMX2()) |
| 2529 | { |
| 2530 | return As<Short4>(x86::punpcklbw(As<Byte8>(x), As<Byte8>(y))); |
| 2531 | } |
| 2532 | else |
| 2533 | { |
| 2534 | Constant *shuffle[8]; |
| 2535 | shuffle[0] = Nucleus::createConstantInt(0); |
| 2536 | shuffle[1] = Nucleus::createConstantInt(8); |
| 2537 | shuffle[2] = Nucleus::createConstantInt(1); |
| 2538 | shuffle[3] = Nucleus::createConstantInt(9); |
| 2539 | shuffle[4] = Nucleus::createConstantInt(2); |
| 2540 | shuffle[5] = Nucleus::createConstantInt(10); |
| 2541 | shuffle[6] = Nucleus::createConstantInt(3); |
| 2542 | shuffle[7] = Nucleus::createConstantInt(11); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2543 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2544 | Value *packed = Nucleus::createShuffleVector(x.value, y.value, Nucleus::createConstantVector(shuffle, 8)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2545 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2546 | return RValue<Short4>(Nucleus::createBitCast(packed, Short4::getType())); |
| 2547 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2548 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2549 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2550 | RValue<Short4> UnpackHigh(RValue<SByte8> x, RValue<SByte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2551 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2552 | if(CPUID::supportsMMX2()) |
| 2553 | { |
| 2554 | return As<Short4>(x86::punpckhbw(As<Byte8>(x), As<Byte8>(y))); |
| 2555 | } |
| 2556 | else |
| 2557 | { |
| 2558 | Constant *shuffle[8]; |
| 2559 | shuffle[0] = Nucleus::createConstantInt(4); |
| 2560 | shuffle[1] = Nucleus::createConstantInt(12); |
| 2561 | shuffle[2] = Nucleus::createConstantInt(5); |
| 2562 | shuffle[3] = Nucleus::createConstantInt(13); |
| 2563 | shuffle[4] = Nucleus::createConstantInt(6); |
| 2564 | shuffle[5] = Nucleus::createConstantInt(14); |
| 2565 | shuffle[6] = Nucleus::createConstantInt(7); |
| 2566 | shuffle[7] = Nucleus::createConstantInt(15); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2567 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2568 | Value *packed = Nucleus::createShuffleVector(x.value, y.value, Nucleus::createConstantVector(shuffle, 8)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2569 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2570 | return RValue<Short4>(Nucleus::createBitCast(packed, Short4::getType())); |
| 2571 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2572 | } |
| 2573 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2574 | RValue<Int> SignMask(RValue<SByte8> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2575 | { |
| 2576 | return x86::pmovmskb(As<Byte8>(x)); |
| 2577 | } |
| 2578 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2579 | RValue<Byte8> CmpGT(RValue<SByte8> x, RValue<SByte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2580 | { |
| 2581 | return x86::pcmpgtb(x, y); |
| 2582 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2583 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2584 | RValue<Byte8> CmpEQ(RValue<SByte8> x, RValue<SByte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2585 | { |
| 2586 | return x86::pcmpeqb(As<Byte8>(x), As<Byte8>(y)); |
| 2587 | } |
| 2588 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2589 | Type *SByte8::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2590 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2591 | if(CPUID::supportsMMX2()) |
| 2592 | { |
| 2593 | return MMX::getType(); |
| 2594 | } |
| 2595 | else |
| 2596 | { |
| 2597 | return VectorType::get(SByte::getType(), 8); |
| 2598 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2599 | } |
| 2600 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2601 | Byte16::Byte16(RValue<Byte16> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2602 | { |
| 2603 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2604 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2605 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2606 | } |
| 2607 | |
| 2608 | Byte16::Byte16(const Byte16 &rhs) |
| 2609 | { |
| 2610 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2611 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2612 | Value *value = rhs.loadValue(); |
| 2613 | storeValue(value); |
| 2614 | } |
| 2615 | |
| 2616 | Byte16::Byte16(const Reference<Byte16> &rhs) |
| 2617 | { |
| 2618 | // xyzw.parent = this; |
| 2619 | |
| 2620 | Value *value = rhs.loadValue(); |
| 2621 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2622 | } |
| 2623 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2624 | RValue<Byte16> Byte16::operator=(RValue<Byte16> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2625 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2626 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2627 | |
| 2628 | return rhs; |
| 2629 | } |
| 2630 | |
| 2631 | RValue<Byte16> Byte16::operator=(const Byte16 &rhs) const |
| 2632 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2633 | Value *value = rhs.loadValue(); |
| 2634 | storeValue(value); |
| 2635 | |
| 2636 | return RValue<Byte16>(value); |
| 2637 | } |
| 2638 | |
| 2639 | RValue<Byte16> Byte16::operator=(const Reference<Byte16> &rhs) const |
| 2640 | { |
| 2641 | Value *value = rhs.loadValue(); |
| 2642 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2643 | |
| 2644 | return RValue<Byte16>(value); |
| 2645 | } |
| 2646 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2647 | Type *Byte16::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2648 | { |
| 2649 | return VectorType::get(Byte::getType(), 16); |
| 2650 | } |
| 2651 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2652 | Type *SByte16::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2653 | { |
| 2654 | return VectorType::get(SByte::getType(), 16); |
| 2655 | } |
| 2656 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2657 | Short4::Short4(RValue<Int> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2658 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2659 | Value *extend = Nucleus::createZExt(cast.value, Long::getType()); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2660 | Value *swizzle = Swizzle(RValue<Short4>(extend), 0x00).value; |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2661 | |
| 2662 | storeValue(swizzle); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2663 | } |
| 2664 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2665 | Short4::Short4(RValue<Int4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2666 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2667 | Value *short8 = Nucleus::createBitCast(cast.value, Short8::getType()); |
| 2668 | |
| 2669 | #if 0 // FIXME: Check codegen (pshuflw phshufhw pshufd) |
| 2670 | Constant *pack[8]; |
| 2671 | pack[0] = Nucleus::createConstantInt(0); |
| 2672 | pack[1] = Nucleus::createConstantInt(2); |
| 2673 | pack[2] = Nucleus::createConstantInt(4); |
| 2674 | pack[3] = Nucleus::createConstantInt(6); |
| 2675 | |
| 2676 | Value *short4 = Nucleus::createShuffleVector(short8, short8, Nucleus::createConstantVector(pack, 4)); |
| 2677 | #else |
| 2678 | Value *packed; |
| 2679 | |
| 2680 | // FIXME: Use Swizzle<Short8> |
| 2681 | if(!CPUID::supportsSSSE3()) |
| 2682 | { |
| 2683 | Constant *pshuflw[8]; |
| 2684 | pshuflw[0] = Nucleus::createConstantInt(0); |
| 2685 | pshuflw[1] = Nucleus::createConstantInt(2); |
| 2686 | pshuflw[2] = Nucleus::createConstantInt(0); |
| 2687 | pshuflw[3] = Nucleus::createConstantInt(2); |
| 2688 | pshuflw[4] = Nucleus::createConstantInt(4); |
| 2689 | pshuflw[5] = Nucleus::createConstantInt(5); |
| 2690 | pshuflw[6] = Nucleus::createConstantInt(6); |
| 2691 | pshuflw[7] = Nucleus::createConstantInt(7); |
| 2692 | |
| 2693 | Constant *pshufhw[8]; |
| 2694 | pshufhw[0] = Nucleus::createConstantInt(0); |
| 2695 | pshufhw[1] = Nucleus::createConstantInt(1); |
| 2696 | pshufhw[2] = Nucleus::createConstantInt(2); |
| 2697 | pshufhw[3] = Nucleus::createConstantInt(3); |
| 2698 | pshufhw[4] = Nucleus::createConstantInt(4); |
| 2699 | pshufhw[5] = Nucleus::createConstantInt(6); |
| 2700 | pshufhw[6] = Nucleus::createConstantInt(4); |
| 2701 | pshufhw[7] = Nucleus::createConstantInt(6); |
| 2702 | |
| 2703 | Value *shuffle1 = Nucleus::createShuffleVector(short8, UndefValue::get(Short8::getType()), Nucleus::createConstantVector(pshuflw, 8)); |
| 2704 | Value *shuffle2 = Nucleus::createShuffleVector(shuffle1, UndefValue::get(Short8::getType()), Nucleus::createConstantVector(pshufhw, 8)); |
| 2705 | Value *int4 = Nucleus::createBitCast(shuffle2, Int4::getType()); |
| 2706 | packed = Nucleus::createSwizzle(int4, 0x88); |
| 2707 | } |
| 2708 | else |
| 2709 | { |
| 2710 | Constant *pshufb[16]; |
| 2711 | pshufb[0] = Nucleus::createConstantInt(0); |
| 2712 | pshufb[1] = Nucleus::createConstantInt(1); |
| 2713 | pshufb[2] = Nucleus::createConstantInt(4); |
| 2714 | pshufb[3] = Nucleus::createConstantInt(5); |
| 2715 | pshufb[4] = Nucleus::createConstantInt(8); |
| 2716 | pshufb[5] = Nucleus::createConstantInt(9); |
| 2717 | pshufb[6] = Nucleus::createConstantInt(12); |
| 2718 | pshufb[7] = Nucleus::createConstantInt(13); |
| 2719 | pshufb[8] = Nucleus::createConstantInt(0); |
| 2720 | pshufb[9] = Nucleus::createConstantInt(1); |
| 2721 | pshufb[10] = Nucleus::createConstantInt(4); |
| 2722 | pshufb[11] = Nucleus::createConstantInt(5); |
| 2723 | pshufb[12] = Nucleus::createConstantInt(8); |
| 2724 | pshufb[13] = Nucleus::createConstantInt(9); |
| 2725 | pshufb[14] = Nucleus::createConstantInt(12); |
| 2726 | pshufb[15] = Nucleus::createConstantInt(13); |
| 2727 | |
| 2728 | Value *byte16 = Nucleus::createBitCast(cast.value, Byte16::getType()); |
| 2729 | packed = Nucleus::createShuffleVector(byte16, UndefValue::get(Byte16::getType()), Nucleus::createConstantVector(pshufb, 16)); |
| 2730 | } |
| 2731 | |
| 2732 | #if 0 // FIXME: No optimal instruction selection |
| 2733 | Value *qword2 = Nucleus::createBitCast(packed, Long2::getType()); |
| 2734 | Value *element = Nucleus::createExtractElement(qword2, 0); |
| 2735 | Value *short4 = Nucleus::createBitCast(element, Short4::getType()); |
| 2736 | #else // FIXME: Requires SSE |
| 2737 | Value *int2 = RValue<Int2>(Int2(RValue<Int4>(packed))).value; |
| 2738 | Value *short4 = Nucleus::createBitCast(int2, Short4::getType()); |
| 2739 | #endif |
| 2740 | #endif |
| 2741 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2742 | storeValue(short4); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2743 | } |
| 2744 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2745 | // Short4::Short4(RValue<Float> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2746 | // { |
| 2747 | // } |
| 2748 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2749 | Short4::Short4(RValue<Float4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2750 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2751 | Int4 v4i32 = Int4(cast); |
| 2752 | v4i32 = As<Int4>(x86::packssdw(v4i32, v4i32)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2753 | |
| 2754 | storeValue(As<Short4>(Int2(v4i32)).value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2755 | } |
| 2756 | |
| 2757 | Short4::Short4() |
| 2758 | { |
| 2759 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2760 | } |
| 2761 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2762 | Short4::Short4(short xyzw) |
| 2763 | { |
| 2764 | // xyzw.parent = this; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2765 | |
| 2766 | Constant *constantVector[4]; |
| 2767 | constantVector[0] = Nucleus::createConstantShort(xyzw); |
| 2768 | constantVector[1] = Nucleus::createConstantShort(xyzw); |
| 2769 | constantVector[2] = Nucleus::createConstantShort(xyzw); |
| 2770 | constantVector[3] = Nucleus::createConstantShort(xyzw); |
| 2771 | Value *vector = Nucleus::createConstantVector(constantVector, 4); |
| 2772 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2773 | storeValue(Nucleus::createBitCast(vector, getType())); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2774 | } |
| 2775 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2776 | Short4::Short4(short x, short y, short z, short w) |
| 2777 | { |
| 2778 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2779 | |
| 2780 | Constant *constantVector[4]; |
| 2781 | constantVector[0] = Nucleus::createConstantShort(x); |
| 2782 | constantVector[1] = Nucleus::createConstantShort(y); |
| 2783 | constantVector[2] = Nucleus::createConstantShort(z); |
| 2784 | constantVector[3] = Nucleus::createConstantShort(w); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2785 | Value *vector = Nucleus::createConstantVector(constantVector, 4); |
| 2786 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2787 | storeValue(Nucleus::createBitCast(vector, getType())); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2788 | } |
| 2789 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2790 | Short4::Short4(RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2791 | { |
| 2792 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2793 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2794 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2795 | } |
| 2796 | |
| 2797 | Short4::Short4(const Short4 &rhs) |
| 2798 | { |
| 2799 | // xyzw.parent = this; |
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 | Value *value = rhs.loadValue(); |
| 2802 | storeValue(value); |
| 2803 | } |
| 2804 | |
| 2805 | Short4::Short4(const Reference<Short4> &rhs) |
| 2806 | { |
| 2807 | // xyzw.parent = this; |
| 2808 | |
| 2809 | Value *value = rhs.loadValue(); |
| 2810 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2811 | } |
| 2812 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2813 | Short4::Short4(RValue<UShort4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2814 | { |
| 2815 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2816 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2817 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2818 | } |
| 2819 | |
| 2820 | Short4::Short4(const UShort4 &rhs) |
| 2821 | { |
| 2822 | // xyzw.parent = this; |
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.loadValue()); |
| 2825 | } |
| 2826 | |
| 2827 | Short4::Short4(const Reference<UShort4> &rhs) |
| 2828 | { |
| 2829 | // xyzw.parent = this; |
| 2830 | |
| 2831 | storeValue(rhs.loadValue()); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2832 | } |
| 2833 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2834 | RValue<Short4> Short4::operator=(RValue<Short4> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2835 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2836 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2837 | |
| 2838 | return rhs; |
| 2839 | } |
| 2840 | |
| 2841 | RValue<Short4> Short4::operator=(const Short4 &rhs) const |
| 2842 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2843 | Value *value = rhs.loadValue(); |
| 2844 | storeValue(value); |
| 2845 | |
| 2846 | return RValue<Short4>(value); |
| 2847 | } |
| 2848 | |
| 2849 | RValue<Short4> Short4::operator=(const Reference<Short4> &rhs) const |
| 2850 | { |
| 2851 | Value *value = rhs.loadValue(); |
| 2852 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2853 | |
| 2854 | return RValue<Short4>(value); |
| 2855 | } |
| 2856 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2857 | RValue<Short4> Short4::operator=(RValue<UShort4> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2858 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2859 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2860 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2861 | return RValue<Short4>(rhs); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2862 | } |
| 2863 | |
| 2864 | RValue<Short4> Short4::operator=(const UShort4 &rhs) const |
| 2865 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2866 | Value *value = rhs.loadValue(); |
| 2867 | storeValue(value); |
| 2868 | |
| 2869 | return RValue<Short4>(value); |
| 2870 | } |
| 2871 | |
| 2872 | RValue<Short4> Short4::operator=(const Reference<UShort4> &rhs) const |
| 2873 | { |
| 2874 | Value *value = rhs.loadValue(); |
| 2875 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2876 | |
| 2877 | return RValue<Short4>(value); |
| 2878 | } |
| 2879 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2880 | RValue<Short4> operator+(RValue<Short4> lhs, RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2881 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2882 | if(CPUID::supportsMMX2()) |
| 2883 | { |
| 2884 | return x86::paddw(lhs, rhs); |
| 2885 | } |
| 2886 | else |
| 2887 | { |
| 2888 | return RValue<Short4>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 2889 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2890 | } |
| 2891 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2892 | RValue<Short4> operator-(RValue<Short4> lhs, RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2893 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2894 | if(CPUID::supportsMMX2()) |
| 2895 | { |
| 2896 | return x86::psubw(lhs, rhs); |
| 2897 | } |
| 2898 | else |
| 2899 | { |
| 2900 | return RValue<Short4>(Nucleus::createSub(lhs.value, rhs.value)); |
| 2901 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2902 | } |
| 2903 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2904 | RValue<Short4> operator*(RValue<Short4> lhs, RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2905 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2906 | if(CPUID::supportsMMX2()) |
| 2907 | { |
| 2908 | return x86::pmullw(lhs, rhs); |
| 2909 | } |
| 2910 | else |
| 2911 | { |
| 2912 | return RValue<Short4>(Nucleus::createMul(lhs.value, rhs.value)); |
| 2913 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2914 | } |
| 2915 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2916 | // RValue<Short4> operator/(RValue<Short4> lhs, RValue<Short4> rhs) |
| 2917 | // { |
| 2918 | // return RValue<Short4>(Nucleus::createSDiv(lhs.value, rhs.value)); |
| 2919 | // } |
| 2920 | |
| 2921 | // RValue<Short4> operator%(RValue<Short4> lhs, RValue<Short4> rhs) |
| 2922 | // { |
| 2923 | // return RValue<Short4>(Nucleus::createSRem(lhs.value, rhs.value)); |
| 2924 | // } |
| 2925 | |
| 2926 | RValue<Short4> operator&(RValue<Short4> lhs, RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2927 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2928 | if(CPUID::supportsMMX2()) |
| 2929 | { |
| 2930 | return x86::pand(lhs, rhs); |
| 2931 | } |
| 2932 | else |
| 2933 | { |
| 2934 | return RValue<Short4>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 2935 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2936 | } |
| 2937 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2938 | RValue<Short4> operator|(RValue<Short4> lhs, RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2939 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2940 | if(CPUID::supportsMMX2()) |
| 2941 | { |
| 2942 | return x86::por(lhs, rhs); |
| 2943 | } |
| 2944 | else |
| 2945 | { |
| 2946 | return RValue<Short4>(Nucleus::createOr(lhs.value, rhs.value)); |
| 2947 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2948 | } |
| 2949 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2950 | RValue<Short4> operator^(RValue<Short4> lhs, RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2951 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2952 | if(CPUID::supportsMMX2()) |
| 2953 | { |
| 2954 | return x86::pxor(lhs, rhs); |
| 2955 | } |
| 2956 | else |
| 2957 | { |
| 2958 | return RValue<Short4>(Nucleus::createXor(lhs.value, rhs.value)); |
| 2959 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2960 | } |
| 2961 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2962 | RValue<Short4> operator<<(RValue<Short4> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2963 | { |
| 2964 | // return RValue<Short4>(Nucleus::createShl(lhs.value, rhs.value)); |
| 2965 | |
| 2966 | return x86::psllw(lhs, rhs); |
| 2967 | } |
| 2968 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2969 | RValue<Short4> operator>>(RValue<Short4> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2970 | { |
| 2971 | // return RValue<Short4>(Nucleus::createAShr(lhs.value, rhs.value)); |
| 2972 | |
| 2973 | return x86::psraw(lhs, rhs); |
| 2974 | } |
| 2975 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2976 | RValue<Short4> operator<<(RValue<Short4> lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2977 | { |
| 2978 | // return RValue<Short4>(Nucleus::createShl(lhs.value, rhs.value)); |
| 2979 | |
| 2980 | return x86::psllw(lhs, rhs); |
| 2981 | } |
| 2982 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2983 | RValue<Short4> operator>>(RValue<Short4> lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2984 | { |
| 2985 | // return RValue<Short4>(Nucleus::createAShr(lhs.value, rhs.value)); |
| 2986 | |
| 2987 | return x86::psraw(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 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 2995 | RValue<Short4> operator-=(const Short4 &lhs, RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2996 | { |
| 2997 | return lhs = lhs - rhs; |
| 2998 | } |
| 2999 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3000 | RValue<Short4> operator*=(const Short4 &lhs, RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 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<Short4> rhs) |
| 3006 | // { |
| 3007 | // return lhs = lhs / rhs; |
| 3008 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3009 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3010 | // RValue<Short4> operator%=(const Short4 &lhs, RValue<Short4> rhs) |
| 3011 | // { |
| 3012 | // return lhs = lhs % rhs; |
| 3013 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3014 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3015 | RValue<Short4> operator&=(const Short4 &lhs, RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3016 | { |
| 3017 | return lhs = lhs & rhs; |
| 3018 | } |
| 3019 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3020 | RValue<Short4> operator|=(const Short4 &lhs, RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3021 | { |
| 3022 | return lhs = lhs | rhs; |
| 3023 | } |
| 3024 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3025 | RValue<Short4> operator^=(const Short4 &lhs, RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3026 | { |
| 3027 | return lhs = lhs ^ rhs; |
| 3028 | } |
| 3029 | |
| 3030 | RValue<Short4> operator<<=(const Short4 &lhs, unsigned char rhs) |
| 3031 | { |
| 3032 | return lhs = lhs << rhs; |
| 3033 | } |
| 3034 | |
| 3035 | RValue<Short4> operator>>=(const Short4 &lhs, unsigned char rhs) |
| 3036 | { |
| 3037 | return lhs = lhs >> rhs; |
| 3038 | } |
| 3039 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3040 | RValue<Short4> operator<<=(const Short4 &lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3041 | { |
| 3042 | return lhs = lhs << rhs; |
| 3043 | } |
| 3044 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3045 | RValue<Short4> operator>>=(const Short4 &lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3046 | { |
| 3047 | return lhs = lhs >> rhs; |
| 3048 | } |
| 3049 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3050 | // RValue<Short4> operator+(RValue<Short4> val) |
| 3051 | // { |
| 3052 | // return val; |
| 3053 | // } |
| 3054 | |
| 3055 | RValue<Short4> operator-(RValue<Short4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3056 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3057 | if(CPUID::supportsMMX2()) |
| 3058 | { |
| 3059 | return Short4(0, 0, 0, 0) - val; |
| 3060 | } |
| 3061 | else |
| 3062 | { |
| 3063 | return RValue<Short4>(Nucleus::createNeg(val.value)); |
| 3064 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3065 | } |
| 3066 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3067 | RValue<Short4> operator~(RValue<Short4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3068 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3069 | if(CPUID::supportsMMX2()) |
| 3070 | { |
| 3071 | return val ^ Short4(0xFFFFu, 0xFFFFu, 0xFFFFu, 0xFFFFu); |
| 3072 | } |
| 3073 | else |
| 3074 | { |
| 3075 | return RValue<Short4>(Nucleus::createNot(val.value)); |
| 3076 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3077 | } |
| 3078 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3079 | RValue<Short4> RoundShort4(RValue<Float4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3080 | { |
| 3081 | RValue<Int4> v4i32 = x86::cvtps2dq(cast); |
| 3082 | v4i32 = As<Int4>(x86::packssdw(v4i32, v4i32)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3083 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3084 | return As<Short4>(Int2(v4i32)); |
| 3085 | } |
| 3086 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3087 | RValue<Short4> Max(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3088 | { |
| 3089 | return x86::pmaxsw(x, y); |
| 3090 | } |
| 3091 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3092 | RValue<Short4> Min(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3093 | { |
| 3094 | return x86::pminsw(x, y); |
| 3095 | } |
| 3096 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3097 | RValue<Short4> AddSat(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3098 | { |
| 3099 | return x86::paddsw(x, y); |
| 3100 | } |
| 3101 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3102 | RValue<Short4> SubSat(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3103 | { |
| 3104 | return x86::psubsw(x, y); |
| 3105 | } |
| 3106 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3107 | RValue<Short4> MulHigh(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3108 | { |
| 3109 | return x86::pmulhw(x, y); |
| 3110 | } |
| 3111 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3112 | RValue<Int2> MulAdd(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3113 | { |
| 3114 | return x86::pmaddwd(x, y); |
| 3115 | } |
| 3116 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3117 | RValue<SByte8> Pack(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3118 | { |
| 3119 | return x86::packsswb(x, y); |
| 3120 | } |
| 3121 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3122 | RValue<Int2> UnpackLow(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3123 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3124 | if(CPUID::supportsMMX2()) |
| 3125 | { |
| 3126 | return x86::punpcklwd(x, y); |
| 3127 | } |
| 3128 | else |
| 3129 | { |
| 3130 | Constant *shuffle[4]; |
| 3131 | shuffle[0] = Nucleus::createConstantInt(0); |
| 3132 | shuffle[1] = Nucleus::createConstantInt(4); |
| 3133 | shuffle[2] = Nucleus::createConstantInt(1); |
| 3134 | shuffle[3] = Nucleus::createConstantInt(5); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3135 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3136 | Value *packed = Nucleus::createShuffleVector(x.value, y.value, Nucleus::createConstantVector(shuffle, 4)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3137 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3138 | return RValue<Int2>(Nucleus::createBitCast(packed, Int2::getType())); |
| 3139 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3140 | } |
| 3141 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3142 | RValue<Int2> UnpackHigh(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3143 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3144 | if(CPUID::supportsMMX2()) |
| 3145 | { |
| 3146 | return x86::punpckhwd(x, y); |
| 3147 | } |
| 3148 | else |
| 3149 | { |
| 3150 | Constant *shuffle[4]; |
| 3151 | shuffle[0] = Nucleus::createConstantInt(2); |
| 3152 | shuffle[1] = Nucleus::createConstantInt(6); |
| 3153 | shuffle[2] = Nucleus::createConstantInt(3); |
| 3154 | shuffle[3] = Nucleus::createConstantInt(7); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3155 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3156 | Value *packed = Nucleus::createShuffleVector(x.value, y.value, Nucleus::createConstantVector(shuffle, 4)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3157 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3158 | return RValue<Int2>(Nucleus::createBitCast(packed, Int2::getType())); |
| 3159 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3160 | } |
| 3161 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3162 | RValue<Short4> Swizzle(RValue<Short4> x, unsigned char select) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3163 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3164 | if(CPUID::supportsMMX2()) |
| 3165 | { |
| 3166 | return x86::pshufw(x, select); |
| 3167 | } |
| 3168 | else |
| 3169 | { |
| 3170 | return RValue<Short4>(Nucleus::createSwizzle(x.value, select)); |
| 3171 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3172 | } |
| 3173 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3174 | RValue<Short4> Insert(RValue<Short4> val, RValue<Short> element, int i) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3175 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3176 | if(CPUID::supportsMMX2()) |
| 3177 | { |
| 3178 | return x86::pinsrw(val, Int(element), i); |
| 3179 | } |
| 3180 | else |
| 3181 | { |
| 3182 | return RValue<Short4>(Nucleus::createInsertElement(val.value, element.value, i)); |
| 3183 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3184 | } |
| 3185 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3186 | RValue<Short> Extract(RValue<Short4> val, int i) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3187 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3188 | if(CPUID::supportsMMX2()) |
| 3189 | { |
| 3190 | return Short(x86::pextrw(val, i)); |
| 3191 | } |
| 3192 | else |
| 3193 | { |
| 3194 | return RValue<Short>(Nucleus::createExtractElement(val.value, i)); |
| 3195 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3196 | } |
| 3197 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3198 | RValue<Short4> CmpGT(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3199 | { |
| 3200 | return x86::pcmpgtw(x, y); |
| 3201 | } |
| 3202 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3203 | RValue<Short4> CmpEQ(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3204 | { |
| 3205 | return x86::pcmpeqw(x, y); |
| 3206 | } |
| 3207 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3208 | Type *Short4::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3209 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3210 | if(CPUID::supportsMMX2()) |
| 3211 | { |
| 3212 | return MMX::getType(); |
| 3213 | } |
| 3214 | else |
| 3215 | { |
| 3216 | return VectorType::get(Short::getType(), 4); |
| 3217 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3218 | } |
| 3219 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3220 | UShort4::UShort4(RValue<Int4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3221 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3222 | *this = Short4(cast); |
| 3223 | } |
| 3224 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3225 | UShort4::UShort4(RValue<Float4> cast, bool saturate) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3226 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3227 | Float4 sat; |
| 3228 | |
| 3229 | if(saturate) |
| 3230 | { |
| 3231 | if(CPUID::supportsSSE4_1()) |
| 3232 | { |
| 3233 | sat = Min(cast, Float4(0xFFFF)); // packusdw takes care of 0x0000 saturation |
| 3234 | } |
| 3235 | else |
| 3236 | { |
| 3237 | sat = Max(Min(cast, Float4(0xFFFF)), Float4(0x0000)); |
| 3238 | } |
| 3239 | } |
| 3240 | else |
| 3241 | { |
| 3242 | sat = cast; |
| 3243 | } |
| 3244 | |
| 3245 | Int4 int4(sat); |
| 3246 | |
| 3247 | if(!saturate || !CPUID::supportsSSE4_1()) |
| 3248 | { |
| 3249 | *this = Short4(Int4(int4)); |
| 3250 | } |
| 3251 | else |
| 3252 | { |
| 3253 | *this = As<Short4>(Int2(As<Int4>(x86::packusdw(As<UInt4>(int4), As<UInt4>(int4))))); |
| 3254 | } |
| 3255 | } |
| 3256 | |
| 3257 | UShort4::UShort4() |
| 3258 | { |
| 3259 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3260 | } |
| 3261 | |
| 3262 | UShort4::UShort4(unsigned short x, unsigned short y, unsigned short z, unsigned short w) |
| 3263 | { |
| 3264 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3265 | |
| 3266 | Constant *constantVector[4]; |
| 3267 | constantVector[0] = Nucleus::createConstantShort(x); |
| 3268 | constantVector[1] = Nucleus::createConstantShort(y); |
| 3269 | constantVector[2] = Nucleus::createConstantShort(z); |
| 3270 | constantVector[3] = Nucleus::createConstantShort(w); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3271 | Value *vector = Nucleus::createConstantVector(constantVector, 4); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3272 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3273 | storeValue(Nucleus::createBitCast(vector, getType())); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3274 | } |
| 3275 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3276 | UShort4::UShort4(RValue<UShort4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3277 | { |
| 3278 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3279 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3280 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3281 | } |
| 3282 | |
| 3283 | UShort4::UShort4(const UShort4 &rhs) |
| 3284 | { |
| 3285 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3286 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3287 | Value *value = rhs.loadValue(); |
| 3288 | storeValue(value); |
| 3289 | } |
| 3290 | |
| 3291 | UShort4::UShort4(const Reference<UShort4> &rhs) |
| 3292 | { |
| 3293 | // xyzw.parent = this; |
| 3294 | |
| 3295 | Value *value = rhs.loadValue(); |
| 3296 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3297 | } |
| 3298 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3299 | UShort4::UShort4(RValue<Short4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3300 | { |
| 3301 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3302 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3303 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3304 | } |
| 3305 | |
| 3306 | UShort4::UShort4(const Short4 &rhs) |
| 3307 | { |
| 3308 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3309 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3310 | Value *value = rhs.loadValue(); |
| 3311 | storeValue(value); |
| 3312 | } |
| 3313 | |
| 3314 | UShort4::UShort4(const Reference<Short4> &rhs) |
| 3315 | { |
| 3316 | // xyzw.parent = this; |
| 3317 | |
| 3318 | Value *value = rhs.loadValue(); |
| 3319 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3320 | } |
| 3321 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3322 | RValue<UShort4> UShort4::operator=(RValue<UShort4> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3323 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3324 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3325 | |
| 3326 | return rhs; |
| 3327 | } |
| 3328 | |
| 3329 | RValue<UShort4> UShort4::operator=(const UShort4 &rhs) const |
| 3330 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3331 | Value *value = rhs.loadValue(); |
| 3332 | storeValue(value); |
| 3333 | |
| 3334 | return RValue<UShort4>(value); |
| 3335 | } |
| 3336 | |
| 3337 | RValue<UShort4> UShort4::operator=(const Reference<UShort4> &rhs) const |
| 3338 | { |
| 3339 | Value *value = rhs.loadValue(); |
| 3340 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3341 | |
| 3342 | return RValue<UShort4>(value); |
| 3343 | } |
| 3344 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3345 | RValue<UShort4> UShort4::operator=(RValue<Short4> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3346 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3347 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3348 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3349 | return RValue<UShort4>(rhs); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3350 | } |
| 3351 | |
| 3352 | RValue<UShort4> UShort4::operator=(const Short4 &rhs) const |
| 3353 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3354 | Value *value = rhs.loadValue(); |
| 3355 | storeValue(value); |
| 3356 | |
| 3357 | return RValue<UShort4>(value); |
| 3358 | } |
| 3359 | |
| 3360 | RValue<UShort4> UShort4::operator=(const Reference<Short4> &rhs) const |
| 3361 | { |
| 3362 | Value *value = rhs.loadValue(); |
| 3363 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3364 | |
| 3365 | return RValue<UShort4>(value); |
| 3366 | } |
| 3367 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3368 | RValue<UShort4> operator+(RValue<UShort4> lhs, RValue<UShort4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3369 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3370 | if(CPUID::supportsMMX2()) |
| 3371 | { |
| 3372 | return As<UShort4>(x86::paddw(As<Short4>(lhs), As<Short4>(rhs))); |
| 3373 | } |
| 3374 | else |
| 3375 | { |
| 3376 | return RValue<UShort4>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 3377 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3378 | } |
| 3379 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3380 | RValue<UShort4> operator-(RValue<UShort4> lhs, RValue<UShort4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3381 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3382 | if(CPUID::supportsMMX2()) |
| 3383 | { |
| 3384 | return As<UShort4>(x86::psubw(As<Short4>(lhs), As<Short4>(rhs))); |
| 3385 | } |
| 3386 | else |
| 3387 | { |
| 3388 | return RValue<UShort4>(Nucleus::createSub(lhs.value, rhs.value)); |
| 3389 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3390 | } |
| 3391 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3392 | |
| 3393 | RValue<UShort4> operator*(RValue<UShort4> lhs, RValue<UShort4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3394 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3395 | if(CPUID::supportsMMX2()) |
| 3396 | { |
| 3397 | return As<UShort4>(x86::pmullw(As<Short4>(lhs), As<Short4>(rhs))); |
| 3398 | } |
| 3399 | else |
| 3400 | { |
| 3401 | return RValue<UShort4>(Nucleus::createMul(lhs.value, rhs.value)); |
| 3402 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3403 | } |
| 3404 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3405 | RValue<UShort4> operator<<(RValue<UShort4> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3406 | { |
| 3407 | // return RValue<Short4>(Nucleus::createShl(lhs.value, rhs.value)); |
| 3408 | |
| 3409 | return As<UShort4>(x86::psllw(As<Short4>(lhs), rhs)); |
| 3410 | } |
| 3411 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3412 | RValue<UShort4> operator>>(RValue<UShort4> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3413 | { |
| 3414 | // return RValue<Short4>(Nucleus::createLShr(lhs.value, rhs.value)); |
| 3415 | |
| 3416 | return x86::psrlw(lhs, rhs); |
| 3417 | } |
| 3418 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3419 | RValue<UShort4> operator<<(RValue<UShort4> lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3420 | { |
| 3421 | // return RValue<Short4>(Nucleus::createShl(lhs.value, rhs.value)); |
| 3422 | |
| 3423 | return As<UShort4>(x86::psllw(As<Short4>(lhs), rhs)); |
| 3424 | } |
| 3425 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3426 | RValue<UShort4> operator>>(RValue<UShort4> lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3427 | { |
| 3428 | // return RValue<Short4>(Nucleus::createLShr(lhs.value, rhs.value)); |
| 3429 | |
| 3430 | return x86::psrlw(lhs, rhs); |
| 3431 | } |
| 3432 | |
| 3433 | RValue<UShort4> operator<<=(const UShort4 &lhs, unsigned char rhs) |
| 3434 | { |
| 3435 | return lhs = lhs << rhs; |
| 3436 | } |
| 3437 | |
| 3438 | RValue<UShort4> operator>>=(const UShort4 &lhs, unsigned char rhs) |
| 3439 | { |
| 3440 | return lhs = lhs >> rhs; |
| 3441 | } |
| 3442 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3443 | RValue<UShort4> operator<<=(const UShort4 &lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3444 | { |
| 3445 | return lhs = lhs << rhs; |
| 3446 | } |
| 3447 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3448 | RValue<UShort4> operator>>=(const UShort4 &lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3449 | { |
| 3450 | return lhs = lhs >> rhs; |
| 3451 | } |
| 3452 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3453 | RValue<UShort4> operator~(RValue<UShort4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3454 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3455 | if(CPUID::supportsMMX2()) |
| 3456 | { |
| 3457 | return As<UShort4>(As<Short4>(val) ^ Short4(0xFFFFu, 0xFFFFu, 0xFFFFu, 0xFFFFu)); |
| 3458 | } |
| 3459 | else |
| 3460 | { |
| 3461 | return RValue<UShort4>(Nucleus::createNot(val.value)); |
| 3462 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3463 | } |
| 3464 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3465 | RValue<UShort4> Max(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3466 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3467 | 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] | 3468 | } |
| 3469 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3470 | RValue<UShort4> Min(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3471 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3472 | 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] | 3473 | } |
| 3474 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3475 | RValue<UShort4> AddSat(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3476 | { |
| 3477 | return x86::paddusw(x, y); |
| 3478 | } |
| 3479 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3480 | RValue<UShort4> SubSat(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3481 | { |
| 3482 | return x86::psubusw(x, y); |
| 3483 | } |
| 3484 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3485 | RValue<UShort4> MulHigh(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3486 | { |
| 3487 | return x86::pmulhuw(x, y); |
| 3488 | } |
| 3489 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3490 | RValue<UShort4> Average(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3491 | { |
| 3492 | return x86::pavgw(x, y); |
| 3493 | } |
| 3494 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3495 | RValue<Byte8> Pack(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3496 | { |
| 3497 | return x86::packuswb(x, y); |
| 3498 | } |
| 3499 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3500 | Type *UShort4::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3501 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3502 | if(CPUID::supportsMMX2()) |
| 3503 | { |
| 3504 | return MMX::getType(); |
| 3505 | } |
| 3506 | else |
| 3507 | { |
| 3508 | return VectorType::get(UShort::getType(), 4); |
| 3509 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3510 | } |
| 3511 | |
| 3512 | Short8::Short8(short c0, short c1, short c2, short c3, short c4, short c5, short c6, short c7) |
| 3513 | { |
| 3514 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3515 | |
| 3516 | Constant *constantVector[8]; |
| 3517 | constantVector[0] = Nucleus::createConstantShort(c0); |
| 3518 | constantVector[1] = Nucleus::createConstantShort(c1); |
| 3519 | constantVector[2] = Nucleus::createConstantShort(c2); |
| 3520 | constantVector[3] = Nucleus::createConstantShort(c3); |
| 3521 | constantVector[4] = Nucleus::createConstantShort(c4); |
| 3522 | constantVector[5] = Nucleus::createConstantShort(c5); |
| 3523 | constantVector[6] = Nucleus::createConstantShort(c6); |
| 3524 | constantVector[7] = Nucleus::createConstantShort(c7); |
| 3525 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3526 | storeValue(Nucleus::createConstantVector(constantVector, 8)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3527 | } |
| 3528 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3529 | Short8::Short8(RValue<Short8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3530 | { |
| 3531 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3532 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3533 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3534 | } |
| 3535 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3536 | RValue<Short8> operator+(RValue<Short8> lhs, RValue<Short8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3537 | { |
| 3538 | return RValue<Short8>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 3539 | } |
| 3540 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3541 | RValue<Short8> operator&(RValue<Short8> lhs, RValue<Short8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3542 | { |
| 3543 | return RValue<Short8>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 3544 | } |
| 3545 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3546 | RValue<Short8> operator<<(RValue<Short8> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3547 | { |
| 3548 | return x86::psllw(lhs, rhs); // FIXME: Fallback required |
| 3549 | } |
| 3550 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3551 | RValue<Short8> operator>>(RValue<Short8> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3552 | { |
| 3553 | return x86::psraw(lhs, rhs); // FIXME: Fallback required |
| 3554 | } |
| 3555 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3556 | RValue<Short8> Concatenate(RValue<Short4> lo, RValue<Short4> hi) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3557 | { |
| 3558 | Value *loLong = Nucleus::createBitCast(lo.value, Long::getType()); |
| 3559 | Value *hiLong = Nucleus::createBitCast(hi.value, Long::getType()); |
| 3560 | |
| 3561 | Value *long2 = UndefValue::get(Long2::getType()); |
| 3562 | long2 = Nucleus::createInsertElement(long2, loLong, 0); |
| 3563 | long2 = Nucleus::createInsertElement(long2, hiLong, 1); |
| 3564 | Value *short8 = Nucleus::createBitCast(long2, Short8::getType()); |
| 3565 | |
| 3566 | return RValue<Short8>(short8); |
| 3567 | } |
| 3568 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3569 | RValue<Int4> MulAdd(RValue<Short8> x, RValue<Short8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3570 | { |
| 3571 | return x86::pmaddwd(x, y); // FIXME: Fallback required |
| 3572 | } |
| 3573 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3574 | RValue<Short8> MulHigh(RValue<Short8> x, RValue<Short8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3575 | { |
| 3576 | return x86::pmulhw(x, y); // FIXME: Fallback required |
| 3577 | } |
| 3578 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3579 | Type *Short8::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3580 | { |
| 3581 | return VectorType::get(Short::getType(), 8); |
| 3582 | } |
| 3583 | |
| 3584 | 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) |
| 3585 | { |
| 3586 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3587 | |
| 3588 | Constant *constantVector[8]; |
| 3589 | constantVector[0] = Nucleus::createConstantShort(c0); |
| 3590 | constantVector[1] = Nucleus::createConstantShort(c1); |
| 3591 | constantVector[2] = Nucleus::createConstantShort(c2); |
| 3592 | constantVector[3] = Nucleus::createConstantShort(c3); |
| 3593 | constantVector[4] = Nucleus::createConstantShort(c4); |
| 3594 | constantVector[5] = Nucleus::createConstantShort(c5); |
| 3595 | constantVector[6] = Nucleus::createConstantShort(c6); |
| 3596 | constantVector[7] = Nucleus::createConstantShort(c7); |
| 3597 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3598 | storeValue(Nucleus::createConstantVector(constantVector, 8)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3599 | } |
| 3600 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3601 | UShort8::UShort8(RValue<UShort8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3602 | { |
| 3603 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3604 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3605 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3606 | } |
| 3607 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3608 | RValue<UShort8> UShort8::operator=(RValue<UShort8> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3609 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3610 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3611 | |
| 3612 | return rhs; |
| 3613 | } |
| 3614 | |
| 3615 | RValue<UShort8> UShort8::operator=(const UShort8 &rhs) const |
| 3616 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3617 | Value *value = rhs.loadValue(); |
| 3618 | storeValue(value); |
| 3619 | |
| 3620 | return RValue<UShort8>(value); |
| 3621 | } |
| 3622 | |
| 3623 | RValue<UShort8> UShort8::operator=(const Reference<UShort8> &rhs) const |
| 3624 | { |
| 3625 | Value *value = rhs.loadValue(); |
| 3626 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3627 | |
| 3628 | return RValue<UShort8>(value); |
| 3629 | } |
| 3630 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3631 | RValue<UShort8> operator&(RValue<UShort8> lhs, RValue<UShort8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3632 | { |
| 3633 | return RValue<UShort8>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 3634 | } |
| 3635 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3636 | RValue<UShort8> operator<<(RValue<UShort8> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3637 | { |
| 3638 | return As<UShort8>(x86::psllw(As<Short8>(lhs), rhs)); // FIXME: Fallback required |
| 3639 | } |
| 3640 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3641 | RValue<UShort8> operator>>(RValue<UShort8> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3642 | { |
| 3643 | return x86::psrlw(lhs, rhs); // FIXME: Fallback required |
| 3644 | } |
| 3645 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3646 | RValue<UShort8> operator+(RValue<UShort8> lhs, RValue<UShort8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3647 | { |
| 3648 | return RValue<UShort8>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 3649 | } |
| 3650 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3651 | RValue<UShort8> operator*(RValue<UShort8> lhs, RValue<UShort8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3652 | { |
| 3653 | return RValue<UShort8>(Nucleus::createMul(lhs.value, rhs.value)); |
| 3654 | } |
| 3655 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3656 | RValue<UShort8> operator+=(const UShort8 &lhs, RValue<UShort8> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3657 | { |
| 3658 | return lhs = lhs + rhs; |
| 3659 | } |
| 3660 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3661 | RValue<UShort8> operator~(RValue<UShort8> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3662 | { |
| 3663 | return RValue<UShort8>(Nucleus::createNot(val.value)); |
| 3664 | } |
| 3665 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3666 | 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] | 3667 | { |
| 3668 | Constant *pshufb[16]; |
| 3669 | pshufb[0] = Nucleus::createConstantInt(select0 + 0); |
| 3670 | pshufb[1] = Nucleus::createConstantInt(select0 + 1); |
| 3671 | pshufb[2] = Nucleus::createConstantInt(select1 + 0); |
| 3672 | pshufb[3] = Nucleus::createConstantInt(select1 + 1); |
| 3673 | pshufb[4] = Nucleus::createConstantInt(select2 + 0); |
| 3674 | pshufb[5] = Nucleus::createConstantInt(select2 + 1); |
| 3675 | pshufb[6] = Nucleus::createConstantInt(select3 + 0); |
| 3676 | pshufb[7] = Nucleus::createConstantInt(select3 + 1); |
| 3677 | pshufb[8] = Nucleus::createConstantInt(select4 + 0); |
| 3678 | pshufb[9] = Nucleus::createConstantInt(select4 + 1); |
| 3679 | pshufb[10] = Nucleus::createConstantInt(select5 + 0); |
| 3680 | pshufb[11] = Nucleus::createConstantInt(select5 + 1); |
| 3681 | pshufb[12] = Nucleus::createConstantInt(select6 + 0); |
| 3682 | pshufb[13] = Nucleus::createConstantInt(select6 + 1); |
| 3683 | pshufb[14] = Nucleus::createConstantInt(select7 + 0); |
| 3684 | pshufb[15] = Nucleus::createConstantInt(select7 + 1); |
| 3685 | |
| 3686 | Value *byte16 = Nucleus::createBitCast(x.value, Byte16::getType()); |
| 3687 | Value *shuffle = Nucleus::createShuffleVector(byte16, UndefValue::get(Byte16::getType()), Nucleus::createConstantVector(pshufb, 16)); |
| 3688 | Value *short8 = Nucleus::createBitCast(shuffle, UShort8::getType()); |
| 3689 | |
| 3690 | return RValue<UShort8>(short8); |
| 3691 | } |
| 3692 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3693 | RValue<UShort8> Concatenate(RValue<UShort4> lo, RValue<UShort4> hi) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3694 | { |
| 3695 | Value *loLong = Nucleus::createBitCast(lo.value, Long::getType()); |
| 3696 | Value *hiLong = Nucleus::createBitCast(hi.value, Long::getType()); |
| 3697 | |
| 3698 | Value *long2 = UndefValue::get(Long2::getType()); |
| 3699 | long2 = Nucleus::createInsertElement(long2, loLong, 0); |
| 3700 | long2 = Nucleus::createInsertElement(long2, hiLong, 1); |
| 3701 | Value *short8 = Nucleus::createBitCast(long2, Short8::getType()); |
| 3702 | |
| 3703 | return RValue<UShort8>(short8); |
| 3704 | } |
| 3705 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3706 | RValue<UShort8> MulHigh(RValue<UShort8> x, RValue<UShort8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3707 | { |
| 3708 | return x86::pmulhuw(x, y); // FIXME: Fallback required |
| 3709 | } |
| 3710 | |
| 3711 | // 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] | 3712 | // RValue<UShort8> PackRepeat(RValue<Byte16> x, RValue<Byte16> y, int element) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3713 | // { |
| 3714 | // Constant *pshufb[16]; |
| 3715 | // pshufb[0] = Nucleus::createConstantInt(element + 0); |
| 3716 | // pshufb[1] = Nucleus::createConstantInt(element + 0); |
| 3717 | // pshufb[2] = Nucleus::createConstantInt(element + 4); |
| 3718 | // pshufb[3] = Nucleus::createConstantInt(element + 4); |
| 3719 | // pshufb[4] = Nucleus::createConstantInt(element + 8); |
| 3720 | // pshufb[5] = Nucleus::createConstantInt(element + 8); |
| 3721 | // pshufb[6] = Nucleus::createConstantInt(element + 12); |
| 3722 | // pshufb[7] = Nucleus::createConstantInt(element + 12); |
| 3723 | // pshufb[8] = Nucleus::createConstantInt(element + 16); |
| 3724 | // pshufb[9] = Nucleus::createConstantInt(element + 16); |
| 3725 | // pshufb[10] = Nucleus::createConstantInt(element + 20); |
| 3726 | // pshufb[11] = Nucleus::createConstantInt(element + 20); |
| 3727 | // pshufb[12] = Nucleus::createConstantInt(element + 24); |
| 3728 | // pshufb[13] = Nucleus::createConstantInt(element + 24); |
| 3729 | // pshufb[14] = Nucleus::createConstantInt(element + 28); |
| 3730 | // pshufb[15] = Nucleus::createConstantInt(element + 28); |
| 3731 | // |
| 3732 | // Value *shuffle = Nucleus::createShuffleVector(x.value, y.value, Nucleus::createConstantVector(pshufb, 16)); |
| 3733 | // Value *short8 = Nucleus::createBitCast(shuffle, UShort8::getType()); |
| 3734 | // |
| 3735 | // return RValue<UShort8>(short8); |
| 3736 | // } |
| 3737 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3738 | Type *UShort8::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3739 | { |
| 3740 | return VectorType::get(UShort::getType(), 8); |
| 3741 | } |
| 3742 | |
| 3743 | Int::Int(Argument *argument) |
| 3744 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3745 | storeValue(argument); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3746 | } |
| 3747 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3748 | Int::Int(RValue<Byte> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3749 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3750 | Value *integer = Nucleus::createZExt(cast.value, Int::getType()); |
| 3751 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3752 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3753 | } |
| 3754 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3755 | Int::Int(RValue<SByte> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3756 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3757 | Value *integer = Nucleus::createSExt(cast.value, Int::getType()); |
| 3758 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3759 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3760 | } |
| 3761 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3762 | Int::Int(RValue<Short> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3763 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3764 | Value *integer = Nucleus::createSExt(cast.value, Int::getType()); |
| 3765 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3766 | storeValue(integer); |
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<UShort> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3770 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3771 | Value *integer = Nucleus::createZExt(cast.value, Int::getType()); |
| 3772 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3773 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3774 | } |
| 3775 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3776 | Int::Int(RValue<Int2> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3777 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3778 | *this = Extract(cast, 0); |
| 3779 | } |
| 3780 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3781 | Int::Int(RValue<Long> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3782 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3783 | Value *integer = Nucleus::createTrunc(cast.value, Int::getType()); |
| 3784 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3785 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3786 | } |
| 3787 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3788 | Int::Int(RValue<Float> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3789 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3790 | Value *integer = Nucleus::createFPToSI(cast.value, Int::getType()); |
| 3791 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3792 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3793 | } |
| 3794 | |
| 3795 | Int::Int() |
| 3796 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3797 | } |
| 3798 | |
| 3799 | Int::Int(int x) |
| 3800 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3801 | storeValue(Nucleus::createConstantInt(x)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3802 | } |
| 3803 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3804 | Int::Int(RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3805 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3806 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3807 | } |
| 3808 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3809 | Int::Int(RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3810 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3811 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3812 | } |
| 3813 | |
| 3814 | Int::Int(const Int &rhs) |
| 3815 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3816 | Value *value = rhs.loadValue(); |
| 3817 | storeValue(value); |
| 3818 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3819 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3820 | Int::Int(const Reference<Int> &rhs) |
| 3821 | { |
| 3822 | Value *value = rhs.loadValue(); |
| 3823 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3824 | } |
| 3825 | |
| 3826 | Int::Int(const UInt &rhs) |
| 3827 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3828 | Value *value = rhs.loadValue(); |
| 3829 | storeValue(value); |
| 3830 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3831 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3832 | Int::Int(const Reference<UInt> &rhs) |
| 3833 | { |
| 3834 | Value *value = rhs.loadValue(); |
| 3835 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3836 | } |
| 3837 | |
| 3838 | RValue<Int> Int::operator=(int rhs) const |
| 3839 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3840 | return RValue<Int>(storeValue(Nucleus::createConstantInt(rhs))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3841 | } |
| 3842 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3843 | RValue<Int> Int::operator=(RValue<Int> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3844 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3845 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3846 | |
| 3847 | return rhs; |
| 3848 | } |
| 3849 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3850 | RValue<Int> Int::operator=(RValue<UInt> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3851 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3852 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3853 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3854 | return RValue<Int>(rhs); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3855 | } |
| 3856 | |
| 3857 | RValue<Int> Int::operator=(const Int &rhs) const |
| 3858 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3859 | Value *value = rhs.loadValue(); |
| 3860 | storeValue(value); |
| 3861 | |
| 3862 | return RValue<Int>(value); |
| 3863 | } |
| 3864 | |
| 3865 | RValue<Int> Int::operator=(const Reference<Int> &rhs) const |
| 3866 | { |
| 3867 | Value *value = rhs.loadValue(); |
| 3868 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3869 | |
| 3870 | return RValue<Int>(value); |
| 3871 | } |
| 3872 | |
| 3873 | RValue<Int> Int::operator=(const UInt &rhs) const |
| 3874 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3875 | Value *value = rhs.loadValue(); |
| 3876 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3877 | |
| 3878 | return RValue<Int>(value); |
| 3879 | } |
| 3880 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3881 | RValue<Int> Int::operator=(const Reference<UInt> &rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3882 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3883 | Value *value = rhs.loadValue(); |
| 3884 | storeValue(value); |
| 3885 | |
| 3886 | return RValue<Int>(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 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::createAdd(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::createSub(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::createMul(lhs.value, rhs.value)); |
| 3902 | } |
| 3903 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3904 | RValue<Int> operator/(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3905 | { |
| 3906 | return RValue<Int>(Nucleus::createSDiv(lhs.value, rhs.value)); |
| 3907 | } |
| 3908 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3909 | RValue<Int> operator%(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3910 | { |
| 3911 | return RValue<Int>(Nucleus::createSRem(lhs.value, rhs.value)); |
| 3912 | } |
| 3913 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3914 | RValue<Int> operator&(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3915 | { |
| 3916 | return RValue<Int>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 3917 | } |
| 3918 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3919 | RValue<Int> operator|(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3920 | { |
| 3921 | return RValue<Int>(Nucleus::createOr(lhs.value, rhs.value)); |
| 3922 | } |
| 3923 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3924 | RValue<Int> operator^(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3925 | { |
| 3926 | return RValue<Int>(Nucleus::createXor(lhs.value, rhs.value)); |
| 3927 | } |
| 3928 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3929 | RValue<Int> operator<<(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3930 | { |
| 3931 | return RValue<Int>(Nucleus::createShl(lhs.value, rhs.value)); |
| 3932 | } |
| 3933 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3934 | RValue<Int> operator>>(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3935 | { |
| 3936 | return RValue<Int>(Nucleus::createAShr(lhs.value, rhs.value)); |
| 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/=(const Int &lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3955 | { |
| 3956 | return lhs = lhs / rhs; |
| 3957 | } |
| 3958 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3959 | RValue<Int> operator%=(const Int &lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3960 | { |
| 3961 | return lhs = lhs % rhs; |
| 3962 | } |
| 3963 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3964 | RValue<Int> operator&=(const Int &lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3965 | { |
| 3966 | return lhs = lhs & rhs; |
| 3967 | } |
| 3968 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3969 | RValue<Int> operator|=(const Int &lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3970 | { |
| 3971 | return lhs = lhs | rhs; |
| 3972 | } |
| 3973 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3974 | RValue<Int> operator^=(const Int &lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3975 | { |
| 3976 | return lhs = lhs ^ rhs; |
| 3977 | } |
| 3978 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3979 | RValue<Int> operator<<=(const Int &lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3980 | { |
| 3981 | return lhs = lhs << rhs; |
| 3982 | } |
| 3983 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3984 | RValue<Int> operator>>=(const Int &lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3985 | { |
| 3986 | return lhs = lhs >> rhs; |
| 3987 | } |
| 3988 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3989 | RValue<Int> operator+(RValue<Int> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3990 | { |
| 3991 | return val; |
| 3992 | } |
| 3993 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3994 | RValue<Int> operator-(RValue<Int> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 3995 | { |
| 3996 | return RValue<Int>(Nucleus::createNeg(val.value)); |
| 3997 | } |
| 3998 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 3999 | RValue<Int> operator~(RValue<Int> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4000 | { |
| 4001 | return RValue<Int>(Nucleus::createNot(val.value)); |
| 4002 | } |
| 4003 | |
| 4004 | RValue<Int> operator++(const Int &val, int) // Post-increment |
| 4005 | { |
| 4006 | RValue<Int> res = val; |
| 4007 | |
| 4008 | Value *inc = Nucleus::createAdd(res.value, Nucleus::createConstantInt(1)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4009 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4010 | |
| 4011 | return res; |
| 4012 | } |
| 4013 | |
| 4014 | const Int &operator++(const Int &val) // Pre-increment |
| 4015 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4016 | Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantInt(1)); |
| 4017 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4018 | |
| 4019 | return val; |
| 4020 | } |
| 4021 | |
| 4022 | RValue<Int> operator--(const Int &val, int) // Post-decrement |
| 4023 | { |
| 4024 | RValue<Int> res = val; |
| 4025 | |
| 4026 | Value *inc = Nucleus::createSub(res.value, Nucleus::createConstantInt(1)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4027 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4028 | |
| 4029 | return res; |
| 4030 | } |
| 4031 | |
| 4032 | const Int &operator--(const Int &val) // Pre-decrement |
| 4033 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4034 | Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantInt(1)); |
| 4035 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4036 | |
| 4037 | return val; |
| 4038 | } |
| 4039 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4040 | RValue<Bool> operator<(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4041 | { |
| 4042 | return RValue<Bool>(Nucleus::createICmpSLT(lhs.value, rhs.value)); |
| 4043 | } |
| 4044 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4045 | RValue<Bool> operator<=(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4046 | { |
| 4047 | return RValue<Bool>(Nucleus::createICmpSLE(lhs.value, rhs.value)); |
| 4048 | } |
| 4049 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4050 | RValue<Bool> operator>(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4051 | { |
| 4052 | return RValue<Bool>(Nucleus::createICmpSGT(lhs.value, rhs.value)); |
| 4053 | } |
| 4054 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4055 | RValue<Bool> operator>=(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4056 | { |
| 4057 | return RValue<Bool>(Nucleus::createICmpSGE(lhs.value, rhs.value)); |
| 4058 | } |
| 4059 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4060 | RValue<Bool> operator!=(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4061 | { |
| 4062 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value)); |
| 4063 | } |
| 4064 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4065 | RValue<Bool> operator==(RValue<Int> lhs, RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4066 | { |
| 4067 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value)); |
| 4068 | } |
| 4069 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4070 | RValue<Int> Max(RValue<Int> x, RValue<Int> y) |
| 4071 | { |
| 4072 | return IfThenElse(x > y, x, y); |
| 4073 | } |
| 4074 | |
| 4075 | RValue<Int> Min(RValue<Int> x, RValue<Int> y) |
| 4076 | { |
| 4077 | return IfThenElse(x < y, x, y); |
| 4078 | } |
| 4079 | |
| 4080 | RValue<Int> Clamp(RValue<Int> x, RValue<Int> min, RValue<Int> max) |
| 4081 | { |
| 4082 | return Min(Max(x, min), max); |
| 4083 | } |
| 4084 | |
| 4085 | RValue<Int> RoundInt(RValue<Float> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4086 | { |
| 4087 | return x86::cvtss2si(cast); |
| 4088 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4089 | // 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] | 4090 | } |
| 4091 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4092 | Type *Int::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4093 | { |
| 4094 | return Type::getInt32Ty(*Nucleus::getContext()); |
| 4095 | } |
| 4096 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4097 | Long::Long(RValue<Int> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4098 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4099 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4100 | |
| 4101 | Value *integer = Nucleus::createSExt(cast.value, Long::getType()); |
| 4102 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4103 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4104 | } |
| 4105 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4106 | Long::Long(RValue<UInt> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4107 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4108 | Value *integer = Nucleus::createZExt(cast.value, Long::getType()); |
| 4109 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4110 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4111 | } |
| 4112 | |
| 4113 | Long::Long() |
| 4114 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4115 | } |
| 4116 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4117 | Long::Long(RValue<Long> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4118 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4119 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4120 | } |
| 4121 | |
| 4122 | RValue<Long> Long::operator=(int64_t rhs) const |
| 4123 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4124 | return RValue<Long>(storeValue(Nucleus::createConstantInt(rhs))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4125 | } |
| 4126 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4127 | RValue<Long> Long::operator=(RValue<Long> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4128 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4129 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4130 | |
| 4131 | return rhs; |
| 4132 | } |
| 4133 | |
| 4134 | RValue<Long> Long::operator=(const Long &rhs) const |
| 4135 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4136 | Value *value = rhs.loadValue(); |
| 4137 | storeValue(value); |
| 4138 | |
| 4139 | return RValue<Long>(value); |
| 4140 | } |
| 4141 | |
| 4142 | RValue<Long> Long::operator=(const Reference<Long> &rhs) const |
| 4143 | { |
| 4144 | Value *value = rhs.loadValue(); |
| 4145 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4146 | |
| 4147 | return RValue<Long>(value); |
| 4148 | } |
| 4149 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4150 | RValue<Long> operator+(RValue<Long> lhs, RValue<Long> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4151 | { |
| 4152 | return RValue<Long>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 4153 | } |
| 4154 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4155 | RValue<Long> operator-(RValue<Long> lhs, RValue<Long> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4156 | { |
| 4157 | return RValue<Long>(Nucleus::createSub(lhs.value, rhs.value)); |
| 4158 | } |
| 4159 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4160 | RValue<Long> operator+=(const Long &lhs, RValue<Long> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4161 | { |
| 4162 | return lhs = lhs + rhs; |
| 4163 | } |
| 4164 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4165 | RValue<Long> operator-=(const Long &lhs, RValue<Long> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4166 | { |
| 4167 | return lhs = lhs - rhs; |
| 4168 | } |
| 4169 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4170 | RValue<Long> AddAtomic(RValue<Pointer<Long> > x, RValue<Long> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4171 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4172 | return RValue<Long>(Nucleus::createAtomicAdd(x.value, y.value)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4173 | } |
| 4174 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4175 | Type *Long::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4176 | { |
| 4177 | return Type::getInt64Ty(*Nucleus::getContext()); |
| 4178 | } |
| 4179 | |
| 4180 | Long1::Long1(const Reference<UInt> &cast) |
| 4181 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4182 | Value *uint = cast.loadValue(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4183 | Value *int64 = Nucleus::createZExt(uint, Long::getType()); |
| 4184 | Value *long1 = Nucleus::createBitCast(int64, Long1::getType()); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4185 | |
| 4186 | storeValue(long1); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4187 | } |
| 4188 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4189 | Long1::Long1(RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4190 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4191 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4192 | } |
| 4193 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4194 | Type *Long1::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4195 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4196 | if(CPUID::supportsMMX2()) |
| 4197 | { |
| 4198 | return MMX::getType(); |
| 4199 | } |
| 4200 | else |
| 4201 | { |
| 4202 | return VectorType::get(Long::getType(), 1); |
| 4203 | } |
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 | RValue<Long2> UnpackHigh(RValue<Long2> x, RValue<Long2> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4207 | { |
| 4208 | Constant *shuffle[2]; |
| 4209 | shuffle[0] = Nucleus::createConstantInt(1); |
| 4210 | shuffle[1] = Nucleus::createConstantInt(3); |
| 4211 | |
| 4212 | Value *packed = Nucleus::createShuffleVector(x.value, y.value, Nucleus::createConstantVector(shuffle, 2)); |
| 4213 | |
| 4214 | return RValue<Long2>(packed); |
| 4215 | } |
| 4216 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4217 | Type *Long2::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4218 | { |
| 4219 | return VectorType::get(Long::getType(), 2); |
| 4220 | } |
| 4221 | |
| 4222 | UInt::UInt(Argument *argument) |
| 4223 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4224 | storeValue(argument); |
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<UShort> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4228 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4229 | Value *integer = Nucleus::createZExt(cast.value, UInt::getType()); |
| 4230 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4231 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4232 | } |
| 4233 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4234 | UInt::UInt(RValue<Long> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4235 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4236 | Value *integer = Nucleus::createTrunc(cast.value, UInt::getType()); |
| 4237 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4238 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4239 | } |
| 4240 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4241 | UInt::UInt(RValue<Float> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4242 | { |
Alexis Hetu | 77dfab4 | 2015-11-23 13:31:22 -0500 | [diff] [blame^] | 4243 | Value *integer = Nucleus::createFPToUI(cast.value, UInt::getType()); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4244 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4245 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4246 | } |
| 4247 | |
| 4248 | UInt::UInt() |
| 4249 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4250 | } |
| 4251 | |
| 4252 | UInt::UInt(int x) |
| 4253 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4254 | storeValue(Nucleus::createConstantInt(x)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4255 | } |
| 4256 | |
| 4257 | UInt::UInt(unsigned int x) |
| 4258 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4259 | storeValue(Nucleus::createConstantInt(x)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4260 | } |
| 4261 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4262 | UInt::UInt(RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4263 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4264 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4265 | } |
| 4266 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4267 | UInt::UInt(RValue<Int> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4268 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4269 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4270 | } |
| 4271 | |
| 4272 | UInt::UInt(const UInt &rhs) |
| 4273 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4274 | Value *value = rhs.loadValue(); |
| 4275 | storeValue(value); |
| 4276 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4277 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4278 | UInt::UInt(const Reference<UInt> &rhs) |
| 4279 | { |
| 4280 | Value *value = rhs.loadValue(); |
| 4281 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4282 | } |
| 4283 | |
| 4284 | UInt::UInt(const Int &rhs) |
| 4285 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4286 | Value *value = rhs.loadValue(); |
| 4287 | storeValue(value); |
| 4288 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4289 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4290 | UInt::UInt(const Reference<Int> &rhs) |
| 4291 | { |
| 4292 | Value *value = rhs.loadValue(); |
| 4293 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4294 | } |
| 4295 | |
| 4296 | RValue<UInt> UInt::operator=(unsigned int rhs) const |
| 4297 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4298 | return RValue<UInt>(storeValue(Nucleus::createConstantInt(rhs))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4299 | } |
| 4300 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4301 | RValue<UInt> UInt::operator=(RValue<UInt> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4302 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4303 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4304 | |
| 4305 | return rhs; |
| 4306 | } |
| 4307 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4308 | RValue<UInt> UInt::operator=(RValue<Int> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4309 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4310 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4311 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4312 | return RValue<UInt>(rhs); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4313 | } |
| 4314 | |
| 4315 | RValue<UInt> UInt::operator=(const UInt &rhs) const |
| 4316 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4317 | Value *value = rhs.loadValue(); |
| 4318 | storeValue(value); |
| 4319 | |
| 4320 | return RValue<UInt>(value); |
| 4321 | } |
| 4322 | |
| 4323 | RValue<UInt> UInt::operator=(const Reference<UInt> &rhs) const |
| 4324 | { |
| 4325 | Value *value = rhs.loadValue(); |
| 4326 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4327 | |
| 4328 | return RValue<UInt>(value); |
| 4329 | } |
| 4330 | |
| 4331 | RValue<UInt> UInt::operator=(const Int &rhs) const |
| 4332 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4333 | Value *value = rhs.loadValue(); |
| 4334 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4335 | |
| 4336 | return RValue<UInt>(value); |
| 4337 | } |
| 4338 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4339 | RValue<UInt> UInt::operator=(const Reference<Int> &rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4340 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4341 | Value *value = rhs.loadValue(); |
| 4342 | storeValue(value); |
| 4343 | |
| 4344 | return RValue<UInt>(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 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::createAdd(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::createSub(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::createMul(lhs.value, rhs.value)); |
| 4360 | } |
| 4361 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4362 | RValue<UInt> operator/(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4363 | { |
| 4364 | return RValue<UInt>(Nucleus::createUDiv(lhs.value, rhs.value)); |
| 4365 | } |
| 4366 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4367 | RValue<UInt> operator%(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4368 | { |
| 4369 | return RValue<UInt>(Nucleus::createURem(lhs.value, rhs.value)); |
| 4370 | } |
| 4371 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4372 | RValue<UInt> operator&(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4373 | { |
| 4374 | return RValue<UInt>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 4375 | } |
| 4376 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4377 | RValue<UInt> operator|(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4378 | { |
| 4379 | return RValue<UInt>(Nucleus::createOr(lhs.value, rhs.value)); |
| 4380 | } |
| 4381 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4382 | RValue<UInt> operator^(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4383 | { |
| 4384 | return RValue<UInt>(Nucleus::createXor(lhs.value, rhs.value)); |
| 4385 | } |
| 4386 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4387 | RValue<UInt> operator<<(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4388 | { |
| 4389 | return RValue<UInt>(Nucleus::createShl(lhs.value, rhs.value)); |
| 4390 | } |
| 4391 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4392 | RValue<UInt> operator>>(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4393 | { |
| 4394 | return RValue<UInt>(Nucleus::createLShr(lhs.value, rhs.value)); |
| 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/=(const UInt &lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4413 | { |
| 4414 | return lhs = lhs / rhs; |
| 4415 | } |
| 4416 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4417 | RValue<UInt> operator%=(const UInt &lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4418 | { |
| 4419 | return lhs = lhs % rhs; |
| 4420 | } |
| 4421 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4422 | RValue<UInt> operator&=(const UInt &lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4423 | { |
| 4424 | return lhs = lhs & rhs; |
| 4425 | } |
| 4426 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4427 | RValue<UInt> operator|=(const UInt &lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4428 | { |
| 4429 | return lhs = lhs | rhs; |
| 4430 | } |
| 4431 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4432 | RValue<UInt> operator^=(const UInt &lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4433 | { |
| 4434 | return lhs = lhs ^ rhs; |
| 4435 | } |
| 4436 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4437 | RValue<UInt> operator<<=(const UInt &lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4438 | { |
| 4439 | return lhs = lhs << rhs; |
| 4440 | } |
| 4441 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4442 | RValue<UInt> operator>>=(const UInt &lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4443 | { |
| 4444 | return lhs = lhs >> rhs; |
| 4445 | } |
| 4446 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4447 | RValue<UInt> operator+(RValue<UInt> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4448 | { |
| 4449 | return val; |
| 4450 | } |
| 4451 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4452 | RValue<UInt> operator-(RValue<UInt> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4453 | { |
| 4454 | return RValue<UInt>(Nucleus::createNeg(val.value)); |
| 4455 | } |
| 4456 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4457 | RValue<UInt> operator~(RValue<UInt> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4458 | { |
| 4459 | return RValue<UInt>(Nucleus::createNot(val.value)); |
| 4460 | } |
| 4461 | |
| 4462 | RValue<UInt> operator++(const UInt &val, int) // Post-increment |
| 4463 | { |
| 4464 | RValue<UInt> res = val; |
| 4465 | |
| 4466 | Value *inc = Nucleus::createAdd(res.value, Nucleus::createConstantInt(1)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4467 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4468 | |
| 4469 | return res; |
| 4470 | } |
| 4471 | |
| 4472 | const UInt &operator++(const UInt &val) // Pre-increment |
| 4473 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4474 | Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantInt(1)); |
| 4475 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4476 | |
| 4477 | return val; |
| 4478 | } |
| 4479 | |
| 4480 | RValue<UInt> operator--(const UInt &val, int) // Post-decrement |
| 4481 | { |
| 4482 | RValue<UInt> res = val; |
| 4483 | |
| 4484 | Value *inc = Nucleus::createSub(res.value, Nucleus::createConstantInt(1)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4485 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4486 | |
| 4487 | return res; |
| 4488 | } |
| 4489 | |
| 4490 | const UInt &operator--(const UInt &val) // Pre-decrement |
| 4491 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4492 | Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantInt(1)); |
| 4493 | val.storeValue(inc); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4494 | |
| 4495 | return val; |
| 4496 | } |
| 4497 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4498 | RValue<UInt> Max(RValue<UInt> x, RValue<UInt> y) |
| 4499 | { |
| 4500 | return IfThenElse(x > y, x, y); |
| 4501 | } |
| 4502 | |
| 4503 | RValue<UInt> Min(RValue<UInt> x, RValue<UInt> y) |
| 4504 | { |
| 4505 | return IfThenElse(x < y, x, y); |
| 4506 | } |
| 4507 | |
| 4508 | RValue<UInt> Clamp(RValue<UInt> x, RValue<UInt> min, RValue<UInt> max) |
| 4509 | { |
| 4510 | return Min(Max(x, min), max); |
| 4511 | } |
| 4512 | |
| 4513 | RValue<Bool> operator<(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4514 | { |
| 4515 | return RValue<Bool>(Nucleus::createICmpULT(lhs.value, rhs.value)); |
| 4516 | } |
| 4517 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4518 | RValue<Bool> operator<=(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4519 | { |
| 4520 | return RValue<Bool>(Nucleus::createICmpULE(lhs.value, rhs.value)); |
| 4521 | } |
| 4522 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4523 | RValue<Bool> operator>(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4524 | { |
| 4525 | return RValue<Bool>(Nucleus::createICmpUGT(lhs.value, rhs.value)); |
| 4526 | } |
| 4527 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4528 | RValue<Bool> operator>=(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4529 | { |
| 4530 | return RValue<Bool>(Nucleus::createICmpUGE(lhs.value, rhs.value)); |
| 4531 | } |
| 4532 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4533 | RValue<Bool> operator!=(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4534 | { |
| 4535 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value)); |
| 4536 | } |
| 4537 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4538 | RValue<Bool> operator==(RValue<UInt> lhs, RValue<UInt> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4539 | { |
| 4540 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value)); |
| 4541 | } |
| 4542 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4543 | // RValue<UInt> RoundUInt(RValue<Float> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4544 | // { |
| 4545 | // return x86::cvtss2si(val); // FIXME: Unsigned |
| 4546 | // |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4547 | // // 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] | 4548 | // } |
| 4549 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4550 | Type *UInt::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4551 | { |
| 4552 | return Type::getInt32Ty(*Nucleus::getContext()); |
| 4553 | } |
| 4554 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4555 | // Int2::Int2(RValue<Int> cast) |
| 4556 | // { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4557 | // Value *extend = Nucleus::createZExt(cast.value, Long::getType()); |
| 4558 | // Value *vector = Nucleus::createBitCast(extend, Int2::getType()); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4559 | // |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4560 | // Constant *shuffle[2]; |
| 4561 | // shuffle[0] = Nucleus::createConstantInt(0); |
| 4562 | // shuffle[1] = Nucleus::createConstantInt(0); |
| 4563 | // |
| 4564 | // Value *replicate = Nucleus::createShuffleVector(vector, UndefValue::get(Int2::getType()), Nucleus::createConstantVector(shuffle, 2)); |
| 4565 | // |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4566 | // storeValue(replicate); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4567 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4568 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4569 | Int2::Int2(RValue<Int4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4570 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4571 | Value *long2 = Nucleus::createBitCast(cast.value, Long2::getType()); |
| 4572 | Value *element = Nucleus::createExtractElement(long2, 0); |
| 4573 | Value *int2 = Nucleus::createBitCast(element, Int2::getType()); |
| 4574 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4575 | storeValue(int2); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4576 | } |
| 4577 | |
| 4578 | Int2::Int2() |
| 4579 | { |
| 4580 | // xy.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4581 | } |
| 4582 | |
| 4583 | Int2::Int2(int x, int y) |
| 4584 | { |
| 4585 | // xy.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4586 | |
| 4587 | Constant *constantVector[2]; |
| 4588 | constantVector[0] = Nucleus::createConstantInt(x); |
| 4589 | constantVector[1] = Nucleus::createConstantInt(y); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4590 | Value *vector = Nucleus::createConstantVector(constantVector, 2); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4591 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4592 | storeValue(Nucleus::createBitCast(vector, getType())); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4593 | } |
| 4594 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4595 | Int2::Int2(RValue<Int2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4596 | { |
| 4597 | // xy.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4598 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4599 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4600 | } |
| 4601 | |
| 4602 | Int2::Int2(const Int2 &rhs) |
| 4603 | { |
| 4604 | // xy.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4605 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4606 | Value *value = rhs.loadValue(); |
| 4607 | storeValue(value); |
| 4608 | } |
| 4609 | |
| 4610 | Int2::Int2(const Reference<Int2> &rhs) |
| 4611 | { |
| 4612 | // xy.parent = this; |
| 4613 | |
| 4614 | Value *value = rhs.loadValue(); |
| 4615 | storeValue(value); |
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> Int2::operator=(RValue<Int2> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4619 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4620 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4621 | |
| 4622 | return rhs; |
| 4623 | } |
| 4624 | |
| 4625 | RValue<Int2> Int2::operator=(const Int2 &rhs) const |
| 4626 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4627 | Value *value = rhs.loadValue(); |
| 4628 | storeValue(value); |
| 4629 | |
| 4630 | return RValue<Int2>(value); |
| 4631 | } |
| 4632 | |
| 4633 | RValue<Int2> Int2::operator=(const Reference<Int2> &rhs) const |
| 4634 | { |
| 4635 | Value *value = rhs.loadValue(); |
| 4636 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4637 | |
| 4638 | return RValue<Int2>(value); |
| 4639 | } |
| 4640 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4641 | RValue<Int2> operator+(RValue<Int2> lhs, RValue<Int2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4642 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4643 | if(CPUID::supportsMMX2()) |
| 4644 | { |
| 4645 | return x86::paddd(lhs, rhs); |
| 4646 | } |
| 4647 | else |
| 4648 | { |
| 4649 | return RValue<Int2>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 4650 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4651 | } |
| 4652 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4653 | RValue<Int2> operator-(RValue<Int2> lhs, RValue<Int2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4654 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4655 | if(CPUID::supportsMMX2()) |
| 4656 | { |
| 4657 | return x86::psubd(lhs, rhs); |
| 4658 | } |
| 4659 | else |
| 4660 | { |
| 4661 | return RValue<Int2>(Nucleus::createSub(lhs.value, rhs.value)); |
| 4662 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4663 | } |
| 4664 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4665 | // RValue<Int2> operator*(RValue<Int2> lhs, RValue<Int2> rhs) |
| 4666 | // { |
| 4667 | // return RValue<Int2>(Nucleus::createMul(lhs.value, rhs.value)); |
| 4668 | // } |
| 4669 | |
| 4670 | // RValue<Int2> operator/(RValue<Int2> lhs, RValue<Int2> rhs) |
| 4671 | // { |
| 4672 | // return RValue<Int2>(Nucleus::createSDiv(lhs.value, rhs.value)); |
| 4673 | // } |
| 4674 | |
| 4675 | // RValue<Int2> operator%(RValue<Int2> lhs, RValue<Int2> rhs) |
| 4676 | // { |
| 4677 | // return RValue<Int2>(Nucleus::createSRem(lhs.value, rhs.value)); |
| 4678 | // } |
| 4679 | |
| 4680 | RValue<Int2> operator&(RValue<Int2> lhs, RValue<Int2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4681 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4682 | if(CPUID::supportsMMX2()) |
| 4683 | { |
| 4684 | return As<Int2>(x86::pand(As<Short4>(lhs), As<Short4>(rhs))); |
| 4685 | } |
| 4686 | else |
| 4687 | { |
| 4688 | return RValue<Int2>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 4689 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4690 | } |
| 4691 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4692 | RValue<Int2> operator|(RValue<Int2> lhs, RValue<Int2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4693 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4694 | if(CPUID::supportsMMX2()) |
| 4695 | { |
| 4696 | return As<Int2>(x86::por(As<Short4>(lhs), As<Short4>(rhs))); |
| 4697 | } |
| 4698 | else |
| 4699 | { |
| 4700 | return RValue<Int2>(Nucleus::createOr(lhs.value, rhs.value)); |
| 4701 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4702 | } |
| 4703 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4704 | RValue<Int2> operator^(RValue<Int2> lhs, RValue<Int2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4705 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4706 | if(CPUID::supportsMMX2()) |
| 4707 | { |
| 4708 | return As<Int2>(x86::pxor(As<Short4>(lhs), As<Short4>(rhs))); |
| 4709 | } |
| 4710 | else |
| 4711 | { |
| 4712 | return RValue<Int2>(Nucleus::createXor(lhs.value, rhs.value)); |
| 4713 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4714 | } |
| 4715 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4716 | RValue<Int2> operator<<(RValue<Int2> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4717 | { |
| 4718 | // return RValue<Int2>(Nucleus::createShl(lhs.value, rhs.value)); |
| 4719 | |
| 4720 | return x86::pslld(lhs, rhs); |
| 4721 | } |
| 4722 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4723 | RValue<Int2> operator>>(RValue<Int2> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4724 | { |
| 4725 | // return RValue<Int2>(Nucleus::createAShr(lhs.value, rhs.value)); |
| 4726 | |
| 4727 | return x86::psrad(lhs, rhs); |
| 4728 | } |
| 4729 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4730 | RValue<Int2> operator<<(RValue<Int2> lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4731 | { |
| 4732 | // return RValue<Int2>(Nucleus::createShl(lhs.value, rhs.value)); |
| 4733 | |
| 4734 | return x86::pslld(lhs, rhs); |
| 4735 | } |
| 4736 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4737 | RValue<Int2> operator>>(RValue<Int2> lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4738 | { |
| 4739 | // return RValue<Int2>(Nucleus::createAShr(lhs.value, rhs.value)); |
| 4740 | |
| 4741 | return x86::psrad(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 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4749 | RValue<Int2> operator-=(const Int2 &lhs, RValue<Int2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4750 | { |
| 4751 | return lhs = lhs - rhs; |
| 4752 | } |
| 4753 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4754 | // RValue<Int2> operator*=(const Int2 &lhs, RValue<Int2> rhs) |
| 4755 | // { |
| 4756 | // return lhs = lhs * rhs; |
| 4757 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4758 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4759 | // RValue<Int2> operator/=(const Int2 &lhs, RValue<Int2> rhs) |
| 4760 | // { |
| 4761 | // return lhs = lhs / rhs; |
| 4762 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4763 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4764 | // RValue<Int2> operator%=(const Int2 &lhs, RValue<Int2> rhs) |
| 4765 | // { |
| 4766 | // return lhs = lhs % rhs; |
| 4767 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4768 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4769 | RValue<Int2> operator&=(const Int2 &lhs, RValue<Int2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4770 | { |
| 4771 | return lhs = lhs & rhs; |
| 4772 | } |
| 4773 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4774 | RValue<Int2> operator|=(const Int2 &lhs, RValue<Int2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4775 | { |
| 4776 | return lhs = lhs | rhs; |
| 4777 | } |
| 4778 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4779 | RValue<Int2> operator^=(const Int2 &lhs, RValue<Int2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4780 | { |
| 4781 | return lhs = lhs ^ rhs; |
| 4782 | } |
| 4783 | |
| 4784 | RValue<Int2> operator<<=(const Int2 &lhs, unsigned char rhs) |
| 4785 | { |
| 4786 | return lhs = lhs << rhs; |
| 4787 | } |
| 4788 | |
| 4789 | RValue<Int2> operator>>=(const Int2 &lhs, unsigned char rhs) |
| 4790 | { |
| 4791 | return lhs = lhs >> rhs; |
| 4792 | } |
| 4793 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4794 | RValue<Int2> operator<<=(const Int2 &lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4795 | { |
| 4796 | return lhs = lhs << rhs; |
| 4797 | } |
| 4798 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4799 | RValue<Int2> operator>>=(const Int2 &lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4800 | { |
| 4801 | return lhs = lhs >> rhs; |
| 4802 | } |
| 4803 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4804 | // RValue<Int2> operator+(RValue<Int2> val) |
| 4805 | // { |
| 4806 | // return val; |
| 4807 | // } |
| 4808 | |
| 4809 | // RValue<Int2> operator-(RValue<Int2> val) |
| 4810 | // { |
| 4811 | // return RValue<Int2>(Nucleus::createNeg(val.value)); |
| 4812 | // } |
| 4813 | |
| 4814 | RValue<Int2> operator~(RValue<Int2> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4815 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4816 | if(CPUID::supportsMMX2()) |
| 4817 | { |
| 4818 | return val ^ Int2(0xFFFFFFFF, 0xFFFFFFFF); |
| 4819 | } |
| 4820 | else |
| 4821 | { |
| 4822 | return RValue<Int2>(Nucleus::createNot(val.value)); |
| 4823 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4824 | } |
| 4825 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4826 | RValue<Long1> UnpackLow(RValue<Int2> x, RValue<Int2> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4827 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4828 | if(CPUID::supportsMMX2()) |
| 4829 | { |
| 4830 | return x86::punpckldq(x, y); |
| 4831 | } |
| 4832 | else |
| 4833 | { |
| 4834 | Constant *shuffle[2]; |
| 4835 | shuffle[0] = Nucleus::createConstantInt(0); |
| 4836 | shuffle[1] = Nucleus::createConstantInt(2); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4837 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4838 | Value *packed = Nucleus::createShuffleVector(x.value, y.value, Nucleus::createConstantVector(shuffle, 2)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4839 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4840 | return RValue<Long1>(Nucleus::createBitCast(packed, Long1::getType())); |
| 4841 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4842 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4843 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4844 | RValue<Long1> UnpackHigh(RValue<Int2> x, RValue<Int2> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4845 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4846 | if(CPUID::supportsMMX2()) |
| 4847 | { |
| 4848 | return x86::punpckhdq(x, y); |
| 4849 | } |
| 4850 | else |
| 4851 | { |
| 4852 | Constant *shuffle[2]; |
| 4853 | shuffle[0] = Nucleus::createConstantInt(1); |
| 4854 | shuffle[1] = Nucleus::createConstantInt(3); |
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 | Value *packed = Nucleus::createShuffleVector(x.value, y.value, Nucleus::createConstantVector(shuffle, 2)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4857 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4858 | return RValue<Long1>(Nucleus::createBitCast(packed, Long1::getType())); |
| 4859 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4860 | } |
| 4861 | |
Nicolas Capens | fff3c9b | 2015-05-13 23:40:44 -0400 | [diff] [blame] | 4862 | RValue<Int2> Concatenate(RValue<Int> lo, RValue<Int> hi) |
| 4863 | { |
| 4864 | Constant *shuffle[2]; |
| 4865 | shuffle[0] = Nucleus::createConstantInt(0); |
| 4866 | shuffle[1] = Nucleus::createConstantInt(1); |
| 4867 | |
| 4868 | Value *packed = Nucleus::createShuffleVector(Nucleus::createBitCast(lo.value, VectorType::get(Int::getType(), 1)), Nucleus::createBitCast(hi.value, VectorType::get(Int::getType(), 1)), Nucleus::createConstantVector(shuffle, 2)); |
| 4869 | |
| 4870 | return RValue<Int2>(Nucleus::createBitCast(packed, Int2::getType())); |
| 4871 | } |
| 4872 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4873 | RValue<Int> Extract(RValue<Int2> val, int i) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4874 | { |
| 4875 | if(false) // FIXME: LLVM does not generate optimal code |
| 4876 | { |
| 4877 | return RValue<Int>(Nucleus::createExtractElement(val.value, i)); |
| 4878 | } |
| 4879 | else |
| 4880 | { |
| 4881 | if(i == 0) |
| 4882 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4883 | 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] | 4884 | } |
| 4885 | else |
| 4886 | { |
| 4887 | Int2 val2 = As<Int2>(UnpackHigh(val, val)); |
| 4888 | |
| 4889 | return Extract(val2, 0); |
| 4890 | } |
| 4891 | } |
| 4892 | } |
| 4893 | |
Nicolas Capens | fff3c9b | 2015-05-13 23:40:44 -0400 | [diff] [blame] | 4894 | RValue<Int2> Insert(RValue<Int2> val, RValue<Int> element, int i) |
| 4895 | { |
| 4896 | return RValue<Int2>(Nucleus::createBitCast(Nucleus::createInsertElement(Nucleus::createBitCast(val.value, VectorType::get(Int::getType(), 2)), element.value, i), Int2::getType())); |
| 4897 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4898 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4899 | Type *Int2::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4900 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4901 | if(CPUID::supportsMMX2()) |
| 4902 | { |
| 4903 | return MMX::getType(); |
| 4904 | } |
| 4905 | else |
| 4906 | { |
| 4907 | return VectorType::get(Int::getType(), 2); |
| 4908 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4909 | } |
| 4910 | |
| 4911 | UInt2::UInt2() |
| 4912 | { |
| 4913 | // xy.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4914 | } |
| 4915 | |
| 4916 | UInt2::UInt2(unsigned int x, unsigned int y) |
| 4917 | { |
| 4918 | // xy.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4919 | |
| 4920 | Constant *constantVector[2]; |
| 4921 | constantVector[0] = Nucleus::createConstantInt(x); |
| 4922 | constantVector[1] = Nucleus::createConstantInt(y); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4923 | Value *vector = Nucleus::createConstantVector(constantVector, 2); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4924 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4925 | storeValue(Nucleus::createBitCast(vector, getType())); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4926 | } |
| 4927 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4928 | UInt2::UInt2(RValue<UInt2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4929 | { |
| 4930 | // xy.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4931 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4932 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4933 | } |
| 4934 | |
| 4935 | UInt2::UInt2(const UInt2 &rhs) |
| 4936 | { |
| 4937 | // xy.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4938 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4939 | Value *value = rhs.loadValue(); |
| 4940 | storeValue(value); |
| 4941 | } |
| 4942 | |
| 4943 | UInt2::UInt2(const Reference<UInt2> &rhs) |
| 4944 | { |
| 4945 | // xy.parent = this; |
| 4946 | |
| 4947 | Value *value = rhs.loadValue(); |
| 4948 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4949 | } |
| 4950 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4951 | RValue<UInt2> UInt2::operator=(RValue<UInt2> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4952 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4953 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4954 | |
| 4955 | return rhs; |
| 4956 | } |
| 4957 | |
| 4958 | RValue<UInt2> UInt2::operator=(const UInt2 &rhs) const |
| 4959 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4960 | Value *value = rhs.loadValue(); |
| 4961 | storeValue(value); |
| 4962 | |
| 4963 | return RValue<UInt2>(value); |
| 4964 | } |
| 4965 | |
| 4966 | RValue<UInt2> UInt2::operator=(const Reference<UInt2> &rhs) const |
| 4967 | { |
| 4968 | Value *value = rhs.loadValue(); |
| 4969 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4970 | |
| 4971 | return RValue<UInt2>(value); |
| 4972 | } |
| 4973 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4974 | RValue<UInt2> operator+(RValue<UInt2> lhs, RValue<UInt2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4975 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4976 | if(CPUID::supportsMMX2()) |
| 4977 | { |
| 4978 | return As<UInt2>(x86::paddd(As<Int2>(lhs), As<Int2>(rhs))); |
| 4979 | } |
| 4980 | else |
| 4981 | { |
| 4982 | return RValue<UInt2>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 4983 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4984 | } |
| 4985 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4986 | RValue<UInt2> operator-(RValue<UInt2> lhs, RValue<UInt2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4987 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4988 | if(CPUID::supportsMMX2()) |
| 4989 | { |
| 4990 | return As<UInt2>(x86::psubd(As<Int2>(lhs), As<Int2>(rhs))); |
| 4991 | } |
| 4992 | else |
| 4993 | { |
| 4994 | return RValue<UInt2>(Nucleus::createSub(lhs.value, rhs.value)); |
| 4995 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4996 | } |
| 4997 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 4998 | // RValue<UInt2> operator*(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 4999 | // { |
| 5000 | // return RValue<UInt2>(Nucleus::createMul(lhs.value, rhs.value)); |
| 5001 | // } |
| 5002 | |
| 5003 | // RValue<UInt2> operator/(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 5004 | // { |
| 5005 | // return RValue<UInt2>(Nucleus::createUDiv(lhs.value, rhs.value)); |
| 5006 | // } |
| 5007 | |
| 5008 | // RValue<UInt2> operator%(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 5009 | // { |
| 5010 | // return RValue<UInt2>(Nucleus::createURem(lhs.value, rhs.value)); |
| 5011 | // } |
| 5012 | |
| 5013 | RValue<UInt2> operator&(RValue<UInt2> lhs, RValue<UInt2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5014 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5015 | if(CPUID::supportsMMX2()) |
| 5016 | { |
| 5017 | return As<UInt2>(x86::pand(As<Short4>(lhs), As<Short4>(rhs))); |
| 5018 | } |
| 5019 | else |
| 5020 | { |
| 5021 | return RValue<UInt2>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 5022 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5023 | } |
| 5024 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5025 | RValue<UInt2> operator|(RValue<UInt2> lhs, RValue<UInt2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5026 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5027 | if(CPUID::supportsMMX2()) |
| 5028 | { |
| 5029 | return As<UInt2>(x86::por(As<Short4>(lhs), As<Short4>(rhs))); |
| 5030 | } |
| 5031 | else |
| 5032 | { |
| 5033 | return RValue<UInt2>(Nucleus::createOr(lhs.value, rhs.value)); |
| 5034 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5035 | } |
| 5036 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5037 | RValue<UInt2> operator^(RValue<UInt2> lhs, RValue<UInt2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5038 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5039 | if(CPUID::supportsMMX2()) |
| 5040 | { |
| 5041 | return As<UInt2>(x86::pxor(As<Short4>(lhs), As<Short4>(rhs))); |
| 5042 | } |
| 5043 | else |
| 5044 | { |
| 5045 | return RValue<UInt2>(Nucleus::createXor(lhs.value, rhs.value)); |
| 5046 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5047 | } |
| 5048 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5049 | RValue<UInt2> operator<<(RValue<UInt2> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5050 | { |
| 5051 | // return RValue<UInt2>(Nucleus::createShl(lhs.value, rhs.value)); |
| 5052 | |
| 5053 | return As<UInt2>(x86::pslld(As<Int2>(lhs), rhs)); |
| 5054 | } |
| 5055 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5056 | RValue<UInt2> operator>>(RValue<UInt2> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5057 | { |
| 5058 | // return RValue<UInt2>(Nucleus::createLShr(lhs.value, rhs.value)); |
| 5059 | |
| 5060 | return x86::psrld(lhs, rhs); |
| 5061 | } |
| 5062 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5063 | RValue<UInt2> operator<<(RValue<UInt2> lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5064 | { |
| 5065 | // return RValue<UInt2>(Nucleus::createShl(lhs.value, rhs.value)); |
| 5066 | |
| 5067 | return As<UInt2>(x86::pslld(As<Int2>(lhs), rhs)); |
| 5068 | } |
| 5069 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5070 | RValue<UInt2> operator>>(RValue<UInt2> lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5071 | { |
| 5072 | // return RValue<UInt2>(Nucleus::createLShr(lhs.value, rhs.value)); |
| 5073 | |
| 5074 | return x86::psrld(lhs, rhs); |
| 5075 | } |
| 5076 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5077 | RValue<UInt2> operator+=(const UInt2 &lhs, RValue<UInt2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 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<UInt2> 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<UInt2> rhs) |
| 5088 | // { |
| 5089 | // return lhs = lhs * rhs; |
| 5090 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5091 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5092 | // RValue<UInt2> operator/=(const UInt2 &lhs, RValue<UInt2> rhs) |
| 5093 | // { |
| 5094 | // return lhs = lhs / rhs; |
| 5095 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5096 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5097 | // RValue<UInt2> operator%=(const UInt2 &lhs, RValue<UInt2> rhs) |
| 5098 | // { |
| 5099 | // return lhs = lhs % rhs; |
| 5100 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5101 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5102 | RValue<UInt2> operator&=(const UInt2 &lhs, RValue<UInt2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5103 | { |
| 5104 | return lhs = lhs & rhs; |
| 5105 | } |
| 5106 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5107 | RValue<UInt2> operator|=(const UInt2 &lhs, RValue<UInt2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5108 | { |
| 5109 | return lhs = lhs | rhs; |
| 5110 | } |
| 5111 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5112 | RValue<UInt2> operator^=(const UInt2 &lhs, RValue<UInt2> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5113 | { |
| 5114 | return lhs = lhs ^ rhs; |
| 5115 | } |
| 5116 | |
| 5117 | RValue<UInt2> operator<<=(const UInt2 &lhs, unsigned char rhs) |
| 5118 | { |
| 5119 | return lhs = lhs << rhs; |
| 5120 | } |
| 5121 | |
| 5122 | RValue<UInt2> operator>>=(const UInt2 &lhs, unsigned char rhs) |
| 5123 | { |
| 5124 | return lhs = lhs >> rhs; |
| 5125 | } |
| 5126 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5127 | RValue<UInt2> operator<<=(const UInt2 &lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5128 | { |
| 5129 | return lhs = lhs << rhs; |
| 5130 | } |
| 5131 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5132 | RValue<UInt2> operator>>=(const UInt2 &lhs, RValue<Long1> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5133 | { |
| 5134 | return lhs = lhs >> rhs; |
| 5135 | } |
| 5136 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5137 | // RValue<UInt2> operator+(RValue<UInt2> val) |
| 5138 | // { |
| 5139 | // return val; |
| 5140 | // } |
| 5141 | |
| 5142 | // RValue<UInt2> operator-(RValue<UInt2> val) |
| 5143 | // { |
| 5144 | // return RValue<UInt2>(Nucleus::createNeg(val.value)); |
| 5145 | // } |
| 5146 | |
| 5147 | RValue<UInt2> operator~(RValue<UInt2> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5148 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5149 | if(CPUID::supportsMMX2()) |
| 5150 | { |
| 5151 | return val ^ UInt2(0xFFFFFFFF, 0xFFFFFFFF); |
| 5152 | } |
| 5153 | else |
| 5154 | { |
| 5155 | return RValue<UInt2>(Nucleus::createNot(val.value)); |
| 5156 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5157 | } |
| 5158 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5159 | Type *UInt2::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5160 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5161 | if(CPUID::supportsMMX2()) |
| 5162 | { |
| 5163 | return MMX::getType(); |
| 5164 | } |
| 5165 | else |
| 5166 | { |
| 5167 | return VectorType::get(UInt::getType(), 2); |
| 5168 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5169 | } |
| 5170 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5171 | Int4::Int4(RValue<Float4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5172 | { |
| 5173 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5174 | |
| 5175 | Value *xyzw = Nucleus::createFPToSI(cast.value, Int4::getType()); |
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(xyzw); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5178 | } |
| 5179 | |
Alexis Hetu | 2aa852f | 2015-10-14 16:32:39 -0400 | [diff] [blame] | 5180 | Int4::Int4(RValue<Short4> cast) |
| 5181 | { |
| 5182 | Value *long2 = UndefValue::get(Long2::getType()); |
| 5183 | Value *element = Nucleus::createBitCast(cast.value, Long::getType()); |
| 5184 | long2 = Nucleus::createInsertElement(long2, element, 0); |
| 5185 | RValue<Int4> vector = RValue<Int4>(Nucleus::createBitCast(long2, Int4::getType())); |
| 5186 | |
| 5187 | if(CPUID::supportsSSE4_1()) |
| 5188 | { |
| 5189 | storeValue(x86::pmovsxwd(vector).value); |
| 5190 | } |
| 5191 | else |
| 5192 | { |
| 5193 | Value *b = Nucleus::createBitCast(vector.value, Short8::getType()); |
| 5194 | |
| 5195 | Constant *swizzle[8]; |
| 5196 | swizzle[0] = Nucleus::createConstantInt(0); |
| 5197 | swizzle[1] = Nucleus::createConstantInt(0); |
| 5198 | swizzle[2] = Nucleus::createConstantInt(1); |
| 5199 | swizzle[3] = Nucleus::createConstantInt(1); |
| 5200 | swizzle[4] = Nucleus::createConstantInt(2); |
| 5201 | swizzle[5] = Nucleus::createConstantInt(2); |
| 5202 | swizzle[6] = Nucleus::createConstantInt(3); |
| 5203 | swizzle[7] = Nucleus::createConstantInt(3); |
| 5204 | |
Nicolas Capens | 6ce5c33 | 2015-10-28 01:58:18 -0400 | [diff] [blame] | 5205 | Value *c = Nucleus::createShuffleVector(b, b, Nucleus::createConstantVector(swizzle, 8)); |
| 5206 | Value *d = Nucleus::createBitCast(c, Int4::getType()); |
| 5207 | storeValue(d); |
Alexis Hetu | 2aa852f | 2015-10-14 16:32:39 -0400 | [diff] [blame] | 5208 | |
| 5209 | // Each Short is packed into each Int in the (Short | Short) format. |
| 5210 | // Shifting by 16 will retrieve the original Short value. |
| 5211 | // Shitfing an Int will propagate the sign bit, which will work |
| 5212 | // for both positive and negative values of a Short. |
| 5213 | *this >>= 16; |
| 5214 | } |
| 5215 | } |
| 5216 | |
| 5217 | Int4::Int4(RValue<UShort4> cast) |
| 5218 | { |
| 5219 | Value *long2 = UndefValue::get(Long2::getType()); |
| 5220 | Value *element = Nucleus::createBitCast(cast.value, Long::getType()); |
| 5221 | long2 = Nucleus::createInsertElement(long2, element, 0); |
| 5222 | RValue<Int4> vector = RValue<Int4>(Nucleus::createBitCast(long2, Int4::getType())); |
| 5223 | |
| 5224 | if(CPUID::supportsSSE4_1()) |
| 5225 | { |
| 5226 | storeValue(x86::pmovzxwd(RValue<Int4>(vector)).value); |
| 5227 | } |
| 5228 | else |
| 5229 | { |
| 5230 | Value *b = Nucleus::createBitCast(vector.value, Short8::getType()); |
| 5231 | |
| 5232 | Constant *swizzle[8]; |
| 5233 | swizzle[0] = Nucleus::createConstantInt(0); |
| 5234 | swizzle[1] = Nucleus::createConstantInt(8); |
| 5235 | swizzle[2] = Nucleus::createConstantInt(1); |
| 5236 | swizzle[3] = Nucleus::createConstantInt(9); |
| 5237 | swizzle[4] = Nucleus::createConstantInt(2); |
| 5238 | swizzle[5] = Nucleus::createConstantInt(10); |
| 5239 | swizzle[6] = Nucleus::createConstantInt(3); |
| 5240 | swizzle[7] = Nucleus::createConstantInt(11); |
| 5241 | |
Nicolas Capens | 6ce5c33 | 2015-10-28 01:58:18 -0400 | [diff] [blame] | 5242 | Value *c = Nucleus::createShuffleVector(b, Nucleus::createNullValue(Short8::getType()), Nucleus::createConstantVector(swizzle, 8)); |
| 5243 | Value *d = Nucleus::createBitCast(c, Int4::getType()); |
| 5244 | storeValue(d); |
Alexis Hetu | 2aa852f | 2015-10-14 16:32:39 -0400 | [diff] [blame] | 5245 | } |
| 5246 | } |
| 5247 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5248 | Int4::Int4() |
| 5249 | { |
| 5250 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5251 | } |
| 5252 | |
| 5253 | Int4::Int4(int xyzw) |
| 5254 | { |
| 5255 | constant(xyzw, xyzw, xyzw, xyzw); |
| 5256 | } |
| 5257 | |
| 5258 | Int4::Int4(int x, int yzw) |
| 5259 | { |
| 5260 | constant(x, yzw, yzw, yzw); |
| 5261 | } |
| 5262 | |
| 5263 | Int4::Int4(int x, int y, int zw) |
| 5264 | { |
| 5265 | constant(x, y, zw, zw); |
| 5266 | } |
| 5267 | |
| 5268 | Int4::Int4(int x, int y, int z, int w) |
| 5269 | { |
| 5270 | constant(x, y, z, w); |
| 5271 | } |
| 5272 | |
| 5273 | void Int4::constant(int x, int y, int z, int w) |
| 5274 | { |
| 5275 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5276 | |
| 5277 | Constant *constantVector[4]; |
| 5278 | constantVector[0] = Nucleus::createConstantInt(x); |
| 5279 | constantVector[1] = Nucleus::createConstantInt(y); |
| 5280 | constantVector[2] = Nucleus::createConstantInt(z); |
| 5281 | constantVector[3] = Nucleus::createConstantInt(w); |
| 5282 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5283 | storeValue(Nucleus::createConstantVector(constantVector, 4)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5284 | } |
| 5285 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5286 | Int4::Int4(RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5287 | { |
| 5288 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5289 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5290 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5291 | } |
| 5292 | |
| 5293 | Int4::Int4(const Int4 &rhs) |
| 5294 | { |
| 5295 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5296 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5297 | Value *value = rhs.loadValue(); |
| 5298 | storeValue(value); |
| 5299 | } |
| 5300 | |
| 5301 | Int4::Int4(const Reference<Int4> &rhs) |
| 5302 | { |
| 5303 | // xyzw.parent = this; |
| 5304 | |
| 5305 | Value *value = rhs.loadValue(); |
| 5306 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5307 | } |
| 5308 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5309 | Int4::Int4(RValue<UInt4> rhs) |
| 5310 | { |
| 5311 | // xyzw.parent = this; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5312 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5313 | storeValue(rhs.value); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5314 | } |
| 5315 | |
| 5316 | Int4::Int4(const UInt4 &rhs) |
| 5317 | { |
| 5318 | // xyzw.parent = this; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5319 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5320 | Value *value = rhs.loadValue(); |
| 5321 | storeValue(value); |
| 5322 | } |
| 5323 | |
| 5324 | Int4::Int4(const Reference<UInt4> &rhs) |
| 5325 | { |
| 5326 | // xyzw.parent = this; |
| 5327 | |
| 5328 | Value *value = rhs.loadValue(); |
| 5329 | storeValue(value); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5330 | } |
| 5331 | |
| 5332 | RValue<Int4> Int4::operator=(RValue<Int4> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5333 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5334 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5335 | |
| 5336 | return rhs; |
| 5337 | } |
| 5338 | |
| 5339 | RValue<Int4> Int4::operator=(const Int4 &rhs) const |
| 5340 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5341 | Value *value = rhs.loadValue(); |
| 5342 | storeValue(value); |
| 5343 | |
| 5344 | return RValue<Int4>(value); |
| 5345 | } |
| 5346 | |
| 5347 | RValue<Int4> Int4::operator=(const Reference<Int4> &rhs) const |
| 5348 | { |
| 5349 | Value *value = rhs.loadValue(); |
| 5350 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5351 | |
| 5352 | return RValue<Int4>(value); |
| 5353 | } |
| 5354 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5355 | RValue<Int4> operator+(RValue<Int4> lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5356 | { |
| 5357 | return RValue<Int4>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 5358 | } |
| 5359 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5360 | RValue<Int4> operator-(RValue<Int4> lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5361 | { |
| 5362 | return RValue<Int4>(Nucleus::createSub(lhs.value, rhs.value)); |
| 5363 | } |
| 5364 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5365 | RValue<Int4> operator*(RValue<Int4> lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5366 | { |
| 5367 | return RValue<Int4>(Nucleus::createMul(lhs.value, rhs.value)); |
| 5368 | } |
| 5369 | |
Alexis Hetu | d9d27bb | 2015-08-18 15:22:15 -0400 | [diff] [blame] | 5370 | RValue<Int4> operator/(RValue<Int4> lhs, RValue<Int4> rhs) |
| 5371 | { |
| 5372 | return RValue<Int4>(Nucleus::createSDiv(lhs.value, rhs.value)); |
| 5373 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5374 | |
Alexis Hetu | d9d27bb | 2015-08-18 15:22:15 -0400 | [diff] [blame] | 5375 | RValue<Int4> operator%(RValue<Int4> lhs, RValue<Int4> rhs) |
| 5376 | { |
| 5377 | return RValue<Int4>(Nucleus::createSRem(lhs.value, rhs.value)); |
| 5378 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5379 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5380 | RValue<Int4> operator&(RValue<Int4> lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5381 | { |
| 5382 | return RValue<Int4>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 5383 | } |
| 5384 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5385 | RValue<Int4> operator|(RValue<Int4> lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5386 | { |
| 5387 | return RValue<Int4>(Nucleus::createOr(lhs.value, rhs.value)); |
| 5388 | } |
| 5389 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5390 | RValue<Int4> operator^(RValue<Int4> lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5391 | { |
| 5392 | return RValue<Int4>(Nucleus::createXor(lhs.value, rhs.value)); |
| 5393 | } |
| 5394 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5395 | RValue<Int4> operator<<(RValue<Int4> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5396 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5397 | return x86::pslld(lhs, rhs); |
| 5398 | } |
| 5399 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5400 | RValue<Int4> operator>>(RValue<Int4> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5401 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5402 | return x86::psrad(lhs, rhs); |
| 5403 | } |
| 5404 | |
Alexis Hetu | d9d27bb | 2015-08-18 15:22:15 -0400 | [diff] [blame] | 5405 | RValue<Int4> operator<<(RValue<Int4> lhs, RValue<Int4> rhs) |
| 5406 | { |
| 5407 | return RValue<Int4>(Nucleus::createShl(lhs.value, rhs.value)); |
| 5408 | } |
| 5409 | |
| 5410 | RValue<Int4> operator>>(RValue<Int4> lhs, RValue<Int4> rhs) |
| 5411 | { |
| 5412 | return RValue<Int4>(Nucleus::createAShr(lhs.value, rhs.value)); |
| 5413 | } |
| 5414 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5415 | RValue<Int4> operator+=(const Int4 &lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5416 | { |
| 5417 | return lhs = lhs + rhs; |
| 5418 | } |
| 5419 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5420 | RValue<Int4> operator-=(const Int4 &lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5421 | { |
| 5422 | return lhs = lhs - rhs; |
| 5423 | } |
| 5424 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5425 | RValue<Int4> operator*=(const Int4 &lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5426 | { |
| 5427 | return lhs = lhs * rhs; |
| 5428 | } |
| 5429 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5430 | // RValue<Int4> operator/=(const Int4 &lhs, RValue<Int4> rhs) |
| 5431 | // { |
| 5432 | // return lhs = lhs / rhs; |
| 5433 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5434 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5435 | // RValue<Int4> operator%=(const Int4 &lhs, RValue<Int4> rhs) |
| 5436 | // { |
| 5437 | // return lhs = lhs % rhs; |
| 5438 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5439 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5440 | RValue<Int4> operator&=(const Int4 &lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5441 | { |
| 5442 | return lhs = lhs & rhs; |
| 5443 | } |
| 5444 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5445 | RValue<Int4> operator|=(const Int4 &lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5446 | { |
| 5447 | return lhs = lhs | rhs; |
| 5448 | } |
| 5449 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5450 | RValue<Int4> operator^=(const Int4 &lhs, RValue<Int4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5451 | { |
| 5452 | return lhs = lhs ^ rhs; |
| 5453 | } |
| 5454 | |
| 5455 | RValue<Int4> operator<<=(const Int4 &lhs, unsigned char rhs) |
| 5456 | { |
| 5457 | return lhs = lhs << rhs; |
| 5458 | } |
| 5459 | |
| 5460 | RValue<Int4> operator>>=(const Int4 &lhs, unsigned char rhs) |
| 5461 | { |
| 5462 | return lhs = lhs >> rhs; |
| 5463 | } |
| 5464 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5465 | RValue<Int4> operator+(RValue<Int4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5466 | { |
| 5467 | return val; |
| 5468 | } |
| 5469 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5470 | RValue<Int4> operator-(RValue<Int4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5471 | { |
| 5472 | return RValue<Int4>(Nucleus::createNeg(val.value)); |
| 5473 | } |
| 5474 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5475 | RValue<Int4> operator~(RValue<Int4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5476 | { |
| 5477 | return RValue<Int4>(Nucleus::createNot(val.value)); |
| 5478 | } |
| 5479 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5480 | RValue<Int4> CmpEQ(RValue<Int4> x, RValue<Int4> y) |
| 5481 | { |
| 5482 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpEQ(x.value, y.value), Int4::getType())); |
| 5483 | } |
| 5484 | |
| 5485 | RValue<Int4> CmpLT(RValue<Int4> x, RValue<Int4> y) |
| 5486 | { |
| 5487 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSLT(x.value, y.value), Int4::getType())); |
| 5488 | } |
| 5489 | |
| 5490 | RValue<Int4> CmpLE(RValue<Int4> x, RValue<Int4> y) |
| 5491 | { |
| 5492 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSLE(x.value, y.value), Int4::getType())); |
| 5493 | } |
| 5494 | |
| 5495 | RValue<Int4> CmpNEQ(RValue<Int4> x, RValue<Int4> y) |
| 5496 | { |
| 5497 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpNE(x.value, y.value), Int4::getType())); |
| 5498 | } |
| 5499 | |
| 5500 | RValue<Int4> CmpNLT(RValue<Int4> x, RValue<Int4> y) |
| 5501 | { |
| 5502 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSGE(x.value, y.value), Int4::getType())); |
| 5503 | } |
| 5504 | |
| 5505 | RValue<Int4> CmpNLE(RValue<Int4> x, RValue<Int4> y) |
| 5506 | { |
| 5507 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSGT(x.value, y.value), Int4::getType())); |
| 5508 | } |
| 5509 | |
| 5510 | RValue<Int4> Max(RValue<Int4> x, RValue<Int4> y) |
| 5511 | { |
| 5512 | if(CPUID::supportsSSE4_1()) |
| 5513 | { |
| 5514 | return x86::pmaxsd(x, y); |
| 5515 | } |
| 5516 | else |
| 5517 | { |
| 5518 | RValue<Int4> greater = CmpNLE(x, y); |
| 5519 | return x & greater | y & ~greater; |
| 5520 | } |
| 5521 | } |
| 5522 | |
| 5523 | RValue<Int4> Min(RValue<Int4> x, RValue<Int4> y) |
| 5524 | { |
| 5525 | if(CPUID::supportsSSE4_1()) |
| 5526 | { |
| 5527 | return x86::pminsd(x, y); |
| 5528 | } |
| 5529 | else |
| 5530 | { |
| 5531 | RValue<Int4> less = CmpLT(x, y); |
| 5532 | return x & less | y & ~less; |
| 5533 | } |
| 5534 | } |
| 5535 | |
| 5536 | RValue<Int4> RoundInt(RValue<Float4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5537 | { |
| 5538 | return x86::cvtps2dq(cast); |
| 5539 | } |
| 5540 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5541 | RValue<Short8> Pack(RValue<Int4> x, RValue<Int4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5542 | { |
| 5543 | return x86::packssdw(x, y); |
| 5544 | } |
| 5545 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5546 | RValue<Int4> Concatenate(RValue<Int2> lo, RValue<Int2> hi) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5547 | { |
| 5548 | Value *loLong = Nucleus::createBitCast(lo.value, Long::getType()); |
| 5549 | Value *hiLong = Nucleus::createBitCast(hi.value, Long::getType()); |
| 5550 | |
| 5551 | Value *long2 = UndefValue::get(Long2::getType()); |
| 5552 | long2 = Nucleus::createInsertElement(long2, loLong, 0); |
| 5553 | long2 = Nucleus::createInsertElement(long2, hiLong, 1); |
| 5554 | Value *int4 = Nucleus::createBitCast(long2, Int4::getType()); |
| 5555 | |
| 5556 | return RValue<Int4>(int4); |
| 5557 | } |
| 5558 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5559 | RValue<Int> Extract(RValue<Int4> x, int i) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5560 | { |
| 5561 | return RValue<Int>(Nucleus::createExtractElement(x.value, i)); |
| 5562 | } |
| 5563 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5564 | RValue<Int4> Insert(RValue<Int4> x, RValue<Int> element, int i) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5565 | { |
| 5566 | return RValue<Int4>(Nucleus::createInsertElement(x.value, element.value, i)); |
| 5567 | } |
| 5568 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5569 | RValue<Int> SignMask(RValue<Int4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5570 | { |
| 5571 | return x86::movmskps(As<Float4>(x)); |
| 5572 | } |
| 5573 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5574 | RValue<Int4> Swizzle(RValue<Int4> x, unsigned char select) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5575 | { |
| 5576 | return RValue<Int4>(Nucleus::createSwizzle(x.value, select)); |
| 5577 | } |
| 5578 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5579 | Type *Int4::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5580 | { |
| 5581 | return VectorType::get(Int::getType(), 4); |
| 5582 | } |
| 5583 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5584 | UInt4::UInt4(RValue<Float4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5585 | { |
| 5586 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5587 | |
| 5588 | Value *xyzw = Nucleus::createFPToUI(cast.value, UInt4::getType()); |
| 5589 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5590 | storeValue(xyzw); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5591 | } |
| 5592 | |
| 5593 | UInt4::UInt4() |
| 5594 | { |
| 5595 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5596 | } |
| 5597 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5598 | UInt4::UInt4(int xyzw) |
| 5599 | { |
| 5600 | constant(xyzw, xyzw, xyzw, xyzw); |
| 5601 | } |
| 5602 | |
| 5603 | UInt4::UInt4(int x, int yzw) |
| 5604 | { |
| 5605 | constant(x, yzw, yzw, yzw); |
| 5606 | } |
| 5607 | |
| 5608 | UInt4::UInt4(int x, int y, int zw) |
| 5609 | { |
| 5610 | constant(x, y, zw, zw); |
| 5611 | } |
| 5612 | |
| 5613 | UInt4::UInt4(int x, int y, int z, int w) |
| 5614 | { |
| 5615 | constant(x, y, z, w); |
| 5616 | } |
| 5617 | |
| 5618 | void UInt4::constant(int x, int y, int z, int w) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5619 | { |
| 5620 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5621 | |
| 5622 | Constant *constantVector[4]; |
| 5623 | constantVector[0] = Nucleus::createConstantInt(x); |
| 5624 | constantVector[1] = Nucleus::createConstantInt(y); |
| 5625 | constantVector[2] = Nucleus::createConstantInt(z); |
| 5626 | constantVector[3] = Nucleus::createConstantInt(w); |
| 5627 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5628 | storeValue(Nucleus::createConstantVector(constantVector, 4)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5629 | } |
| 5630 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5631 | UInt4::UInt4(RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5632 | { |
| 5633 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5634 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5635 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5636 | } |
| 5637 | |
| 5638 | UInt4::UInt4(const UInt4 &rhs) |
| 5639 | { |
| 5640 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5641 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5642 | Value *value = rhs.loadValue(); |
| 5643 | storeValue(value); |
| 5644 | } |
| 5645 | |
| 5646 | UInt4::UInt4(const Reference<UInt4> &rhs) |
| 5647 | { |
| 5648 | // xyzw.parent = this; |
| 5649 | |
| 5650 | Value *value = rhs.loadValue(); |
| 5651 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5652 | } |
| 5653 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5654 | UInt4::UInt4(RValue<Int4> rhs) |
| 5655 | { |
| 5656 | // xyzw.parent = this; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5657 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5658 | storeValue(rhs.value); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5659 | } |
| 5660 | |
| 5661 | UInt4::UInt4(const Int4 &rhs) |
| 5662 | { |
| 5663 | // xyzw.parent = this; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5664 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5665 | Value *value = rhs.loadValue(); |
| 5666 | storeValue(value); |
| 5667 | } |
| 5668 | |
| 5669 | UInt4::UInt4(const Reference<Int4> &rhs) |
| 5670 | { |
| 5671 | // xyzw.parent = this; |
| 5672 | |
| 5673 | Value *value = rhs.loadValue(); |
| 5674 | storeValue(value); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5675 | } |
| 5676 | |
| 5677 | RValue<UInt4> UInt4::operator=(RValue<UInt4> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5678 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5679 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5680 | |
| 5681 | return rhs; |
| 5682 | } |
| 5683 | |
| 5684 | RValue<UInt4> UInt4::operator=(const UInt4 &rhs) const |
| 5685 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5686 | Value *value = rhs.loadValue(); |
| 5687 | storeValue(value); |
| 5688 | |
| 5689 | return RValue<UInt4>(value); |
| 5690 | } |
| 5691 | |
| 5692 | RValue<UInt4> UInt4::operator=(const Reference<UInt4> &rhs) const |
| 5693 | { |
| 5694 | Value *value = rhs.loadValue(); |
| 5695 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5696 | |
| 5697 | return RValue<UInt4>(value); |
| 5698 | } |
| 5699 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5700 | RValue<UInt4> operator+(RValue<UInt4> lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5701 | { |
| 5702 | return RValue<UInt4>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 5703 | } |
| 5704 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5705 | RValue<UInt4> operator-(RValue<UInt4> lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5706 | { |
| 5707 | return RValue<UInt4>(Nucleus::createSub(lhs.value, rhs.value)); |
| 5708 | } |
| 5709 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5710 | RValue<UInt4> operator*(RValue<UInt4> lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5711 | { |
| 5712 | return RValue<UInt4>(Nucleus::createMul(lhs.value, rhs.value)); |
| 5713 | } |
| 5714 | |
Alexis Hetu | d9d27bb | 2015-08-18 15:22:15 -0400 | [diff] [blame] | 5715 | RValue<UInt4> operator/(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 5716 | { |
| 5717 | return RValue<UInt4>(Nucleus::createUDiv(lhs.value, rhs.value)); |
| 5718 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5719 | |
Alexis Hetu | d9d27bb | 2015-08-18 15:22:15 -0400 | [diff] [blame] | 5720 | RValue<UInt4> operator%(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 5721 | { |
| 5722 | return RValue<UInt4>(Nucleus::createURem(lhs.value, rhs.value)); |
| 5723 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5724 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5725 | RValue<UInt4> operator&(RValue<UInt4> lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5726 | { |
| 5727 | return RValue<UInt4>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 5728 | } |
| 5729 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5730 | RValue<UInt4> operator|(RValue<UInt4> lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5731 | { |
| 5732 | return RValue<UInt4>(Nucleus::createOr(lhs.value, rhs.value)); |
| 5733 | } |
| 5734 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5735 | RValue<UInt4> operator^(RValue<UInt4> lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5736 | { |
| 5737 | return RValue<UInt4>(Nucleus::createXor(lhs.value, rhs.value)); |
| 5738 | } |
| 5739 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5740 | RValue<UInt4> operator<<(RValue<UInt4> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5741 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5742 | return As<UInt4>(x86::pslld(As<Int4>(lhs), rhs)); |
| 5743 | } |
| 5744 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5745 | RValue<UInt4> operator>>(RValue<UInt4> lhs, unsigned char rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5746 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5747 | return x86::psrld(lhs, rhs); |
| 5748 | } |
| 5749 | |
Alexis Hetu | d9d27bb | 2015-08-18 15:22:15 -0400 | [diff] [blame] | 5750 | RValue<UInt4> operator<<(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 5751 | { |
| 5752 | return RValue<UInt4>(Nucleus::createShl(lhs.value, rhs.value)); |
| 5753 | } |
| 5754 | |
| 5755 | RValue<UInt4> operator>>(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 5756 | { |
| 5757 | return RValue<UInt4>(Nucleus::createLShr(lhs.value, rhs.value)); |
| 5758 | } |
| 5759 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5760 | RValue<UInt4> operator+=(const UInt4 &lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5761 | { |
| 5762 | return lhs = lhs + rhs; |
| 5763 | } |
| 5764 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5765 | RValue<UInt4> operator-=(const UInt4 &lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5766 | { |
| 5767 | return lhs = lhs - rhs; |
| 5768 | } |
| 5769 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5770 | RValue<UInt4> operator*=(const UInt4 &lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5771 | { |
| 5772 | return lhs = lhs * rhs; |
| 5773 | } |
| 5774 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5775 | // RValue<UInt4> operator/=(const UInt4 &lhs, RValue<UInt4> rhs) |
| 5776 | // { |
| 5777 | // return lhs = lhs / rhs; |
| 5778 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5779 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5780 | // RValue<UInt4> operator%=(const UInt4 &lhs, RValue<UInt4> rhs) |
| 5781 | // { |
| 5782 | // return lhs = lhs % rhs; |
| 5783 | // } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5784 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5785 | RValue<UInt4> operator&=(const UInt4 &lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5786 | { |
| 5787 | return lhs = lhs & rhs; |
| 5788 | } |
| 5789 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5790 | RValue<UInt4> operator|=(const UInt4 &lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5791 | { |
| 5792 | return lhs = lhs | rhs; |
| 5793 | } |
| 5794 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5795 | RValue<UInt4> operator^=(const UInt4 &lhs, RValue<UInt4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5796 | { |
| 5797 | return lhs = lhs ^ rhs; |
| 5798 | } |
| 5799 | |
| 5800 | RValue<UInt4> operator<<=(const UInt4 &lhs, unsigned char rhs) |
| 5801 | { |
| 5802 | return lhs = lhs << rhs; |
| 5803 | } |
| 5804 | |
| 5805 | RValue<UInt4> operator>>=(const UInt4 &lhs, unsigned char rhs) |
| 5806 | { |
| 5807 | return lhs = lhs >> rhs; |
| 5808 | } |
| 5809 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5810 | RValue<UInt4> operator+(RValue<UInt4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5811 | { |
| 5812 | return val; |
| 5813 | } |
| 5814 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5815 | RValue<UInt4> operator-(RValue<UInt4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5816 | { |
| 5817 | return RValue<UInt4>(Nucleus::createNeg(val.value)); |
| 5818 | } |
| 5819 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5820 | RValue<UInt4> operator~(RValue<UInt4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5821 | { |
| 5822 | return RValue<UInt4>(Nucleus::createNot(val.value)); |
| 5823 | } |
| 5824 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5825 | RValue<UInt4> CmpEQ(RValue<UInt4> x, RValue<UInt4> y) |
| 5826 | { |
| 5827 | return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpEQ(x.value, y.value), Int4::getType())); |
| 5828 | } |
| 5829 | |
| 5830 | RValue<UInt4> CmpLT(RValue<UInt4> x, RValue<UInt4> y) |
| 5831 | { |
| 5832 | return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpULT(x.value, y.value), Int4::getType())); |
| 5833 | } |
| 5834 | |
| 5835 | RValue<UInt4> CmpLE(RValue<UInt4> x, RValue<UInt4> y) |
| 5836 | { |
| 5837 | return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpULE(x.value, y.value), Int4::getType())); |
| 5838 | } |
| 5839 | |
| 5840 | RValue<UInt4> CmpNEQ(RValue<UInt4> x, RValue<UInt4> y) |
| 5841 | { |
| 5842 | return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpNE(x.value, y.value), Int4::getType())); |
| 5843 | } |
| 5844 | |
| 5845 | RValue<UInt4> CmpNLT(RValue<UInt4> x, RValue<UInt4> y) |
| 5846 | { |
| 5847 | return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpUGE(x.value, y.value), Int4::getType())); |
| 5848 | } |
| 5849 | |
| 5850 | RValue<UInt4> CmpNLE(RValue<UInt4> x, RValue<UInt4> y) |
| 5851 | { |
| 5852 | return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpUGT(x.value, y.value), Int4::getType())); |
| 5853 | } |
| 5854 | |
| 5855 | RValue<UInt4> Max(RValue<UInt4> x, RValue<UInt4> y) |
| 5856 | { |
| 5857 | if(CPUID::supportsSSE4_1()) |
| 5858 | { |
| 5859 | return x86::pmaxud(x, y); |
| 5860 | } |
| 5861 | else |
| 5862 | { |
| 5863 | RValue<UInt4> greater = CmpNLE(x, y); |
| 5864 | return x & greater | y & ~greater; |
| 5865 | } |
| 5866 | } |
| 5867 | |
| 5868 | RValue<UInt4> Min(RValue<UInt4> x, RValue<UInt4> y) |
| 5869 | { |
| 5870 | if(CPUID::supportsSSE4_1()) |
| 5871 | { |
| 5872 | return x86::pminud(x, y); |
| 5873 | } |
| 5874 | else |
| 5875 | { |
| 5876 | RValue<UInt4> less = CmpLT(x, y); |
| 5877 | return x & less | y & ~less; |
| 5878 | } |
| 5879 | } |
| 5880 | |
| 5881 | RValue<UShort8> Pack(RValue<UInt4> x, RValue<UInt4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5882 | { |
| 5883 | return x86::packusdw(x, y); // FIXME: Fallback required |
| 5884 | } |
| 5885 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5886 | RValue<UInt4> Concatenate(RValue<UInt2> lo, RValue<UInt2> hi) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5887 | { |
| 5888 | Value *loLong = Nucleus::createBitCast(lo.value, Long::getType()); |
| 5889 | Value *hiLong = Nucleus::createBitCast(hi.value, Long::getType()); |
| 5890 | |
| 5891 | Value *long2 = UndefValue::get(Long2::getType()); |
| 5892 | long2 = Nucleus::createInsertElement(long2, loLong, 0); |
| 5893 | long2 = Nucleus::createInsertElement(long2, hiLong, 1); |
| 5894 | Value *uint4 = Nucleus::createBitCast(long2, Int4::getType()); |
| 5895 | |
| 5896 | return RValue<UInt4>(uint4); |
| 5897 | } |
| 5898 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5899 | Type *UInt4::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5900 | { |
| 5901 | return VectorType::get(UInt::getType(), 4); |
| 5902 | } |
| 5903 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5904 | Float::Float(RValue<Int> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5905 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5906 | Value *integer = Nucleus::createSIToFP(cast.value, Float::getType()); |
| 5907 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5908 | storeValue(integer); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5909 | } |
| 5910 | |
| 5911 | Float::Float() |
| 5912 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5913 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5914 | } |
| 5915 | |
| 5916 | Float::Float(float x) |
| 5917 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5918 | storeValue(Nucleus::createConstantFloat(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 | Float::Float(RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5922 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5923 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5924 | } |
| 5925 | |
| 5926 | Float::Float(const Float &rhs) |
| 5927 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5928 | Value *value = rhs.loadValue(); |
| 5929 | storeValue(value); |
| 5930 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5931 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5932 | Float::Float(const Reference<Float> &rhs) |
| 5933 | { |
| 5934 | Value *value = rhs.loadValue(); |
| 5935 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5936 | } |
| 5937 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5938 | RValue<Float> Float::operator=(RValue<Float> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5939 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5940 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5941 | |
| 5942 | return rhs; |
| 5943 | } |
| 5944 | |
| 5945 | RValue<Float> Float::operator=(const Float &rhs) const |
| 5946 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5947 | Value *value = rhs.loadValue(); |
| 5948 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5949 | |
| 5950 | return RValue<Float>(value); |
| 5951 | } |
| 5952 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5953 | RValue<Float> Float::operator=(const Reference<Float> &rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5954 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5955 | Value *value = rhs.loadValue(); |
| 5956 | storeValue(value); |
| 5957 | |
| 5958 | return RValue<Float>(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5959 | } |
| 5960 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5961 | RValue<Float> operator+(RValue<Float> lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5962 | { |
| 5963 | return RValue<Float>(Nucleus::createFAdd(lhs.value, rhs.value)); |
| 5964 | } |
| 5965 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5966 | RValue<Float> operator-(RValue<Float> lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5967 | { |
| 5968 | return RValue<Float>(Nucleus::createFSub(lhs.value, rhs.value)); |
| 5969 | } |
| 5970 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5971 | RValue<Float> operator*(RValue<Float> lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5972 | { |
| 5973 | return RValue<Float>(Nucleus::createFMul(lhs.value, rhs.value)); |
| 5974 | } |
| 5975 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5976 | RValue<Float> operator/(RValue<Float> lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5977 | { |
| 5978 | return RValue<Float>(Nucleus::createFDiv(lhs.value, rhs.value)); |
| 5979 | } |
| 5980 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5981 | RValue<Float> operator+=(const Float &lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5982 | { |
| 5983 | return lhs = lhs + rhs; |
| 5984 | } |
| 5985 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5986 | RValue<Float> operator-=(const Float &lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5987 | { |
| 5988 | return lhs = lhs - rhs; |
| 5989 | } |
| 5990 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5991 | RValue<Float> operator*=(const Float &lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5992 | { |
| 5993 | return lhs = lhs * rhs; |
| 5994 | } |
| 5995 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 5996 | RValue<Float> operator/=(const Float &lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 5997 | { |
| 5998 | return lhs = lhs / rhs; |
| 5999 | } |
| 6000 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6001 | RValue<Float> operator+(RValue<Float> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6002 | { |
| 6003 | return val; |
| 6004 | } |
| 6005 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6006 | RValue<Float> operator-(RValue<Float> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6007 | { |
| 6008 | return RValue<Float>(Nucleus::createFNeg(val.value)); |
| 6009 | } |
| 6010 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6011 | RValue<Bool> operator<(RValue<Float> lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6012 | { |
| 6013 | return RValue<Bool>(Nucleus::createFCmpOLT(lhs.value, rhs.value)); |
| 6014 | } |
| 6015 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6016 | RValue<Bool> operator<=(RValue<Float> lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6017 | { |
| 6018 | return RValue<Bool>(Nucleus::createFCmpOLE(lhs.value, rhs.value)); |
| 6019 | } |
| 6020 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6021 | RValue<Bool> operator>(RValue<Float> lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6022 | { |
| 6023 | return RValue<Bool>(Nucleus::createFCmpOGT(lhs.value, rhs.value)); |
| 6024 | } |
| 6025 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6026 | RValue<Bool> operator>=(RValue<Float> lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6027 | { |
| 6028 | return RValue<Bool>(Nucleus::createFCmpOGE(lhs.value, rhs.value)); |
| 6029 | } |
| 6030 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6031 | RValue<Bool> operator!=(RValue<Float> lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6032 | { |
| 6033 | return RValue<Bool>(Nucleus::createFCmpONE(lhs.value, rhs.value)); |
| 6034 | } |
| 6035 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6036 | RValue<Bool> operator==(RValue<Float> lhs, RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6037 | { |
| 6038 | return RValue<Bool>(Nucleus::createFCmpOEQ(lhs.value, rhs.value)); |
| 6039 | } |
| 6040 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6041 | RValue<Float> Abs(RValue<Float> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6042 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6043 | return IfThenElse(x > 0.0f, x, -x); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6044 | } |
| 6045 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6046 | RValue<Float> Max(RValue<Float> x, RValue<Float> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6047 | { |
| 6048 | return IfThenElse(x > y, x, y); |
| 6049 | } |
| 6050 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6051 | RValue<Float> Min(RValue<Float> x, RValue<Float> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6052 | { |
| 6053 | return IfThenElse(x < y, x, y); |
| 6054 | } |
| 6055 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6056 | RValue<Float> Rcp_pp(RValue<Float> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6057 | { |
| 6058 | return x86::rcpss(x); |
| 6059 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6060 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6061 | RValue<Float> RcpSqrt_pp(RValue<Float> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6062 | { |
| 6063 | return x86::rsqrtss(x); |
| 6064 | } |
| 6065 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6066 | RValue<Float> Sqrt(RValue<Float> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6067 | { |
| 6068 | return x86::sqrtss(x); |
| 6069 | } |
| 6070 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6071 | RValue<Float> Round(RValue<Float> x) |
| 6072 | { |
| 6073 | if(CPUID::supportsSSE4_1()) |
| 6074 | { |
| 6075 | return x86::roundss(x, 0); |
| 6076 | } |
| 6077 | else |
| 6078 | { |
| 6079 | return Float4(Round(Float4(x))).x; |
| 6080 | } |
| 6081 | } |
| 6082 | |
| 6083 | RValue<Float> Trunc(RValue<Float> x) |
| 6084 | { |
| 6085 | if(CPUID::supportsSSE4_1()) |
| 6086 | { |
| 6087 | return x86::roundss(x, 3); |
| 6088 | } |
| 6089 | else |
| 6090 | { |
| 6091 | return Float(Int(x)); // Rounded toward zero |
| 6092 | } |
| 6093 | } |
| 6094 | |
| 6095 | RValue<Float> Frac(RValue<Float> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6096 | { |
| 6097 | if(CPUID::supportsSSE4_1()) |
| 6098 | { |
| 6099 | return x - x86::floorss(x); |
| 6100 | } |
| 6101 | else |
| 6102 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6103 | return Float4(Frac(Float4(x))).x; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6104 | } |
| 6105 | } |
| 6106 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6107 | RValue<Float> Floor(RValue<Float> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6108 | { |
| 6109 | if(CPUID::supportsSSE4_1()) |
| 6110 | { |
| 6111 | return x86::floorss(x); |
| 6112 | } |
| 6113 | else |
| 6114 | { |
| 6115 | return Float4(Floor(Float4(x))).x; |
| 6116 | } |
| 6117 | } |
| 6118 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6119 | RValue<Float> Ceil(RValue<Float> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6120 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6121 | if(CPUID::supportsSSE4_1()) |
| 6122 | { |
| 6123 | return x86::ceilss(x); |
| 6124 | } |
| 6125 | else |
| 6126 | { |
| 6127 | return Float4(Ceil(Float4(x))).x; |
| 6128 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6129 | } |
| 6130 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6131 | Type *Float::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6132 | { |
| 6133 | return Type::getFloatTy(*Nucleus::getContext()); |
| 6134 | } |
| 6135 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6136 | Float2::Float2(RValue<Float4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6137 | { |
| 6138 | // xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6139 | |
| 6140 | Value *int64x2 = Nucleus::createBitCast(cast.value, Long2::getType()); |
| 6141 | Value *int64 = Nucleus::createExtractElement(int64x2, 0); |
| 6142 | Value *float2 = Nucleus::createBitCast(int64, Float2::getType()); |
| 6143 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6144 | storeValue(float2); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6145 | } |
| 6146 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6147 | Type *Float2::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6148 | { |
| 6149 | return VectorType::get(Float::getType(), 2); |
| 6150 | } |
| 6151 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6152 | Float4::Float4(RValue<Byte4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6153 | { |
| 6154 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6155 | |
| 6156 | #if 0 |
| 6157 | Value *xyzw = Nucleus::createUIToFP(cast.value, Float4::getType()); // FIXME: Crashes |
| 6158 | #elif 0 |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6159 | Value *vector = loadValue(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6160 | |
| 6161 | Value *i8x = Nucleus::createExtractElement(cast.value, 0); |
| 6162 | Value *f32x = Nucleus::createUIToFP(i8x, Float::getType()); |
| 6163 | Value *x = Nucleus::createInsertElement(vector, f32x, 0); |
| 6164 | |
| 6165 | Value *i8y = Nucleus::createExtractElement(cast.value, Nucleus::createConstantInt(1)); |
| 6166 | Value *f32y = Nucleus::createUIToFP(i8y, Float::getType()); |
| 6167 | Value *xy = Nucleus::createInsertElement(x, f32y, Nucleus::createConstantInt(1)); |
| 6168 | |
| 6169 | Value *i8z = Nucleus::createExtractElement(cast.value, Nucleus::createConstantInt(2)); |
| 6170 | Value *f32z = Nucleus::createUIToFP(i8z, Float::getType()); |
| 6171 | Value *xyz = Nucleus::createInsertElement(xy, f32z, Nucleus::createConstantInt(2)); |
| 6172 | |
| 6173 | Value *i8w = Nucleus::createExtractElement(cast.value, Nucleus::createConstantInt(3)); |
| 6174 | Value *f32w = Nucleus::createUIToFP(i8w, Float::getType()); |
| 6175 | Value *xyzw = Nucleus::createInsertElement(xyz, f32w, Nucleus::createConstantInt(3)); |
| 6176 | #else |
| 6177 | Value *x = Nucleus::createBitCast(cast.value, Int::getType()); |
| 6178 | Value *a = Nucleus::createInsertElement(UndefValue::get(Int4::getType()), x, 0); |
| 6179 | |
| 6180 | Value *e; |
| 6181 | |
| 6182 | if(CPUID::supportsSSE4_1()) |
| 6183 | { |
| 6184 | e = x86::pmovzxbd(RValue<Int4>(a)).value; |
| 6185 | } |
| 6186 | else |
| 6187 | { |
| 6188 | Constant *swizzle[16]; |
| 6189 | swizzle[0] = Nucleus::createConstantInt(0); |
| 6190 | swizzle[1] = Nucleus::createConstantInt(16); |
| 6191 | swizzle[2] = Nucleus::createConstantInt(1); |
| 6192 | swizzle[3] = Nucleus::createConstantInt(17); |
| 6193 | swizzle[4] = Nucleus::createConstantInt(2); |
| 6194 | swizzle[5] = Nucleus::createConstantInt(18); |
| 6195 | swizzle[6] = Nucleus::createConstantInt(3); |
| 6196 | swizzle[7] = Nucleus::createConstantInt(19); |
| 6197 | swizzle[8] = Nucleus::createConstantInt(4); |
| 6198 | swizzle[9] = Nucleus::createConstantInt(20); |
| 6199 | swizzle[10] = Nucleus::createConstantInt(5); |
| 6200 | swizzle[11] = Nucleus::createConstantInt(21); |
| 6201 | swizzle[12] = Nucleus::createConstantInt(6); |
| 6202 | swizzle[13] = Nucleus::createConstantInt(22); |
| 6203 | swizzle[14] = Nucleus::createConstantInt(7); |
| 6204 | swizzle[15] = Nucleus::createConstantInt(23); |
| 6205 | |
| 6206 | Value *b = Nucleus::createBitCast(a, Byte16::getType()); |
| 6207 | Value *c = Nucleus::createShuffleVector(b, Nucleus::createNullValue(Byte16::getType()), Nucleus::createConstantVector(swizzle, 16)); |
| 6208 | |
| 6209 | Constant *swizzle2[8]; |
| 6210 | swizzle2[0] = Nucleus::createConstantInt(0); |
| 6211 | swizzle2[1] = Nucleus::createConstantInt(8); |
| 6212 | swizzle2[2] = Nucleus::createConstantInt(1); |
| 6213 | swizzle2[3] = Nucleus::createConstantInt(9); |
| 6214 | swizzle2[4] = Nucleus::createConstantInt(2); |
| 6215 | swizzle2[5] = Nucleus::createConstantInt(10); |
| 6216 | swizzle2[6] = Nucleus::createConstantInt(3); |
| 6217 | swizzle2[7] = Nucleus::createConstantInt(11); |
| 6218 | |
| 6219 | Value *d = Nucleus::createBitCast(c, Short8::getType()); |
| 6220 | e = Nucleus::createShuffleVector(d, Nucleus::createNullValue(Short8::getType()), Nucleus::createConstantVector(swizzle2, 8)); |
| 6221 | } |
| 6222 | |
| 6223 | Value *f = Nucleus::createBitCast(e, Int4::getType()); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6224 | Value *g = Nucleus::createSIToFP(f, Float4::getType()); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6225 | Value *xyzw = g; |
| 6226 | #endif |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6227 | |
| 6228 | storeValue(xyzw); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6229 | } |
| 6230 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6231 | Float4::Float4(RValue<SByte4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6232 | { |
| 6233 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6234 | |
| 6235 | #if 0 |
| 6236 | Value *xyzw = Nucleus::createSIToFP(cast.value, Float4::getType()); // FIXME: Crashes |
| 6237 | #elif 0 |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6238 | Value *vector = loadValue(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6239 | |
| 6240 | Value *i8x = Nucleus::createExtractElement(cast.value, 0); |
| 6241 | Value *f32x = Nucleus::createSIToFP(i8x, Float::getType()); |
| 6242 | Value *x = Nucleus::createInsertElement(vector, f32x, 0); |
| 6243 | |
| 6244 | Value *i8y = Nucleus::createExtractElement(cast.value, Nucleus::createConstantInt(1)); |
| 6245 | Value *f32y = Nucleus::createSIToFP(i8y, Float::getType()); |
| 6246 | Value *xy = Nucleus::createInsertElement(x, f32y, Nucleus::createConstantInt(1)); |
| 6247 | |
| 6248 | Value *i8z = Nucleus::createExtractElement(cast.value, Nucleus::createConstantInt(2)); |
| 6249 | Value *f32z = Nucleus::createSIToFP(i8z, Float::getType()); |
| 6250 | Value *xyz = Nucleus::createInsertElement(xy, f32z, Nucleus::createConstantInt(2)); |
| 6251 | |
| 6252 | Value *i8w = Nucleus::createExtractElement(cast.value, Nucleus::createConstantInt(3)); |
| 6253 | Value *f32w = Nucleus::createSIToFP(i8w, Float::getType()); |
| 6254 | Value *xyzw = Nucleus::createInsertElement(xyz, f32w, Nucleus::createConstantInt(3)); |
| 6255 | #else |
| 6256 | Value *x = Nucleus::createBitCast(cast.value, Int::getType()); |
| 6257 | Value *a = Nucleus::createInsertElement(UndefValue::get(Int4::getType()), x, 0); |
| 6258 | |
| 6259 | Value *g; |
| 6260 | |
| 6261 | if(CPUID::supportsSSE4_1()) |
| 6262 | { |
| 6263 | g = x86::pmovsxbd(RValue<Int4>(a)).value; |
| 6264 | } |
| 6265 | else |
| 6266 | { |
| 6267 | Constant *swizzle[16]; |
| 6268 | swizzle[0] = Nucleus::createConstantInt(0); |
| 6269 | swizzle[1] = Nucleus::createConstantInt(0); |
| 6270 | swizzle[2] = Nucleus::createConstantInt(1); |
| 6271 | swizzle[3] = Nucleus::createConstantInt(1); |
| 6272 | swizzle[4] = Nucleus::createConstantInt(2); |
| 6273 | swizzle[5] = Nucleus::createConstantInt(2); |
| 6274 | swizzle[6] = Nucleus::createConstantInt(3); |
| 6275 | swizzle[7] = Nucleus::createConstantInt(3); |
| 6276 | swizzle[8] = Nucleus::createConstantInt(4); |
| 6277 | swizzle[9] = Nucleus::createConstantInt(4); |
| 6278 | swizzle[10] = Nucleus::createConstantInt(5); |
| 6279 | swizzle[11] = Nucleus::createConstantInt(5); |
| 6280 | swizzle[12] = Nucleus::createConstantInt(6); |
| 6281 | swizzle[13] = Nucleus::createConstantInt(6); |
| 6282 | swizzle[14] = Nucleus::createConstantInt(7); |
| 6283 | swizzle[15] = Nucleus::createConstantInt(7); |
| 6284 | |
| 6285 | Value *b = Nucleus::createBitCast(a, Byte16::getType()); |
| 6286 | Value *c = Nucleus::createShuffleVector(b, b, Nucleus::createConstantVector(swizzle, 16)); |
| 6287 | |
| 6288 | Constant *swizzle2[8]; |
| 6289 | swizzle2[0] = Nucleus::createConstantInt(0); |
| 6290 | swizzle2[1] = Nucleus::createConstantInt(0); |
| 6291 | swizzle2[2] = Nucleus::createConstantInt(1); |
| 6292 | swizzle2[3] = Nucleus::createConstantInt(1); |
| 6293 | swizzle2[4] = Nucleus::createConstantInt(2); |
| 6294 | swizzle2[5] = Nucleus::createConstantInt(2); |
| 6295 | swizzle2[6] = Nucleus::createConstantInt(3); |
| 6296 | swizzle2[7] = Nucleus::createConstantInt(3); |
| 6297 | |
| 6298 | Value *d = Nucleus::createBitCast(c, Short8::getType()); |
| 6299 | Value *e = Nucleus::createShuffleVector(d, d, Nucleus::createConstantVector(swizzle2, 8)); |
| 6300 | |
| 6301 | Value *f = Nucleus::createBitCast(e, Int4::getType()); |
| 6302 | // g = Nucleus::createAShr(f, Nucleus::createConstantInt(24)); |
| 6303 | g = x86::psrad(RValue<Int4>(f), 24).value; |
| 6304 | } |
| 6305 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6306 | Value *xyzw = Nucleus::createSIToFP(g, Float4::getType()); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6307 | #endif |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6308 | |
| 6309 | storeValue(xyzw); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6310 | } |
| 6311 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6312 | Float4::Float4(RValue<Short4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6313 | { |
| 6314 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6315 | |
Alexis Hetu | 2aa852f | 2015-10-14 16:32:39 -0400 | [diff] [blame] | 6316 | Int4 c(cast); |
| 6317 | storeValue(Nucleus::createSIToFP(RValue<Int4>(c).value, Float4::getType())); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6318 | } |
| 6319 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6320 | Float4::Float4(RValue<UShort4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6321 | { |
| 6322 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6323 | |
Alexis Hetu | 2aa852f | 2015-10-14 16:32:39 -0400 | [diff] [blame] | 6324 | Int4 c(cast); |
| 6325 | storeValue(Nucleus::createSIToFP(RValue<Int4>(c).value, Float4::getType())); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6326 | } |
| 6327 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6328 | Float4::Float4(RValue<Int4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6329 | { |
| 6330 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6331 | |
| 6332 | Value *xyzw = Nucleus::createSIToFP(cast.value, Float4::getType()); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6333 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6334 | storeValue(xyzw); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6335 | } |
| 6336 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6337 | Float4::Float4(RValue<UInt4> cast) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6338 | { |
| 6339 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6340 | |
| 6341 | Value *xyzw = Nucleus::createUIToFP(cast.value, Float4::getType()); |
| 6342 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6343 | storeValue(xyzw); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6344 | } |
| 6345 | |
| 6346 | Float4::Float4() |
| 6347 | { |
| 6348 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6349 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6350 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6351 | Float4::Float4(float xyzw) |
| 6352 | { |
| 6353 | constant(xyzw, xyzw, xyzw, xyzw); |
| 6354 | } |
| 6355 | |
| 6356 | Float4::Float4(float x, float yzw) |
| 6357 | { |
| 6358 | constant(x, yzw, yzw, yzw); |
| 6359 | } |
| 6360 | |
| 6361 | Float4::Float4(float x, float y, float zw) |
| 6362 | { |
| 6363 | constant(x, y, zw, zw); |
| 6364 | } |
| 6365 | |
| 6366 | Float4::Float4(float x, float y, float z, float w) |
| 6367 | { |
| 6368 | constant(x, y, z, w); |
| 6369 | } |
| 6370 | |
| 6371 | void Float4::constant(float x, float y, float z, float w) |
| 6372 | { |
| 6373 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6374 | |
| 6375 | Constant *constantVector[4]; |
| 6376 | constantVector[0] = Nucleus::createConstantFloat(x); |
| 6377 | constantVector[1] = Nucleus::createConstantFloat(y); |
| 6378 | constantVector[2] = Nucleus::createConstantFloat(z); |
| 6379 | constantVector[3] = Nucleus::createConstantFloat(w); |
| 6380 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6381 | storeValue(Nucleus::createConstantVector(constantVector, 4)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6382 | } |
| 6383 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6384 | Float4::Float4(RValue<Float4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6385 | { |
| 6386 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6387 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6388 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6389 | } |
| 6390 | |
| 6391 | Float4::Float4(const Float4 &rhs) |
| 6392 | { |
| 6393 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6394 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6395 | Value *value = rhs.loadValue(); |
| 6396 | storeValue(value); |
| 6397 | } |
| 6398 | |
| 6399 | Float4::Float4(const Reference<Float4> &rhs) |
| 6400 | { |
| 6401 | xyzw.parent = this; |
| 6402 | |
| 6403 | Value *value = rhs.loadValue(); |
| 6404 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6405 | } |
| 6406 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6407 | Float4::Float4(RValue<Float> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6408 | { |
| 6409 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6410 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6411 | Value *vector = loadValue(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6412 | Value *insert = Nucleus::createInsertElement(vector, rhs.value, 0); |
| 6413 | |
| 6414 | Constant *swizzle[4]; |
| 6415 | swizzle[0] = Nucleus::createConstantInt(0); |
| 6416 | swizzle[1] = Nucleus::createConstantInt(0); |
| 6417 | swizzle[2] = Nucleus::createConstantInt(0); |
| 6418 | swizzle[3] = Nucleus::createConstantInt(0); |
| 6419 | |
| 6420 | Value *replicate = Nucleus::createShuffleVector(insert, UndefValue::get(Float4::getType()), Nucleus::createConstantVector(swizzle, 4)); |
| 6421 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6422 | storeValue(replicate); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6423 | } |
| 6424 | |
| 6425 | Float4::Float4(const Float &rhs) |
| 6426 | { |
| 6427 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6428 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6429 | *this = RValue<Float>(rhs.loadValue()); |
| 6430 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6431 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6432 | Float4::Float4(const Reference<Float> &rhs) |
| 6433 | { |
| 6434 | xyzw.parent = this; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6435 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6436 | *this = RValue<Float>(rhs.loadValue()); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6437 | } |
| 6438 | |
| 6439 | RValue<Float4> Float4::operator=(float x) const |
| 6440 | { |
| 6441 | return *this = Float4(x, x, x, x); |
| 6442 | } |
| 6443 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6444 | RValue<Float4> Float4::operator=(RValue<Float4> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6445 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6446 | storeValue(rhs.value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6447 | |
| 6448 | return rhs; |
| 6449 | } |
| 6450 | |
| 6451 | RValue<Float4> Float4::operator=(const Float4 &rhs) const |
| 6452 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6453 | Value *value = rhs.loadValue(); |
| 6454 | storeValue(value); |
| 6455 | |
| 6456 | return RValue<Float4>(value); |
| 6457 | } |
| 6458 | |
| 6459 | RValue<Float4> Float4::operator=(const Reference<Float4> &rhs) const |
| 6460 | { |
| 6461 | Value *value = rhs.loadValue(); |
| 6462 | storeValue(value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6463 | |
| 6464 | return RValue<Float4>(value); |
| 6465 | } |
| 6466 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6467 | RValue<Float4> Float4::operator=(RValue<Float> rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6468 | { |
| 6469 | return *this = Float4(rhs); |
| 6470 | } |
| 6471 | |
| 6472 | RValue<Float4> Float4::operator=(const Float &rhs) const |
| 6473 | { |
| 6474 | return *this = Float4(rhs); |
| 6475 | } |
| 6476 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6477 | RValue<Float4> Float4::operator=(const Reference<Float> &rhs) const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6478 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6479 | return *this = Float4(rhs); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6480 | } |
| 6481 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6482 | RValue<Float4> operator+(RValue<Float4> lhs, RValue<Float4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6483 | { |
| 6484 | return RValue<Float4>(Nucleus::createFAdd(lhs.value, rhs.value)); |
| 6485 | } |
| 6486 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6487 | RValue<Float4> operator-(RValue<Float4> lhs, RValue<Float4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6488 | { |
| 6489 | return RValue<Float4>(Nucleus::createFSub(lhs.value, rhs.value)); |
| 6490 | } |
| 6491 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6492 | RValue<Float4> operator*(RValue<Float4> lhs, RValue<Float4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6493 | { |
| 6494 | return RValue<Float4>(Nucleus::createFMul(lhs.value, rhs.value)); |
| 6495 | } |
| 6496 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6497 | RValue<Float4> operator/(RValue<Float4> lhs, RValue<Float4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6498 | { |
| 6499 | return RValue<Float4>(Nucleus::createFDiv(lhs.value, rhs.value)); |
| 6500 | } |
| 6501 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6502 | RValue<Float4> operator%(RValue<Float4> lhs, RValue<Float4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6503 | { |
| 6504 | return RValue<Float4>(Nucleus::createFRem(lhs.value, rhs.value)); |
| 6505 | } |
| 6506 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6507 | RValue<Float4> operator+=(const Float4 &lhs, RValue<Float4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6508 | { |
| 6509 | return lhs = lhs + rhs; |
| 6510 | } |
| 6511 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6512 | RValue<Float4> operator-=(const Float4 &lhs, RValue<Float4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6513 | { |
| 6514 | return lhs = lhs - rhs; |
| 6515 | } |
| 6516 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6517 | RValue<Float4> operator*=(const Float4 &lhs, RValue<Float4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6518 | { |
| 6519 | return lhs = lhs * rhs; |
| 6520 | } |
| 6521 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6522 | RValue<Float4> operator/=(const Float4 &lhs, RValue<Float4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6523 | { |
| 6524 | return lhs = lhs / rhs; |
| 6525 | } |
| 6526 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6527 | RValue<Float4> operator%=(const Float4 &lhs, RValue<Float4> rhs) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6528 | { |
| 6529 | return lhs = lhs % rhs; |
| 6530 | } |
| 6531 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6532 | RValue<Float4> operator+(RValue<Float4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6533 | { |
| 6534 | return val; |
| 6535 | } |
| 6536 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6537 | RValue<Float4> operator-(RValue<Float4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6538 | { |
| 6539 | return RValue<Float4>(Nucleus::createFNeg(val.value)); |
| 6540 | } |
| 6541 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6542 | RValue<Float4> Abs(RValue<Float4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6543 | { |
| 6544 | Value *vector = Nucleus::createBitCast(x.value, Int4::getType()); |
| 6545 | |
| 6546 | Constant *constantVector[4]; |
| 6547 | constantVector[0] = Nucleus::createConstantInt(0x7FFFFFFF); |
| 6548 | constantVector[1] = Nucleus::createConstantInt(0x7FFFFFFF); |
| 6549 | constantVector[2] = Nucleus::createConstantInt(0x7FFFFFFF); |
| 6550 | constantVector[3] = Nucleus::createConstantInt(0x7FFFFFFF); |
| 6551 | |
| 6552 | Value *result = Nucleus::createAnd(vector, Nucleus::createConstantVector(constantVector, 4)); |
| 6553 | |
| 6554 | return RValue<Float4>(Nucleus::createBitCast(result, Float4::getType())); |
| 6555 | } |
| 6556 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6557 | RValue<Float4> Max(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6558 | { |
| 6559 | return x86::maxps(x, y); |
| 6560 | } |
| 6561 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6562 | RValue<Float4> Min(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6563 | { |
| 6564 | return x86::minps(x, y); |
| 6565 | } |
| 6566 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6567 | RValue<Float4> Rcp_pp(RValue<Float4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6568 | { |
| 6569 | return x86::rcpps(x); |
| 6570 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6571 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6572 | RValue<Float4> RcpSqrt_pp(RValue<Float4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6573 | { |
| 6574 | return x86::rsqrtps(x); |
| 6575 | } |
| 6576 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6577 | RValue<Float4> Sqrt(RValue<Float4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6578 | { |
| 6579 | return x86::sqrtps(x); |
| 6580 | } |
| 6581 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6582 | RValue<Float4> Insert(const Float4 &val, RValue<Float> element, int i) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6583 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6584 | llvm::Value *value = val.loadValue(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6585 | llvm::Value *insert = Nucleus::createInsertElement(value, element.value, i); |
| 6586 | |
| 6587 | val = RValue<Float4>(insert); |
| 6588 | |
| 6589 | return val; |
| 6590 | } |
| 6591 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6592 | RValue<Float> Extract(RValue<Float4> x, int i) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6593 | { |
| 6594 | return RValue<Float>(Nucleus::createExtractElement(x.value, i)); |
| 6595 | } |
| 6596 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6597 | RValue<Float4> Swizzle(RValue<Float4> x, unsigned char select) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6598 | { |
| 6599 | return RValue<Float4>(Nucleus::createSwizzle(x.value, select)); |
| 6600 | } |
| 6601 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6602 | RValue<Float4> ShuffleLowHigh(RValue<Float4> x, RValue<Float4> y, unsigned char imm) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6603 | { |
| 6604 | Constant *shuffle[4]; |
| 6605 | shuffle[0] = Nucleus::createConstantInt(((imm >> 0) & 0x03) + 0); |
| 6606 | shuffle[1] = Nucleus::createConstantInt(((imm >> 2) & 0x03) + 0); |
| 6607 | shuffle[2] = Nucleus::createConstantInt(((imm >> 4) & 0x03) + 4); |
| 6608 | shuffle[3] = Nucleus::createConstantInt(((imm >> 6) & 0x03) + 4); |
| 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> UnpackLow(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(0); |
| 6617 | shuffle[1] = Nucleus::createConstantInt(4); |
| 6618 | shuffle[2] = Nucleus::createConstantInt(1); |
| 6619 | shuffle[3] = Nucleus::createConstantInt(5); |
| 6620 | |
| 6621 | return RValue<Float4>(Nucleus::createShuffleVector(x.value, y.value, Nucleus::createConstantVector(shuffle, 4))); |
| 6622 | } |
| 6623 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6624 | RValue<Float4> UnpackHigh(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6625 | { |
| 6626 | Constant *shuffle[4]; |
| 6627 | shuffle[0] = Nucleus::createConstantInt(2); |
| 6628 | shuffle[1] = Nucleus::createConstantInt(6); |
| 6629 | shuffle[2] = Nucleus::createConstantInt(3); |
| 6630 | shuffle[3] = Nucleus::createConstantInt(7); |
| 6631 | |
| 6632 | return RValue<Float4>(Nucleus::createShuffleVector(x.value, y.value, Nucleus::createConstantVector(shuffle, 4))); |
| 6633 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6634 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6635 | RValue<Float4> Mask(Float4 &lhs, RValue<Float4> rhs, unsigned char select) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6636 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6637 | Value *vector = lhs.loadValue(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6638 | Value *shuffle = Nucleus::createMask(vector, rhs.value, select); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6639 | lhs.storeValue(shuffle); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6640 | |
| 6641 | return RValue<Float4>(shuffle); |
| 6642 | } |
| 6643 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6644 | RValue<Int> SignMask(RValue<Float4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6645 | { |
| 6646 | return x86::movmskps(x); |
| 6647 | } |
| 6648 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6649 | RValue<Int4> CmpEQ(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6650 | { |
| 6651 | // return As<Int4>(x86::cmpeqps(x, y)); |
| 6652 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOEQ(x.value, y.value), Int4::getType())); |
| 6653 | } |
| 6654 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6655 | RValue<Int4> CmpLT(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6656 | { |
| 6657 | // return As<Int4>(x86::cmpltps(x, y)); |
| 6658 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOLT(x.value, y.value), Int4::getType())); |
| 6659 | } |
| 6660 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6661 | RValue<Int4> CmpLE(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6662 | { |
| 6663 | // return As<Int4>(x86::cmpleps(x, y)); |
| 6664 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOLE(x.value, y.value), Int4::getType())); |
| 6665 | } |
| 6666 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6667 | RValue<Int4> CmpNEQ(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6668 | { |
| 6669 | // return As<Int4>(x86::cmpneqps(x, y)); |
| 6670 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpONE(x.value, y.value), Int4::getType())); |
| 6671 | } |
| 6672 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6673 | RValue<Int4> CmpNLT(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6674 | { |
| 6675 | // return As<Int4>(x86::cmpnltps(x, y)); |
| 6676 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOGE(x.value, y.value), Int4::getType())); |
| 6677 | } |
| 6678 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6679 | RValue<Int4> CmpNLE(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6680 | { |
| 6681 | // return As<Int4>(x86::cmpnleps(x, y)); |
| 6682 | return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOGT(x.value, y.value), Int4::getType())); |
| 6683 | } |
| 6684 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6685 | RValue<Float4> Round(RValue<Float4> x) |
| 6686 | { |
| 6687 | if(CPUID::supportsSSE4_1()) |
| 6688 | { |
| 6689 | return x86::roundps(x, 0); |
| 6690 | } |
| 6691 | else |
| 6692 | { |
| 6693 | return Float4(RoundInt(x)); |
| 6694 | } |
| 6695 | } |
| 6696 | |
| 6697 | RValue<Float4> Trunc(RValue<Float4> x) |
| 6698 | { |
| 6699 | if(CPUID::supportsSSE4_1()) |
| 6700 | { |
| 6701 | return x86::roundps(x, 3); |
| 6702 | } |
| 6703 | else |
| 6704 | { |
| 6705 | return Float4(Int4(x)); // Rounded toward zero |
| 6706 | } |
| 6707 | } |
| 6708 | |
| 6709 | RValue<Float4> Frac(RValue<Float4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6710 | { |
| 6711 | if(CPUID::supportsSSE4_1()) |
| 6712 | { |
| 6713 | return x - x86::floorps(x); |
| 6714 | } |
| 6715 | else |
| 6716 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6717 | Float4 frc = x - Float4(Int4(x)); // Signed fractional part |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6718 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6719 | 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] | 6720 | } |
| 6721 | } |
| 6722 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6723 | RValue<Float4> Floor(RValue<Float4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6724 | { |
| 6725 | if(CPUID::supportsSSE4_1()) |
| 6726 | { |
| 6727 | return x86::floorps(x); |
| 6728 | } |
| 6729 | else |
| 6730 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6731 | return x - Frac(x); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6732 | } |
| 6733 | } |
| 6734 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6735 | RValue<Float4> Ceil(RValue<Float4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6736 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6737 | if(CPUID::supportsSSE4_1()) |
| 6738 | { |
| 6739 | return x86::ceilps(x); |
| 6740 | } |
| 6741 | else |
| 6742 | { |
| 6743 | return -Floor(-x); |
| 6744 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6745 | } |
| 6746 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6747 | Type *Float4::getType() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6748 | { |
| 6749 | return VectorType::get(Float::getType(), 4); |
| 6750 | } |
| 6751 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6752 | RValue<Pointer<Byte> > operator+(RValue<Pointer<Byte> > lhs, int offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6753 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6754 | return RValue<Pointer<Byte> >(Nucleus::createGEP(lhs.value, Nucleus::createConstantInt(offset))); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6755 | } |
| 6756 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6757 | RValue<Pointer<Byte> > operator+(RValue<Pointer<Byte> > lhs, RValue<Int> offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6758 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6759 | return RValue<Pointer<Byte> >(Nucleus::createGEP(lhs.value, offset.value)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6760 | } |
| 6761 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6762 | RValue<Pointer<Byte> > operator+(RValue<Pointer<Byte> > lhs, RValue<UInt> offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6763 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6764 | return RValue<Pointer<Byte> >(Nucleus::createGEP(lhs.value, offset.value)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6765 | } |
| 6766 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6767 | RValue<Pointer<Byte> > operator+=(const Pointer<Byte> &lhs, int offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6768 | { |
| 6769 | return lhs = lhs + offset; |
| 6770 | } |
| 6771 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6772 | RValue<Pointer<Byte> > operator+=(const Pointer<Byte> &lhs, RValue<Int> offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6773 | { |
| 6774 | return lhs = lhs + offset; |
| 6775 | } |
| 6776 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6777 | RValue<Pointer<Byte> > operator+=(const Pointer<Byte> &lhs, RValue<UInt> offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6778 | { |
| 6779 | return lhs = lhs + offset; |
| 6780 | } |
| 6781 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6782 | RValue<Pointer<Byte> > operator-(RValue<Pointer<Byte> > lhs, int offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6783 | { |
| 6784 | return lhs + -offset; |
| 6785 | } |
| 6786 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6787 | RValue<Pointer<Byte> > operator-(RValue<Pointer<Byte> > lhs, RValue<Int> offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6788 | { |
| 6789 | return lhs + -offset; |
| 6790 | } |
| 6791 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6792 | RValue<Pointer<Byte> > operator-(RValue<Pointer<Byte> > lhs, RValue<UInt> offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6793 | { |
| 6794 | return lhs + -offset; |
| 6795 | } |
| 6796 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6797 | RValue<Pointer<Byte> > operator-=(const Pointer<Byte> &lhs, int offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6798 | { |
| 6799 | return lhs = lhs - offset; |
| 6800 | } |
| 6801 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6802 | RValue<Pointer<Byte> > operator-=(const Pointer<Byte> &lhs, RValue<Int> offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6803 | { |
| 6804 | return lhs = lhs - offset; |
| 6805 | } |
| 6806 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6807 | RValue<Pointer<Byte> > operator-=(const Pointer<Byte> &lhs, RValue<UInt> offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6808 | { |
| 6809 | return lhs = lhs - offset; |
| 6810 | } |
| 6811 | |
| 6812 | void Return() |
| 6813 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6814 | Nucleus::createRetVoid(); |
| 6815 | Nucleus::setInsertBlock(Nucleus::createBasicBlock()); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6816 | Nucleus::createUnreachable(); |
| 6817 | } |
| 6818 | |
| 6819 | void Return(bool ret) |
| 6820 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6821 | Nucleus::createRet(Nucleus::createConstantBool(ret)); |
| 6822 | Nucleus::setInsertBlock(Nucleus::createBasicBlock()); |
| 6823 | Nucleus::createUnreachable(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6824 | } |
| 6825 | |
| 6826 | void Return(const Int &ret) |
| 6827 | { |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6828 | Nucleus::createRet(ret.loadValue()); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6829 | Nucleus::setInsertBlock(Nucleus::createBasicBlock()); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6830 | Nucleus::createUnreachable(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6831 | } |
| 6832 | |
| 6833 | BasicBlock *beginLoop() |
| 6834 | { |
| 6835 | BasicBlock *loopBB = Nucleus::createBasicBlock(); |
| 6836 | |
| 6837 | Nucleus::createBr(loopBB); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6838 | Nucleus::setInsertBlock(loopBB); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6839 | |
| 6840 | return loopBB; |
| 6841 | } |
| 6842 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6843 | bool branch(RValue<Bool> cmp, BasicBlock *bodyBB, BasicBlock *endBB) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6844 | { |
| 6845 | Nucleus::createCondBr(cmp.value, bodyBB, endBB); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6846 | Nucleus::setInsertBlock(bodyBB); |
| 6847 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6848 | return true; |
| 6849 | } |
| 6850 | |
| 6851 | bool elseBlock(BasicBlock *falseBB) |
| 6852 | { |
| 6853 | falseBB->back().eraseFromParent(); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6854 | Nucleus::setInsertBlock(falseBB); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6855 | |
| 6856 | return true; |
| 6857 | } |
| 6858 | |
| 6859 | RValue<Long> Ticks() |
| 6860 | { |
| 6861 | Module *module = Nucleus::getModule(); |
| 6862 | llvm::Function *rdtsc = Intrinsic::getDeclaration(module, Intrinsic::readcyclecounter); |
| 6863 | |
| 6864 | return RValue<Long>(Nucleus::createCall(rdtsc)); |
| 6865 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6866 | } |
| 6867 | |
| 6868 | namespace sw |
| 6869 | { |
| 6870 | namespace x86 |
| 6871 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6872 | RValue<Int> cvtss2si(RValue<Float> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6873 | { |
| 6874 | Module *module = Nucleus::getModule(); |
| 6875 | llvm::Function *cvtss2si = Intrinsic::getDeclaration(module, Intrinsic::x86_sse_cvtss2si); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6876 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6877 | Float4 vector; |
| 6878 | vector.x = val; |
| 6879 | |
| 6880 | return RValue<Int>(Nucleus::createCall(cvtss2si, RValue<Float4>(vector).value)); |
| 6881 | } |
| 6882 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6883 | RValue<Int2> cvtps2pi(RValue<Float4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6884 | { |
| 6885 | Module *module = Nucleus::getModule(); |
| 6886 | llvm::Function *cvtps2pi = Intrinsic::getDeclaration(module, Intrinsic::x86_sse_cvtps2pi); |
| 6887 | |
| 6888 | return RValue<Int2>(Nucleus::createCall(cvtps2pi, val.value)); |
| 6889 | } |
| 6890 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6891 | RValue<Int2> cvttps2pi(RValue<Float4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6892 | { |
| 6893 | Module *module = Nucleus::getModule(); |
| 6894 | llvm::Function *cvttps2pi = Intrinsic::getDeclaration(module, Intrinsic::x86_sse_cvttps2pi); |
| 6895 | |
| 6896 | return RValue<Int2>(Nucleus::createCall(cvttps2pi, val.value)); |
| 6897 | } |
| 6898 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6899 | RValue<Int4> cvtps2dq(RValue<Float4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6900 | { |
| 6901 | if(CPUID::supportsSSE2()) |
| 6902 | { |
| 6903 | Module *module = Nucleus::getModule(); |
| 6904 | llvm::Function *cvtps2dq = Intrinsic::getDeclaration(module, Intrinsic::x86_sse2_cvtps2dq); |
| 6905 | |
| 6906 | return RValue<Int4>(Nucleus::createCall(cvtps2dq, val.value)); |
| 6907 | } |
| 6908 | else |
| 6909 | { |
| 6910 | Int2 lo = x86::cvtps2pi(val); |
| 6911 | Int2 hi = x86::cvtps2pi(Swizzle(val, 0xEE)); |
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 Concatenate(lo, hi); |
| 6914 | } |
| 6915 | } |
| 6916 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6917 | RValue<Float> rcpss(RValue<Float> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6918 | { |
| 6919 | Module *module = Nucleus::getModule(); |
| 6920 | llvm::Function *rcpss = Intrinsic::getDeclaration(module, Intrinsic::x86_sse_rcp_ss); |
| 6921 | |
| 6922 | Value *vector = Nucleus::createInsertElement(UndefValue::get(Float4::getType()), val.value, 0); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6923 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6924 | return RValue<Float>(Nucleus::createExtractElement(Nucleus::createCall(rcpss, vector), 0)); |
| 6925 | } |
| 6926 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6927 | RValue<Float> sqrtss(RValue<Float> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6928 | { |
| 6929 | Module *module = Nucleus::getModule(); |
| 6930 | llvm::Function *sqrtss = Intrinsic::getDeclaration(module, Intrinsic::x86_sse_sqrt_ss); |
| 6931 | |
| 6932 | Value *vector = Nucleus::createInsertElement(UndefValue::get(Float4::getType()), val.value, 0); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6933 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6934 | return RValue<Float>(Nucleus::createExtractElement(Nucleus::createCall(sqrtss, vector), 0)); |
| 6935 | } |
| 6936 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6937 | RValue<Float> rsqrtss(RValue<Float> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6938 | { |
| 6939 | Module *module = Nucleus::getModule(); |
| 6940 | llvm::Function *rsqrtss = Intrinsic::getDeclaration(module, Intrinsic::x86_sse_rsqrt_ss); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6941 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6942 | Value *vector = Nucleus::createInsertElement(UndefValue::get(Float4::getType()), val.value, 0); |
| 6943 | |
| 6944 | return RValue<Float>(Nucleus::createExtractElement(Nucleus::createCall(rsqrtss, vector), 0)); |
| 6945 | } |
| 6946 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6947 | RValue<Float4> rcpps(RValue<Float4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6948 | { |
| 6949 | Module *module = Nucleus::getModule(); |
| 6950 | llvm::Function *rcpps = Intrinsic::getDeclaration(module, Intrinsic::x86_sse_rcp_ps); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6951 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6952 | return RValue<Float4>(Nucleus::createCall(rcpps, val.value)); |
| 6953 | } |
| 6954 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6955 | RValue<Float4> sqrtps(RValue<Float4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6956 | { |
| 6957 | Module *module = Nucleus::getModule(); |
| 6958 | llvm::Function *sqrtps = Intrinsic::getDeclaration(module, Intrinsic::x86_sse_sqrt_ps); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6959 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6960 | return RValue<Float4>(Nucleus::createCall(sqrtps, val.value)); |
| 6961 | } |
| 6962 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6963 | RValue<Float4> rsqrtps(RValue<Float4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6964 | { |
| 6965 | Module *module = Nucleus::getModule(); |
| 6966 | llvm::Function *rsqrtps = Intrinsic::getDeclaration(module, Intrinsic::x86_sse_rsqrt_ps); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6967 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6968 | return RValue<Float4>(Nucleus::createCall(rsqrtps, val.value)); |
| 6969 | } |
| 6970 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6971 | RValue<Float4> maxps(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6972 | { |
| 6973 | Module *module = Nucleus::getModule(); |
| 6974 | llvm::Function *maxps = Intrinsic::getDeclaration(module, Intrinsic::x86_sse_max_ps); |
| 6975 | |
| 6976 | return RValue<Float4>(Nucleus::createCall(maxps, x.value, y.value)); |
| 6977 | } |
| 6978 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6979 | RValue<Float4> minps(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6980 | { |
| 6981 | Module *module = Nucleus::getModule(); |
| 6982 | llvm::Function *minps = Intrinsic::getDeclaration(module, Intrinsic::x86_sse_min_ps); |
| 6983 | |
| 6984 | return RValue<Float4>(Nucleus::createCall(minps, x.value, y.value)); |
| 6985 | } |
| 6986 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6987 | RValue<Float> roundss(RValue<Float> val, unsigned char imm) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6988 | { |
| 6989 | Module *module = Nucleus::getModule(); |
| 6990 | llvm::Function *roundss = Intrinsic::getDeclaration(module, Intrinsic::x86_sse41_round_ss); |
| 6991 | |
| 6992 | Value *undef = UndefValue::get(Float4::getType()); |
| 6993 | Value *vector = Nucleus::createInsertElement(undef, val.value, 0); |
| 6994 | |
| 6995 | return RValue<Float>(Nucleus::createExtractElement(Nucleus::createCall(roundss, undef, vector, Nucleus::createConstantInt(imm)), 0)); |
| 6996 | } |
| 6997 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 6998 | RValue<Float> floorss(RValue<Float> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6999 | { |
| 7000 | return roundss(val, 1); |
| 7001 | } |
| 7002 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7003 | RValue<Float> ceilss(RValue<Float> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7004 | { |
| 7005 | return roundss(val, 2); |
| 7006 | } |
| 7007 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7008 | RValue<Float4> roundps(RValue<Float4> val, unsigned char imm) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7009 | { |
| 7010 | Module *module = Nucleus::getModule(); |
| 7011 | llvm::Function *roundps = Intrinsic::getDeclaration(module, Intrinsic::x86_sse41_round_ps); |
| 7012 | |
| 7013 | return RValue<Float4>(Nucleus::createCall(roundps, val.value, Nucleus::createConstantInt(imm))); |
| 7014 | } |
| 7015 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7016 | RValue<Float4> floorps(RValue<Float4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7017 | { |
| 7018 | return roundps(val, 1); |
| 7019 | } |
| 7020 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7021 | RValue<Float4> ceilps(RValue<Float4> val) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7022 | { |
| 7023 | return roundps(val, 2); |
| 7024 | } |
| 7025 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7026 | RValue<Float4> cmpps(RValue<Float4> x, RValue<Float4> y, unsigned char imm) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7027 | { |
| 7028 | Module *module = Nucleus::getModule(); |
| 7029 | llvm::Function *cmpps = Intrinsic::getDeclaration(module, Intrinsic::x86_sse_cmp_ps); |
| 7030 | |
| 7031 | return RValue<Float4>(Nucleus::createCall(cmpps, x.value, y.value, Nucleus::createConstantByte(imm))); |
| 7032 | } |
| 7033 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7034 | RValue<Float4> cmpeqps(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7035 | { |
| 7036 | return cmpps(x, y, 0); |
| 7037 | } |
| 7038 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7039 | RValue<Float4> cmpltps(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7040 | { |
| 7041 | return cmpps(x, y, 1); |
| 7042 | } |
| 7043 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7044 | RValue<Float4> cmpleps(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7045 | { |
| 7046 | return cmpps(x, y, 2); |
| 7047 | } |
| 7048 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7049 | RValue<Float4> cmpunordps(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7050 | { |
| 7051 | return cmpps(x, y, 3); |
| 7052 | } |
| 7053 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7054 | RValue<Float4> cmpneqps(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7055 | { |
| 7056 | return cmpps(x, y, 4); |
| 7057 | } |
| 7058 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7059 | RValue<Float4> cmpnltps(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7060 | { |
| 7061 | return cmpps(x, y, 5); |
| 7062 | } |
| 7063 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7064 | RValue<Float4> cmpnleps(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7065 | { |
| 7066 | return cmpps(x, y, 6); |
| 7067 | } |
| 7068 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7069 | RValue<Float4> cmpordps(RValue<Float4> x, RValue<Float4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7070 | { |
| 7071 | return cmpps(x, y, 7); |
| 7072 | } |
| 7073 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7074 | RValue<Float> cmpss(RValue<Float> x, RValue<Float> y, unsigned char imm) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7075 | { |
| 7076 | Module *module = Nucleus::getModule(); |
| 7077 | llvm::Function *cmpss = Intrinsic::getDeclaration(module, Intrinsic::x86_sse_cmp_ss); |
| 7078 | |
| 7079 | Value *vector1 = Nucleus::createInsertElement(UndefValue::get(Float4::getType()), x.value, 0); |
| 7080 | Value *vector2 = Nucleus::createInsertElement(UndefValue::get(Float4::getType()), y.value, 0); |
| 7081 | |
| 7082 | return RValue<Float>(Nucleus::createExtractElement(Nucleus::createCall(cmpss, vector1, vector2, Nucleus::createConstantByte(imm)), 0)); |
| 7083 | } |
| 7084 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7085 | RValue<Float> cmpeqss(RValue<Float> x, RValue<Float> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7086 | { |
| 7087 | return cmpss(x, y, 0); |
| 7088 | } |
| 7089 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7090 | RValue<Float> cmpltss(RValue<Float> x, RValue<Float> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7091 | { |
| 7092 | return cmpss(x, y, 1); |
| 7093 | } |
| 7094 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7095 | RValue<Float> cmpless(RValue<Float> x, RValue<Float> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7096 | { |
| 7097 | return cmpss(x, y, 2); |
| 7098 | } |
| 7099 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7100 | RValue<Float> cmpunordss(RValue<Float> x, RValue<Float> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7101 | { |
| 7102 | return cmpss(x, y, 3); |
| 7103 | } |
| 7104 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7105 | RValue<Float> cmpneqss(RValue<Float> x, RValue<Float> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7106 | { |
| 7107 | return cmpss(x, y, 4); |
| 7108 | } |
| 7109 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7110 | RValue<Float> cmpnltss(RValue<Float> x, RValue<Float> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7111 | { |
| 7112 | return cmpss(x, y, 5); |
| 7113 | } |
| 7114 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7115 | RValue<Float> cmpnless(RValue<Float> x, RValue<Float> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7116 | { |
| 7117 | return cmpss(x, y, 6); |
| 7118 | } |
| 7119 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7120 | RValue<Float> cmpordss(RValue<Float> x, RValue<Float> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7121 | { |
| 7122 | return cmpss(x, y, 7); |
| 7123 | } |
| 7124 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7125 | RValue<Int4> pabsd(RValue<Int4> x, RValue<Int4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7126 | { |
| 7127 | Module *module = Nucleus::getModule(); |
| 7128 | llvm::Function *pabsd = Intrinsic::getDeclaration(module, Intrinsic::x86_ssse3_pabs_d_128); |
| 7129 | |
| 7130 | return RValue<Int4>(Nucleus::createCall(pabsd, x.value, y.value)); |
| 7131 | } |
| 7132 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7133 | RValue<Short4> paddsw(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7134 | { |
| 7135 | Module *module = Nucleus::getModule(); |
| 7136 | llvm::Function *paddsw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_padds_w); |
| 7137 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7138 | 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] | 7139 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7140 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7141 | RValue<Short4> psubsw(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7142 | { |
| 7143 | Module *module = Nucleus::getModule(); |
| 7144 | llvm::Function *psubsw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_psubs_w); |
| 7145 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7146 | 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] | 7147 | } |
| 7148 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7149 | RValue<UShort4> paddusw(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7150 | { |
| 7151 | Module *module = Nucleus::getModule(); |
| 7152 | llvm::Function *paddusw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_paddus_w); |
| 7153 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7154 | 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] | 7155 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7156 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7157 | RValue<UShort4> psubusw(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7158 | { |
| 7159 | Module *module = Nucleus::getModule(); |
| 7160 | llvm::Function *psubusw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_psubus_w); |
| 7161 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7162 | 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] | 7163 | } |
| 7164 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7165 | RValue<SByte8> paddsb(RValue<SByte8> x, RValue<SByte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7166 | { |
| 7167 | Module *module = Nucleus::getModule(); |
| 7168 | llvm::Function *paddsb = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_padds_b); |
| 7169 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7170 | 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] | 7171 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7172 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7173 | RValue<SByte8> psubsb(RValue<SByte8> x, RValue<SByte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7174 | { |
| 7175 | Module *module = Nucleus::getModule(); |
| 7176 | llvm::Function *psubsb = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_psubs_b); |
| 7177 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7178 | 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] | 7179 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7180 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7181 | RValue<Byte8> paddusb(RValue<Byte8> x, RValue<Byte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7182 | { |
| 7183 | Module *module = Nucleus::getModule(); |
| 7184 | llvm::Function *paddusb = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_paddus_b); |
| 7185 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7186 | 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] | 7187 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7188 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7189 | RValue<Byte8> psubusb(RValue<Byte8> x, RValue<Byte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7190 | { |
| 7191 | Module *module = Nucleus::getModule(); |
| 7192 | llvm::Function *psubusb = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_psubus_b); |
| 7193 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7194 | 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] | 7195 | } |
| 7196 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7197 | RValue<Short4> paddw(RValue<Short4> x, RValue<Short4> y) |
| 7198 | { |
| 7199 | Module *module = Nucleus::getModule(); |
| 7200 | llvm::Function *paddw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_padd_w); |
| 7201 | |
| 7202 | return As<Short4>(RValue<MMX>(Nucleus::createCall(paddw, As<MMX>(x).value, As<MMX>(y).value))); |
| 7203 | } |
| 7204 | |
| 7205 | RValue<Short4> psubw(RValue<Short4> x, RValue<Short4> y) |
| 7206 | { |
| 7207 | Module *module = Nucleus::getModule(); |
| 7208 | llvm::Function *psubw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_psub_w); |
| 7209 | |
| 7210 | return As<Short4>(RValue<MMX>(Nucleus::createCall(psubw, As<MMX>(x).value, As<MMX>(y).value))); |
| 7211 | } |
| 7212 | |
| 7213 | RValue<Short4> pmullw(RValue<Short4> x, RValue<Short4> y) |
| 7214 | { |
| 7215 | Module *module = Nucleus::getModule(); |
| 7216 | llvm::Function *pmullw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pmull_w); |
| 7217 | |
| 7218 | return As<Short4>(RValue<MMX>(Nucleus::createCall(pmullw, As<MMX>(x).value, As<MMX>(y).value))); |
| 7219 | } |
| 7220 | |
| 7221 | RValue<Short4> pand(RValue<Short4> x, RValue<Short4> y) |
| 7222 | { |
| 7223 | Module *module = Nucleus::getModule(); |
| 7224 | llvm::Function *pand = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pand); |
| 7225 | |
| 7226 | return As<Short4>(RValue<MMX>(Nucleus::createCall(pand, As<MMX>(x).value, As<MMX>(y).value))); |
| 7227 | } |
| 7228 | |
| 7229 | RValue<Short4> por(RValue<Short4> x, RValue<Short4> y) |
| 7230 | { |
| 7231 | Module *module = Nucleus::getModule(); |
| 7232 | llvm::Function *por = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_por); |
| 7233 | |
| 7234 | return As<Short4>(RValue<MMX>(Nucleus::createCall(por, As<MMX>(x).value, As<MMX>(y).value))); |
| 7235 | } |
| 7236 | |
| 7237 | RValue<Short4> pxor(RValue<Short4> x, RValue<Short4> y) |
| 7238 | { |
| 7239 | Module *module = Nucleus::getModule(); |
| 7240 | llvm::Function *pxor = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pxor); |
| 7241 | |
| 7242 | return As<Short4>(RValue<MMX>(Nucleus::createCall(pxor, As<MMX>(x).value, As<MMX>(y).value))); |
| 7243 | } |
| 7244 | |
| 7245 | RValue<Short4> pshufw(RValue<Short4> x, unsigned char y) |
| 7246 | { |
| 7247 | Module *module = Nucleus::getModule(); |
| 7248 | llvm::Function *pshufw = Intrinsic::getDeclaration(module, Intrinsic::x86_sse_pshuf_w); |
| 7249 | |
| 7250 | return As<Short4>(RValue<MMX>(Nucleus::createCall(pshufw, As<MMX>(x).value, Nucleus::createConstantByte(y)))); |
| 7251 | } |
| 7252 | |
| 7253 | RValue<Int2> punpcklwd(RValue<Short4> x, RValue<Short4> y) |
| 7254 | { |
| 7255 | Module *module = Nucleus::getModule(); |
| 7256 | llvm::Function *punpcklwd = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_punpcklwd); |
| 7257 | |
| 7258 | return As<Int2>(RValue<MMX>(Nucleus::createCall(punpcklwd, As<MMX>(x).value, As<MMX>(y).value))); |
| 7259 | } |
| 7260 | |
| 7261 | RValue<Int2> punpckhwd(RValue<Short4> x, RValue<Short4> y) |
| 7262 | { |
| 7263 | Module *module = Nucleus::getModule(); |
| 7264 | llvm::Function *punpckhwd = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_punpckhwd); |
| 7265 | |
| 7266 | return As<Int2>(RValue<MMX>(Nucleus::createCall(punpckhwd, As<MMX>(x).value, As<MMX>(y).value))); |
| 7267 | } |
| 7268 | |
| 7269 | RValue<Short4> pinsrw(RValue<Short4> x, RValue<Int> y, unsigned int i) |
| 7270 | { |
| 7271 | Module *module = Nucleus::getModule(); |
| 7272 | llvm::Function *pinsrw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pinsr_w); |
| 7273 | |
| 7274 | return As<Short4>(RValue<MMX>(Nucleus::createCall(pinsrw, As<MMX>(x).value, y.value, Nucleus::createConstantInt(i)))); |
| 7275 | } |
| 7276 | |
| 7277 | RValue<Int> pextrw(RValue<Short4> x, unsigned int i) |
| 7278 | { |
| 7279 | Module *module = Nucleus::getModule(); |
| 7280 | llvm::Function *pextrw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pextr_w); |
| 7281 | |
| 7282 | return RValue<Int>(Nucleus::createCall(pextrw, As<MMX>(x).value, Nucleus::createConstantInt(i))); |
| 7283 | } |
| 7284 | |
| 7285 | RValue<Long1> punpckldq(RValue<Int2> x, RValue<Int2> y) |
| 7286 | { |
| 7287 | Module *module = Nucleus::getModule(); |
| 7288 | llvm::Function *punpckldq = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_punpckldq); |
| 7289 | |
| 7290 | return As<Long1>(RValue<MMX>(Nucleus::createCall(punpckldq, As<MMX>(x).value, As<MMX>(y).value))); |
| 7291 | } |
| 7292 | |
| 7293 | RValue<Long1> punpckhdq(RValue<Int2> x, RValue<Int2> y) |
| 7294 | { |
| 7295 | Module *module = Nucleus::getModule(); |
| 7296 | llvm::Function *punpckhdq = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_punpckhdq); |
| 7297 | |
| 7298 | return As<Long1>(RValue<MMX>(Nucleus::createCall(punpckhdq, As<MMX>(x).value, As<MMX>(y).value))); |
| 7299 | } |
| 7300 | |
| 7301 | RValue<Short4> punpcklbw(RValue<Byte8> x, RValue<Byte8> y) |
| 7302 | { |
| 7303 | Module *module = Nucleus::getModule(); |
| 7304 | llvm::Function *punpcklbw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_punpcklbw); |
| 7305 | |
| 7306 | return As<Short4>(RValue<MMX>(Nucleus::createCall(punpcklbw, As<MMX>(x).value, As<MMX>(y).value))); |
| 7307 | } |
| 7308 | |
| 7309 | RValue<Short4> punpckhbw(RValue<Byte8> x, RValue<Byte8> y) |
| 7310 | { |
| 7311 | Module *module = Nucleus::getModule(); |
| 7312 | llvm::Function *punpckhbw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_punpckhbw); |
| 7313 | |
| 7314 | return As<Short4>(RValue<MMX>(Nucleus::createCall(punpckhbw, As<MMX>(x).value, As<MMX>(y).value))); |
| 7315 | } |
| 7316 | |
| 7317 | RValue<Byte8> paddb(RValue<Byte8> x, RValue<Byte8> y) |
| 7318 | { |
| 7319 | Module *module = Nucleus::getModule(); |
| 7320 | llvm::Function *paddb = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_padd_b); |
| 7321 | |
| 7322 | return As<Byte8>(RValue<MMX>(Nucleus::createCall(paddb, As<MMX>(x).value, As<MMX>(y).value))); |
| 7323 | } |
| 7324 | |
| 7325 | RValue<Byte8> psubb(RValue<Byte8> x, RValue<Byte8> y) |
| 7326 | { |
| 7327 | Module *module = Nucleus::getModule(); |
| 7328 | llvm::Function *psubb = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_psub_b); |
| 7329 | |
| 7330 | return As<Byte8>(RValue<MMX>(Nucleus::createCall(psubb, As<MMX>(x).value, As<MMX>(y).value))); |
| 7331 | } |
| 7332 | |
| 7333 | RValue<Int2> paddd(RValue<Int2> x, RValue<Int2> y) |
| 7334 | { |
| 7335 | Module *module = Nucleus::getModule(); |
| 7336 | llvm::Function *paddd = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_padd_d); |
| 7337 | |
| 7338 | return As<Int2>(RValue<MMX>(Nucleus::createCall(paddd, As<MMX>(x).value, As<MMX>(y).value))); |
| 7339 | } |
| 7340 | |
| 7341 | RValue<Int2> psubd(RValue<Int2> x, RValue<Int2> y) |
| 7342 | { |
| 7343 | Module *module = Nucleus::getModule(); |
| 7344 | llvm::Function *psubd = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_psub_d); |
| 7345 | |
| 7346 | return As<Int2>(RValue<MMX>(Nucleus::createCall(psubd, As<MMX>(x).value, As<MMX>(y).value))); |
| 7347 | } |
| 7348 | |
| 7349 | RValue<UShort4> pavgw(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7350 | { |
| 7351 | Module *module = Nucleus::getModule(); |
| 7352 | llvm::Function *pavgw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pavg_w); |
| 7353 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7354 | 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] | 7355 | } |
| 7356 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7357 | RValue<Short4> pmaxsw(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7358 | { |
| 7359 | Module *module = Nucleus::getModule(); |
| 7360 | llvm::Function *pmaxsw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pmaxs_w); |
| 7361 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7362 | 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] | 7363 | } |
| 7364 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7365 | RValue<Short4> pminsw(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7366 | { |
| 7367 | Module *module = Nucleus::getModule(); |
| 7368 | llvm::Function *pminsw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pmins_w); |
| 7369 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7370 | 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] | 7371 | } |
| 7372 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7373 | RValue<Short4> pcmpgtw(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7374 | { |
| 7375 | Module *module = Nucleus::getModule(); |
| 7376 | llvm::Function *pcmpgtw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pcmpgt_w); |
| 7377 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7378 | 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] | 7379 | } |
| 7380 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7381 | RValue<Short4> pcmpeqw(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7382 | { |
| 7383 | Module *module = Nucleus::getModule(); |
| 7384 | llvm::Function *pcmpeqw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pcmpeq_w); |
| 7385 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7386 | 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] | 7387 | } |
| 7388 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7389 | RValue<Byte8> pcmpgtb(RValue<SByte8> x, RValue<SByte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7390 | { |
| 7391 | Module *module = Nucleus::getModule(); |
| 7392 | llvm::Function *pcmpgtb = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pcmpgt_b); |
| 7393 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7394 | 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] | 7395 | } |
| 7396 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7397 | RValue<Byte8> pcmpeqb(RValue<Byte8> x, RValue<Byte8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7398 | { |
| 7399 | Module *module = Nucleus::getModule(); |
| 7400 | llvm::Function *pcmpeqb = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pcmpeq_b); |
| 7401 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7402 | 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] | 7403 | } |
| 7404 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7405 | RValue<Short4> packssdw(RValue<Int2> x, RValue<Int2> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7406 | { |
| 7407 | Module *module = Nucleus::getModule(); |
| 7408 | llvm::Function *packssdw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_packssdw); |
| 7409 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7410 | 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] | 7411 | } |
| 7412 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7413 | RValue<Short8> packssdw(RValue<Int4> x, RValue<Int4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7414 | { |
| 7415 | if(CPUID::supportsSSE2()) |
| 7416 | { |
| 7417 | Module *module = Nucleus::getModule(); |
| 7418 | llvm::Function *packssdw = Intrinsic::getDeclaration(module, Intrinsic::x86_sse2_packssdw_128); |
| 7419 | |
| 7420 | return RValue<Short8>(Nucleus::createCall(packssdw, x.value, y.value)); |
| 7421 | } |
| 7422 | else |
| 7423 | { |
| 7424 | Int2 loX = Int2(x); |
| 7425 | Int2 hiX = Int2(Swizzle(x, 0xEE)); |
| 7426 | |
| 7427 | Int2 loY = Int2(y); |
| 7428 | Int2 hiY = Int2(Swizzle(y, 0xEE)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7429 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7430 | Short4 lo = x86::packssdw(loX, hiX); |
| 7431 | Short4 hi = x86::packssdw(loY, hiY); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7432 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7433 | return Concatenate(lo, hi); |
| 7434 | } |
| 7435 | } |
| 7436 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7437 | RValue<SByte8> packsswb(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7438 | { |
| 7439 | Module *module = Nucleus::getModule(); |
| 7440 | llvm::Function *packsswb = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_packsswb); |
| 7441 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7442 | 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] | 7443 | } |
| 7444 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7445 | RValue<Byte8> packuswb(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7446 | { |
| 7447 | Module *module = Nucleus::getModule(); |
| 7448 | llvm::Function *packuswb = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_packuswb); |
| 7449 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7450 | 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] | 7451 | } |
| 7452 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7453 | RValue<UShort8> packusdw(RValue<UInt4> x, RValue<UInt4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7454 | { |
| 7455 | if(CPUID::supportsSSE4_1()) |
| 7456 | { |
| 7457 | Module *module = Nucleus::getModule(); |
| 7458 | llvm::Function *packusdw = Intrinsic::getDeclaration(module, Intrinsic::x86_sse41_packusdw); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7459 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7460 | return RValue<UShort8>(Nucleus::createCall(packusdw, x.value, y.value)); |
| 7461 | } |
| 7462 | else |
| 7463 | { |
| 7464 | // FIXME: Not an exact replacement! |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7465 | 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] | 7466 | } |
| 7467 | } |
| 7468 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7469 | RValue<UShort4> psrlw(RValue<UShort4> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7470 | { |
| 7471 | Module *module = Nucleus::getModule(); |
| 7472 | llvm::Function *psrlw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_psrli_w); |
| 7473 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7474 | 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] | 7475 | } |
| 7476 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7477 | RValue<UShort8> psrlw(RValue<UShort8> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7478 | { |
| 7479 | Module *module = Nucleus::getModule(); |
| 7480 | llvm::Function *psrlw = Intrinsic::getDeclaration(module, Intrinsic::x86_sse2_psrli_w); |
| 7481 | |
| 7482 | return RValue<UShort8>(Nucleus::createCall(psrlw, x.value, Nucleus::createConstantInt(y))); |
| 7483 | } |
| 7484 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7485 | RValue<Short4> psraw(RValue<Short4> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7486 | { |
| 7487 | Module *module = Nucleus::getModule(); |
| 7488 | llvm::Function *psraw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_psrai_w); |
| 7489 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7490 | 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] | 7491 | } |
| 7492 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7493 | RValue<Short8> psraw(RValue<Short8> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7494 | { |
| 7495 | Module *module = Nucleus::getModule(); |
| 7496 | llvm::Function *psraw = Intrinsic::getDeclaration(module, Intrinsic::x86_sse2_psrai_w); |
| 7497 | |
| 7498 | return RValue<Short8>(Nucleus::createCall(psraw, x.value, Nucleus::createConstantInt(y))); |
| 7499 | } |
| 7500 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7501 | RValue<Short4> psllw(RValue<Short4> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7502 | { |
| 7503 | Module *module = Nucleus::getModule(); |
| 7504 | llvm::Function *psllw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pslli_w); |
| 7505 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7506 | 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] | 7507 | } |
| 7508 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7509 | RValue<Short8> psllw(RValue<Short8> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7510 | { |
| 7511 | Module *module = Nucleus::getModule(); |
| 7512 | llvm::Function *psllw = Intrinsic::getDeclaration(module, Intrinsic::x86_sse2_pslli_w); |
| 7513 | |
| 7514 | return RValue<Short8>(Nucleus::createCall(psllw, x.value, Nucleus::createConstantInt(y))); |
| 7515 | } |
| 7516 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7517 | RValue<Int2> pslld(RValue<Int2> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7518 | { |
| 7519 | Module *module = Nucleus::getModule(); |
| 7520 | llvm::Function *pslld = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pslli_d); |
| 7521 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7522 | 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] | 7523 | } |
| 7524 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7525 | RValue<Int4> pslld(RValue<Int4> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7526 | { |
| 7527 | if(CPUID::supportsSSE2()) |
| 7528 | { |
| 7529 | Module *module = Nucleus::getModule(); |
| 7530 | llvm::Function *pslld = Intrinsic::getDeclaration(module, Intrinsic::x86_sse2_pslli_d); |
| 7531 | |
| 7532 | return RValue<Int4>(Nucleus::createCall(pslld, x.value, Nucleus::createConstantInt(y))); |
| 7533 | } |
| 7534 | else |
| 7535 | { |
| 7536 | Int2 lo = Int2(x); |
| 7537 | Int2 hi = Int2(Swizzle(x, 0xEE)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7538 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7539 | lo = x86::pslld(lo, y); |
| 7540 | hi = x86::pslld(hi, y); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7541 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7542 | return Concatenate(lo, hi); |
| 7543 | } |
| 7544 | } |
| 7545 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7546 | RValue<Int2> psrad(RValue<Int2> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7547 | { |
| 7548 | Module *module = Nucleus::getModule(); |
| 7549 | llvm::Function *psrad = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_psrai_d); |
| 7550 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7551 | 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] | 7552 | } |
| 7553 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7554 | RValue<Int4> psrad(RValue<Int4> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7555 | { |
| 7556 | if(CPUID::supportsSSE2()) |
| 7557 | { |
| 7558 | Module *module = Nucleus::getModule(); |
| 7559 | llvm::Function *psrad = Intrinsic::getDeclaration(module, Intrinsic::x86_sse2_psrai_d); |
| 7560 | |
| 7561 | return RValue<Int4>(Nucleus::createCall(psrad, x.value, Nucleus::createConstantInt(y))); |
| 7562 | } |
| 7563 | else |
| 7564 | { |
| 7565 | Int2 lo = Int2(x); |
| 7566 | Int2 hi = Int2(Swizzle(x, 0xEE)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7567 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7568 | lo = x86::psrad(lo, y); |
| 7569 | hi = x86::psrad(hi, y); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7570 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7571 | return Concatenate(lo, hi); |
| 7572 | } |
| 7573 | } |
| 7574 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7575 | RValue<UInt2> psrld(RValue<UInt2> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7576 | { |
| 7577 | Module *module = Nucleus::getModule(); |
| 7578 | llvm::Function *psrld = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_psrli_d); |
| 7579 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7580 | 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] | 7581 | } |
| 7582 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7583 | RValue<UInt4> psrld(RValue<UInt4> x, unsigned char y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7584 | { |
| 7585 | if(CPUID::supportsSSE2()) |
| 7586 | { |
| 7587 | Module *module = Nucleus::getModule(); |
| 7588 | llvm::Function *psrld = Intrinsic::getDeclaration(module, Intrinsic::x86_sse2_psrli_d); |
| 7589 | |
| 7590 | return RValue<UInt4>(Nucleus::createCall(psrld, x.value, Nucleus::createConstantInt(y))); |
| 7591 | } |
| 7592 | else |
| 7593 | { |
| 7594 | UInt2 lo = As<UInt2>(Int2(As<Int4>(x))); |
| 7595 | UInt2 hi = As<UInt2>(Int2(Swizzle(As<Int4>(x), 0xEE))); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7596 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7597 | lo = x86::psrld(lo, y); |
| 7598 | hi = x86::psrld(hi, y); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7599 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7600 | return Concatenate(lo, hi); |
| 7601 | } |
| 7602 | } |
| 7603 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7604 | RValue<UShort4> psrlw(RValue<UShort4> x, RValue<Long1> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7605 | { |
| 7606 | Module *module = Nucleus::getModule(); |
| 7607 | llvm::Function *psrlw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_psrl_w); |
| 7608 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7609 | 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] | 7610 | } |
| 7611 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7612 | RValue<Short4> psraw(RValue<Short4> x, RValue<Long1> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7613 | { |
| 7614 | Module *module = Nucleus::getModule(); |
| 7615 | llvm::Function *psraw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_psra_w); |
| 7616 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7617 | 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] | 7618 | } |
| 7619 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7620 | RValue<Short4> psllw(RValue<Short4> x, RValue<Long1> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7621 | { |
| 7622 | Module *module = Nucleus::getModule(); |
| 7623 | llvm::Function *psllw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_psll_w); |
| 7624 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7625 | 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] | 7626 | } |
| 7627 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7628 | RValue<Int2> pslld(RValue<Int2> x, RValue<Long1> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7629 | { |
| 7630 | Module *module = Nucleus::getModule(); |
| 7631 | llvm::Function *pslld = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_psll_d); |
| 7632 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7633 | 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] | 7634 | } |
| 7635 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7636 | RValue<UInt2> psrld(RValue<UInt2> x, RValue<Long1> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7637 | { |
| 7638 | Module *module = Nucleus::getModule(); |
| 7639 | llvm::Function *psrld = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_psrl_d); |
| 7640 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7641 | 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] | 7642 | } |
| 7643 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7644 | RValue<Int2> psrad(RValue<Int2> x, RValue<Long1> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7645 | { |
| 7646 | Module *module = Nucleus::getModule(); |
| 7647 | llvm::Function *psrld = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_psra_d); |
| 7648 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7649 | 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] | 7650 | } |
| 7651 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7652 | RValue<Int4> pmaxsd(RValue<Int4> x, RValue<Int4> y) |
| 7653 | { |
| 7654 | Module *module = Nucleus::getModule(); |
| 7655 | llvm::Function *pmaxsd = Intrinsic::getDeclaration(module, Intrinsic::x86_sse41_pmaxsd); |
| 7656 | |
| 7657 | return RValue<Int4>(Nucleus::createCall(pmaxsd, x.value, y.value)); |
| 7658 | } |
| 7659 | |
| 7660 | RValue<Int4> pminsd(RValue<Int4> x, RValue<Int4> y) |
| 7661 | { |
| 7662 | Module *module = Nucleus::getModule(); |
| 7663 | llvm::Function *pminsd = Intrinsic::getDeclaration(module, Intrinsic::x86_sse41_pminsd); |
| 7664 | |
| 7665 | return RValue<Int4>(Nucleus::createCall(pminsd, x.value, y.value)); |
| 7666 | } |
| 7667 | |
| 7668 | RValue<UInt4> pmaxud(RValue<UInt4> x, RValue<UInt4> y) |
| 7669 | { |
| 7670 | Module *module = Nucleus::getModule(); |
| 7671 | llvm::Function *pmaxud = Intrinsic::getDeclaration(module, Intrinsic::x86_sse41_pmaxud); |
| 7672 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7673 | return RValue<UInt4>(Nucleus::createCall(pmaxud, x.value, y.value)); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7674 | } |
| 7675 | |
| 7676 | RValue<UInt4> pminud(RValue<UInt4> x, RValue<UInt4> y) |
| 7677 | { |
| 7678 | Module *module = Nucleus::getModule(); |
| 7679 | llvm::Function *pminud = Intrinsic::getDeclaration(module, Intrinsic::x86_sse41_pminud); |
| 7680 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7681 | return RValue<UInt4>(Nucleus::createCall(pminud, x.value, y.value)); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7682 | } |
| 7683 | |
| 7684 | RValue<Short4> pmulhw(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7685 | { |
| 7686 | Module *module = Nucleus::getModule(); |
| 7687 | llvm::Function *pmulhw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pmulh_w); |
| 7688 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7689 | 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] | 7690 | } |
| 7691 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7692 | RValue<UShort4> pmulhuw(RValue<UShort4> x, RValue<UShort4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7693 | { |
| 7694 | Module *module = Nucleus::getModule(); |
| 7695 | llvm::Function *pmulhuw = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pmulhu_w); |
| 7696 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7697 | 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] | 7698 | } |
| 7699 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7700 | RValue<Int2> pmaddwd(RValue<Short4> x, RValue<Short4> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7701 | { |
| 7702 | Module *module = Nucleus::getModule(); |
| 7703 | llvm::Function *pmaddwd = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pmadd_wd); |
| 7704 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7705 | 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] | 7706 | } |
| 7707 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7708 | RValue<Short8> pmulhw(RValue<Short8> x, RValue<Short8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7709 | { |
| 7710 | Module *module = Nucleus::getModule(); |
| 7711 | llvm::Function *pmulhw = Intrinsic::getDeclaration(module, Intrinsic::x86_sse2_pmulh_w); |
| 7712 | |
| 7713 | return RValue<Short8>(Nucleus::createCall(pmulhw, x.value, y.value)); |
| 7714 | } |
| 7715 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7716 | RValue<UShort8> pmulhuw(RValue<UShort8> x, RValue<UShort8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7717 | { |
| 7718 | Module *module = Nucleus::getModule(); |
| 7719 | llvm::Function *pmulhuw = Intrinsic::getDeclaration(module, Intrinsic::x86_sse2_pmulhu_w); |
| 7720 | |
| 7721 | return RValue<UShort8>(Nucleus::createCall(pmulhuw, x.value, y.value)); |
| 7722 | } |
| 7723 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7724 | RValue<Int4> pmaddwd(RValue<Short8> x, RValue<Short8> y) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7725 | { |
| 7726 | Module *module = Nucleus::getModule(); |
| 7727 | llvm::Function *pmaddwd = Intrinsic::getDeclaration(module, Intrinsic::x86_sse2_pmadd_wd); |
| 7728 | |
| 7729 | return RValue<Int4>(Nucleus::createCall(pmaddwd, x.value, y.value)); |
| 7730 | } |
| 7731 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7732 | RValue<Int> movmskps(RValue<Float4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7733 | { |
| 7734 | Module *module = Nucleus::getModule(); |
| 7735 | llvm::Function *movmskps = Intrinsic::getDeclaration(module, Intrinsic::x86_sse_movmsk_ps); |
| 7736 | |
| 7737 | return RValue<Int>(Nucleus::createCall(movmskps, x.value)); |
| 7738 | } |
| 7739 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7740 | RValue<Int> pmovmskb(RValue<Byte8> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7741 | { |
| 7742 | Module *module = Nucleus::getModule(); |
| 7743 | llvm::Function *pmovmskb = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_pmovmskb); |
| 7744 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7745 | return RValue<Int>(Nucleus::createCall(pmovmskb, As<MMX>(x).value)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7746 | } |
| 7747 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7748 | //RValue<Int2> movd(RValue<Pointer<Int> > x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7749 | //{ |
| 7750 | // Value *element = Nucleus::createLoad(x.value); |
| 7751 | |
| 7752 | //// Value *int2 = UndefValue::get(Int2::getType()); |
| 7753 | //// int2 = Nucleus::createInsertElement(int2, element, ConstantInt::get(Int::getType(), 0)); |
| 7754 | |
| 7755 | // Value *int2 = Nucleus::createBitCast(Nucleus::createZExt(element, Long::getType()), Int2::getType()); |
| 7756 | |
| 7757 | // return RValue<Int2>(int2); |
| 7758 | //} |
| 7759 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7760 | //RValue<Int2> movdq2q(RValue<Int4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7761 | //{ |
| 7762 | // Value *long2 = Nucleus::createBitCast(x.value, Long2::getType()); |
| 7763 | // Value *element = Nucleus::createExtractElement(long2, ConstantInt::get(Int::getType(), 0)); |
| 7764 | |
| 7765 | // return RValue<Int2>(Nucleus::createBitCast(element, Int2::getType())); |
| 7766 | //} |
| 7767 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7768 | RValue<Int4> pmovzxbd(RValue<Int4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7769 | { |
| 7770 | Module *module = Nucleus::getModule(); |
| 7771 | llvm::Function *pmovzxbd = Intrinsic::getDeclaration(module, Intrinsic::x86_sse41_pmovzxbd); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7772 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7773 | return RValue<Int4>(Nucleus::createCall(pmovzxbd, Nucleus::createBitCast(x.value, Byte16::getType()))); |
| 7774 | } |
| 7775 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7776 | RValue<Int4> pmovsxbd(RValue<Int4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7777 | { |
| 7778 | Module *module = Nucleus::getModule(); |
| 7779 | llvm::Function *pmovsxbd = Intrinsic::getDeclaration(module, Intrinsic::x86_sse41_pmovsxbd); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7780 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7781 | return RValue<Int4>(Nucleus::createCall(pmovsxbd, Nucleus::createBitCast(x.value, SByte16::getType()))); |
| 7782 | } |
| 7783 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7784 | RValue<Int4> pmovzxwd(RValue<Int4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7785 | { |
| 7786 | Module *module = Nucleus::getModule(); |
| 7787 | llvm::Function *pmovzxwd = Intrinsic::getDeclaration(module, Intrinsic::x86_sse41_pmovzxwd); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7788 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7789 | return RValue<Int4>(Nucleus::createCall(pmovzxwd, Nucleus::createBitCast(x.value, UShort8::getType()))); |
| 7790 | } |
| 7791 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 7792 | RValue<Int4> pmovsxwd(RValue<Int4> x) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7793 | { |
| 7794 | Module *module = Nucleus::getModule(); |
| 7795 | llvm::Function *pmovsxwd = Intrinsic::getDeclaration(module, Intrinsic::x86_sse41_pmovsxwd); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7796 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 7797 | return RValue<Int4>(Nucleus::createCall(pmovsxwd, Nucleus::createBitCast(x.value, Short8::getType()))); |
| 7798 | } |
| 7799 | |
| 7800 | void emms() |
| 7801 | { |
| 7802 | Module *module = Nucleus::getModule(); |
| 7803 | llvm::Function *emms = Intrinsic::getDeclaration(module, Intrinsic::x86_mmx_emms); |
| 7804 | |
| 7805 | Nucleus::createCall(emms); |
| 7806 | } |
| 7807 | } |
| 7808 | } |