[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 <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
dan sinclair 2023-04-25 15:07:26 +00:00 committed by Dawn LUCI CQ
parent 41428ad681
commit 03f9f5f538
10 changed files with 104 additions and 104 deletions

View File

@ -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()

View File

@ -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<type::I32>(), b.builder.Constant(4_i),
b.builder.Constant(2_i));
EXPECT_EQ(instr->GetKind(), Binary::Kind::kAnd);
ASSERT_TRUE(instr->Result()->Is<Temp>());
ASSERT_TRUE(instr->Result()->Is<Runtime>());
ASSERT_NE(instr->Result()->Type(), nullptr);
EXPECT_EQ(Temp::Id(42), instr->Result()->As<Temp>()->AsId());
EXPECT_EQ(Runtime::Id(42), instr->Result()->As<Runtime>()->AsId());
ASSERT_TRUE(instr->LHS()->Is<Constant>());
auto lhs = instr->LHS()->As<Constant>()->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<type::I32>(), b.builder.Constant(4_i),
b.builder.Constant(2_i));
EXPECT_EQ(instr->GetKind(), Binary::Kind::kOr);
ASSERT_TRUE(instr->Result()->Is<Temp>());
EXPECT_EQ(Temp::Id(42), instr->Result()->As<Temp>()->AsId());
ASSERT_TRUE(instr->Result()->Is<Runtime>());
EXPECT_EQ(Runtime::Id(42), instr->Result()->As<Runtime>()->AsId());
ASSERT_TRUE(instr->LHS()->Is<Constant>());
auto lhs = instr->LHS()->As<Constant>()->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<type::I32>(), b.builder.Constant(4_i),
b.builder.Constant(2_i));
EXPECT_EQ(instr->GetKind(), Binary::Kind::kXor);
ASSERT_TRUE(instr->Result()->Is<Temp>());
EXPECT_EQ(Temp::Id(42), instr->Result()->As<Temp>()->AsId());
ASSERT_TRUE(instr->Result()->Is<Runtime>());
EXPECT_EQ(Runtime::Id(42), instr->Result()->As<Runtime>()->AsId());
ASSERT_TRUE(instr->LHS()->Is<Constant>());
auto lhs = instr->LHS()->As<Constant>()->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<type::Bool>(),
b.builder.Constant(4_i), b.builder.Constant(2_i));
EXPECT_EQ(instr->GetKind(), Binary::Kind::kLogicalAnd);
ASSERT_TRUE(instr->Result()->Is<Temp>());
EXPECT_EQ(Temp::Id(42), instr->Result()->As<Temp>()->AsId());
ASSERT_TRUE(instr->Result()->Is<Runtime>());
EXPECT_EQ(Runtime::Id(42), instr->Result()->As<Runtime>()->AsId());
ASSERT_TRUE(instr->LHS()->Is<Constant>());
auto lhs = instr->LHS()->As<Constant>()->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<type::Bool>(),
b.builder.Constant(4_i), b.builder.Constant(2_i));
EXPECT_EQ(instr->GetKind(), Binary::Kind::kLogicalOr);
ASSERT_TRUE(instr->Result()->Is<Temp>());
EXPECT_EQ(Temp::Id(42), instr->Result()->As<Temp>()->AsId());
ASSERT_TRUE(instr->Result()->Is<Runtime>());
EXPECT_EQ(Runtime::Id(42), instr->Result()->As<Runtime>()->AsId());
ASSERT_TRUE(instr->LHS()->Is<Constant>());
auto lhs = instr->LHS()->As<Constant>()->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<type::Bool>(),
b.builder.Constant(4_i), b.builder.Constant(2_i));
EXPECT_EQ(instr->GetKind(), Binary::Kind::kEqual);
ASSERT_TRUE(instr->Result()->Is<Temp>());
EXPECT_EQ(Temp::Id(42), instr->Result()->As<Temp>()->AsId());
ASSERT_TRUE(instr->Result()->Is<Runtime>());
EXPECT_EQ(Runtime::Id(42), instr->Result()->As<Runtime>()->AsId());
ASSERT_TRUE(instr->LHS()->Is<Constant>());
auto lhs = instr->LHS()->As<Constant>()->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<type::Bool>(),
b.builder.Constant(4_i), b.builder.Constant(2_i));
EXPECT_EQ(instr->GetKind(), Binary::Kind::kNotEqual);
ASSERT_TRUE(instr->Result()->Is<Temp>());
EXPECT_EQ(Temp::Id(42), instr->Result()->As<Temp>()->AsId());
ASSERT_TRUE(instr->Result()->Is<Runtime>());
EXPECT_EQ(Runtime::Id(42), instr->Result()->As<Runtime>()->AsId());
ASSERT_TRUE(instr->LHS()->Is<Constant>());
auto lhs = instr->LHS()->As<Constant>()->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<type::Bool>(),
b.builder.Constant(4_i), b.builder.Constant(2_i));
EXPECT_EQ(instr->GetKind(), Binary::Kind::kLessThan);
ASSERT_TRUE(instr->Result()->Is<Temp>());
EXPECT_EQ(Temp::Id(42), instr->Result()->As<Temp>()->AsId());
ASSERT_TRUE(instr->Result()->Is<Runtime>());
EXPECT_EQ(Runtime::Id(42), instr->Result()->As<Runtime>()->AsId());
ASSERT_TRUE(instr->LHS()->Is<Constant>());
auto lhs = instr->LHS()->As<Constant>()->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<type::Bool>(),
b.builder.Constant(4_i), b.builder.Constant(2_i));
EXPECT_EQ(instr->GetKind(), Binary::Kind::kGreaterThan);
ASSERT_TRUE(instr->Result()->Is<Temp>());
EXPECT_EQ(Temp::Id(42), instr->Result()->As<Temp>()->AsId());
ASSERT_TRUE(instr->Result()->Is<Runtime>());
EXPECT_EQ(Runtime::Id(42), instr->Result()->As<Runtime>()->AsId());
ASSERT_TRUE(instr->LHS()->Is<Constant>());
auto lhs = instr->LHS()->As<Constant>()->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<type::Bool>(),
b.builder.Constant(4_i), b.builder.Constant(2_i));
EXPECT_EQ(instr->GetKind(), Binary::Kind::kLessThanEqual);
ASSERT_TRUE(instr->Result()->Is<Temp>());
EXPECT_EQ(Temp::Id(42), instr->Result()->As<Temp>()->AsId());
ASSERT_TRUE(instr->Result()->Is<Runtime>());
EXPECT_EQ(Runtime::Id(42), instr->Result()->As<Runtime>()->AsId());
ASSERT_TRUE(instr->LHS()->Is<Constant>());
auto lhs = instr->LHS()->As<Constant>()->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<type::Bool>(), b.builder.Constant(4_i), b.builder.Constant(2_i));
EXPECT_EQ(instr->GetKind(), Binary::Kind::kGreaterThanEqual);
ASSERT_TRUE(instr->Result()->Is<Temp>());
EXPECT_EQ(Temp::Id(42), instr->Result()->As<Temp>()->AsId());
ASSERT_TRUE(instr->Result()->Is<Runtime>());
EXPECT_EQ(Runtime::Id(42), instr->Result()->As<Runtime>()->AsId());
ASSERT_TRUE(instr->LHS()->Is<Constant>());
auto lhs = instr->LHS()->As<Constant>()->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<type::I32>(),
b.builder.Constant(4_i), b.builder.Constant(2_i));
EXPECT_EQ(instr->GetKind(), Binary::Kind::kShiftLeft);
ASSERT_TRUE(instr->Result()->Is<Temp>());
EXPECT_EQ(Temp::Id(42), instr->Result()->As<Temp>()->AsId());
ASSERT_TRUE(instr->Result()->Is<Runtime>());
EXPECT_EQ(Runtime::Id(42), instr->Result()->As<Runtime>()->AsId());
ASSERT_TRUE(instr->LHS()->Is<Constant>());
auto lhs = instr->LHS()->As<Constant>()->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<type::I32>(),
b.builder.Constant(4_i), b.builder.Constant(2_i));
EXPECT_EQ(instr->GetKind(), Binary::Kind::kShiftRight);
ASSERT_TRUE(instr->Result()->Is<Temp>());
EXPECT_EQ(Temp::Id(42), instr->Result()->As<Temp>()->AsId());
ASSERT_TRUE(instr->Result()->Is<Runtime>());
EXPECT_EQ(Runtime::Id(42), instr->Result()->As<Runtime>()->AsId());
ASSERT_TRUE(instr->LHS()->Is<Constant>());
auto lhs = instr->LHS()->As<Constant>()->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<type::I32>(), b.builder.Constant(4_i),
b.builder.Constant(2_i));
EXPECT_EQ(instr->GetKind(), Binary::Kind::kAdd);
ASSERT_TRUE(instr->Result()->Is<Temp>());
EXPECT_EQ(Temp::Id(42), instr->Result()->As<Temp>()->AsId());
ASSERT_TRUE(instr->Result()->Is<Runtime>());
EXPECT_EQ(Runtime::Id(42), instr->Result()->As<Runtime>()->AsId());
ASSERT_TRUE(instr->LHS()->Is<Constant>());
auto lhs = instr->LHS()->As<Constant>()->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<type::I32>(),
b.builder.Constant(4_i), b.builder.Constant(2_i));
EXPECT_EQ(instr->GetKind(), Binary::Kind::kSubtract);
ASSERT_TRUE(instr->Result()->Is<Temp>());
EXPECT_EQ(Temp::Id(42), instr->Result()->As<Temp>()->AsId());
ASSERT_TRUE(instr->Result()->Is<Runtime>());
EXPECT_EQ(Runtime::Id(42), instr->Result()->As<Runtime>()->AsId());
ASSERT_TRUE(instr->LHS()->Is<Constant>());
auto lhs = instr->LHS()->As<Constant>()->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<type::I32>(),
b.builder.Constant(4_i), b.builder.Constant(2_i));
EXPECT_EQ(instr->GetKind(), Binary::Kind::kMultiply);
ASSERT_TRUE(instr->Result()->Is<Temp>());
EXPECT_EQ(Temp::Id(42), instr->Result()->As<Temp>()->AsId());
ASSERT_TRUE(instr->Result()->Is<Runtime>());
EXPECT_EQ(Runtime::Id(42), instr->Result()->As<Runtime>()->AsId());
ASSERT_TRUE(instr->LHS()->Is<Constant>());
auto lhs = instr->LHS()->As<Constant>()->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<type::I32>(),
b.builder.Constant(4_i), b.builder.Constant(2_i));
EXPECT_EQ(instr->GetKind(), Binary::Kind::kDivide);
ASSERT_TRUE(instr->Result()->Is<Temp>());
EXPECT_EQ(Temp::Id(42), instr->Result()->As<Temp>()->AsId());
ASSERT_TRUE(instr->Result()->Is<Runtime>());
EXPECT_EQ(Runtime::Id(42), instr->Result()->As<Runtime>()->AsId());
ASSERT_TRUE(instr->LHS()->Is<Constant>());
auto lhs = instr->LHS()->As<Constant>()->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<type::I32>(),
b.builder.Constant(4_i), b.builder.Constant(2_i));
EXPECT_EQ(instr->GetKind(), Binary::Kind::kModulo);
ASSERT_TRUE(instr->Result()->Is<Temp>());
EXPECT_EQ(Temp::Id(42), instr->Result()->As<Temp>()->AsId());
ASSERT_TRUE(instr->Result()->Is<Runtime>());
EXPECT_EQ(Runtime::Id(42), instr->Result()->As<Runtime>()->AsId());
ASSERT_TRUE(instr->LHS()->Is<Constant>());
auto lhs = instr->LHS()->As<Constant>()->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<type::I32>(), 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<type::I32>(), val, val);
EXPECT_EQ(instr->GetKind(), Binary::Kind::kAnd);

View File

@ -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<type::I32>(), b.builder.Constant(4_i));
ASSERT_TRUE(instr->Result()->Is<Temp>());
EXPECT_EQ(Temp::Id(42), instr->Result()->As<Temp>()->AsId());
ASSERT_TRUE(instr->Result()->Is<Runtime>());
EXPECT_EQ(Runtime::Id(42), instr->Result()->As<Runtime>()->AsId());
ASSERT_NE(instr->Result()->Type(), nullptr);
ASSERT_TRUE(instr->Val()->Is<Constant>());
@ -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<type::I32>(), b.builder.Constant(4_i));

View File

@ -93,12 +93,12 @@ void Builder::Branch(Block* from, FlowNode* to, utils::VectorRef<Value*> 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<ir::Binary>(kind, Temp(type), lhs, rhs);
return ir.instructions.Create<ir::Binary>(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<ir::Bitcast>(Temp(type), val);
return ir.instructions.Create<ir::Bitcast>(Runtime(type), val);
}
ir::UserCall* Builder::UserCall(const type::Type* type,
Symbol name,
utils::VectorRef<Value*> args) {
return ir.instructions.Create<ir::UserCall>(Temp(type), name, std::move(args));
return ir.instructions.Create<ir::UserCall>(Runtime(type), name, std::move(args));
}
ir::Convert* Builder::Convert(const type::Type* to,
const type::Type* from,
utils::VectorRef<Value*> args) {
return ir.instructions.Create<ir::Convert>(Temp(to), from, std::move(args));
return ir.instructions.Create<ir::Convert>(Runtime(to), from, std::move(args));
}
ir::Construct* Builder::Construct(const type::Type* to, utils::VectorRef<Value*> args) {
return ir.instructions.Create<ir::Construct>(Temp(to), std::move(args));
return ir.instructions.Create<ir::Construct>(Runtime(to), std::move(args));
}
ir::Builtin* Builder::Builtin(const type::Type* type,
builtin::Function func,
utils::VectorRef<Value*> args) {
return ir.instructions.Create<ir::Builtin>(Temp(type), func, args);
return ir.instructions.Create<ir::Builtin>(Runtime(type), func, args);
}
} // namespace tint::ir

View File

@ -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<constant::Scalar<bool>>(ir.types.Get<type::Bool>(), 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<ir::Temp>(type, AllocateTempId());
ir::Runtime* Runtime(const type::Type* type) {
return ir.values.Create<ir::Runtime>(type, AllocateRuntimeId());
}
/// Creates an op for `lhs kind rhs`
@ -315,14 +315,14 @@ class Builder {
builtin::Function func,
utils::VectorRef<Value*> 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

View File

@ -624,7 +624,7 @@ utils::Result<Value*> 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<type::Void>();
return builder.Temp(v);
return builder.Runtime(v);
});
}

View File

@ -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 <string>
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;
}

View File

@ -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<Temp, Value> {
/// Runtime value in the IR.
class Runtime : public utils::Castable<Runtime, Value> {
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<Temp, Value> {
} // namespace tint::ir
#endif // SRC_TINT_IR_TEMP_H_
#endif // SRC_TINT_IR_RUNTIME_H_

View File

@ -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<type::I32>());
b.builder.next_runtime_id = Runtime::Id(4);
auto* val = b.builder.Runtime(b.builder.ir.types.Get<type::I32>());
EXPECT_EQ(4u, val->AsId());
val->ToString(str);

View File

@ -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);