1 // Copyright 2020 The Tint Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef SRC_AST_WORKGROUP_DECORATION_H_ 16 #define SRC_AST_WORKGROUP_DECORATION_H_ 17 18 #include <array> 19 #include <string> 20 21 #include "src/ast/decoration.h" 22 23 namespace tint { 24 namespace ast { 25 26 // Forward declaration 27 class Expression; 28 29 /// A workgroup decoration 30 class WorkgroupDecoration : public Castable<WorkgroupDecoration, Decoration> { 31 public: 32 /// constructor 33 /// @param pid the identifier of the program that owns this node 34 /// @param src the source of this node 35 /// @param x the workgroup x dimension expression 36 /// @param y the optional workgroup y dimension expression 37 /// @param z the optional workgroup z dimension expression 38 WorkgroupDecoration(ProgramID pid, 39 const Source& src, 40 const ast::Expression* x, 41 const ast::Expression* y = nullptr, 42 const ast::Expression* z = nullptr); 43 44 ~WorkgroupDecoration() override; 45 46 /// @returns the workgroup dimensions Values()47 std::array<const ast::Expression*, 3> Values() const { return {x, y, z}; } 48 49 /// @returns the WGSL name for the decoration 50 std::string Name() const override; 51 52 /// Clones this node and all transitive child nodes using the `CloneContext` 53 /// `ctx`. 54 /// @param ctx the clone context 55 /// @return the newly cloned node 56 const WorkgroupDecoration* Clone(CloneContext* ctx) const override; 57 58 /// The workgroup x dimension. 59 const ast::Expression* const x; 60 /// The optional workgroup y dimension. May be null. 61 const ast::Expression* const y = nullptr; 62 /// The optional workgroup z dimension. May be null. 63 const ast::Expression* const z = nullptr; 64 }; 65 66 } // namespace ast 67 } // namespace tint 68 69 #endif // SRC_AST_WORKGROUP_DECORATION_H_ 70