Add break-if support.
This CL adds support for `break-if` to Tint.
Bug: tint:1633, tint:1451
Change-Id: I30dfd62a3e09255624ff76ebe0cdd3a3c7cf9c5f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106420
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: dan sinclair <dsinclair@google.com>
diff --git a/src/tint/program_builder.h b/src/tint/program_builder.h
index 986133c..25e6214 100644
--- a/src/tint/program_builder.h
+++ b/src/tint/program_builder.h
@@ -30,6 +30,7 @@
#include "src/tint/ast/bitcast_expression.h"
#include "src/tint/ast/bool.h"
#include "src/tint/ast/bool_literal_expression.h"
+#include "src/tint/ast/break_if_statement.h"
#include "src/tint/ast/break_statement.h"
#include "src/tint/ast/call_expression.h"
#include "src/tint/ast/call_statement.h"
@@ -2416,6 +2417,23 @@
/// @returns the break statement pointer
const ast::BreakStatement* Break() { return create<ast::BreakStatement>(); }
+ /// Creates a ast::BreakIfStatement with input condition
+ /// @param source the source information for the if statement
+ /// @param condition the if statement condition expression
+ /// @returns the break-if statement pointer
+ template <typename CONDITION>
+ const ast::BreakIfStatement* BreakIf(const Source& source, CONDITION&& condition) {
+ return create<ast::BreakIfStatement>(source, Expr(std::forward<CONDITION>(condition)));
+ }
+
+ /// Creates a ast::BreakIfStatement with input condition
+ /// @param condition the if statement condition expression
+ /// @returns the break-if statement pointer
+ template <typename CONDITION>
+ const ast::BreakIfStatement* BreakIf(CONDITION&& condition) {
+ return create<ast::BreakIfStatement>(Expr(std::forward<CONDITION>(condition)));
+ }
+
/// Creates an ast::ContinueStatement
/// @param source the source information
/// @returns the continue statement pointer