#include "Memory.hpp"
#include "MutexLock.hpp"
-#include <xmmintrin.h>
#include <fstream>
+#if defined(__i386__) || defined(__x86_64__)
+#include <xmmintrin.h>
+#endif
+
#if defined(__x86_64__) && defined(_WIN32)
extern "C" void X86CompilationCallback()
{
llvm::Module *module = nullptr;
llvm::Function *function = nullptr;
- sw::BackoffLock codegenMutex;
+ sw::MutexLock codegenMutex;
}
namespace sw
{
- using namespace llvm;
-
Optimization optimization[10] = {InstructionCombining, Disabled};
- class Type : public llvm::Type {};
+ enum EmulatedType
+ {
+ Type_v2i32,
+ Type_v4i16,
+ Type_v2i16,
+ Type_v8i8,
+ Type_v4i8,
+ Type_v2f32,
+ EmulatedTypeCount
+ };
+
class Value : public llvm::Value {};
+ class SwitchCases : public llvm::SwitchInst {};
class BasicBlock : public llvm::BasicBlock {};
+ llvm::Type *T(Type *t)
+ {
+ std::uintptr_t type = reinterpret_cast<std::uintptr_t>(t);
+ if(type < EmulatedTypeCount)
+ {
+ switch(type)
+ {
+ case Type_v2i32: return llvm::Type::getX86_MMXTy(*::context);
+ case Type_v4i16: return llvm::Type::getX86_MMXTy(*::context);
+ case Type_v2i16: return llvm::Type::getInt32Ty(*::context);
+ case Type_v8i8: return llvm::Type::getX86_MMXTy(*::context);
+ case Type_v4i8: return llvm::Type::getInt32Ty(*::context);
+ case Type_v2f32: return llvm::VectorType::get(T(Float::getType()), 2);
+ default: assert(false);
+ }
+ }
+
+ return reinterpret_cast<llvm::Type*>(t);
+ }
+
inline Type *T(llvm::Type *t)
{
return reinterpret_cast<Type*>(t);
}
+ Type *T(EmulatedType t)
+ {
+ return reinterpret_cast<Type*>(t);
+ }
+
inline Value *V(llvm::Value *t)
{
return reinterpret_cast<Value*>(t);
{
::codegenMutex.lock(); // Reactor and LLVM are currently not thread safe
- InitializeNativeTarget();
- JITEmitDebugInfo = false;
+ llvm::InitializeNativeTarget();
+ llvm::JITEmitDebugInfo = false;
if(!::context)
{
- ::context = new LLVMContext();
+ ::context = new llvm::LLVMContext();
}
- ::module = new Module("", *::context);
+ ::module = new llvm::Module("", *::context);
::routineManager = new LLVMRoutineManager();
#if defined(__x86_64__)
const char *architecture = "x86";
#endif
- SmallVector<std::string, 1> MAttrs;
+ llvm::SmallVector<std::string, 1> MAttrs;
MAttrs.push_back(CPUID::supportsMMX() ? "+mmx" : "-mmx");
MAttrs.push_back(CPUID::supportsCMOV() ? "+cmov" : "-cmov");
MAttrs.push_back(CPUID::supportsSSE() ? "+sse" : "-sse");
MAttrs.push_back(CPUID::supportsSSE4_1() ? "+sse41" : "-sse41");
std::string error;
- TargetMachine *targetMachine = EngineBuilder::selectTarget(::module, architecture, "", MAttrs, Reloc::Default, CodeModel::JITDefault, &error);
- ::executionEngine = JIT::createJIT(::module, 0, ::routineManager, CodeGenOpt::Aggressive, true, targetMachine);
+ llvm::TargetMachine *targetMachine = llvm::EngineBuilder::selectTarget(::module, architecture, "", MAttrs, llvm::Reloc::Default, llvm::CodeModel::JITDefault, &error);
+ ::executionEngine = llvm::JIT::createJIT(::module, 0, ::routineManager, llvm::CodeGenOpt::Aggressive, true, targetMachine);
if(!::builder)
{
- ::builder = new IRBuilder<>(*::context);
+ ::builder = new llvm::IRBuilder<>(*::context);
#if defined(_WIN32)
HMODULE CodeAnalyst = LoadLibrary("CAJitNtfyLib.dll");
}
else
{
- createRet(V(UndefValue::get(type)));
+ createRet(V(llvm::UndefValue::get(type)));
}
}
if(false)
{
std::string error;
- raw_fd_ostream file("llvm-dump-unopt.txt", error);
+ llvm::raw_fd_ostream file("llvm-dump-unopt.txt", error);
::module->print(file, 0);
}
if(false)
{
std::string error;
- raw_fd_ostream file("llvm-dump-opt.txt", error);
+ llvm::raw_fd_ostream file("llvm-dump-opt.txt", error);
::module->print(file, 0);
}
void Nucleus::optimize()
{
- static PassManager *passManager = nullptr;
+ static llvm::PassManager *passManager = nullptr;
if(!passManager)
{
- passManager = new PassManager();
+ passManager = new llvm::PassManager();
- UnsafeFPMath = true;
- // NoInfsFPMath = true;
- // NoNaNsFPMath = true;
+ llvm::UnsafeFPMath = true;
+ // llvm::NoInfsFPMath = true;
+ // llvm::NoNaNsFPMath = true;
- passManager->add(new TargetData(*::executionEngine->getTargetData()));
- passManager->add(createScalarReplAggregatesPass());
+ passManager->add(new llvm::TargetData(*::executionEngine->getTargetData()));
+ passManager->add(llvm::createScalarReplAggregatesPass());
for(int pass = 0; pass < 10 && optimization[pass] != Disabled; pass++)
{
switch(optimization[pass])
{
- case Disabled: break;
- case CFGSimplification: passManager->add(createCFGSimplificationPass()); break;
- case LICM: passManager->add(createLICMPass()); break;
- case AggressiveDCE: passManager->add(createAggressiveDCEPass()); break;
- case GVN: passManager->add(createGVNPass()); break;
- case InstructionCombining: passManager->add(createInstructionCombiningPass()); break;
- case Reassociate: passManager->add(createReassociatePass()); break;
- case DeadStoreElimination: passManager->add(createDeadStoreEliminationPass()); break;
- case SCCP: passManager->add(createSCCPPass()); break;
- case ScalarReplAggregates: passManager->add(createScalarReplAggregatesPass()); break;
+ case Disabled: break;
+ case CFGSimplification: passManager->add(llvm::createCFGSimplificationPass()); break;
+ case LICM: passManager->add(llvm::createLICMPass()); break;
+ case AggressiveDCE: passManager->add(llvm::createAggressiveDCEPass()); break;
+ case GVN: passManager->add(llvm::createGVNPass()); break;
+ case InstructionCombining: passManager->add(llvm::createInstructionCombiningPass()); break;
+ case Reassociate: passManager->add(llvm::createReassociatePass()); break;
+ case DeadStoreElimination: passManager->add(llvm::createDeadStoreEliminationPass()); break;
+ case SCCP: passManager->add(llvm::createSCCPPass()); break;
+ case ScalarReplAggregates: passManager->add(llvm::createScalarReplAggregatesPass()); break;
default:
assert(false);
}
// Need to allocate it in the entry block for mem2reg to work
llvm::BasicBlock &entryBlock = ::function->getEntryBlock();
- Instruction *declaration;
+ llvm::Instruction *declaration;
if(arraySize)
{
- declaration = new AllocaInst(type, Nucleus::createConstantInt(arraySize));
+ declaration = new llvm::AllocaInst(T(type), Nucleus::createConstantInt(arraySize));
}
else
{
- declaration = new AllocaInst(type, (Value*)0);
+ declaration = new llvm::AllocaInst(T(type), (Value*)nullptr);
}
entryBlock.getInstList().push_front(declaration);
return ::builder->SetInsertPoint(basicBlock);
}
- BasicBlock *Nucleus::getPredecessor(BasicBlock *basicBlock)
- {
- return B(*pred_begin(basicBlock));
- }
-
void Nucleus::createFunction(Type *ReturnType, std::vector<Type*> &Params)
{
- llvm::FunctionType *functionType = llvm::FunctionType::get(ReturnType, T(Params), false);
+ llvm::FunctionType *functionType = llvm::FunctionType::get(T(ReturnType), T(Params), false);
::function = llvm::Function::Create(functionType, llvm::GlobalValue::InternalLinkage, "", ::module);
::function->setCallingConv(llvm::CallingConv::C);
Value *Nucleus::createLoad(Value *ptr, Type *type, bool isVolatile, unsigned int align)
{
- assert(ptr->getType()->getContainedType(0) == type);
- return V(::builder->Insert(new LoadInst(ptr, "", isVolatile, align)));
+ assert(ptr->getType()->getContainedType(0) == T(type));
+ return V(::builder->Insert(new llvm::LoadInst(ptr, "", isVolatile, align)));
}
Value *Nucleus::createStore(Value *value, Value *ptr, Type *type, bool isVolatile, unsigned int align)
{
- assert(ptr->getType()->getContainedType(0) == type);
- ::builder->Insert(new StoreInst(value, ptr, isVolatile, align));
+ assert(ptr->getType()->getContainedType(0) == T(type));
+ ::builder->Insert(new llvm::StoreInst(value, ptr, isVolatile, align));
return value;
}
- Value *Nucleus::createGEP(Value *ptr, Type *type, Value *index)
+ Value *Nucleus::createGEP(Value *ptr, Type *type, Value *index, bool unsignedIndex)
{
- assert(ptr->getType()->getContainedType(0) == type);
+ if(unsignedIndex && sizeof(void*) == 8)
+ {
+ index = createZExt(index, Long::getType());
+ }
+
+ assert(ptr->getType()->getContainedType(0) == T(type));
return V(::builder->CreateGEP(ptr, index));
}
Value *Nucleus::createAtomicAdd(Value *ptr, Value *value)
{
- return V(::builder->CreateAtomicRMW(AtomicRMWInst::Add, ptr, value, SequentiallyConsistent));
+ return V(::builder->CreateAtomicRMW(llvm::AtomicRMWInst::Add, ptr, value, llvm::SequentiallyConsistent));
}
Value *Nucleus::createTrunc(Value *v, Type *destType)
{
- return V(::builder->CreateTrunc(v, destType));
+ return V(::builder->CreateTrunc(v, T(destType)));
}
Value *Nucleus::createZExt(Value *v, Type *destType)
{
- return V(::builder->CreateZExt(v, destType));
+ return V(::builder->CreateZExt(v, T(destType)));
}
Value *Nucleus::createSExt(Value *v, Type *destType)
{
- return V(::builder->CreateSExt(v, destType));
+ return V(::builder->CreateSExt(v, T(destType)));
}
Value *Nucleus::createFPToSI(Value *v, Type *destType)
{
- return V(::builder->CreateFPToSI(v, destType));
- }
-
- Value *Nucleus::createUIToFP(Value *v, Type *destType)
- {
- return V(::builder->CreateUIToFP(v, destType));
+ return V(::builder->CreateFPToSI(v, T(destType)));
}
Value *Nucleus::createSIToFP(Value *v, Type *destType)
{
- return V(::builder->CreateSIToFP(v, destType));
+ return V(::builder->CreateSIToFP(v, T(destType)));
}
Value *Nucleus::createFPTrunc(Value *v, Type *destType)
{
- return V(::builder->CreateFPTrunc(v, destType));
+ return V(::builder->CreateFPTrunc(v, T(destType)));
}
Value *Nucleus::createFPExt(Value *v, Type *destType)
{
- return V(::builder->CreateFPExt(v, destType));
+ return V(::builder->CreateFPExt(v, T(destType)));
}
Value *Nucleus::createBitCast(Value *v, Type *destType)
{
- return V(::builder->CreateBitCast(v, destType));
- }
-
- Value *Nucleus::createIntCast(Value *v, Type *destType, bool isSigned)
- {
- return V(::builder->CreateIntCast(v, destType, isSigned));
+ return V(::builder->CreateBitCast(v, T(destType)));
}
Value *Nucleus::createICmpEQ(Value *lhs, Value *rhs)
Value *Nucleus::createExtractElement(Value *vector, Type *type, int index)
{
- assert(vector->getType()->getContainedType(0) == type);
+ assert(vector->getType()->getContainedType(0) == T(type));
return V(::builder->CreateExtractElement(vector, createConstantInt(index)));
}
for(int i = 0; i < size; i++)
{
- swizzle[i] = llvm::ConstantInt::get(Type::getInt32Ty(*::context), select[i]);
+ swizzle[i] = llvm::ConstantInt::get(llvm::Type::getInt32Ty(*::context), select[i]);
}
llvm::Value *shuffle = llvm::ConstantVector::get(llvm::ArrayRef<llvm::Constant*>(swizzle, size));
return V(::builder->CreateSelect(C, ifTrue, ifFalse));
}
- Value *Nucleus::createSwitch(Value *v, BasicBlock *Dest, unsigned NumCases)
+ SwitchCases *Nucleus::createSwitch(Value *control, BasicBlock *defaultBranch, unsigned numCases)
{
- return V(::builder->CreateSwitch(v, Dest, NumCases));
+ return reinterpret_cast<SwitchCases*>(::builder->CreateSwitch(control, defaultBranch, numCases));
}
- void Nucleus::addSwitchCase(Value *Switch, int Case, BasicBlock *Branch)
+ void Nucleus::addSwitchCase(SwitchCases *switchCases, int label, BasicBlock *branch)
{
- reinterpret_cast<SwitchInst*>(Switch)->addCase(llvm::ConstantInt::get(Type::getInt32Ty(*::context), Case, true), Branch);
+ switchCases->addCase(llvm::ConstantInt::get(llvm::Type::getInt32Ty(*::context), label, true), branch);
}
void Nucleus::createUnreachable()
mask[3] ? 7 : 3,
};
- Value *shuffle = Nucleus::createShuffleVector(lhs, rhs, swizzle);
-
- return shuffle;
- }
-
- Value *Nucleus::createConstantPointer(const void *address, Type *Ty, bool isConstant, unsigned int Align)
- {
- const GlobalValue *existingGlobal = ::executionEngine->getGlobalValueAtAddress(const_cast<void*>(address)); // FIXME: Const
-
- if(existingGlobal)
- {
- return (Value*)existingGlobal;
- }
-
- llvm::GlobalValue *global = new llvm::GlobalVariable(*::module, Ty, isConstant, llvm::GlobalValue::ExternalLinkage, 0, "");
-
- global->setAlignment(Align);
-
- ::executionEngine->addGlobalMapping(global, const_cast<void*>(address));
-
- return V(global);
+ return Nucleus::createShuffleVector(lhs, rhs, swizzle);
}
Type *Nucleus::getPointerType(Type *ElementType)
{
- return T(llvm::PointerType::get(ElementType, 0));
+ return T(llvm::PointerType::get(T(ElementType), 0));
}
Value *Nucleus::createNullValue(Type *Ty)
{
- return V(llvm::Constant::getNullValue(Ty));
+ return V(llvm::Constant::getNullValue(T(Ty)));
}
Value *Nucleus::createConstantLong(int64_t i)
{
- return V(llvm::ConstantInt::get(Type::getInt64Ty(*::context), i, true));
+ return V(llvm::ConstantInt::get(llvm::Type::getInt64Ty(*::context), i, true));
}
Value *Nucleus::createConstantInt(int i)
{
- return V(llvm::ConstantInt::get(Type::getInt32Ty(*::context), i, true));
+ return V(llvm::ConstantInt::get(llvm::Type::getInt32Ty(*::context), i, true));
}
Value *Nucleus::createConstantInt(unsigned int i)
{
- return V(llvm::ConstantInt::get(Type::getInt32Ty(*::context), i, false));
+ return V(llvm::ConstantInt::get(llvm::Type::getInt32Ty(*::context), i, false));
}
Value *Nucleus::createConstantBool(bool b)
{
- return V(llvm::ConstantInt::get(Type::getInt1Ty(*::context), b));
+ return V(llvm::ConstantInt::get(llvm::Type::getInt1Ty(*::context), b));
}
Value *Nucleus::createConstantByte(signed char i)
{
- return V(llvm::ConstantInt::get(Type::getInt8Ty(*::context), i, true));
+ return V(llvm::ConstantInt::get(llvm::Type::getInt8Ty(*::context), i, true));
}
Value *Nucleus::createConstantByte(unsigned char i)
{
- return V(llvm::ConstantInt::get(Type::getInt8Ty(*::context), i, false));
+ return V(llvm::ConstantInt::get(llvm::Type::getInt8Ty(*::context), i, false));
}
Value *Nucleus::createConstantShort(short i)
{
- return V(llvm::ConstantInt::get(Type::getInt16Ty(*::context), i, true));
+ return V(llvm::ConstantInt::get(llvm::Type::getInt16Ty(*::context), i, true));
}
Value *Nucleus::createConstantShort(unsigned short i)
{
- return V(llvm::ConstantInt::get(Type::getInt16Ty(*::context), i, false));
+ return V(llvm::ConstantInt::get(llvm::Type::getInt16Ty(*::context), i, false));
}
Value *Nucleus::createConstantFloat(float x)
{
- return V(llvm::ConstantFP::get(Float::getType(), x));
+ return V(llvm::ConstantFP::get(T(Float::getType()), x));
}
Value *Nucleus::createNullPointer(Type *Ty)
{
- return V(llvm::ConstantPointerNull::get(llvm::PointerType::get(Ty, 0)));
+ return V(llvm::ConstantPointerNull::get(llvm::PointerType::get(T(Ty), 0)));
}
Value *Nucleus::createConstantVector(const int64_t *constants, Type *type)
{
- assert(llvm::isa<VectorType>(type));
- const int numConstants = llvm::cast<VectorType>(type)->getNumElements();
+ assert(llvm::isa<llvm::VectorType>(T(type)));
+ const int numConstants = llvm::cast<llvm::VectorType>(T(type))->getNumElements();
assert(numConstants <= 16);
llvm::Constant *constantVector[16];
for(int i = 0; i < numConstants; i++)
{
- constantVector[i] = llvm::ConstantInt::get(type->getContainedType(0), constants[i]);
+ constantVector[i] = llvm::ConstantInt::get(T(type)->getContainedType(0), constants[i]);
}
return V(llvm::ConstantVector::get(llvm::ArrayRef<llvm::Constant*>(constantVector, numConstants)));
Value *Nucleus::createConstantVector(const double *constants, Type *type)
{
- assert(llvm::isa<VectorType>(type));
- const int numConstants = llvm::cast<VectorType>(type)->getNumElements();
+ assert(llvm::isa<llvm::VectorType>(T(type)));
+ const int numConstants = llvm::cast<llvm::VectorType>(T(type))->getNumElements();
assert(numConstants <= 8);
llvm::Constant *constantVector[8];
for(int i = 0; i < numConstants; i++)
{
- constantVector[i] = llvm::ConstantFP::get(type->getContainedType(0), constants[i]);
+ constantVector[i] = llvm::ConstantFP::get(T(type)->getContainedType(0), constants[i]);
}
return V(llvm::ConstantVector::get(llvm::ArrayRef<llvm::Constant*>(constantVector, numConstants)));
return T(llvm::Type::getVoidTy(*::context));
}
- class MMX : public Variable<MMX>
+ class MMX : public LValue<MMX>
{
public:
static Type *getType();
storeValue(argument.value);
}
- Bool::Bool()
- {
- }
-
Bool::Bool(bool x)
{
storeValue(Nucleus::createConstantBool(x));
storeValue(value);
}
- RValue<Bool> Bool::operator=(RValue<Bool> rhs) const
+ RValue<Bool> Bool::operator=(RValue<Bool> rhs)
{
storeValue(rhs.value);
return rhs;
}
- RValue<Bool> Bool::operator=(const Bool &rhs) const
+ RValue<Bool> Bool::operator=(const Bool &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<Bool>(value);
}
- RValue<Bool> Bool::operator=(const Reference<Bool> &rhs) const
+ RValue<Bool> Bool::operator=(const Reference<Bool> &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
storeValue(integer);
}
- Byte::Byte()
- {
- }
-
Byte::Byte(int x)
{
storeValue(Nucleus::createConstantByte((unsigned char)x));
storeValue(value);
}
- RValue<Byte> Byte::operator=(RValue<Byte> rhs) const
+ RValue<Byte> Byte::operator=(RValue<Byte> rhs)
{
storeValue(rhs.value);
return rhs;
}
- RValue<Byte> Byte::operator=(const Byte &rhs) const
+ RValue<Byte> Byte::operator=(const Byte &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<Byte>(value);
}
- RValue<Byte> Byte::operator=(const Reference<Byte> &rhs) const
+ RValue<Byte> Byte::operator=(const Reference<Byte> &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<Byte>(Nucleus::createLShr(lhs.value, rhs.value));
}
- RValue<Byte> operator+=(const Byte &lhs, RValue<Byte> rhs)
+ RValue<Byte> operator+=(Byte &lhs, RValue<Byte> rhs)
{
return lhs = lhs + rhs;
}
- RValue<Byte> operator-=(const Byte &lhs, RValue<Byte> rhs)
+ RValue<Byte> operator-=(Byte &lhs, RValue<Byte> rhs)
{
return lhs = lhs - rhs;
}
- RValue<Byte> operator*=(const Byte &lhs, RValue<Byte> rhs)
+ RValue<Byte> operator*=(Byte &lhs, RValue<Byte> rhs)
{
return lhs = lhs * rhs;
}
- RValue<Byte> operator/=(const Byte &lhs, RValue<Byte> rhs)
+ RValue<Byte> operator/=(Byte &lhs, RValue<Byte> rhs)
{
return lhs = lhs / rhs;
}
- RValue<Byte> operator%=(const Byte &lhs, RValue<Byte> rhs)
+ RValue<Byte> operator%=(Byte &lhs, RValue<Byte> rhs)
{
return lhs = lhs % rhs;
}
- RValue<Byte> operator&=(const Byte &lhs, RValue<Byte> rhs)
+ RValue<Byte> operator&=(Byte &lhs, RValue<Byte> rhs)
{
return lhs = lhs & rhs;
}
- RValue<Byte> operator|=(const Byte &lhs, RValue<Byte> rhs)
+ RValue<Byte> operator|=(Byte &lhs, RValue<Byte> rhs)
{
return lhs = lhs | rhs;
}
- RValue<Byte> operator^=(const Byte &lhs, RValue<Byte> rhs)
+ RValue<Byte> operator^=(Byte &lhs, RValue<Byte> rhs)
{
return lhs = lhs ^ rhs;
}
- RValue<Byte> operator<<=(const Byte &lhs, RValue<Byte> rhs)
+ RValue<Byte> operator<<=(Byte &lhs, RValue<Byte> rhs)
{
return lhs = lhs << rhs;
}
- RValue<Byte> operator>>=(const Byte &lhs, RValue<Byte> rhs)
+ RValue<Byte> operator>>=(Byte &lhs, RValue<Byte> rhs)
{
return lhs = lhs >> rhs;
}
return RValue<Byte>(Nucleus::createNot(val.value));
}
- RValue<Byte> operator++(const Byte &val, int) // Post-increment
+ RValue<Byte> operator++(Byte &val, int) // Post-increment
{
RValue<Byte> res = val;
return res;
}
- const Byte &operator++(const Byte &val) // Pre-increment
+ const Byte &operator++(Byte &val) // Pre-increment
{
Value *inc = Nucleus::createAdd(val.loadValue(), V(Nucleus::createConstantByte((unsigned char)1)));
val.storeValue(inc);
return val;
}
- RValue<Byte> operator--(const Byte &val, int) // Post-decrement
+ RValue<Byte> operator--(Byte &val, int) // Post-decrement
{
RValue<Byte> res = val;
return res;
}
- const Byte &operator--(const Byte &val) // Pre-decrement
+ const Byte &operator--(Byte &val) // Pre-decrement
{
Value *inc = Nucleus::createSub(val.loadValue(), V(Nucleus::createConstantByte((unsigned char)1)));
val.storeValue(inc);
storeValue(integer);
}
- SByte::SByte()
- {
- }
-
SByte::SByte(signed char x)
{
storeValue(Nucleus::createConstantByte(x));
storeValue(value);
}
- RValue<SByte> SByte::operator=(RValue<SByte> rhs) const
+ RValue<SByte> SByte::operator=(RValue<SByte> rhs)
{
storeValue(rhs.value);
return rhs;
}
- RValue<SByte> SByte::operator=(const SByte &rhs) const
+ RValue<SByte> SByte::operator=(const SByte &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<SByte>(value);
}
- RValue<SByte> SByte::operator=(const Reference<SByte> &rhs) const
+ RValue<SByte> SByte::operator=(const Reference<SByte> &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<SByte>(Nucleus::createAShr(lhs.value, rhs.value));
}
- RValue<SByte> operator+=(const SByte &lhs, RValue<SByte> rhs)
+ RValue<SByte> operator+=(SByte &lhs, RValue<SByte> rhs)
{
return lhs = lhs + rhs;
}
- RValue<SByte> operator-=(const SByte &lhs, RValue<SByte> rhs)
+ RValue<SByte> operator-=(SByte &lhs, RValue<SByte> rhs)
{
return lhs = lhs - rhs;
}
- RValue<SByte> operator*=(const SByte &lhs, RValue<SByte> rhs)
+ RValue<SByte> operator*=(SByte &lhs, RValue<SByte> rhs)
{
return lhs = lhs * rhs;
}
- RValue<SByte> operator/=(const SByte &lhs, RValue<SByte> rhs)
+ RValue<SByte> operator/=(SByte &lhs, RValue<SByte> rhs)
{
return lhs = lhs / rhs;
}
- RValue<SByte> operator%=(const SByte &lhs, RValue<SByte> rhs)
+ RValue<SByte> operator%=(SByte &lhs, RValue<SByte> rhs)
{
return lhs = lhs % rhs;
}
- RValue<SByte> operator&=(const SByte &lhs, RValue<SByte> rhs)
+ RValue<SByte> operator&=(SByte &lhs, RValue<SByte> rhs)
{
return lhs = lhs & rhs;
}
- RValue<SByte> operator|=(const SByte &lhs, RValue<SByte> rhs)
+ RValue<SByte> operator|=(SByte &lhs, RValue<SByte> rhs)
{
return lhs = lhs | rhs;
}
- RValue<SByte> operator^=(const SByte &lhs, RValue<SByte> rhs)
+ RValue<SByte> operator^=(SByte &lhs, RValue<SByte> rhs)
{
return lhs = lhs ^ rhs;
}
- RValue<SByte> operator<<=(const SByte &lhs, RValue<SByte> rhs)
+ RValue<SByte> operator<<=(SByte &lhs, RValue<SByte> rhs)
{
return lhs = lhs << rhs;
}
- RValue<SByte> operator>>=(const SByte &lhs, RValue<SByte> rhs)
+ RValue<SByte> operator>>=(SByte &lhs, RValue<SByte> rhs)
{
return lhs = lhs >> rhs;
}
return RValue<SByte>(Nucleus::createNot(val.value));
}
- RValue<SByte> operator++(const SByte &val, int) // Post-increment
+ RValue<SByte> operator++(SByte &val, int) // Post-increment
{
RValue<SByte> res = val;
return res;
}
- const SByte &operator++(const SByte &val) // Pre-increment
+ const SByte &operator++(SByte &val) // Pre-increment
{
Value *inc = Nucleus::createAdd(val.loadValue(), V(Nucleus::createConstantByte((signed char)1)));
val.storeValue(inc);
return val;
}
- RValue<SByte> operator--(const SByte &val, int) // Post-decrement
+ RValue<SByte> operator--(SByte &val, int) // Post-decrement
{
RValue<SByte> res = val;
return res;
}
- const SByte &operator--(const SByte &val) // Pre-decrement
+ const SByte &operator--(SByte &val) // Pre-decrement
{
Value *inc = Nucleus::createSub(val.loadValue(), V(Nucleus::createConstantByte((signed char)1)));
val.storeValue(inc);
storeValue(integer);
}
- Short::Short()
- {
- }
-
Short::Short(short x)
{
storeValue(Nucleus::createConstantShort(x));
storeValue(value);
}
- RValue<Short> Short::operator=(RValue<Short> rhs) const
+ RValue<Short> Short::operator=(RValue<Short> rhs)
{
storeValue(rhs.value);
return rhs;
}
- RValue<Short> Short::operator=(const Short &rhs) const
+ RValue<Short> Short::operator=(const Short &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<Short>(value);
}
- RValue<Short> Short::operator=(const Reference<Short> &rhs) const
+ RValue<Short> Short::operator=(const Reference<Short> &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<Short>(Nucleus::createAShr(lhs.value, rhs.value));
}
- RValue<Short> operator+=(const Short &lhs, RValue<Short> rhs)
+ RValue<Short> operator+=(Short &lhs, RValue<Short> rhs)
{
return lhs = lhs + rhs;
}
- RValue<Short> operator-=(const Short &lhs, RValue<Short> rhs)
+ RValue<Short> operator-=(Short &lhs, RValue<Short> rhs)
{
return lhs = lhs - rhs;
}
- RValue<Short> operator*=(const Short &lhs, RValue<Short> rhs)
+ RValue<Short> operator*=(Short &lhs, RValue<Short> rhs)
{
return lhs = lhs * rhs;
}
- RValue<Short> operator/=(const Short &lhs, RValue<Short> rhs)
+ RValue<Short> operator/=(Short &lhs, RValue<Short> rhs)
{
return lhs = lhs / rhs;
}
- RValue<Short> operator%=(const Short &lhs, RValue<Short> rhs)
+ RValue<Short> operator%=(Short &lhs, RValue<Short> rhs)
{
return lhs = lhs % rhs;
}
- RValue<Short> operator&=(const Short &lhs, RValue<Short> rhs)
+ RValue<Short> operator&=(Short &lhs, RValue<Short> rhs)
{
return lhs = lhs & rhs;
}
- RValue<Short> operator|=(const Short &lhs, RValue<Short> rhs)
+ RValue<Short> operator|=(Short &lhs, RValue<Short> rhs)
{
return lhs = lhs | rhs;
}
- RValue<Short> operator^=(const Short &lhs, RValue<Short> rhs)
+ RValue<Short> operator^=(Short &lhs, RValue<Short> rhs)
{
return lhs = lhs ^ rhs;
}
- RValue<Short> operator<<=(const Short &lhs, RValue<Short> rhs)
+ RValue<Short> operator<<=(Short &lhs, RValue<Short> rhs)
{
return lhs = lhs << rhs;
}
- RValue<Short> operator>>=(const Short &lhs, RValue<Short> rhs)
+ RValue<Short> operator>>=(Short &lhs, RValue<Short> rhs)
{
return lhs = lhs >> rhs;
}
return RValue<Short>(Nucleus::createNot(val.value));
}
- RValue<Short> operator++(const Short &val, int) // Post-increment
+ RValue<Short> operator++(Short &val, int) // Post-increment
{
RValue<Short> res = val;
return res;
}
- const Short &operator++(const Short &val) // Pre-increment
+ const Short &operator++(Short &val) // Pre-increment
{
Value *inc = Nucleus::createAdd(val.loadValue(), V(Nucleus::createConstantShort((short)1)));
val.storeValue(inc);
return val;
}
- RValue<Short> operator--(const Short &val, int) // Post-decrement
+ RValue<Short> operator--(Short &val, int) // Post-decrement
{
RValue<Short> res = val;
return res;
}
- const Short &operator--(const Short &val) // Pre-decrement
+ const Short &operator--(Short &val) // Pre-decrement
{
Value *inc = Nucleus::createSub(val.loadValue(), V(Nucleus::createConstantShort((short)1)));
val.storeValue(inc);
storeValue(integer);
}
- UShort::UShort()
- {
- }
-
UShort::UShort(unsigned short x)
{
storeValue(Nucleus::createConstantShort(x));
storeValue(value);
}
- RValue<UShort> UShort::operator=(RValue<UShort> rhs) const
+ RValue<UShort> UShort::operator=(RValue<UShort> rhs)
{
storeValue(rhs.value);
return rhs;
}
- RValue<UShort> UShort::operator=(const UShort &rhs) const
+ RValue<UShort> UShort::operator=(const UShort &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<UShort>(value);
}
- RValue<UShort> UShort::operator=(const Reference<UShort> &rhs) const
+ RValue<UShort> UShort::operator=(const Reference<UShort> &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<UShort>(Nucleus::createLShr(lhs.value, rhs.value));
}
- RValue<UShort> operator+=(const UShort &lhs, RValue<UShort> rhs)
+ RValue<UShort> operator+=(UShort &lhs, RValue<UShort> rhs)
{
return lhs = lhs + rhs;
}
- RValue<UShort> operator-=(const UShort &lhs, RValue<UShort> rhs)
+ RValue<UShort> operator-=(UShort &lhs, RValue<UShort> rhs)
{
return lhs = lhs - rhs;
}
- RValue<UShort> operator*=(const UShort &lhs, RValue<UShort> rhs)
+ RValue<UShort> operator*=(UShort &lhs, RValue<UShort> rhs)
{
return lhs = lhs * rhs;
}
- RValue<UShort> operator/=(const UShort &lhs, RValue<UShort> rhs)
+ RValue<UShort> operator/=(UShort &lhs, RValue<UShort> rhs)
{
return lhs = lhs / rhs;
}
- RValue<UShort> operator%=(const UShort &lhs, RValue<UShort> rhs)
+ RValue<UShort> operator%=(UShort &lhs, RValue<UShort> rhs)
{
return lhs = lhs % rhs;
}
- RValue<UShort> operator&=(const UShort &lhs, RValue<UShort> rhs)
+ RValue<UShort> operator&=(UShort &lhs, RValue<UShort> rhs)
{
return lhs = lhs & rhs;
}
- RValue<UShort> operator|=(const UShort &lhs, RValue<UShort> rhs)
+ RValue<UShort> operator|=(UShort &lhs, RValue<UShort> rhs)
{
return lhs = lhs | rhs;
}
- RValue<UShort> operator^=(const UShort &lhs, RValue<UShort> rhs)
+ RValue<UShort> operator^=(UShort &lhs, RValue<UShort> rhs)
{
return lhs = lhs ^ rhs;
}
- RValue<UShort> operator<<=(const UShort &lhs, RValue<UShort> rhs)
+ RValue<UShort> operator<<=(UShort &lhs, RValue<UShort> rhs)
{
return lhs = lhs << rhs;
}
- RValue<UShort> operator>>=(const UShort &lhs, RValue<UShort> rhs)
+ RValue<UShort> operator>>=(UShort &lhs, RValue<UShort> rhs)
{
return lhs = lhs >> rhs;
}
return RValue<UShort>(Nucleus::createNot(val.value));
}
- RValue<UShort> operator++(const UShort &val, int) // Post-increment
+ RValue<UShort> operator++(UShort &val, int) // Post-increment
{
RValue<UShort> res = val;
return res;
}
- const UShort &operator++(const UShort &val) // Pre-increment
+ const UShort &operator++(UShort &val) // Pre-increment
{
Value *inc = Nucleus::createAdd(val.loadValue(), V(Nucleus::createConstantShort((unsigned short)1)));
val.storeValue(inc);
return val;
}
- RValue<UShort> operator--(const UShort &val, int) // Post-decrement
+ RValue<UShort> operator--(UShort &val, int) // Post-decrement
{
RValue<UShort> res = val;
return res;
}
- const UShort &operator--(const UShort &val) // Pre-decrement
+ const UShort &operator--(UShort &val) // Pre-decrement
{
Value *inc = Nucleus::createSub(val.loadValue(), V(Nucleus::createConstantShort((unsigned short)1)));
val.storeValue(inc);
Byte4::Byte4(RValue<Byte8> cast)
{
- // xyzw.parent = this;
-
storeValue(Nucleus::createTrunc(Nucleus::createBitCast(cast.value, Long::getType()), Int::getType()));
}
Byte4::Byte4(const Reference<Byte4> &rhs)
{
- // xyzw.parent = this;
-
Value *value = rhs.loadValue();
storeValue(value);
}
Type *Byte4::getType()
{
- #if 0
- return T(VectorType::get(Byte::getType(), 4));
- #else
- return UInt::getType(); // FIXME: LLVM doesn't manipulate it as one 32-bit block
- #endif
+ return T(Type_v4i8);
}
Type *SByte4::getType()
{
- #if 0
- return T(VectorType::get(SByte::getType(), 4));
- #else
- return Int::getType(); // FIXME: LLVM doesn't manipulate it as one 32-bit block
- #endif
- }
-
- Byte8::Byte8()
- {
- // xyzw.parent = this;
+ return T(Type_v4i8);
}
Byte8::Byte8(uint8_t x0, uint8_t x1, uint8_t x2, uint8_t x3, uint8_t x4, uint8_t x5, uint8_t x6, uint8_t x7)
{
- // xyzw.parent = this;
-
int64_t constantVector[8] = {x0, x1, x2, x3, x4, x5, x6, x7};
- Value *vector = V(Nucleus::createConstantVector(constantVector, T(VectorType::get(Byte::getType(), 8))));
+ Value *vector = V(Nucleus::createConstantVector(constantVector, T(llvm::VectorType::get(T(Byte::getType()), 8))));
storeValue(Nucleus::createBitCast(vector, getType()));
}
Byte8::Byte8(RValue<Byte8> rhs)
{
- // xyzw.parent = this;
-
storeValue(rhs.value);
}
Byte8::Byte8(const Byte8 &rhs)
{
- // xyzw.parent = this;
-
Value *value = rhs.loadValue();
storeValue(value);
}
Byte8::Byte8(const Reference<Byte8> &rhs)
{
- // xyzw.parent = this;
-
Value *value = rhs.loadValue();
storeValue(value);
}
- RValue<Byte8> Byte8::operator=(RValue<Byte8> rhs) const
+ RValue<Byte8> Byte8::operator=(RValue<Byte8> rhs)
{
storeValue(rhs.value);
return rhs;
}
- RValue<Byte8> Byte8::operator=(const Byte8 &rhs) const
+ RValue<Byte8> Byte8::operator=(const Byte8 &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<Byte8>(value);
}
- RValue<Byte8> Byte8::operator=(const Reference<Byte8> &rhs) const
+ RValue<Byte8> Byte8::operator=(const Reference<Byte8> &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
// return RValue<Byte8>(Nucleus::createLShr(lhs.value, rhs.value));
// }
- RValue<Byte8> operator+=(const Byte8 &lhs, RValue<Byte8> rhs)
+ RValue<Byte8> operator+=(Byte8 &lhs, RValue<Byte8> rhs)
{
return lhs = lhs + rhs;
}
- RValue<Byte8> operator-=(const Byte8 &lhs, RValue<Byte8> rhs)
+ RValue<Byte8> operator-=(Byte8 &lhs, RValue<Byte8> rhs)
{
return lhs = lhs - rhs;
}
-// RValue<Byte8> operator*=(const Byte8 &lhs, RValue<Byte8> rhs)
+// RValue<Byte8> operator*=(Byte8 &lhs, RValue<Byte8> rhs)
// {
// return lhs = lhs * rhs;
// }
-// RValue<Byte8> operator/=(const Byte8 &lhs, RValue<Byte8> rhs)
+// RValue<Byte8> operator/=(Byte8 &lhs, RValue<Byte8> rhs)
// {
// return lhs = lhs / rhs;
// }
-// RValue<Byte8> operator%=(const Byte8 &lhs, RValue<Byte8> rhs)
+// RValue<Byte8> operator%=(Byte8 &lhs, RValue<Byte8> rhs)
// {
// return lhs = lhs % rhs;
// }
- RValue<Byte8> operator&=(const Byte8 &lhs, RValue<Byte8> rhs)
+ RValue<Byte8> operator&=(Byte8 &lhs, RValue<Byte8> rhs)
{
return lhs = lhs & rhs;
}
- RValue<Byte8> operator|=(const Byte8 &lhs, RValue<Byte8> rhs)
+ RValue<Byte8> operator|=(Byte8 &lhs, RValue<Byte8> rhs)
{
return lhs = lhs | rhs;
}
- RValue<Byte8> operator^=(const Byte8 &lhs, RValue<Byte8> rhs)
+ RValue<Byte8> operator^=(Byte8 &lhs, RValue<Byte8> rhs)
{
return lhs = lhs ^ rhs;
}
-// RValue<Byte8> operator<<=(const Byte8 &lhs, RValue<Byte8> rhs)
+// RValue<Byte8> operator<<=(Byte8 &lhs, RValue<Byte8> rhs)
// {
// return lhs = lhs << rhs;
// }
-// RValue<Byte8> operator>>=(const Byte8 &lhs, RValue<Byte8> rhs)
+// RValue<Byte8> operator>>=(Byte8 &lhs, RValue<Byte8> rhs)
// {
// return lhs = lhs >> rhs;
// }
RValue<Short4> Unpack(RValue<Byte4> x)
{
- Value *int2 = Nucleus::createInsertElement(V(UndefValue::get(VectorType::get(Int::getType(), 2))), x.value, 0);
+ Value *int2 = Nucleus::createInsertElement(V(llvm::UndefValue::get(llvm::VectorType::get(T(Int::getType()), 2))), x.value, 0);
Value *byte8 = Nucleus::createBitCast(int2, Byte8::getType());
return UnpackLow(RValue<Byte8>(byte8), RValue<Byte8>(byte8));
}
+ RValue<Short4> Unpack(RValue<Byte4> x, RValue<Byte4> y)
+ {
+ Value *xx = Nucleus::createInsertElement(V(llvm::UndefValue::get(llvm::VectorType::get(T(Int::getType()), 2))), x.value, 0);
+ Value *yy = Nucleus::createInsertElement(V(llvm::UndefValue::get(llvm::VectorType::get(T(Int::getType()), 2))), y.value, 0);
+
+ return UnpackLow(As<Byte8>(xx), As<Byte8>(yy));
+ }
+
RValue<Short4> UnpackLow(RValue<Byte8> x, RValue<Byte8> y)
{
if(CPUID::supportsMMX2())
Type *Byte8::getType()
{
- if(CPUID::supportsMMX2())
- {
- return MMX::getType();
- }
- else
- {
- return T(VectorType::get(Byte::getType(), 8));
- }
- }
-
- SByte8::SByte8()
- {
- // xyzw.parent = this;
+ return T(Type_v8i8);
}
SByte8::SByte8(uint8_t x0, uint8_t x1, uint8_t x2, uint8_t x3, uint8_t x4, uint8_t x5, uint8_t x6, uint8_t x7)
{
- // xyzw.parent = this;
-
int64_t constantVector[8] = {x0, x1, x2, x3, x4, x5, x6, x7};
- Value *vector = V(Nucleus::createConstantVector(constantVector, T(VectorType::get(SByte::getType(), 8))));
+ Value *vector = V(Nucleus::createConstantVector(constantVector, T(llvm::VectorType::get(T(SByte::getType()), 8))));
storeValue(Nucleus::createBitCast(vector, getType()));
}
SByte8::SByte8(RValue<SByte8> rhs)
{
- // xyzw.parent = this;
-
storeValue(rhs.value);
}
SByte8::SByte8(const SByte8 &rhs)
{
- // xyzw.parent = this;
-
Value *value = rhs.loadValue();
storeValue(value);
}
SByte8::SByte8(const Reference<SByte8> &rhs)
{
- // xyzw.parent = this;
-
Value *value = rhs.loadValue();
storeValue(value);
}
- RValue<SByte8> SByte8::operator=(RValue<SByte8> rhs) const
+ RValue<SByte8> SByte8::operator=(RValue<SByte8> rhs)
{
storeValue(rhs.value);
return rhs;
}
- RValue<SByte8> SByte8::operator=(const SByte8 &rhs) const
+ RValue<SByte8> SByte8::operator=(const SByte8 &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<SByte8>(value);
}
- RValue<SByte8> SByte8::operator=(const Reference<SByte8> &rhs) const
+ RValue<SByte8> SByte8::operator=(const Reference<SByte8> &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
// return RValue<SByte8>(Nucleus::createAShr(lhs.value, rhs.value));
// }
- RValue<SByte8> operator+=(const SByte8 &lhs, RValue<SByte8> rhs)
+ RValue<SByte8> operator+=(SByte8 &lhs, RValue<SByte8> rhs)
{
return lhs = lhs + rhs;
}
- RValue<SByte8> operator-=(const SByte8 &lhs, RValue<SByte8> rhs)
+ RValue<SByte8> operator-=(SByte8 &lhs, RValue<SByte8> rhs)
{
return lhs = lhs - rhs;
}
-// RValue<SByte8> operator*=(const SByte8 &lhs, RValue<SByte8> rhs)
+// RValue<SByte8> operator*=(SByte8 &lhs, RValue<SByte8> rhs)
// {
// return lhs = lhs * rhs;
// }
-// RValue<SByte8> operator/=(const SByte8 &lhs, RValue<SByte8> rhs)
+// RValue<SByte8> operator/=(SByte8 &lhs, RValue<SByte8> rhs)
// {
// return lhs = lhs / rhs;
// }
-// RValue<SByte8> operator%=(const SByte8 &lhs, RValue<SByte8> rhs)
+// RValue<SByte8> operator%=(SByte8 &lhs, RValue<SByte8> rhs)
// {
// return lhs = lhs % rhs;
// }
- RValue<SByte8> operator&=(const SByte8 &lhs, RValue<SByte8> rhs)
+ RValue<SByte8> operator&=(SByte8 &lhs, RValue<SByte8> rhs)
{
return lhs = lhs & rhs;
}
- RValue<SByte8> operator|=(const SByte8 &lhs, RValue<SByte8> rhs)
+ RValue<SByte8> operator|=(SByte8 &lhs, RValue<SByte8> rhs)
{
return lhs = lhs | rhs;
}
- RValue<SByte8> operator^=(const SByte8 &lhs, RValue<SByte8> rhs)
+ RValue<SByte8> operator^=(SByte8 &lhs, RValue<SByte8> rhs)
{
return lhs = lhs ^ rhs;
}
-// RValue<SByte8> operator<<=(const SByte8 &lhs, RValue<SByte8> rhs)
+// RValue<SByte8> operator<<=(SByte8 &lhs, RValue<SByte8> rhs)
// {
// return lhs = lhs << rhs;
// }
-// RValue<SByte8> operator>>=(const SByte8 &lhs, RValue<SByte8> rhs)
+// RValue<SByte8> operator>>=(SByte8 &lhs, RValue<SByte8> rhs)
// {
// return lhs = lhs >> rhs;
// }
Type *SByte8::getType()
{
- if(CPUID::supportsMMX2())
- {
- return MMX::getType();
- }
- else
- {
- return T(VectorType::get(SByte::getType(), 8));
- }
+ return T(Type_v8i8);
}
Byte16::Byte16(RValue<Byte16> rhs)
{
- // xyzw.parent = this;
-
storeValue(rhs.value);
}
Byte16::Byte16(const Byte16 &rhs)
{
- // xyzw.parent = this;
-
Value *value = rhs.loadValue();
storeValue(value);
}
Byte16::Byte16(const Reference<Byte16> &rhs)
{
- // xyzw.parent = this;
-
Value *value = rhs.loadValue();
storeValue(value);
}
- RValue<Byte16> Byte16::operator=(RValue<Byte16> rhs) const
+ RValue<Byte16> Byte16::operator=(RValue<Byte16> rhs)
{
storeValue(rhs.value);
return rhs;
}
- RValue<Byte16> Byte16::operator=(const Byte16 &rhs) const
+ RValue<Byte16> Byte16::operator=(const Byte16 &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<Byte16>(value);
}
- RValue<Byte16> Byte16::operator=(const Reference<Byte16> &rhs) const
+ RValue<Byte16> Byte16::operator=(const Reference<Byte16> &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
Type *Byte16::getType()
{
- return T(VectorType::get(Byte::getType(), 16));
+ return T(llvm::VectorType::get(T(Byte::getType()), 16));
}
Type *SByte16::getType()
{
- return T( VectorType::get(SByte::getType(), 16));
+ return T(llvm::VectorType::get(T(SByte::getType()), 16));
}
Short2::Short2(RValue<Short4> cast)
Type *Short2::getType()
{
- #if 0
- return T(VectorType::get(Short::getType(), 2));
- #else
- return UInt::getType(); // FIXME: LLVM doesn't manipulate it as one 32-bit block
- #endif
+ return T(Type_v2i16);
}
UShort2::UShort2(RValue<UShort4> cast)
Type *UShort2::getType()
{
- #if 0
- return T(VectorType::get(UShort::getType(), 2));
- #else
- return UInt::getType(); // FIXME: LLVM doesn't manipulate it as one 32-bit block
- #endif
+ return T(Type_v2i16);
}
Short4::Short4(RValue<Int> cast)
{
Value *extend = Nucleus::createZExt(cast.value, Long::getType());
- Value *swizzle = Swizzle(RValue<Short4>(extend), 0x00).value;
+ Value *swizzle = Swizzle(As<Short4>(extend), 0x00).value;
storeValue(swizzle);
}
{
Value *short8 = Nucleus::createBitCast(cast.value, Short8::getType());
- #if 0 // FIXME: Check codegen (pshuflw phshufhw pshufd)
- Constant *pack[8];
- pack[0] = Nucleus::createConstantInt(0);
- pack[1] = Nucleus::createConstantInt(2);
- pack[2] = Nucleus::createConstantInt(4);
- pack[3] = Nucleus::createConstantInt(6);
+ Value *packed;
- Value *short4 = Nucleus::createShuffleVector(short8, short8, Nucleus::createConstantVector(pack, 4));
- #else
- Value *packed;
-
- // FIXME: Use Swizzle<Short8>
- if(!CPUID::supportsSSSE3())
- {
- int pshuflw[8] = {0, 2, 0, 2, 4, 5, 6, 7};
- int pshufhw[8] = {0, 1, 2, 3, 4, 6, 4, 6};
+ // FIXME: Use Swizzle<Short8>
+ if(!CPUID::supportsSSSE3())
+ {
+ int pshuflw[8] = {0, 2, 0, 2, 4, 5, 6, 7};
+ int pshufhw[8] = {0, 1, 2, 3, 4, 6, 4, 6};
- Value *shuffle1 = Nucleus::createShuffleVector(short8, short8, pshuflw);
- Value *shuffle2 = Nucleus::createShuffleVector(shuffle1, shuffle1, pshufhw);
- Value *int4 = Nucleus::createBitCast(shuffle2, Int4::getType());
- packed = createSwizzle4(int4, 0x88);
- }
- else
- {
- int pshufb[16] = {0, 1, 4, 5, 8, 9, 12, 13, 0, 1, 4, 5, 8, 9, 12, 13};
- Value *byte16 = Nucleus::createBitCast(cast.value, Byte16::getType());
- packed = Nucleus::createShuffleVector(byte16, byte16, pshufb);
- }
+ Value *shuffle1 = Nucleus::createShuffleVector(short8, short8, pshuflw);
+ Value *shuffle2 = Nucleus::createShuffleVector(shuffle1, shuffle1, pshufhw);
+ Value *int4 = Nucleus::createBitCast(shuffle2, Int4::getType());
+ packed = createSwizzle4(int4, 0x88);
+ }
+ else
+ {
+ int pshufb[16] = {0, 1, 4, 5, 8, 9, 12, 13, 0, 1, 4, 5, 8, 9, 12, 13};
+ Value *byte16 = Nucleus::createBitCast(cast.value, Byte16::getType());
+ packed = Nucleus::createShuffleVector(byte16, byte16, pshufb);
+ }
- #if 0 // FIXME: No optimal instruction selection
- Value *qword2 = Nucleus::createBitCast(packed, Long2::getType());
- Value *element = Nucleus::createExtractElement(qword2, 0);
- Value *short4 = Nucleus::createBitCast(element, Short4::getType());
- #else // FIXME: Requires SSE
- Value *int2 = RValue<Int2>(Int2(RValue<Int4>(packed))).value;
- Value *short4 = Nucleus::createBitCast(int2, Short4::getType());
- #endif
- #endif
+ Value *int2 = RValue<Int2>(Int2(As<Int4>(packed))).value;
+ Value *short4 = Nucleus::createBitCast(int2, Short4::getType());
storeValue(short4);
}
storeValue(As<Short4>(Int2(v4i32)).value);
}
- Short4::Short4()
- {
- // xyzw.parent = this;
- }
-
Short4::Short4(short xyzw)
{
- // xyzw.parent = this;
-
int64_t constantVector[4] = {xyzw, xyzw, xyzw, xyzw};
- Value *vector = V(Nucleus::createConstantVector(constantVector, T(VectorType::get(Short::getType(), 4))));
+ Value *vector = V(Nucleus::createConstantVector(constantVector, T(llvm::VectorType::get(T(Short::getType()), 4))));
storeValue(Nucleus::createBitCast(vector, getType()));
}
Short4::Short4(short x, short y, short z, short w)
{
- // xyzw.parent = this;
-
int64_t constantVector[4] = {x, y, z, w};
- Value *vector = V(Nucleus::createConstantVector(constantVector, T(VectorType::get(Short::getType(), 4))));
+ Value *vector = V(Nucleus::createConstantVector(constantVector, T(llvm::VectorType::get(T(Short::getType()), 4))));
storeValue(Nucleus::createBitCast(vector, getType()));
}
Short4::Short4(RValue<Short4> rhs)
{
- // xyzw.parent = this;
-
storeValue(rhs.value);
}
Short4::Short4(const Short4 &rhs)
{
- // xyzw.parent = this;
-
Value *value = rhs.loadValue();
storeValue(value);
}
Short4::Short4(const Reference<Short4> &rhs)
{
- // xyzw.parent = this;
-
Value *value = rhs.loadValue();
storeValue(value);
}
Short4::Short4(RValue<UShort4> rhs)
{
- // xyzw.parent = this;
-
storeValue(rhs.value);
}
Short4::Short4(const UShort4 &rhs)
{
- // xyzw.parent = this;
-
storeValue(rhs.loadValue());
}
Short4::Short4(const Reference<UShort4> &rhs)
{
- // xyzw.parent = this;
-
storeValue(rhs.loadValue());
}
- RValue<Short4> Short4::operator=(RValue<Short4> rhs) const
+ RValue<Short4> Short4::operator=(RValue<Short4> rhs)
{
storeValue(rhs.value);
return rhs;
}
- RValue<Short4> Short4::operator=(const Short4 &rhs) const
+ RValue<Short4> Short4::operator=(const Short4 &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<Short4>(value);
}
- RValue<Short4> Short4::operator=(const Reference<Short4> &rhs) const
+ RValue<Short4> Short4::operator=(const Reference<Short4> &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<Short4>(value);
}
- RValue<Short4> Short4::operator=(RValue<UShort4> rhs) const
+ RValue<Short4> Short4::operator=(RValue<UShort4> rhs)
{
storeValue(rhs.value);
return RValue<Short4>(rhs);
}
- RValue<Short4> Short4::operator=(const UShort4 &rhs) const
+ RValue<Short4> Short4::operator=(const UShort4 &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<Short4>(value);
}
- RValue<Short4> Short4::operator=(const Reference<UShort4> &rhs) const
+ RValue<Short4> Short4::operator=(const Reference<UShort4> &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return x86::psraw(lhs, rhs);
}
- RValue<Short4> operator<<(RValue<Short4> lhs, RValue<Long1> rhs)
- {
- // return RValue<Short4>(Nucleus::createShl(lhs.value, rhs.value));
-
- return x86::psllw(lhs, rhs);
- }
-
- RValue<Short4> operator>>(RValue<Short4> lhs, RValue<Long1> rhs)
- {
- // return RValue<Short4>(Nucleus::createAShr(lhs.value, rhs.value));
-
- return x86::psraw(lhs, rhs);
- }
-
- RValue<Short4> operator+=(const Short4 &lhs, RValue<Short4> rhs)
+ RValue<Short4> operator+=(Short4 &lhs, RValue<Short4> rhs)
{
return lhs = lhs + rhs;
}
- RValue<Short4> operator-=(const Short4 &lhs, RValue<Short4> rhs)
+ RValue<Short4> operator-=(Short4 &lhs, RValue<Short4> rhs)
{
return lhs = lhs - rhs;
}
- RValue<Short4> operator*=(const Short4 &lhs, RValue<Short4> rhs)
+ RValue<Short4> operator*=(Short4 &lhs, RValue<Short4> rhs)
{
return lhs = lhs * rhs;
}
-// RValue<Short4> operator/=(const Short4 &lhs, RValue<Short4> rhs)
+// RValue<Short4> operator/=(Short4 &lhs, RValue<Short4> rhs)
// {
// return lhs = lhs / rhs;
// }
-// RValue<Short4> operator%=(const Short4 &lhs, RValue<Short4> rhs)
+// RValue<Short4> operator%=(Short4 &lhs, RValue<Short4> rhs)
// {
// return lhs = lhs % rhs;
// }
- RValue<Short4> operator&=(const Short4 &lhs, RValue<Short4> rhs)
+ RValue<Short4> operator&=(Short4 &lhs, RValue<Short4> rhs)
{
return lhs = lhs & rhs;
}
- RValue<Short4> operator|=(const Short4 &lhs, RValue<Short4> rhs)
+ RValue<Short4> operator|=(Short4 &lhs, RValue<Short4> rhs)
{
return lhs = lhs | rhs;
}
- RValue<Short4> operator^=(const Short4 &lhs, RValue<Short4> rhs)
+ RValue<Short4> operator^=(Short4 &lhs, RValue<Short4> rhs)
{
return lhs = lhs ^ rhs;
}
- RValue<Short4> operator<<=(const Short4 &lhs, unsigned char rhs)
- {
- return lhs = lhs << rhs;
- }
-
- RValue<Short4> operator>>=(const Short4 &lhs, unsigned char rhs)
- {
- return lhs = lhs >> rhs;
- }
-
- RValue<Short4> operator<<=(const Short4 &lhs, RValue<Long1> rhs)
+ RValue<Short4> operator<<=(Short4 &lhs, unsigned char rhs)
{
return lhs = lhs << rhs;
}
- RValue<Short4> operator>>=(const Short4 &lhs, RValue<Long1> rhs)
+ RValue<Short4> operator>>=(Short4 &lhs, unsigned char rhs)
{
return lhs = lhs >> rhs;
}
Type *Short4::getType()
{
- if(CPUID::supportsMMX2())
- {
- return MMX::getType();
- }
- else
- {
- return T(VectorType::get(Short::getType(), 4));
- }
+ return T(Type_v4i16);
}
UShort4::UShort4(RValue<Int4> cast)
if(!saturate || !CPUID::supportsSSE4_1())
{
- *this = Short4(Int4(int4));
+ *this = Short4(int4);
}
else
{
- *this = As<Short4>(Int2(As<Int4>(x86::packusdw(As<UInt4>(int4), As<UInt4>(int4)))));
+ *this = As<Short4>(Int2(As<Int4>(x86::packusdw(int4, int4))));
}
}
- UShort4::UShort4()
- {
- // xyzw.parent = this;
- }
-
UShort4::UShort4(unsigned short xyzw)
{
- // xyzw.parent = this;
-
int64_t constantVector[4] = {xyzw, xyzw, xyzw, xyzw};
- Value *vector = V(Nucleus::createConstantVector(constantVector, T(VectorType::get(UShort::getType(), 4))));
+ Value *vector = V(Nucleus::createConstantVector(constantVector, T(llvm::VectorType::get(T(UShort::getType()), 4))));
storeValue(Nucleus::createBitCast(vector, getType()));
}
UShort4::UShort4(unsigned short x, unsigned short y, unsigned short z, unsigned short w)
{
- // xyzw.parent = this;
-
int64_t constantVector[4] = {x, y, z, w};
- Value *vector = V(Nucleus::createConstantVector(constantVector, T(VectorType::get(UShort::getType(), 4))));
+ Value *vector = V(Nucleus::createConstantVector(constantVector, T(llvm::VectorType::get(T(UShort::getType()), 4))));
storeValue(Nucleus::createBitCast(vector, getType()));
}
UShort4::UShort4(RValue<UShort4> rhs)
{
- // xyzw.parent = this;
-
storeValue(rhs.value);
}
UShort4::UShort4(const UShort4 &rhs)
{
- // xyzw.parent = this;
-
Value *value = rhs.loadValue();
storeValue(value);
}
UShort4::UShort4(const Reference<UShort4> &rhs)
{
- // xyzw.parent = this;
-
Value *value = rhs.loadValue();
storeValue(value);
}
UShort4::UShort4(RValue<Short4> rhs)
{
- // xyzw.parent = this;
-
storeValue(rhs.value);
}
UShort4::UShort4(const Short4 &rhs)
{
- // xyzw.parent = this;
-
Value *value = rhs.loadValue();
storeValue(value);
}
UShort4::UShort4(const Reference<Short4> &rhs)
{
- // xyzw.parent = this;
-
Value *value = rhs.loadValue();
storeValue(value);
}
- RValue<UShort4> UShort4::operator=(RValue<UShort4> rhs) const
+ RValue<UShort4> UShort4::operator=(RValue<UShort4> rhs)
{
storeValue(rhs.value);
return rhs;
}
- RValue<UShort4> UShort4::operator=(const UShort4 &rhs) const
+ RValue<UShort4> UShort4::operator=(const UShort4 &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<UShort4>(value);
}
- RValue<UShort4> UShort4::operator=(const Reference<UShort4> &rhs) const
+ RValue<UShort4> UShort4::operator=(const Reference<UShort4> &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<UShort4>(value);
}
- RValue<UShort4> UShort4::operator=(RValue<Short4> rhs) const
+ RValue<UShort4> UShort4::operator=(RValue<Short4> rhs)
{
storeValue(rhs.value);
return RValue<UShort4>(rhs);
}
- RValue<UShort4> UShort4::operator=(const Short4 &rhs) const
+ RValue<UShort4> UShort4::operator=(const Short4 &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<UShort4>(value);
}
- RValue<UShort4> UShort4::operator=(const Reference<Short4> &rhs) const
+ RValue<UShort4> UShort4::operator=(const Reference<Short4> &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return x86::psrlw(lhs, rhs);
}
- RValue<UShort4> operator<<(RValue<UShort4> lhs, RValue<Long1> rhs)
- {
- // return RValue<Short4>(Nucleus::createShl(lhs.value, rhs.value));
-
- return As<UShort4>(x86::psllw(As<Short4>(lhs), rhs));
- }
-
- RValue<UShort4> operator>>(RValue<UShort4> lhs, RValue<Long1> rhs)
- {
- // return RValue<Short4>(Nucleus::createLShr(lhs.value, rhs.value));
-
- return x86::psrlw(lhs, rhs);
- }
-
- RValue<UShort4> operator<<=(const UShort4 &lhs, unsigned char rhs)
+ RValue<UShort4> operator<<=(UShort4 &lhs, unsigned char rhs)
{
return lhs = lhs << rhs;
}
- RValue<UShort4> operator>>=(const UShort4 &lhs, unsigned char rhs)
- {
- return lhs = lhs >> rhs;
- }
-
- RValue<UShort4> operator<<=(const UShort4 &lhs, RValue<Long1> rhs)
- {
- return lhs = lhs << rhs;
- }
-
- RValue<UShort4> operator>>=(const UShort4 &lhs, RValue<Long1> rhs)
+ RValue<UShort4> operator>>=(UShort4 &lhs, unsigned char rhs)
{
return lhs = lhs >> rhs;
}
Type *UShort4::getType()
{
- if(CPUID::supportsMMX2())
- {
- return MMX::getType();
- }
- else
- {
- return T(VectorType::get(UShort::getType(), 4));
- }
+ return T(Type_v4i16);
}
- Short8::Short8(short c0, short c1, short c2, short c3, short c4, short c5, short c6, short c7)
+ Short8::Short8(short c)
{
- // xyzw.parent = this;
+ int64_t constantVector[8] = {c, c, c, c, c, c, c, c};
+ storeValue(Nucleus::createConstantVector(constantVector, getType()));
+ }
+ Short8::Short8(short c0, short c1, short c2, short c3, short c4, short c5, short c6, short c7)
+ {
int64_t constantVector[8] = {c0, c1, c2, c3, c4, c5, c6, c7};
storeValue(Nucleus::createConstantVector(constantVector, getType()));
}
Short8::Short8(RValue<Short8> rhs)
{
- // xyzw.parent = this;
-
storeValue(rhs.value);
}
Short8::Short8(const Reference<Short8> &rhs)
{
- // xyzw.parent = this;
-
Value *value = rhs.loadValue();
storeValue(value);
}
Value *loLong = Nucleus::createBitCast(lo.value, Long::getType());
Value *hiLong = Nucleus::createBitCast(hi.value, Long::getType());
- Value *long2 = V(UndefValue::get(Long2::getType()));
+ Value *long2 = V(llvm::UndefValue::get(llvm::VectorType::get(T(Long::getType()), 2)));
long2 = Nucleus::createInsertElement(long2, loLong, 0);
long2 = Nucleus::createInsertElement(long2, hiLong, 1);
Value *short8 = Nucleus::createBitCast(long2, Short8::getType());
Type *Short8::getType()
{
- return T(VectorType::get(Short::getType(), 8));
+ return T(llvm::VectorType::get(T(Short::getType()), 8));
}
- 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)
+ UShort8::UShort8(unsigned short c)
{
- // xyzw.parent = this;
+ int64_t constantVector[8] = {c, c, c, c, c, c, c, c};
+ storeValue(Nucleus::createConstantVector(constantVector, getType()));
+ }
+ 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)
+ {
int64_t constantVector[8] = {c0, c1, c2, c3, c4, c5, c6, c7};
storeValue(Nucleus::createConstantVector(constantVector, getType()));
}
UShort8::UShort8(RValue<UShort8> rhs)
{
- // xyzw.parent = this;
-
storeValue(rhs.value);
}
UShort8::UShort8(const Reference<UShort8> &rhs)
{
- // xyzw.parent = this;
-
Value *value = rhs.loadValue();
storeValue(value);
}
Value *loLong = Nucleus::createBitCast(lo.value, Long::getType());
Value *hiLong = Nucleus::createBitCast(hi.value, Long::getType());
- Value *long2 = V(UndefValue::get(Long2::getType()));
+ Value *long2 = V(llvm::UndefValue::get(llvm::VectorType::get(T(Long::getType()), 2)));
long2 = Nucleus::createInsertElement(long2, loLong, 0);
long2 = Nucleus::createInsertElement(long2, hiLong, 1);
Value *short8 = Nucleus::createBitCast(long2, Short8::getType());
storeValue(short8);
}
- RValue<UShort8> UShort8::operator=(RValue<UShort8> rhs) const
+ RValue<UShort8> UShort8::operator=(RValue<UShort8> rhs)
{
storeValue(rhs.value);
return rhs;
}
- RValue<UShort8> UShort8::operator=(const UShort8 &rhs) const
+ RValue<UShort8> UShort8::operator=(const UShort8 &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<UShort8>(value);
}
- RValue<UShort8> UShort8::operator=(const Reference<UShort8> &rhs) const
+ RValue<UShort8> UShort8::operator=(const Reference<UShort8> &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<UShort8>(Nucleus::createMul(lhs.value, rhs.value));
}
- RValue<UShort8> operator+=(const UShort8 &lhs, RValue<UShort8> rhs)
+ RValue<UShort8> operator+=(UShort8 &lhs, RValue<UShort8> rhs)
{
return lhs = lhs + rhs;
}
Type *UShort8::getType()
{
- return T(VectorType::get(UShort::getType(), 8));
+ return T(llvm::VectorType::get(T(UShort::getType()), 8));
}
Int::Int(Argument<Int> argument)
storeValue(integer);
}
- Int::Int()
- {
- }
-
Int::Int(int x)
{
storeValue(Nucleus::createConstantInt(x));
storeValue(value);
}
- RValue<Int> Int::operator=(int rhs) const
+ RValue<Int> Int::operator=(int rhs)
{
return RValue<Int>(storeValue(Nucleus::createConstantInt(rhs)));
}
- RValue<Int> Int::operator=(RValue<Int> rhs) const
+ RValue<Int> Int::operator=(RValue<Int> rhs)
{
storeValue(rhs.value);
return rhs;
}
- RValue<Int> Int::operator=(RValue<UInt> rhs) const
+ RValue<Int> Int::operator=(RValue<UInt> rhs)
{
storeValue(rhs.value);
return RValue<Int>(rhs);
}
- RValue<Int> Int::operator=(const Int &rhs) const
+ RValue<Int> Int::operator=(const Int &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<Int>(value);
}
- RValue<Int> Int::operator=(const Reference<Int> &rhs) const
+ RValue<Int> Int::operator=(const Reference<Int> &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<Int>(value);
}
- RValue<Int> Int::operator=(const UInt &rhs) const
+ RValue<Int> Int::operator=(const UInt &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<Int>(value);
}
- RValue<Int> Int::operator=(const Reference<UInt> &rhs) const
+ RValue<Int> Int::operator=(const Reference<UInt> &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<Int>(Nucleus::createAShr(lhs.value, rhs.value));
}
- RValue<Int> operator+=(const Int &lhs, RValue<Int> rhs)
+ RValue<Int> operator+=(Int &lhs, RValue<Int> rhs)
{
return lhs = lhs + rhs;
}
- RValue<Int> operator-=(const Int &lhs, RValue<Int> rhs)
+ RValue<Int> operator-=(Int &lhs, RValue<Int> rhs)
{
return lhs = lhs - rhs;
}
- RValue<Int> operator*=(const Int &lhs, RValue<Int> rhs)
+ RValue<Int> operator*=(Int &lhs, RValue<Int> rhs)
{
return lhs = lhs * rhs;
}
- RValue<Int> operator/=(const Int &lhs, RValue<Int> rhs)
+ RValue<Int> operator/=(Int &lhs, RValue<Int> rhs)
{
return lhs = lhs / rhs;
}
- RValue<Int> operator%=(const Int &lhs, RValue<Int> rhs)
+ RValue<Int> operator%=(Int &lhs, RValue<Int> rhs)
{
return lhs = lhs % rhs;
}
- RValue<Int> operator&=(const Int &lhs, RValue<Int> rhs)
+ RValue<Int> operator&=(Int &lhs, RValue<Int> rhs)
{
return lhs = lhs & rhs;
}
- RValue<Int> operator|=(const Int &lhs, RValue<Int> rhs)
+ RValue<Int> operator|=(Int &lhs, RValue<Int> rhs)
{
return lhs = lhs | rhs;
}
- RValue<Int> operator^=(const Int &lhs, RValue<Int> rhs)
+ RValue<Int> operator^=(Int &lhs, RValue<Int> rhs)
{
return lhs = lhs ^ rhs;
}
- RValue<Int> operator<<=(const Int &lhs, RValue<Int> rhs)
+ RValue<Int> operator<<=(Int &lhs, RValue<Int> rhs)
{
return lhs = lhs << rhs;
}
- RValue<Int> operator>>=(const Int &lhs, RValue<Int> rhs)
+ RValue<Int> operator>>=(Int &lhs, RValue<Int> rhs)
{
return lhs = lhs >> rhs;
}
return RValue<Int>(Nucleus::createNot(val.value));
}
- RValue<Int> operator++(const Int &val, int) // Post-increment
+ RValue<Int> operator++(Int &val, int) // Post-increment
{
RValue<Int> res = val;
return res;
}
- const Int &operator++(const Int &val) // Pre-increment
+ const Int &operator++(Int &val) // Pre-increment
{
Value *inc = Nucleus::createAdd(val.loadValue(), V(Nucleus::createConstantInt(1)));
val.storeValue(inc);
return val;
}
- RValue<Int> operator--(const Int &val, int) // Post-decrement
+ RValue<Int> operator--(Int &val, int) // Post-decrement
{
RValue<Int> res = val;
return res;
}
- const Int &operator--(const Int &val) // Pre-decrement
+ const Int &operator--(Int &val) // Pre-decrement
{
Value *inc = Nucleus::createSub(val.loadValue(), V(Nucleus::createConstantInt(1)));
val.storeValue(inc);
storeValue(integer);
}
- Long::Long()
- {
- }
-
Long::Long(RValue<Long> rhs)
{
storeValue(rhs.value);
}
- RValue<Long> Long::operator=(int64_t rhs) const
+ RValue<Long> Long::operator=(int64_t rhs)
{
return RValue<Long>(storeValue(Nucleus::createConstantLong(rhs)));
}
- RValue<Long> Long::operator=(RValue<Long> rhs) const
+ RValue<Long> Long::operator=(RValue<Long> rhs)
{
storeValue(rhs.value);
return rhs;
}
- RValue<Long> Long::operator=(const Long &rhs) const
+ RValue<Long> Long::operator=(const Long &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<Long>(value);
}
- RValue<Long> Long::operator=(const Reference<Long> &rhs) const
+ RValue<Long> Long::operator=(const Reference<Long> &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<Long>(Nucleus::createSub(lhs.value, rhs.value));
}
- RValue<Long> operator+=(const Long &lhs, RValue<Long> rhs)
+ RValue<Long> operator+=(Long &lhs, RValue<Long> rhs)
{
return lhs = lhs + rhs;
}
- RValue<Long> operator-=(const Long &lhs, RValue<Long> rhs)
+ RValue<Long> operator-=(Long &lhs, RValue<Long> rhs)
{
return lhs = lhs - rhs;
}
return T(llvm::Type::getInt64Ty(*::context));
}
- Long1::Long1(const RValue<UInt> cast)
- {
- Value *undefCast = Nucleus::createInsertElement(V(UndefValue::get(VectorType::get(Int::getType(), 2))), cast.value, 0);
- Value *zeroCast = Nucleus::createInsertElement(undefCast, V(Nucleus::createConstantInt(0)), 1);
-
- storeValue(Nucleus::createBitCast(zeroCast, Long1::getType()));
- }
-
- Long1::Long1(RValue<Long1> rhs)
- {
- storeValue(rhs.value);
- }
-
- Type *Long1::getType()
- {
- if(CPUID::supportsMMX2())
- {
- return MMX::getType();
- }
- else
- {
- return T(VectorType::get(Long::getType(), 1));
- }
- }
-
- RValue<Long2> UnpackHigh(RValue<Long2> x, RValue<Long2> y)
- {
- int shuffle[2] = {1, 3};
- Value *packed = Nucleus::createShuffleVector(x.value, y.value, shuffle);
-
- return RValue<Long2>(packed);
- }
-
- Type *Long2::getType()
- {
- return T(VectorType::get(Long::getType(), 2));
- }
-
UInt::UInt(Argument<UInt> argument)
{
storeValue(argument.value);
Int(cast))).value);
}
- UInt::UInt()
- {
- }
-
UInt::UInt(int x)
{
storeValue(Nucleus::createConstantInt(x));
storeValue(value);
}
- RValue<UInt> UInt::operator=(unsigned int rhs) const
+ RValue<UInt> UInt::operator=(unsigned int rhs)
{
return RValue<UInt>(storeValue(Nucleus::createConstantInt(rhs)));
}
- RValue<UInt> UInt::operator=(RValue<UInt> rhs) const
+ RValue<UInt> UInt::operator=(RValue<UInt> rhs)
{
storeValue(rhs.value);
return rhs;
}
- RValue<UInt> UInt::operator=(RValue<Int> rhs) const
+ RValue<UInt> UInt::operator=(RValue<Int> rhs)
{
storeValue(rhs.value);
return RValue<UInt>(rhs);
}
- RValue<UInt> UInt::operator=(const UInt &rhs) const
+ RValue<UInt> UInt::operator=(const UInt &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<UInt>(value);
}
- RValue<UInt> UInt::operator=(const Reference<UInt> &rhs) const
+ RValue<UInt> UInt::operator=(const Reference<UInt> &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<UInt>(value);
}
- RValue<UInt> UInt::operator=(const Int &rhs) const
+ RValue<UInt> UInt::operator=(const Int &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<UInt>(value);
}
- RValue<UInt> UInt::operator=(const Reference<Int> &rhs) const
+ RValue<UInt> UInt::operator=(const Reference<Int> &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<UInt>(Nucleus::createLShr(lhs.value, rhs.value));
}
- RValue<UInt> operator+=(const UInt &lhs, RValue<UInt> rhs)
+ RValue<UInt> operator+=(UInt &lhs, RValue<UInt> rhs)
{
return lhs = lhs + rhs;
}
- RValue<UInt> operator-=(const UInt &lhs, RValue<UInt> rhs)
+ RValue<UInt> operator-=(UInt &lhs, RValue<UInt> rhs)
{
return lhs = lhs - rhs;
}
- RValue<UInt> operator*=(const UInt &lhs, RValue<UInt> rhs)
+ RValue<UInt> operator*=(UInt &lhs, RValue<UInt> rhs)
{
return lhs = lhs * rhs;
}
- RValue<UInt> operator/=(const UInt &lhs, RValue<UInt> rhs)
+ RValue<UInt> operator/=(UInt &lhs, RValue<UInt> rhs)
{
return lhs = lhs / rhs;
}
- RValue<UInt> operator%=(const UInt &lhs, RValue<UInt> rhs)
+ RValue<UInt> operator%=(UInt &lhs, RValue<UInt> rhs)
{
return lhs = lhs % rhs;
}
- RValue<UInt> operator&=(const UInt &lhs, RValue<UInt> rhs)
+ RValue<UInt> operator&=(UInt &lhs, RValue<UInt> rhs)
{
return lhs = lhs & rhs;
}
- RValue<UInt> operator|=(const UInt &lhs, RValue<UInt> rhs)
+ RValue<UInt> operator|=(UInt &lhs, RValue<UInt> rhs)
{
return lhs = lhs | rhs;
}
- RValue<UInt> operator^=(const UInt &lhs, RValue<UInt> rhs)
+ RValue<UInt> operator^=(UInt &lhs, RValue<UInt> rhs)
{
return lhs = lhs ^ rhs;
}
- RValue<UInt> operator<<=(const UInt &lhs, RValue<UInt> rhs)
+ RValue<UInt> operator<<=(UInt &lhs, RValue<UInt> rhs)
{
return lhs = lhs << rhs;
}
- RValue<UInt> operator>>=(const UInt &lhs, RValue<UInt> rhs)
+ RValue<UInt> operator>>=(UInt &lhs, RValue<UInt> rhs)
{
return lhs = lhs >> rhs;
}
return RValue<UInt>(Nucleus::createNot(val.value));
}
- RValue<UInt> operator++(const UInt &val, int) // Post-increment
+ RValue<UInt> operator++(UInt &val, int) // Post-increment
{
RValue<UInt> res = val;
return res;
}
- const UInt &operator++(const UInt &val) // Pre-increment
+ const UInt &operator++(UInt &val) // Pre-increment
{
Value *inc = Nucleus::createAdd(val.loadValue(), V(Nucleus::createConstantInt(1)));
val.storeValue(inc);
return val;
}
- RValue<UInt> operator--(const UInt &val, int) // Post-decrement
+ RValue<UInt> operator--(UInt &val, int) // Post-decrement
{
RValue<UInt> res = val;
return res;
}
- const UInt &operator--(const UInt &val) // Pre-decrement
+ const UInt &operator--(UInt &val) // Pre-decrement
{
Value *inc = Nucleus::createSub(val.loadValue(), V(Nucleus::createConstantInt(1)));
val.storeValue(inc);
Int2::Int2(RValue<Int4> cast)
{
- Value *long2 = Nucleus::createBitCast(cast.value, Long2::getType());
+ Value *long2 = Nucleus::createBitCast(cast.value, T(llvm::VectorType::get(T(Long::getType()), 2)));
Value *element = Nucleus::createExtractElement(long2, Long::getType(), 0);
Value *int2 = Nucleus::createBitCast(element, Int2::getType());
storeValue(int2);
}
- Int2::Int2()
- {
- // xy.parent = this;
- }
-
Int2::Int2(int x, int y)
{
- // xy.parent = this;
-
int64_t constantVector[2] = {x, y};
- Value *vector = V(Nucleus::createConstantVector(constantVector, T(VectorType::get(Int::getType(), 2))));
+ Value *vector = V(Nucleus::createConstantVector(constantVector, T(llvm::VectorType::get(T(Int::getType()), 2))));
storeValue(Nucleus::createBitCast(vector, getType()));
}
Int2::Int2(RValue<Int2> rhs)
{
- // xy.parent = this;
-
storeValue(rhs.value);
}
Int2::Int2(const Int2 &rhs)
{
- // xy.parent = this;
-
Value *value = rhs.loadValue();
storeValue(value);
}
Int2::Int2(const Reference<Int2> &rhs)
{
- // xy.parent = this;
-
Value *value = rhs.loadValue();
storeValue(value);
}
// movd mm0, lo
// movd mm1, hi
// punpckldq mm0, mm1
- storeValue(As<Int2>(UnpackLow(As<Int2>(Long1(RValue<UInt>(lo))), As<Int2>(Long1(RValue<UInt>(hi))))).value);
+
+ Value *loLong = Nucleus::createInsertElement(V(llvm::UndefValue::get(llvm::VectorType::get(T(Int::getType()), 2))), lo.value, 0);
+ loLong = Nucleus::createInsertElement(loLong, V(llvm::ConstantInt::get(T(Int::getType()), 0)), 1);
+ Value *hiLong = Nucleus::createInsertElement(V(llvm::UndefValue::get(llvm::VectorType::get(T(Int::getType()), 2))), hi.value, 0);
+ hiLong = Nucleus::createInsertElement(hiLong, V(llvm::ConstantInt::get(T(Int::getType()), 0)), 1);
+
+ storeValue(As<Int2>(UnpackLow(As<Int2>(loLong), As<Int2>(hiLong))).value);
}
else
{
int shuffle[2] = {0, 1};
- Value *packed = Nucleus::createShuffleVector(Nucleus::createBitCast(lo.value, T(VectorType::get(Int::getType(), 1))), Nucleus::createBitCast(hi.value, T(VectorType::get(Int::getType(), 1))), shuffle);
+ Value *packed = Nucleus::createShuffleVector(Nucleus::createBitCast(lo.value, T(llvm::VectorType::get(T(Int::getType()), 1))), Nucleus::createBitCast(hi.value, T(llvm::VectorType::get(T(Int::getType()), 1))), shuffle);
storeValue(Nucleus::createBitCast(packed, Int2::getType()));
}
}
- RValue<Int2> Int2::operator=(RValue<Int2> rhs) const
+ RValue<Int2> Int2::operator=(RValue<Int2> rhs)
{
storeValue(rhs.value);
return rhs;
}
- RValue<Int2> Int2::operator=(const Int2 &rhs) const
+ RValue<Int2> Int2::operator=(const Int2 &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<Int2>(value);
}
- RValue<Int2> Int2::operator=(const Reference<Int2> &rhs) const
+ RValue<Int2> Int2::operator=(const Reference<Int2> &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return x86::psrad(lhs, rhs);
}
- RValue<Int2> operator<<(RValue<Int2> lhs, RValue<Long1> rhs)
- {
- // return RValue<Int2>(Nucleus::createShl(lhs.value, rhs.value));
-
- return x86::pslld(lhs, rhs);
- }
-
- RValue<Int2> operator>>(RValue<Int2> lhs, RValue<Long1> rhs)
- {
- // return RValue<Int2>(Nucleus::createAShr(lhs.value, rhs.value));
-
- return x86::psrad(lhs, rhs);
- }
-
- RValue<Int2> operator+=(const Int2 &lhs, RValue<Int2> rhs)
+ RValue<Int2> operator+=(Int2 &lhs, RValue<Int2> rhs)
{
return lhs = lhs + rhs;
}
- RValue<Int2> operator-=(const Int2 &lhs, RValue<Int2> rhs)
+ RValue<Int2> operator-=(Int2 &lhs, RValue<Int2> rhs)
{
return lhs = lhs - rhs;
}
-// RValue<Int2> operator*=(const Int2 &lhs, RValue<Int2> rhs)
+// RValue<Int2> operator*=(Int2 &lhs, RValue<Int2> rhs)
// {
// return lhs = lhs * rhs;
// }
-// RValue<Int2> operator/=(const Int2 &lhs, RValue<Int2> rhs)
+// RValue<Int2> operator/=(Int2 &lhs, RValue<Int2> rhs)
// {
// return lhs = lhs / rhs;
// }
-// RValue<Int2> operator%=(const Int2 &lhs, RValue<Int2> rhs)
+// RValue<Int2> operator%=(Int2 &lhs, RValue<Int2> rhs)
// {
// return lhs = lhs % rhs;
// }
- RValue<Int2> operator&=(const Int2 &lhs, RValue<Int2> rhs)
+ RValue<Int2> operator&=(Int2 &lhs, RValue<Int2> rhs)
{
return lhs = lhs & rhs;
}
- RValue<Int2> operator|=(const Int2 &lhs, RValue<Int2> rhs)
+ RValue<Int2> operator|=(Int2 &lhs, RValue<Int2> rhs)
{
return lhs = lhs | rhs;
}
- RValue<Int2> operator^=(const Int2 &lhs, RValue<Int2> rhs)
+ RValue<Int2> operator^=(Int2 &lhs, RValue<Int2> rhs)
{
return lhs = lhs ^ rhs;
}
- RValue<Int2> operator<<=(const Int2 &lhs, unsigned char rhs)
- {
- return lhs = lhs << rhs;
- }
-
- RValue<Int2> operator>>=(const Int2 &lhs, unsigned char rhs)
- {
- return lhs = lhs >> rhs;
- }
-
- RValue<Int2> operator<<=(const Int2 &lhs, RValue<Long1> rhs)
+ RValue<Int2> operator<<=(Int2 &lhs, unsigned char rhs)
{
return lhs = lhs << rhs;
}
- RValue<Int2> operator>>=(const Int2 &lhs, RValue<Long1> rhs)
+ RValue<Int2> operator>>=(Int2 &lhs, unsigned char rhs)
{
return lhs = lhs >> rhs;
}
}
}
- RValue<Long1> UnpackLow(RValue<Int2> x, RValue<Int2> y)
+ RValue<Short4> UnpackLow(RValue<Int2> x, RValue<Int2> y)
{
if(CPUID::supportsMMX2())
{
int shuffle[2] = {0, 2};
Value *packed = Nucleus::createShuffleVector(x.value, y.value, shuffle);
- return RValue<Long1>(Nucleus::createBitCast(packed, Long1::getType()));
+ return As<Short4>(packed);
}
}
- RValue<Long1> UnpackHigh(RValue<Int2> x, RValue<Int2> y)
+ RValue<Short4> UnpackHigh(RValue<Int2> x, RValue<Int2> y)
{
if(CPUID::supportsMMX2())
{
int shuffle[2] = {1, 3};
Value *packed = Nucleus::createShuffleVector(x.value, y.value, shuffle);
- return RValue<Long1>(Nucleus::createBitCast(packed, Long1::getType()));
+ return As<Short4>(packed);
}
}
RValue<Int> Extract(RValue<Int2> val, int i)
{
- if(false) // FIXME: LLVM does not generate optimal code
+ if(i == 0)
{
- return RValue<Int>(Nucleus::createExtractElement(val.value, Int::getType(), i));
+ return RValue<Int>(Nucleus::createExtractElement(Nucleus::createBitCast(val.value, T(llvm::VectorType::get(T(Int::getType()), 2))), Int::getType(), 0));
}
else
{
- if(i == 0)
- {
- return RValue<Int>(Nucleus::createExtractElement(Nucleus::createBitCast(val.value, T(VectorType::get(Int::getType(), 2))), Int::getType(), 0));
- }
- else
- {
- Int2 val2 = As<Int2>(UnpackHigh(val, val));
+ Int2 val2 = As<Int2>(UnpackHigh(val, val));
- return Extract(val2, 0);
- }
+ return Extract(val2, 0);
}
}
RValue<Int2> Insert(RValue<Int2> val, RValue<Int> element, int i)
{
- return RValue<Int2>(Nucleus::createBitCast(Nucleus::createInsertElement(Nucleus::createBitCast(val.value, T(VectorType::get(Int::getType(), 2))), element.value, i), Int2::getType()));
+ return RValue<Int2>(Nucleus::createBitCast(Nucleus::createInsertElement(Nucleus::createBitCast(val.value, T(llvm::VectorType::get(T(Int::getType()), 2))), element.value, i), Int2::getType()));
}
Type *Int2::getType()
{
- if(CPUID::supportsMMX2())
- {
- return MMX::getType();
- }
- else
- {
- return T(VectorType::get(Int::getType(), 2));
- }
- }
-
- UInt2::UInt2()
- {
- // xy.parent = this;
+ return T(Type_v2i32);
}
UInt2::UInt2(unsigned int x, unsigned int y)
{
- // xy.parent = this;
-
int64_t constantVector[2] = {x, y};
- Value *vector = V(Nucleus::createConstantVector(constantVector, T(VectorType::get(UInt::getType(), 2))));
+ Value *vector = V(Nucleus::createConstantVector(constantVector, T(llvm::VectorType::get(T(UInt::getType()), 2))));
storeValue(Nucleus::createBitCast(vector, getType()));
}
UInt2::UInt2(RValue<UInt2> rhs)
{
- // xy.parent = this;
-
storeValue(rhs.value);
}
UInt2::UInt2(const UInt2 &rhs)
{
- // xy.parent = this;
-
Value *value = rhs.loadValue();
storeValue(value);
}
UInt2::UInt2(const Reference<UInt2> &rhs)
{
- // xy.parent = this;
-
Value *value = rhs.loadValue();
storeValue(value);
}
- RValue<UInt2> UInt2::operator=(RValue<UInt2> rhs) const
+ RValue<UInt2> UInt2::operator=(RValue<UInt2> rhs)
{
storeValue(rhs.value);
return rhs;
}
- RValue<UInt2> UInt2::operator=(const UInt2 &rhs) const
+ RValue<UInt2> UInt2::operator=(const UInt2 &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<UInt2>(value);
}
- RValue<UInt2> UInt2::operator=(const Reference<UInt2> &rhs) const
+ RValue<UInt2> UInt2::operator=(const Reference<UInt2> &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return x86::psrld(lhs, rhs);
}
- RValue<UInt2> operator<<(RValue<UInt2> lhs, RValue<Long1> rhs)
- {
- // return RValue<UInt2>(Nucleus::createShl(lhs.value, rhs.value));
-
- return As<UInt2>(x86::pslld(As<Int2>(lhs), rhs));
- }
-
- RValue<UInt2> operator>>(RValue<UInt2> lhs, RValue<Long1> rhs)
- {
- // return RValue<UInt2>(Nucleus::createLShr(lhs.value, rhs.value));
-
- return x86::psrld(lhs, rhs);
- }
-
- RValue<UInt2> operator+=(const UInt2 &lhs, RValue<UInt2> rhs)
+ RValue<UInt2> operator+=(UInt2 &lhs, RValue<UInt2> rhs)
{
return lhs = lhs + rhs;
}
- RValue<UInt2> operator-=(const UInt2 &lhs, RValue<UInt2> rhs)
+ RValue<UInt2> operator-=(UInt2 &lhs, RValue<UInt2> rhs)
{
return lhs = lhs - rhs;
}
-// RValue<UInt2> operator*=(const UInt2 &lhs, RValue<UInt2> rhs)
+// RValue<UInt2> operator*=(UInt2 &lhs, RValue<UInt2> rhs)
// {
// return lhs = lhs * rhs;
// }
-// RValue<UInt2> operator/=(const UInt2 &lhs, RValue<UInt2> rhs)
+// RValue<UInt2> operator/=(UInt2 &lhs, RValue<UInt2> rhs)
// {
// return lhs = lhs / rhs;
// }
-// RValue<UInt2> operator%=(const UInt2 &lhs, RValue<UInt2> rhs)
+// RValue<UInt2> operator%=(UInt2 &lhs, RValue<UInt2> rhs)
// {
// return lhs = lhs % rhs;
// }
- RValue<UInt2> operator&=(const UInt2 &lhs, RValue<UInt2> rhs)
+ RValue<UInt2> operator&=(UInt2 &lhs, RValue<UInt2> rhs)
{
return lhs = lhs & rhs;
}
- RValue<UInt2> operator|=(const UInt2 &lhs, RValue<UInt2> rhs)
+ RValue<UInt2> operator|=(UInt2 &lhs, RValue<UInt2> rhs)
{
return lhs = lhs | rhs;
}
- RValue<UInt2> operator^=(const UInt2 &lhs, RValue<UInt2> rhs)
+ RValue<UInt2> operator^=(UInt2 &lhs, RValue<UInt2> rhs)
{
return lhs = lhs ^ rhs;
}
- RValue<UInt2> operator<<=(const UInt2 &lhs, unsigned char rhs)
- {
- return lhs = lhs << rhs;
- }
-
- RValue<UInt2> operator>>=(const UInt2 &lhs, unsigned char rhs)
- {
- return lhs = lhs >> rhs;
- }
-
- RValue<UInt2> operator<<=(const UInt2 &lhs, RValue<Long1> rhs)
+ RValue<UInt2> operator<<=(UInt2 &lhs, unsigned char rhs)
{
return lhs = lhs << rhs;
}
- RValue<UInt2> operator>>=(const UInt2 &lhs, RValue<Long1> rhs)
+ RValue<UInt2> operator>>=(UInt2 &lhs, unsigned char rhs)
{
return lhs = lhs >> rhs;
}
Type *UInt2::getType()
{
- if(CPUID::supportsMMX2())
- {
- return MMX::getType();
- }
- else
- {
- return T(VectorType::get(UInt::getType(), 2));
- }
+ return T(Type_v2i32);
}
Int4::Int4(RValue<Byte4> cast)
{
Value *x = Nucleus::createBitCast(cast.value, Int::getType());
- Value *a = Nucleus::createInsertElement(V(UndefValue::get(Int4::getType())), x, 0);
+ Value *a = Nucleus::createInsertElement(V(llvm::UndefValue::get(T(Int4::getType()))), x, 0);
Value *e;
Int4::Int4(RValue<SByte4> cast)
{
Value *x = Nucleus::createBitCast(cast.value, Int::getType());
- Value *a = Nucleus::createInsertElement(V(UndefValue::get(Int4::getType())), x, 0);
+ Value *a = Nucleus::createInsertElement(V(llvm::UndefValue::get(T(Int4::getType()))), x, 0);
Value *g;
Int4::Int4(RValue<Float4> cast)
{
- // xyzw.parent = this;
-
Value *xyzw = Nucleus::createFPToSI(cast.value, Int4::getType());
storeValue(xyzw);
Int4::Int4(RValue<Short4> cast)
{
- Value *long2 = V(UndefValue::get(Long2::getType()));
+ Value *long2 = V(llvm::UndefValue::get(llvm::VectorType::get(T(Long::getType()), 2)));
Value *element = Nucleus::createBitCast(cast.value, Long::getType());
long2 = Nucleus::createInsertElement(long2, element, 0);
RValue<Int4> vector = RValue<Int4>(Nucleus::createBitCast(long2, Int4::getType()));
// Each Short is packed into each Int in the (Short | Short) format.
// Shifting by 16 will retrieve the original Short value.
- // Shitfing an Int will propagate the sign bit, which will work
+ // Shifting an Int will propagate the sign bit, which will work
// for both positive and negative values of a Short.
*this >>= 16;
}
Int4::Int4(RValue<UShort4> cast)
{
- Value *long2 = V(UndefValue::get(Long2::getType()));
+ Value *long2 = V(llvm::UndefValue::get(llvm::VectorType::get(T(Long::getType()), 2)));
Value *element = Nucleus::createBitCast(cast.value, Long::getType());
long2 = Nucleus::createInsertElement(long2, element, 0);
RValue<Int4> vector = RValue<Int4>(Nucleus::createBitCast(long2, Int4::getType()));
}
}
- Int4::Int4()
- {
- // xyzw.parent = this;
- }
-
Int4::Int4(int xyzw)
{
constant(xyzw, xyzw, xyzw, xyzw);
void Int4::constant(int x, int y, int z, int w)
{
- // xyzw.parent = this;
-
int64_t constantVector[4] = {x, y, z, w};
storeValue(Nucleus::createConstantVector(constantVector, getType()));
}
Int4::Int4(RValue<Int4> rhs)
{
- // xyzw.parent = this;
-
storeValue(rhs.value);
}
Int4::Int4(const Int4 &rhs)
{
- // xyzw.parent = this;
-
Value *value = rhs.loadValue();
storeValue(value);
}
Int4::Int4(const Reference<Int4> &rhs)
{
- // xyzw.parent = this;
-
Value *value = rhs.loadValue();
storeValue(value);
}
Int4::Int4(RValue<UInt4> rhs)
{
- // xyzw.parent = this;
-
storeValue(rhs.value);
}
Int4::Int4(const UInt4 &rhs)
{
- // xyzw.parent = this;
-
Value *value = rhs.loadValue();
storeValue(value);
}
Int4::Int4(const Reference<UInt4> &rhs)
{
- // xyzw.parent = this;
-
Value *value = rhs.loadValue();
storeValue(value);
}
Int4::Int4(RValue<Int2> lo, RValue<Int2> hi)
{
- // xyzw.parent = this;
-
Value *loLong = Nucleus::createBitCast(lo.value, Long::getType());
Value *hiLong = Nucleus::createBitCast(hi.value, Long::getType());
- Value *long2 = V(UndefValue::get(Long2::getType()));
+ Value *long2 = V(llvm::UndefValue::get(llvm::VectorType::get(T(Long::getType()), 2)));
long2 = Nucleus::createInsertElement(long2, loLong, 0);
long2 = Nucleus::createInsertElement(long2, hiLong, 1);
Value *int4 = Nucleus::createBitCast(long2, Int4::getType());
Int4::Int4(RValue<Int> rhs)
{
- // xyzw.parent = this;
-
Value *vector = loadValue();
Value *insert = Nucleus::createInsertElement(vector, rhs.value, 0);
Int4::Int4(const Int &rhs)
{
- // xyzw.parent = this;
-
*this = RValue<Int>(rhs.loadValue());
}
Int4::Int4(const Reference<Int> &rhs)
{
- // xyzw.parent = this;
-
*this = RValue<Int>(rhs.loadValue());
}
- RValue<Int4> Int4::operator=(RValue<Int4> rhs) const
+ RValue<Int4> Int4::operator=(RValue<Int4> rhs)
{
storeValue(rhs.value);
return rhs;
}
- RValue<Int4> Int4::operator=(const Int4 &rhs) const
+ RValue<Int4> Int4::operator=(const Int4 &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<Int4>(value);
}
- RValue<Int4> Int4::operator=(const Reference<Int4> &rhs) const
+ RValue<Int4> Int4::operator=(const Reference<Int4> &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<Int4>(Nucleus::createAShr(lhs.value, rhs.value));
}
- RValue<Int4> operator+=(const Int4 &lhs, RValue<Int4> rhs)
+ RValue<Int4> operator+=(Int4 &lhs, RValue<Int4> rhs)
{
return lhs = lhs + rhs;
}
- RValue<Int4> operator-=(const Int4 &lhs, RValue<Int4> rhs)
+ RValue<Int4> operator-=(Int4 &lhs, RValue<Int4> rhs)
{
return lhs = lhs - rhs;
}
- RValue<Int4> operator*=(const Int4 &lhs, RValue<Int4> rhs)
+ RValue<Int4> operator*=(Int4 &lhs, RValue<Int4> rhs)
{
return lhs = lhs * rhs;
}
-// RValue<Int4> operator/=(const Int4 &lhs, RValue<Int4> rhs)
+// RValue<Int4> operator/=(Int4 &lhs, RValue<Int4> rhs)
// {
// return lhs = lhs / rhs;
// }
-// RValue<Int4> operator%=(const Int4 &lhs, RValue<Int4> rhs)
+// RValue<Int4> operator%=(Int4 &lhs, RValue<Int4> rhs)
// {
// return lhs = lhs % rhs;
// }
- RValue<Int4> operator&=(const Int4 &lhs, RValue<Int4> rhs)
+ RValue<Int4> operator&=(Int4 &lhs, RValue<Int4> rhs)
{
return lhs = lhs & rhs;
}
- RValue<Int4> operator|=(const Int4 &lhs, RValue<Int4> rhs)
+ RValue<Int4> operator|=(Int4 &lhs, RValue<Int4> rhs)
{
return lhs = lhs | rhs;
}
- RValue<Int4> operator^=(const Int4 &lhs, RValue<Int4> rhs)
+ RValue<Int4> operator^=(Int4 &lhs, RValue<Int4> rhs)
{
return lhs = lhs ^ rhs;
}
- RValue<Int4> operator<<=(const Int4 &lhs, unsigned char rhs)
+ RValue<Int4> operator<<=(Int4 &lhs, unsigned char rhs)
{
return lhs = lhs << rhs;
}
- RValue<Int4> operator>>=(const Int4 &lhs, unsigned char rhs)
+ RValue<Int4> operator>>=(Int4 &lhs, unsigned char rhs)
{
return lhs = lhs >> rhs;
}
else
{
RValue<Int4> greater = CmpNLE(x, y);
- return x & greater | y & ~greater;
+ return (x & greater) | (y & ~greater);
}
}
else
{
RValue<Int4> less = CmpLT(x, y);
- return x & less | y & ~less;
+ return (x & less) | (y & ~less);
}
}
Type *Int4::getType()
{
- return T(VectorType::get(Int::getType(), 4));
+ return T(llvm::VectorType::get(T(Int::getType()), 4));
}
UInt4::UInt4(RValue<Float4> cast)
{
- // xyzw.parent = this;
-
// Note: createFPToUI is broken, must perform conversion using createFPtoSI
// Value *xyzw = Nucleus::createFPToUI(cast.value, UInt4::getType());
storeValue((~(As<Int4>(cast) >> 31) & uiValue).value);
}
- UInt4::UInt4()
- {
- // xyzw.parent = this;
- }
-
UInt4::UInt4(int xyzw)
{
constant(xyzw, xyzw, xyzw, xyzw);
void UInt4::constant(int x, int y, int z, int w)
{
- // xyzw.parent = this;
-
int64_t constantVector[4] = {x, y, z, w};
storeValue(Nucleus::createConstantVector(constantVector, getType()));
}
UInt4::UInt4(RValue<UInt4> rhs)
{
- // xyzw.parent = this;
-
storeValue(rhs.value);
}
UInt4::UInt4(const UInt4 &rhs)
{
- // xyzw.parent = this;
-
Value *value = rhs.loadValue();
storeValue(value);
}
UInt4::UInt4(const Reference<UInt4> &rhs)
{
- // xyzw.parent = this;
-
Value *value = rhs.loadValue();
storeValue(value);
}
UInt4::UInt4(RValue<Int4> rhs)
{
- // xyzw.parent = this;
-
storeValue(rhs.value);
}
UInt4::UInt4(const Int4 &rhs)
{
- // xyzw.parent = this;
-
Value *value = rhs.loadValue();
storeValue(value);
}
UInt4::UInt4(const Reference<Int4> &rhs)
{
- // xyzw.parent = this;
-
Value *value = rhs.loadValue();
storeValue(value);
}
Value *loLong = Nucleus::createBitCast(lo.value, Long::getType());
Value *hiLong = Nucleus::createBitCast(hi.value, Long::getType());
- Value *long2 = V(UndefValue::get(Long2::getType()));
+ Value *long2 = V(llvm::UndefValue::get(llvm::VectorType::get(T(Long::getType()), 2)));
long2 = Nucleus::createInsertElement(long2, loLong, 0);
long2 = Nucleus::createInsertElement(long2, hiLong, 1);
Value *uint4 = Nucleus::createBitCast(long2, Int4::getType());
storeValue(uint4);
}
- RValue<UInt4> UInt4::operator=(RValue<UInt4> rhs) const
+ RValue<UInt4> UInt4::operator=(RValue<UInt4> rhs)
{
storeValue(rhs.value);
return rhs;
}
- RValue<UInt4> UInt4::operator=(const UInt4 &rhs) const
+ RValue<UInt4> UInt4::operator=(const UInt4 &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<UInt4>(value);
}
- RValue<UInt4> UInt4::operator=(const Reference<UInt4> &rhs) const
+ RValue<UInt4> UInt4::operator=(const Reference<UInt4> &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<UInt4>(Nucleus::createLShr(lhs.value, rhs.value));
}
- RValue<UInt4> operator+=(const UInt4 &lhs, RValue<UInt4> rhs)
+ RValue<UInt4> operator+=(UInt4 &lhs, RValue<UInt4> rhs)
{
return lhs = lhs + rhs;
}
- RValue<UInt4> operator-=(const UInt4 &lhs, RValue<UInt4> rhs)
+ RValue<UInt4> operator-=(UInt4 &lhs, RValue<UInt4> rhs)
{
return lhs = lhs - rhs;
}
- RValue<UInt4> operator*=(const UInt4 &lhs, RValue<UInt4> rhs)
+ RValue<UInt4> operator*=(UInt4 &lhs, RValue<UInt4> rhs)
{
return lhs = lhs * rhs;
}
-// RValue<UInt4> operator/=(const UInt4 &lhs, RValue<UInt4> rhs)
+// RValue<UInt4> operator/=(UInt4 &lhs, RValue<UInt4> rhs)
// {
// return lhs = lhs / rhs;
// }
-// RValue<UInt4> operator%=(const UInt4 &lhs, RValue<UInt4> rhs)
+// RValue<UInt4> operator%=(UInt4 &lhs, RValue<UInt4> rhs)
// {
// return lhs = lhs % rhs;
// }
- RValue<UInt4> operator&=(const UInt4 &lhs, RValue<UInt4> rhs)
+ RValue<UInt4> operator&=(UInt4 &lhs, RValue<UInt4> rhs)
{
return lhs = lhs & rhs;
}
- RValue<UInt4> operator|=(const UInt4 &lhs, RValue<UInt4> rhs)
+ RValue<UInt4> operator|=(UInt4 &lhs, RValue<UInt4> rhs)
{
return lhs = lhs | rhs;
}
- RValue<UInt4> operator^=(const UInt4 &lhs, RValue<UInt4> rhs)
+ RValue<UInt4> operator^=(UInt4 &lhs, RValue<UInt4> rhs)
{
return lhs = lhs ^ rhs;
}
- RValue<UInt4> operator<<=(const UInt4 &lhs, unsigned char rhs)
+ RValue<UInt4> operator<<=(UInt4 &lhs, unsigned char rhs)
{
return lhs = lhs << rhs;
}
- RValue<UInt4> operator>>=(const UInt4 &lhs, unsigned char rhs)
+ RValue<UInt4> operator>>=(UInt4 &lhs, unsigned char rhs)
{
return lhs = lhs >> rhs;
}
else
{
RValue<UInt4> greater = CmpNLE(x, y);
- return x & greater | y & ~greater;
+ return (x & greater) | (y & ~greater);
}
}
else
{
RValue<UInt4> less = CmpLT(x, y);
- return x & less | y & ~less;
+ return (x & less) | (y & ~less);
}
}
RValue<UShort8> Pack(RValue<UInt4> x, RValue<UInt4> y)
{
- return x86::packusdw(x, y); // FIXME: Fallback required
+ return x86::packusdw(As<Int4>(x), As<Int4>(y));
}
Type *UInt4::getType()
{
- return T(VectorType::get(UInt::getType(), 4));
+ return T(llvm::VectorType::get(T(UInt::getType()), 4));
}
Float::Float(RValue<Int> cast)
storeValue(integer);
}
- Float::Float()
+ Float::Float(RValue<UInt> cast)
{
+ RValue<Float> result = Float(Int(cast & UInt(0x7FFFFFFF))) +
+ As<Float>((As<Int>(cast) >> 31) & As<Int>(Float(0x80000000u)));
+ storeValue(result.value);
}
Float::Float(float x)
storeValue(value);
}
- RValue<Float> Float::operator=(RValue<Float> rhs) const
+ RValue<Float> Float::operator=(RValue<Float> rhs)
{
storeValue(rhs.value);
return rhs;
}
- RValue<Float> Float::operator=(const Float &rhs) const
+ RValue<Float> Float::operator=(const Float &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<Float>(value);
}
- RValue<Float> Float::operator=(const Reference<Float> &rhs) const
+ RValue<Float> Float::operator=(const Reference<Float> &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<Float>(Nucleus::createFDiv(lhs.value, rhs.value));
}
- RValue<Float> operator+=(const Float &lhs, RValue<Float> rhs)
+ RValue<Float> operator+=(Float &lhs, RValue<Float> rhs)
{
return lhs = lhs + rhs;
}
- RValue<Float> operator-=(const Float &lhs, RValue<Float> rhs)
+ RValue<Float> operator-=(Float &lhs, RValue<Float> rhs)
{
return lhs = lhs - rhs;
}
- RValue<Float> operator*=(const Float &lhs, RValue<Float> rhs)
+ RValue<Float> operator*=(Float &lhs, RValue<Float> rhs)
{
return lhs = lhs * rhs;
}
- RValue<Float> operator/=(const Float &lhs, RValue<Float> rhs)
+ RValue<Float> operator/=(Float &lhs, RValue<Float> rhs)
{
return lhs = lhs / rhs;
}
RValue<Float> Rcp_pp(RValue<Float> x, bool exactAtPow2)
{
- if(exactAtPow2)
- {
- // rcpss uses a piecewise-linear approximation which minimizes the relative error
- // but is not exact at power-of-two values. Rectify by multiplying by the inverse.
- return x86::rcpss(x) * Float(1.0f / _mm_cvtss_f32(_mm_rcp_ss(_mm_set_ps1(1.0f))));
- }
- else
- {
- return x86::rcpss(x);
- }
+ #if defined(__i386__) || defined(__x86_64__)
+ if(exactAtPow2)
+ {
+ // rcpss uses a piecewise-linear approximation which minimizes the relative error
+ // but is not exact at power-of-two values. Rectify by multiplying by the inverse.
+ return x86::rcpss(x) * Float(1.0f / _mm_cvtss_f32(_mm_rcp_ss(_mm_set_ps1(1.0f))));
+ }
+ #endif
+
+ return x86::rcpss(x);
}
RValue<Float> RcpSqrt_pp(RValue<Float> x)
Float2::Float2(RValue<Float4> cast)
{
- // xyzw.parent = this;
-
- Value *int64x2 = Nucleus::createBitCast(cast.value, Long2::getType());
+ Value *int64x2 = Nucleus::createBitCast(cast.value, T(llvm::VectorType::get(T(Long::getType()), 2)));
Value *int64 = Nucleus::createExtractElement(int64x2, Long::getType(), 0);
Value *float2 = Nucleus::createBitCast(int64, Float2::getType());
Type *Float2::getType()
{
- return T(VectorType::get(Float::getType(), 2));
+ return T(Type_v2f32);
}
- Float4::Float4(RValue<Byte4> cast)
+ Float4::Float4(RValue<Byte4> cast) : FloatXYZW(this)
{
- xyzw.parent = this;
-
- #if 0
- Value *xyzw = Nucleus::createUIToFP(cast.value, Float4::getType()); // FIXME: Crashes
- #elif 0
- Value *vector = loadValue();
-
- Value *i8x = Nucleus::createExtractElement(cast.value, 0);
- Value *f32x = Nucleus::createUIToFP(i8x, Float::getType());
- Value *x = Nucleus::createInsertElement(vector, f32x, 0);
-
- Value *i8y = Nucleus::createExtractElement(cast.value, V(Nucleus::createConstantInt(1)));
- Value *f32y = Nucleus::createUIToFP(i8y, Float::getType());
- Value *xy = Nucleus::createInsertElement(x, f32y, V(Nucleus::createConstantInt(1)));
-
- Value *i8z = Nucleus::createExtractElement(cast.value, Nucleus::createConstantInt(2));
- Value *f32z = Nucleus::createUIToFP(i8z, Float::getType());
- Value *xyz = Nucleus::createInsertElement(xy, f32z, Nucleus::createConstantInt(2));
-
- Value *i8w = Nucleus::createExtractElement(cast.value, Nucleus::createConstantInt(3));
- Value *f32w = Nucleus::createUIToFP(i8w, Float::getType());
- Value *xyzw = Nucleus::createInsertElement(xyz, f32w, Nucleus::createConstantInt(3));
- #else
- Value *a = Int4(cast).loadValue();
- Value *xyzw = Nucleus::createSIToFP(a, Float4::getType());
- #endif
+ Value *a = Int4(cast).loadValue();
+ Value *xyzw = Nucleus::createSIToFP(a, Float4::getType());
storeValue(xyzw);
}
- Float4::Float4(RValue<SByte4> cast)
+ Float4::Float4(RValue<SByte4> cast) : FloatXYZW(this)
{
- xyzw.parent = this;
-
- #if 0
- Value *xyzw = Nucleus::createSIToFP(cast.value, Float4::getType()); // FIXME: Crashes
- #elif 0
- Value *vector = loadValue();
-
- Value *i8x = Nucleus::createExtractElement(cast.value, 0);
- Value *f32x = Nucleus::createSIToFP(i8x, Float::getType());
- Value *x = Nucleus::createInsertElement(vector, f32x, 0);
-
- Value *i8y = Nucleus::createExtractElement(cast.value, V(Nucleus::createConstantInt(1)));
- Value *f32y = Nucleus::createSIToFP(i8y, Float::getType());
- Value *xy = Nucleus::createInsertElement(x, f32y, V(Nucleus::createConstantInt(1)));
-
- Value *i8z = Nucleus::createExtractElement(cast.value, Nucleus::createConstantInt(2));
- Value *f32z = Nucleus::createSIToFP(i8z, Float::getType());
- Value *xyz = Nucleus::createInsertElement(xy, f32z, Nucleus::createConstantInt(2));
-
- Value *i8w = Nucleus::createExtractElement(cast.value, Nucleus::createConstantInt(3));
- Value *f32w = Nucleus::createSIToFP(i8w, Float::getType());
- Value *xyzw = Nucleus::createInsertElement(xyz, f32w, Nucleus::createConstantInt(3));
- #else
- Value *a = Int4(cast).loadValue();
- Value *xyzw = Nucleus::createSIToFP(a, Float4::getType());
- #endif
+ Value *a = Int4(cast).loadValue();
+ Value *xyzw = Nucleus::createSIToFP(a, Float4::getType());
storeValue(xyzw);
}
- Float4::Float4(RValue<Short4> cast)
+ Float4::Float4(RValue<Short4> cast) : FloatXYZW(this)
{
- xyzw.parent = this;
-
Int4 c(cast);
storeValue(Nucleus::createSIToFP(RValue<Int4>(c).value, Float4::getType()));
}
- Float4::Float4(RValue<UShort4> cast)
+ Float4::Float4(RValue<UShort4> cast) : FloatXYZW(this)
{
- xyzw.parent = this;
-
Int4 c(cast);
storeValue(Nucleus::createSIToFP(RValue<Int4>(c).value, Float4::getType()));
}
- Float4::Float4(RValue<Int4> cast)
+ Float4::Float4(RValue<Int4> cast) : FloatXYZW(this)
{
- xyzw.parent = this;
-
Value *xyzw = Nucleus::createSIToFP(cast.value, Float4::getType());
storeValue(xyzw);
}
- Float4::Float4(RValue<UInt4> cast)
+ Float4::Float4(RValue<UInt4> cast) : FloatXYZW(this)
{
- xyzw.parent = this;
+ RValue<Float4> result = Float4(Int4(cast & UInt4(0x7FFFFFFF))) +
+ As<Float4>((As<Int4>(cast) >> 31) & As<Int4>(Float4(0x80000000u)));
- Value *xyzw = Nucleus::createUIToFP(cast.value, Float4::getType());
-
- storeValue(xyzw);
+ storeValue(result.value);
}
- Float4::Float4()
+ Float4::Float4() : FloatXYZW(this)
{
- xyzw.parent = this;
}
- Float4::Float4(float xyzw)
+ Float4::Float4(float xyzw) : FloatXYZW(this)
{
constant(xyzw, xyzw, xyzw, xyzw);
}
- Float4::Float4(float x, float yzw)
+ Float4::Float4(float x, float yzw) : FloatXYZW(this)
{
constant(x, yzw, yzw, yzw);
}
- Float4::Float4(float x, float y, float zw)
+ Float4::Float4(float x, float y, float zw) : FloatXYZW(this)
{
constant(x, y, zw, zw);
}
- Float4::Float4(float x, float y, float z, float w)
+ Float4::Float4(float x, float y, float z, float w) : FloatXYZW(this)
{
constant(x, y, z, w);
}
void Float4::constant(float x, float y, float z, float w)
{
- xyzw.parent = this;
-
double constantVector[4] = {x, y, z, w};
storeValue(Nucleus::createConstantVector(constantVector, getType()));
}
- Float4::Float4(RValue<Float4> rhs)
+ Float4::Float4(RValue<Float4> rhs) : FloatXYZW(this)
{
- xyzw.parent = this;
-
storeValue(rhs.value);
}
- Float4::Float4(const Float4 &rhs)
+ Float4::Float4(const Float4 &rhs) : FloatXYZW(this)
{
- xyzw.parent = this;
-
Value *value = rhs.loadValue();
storeValue(value);
}
- Float4::Float4(const Reference<Float4> &rhs)
+ Float4::Float4(const Reference<Float4> &rhs) : FloatXYZW(this)
{
- xyzw.parent = this;
-
Value *value = rhs.loadValue();
storeValue(value);
}
- Float4::Float4(RValue<Float> rhs)
+ Float4::Float4(RValue<Float> rhs) : FloatXYZW(this)
{
- xyzw.parent = this;
-
Value *vector = loadValue();
Value *insert = Nucleus::createInsertElement(vector, rhs.value, 0);
storeValue(replicate);
}
- Float4::Float4(const Float &rhs)
+ Float4::Float4(const Float &rhs) : FloatXYZW(this)
{
- xyzw.parent = this;
-
*this = RValue<Float>(rhs.loadValue());
}
- Float4::Float4(const Reference<Float> &rhs)
+ Float4::Float4(const Reference<Float> &rhs) : FloatXYZW(this)
{
- xyzw.parent = this;
-
*this = RValue<Float>(rhs.loadValue());
}
- RValue<Float4> Float4::operator=(float x) const
+ RValue<Float4> Float4::operator=(float x)
{
return *this = Float4(x, x, x, x);
}
- RValue<Float4> Float4::operator=(RValue<Float4> rhs) const
+ RValue<Float4> Float4::operator=(RValue<Float4> rhs)
{
storeValue(rhs.value);
return rhs;
}
- RValue<Float4> Float4::operator=(const Float4 &rhs) const
+ RValue<Float4> Float4::operator=(const Float4 &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<Float4>(value);
}
- RValue<Float4> Float4::operator=(const Reference<Float4> &rhs) const
+ RValue<Float4> Float4::operator=(const Reference<Float4> &rhs)
{
Value *value = rhs.loadValue();
storeValue(value);
return RValue<Float4>(value);
}
- RValue<Float4> Float4::operator=(RValue<Float> rhs) const
+ RValue<Float4> Float4::operator=(RValue<Float> rhs)
{
return *this = Float4(rhs);
}
- RValue<Float4> Float4::operator=(const Float &rhs) const
+ RValue<Float4> Float4::operator=(const Float &rhs)
{
return *this = Float4(rhs);
}
- RValue<Float4> Float4::operator=(const Reference<Float> &rhs) const
+ RValue<Float4> Float4::operator=(const Reference<Float> &rhs)
{
return *this = Float4(rhs);
}
return RValue<Float4>(Nucleus::createFRem(lhs.value, rhs.value));
}
- RValue<Float4> operator+=(const Float4 &lhs, RValue<Float4> rhs)
+ RValue<Float4> operator+=(Float4 &lhs, RValue<Float4> rhs)
{
return lhs = lhs + rhs;
}
- RValue<Float4> operator-=(const Float4 &lhs, RValue<Float4> rhs)
+ RValue<Float4> operator-=(Float4 &lhs, RValue<Float4> rhs)
{
return lhs = lhs - rhs;
}
- RValue<Float4> operator*=(const Float4 &lhs, RValue<Float4> rhs)
+ RValue<Float4> operator*=(Float4 &lhs, RValue<Float4> rhs)
{
return lhs = lhs * rhs;
}
- RValue<Float4> operator/=(const Float4 &lhs, RValue<Float4> rhs)
+ RValue<Float4> operator/=(Float4 &lhs, RValue<Float4> rhs)
{
return lhs = lhs / rhs;
}
- RValue<Float4> operator%=(const Float4 &lhs, RValue<Float4> rhs)
+ RValue<Float4> operator%=(Float4 &lhs, RValue<Float4> rhs)
{
return lhs = lhs % rhs;
}
RValue<Float4> Rcp_pp(RValue<Float4> x, bool exactAtPow2)
{
- if(exactAtPow2)
- {
- // rcpps uses a piecewise-linear approximation which minimizes the relative error
- // but is not exact at power-of-two values. Rectify by multiplying by the inverse.
- return x86::rcpps(x) * Float4(1.0f / _mm_cvtss_f32(_mm_rcp_ss(_mm_set_ps1(1.0f))));
- }
- else
- {
- return x86::rcpps(x);
- }
+ #if defined(__i386__) || defined(__x86_64__)
+ if(exactAtPow2)
+ {
+ // rcpps uses a piecewise-linear approximation which minimizes the relative error
+ // but is not exact at power-of-two values. Rectify by multiplying by the inverse.
+ return x86::rcpps(x) * Float4(1.0f / _mm_cvtss_f32(_mm_rcp_ss(_mm_set_ps1(1.0f))));
+ }
+ #endif
+
+ return x86::rcpps(x);
}
RValue<Float4> RcpSqrt_pp(RValue<Float4> x)
return x86::sqrtps(x);
}
- RValue<Float4> Insert(const Float4 &val, RValue<Float> element, int i)
+ RValue<Float4> Insert(RValue<Float4> val, RValue<Float> element, int i)
{
- Value *value = val.loadValue();
- Value *insert = Nucleus::createInsertElement(value, element.value, i);
-
- val = RValue<Float4>(insert);
-
- return val;
+ return RValue<Float4>(Nucleus::createInsertElement(val.value, element.value, i));
}
RValue<Float> Extract(RValue<Float4> x, int i)
RValue<Float4> Frac(RValue<Float4> x)
{
+ Float4 frc;
+
if(CPUID::supportsSSE4_1())
{
- return x - x86::floorps(x);
+ frc = x - x86::floorps(x);
}
else
{
- Float4 frc = x - Float4(Int4(x)); // Signed fractional part
+ frc = x - Float4(Int4(x)); // Signed fractional part.
- return frc + As<Float4>(As<Int4>(CmpNLE(Float4(0.0f), frc)) & As<Int4>(Float4(1, 1, 1, 1)));
+ frc += As<Float4>(As<Int4>(CmpNLE(Float4(0.0f), frc)) & As<Int4>(Float4(1.0f))); // Add 1.0 if negative.
}
+
+ // x - floor(x) can be 1.0 for very small negative x.
+ // Clamp against the value just below 1.0.
+ return Min(frc, As<Float4>(Int4(0x3F7FFFFF)));
}
RValue<Float4> Floor(RValue<Float4> x)
Type *Float4::getType()
{
- return T(VectorType::get(Float::getType(), 4));
+ return T(llvm::VectorType::get(T(Float::getType()), 4));
}
RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, int offset)
{
- return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value, Byte::getType(), V(Nucleus::createConstantInt(offset))));
+ return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value, Byte::getType(), V(Nucleus::createConstantInt(offset)), false));
}
RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<Int> offset)
{
- return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value, Byte::getType(), offset.value));
+ return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value, Byte::getType(), offset.value, false));
}
RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<UInt> offset)
{
- return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value, Byte::getType(), offset.value));
+ return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value, Byte::getType(), offset.value, true));
}
- RValue<Pointer<Byte>> operator+=(const Pointer<Byte> &lhs, int offset)
+ RValue<Pointer<Byte>> operator+=(Pointer<Byte> &lhs, int offset)
{
return lhs = lhs + offset;
}
- RValue<Pointer<Byte>> operator+=(const Pointer<Byte> &lhs, RValue<Int> offset)
+ RValue<Pointer<Byte>> operator+=(Pointer<Byte> &lhs, RValue<Int> offset)
{
return lhs = lhs + offset;
}
- RValue<Pointer<Byte>> operator+=(const Pointer<Byte> &lhs, RValue<UInt> offset)
+ RValue<Pointer<Byte>> operator+=(Pointer<Byte> &lhs, RValue<UInt> offset)
{
return lhs = lhs + offset;
}
return lhs + -offset;
}
- RValue<Pointer<Byte>> operator-=(const Pointer<Byte> &lhs, int offset)
+ RValue<Pointer<Byte>> operator-=(Pointer<Byte> &lhs, int offset)
{
return lhs = lhs - offset;
}
- RValue<Pointer<Byte>> operator-=(const Pointer<Byte> &lhs, RValue<Int> offset)
+ RValue<Pointer<Byte>> operator-=(Pointer<Byte> &lhs, RValue<Int> offset)
{
return lhs = lhs - offset;
}
- RValue<Pointer<Byte>> operator-=(const Pointer<Byte> &lhs, RValue<UInt> offset)
+ RValue<Pointer<Byte>> operator-=(Pointer<Byte> &lhs, RValue<UInt> offset)
{
return lhs = lhs - offset;
}
Nucleus::createUnreachable();
}
- void Return(bool ret)
+ void Return(RValue<Int> ret)
{
- Nucleus::createRet(V(Nucleus::createConstantBool(ret)));
+ Nucleus::createRet(ret.value);
Nucleus::setInsertBlock(Nucleus::createBasicBlock());
Nucleus::createUnreachable();
}
- void Return(const Int &ret)
- {
- Nucleus::createRet(ret.loadValue());
- Nucleus::setInsertBlock(Nucleus::createBasicBlock());
- Nucleus::createUnreachable();
- }
-
- BasicBlock *beginLoop()
- {
- BasicBlock *loopBB = Nucleus::createBasicBlock();
-
- Nucleus::createBr(loopBB);
- Nucleus::setInsertBlock(loopBB);
-
- return loopBB;
- }
-
- bool branch(RValue<Bool> cmp, BasicBlock *bodyBB, BasicBlock *endBB)
+ void branch(RValue<Bool> cmp, BasicBlock *bodyBB, BasicBlock *endBB)
{
Nucleus::createCondBr(cmp.value, bodyBB, endBB);
Nucleus::setInsertBlock(bodyBB);
-
- return true;
- }
-
- bool elseBlock(BasicBlock *falseBB)
- {
- falseBB->back().eraseFromParent();
- Nucleus::setInsertBlock(falseBB);
-
- return true;
}
RValue<Long> Ticks()
{
- llvm::Function *rdtsc = Intrinsic::getDeclaration(::module, Intrinsic::readcyclecounter);
+ llvm::Function *rdtsc = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::readcyclecounter);
return RValue<Long>(V(::builder->CreateCall(rdtsc)));
}
{
RValue<Int> cvtss2si(RValue<Float> val)
{
- llvm::Function *cvtss2si = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse_cvtss2si);
+ llvm::Function *cvtss2si = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse_cvtss2si);
Float4 vector;
vector.x = val;
RValue<Int2> cvtps2pi(RValue<Float4> val)
{
- llvm::Function *cvtps2pi = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse_cvtps2pi);
+ llvm::Function *cvtps2pi = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse_cvtps2pi);
return RValue<Int2>(V(::builder->CreateCall(cvtps2pi, val.value)));
}
RValue<Int2> cvttps2pi(RValue<Float4> val)
{
- llvm::Function *cvttps2pi = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse_cvttps2pi);
+ llvm::Function *cvttps2pi = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse_cvttps2pi);
return RValue<Int2>(V(::builder->CreateCall(cvttps2pi, val.value)));
}
RValue<Int4> cvtps2dq(RValue<Float4> val)
{
- if(CPUID::supportsSSE2())
- {
- llvm::Function *cvtps2dq = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse2_cvtps2dq);
+ llvm::Function *cvtps2dq = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_cvtps2dq);
- return RValue<Int4>(V(::builder->CreateCall(cvtps2dq, val.value)));
- }
- else
- {
- Int2 lo = x86::cvtps2pi(val);
- Int2 hi = x86::cvtps2pi(Swizzle(val, 0xEE));
-
- return Int4(lo, hi);
- }
+ return RValue<Int4>(V(::builder->CreateCall(cvtps2dq, val.value)));
}
RValue<Float> rcpss(RValue<Float> val)
{
- llvm::Function *rcpss = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse_rcp_ss);
+ llvm::Function *rcpss = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse_rcp_ss);
- Value *vector = Nucleus::createInsertElement(V(UndefValue::get(Float4::getType())), val.value, 0);
+ Value *vector = Nucleus::createInsertElement(V(llvm::UndefValue::get(T(Float4::getType()))), val.value, 0);
return RValue<Float>(Nucleus::createExtractElement(V(::builder->CreateCall(rcpss, vector)), Float::getType(), 0));
}
RValue<Float> sqrtss(RValue<Float> val)
{
- llvm::Function *sqrtss = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse_sqrt_ss);
+ llvm::Function *sqrtss = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse_sqrt_ss);
- Value *vector = Nucleus::createInsertElement(V(UndefValue::get(Float4::getType())), val.value, 0);
+ Value *vector = Nucleus::createInsertElement(V(llvm::UndefValue::get(T(Float4::getType()))), val.value, 0);
return RValue<Float>(Nucleus::createExtractElement(V(::builder->CreateCall(sqrtss, vector)), Float::getType(), 0));
}
RValue<Float> rsqrtss(RValue<Float> val)
{
- llvm::Function *rsqrtss = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse_rsqrt_ss);
+ llvm::Function *rsqrtss = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse_rsqrt_ss);
- Value *vector = Nucleus::createInsertElement(V(UndefValue::get(Float4::getType())), val.value, 0);
+ Value *vector = Nucleus::createInsertElement(V(llvm::UndefValue::get(T(Float4::getType()))), val.value, 0);
return RValue<Float>(Nucleus::createExtractElement(V(::builder->CreateCall(rsqrtss, vector)), Float::getType(), 0));
}
RValue<Float4> rcpps(RValue<Float4> val)
{
- llvm::Function *rcpps = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse_rcp_ps);
+ llvm::Function *rcpps = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse_rcp_ps);
return RValue<Float4>(V(::builder->CreateCall(rcpps, val.value)));
}
RValue<Float4> sqrtps(RValue<Float4> val)
{
- llvm::Function *sqrtps = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse_sqrt_ps);
+ llvm::Function *sqrtps = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse_sqrt_ps);
return RValue<Float4>(V(::builder->CreateCall(sqrtps, val.value)));
}
RValue<Float4> rsqrtps(RValue<Float4> val)
{
- llvm::Function *rsqrtps = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse_rsqrt_ps);
+ llvm::Function *rsqrtps = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse_rsqrt_ps);
return RValue<Float4>(V(::builder->CreateCall(rsqrtps, val.value)));
}
RValue<Float4> maxps(RValue<Float4> x, RValue<Float4> y)
{
- llvm::Function *maxps = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse_max_ps);
+ llvm::Function *maxps = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse_max_ps);
return RValue<Float4>(V(::builder->CreateCall2(maxps, x.value, y.value)));
}
RValue<Float4> minps(RValue<Float4> x, RValue<Float4> y)
{
- llvm::Function *minps = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse_min_ps);
+ llvm::Function *minps = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse_min_ps);
return RValue<Float4>(V(::builder->CreateCall2(minps, x.value, y.value)));
}
RValue<Float> roundss(RValue<Float> val, unsigned char imm)
{
- llvm::Function *roundss = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse41_round_ss);
+ llvm::Function *roundss = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse41_round_ss);
- Value *undef = V(UndefValue::get(Float4::getType()));
+ Value *undef = V(llvm::UndefValue::get(T(Float4::getType())));
Value *vector = Nucleus::createInsertElement(undef, val.value, 0);
return RValue<Float>(Nucleus::createExtractElement(V(::builder->CreateCall3(roundss, undef, vector, V(Nucleus::createConstantInt(imm)))), Float::getType(), 0));
RValue<Float4> roundps(RValue<Float4> val, unsigned char imm)
{
- llvm::Function *roundps = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse41_round_ps);
+ llvm::Function *roundps = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse41_round_ps);
return RValue<Float4>(V(::builder->CreateCall2(roundps, val.value, V(Nucleus::createConstantInt(imm)))));
}
RValue<Float4> cmpps(RValue<Float4> x, RValue<Float4> y, unsigned char imm)
{
- llvm::Function *cmpps = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse_cmp_ps);
+ llvm::Function *cmpps = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse_cmp_ps);
return RValue<Float4>(V(::builder->CreateCall3(cmpps, x.value, y.value, V(Nucleus::createConstantByte(imm)))));
}
RValue<Float> cmpss(RValue<Float> x, RValue<Float> y, unsigned char imm)
{
- llvm::Function *cmpss = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse_cmp_ss);
+ llvm::Function *cmpss = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse_cmp_ss);
- Value *vector1 = Nucleus::createInsertElement(V(UndefValue::get(Float4::getType())), x.value, 0);
- Value *vector2 = Nucleus::createInsertElement(V(UndefValue::get(Float4::getType())), y.value, 0);
+ Value *vector1 = Nucleus::createInsertElement(V(llvm::UndefValue::get(T(Float4::getType()))), x.value, 0);
+ Value *vector2 = Nucleus::createInsertElement(V(llvm::UndefValue::get(T(Float4::getType()))), y.value, 0);
return RValue<Float>(Nucleus::createExtractElement(V(::builder->CreateCall3(cmpss, vector1, vector2, V(Nucleus::createConstantByte(imm)))), Float::getType(), 0));
}
RValue<Int4> pabsd(RValue<Int4> x)
{
- llvm::Function *pabsd = Intrinsic::getDeclaration(::module, Intrinsic::x86_ssse3_pabs_d_128);
+ llvm::Function *pabsd = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_ssse3_pabs_d_128);
return RValue<Int4>(V(::builder->CreateCall(pabsd, x.value)));
}
RValue<Short4> paddsw(RValue<Short4> x, RValue<Short4> y)
{
- llvm::Function *paddsw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_padds_w);
+ llvm::Function *paddsw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_padds_w);
- return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(paddsw, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<Short4>(V(::builder->CreateCall2(paddsw, As<MMX>(x).value, As<MMX>(y).value)));
}
RValue<Short4> psubsw(RValue<Short4> x, RValue<Short4> y)
{
- llvm::Function *psubsw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psubs_w);
+ llvm::Function *psubsw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_psubs_w);
- return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(psubsw, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<Short4>(V(::builder->CreateCall2(psubsw, As<MMX>(x).value, As<MMX>(y).value)));
}
RValue<UShort4> paddusw(RValue<UShort4> x, RValue<UShort4> y)
{
- llvm::Function *paddusw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_paddus_w);
+ llvm::Function *paddusw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_paddus_w);
- return As<UShort4>(RValue<MMX>(V(::builder->CreateCall2(paddusw, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<UShort4>(V(::builder->CreateCall2(paddusw, As<MMX>(x).value, As<MMX>(y).value)));
}
RValue<UShort4> psubusw(RValue<UShort4> x, RValue<UShort4> y)
{
- llvm::Function *psubusw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psubus_w);
+ llvm::Function *psubusw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_psubus_w);
- return As<UShort4>(RValue<MMX>(V(::builder->CreateCall2(psubusw, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<UShort4>(V(::builder->CreateCall2(psubusw, As<MMX>(x).value, As<MMX>(y).value)));
}
RValue<SByte8> paddsb(RValue<SByte8> x, RValue<SByte8> y)
{
- llvm::Function *paddsb = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_padds_b);
+ llvm::Function *paddsb = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_padds_b);
- return As<SByte8>(RValue<MMX>(V(::builder->CreateCall2(paddsb, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<SByte8>(V(::builder->CreateCall2(paddsb, As<MMX>(x).value, As<MMX>(y).value)));
}
RValue<SByte8> psubsb(RValue<SByte8> x, RValue<SByte8> y)
{
- llvm::Function *psubsb = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psubs_b);
+ llvm::Function *psubsb = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_psubs_b);
- return As<SByte8>(RValue<MMX>(V(::builder->CreateCall2(psubsb, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<SByte8>(V(::builder->CreateCall2(psubsb, As<MMX>(x).value, As<MMX>(y).value)));
}
RValue<Byte8> paddusb(RValue<Byte8> x, RValue<Byte8> y)
{
- llvm::Function *paddusb = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_paddus_b);
+ llvm::Function *paddusb = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_paddus_b);
- return As<Byte8>(RValue<MMX>(V(::builder->CreateCall2(paddusb, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<Byte8>(V(::builder->CreateCall2(paddusb, As<MMX>(x).value, As<MMX>(y).value)));
}
RValue<Byte8> psubusb(RValue<Byte8> x, RValue<Byte8> y)
{
- llvm::Function *psubusb = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psubus_b);
+ llvm::Function *psubusb = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_psubus_b);
- return As<Byte8>(RValue<MMX>(V(::builder->CreateCall2(psubusb, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<Byte8>(V(::builder->CreateCall2(psubusb, As<MMX>(x).value, As<MMX>(y).value)));
}
RValue<Short4> paddw(RValue<Short4> x, RValue<Short4> y)
{
- llvm::Function *paddw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_padd_w);
+ llvm::Function *paddw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_padd_w);
- return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(paddw, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<Short4>(V(::builder->CreateCall2(paddw, As<MMX>(x).value, As<MMX>(y).value)));
}
RValue<Short4> psubw(RValue<Short4> x, RValue<Short4> y)
{
- llvm::Function *psubw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psub_w);
+ llvm::Function *psubw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_psub_w);
- return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(psubw, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<Short4>(V(::builder->CreateCall2(psubw, As<MMX>(x).value, As<MMX>(y).value)));
}
RValue<Short4> pmullw(RValue<Short4> x, RValue<Short4> y)
{
- llvm::Function *pmullw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pmull_w);
+ llvm::Function *pmullw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_pmull_w);
- return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(pmullw, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<Short4>(V(::builder->CreateCall2(pmullw, As<MMX>(x).value, As<MMX>(y).value)));
}
RValue<Short4> pand(RValue<Short4> x, RValue<Short4> y)
{
- llvm::Function *pand = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pand);
+ llvm::Function *pand = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_pand);
- return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(pand, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<Short4>(V(::builder->CreateCall2(pand, As<MMX>(x).value, As<MMX>(y).value)));
}
RValue<Short4> por(RValue<Short4> x, RValue<Short4> y)
{
- llvm::Function *por = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_por);
+ llvm::Function *por = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_por);
- return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(por, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<Short4>(V(::builder->CreateCall2(por, As<MMX>(x).value, As<MMX>(y).value)));
}
RValue<Short4> pxor(RValue<Short4> x, RValue<Short4> y)
{
- llvm::Function *pxor = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pxor);
+ llvm::Function *pxor = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_pxor);
- return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(pxor, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<Short4>(V(::builder->CreateCall2(pxor, As<MMX>(x).value, As<MMX>(y).value)));
}
RValue<Short4> pshufw(RValue<Short4> x, unsigned char y)
{
- llvm::Function *pshufw = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse_pshuf_w);
+ llvm::Function *pshufw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse_pshuf_w);
- return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(pshufw, As<MMX>(x).value, V(Nucleus::createConstantByte(y))))));
+ return As<Short4>(V(::builder->CreateCall2(pshufw, As<MMX>(x).value, V(Nucleus::createConstantByte(y)))));
}
RValue<Int2> punpcklwd(RValue<Short4> x, RValue<Short4> y)
{
- llvm::Function *punpcklwd = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_punpcklwd);
+ llvm::Function *punpcklwd = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_punpcklwd);
- return As<Int2>(RValue<MMX>(V(::builder->CreateCall2(punpcklwd, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<Int2>(V(::builder->CreateCall2(punpcklwd, As<MMX>(x).value, As<MMX>(y).value)));
}
RValue<Int2> punpckhwd(RValue<Short4> x, RValue<Short4> y)
{
- llvm::Function *punpckhwd = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_punpckhwd);
+ llvm::Function *punpckhwd = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_punpckhwd);
- return As<Int2>(RValue<MMX>(V(::builder->CreateCall2(punpckhwd, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<Int2>(V(::builder->CreateCall2(punpckhwd, As<MMX>(x).value, As<MMX>(y).value)));
}
RValue<Short4> pinsrw(RValue<Short4> x, RValue<Int> y, unsigned int i)
{
- llvm::Function *pinsrw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pinsr_w);
+ llvm::Function *pinsrw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_pinsr_w);
- return As<Short4>(RValue<MMX>(V(::builder->CreateCall3(pinsrw, As<MMX>(x).value, y.value, V(Nucleus::createConstantInt(i))))));
+ return As<Short4>(V(::builder->CreateCall3(pinsrw, As<MMX>(x).value, y.value, V(Nucleus::createConstantInt(i)))));
}
RValue<Int> pextrw(RValue<Short4> x, unsigned int i)
{
- llvm::Function *pextrw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pextr_w);
+ llvm::Function *pextrw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_pextr_w);
return RValue<Int>(V(::builder->CreateCall2(pextrw, As<MMX>(x).value, V(Nucleus::createConstantInt(i)))));
}
- RValue<Long1> punpckldq(RValue<Int2> x, RValue<Int2> y)
+ RValue<Short4> punpckldq(RValue<Int2> x, RValue<Int2> y)
{
- llvm::Function *punpckldq = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_punpckldq);
+ llvm::Function *punpckldq = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_punpckldq);
- return As<Long1>(RValue<MMX>(V(::builder->CreateCall2(punpckldq, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<Short4>(V(::builder->CreateCall2(punpckldq, As<MMX>(x).value, As<MMX>(y).value)));
}
- RValue<Long1> punpckhdq(RValue<Int2> x, RValue<Int2> y)
+ RValue<Short4> punpckhdq(RValue<Int2> x, RValue<Int2> y)
{
- llvm::Function *punpckhdq = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_punpckhdq);
+ llvm::Function *punpckhdq = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_punpckhdq);
- return As<Long1>(RValue<MMX>(V(::builder->CreateCall2(punpckhdq, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<Short4>(V(::builder->CreateCall2(punpckhdq, As<MMX>(x).value, As<MMX>(y).value)));
}
RValue<Short4> punpcklbw(RValue<Byte8> x, RValue<Byte8> y)
{
- llvm::Function *punpcklbw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_punpcklbw);
+ llvm::Function *punpcklbw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_punpcklbw);
- return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(punpcklbw, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<Short4>(V(::builder->CreateCall2(punpcklbw, As<MMX>(x).value, As<MMX>(y).value)));
}
RValue<Short4> punpckhbw(RValue<Byte8> x, RValue<Byte8> y)
{
- llvm::Function *punpckhbw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_punpckhbw);
+ llvm::Function *punpckhbw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_punpckhbw);
- return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(punpckhbw, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<Short4>(V(::builder->CreateCall2(punpckhbw, As<MMX>(x).value, As<MMX>(y).value)));
}
RValue<Byte8> paddb(RValue<Byte8> x, RValue<Byte8> y)
{
- llvm::Function *paddb = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_padd_b);
+ llvm::Function *paddb = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_padd_b);
- return As<Byte8>(RValue<MMX>(V(::builder->CreateCall2(paddb, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<Byte8>(V(::builder->CreateCall2(paddb, As<MMX>(x).value, As<MMX>(y).value)));
}
RValue<Byte8> psubb(RValue<Byte8> x, RValue<Byte8> y)
{
- llvm::Function *psubb = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psub_b);
+ llvm::Function *psubb = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_psub_b);
- return As<Byte8>(RValue<MMX>(V(::builder->CreateCall2(psubb, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<Byte8>(V(::builder->CreateCall2(psubb, As<MMX>(x).value, As<MMX>(y).value)));
}
RValue<Int2> paddd(RValue<Int2> x, RValue<Int2> y)
{
- llvm::Function *paddd = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_padd_d);
+ llvm::Function *paddd = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_padd_d);
- return As<Int2>(RValue<MMX>(V(::builder->CreateCall2(paddd, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<Int2>(V(::builder->CreateCall2(paddd, As<MMX>(x).value, As<MMX>(y).value)));
}
RValue<Int2> psubd(RValue<Int2> x, RValue<Int2> y)
{
- llvm::Function *psubd = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psub_d);
+ llvm::Function *psubd = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_psub_d);
- return As<Int2>(RValue<MMX>(V(::builder->CreateCall2(psubd, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<Int2>(V(::builder->CreateCall2(psubd, As<MMX>(x).value, As<MMX>(y).value)));
}
RValue<UShort4> pavgw(RValue<UShort4> x, RValue<UShort4> y)
{
- llvm::Function *pavgw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pavg_w);
+ llvm::Function *pavgw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_pavg_w);
- return As<UShort4>(RValue<MMX>(V(::builder->CreateCall2(pavgw, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<UShort4>(V(::builder->CreateCall2(pavgw, As<MMX>(x).value, As<MMX>(y).value)));
}
RValue<Short4> pmaxsw(RValue<Short4> x, RValue<Short4> y)
{
- llvm::Function *pmaxsw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pmaxs_w);
+ llvm::Function *pmaxsw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_pmaxs_w);
- return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(pmaxsw, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<Short4>(V(::builder->CreateCall2(pmaxsw, As<MMX>(x).value, As<MMX>(y).value)));
}
RValue<Short4> pminsw(RValue<Short4> x, RValue<Short4> y)
{
- llvm::Function *pminsw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pmins_w);
+ llvm::Function *pminsw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_pmins_w);
- return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(pminsw, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<Short4>(V(::builder->CreateCall2(pminsw, As<MMX>(x).value, As<MMX>(y).value)));
}
RValue<Short4> pcmpgtw(RValue<Short4> x, RValue<Short4> y)
{
- llvm::Function *pcmpgtw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pcmpgt_w);
+ llvm::Function *pcmpgtw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_pcmpgt_w);
- return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(pcmpgtw, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<Short4>(V(::builder->CreateCall2(pcmpgtw, As<MMX>(x).value, As<MMX>(y).value)));
}
RValue<Short4> pcmpeqw(RValue<Short4> x, RValue<Short4> y)
{
- llvm::Function *pcmpeqw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pcmpeq_w);
+ llvm::Function *pcmpeqw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_pcmpeq_w);
- return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(pcmpeqw, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<Short4>(V(::builder->CreateCall2(pcmpeqw, As<MMX>(x).value, As<MMX>(y).value)));
}
RValue<Byte8> pcmpgtb(RValue<SByte8> x, RValue<SByte8> y)
{
- llvm::Function *pcmpgtb = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pcmpgt_b);
+ llvm::Function *pcmpgtb = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_pcmpgt_b);
- return As<Byte8>(RValue<MMX>(V(::builder->CreateCall2(pcmpgtb, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<Byte8>(V(::builder->CreateCall2(pcmpgtb, As<MMX>(x).value, As<MMX>(y).value)));
}
RValue<Byte8> pcmpeqb(RValue<Byte8> x, RValue<Byte8> y)
{
- llvm::Function *pcmpeqb = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pcmpeq_b);
+ llvm::Function *pcmpeqb = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_pcmpeq_b);
- return As<Byte8>(RValue<MMX>(V(::builder->CreateCall2(pcmpeqb, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<Byte8>(V(::builder->CreateCall2(pcmpeqb, As<MMX>(x).value, As<MMX>(y).value)));
}
RValue<Short4> packssdw(RValue<Int2> x, RValue<Int2> y)
{
- llvm::Function *packssdw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_packssdw);
+ llvm::Function *packssdw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_packssdw);
- return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(packssdw, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<Short4>(V(::builder->CreateCall2(packssdw, As<MMX>(x).value, As<MMX>(y).value)));
}
RValue<Short8> packssdw(RValue<Int4> x, RValue<Int4> y)
{
- if(CPUID::supportsSSE2())
- {
- llvm::Function *packssdw = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse2_packssdw_128);
-
- return RValue<Short8>(V(::builder->CreateCall2(packssdw, x.value, y.value)));
- }
- else
- {
- Int2 loX = Int2(x);
- Int2 hiX = Int2(Swizzle(x, 0xEE));
+ llvm::Function *packssdw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_packssdw_128);
- Int2 loY = Int2(y);
- Int2 hiY = Int2(Swizzle(y, 0xEE));
-
- Short4 lo = x86::packssdw(loX, hiX);
- Short4 hi = x86::packssdw(loY, hiY);
-
- return Short8(lo, hi);
- }
+ return RValue<Short8>(V(::builder->CreateCall2(packssdw, x.value, y.value)));
}
RValue<SByte8> packsswb(RValue<Short4> x, RValue<Short4> y)
{
- llvm::Function *packsswb = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_packsswb);
+ llvm::Function *packsswb = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_packsswb);
- return As<SByte8>(RValue<MMX>(V(::builder->CreateCall2(packsswb, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<SByte8>(V(::builder->CreateCall2(packsswb, As<MMX>(x).value, As<MMX>(y).value)));
}
RValue<Byte8> packuswb(RValue<UShort4> x, RValue<UShort4> y)
{
- llvm::Function *packuswb = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_packuswb);
+ llvm::Function *packuswb = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_packuswb);
- return As<Byte8>(RValue<MMX>(V(::builder->CreateCall2(packuswb, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<Byte8>(V(::builder->CreateCall2(packuswb, As<MMX>(x).value, As<MMX>(y).value)));
}
- RValue<UShort8> packusdw(RValue<UInt4> x, RValue<UInt4> y)
+ RValue<UShort8> packusdw(RValue<Int4> x, RValue<Int4> y)
{
if(CPUID::supportsSSE4_1())
{
- llvm::Function *packusdw = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse41_packusdw);
+ llvm::Function *packusdw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse41_packusdw);
return RValue<UShort8>(V(::builder->CreateCall2(packusdw, x.value, y.value)));
}
else
{
- // FIXME: Not an exact replacement!
- 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));
+ RValue<Int4> bx = (x & ~(x >> 31)) - Int4(0x8000);
+ RValue<Int4> by = (y & ~(y >> 31)) - Int4(0x8000);
+
+ return As<UShort8>(packssdw(bx, by) + Short8(0x8000u));
}
}
RValue<UShort4> psrlw(RValue<UShort4> x, unsigned char y)
{
- llvm::Function *psrlw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psrli_w);
+ llvm::Function *psrlw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_psrli_w);
- return As<UShort4>(RValue<MMX>(V(::builder->CreateCall2(psrlw, As<MMX>(x).value, V(Nucleus::createConstantInt(y))))));
+ return As<UShort4>(V(::builder->CreateCall2(psrlw, As<MMX>(x).value, V(Nucleus::createConstantInt(y)))));
}
RValue<UShort8> psrlw(RValue<UShort8> x, unsigned char y)
{
- llvm::Function *psrlw = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse2_psrli_w);
+ llvm::Function *psrlw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_psrli_w);
return RValue<UShort8>(V(::builder->CreateCall2(psrlw, x.value, V(Nucleus::createConstantInt(y)))));
}
RValue<Short4> psraw(RValue<Short4> x, unsigned char y)
{
- llvm::Function *psraw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psrai_w);
+ llvm::Function *psraw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_psrai_w);
- return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(psraw, As<MMX>(x).value, V(Nucleus::createConstantInt(y))))));
+ return As<Short4>(V(::builder->CreateCall2(psraw, As<MMX>(x).value, V(Nucleus::createConstantInt(y)))));
}
RValue<Short8> psraw(RValue<Short8> x, unsigned char y)
{
- llvm::Function *psraw = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse2_psrai_w);
+ llvm::Function *psraw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_psrai_w);
return RValue<Short8>(V(::builder->CreateCall2(psraw, x.value, V(Nucleus::createConstantInt(y)))));
}
RValue<Short4> psllw(RValue<Short4> x, unsigned char y)
{
- llvm::Function *psllw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pslli_w);
+ llvm::Function *psllw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_pslli_w);
- return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(psllw, As<MMX>(x).value, V(Nucleus::createConstantInt(y))))));
+ return As<Short4>(V(::builder->CreateCall2(psllw, As<MMX>(x).value, V(Nucleus::createConstantInt(y)))));
}
RValue<Short8> psllw(RValue<Short8> x, unsigned char y)
{
- llvm::Function *psllw = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse2_pslli_w);
+ llvm::Function *psllw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_pslli_w);
return RValue<Short8>(V(::builder->CreateCall2(psllw, x.value, V(Nucleus::createConstantInt(y)))));
}
RValue<Int2> pslld(RValue<Int2> x, unsigned char y)
{
- llvm::Function *pslld = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pslli_d);
+ llvm::Function *pslld = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_pslli_d);
- return As<Int2>(RValue<MMX>(V(::builder->CreateCall2(pslld, As<MMX>(x).value, V(Nucleus::createConstantInt(y))))));
+ return As<Int2>(V(::builder->CreateCall2(pslld, As<MMX>(x).value, V(Nucleus::createConstantInt(y)))));
}
RValue<Int4> pslld(RValue<Int4> x, unsigned char y)
{
- if(CPUID::supportsSSE2())
- {
- llvm::Function *pslld = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse2_pslli_d);
+ llvm::Function *pslld = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_pslli_d);
- return RValue<Int4>(V(::builder->CreateCall2(pslld, x.value, V(Nucleus::createConstantInt(y)))));
- }
- else
- {
- Int2 lo = Int2(x);
- Int2 hi = Int2(Swizzle(x, 0xEE));
-
- lo = x86::pslld(lo, y);
- hi = x86::pslld(hi, y);
-
- return Int4(lo, hi);
- }
+ return RValue<Int4>(V(::builder->CreateCall2(pslld, x.value, V(Nucleus::createConstantInt(y)))));
}
RValue<Int2> psrad(RValue<Int2> x, unsigned char y)
{
- llvm::Function *psrad = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psrai_d);
+ llvm::Function *psrad = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_psrai_d);
- return As<Int2>(RValue<MMX>(V(::builder->CreateCall2(psrad, As<MMX>(x).value, V(Nucleus::createConstantInt(y))))));
+ return As<Int2>(V(::builder->CreateCall2(psrad, As<MMX>(x).value, V(Nucleus::createConstantInt(y)))));
}
RValue<Int4> psrad(RValue<Int4> x, unsigned char y)
{
- if(CPUID::supportsSSE2())
- {
- llvm::Function *psrad = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse2_psrai_d);
-
- return RValue<Int4>(V(::builder->CreateCall2(psrad, x.value, V(Nucleus::createConstantInt(y)))));
- }
- else
- {
- Int2 lo = Int2(x);
- Int2 hi = Int2(Swizzle(x, 0xEE));
+ llvm::Function *psrad = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_psrai_d);
- lo = x86::psrad(lo, y);
- hi = x86::psrad(hi, y);
-
- return Int4(lo, hi);
- }
+ return RValue<Int4>(V(::builder->CreateCall2(psrad, x.value, V(Nucleus::createConstantInt(y)))));
}
RValue<UInt2> psrld(RValue<UInt2> x, unsigned char y)
{
- llvm::Function *psrld = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psrli_d);
+ llvm::Function *psrld = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_psrli_d);
- return As<UInt2>(RValue<MMX>(V(::builder->CreateCall2(psrld, As<MMX>(x).value, V(Nucleus::createConstantInt(y))))));
+ return As<UInt2>(V(::builder->CreateCall2(psrld, As<MMX>(x).value, V(Nucleus::createConstantInt(y)))));
}
RValue<UInt4> psrld(RValue<UInt4> x, unsigned char y)
{
- if(CPUID::supportsSSE2())
- {
- llvm::Function *psrld = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse2_psrli_d);
-
- return RValue<UInt4>(V(::builder->CreateCall2(psrld, x.value, V(Nucleus::createConstantInt(y)))));
- }
- else
- {
- UInt2 lo = As<UInt2>(Int2(As<Int4>(x)));
- UInt2 hi = As<UInt2>(Int2(Swizzle(As<Int4>(x), 0xEE)));
-
- lo = x86::psrld(lo, y);
- hi = x86::psrld(hi, y);
-
- return UInt4(lo, hi);
- }
- }
-
- RValue<UShort4> psrlw(RValue<UShort4> x, RValue<Long1> y)
- {
- llvm::Function *psrlw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psrl_w);
-
- return As<UShort4>(RValue<MMX>(V(::builder->CreateCall2(psrlw, As<MMX>(x).value, As<MMX>(y).value))));
- }
-
- RValue<Short4> psraw(RValue<Short4> x, RValue<Long1> y)
- {
- llvm::Function *psraw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psra_w);
-
- return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(psraw, As<MMX>(x).value, As<MMX>(y).value))));
- }
-
- RValue<Short4> psllw(RValue<Short4> x, RValue<Long1> y)
- {
- llvm::Function *psllw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psll_w);
-
- return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(psllw, As<MMX>(x).value, As<MMX>(y).value))));
- }
-
- RValue<Int2> pslld(RValue<Int2> x, RValue<Long1> y)
- {
- llvm::Function *pslld = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psll_d);
-
- return As<Int2>(RValue<MMX>(V(::builder->CreateCall2(pslld, As<MMX>(x).value, As<MMX>(y).value))));
- }
-
- RValue<UInt2> psrld(RValue<UInt2> x, RValue<Long1> y)
- {
- llvm::Function *psrld = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psrl_d);
-
- return As<UInt2>(RValue<MMX>(V(::builder->CreateCall2(psrld, As<MMX>(x).value, As<MMX>(y).value))));
- }
-
- RValue<Int2> psrad(RValue<Int2> x, RValue<Long1> y)
- {
- llvm::Function *psrld = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psra_d);
+ llvm::Function *psrld = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_psrli_d);
- return As<Int2>(RValue<MMX>(V(::builder->CreateCall2(psrld, As<MMX>(x).value, As<MMX>(y).value))));
+ return RValue<UInt4>(V(::builder->CreateCall2(psrld, x.value, V(Nucleus::createConstantInt(y)))));
}
RValue<Int4> pmaxsd(RValue<Int4> x, RValue<Int4> y)
{
- llvm::Function *pmaxsd = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse41_pmaxsd);
+ llvm::Function *pmaxsd = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse41_pmaxsd);
return RValue<Int4>(V(::builder->CreateCall2(pmaxsd, x.value, y.value)));
}
RValue<Int4> pminsd(RValue<Int4> x, RValue<Int4> y)
{
- llvm::Function *pminsd = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse41_pminsd);
+ llvm::Function *pminsd = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse41_pminsd);
return RValue<Int4>(V(::builder->CreateCall2(pminsd, x.value, y.value)));
}
RValue<UInt4> pmaxud(RValue<UInt4> x, RValue<UInt4> y)
{
- llvm::Function *pmaxud = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse41_pmaxud);
+ llvm::Function *pmaxud = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse41_pmaxud);
return RValue<UInt4>(V(::builder->CreateCall2(pmaxud, x.value, y.value)));
}
RValue<UInt4> pminud(RValue<UInt4> x, RValue<UInt4> y)
{
- llvm::Function *pminud = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse41_pminud);
+ llvm::Function *pminud = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse41_pminud);
return RValue<UInt4>(V(::builder->CreateCall2(pminud, x.value, y.value)));
}
RValue<Short4> pmulhw(RValue<Short4> x, RValue<Short4> y)
{
- llvm::Function *pmulhw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pmulh_w);
+ llvm::Function *pmulhw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_pmulh_w);
- return As<Short4>(RValue<MMX>(V(::builder->CreateCall2(pmulhw, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<Short4>(V(::builder->CreateCall2(pmulhw, As<MMX>(x).value, As<MMX>(y).value)));
}
RValue<UShort4> pmulhuw(RValue<UShort4> x, RValue<UShort4> y)
{
- llvm::Function *pmulhuw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pmulhu_w);
+ llvm::Function *pmulhuw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_pmulhu_w);
- return As<UShort4>(RValue<MMX>(V(::builder->CreateCall2(pmulhuw, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<UShort4>(V(::builder->CreateCall2(pmulhuw, As<MMX>(x).value, As<MMX>(y).value)));
}
RValue<Int2> pmaddwd(RValue<Short4> x, RValue<Short4> y)
{
- llvm::Function *pmaddwd = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pmadd_wd);
+ llvm::Function *pmaddwd = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_pmadd_wd);
- return As<Int2>(RValue<MMX>(V(::builder->CreateCall2(pmaddwd, As<MMX>(x).value, As<MMX>(y).value))));
+ return As<Int2>(V(::builder->CreateCall2(pmaddwd, As<MMX>(x).value, As<MMX>(y).value)));
}
RValue<Short8> pmulhw(RValue<Short8> x, RValue<Short8> y)
{
- llvm::Function *pmulhw = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse2_pmulh_w);
+ llvm::Function *pmulhw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_pmulh_w);
return RValue<Short8>(V(::builder->CreateCall2(pmulhw, x.value, y.value)));
}
RValue<UShort8> pmulhuw(RValue<UShort8> x, RValue<UShort8> y)
{
- llvm::Function *pmulhuw = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse2_pmulhu_w);
+ llvm::Function *pmulhuw = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_pmulhu_w);
return RValue<UShort8>(V(::builder->CreateCall2(pmulhuw, x.value, y.value)));
}
RValue<Int4> pmaddwd(RValue<Short8> x, RValue<Short8> y)
{
- llvm::Function *pmaddwd = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse2_pmadd_wd);
+ llvm::Function *pmaddwd = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse2_pmadd_wd);
return RValue<Int4>(V(::builder->CreateCall2(pmaddwd, x.value, y.value)));
}
RValue<Int> movmskps(RValue<Float4> x)
{
- llvm::Function *movmskps = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse_movmsk_ps);
+ llvm::Function *movmskps = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse_movmsk_ps);
return RValue<Int>(V(::builder->CreateCall(movmskps, x.value)));
}
RValue<Int> pmovmskb(RValue<Byte8> x)
{
- llvm::Function *pmovmskb = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_pmovmskb);
+ llvm::Function *pmovmskb = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_pmovmskb);
return RValue<Int>(V(::builder->CreateCall(pmovmskb, As<MMX>(x).value)));
}
// Value *element = Nucleus::createLoad(x.value);
//// Value *int2 = UndefValue::get(Int2::getType());
- //// int2 = Nucleus::createInsertElement(int2, element, ConstantInt::get(Int::getType(), 0));
+ //// int2 = Nucleus::createInsertElement(int2, element, ConstantInt::get(T(Int::getType()), 0));
// Value *int2 = Nucleus::createBitCast(Nucleus::createZExt(element, Long::getType()), Int2::getType());
//RValue<Int2> movdq2q(RValue<Int4> x)
//{
- // Value *long2 = Nucleus::createBitCast(x.value, Long2::getType());
- // Value *element = Nucleus::createExtractElement(long2, ConstantInt::get(Int::getType(), 0));
+ // Value *long2 = Nucleus::createBitCast(x.value, T(llvm::VectorType::get(T(Long::getType()), 2)));
+ // Value *element = Nucleus::createExtractElement(long2, ConstantInt::get(T(Int::getType()), 0));
// return RValue<Int2>(Nucleus::createBitCast(element, Int2::getType()));
//}
RValue<Int4> pmovzxbd(RValue<Int4> x)
{
- llvm::Function *pmovzxbd = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse41_pmovzxbd);
+ llvm::Function *pmovzxbd = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse41_pmovzxbd);
return RValue<Int4>(V(::builder->CreateCall(pmovzxbd, Nucleus::createBitCast(x.value, Byte16::getType()))));
}
RValue<Int4> pmovsxbd(RValue<Int4> x)
{
- llvm::Function *pmovsxbd = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse41_pmovsxbd);
+ llvm::Function *pmovsxbd = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse41_pmovsxbd);
return RValue<Int4>(V(::builder->CreateCall(pmovsxbd, Nucleus::createBitCast(x.value, SByte16::getType()))));
}
RValue<Int4> pmovzxwd(RValue<Int4> x)
{
- llvm::Function *pmovzxwd = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse41_pmovzxwd);
+ llvm::Function *pmovzxwd = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse41_pmovzxwd);
return RValue<Int4>(V(::builder->CreateCall(pmovzxwd, Nucleus::createBitCast(x.value, UShort8::getType()))));
}
RValue<Int4> pmovsxwd(RValue<Int4> x)
{
- llvm::Function *pmovsxwd = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse41_pmovsxwd);
+ llvm::Function *pmovsxwd = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_sse41_pmovsxwd);
return RValue<Int4>(V(::builder->CreateCall(pmovsxwd, Nucleus::createBitCast(x.value, Short8::getType()))));
}
void emms()
{
- llvm::Function *emms = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_emms);
+ llvm::Function *emms = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::x86_mmx_emms);
V(::builder->CreateCall(emms));
}