blob: 4f1c5b207fe8d8258c90eeb37a8f50340a2cdcb7 [file] [log] [blame]
dan sinclaireee8d882022-10-28 01:22:58 +00001// Copyright 2022 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
dan sinclair97c37272023-07-24 17:11:53 +000015#include "src/tint/lang/core/ir/switch.h"
dan sinclaireee8d882022-10-28 01:22:58 +000016
17TINT_INSTANTIATE_TYPEINFO(tint::ir::Switch);
18
19namespace tint::ir {
20
Ben Claytonc8f07082023-06-20 16:42:21 +000021Switch::Switch(Value* cond) {
22 TINT_ASSERT(IR, cond);
dan sinclaireefa7fe2023-06-05 15:16:53 +000023
dan sinclair4934dc02023-06-16 12:11:56 +000024 AddOperand(Switch::kConditionOperandOffset, cond);
dan sinclair68b4e642023-05-23 22:26:24 +000025}
dan sinclaireee8d882022-10-28 01:22:58 +000026
27Switch::~Switch() = default;
28
Ben Claytonc8f07082023-06-20 16:42:21 +000029void Switch::ForeachBlock(const std::function<void(ir::Block*)>& cb) {
30 for (auto& c : cases_) {
Ben Clayton93977142023-06-20 16:48:35 +000031 cb(c.Block());
Ben Claytonc8f07082023-06-20 16:42:21 +000032 }
33}
34
dan sinclaireee8d882022-10-28 01:22:58 +000035} // namespace tint::ir