Add helper to find and cache void type

This commit is contained in:
baldurk
2020-06-09 12:16:45 +01:00
parent 0000916e75
commit 9697bc294d
2 changed files with 23 additions and 8 deletions
@@ -1233,14 +1233,7 @@ Program::Program(const byte *bytes, size_t length)
if(op.ops.empty())
{
for(size_t i = 0; i < m_Types.size(); i++)
{
if(m_Types[i].isVoid())
{
inst.type = &m_Types[i];
break;
}
}
inst.type = GetVoidType();
RDCASSERT(inst.type);
}
@@ -1441,6 +1434,26 @@ const Metadata *Program::GetFunctionMetadata(const Function &f, uint64_t v)
return idx < m_Metadata.size() ? &m_Metadata[idx] : &f.metadata[idx - m_Metadata.size()];
}
const DXIL::Type *Program::GetVoidType()
{
if(m_VoidType)
return m_VoidType;
for(size_t i = 0; i < m_Types.size(); i++)
{
if(m_Types[i].isVoid())
{
m_VoidType = &m_Types[i];
break;
}
}
if(!m_VoidType)
RDCERR("Couldn't find void type");
return m_VoidType;
}
Metadata::~Metadata()
{
SAFE_DELETE(dwarf);
@@ -395,6 +395,7 @@ private:
const Type *GetSymbolType(const Function &f, Symbol s);
const Value *GetFunctionValue(const Function &f, uint64_t v);
const Metadata *GetFunctionMetadata(const Function &f, uint64_t v);
const Type *GetVoidType();
DXBC::ShaderType m_Type;
uint32_t m_Major, m_Minor;
@@ -407,6 +408,7 @@ private:
rdcarray<rdcstr> m_Kinds;
rdcarray<Type> m_Types;
const Type *m_VoidType = NULL;
rdcarray<Attributes> m_AttributeGroups;
rdcarray<Attributes> m_Attributes;