[ir] Update UserCall to hold Function Values.
This CL updates the `UserCall` to hold a `Function` value instead of the functions name symbol. The name symbol is also removed from the function itself and stored into the module like all other values. Bug: tint:1718 Change-Id: I6c94ce435a6a260f9fe953a04278129b35b3bd39 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/134303 Reviewed-by: James Price <jrprice@google.com> Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Dan Sinclair <dsinclair@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
79fe4ab42f
commit
a2b489b900
|
@ -49,19 +49,12 @@ Function* Builder::CreateFunction(std::string_view name,
|
|||
const type::Type* return_type,
|
||||
Function::PipelineStage stage,
|
||||
std::optional<std::array<uint32_t, 3>> wg_size) {
|
||||
return CreateFunction(ir.symbols.Register(name), return_type, stage, wg_size);
|
||||
}
|
||||
|
||||
Function* Builder::CreateFunction(Symbol name,
|
||||
const type::Type* return_type,
|
||||
Function::PipelineStage stage,
|
||||
std::optional<std::array<uint32_t, 3>> wg_size) {
|
||||
TINT_ASSERT(IR, return_type);
|
||||
|
||||
auto* ir_func = ir.values.Create<Function>(name, return_type, stage, wg_size);
|
||||
auto* ir_func = ir.values.Create<Function>(return_type, stage, wg_size);
|
||||
ir_func->SetStartTarget(CreateBlock());
|
||||
ir_func->SetEndTarget(CreateFunctionTerminator());
|
||||
|
||||
ir.SetName(ir_func, name);
|
||||
return ir_func;
|
||||
}
|
||||
|
||||
|
@ -182,9 +175,9 @@ ir::Discard* Builder::Discard() {
|
|||
}
|
||||
|
||||
ir::UserCall* Builder::UserCall(const type::Type* type,
|
||||
Symbol name,
|
||||
Function* func,
|
||||
utils::VectorRef<Value*> args) {
|
||||
return ir.values.Create<ir::UserCall>(type, name, std::move(args));
|
||||
return ir.values.Create<ir::UserCall>(type, func, std::move(args));
|
||||
}
|
||||
|
||||
ir::Convert* Builder::Convert(const type::Type* to,
|
||||
|
|
|
@ -79,17 +79,6 @@ class Builder {
|
|||
Function::PipelineStage stage = Function::PipelineStage::kUndefined,
|
||||
std::optional<std::array<uint32_t, 3>> wg_size = {});
|
||||
|
||||
/// Creates a function flow node
|
||||
/// @param name the function name
|
||||
/// @param return_type the function return type
|
||||
/// @param stage the function stage
|
||||
/// @param wg_size the workgroup_size
|
||||
/// @returns the flow node
|
||||
Function* CreateFunction(Symbol name,
|
||||
const type::Type* return_type,
|
||||
Function::PipelineStage stage = Function::PipelineStage::kUndefined,
|
||||
std::optional<std::array<uint32_t, 3>> wg_size = {});
|
||||
|
||||
/// Creates an if flow node
|
||||
/// @param condition the if condition
|
||||
/// @returns the flow node
|
||||
|
@ -299,10 +288,10 @@ class Builder {
|
|||
|
||||
/// Creates a user function call instruction
|
||||
/// @param type the return type of the call
|
||||
/// @param name the name of the function being called
|
||||
/// @param func the function being called
|
||||
/// @param args the call arguments
|
||||
/// @returns the instruction
|
||||
ir::UserCall* UserCall(const type::Type* type, Symbol name, utils::VectorRef<Value*> args);
|
||||
ir::UserCall* UserCall(const type::Type* type, Function* func, utils::VectorRef<Value*> args);
|
||||
|
||||
/// Creates a value conversion instruction
|
||||
/// @param to the type converted to
|
||||
|
|
|
@ -78,8 +78,8 @@ std::string Debug::AsDotGraph(const Module* mod) {
|
|||
out << "digraph G {" << std::endl;
|
||||
for (const auto* func : mod->functions) {
|
||||
// Cluster each function to label and draw a box around it.
|
||||
out << "subgraph cluster_" << func->Name().Name() << " {" << std::endl;
|
||||
out << R"(label=")" << func->Name().Name() << R"(")" << std::endl;
|
||||
out << "subgraph cluster_" << mod->NameOf(func).Name() << " {" << std::endl;
|
||||
out << R"(label=")" << mod->NameOf(func).Name() << R"(")" << std::endl;
|
||||
out << name_for(func->StartTarget()) << R"( [label="start"])" << std::endl;
|
||||
out << name_for(func->EndTarget()) << R"( [label="end"])" << std::endl;
|
||||
Graph(func->StartTarget());
|
||||
|
|
|
@ -151,7 +151,7 @@ void Disassembler::Walk(const Block* blk) {
|
|||
void Disassembler::EmitFunction(const Function* func) {
|
||||
in_function_ = true;
|
||||
|
||||
Indent() << "%" << IdOf(func) << " = func " << func->Name().Name() << "(";
|
||||
Indent() << "%" << IdOf(func) << " = func(";
|
||||
for (auto* p : func->Params()) {
|
||||
if (p != func->Params().Front()) {
|
||||
out_ << ", ";
|
||||
|
@ -292,7 +292,7 @@ void Disassembler::EmitInstruction(const Instruction* inst) {
|
|||
},
|
||||
[&](const ir::UserCall* uc) {
|
||||
EmitValueWithType(uc);
|
||||
out_ << " = call " << uc->Name().Name();
|
||||
out_ << " = call %" << IdOf(uc->Func());
|
||||
if (!uc->Args().IsEmpty()) {
|
||||
out_ << ", ";
|
||||
}
|
||||
|
|
|
@ -196,10 +196,6 @@ class Impl {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
Symbol CloneSymbol(Symbol sym) const {
|
||||
return clone_ctx_.type_ctx.dst.st->Register(sym.Name());
|
||||
}
|
||||
|
||||
ResultType EmitModule() {
|
||||
auto* sem = program_->Sem().Module();
|
||||
|
||||
|
@ -250,11 +246,13 @@ class Impl {
|
|||
|
||||
const auto* sem = program_->Sem().Get(ast_func);
|
||||
|
||||
auto* ir_func = builder_.CreateFunction(CloneSymbol(ast_func->name->symbol),
|
||||
auto* ir_func = builder_.CreateFunction(ast_func->name->symbol.NameView(),
|
||||
sem->ReturnType()->Clone(clone_ctx_.type_ctx));
|
||||
current_function_ = ir_func;
|
||||
builder_.ir.functions.Push(ir_func);
|
||||
|
||||
scopes_.Set(ast_func->name->symbol, ir_func);
|
||||
|
||||
if (ast_func->IsEntryPoint()) {
|
||||
switch (ast_func->PipelineStage()) {
|
||||
case ast::PipelineStage::kVertex:
|
||||
|
@ -1136,8 +1134,9 @@ class Impl {
|
|||
return utils::Failure;
|
||||
} else {
|
||||
// Not a builtin and not a templated call, so this is a user function.
|
||||
auto name = CloneSymbol(expr->target->identifier->symbol);
|
||||
inst = builder_.UserCall(ty, name, std::move(args));
|
||||
inst = builder_.UserCall(
|
||||
ty, scopes_.Get(expr->target->identifier->symbol)->As<ir::Function>(),
|
||||
std::move(args));
|
||||
}
|
||||
if (inst == nullptr) {
|
||||
return utils::Failure;
|
||||
|
|
|
@ -34,15 +34,15 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Add) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%1 = func my_func():u32 -> %fn1 {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%my_func = func():u32 -> %fn1 {
|
||||
%fn1 = block {
|
||||
br %fn2 0u # return
|
||||
}
|
||||
%fn2 = func_terminator
|
||||
}
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:u32 = call my_func
|
||||
%3:u32 = call %my_func
|
||||
%tint_symbol:u32 = add %3, 4u
|
||||
br %fn4 # return
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Increment) {
|
|||
|
||||
%fn2 = root_terminator
|
||||
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:u32 = load %v1
|
||||
%4:u32 = add %3, 1u
|
||||
|
@ -95,7 +95,7 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundAdd) {
|
|||
|
||||
%fn2 = root_terminator
|
||||
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:u32 = load %v1
|
||||
%4:u32 = add %3, 1u
|
||||
|
@ -115,15 +115,15 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Subtract) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%1 = func my_func():u32 -> %fn1 {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%my_func = func():u32 -> %fn1 {
|
||||
%fn1 = block {
|
||||
br %fn2 0u # return
|
||||
}
|
||||
%fn2 = func_terminator
|
||||
}
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:u32 = call my_func
|
||||
%3:u32 = call %my_func
|
||||
%tint_symbol:u32 = sub %3, 4u
|
||||
br %fn4 # return
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Decrement) {
|
|||
|
||||
%fn2 = root_terminator
|
||||
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:i32 = load %v1
|
||||
%4:i32 = sub %3, 1i
|
||||
|
@ -176,7 +176,7 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundSubtract) {
|
|||
|
||||
%fn2 = root_terminator
|
||||
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:u32 = load %v1
|
||||
%4:u32 = sub %3, 1u
|
||||
|
@ -196,15 +196,15 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Multiply) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%1 = func my_func():u32 -> %fn1 {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%my_func = func():u32 -> %fn1 {
|
||||
%fn1 = block {
|
||||
br %fn2 0u # return
|
||||
}
|
||||
%fn2 = func_terminator
|
||||
}
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:u32 = call my_func
|
||||
%3:u32 = call %my_func
|
||||
%tint_symbol:u32 = mul %3, 4u
|
||||
br %fn4 # return
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundMultiply) {
|
|||
|
||||
%fn2 = root_terminator
|
||||
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:u32 = load %v1
|
||||
%4:u32 = mul %3, 1u
|
||||
|
@ -249,15 +249,15 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Div) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%1 = func my_func():u32 -> %fn1 {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%my_func = func():u32 -> %fn1 {
|
||||
%fn1 = block {
|
||||
br %fn2 0u # return
|
||||
}
|
||||
%fn2 = func_terminator
|
||||
}
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:u32 = call my_func
|
||||
%3:u32 = call %my_func
|
||||
%tint_symbol:u32 = div %3, 4u
|
||||
br %fn4 # return
|
||||
}
|
||||
|
@ -282,7 +282,7 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundDiv) {
|
|||
|
||||
%fn2 = root_terminator
|
||||
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:u32 = load %v1
|
||||
%4:u32 = div %3, 1u
|
||||
|
@ -302,15 +302,15 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Modulo) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%1 = func my_func():u32 -> %fn1 {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%my_func = func():u32 -> %fn1 {
|
||||
%fn1 = block {
|
||||
br %fn2 0u # return
|
||||
}
|
||||
%fn2 = func_terminator
|
||||
}
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:u32 = call my_func
|
||||
%3:u32 = call %my_func
|
||||
%tint_symbol:u32 = mod %3, 4u
|
||||
br %fn4 # return
|
||||
}
|
||||
|
@ -335,7 +335,7 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundModulo) {
|
|||
|
||||
%fn2 = root_terminator
|
||||
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:u32 = load %v1
|
||||
%4:u32 = mod %3, 1u
|
||||
|
@ -355,15 +355,15 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_And) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%1 = func my_func():u32 -> %fn1 {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%my_func = func():u32 -> %fn1 {
|
||||
%fn1 = block {
|
||||
br %fn2 0u # return
|
||||
}
|
||||
%fn2 = func_terminator
|
||||
}
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:u32 = call my_func
|
||||
%3:u32 = call %my_func
|
||||
%tint_symbol:u32 = and %3, 4u
|
||||
br %fn4 # return
|
||||
}
|
||||
|
@ -388,7 +388,7 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundAnd) {
|
|||
|
||||
%fn2 = root_terminator
|
||||
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:bool = load %v1
|
||||
%4:bool = and %3, false
|
||||
|
@ -408,15 +408,15 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Or) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%1 = func my_func():u32 -> %fn1 {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%my_func = func():u32 -> %fn1 {
|
||||
%fn1 = block {
|
||||
br %fn2 0u # return
|
||||
}
|
||||
%fn2 = func_terminator
|
||||
}
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:u32 = call my_func
|
||||
%3:u32 = call %my_func
|
||||
%tint_symbol:u32 = or %3, 4u
|
||||
br %fn4 # return
|
||||
}
|
||||
|
@ -441,7 +441,7 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundOr) {
|
|||
|
||||
%fn2 = root_terminator
|
||||
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:bool = load %v1
|
||||
%4:bool = or %3, false
|
||||
|
@ -461,15 +461,15 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Xor) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%1 = func my_func():u32 -> %fn1 {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%my_func = func():u32 -> %fn1 {
|
||||
%fn1 = block {
|
||||
br %fn2 0u # return
|
||||
}
|
||||
%fn2 = func_terminator
|
||||
}
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:u32 = call my_func
|
||||
%3:u32 = call %my_func
|
||||
%tint_symbol:u32 = xor %3, 4u
|
||||
br %fn4 # return
|
||||
}
|
||||
|
@ -494,7 +494,7 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundXor) {
|
|||
|
||||
%fn2 = root_terminator
|
||||
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:u32 = load %v1
|
||||
%4:u32 = xor %3, 1u
|
||||
|
@ -514,15 +514,15 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_LogicalAnd) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%1 = func my_func():bool -> %fn1 {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%my_func = func():bool -> %fn1 {
|
||||
%fn1 = block {
|
||||
br %fn2 true # return
|
||||
}
|
||||
%fn2 = func_terminator
|
||||
}
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:bool = call my_func
|
||||
%3:bool = call %my_func
|
||||
if %3 [t: %fn4, f: %fn5, m: %fn6]
|
||||
# True block
|
||||
%fn4 = block {
|
||||
|
@ -570,15 +570,15 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_LogicalOr) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%1 = func my_func():bool -> %fn1 {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%my_func = func():bool -> %fn1 {
|
||||
%fn1 = block {
|
||||
br %fn2 true # return
|
||||
}
|
||||
%fn2 = func_terminator
|
||||
}
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:bool = call my_func
|
||||
%3:bool = call %my_func
|
||||
if %3 [t: %fn4, f: %fn5, m: %fn6]
|
||||
# True block
|
||||
%fn4 = block {
|
||||
|
@ -626,15 +626,15 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Equal) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%1 = func my_func():u32 -> %fn1 {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%my_func = func():u32 -> %fn1 {
|
||||
%fn1 = block {
|
||||
br %fn2 0u # return
|
||||
}
|
||||
%fn2 = func_terminator
|
||||
}
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:u32 = call my_func
|
||||
%3:u32 = call %my_func
|
||||
%tint_symbol:bool = eq %3, 4u
|
||||
br %fn4 # return
|
||||
}
|
||||
|
@ -651,15 +651,15 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_NotEqual) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%1 = func my_func():u32 -> %fn1 {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%my_func = func():u32 -> %fn1 {
|
||||
%fn1 = block {
|
||||
br %fn2 0u # return
|
||||
}
|
||||
%fn2 = func_terminator
|
||||
}
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:u32 = call my_func
|
||||
%3:u32 = call %my_func
|
||||
%tint_symbol:bool = neq %3, 4u
|
||||
br %fn4 # return
|
||||
}
|
||||
|
@ -676,15 +676,15 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_LessThan) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%1 = func my_func():u32 -> %fn1 {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%my_func = func():u32 -> %fn1 {
|
||||
%fn1 = block {
|
||||
br %fn2 0u # return
|
||||
}
|
||||
%fn2 = func_terminator
|
||||
}
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:u32 = call my_func
|
||||
%3:u32 = call %my_func
|
||||
%tint_symbol:bool = lt %3, 4u
|
||||
br %fn4 # return
|
||||
}
|
||||
|
@ -701,15 +701,15 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_GreaterThan) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%1 = func my_func():u32 -> %fn1 {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%my_func = func():u32 -> %fn1 {
|
||||
%fn1 = block {
|
||||
br %fn2 0u # return
|
||||
}
|
||||
%fn2 = func_terminator
|
||||
}
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:u32 = call my_func
|
||||
%3:u32 = call %my_func
|
||||
%tint_symbol:bool = gt %3, 4u
|
||||
br %fn4 # return
|
||||
}
|
||||
|
@ -726,15 +726,15 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_LessThanEqual) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%1 = func my_func():u32 -> %fn1 {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%my_func = func():u32 -> %fn1 {
|
||||
%fn1 = block {
|
||||
br %fn2 0u # return
|
||||
}
|
||||
%fn2 = func_terminator
|
||||
}
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:u32 = call my_func
|
||||
%3:u32 = call %my_func
|
||||
%tint_symbol:bool = lte %3, 4u
|
||||
br %fn4 # return
|
||||
}
|
||||
|
@ -751,15 +751,15 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_GreaterThanEqual) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%1 = func my_func():u32 -> %fn1 {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%my_func = func():u32 -> %fn1 {
|
||||
%fn1 = block {
|
||||
br %fn2 0u # return
|
||||
}
|
||||
%fn2 = func_terminator
|
||||
}
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:u32 = call my_func
|
||||
%3:u32 = call %my_func
|
||||
%tint_symbol:bool = gte %3, 4u
|
||||
br %fn4 # return
|
||||
}
|
||||
|
@ -776,15 +776,15 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_ShiftLeft) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%1 = func my_func():u32 -> %fn1 {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%my_func = func():u32 -> %fn1 {
|
||||
%fn1 = block {
|
||||
br %fn2 0u # return
|
||||
}
|
||||
%fn2 = func_terminator
|
||||
}
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:u32 = call my_func
|
||||
%3:u32 = call %my_func
|
||||
%tint_symbol:u32 = shiftl %3, 4u
|
||||
br %fn4 # return
|
||||
}
|
||||
|
@ -809,7 +809,7 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundShiftLeft) {
|
|||
|
||||
%fn2 = root_terminator
|
||||
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:u32 = load %v1
|
||||
%4:u32 = shiftl %3, 1u
|
||||
|
@ -829,15 +829,15 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_ShiftRight) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%1 = func my_func():u32 -> %fn1 {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%my_func = func():u32 -> %fn1 {
|
||||
%fn1 = block {
|
||||
br %fn2 0u # return
|
||||
}
|
||||
%fn2 = func_terminator
|
||||
}
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:u32 = call my_func
|
||||
%3:u32 = call %my_func
|
||||
%tint_symbol:u32 = shiftr %3, 4u
|
||||
br %fn4 # return
|
||||
}
|
||||
|
@ -862,7 +862,7 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundShiftRight) {
|
|||
|
||||
%fn2 = root_terminator
|
||||
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:u32 = load %v1
|
||||
%4:u32 = shiftr %3, 1u
|
||||
|
@ -884,21 +884,21 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Compound) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%1 = func my_func():f32 -> %fn1 {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%my_func = func():f32 -> %fn1 {
|
||||
%fn1 = block {
|
||||
br %fn2 0.0f # return
|
||||
}
|
||||
%fn2 = func_terminator
|
||||
}
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:f32 = call my_func
|
||||
%3:f32 = call %my_func
|
||||
%4:bool = lt %3, 2.0f
|
||||
if %4 [t: %fn4, f: %fn5, m: %fn6]
|
||||
# True block
|
||||
%fn4 = block {
|
||||
%5:f32 = call my_func
|
||||
%6:f32 = call my_func
|
||||
%5:f32 = call %my_func
|
||||
%6:f32 = call %my_func
|
||||
%7:f32 = mul 2.29999995231628417969f, %6
|
||||
%8:f32 = div %5, %7
|
||||
%9:bool = gt 2.5f, %8
|
||||
|
@ -931,15 +931,15 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Compound_WithConstEval) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%1 = func my_func(%p:bool):bool -> %fn1 {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%my_func = func(%p:bool):bool -> %fn1 {
|
||||
%fn1 = block {
|
||||
br %fn2 true # return
|
||||
}
|
||||
%fn2 = func_terminator
|
||||
}
|
||||
%3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%tint_symbol:bool = call my_func, false
|
||||
%tint_symbol:bool = call %my_func, false
|
||||
br %fn4 # return
|
||||
}
|
||||
%fn4 = func_terminator
|
||||
|
|
|
@ -35,15 +35,15 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Bitcast) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%1 = func my_func():f32 -> %fn1 {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%my_func = func():f32 -> %fn1 {
|
||||
%fn1 = block {
|
||||
br %fn2 0.0f # return
|
||||
}
|
||||
%fn2 = func_terminator
|
||||
}
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:f32 = call my_func
|
||||
%3:f32 = call %my_func
|
||||
%tint_symbol:f32 = bitcast %3
|
||||
br %fn4 # return
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ TEST_F(IR_BuilderImplTest, EmitStatement_Discard) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%1 = func test_function():void [@fragment] -> %fn1 {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%test_function = func():void [@fragment] -> %fn1 {
|
||||
%fn1 = block {
|
||||
discard
|
||||
br %fn2 # return
|
||||
|
@ -80,15 +80,15 @@ TEST_F(IR_BuilderImplTest, EmitStatement_UserFunction) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%1 = func my_func(%p:f32):void -> %fn1 {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%my_func = func(%p:f32):void -> %fn1 {
|
||||
%fn1 = block {
|
||||
br %fn2 # return
|
||||
}
|
||||
%fn2 = func_terminator
|
||||
}
|
||||
%3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%4:void = call my_func, 6.0f
|
||||
%4:void = call %my_func, 6.0f
|
||||
br %fn4 # return
|
||||
}
|
||||
%fn4 = func_terminator
|
||||
|
@ -112,7 +112,7 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Convert) {
|
|||
|
||||
%fn2 = root_terminator
|
||||
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:i32 = load %i
|
||||
%tint_symbol:f32 = convert i32, %3
|
||||
|
@ -157,7 +157,7 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Construct) {
|
|||
|
||||
%fn2 = root_terminator
|
||||
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:f32 = load %i
|
||||
%tint_symbol:vec3<f32> = construct 2.0f, 3.0f, %3
|
||||
|
|
|
@ -34,7 +34,7 @@ TEST_F(IR_BuilderImplTest, EmitExpression_MaterializedCall) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%1 = func test_function():f32 -> %fn1 {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%test_function = func():f32 -> %fn1 {
|
||||
%fn1 = block {
|
||||
br %fn2 2.0f # return
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ TEST_F(IR_BuilderImplTest, EmitStatement_Assign) {
|
|||
|
||||
%fn2 = root_terminator
|
||||
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
store %a, 4u
|
||||
br %fn4 # return
|
||||
|
|
|
@ -70,7 +70,7 @@ TEST_F(IR_BuilderImplTest, Func) {
|
|||
|
||||
EXPECT_EQ(m->functions[0]->Stage(), Function::PipelineStage::kUndefined);
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%1 = func f():void -> %fn1 {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%f = func():void -> %fn1 {
|
||||
%fn1 = block {
|
||||
br %fn2 # return
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ TEST_F(IR_BuilderImplTest, Func_WithParam) {
|
|||
|
||||
EXPECT_EQ(m->functions[0]->Stage(), Function::PipelineStage::kUndefined);
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%1 = func f(%a:u32):u32 -> %fn1 {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%f = func(%a:u32):u32 -> %fn1 {
|
||||
%fn1 = block {
|
||||
br %fn2 %a # return
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ TEST_F(IR_BuilderImplTest, Func_WithMultipleParam) {
|
|||
|
||||
EXPECT_EQ(m->functions[0]->Stage(), Function::PipelineStage::kUndefined);
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%1 = func f(%a:u32, %b:i32, %c:bool):void -> %fn1 {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%f = func(%a:u32, %b:i32, %c:bool):void -> %fn1 {
|
||||
%fn1 = block {
|
||||
br %fn2 # return
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ TEST_F(IR_BuilderImplTest, IfStatement) {
|
|||
EXPECT_EQ(1u, func->EndTarget()->InboundBranches().Length());
|
||||
|
||||
EXPECT_EQ(Disassemble(m),
|
||||
R"(%1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
R"(%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
%fn1 = block {
|
||||
if true [t: %fn2, f: %fn3, m: %fn4]
|
||||
# True block
|
||||
|
@ -203,7 +203,7 @@ TEST_F(IR_BuilderImplTest, IfStatement_TrueReturns) {
|
|||
EXPECT_EQ(2u, func->EndTarget()->InboundBranches().Length());
|
||||
|
||||
EXPECT_EQ(Disassemble(m),
|
||||
R"(%1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
R"(%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
%fn1 = block {
|
||||
if true [t: %fn2, f: %fn3, m: %fn4]
|
||||
# True block
|
||||
|
@ -246,7 +246,7 @@ TEST_F(IR_BuilderImplTest, IfStatement_FalseReturns) {
|
|||
EXPECT_EQ(2u, func->EndTarget()->InboundBranches().Length());
|
||||
|
||||
EXPECT_EQ(Disassemble(m),
|
||||
R"(%1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
R"(%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
%fn1 = block {
|
||||
if true [t: %fn2, f: %fn3, m: %fn4]
|
||||
# True block
|
||||
|
@ -289,7 +289,7 @@ TEST_F(IR_BuilderImplTest, IfStatement_BothReturn) {
|
|||
EXPECT_EQ(2u, func->EndTarget()->InboundBranches().Length());
|
||||
|
||||
EXPECT_EQ(Disassemble(m),
|
||||
R"(%1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
R"(%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
%fn1 = block {
|
||||
if true [t: %fn2, f: %fn3]
|
||||
# True block
|
||||
|
@ -324,7 +324,7 @@ TEST_F(IR_BuilderImplTest, IfStatement_JumpChainToMerge) {
|
|||
ASSERT_NE(loop_flow, nullptr);
|
||||
|
||||
EXPECT_EQ(Disassemble(m),
|
||||
R"(%1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
R"(%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
%fn1 = block {
|
||||
if true [t: %fn2, f: %fn3, m: %fn4]
|
||||
# True block
|
||||
|
@ -383,7 +383,7 @@ TEST_F(IR_BuilderImplTest, Loop_WithBreak) {
|
|||
EXPECT_EQ(1u, func->EndTarget()->InboundBranches().Length());
|
||||
|
||||
EXPECT_EQ(Disassemble(m),
|
||||
R"(%1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
R"(%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
%fn1 = block {
|
||||
loop [s: %fn2, c: %fn3, m: %fn4]
|
||||
%fn2 = block {
|
||||
|
@ -432,7 +432,7 @@ TEST_F(IR_BuilderImplTest, Loop_WithContinue) {
|
|||
EXPECT_EQ(1u, func->EndTarget()->InboundBranches().Length());
|
||||
|
||||
EXPECT_EQ(Disassemble(m),
|
||||
R"(%1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
R"(%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
%fn1 = block {
|
||||
loop [s: %fn2, c: %fn3, m: %fn4]
|
||||
%fn2 = block {
|
||||
|
@ -496,7 +496,7 @@ TEST_F(IR_BuilderImplTest, Loop_WithContinuing_BreakIf) {
|
|||
EXPECT_EQ(1u, func->EndTarget()->InboundBranches().Length());
|
||||
|
||||
EXPECT_EQ(Disassemble(m),
|
||||
R"(%1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
R"(%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
%fn1 = block {
|
||||
loop [s: %fn2, c: %fn3, m: %fn4]
|
||||
%fn2 = block {
|
||||
|
@ -547,7 +547,7 @@ TEST_F(IR_BuilderImplTest, Loop_Continuing_Body_Scope) {
|
|||
|
||||
auto m = res.Move();
|
||||
EXPECT_EQ(Disassemble(m),
|
||||
R"(%1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
R"(%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
%fn1 = block {
|
||||
loop [s: %fn2, c: %fn3, m: %fn4]
|
||||
%fn2 = block {
|
||||
|
@ -611,7 +611,7 @@ TEST_F(IR_BuilderImplTest, Loop_WithReturn) {
|
|||
EXPECT_EQ(1u, func->EndTarget()->InboundBranches().Length());
|
||||
|
||||
EXPECT_EQ(Disassemble(m),
|
||||
R"(%1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
R"(%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
%fn1 = block {
|
||||
loop [s: %fn2, c: %fn3]
|
||||
%fn2 = block {
|
||||
|
@ -665,7 +665,7 @@ TEST_F(IR_BuilderImplTest, Loop_WithOnlyReturn) {
|
|||
EXPECT_EQ(1u, func->EndTarget()->InboundBranches().Length());
|
||||
|
||||
EXPECT_EQ(Disassemble(m),
|
||||
R"(%1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
R"(%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
%fn1 = block {
|
||||
loop [s: %fn2, c: %fn3]
|
||||
%fn2 = block {
|
||||
|
@ -712,7 +712,7 @@ TEST_F(IR_BuilderImplTest, Loop_WithOnlyReturn_ContinuingBreakIf) {
|
|||
EXPECT_EQ(3u, func->EndTarget()->InboundBranches().Length());
|
||||
|
||||
EXPECT_EQ(Disassemble(m),
|
||||
R"(%1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
R"(%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
%fn1 = block {
|
||||
loop [s: %fn2, c: %fn3, m: %fn4]
|
||||
%fn2 = block {
|
||||
|
@ -790,7 +790,7 @@ TEST_F(IR_BuilderImplTest, Loop_WithIf_BothBranchesBreak) {
|
|||
EXPECT_EQ(1u, func->EndTarget()->InboundBranches().Length());
|
||||
|
||||
EXPECT_EQ(Disassemble(m),
|
||||
R"(%1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
R"(%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
%fn1 = block {
|
||||
loop [s: %fn2, c: %fn3, m: %fn4]
|
||||
%fn2 = block {
|
||||
|
@ -843,7 +843,7 @@ TEST_F(IR_BuilderImplTest, Loop_Nested) {
|
|||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()),
|
||||
R"(%1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
R"(%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
%fn1 = block {
|
||||
loop [s: %fn2, c: %fn3, m: %fn4]
|
||||
%fn2 = block {
|
||||
|
@ -1002,7 +1002,7 @@ TEST_F(IR_BuilderImplTest, While) {
|
|||
EXPECT_EQ(2u, if_flow->Merge()->InboundBranches().Length());
|
||||
|
||||
EXPECT_EQ(Disassemble(m),
|
||||
R"(%1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
R"(%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
%fn1 = block {
|
||||
loop [s: %fn2, c: %fn3, m: %fn4]
|
||||
%fn2 = block {
|
||||
|
@ -1068,7 +1068,7 @@ TEST_F(IR_BuilderImplTest, While_Return) {
|
|||
EXPECT_EQ(2u, if_flow->Merge()->InboundBranches().Length());
|
||||
|
||||
EXPECT_EQ(Disassemble(m),
|
||||
R"(%1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
R"(%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
%fn1 = block {
|
||||
loop [s: %fn2, c: %fn3, m: %fn4]
|
||||
%fn2 = block {
|
||||
|
@ -1167,7 +1167,7 @@ TEST_F(IR_BuilderImplTest, For_NoInitCondOrContinuing) {
|
|||
EXPECT_EQ(1u, func->EndTarget()->InboundBranches().Length());
|
||||
|
||||
EXPECT_EQ(Disassemble(m),
|
||||
R"(%1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
R"(%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
%fn1 = block {
|
||||
loop [s: %fn2, c: %fn3, m: %fn4]
|
||||
%fn2 = block {
|
||||
|
@ -1230,7 +1230,7 @@ TEST_F(IR_BuilderImplTest, Switch) {
|
|||
EXPECT_EQ(1u, func->EndTarget()->InboundBranches().Length());
|
||||
|
||||
EXPECT_EQ(Disassemble(m),
|
||||
R"(%1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
R"(%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
%fn1 = block {
|
||||
switch 1i [c: (0i, %fn2), c: (1i, %fn3), c: (default, %fn4), m: %fn5]
|
||||
# Case block
|
||||
|
@ -1295,7 +1295,7 @@ TEST_F(IR_BuilderImplTest, Switch_MultiSelector) {
|
|||
EXPECT_EQ(1u, func->EndTarget()->InboundBranches().Length());
|
||||
|
||||
EXPECT_EQ(Disassemble(m),
|
||||
R"(%1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
R"(%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
%fn1 = block {
|
||||
switch 1i [c: (0i 1i default, %fn2), m: %fn3]
|
||||
# Case block
|
||||
|
@ -1338,7 +1338,7 @@ TEST_F(IR_BuilderImplTest, Switch_OnlyDefault) {
|
|||
EXPECT_EQ(1u, func->EndTarget()->InboundBranches().Length());
|
||||
|
||||
EXPECT_EQ(Disassemble(m),
|
||||
R"(%1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
R"(%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
%fn1 = block {
|
||||
switch 1i [c: (default, %fn2), m: %fn3]
|
||||
# Case block
|
||||
|
@ -1390,7 +1390,7 @@ TEST_F(IR_BuilderImplTest, Switch_WithBreak) {
|
|||
EXPECT_EQ(1u, func->EndTarget()->InboundBranches().Length());
|
||||
|
||||
EXPECT_EQ(Disassemble(m),
|
||||
R"(%1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
R"(%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
%fn1 = block {
|
||||
switch 1i [c: (0i, %fn2), c: (default, %fn3), m: %fn4]
|
||||
# Case block
|
||||
|
@ -1449,7 +1449,7 @@ TEST_F(IR_BuilderImplTest, Switch_AllReturn) {
|
|||
EXPECT_EQ(2u, func->EndTarget()->InboundBranches().Length());
|
||||
|
||||
EXPECT_EQ(Disassemble(m),
|
||||
R"(%1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
R"(%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
%fn1 = block {
|
||||
switch 1i [c: (0i, %fn2), c: (default, %fn3)]
|
||||
# Case block
|
||||
|
@ -1476,15 +1476,15 @@ TEST_F(IR_BuilderImplTest, Emit_Phony) {
|
|||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()),
|
||||
R"(%1 = func b():i32 -> %fn1 {
|
||||
R"(%b = func():i32 -> %fn1 {
|
||||
%fn1 = block {
|
||||
br %fn2 1i # return
|
||||
}
|
||||
%fn2 = func_terminator
|
||||
}
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:i32 = call b
|
||||
%3:i32 = call %b
|
||||
br %fn4 # return
|
||||
}
|
||||
%fn4 = func_terminator
|
||||
|
|
|
@ -34,15 +34,15 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Unary_Not) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%1 = func my_func():bool -> %fn1 {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%my_func = func():bool -> %fn1 {
|
||||
%fn1 = block {
|
||||
br %fn2 false # return
|
||||
}
|
||||
%fn2 = func_terminator
|
||||
}
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:bool = call my_func
|
||||
%3:bool = call %my_func
|
||||
%tint_symbol:bool = eq %3, false
|
||||
br %fn4 # return
|
||||
}
|
||||
|
@ -59,15 +59,15 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Unary_Complement) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%1 = func my_func():u32 -> %fn1 {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%my_func = func():u32 -> %fn1 {
|
||||
%fn1 = block {
|
||||
br %fn2 1u # return
|
||||
}
|
||||
%fn2 = func_terminator
|
||||
}
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:u32 = call my_func
|
||||
%3:u32 = call %my_func
|
||||
%tint_symbol:u32 = complement %3
|
||||
br %fn4 # return
|
||||
}
|
||||
|
@ -84,15 +84,15 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Unary_Negation) {
|
|||
auto m = Build();
|
||||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%1 = func my_func():i32 -> %fn1 {
|
||||
EXPECT_EQ(Disassemble(m.Get()), R"(%my_func = func():i32 -> %fn1 {
|
||||
%fn1 = block {
|
||||
br %fn2 1i # return
|
||||
}
|
||||
%fn2 = func_terminator
|
||||
}
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
%3:i32 = call my_func
|
||||
%3:i32 = call %my_func
|
||||
%tint_symbol:i32 = negation %3
|
||||
br %fn4 # return
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Unary_AddressOf) {
|
|||
|
||||
%fn2 = root_terminator
|
||||
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
br %fn4 # return
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Unary_Indirection) {
|
|||
|
||||
%fn2 = root_terminator
|
||||
|
||||
%2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
|
||||
%fn3 = block {
|
||||
store %v3, 42i
|
||||
br %fn4 # return
|
||||
|
|
|
@ -69,7 +69,7 @@ TEST_F(IR_BuilderImplTest, Emit_Var_NoInit) {
|
|||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()),
|
||||
R"(%1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
R"(%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
%fn1 = block {
|
||||
%a:ptr<function, u32, read_write> = var
|
||||
br %fn2 # return
|
||||
|
@ -88,7 +88,7 @@ TEST_F(IR_BuilderImplTest, Emit_Var_Init) {
|
|||
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
||||
|
||||
EXPECT_EQ(Disassemble(m.Get()),
|
||||
R"(%1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
R"(%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
%fn1 = block {
|
||||
%a:ptr<function, u32, read_write> = var, 2u
|
||||
br %fn2 # return
|
||||
|
|
|
@ -18,11 +18,10 @@ TINT_INSTANTIATE_TYPEINFO(tint::ir::Function);
|
|||
|
||||
namespace tint::ir {
|
||||
|
||||
Function::Function(Symbol name,
|
||||
const type::Type* rt,
|
||||
Function::Function(const type::Type* rt,
|
||||
PipelineStage stage,
|
||||
std::optional<std::array<uint32_t, 3>> wg_size)
|
||||
: Base(), name_(name), return_type_(rt), pipeline_stage_(stage), workgroup_size_(wg_size) {}
|
||||
: Base(), return_type_(rt), pipeline_stage_(stage), workgroup_size_(wg_size) {}
|
||||
|
||||
Function::~Function() = default;
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
#include "src/tint/ir/function_param.h"
|
||||
#include "src/tint/ir/value.h"
|
||||
#include "src/tint/symbol.h"
|
||||
#include "src/tint/type/type.h"
|
||||
|
||||
// Forward declarations
|
||||
|
@ -64,19 +63,14 @@ class Function : public utils::Castable<Function, Value> {
|
|||
};
|
||||
|
||||
/// Constructor
|
||||
/// @param n the function name
|
||||
/// @param rt the function return type
|
||||
/// @param stage the function stage
|
||||
/// @param wg_size the workgroup_size
|
||||
Function(Symbol n,
|
||||
const type::Type* rt,
|
||||
Function(const type::Type* rt,
|
||||
PipelineStage stage = PipelineStage::kUndefined,
|
||||
std::optional<std::array<uint32_t, 3>> wg_size = {});
|
||||
~Function() override;
|
||||
|
||||
/// @returns the function name
|
||||
Symbol Name() const { return name_; }
|
||||
|
||||
/// Sets the function stage
|
||||
/// @param stage the stage to set
|
||||
void SetStage(PipelineStage stage) { pipeline_stage_ = stage; }
|
||||
|
@ -130,7 +124,6 @@ class Function : public utils::Castable<Function, Value> {
|
|||
FunctionTerminator* EndTarget() const { return end_target_; }
|
||||
|
||||
private:
|
||||
Symbol name_;
|
||||
const type::Type* return_type_;
|
||||
PipelineStage pipeline_stage_;
|
||||
std::optional<std::array<uint32_t, 3>> workgroup_size_;
|
||||
|
|
|
@ -91,7 +91,7 @@ class State {
|
|||
const ast::Function* Fn(const Function* fn) {
|
||||
SCOPED_NESTING();
|
||||
|
||||
auto name = Sym(fn->Name());
|
||||
auto name = NameOf(fn);
|
||||
// TODO(crbug.com/tint/1915): Properly implement this when we've fleshed out Function
|
||||
utils::Vector<const ast::Parameter*, 1> params{};
|
||||
auto ret_ty = Type(fn->ReturnType());
|
||||
|
@ -349,7 +349,7 @@ class State {
|
|||
}
|
||||
return tint::Switch(
|
||||
call, //
|
||||
[&](const ir::UserCall* c) { return b.Call(Sym(c->Name()), std::move(args)); },
|
||||
[&](const ir::UserCall* c) { return b.Call(NameOf(c->Func()), std::move(args)); },
|
||||
[&](Default) {
|
||||
UNHANDLED_CASE(call);
|
||||
return nullptr;
|
||||
|
@ -497,8 +497,6 @@ class State {
|
|||
});
|
||||
}
|
||||
|
||||
Symbol Sym(const Symbol& s) { return b.Symbols().Register(s.NameView()); }
|
||||
|
||||
void Err(std::string str) { b.Diagnostics().add_error(diag::System::IR, std::move(str)); }
|
||||
};
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ void AddEmptyEntryPoint::Run(ir::Module* ir, const DataMap&, DataMap&) const {
|
|||
}
|
||||
|
||||
ir::Builder builder(*ir);
|
||||
auto* ep = builder.CreateFunction(ir->symbols.New("unused_entry_point"), ir->Types().void_(),
|
||||
auto* ep = builder.CreateFunction("unused_entry_point", ir->Types().void_(),
|
||||
Function::PipelineStage::kCompute, std::array{1u, 1u, 1u});
|
||||
ep->StartTarget()->SetInstructions(utils::Vector{builder.Branch(ep->EndTarget())});
|
||||
ir->functions.Push(ep);
|
||||
|
|
|
@ -25,7 +25,7 @@ using IR_AddEmptyEntryPointTest = TransformTest;
|
|||
|
||||
TEST_F(IR_AddEmptyEntryPointTest, EmptyModule) {
|
||||
auto* expect = R"(
|
||||
%1 = func unused_entry_point():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
%unused_entry_point = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn1 {
|
||||
%fn1 = block {
|
||||
br %fn2 # return
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ TEST_F(IR_AddEmptyEntryPointTest, ExistingEntryPoint) {
|
|||
mod.functions.Push(ep);
|
||||
|
||||
auto* expect = R"(
|
||||
%1 = func main():void [@fragment] -> %fn1 {
|
||||
%main = func():void [@fragment] -> %fn1 {
|
||||
%fn1 = block {
|
||||
br %fn2 # return
|
||||
}
|
||||
|
|
|
@ -22,8 +22,10 @@ TINT_INSTANTIATE_TYPEINFO(tint::ir::UserCall);
|
|||
|
||||
namespace tint::ir {
|
||||
|
||||
UserCall::UserCall(const type::Type* ty, Symbol n, utils::VectorRef<Value*> arguments)
|
||||
: Base(ty, std::move(arguments)), name_(n) {}
|
||||
UserCall::UserCall(const type::Type* ty, Function* func, utils::VectorRef<Value*> arguments)
|
||||
: Base(ty, std::move(arguments)), func_(func) {
|
||||
func->AddUsage(this);
|
||||
}
|
||||
|
||||
UserCall::~UserCall() = default;
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#define SRC_TINT_IR_USER_CALL_H_
|
||||
|
||||
#include "src/tint/ir/call.h"
|
||||
#include "src/tint/symbol.h"
|
||||
#include "src/tint/ir/function.h"
|
||||
#include "src/tint/utils/castable.h"
|
||||
|
||||
namespace tint::ir {
|
||||
|
@ -26,16 +26,16 @@ class UserCall : public utils::Castable<UserCall, Call> {
|
|||
public:
|
||||
/// Constructor
|
||||
/// @param type the result type
|
||||
/// @param name the function name
|
||||
/// @param func the function being called
|
||||
/// @param args the function arguments
|
||||
UserCall(const type::Type* type, Symbol name, utils::VectorRef<Value*> args);
|
||||
UserCall(const type::Type* type, Function* func, utils::VectorRef<Value*> args);
|
||||
~UserCall() override;
|
||||
|
||||
/// @returns the called function name
|
||||
Symbol Name() const { return name_; }
|
||||
const Function* Func() const { return func_; }
|
||||
|
||||
private:
|
||||
Symbol name_;
|
||||
const Function* func_ = nullptr;
|
||||
};
|
||||
|
||||
} // namespace tint::ir
|
||||
|
|
|
@ -50,8 +50,7 @@ class AST_AddFunction final : public ast::transform::Transform {
|
|||
class IR_AddFunction final : public ir::transform::Transform {
|
||||
void Run(ir::Module* mod, const DataMap&, DataMap&) const override {
|
||||
ir::Builder builder(*mod);
|
||||
auto* func =
|
||||
builder.CreateFunction(mod->symbols.New("ir_func"), mod->Types().Get<type::Void>());
|
||||
auto* func = builder.CreateFunction("ir_func", mod->Types().Get<type::Void>());
|
||||
func->StartTarget()->SetInstructions(utils::Vector{builder.Branch(func->EndTarget())});
|
||||
mod->functions.Push(func);
|
||||
}
|
||||
|
@ -68,8 +67,7 @@ Program MakeAST() {
|
|||
ir::Module MakeIR() {
|
||||
ir::Module mod;
|
||||
ir::Builder builder(mod);
|
||||
auto* func =
|
||||
builder.CreateFunction(builder.ir.symbols.New("main"), mod.Types().Get<type::Void>());
|
||||
auto* func = builder.CreateFunction("main", mod.Types().Get<type::Void>());
|
||||
func->StartTarget()->SetInstructions(utils::Vector{builder.Branch(func->EndTarget())});
|
||||
builder.ir.functions.Push(func);
|
||||
return mod;
|
||||
|
@ -104,8 +102,8 @@ TEST_F(TransformManagerTest, IR_MutateInPlace) {
|
|||
manager.Run(&ir, {}, outputs);
|
||||
|
||||
ASSERT_EQ(ir.functions.Length(), 2u);
|
||||
EXPECT_EQ(ir.functions[0]->Name().Name(), "main");
|
||||
EXPECT_EQ(ir.functions[1]->Name().Name(), "ir_func");
|
||||
EXPECT_EQ(ir.NameOf(ir.functions[0]).Name(), "main");
|
||||
EXPECT_EQ(ir.NameOf(ir.functions[1]).Name(), "ir_func");
|
||||
}
|
||||
|
||||
TEST_F(TransformManagerTest, AST_MixedTransforms_AST_Before_IR) {
|
||||
|
@ -150,9 +148,9 @@ TEST_F(TransformManagerTest, IR_MixedTransforms_AST_Before_IR) {
|
|||
|
||||
manager.Run(&ir, {}, outputs);
|
||||
ASSERT_EQ(ir.functions.Length(), 3u);
|
||||
EXPECT_EQ(ir.functions[0]->Name().Name(), "ast_func");
|
||||
EXPECT_EQ(ir.functions[1]->Name().Name(), "main");
|
||||
EXPECT_EQ(ir.functions[2]->Name().Name(), "ir_func");
|
||||
EXPECT_EQ(ir.NameOf(ir.functions[0]).Name(), "ast_func");
|
||||
EXPECT_EQ(ir.NameOf(ir.functions[1]).Name(), "main");
|
||||
EXPECT_EQ(ir.NameOf(ir.functions[2]).Name(), "ir_func");
|
||||
}
|
||||
|
||||
TEST_F(TransformManagerTest, IR_MixedTransforms_IR_Before_AST) {
|
||||
|
@ -165,9 +163,9 @@ TEST_F(TransformManagerTest, IR_MixedTransforms_IR_Before_AST) {
|
|||
|
||||
manager.Run(&ir, {}, outputs);
|
||||
ASSERT_EQ(ir.functions.Length(), 3u);
|
||||
EXPECT_EQ(ir.functions[0]->Name().Name(), "ast_func");
|
||||
EXPECT_EQ(ir.functions[1]->Name().Name(), "main");
|
||||
EXPECT_EQ(ir.functions[2]->Name().Name(), "ir_func");
|
||||
EXPECT_EQ(ir.NameOf(ir.functions[0]).Name(), "ast_func");
|
||||
EXPECT_EQ(ir.NameOf(ir.functions[1]).Name(), "main");
|
||||
EXPECT_EQ(ir.NameOf(ir.functions[2]).Name(), "ir_func");
|
||||
}
|
||||
#endif // TINT_BUILD_IR
|
||||
|
||||
|
|
|
@ -223,10 +223,10 @@ uint32_t GeneratorImplIr::Label(const ir::Block* block) {
|
|||
void GeneratorImplIr::EmitFunction(const ir::Function* func) {
|
||||
// Make an ID for the function.
|
||||
auto id = module_.NextId();
|
||||
functions_.Add(func->Name(), id);
|
||||
values_.Add(func, id);
|
||||
|
||||
// Emit the function name.
|
||||
module_.PushDebug(spv::Op::OpName, {id, Operand(func->Name().Name())});
|
||||
module_.PushDebug(spv::Op::OpName, {id, Operand(ir_->NameOf(func).Name())});
|
||||
|
||||
// Emit OpEntryPoint and OpExecutionMode declarations if needed.
|
||||
if (func->Stage() != ir::Function::PipelineStage::kUndefined) {
|
||||
|
@ -306,7 +306,8 @@ void GeneratorImplIr::EmitEntryPoint(const ir::Function* func, uint32_t id) {
|
|||
}
|
||||
|
||||
// TODO(jrprice): Add the interface list of all referenced global variables.
|
||||
module_.PushEntryPoint(spv::Op::OpEntryPoint, {U32Operand(stage), id, func->Name().Name()});
|
||||
module_.PushEntryPoint(spv::Op::OpEntryPoint,
|
||||
{U32Operand(stage), id, ir_->NameOf(func).Name()});
|
||||
}
|
||||
|
||||
void GeneratorImplIr::EmitBlock(const ir::Block* block) {
|
||||
|
@ -525,7 +526,7 @@ void GeneratorImplIr::EmitStore(const ir::Store* store) {
|
|||
|
||||
uint32_t GeneratorImplIr::EmitUserCall(const ir::UserCall* call) {
|
||||
auto id = module_.NextId();
|
||||
OperandList operands = {Type(call->Type()), id, functions_.Get(call->Name()).value()};
|
||||
OperandList operands = {Type(call->Type()), id, values_.Get(call->Func()).value()};
|
||||
for (auto* arg : call->Args()) {
|
||||
operands.push_back(Value(arg));
|
||||
}
|
||||
|
|
|
@ -178,10 +178,6 @@ class GeneratorImplIr {
|
|||
/// The map of constants to their result IDs.
|
||||
utils::Hashmap<const constant::Value*, uint32_t, 16> constants_;
|
||||
|
||||
/// The map of functions to their result IDs.
|
||||
/// TODO(jrprice): Merge into `values_` map when `ir::Function` becomes an `ir::Value`.
|
||||
utils::Hashmap<Symbol, uint32_t, 8> functions_;
|
||||
|
||||
/// The map of non-constant values to their result IDs.
|
||||
utils::Hashmap<const ir::Value*, uint32_t, 8> values_;
|
||||
|
||||
|
|
|
@ -196,9 +196,8 @@ TEST_F(SpvGeneratorImplTest, Function_Call) {
|
|||
utils::Vector{result, b.Branch(foo->EndTarget(), utils::Vector{result})});
|
||||
|
||||
auto* bar = b.CreateFunction("bar", mod.Types().void_());
|
||||
bar->StartTarget()->SetInstructions(
|
||||
utils::Vector{b.UserCall(i32_ty, mod.symbols.Get("foo"),
|
||||
utils::Vector{b.Constant(i32(2)), b.Constant(i32(3))}),
|
||||
bar->StartTarget()->SetInstructions(utils::Vector{
|
||||
b.UserCall(i32_ty, foo, utils::Vector{b.Constant(i32(2)), b.Constant(i32(3))}),
|
||||
b.Branch(bar->EndTarget())});
|
||||
|
||||
generator_.EmitFunction(foo);
|
||||
|
@ -231,9 +230,8 @@ TEST_F(SpvGeneratorImplTest, Function_Call_Void) {
|
|||
foo->StartTarget()->SetInstructions(utils::Vector{b.Branch(foo->EndTarget())});
|
||||
|
||||
auto* bar = b.CreateFunction("bar", mod.Types().void_());
|
||||
bar->StartTarget()->SetInstructions(
|
||||
utils::Vector{b.UserCall(mod.Types().void_(), mod.symbols.Get("foo"), utils::Empty),
|
||||
b.Branch(bar->EndTarget())});
|
||||
bar->StartTarget()->SetInstructions(utils::Vector{
|
||||
b.UserCall(mod.Types().void_(), foo, utils::Empty), b.Branch(bar->EndTarget())});
|
||||
|
||||
generator_.EmitFunction(foo);
|
||||
generator_.EmitFunction(bar);
|
||||
|
|
Loading…
Reference in New Issue