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_value.h"
|
|
|
|
#include "ssa_int.h"
|
|
|
|
#include "ssa_scope.h"
|
|
|
|
|
2016-10-08 07:29:26 +00:00
|
|
|
SSAValue SSAValue::load(bool constantScopeDomain)
|
2016-09-26 07:00:19 +00:00
|
|
|
{
|
2016-10-08 07:29:26 +00:00
|
|
|
auto loadInst = SSAScope::builder().CreateLoad(v, false);
|
|
|
|
if (constantScopeDomain)
|
|
|
|
loadInst->setMetadata(llvm::LLVMContext::MD_alias_scope, SSAScope::constant_scope_list());
|
|
|
|
return SSAValue::from_llvm(loadInst);
|
2016-09-26 07:00:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SSAValue::store(llvm::Value *value)
|
|
|
|
{
|
2016-10-08 07:29:26 +00:00
|
|
|
auto inst = SSAScope::builder().CreateStore(value, v, false);
|
|
|
|
inst->setMetadata(llvm::LLVMContext::MD_noalias, SSAScope::constant_scope_list());
|
2016-09-26 07:00:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SSAIndexLookup SSAValue::operator[](int index)
|
|
|
|
{
|
|
|
|
SSAIndexLookup result;
|
|
|
|
result.v = v;
|
|
|
|
result.indexes.push_back(SSAInt(index).v);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
SSAIndexLookup SSAValue::operator[](SSAInt index)
|
|
|
|
{
|
|
|
|
SSAIndexLookup result;
|
|
|
|
result.v = v;
|
|
|
|
result.indexes.push_back(index.v);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
SSAIndexLookup::operator SSAValue()
|
|
|
|
{
|
|
|
|
return SSAValue::from_llvm(SSAScope::builder().CreateGEP(v, indexes));
|
|
|
|
}
|
|
|
|
|
|
|
|
SSAIndexLookup SSAIndexLookup::operator[](int index)
|
|
|
|
{
|
|
|
|
SSAIndexLookup result;
|
|
|
|
result.v = v;
|
|
|
|
result.indexes = indexes;
|
|
|
|
result.indexes.push_back(SSAInt(index).v);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
SSAIndexLookup SSAIndexLookup::operator[](SSAInt index)
|
|
|
|
{
|
|
|
|
SSAIndexLookup result;
|
|
|
|
result.v = v;
|
|
|
|
result.indexes = indexes;
|
|
|
|
result.indexes.push_back(index.v);
|
|
|
|
return result;
|
|
|
|
}
|