mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-09 00:01:07 +00:00
Remove static DXIL::dxcStyleFormatting and DXIL::dxilIdentifier
Pass in bool dxcStyleFormatting parameter to helper functions Derive dxilIdentifier from dxcStyleFormatting i.e. '%' or '_' DXIL Debugger and RD Disassembly specific helper methods choose to use "dxcStyleFormatting = false"
This commit is contained in:
@@ -113,9 +113,9 @@ struct Type
|
||||
static void *operator new(size_t count, BumpAllocator &b) { return b.alloc(count); }
|
||||
static void operator delete(void *ptr, BumpAllocator &b) {}
|
||||
bool isVoid() const { return type == Scalar && scalarType == Void; }
|
||||
rdcstr toString() const;
|
||||
rdcstr toString(bool dxcStyleFormatting) const;
|
||||
rdcstr declFunction(rdcstr funcName, const rdcarray<Instruction *> &args,
|
||||
const AttributeSet *attrs) const;
|
||||
const AttributeSet *attrs, bool dxcStyleFormatting) const;
|
||||
|
||||
// for scalars, arrays, vectors, pointers
|
||||
union
|
||||
@@ -716,7 +716,7 @@ struct Value
|
||||
static constexpr uint32_t VisitedID = 0x00fffffd;
|
||||
uint32_t id : 24;
|
||||
|
||||
rdcstr toString(bool withType = false) const;
|
||||
rdcstr toString(bool dxcStyleFormatting, bool withType = false) const;
|
||||
|
||||
static void *operator new(size_t count, BumpAllocator &b) { return b.alloc(count); }
|
||||
static void operator delete(void *ptr, BumpAllocator &b) {}
|
||||
@@ -1049,7 +1049,7 @@ struct Constant : public ForwardReferencableValue<Constant>
|
||||
return empty;
|
||||
}
|
||||
|
||||
rdcstr toString(bool withType = false) const;
|
||||
rdcstr toString(bool dxcStyleFormatting, bool withType = false) const;
|
||||
|
||||
private:
|
||||
union
|
||||
@@ -1099,7 +1099,7 @@ struct DIBase
|
||||
|
||||
DIBase(Type t) : type(t) {}
|
||||
virtual ~DIBase() = default;
|
||||
virtual rdcstr toString() const = 0;
|
||||
virtual rdcstr toString(bool dxcStyleFormatting) const = 0;
|
||||
virtual void setID(uint32_t ID) {}
|
||||
template <typename Derived>
|
||||
const Derived *As() const
|
||||
@@ -1125,7 +1125,7 @@ struct DebugLocation
|
||||
return line == o.line && col == o.col && scope == o.scope && inlinedAt == o.inlinedAt;
|
||||
}
|
||||
|
||||
rdcstr toString() const;
|
||||
rdcstr toString(bool dxcStyleFormatting) const;
|
||||
};
|
||||
|
||||
struct Metadata : public Value
|
||||
@@ -1147,8 +1147,8 @@ struct Metadata : public Value
|
||||
DIBase *dwarf = NULL;
|
||||
DebugLocation *debugLoc = NULL;
|
||||
|
||||
rdcstr refString() const;
|
||||
rdcstr valString() const;
|
||||
rdcstr refString(bool dxcStyleFormatting) const;
|
||||
rdcstr valString(bool dxcStyleFormatting) const;
|
||||
};
|
||||
|
||||
// loose wrapper around an array for metadata pointer. This creates metadata nodes on demand because
|
||||
@@ -1539,6 +1539,8 @@ public:
|
||||
|
||||
const Metadata *GetMetadataByName(const rdcstr &name) const;
|
||||
uint32_t GetDirectHeapAcessCount() const { return m_directHeapAccessCount; }
|
||||
|
||||
static char GetDXILIdentifier(const bool dxcStyle) { return dxcStyle ? '%' : '_'; }
|
||||
protected:
|
||||
void Parse(const DXBC::Reflection *reflection);
|
||||
void SettleIDs();
|
||||
|
||||
@@ -323,16 +323,16 @@ rdcstr getOptMetaString(const Metadata *meta)
|
||||
return meta ? escapeString(meta->str).c_str() : "\"\"";
|
||||
}
|
||||
|
||||
rdcstr DIFile::toString() const
|
||||
rdcstr DIFile::toString(bool dxcStyleFormatting) const
|
||||
{
|
||||
return StringFormat::Fmt("!DIFile(filename: %s, directory: %s)", getOptMetaString(file).c_str(),
|
||||
getOptMetaString(dir).c_str());
|
||||
}
|
||||
|
||||
rdcstr DICompileUnit::toString() const
|
||||
rdcstr DICompileUnit::toString(bool dxcStyleFormatting) const
|
||||
{
|
||||
rdcstr ret = StringFormat::Fmt("!DICompileUnit(language: %s, file: %s", ToStr(lang).c_str(),
|
||||
file ? file->refString().c_str() : "null");
|
||||
file ? file->refString(dxcStyleFormatting).c_str() : "null");
|
||||
|
||||
if(producer)
|
||||
ret += ", producer: " + escapeString(*producer);
|
||||
@@ -344,22 +344,22 @@ rdcstr DICompileUnit::toString() const
|
||||
ret += ", splitDebugFilename: " + escapeString(*splitDebugFilename);
|
||||
ret += StringFormat::Fmt(", emissionKind: %llu", emissionKind);
|
||||
if(enums)
|
||||
ret += ", enums: " + enums->refString();
|
||||
ret += ", enums: " + enums->refString(dxcStyleFormatting);
|
||||
if(retainedTypes)
|
||||
ret += ", retainedTypes: " + retainedTypes->refString();
|
||||
ret += ", retainedTypes: " + retainedTypes->refString(dxcStyleFormatting);
|
||||
if(subprograms)
|
||||
ret += ", subprograms: " + subprograms->refString();
|
||||
ret += ", subprograms: " + subprograms->refString(dxcStyleFormatting);
|
||||
if(globals)
|
||||
ret += ", globals: " + globals->refString();
|
||||
ret += ", globals: " + globals->refString(dxcStyleFormatting);
|
||||
if(imports)
|
||||
ret += ", imports: " + imports->refString();
|
||||
ret += ", imports: " + imports->refString(dxcStyleFormatting);
|
||||
|
||||
ret += ")";
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
rdcstr DIBasicType::toString() const
|
||||
rdcstr DIBasicType::toString(bool dxcStyleFormatting) const
|
||||
{
|
||||
rdcstr ret = "!DIBasicType(";
|
||||
if(tag != DW_TAG_base_type)
|
||||
@@ -372,19 +372,19 @@ rdcstr DIBasicType::toString() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
rdcstr DIDerivedType::toString() const
|
||||
rdcstr DIDerivedType::toString(bool dxcStyleFormatting) const
|
||||
{
|
||||
rdcstr ret = StringFormat::Fmt("!DIDerivedType(tag: %s", ToStr(tag).c_str());
|
||||
if(name)
|
||||
ret += StringFormat::Fmt(", name: %s", escapeString(*name).c_str());
|
||||
if(scope)
|
||||
ret += StringFormat::Fmt(", scope: %s", scope->refString().c_str());
|
||||
ret += StringFormat::Fmt(", scope: %s", scope->refString(dxcStyleFormatting).c_str());
|
||||
if(file)
|
||||
ret += StringFormat::Fmt(", file: %s", file->refString().c_str());
|
||||
ret += StringFormat::Fmt(", file: %s", file->refString(dxcStyleFormatting).c_str());
|
||||
if(line)
|
||||
ret += StringFormat::Fmt(", line: %llu", line);
|
||||
if(base)
|
||||
ret += StringFormat::Fmt(", baseType: %s", base->refString().c_str());
|
||||
ret += StringFormat::Fmt(", baseType: %s", base->refString(dxcStyleFormatting).c_str());
|
||||
else
|
||||
ret += ", baseType: null";
|
||||
if(sizeInBits)
|
||||
@@ -396,24 +396,24 @@ rdcstr DIDerivedType::toString() const
|
||||
if(flags != DIFlagNone)
|
||||
ret += StringFormat::Fmt(", flags: %s", ToStr(flags).c_str());
|
||||
if(extra)
|
||||
ret += StringFormat::Fmt(", extraData: %s", extra->refString().c_str());
|
||||
ret += StringFormat::Fmt(", extraData: %s", extra->refString(dxcStyleFormatting).c_str());
|
||||
ret += ")";
|
||||
return ret;
|
||||
}
|
||||
|
||||
rdcstr DICompositeType::toString() const
|
||||
rdcstr DICompositeType::toString(bool dxcStyleFormatting) const
|
||||
{
|
||||
rdcstr ret = StringFormat::Fmt("!DICompositeType(tag: %s", ToStr(tag).c_str());
|
||||
if(name)
|
||||
ret += StringFormat::Fmt(", name: %s", escapeString(*name).c_str());
|
||||
if(scope)
|
||||
ret += StringFormat::Fmt(", scope: %s", scope->refString().c_str());
|
||||
ret += StringFormat::Fmt(", scope: %s", scope->refString(dxcStyleFormatting).c_str());
|
||||
if(file)
|
||||
ret += StringFormat::Fmt(", file: %s", file->refString().c_str());
|
||||
ret += StringFormat::Fmt(", file: %s", file->refString(dxcStyleFormatting).c_str());
|
||||
if(line)
|
||||
ret += StringFormat::Fmt(", line: %llu", line);
|
||||
if(base)
|
||||
ret += StringFormat::Fmt(", baseType: %s", base->refString().c_str());
|
||||
ret += StringFormat::Fmt(", baseType: %s", base->refString(dxcStyleFormatting).c_str());
|
||||
if(sizeInBits)
|
||||
ret += StringFormat::Fmt(", size: %llu", sizeInBits);
|
||||
if(alignInBits)
|
||||
@@ -423,14 +423,15 @@ rdcstr DICompositeType::toString() const
|
||||
if(flags != DIFlagNone)
|
||||
ret += StringFormat::Fmt(", flags: %s", ToStr(flags).c_str());
|
||||
if(elements)
|
||||
ret += StringFormat::Fmt(", elements: %s", elements->refString().c_str());
|
||||
ret += StringFormat::Fmt(", elements: %s", elements->refString(dxcStyleFormatting).c_str());
|
||||
if(templateParams)
|
||||
ret += StringFormat::Fmt(", templateParams: %s", templateParams->refString().c_str());
|
||||
ret += StringFormat::Fmt(", templateParams: %s",
|
||||
templateParams->refString(dxcStyleFormatting).c_str());
|
||||
ret += ")";
|
||||
return ret;
|
||||
}
|
||||
|
||||
rdcstr DIEnum::toString() const
|
||||
rdcstr DIEnum::toString(bool dxcStyleFormatting) const
|
||||
{
|
||||
rdcstr ret = "!DIEnumerator(";
|
||||
ret += StringFormat::Fmt("name: %s", escapeString(*name).c_str());
|
||||
@@ -439,22 +440,22 @@ rdcstr DIEnum::toString() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
rdcstr DITemplateTypeParameter::toString() const
|
||||
rdcstr DITemplateTypeParameter::toString(bool dxcStyleFormatting) const
|
||||
{
|
||||
return StringFormat::Fmt("!DITemplateTypeParameter(name: %s, type: %s)",
|
||||
escapeString(name ? *name : rdcstr()).c_str(),
|
||||
type ? type->refString().c_str() : "null");
|
||||
type ? type->refString(dxcStyleFormatting).c_str() : "null");
|
||||
}
|
||||
|
||||
rdcstr DITemplateValueParameter::toString() const
|
||||
rdcstr DITemplateValueParameter::toString(bool dxcStyleFormatting) const
|
||||
{
|
||||
return StringFormat::Fmt("!DITemplateValueParameter(name: %s, type: %s, value: %s)",
|
||||
escapeString(name ? *name : rdcstr()).c_str(),
|
||||
type ? type->refString().c_str() : "null",
|
||||
value ? value->refString().c_str() : "null");
|
||||
type ? type->refString(dxcStyleFormatting).c_str() : "null",
|
||||
value ? value->refString(dxcStyleFormatting).c_str() : "null");
|
||||
}
|
||||
|
||||
rdcstr DISubprogram::toString() const
|
||||
rdcstr DISubprogram::toString(bool dxcStyleFormatting) const
|
||||
{
|
||||
rdcstr ret = "!DISubprogram(";
|
||||
if(name)
|
||||
@@ -462,21 +463,22 @@ rdcstr DISubprogram::toString() const
|
||||
if(linkageName)
|
||||
ret += StringFormat::Fmt("linkageName: %s, ", escapeString(*linkageName).c_str());
|
||||
if(scope)
|
||||
ret += StringFormat::Fmt("scope: %s, ", scope->refString().c_str());
|
||||
ret += StringFormat::Fmt("scope: %s, ", scope->refString(dxcStyleFormatting).c_str());
|
||||
if(file)
|
||||
ret += StringFormat::Fmt("file: %s", file->refString().c_str());
|
||||
ret += StringFormat::Fmt("file: %s", file->refString(dxcStyleFormatting).c_str());
|
||||
else
|
||||
ret += "file: null";
|
||||
if(line)
|
||||
ret += StringFormat::Fmt(", line: %llu", line);
|
||||
if(type)
|
||||
ret += StringFormat::Fmt(", type: %s", type->refString().c_str());
|
||||
ret += StringFormat::Fmt(", type: %s", type->refString(dxcStyleFormatting).c_str());
|
||||
ret += StringFormat::Fmt(", isLocal: %s", isLocal ? "true" : "false");
|
||||
ret += StringFormat::Fmt(", isDefinition: %s", isDefinition ? "true" : "false");
|
||||
if(scopeLine)
|
||||
ret += StringFormat::Fmt(", scopeLine: %llu", scopeLine);
|
||||
if(containingType)
|
||||
ret += StringFormat::Fmt(", containingType: %s", containingType->refString().c_str());
|
||||
ret += StringFormat::Fmt(", containingType: %s",
|
||||
containingType->refString(dxcStyleFormatting).c_str());
|
||||
|
||||
if(virtuality)
|
||||
{
|
||||
@@ -491,73 +493,74 @@ rdcstr DISubprogram::toString() const
|
||||
ret += StringFormat::Fmt(", isOptimized: %s", isOptimized ? "true" : "false");
|
||||
|
||||
if(function)
|
||||
ret += StringFormat::Fmt(", function: %s", function->refString().c_str());
|
||||
ret += StringFormat::Fmt(", function: %s", function->refString(dxcStyleFormatting).c_str());
|
||||
if(templateParams)
|
||||
ret += StringFormat::Fmt(", templateParams: %s", templateParams->refString().c_str());
|
||||
ret += StringFormat::Fmt(", templateParams: %s",
|
||||
templateParams->refString(dxcStyleFormatting).c_str());
|
||||
if(declaration)
|
||||
ret += StringFormat::Fmt(", declaration: %s", declaration->refString().c_str());
|
||||
ret += StringFormat::Fmt(", declaration: %s", declaration->refString(dxcStyleFormatting).c_str());
|
||||
if(variables)
|
||||
ret += StringFormat::Fmt(", variables: %s", variables->refString().c_str());
|
||||
ret += StringFormat::Fmt(", variables: %s", variables->refString(dxcStyleFormatting).c_str());
|
||||
|
||||
ret += ")";
|
||||
return ret;
|
||||
}
|
||||
|
||||
rdcstr DISubroutineType::toString() const
|
||||
rdcstr DISubroutineType::toString(bool dxcStyleFormatting) const
|
||||
{
|
||||
return StringFormat::Fmt("!DISubroutineType(types: %s)",
|
||||
types ? types->refString().c_str() : "null");
|
||||
types ? types->refString(dxcStyleFormatting).c_str() : "null");
|
||||
}
|
||||
|
||||
rdcstr DIGlobalVariable::toString() const
|
||||
rdcstr DIGlobalVariable::toString(bool dxcStyleFormatting) const
|
||||
{
|
||||
rdcstr ret =
|
||||
StringFormat::Fmt("!DIGlobalVariable(name: %s", escapeString(name ? *name : rdcstr()).c_str());
|
||||
if(linkageName)
|
||||
ret += StringFormat::Fmt(", linkageName: %s", escapeString(*linkageName).c_str());
|
||||
if(scope)
|
||||
ret += StringFormat::Fmt(", scope: %s", scope->refString().c_str());
|
||||
ret += StringFormat::Fmt(", scope: %s", scope->refString(dxcStyleFormatting).c_str());
|
||||
if(file)
|
||||
ret += StringFormat::Fmt(", file: %s", file->refString().c_str());
|
||||
ret += StringFormat::Fmt(", file: %s", file->refString(dxcStyleFormatting).c_str());
|
||||
else
|
||||
ret += ", file: null";
|
||||
if(line)
|
||||
ret += StringFormat::Fmt(", line: %llu", line);
|
||||
if(type)
|
||||
ret += StringFormat::Fmt(", type: %s", type->refString().c_str());
|
||||
ret += StringFormat::Fmt(", type: %s", type->refString(dxcStyleFormatting).c_str());
|
||||
ret += StringFormat::Fmt(", isLocal: %s", isLocal ? "true" : "false");
|
||||
ret += StringFormat::Fmt(", isDefinition: %s", isDefinition ? "true" : "false");
|
||||
if(declaration)
|
||||
ret += StringFormat::Fmt(", declaration: %s", declaration->refString().c_str());
|
||||
ret += StringFormat::Fmt(", declaration: %s", declaration->refString(dxcStyleFormatting).c_str());
|
||||
if(variable)
|
||||
ret += StringFormat::Fmt(", variable: %s", variable->refString().c_str());
|
||||
ret += StringFormat::Fmt(", variable: %s", variable->refString(dxcStyleFormatting).c_str());
|
||||
ret += ")";
|
||||
return ret;
|
||||
}
|
||||
|
||||
rdcstr DILocalVariable::toString() const
|
||||
rdcstr DILocalVariable::toString(bool dxcStyleFormatting) const
|
||||
{
|
||||
rdcstr ret = StringFormat::Fmt("!DILocalVariable(tag: %s, name: %s", ToStr(tag).c_str(),
|
||||
escapeString(name ? *name : rdcstr()).c_str());
|
||||
if(arg || tag != DW_TAG_auto_variable)
|
||||
ret += StringFormat::Fmt(", arg: %llu", arg);
|
||||
if(scope)
|
||||
ret += StringFormat::Fmt(", scope: %s", scope->refString().c_str());
|
||||
ret += StringFormat::Fmt(", scope: %s", scope->refString(dxcStyleFormatting).c_str());
|
||||
else
|
||||
ret += ", scope: null";
|
||||
if(file)
|
||||
ret += StringFormat::Fmt(", file: %s", file->refString().c_str());
|
||||
ret += StringFormat::Fmt(", file: %s", file->refString(dxcStyleFormatting).c_str());
|
||||
if(line)
|
||||
ret += StringFormat::Fmt(", line: %llu", line);
|
||||
if(type)
|
||||
ret += StringFormat::Fmt(", type: %s", type->refString().c_str());
|
||||
ret += StringFormat::Fmt(", type: %s", type->refString(dxcStyleFormatting).c_str());
|
||||
if(flags != DIFlagNone)
|
||||
ret += StringFormat::Fmt(", flags: %s", ToStr(flags).c_str());
|
||||
ret += ")";
|
||||
return ret;
|
||||
}
|
||||
|
||||
rdcstr DIExpression::toString() const
|
||||
rdcstr DIExpression::toString(bool dxcStyleFormatting) const
|
||||
{
|
||||
if(op == DW_OP_bit_piece)
|
||||
return StringFormat::Fmt("!DIExpression(DW_OP_bit_piece, %llu, %llu)",
|
||||
@@ -580,15 +583,15 @@ rdcstr DIExpression::toString() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
rdcstr DILexicalBlock::toString() const
|
||||
rdcstr DILexicalBlock::toString(bool dxcStyleFormatting) const
|
||||
{
|
||||
rdcstr ret = "!DILexicalBlock(";
|
||||
if(scope)
|
||||
ret += StringFormat::Fmt("scope: %s", scope->refString().c_str());
|
||||
ret += StringFormat::Fmt("scope: %s", scope->refString(dxcStyleFormatting).c_str());
|
||||
else
|
||||
ret += "scope: null";
|
||||
if(file)
|
||||
ret += StringFormat::Fmt(", file: %s", file->refString().c_str());
|
||||
ret += StringFormat::Fmt(", file: %s", file->refString(dxcStyleFormatting).c_str());
|
||||
if(line)
|
||||
ret += StringFormat::Fmt(", line: %llu", line);
|
||||
if(column)
|
||||
@@ -597,7 +600,7 @@ rdcstr DILexicalBlock::toString() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
rdcstr DISubrange::toString() const
|
||||
rdcstr DISubrange::toString(bool dxcStyleFormatting) const
|
||||
{
|
||||
rdcstr ret = "!DISubrange(";
|
||||
ret += StringFormat::Fmt("count: %lld", count);
|
||||
@@ -607,33 +610,33 @@ rdcstr DISubrange::toString() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
rdcstr DINamespace::toString() const
|
||||
rdcstr DINamespace::toString(bool dxcStyleFormatting) const
|
||||
{
|
||||
rdcstr ret = "!DINamespace(";
|
||||
if(name)
|
||||
ret += StringFormat::Fmt("name: %s, ", escapeString(*name).c_str());
|
||||
if(scope)
|
||||
ret += StringFormat::Fmt("scope: %s", scope->refString().c_str());
|
||||
ret += StringFormat::Fmt("scope: %s", scope->refString(dxcStyleFormatting).c_str());
|
||||
else
|
||||
ret += "scope: null";
|
||||
if(file)
|
||||
ret += StringFormat::Fmt(", file: %s", file->refString().c_str());
|
||||
ret += StringFormat::Fmt(", file: %s", file->refString(dxcStyleFormatting).c_str());
|
||||
ret += StringFormat::Fmt(", line: %llu", line);
|
||||
ret += ")";
|
||||
return ret;
|
||||
}
|
||||
|
||||
rdcstr DIImportedEntity::toString() const
|
||||
rdcstr DIImportedEntity::toString(bool dxcStyleFormatting) const
|
||||
{
|
||||
rdcstr ret = StringFormat::Fmt("!DIImportedEntity(tag: %s", ToStr(tag).c_str());
|
||||
if(name)
|
||||
ret += StringFormat::Fmt(", name: %s, ", escapeString(*name).c_str());
|
||||
if(scope)
|
||||
ret += StringFormat::Fmt(", scope: %s", scope->refString().c_str());
|
||||
ret += StringFormat::Fmt(", scope: %s", scope->refString(dxcStyleFormatting).c_str());
|
||||
else
|
||||
ret += ", scope: null";
|
||||
if(entity)
|
||||
ret += StringFormat::Fmt(", entity: %s", entity->refString().c_str());
|
||||
ret += StringFormat::Fmt(", entity: %s", entity->refString(dxcStyleFormatting).c_str());
|
||||
if(line)
|
||||
ret += StringFormat::Fmt(", line: %llu", line);
|
||||
ret += ")";
|
||||
|
||||
@@ -363,7 +363,7 @@ struct DIFile : public DIBase
|
||||
const Metadata *file;
|
||||
const Metadata *dir;
|
||||
|
||||
virtual rdcstr toString() const;
|
||||
virtual rdcstr toString(bool dxcStyleFormatting) const;
|
||||
};
|
||||
|
||||
struct DICompileUnit : public DIBase
|
||||
@@ -404,7 +404,7 @@ struct DICompileUnit : public DIBase
|
||||
const Metadata *globals;
|
||||
const Metadata *imports;
|
||||
|
||||
virtual rdcstr toString() const;
|
||||
virtual rdcstr toString(bool dxcStyleFormatting) const;
|
||||
};
|
||||
|
||||
struct DIBasicType : public DIBase
|
||||
@@ -427,7 +427,7 @@ struct DIBasicType : public DIBase
|
||||
uint64_t alignInBits;
|
||||
DW_ENCODING encoding;
|
||||
|
||||
virtual rdcstr toString() const;
|
||||
virtual rdcstr toString(bool dxcStyleFormatting) const;
|
||||
};
|
||||
|
||||
struct DIDerivedType : public DIBase
|
||||
@@ -463,7 +463,7 @@ struct DIDerivedType : public DIBase
|
||||
DIFlags flags;
|
||||
const Metadata *extra;
|
||||
|
||||
virtual rdcstr toString() const;
|
||||
virtual rdcstr toString(bool dxcStyleFormatting) const;
|
||||
};
|
||||
|
||||
struct DICompositeType : public DIBase
|
||||
@@ -502,7 +502,7 @@ struct DICompositeType : public DIBase
|
||||
const Metadata *elements;
|
||||
const Metadata *templateParams;
|
||||
|
||||
virtual rdcstr toString() const;
|
||||
virtual rdcstr toString(bool dxcStyleFormatting) const;
|
||||
};
|
||||
|
||||
struct DIEnum : public DIBase
|
||||
@@ -512,7 +512,7 @@ struct DIEnum : public DIBase
|
||||
int64_t value;
|
||||
const rdcstr *name;
|
||||
|
||||
virtual rdcstr toString() const;
|
||||
virtual rdcstr toString(bool dxcStyleFormatting) const;
|
||||
};
|
||||
|
||||
struct DITemplateTypeParameter : public DIBase
|
||||
@@ -525,7 +525,7 @@ struct DITemplateTypeParameter : public DIBase
|
||||
const rdcstr *name;
|
||||
const Metadata *type;
|
||||
|
||||
virtual rdcstr toString() const;
|
||||
virtual rdcstr toString(bool dxcStyleFormatting) const;
|
||||
};
|
||||
|
||||
struct DITemplateValueParameter : public DIBase
|
||||
@@ -541,7 +541,7 @@ struct DITemplateValueParameter : public DIBase
|
||||
const Metadata *type;
|
||||
const Metadata *value;
|
||||
|
||||
virtual rdcstr toString() const;
|
||||
virtual rdcstr toString(bool dxcStyleFormatting) const;
|
||||
};
|
||||
|
||||
struct DISubprogram : public DIBase
|
||||
@@ -600,7 +600,7 @@ struct DISubprogram : public DIBase
|
||||
function->id = ID;
|
||||
}
|
||||
|
||||
virtual rdcstr toString() const;
|
||||
virtual rdcstr toString(bool dxcStyleFormatting) const;
|
||||
};
|
||||
|
||||
struct DISubroutineType : public DIBase
|
||||
@@ -609,7 +609,7 @@ struct DISubroutineType : public DIBase
|
||||
DISubroutineType(const Metadata *types) : DIBase(DIType), types(types) {}
|
||||
const Metadata *types;
|
||||
|
||||
virtual rdcstr toString() const;
|
||||
virtual rdcstr toString(bool dxcStyleFormatting) const;
|
||||
};
|
||||
|
||||
struct DIGlobalVariable : public DIBase
|
||||
@@ -643,7 +643,7 @@ struct DIGlobalVariable : public DIBase
|
||||
const Metadata *variable;
|
||||
const Metadata *declaration;
|
||||
|
||||
virtual rdcstr toString() const;
|
||||
virtual rdcstr toString(bool dxcStyleFormatting) const;
|
||||
};
|
||||
|
||||
struct DILocalVariable : public DIBase
|
||||
@@ -673,7 +673,7 @@ struct DILocalVariable : public DIBase
|
||||
DIFlags flags;
|
||||
uint64_t alignInBits;
|
||||
|
||||
virtual rdcstr toString() const;
|
||||
virtual rdcstr toString(bool dxcStyleFormatting) const;
|
||||
};
|
||||
|
||||
struct DIExpression : public DIBase
|
||||
@@ -691,7 +691,7 @@ struct DIExpression : public DIBase
|
||||
} bit_piece;
|
||||
} evaluated;
|
||||
|
||||
virtual rdcstr toString() const;
|
||||
virtual rdcstr toString(bool dxcStyleFormatting) const;
|
||||
};
|
||||
|
||||
struct DILexicalBlock : public DIBase
|
||||
@@ -707,7 +707,7 @@ struct DILexicalBlock : public DIBase
|
||||
uint64_t line;
|
||||
uint64_t column;
|
||||
|
||||
virtual rdcstr toString() const;
|
||||
virtual rdcstr toString(bool dxcStyleFormatting) const;
|
||||
};
|
||||
|
||||
struct DISubrange : public DIBase
|
||||
@@ -721,7 +721,7 @@ struct DISubrange : public DIBase
|
||||
int64_t count;
|
||||
int64_t lowerBound;
|
||||
|
||||
virtual rdcstr toString() const;
|
||||
virtual rdcstr toString(bool dxcStyleFormatting) const;
|
||||
};
|
||||
|
||||
struct DINamespace : public DIBase
|
||||
@@ -737,7 +737,7 @@ struct DINamespace : public DIBase
|
||||
const rdcstr *name;
|
||||
uint64_t line;
|
||||
|
||||
virtual rdcstr toString() const;
|
||||
virtual rdcstr toString(bool dxcStyleFormatting) const;
|
||||
};
|
||||
|
||||
struct DIImportedEntity : public DIBase
|
||||
@@ -755,7 +755,7 @@ struct DIImportedEntity : public DIBase
|
||||
uint64_t line;
|
||||
const rdcstr *name;
|
||||
|
||||
virtual rdcstr toString() const;
|
||||
virtual rdcstr toString(bool dxcStyleFormatting) const;
|
||||
};
|
||||
}; // namespace DXIL
|
||||
|
||||
|
||||
@@ -38,9 +38,6 @@
|
||||
|
||||
namespace DXIL
|
||||
{
|
||||
static bool dxcStyleFormatting = true;
|
||||
static char dxilIdentifier = '%';
|
||||
|
||||
bool needsEscaping(const rdcstr &name)
|
||||
{
|
||||
return name.find_first_not_of(
|
||||
@@ -1230,7 +1227,8 @@ const Metadata *Program::FindMetadata(uint32_t slot) const
|
||||
rdcstr Program::ArgToString(const Value *v, bool withTypes, const rdcstr &attrString) const
|
||||
{
|
||||
rdcstr ret;
|
||||
|
||||
const bool dxcStyleFormatting = m_DXCStyle;
|
||||
const char dxilIdentifier = Program::GetDXILIdentifier(dxcStyleFormatting);
|
||||
if(const Literal *lit = cast<Literal>(v))
|
||||
{
|
||||
if(withTypes)
|
||||
@@ -1253,16 +1251,16 @@ rdcstr Program::ArgToString(const Value *v, bool withTypes, const rdcstr &attrSt
|
||||
metaConst->isUndef() || metaConst->isNULL() ||
|
||||
metaConst->type->name.beginsWith("class.matrix.")))
|
||||
{
|
||||
ret += metaConst->toString(withTypes);
|
||||
ret += metaConst->toString(dxcStyleFormatting, withTypes);
|
||||
}
|
||||
else if(m.isConstant && metaInst)
|
||||
{
|
||||
ret += m.valString();
|
||||
ret += m.valString(dxcStyleFormatting);
|
||||
}
|
||||
else if(m.isConstant && metaGlobal)
|
||||
{
|
||||
if(withTypes)
|
||||
ret += metaGlobal->type->toString() + " ";
|
||||
ret += metaGlobal->type->toString(dxcStyleFormatting) + " ";
|
||||
ret += "@" + escapeStringIfNeeded(metaGlobal->name);
|
||||
}
|
||||
else
|
||||
@@ -1279,45 +1277,43 @@ rdcstr Program::ArgToString(const Value *v, bool withTypes, const rdcstr &attrSt
|
||||
else if(const GlobalVar *global = cast<GlobalVar>(v))
|
||||
{
|
||||
if(withTypes)
|
||||
ret = global->type->toString() + " ";
|
||||
ret = global->type->toString(dxcStyleFormatting) + " ";
|
||||
ret += attrString;
|
||||
ret += "@" + escapeStringIfNeeded(global->name);
|
||||
}
|
||||
else if(const Constant *c = cast<Constant>(v))
|
||||
{
|
||||
ret += attrString;
|
||||
ret = c->toString(withTypes);
|
||||
ret = c->toString(dxcStyleFormatting, withTypes);
|
||||
}
|
||||
else if(const Instruction *inst = cast<Instruction>(v))
|
||||
{
|
||||
if(withTypes)
|
||||
ret = inst->type->toString() + " ";
|
||||
ret = inst->type->toString(dxcStyleFormatting) + " ";
|
||||
ret += attrString;
|
||||
if(inst->getName().empty())
|
||||
ret += StringFormat::Fmt("%c%u", DXIL::dxilIdentifier, inst->slot);
|
||||
ret += StringFormat::Fmt("%c%u", dxilIdentifier, inst->slot);
|
||||
else
|
||||
ret += StringFormat::Fmt("%c%s", DXIL::dxilIdentifier,
|
||||
escapeStringIfNeeded(inst->getName()).c_str());
|
||||
ret += StringFormat::Fmt("%c%s", dxilIdentifier, escapeStringIfNeeded(inst->getName()).c_str());
|
||||
}
|
||||
else if(const Block *block = cast<Block>(v))
|
||||
{
|
||||
if(withTypes)
|
||||
ret = "label ";
|
||||
ret += attrString;
|
||||
if(DXIL::dxcStyleFormatting)
|
||||
if(dxcStyleFormatting)
|
||||
{
|
||||
if(block->name.empty())
|
||||
ret += StringFormat::Fmt("%c%u", DXIL::dxilIdentifier, block->slot);
|
||||
ret += StringFormat::Fmt("%c%u", dxilIdentifier, block->slot);
|
||||
else
|
||||
ret += StringFormat::Fmt("%c%s", DXIL::dxilIdentifier,
|
||||
escapeStringIfNeeded(block->name).c_str());
|
||||
ret += StringFormat::Fmt("%c%s", dxilIdentifier, escapeStringIfNeeded(block->name).c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
if(block->name.empty())
|
||||
ret += StringFormat::Fmt("%clabel%u", DXIL::dxilIdentifier, block->slot);
|
||||
ret += StringFormat::Fmt("%clabel%u", dxilIdentifier, block->slot);
|
||||
else
|
||||
ret += StringFormat::Fmt("%clabel_%s%u", DXIL::dxilIdentifier,
|
||||
ret += StringFormat::Fmt("%clabel_%s%u", dxilIdentifier,
|
||||
DXBC::BasicDemangle(block->name).c_str(), block->id);
|
||||
}
|
||||
}
|
||||
@@ -1357,13 +1353,14 @@ rdcstr Program::DisassembleComDats(int &instructionLine) const
|
||||
|
||||
rdcstr Program::DisassembleTypes(int &instructionLine) const
|
||||
{
|
||||
const bool dxcStyleFormatting = m_DXCStyle;
|
||||
rdcstr ret;
|
||||
bool printedTypes = false;
|
||||
for(const Type *typ : m_Accum.printOrderTypes)
|
||||
{
|
||||
if(typ->type == Type::Struct && !typ->name.empty())
|
||||
{
|
||||
rdcstr name = typ->toString();
|
||||
rdcstr name = typ->toString(dxcStyleFormatting);
|
||||
ret += StringFormat::Fmt("%s = type { ", name.c_str());
|
||||
bool first = true;
|
||||
for(const Type *t : typ->members)
|
||||
@@ -1371,7 +1368,7 @@ rdcstr Program::DisassembleTypes(int &instructionLine) const
|
||||
if(!first)
|
||||
ret += ", ";
|
||||
first = false;
|
||||
ret += StringFormat::Fmt("%s", t->toString().c_str());
|
||||
ret += StringFormat::Fmt("%s", t->toString(dxcStyleFormatting).c_str());
|
||||
}
|
||||
if(typ->members.empty())
|
||||
{
|
||||
@@ -1398,6 +1395,7 @@ rdcstr Program::DisassembleTypes(int &instructionLine) const
|
||||
|
||||
rdcstr Program::DisassembleGlobalVars(int &instructionLine) const
|
||||
{
|
||||
const bool dxcStyleFormatting = m_DXCStyle;
|
||||
rdcstr ret;
|
||||
for(size_t i = 0; i < m_GlobalVars.size(); i++)
|
||||
{
|
||||
@@ -1435,9 +1433,9 @@ rdcstr Program::DisassembleGlobalVars(int &instructionLine) const
|
||||
ret += "global ";
|
||||
|
||||
if(g.initialiser)
|
||||
ret += g.initialiser->toString(true);
|
||||
ret += g.initialiser->toString(dxcStyleFormatting, true);
|
||||
else
|
||||
ret += g.type->inner->toString();
|
||||
ret += g.type->inner->toString(dxcStyleFormatting);
|
||||
|
||||
if(g.align > 0)
|
||||
ret += StringFormat::Fmt(", align %u", g.align);
|
||||
@@ -1498,6 +1496,7 @@ rdcstr Program::DisassembleFuncAttrGroups() const
|
||||
|
||||
rdcstr Program::DisassembleMeta() const
|
||||
{
|
||||
const bool dxcStyleFormatting = m_DXCStyle;
|
||||
rdcstr ret;
|
||||
size_t numIdx = 0;
|
||||
size_t dbgIdx = 0;
|
||||
@@ -1508,7 +1507,7 @@ rdcstr Program::DisassembleMeta() const
|
||||
{
|
||||
rdcstr metaline =
|
||||
StringFormat::Fmt("!%u = %s%s\n", i, m_MetaSlots[numIdx]->isDistinct ? "distinct " : "",
|
||||
m_MetaSlots[numIdx]->valString().c_str());
|
||||
m_MetaSlots[numIdx]->valString(dxcStyleFormatting).c_str());
|
||||
#if ENABLED(DXC_COMPATIBLE_DISASM)
|
||||
for(size_t c = 0; c < metaline.size(); c += 4096)
|
||||
ret += metaline.substr(c, 4096);
|
||||
@@ -1521,7 +1520,8 @@ rdcstr Program::DisassembleMeta() const
|
||||
}
|
||||
else if(dbgIdx < m_DebugLocations.size() && m_DebugLocations[dbgIdx].slot == i)
|
||||
{
|
||||
ret += StringFormat::Fmt("!%u = %s\n", i, m_DebugLocations[dbgIdx].toString().c_str());
|
||||
ret += StringFormat::Fmt("!%u = %s\n", i,
|
||||
m_DebugLocations[dbgIdx].toString(dxcStyleFormatting).c_str());
|
||||
dbgIdx++;
|
||||
}
|
||||
else
|
||||
@@ -1548,17 +1548,6 @@ const rdcstr &Program::GetDisassembly(bool dxcStyle, const DXBC::Reflection *ref
|
||||
if(m_Disassembly.empty() || (dxcStyle != m_DXCStyle))
|
||||
{
|
||||
m_DXCStyle = dxcStyle;
|
||||
// Need to set the style formatting before Parse() to get consistent SSA identifiers
|
||||
if(m_DXCStyle)
|
||||
{
|
||||
DXIL::dxcStyleFormatting = true;
|
||||
DXIL::dxilIdentifier = '%';
|
||||
}
|
||||
else
|
||||
{
|
||||
DXIL::dxcStyleFormatting = false;
|
||||
DXIL::dxilIdentifier = '_';
|
||||
}
|
||||
|
||||
Parse(reflection);
|
||||
|
||||
@@ -1572,6 +1561,9 @@ const rdcstr &Program::GetDisassembly(bool dxcStyle, const DXBC::Reflection *ref
|
||||
|
||||
void Program::MakeDXCDisassemblyString()
|
||||
{
|
||||
const bool dxcStyleFormatting = true;
|
||||
const char dxilIdentifier = Program::GetDXILIdentifier(dxcStyleFormatting);
|
||||
|
||||
m_Disassembly.clear();
|
||||
#if DISABLED(DXC_COMPATIBLE_DISASM)
|
||||
m_Disassembly += StringFormat::Fmt("; %s Shader, compiled under SM%u.%u\n\n",
|
||||
@@ -1605,8 +1597,8 @@ void Program::MakeDXCDisassemblyString()
|
||||
m_Disassembly += (func.external ? "declare " : "define ");
|
||||
if(func.internalLinkage)
|
||||
m_Disassembly += "internal ";
|
||||
m_Disassembly +=
|
||||
func.type->declFunction("@" + escapeStringIfNeeded(func.name), func.args, func.attrs);
|
||||
m_Disassembly += func.type->declFunction("@" + escapeStringIfNeeded(func.name), func.args,
|
||||
func.attrs, dxcStyleFormatting);
|
||||
|
||||
if(func.comdatIdx < m_Comdats.size())
|
||||
m_Disassembly += StringFormat::Fmt(
|
||||
@@ -1640,10 +1632,10 @@ void Program::MakeDXCDisassemblyString()
|
||||
inst.disassemblyLine = m_DisassemblyInstructionLine;
|
||||
m_Disassembly += " ";
|
||||
if(!inst.getName().empty())
|
||||
m_Disassembly += StringFormat::Fmt("%c%s = ", DXIL::dxilIdentifier,
|
||||
m_Disassembly += StringFormat::Fmt("%c%s = ", dxilIdentifier,
|
||||
escapeStringIfNeeded(inst.getName()).c_str());
|
||||
else if(inst.slot != ~0U)
|
||||
m_Disassembly += StringFormat::Fmt("%c%u = ", DXIL::dxilIdentifier, inst.slot);
|
||||
m_Disassembly += StringFormat::Fmt("%c%u = ", dxilIdentifier, inst.slot);
|
||||
|
||||
bool debugCall = false;
|
||||
|
||||
@@ -1653,7 +1645,7 @@ void Program::MakeDXCDisassemblyString()
|
||||
case Operation::Call:
|
||||
{
|
||||
rdcstr funcCallName = inst.getFuncCall()->name;
|
||||
m_Disassembly += "call " + inst.type->toString();
|
||||
m_Disassembly += "call " + inst.type->toString(dxcStyleFormatting);
|
||||
m_Disassembly += " @" + escapeStringIfNeeded(funcCallName);
|
||||
m_Disassembly += "(";
|
||||
bool first = true;
|
||||
@@ -1721,7 +1713,7 @@ void Program::MakeDXCDisassemblyString()
|
||||
|
||||
m_Disassembly += ArgToString(inst.args[0], true);
|
||||
m_Disassembly += " to ";
|
||||
m_Disassembly += inst.type->toString();
|
||||
m_Disassembly += inst.type->toString(dxcStyleFormatting);
|
||||
break;
|
||||
}
|
||||
case Operation::ExtractVal:
|
||||
@@ -1802,7 +1794,7 @@ void Program::MakeDXCDisassemblyString()
|
||||
case Operation::Ret:
|
||||
{
|
||||
if(inst.args.empty())
|
||||
m_Disassembly += "ret " + inst.type->toString();
|
||||
m_Disassembly += "ret " + inst.type->toString(dxcStyleFormatting);
|
||||
else
|
||||
m_Disassembly += "ret " + ArgToString(inst.args[0], true);
|
||||
break;
|
||||
@@ -1811,7 +1803,7 @@ void Program::MakeDXCDisassemblyString()
|
||||
case Operation::Alloca:
|
||||
{
|
||||
m_Disassembly += "alloca ";
|
||||
m_Disassembly += inst.type->inner->toString();
|
||||
m_Disassembly += inst.type->inner->toString(dxcStyleFormatting);
|
||||
if(inst.align > 0)
|
||||
m_Disassembly += StringFormat::Fmt(", align %u", (1U << inst.align) >> 1);
|
||||
break;
|
||||
@@ -1821,7 +1813,7 @@ void Program::MakeDXCDisassemblyString()
|
||||
m_Disassembly += "getelementptr ";
|
||||
if(inst.opFlags() & InstructionFlags::InBounds)
|
||||
m_Disassembly += "inbounds ";
|
||||
m_Disassembly += inst.args[0]->type->inner->toString();
|
||||
m_Disassembly += inst.args[0]->type->inner->toString(dxcStyleFormatting);
|
||||
m_Disassembly += ", ";
|
||||
bool first = true;
|
||||
for(const Value *s : inst.args)
|
||||
@@ -1839,7 +1831,7 @@ void Program::MakeDXCDisassemblyString()
|
||||
m_Disassembly += "load ";
|
||||
if(inst.opFlags() & InstructionFlags::Volatile)
|
||||
m_Disassembly += "volatile ";
|
||||
m_Disassembly += inst.type->toString();
|
||||
m_Disassembly += inst.type->toString(dxcStyleFormatting);
|
||||
m_Disassembly += ", ";
|
||||
bool first = true;
|
||||
for(const Value *s : inst.args)
|
||||
@@ -2020,7 +2012,7 @@ void Program::MakeDXCDisassemblyString()
|
||||
case Operation::Phi:
|
||||
{
|
||||
m_Disassembly += "phi ";
|
||||
m_Disassembly += inst.type->toString();
|
||||
m_Disassembly += inst.type->toString(dxcStyleFormatting);
|
||||
for(size_t a = 0; a < inst.args.size(); a += 2)
|
||||
{
|
||||
if(a == 0)
|
||||
@@ -2075,7 +2067,7 @@ void Program::MakeDXCDisassemblyString()
|
||||
m_Disassembly += "load atomic ";
|
||||
if(inst.opFlags() & InstructionFlags::Volatile)
|
||||
m_Disassembly += "volatile ";
|
||||
m_Disassembly += inst.type->toString();
|
||||
m_Disassembly += inst.type->toString(dxcStyleFormatting);
|
||||
m_Disassembly += ", ";
|
||||
bool first = true;
|
||||
for(const Value *s : inst.args)
|
||||
@@ -2257,7 +2249,7 @@ void Program::MakeDXCDisassemblyString()
|
||||
RDCASSERT(expr);
|
||||
m_Disassembly +=
|
||||
StringFormat::Fmt(" ; var:%s ", escapeString(GetDebugVarName(var->dwarf)).c_str());
|
||||
m_Disassembly += expr->valString();
|
||||
m_Disassembly += expr->valString(dxcStyleFormatting);
|
||||
|
||||
rdcstr funcName = GetFunctionScopeName(var->dwarf);
|
||||
if(!funcName.empty())
|
||||
@@ -2465,9 +2457,9 @@ void Program::MakeDXCDisassemblyString()
|
||||
labelName += ", ";
|
||||
first = false;
|
||||
if(pred->name.empty())
|
||||
labelName += StringFormat::Fmt("%c%u", DXIL::dxilIdentifier, pred->slot);
|
||||
labelName += StringFormat::Fmt("%c%u", dxilIdentifier, pred->slot);
|
||||
else
|
||||
labelName += StringFormat::Fmt("%c%s", DXIL::dxilIdentifier,
|
||||
labelName += StringFormat::Fmt("%c%s", dxilIdentifier,
|
||||
escapeStringIfNeeded(pred->name).c_str());
|
||||
}
|
||||
#endif
|
||||
@@ -2643,6 +2635,9 @@ rdcstr ProcessNormCompType(ComponentType &compType)
|
||||
|
||||
void Program::MakeRDDisassemblyString(const DXBC::Reflection *reflection)
|
||||
{
|
||||
const bool dxcStyleFormatting = m_DXCStyle;
|
||||
const char dxilIdentifier = Program::GetDXILIdentifier(dxcStyleFormatting);
|
||||
|
||||
m_Disassembly.clear();
|
||||
m_DisassemblyInstructionLine = 1;
|
||||
|
||||
@@ -2908,8 +2903,8 @@ void Program::MakeRDDisassemblyString(const DXBC::Reflection *reflection)
|
||||
|
||||
if(func.internalLinkage)
|
||||
m_Disassembly += "internal ";
|
||||
m_Disassembly +=
|
||||
func.type->declFunction("@" + escapeStringIfNeeded(func.name), func.args, func.attrs);
|
||||
m_Disassembly += func.type->declFunction("@" + escapeStringIfNeeded(func.name), func.args,
|
||||
func.attrs, dxcStyleFormatting);
|
||||
|
||||
if(func.comdatIdx < m_Comdats.size())
|
||||
m_Disassembly += StringFormat::Fmt(
|
||||
@@ -2944,7 +2939,7 @@ void Program::MakeRDDisassemblyString(const DXBC::Reflection *reflection)
|
||||
rdcstr resultTypeStr;
|
||||
if(!inst.type->isVoid())
|
||||
{
|
||||
resultTypeStr += inst.type->toString();
|
||||
resultTypeStr += inst.type->toString(dxcStyleFormatting);
|
||||
resultTypeStr += " ";
|
||||
}
|
||||
rdcstr resultIdStr;
|
||||
@@ -3890,7 +3885,9 @@ void Program::MakeRDDisassemblyString(const DXBC::Reflection *reflection)
|
||||
case Operation::FToU:
|
||||
case Operation::FToS:
|
||||
case Operation::PtrToI:
|
||||
case Operation::SToF: lineStr += "(" + inst.type->toString() + ")"; break;
|
||||
case Operation::SToF:
|
||||
lineStr += "(" + inst.type->toString(dxcStyleFormatting) + ")";
|
||||
break;
|
||||
case Operation::IToPtr: lineStr += "(void *)"; break;
|
||||
case Operation::AddrSpaceCast: lineStr += "addrspacecast"; break;
|
||||
default: break;
|
||||
@@ -4001,7 +3998,7 @@ void Program::MakeRDDisassemblyString(const DXBC::Reflection *reflection)
|
||||
case Operation::Alloca:
|
||||
{
|
||||
lineStr += "alloca ";
|
||||
lineStr += inst.type->inner->toString();
|
||||
lineStr += inst.type->inner->toString(dxcStyleFormatting);
|
||||
if(inst.align > 0)
|
||||
lineStr += StringFormat::Fmt(", align %u", (1U << inst.align) >> 1);
|
||||
break;
|
||||
@@ -4012,7 +4009,7 @@ void Program::MakeRDDisassemblyString(const DXBC::Reflection *reflection)
|
||||
if(!inst.type->isVoid())
|
||||
{
|
||||
// type "float addrspace(3)*" : addrspace(3) is DXIL specific, see DXIL::Type::PointerAddrSpace
|
||||
rdcstr typeStr = inst.type->toString();
|
||||
rdcstr typeStr = inst.type->toString(dxcStyleFormatting);
|
||||
int start = typeStr.find(" addrspace(");
|
||||
if(start > 0)
|
||||
{
|
||||
@@ -4333,7 +4330,7 @@ void Program::MakeRDDisassemblyString(const DXBC::Reflection *reflection)
|
||||
case Operation::Phi:
|
||||
{
|
||||
lineStr += "phi ";
|
||||
lineStr += inst.type->toString();
|
||||
lineStr += inst.type->toString(dxcStyleFormatting);
|
||||
for(uint32_t a = 0; a < inst.args.size(); a += 2)
|
||||
{
|
||||
if(a == 0)
|
||||
@@ -4509,10 +4506,9 @@ void Program::MakeRDDisassemblyString(const DXBC::Reflection *reflection)
|
||||
rdcstr labelName;
|
||||
|
||||
if(func.blocks[curBlock]->name.empty())
|
||||
labelName =
|
||||
StringFormat::Fmt("%clabel%u: ", DXIL::dxilIdentifier, func.blocks[curBlock]->slot);
|
||||
labelName = StringFormat::Fmt("%clabel%u: ", dxilIdentifier, func.blocks[curBlock]->slot);
|
||||
else
|
||||
labelName = StringFormat::Fmt("%clabel_%s%u: ", DXIL::dxilIdentifier,
|
||||
labelName = StringFormat::Fmt("%clabel_%s%u: ", dxilIdentifier,
|
||||
DXBC::BasicDemangle(func.blocks[curBlock]->name).c_str(),
|
||||
func.blocks[curBlock]->id);
|
||||
|
||||
@@ -4532,7 +4528,7 @@ void Program::MakeRDDisassemblyString(const DXBC::Reflection *reflection)
|
||||
if(!first)
|
||||
predicates += ", ";
|
||||
first = false;
|
||||
predicates += StringFormat::Fmt("%clabel%u", DXIL::dxilIdentifier, pred->slot);
|
||||
predicates += StringFormat::Fmt("%clabel%u", dxilIdentifier, pred->slot);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -4540,7 +4536,7 @@ void Program::MakeRDDisassemblyString(const DXBC::Reflection *reflection)
|
||||
if(!first)
|
||||
predicates += ", ";
|
||||
first = false;
|
||||
predicates += StringFormat::Fmt("%clabel_%s%u", DXIL::dxilIdentifier,
|
||||
predicates += StringFormat::Fmt("%clabel_%s%u", dxilIdentifier,
|
||||
DXBC::BasicDemangle(pred->name).c_str(), pred->id);
|
||||
}
|
||||
}
|
||||
@@ -4871,11 +4867,12 @@ void Program::ParseReferences(const DXBC::Reflection *reflection)
|
||||
}
|
||||
}
|
||||
|
||||
rdcstr Type::toString() const
|
||||
rdcstr Type::toString(bool dxcStyleFormatting) const
|
||||
{
|
||||
const char dxilIdentifier = Program::GetDXILIdentifier(dxcStyleFormatting);
|
||||
if(!name.empty())
|
||||
{
|
||||
return StringFormat::Fmt("%c%s", DXIL::dxilIdentifier, escapeStringIfNeeded(name).c_str());
|
||||
return StringFormat::Fmt("%c%s", dxilIdentifier, escapeStringIfNeeded(name).c_str());
|
||||
}
|
||||
|
||||
switch(type)
|
||||
@@ -4886,7 +4883,7 @@ rdcstr Type::toString() const
|
||||
{
|
||||
case Void: return "void";
|
||||
case Int:
|
||||
if(DXIL::dxcStyleFormatting)
|
||||
if(dxcStyleFormatting)
|
||||
{
|
||||
return StringFormat::Fmt("i%u", bitWidth);
|
||||
}
|
||||
@@ -4914,33 +4911,35 @@ rdcstr Type::toString() const
|
||||
}
|
||||
case Vector:
|
||||
{
|
||||
if(DXIL::dxcStyleFormatting)
|
||||
return StringFormat::Fmt("<%u x %s>", elemCount, inner->toString().c_str());
|
||||
if(dxcStyleFormatting)
|
||||
return StringFormat::Fmt("<%u x %s>", elemCount, inner->toString(dxcStyleFormatting).c_str());
|
||||
else
|
||||
return StringFormat::Fmt("%s%u", inner->toString().c_str(), elemCount);
|
||||
return StringFormat::Fmt("%s%u", inner->toString(dxcStyleFormatting).c_str(), elemCount);
|
||||
}
|
||||
case Pointer:
|
||||
{
|
||||
if(inner->type == Type::Function)
|
||||
{
|
||||
if(addrSpace == Type::PointerAddrSpace::Default)
|
||||
return inner->toString();
|
||||
return inner->toString(dxcStyleFormatting);
|
||||
else
|
||||
return StringFormat::Fmt("%s addrspace(%d)", inner->toString().c_str(), addrSpace);
|
||||
return StringFormat::Fmt("%s addrspace(%d)", inner->toString(dxcStyleFormatting).c_str(),
|
||||
addrSpace);
|
||||
}
|
||||
if(addrSpace == Type::PointerAddrSpace::Default)
|
||||
return StringFormat::Fmt("%s*", inner->toString().c_str());
|
||||
return StringFormat::Fmt("%s*", inner->toString(dxcStyleFormatting).c_str());
|
||||
else
|
||||
return StringFormat::Fmt("%s addrspace(%d)*", inner->toString().c_str(), addrSpace);
|
||||
return StringFormat::Fmt("%s addrspace(%d)*", inner->toString(dxcStyleFormatting).c_str(),
|
||||
addrSpace);
|
||||
}
|
||||
case Array:
|
||||
{
|
||||
if(DXIL::dxcStyleFormatting)
|
||||
return StringFormat::Fmt("[%u x %s]", elemCount, inner->toString().c_str());
|
||||
if(dxcStyleFormatting)
|
||||
return StringFormat::Fmt("[%u x %s]", elemCount, inner->toString(dxcStyleFormatting).c_str());
|
||||
else
|
||||
return StringFormat::Fmt("%s[%u]", inner->toString().c_str(), elemCount);
|
||||
return StringFormat::Fmt("%s[%u]", inner->toString(dxcStyleFormatting).c_str(), elemCount);
|
||||
}
|
||||
case Function: return declFunction(rdcstr(), {}, NULL) + "*";
|
||||
case Function: return declFunction(rdcstr(), {}, NULL, dxcStyleFormatting) + "*";
|
||||
case Struct:
|
||||
{
|
||||
rdcstr ret;
|
||||
@@ -4952,7 +4951,7 @@ rdcstr Type::toString() const
|
||||
{
|
||||
if(i > 0)
|
||||
ret += ", ";
|
||||
ret += members[i]->toString();
|
||||
ret += members[i]->toString(dxcStyleFormatting);
|
||||
}
|
||||
if(packedStruct)
|
||||
ret += " }>";
|
||||
@@ -4968,15 +4967,15 @@ rdcstr Type::toString() const
|
||||
}
|
||||
|
||||
rdcstr Type::declFunction(rdcstr funcName, const rdcarray<Instruction *> &args,
|
||||
const AttributeSet *attrs) const
|
||||
const AttributeSet *attrs, bool dxcStyleFormatting) const
|
||||
{
|
||||
rdcstr ret = inner->toString();
|
||||
rdcstr ret = inner->toString(dxcStyleFormatting);
|
||||
ret += " " + funcName + "(";
|
||||
for(size_t i = 0; i < members.size(); i++)
|
||||
{
|
||||
if(i > 0)
|
||||
ret += ", ";
|
||||
ret += members[i]->toString();
|
||||
ret += members[i]->toString(dxcStyleFormatting);
|
||||
|
||||
if(attrs && i + 1 < attrs->groupSlots.size() && attrs->groupSlots[i + 1])
|
||||
{
|
||||
@@ -5043,34 +5042,36 @@ rdcstr AttributeGroup::toString(bool stringAttrs) const
|
||||
return ret.trimmed();
|
||||
}
|
||||
|
||||
rdcstr Metadata::refString() const
|
||||
rdcstr Metadata::refString(bool dxcStyleFormatting) const
|
||||
{
|
||||
if(slot == ~0U)
|
||||
return valString();
|
||||
return valString(dxcStyleFormatting);
|
||||
return StringFormat::Fmt("!%u", slot);
|
||||
}
|
||||
|
||||
rdcstr DebugLocation::toString() const
|
||||
rdcstr DebugLocation::toString(bool dxcStyleFormatting) const
|
||||
{
|
||||
rdcstr ret = StringFormat::Fmt("!DILocation(line: %llu", line);
|
||||
if(col)
|
||||
ret += StringFormat::Fmt(", column: %llu", col);
|
||||
ret += StringFormat::Fmt(", scope: %s", scope ? scope->refString().c_str() : "null");
|
||||
ret += StringFormat::Fmt(", scope: %s",
|
||||
scope ? scope->refString(dxcStyleFormatting).c_str() : "null");
|
||||
if(inlinedAt)
|
||||
ret += StringFormat::Fmt(", inlinedAt: %s", inlinedAt->refString().c_str());
|
||||
ret += StringFormat::Fmt(", inlinedAt: %s", inlinedAt->refString(dxcStyleFormatting).c_str());
|
||||
ret += ")";
|
||||
return ret;
|
||||
}
|
||||
|
||||
rdcstr Metadata::valString() const
|
||||
rdcstr Metadata::valString(bool dxcStyleFormatting) const
|
||||
{
|
||||
const char dxilIdentifier = Program::GetDXILIdentifier(dxcStyleFormatting);
|
||||
if(dwarf)
|
||||
{
|
||||
return dwarf->toString();
|
||||
return dwarf->toString(dxcStyleFormatting);
|
||||
}
|
||||
else if(debugLoc)
|
||||
{
|
||||
return debugLoc->toString();
|
||||
return debugLoc->toString(dxcStyleFormatting);
|
||||
}
|
||||
else if(isConstant)
|
||||
{
|
||||
@@ -5098,15 +5099,15 @@ rdcstr Metadata::valString() const
|
||||
if(i)
|
||||
{
|
||||
if(i->getName().empty())
|
||||
return StringFormat::Fmt("%s %c%u", i->type->toString().c_str(), DXIL::dxilIdentifier,
|
||||
i->slot);
|
||||
return StringFormat::Fmt("%s %c%u", i->type->toString(dxcStyleFormatting).c_str(),
|
||||
dxilIdentifier, i->slot);
|
||||
else
|
||||
return StringFormat::Fmt("%s %c%s", i->type->toString().c_str(), DXIL::dxilIdentifier,
|
||||
escapeStringIfNeeded(i->getName()).c_str());
|
||||
return StringFormat::Fmt("%s %c%s", i->type->toString(dxcStyleFormatting).c_str(),
|
||||
dxilIdentifier, escapeStringIfNeeded(i->getName()).c_str());
|
||||
}
|
||||
else if(value)
|
||||
{
|
||||
return value->toString(true);
|
||||
return value->toString(dxcStyleFormatting, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -5125,7 +5126,7 @@ rdcstr Metadata::valString() const
|
||||
if(!children[i])
|
||||
ret += "null";
|
||||
else if(children[i]->isConstant)
|
||||
ret += children[i]->valString();
|
||||
ret += children[i]->valString(dxcStyleFormatting);
|
||||
else
|
||||
ret += StringFormat::Fmt("!%u", children[i]->slot);
|
||||
}
|
||||
@@ -5135,9 +5136,10 @@ rdcstr Metadata::valString() const
|
||||
}
|
||||
}
|
||||
|
||||
static void floatAppendToString(const Type *t, const ShaderValue &val, uint32_t i, rdcstr &ret)
|
||||
static void floatAppendToString(const Type *t, const ShaderValue &val, uint32_t i, rdcstr &ret,
|
||||
bool dxcStyleFormatting)
|
||||
{
|
||||
if(DXIL::dxcStyleFormatting)
|
||||
if(dxcStyleFormatting)
|
||||
{
|
||||
#if ENABLED(DXC_COMPATIBLE_DISASM)
|
||||
// dxc/llvm always prints half floats as their 16-bit hex representation.
|
||||
@@ -5154,7 +5156,7 @@ static void floatAppendToString(const Type *t, const ShaderValue &val, uint32_t
|
||||
// NaNs/infs are printed as hex to ensure we don't lose bits
|
||||
if(RDCISFINITE(d))
|
||||
{
|
||||
if(DXIL::dxcStyleFormatting)
|
||||
if(dxcStyleFormatting)
|
||||
{
|
||||
// check we can reparse precisely a float-formatted string. Otherwise we print as hex
|
||||
rdcstr flt = StringFormat::Fmt("%.6le", d);
|
||||
@@ -5187,11 +5189,12 @@ static void floatAppendToString(const Type *t, const ShaderValue &val, uint32_t
|
||||
ret += StringFormat::Fmt("0x%llX", d);
|
||||
}
|
||||
|
||||
void shaderValAppendToString(const Type *type, const ShaderValue &val, uint32_t i, rdcstr &ret)
|
||||
void shaderValAppendToString(const Type *type, const ShaderValue &val, uint32_t i, rdcstr &ret,
|
||||
bool dxcStyleFormatting)
|
||||
{
|
||||
if(type->scalarType == Type::Float)
|
||||
{
|
||||
floatAppendToString(type, val, i, ret);
|
||||
floatAppendToString(type, val, i, ret, dxcStyleFormatting);
|
||||
}
|
||||
else if(type->scalarType == Type::Int)
|
||||
{
|
||||
@@ -5205,13 +5208,13 @@ void shaderValAppendToString(const Type *type, const ShaderValue &val, uint32_t
|
||||
}
|
||||
}
|
||||
|
||||
rdcstr Value::toString(bool withType) const
|
||||
rdcstr Value::toString(bool dxcStyleFormatting, bool withType) const
|
||||
{
|
||||
rdcstr ret;
|
||||
if(withType)
|
||||
{
|
||||
if(type)
|
||||
ret += type->toString() + " ";
|
||||
ret += type->toString(dxcStyleFormatting) + " ";
|
||||
else
|
||||
RDCERR("Type requested in value string, but no type available");
|
||||
}
|
||||
@@ -5226,7 +5229,9 @@ rdcstr Value::toString(bool withType) const
|
||||
case ValueKind::Alias:
|
||||
ret += StringFormat::Fmt("@%s", escapeStringIfNeeded(cast<Alias>(this)->name).c_str());
|
||||
break;
|
||||
case ValueKind::Constant: return cast<Constant>(this)->toString(withType); break;
|
||||
case ValueKind::Constant:
|
||||
return cast<Constant>(this)->toString(dxcStyleFormatting, withType);
|
||||
break;
|
||||
case ValueKind::ForwardReferencePlaceholder:
|
||||
RDCERR("forward-reference value being stringised");
|
||||
ret += "???";
|
||||
@@ -5242,14 +5247,14 @@ rdcstr Value::toString(bool withType) const
|
||||
return ret;
|
||||
}
|
||||
|
||||
rdcstr Constant::toString(bool withType) const
|
||||
rdcstr Constant::toString(bool dxcStyleFormatting, bool withType) const
|
||||
{
|
||||
if(type == NULL)
|
||||
return escapeString(str);
|
||||
|
||||
rdcstr ret;
|
||||
if(withType)
|
||||
ret += type->toString() + " ";
|
||||
ret += type->toString(dxcStyleFormatting) + " ";
|
||||
if(isUndef())
|
||||
{
|
||||
ret += "undef";
|
||||
@@ -5265,12 +5270,12 @@ rdcstr Constant::toString(bool withType) const
|
||||
|
||||
const Type *baseType = members->at(0)->type;
|
||||
RDCASSERTEQUAL(baseType->type, Type::Pointer);
|
||||
ret += baseType->inner->toString();
|
||||
ret += baseType->inner->toString(dxcStyleFormatting);
|
||||
for(size_t i = 0; i < members->size(); i++)
|
||||
{
|
||||
ret += ", ";
|
||||
|
||||
ret += members->at(i)->toString(withType);
|
||||
ret += members->at(i)->toString(dxcStyleFormatting, withType);
|
||||
}
|
||||
ret += ")";
|
||||
break;
|
||||
@@ -5308,9 +5313,9 @@ rdcstr Constant::toString(bool withType) const
|
||||
}
|
||||
|
||||
ret += "(";
|
||||
ret += inner->toString(withType);
|
||||
ret += inner->toString(dxcStyleFormatting, withType);
|
||||
ret += " to ";
|
||||
ret += type->toString();
|
||||
ret += type->toString(dxcStyleFormatting);
|
||||
ret += ")";
|
||||
break;
|
||||
}
|
||||
@@ -5367,11 +5372,11 @@ rdcstr Constant::toString(bool withType) const
|
||||
ShaderValue v;
|
||||
v.u64v[0] = l->literal;
|
||||
|
||||
shaderValAppendToString(members->at(i)->type, v, 0, ret);
|
||||
shaderValAppendToString(members->at(i)->type, v, 0, ret, dxcStyleFormatting);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret += members->at(i)->toString(withType);
|
||||
ret += members->at(i)->toString(dxcStyleFormatting, withType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5385,7 +5390,7 @@ rdcstr Constant::toString(bool withType) const
|
||||
{
|
||||
ShaderValue v;
|
||||
v.u64v[0] = u64;
|
||||
shaderValAppendToString(type, v, 0, ret);
|
||||
shaderValAppendToString(type, v, 0, ret, dxcStyleFormatting);
|
||||
}
|
||||
else if(isNULL())
|
||||
{
|
||||
@@ -5421,11 +5426,11 @@ rdcstr Constant::toString(bool withType) const
|
||||
if(i > 0)
|
||||
ret += ", ";
|
||||
if(withType)
|
||||
ret += type->inner->toString() + " ";
|
||||
ret += type->inner->toString(dxcStyleFormatting) + " ";
|
||||
if(isCompound() && cast<Constant>(members->at(i))->isUndef())
|
||||
ret += "undef";
|
||||
else
|
||||
shaderValAppendToString(type, v, i, ret);
|
||||
shaderValAppendToString(type, v, i, ret, dxcStyleFormatting);
|
||||
}
|
||||
ret += ">";
|
||||
}
|
||||
@@ -5446,16 +5451,16 @@ rdcstr Constant::toString(bool withType) const
|
||||
if(Literal *l = cast<Literal>(members->at(i)))
|
||||
{
|
||||
if(withType)
|
||||
ret += type->inner->toString() + " ";
|
||||
ret += type->inner->toString(dxcStyleFormatting) + " ";
|
||||
|
||||
ShaderValue v;
|
||||
v.u64v[0] = l->literal;
|
||||
|
||||
shaderValAppendToString(type->inner, v, 0, ret);
|
||||
shaderValAppendToString(type->inner, v, 0, ret, dxcStyleFormatting);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret += members->at(i)->toString(withType);
|
||||
ret += members->at(i)->toString(dxcStyleFormatting, withType);
|
||||
}
|
||||
}
|
||||
ret += "]";
|
||||
@@ -5500,11 +5505,11 @@ rdcstr Constant::toString(bool withType) const
|
||||
ShaderValue v;
|
||||
v.u64v[0] = l->literal;
|
||||
|
||||
shaderValAppendToString(members->at(i)->type, v, 0, ret);
|
||||
shaderValAppendToString(members->at(i)->type, v, 0, ret, dxcStyleFormatting);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret += members->at(i)->toString(withType);
|
||||
ret += members->at(i)->toString(dxcStyleFormatting, withType);
|
||||
}
|
||||
}
|
||||
ret += " }";
|
||||
@@ -5520,15 +5525,14 @@ rdcstr Constant::toString(bool withType) const
|
||||
|
||||
rdcstr Program::GetArgId(const Instruction &inst, uint32_t arg) const
|
||||
{
|
||||
return ArgToString(inst.args[arg], false);
|
||||
return ArgToString(inst.args[arg], false, false);
|
||||
}
|
||||
|
||||
void Program::MakeResultId(const DXIL::Instruction &inst, rdcstr &resultId)
|
||||
{
|
||||
if(!inst.getName().empty())
|
||||
resultId = StringFormat::Fmt("%c%s", DXIL::dxilIdentifier,
|
||||
escapeStringIfNeeded(inst.getName()).c_str());
|
||||
resultId = StringFormat::Fmt("%c%s", '_', escapeStringIfNeeded(inst.getName()).c_str());
|
||||
else if(inst.slot != ~0U)
|
||||
resultId = StringFormat::Fmt("%c%s", DXIL::dxilIdentifier, ToStr(inst.slot).c_str());
|
||||
resultId = StringFormat::Fmt("%c%s", '_', ToStr(inst.slot).c_str());
|
||||
}
|
||||
}; // namespace DXIL
|
||||
|
||||
@@ -1470,6 +1470,7 @@ rdcarray<ShaderEntryPoint> Program::GetEntryPoints()
|
||||
|
||||
DXBC::Reflection *Program::GetReflection()
|
||||
{
|
||||
const bool dxcStyleFormatting = m_DXCStyle;
|
||||
using namespace DXBC;
|
||||
|
||||
Reflection *refl = new Reflection;
|
||||
@@ -1489,10 +1490,10 @@ DXBC::Reflection *Program::GetReflection()
|
||||
|
||||
if(dx.valver && dx.valver->children.size() == 1 && dx.valver->children[0]->children.size() == 2)
|
||||
{
|
||||
m_CompilerSig +=
|
||||
StringFormat::Fmt(" (Validation version %s.%s)",
|
||||
dx.valver->children[0]->children[0]->value->toString().c_str(),
|
||||
dx.valver->children[0]->children[1]->value->toString().c_str());
|
||||
m_CompilerSig += StringFormat::Fmt(
|
||||
" (Validation version %s.%s)",
|
||||
dx.valver->children[0]->children[0]->value->toString(dxcStyleFormatting).c_str(),
|
||||
dx.valver->children[0]->children[1]->value->toString(dxcStyleFormatting).c_str());
|
||||
}
|
||||
|
||||
if(dx.entryPoints && dx.entryPoints->children.size() > 0 &&
|
||||
@@ -1509,10 +1510,10 @@ DXBC::Reflection *Program::GetReflection()
|
||||
if(dx.shaderModel && dx.shaderModel->children.size() == 1 &&
|
||||
dx.shaderModel->children[0]->children.size() == 3)
|
||||
{
|
||||
m_Profile =
|
||||
StringFormat::Fmt("%s_%s_%s", dx.shaderModel->children[0]->children[0]->str.c_str(),
|
||||
dx.shaderModel->children[0]->children[1]->value->toString().c_str(),
|
||||
dx.shaderModel->children[0]->children[2]->value->toString().c_str());
|
||||
m_Profile = StringFormat::Fmt(
|
||||
"%s_%s_%s", dx.shaderModel->children[0]->children[0]->str.c_str(),
|
||||
dx.shaderModel->children[0]->children[1]->value->toString(dxcStyleFormatting).c_str(),
|
||||
dx.shaderModel->children[0]->children[2]->value->toString(dxcStyleFormatting).c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user