Commit 471c120a by Nicolas Capens Committed by Nicolas Capens

Don't inline rr::Variable methods

This is not a template class, so its methods don't have to be inlined. Nor are they trivial enough to save us anything in performance or binary size if they were inlined. Instead, this could reduce binary size a bit because there are a large number of rr::Variable uses. Bug: chromium:1086501 Change-Id: I1a6d078628ed7e634e0d90d6d8455e7d2938d134 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/45388 Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAntonio Maiorano <amaiorano@google.com>
parent 9e718f96
...@@ -70,6 +70,61 @@ Variable::~Variable() ...@@ -70,6 +70,61 @@ Variable::~Variable()
unmaterializedVariables->erase(this); unmaterializedVariables->erase(this);
} }
void Variable::materialize() const
{
if(!address)
{
address = allocate();
RR_DEBUG_INFO_EMIT_VAR(address);
if(rvalue)
{
storeValue(rvalue);
rvalue = nullptr;
}
}
}
Value *Variable::loadValue() const
{
if(rvalue)
{
return rvalue;
}
if(!address)
{
// TODO: Return undef instead.
materialize();
}
return Nucleus::createLoad(address, getType(), false, 0);
}
Value *Variable::storeValue(Value *value) const
{
if(address)
{
return Nucleus::createStore(value, address, getType(), false, 0);
}
rvalue = value;
return value;
}
Value *Variable::getBaseAddress() const
{
materialize();
return address;
}
Value *Variable::getElementPointer(Value *index, bool unsignedIndex) const
{
return Nucleus::createGEP(getBaseAddress(), getType(), index, unsignedIndex);
}
Value *Variable::allocate() const Value *Variable::allocate() const
{ {
return Nucleus::allocateStackVariable(getType()); return Nucleus::allocateStackVariable(getType());
......
...@@ -2625,61 +2625,6 @@ LValue<T>::LValue() ...@@ -2625,61 +2625,6 @@ LValue<T>::LValue()
#endif // ENABLE_RR_DEBUG_INFO #endif // ENABLE_RR_DEBUG_INFO
} }
inline void Variable::materialize() const
{
if(!address)
{
address = allocate();
RR_DEBUG_INFO_EMIT_VAR(address);
if(rvalue)
{
storeValue(rvalue);
rvalue = nullptr;
}
}
}
inline Value *Variable::loadValue() const
{
if(rvalue)
{
return rvalue;
}
if(!address)
{
// TODO: Return undef instead.
materialize();
}
return Nucleus::createLoad(address, getType(), false, 0);
}
inline Value *Variable::storeValue(Value *value) const
{
if(address)
{
return Nucleus::createStore(value, address, getType(), false, 0);
}
rvalue = value;
return value;
}
inline Value *Variable::getBaseAddress() const
{
materialize();
return address;
}
inline Value *Variable::getElementPointer(Value *index, bool unsignedIndex) const
{
return Nucleus::createGEP(getBaseAddress(), getType(), index, unsignedIndex);
}
template<class T> template<class T>
RValue<Pointer<T>> LValue<T>::operator&() RValue<Pointer<T>> LValue<T>::operator&()
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment