Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 1 | // Copyright 2023 The Dawn & Tint Authors |
Ben Clayton | b8ff13e | 2023-10-09 12:22:38 +0000 | [diff] [blame] | 2 | // |
Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 3 | // Redistribution and use in source and binary forms, with or without |
| 4 | // modification, are permitted provided that the following conditions are met: |
Ben Clayton | b8ff13e | 2023-10-09 12:22:38 +0000 | [diff] [blame] | 5 | // |
Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 6 | // 1. Redistributions of source code must retain the above copyright notice, this |
| 7 | // list of conditions and the following disclaimer. |
Ben Clayton | b8ff13e | 2023-10-09 12:22:38 +0000 | [diff] [blame] | 8 | // |
Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, |
| 10 | // this list of conditions and the following disclaimer in the documentation |
| 11 | // and/or other materials provided with the distribution. |
| 12 | // |
| 13 | // 3. Neither the name of the copyright holder nor the names of its |
| 14 | // contributors may be used to endorse or promote products derived from |
| 15 | // this software without specific prior written permission. |
| 16 | // |
| 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| 21 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 22 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 23 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 24 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 25 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Ben Clayton | b8ff13e | 2023-10-09 12:22:38 +0000 | [diff] [blame] | 27 | |
| 28 | #ifndef SRC_TINT_LANG_WGSL_SEM_ARRAY_H_ |
| 29 | #define SRC_TINT_LANG_WGSL_SEM_ARRAY_H_ |
| 30 | |
| 31 | #include "src/tint/lang/core/type/array.h" |
| 32 | #include "src/tint/utils/containers/unique_vector.h" |
| 33 | |
| 34 | /// Forward declarations |
| 35 | namespace tint::sem { |
| 36 | class GlobalVariable; |
| 37 | } |
| 38 | |
| 39 | namespace tint::sem { |
| 40 | |
| 41 | /// Array holds the semantic information for Arrays. |
| 42 | class Array final : public Castable<Array, core::type::Array> { |
| 43 | public: |
| 44 | /// Constructor |
| 45 | /// @param element the array element type |
| 46 | /// @param count the number of elements in the array. |
| 47 | /// @param align the byte alignment of the array |
| 48 | /// @param size the byte size of the array. The size will be 0 if the array element count is |
| 49 | /// pipeline overridable. |
| 50 | /// @param stride the number of bytes from the start of one element of the |
| 51 | /// array to the start of the next element |
| 52 | /// @param implicit_stride the number of bytes from the start of one element |
| 53 | /// of the array to the start of the next element, if there was no `@stride` |
| 54 | /// attribute applied. |
| 55 | Array(core::type::Type const* element, |
| 56 | const core::type::ArrayCount* count, |
| 57 | uint32_t align, |
| 58 | uint32_t size, |
| 59 | uint32_t stride, |
| 60 | uint32_t implicit_stride); |
| 61 | |
| 62 | /// Destructor |
| 63 | ~Array() override; |
Ben Clayton | 535535b | 2023-10-09 15:14:34 +0000 | [diff] [blame] | 64 | |
| 65 | /// Records that this variable (transitively) references the given override variable. |
| 66 | /// @param var the module-scope override variable |
| 67 | void AddTransitivelyReferencedOverride(const GlobalVariable* var); |
| 68 | |
| 69 | /// @returns all transitively referenced override variables |
| 70 | VectorRef<const GlobalVariable*> TransitivelyReferencedOverrides() const { |
| 71 | return transitively_referenced_overrides_; |
| 72 | } |
| 73 | |
| 74 | private: |
| 75 | UniqueVector<const GlobalVariable*, 4> transitively_referenced_overrides_; |
Ben Clayton | b8ff13e | 2023-10-09 12:22:38 +0000 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | } // namespace tint::sem |
| 79 | |
| 80 | #endif // SRC_TINT_LANG_WGSL_SEM_ARRAY_H_ |