From 03f9f5f538121da7bc3c6175de9fd38fa2aaf0e0 Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Tue, 25 Apr 2023 15:07:26 +0000 Subject: [PATCH] [ir] Rename ir::Temp This CL renames ir::Temp to ir::Runtime to better reflect that this is a runtime generated ID. Bug: tint:1718 Change-Id: I24edbe0e2e19303f50355117ec7cd4b5b8f45aef Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129100 Reviewed-by: Ben Clayton Kokoro: Kokoro Commit-Queue: Dan Sinclair --- src/tint/CMakeLists.txt | 6 +- src/tint/ir/binary_test.cc | 112 +++++++++--------- src/tint/ir/bitcast_test.cc | 8 +- src/tint/ir/builder.cc | 16 +-- src/tint/ir/builder.h | 14 +-- src/tint/ir/builder_impl.cc | 2 +- src/tint/ir/{temp.cc => runtime.cc} | 10 +- src/tint/ir/{temp.h => runtime.h} | 28 ++--- src/tint/ir/{temp_test.cc => runtime_test.cc} | 10 +- src/tint/ir/value.cc | 2 +- 10 files changed, 104 insertions(+), 104 deletions(-) rename src/tint/ir/{temp.cc => runtime.cc} (74%) rename src/tint/ir/{temp.h => runtime.h} (69%) rename src/tint/ir/{temp_test.cc => runtime_test.cc} (81%) diff --git a/src/tint/CMakeLists.txt b/src/tint/CMakeLists.txt index 7bac6ed6a8..1ec518db17 100644 --- a/src/tint/CMakeLists.txt +++ b/src/tint/CMakeLists.txt @@ -732,10 +732,10 @@ if(${TINT_BUILD_IR}) ir/loop.h ir/module.cc ir/module.h + ir/runtime.cc + ir/runtime.h ir/switch.cc ir/switch.h - ir/temp.cc - ir/temp.h ir/terminator.cc ir/terminator.h ir/user_call.cc @@ -1413,7 +1413,7 @@ if(TINT_BUILD_TESTS) ir/bitcast_test.cc ir/builder_impl_test.cc ir/constant_test.cc - ir/temp_test.cc + ir/runtime_test.cc ir/test_helper.h ) endif() diff --git a/src/tint/ir/binary_test.cc b/src/tint/ir/binary_test.cc index 31972cea98..6be82f936a 100644 --- a/src/tint/ir/binary_test.cc +++ b/src/tint/ir/binary_test.cc @@ -26,15 +26,15 @@ using IR_InstructionTest = TestHelper; TEST_F(IR_InstructionTest, CreateAnd) { auto& b = CreateEmptyBuilder(); - b.builder.next_temp_id = Temp::Id(42); + b.builder.next_runtime_id = Runtime::Id(42); const auto* instr = b.builder.And(b.builder.ir.types.Get(), b.builder.Constant(4_i), b.builder.Constant(2_i)); EXPECT_EQ(instr->GetKind(), Binary::Kind::kAnd); - ASSERT_TRUE(instr->Result()->Is()); + ASSERT_TRUE(instr->Result()->Is()); ASSERT_NE(instr->Result()->Type(), nullptr); - EXPECT_EQ(Temp::Id(42), instr->Result()->As()->AsId()); + EXPECT_EQ(Runtime::Id(42), instr->Result()->As()->AsId()); ASSERT_TRUE(instr->LHS()->Is()); auto lhs = instr->LHS()->As()->value; @@ -54,14 +54,14 @@ TEST_F(IR_InstructionTest, CreateAnd) { TEST_F(IR_InstructionTest, CreateOr) { auto& b = CreateEmptyBuilder(); - b.builder.next_temp_id = Temp::Id(42); + b.builder.next_runtime_id = Runtime::Id(42); const auto* instr = b.builder.Or(b.builder.ir.types.Get(), b.builder.Constant(4_i), b.builder.Constant(2_i)); EXPECT_EQ(instr->GetKind(), Binary::Kind::kOr); - ASSERT_TRUE(instr->Result()->Is()); - EXPECT_EQ(Temp::Id(42), instr->Result()->As()->AsId()); + ASSERT_TRUE(instr->Result()->Is()); + EXPECT_EQ(Runtime::Id(42), instr->Result()->As()->AsId()); ASSERT_TRUE(instr->LHS()->Is()); auto lhs = instr->LHS()->As()->value; @@ -81,14 +81,14 @@ TEST_F(IR_InstructionTest, CreateOr) { TEST_F(IR_InstructionTest, CreateXor) { auto& b = CreateEmptyBuilder(); - b.builder.next_temp_id = Temp::Id(42); + b.builder.next_runtime_id = Runtime::Id(42); const auto* instr = b.builder.Xor(b.builder.ir.types.Get(), b.builder.Constant(4_i), b.builder.Constant(2_i)); EXPECT_EQ(instr->GetKind(), Binary::Kind::kXor); - ASSERT_TRUE(instr->Result()->Is()); - EXPECT_EQ(Temp::Id(42), instr->Result()->As()->AsId()); + ASSERT_TRUE(instr->Result()->Is()); + EXPECT_EQ(Runtime::Id(42), instr->Result()->As()->AsId()); ASSERT_TRUE(instr->LHS()->Is()); auto lhs = instr->LHS()->As()->value; @@ -108,14 +108,14 @@ TEST_F(IR_InstructionTest, CreateXor) { TEST_F(IR_InstructionTest, CreateLogicalAnd) { auto& b = CreateEmptyBuilder(); - b.builder.next_temp_id = Temp::Id(42); + b.builder.next_runtime_id = Runtime::Id(42); const auto* instr = b.builder.LogicalAnd(b.builder.ir.types.Get(), b.builder.Constant(4_i), b.builder.Constant(2_i)); EXPECT_EQ(instr->GetKind(), Binary::Kind::kLogicalAnd); - ASSERT_TRUE(instr->Result()->Is()); - EXPECT_EQ(Temp::Id(42), instr->Result()->As()->AsId()); + ASSERT_TRUE(instr->Result()->Is()); + EXPECT_EQ(Runtime::Id(42), instr->Result()->As()->AsId()); ASSERT_TRUE(instr->LHS()->Is()); auto lhs = instr->LHS()->As()->value; @@ -135,14 +135,14 @@ TEST_F(IR_InstructionTest, CreateLogicalAnd) { TEST_F(IR_InstructionTest, CreateLogicalOr) { auto& b = CreateEmptyBuilder(); - b.builder.next_temp_id = Temp::Id(42); + b.builder.next_runtime_id = Runtime::Id(42); const auto* instr = b.builder.LogicalOr(b.builder.ir.types.Get(), b.builder.Constant(4_i), b.builder.Constant(2_i)); EXPECT_EQ(instr->GetKind(), Binary::Kind::kLogicalOr); - ASSERT_TRUE(instr->Result()->Is()); - EXPECT_EQ(Temp::Id(42), instr->Result()->As()->AsId()); + ASSERT_TRUE(instr->Result()->Is()); + EXPECT_EQ(Runtime::Id(42), instr->Result()->As()->AsId()); ASSERT_TRUE(instr->LHS()->Is()); auto lhs = instr->LHS()->As()->value; @@ -162,14 +162,14 @@ TEST_F(IR_InstructionTest, CreateLogicalOr) { TEST_F(IR_InstructionTest, CreateEqual) { auto& b = CreateEmptyBuilder(); - b.builder.next_temp_id = Temp::Id(42); + b.builder.next_runtime_id = Runtime::Id(42); const auto* instr = b.builder.Equal(b.builder.ir.types.Get(), b.builder.Constant(4_i), b.builder.Constant(2_i)); EXPECT_EQ(instr->GetKind(), Binary::Kind::kEqual); - ASSERT_TRUE(instr->Result()->Is()); - EXPECT_EQ(Temp::Id(42), instr->Result()->As()->AsId()); + ASSERT_TRUE(instr->Result()->Is()); + EXPECT_EQ(Runtime::Id(42), instr->Result()->As()->AsId()); ASSERT_TRUE(instr->LHS()->Is()); auto lhs = instr->LHS()->As()->value; @@ -189,14 +189,14 @@ TEST_F(IR_InstructionTest, CreateEqual) { TEST_F(IR_InstructionTest, CreateNotEqual) { auto& b = CreateEmptyBuilder(); - b.builder.next_temp_id = Temp::Id(42); + b.builder.next_runtime_id = Runtime::Id(42); const auto* instr = b.builder.NotEqual(b.builder.ir.types.Get(), b.builder.Constant(4_i), b.builder.Constant(2_i)); EXPECT_EQ(instr->GetKind(), Binary::Kind::kNotEqual); - ASSERT_TRUE(instr->Result()->Is()); - EXPECT_EQ(Temp::Id(42), instr->Result()->As()->AsId()); + ASSERT_TRUE(instr->Result()->Is()); + EXPECT_EQ(Runtime::Id(42), instr->Result()->As()->AsId()); ASSERT_TRUE(instr->LHS()->Is()); auto lhs = instr->LHS()->As()->value; @@ -216,14 +216,14 @@ TEST_F(IR_InstructionTest, CreateNotEqual) { TEST_F(IR_InstructionTest, CreateLessThan) { auto& b = CreateEmptyBuilder(); - b.builder.next_temp_id = Temp::Id(42); + b.builder.next_runtime_id = Runtime::Id(42); const auto* instr = b.builder.LessThan(b.builder.ir.types.Get(), b.builder.Constant(4_i), b.builder.Constant(2_i)); EXPECT_EQ(instr->GetKind(), Binary::Kind::kLessThan); - ASSERT_TRUE(instr->Result()->Is()); - EXPECT_EQ(Temp::Id(42), instr->Result()->As()->AsId()); + ASSERT_TRUE(instr->Result()->Is()); + EXPECT_EQ(Runtime::Id(42), instr->Result()->As()->AsId()); ASSERT_TRUE(instr->LHS()->Is()); auto lhs = instr->LHS()->As()->value; @@ -243,14 +243,14 @@ TEST_F(IR_InstructionTest, CreateLessThan) { TEST_F(IR_InstructionTest, CreateGreaterThan) { auto& b = CreateEmptyBuilder(); - b.builder.next_temp_id = Temp::Id(42); + b.builder.next_runtime_id = Runtime::Id(42); const auto* instr = b.builder.GreaterThan(b.builder.ir.types.Get(), b.builder.Constant(4_i), b.builder.Constant(2_i)); EXPECT_EQ(instr->GetKind(), Binary::Kind::kGreaterThan); - ASSERT_TRUE(instr->Result()->Is()); - EXPECT_EQ(Temp::Id(42), instr->Result()->As()->AsId()); + ASSERT_TRUE(instr->Result()->Is()); + EXPECT_EQ(Runtime::Id(42), instr->Result()->As()->AsId()); ASSERT_TRUE(instr->LHS()->Is()); auto lhs = instr->LHS()->As()->value; @@ -270,14 +270,14 @@ TEST_F(IR_InstructionTest, CreateGreaterThan) { TEST_F(IR_InstructionTest, CreateLessThanEqual) { auto& b = CreateEmptyBuilder(); - b.builder.next_temp_id = Temp::Id(42); + b.builder.next_runtime_id = Runtime::Id(42); const auto* instr = b.builder.LessThanEqual(b.builder.ir.types.Get(), b.builder.Constant(4_i), b.builder.Constant(2_i)); EXPECT_EQ(instr->GetKind(), Binary::Kind::kLessThanEqual); - ASSERT_TRUE(instr->Result()->Is()); - EXPECT_EQ(Temp::Id(42), instr->Result()->As()->AsId()); + ASSERT_TRUE(instr->Result()->Is()); + EXPECT_EQ(Runtime::Id(42), instr->Result()->As()->AsId()); ASSERT_TRUE(instr->LHS()->Is()); auto lhs = instr->LHS()->As()->value; @@ -297,14 +297,14 @@ TEST_F(IR_InstructionTest, CreateLessThanEqual) { TEST_F(IR_InstructionTest, CreateGreaterThanEqual) { auto& b = CreateEmptyBuilder(); - b.builder.next_temp_id = Temp::Id(42); + b.builder.next_runtime_id = Runtime::Id(42); const auto* instr = b.builder.GreaterThanEqual( b.builder.ir.types.Get(), b.builder.Constant(4_i), b.builder.Constant(2_i)); EXPECT_EQ(instr->GetKind(), Binary::Kind::kGreaterThanEqual); - ASSERT_TRUE(instr->Result()->Is()); - EXPECT_EQ(Temp::Id(42), instr->Result()->As()->AsId()); + ASSERT_TRUE(instr->Result()->Is()); + EXPECT_EQ(Runtime::Id(42), instr->Result()->As()->AsId()); ASSERT_TRUE(instr->LHS()->Is()); auto lhs = instr->LHS()->As()->value; @@ -324,14 +324,14 @@ TEST_F(IR_InstructionTest, CreateGreaterThanEqual) { TEST_F(IR_InstructionTest, CreateShiftLeft) { auto& b = CreateEmptyBuilder(); - b.builder.next_temp_id = Temp::Id(42); + b.builder.next_runtime_id = Runtime::Id(42); const auto* instr = b.builder.ShiftLeft(b.builder.ir.types.Get(), b.builder.Constant(4_i), b.builder.Constant(2_i)); EXPECT_EQ(instr->GetKind(), Binary::Kind::kShiftLeft); - ASSERT_TRUE(instr->Result()->Is()); - EXPECT_EQ(Temp::Id(42), instr->Result()->As()->AsId()); + ASSERT_TRUE(instr->Result()->Is()); + EXPECT_EQ(Runtime::Id(42), instr->Result()->As()->AsId()); ASSERT_TRUE(instr->LHS()->Is()); auto lhs = instr->LHS()->As()->value; @@ -351,14 +351,14 @@ TEST_F(IR_InstructionTest, CreateShiftLeft) { TEST_F(IR_InstructionTest, CreateShiftRight) { auto& b = CreateEmptyBuilder(); - b.builder.next_temp_id = Temp::Id(42); + b.builder.next_runtime_id = Runtime::Id(42); const auto* instr = b.builder.ShiftRight(b.builder.ir.types.Get(), b.builder.Constant(4_i), b.builder.Constant(2_i)); EXPECT_EQ(instr->GetKind(), Binary::Kind::kShiftRight); - ASSERT_TRUE(instr->Result()->Is()); - EXPECT_EQ(Temp::Id(42), instr->Result()->As()->AsId()); + ASSERT_TRUE(instr->Result()->Is()); + EXPECT_EQ(Runtime::Id(42), instr->Result()->As()->AsId()); ASSERT_TRUE(instr->LHS()->Is()); auto lhs = instr->LHS()->As()->value; @@ -378,14 +378,14 @@ TEST_F(IR_InstructionTest, CreateShiftRight) { TEST_F(IR_InstructionTest, CreateAdd) { auto& b = CreateEmptyBuilder(); - b.builder.next_temp_id = Temp::Id(42); + b.builder.next_runtime_id = Runtime::Id(42); const auto* instr = b.builder.Add(b.builder.ir.types.Get(), b.builder.Constant(4_i), b.builder.Constant(2_i)); EXPECT_EQ(instr->GetKind(), Binary::Kind::kAdd); - ASSERT_TRUE(instr->Result()->Is()); - EXPECT_EQ(Temp::Id(42), instr->Result()->As()->AsId()); + ASSERT_TRUE(instr->Result()->Is()); + EXPECT_EQ(Runtime::Id(42), instr->Result()->As()->AsId()); ASSERT_TRUE(instr->LHS()->Is()); auto lhs = instr->LHS()->As()->value; @@ -405,14 +405,14 @@ TEST_F(IR_InstructionTest, CreateAdd) { TEST_F(IR_InstructionTest, CreateSubtract) { auto& b = CreateEmptyBuilder(); - b.builder.next_temp_id = Temp::Id(42); + b.builder.next_runtime_id = Runtime::Id(42); const auto* instr = b.builder.Subtract(b.builder.ir.types.Get(), b.builder.Constant(4_i), b.builder.Constant(2_i)); EXPECT_EQ(instr->GetKind(), Binary::Kind::kSubtract); - ASSERT_TRUE(instr->Result()->Is()); - EXPECT_EQ(Temp::Id(42), instr->Result()->As()->AsId()); + ASSERT_TRUE(instr->Result()->Is()); + EXPECT_EQ(Runtime::Id(42), instr->Result()->As()->AsId()); ASSERT_TRUE(instr->LHS()->Is()); auto lhs = instr->LHS()->As()->value; @@ -432,14 +432,14 @@ TEST_F(IR_InstructionTest, CreateSubtract) { TEST_F(IR_InstructionTest, CreateMultiply) { auto& b = CreateEmptyBuilder(); - b.builder.next_temp_id = Temp::Id(42); + b.builder.next_runtime_id = Runtime::Id(42); const auto* instr = b.builder.Multiply(b.builder.ir.types.Get(), b.builder.Constant(4_i), b.builder.Constant(2_i)); EXPECT_EQ(instr->GetKind(), Binary::Kind::kMultiply); - ASSERT_TRUE(instr->Result()->Is()); - EXPECT_EQ(Temp::Id(42), instr->Result()->As()->AsId()); + ASSERT_TRUE(instr->Result()->Is()); + EXPECT_EQ(Runtime::Id(42), instr->Result()->As()->AsId()); ASSERT_TRUE(instr->LHS()->Is()); auto lhs = instr->LHS()->As()->value; @@ -459,14 +459,14 @@ TEST_F(IR_InstructionTest, CreateMultiply) { TEST_F(IR_InstructionTest, CreateDivide) { auto& b = CreateEmptyBuilder(); - b.builder.next_temp_id = Temp::Id(42); + b.builder.next_runtime_id = Runtime::Id(42); const auto* instr = b.builder.Divide(b.builder.ir.types.Get(), b.builder.Constant(4_i), b.builder.Constant(2_i)); EXPECT_EQ(instr->GetKind(), Binary::Kind::kDivide); - ASSERT_TRUE(instr->Result()->Is()); - EXPECT_EQ(Temp::Id(42), instr->Result()->As()->AsId()); + ASSERT_TRUE(instr->Result()->Is()); + EXPECT_EQ(Runtime::Id(42), instr->Result()->As()->AsId()); ASSERT_TRUE(instr->LHS()->Is()); auto lhs = instr->LHS()->As()->value; @@ -486,14 +486,14 @@ TEST_F(IR_InstructionTest, CreateDivide) { TEST_F(IR_InstructionTest, CreateModulo) { auto& b = CreateEmptyBuilder(); - b.builder.next_temp_id = Temp::Id(42); + b.builder.next_runtime_id = Runtime::Id(42); const auto* instr = b.builder.Modulo(b.builder.ir.types.Get(), b.builder.Constant(4_i), b.builder.Constant(2_i)); EXPECT_EQ(instr->GetKind(), Binary::Kind::kModulo); - ASSERT_TRUE(instr->Result()->Is()); - EXPECT_EQ(Temp::Id(42), instr->Result()->As()->AsId()); + ASSERT_TRUE(instr->Result()->Is()); + EXPECT_EQ(Runtime::Id(42), instr->Result()->As()->AsId()); ASSERT_TRUE(instr->LHS()->Is()); auto lhs = instr->LHS()->As()->value; @@ -513,7 +513,7 @@ TEST_F(IR_InstructionTest, CreateModulo) { TEST_F(IR_InstructionTest, Binary_Usage) { auto& b = CreateEmptyBuilder(); - b.builder.next_temp_id = Temp::Id(42); + b.builder.next_runtime_id = Runtime::Id(42); const auto* instr = b.builder.And(b.builder.ir.types.Get(), b.builder.Constant(4_i), b.builder.Constant(2_i)); @@ -537,7 +537,7 @@ TEST_F(IR_InstructionTest, Binary_Usage_DuplicateValue) { auto val = b.builder.Constant(4_i); - b.builder.next_temp_id = Temp::Id(42); + b.builder.next_runtime_id = Runtime::Id(42); const auto* instr = b.builder.And(b.builder.ir.types.Get(), val, val); EXPECT_EQ(instr->GetKind(), Binary::Kind::kAnd); diff --git a/src/tint/ir/bitcast_test.cc b/src/tint/ir/bitcast_test.cc index b46c334805..2e6ca9dd90 100644 --- a/src/tint/ir/bitcast_test.cc +++ b/src/tint/ir/bitcast_test.cc @@ -26,12 +26,12 @@ using IR_InstructionTest = TestHelper; TEST_F(IR_InstructionTest, Bitcast) { auto& b = CreateEmptyBuilder(); - b.builder.next_temp_id = Temp::Id(42); + b.builder.next_runtime_id = Runtime::Id(42); const auto* instr = b.builder.Bitcast(b.builder.ir.types.Get(), b.builder.Constant(4_i)); - ASSERT_TRUE(instr->Result()->Is()); - EXPECT_EQ(Temp::Id(42), instr->Result()->As()->AsId()); + ASSERT_TRUE(instr->Result()->Is()); + EXPECT_EQ(Runtime::Id(42), instr->Result()->As()->AsId()); ASSERT_NE(instr->Result()->Type(), nullptr); ASSERT_TRUE(instr->Val()->Is()); @@ -47,7 +47,7 @@ TEST_F(IR_InstructionTest, Bitcast) { TEST_F(IR_InstructionTest, Bitcast_Usage) { auto& b = CreateEmptyBuilder(); - b.builder.next_temp_id = Temp::Id(42); + b.builder.next_runtime_id = Runtime::Id(42); const auto* instr = b.builder.Bitcast(b.builder.ir.types.Get(), b.builder.Constant(4_i)); diff --git a/src/tint/ir/builder.cc b/src/tint/ir/builder.cc index a3d2a31617..bf02e5c844 100644 --- a/src/tint/ir/builder.cc +++ b/src/tint/ir/builder.cc @@ -93,12 +93,12 @@ void Builder::Branch(Block* from, FlowNode* to, utils::VectorRef args) { to->inbound_branches.Push(from); } -Temp::Id Builder::AllocateTempId() { - return next_temp_id++; +Runtime::Id Builder::AllocateRuntimeId() { + return next_runtime_id++; } Binary* Builder::CreateBinary(Binary::Kind kind, const type::Type* type, Value* lhs, Value* rhs) { - return ir.instructions.Create(kind, Temp(type), lhs, rhs); + return ir.instructions.Create(kind, Runtime(type), lhs, rhs); } Binary* Builder::And(const type::Type* type, Value* lhs, Value* rhs) { @@ -174,29 +174,29 @@ Binary* Builder::Modulo(const type::Type* type, Value* lhs, Value* rhs) { } ir::Bitcast* Builder::Bitcast(const type::Type* type, Value* val) { - return ir.instructions.Create(Temp(type), val); + return ir.instructions.Create(Runtime(type), val); } ir::UserCall* Builder::UserCall(const type::Type* type, Symbol name, utils::VectorRef args) { - return ir.instructions.Create(Temp(type), name, std::move(args)); + return ir.instructions.Create(Runtime(type), name, std::move(args)); } ir::Convert* Builder::Convert(const type::Type* to, const type::Type* from, utils::VectorRef args) { - return ir.instructions.Create(Temp(to), from, std::move(args)); + return ir.instructions.Create(Runtime(to), from, std::move(args)); } ir::Construct* Builder::Construct(const type::Type* to, utils::VectorRef args) { - return ir.instructions.Create(Temp(to), std::move(args)); + return ir.instructions.Create(Runtime(to), std::move(args)); } ir::Builtin* Builder::Builtin(const type::Type* type, builtin::Function func, utils::VectorRef args) { - return ir.instructions.Create(Temp(type), func, args); + return ir.instructions.Create(Runtime(type), func, args); } } // namespace tint::ir diff --git a/src/tint/ir/builder.h b/src/tint/ir/builder.h index b090bdf1d4..64bbf0d9bb 100644 --- a/src/tint/ir/builder.h +++ b/src/tint/ir/builder.h @@ -28,8 +28,8 @@ #include "src/tint/ir/if.h" #include "src/tint/ir/loop.h" #include "src/tint/ir/module.h" +#include "src/tint/ir/runtime.h" #include "src/tint/ir/switch.h" -#include "src/tint/ir/temp.h" #include "src/tint/ir/terminator.h" #include "src/tint/ir/user_call.h" #include "src/tint/ir/value.h" @@ -137,11 +137,11 @@ class Builder { return Constant(create>(ir.types.Get(), v)); } - /// Creates a new Temporary + /// Creates a new Runtime value /// @param type the type of the temporary /// @returns the new temporary - ir::Temp* Temp(const type::Type* type) { - return ir.values.Create(type, AllocateTempId()); + ir::Runtime* Runtime(const type::Type* type) { + return ir.values.Create(type, AllocateRuntimeId()); } /// Creates an op for `lhs kind rhs` @@ -315,14 +315,14 @@ class Builder { builtin::Function func, utils::VectorRef args); - /// @returns a unique temp id - Temp::Id AllocateTempId(); + /// @returns a unique runtime id + Runtime::Id AllocateRuntimeId(); /// The IR module. Module ir; /// The next temporary number to allocate - Temp::Id next_temp_id = 1; + Runtime::Id next_runtime_id = 1; }; } // namespace tint::ir diff --git a/src/tint/ir/builder_impl.cc b/src/tint/ir/builder_impl.cc index c6c6ed0422..5ded821560 100644 --- a/src/tint/ir/builder_impl.cc +++ b/src/tint/ir/builder_impl.cc @@ -624,7 +624,7 @@ utils::Result BuilderImpl::EmitExpression(const ast::Expression* expr) { // TODO(dsinclair): This should return utils::Failure; Switch back // once all the above cases are handled. auto* v = builder.ir.types.Get(); - return builder.Temp(v); + return builder.Runtime(v); }); } diff --git a/src/tint/ir/temp.cc b/src/tint/ir/runtime.cc similarity index 74% rename from src/tint/ir/temp.cc rename to src/tint/ir/runtime.cc index b6c9a8e3b8..a1f485de10 100644 --- a/src/tint/ir/temp.cc +++ b/src/tint/ir/runtime.cc @@ -12,19 +12,19 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/ir/temp.h" +#include "src/tint/ir/runtime.h" #include -TINT_INSTANTIATE_TYPEINFO(tint::ir::Temp); +TINT_INSTANTIATE_TYPEINFO(tint::ir::Runtime); namespace tint::ir { -Temp::Temp(const type::Type* type, Id id) : type_(type), id_(id) {} +Runtime::Runtime(const type::Type* type, Id id) : type_(type), id_(id) {} -Temp::~Temp() = default; +Runtime::~Runtime() = default; -utils::StringStream& Temp::ToString(utils::StringStream& out) const { +utils::StringStream& Runtime::ToString(utils::StringStream& out) const { out << "%" << std::to_string(AsId()) << " (" << type_->FriendlyName() << ")"; return out; } diff --git a/src/tint/ir/temp.h b/src/tint/ir/runtime.h similarity index 69% rename from src/tint/ir/temp.h rename to src/tint/ir/runtime.h index 31bc28489d..8cf71a3a49 100644 --- a/src/tint/ir/temp.h +++ b/src/tint/ir/runtime.h @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef SRC_TINT_IR_TEMP_H_ -#define SRC_TINT_IR_TEMP_H_ +#ifndef SRC_TINT_IR_RUNTIME_H_ +#define SRC_TINT_IR_RUNTIME_H_ #include "src/tint/ir/value.h" #include "src/tint/symbol_table.h" @@ -21,33 +21,33 @@ namespace tint::ir { -/// Temporary value in the IR. -class Temp : public utils::Castable { +/// Runtime value in the IR. +class Runtime : public utils::Castable { public: /// A value id. using Id = uint32_t; /// Constructor - /// @param type the type of the temporary + /// @param type the type of the value /// @param id the id for the value - Temp(const type::Type* type, Id id); + Runtime(const type::Type* type, Id id); /// Destructor - ~Temp() override; + ~Runtime() override; - Temp(const Temp&) = delete; - Temp(Temp&&) = delete; + Runtime(const Runtime&) = delete; + Runtime(Runtime&&) = delete; - Temp& operator=(const Temp&) = delete; - Temp& operator=(Temp&&) = delete; + Runtime& operator=(const Runtime&) = delete; + Runtime& operator=(Runtime&&) = delete; /// @returns the value data as an `Id`. Id AsId() const { return id_; } - /// @returns the type of the temporary + /// @returns the type of the value const type::Type* Type() const override { return type_; } - /// Write the temp to the given stream + /// Write the id to the given stream /// @param out the stream to write to /// @returns the stream utils::StringStream& ToString(utils::StringStream& out) const override; @@ -59,4 +59,4 @@ class Temp : public utils::Castable { } // namespace tint::ir -#endif // SRC_TINT_IR_TEMP_H_ +#endif // SRC_TINT_IR_RUNTIME_H_ diff --git a/src/tint/ir/temp_test.cc b/src/tint/ir/runtime_test.cc similarity index 81% rename from src/tint/ir/temp_test.cc rename to src/tint/ir/runtime_test.cc index edd002bae5..79599091ef 100644 --- a/src/tint/ir/temp_test.cc +++ b/src/tint/ir/runtime_test.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/ir/temp.h" +#include "src/tint/ir/runtime.h" #include "src/tint/ir/test_helper.h" #include "src/tint/utils/string_stream.h" @@ -21,15 +21,15 @@ namespace { using namespace tint::number_suffixes; // NOLINT -using IR_TempTest = TestHelper; +using IR_RuntimeTest = TestHelper; -TEST_F(IR_TempTest, id) { +TEST_F(IR_RuntimeTest, id) { auto& b = CreateEmptyBuilder(); utils::StringStream str; - b.builder.next_temp_id = Temp::Id(4); - auto* val = b.builder.Temp(b.builder.ir.types.Get()); + b.builder.next_runtime_id = Runtime::Id(4); + auto* val = b.builder.Runtime(b.builder.ir.types.Get()); EXPECT_EQ(4u, val->AsId()); val->ToString(str); diff --git a/src/tint/ir/value.cc b/src/tint/ir/value.cc index 93040cfb21..750fe19191 100644 --- a/src/tint/ir/value.cc +++ b/src/tint/ir/value.cc @@ -15,7 +15,7 @@ #include "src/tint/ir/value.h" #include "src/tint/ir/constant.h" -#include "src/tint/ir/temp.h" +#include "src/tint/ir/runtime.h" TINT_INSTANTIATE_TYPEINFO(tint::ir::Value);