[ir] Remove the VarData from Value.

This CL removes VarData from Value. This will be implemented in another
way and is not currently used anywhere.

Bug: tint:1718
Change-Id: If5758cf050a080c6f68812219cd8ac968b54a8d6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/112042
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
dan sinclair 2022-11-29 14:34:47 +00:00 committed by Dawn LUCI CQ
parent 0285801376
commit ec7a1d2a1b
3 changed files with 1 additions and 67 deletions

View File

@ -30,8 +30,6 @@ Value::Value(i32 i) : kind_(Kind::kI32), data_(i) {}
Value::Value(bool b) : kind_(Kind::kBool), data_(b) {} Value::Value(bool b) : kind_(Kind::kBool), data_(b) {}
Value::Value(Symbol s, Id id) : kind_(Kind::kVar), data_(VarData{s, id}) {}
Value::~Value() = default; Value::~Value() = default;
Value::Value(const Value& o) = default; Value::Value(const Value& o) = default;
@ -59,10 +57,6 @@ std::ostream& operator<<(std::ostream& out, const Value& r) {
case Value::Kind::kU32: case Value::Kind::kU32:
out << std::to_string(r.AsU32().value); out << std::to_string(r.AsU32().value);
break; break;
// TODO(dsinclair): Emit the symbol instead of v
case Value::Kind::kVar:
out << "%v" << std::to_string(r.AsVarData().id);
break;
case Value::Kind::kBool: case Value::Kind::kBool:
out << (r.AsBool() ? "true" : "false"); out << (r.AsBool() ? "true" : "false");
break; break;

View File

@ -19,7 +19,6 @@
#include <variant> #include <variant>
#include "src/tint/number.h" #include "src/tint/number.h"
#include "src/tint/symbol.h"
namespace tint::ir { namespace tint::ir {
@ -45,24 +44,10 @@ class Value {
kI32, kI32,
/// A u32 value /// A u32 value
kU32, kU32,
/// A variable value
kVar,
/// A boolean value /// A boolean value
kBool, kBool,
}; };
/// Stores data for a given variable. There will be multiple `VarData` entries for a given `id`.
/// The `id` acts like a generation number (although they aren't sequential, they are
/// increasing). As the variable is stored too a new value will be created and the the `id`
/// will be incremented.
struct VarData {
/// The symbol for the variable
Symbol sym;
/// The id for the variable.
Id id;
// TODO(dsinclair): Should var type data be stored here along side the variable info?
};
/// Constructor /// Constructor
/// Creates a uninitialized value /// Creates a uninitialized value
Value(); Value();
@ -71,11 +56,6 @@ class Value {
/// @param id the id for the value /// @param id the id for the value
explicit Value(Id id); explicit Value(Id id);
/// Constructor
/// @param s the symbol for the value
/// @param id the id for the value
Value(Symbol s, Id id);
/// Constructor /// Constructor
/// @param b the `bool` value to store in the value /// @param b the `bool` value to store in the value
explicit Value(bool b); explicit Value(bool b);
@ -125,8 +105,6 @@ class Value {
bool IsI32() const { return kind_ == Kind::kI32; } bool IsI32() const { return kind_ == Kind::kI32; }
/// @returns true if this is a u32 value /// @returns true if this is a u32 value
bool IsU32() const { return kind_ == Kind::kU32; } bool IsU32() const { return kind_ == Kind::kU32; }
/// @returns true if this is a var value
bool IsVar() const { return kind_ == Kind::kVar; }
/// @returns true if this is a bool value /// @returns true if this is a bool value
bool IsBool() const { return kind_ == Kind::kBool; } bool IsBool() const { return kind_ == Kind::kBool; }
@ -148,9 +126,6 @@ class Value {
/// @returns the value data as an `Id`. /// @returns the value data as an `Id`.
/// @note, must only be called if `IsTemp()` is true /// @note, must only be called if `IsTemp()` is true
Id AsId() const { return std::get<Id>(data_); } Id AsId() const { return std::get<Id>(data_); }
/// @returns the value data as a `VarData` structure.
/// @note, must only be called if `IsVar()` is true
VarData AsVarData() const { return std::get<VarData>(data_); }
/// @returns the value data as a `bool`. /// @returns the value data as a `bool`.
/// @note, must only be called if `IsBool()` is true /// @note, must only be called if `IsBool()` is true
bool AsBool() const { return std::get<bool>(data_); } bool AsBool() const { return std::get<bool>(data_); }
@ -159,7 +134,7 @@ class Value {
/// The type of data stored in this value /// The type of data stored in this value
Kind kind_; Kind kind_;
/// The data stored in the value /// The data stored in the value
std::variant<Id, f32, f16, u32, i32, VarData, bool> data_; std::variant<Id, f32, f16, u32, i32, bool> data_;
}; };
std::ostream& operator<<(std::ostream& out, const Value& r); std::ostream& operator<<(std::ostream& out, const Value& r);

View File

@ -38,7 +38,6 @@ TEST_F(IR_ValueTest, f32) {
EXPECT_FALSE(val.IsI32()); EXPECT_FALSE(val.IsI32());
EXPECT_FALSE(val.IsU32()); EXPECT_FALSE(val.IsU32());
EXPECT_FALSE(val.IsTemp()); EXPECT_FALSE(val.IsTemp());
EXPECT_FALSE(val.IsVar());
EXPECT_FALSE(val.IsBool()); EXPECT_FALSE(val.IsBool());
} }
@ -56,7 +55,6 @@ TEST_F(IR_ValueTest, f16) {
EXPECT_FALSE(val.IsI32()); EXPECT_FALSE(val.IsI32());
EXPECT_FALSE(val.IsU32()); EXPECT_FALSE(val.IsU32());
EXPECT_FALSE(val.IsTemp()); EXPECT_FALSE(val.IsTemp());
EXPECT_FALSE(val.IsVar());
EXPECT_FALSE(val.IsBool()); EXPECT_FALSE(val.IsBool());
} }
@ -74,7 +72,6 @@ TEST_F(IR_ValueTest, i32) {
EXPECT_TRUE(val.IsI32()); EXPECT_TRUE(val.IsI32());
EXPECT_FALSE(val.IsU32()); EXPECT_FALSE(val.IsU32());
EXPECT_FALSE(val.IsTemp()); EXPECT_FALSE(val.IsTemp());
EXPECT_FALSE(val.IsVar());
EXPECT_FALSE(val.IsBool()); EXPECT_FALSE(val.IsBool());
} }
@ -92,7 +89,6 @@ TEST_F(IR_ValueTest, u32) {
EXPECT_FALSE(val.IsI32()); EXPECT_FALSE(val.IsI32());
EXPECT_TRUE(val.IsU32()); EXPECT_TRUE(val.IsU32());
EXPECT_FALSE(val.IsTemp()); EXPECT_FALSE(val.IsTemp());
EXPECT_FALSE(val.IsVar());
EXPECT_FALSE(val.IsBool()); EXPECT_FALSE(val.IsBool());
} }
@ -110,7 +106,6 @@ TEST_F(IR_ValueTest, id) {
EXPECT_FALSE(val.IsI32()); EXPECT_FALSE(val.IsI32());
EXPECT_FALSE(val.IsU32()); EXPECT_FALSE(val.IsU32());
EXPECT_TRUE(val.IsTemp()); EXPECT_TRUE(val.IsTemp());
EXPECT_FALSE(val.IsVar());
EXPECT_FALSE(val.IsBool()); EXPECT_FALSE(val.IsBool());
} }
@ -135,38 +130,9 @@ TEST_F(IR_ValueTest, bool) {
EXPECT_FALSE(val.IsI32()); EXPECT_FALSE(val.IsI32());
EXPECT_FALSE(val.IsU32()); EXPECT_FALSE(val.IsU32());
EXPECT_FALSE(val.IsTemp()); EXPECT_FALSE(val.IsTemp());
EXPECT_FALSE(val.IsVar());
EXPECT_TRUE(val.IsBool()); EXPECT_TRUE(val.IsBool());
} }
TEST_F(IR_ValueTest, var) {
std::stringstream str;
Symbol s;
Value val(s, 2);
EXPECT_EQ(2u, val.AsVarData().id);
EXPECT_EQ(s, val.AsVarData().sym);
str << val;
EXPECT_EQ("%v2", str.str());
str.str("");
val = Value(s, 4);
EXPECT_EQ(4u, val.AsVarData().id);
EXPECT_EQ(s, val.AsVarData().sym);
str << val;
EXPECT_EQ("%v4", str.str());
EXPECT_FALSE(val.IsF32());
EXPECT_FALSE(val.IsF16());
EXPECT_FALSE(val.IsI32());
EXPECT_FALSE(val.IsU32());
EXPECT_FALSE(val.IsTemp());
EXPECT_TRUE(val.IsVar());
EXPECT_FALSE(val.IsBool());
}
TEST_F(IR_ValueTest, uninitialized) { TEST_F(IR_ValueTest, uninitialized) {
Value val; Value val;
@ -175,7 +141,6 @@ TEST_F(IR_ValueTest, uninitialized) {
EXPECT_FALSE(val.IsI32()); EXPECT_FALSE(val.IsI32());
EXPECT_FALSE(val.IsU32()); EXPECT_FALSE(val.IsU32());
EXPECT_FALSE(val.IsTemp()); EXPECT_FALSE(val.IsTemp());
EXPECT_FALSE(val.IsVar());
EXPECT_FALSE(val.IsBool()); EXPECT_FALSE(val.IsBool());
} }