diff options
author | Tony Wasserka <tony.wasserka@gmx.de> | 2020-10-28 13:35:06 +0100 |
---|---|---|
committer | Marge Bot <eric+marge@anholt.net> | 2021-01-13 18:21:05 +0000 |
commit | 9bbd6162a9f2160b8682ba9b4db0e8680bdd4987 (patch) | |
tree | 1e333f43304c6d47c900f41d90e012f32cbb8c72 /src/amd | |
parent | 67c1f32228de25dff56ec9c625af3001932e1d4b (diff) |
aco/ra: Introduce PhysRegInterval helper class
This mainly clarifies the semantics of register bounds (inclusive vs
exclusive), and further groups related varaibles together to clarify
sliding-window-style loops.
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7799>
Diffstat (limited to 'src/amd')
-rw-r--r-- | src/amd/compiler/aco_register_allocation.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/amd/compiler/aco_register_allocation.cpp b/src/amd/compiler/aco_register_allocation.cpp index 247219ee1c0..fc859e3f21e 100644 --- a/src/amd/compiler/aco_register_allocation.cpp +++ b/src/amd/compiler/aco_register_allocation.cpp @@ -92,6 +92,36 @@ struct ra_ctx { } }; +/* Half-open register interval used in "sliding window"-style for-loops */ +struct PhysRegInterval { + unsigned lo_; + unsigned size; + + /* Inclusive lower bound */ + unsigned lo() const { + return lo_; + } + + /* Exclusive upper bound */ + unsigned hi() const { + return lo() + size; + } + + PhysRegInterval& operator+=(uint32_t stride) { + lo_ += stride; + return *this; + } + + bool operator!=(const PhysRegInterval& oth) const { + return lo_ != oth.lo_ || size != oth.size; + } + + /* Construct a half-open interval, excluding the end register */ + static PhysRegInterval from_until(unsigned first, unsigned end) { + return { first, end - first }; + } +}; + struct DefInfo { uint16_t lb; uint16_t ub; |