summaryrefslogtreecommitdiffstats
path: root/source/core
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2022-05-17 13:12:59 -0400
committerGitHub <noreply@github.com>2022-05-17 13:12:59 -0400
commit90c123a177b6282e797ee4c90b17bee867876c1a (patch)
tree3c21b80fc2bb912d6d0f46ee27cc4d2460dbd6b6 /source/core
parent2b350a5e93c44f59aefaf454887212254f2910ed (diff)
Liveness tracking with phis (#2233)
* #include an absolute path didn't work - because paths were taken to always be relative. * Refactor Liveness pass, such that locations can be found independently of setting up ranges. * Refactor around different stages of liveness span analysis. * WIP Take into account PHI temporaries in liveness tracking. * WIP First pass of PHI liveness refactor. * Add BlockIndex. * WIP Refactor phi liveness around inst runs. * More improvements around liveness tracking. * Bug fixes. Special handling to not add multiple ends, at starts of blocks and after accesses. * Fix test output. * Use IRInsertLoc to track insertion point. * Liveness markers don't have side effects. * Fix typo in liveness test. * Small improvements around setting SuccessorResult. * Fix memory issue around reallocation and RAIIStackArray. Update test output. * Update test output for liveness.slang. * Fix typo in SuccessorResult blockIndex. * Small tidy up. * Handle the root start block, correctly scoping the run. * Split BlockInfo into 'Root' and 'Function'. Store successors as BlockIndices. * Tidy up around liveness tracking. * Add head/tail support to ArrayViews. Use Count where appropriate. Use head/tail in liveness impl.
Diffstat (limited to 'source/core')
-rw-r--r--source/core/slang-array-view.h49
1 files changed, 37 insertions, 12 deletions
diff --git a/source/core/slang-array-view.h b/source/core/slang-array-view.h
index 6f5277f5f..f6ac92004 100644
--- a/source/core/slang-array-view.h
+++ b/source/core/slang-array-view.h
@@ -14,19 +14,19 @@ namespace Slang
public:
typedef ConstArrayView ThisType;
- const T* begin() const { return m_buffer; }
+ SLANG_FORCE_INLINE const T* begin() const { return m_buffer; }
- const T* end() const { return m_buffer + m_count; }
+ SLANG_FORCE_INLINE const T* end() const { return m_buffer + m_count; }
- inline Index getCount() const { return m_count; }
+ SLANG_FORCE_INLINE Count getCount() const { return m_count; }
- inline const T& operator [](Index idx) const
+ SLANG_FORCE_INLINE const T& operator [](Index idx) const
{
SLANG_ASSERT(idx >= 0 && idx < m_count);
return m_buffer[idx];
}
- inline const T* getBuffer() const { return m_buffer; }
+ SLANG_FORCE_INLINE const T* getBuffer() const { return m_buffer; }
template<typename T2>
Index indexOf(const T2& val) const
@@ -78,7 +78,7 @@ namespace Slang
{
return true;
}
- const Index count = getCount();
+ const Count count = getCount();
if (count != rhs.getCount())
{
return false;
@@ -96,27 +96,38 @@ namespace Slang
}
SLANG_FORCE_INLINE bool operator!=(const ThisType& rhs) const { return !(*this == rhs); }
+ ThisType head(Index index) const
+ {
+ SLANG_ASSERT(index >= 0 && index <= m_count);
+ return ThisType(m_buffer, index);
+ }
+ ThisType tail(Index index) const
+ {
+ SLANG_ASSERT(index >= 0 && index <= m_count);
+ return ThisType(m_buffer + index, m_count - index);
+ }
+
ConstArrayView() :
m_buffer(nullptr),
m_count(0)
{
}
- ConstArrayView(const T* buffer, Index count) :
+ ConstArrayView(const T* buffer, Count count) :
m_buffer(const_cast<T*>(buffer)),
m_count(count)
{
}
protected:
- ConstArrayView(T* buffer, Index count) :
+ ConstArrayView(T* buffer, Count count) :
m_buffer(buffer),
m_count(count)
{
}
T* m_buffer; ///< Note that this isn't const, as is used for derived class ArrayView also
- Index m_count;
+ Count m_count;
};
template<typename T>
@@ -126,7 +137,7 @@ namespace Slang
}
template<typename T>
- ConstArrayView<T> makeConstArrayView(const T* buffer, Index count)
+ ConstArrayView<T> makeConstArrayView(const T* buffer, Count count)
{
return ConstArrayView<T>(buffer, count);
}
@@ -157,6 +168,9 @@ namespace Slang
using Super::end;
T* end() { return m_buffer + m_count; }
+ using Super::head;
+ using Super::tail;
+
using Super::operator[];
inline T& operator [](Index idx)
{
@@ -167,6 +181,17 @@ namespace Slang
using Super::getBuffer;
inline T* getBuffer() { return m_buffer; }
+ ThisType head(Index index)
+ {
+ SLANG_ASSERT(index >= 0 && index <= m_count);
+ return ThisType(m_buffer, index);
+ }
+ ThisType tail(Index index)
+ {
+ SLANG_ASSERT(index >= 0 && index <= m_count);
+ return ThisType(m_buffer + index, m_count - index);
+ }
+
ArrayView() : Super() {}
ArrayView(T* buffer, Index size) :Super(buffer, size) {}
};
@@ -178,7 +203,7 @@ namespace Slang
}
template<typename T>
- ArrayView<T> makeArrayView(T* buffer, Index count)
+ ArrayView<T> makeArrayView(T* buffer, Count count)
{
return ArrayView<T>(buffer, count);
}
@@ -186,7 +211,7 @@ namespace Slang
template<typename T, size_t N>
ArrayView<T> makeArrayView(T (&arr)[N])
{
- return ArrayView<T>(arr, Index(N));
+ return ArrayView<T>(arr, Count(N));
}