blob: 01e8d61d7a82440d46cfe748fb86da618f2bddb7 [file] [log] [blame]
dan sinclair367fad82023-06-19 12:58:53 +00001// Copyright 2023 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/instruction_result.h"
dan sinclair367fad82023-06-19 12:58:53 +000016
dan sinclair16cb4bd2023-09-21 08:52:11 +000017#include "src/tint/lang/core/ir/clone_context.h"
dan sinclair97c37272023-07-24 17:11:53 +000018#include "src/tint/lang/core/ir/constant.h"
19#include "src/tint/lang/core/ir/instruction.h"
dan sinclair16cb4bd2023-09-21 08:52:11 +000020#include "src/tint/lang/core/ir/module.h"
Ben Claytonf848af22023-07-28 16:37:32 +000021#include "src/tint/utils/ice/ice.h"
dan sinclair367fad82023-06-19 12:58:53 +000022
dan sinclair6f138fe2023-08-15 21:29:34 +000023TINT_INSTANTIATE_TYPEINFO(tint::core::ir::InstructionResult);
dan sinclair367fad82023-06-19 12:58:53 +000024
dan sinclair6f138fe2023-08-15 21:29:34 +000025namespace tint::core::ir {
dan sinclair367fad82023-06-19 12:58:53 +000026
dan sinclaircedcdf32023-08-10 02:39:48 +000027InstructionResult::InstructionResult(const core::type::Type* type) : type_(type) {
Ben Claytonf848af22023-07-28 16:37:32 +000028 TINT_ASSERT(type_ != nullptr);
dan sinclair0d80c3d2023-06-19 13:32:03 +000029}
dan sinclair367fad82023-06-19 12:58:53 +000030
31InstructionResult::~InstructionResult() = default;
32
Ben Claytonab0cbed2023-06-19 18:45:19 +000033void InstructionResult::Destroy() {
Ben Claytonf848af22023-07-28 16:37:32 +000034 TINT_ASSERT(source_ == nullptr);
Ben Claytonab0cbed2023-06-19 18:45:19 +000035 Base::Destroy();
36}
37
dan sinclair16cb4bd2023-09-21 08:52:11 +000038InstructionResult* InstructionResult::Clone(CloneContext& ctx) {
39 // Do not clone the `Source`. It will be set when this result is placed in the new parent
40 // instruction.
41 return ctx.ir.values.Create<InstructionResult>(type_);
42}
43
dan sinclair6f138fe2023-08-15 21:29:34 +000044} // namespace tint::core::ir