dan sinclair | eee8d88 | 2022-10-28 01:22:58 +0000 | [diff] [blame] | 1 | // 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 sinclair | 97c3727 | 2023-07-24 17:11:53 +0000 | [diff] [blame^] | 15 | #include "src/tint/lang/core/ir/switch.h" |
dan sinclair | eee8d88 | 2022-10-28 01:22:58 +0000 | [diff] [blame] | 16 | |
| 17 | TINT_INSTANTIATE_TYPEINFO(tint::ir::Switch); |
| 18 | |
| 19 | namespace tint::ir { |
| 20 | |
Ben Clayton | c8f0708 | 2023-06-20 16:42:21 +0000 | [diff] [blame] | 21 | Switch::Switch(Value* cond) { |
| 22 | TINT_ASSERT(IR, cond); |
dan sinclair | eefa7fe | 2023-06-05 15:16:53 +0000 | [diff] [blame] | 23 | |
dan sinclair | 4934dc0 | 2023-06-16 12:11:56 +0000 | [diff] [blame] | 24 | AddOperand(Switch::kConditionOperandOffset, cond); |
dan sinclair | 68b4e64 | 2023-05-23 22:26:24 +0000 | [diff] [blame] | 25 | } |
dan sinclair | eee8d88 | 2022-10-28 01:22:58 +0000 | [diff] [blame] | 26 | |
| 27 | Switch::~Switch() = default; |
| 28 | |
Ben Clayton | c8f0708 | 2023-06-20 16:42:21 +0000 | [diff] [blame] | 29 | void Switch::ForeachBlock(const std::function<void(ir::Block*)>& cb) { |
| 30 | for (auto& c : cases_) { |
Ben Clayton | 9397714 | 2023-06-20 16:48:35 +0000 | [diff] [blame] | 31 | cb(c.Block()); |
Ben Clayton | c8f0708 | 2023-06-20 16:42:21 +0000 | [diff] [blame] | 32 | } |
| 33 | } |
| 34 | |
dan sinclair | eee8d88 | 2022-10-28 01:22:58 +0000 | [diff] [blame] | 35 | } // namespace tint::ir |