[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 <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
dan sinclair 2023-04-27 20:02:17 +00:00 committed by Dawn LUCI CQ
parent 6e614cc0b3
commit 4a2e0ad36b
3 changed files with 13 additions and 7 deletions

View File

@ -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<Value*> args)
: Base(id, type), args_(args) {
for (auto* arg : args) {

View File

@ -24,11 +24,6 @@ namespace tint::ir {
/// A Call instruction in the IR.
class Call : public utils::Castable<Call, Instruction> {
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<Value*> args);
Call(const Call& inst) = delete;
Call(Call&& inst) = delete;
~Call() override;
@ -43,6 +38,15 @@ class Call : public utils::Castable<Call, Instruction> {
/// @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<Value*> args);
private:
utils::Vector<Value*, 1> args_;
};

View File

@ -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<Discard, Instruction> {
class Discard : public utils::Castable<Discard, Call> {
public:
/// Constructor
Discard();