2016-09-26 07:00:19 +00:00
|
|
|
|
2016-10-01 09:47:21 +00:00
|
|
|
#include "r_compiler/llvm_include.h"
|
2016-09-26 07:00:19 +00:00
|
|
|
#include "ssa_vec4f_ptr.h"
|
|
|
|
#include "ssa_scope.h"
|
|
|
|
|
|
|
|
SSAVec4fPtr::SSAVec4fPtr()
|
|
|
|
: v(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SSAVec4fPtr::SSAVec4fPtr(llvm::Value *v)
|
|
|
|
: v(v)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
llvm::Type *SSAVec4fPtr::llvm_type()
|
|
|
|
{
|
|
|
|
return llvm::VectorType::get(llvm::Type::getFloatTy(SSAScope::context()), 4)->getPointerTo();
|
|
|
|
}
|
|
|
|
|
|
|
|
SSAVec4fPtr SSAVec4fPtr::operator[](SSAInt index) const
|
|
|
|
{
|
|
|
|
return SSAVec4fPtr::from_llvm(SSAScope::builder().CreateGEP(v, index.v, SSAScope::hint()));
|
|
|
|
}
|
|
|
|
|
2016-10-08 07:29:26 +00:00
|
|
|
SSAVec4f SSAVec4fPtr::load(bool constantScopeDomain) const
|
2016-09-26 07:00:19 +00:00
|
|
|
{
|
2016-10-08 07:29:26 +00:00
|
|
|
auto loadInst = SSAScope::builder().CreateLoad(v, false, SSAScope::hint());
|
|
|
|
if (constantScopeDomain)
|
|
|
|
loadInst->setMetadata(llvm::LLVMContext::MD_alias_scope, SSAScope::constant_scope_list());
|
|
|
|
return SSAVec4f::from_llvm(loadInst);
|
2016-09-26 07:00:19 +00:00
|
|
|
}
|
|
|
|
|
2016-10-08 07:29:26 +00:00
|
|
|
SSAVec4f SSAVec4fPtr::load_unaligned(bool constantScopeDomain) const
|
2016-09-26 07:00:19 +00:00
|
|
|
{
|
2016-10-08 07:29:26 +00:00
|
|
|
auto loadInst = SSAScope::builder().CreateAlignedLoad(v, 4, false, SSAScope::hint());
|
|
|
|
if (constantScopeDomain)
|
|
|
|
loadInst->setMetadata(llvm::LLVMContext::MD_alias_scope, SSAScope::constant_scope_list());
|
|
|
|
return SSAVec4f::from_llvm(loadInst);
|
2016-09-26 07:00:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SSAVec4fPtr::store(const SSAVec4f &new_value)
|
|
|
|
{
|
2016-10-08 07:29:26 +00:00
|
|
|
auto inst = SSAScope::builder().CreateStore(new_value.v, v, false);
|
|
|
|
inst->setMetadata(llvm::LLVMContext::MD_noalias, SSAScope::constant_scope_list());
|
2016-09-26 07:00:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SSAVec4fPtr::store_unaligned(const SSAVec4f &new_value)
|
|
|
|
{
|
2016-10-08 07:29:26 +00:00
|
|
|
auto inst = SSAScope::builder().CreateAlignedStore(new_value.v, v, 4, false);
|
|
|
|
inst->setMetadata(llvm::LLVMContext::MD_noalias, SSAScope::constant_scope_list());
|
2016-09-26 07:00:19 +00:00
|
|
|
}
|