[ir] Update disassembly output.
This CL switches the disassembler back to being recursive and fixes up the indenting of blocks to better highlight if branches and switch cases. Bug: tint:1718 Change-Id: I14e8d7c68a083bf3afd9ff7241d49b2aa76be4ba Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/134300 Commit-Queue: Dan Sinclair <dsinclair@chromium.org> Reviewed-by: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
b3e680bb88
commit
a518707db4
|
@ -89,73 +89,28 @@ std::string_view Disassembler::IdOf(const Value* value) {
|
|||
|
||||
std::string Disassembler::Disassemble() {
|
||||
if (mod_.root_block) {
|
||||
walk_list_.push_back(mod_.root_block);
|
||||
Walk();
|
||||
TINT_ASSERT(IR, walk_list_.empty());
|
||||
Indent() << "# Root block" << std::endl;
|
||||
Walk(mod_.root_block);
|
||||
Walk(mod_.root_block->Branch()->To());
|
||||
}
|
||||
|
||||
for (auto* func : mod_.functions) {
|
||||
walk_list_.push_back(func);
|
||||
Walk();
|
||||
TINT_ASSERT(IR, walk_list_.empty());
|
||||
EmitFunction(func);
|
||||
}
|
||||
return out_.str();
|
||||
}
|
||||
|
||||
void Disassembler::Walk() {
|
||||
utils::Hashset<const FlowNode*, 32> visited_;
|
||||
|
||||
while (!walk_list_.empty()) {
|
||||
const FlowNode* node = walk_list_.front();
|
||||
walk_list_.pop_front();
|
||||
|
||||
if (visited_.Contains(node)) {
|
||||
continue;
|
||||
void Disassembler::Walk(const Block* blk) {
|
||||
if (visited_.Contains(blk)) {
|
||||
return;
|
||||
}
|
||||
visited_.Add(node);
|
||||
visited_.Add(blk);
|
||||
|
||||
tint::Switch(
|
||||
node,
|
||||
[&](const ir::Function* f) {
|
||||
in_function_ = true;
|
||||
|
||||
Indent() << "%fn" << IdOf(f) << " = func " << f->Name().Name() << "(";
|
||||
for (auto* p : f->Params()) {
|
||||
if (p != f->Params().Front()) {
|
||||
out_ << ", ";
|
||||
}
|
||||
out_ << "%" << IdOf(p) << ":" << p->Type()->FriendlyName();
|
||||
}
|
||||
out_ << "):" << f->ReturnType()->FriendlyName();
|
||||
|
||||
if (f->Stage() != Function::PipelineStage::kUndefined) {
|
||||
out_ << " [@" << f->Stage();
|
||||
|
||||
if (f->WorkgroupSize()) {
|
||||
auto arr = f->WorkgroupSize().value();
|
||||
out_ << " @workgroup_size(" << arr[0] << ", " << arr[1] << ", " << arr[2]
|
||||
<< ")";
|
||||
}
|
||||
|
||||
if (!f->ReturnAttributes().IsEmpty()) {
|
||||
out_ << " ra:";
|
||||
|
||||
for (auto attr : f->ReturnAttributes()) {
|
||||
out_ << " @" << attr;
|
||||
if (attr == Function::ReturnAttribute::kLocation) {
|
||||
out_ << "(" << f->ReturnLocation().value() << ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
out_ << "]";
|
||||
}
|
||||
out_ << " -> %fn" << IdOf(f->StartTarget()) << std::endl;
|
||||
walk_list_.push_back(f->StartTarget());
|
||||
},
|
||||
blk,
|
||||
[&](const ir::FunctionTerminator* t) {
|
||||
TINT_ASSERT(IR, in_function_);
|
||||
Indent() << "%fn" << IdOf(t) << " = func_terminator" << std::endl << std::endl;
|
||||
Indent() << "%fn" << IdOf(t) << " = func_terminator" << std::endl;
|
||||
in_function_ = false;
|
||||
},
|
||||
[&](const ir::RootTerminator* t) {
|
||||
|
@ -190,10 +145,50 @@ void Disassembler::Walk() {
|
|||
if (!b->Branch()->To()->Is<FunctionTerminator>()) {
|
||||
out_ << std::endl;
|
||||
}
|
||||
|
||||
walk_list_.push_back(b->Branch()->To());
|
||||
});
|
||||
}
|
||||
|
||||
void Disassembler::EmitFunction(const Function* func) {
|
||||
in_function_ = true;
|
||||
|
||||
Indent() << "%fn" << IdOf(func) << " = func " << func->Name().Name() << "(";
|
||||
for (auto* p : func->Params()) {
|
||||
if (p != func->Params().Front()) {
|
||||
out_ << ", ";
|
||||
}
|
||||
out_ << "%" << IdOf(p) << ":" << p->Type()->FriendlyName();
|
||||
}
|
||||
out_ << "):" << func->ReturnType()->FriendlyName();
|
||||
|
||||
if (func->Stage() != Function::PipelineStage::kUndefined) {
|
||||
out_ << " [@" << func->Stage();
|
||||
|
||||
if (func->WorkgroupSize()) {
|
||||
auto arr = func->WorkgroupSize().value();
|
||||
out_ << " @workgroup_size(" << arr[0] << ", " << arr[1] << ", " << arr[2] << ")";
|
||||
}
|
||||
|
||||
if (!func->ReturnAttributes().IsEmpty()) {
|
||||
out_ << " ra:";
|
||||
|
||||
for (auto attr : func->ReturnAttributes()) {
|
||||
out_ << " @" << attr;
|
||||
if (attr == Function::ReturnAttribute::kLocation) {
|
||||
out_ << "(" << func->ReturnLocation().value() << ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
out_ << "]";
|
||||
}
|
||||
out_ << " -> %fn" << IdOf(func->StartTarget()) << " {" << std::endl;
|
||||
|
||||
{
|
||||
ScopedIndent si(indent_size_);
|
||||
Walk(func->StartTarget());
|
||||
Walk(func->EndTarget());
|
||||
}
|
||||
Indent() << "}" << std::endl;
|
||||
}
|
||||
|
||||
void Disassembler::EmitValueWithType(const Value* val) {
|
||||
|
@ -335,16 +330,21 @@ void Disassembler::EmitIf(const If* i) {
|
|||
if (i->Merge()->IsConnected()) {
|
||||
out_ << ", m: %fn" << IdOf(i->Merge());
|
||||
}
|
||||
out_ << "]";
|
||||
out_ << "]" << std::endl;
|
||||
|
||||
if (has_true) {
|
||||
walk_list_.push_back(i->True());
|
||||
ScopedIndent si(indent_size_);
|
||||
Indent() << "# True block" << std::endl;
|
||||
Walk(i->True());
|
||||
}
|
||||
if (has_false) {
|
||||
walk_list_.push_back(i->False());
|
||||
ScopedIndent si(indent_size_);
|
||||
Indent() << "# False block" << std::endl;
|
||||
Walk(i->False());
|
||||
}
|
||||
if (i->Merge()->IsConnected()) {
|
||||
walk_list_.push_back(i->Merge());
|
||||
Indent() << "# Merge block" << std::endl;
|
||||
Walk(i->Merge());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -357,15 +357,21 @@ void Disassembler::EmitLoop(const Loop* l) {
|
|||
if (l->Merge()->IsConnected()) {
|
||||
out_ << ", m: %fn" << IdOf(l->Merge());
|
||||
}
|
||||
out_ << "]";
|
||||
out_ << "]" << std::endl;
|
||||
|
||||
{ walk_list_.push_back(l->Start()); }
|
||||
{
|
||||
ScopedIndent si(indent_size_);
|
||||
Walk(l->Start());
|
||||
}
|
||||
|
||||
if (l->Continuing()->IsConnected()) {
|
||||
walk_list_.push_back(l->Continuing());
|
||||
ScopedIndent si(indent_size_);
|
||||
Indent() << "# Continuing block" << std::endl;
|
||||
Walk(l->Continuing());
|
||||
}
|
||||
if (l->Merge()->IsConnected()) {
|
||||
walk_list_.push_back(l->Merge());
|
||||
Indent() << "# Merge block" << std::endl;
|
||||
Walk(l->Merge());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -394,13 +400,16 @@ void Disassembler::EmitSwitch(const Switch* s) {
|
|||
if (s->Merge()->IsConnected()) {
|
||||
out_ << ", m: %fn" << IdOf(s->Merge());
|
||||
}
|
||||
out_ << "]";
|
||||
out_ << "]" << std::endl;
|
||||
|
||||
for (auto& c : s->Cases()) {
|
||||
walk_list_.push_back(c.Start());
|
||||
ScopedIndent si(indent_size_);
|
||||
Indent() << "# Case block" << std::endl;
|
||||
Walk(c.Start());
|
||||
}
|
||||
if (s->Merge()->IsConnected()) {
|
||||
walk_list_.push_back(s->Merge());
|
||||
Indent() << "# Merge block" << std::endl;
|
||||
Walk(s->Merge());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#ifndef SRC_TINT_IR_DISASSEMBLER_H_
|
||||
#define SRC_TINT_IR_DISASSEMBLER_H_
|
||||
|
||||
#include <deque>
|
||||
#include <string>
|
||||
|
||||
#include "src/tint/ir/binary.h"
|
||||
|
@ -27,6 +26,7 @@
|
|||
#include "src/tint/ir/switch.h"
|
||||
#include "src/tint/ir/unary.h"
|
||||
#include "src/tint/utils/hashmap.h"
|
||||
#include "src/tint/utils/hashset.h"
|
||||
#include "src/tint/utils/string_stream.h"
|
||||
|
||||
namespace tint::ir {
|
||||
|
@ -56,7 +56,8 @@ class Disassembler {
|
|||
size_t IdOf(const FlowNode* node);
|
||||
std::string_view IdOf(const Value* node);
|
||||
|
||||
void Walk();
|
||||
void Walk(const Block* blk);
|
||||
void EmitFunction(const Function* func);
|
||||
void EmitInstruction(const Instruction* inst);
|
||||
void EmitValueWithType(const Value* val);
|
||||
void EmitValue(const Value* val);
|
||||
|
@ -70,7 +71,7 @@ class Disassembler {
|
|||
|
||||
const Module& mod_;
|
||||
utils::StringStream out_;
|
||||
std::deque<const FlowNode*> walk_list_;
|
||||
utils::Hashset<const Block*, 32> visited_;
|
||||
utils::Hashmap<const FlowNode*, size_t, 32> flow_node_ids_;
|
||||
utils::Hashmap<const Value*, std::string, 32> value_ids_;
|
||||
uint32_t indent_size_ = 0;
|
||||
|
|
|
@ -34,20 +34,20 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Add) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 -> %fn2
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 -> %fn2 {
|
||||
%fn2 = block {
|
||||
br %fn3 0u # return
|
||||
}
|
||||
%fn3 = func_terminator
|
||||
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5
|
||||
}
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5 {
|
||||
%fn5 = block {
|
||||
%1:u32 = call my_func
|
||||
%tint_symbol:u32 = add %1, 4u
|
||||
br %fn6 # return
|
||||
}
|
||||
%fn6 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -59,14 +59,15 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Increment) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(# Root block
|
||||
%fn1 = block {
|
||||
%v1:ptr<private, u32, read_write> = var
|
||||
br %fn2 # root_end
|
||||
}
|
||||
|
||||
%fn2 = root_terminator
|
||||
|
||||
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn4
|
||||
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn4 {
|
||||
%fn4 = block {
|
||||
%2:u32 = load %v1
|
||||
%3:u32 = add %2, 1u
|
||||
|
@ -74,7 +75,7 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Increment) {
|
|||
br %fn5 # return
|
||||
}
|
||||
%fn5 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -86,14 +87,15 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundAdd) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(# Root block
|
||||
%fn1 = block {
|
||||
%v1:ptr<private, u32, read_write> = var
|
||||
br %fn2 # root_end
|
||||
}
|
||||
|
||||
%fn2 = root_terminator
|
||||
|
||||
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn4
|
||||
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn4 {
|
||||
%fn4 = block {
|
||||
%2:u32 = load %v1
|
||||
%3:u32 = add %2, 1u
|
||||
|
@ -101,7 +103,7 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundAdd) {
|
|||
br %fn5 # return
|
||||
}
|
||||
%fn5 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -113,20 +115,20 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Subtract) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 -> %fn2
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 -> %fn2 {
|
||||
%fn2 = block {
|
||||
br %fn3 0u # return
|
||||
}
|
||||
%fn3 = func_terminator
|
||||
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5
|
||||
}
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5 {
|
||||
%fn5 = block {
|
||||
%1:u32 = call my_func
|
||||
%tint_symbol:u32 = sub %1, 4u
|
||||
br %fn6 # return
|
||||
}
|
||||
%fn6 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -138,14 +140,15 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Decrement) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(# Root block
|
||||
%fn1 = block {
|
||||
%v1:ptr<private, i32, read_write> = var
|
||||
br %fn2 # root_end
|
||||
}
|
||||
|
||||
%fn2 = root_terminator
|
||||
|
||||
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn4
|
||||
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn4 {
|
||||
%fn4 = block {
|
||||
%2:i32 = load %v1
|
||||
%3:i32 = sub %2, 1i
|
||||
|
@ -153,7 +156,7 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Decrement) {
|
|||
br %fn5 # return
|
||||
}
|
||||
%fn5 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -165,14 +168,15 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundSubtract) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(# Root block
|
||||
%fn1 = block {
|
||||
%v1:ptr<private, u32, read_write> = var
|
||||
br %fn2 # root_end
|
||||
}
|
||||
|
||||
%fn2 = root_terminator
|
||||
|
||||
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn4
|
||||
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn4 {
|
||||
%fn4 = block {
|
||||
%2:u32 = load %v1
|
||||
%3:u32 = sub %2, 1u
|
||||
|
@ -180,7 +184,7 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundSubtract) {
|
|||
br %fn5 # return
|
||||
}
|
||||
%fn5 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -192,20 +196,20 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Multiply) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 -> %fn2
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 -> %fn2 {
|
||||
%fn2 = block {
|
||||
br %fn3 0u # return
|
||||
}
|
||||
%fn3 = func_terminator
|
||||
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5
|
||||
}
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5 {
|
||||
%fn5 = block {
|
||||
%1:u32 = call my_func
|
||||
%tint_symbol:u32 = mul %1, 4u
|
||||
br %fn6 # return
|
||||
}
|
||||
%fn6 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -217,14 +221,15 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundMultiply) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(# Root block
|
||||
%fn1 = block {
|
||||
%v1:ptr<private, u32, read_write> = var
|
||||
br %fn2 # root_end
|
||||
}
|
||||
|
||||
%fn2 = root_terminator
|
||||
|
||||
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn4
|
||||
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn4 {
|
||||
%fn4 = block {
|
||||
%2:u32 = load %v1
|
||||
%3:u32 = mul %2, 1u
|
||||
|
@ -232,7 +237,7 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundMultiply) {
|
|||
br %fn5 # return
|
||||
}
|
||||
%fn5 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -244,20 +249,20 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Div) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 -> %fn2
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 -> %fn2 {
|
||||
%fn2 = block {
|
||||
br %fn3 0u # return
|
||||
}
|
||||
%fn3 = func_terminator
|
||||
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5
|
||||
}
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5 {
|
||||
%fn5 = block {
|
||||
%1:u32 = call my_func
|
||||
%tint_symbol:u32 = div %1, 4u
|
||||
br %fn6 # return
|
||||
}
|
||||
%fn6 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -269,14 +274,15 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundDiv) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(# Root block
|
||||
%fn1 = block {
|
||||
%v1:ptr<private, u32, read_write> = var
|
||||
br %fn2 # root_end
|
||||
}
|
||||
|
||||
%fn2 = root_terminator
|
||||
|
||||
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn4
|
||||
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn4 {
|
||||
%fn4 = block {
|
||||
%2:u32 = load %v1
|
||||
%3:u32 = div %2, 1u
|
||||
|
@ -284,7 +290,7 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundDiv) {
|
|||
br %fn5 # return
|
||||
}
|
||||
%fn5 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -296,20 +302,20 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Modulo) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 -> %fn2
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 -> %fn2 {
|
||||
%fn2 = block {
|
||||
br %fn3 0u # return
|
||||
}
|
||||
%fn3 = func_terminator
|
||||
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5
|
||||
}
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5 {
|
||||
%fn5 = block {
|
||||
%1:u32 = call my_func
|
||||
%tint_symbol:u32 = mod %1, 4u
|
||||
br %fn6 # return
|
||||
}
|
||||
%fn6 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -321,14 +327,15 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundModulo) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(# Root block
|
||||
%fn1 = block {
|
||||
%v1:ptr<private, u32, read_write> = var
|
||||
br %fn2 # root_end
|
||||
}
|
||||
|
||||
%fn2 = root_terminator
|
||||
|
||||
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn4
|
||||
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn4 {
|
||||
%fn4 = block {
|
||||
%2:u32 = load %v1
|
||||
%3:u32 = mod %2, 1u
|
||||
|
@ -336,7 +343,7 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundModulo) {
|
|||
br %fn5 # return
|
||||
}
|
||||
%fn5 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -348,20 +355,20 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_And) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 -> %fn2
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 -> %fn2 {
|
||||
%fn2 = block {
|
||||
br %fn3 0u # return
|
||||
}
|
||||
%fn3 = func_terminator
|
||||
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5
|
||||
}
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5 {
|
||||
%fn5 = block {
|
||||
%1:u32 = call my_func
|
||||
%tint_symbol:u32 = and %1, 4u
|
||||
br %fn6 # return
|
||||
}
|
||||
%fn6 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -373,14 +380,15 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundAnd) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(# Root block
|
||||
%fn1 = block {
|
||||
%v1:ptr<private, bool, read_write> = var
|
||||
br %fn2 # root_end
|
||||
}
|
||||
|
||||
%fn2 = root_terminator
|
||||
|
||||
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn4
|
||||
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn4 {
|
||||
%fn4 = block {
|
||||
%2:bool = load %v1
|
||||
%3:bool = and %2, false
|
||||
|
@ -388,7 +396,7 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundAnd) {
|
|||
br %fn5 # return
|
||||
}
|
||||
%fn5 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -400,20 +408,20 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Or) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 -> %fn2
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 -> %fn2 {
|
||||
%fn2 = block {
|
||||
br %fn3 0u # return
|
||||
}
|
||||
%fn3 = func_terminator
|
||||
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5
|
||||
}
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5 {
|
||||
%fn5 = block {
|
||||
%1:u32 = call my_func
|
||||
%tint_symbol:u32 = or %1, 4u
|
||||
br %fn6 # return
|
||||
}
|
||||
%fn6 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -425,14 +433,15 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundOr) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(# Root block
|
||||
%fn1 = block {
|
||||
%v1:ptr<private, bool, read_write> = var
|
||||
br %fn2 # root_end
|
||||
}
|
||||
|
||||
%fn2 = root_terminator
|
||||
|
||||
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn4
|
||||
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn4 {
|
||||
%fn4 = block {
|
||||
%2:bool = load %v1
|
||||
%3:bool = or %2, false
|
||||
|
@ -440,7 +449,7 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundOr) {
|
|||
br %fn5 # return
|
||||
}
|
||||
%fn5 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -452,20 +461,20 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Xor) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 -> %fn2
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 -> %fn2 {
|
||||
%fn2 = block {
|
||||
br %fn3 0u # return
|
||||
}
|
||||
%fn3 = func_terminator
|
||||
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5
|
||||
}
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5 {
|
||||
%fn5 = block {
|
||||
%1:u32 = call my_func
|
||||
%tint_symbol:u32 = xor %1, 4u
|
||||
br %fn6 # return
|
||||
}
|
||||
%fn6 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -477,14 +486,15 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundXor) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(# Root block
|
||||
%fn1 = block {
|
||||
%v1:ptr<private, u32, read_write> = var
|
||||
br %fn2 # root_end
|
||||
}
|
||||
|
||||
%fn2 = root_terminator
|
||||
|
||||
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn4
|
||||
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn4 {
|
||||
%fn4 = block {
|
||||
%2:u32 = load %v1
|
||||
%3:u32 = xor %2, 1u
|
||||
|
@ -492,7 +502,7 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundXor) {
|
|||
br %fn5 # return
|
||||
}
|
||||
%fn5 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -504,43 +514,51 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_LogicalAnd) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():bool -> %fn2
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():bool -> %fn2 {
|
||||
%fn2 = block {
|
||||
br %fn3 true # return
|
||||
}
|
||||
%fn3 = func_terminator
|
||||
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5
|
||||
}
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5 {
|
||||
%fn5 = block {
|
||||
%1:bool = call my_func
|
||||
if %1 [t: %fn6, f: %fn7, m: %fn8]
|
||||
}
|
||||
|
||||
# True block
|
||||
%fn6 = block {
|
||||
br %fn8 false
|
||||
}
|
||||
|
||||
# False block
|
||||
%fn7 = block {
|
||||
br %fn8 %1
|
||||
}
|
||||
|
||||
# Merge block
|
||||
%fn8 = block (%2:bool) {
|
||||
if %2:bool [t: %fn9, f: %fn10, m: %fn11]
|
||||
}
|
||||
|
||||
# True block
|
||||
%fn9 = block {
|
||||
br %fn11
|
||||
}
|
||||
|
||||
# False block
|
||||
%fn10 = block {
|
||||
br %fn11
|
||||
}
|
||||
|
||||
# Merge block
|
||||
%fn11 = block {
|
||||
br %fn12 # return
|
||||
}
|
||||
%fn12 = func_terminator
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
%fn12 = func_terminator
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -552,43 +570,51 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_LogicalOr) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():bool -> %fn2
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():bool -> %fn2 {
|
||||
%fn2 = block {
|
||||
br %fn3 true # return
|
||||
}
|
||||
%fn3 = func_terminator
|
||||
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5
|
||||
}
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5 {
|
||||
%fn5 = block {
|
||||
%1:bool = call my_func
|
||||
if %1 [t: %fn6, f: %fn7, m: %fn8]
|
||||
}
|
||||
|
||||
# True block
|
||||
%fn6 = block {
|
||||
br %fn8 %1
|
||||
}
|
||||
|
||||
# False block
|
||||
%fn7 = block {
|
||||
br %fn8 true
|
||||
}
|
||||
|
||||
# Merge block
|
||||
%fn8 = block (%2:bool) {
|
||||
if %2:bool [t: %fn9, f: %fn10, m: %fn11]
|
||||
}
|
||||
|
||||
# True block
|
||||
%fn9 = block {
|
||||
br %fn11
|
||||
}
|
||||
|
||||
# False block
|
||||
%fn10 = block {
|
||||
br %fn11
|
||||
}
|
||||
|
||||
# Merge block
|
||||
%fn11 = block {
|
||||
br %fn12 # return
|
||||
}
|
||||
%fn12 = func_terminator
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
%fn12 = func_terminator
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -600,20 +626,20 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Equal) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 -> %fn2
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 -> %fn2 {
|
||||
%fn2 = block {
|
||||
br %fn3 0u # return
|
||||
}
|
||||
%fn3 = func_terminator
|
||||
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5
|
||||
}
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5 {
|
||||
%fn5 = block {
|
||||
%1:u32 = call my_func
|
||||
%tint_symbol:bool = eq %1, 4u
|
||||
br %fn6 # return
|
||||
}
|
||||
%fn6 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -625,20 +651,20 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_NotEqual) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 -> %fn2
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 -> %fn2 {
|
||||
%fn2 = block {
|
||||
br %fn3 0u # return
|
||||
}
|
||||
%fn3 = func_terminator
|
||||
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5
|
||||
}
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5 {
|
||||
%fn5 = block {
|
||||
%1:u32 = call my_func
|
||||
%tint_symbol:bool = neq %1, 4u
|
||||
br %fn6 # return
|
||||
}
|
||||
%fn6 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -650,20 +676,20 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_LessThan) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 -> %fn2
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 -> %fn2 {
|
||||
%fn2 = block {
|
||||
br %fn3 0u # return
|
||||
}
|
||||
%fn3 = func_terminator
|
||||
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5
|
||||
}
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5 {
|
||||
%fn5 = block {
|
||||
%1:u32 = call my_func
|
||||
%tint_symbol:bool = lt %1, 4u
|
||||
br %fn6 # return
|
||||
}
|
||||
%fn6 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -675,20 +701,20 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_GreaterThan) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 -> %fn2
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 -> %fn2 {
|
||||
%fn2 = block {
|
||||
br %fn3 0u # return
|
||||
}
|
||||
%fn3 = func_terminator
|
||||
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5
|
||||
}
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5 {
|
||||
%fn5 = block {
|
||||
%1:u32 = call my_func
|
||||
%tint_symbol:bool = gt %1, 4u
|
||||
br %fn6 # return
|
||||
}
|
||||
%fn6 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -700,20 +726,20 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_LessThanEqual) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 -> %fn2
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 -> %fn2 {
|
||||
%fn2 = block {
|
||||
br %fn3 0u # return
|
||||
}
|
||||
%fn3 = func_terminator
|
||||
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5
|
||||
}
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5 {
|
||||
%fn5 = block {
|
||||
%1:u32 = call my_func
|
||||
%tint_symbol:bool = lte %1, 4u
|
||||
br %fn6 # return
|
||||
}
|
||||
%fn6 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -725,20 +751,20 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_GreaterThanEqual) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 -> %fn2
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 -> %fn2 {
|
||||
%fn2 = block {
|
||||
br %fn3 0u # return
|
||||
}
|
||||
%fn3 = func_terminator
|
||||
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5
|
||||
}
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5 {
|
||||
%fn5 = block {
|
||||
%1:u32 = call my_func
|
||||
%tint_symbol:bool = gte %1, 4u
|
||||
br %fn6 # return
|
||||
}
|
||||
%fn6 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -750,20 +776,20 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_ShiftLeft) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 -> %fn2
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 -> %fn2 {
|
||||
%fn2 = block {
|
||||
br %fn3 0u # return
|
||||
}
|
||||
%fn3 = func_terminator
|
||||
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5
|
||||
}
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5 {
|
||||
%fn5 = block {
|
||||
%1:u32 = call my_func
|
||||
%tint_symbol:u32 = shiftl %1, 4u
|
||||
br %fn6 # return
|
||||
}
|
||||
%fn6 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -775,14 +801,15 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundShiftLeft) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(# Root block
|
||||
%fn1 = block {
|
||||
%v1:ptr<private, u32, read_write> = var
|
||||
br %fn2 # root_end
|
||||
}
|
||||
|
||||
%fn2 = root_terminator
|
||||
|
||||
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn4
|
||||
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn4 {
|
||||
%fn4 = block {
|
||||
%2:u32 = load %v1
|
||||
%3:u32 = shiftl %2, 1u
|
||||
|
@ -790,7 +817,7 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundShiftLeft) {
|
|||
br %fn5 # return
|
||||
}
|
||||
%fn5 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -802,20 +829,20 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_ShiftRight) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 -> %fn2
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 -> %fn2 {
|
||||
%fn2 = block {
|
||||
br %fn3 0u # return
|
||||
}
|
||||
%fn3 = func_terminator
|
||||
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5
|
||||
}
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5 {
|
||||
%fn5 = block {
|
||||
%1:u32 = call my_func
|
||||
%tint_symbol:u32 = shiftr %1, 4u
|
||||
br %fn6 # return
|
||||
}
|
||||
%fn6 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -827,14 +854,15 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundShiftRight) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(# Root block
|
||||
%fn1 = block {
|
||||
%v1:ptr<private, u32, read_write> = var
|
||||
br %fn2 # root_end
|
||||
}
|
||||
|
||||
%fn2 = root_terminator
|
||||
|
||||
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn4
|
||||
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn4 {
|
||||
%fn4 = block {
|
||||
%2:u32 = load %v1
|
||||
%3:u32 = shiftr %2, 1u
|
||||
|
@ -842,7 +870,7 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundShiftRight) {
|
|||
br %fn5 # return
|
||||
}
|
||||
%fn5 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -856,19 +884,18 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Compound) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():f32 -> %fn2
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():f32 -> %fn2 {
|
||||
%fn2 = block {
|
||||
br %fn3 0.0f # return
|
||||
}
|
||||
%fn3 = func_terminator
|
||||
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5
|
||||
}
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5 {
|
||||
%fn5 = block {
|
||||
%1:f32 = call my_func
|
||||
%2:bool = lt %1, 2.0f
|
||||
if %2 [t: %fn6, f: %fn7, m: %fn8]
|
||||
}
|
||||
|
||||
# True block
|
||||
%fn6 = block {
|
||||
%3:f32 = call my_func
|
||||
%4:f32 = call my_func
|
||||
|
@ -878,15 +905,20 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Compound) {
|
|||
br %fn8 %7
|
||||
}
|
||||
|
||||
# False block
|
||||
%fn7 = block {
|
||||
br %fn8 %2
|
||||
}
|
||||
|
||||
# Merge block
|
||||
%fn8 = block (%tint_symbol:bool) {
|
||||
br %fn9 # return
|
||||
}
|
||||
%fn9 = func_terminator
|
||||
|
||||
}
|
||||
|
||||
%fn9 = func_terminator
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -899,19 +931,19 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Compound_WithConstEval) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func(%p:bool):bool -> %fn2
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func(%p:bool):bool -> %fn2 {
|
||||
%fn2 = block {
|
||||
br %fn3 true # return
|
||||
}
|
||||
%fn3 = func_terminator
|
||||
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5
|
||||
}
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5 {
|
||||
%fn5 = block {
|
||||
%tint_symbol:bool = call my_func, false
|
||||
br %fn6 # return
|
||||
}
|
||||
%fn6 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
|
|
@ -35,20 +35,20 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Bitcast) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():f32 -> %fn2
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():f32 -> %fn2 {
|
||||
%fn2 = block {
|
||||
br %fn3 0.0f # return
|
||||
}
|
||||
%fn3 = func_terminator
|
||||
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5
|
||||
}
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5 {
|
||||
%fn5 = block {
|
||||
%1:f32 = call my_func
|
||||
%tint_symbol:f32 = bitcast %1
|
||||
br %fn6 # return
|
||||
}
|
||||
%fn6 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -62,13 +62,13 @@ TEST_F(IR_BuilderImplTest, EmitStatement_Discard) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func test_function():void [@fragment] -> %fn2
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func test_function():void [@fragment] -> %fn2 {
|
||||
%fn2 = block {
|
||||
discard
|
||||
br %fn3 # return
|
||||
}
|
||||
%fn3 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -80,19 +80,19 @@ TEST_F(IR_BuilderImplTest, EmitStatement_UserFunction) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func(%p:f32):void -> %fn2
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func(%p:f32):void -> %fn2 {
|
||||
%fn2 = block {
|
||||
br %fn3 # return
|
||||
}
|
||||
%fn3 = func_terminator
|
||||
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5
|
||||
}
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5 {
|
||||
%fn5 = block {
|
||||
%2:void = call my_func, 6.0f
|
||||
br %fn6 # return
|
||||
}
|
||||
%fn6 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -104,21 +104,22 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Convert) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(# Root block
|
||||
%fn1 = block {
|
||||
%i:ptr<private, i32, read_write> = var, 1i
|
||||
br %fn2 # root_end
|
||||
}
|
||||
|
||||
%fn2 = root_terminator
|
||||
|
||||
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn4
|
||||
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn4 {
|
||||
%fn4 = block {
|
||||
%2:i32 = load %i
|
||||
%tint_symbol:f32 = convert i32, %2
|
||||
br %fn5 # return
|
||||
}
|
||||
%fn5 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -129,7 +130,8 @@ TEST_F(IR_BuilderImplTest, EmitExpression_ConstructEmpty) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(# Root block
|
||||
%fn1 = block {
|
||||
%i:ptr<private, vec3<f32>, read_write> = var, vec3<f32> 0.0f
|
||||
br %fn2 # root_end
|
||||
}
|
||||
|
@ -147,21 +149,22 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Construct) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(# Root block
|
||||
%fn1 = block {
|
||||
%i:ptr<private, f32, read_write> = var, 1.0f
|
||||
br %fn2 # root_end
|
||||
}
|
||||
|
||||
%fn2 = root_terminator
|
||||
|
||||
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn4
|
||||
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn4 {
|
||||
%fn4 = block {
|
||||
%2:f32 = load %i
|
||||
%tint_symbol:vec3<f32> = construct 2.0f, 3.0f, %2
|
||||
br %fn5 # return
|
||||
}
|
||||
%fn5 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
|
|
@ -34,12 +34,12 @@ TEST_F(IR_BuilderImplTest, EmitExpression_MaterializedCall) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func test_function():f32 -> %fn2
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func test_function():f32 -> %fn2 {
|
||||
%fn2 = block {
|
||||
br %fn3 2.0f # return
|
||||
}
|
||||
%fn3 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
|
|
@ -35,20 +35,21 @@ TEST_F(IR_BuilderImplTest, EmitStatement_Assign) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(# Root block
|
||||
%fn1 = block {
|
||||
%a:ptr<private, u32, read_write> = var
|
||||
br %fn2 # root_end
|
||||
}
|
||||
|
||||
%fn2 = root_terminator
|
||||
|
||||
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn4
|
||||
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn4 {
|
||||
%fn4 = block {
|
||||
store %a, 4u
|
||||
br %fn5 # return
|
||||
}
|
||||
%fn5 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -34,20 +34,20 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Unary_Not) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():bool -> %fn2
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():bool -> %fn2 {
|
||||
%fn2 = block {
|
||||
br %fn3 false # return
|
||||
}
|
||||
%fn3 = func_terminator
|
||||
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5
|
||||
}
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5 {
|
||||
%fn5 = block {
|
||||
%1:bool = call my_func
|
||||
%tint_symbol:bool = eq %1, false
|
||||
br %fn6 # return
|
||||
}
|
||||
%fn6 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -59,20 +59,20 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Unary_Complement) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 -> %fn2
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 -> %fn2 {
|
||||
%fn2 = block {
|
||||
br %fn3 1u # return
|
||||
}
|
||||
%fn3 = func_terminator
|
||||
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5
|
||||
}
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5 {
|
||||
%fn5 = block {
|
||||
%1:u32 = call my_func
|
||||
%tint_symbol:u32 = complement %1
|
||||
br %fn6 # return
|
||||
}
|
||||
%fn6 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -84,20 +84,20 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Unary_Negation) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():i32 -> %fn2
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():i32 -> %fn2 {
|
||||
%fn2 = block {
|
||||
br %fn3 1i # return
|
||||
}
|
||||
%fn3 = func_terminator
|
||||
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5
|
||||
}
|
||||
%fn4 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn5 {
|
||||
%fn5 = block {
|
||||
%1:i32 = call my_func
|
||||
%tint_symbol:i32 = negation %1
|
||||
br %fn6 # return
|
||||
}
|
||||
%fn6 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -110,19 +110,20 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Unary_AddressOf) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(# Root block
|
||||
%fn1 = block {
|
||||
%v2:ptr<private, i32, read_write> = var
|
||||
br %fn2 # root_end
|
||||
}
|
||||
|
||||
%fn2 = root_terminator
|
||||
|
||||
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn4
|
||||
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn4 {
|
||||
%fn4 = block {
|
||||
br %fn5 # return
|
||||
}
|
||||
%fn5 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -137,20 +138,21 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Unary_Indirection) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(# Root block
|
||||
%fn1 = block {
|
||||
%v3:ptr<private, i32, read_write> = var
|
||||
br %fn2 # root_end
|
||||
}
|
||||
|
||||
%fn2 = root_terminator
|
||||
|
||||
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn4
|
||||
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn4 {
|
||||
%fn4 = block {
|
||||
store %v3, 42i
|
||||
br %fn5 # return
|
||||
}
|
||||
%fn5 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,8 @@ TEST_F(IR_BuilderImplTest, Emit_GlobalVar_NoInit) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(# Root block
|
||||
%fn1 = block {
|
||||
%a:ptr<private, u32, read_write> = var
|
||||
br %fn2 # root_end
|
||||
}
|
||||
|
@ -49,7 +50,8 @@ TEST_F(IR_BuilderImplTest, Emit_GlobalVar_Init) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(# Root block
|
||||
%fn1 = block {
|
||||
%a:ptr<private, u32, read_write> = var, 2u
|
||||
br %fn2 # root_end
|
||||
}
|
||||
|
@ -67,13 +69,13 @@ TEST_F(IR_BuilderImplTest, Emit_Var_NoInit) {
|
|||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()),
|
||||
R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn2
|
||||
R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn2 {
|
||||
%fn2 = block {
|
||||
%a:ptr<function, u32, read_write> = var
|
||||
br %fn3 # return
|
||||
}
|
||||
%fn3 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
|
@ -86,13 +88,13 @@ TEST_F(IR_BuilderImplTest, Emit_Var_Init) {
|
|||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()),
|
||||
R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn2
|
||||
R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn2 {
|
||||
%fn2 = block {
|
||||
%a:ptr<function, u32, read_write> = var, 2u
|
||||
br %fn3 # return
|
||||
}
|
||||
%fn3 = func_terminator
|
||||
|
||||
}
|
||||
)");
|
||||
}
|
||||
} // namespace
|
||||
|
|
|
@ -25,12 +25,12 @@ using IR_AddEmptyEntryPointTest = TransformTest;
|
|||
|
||||
TEST_F(IR_AddEmptyEntryPointTest, EmptyModule) {
|
||||
auto* expect = R"(
|
||||
%fn1 = func unused_entry_point():void [@compute @workgroup_size(1, 1, 1)] -> %fn2
|
||||
%fn1 = func unused_entry_point():void [@compute @workgroup_size(1, 1, 1)] -> %fn2 {
|
||||
%fn2 = block {
|
||||
br %fn3 # return
|
||||
}
|
||||
%fn3 = func_terminator
|
||||
|
||||
}
|
||||
)";
|
||||
|
||||
Run<AddEmptyEntryPoint>();
|
||||
|
@ -44,12 +44,12 @@ TEST_F(IR_AddEmptyEntryPointTest, ExistingEntryPoint) {
|
|||
mod.functions.Push(ep);
|
||||
|
||||
auto* expect = R"(
|
||||
%fn1 = func main():void [@fragment] -> %fn2
|
||||
%fn1 = func main():void [@fragment] -> %fn2 {
|
||||
%fn2 = block {
|
||||
br %fn3 # return
|
||||
}
|
||||
%fn3 = func_terminator
|
||||
|
||||
}
|
||||
)";
|
||||
|
||||
Run<AddEmptyEntryPoint>();
|
||||
|
|
Loading…
Reference in New Issue