mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-03 11:46:09 +00:00
[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:
parent
41428ad681
commit
03f9f5f538
@ -732,10 +732,10 @@ if(${TINT_BUILD_IR})
|
|||||||
ir/loop.h
|
ir/loop.h
|
||||||
ir/module.cc
|
ir/module.cc
|
||||||
ir/module.h
|
ir/module.h
|
||||||
|
ir/runtime.cc
|
||||||
|
ir/runtime.h
|
||||||
ir/switch.cc
|
ir/switch.cc
|
||||||
ir/switch.h
|
ir/switch.h
|
||||||
ir/temp.cc
|
|
||||||
ir/temp.h
|
|
||||||
ir/terminator.cc
|
ir/terminator.cc
|
||||||
ir/terminator.h
|
ir/terminator.h
|
||||||
ir/user_call.cc
|
ir/user_call.cc
|
||||||
@ -1413,7 +1413,7 @@ if(TINT_BUILD_TESTS)
|
|||||||
ir/bitcast_test.cc
|
ir/bitcast_test.cc
|
||||||
ir/builder_impl_test.cc
|
ir/builder_impl_test.cc
|
||||||
ir/constant_test.cc
|
ir/constant_test.cc
|
||||||
ir/temp_test.cc
|
ir/runtime_test.cc
|
||||||
ir/test_helper.h
|
ir/test_helper.h
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
@ -26,15 +26,15 @@ using IR_InstructionTest = TestHelper;
|
|||||||
TEST_F(IR_InstructionTest, CreateAnd) {
|
TEST_F(IR_InstructionTest, CreateAnd) {
|
||||||
auto& b = CreateEmptyBuilder();
|
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),
|
const auto* instr = b.builder.And(b.builder.ir.types.Get<type::I32>(), b.builder.Constant(4_i),
|
||||||
b.builder.Constant(2_i));
|
b.builder.Constant(2_i));
|
||||||
|
|
||||||
EXPECT_EQ(instr->GetKind(), Binary::Kind::kAnd);
|
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);
|
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>());
|
ASSERT_TRUE(instr->LHS()->Is<Constant>());
|
||||||
auto lhs = instr->LHS()->As<Constant>()->value;
|
auto lhs = instr->LHS()->As<Constant>()->value;
|
||||||
@ -54,14 +54,14 @@ TEST_F(IR_InstructionTest, CreateAnd) {
|
|||||||
TEST_F(IR_InstructionTest, CreateOr) {
|
TEST_F(IR_InstructionTest, CreateOr) {
|
||||||
auto& b = CreateEmptyBuilder();
|
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),
|
const auto* instr = b.builder.Or(b.builder.ir.types.Get<type::I32>(), b.builder.Constant(4_i),
|
||||||
b.builder.Constant(2_i));
|
b.builder.Constant(2_i));
|
||||||
|
|
||||||
EXPECT_EQ(instr->GetKind(), Binary::Kind::kOr);
|
EXPECT_EQ(instr->GetKind(), Binary::Kind::kOr);
|
||||||
|
|
||||||
ASSERT_TRUE(instr->Result()->Is<Temp>());
|
ASSERT_TRUE(instr->Result()->Is<Runtime>());
|
||||||
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>());
|
ASSERT_TRUE(instr->LHS()->Is<Constant>());
|
||||||
auto lhs = instr->LHS()->As<Constant>()->value;
|
auto lhs = instr->LHS()->As<Constant>()->value;
|
||||||
@ -81,14 +81,14 @@ TEST_F(IR_InstructionTest, CreateOr) {
|
|||||||
TEST_F(IR_InstructionTest, CreateXor) {
|
TEST_F(IR_InstructionTest, CreateXor) {
|
||||||
auto& b = CreateEmptyBuilder();
|
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),
|
const auto* instr = b.builder.Xor(b.builder.ir.types.Get<type::I32>(), b.builder.Constant(4_i),
|
||||||
b.builder.Constant(2_i));
|
b.builder.Constant(2_i));
|
||||||
|
|
||||||
EXPECT_EQ(instr->GetKind(), Binary::Kind::kXor);
|
EXPECT_EQ(instr->GetKind(), Binary::Kind::kXor);
|
||||||
|
|
||||||
ASSERT_TRUE(instr->Result()->Is<Temp>());
|
ASSERT_TRUE(instr->Result()->Is<Runtime>());
|
||||||
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>());
|
ASSERT_TRUE(instr->LHS()->Is<Constant>());
|
||||||
auto lhs = instr->LHS()->As<Constant>()->value;
|
auto lhs = instr->LHS()->As<Constant>()->value;
|
||||||
@ -108,14 +108,14 @@ TEST_F(IR_InstructionTest, CreateXor) {
|
|||||||
TEST_F(IR_InstructionTest, CreateLogicalAnd) {
|
TEST_F(IR_InstructionTest, CreateLogicalAnd) {
|
||||||
auto& b = CreateEmptyBuilder();
|
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>(),
|
const auto* instr = b.builder.LogicalAnd(b.builder.ir.types.Get<type::Bool>(),
|
||||||
b.builder.Constant(4_i), b.builder.Constant(2_i));
|
b.builder.Constant(4_i), b.builder.Constant(2_i));
|
||||||
|
|
||||||
EXPECT_EQ(instr->GetKind(), Binary::Kind::kLogicalAnd);
|
EXPECT_EQ(instr->GetKind(), Binary::Kind::kLogicalAnd);
|
||||||
|
|
||||||
ASSERT_TRUE(instr->Result()->Is<Temp>());
|
ASSERT_TRUE(instr->Result()->Is<Runtime>());
|
||||||
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>());
|
ASSERT_TRUE(instr->LHS()->Is<Constant>());
|
||||||
auto lhs = instr->LHS()->As<Constant>()->value;
|
auto lhs = instr->LHS()->As<Constant>()->value;
|
||||||
@ -135,14 +135,14 @@ TEST_F(IR_InstructionTest, CreateLogicalAnd) {
|
|||||||
TEST_F(IR_InstructionTest, CreateLogicalOr) {
|
TEST_F(IR_InstructionTest, CreateLogicalOr) {
|
||||||
auto& b = CreateEmptyBuilder();
|
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>(),
|
const auto* instr = b.builder.LogicalOr(b.builder.ir.types.Get<type::Bool>(),
|
||||||
b.builder.Constant(4_i), b.builder.Constant(2_i));
|
b.builder.Constant(4_i), b.builder.Constant(2_i));
|
||||||
|
|
||||||
EXPECT_EQ(instr->GetKind(), Binary::Kind::kLogicalOr);
|
EXPECT_EQ(instr->GetKind(), Binary::Kind::kLogicalOr);
|
||||||
|
|
||||||
ASSERT_TRUE(instr->Result()->Is<Temp>());
|
ASSERT_TRUE(instr->Result()->Is<Runtime>());
|
||||||
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>());
|
ASSERT_TRUE(instr->LHS()->Is<Constant>());
|
||||||
auto lhs = instr->LHS()->As<Constant>()->value;
|
auto lhs = instr->LHS()->As<Constant>()->value;
|
||||||
@ -162,14 +162,14 @@ TEST_F(IR_InstructionTest, CreateLogicalOr) {
|
|||||||
TEST_F(IR_InstructionTest, CreateEqual) {
|
TEST_F(IR_InstructionTest, CreateEqual) {
|
||||||
auto& b = CreateEmptyBuilder();
|
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>(),
|
const auto* instr = b.builder.Equal(b.builder.ir.types.Get<type::Bool>(),
|
||||||
b.builder.Constant(4_i), b.builder.Constant(2_i));
|
b.builder.Constant(4_i), b.builder.Constant(2_i));
|
||||||
|
|
||||||
EXPECT_EQ(instr->GetKind(), Binary::Kind::kEqual);
|
EXPECT_EQ(instr->GetKind(), Binary::Kind::kEqual);
|
||||||
|
|
||||||
ASSERT_TRUE(instr->Result()->Is<Temp>());
|
ASSERT_TRUE(instr->Result()->Is<Runtime>());
|
||||||
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>());
|
ASSERT_TRUE(instr->LHS()->Is<Constant>());
|
||||||
auto lhs = instr->LHS()->As<Constant>()->value;
|
auto lhs = instr->LHS()->As<Constant>()->value;
|
||||||
@ -189,14 +189,14 @@ TEST_F(IR_InstructionTest, CreateEqual) {
|
|||||||
TEST_F(IR_InstructionTest, CreateNotEqual) {
|
TEST_F(IR_InstructionTest, CreateNotEqual) {
|
||||||
auto& b = CreateEmptyBuilder();
|
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>(),
|
const auto* instr = b.builder.NotEqual(b.builder.ir.types.Get<type::Bool>(),
|
||||||
b.builder.Constant(4_i), b.builder.Constant(2_i));
|
b.builder.Constant(4_i), b.builder.Constant(2_i));
|
||||||
|
|
||||||
EXPECT_EQ(instr->GetKind(), Binary::Kind::kNotEqual);
|
EXPECT_EQ(instr->GetKind(), Binary::Kind::kNotEqual);
|
||||||
|
|
||||||
ASSERT_TRUE(instr->Result()->Is<Temp>());
|
ASSERT_TRUE(instr->Result()->Is<Runtime>());
|
||||||
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>());
|
ASSERT_TRUE(instr->LHS()->Is<Constant>());
|
||||||
auto lhs = instr->LHS()->As<Constant>()->value;
|
auto lhs = instr->LHS()->As<Constant>()->value;
|
||||||
@ -216,14 +216,14 @@ TEST_F(IR_InstructionTest, CreateNotEqual) {
|
|||||||
TEST_F(IR_InstructionTest, CreateLessThan) {
|
TEST_F(IR_InstructionTest, CreateLessThan) {
|
||||||
auto& b = CreateEmptyBuilder();
|
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>(),
|
const auto* instr = b.builder.LessThan(b.builder.ir.types.Get<type::Bool>(),
|
||||||
b.builder.Constant(4_i), b.builder.Constant(2_i));
|
b.builder.Constant(4_i), b.builder.Constant(2_i));
|
||||||
|
|
||||||
EXPECT_EQ(instr->GetKind(), Binary::Kind::kLessThan);
|
EXPECT_EQ(instr->GetKind(), Binary::Kind::kLessThan);
|
||||||
|
|
||||||
ASSERT_TRUE(instr->Result()->Is<Temp>());
|
ASSERT_TRUE(instr->Result()->Is<Runtime>());
|
||||||
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>());
|
ASSERT_TRUE(instr->LHS()->Is<Constant>());
|
||||||
auto lhs = instr->LHS()->As<Constant>()->value;
|
auto lhs = instr->LHS()->As<Constant>()->value;
|
||||||
@ -243,14 +243,14 @@ TEST_F(IR_InstructionTest, CreateLessThan) {
|
|||||||
TEST_F(IR_InstructionTest, CreateGreaterThan) {
|
TEST_F(IR_InstructionTest, CreateGreaterThan) {
|
||||||
auto& b = CreateEmptyBuilder();
|
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>(),
|
const auto* instr = b.builder.GreaterThan(b.builder.ir.types.Get<type::Bool>(),
|
||||||
b.builder.Constant(4_i), b.builder.Constant(2_i));
|
b.builder.Constant(4_i), b.builder.Constant(2_i));
|
||||||
|
|
||||||
EXPECT_EQ(instr->GetKind(), Binary::Kind::kGreaterThan);
|
EXPECT_EQ(instr->GetKind(), Binary::Kind::kGreaterThan);
|
||||||
|
|
||||||
ASSERT_TRUE(instr->Result()->Is<Temp>());
|
ASSERT_TRUE(instr->Result()->Is<Runtime>());
|
||||||
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>());
|
ASSERT_TRUE(instr->LHS()->Is<Constant>());
|
||||||
auto lhs = instr->LHS()->As<Constant>()->value;
|
auto lhs = instr->LHS()->As<Constant>()->value;
|
||||||
@ -270,14 +270,14 @@ TEST_F(IR_InstructionTest, CreateGreaterThan) {
|
|||||||
TEST_F(IR_InstructionTest, CreateLessThanEqual) {
|
TEST_F(IR_InstructionTest, CreateLessThanEqual) {
|
||||||
auto& b = CreateEmptyBuilder();
|
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>(),
|
const auto* instr = b.builder.LessThanEqual(b.builder.ir.types.Get<type::Bool>(),
|
||||||
b.builder.Constant(4_i), b.builder.Constant(2_i));
|
b.builder.Constant(4_i), b.builder.Constant(2_i));
|
||||||
|
|
||||||
EXPECT_EQ(instr->GetKind(), Binary::Kind::kLessThanEqual);
|
EXPECT_EQ(instr->GetKind(), Binary::Kind::kLessThanEqual);
|
||||||
|
|
||||||
ASSERT_TRUE(instr->Result()->Is<Temp>());
|
ASSERT_TRUE(instr->Result()->Is<Runtime>());
|
||||||
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>());
|
ASSERT_TRUE(instr->LHS()->Is<Constant>());
|
||||||
auto lhs = instr->LHS()->As<Constant>()->value;
|
auto lhs = instr->LHS()->As<Constant>()->value;
|
||||||
@ -297,14 +297,14 @@ TEST_F(IR_InstructionTest, CreateLessThanEqual) {
|
|||||||
TEST_F(IR_InstructionTest, CreateGreaterThanEqual) {
|
TEST_F(IR_InstructionTest, CreateGreaterThanEqual) {
|
||||||
auto& b = CreateEmptyBuilder();
|
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(
|
const auto* instr = b.builder.GreaterThanEqual(
|
||||||
b.builder.ir.types.Get<type::Bool>(), b.builder.Constant(4_i), b.builder.Constant(2_i));
|
b.builder.ir.types.Get<type::Bool>(), b.builder.Constant(4_i), b.builder.Constant(2_i));
|
||||||
|
|
||||||
EXPECT_EQ(instr->GetKind(), Binary::Kind::kGreaterThanEqual);
|
EXPECT_EQ(instr->GetKind(), Binary::Kind::kGreaterThanEqual);
|
||||||
|
|
||||||
ASSERT_TRUE(instr->Result()->Is<Temp>());
|
ASSERT_TRUE(instr->Result()->Is<Runtime>());
|
||||||
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>());
|
ASSERT_TRUE(instr->LHS()->Is<Constant>());
|
||||||
auto lhs = instr->LHS()->As<Constant>()->value;
|
auto lhs = instr->LHS()->As<Constant>()->value;
|
||||||
@ -324,14 +324,14 @@ TEST_F(IR_InstructionTest, CreateGreaterThanEqual) {
|
|||||||
TEST_F(IR_InstructionTest, CreateShiftLeft) {
|
TEST_F(IR_InstructionTest, CreateShiftLeft) {
|
||||||
auto& b = CreateEmptyBuilder();
|
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>(),
|
const auto* instr = b.builder.ShiftLeft(b.builder.ir.types.Get<type::I32>(),
|
||||||
b.builder.Constant(4_i), b.builder.Constant(2_i));
|
b.builder.Constant(4_i), b.builder.Constant(2_i));
|
||||||
|
|
||||||
EXPECT_EQ(instr->GetKind(), Binary::Kind::kShiftLeft);
|
EXPECT_EQ(instr->GetKind(), Binary::Kind::kShiftLeft);
|
||||||
|
|
||||||
ASSERT_TRUE(instr->Result()->Is<Temp>());
|
ASSERT_TRUE(instr->Result()->Is<Runtime>());
|
||||||
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>());
|
ASSERT_TRUE(instr->LHS()->Is<Constant>());
|
||||||
auto lhs = instr->LHS()->As<Constant>()->value;
|
auto lhs = instr->LHS()->As<Constant>()->value;
|
||||||
@ -351,14 +351,14 @@ TEST_F(IR_InstructionTest, CreateShiftLeft) {
|
|||||||
TEST_F(IR_InstructionTest, CreateShiftRight) {
|
TEST_F(IR_InstructionTest, CreateShiftRight) {
|
||||||
auto& b = CreateEmptyBuilder();
|
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>(),
|
const auto* instr = b.builder.ShiftRight(b.builder.ir.types.Get<type::I32>(),
|
||||||
b.builder.Constant(4_i), b.builder.Constant(2_i));
|
b.builder.Constant(4_i), b.builder.Constant(2_i));
|
||||||
|
|
||||||
EXPECT_EQ(instr->GetKind(), Binary::Kind::kShiftRight);
|
EXPECT_EQ(instr->GetKind(), Binary::Kind::kShiftRight);
|
||||||
|
|
||||||
ASSERT_TRUE(instr->Result()->Is<Temp>());
|
ASSERT_TRUE(instr->Result()->Is<Runtime>());
|
||||||
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>());
|
ASSERT_TRUE(instr->LHS()->Is<Constant>());
|
||||||
auto lhs = instr->LHS()->As<Constant>()->value;
|
auto lhs = instr->LHS()->As<Constant>()->value;
|
||||||
@ -378,14 +378,14 @@ TEST_F(IR_InstructionTest, CreateShiftRight) {
|
|||||||
TEST_F(IR_InstructionTest, CreateAdd) {
|
TEST_F(IR_InstructionTest, CreateAdd) {
|
||||||
auto& b = CreateEmptyBuilder();
|
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),
|
const auto* instr = b.builder.Add(b.builder.ir.types.Get<type::I32>(), b.builder.Constant(4_i),
|
||||||
b.builder.Constant(2_i));
|
b.builder.Constant(2_i));
|
||||||
|
|
||||||
EXPECT_EQ(instr->GetKind(), Binary::Kind::kAdd);
|
EXPECT_EQ(instr->GetKind(), Binary::Kind::kAdd);
|
||||||
|
|
||||||
ASSERT_TRUE(instr->Result()->Is<Temp>());
|
ASSERT_TRUE(instr->Result()->Is<Runtime>());
|
||||||
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>());
|
ASSERT_TRUE(instr->LHS()->Is<Constant>());
|
||||||
auto lhs = instr->LHS()->As<Constant>()->value;
|
auto lhs = instr->LHS()->As<Constant>()->value;
|
||||||
@ -405,14 +405,14 @@ TEST_F(IR_InstructionTest, CreateAdd) {
|
|||||||
TEST_F(IR_InstructionTest, CreateSubtract) {
|
TEST_F(IR_InstructionTest, CreateSubtract) {
|
||||||
auto& b = CreateEmptyBuilder();
|
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>(),
|
const auto* instr = b.builder.Subtract(b.builder.ir.types.Get<type::I32>(),
|
||||||
b.builder.Constant(4_i), b.builder.Constant(2_i));
|
b.builder.Constant(4_i), b.builder.Constant(2_i));
|
||||||
|
|
||||||
EXPECT_EQ(instr->GetKind(), Binary::Kind::kSubtract);
|
EXPECT_EQ(instr->GetKind(), Binary::Kind::kSubtract);
|
||||||
|
|
||||||
ASSERT_TRUE(instr->Result()->Is<Temp>());
|
ASSERT_TRUE(instr->Result()->Is<Runtime>());
|
||||||
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>());
|
ASSERT_TRUE(instr->LHS()->Is<Constant>());
|
||||||
auto lhs = instr->LHS()->As<Constant>()->value;
|
auto lhs = instr->LHS()->As<Constant>()->value;
|
||||||
@ -432,14 +432,14 @@ TEST_F(IR_InstructionTest, CreateSubtract) {
|
|||||||
TEST_F(IR_InstructionTest, CreateMultiply) {
|
TEST_F(IR_InstructionTest, CreateMultiply) {
|
||||||
auto& b = CreateEmptyBuilder();
|
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>(),
|
const auto* instr = b.builder.Multiply(b.builder.ir.types.Get<type::I32>(),
|
||||||
b.builder.Constant(4_i), b.builder.Constant(2_i));
|
b.builder.Constant(4_i), b.builder.Constant(2_i));
|
||||||
|
|
||||||
EXPECT_EQ(instr->GetKind(), Binary::Kind::kMultiply);
|
EXPECT_EQ(instr->GetKind(), Binary::Kind::kMultiply);
|
||||||
|
|
||||||
ASSERT_TRUE(instr->Result()->Is<Temp>());
|
ASSERT_TRUE(instr->Result()->Is<Runtime>());
|
||||||
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>());
|
ASSERT_TRUE(instr->LHS()->Is<Constant>());
|
||||||
auto lhs = instr->LHS()->As<Constant>()->value;
|
auto lhs = instr->LHS()->As<Constant>()->value;
|
||||||
@ -459,14 +459,14 @@ TEST_F(IR_InstructionTest, CreateMultiply) {
|
|||||||
TEST_F(IR_InstructionTest, CreateDivide) {
|
TEST_F(IR_InstructionTest, CreateDivide) {
|
||||||
auto& b = CreateEmptyBuilder();
|
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>(),
|
const auto* instr = b.builder.Divide(b.builder.ir.types.Get<type::I32>(),
|
||||||
b.builder.Constant(4_i), b.builder.Constant(2_i));
|
b.builder.Constant(4_i), b.builder.Constant(2_i));
|
||||||
|
|
||||||
EXPECT_EQ(instr->GetKind(), Binary::Kind::kDivide);
|
EXPECT_EQ(instr->GetKind(), Binary::Kind::kDivide);
|
||||||
|
|
||||||
ASSERT_TRUE(instr->Result()->Is<Temp>());
|
ASSERT_TRUE(instr->Result()->Is<Runtime>());
|
||||||
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>());
|
ASSERT_TRUE(instr->LHS()->Is<Constant>());
|
||||||
auto lhs = instr->LHS()->As<Constant>()->value;
|
auto lhs = instr->LHS()->As<Constant>()->value;
|
||||||
@ -486,14 +486,14 @@ TEST_F(IR_InstructionTest, CreateDivide) {
|
|||||||
TEST_F(IR_InstructionTest, CreateModulo) {
|
TEST_F(IR_InstructionTest, CreateModulo) {
|
||||||
auto& b = CreateEmptyBuilder();
|
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>(),
|
const auto* instr = b.builder.Modulo(b.builder.ir.types.Get<type::I32>(),
|
||||||
b.builder.Constant(4_i), b.builder.Constant(2_i));
|
b.builder.Constant(4_i), b.builder.Constant(2_i));
|
||||||
|
|
||||||
EXPECT_EQ(instr->GetKind(), Binary::Kind::kModulo);
|
EXPECT_EQ(instr->GetKind(), Binary::Kind::kModulo);
|
||||||
|
|
||||||
ASSERT_TRUE(instr->Result()->Is<Temp>());
|
ASSERT_TRUE(instr->Result()->Is<Runtime>());
|
||||||
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>());
|
ASSERT_TRUE(instr->LHS()->Is<Constant>());
|
||||||
auto lhs = instr->LHS()->As<Constant>()->value;
|
auto lhs = instr->LHS()->As<Constant>()->value;
|
||||||
@ -513,7 +513,7 @@ TEST_F(IR_InstructionTest, CreateModulo) {
|
|||||||
TEST_F(IR_InstructionTest, Binary_Usage) {
|
TEST_F(IR_InstructionTest, Binary_Usage) {
|
||||||
auto& b = CreateEmptyBuilder();
|
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),
|
const auto* instr = b.builder.And(b.builder.ir.types.Get<type::I32>(), b.builder.Constant(4_i),
|
||||||
b.builder.Constant(2_i));
|
b.builder.Constant(2_i));
|
||||||
|
|
||||||
@ -537,7 +537,7 @@ TEST_F(IR_InstructionTest, Binary_Usage_DuplicateValue) {
|
|||||||
|
|
||||||
auto val = b.builder.Constant(4_i);
|
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);
|
const auto* instr = b.builder.And(b.builder.ir.types.Get<type::I32>(), val, val);
|
||||||
|
|
||||||
EXPECT_EQ(instr->GetKind(), Binary::Kind::kAnd);
|
EXPECT_EQ(instr->GetKind(), Binary::Kind::kAnd);
|
||||||
|
@ -26,12 +26,12 @@ using IR_InstructionTest = TestHelper;
|
|||||||
TEST_F(IR_InstructionTest, Bitcast) {
|
TEST_F(IR_InstructionTest, Bitcast) {
|
||||||
auto& b = CreateEmptyBuilder();
|
auto& b = CreateEmptyBuilder();
|
||||||
|
|
||||||
b.builder.next_temp_id = Temp::Id(42);
|
b.builder.next_runtime_id = Runtime::Id(42);
|
||||||
const auto* instr =
|
const auto* instr =
|
||||||
b.builder.Bitcast(b.builder.ir.types.Get<type::I32>(), b.builder.Constant(4_i));
|
b.builder.Bitcast(b.builder.ir.types.Get<type::I32>(), b.builder.Constant(4_i));
|
||||||
|
|
||||||
ASSERT_TRUE(instr->Result()->Is<Temp>());
|
ASSERT_TRUE(instr->Result()->Is<Runtime>());
|
||||||
EXPECT_EQ(Temp::Id(42), instr->Result()->As<Temp>()->AsId());
|
EXPECT_EQ(Runtime::Id(42), instr->Result()->As<Runtime>()->AsId());
|
||||||
ASSERT_NE(instr->Result()->Type(), nullptr);
|
ASSERT_NE(instr->Result()->Type(), nullptr);
|
||||||
|
|
||||||
ASSERT_TRUE(instr->Val()->Is<Constant>());
|
ASSERT_TRUE(instr->Val()->Is<Constant>());
|
||||||
@ -47,7 +47,7 @@ TEST_F(IR_InstructionTest, Bitcast) {
|
|||||||
TEST_F(IR_InstructionTest, Bitcast_Usage) {
|
TEST_F(IR_InstructionTest, Bitcast_Usage) {
|
||||||
auto& b = CreateEmptyBuilder();
|
auto& b = CreateEmptyBuilder();
|
||||||
|
|
||||||
b.builder.next_temp_id = Temp::Id(42);
|
b.builder.next_runtime_id = Runtime::Id(42);
|
||||||
const auto* instr =
|
const auto* instr =
|
||||||
b.builder.Bitcast(b.builder.ir.types.Get<type::I32>(), b.builder.Constant(4_i));
|
b.builder.Bitcast(b.builder.ir.types.Get<type::I32>(), b.builder.Constant(4_i));
|
||||||
|
|
||||||
|
@ -93,12 +93,12 @@ void Builder::Branch(Block* from, FlowNode* to, utils::VectorRef<Value*> args) {
|
|||||||
to->inbound_branches.Push(from);
|
to->inbound_branches.Push(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
Temp::Id Builder::AllocateTempId() {
|
Runtime::Id Builder::AllocateRuntimeId() {
|
||||||
return next_temp_id++;
|
return next_runtime_id++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Binary* Builder::CreateBinary(Binary::Kind kind, const type::Type* type, Value* lhs, Value* rhs) {
|
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) {
|
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) {
|
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,
|
ir::UserCall* Builder::UserCall(const type::Type* type,
|
||||||
Symbol name,
|
Symbol name,
|
||||||
utils::VectorRef<Value*> args) {
|
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,
|
ir::Convert* Builder::Convert(const type::Type* to,
|
||||||
const type::Type* from,
|
const type::Type* from,
|
||||||
utils::VectorRef<Value*> args) {
|
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) {
|
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,
|
ir::Builtin* Builder::Builtin(const type::Type* type,
|
||||||
builtin::Function func,
|
builtin::Function func,
|
||||||
utils::VectorRef<Value*> args) {
|
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
|
} // namespace tint::ir
|
||||||
|
@ -28,8 +28,8 @@
|
|||||||
#include "src/tint/ir/if.h"
|
#include "src/tint/ir/if.h"
|
||||||
#include "src/tint/ir/loop.h"
|
#include "src/tint/ir/loop.h"
|
||||||
#include "src/tint/ir/module.h"
|
#include "src/tint/ir/module.h"
|
||||||
|
#include "src/tint/ir/runtime.h"
|
||||||
#include "src/tint/ir/switch.h"
|
#include "src/tint/ir/switch.h"
|
||||||
#include "src/tint/ir/temp.h"
|
|
||||||
#include "src/tint/ir/terminator.h"
|
#include "src/tint/ir/terminator.h"
|
||||||
#include "src/tint/ir/user_call.h"
|
#include "src/tint/ir/user_call.h"
|
||||||
#include "src/tint/ir/value.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));
|
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
|
/// @param type the type of the temporary
|
||||||
/// @returns the new temporary
|
/// @returns the new temporary
|
||||||
ir::Temp* Temp(const type::Type* type) {
|
ir::Runtime* Runtime(const type::Type* type) {
|
||||||
return ir.values.Create<ir::Temp>(type, AllocateTempId());
|
return ir.values.Create<ir::Runtime>(type, AllocateRuntimeId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates an op for `lhs kind rhs`
|
/// Creates an op for `lhs kind rhs`
|
||||||
@ -315,14 +315,14 @@ class Builder {
|
|||||||
builtin::Function func,
|
builtin::Function func,
|
||||||
utils::VectorRef<Value*> args);
|
utils::VectorRef<Value*> args);
|
||||||
|
|
||||||
/// @returns a unique temp id
|
/// @returns a unique runtime id
|
||||||
Temp::Id AllocateTempId();
|
Runtime::Id AllocateRuntimeId();
|
||||||
|
|
||||||
/// The IR module.
|
/// The IR module.
|
||||||
Module ir;
|
Module ir;
|
||||||
|
|
||||||
/// The next temporary number to allocate
|
/// The next temporary number to allocate
|
||||||
Temp::Id next_temp_id = 1;
|
Runtime::Id next_runtime_id = 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace tint::ir
|
} // namespace tint::ir
|
||||||
|
@ -624,7 +624,7 @@ utils::Result<Value*> BuilderImpl::EmitExpression(const ast::Expression* expr) {
|
|||||||
// TODO(dsinclair): This should return utils::Failure; Switch back
|
// TODO(dsinclair): This should return utils::Failure; Switch back
|
||||||
// once all the above cases are handled.
|
// once all the above cases are handled.
|
||||||
auto* v = builder.ir.types.Get<type::Void>();
|
auto* v = builder.ir.types.Get<type::Void>();
|
||||||
return builder.Temp(v);
|
return builder.Runtime(v);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,19 +12,19 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/tint/ir/temp.h"
|
#include "src/tint/ir/runtime.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
TINT_INSTANTIATE_TYPEINFO(tint::ir::Temp);
|
TINT_INSTANTIATE_TYPEINFO(tint::ir::Runtime);
|
||||||
|
|
||||||
namespace tint::ir {
|
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() << ")";
|
out << "%" << std::to_string(AsId()) << " (" << type_->FriendlyName() << ")";
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
@ -12,8 +12,8 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#ifndef SRC_TINT_IR_TEMP_H_
|
#ifndef SRC_TINT_IR_RUNTIME_H_
|
||||||
#define SRC_TINT_IR_TEMP_H_
|
#define SRC_TINT_IR_RUNTIME_H_
|
||||||
|
|
||||||
#include "src/tint/ir/value.h"
|
#include "src/tint/ir/value.h"
|
||||||
#include "src/tint/symbol_table.h"
|
#include "src/tint/symbol_table.h"
|
||||||
@ -21,33 +21,33 @@
|
|||||||
|
|
||||||
namespace tint::ir {
|
namespace tint::ir {
|
||||||
|
|
||||||
/// Temporary value in the IR.
|
/// Runtime value in the IR.
|
||||||
class Temp : public utils::Castable<Temp, Value> {
|
class Runtime : public utils::Castable<Runtime, Value> {
|
||||||
public:
|
public:
|
||||||
/// A value id.
|
/// A value id.
|
||||||
using Id = uint32_t;
|
using Id = uint32_t;
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param type the type of the temporary
|
/// @param type the type of the value
|
||||||
/// @param id the id for the value
|
/// @param id the id for the value
|
||||||
Temp(const type::Type* type, Id id);
|
Runtime(const type::Type* type, Id id);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
~Temp() override;
|
~Runtime() override;
|
||||||
|
|
||||||
Temp(const Temp&) = delete;
|
Runtime(const Runtime&) = delete;
|
||||||
Temp(Temp&&) = delete;
|
Runtime(Runtime&&) = delete;
|
||||||
|
|
||||||
Temp& operator=(const Temp&) = delete;
|
Runtime& operator=(const Runtime&) = delete;
|
||||||
Temp& operator=(Temp&&) = delete;
|
Runtime& operator=(Runtime&&) = delete;
|
||||||
|
|
||||||
/// @returns the value data as an `Id`.
|
/// @returns the value data as an `Id`.
|
||||||
Id AsId() const { return 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_; }
|
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
|
/// @param out the stream to write to
|
||||||
/// @returns the stream
|
/// @returns the stream
|
||||||
utils::StringStream& ToString(utils::StringStream& out) const override;
|
utils::StringStream& ToString(utils::StringStream& out) const override;
|
||||||
@ -59,4 +59,4 @@ class Temp : public utils::Castable<Temp, Value> {
|
|||||||
|
|
||||||
} // namespace tint::ir
|
} // namespace tint::ir
|
||||||
|
|
||||||
#endif // SRC_TINT_IR_TEMP_H_
|
#endif // SRC_TINT_IR_RUNTIME_H_
|
@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// 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/ir/test_helper.h"
|
||||||
#include "src/tint/utils/string_stream.h"
|
#include "src/tint/utils/string_stream.h"
|
||||||
|
|
||||||
@ -21,15 +21,15 @@ namespace {
|
|||||||
|
|
||||||
using namespace tint::number_suffixes; // NOLINT
|
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();
|
auto& b = CreateEmptyBuilder();
|
||||||
|
|
||||||
utils::StringStream str;
|
utils::StringStream str;
|
||||||
|
|
||||||
b.builder.next_temp_id = Temp::Id(4);
|
b.builder.next_runtime_id = Runtime::Id(4);
|
||||||
auto* val = b.builder.Temp(b.builder.ir.types.Get<type::I32>());
|
auto* val = b.builder.Runtime(b.builder.ir.types.Get<type::I32>());
|
||||||
EXPECT_EQ(4u, val->AsId());
|
EXPECT_EQ(4u, val->AsId());
|
||||||
|
|
||||||
val->ToString(str);
|
val->ToString(str);
|
@ -15,7 +15,7 @@
|
|||||||
#include "src/tint/ir/value.h"
|
#include "src/tint/ir/value.h"
|
||||||
|
|
||||||
#include "src/tint/ir/constant.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);
|
TINT_INSTANTIATE_TYPEINFO(tint::ir::Value);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user