summaryrefslogtreecommitdiffstats
path: root/source/core
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2023-03-10 14:19:48 -0500
committerGitHub <noreply@github.com>2023-03-10 14:19:48 -0500
commit3fea56ef77a33273bf5af6f432163b30c0a0e1dc (patch)
tree446df8ddd73521b33e836facaea2c27ef84c47fe /source/core
parente39893e8eb1a9411fca4e5f885456a27a770d3a2 (diff)
Support for PDB output from DXC (#2693)
* #include an absolute path didn't work - because paths were taken to always be relative. * Add versioning to CompileOptions for DownstreamCompiler so we can add new options without breaking binary interface. * Add support for debug info format to API/command line processing. * Small simplification. * Add support for adding PDB output from a compilation. * Use builtin offset of directly. * Fix typo in debug.
Diffstat (limited to 'source/core')
-rw-r--r--source/core/slang-type-text-util.cpp43
-rw-r--r--source/core/slang-type-text-util.h6
2 files changed, 49 insertions, 0 deletions
diff --git a/source/core/slang-type-text-util.cpp b/source/core/slang-type-text-util.cpp
index bfa193486..2ba3011d8 100644
--- a/source/core/slang-type-text-util.cpp
+++ b/source/core/slang-type-text-util.cpp
@@ -1,5 +1,6 @@
#include "slang-type-text-util.h"
+#include "slang-array-view.h"
#include "slang-string-util.h"
@@ -30,6 +31,14 @@ namespace Slang
x(nvrtc, NVRTC) \
x(llvm, LLVM)
+#define SLANG_DEBUG_INFO_FORMATS(x) \
+ x(default-format, DEFAULT) \
+ x(c7, C7) \
+ x(pdb, PDB) \
+ x(stabs, STABS) \
+ x(coff, COFF) \
+ x(dwarf, DWARF)
+
namespace { // anonymous
struct ScalarTypeInfo
@@ -109,6 +118,40 @@ static const ArchiveTypeInfo s_archiveTypeInfos[] =
return SLANG_ARCHIVE_TYPE_UNDEFINED;
}
+struct DebugInfoFormatTable
+{
+ UnownedStringSlice entries[SLANG_DEBUG_INFO_FORMAT_COUNT_OF];
+
+ static DebugInfoFormatTable _makeTable()
+ {
+ DebugInfoFormatTable dst;
+#define SLANG_DEBUG_INFO_FORMAT_ENTRY(name, value) \
+ dst.entries[SLANG_DEBUG_INFO_FORMAT_##value] = toSlice(#name);
+ SLANG_DEBUG_INFO_FORMATS(SLANG_DEBUG_INFO_FORMAT_ENTRY)
+ return dst;
+ }
+
+ static Index findIndex(const UnownedStringSlice slice) { return makeConstArrayView(table.entries).indexOf(slice); }
+ static UnownedStringSlice getSlice(SlangDebugInfoFormat format) { return table.entries[Index(format)]; }
+
+ static const DebugInfoFormatTable table;
+};
+
+/* static */const DebugInfoFormatTable DebugInfoFormatTable::table = DebugInfoFormatTable::_makeTable();
+
+/* static */SlangResult TypeTextUtil::findDebugInfoFormat(const Slang::UnownedStringSlice& text, SlangDebugInfoFormat& out)
+{
+ const auto index = DebugInfoFormatTable::findIndex(text);
+ if (index >= 0)
+ {
+ out = SlangDebugInfoFormat(index);
+ return SLANG_OK;
+ }
+ return SLANG_FAIL;
+}
+
+/* static */UnownedStringSlice TypeTextUtil::getDebugInfoFormatName(SlangDebugInfoFormat format) { return DebugInfoFormatTable::getSlice(format); }
+
/* static */UnownedStringSlice TypeTextUtil::getScalarTypeName(slang::TypeReflection::ScalarType scalarType)
{
typedef slang::TypeReflection::ScalarType ScalarType;
diff --git a/source/core/slang-type-text-util.h b/source/core/slang-type-text-util.h
index f5534ec72..df9b83013 100644
--- a/source/core/slang-type-text-util.h
+++ b/source/core/slang-type-text-util.h
@@ -18,6 +18,12 @@ struct TypeTextUtil
// Converts text to scalar type. Returns 'none' if not determined
static slang::TypeReflection::ScalarType findScalarType(const Slang::UnownedStringSlice& text);
+ /// Given a slice finds the associated debug info format
+ static SlangResult findDebugInfoFormat(const Slang::UnownedStringSlice& text, SlangDebugInfoFormat& out);
+
+ /// Get the text name for a format
+ static UnownedStringSlice getDebugInfoFormatName(SlangDebugInfoFormat format);
+
/// As human readable text
static UnownedStringSlice getPassThroughAsHumanText(SlangPassThrough type);
/// Gets pass through from human text (as from getPassThroughAsHumanText)