From 4a2e0ad36b0ed0738a1c32fd1ddf5268231e749b Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Thu, 27 Apr 2023 20:02:17 +0000 Subject: [PATCH] [ir] Make `ir::Discard` a child of `ir::Call`. The `discard` statement is, essentially, a function call. This CL moves the `ir` node from being under `Instruction` to be under `Call`. Bug: tint:1905 Change-Id: I8098dfc6047286b1c5249679139bcc83aa1cb21d Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129681 Kokoro: Kokoro Reviewed-by: Ben Clayton Commit-Queue: Dan Sinclair --- src/tint/ir/call.cc | 2 ++ src/tint/ir/call.h | 14 +++++++++----- src/tint/ir/discard.h | 4 ++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/tint/ir/call.cc b/src/tint/ir/call.cc index 5d53886b99..322f83d62e 100644 --- a/src/tint/ir/call.cc +++ b/src/tint/ir/call.cc @@ -18,6 +18,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ir::Call); namespace tint::ir { +Call::Call() : Base() {} + Call::Call(uint32_t id, const type::Type* type, utils::VectorRef args) : Base(id, type), args_(args) { for (auto* arg : args) { diff --git a/src/tint/ir/call.h b/src/tint/ir/call.h index fcd2c62d79..a49e9fafe7 100644 --- a/src/tint/ir/call.h +++ b/src/tint/ir/call.h @@ -24,11 +24,6 @@ namespace tint::ir { /// A Call instruction in the IR. class Call : public utils::Castable { public: - /// Constructor - /// @param id the instruction id - /// @param type the result type - /// @param args the constructor arguments - Call(uint32_t id, const type::Type* type, utils::VectorRef args); Call(const Call& inst) = delete; Call(Call&& inst) = delete; ~Call() override; @@ -43,6 +38,15 @@ class Call : public utils::Castable { /// @param out the output stream void EmitArgs(utils::StringStream& out) const; + protected: + /// Constructor + Call(); + /// Constructor + /// @param id the instruction id + /// @param type the result type + /// @param args the constructor arguments + Call(uint32_t id, const type::Type* type, utils::VectorRef args); + private: utils::Vector args_; }; diff --git a/src/tint/ir/discard.h b/src/tint/ir/discard.h index 042f131eb3..456c8d56b2 100644 --- a/src/tint/ir/discard.h +++ b/src/tint/ir/discard.h @@ -16,14 +16,14 @@ #define SRC_TINT_IR_DISCARD_H_ #include "src/tint/debug.h" -#include "src/tint/ir/instruction.h" +#include "src/tint/ir/call.h" #include "src/tint/utils/castable.h" #include "src/tint/utils/string_stream.h" namespace tint::ir { /// A discard instruction in the IR. -class Discard : public utils::Castable { +class Discard : public utils::Castable { public: /// Constructor Discard();