mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-10-05 03:48:01 +00:00
Rename 'Value' to 'Constant' to get away from the overloaded LLVM term
This commit is contained in:
@@ -226,8 +226,8 @@ enum class TypeRecord : uint32_t
|
||||
void ParseConstant(const LLVMBC::BlockOrRecord &constant, const Type *&curType,
|
||||
std::function<const Type *(uint64_t)> getType,
|
||||
std::function<const Type *(const Type *)> getPtrType,
|
||||
std::function<const Value *(uint64_t)> getValue,
|
||||
std::function<void(const Value &)> addValue)
|
||||
std::function<const Constant *(uint64_t)> getConstant,
|
||||
std::function<void(const Constant &)> addConstant)
|
||||
{
|
||||
if(IS_KNOWN(constant.id, ConstantsRecord::SETTYPE))
|
||||
{
|
||||
@@ -236,22 +236,22 @@ void ParseConstant(const LLVMBC::BlockOrRecord &constant, const Type *&curType,
|
||||
else if(IS_KNOWN(constant.id, ConstantsRecord::CONST_NULL) ||
|
||||
IS_KNOWN(constant.id, ConstantsRecord::UNDEF))
|
||||
{
|
||||
Value v;
|
||||
Constant v;
|
||||
v.type = curType;
|
||||
v.nullconst = IS_KNOWN(constant.id, ConstantsRecord::CONST_NULL);
|
||||
v.undef = IS_KNOWN(constant.id, ConstantsRecord::UNDEF);
|
||||
addValue(v);
|
||||
addConstant(v);
|
||||
}
|
||||
else if(IS_KNOWN(constant.id, ConstantsRecord::INTEGER))
|
||||
{
|
||||
Value v;
|
||||
Constant v;
|
||||
v.type = curType;
|
||||
v.val.s64v[0] = LLVMBC::BitReader::svbr(constant.ops[0]);
|
||||
addValue(v);
|
||||
addConstant(v);
|
||||
}
|
||||
else if(IS_KNOWN(constant.id, ConstantsRecord::FLOAT))
|
||||
{
|
||||
Value v;
|
||||
Constant v;
|
||||
v.type = curType;
|
||||
if(curType->bitWidth == 16)
|
||||
v.val.fv[0] = ConvertFromHalf(uint16_t(constant.ops[0] & 0xffff));
|
||||
@@ -259,21 +259,21 @@ void ParseConstant(const LLVMBC::BlockOrRecord &constant, const Type *&curType,
|
||||
memcpy(&v.val.fv[0], &constant.ops[0], sizeof(float));
|
||||
else
|
||||
memcpy(&v.val.dv[0], &constant.ops[0], sizeof(double));
|
||||
addValue(v);
|
||||
addConstant(v);
|
||||
}
|
||||
else if(IS_KNOWN(constant.id, ConstantsRecord::STRING) ||
|
||||
IS_KNOWN(constant.id, ConstantsRecord::CSTRING))
|
||||
{
|
||||
Value v;
|
||||
Constant v;
|
||||
v.type = curType;
|
||||
v.str = constant.getString(0);
|
||||
addValue(v);
|
||||
addConstant(v);
|
||||
}
|
||||
else if(IS_KNOWN(constant.id, ConstantsRecord::EVAL_GEP))
|
||||
{
|
||||
Value v;
|
||||
Constant v;
|
||||
|
||||
v.op = Value::GEP;
|
||||
v.op = Constant::GEP;
|
||||
|
||||
size_t idx = 0;
|
||||
if(constant.ops.size() & 1)
|
||||
@@ -282,7 +282,7 @@ void ParseConstant(const LLVMBC::BlockOrRecord &constant, const Type *&curType,
|
||||
for(; idx < constant.ops.size(); idx += 2)
|
||||
{
|
||||
const Type *t = getType(constant.ops[idx]);
|
||||
const Value *a = getValue(constant.ops[idx + 1]);
|
||||
const Constant *a = getConstant(constant.ops[idx + 1]);
|
||||
RDCASSERT(t == a->type);
|
||||
|
||||
v.members.push_back(*a);
|
||||
@@ -311,18 +311,18 @@ void ParseConstant(const LLVMBC::BlockOrRecord &constant, const Type *&curType,
|
||||
// the result is a pointer to the return type
|
||||
v.type = getPtrType(v.type);
|
||||
|
||||
addValue(v);
|
||||
addConstant(v);
|
||||
}
|
||||
else if(IS_KNOWN(constant.id, ConstantsRecord::AGGREGATE))
|
||||
{
|
||||
Value v;
|
||||
Constant v;
|
||||
v.type = curType;
|
||||
if(v.type->type == Type::Vector)
|
||||
{
|
||||
// inline vectors
|
||||
for(size_t m = 0; m < constant.ops.size(); m++)
|
||||
{
|
||||
const Value *member = getValue(constant.ops[m]);
|
||||
const Constant *member = getConstant(constant.ops[m]);
|
||||
|
||||
if(member)
|
||||
{
|
||||
@@ -333,7 +333,7 @@ void ParseConstant(const LLVMBC::BlockOrRecord &constant, const Type *&curType,
|
||||
}
|
||||
else
|
||||
{
|
||||
RDCERR("Index %llu out of bounds for values array", constant.ops[m]);
|
||||
RDCERR("Index %llu out of bounds for constants array", constant.ops[m]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -341,7 +341,7 @@ void ParseConstant(const LLVMBC::BlockOrRecord &constant, const Type *&curType,
|
||||
{
|
||||
for(uint64_t m : constant.ops)
|
||||
{
|
||||
const Value *member = getValue(m);
|
||||
const Constant *member = getConstant(m);
|
||||
|
||||
if(member)
|
||||
{
|
||||
@@ -349,16 +349,16 @@ void ParseConstant(const LLVMBC::BlockOrRecord &constant, const Type *&curType,
|
||||
}
|
||||
else
|
||||
{
|
||||
v.members.push_back(Value());
|
||||
RDCERR("Index %llu out of bounds for values array", m);
|
||||
v.members.push_back(Constant());
|
||||
RDCERR("Index %llu out of bounds for constants array", m);
|
||||
}
|
||||
}
|
||||
}
|
||||
addValue(v);
|
||||
addConstant(v);
|
||||
}
|
||||
else if(IS_KNOWN(constant.id, ConstantsRecord::DATA))
|
||||
{
|
||||
Value v;
|
||||
Constant v;
|
||||
v.type = curType;
|
||||
if(v.type->type == Type::Vector)
|
||||
{
|
||||
@@ -374,7 +374,7 @@ void ParseConstant(const LLVMBC::BlockOrRecord &constant, const Type *&curType,
|
||||
{
|
||||
for(size_t m = 0; m < constant.ops.size(); m++)
|
||||
{
|
||||
Value el;
|
||||
Constant el;
|
||||
el.type = v.type->inner;
|
||||
if(el.type->bitWidth <= 32)
|
||||
el.val.uv[0] = constant.ops[m] & ((1ULL << el.type->bitWidth) - 1);
|
||||
@@ -383,7 +383,7 @@ void ParseConstant(const LLVMBC::BlockOrRecord &constant, const Type *&curType,
|
||||
v.members.push_back(el);
|
||||
}
|
||||
}
|
||||
addValue(v);
|
||||
addConstant(v);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -498,7 +498,7 @@ Program::Program(const byte *bytes, size_t length)
|
||||
|
||||
// all global symbols are 'values' in LLVM, we don't need this but need to keep indexing the
|
||||
// same
|
||||
Value v;
|
||||
Constant v;
|
||||
v.type = g.type;
|
||||
v.symbol = true;
|
||||
|
||||
@@ -509,7 +509,7 @@ Program::Program(const byte *bytes, size_t length)
|
||||
|
||||
g.type = v.type;
|
||||
|
||||
m_Values.push_back(v);
|
||||
m_Constants.push_back(v);
|
||||
m_GlobalVars.push_back(g);
|
||||
}
|
||||
else if(IS_KNOWN(rootchild.id, ModuleRecord::FUNCTION))
|
||||
@@ -531,7 +531,7 @@ Program::Program(const byte *bytes, size_t length)
|
||||
|
||||
// all global symbols are 'values' in LLVM, we don't need this but need to keep indexing the
|
||||
// same
|
||||
Value v;
|
||||
Constant v;
|
||||
v.symbol = true;
|
||||
v.type = f.funcType;
|
||||
|
||||
@@ -547,7 +547,7 @@ Program::Program(const byte *bytes, size_t length)
|
||||
if(v.type == f.funcType)
|
||||
RDCERR("Expected to find pointer type for function");
|
||||
|
||||
m_Values.push_back(v);
|
||||
m_Constants.push_back(v);
|
||||
|
||||
if(!f.external)
|
||||
functionDecls.push_back(m_Functions.size());
|
||||
@@ -564,10 +564,10 @@ Program::Program(const byte *bytes, size_t length)
|
||||
|
||||
// all global symbols are 'values' in LLVM, we don't need this but need to keep indexing the
|
||||
// same
|
||||
Value v;
|
||||
Constant v;
|
||||
v.type = &m_Types[(size_t)rootchild.ops[0]];
|
||||
v.symbol = true;
|
||||
m_Values.push_back(v);
|
||||
m_Constants.push_back(v);
|
||||
|
||||
m_Aliases.push_back(a);
|
||||
}
|
||||
@@ -859,11 +859,11 @@ Program::Program(const byte *bytes, size_t length)
|
||||
[this](const Type *t) { return GetPointerType(t); },
|
||||
[this](uint64_t v) {
|
||||
size_t idx = (size_t)v;
|
||||
return idx < m_Values.size() ? &m_Values[idx] : NULL;
|
||||
return idx < m_Constants.size() ? &m_Constants[idx] : NULL;
|
||||
},
|
||||
[this](const Value &v) {
|
||||
m_Symbols.push_back({SymbolType::Constant, m_Values.size()});
|
||||
m_Values.push_back(v);
|
||||
[this](const Constant &v) {
|
||||
m_Symbols.push_back({SymbolType::Constant, m_Constants.size()});
|
||||
m_Constants.push_back(v);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -899,13 +899,13 @@ Program::Program(const byte *bytes, size_t length)
|
||||
RDCERR("Unexpected global symbol referring to %d", m_Symbols[s].type);
|
||||
break;
|
||||
case SymbolType::GlobalVar:
|
||||
m_Values[s].str = m_GlobalVars[idx].name = symtab.getString(1);
|
||||
m_Constants[s].str = m_GlobalVars[idx].name = symtab.getString(1);
|
||||
break;
|
||||
case SymbolType::Function:
|
||||
m_Values[s].str = m_Functions[idx].name = symtab.getString(1);
|
||||
m_Constants[s].str = m_Functions[idx].name = symtab.getString(1);
|
||||
break;
|
||||
case SymbolType::Alias:
|
||||
m_Values[s].str = m_Aliases[idx].name = symtab.getString(1);
|
||||
m_Constants[s].str = m_Aliases[idx].name = symtab.getString(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -963,20 +963,20 @@ Program::Program(const byte *bytes, size_t length)
|
||||
|
||||
if(IS_KNOWN(metaRecord.id, MetaDataRecord::STRING_OLD))
|
||||
{
|
||||
meta.value = true;
|
||||
meta.isConstant = true;
|
||||
meta.str = metaRecord.getString();
|
||||
}
|
||||
else if(IS_KNOWN(metaRecord.id, MetaDataRecord::VALUE))
|
||||
{
|
||||
meta.value = true;
|
||||
meta.val = &m_Values[(size_t)metaRecord.ops[1]];
|
||||
meta.isConstant = true;
|
||||
meta.constant = &m_Constants[(size_t)metaRecord.ops[1]];
|
||||
meta.type = &m_Types[(size_t)metaRecord.ops[0]];
|
||||
}
|
||||
else if(IS_KNOWN(metaRecord.id, MetaDataRecord::NODE) ||
|
||||
IS_KNOWN(metaRecord.id, MetaDataRecord::DISTINCT_NODE))
|
||||
{
|
||||
if(IS_KNOWN(metaRecord.id, MetaDataRecord::DISTINCT_NODE))
|
||||
meta.distinct = true;
|
||||
meta.isDistinct = true;
|
||||
|
||||
for(uint64_t op : metaRecord.ops)
|
||||
meta.children.push_back(getMetaOrNull(op));
|
||||
@@ -997,7 +997,7 @@ Program::Program(const byte *bytes, size_t length)
|
||||
Function &f = m_Functions[functionDecls[0]];
|
||||
functionDecls.erase(0);
|
||||
|
||||
auto getValue = [this, &f](uint64_t v) { return GetFunctionValue(f, v); };
|
||||
auto getConstant = [this, &f](uint64_t v) { return GetFunctionConstant(f, v); };
|
||||
auto getMeta = [this, &f](uint64_t v) {
|
||||
size_t idx = (size_t)v;
|
||||
return idx - 1 < m_Metadata.size() ? &m_Metadata[idx] : &f.metadata[idx];
|
||||
@@ -1036,7 +1036,7 @@ Program::Program(const byte *bytes, size_t length)
|
||||
{
|
||||
if(IS_KNOWN(funcChild.id, KnownBlocks::CONSTANTS_BLOCK))
|
||||
{
|
||||
f.values.reserve(funcChild.children.size());
|
||||
f.constants.reserve(funcChild.children.size());
|
||||
|
||||
const Type *t = NULL;
|
||||
for(const LLVMBC::BlockOrRecord &constant : funcChild.children)
|
||||
@@ -1047,13 +1047,13 @@ Program::Program(const byte *bytes, size_t length)
|
||||
continue;
|
||||
}
|
||||
|
||||
ParseConstant(
|
||||
constant, t, [this](uint64_t op) { return &m_Types[(size_t)op]; },
|
||||
[this](const Type *t) { return GetPointerType(t); }, getValue,
|
||||
[this, &f](const Value &v) {
|
||||
m_Symbols.push_back({SymbolType::Constant, m_Values.size() + f.values.size()});
|
||||
f.values.push_back(v);
|
||||
});
|
||||
ParseConstant(constant, t, [this](uint64_t op) { return &m_Types[(size_t)op]; },
|
||||
[this](const Type *t) { return GetPointerType(t); }, getConstant,
|
||||
[this, &f](const Constant &v) {
|
||||
m_Symbols.push_back({SymbolType::Constant,
|
||||
m_Constants.size() + f.constants.size()});
|
||||
f.constants.push_back(v);
|
||||
});
|
||||
}
|
||||
|
||||
instrSymbolStart = m_Symbols.size();
|
||||
@@ -1076,26 +1076,26 @@ Program::Program(const byte *bytes, size_t length)
|
||||
|
||||
if(IS_KNOWN(metaRecord.id, MetaDataRecord::VALUE))
|
||||
{
|
||||
meta.value = true;
|
||||
meta.isConstant = true;
|
||||
size_t idx = metaRecord.ops[1];
|
||||
if(idx < m_Values.size())
|
||||
if(idx < m_Constants.size())
|
||||
{
|
||||
// global value reference
|
||||
meta.val = &m_Values[idx];
|
||||
// global constant reference
|
||||
meta.constant = &m_Constants[idx];
|
||||
}
|
||||
else
|
||||
{
|
||||
idx -= m_Values.size();
|
||||
if(idx < f.values.size())
|
||||
idx -= m_Constants.size();
|
||||
if(idx < f.constants.size())
|
||||
{
|
||||
// function-local value reference
|
||||
meta.val = &f.values[idx];
|
||||
// function-local constant reference
|
||||
meta.constant = &f.constants[idx];
|
||||
}
|
||||
else
|
||||
{
|
||||
// forward reference to instruction
|
||||
meta.func = &f;
|
||||
meta.instruction = idx - f.values.size();
|
||||
meta.instruction = idx - f.constants.size();
|
||||
}
|
||||
}
|
||||
meta.type = &m_Types[(size_t)metaRecord.ops[0]];
|
||||
@@ -1135,10 +1135,10 @@ Program::Program(const byte *bytes, size_t length)
|
||||
{
|
||||
case SymbolType::Unknown:
|
||||
case SymbolType::Constant:
|
||||
if(s.idx < m_Values.size())
|
||||
if(s.idx < m_Constants.size())
|
||||
RDCERR("Unexpected local symbol referring to global value");
|
||||
else
|
||||
f.values[s.idx - m_Values.size()].str = symtab.getString(1);
|
||||
f.constants[s.idx - m_Constants.size()].str = symtab.getString(1);
|
||||
break;
|
||||
case SymbolType::Argument: f.args[s.idx].name = symtab.getString(1); break;
|
||||
case SymbolType::Instruction:
|
||||
@@ -1498,7 +1498,7 @@ Program::Program(const byte *bytes, size_t length)
|
||||
Symbol s = inst.args[idx];
|
||||
// if it's a struct the index must be constant
|
||||
RDCASSERT(s.type == SymbolType::Constant);
|
||||
inst.type = inst.type->members[GetFunctionValue(f, s.idx)->val.uv[0]];
|
||||
inst.type = inst.type->members[GetFunctionConstant(f, s.idx)->val.uv[0]];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2251,7 +2251,7 @@ uint32_t Program::GetOrAssignMetaID(Metadata *m)
|
||||
// assign meta IDs to the children now
|
||||
for(Metadata *c : m->children)
|
||||
{
|
||||
if(!c || c->value)
|
||||
if(!c || c->isConstant)
|
||||
continue;
|
||||
|
||||
GetOrAssignMetaID(c);
|
||||
@@ -2281,10 +2281,10 @@ const Type *Program::GetSymbolType(const Function &f, Symbol s)
|
||||
switch(s.type)
|
||||
{
|
||||
case SymbolType::Constant:
|
||||
if(s.idx < m_Values.size())
|
||||
ret = m_Values[s.idx].type;
|
||||
if(s.idx < m_Constants.size())
|
||||
ret = m_Constants[s.idx].type;
|
||||
else
|
||||
ret = f.values[s.idx - m_Values.size()].type;
|
||||
ret = f.constants[s.idx - m_Constants.size()].type;
|
||||
break;
|
||||
case SymbolType::Argument: ret = f.funcType->members[s.idx]; break;
|
||||
case SymbolType::Instruction: ret = f.instructions[s.idx].type; break;
|
||||
@@ -2304,10 +2304,10 @@ const Type *Program::GetSymbolType(const Function &f, Symbol s)
|
||||
return ret;
|
||||
}
|
||||
|
||||
const Value *Program::GetFunctionValue(const Function &f, uint64_t v)
|
||||
const Constant *Program::GetFunctionConstant(const Function &f, uint64_t v)
|
||||
{
|
||||
size_t idx = (size_t)v;
|
||||
return idx < m_Values.size() ? &m_Values[idx] : &f.values[idx - m_Values.size()];
|
||||
return idx < m_Constants.size() ? &m_Constants[idx] : &f.constants[idx - m_Constants.size()];
|
||||
}
|
||||
|
||||
const Metadata *Program::GetFunctionMetadata(const Function &f, uint64_t v)
|
||||
|
||||
@@ -204,14 +204,14 @@ struct Attributes
|
||||
rdcstr toString() const;
|
||||
};
|
||||
|
||||
struct Value
|
||||
struct Constant
|
||||
{
|
||||
const Type *type = NULL;
|
||||
ShaderValue val = {};
|
||||
rdcarray<Value> members;
|
||||
rdcarray<Constant> members;
|
||||
rdcstr str;
|
||||
bool undef = false, nullconst = false, symbol = false;
|
||||
enum ValueOp : uint8_t
|
||||
enum ConstantOp : uint8_t
|
||||
{
|
||||
NoOp = 0,
|
||||
GEP,
|
||||
@@ -278,9 +278,9 @@ struct Metadata
|
||||
~Metadata();
|
||||
|
||||
uint32_t id = ~0U;
|
||||
bool distinct = false, value = false;
|
||||
bool isDistinct = false, isConstant = false;
|
||||
|
||||
const Value *val = NULL;
|
||||
const Constant *constant = NULL;
|
||||
|
||||
const Function *func = NULL;
|
||||
size_t instruction = ~0U;
|
||||
@@ -487,7 +487,7 @@ struct Function
|
||||
rdcarray<Instruction> instructions;
|
||||
|
||||
rdcarray<Block> blocks;
|
||||
rdcarray<Value> values;
|
||||
rdcarray<Constant> constants;
|
||||
rdcarray<Metadata> metadata;
|
||||
|
||||
AttachedMetadata attachedMeta;
|
||||
@@ -525,7 +525,7 @@ private:
|
||||
uint32_t GetOrAssignMetaID(Metadata *m);
|
||||
uint32_t GetOrAssignMetaID(DebugLocation &l);
|
||||
const Type *GetSymbolType(const Function &f, Symbol s);
|
||||
const Value *GetFunctionValue(const Function &f, uint64_t v);
|
||||
const Constant *GetFunctionConstant(const Function &f, uint64_t v);
|
||||
const Metadata *GetFunctionMetadata(const Function &f, uint64_t v);
|
||||
const Type *GetVoidType();
|
||||
const Type *GetBoolType();
|
||||
@@ -548,7 +548,7 @@ private:
|
||||
rdcarray<Attributes> m_AttributeGroups;
|
||||
rdcarray<Attributes> m_Attributes;
|
||||
|
||||
rdcarray<Value> m_Values;
|
||||
rdcarray<Constant> m_Constants;
|
||||
|
||||
rdcarray<Metadata> m_Metadata;
|
||||
rdcarray<NamedMetadata> m_NamedMeta;
|
||||
|
||||
@@ -83,7 +83,7 @@ bool Program::ParseDebugMetaRecord(const LLVMBC::BlockOrRecord &metaRecord, Meta
|
||||
|
||||
if(id == MetaDataRecord::FILE)
|
||||
{
|
||||
meta.distinct = (metaRecord.ops[0] & 0x1);
|
||||
meta.isDistinct = (metaRecord.ops[0] & 0x1);
|
||||
|
||||
meta.dwarf = new DIFile(getMeta(metaRecord.ops[1]), getMeta(metaRecord.ops[2]));
|
||||
meta.children = {getMeta(metaRecord.ops[1]), getMeta(metaRecord.ops[2])};
|
||||
@@ -95,7 +95,7 @@ bool Program::ParseDebugMetaRecord(const LLVMBC::BlockOrRecord &metaRecord, Meta
|
||||
|
||||
// we expect it to be marked as distinct, but we'll always treat it that way
|
||||
RDCASSERT(metaRecord.ops[0] & 0x1);
|
||||
meta.distinct = true;
|
||||
meta.isDistinct = true;
|
||||
|
||||
meta.dwarf = new DICompileUnit(
|
||||
DW_LANG(metaRecord.ops[1]), getMeta(metaRecord.ops[2]), getMetaString(metaRecord.ops[3]),
|
||||
@@ -109,7 +109,7 @@ bool Program::ParseDebugMetaRecord(const LLVMBC::BlockOrRecord &metaRecord, Meta
|
||||
}
|
||||
else if(id == MetaDataRecord::BASIC_TYPE)
|
||||
{
|
||||
meta.distinct = (metaRecord.ops[0] & 0x1);
|
||||
meta.isDistinct = (metaRecord.ops[0] & 0x1);
|
||||
|
||||
meta.dwarf =
|
||||
new DIBasicType(DW_TAG(metaRecord.ops[1]), getMetaString(metaRecord.ops[2]),
|
||||
@@ -117,7 +117,7 @@ bool Program::ParseDebugMetaRecord(const LLVMBC::BlockOrRecord &metaRecord, Meta
|
||||
}
|
||||
else if(id == MetaDataRecord::DERIVED_TYPE)
|
||||
{
|
||||
meta.distinct = (metaRecord.ops[0] & 0x1);
|
||||
meta.isDistinct = (metaRecord.ops[0] & 0x1);
|
||||
|
||||
meta.dwarf = new DIDerivedType(DW_TAG(metaRecord.ops[1]), getMetaString(metaRecord.ops[2]),
|
||||
getMeta(metaRecord.ops[3]), metaRecord.ops[4],
|
||||
@@ -130,7 +130,7 @@ bool Program::ParseDebugMetaRecord(const LLVMBC::BlockOrRecord &metaRecord, Meta
|
||||
}
|
||||
else if(id == MetaDataRecord::COMPOSITE_TYPE)
|
||||
{
|
||||
meta.distinct = (metaRecord.ops[0] & 0x1);
|
||||
meta.isDistinct = (metaRecord.ops[0] & 0x1);
|
||||
|
||||
// TODO handle forward declarations?
|
||||
meta.dwarf = new DICompositeType(
|
||||
@@ -145,7 +145,7 @@ bool Program::ParseDebugMetaRecord(const LLVMBC::BlockOrRecord &metaRecord, Meta
|
||||
}
|
||||
else if(id == MetaDataRecord::TEMPLATE_TYPE)
|
||||
{
|
||||
meta.distinct = (metaRecord.ops[0] & 0x1);
|
||||
meta.isDistinct = (metaRecord.ops[0] & 0x1);
|
||||
|
||||
meta.dwarf =
|
||||
new DITemplateTypeParameter(getMetaString(metaRecord.ops[1]), getMeta(metaRecord.ops[2]));
|
||||
@@ -154,7 +154,7 @@ bool Program::ParseDebugMetaRecord(const LLVMBC::BlockOrRecord &metaRecord, Meta
|
||||
}
|
||||
else if(id == MetaDataRecord::TEMPLATE_VALUE)
|
||||
{
|
||||
meta.distinct = (metaRecord.ops[0] & 0x1);
|
||||
meta.isDistinct = (metaRecord.ops[0] & 0x1);
|
||||
|
||||
meta.dwarf =
|
||||
new DITemplateValueParameter(DW_TAG(metaRecord.ops[1]), getMetaString(metaRecord.ops[2]),
|
||||
@@ -164,7 +164,7 @@ bool Program::ParseDebugMetaRecord(const LLVMBC::BlockOrRecord &metaRecord, Meta
|
||||
}
|
||||
else if(id == MetaDataRecord::SUBPROGRAM)
|
||||
{
|
||||
meta.distinct = (metaRecord.ops[0] & 0x1);
|
||||
meta.isDistinct = (metaRecord.ops[0] & 0x1);
|
||||
|
||||
meta.dwarf = new DISubprogram(
|
||||
getMeta(metaRecord.ops[1]), getMetaString(metaRecord.ops[2]),
|
||||
@@ -181,7 +181,7 @@ bool Program::ParseDebugMetaRecord(const LLVMBC::BlockOrRecord &metaRecord, Meta
|
||||
}
|
||||
else if(id == MetaDataRecord::SUBROUTINE_TYPE)
|
||||
{
|
||||
meta.distinct = (metaRecord.ops[0] & 0x1);
|
||||
meta.isDistinct = (metaRecord.ops[0] & 0x1);
|
||||
|
||||
meta.dwarf = new DISubroutineType(getMeta(metaRecord.ops[2]));
|
||||
|
||||
@@ -189,7 +189,7 @@ bool Program::ParseDebugMetaRecord(const LLVMBC::BlockOrRecord &metaRecord, Meta
|
||||
}
|
||||
else if(id == MetaDataRecord::GLOBAL_VAR)
|
||||
{
|
||||
meta.distinct = (metaRecord.ops[0] & 0x1);
|
||||
meta.isDistinct = (metaRecord.ops[0] & 0x1);
|
||||
|
||||
uint64_t version = metaRecord.ops[0] >> 1;
|
||||
|
||||
@@ -212,7 +212,7 @@ bool Program::ParseDebugMetaRecord(const LLVMBC::BlockOrRecord &metaRecord, Meta
|
||||
}
|
||||
else if(id == MetaDataRecord::LOCATION)
|
||||
{
|
||||
meta.distinct = (metaRecord.ops[0] & 0x1);
|
||||
meta.isDistinct = (metaRecord.ops[0] & 0x1);
|
||||
|
||||
meta.debugLoc = new DebugLocation;
|
||||
meta.debugLoc->line = metaRecord.ops[1];
|
||||
@@ -224,7 +224,7 @@ bool Program::ParseDebugMetaRecord(const LLVMBC::BlockOrRecord &metaRecord, Meta
|
||||
}
|
||||
else if(id == MetaDataRecord::LOCAL_VAR)
|
||||
{
|
||||
meta.distinct = (metaRecord.ops[0] & 0x1);
|
||||
meta.isDistinct = (metaRecord.ops[0] & 0x1);
|
||||
|
||||
meta.dwarf = new DILocalVariable(
|
||||
DW_TAG(metaRecord.ops[1]), getMeta(metaRecord.ops[2]), getMetaString(metaRecord.ops[3]),
|
||||
@@ -236,7 +236,7 @@ bool Program::ParseDebugMetaRecord(const LLVMBC::BlockOrRecord &metaRecord, Meta
|
||||
}
|
||||
else if(id == MetaDataRecord::LEXICAL_BLOCK)
|
||||
{
|
||||
meta.distinct = (metaRecord.ops[0] & 0x1);
|
||||
meta.isDistinct = (metaRecord.ops[0] & 0x1);
|
||||
|
||||
meta.dwarf = new DILexicalBlock(getMeta(metaRecord.ops[1]), getMeta(metaRecord.ops[2]),
|
||||
metaRecord.ops[3], metaRecord.ops[4]);
|
||||
@@ -245,7 +245,7 @@ bool Program::ParseDebugMetaRecord(const LLVMBC::BlockOrRecord &metaRecord, Meta
|
||||
}
|
||||
else if(id == MetaDataRecord::SUBRANGE)
|
||||
{
|
||||
meta.distinct = (metaRecord.ops[0] & 0x1);
|
||||
meta.isDistinct = (metaRecord.ops[0] & 0x1);
|
||||
|
||||
meta.dwarf = new DISubrange(metaRecord.ops[1], LLVMBC::BitReader::svbr(metaRecord.ops[2]));
|
||||
}
|
||||
@@ -253,7 +253,7 @@ bool Program::ParseDebugMetaRecord(const LLVMBC::BlockOrRecord &metaRecord, Meta
|
||||
{
|
||||
DIExpression *expr = new DIExpression;
|
||||
|
||||
meta.distinct = (metaRecord.ops[0] & 0x1);
|
||||
meta.isDistinct = (metaRecord.ops[0] & 0x1);
|
||||
|
||||
expr->op = DW_OP_none;
|
||||
|
||||
|
||||
@@ -85,8 +85,8 @@ struct TypeOrderer
|
||||
if(m->type)
|
||||
accumulate(m->type);
|
||||
|
||||
if(m->val)
|
||||
accumulate(m->val->type);
|
||||
if(m->constant)
|
||||
accumulate(m->constant->type);
|
||||
|
||||
for(const Metadata *c : m->children)
|
||||
if(c)
|
||||
@@ -375,7 +375,7 @@ void Program::MakeDisassemblyString()
|
||||
typeOrderer.accumulate(g.type);
|
||||
|
||||
if(g.initialiser.type == SymbolType::Constant)
|
||||
typeOrderer.accumulate(m_Values[g.initialiser.idx].type);
|
||||
typeOrderer.accumulate(m_Constants[g.initialiser.idx].type);
|
||||
}
|
||||
|
||||
for(size_t i = 0; i < m_Functions.size(); i++)
|
||||
@@ -457,7 +457,7 @@ void Program::MakeDisassemblyString()
|
||||
m_Disassembly += "global ";
|
||||
|
||||
if(g.initialiser.type == SymbolType::Constant)
|
||||
m_Disassembly += m_Values[g.initialiser.idx].toString(true);
|
||||
m_Disassembly += m_Constants[g.initialiser.idx].toString(true);
|
||||
else
|
||||
m_Disassembly += g.type->inner->toString();
|
||||
|
||||
@@ -481,7 +481,7 @@ void Program::MakeDisassemblyString()
|
||||
for(size_t i = 0; i < m_NamedMeta.size(); i++)
|
||||
{
|
||||
namedMeta += StringFormat::Fmt("!%s = %s!{", m_NamedMeta[i].name.c_str(),
|
||||
m_NamedMeta[i].distinct ? "distinct " : "");
|
||||
m_NamedMeta[i].isDistinct ? "distinct " : "");
|
||||
for(size_t m = 0; m < m_NamedMeta[i].children.size(); m++)
|
||||
{
|
||||
if(m != 0)
|
||||
@@ -516,10 +516,11 @@ void Program::MakeDisassemblyString()
|
||||
if(s.idx < m_Metadata.size())
|
||||
{
|
||||
Metadata &m = m_Metadata[s.idx];
|
||||
if(m.value && m.val && m.val->symbol)
|
||||
ret += m.val->toString(withTypes);
|
||||
else if(m.value && m.val && (m.val->type->type == Type::Scalar || m.val->nullconst))
|
||||
ret += m.val->toString(withTypes);
|
||||
if(m.isConstant && m.constant && m.constant->symbol)
|
||||
ret += m.constant->toString(withTypes);
|
||||
else if(m.isConstant && m.constant &&
|
||||
(m.constant->type->type == Type::Scalar || m.constant->nullconst))
|
||||
ret += m.constant->toString(withTypes);
|
||||
else
|
||||
ret += StringFormat::Fmt("!%u", GetOrAssignMetaID(&m));
|
||||
}
|
||||
@@ -534,7 +535,9 @@ void Program::MakeDisassemblyString()
|
||||
ret = m_GlobalVars[s.idx].type->toString() + " ";
|
||||
ret += "@" + escapeStringIfNeeded(m_GlobalVars[s.idx].name);
|
||||
break;
|
||||
case SymbolType::Constant: ret = GetFunctionValue(func, s.idx)->toString(withTypes); break;
|
||||
case SymbolType::Constant:
|
||||
ret = GetFunctionConstant(func, s.idx)->toString(withTypes);
|
||||
break;
|
||||
case SymbolType::Argument:
|
||||
if(withTypes)
|
||||
ret = func.args[s.idx].type->toString() + " ";
|
||||
@@ -1194,7 +1197,7 @@ void Program::MakeDisassemblyString()
|
||||
{
|
||||
if(inst.args[0].type == SymbolType::Constant)
|
||||
{
|
||||
uint32_t opcode = GetFunctionValue(func, inst.args[0].idx)->val.uv[0];
|
||||
uint32_t opcode = GetFunctionConstant(func, inst.args[0].idx)->val.uv[0];
|
||||
if(opcode < ARRAY_COUNT(funcSigs))
|
||||
{
|
||||
m_Disassembly += " ; ";
|
||||
@@ -1208,8 +1211,9 @@ void Program::MakeDisassemblyString()
|
||||
if(inst.args[2].type == SymbolType::Constant && inst.args[3].type == SymbolType::Constant)
|
||||
{
|
||||
ResourceClass resClass =
|
||||
(ResourceClass)GetFunctionValue(func, inst.args[2].idx)->val.uv[0];
|
||||
ResourceKind resKind = (ResourceKind)GetFunctionValue(func, inst.args[3].idx)->val.uv[0];
|
||||
(ResourceClass)GetFunctionConstant(func, inst.args[2].idx)->val.uv[0];
|
||||
ResourceKind resKind =
|
||||
(ResourceKind)GetFunctionConstant(func, inst.args[3].idx)->val.uv[0];
|
||||
|
||||
m_Disassembly += " resource: ";
|
||||
|
||||
@@ -1217,7 +1221,7 @@ void Program::MakeDisassemblyString()
|
||||
|
||||
uint32_t packedProps[2] = {};
|
||||
|
||||
const Value *props = GetFunctionValue(func, inst.args[4].idx);
|
||||
const Constant *props = GetFunctionConstant(func, inst.args[4].idx);
|
||||
|
||||
if(props && !props->nullconst)
|
||||
{
|
||||
@@ -1386,9 +1390,9 @@ void Program::MakeDisassemblyString()
|
||||
{
|
||||
if(numIdx < m_NumberedMeta.size() && m_NumberedMeta[numIdx]->id == i)
|
||||
{
|
||||
m_Disassembly +=
|
||||
StringFormat::Fmt("!%u = %s%s\n", i, m_NumberedMeta[numIdx]->distinct ? "distinct " : "",
|
||||
m_NumberedMeta[numIdx]->valString().c_str());
|
||||
m_Disassembly += StringFormat::Fmt("!%u = %s%s\n", i,
|
||||
m_NumberedMeta[numIdx]->isDistinct ? "distinct " : "",
|
||||
m_NumberedMeta[numIdx]->valString().c_str());
|
||||
if(m_NumberedMeta[numIdx]->dwarf)
|
||||
m_NumberedMeta[numIdx]->dwarf->setID(i);
|
||||
numIdx++;
|
||||
@@ -1552,7 +1556,7 @@ rdcstr Metadata::valString() const
|
||||
{
|
||||
return debugLoc->toString();
|
||||
}
|
||||
else if(value)
|
||||
else if(isConstant)
|
||||
{
|
||||
if(type == NULL)
|
||||
{
|
||||
@@ -1560,11 +1564,11 @@ rdcstr Metadata::valString() const
|
||||
}
|
||||
else
|
||||
{
|
||||
if(val)
|
||||
if(constant)
|
||||
{
|
||||
if(type != val->type)
|
||||
if(type != constant->type)
|
||||
RDCERR("Type mismatch in metadata");
|
||||
return val->toString(true);
|
||||
return constant->toString(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1594,7 +1598,7 @@ rdcstr Metadata::valString() const
|
||||
ret += ", ";
|
||||
if(!children[i])
|
||||
ret += "null";
|
||||
else if(children[i]->value)
|
||||
else if(children[i]->isConstant)
|
||||
ret += children[i]->valString();
|
||||
else
|
||||
ret += StringFormat::Fmt("!%u", children[i]->id);
|
||||
@@ -1605,7 +1609,7 @@ rdcstr Metadata::valString() const
|
||||
}
|
||||
}
|
||||
|
||||
rdcstr Value::toString(bool withType) const
|
||||
rdcstr Constant::toString(bool withType) const
|
||||
{
|
||||
if(type == NULL)
|
||||
return escapeString(str);
|
||||
@@ -1621,12 +1625,12 @@ rdcstr Value::toString(bool withType) const
|
||||
{
|
||||
ret += StringFormat::Fmt("@%s", escapeStringIfNeeded(str).c_str());
|
||||
}
|
||||
else if(op != Value::NoOp)
|
||||
else if(op != Constant::NoOp)
|
||||
{
|
||||
switch(op)
|
||||
{
|
||||
case Value::NoOp: break;
|
||||
case Value::GEP:
|
||||
case Constant::NoOp: break;
|
||||
case Constant::GEP:
|
||||
{
|
||||
ret += "getelementptr inbounds (";
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ enum class StructMemberAnnotation
|
||||
template <typename T>
|
||||
T getival(const Metadata *m)
|
||||
{
|
||||
return T(m->val->val.uv[0]);
|
||||
return T(m->constant->val.uv[0]);
|
||||
}
|
||||
|
||||
void Program::FetchComputeProperties(DXBC::Reflection *reflection)
|
||||
@@ -146,7 +146,7 @@ void Program::FetchComputeProperties(DXBC::Reflection *reflection)
|
||||
|
||||
for(size_t t = 0; t < tags.children.size(); t += 2)
|
||||
{
|
||||
RDCASSERT(tags.children[t]->value);
|
||||
RDCASSERT(tags.children[t]->isConstant);
|
||||
if(getival<ShaderTag>(tags.children[t]) == ShaderTag::Compute)
|
||||
{
|
||||
Metadata &threadDim = *tags.children[t + 1];
|
||||
@@ -187,7 +187,7 @@ D3D_PRIMITIVE_TOPOLOGY Program::GetOutputTopology()
|
||||
|
||||
for(size_t t = 0; t < tags.children.size(); t += 2)
|
||||
{
|
||||
RDCASSERT(tags.children[t]->value);
|
||||
RDCASSERT(tags.children[t]->isConstant);
|
||||
if(getival<ShaderTag>(tags.children[t]) == ShaderTag::Geometry)
|
||||
{
|
||||
Metadata &geomData = *tags.children[t + 1];
|
||||
@@ -558,7 +558,7 @@ static void AddResourceBind(DXBC::Reflection *refl, const TypeInfo &typeInfo, co
|
||||
uint32_t structStride = 0;
|
||||
for(size_t t = 0; tags && t < tags->children.size(); t += 2)
|
||||
{
|
||||
RDCASSERT(tags->children[t]->value);
|
||||
RDCASSERT(tags->children[t]->isConstant);
|
||||
if(getival<SRVUAVTag>(tags->children[t]) == SRVUAVTag::StructStride)
|
||||
{
|
||||
structStride = getival<uint32_t>(tags->children[t + 1]);
|
||||
|
||||
Reference in New Issue
Block a user