summaryrefslogtreecommitdiff
path: root/source/core/slang-semantic-version.h
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2022-08-22 17:39:56 -0400
committerGitHub <noreply@github.com>2022-08-22 14:39:56 -0700
commit6ab0baf910dea838dca2d29557c3361297180a34 (patch)
tree4f2a3418f0662c8a61fd1ba9bf1c1d24b77c276b /source/core/slang-semantic-version.h
parent4bd3e6e02324f913e8927fe69d32c0aafe9fc831 (diff)
Improve binary compatibility for DownstreamCompiler types (#2371)
* #include an absolute path didn't work - because paths were taken to always be relative. * WIP replacing DownstreamCompileResult. * First attempt at replacing DownstreamCompileResult with IArtifact and associated types. * Small renaming around CharSlice. * ICastable -> ISlangCastable Added IClonable Fix issue with cloning in ArtifactDiagnostics. * Only add the blob if one is defined in DXC. * Guard adding blob representation. * Make cloneInterface available across code base. Set enums backing type for ArtifactDiagnostic. * Added ::create for ArtifactDiagnostics. * Use SemanticVersion for DownstreamCompilerDesc. Set sizes for enum types. * Depreciate old incompatible CompileOptions. Change SemanticVersion use 32 bits for the patch. * Split out CastableUtil. * Change IDownstreamCompiler to use canConvert and convert to use artifact types. * Fix typos. * Fix typo bug. Allow trafficing in PTX assembly/binaries * struct DownstreamCompilerBaseUtil -> struct DownstreamCompilerUtilBase Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source/core/slang-semantic-version.h')
-rw-r--r--source/core/slang-semantic-version.h21
1 files changed, 13 insertions, 8 deletions
diff --git a/source/core/slang-semantic-version.h b/source/core/slang-semantic-version.h
index 4d64627c2..e7f10eeed 100644
--- a/source/core/slang-semantic-version.h
+++ b/source/core/slang-semantic-version.h
@@ -3,6 +3,7 @@
#define SLANG_SEMANTIC_VERSION_H
#include "../core/slang-basic.h"
+#include "../core/slang-hash.h"
namespace Slang
{
@@ -14,10 +15,11 @@ struct SemanticVersion
typedef uint64_t IntegerType;
SemanticVersion():m_major(0), m_minor(0), m_patch(0) {}
+
SemanticVersion(int inMajor, int inMinor = 0, int inPatch = 0):
- m_major(uint32_t(inMajor)),
+ m_major(uint16_t(inMajor)),
m_minor(uint16_t(inMinor)),
- m_patch(uint16_t(inPatch))
+ m_patch(uint32_t(inPatch))
{}
void reset()
@@ -30,20 +32,23 @@ struct SemanticVersion
/// All zeros means nothing is set
bool isSet() const { return m_major || m_minor || m_patch; }
- IntegerType toInteger() const { return (IntegerType(m_major) << 32) | (uint32_t(m_minor) << 16) | m_patch; }
+ IntegerType toInteger() const { return (IntegerType(m_major) << 48) | (IntegerType(m_minor) << 32) | m_patch; }
void setFromInteger(IntegerType v)
{
- set(int(v >> 32), int((v >> 16) & 0xffff), int(v & 0xffff));
+ set(int(v >> 48), int((v >> 32) & 0xffff), int(v & 0xffffffff));
}
void set(int major, int minor, int patch = 0)
{
SLANG_ASSERT(major >= 0 && minor >=0 && patch >= 0);
- m_major = uint32_t(major);
+ m_major = uint16_t(major);
m_minor = uint16_t(minor);
- m_patch = uint16_t(patch);
+ m_patch = uint32_t(patch);
}
+ /// Get hash value
+ HashCode getHashCode() const { return Slang::getHashCode(toInteger()); }
+
static SlangResult parse(const UnownedStringSlice& value, SemanticVersion& outVersion);
static SlangResult parse(const UnownedStringSlice& value, char separatorChar, SemanticVersion& outVersion);
@@ -61,9 +66,9 @@ struct SemanticVersion
bool operator==(const ThisType& rhs) const { return toInteger() == rhs.toInteger(); }
bool operator!=(const ThisType& rhs) const { return toInteger() != rhs.toInteger(); }
- uint32_t m_major;
+ uint16_t m_major;
uint16_t m_minor;
- uint16_t m_patch;
+ uint32_t m_patch; ///< Patch number. Can actually be quite large for some code bases.
};
/* Adds to the semantic versioning information for an incomplete version that can be matched */