Add support for DISubrange

This commit is contained in:
baldurk
2020-06-09 12:16:57 +01:00
parent 9697bc294d
commit 10da3b73ae
3 changed files with 31 additions and 0 deletions
@@ -205,6 +205,7 @@ struct DIBase
LocalVariable,
Expression,
LexicalBlock,
Subrange,
} type;
DIBase(Type t) : type(t) {}
@@ -234,6 +234,12 @@ bool Program::ParseDebugMetaRecord(const LLVMBC::BlockOrRecord &metaRecord, Meta
meta.children = {getMeta(metaRecord.ops[1]), getMeta(metaRecord.ops[2])};
}
else if(id == MetaDataRecord::SUBRANGE)
{
meta.distinct = (metaRecord.ops[0] & 0x1);
meta.dwarf = new DISubrange(metaRecord.ops[1], LLVMBC::BitReader::svbr(metaRecord.ops[2]));
}
else if(id == MetaDataRecord::EXPRESSION)
{
DIExpression *expr = new DIExpression;
@@ -544,6 +550,16 @@ rdcstr DILexicalBlock::toString() const
return ret;
}
rdcstr DISubrange::toString() const
{
rdcstr ret = "!DISubrange(";
ret += StringFormat::Fmt("count: %llu", count);
if(lowerBound)
ret += StringFormat::Fmt(", lowerBound: %lld", lowerBound);
ret += ")";
return ret;
}
}; // namespace DXIL
template <>
@@ -695,6 +695,20 @@ struct DILexicalBlock : public DIBase
virtual rdcstr toString() const;
};
struct DISubrange : public DIBase
{
static const DIBase::Type DIType = DIBase::Subrange;
DISubrange(uint64_t count, int64_t lowerBound)
: DIBase(DIType), count(count), lowerBound(lowerBound)
{
}
uint64_t count;
int64_t lowerBound;
virtual rdcstr toString() const;
};
}; // namespace DXIL
DECLARE_REFLECTION_ENUM(DXIL::DW_LANG);