[tint][ir] Make the ir::BuilderImpl PIMPL
Black-box the BuilderImpl by putting the BuilderImpl into the from_program.cc file. Why: * It means there's only a single definition of all the methods that need to be maintained, instead of pointlessly splitting code between two files (.cc / .h). * It removes all the implementation details from the header. * It removes a whole bunch of transitive includes, slowing compiles. * It prevents the temptation for future #includes to private-implementation details. * It reduces the amount of symbols declared outside of anonymous namespaces, reducing symbol polution and the amount of work on the linker. Bug: tint:1718 Change-Id: I82838089f784ab003dae4ef06545bba1ca2401cc Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/132321 Commit-Queue: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
c9dd75a0e9
commit
8d98977a30
|
@ -1121,8 +1121,6 @@ libtint_source_set("libtint_syntax_tree_writer_src") {
|
|||
|
||||
libtint_source_set("libtint_ir_builder_src") {
|
||||
sources = [
|
||||
"ir/builder_impl.cc",
|
||||
"ir/builder_impl.h",
|
||||
"ir/from_program.cc",
|
||||
"ir/from_program.h",
|
||||
]
|
||||
|
@ -2151,16 +2149,16 @@ if (tint_build_unittests) {
|
|||
sources = [
|
||||
"ir/binary_test.cc",
|
||||
"ir/bitcast_test.cc",
|
||||
"ir/builder_impl_binary_test.cc",
|
||||
"ir/builder_impl_call_test.cc",
|
||||
"ir/builder_impl_literal_test.cc",
|
||||
"ir/builder_impl_materialize_test.cc",
|
||||
"ir/builder_impl_store_test.cc",
|
||||
"ir/builder_impl_test.cc",
|
||||
"ir/builder_impl_unary_test.cc",
|
||||
"ir/builder_impl_var_test.cc",
|
||||
"ir/constant_test.cc",
|
||||
"ir/discard_test.cc",
|
||||
"ir/from_program_binary_test.cc",
|
||||
"ir/from_program_call_test.cc",
|
||||
"ir/from_program_literal_test.cc",
|
||||
"ir/from_program_materialize_test.cc",
|
||||
"ir/from_program_store_test.cc",
|
||||
"ir/from_program_test.cc",
|
||||
"ir/from_program_unary_test.cc",
|
||||
"ir/from_program_var_test.cc",
|
||||
"ir/module_test.cc",
|
||||
"ir/store_test.cc",
|
||||
"ir/test_helper.h",
|
||||
|
|
|
@ -716,8 +716,6 @@ if(${TINT_BUILD_IR})
|
|||
ir/block.h
|
||||
ir/builder.cc
|
||||
ir/builder.h
|
||||
ir/builder_impl.cc
|
||||
ir/builder_impl.h
|
||||
ir/builtin.cc
|
||||
ir/builtin.h
|
||||
ir/call.cc
|
||||
|
@ -1447,16 +1445,16 @@ if(TINT_BUILD_TESTS)
|
|||
list(APPEND TINT_TEST_SRCS
|
||||
ir/binary_test.cc
|
||||
ir/bitcast_test.cc
|
||||
ir/builder_impl_binary_test.cc
|
||||
ir/builder_impl_call_test.cc
|
||||
ir/builder_impl_literal_test.cc
|
||||
ir/builder_impl_materialize_test.cc
|
||||
ir/builder_impl_store_test.cc
|
||||
ir/builder_impl_test.cc
|
||||
ir/builder_impl_unary_test.cc
|
||||
ir/builder_impl_var_test.cc
|
||||
ir/constant_test.cc
|
||||
ir/discard_test.cc
|
||||
ir/from_program_binary_test.cc
|
||||
ir/from_program_call_test.cc
|
||||
ir/from_program_literal_test.cc
|
||||
ir/from_program_materialize_test.cc
|
||||
ir/from_program_store_test.cc
|
||||
ir/from_program_test.cc
|
||||
ir/from_program_unary_test.cc
|
||||
ir/from_program_var_test.cc
|
||||
ir/module_test.cc
|
||||
ir/store_test.cc
|
||||
ir/test_helper.h
|
||||
|
|
|
@ -24,7 +24,8 @@ using namespace tint::number_suffixes; // NOLINT
|
|||
using IR_InstructionTest = TestHelper;
|
||||
|
||||
TEST_F(IR_InstructionTest, CreateAnd) {
|
||||
Builder b;
|
||||
Module mod;
|
||||
Builder b{mod};
|
||||
|
||||
const auto* inst = b.And(b.ir.types.Get<type::I32>(), b.Constant(4_i), b.Constant(2_i));
|
||||
|
||||
|
@ -45,7 +46,8 @@ TEST_F(IR_InstructionTest, CreateAnd) {
|
|||
}
|
||||
|
||||
TEST_F(IR_InstructionTest, CreateOr) {
|
||||
Builder b;
|
||||
Module mod;
|
||||
Builder b{mod};
|
||||
|
||||
const auto* inst = b.Or(b.ir.types.Get<type::I32>(), b.Constant(4_i), b.Constant(2_i));
|
||||
|
||||
|
@ -64,7 +66,8 @@ TEST_F(IR_InstructionTest, CreateOr) {
|
|||
}
|
||||
|
||||
TEST_F(IR_InstructionTest, CreateXor) {
|
||||
Builder b;
|
||||
Module mod;
|
||||
Builder b{mod};
|
||||
|
||||
const auto* inst = b.Xor(b.ir.types.Get<type::I32>(), b.Constant(4_i), b.Constant(2_i));
|
||||
|
||||
|
@ -83,7 +86,8 @@ TEST_F(IR_InstructionTest, CreateXor) {
|
|||
}
|
||||
|
||||
TEST_F(IR_InstructionTest, CreateEqual) {
|
||||
Builder b;
|
||||
Module mod;
|
||||
Builder b{mod};
|
||||
|
||||
const auto* inst = b.Equal(b.ir.types.Get<type::Bool>(), b.Constant(4_i), b.Constant(2_i));
|
||||
|
||||
|
@ -102,7 +106,8 @@ TEST_F(IR_InstructionTest, CreateEqual) {
|
|||
}
|
||||
|
||||
TEST_F(IR_InstructionTest, CreateNotEqual) {
|
||||
Builder b;
|
||||
Module mod;
|
||||
Builder b{mod};
|
||||
|
||||
const auto* inst = b.NotEqual(b.ir.types.Get<type::Bool>(), b.Constant(4_i), b.Constant(2_i));
|
||||
|
||||
|
@ -121,7 +126,8 @@ TEST_F(IR_InstructionTest, CreateNotEqual) {
|
|||
}
|
||||
|
||||
TEST_F(IR_InstructionTest, CreateLessThan) {
|
||||
Builder b;
|
||||
Module mod;
|
||||
Builder b{mod};
|
||||
|
||||
const auto* inst = b.LessThan(b.ir.types.Get<type::Bool>(), b.Constant(4_i), b.Constant(2_i));
|
||||
|
||||
|
@ -140,7 +146,8 @@ TEST_F(IR_InstructionTest, CreateLessThan) {
|
|||
}
|
||||
|
||||
TEST_F(IR_InstructionTest, CreateGreaterThan) {
|
||||
Builder b;
|
||||
Module mod;
|
||||
Builder b{mod};
|
||||
|
||||
const auto* inst =
|
||||
b.GreaterThan(b.ir.types.Get<type::Bool>(), b.Constant(4_i), b.Constant(2_i));
|
||||
|
@ -160,7 +167,8 @@ TEST_F(IR_InstructionTest, CreateGreaterThan) {
|
|||
}
|
||||
|
||||
TEST_F(IR_InstructionTest, CreateLessThanEqual) {
|
||||
Builder b;
|
||||
Module mod;
|
||||
Builder b{mod};
|
||||
|
||||
const auto* inst =
|
||||
b.LessThanEqual(b.ir.types.Get<type::Bool>(), b.Constant(4_i), b.Constant(2_i));
|
||||
|
@ -180,7 +188,8 @@ TEST_F(IR_InstructionTest, CreateLessThanEqual) {
|
|||
}
|
||||
|
||||
TEST_F(IR_InstructionTest, CreateGreaterThanEqual) {
|
||||
Builder b;
|
||||
Module mod;
|
||||
Builder b{mod};
|
||||
|
||||
const auto* inst =
|
||||
b.GreaterThanEqual(b.ir.types.Get<type::Bool>(), b.Constant(4_i), b.Constant(2_i));
|
||||
|
@ -200,7 +209,8 @@ TEST_F(IR_InstructionTest, CreateGreaterThanEqual) {
|
|||
}
|
||||
|
||||
TEST_F(IR_InstructionTest, CreateNot) {
|
||||
Builder b;
|
||||
Module mod;
|
||||
Builder b{mod};
|
||||
const auto* inst = b.Not(b.ir.types.Get<type::Bool>(), b.Constant(true));
|
||||
|
||||
ASSERT_TRUE(inst->Is<Binary>());
|
||||
|
@ -218,7 +228,8 @@ TEST_F(IR_InstructionTest, CreateNot) {
|
|||
}
|
||||
|
||||
TEST_F(IR_InstructionTest, CreateShiftLeft) {
|
||||
Builder b;
|
||||
Module mod;
|
||||
Builder b{mod};
|
||||
|
||||
const auto* inst = b.ShiftLeft(b.ir.types.Get<type::I32>(), b.Constant(4_i), b.Constant(2_i));
|
||||
|
||||
|
@ -237,7 +248,8 @@ TEST_F(IR_InstructionTest, CreateShiftLeft) {
|
|||
}
|
||||
|
||||
TEST_F(IR_InstructionTest, CreateShiftRight) {
|
||||
Builder b;
|
||||
Module mod;
|
||||
Builder b{mod};
|
||||
|
||||
const auto* inst = b.ShiftRight(b.ir.types.Get<type::I32>(), b.Constant(4_i), b.Constant(2_i));
|
||||
|
||||
|
@ -256,7 +268,8 @@ TEST_F(IR_InstructionTest, CreateShiftRight) {
|
|||
}
|
||||
|
||||
TEST_F(IR_InstructionTest, CreateAdd) {
|
||||
Builder b;
|
||||
Module mod;
|
||||
Builder b{mod};
|
||||
|
||||
const auto* inst = b.Add(b.ir.types.Get<type::I32>(), b.Constant(4_i), b.Constant(2_i));
|
||||
|
||||
|
@ -275,7 +288,8 @@ TEST_F(IR_InstructionTest, CreateAdd) {
|
|||
}
|
||||
|
||||
TEST_F(IR_InstructionTest, CreateSubtract) {
|
||||
Builder b;
|
||||
Module mod;
|
||||
Builder b{mod};
|
||||
|
||||
const auto* inst = b.Subtract(b.ir.types.Get<type::I32>(), b.Constant(4_i), b.Constant(2_i));
|
||||
|
||||
|
@ -294,7 +308,8 @@ TEST_F(IR_InstructionTest, CreateSubtract) {
|
|||
}
|
||||
|
||||
TEST_F(IR_InstructionTest, CreateMultiply) {
|
||||
Builder b;
|
||||
Module mod;
|
||||
Builder b{mod};
|
||||
|
||||
const auto* inst = b.Multiply(b.ir.types.Get<type::I32>(), b.Constant(4_i), b.Constant(2_i));
|
||||
|
||||
|
@ -313,7 +328,8 @@ TEST_F(IR_InstructionTest, CreateMultiply) {
|
|||
}
|
||||
|
||||
TEST_F(IR_InstructionTest, CreateDivide) {
|
||||
Builder b;
|
||||
Module mod;
|
||||
Builder b{mod};
|
||||
|
||||
const auto* inst = b.Divide(b.ir.types.Get<type::I32>(), b.Constant(4_i), b.Constant(2_i));
|
||||
|
||||
|
@ -332,7 +348,8 @@ TEST_F(IR_InstructionTest, CreateDivide) {
|
|||
}
|
||||
|
||||
TEST_F(IR_InstructionTest, CreateModulo) {
|
||||
Builder b;
|
||||
Module mod;
|
||||
Builder b{mod};
|
||||
|
||||
const auto* inst = b.Modulo(b.ir.types.Get<type::I32>(), b.Constant(4_i), b.Constant(2_i));
|
||||
|
||||
|
@ -351,7 +368,8 @@ TEST_F(IR_InstructionTest, CreateModulo) {
|
|||
}
|
||||
|
||||
TEST_F(IR_InstructionTest, Binary_Usage) {
|
||||
Builder b;
|
||||
Module mod;
|
||||
Builder b{mod};
|
||||
const auto* inst = b.And(b.ir.types.Get<type::I32>(), b.Constant(4_i), b.Constant(2_i));
|
||||
|
||||
EXPECT_EQ(inst->kind, Binary::Kind::kAnd);
|
||||
|
@ -366,7 +384,8 @@ TEST_F(IR_InstructionTest, Binary_Usage) {
|
|||
}
|
||||
|
||||
TEST_F(IR_InstructionTest, Binary_Usage_DuplicateValue) {
|
||||
Builder b;
|
||||
Module mod;
|
||||
Builder b{mod};
|
||||
auto val = b.Constant(4_i);
|
||||
const auto* inst = b.And(b.ir.types.Get<type::I32>(), val, val);
|
||||
|
||||
|
|
|
@ -25,7 +25,8 @@ using namespace tint::number_suffixes; // NOLINT
|
|||
using IR_InstructionTest = TestHelper;
|
||||
|
||||
TEST_F(IR_InstructionTest, Bitcast) {
|
||||
Builder b;
|
||||
Module mod;
|
||||
Builder b{mod};
|
||||
const auto* inst = b.Bitcast(b.ir.types.Get<type::I32>(), b.Constant(4_i));
|
||||
|
||||
ASSERT_TRUE(inst->Is<ir::Bitcast>());
|
||||
|
@ -39,7 +40,8 @@ TEST_F(IR_InstructionTest, Bitcast) {
|
|||
}
|
||||
|
||||
TEST_F(IR_InstructionTest, Bitcast_Usage) {
|
||||
Builder b;
|
||||
Module mod;
|
||||
Builder b{mod};
|
||||
const auto* inst = b.Bitcast(b.ir.types.Get<type::I32>(), b.Constant(4_i));
|
||||
|
||||
ASSERT_EQ(inst->args.Length(), 1u);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,245 +0,0 @@
|
|||
// Copyright 2022 The Tint Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef SRC_TINT_IR_BUILDER_IMPL_H_
|
||||
#define SRC_TINT_IR_BUILDER_IMPL_H_
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
|
||||
#include "src/tint/ast/type.h"
|
||||
#include "src/tint/constant/clone_context.h"
|
||||
#include "src/tint/diagnostic/diagnostic.h"
|
||||
#include "src/tint/ir/builder.h"
|
||||
#include "src/tint/ir/flow_node.h"
|
||||
#include "src/tint/ir/module.h"
|
||||
#include "src/tint/ir/value.h"
|
||||
#include "src/tint/scope_stack.h"
|
||||
#include "src/tint/utils/result.h"
|
||||
|
||||
// Forward Declarations
|
||||
namespace tint {
|
||||
class Program;
|
||||
} // namespace tint
|
||||
namespace tint::ast {
|
||||
class Attribute;
|
||||
class AssignmentStatement;
|
||||
class BinaryExpression;
|
||||
class BitcastExpression;
|
||||
class BlockStatement;
|
||||
class BreakIfStatement;
|
||||
class BreakStatement;
|
||||
class CallExpression;
|
||||
class CallStatement;
|
||||
class CompoundAssignmentStatement;
|
||||
class ContinueStatement;
|
||||
class DiscardStatement;
|
||||
class Expression;
|
||||
class ForLoopStatement;
|
||||
class Function;
|
||||
class IfStatement;
|
||||
class LoopStatement;
|
||||
class LiteralExpression;
|
||||
class Node;
|
||||
class ReturnStatement;
|
||||
class Statement;
|
||||
class SwitchStatement;
|
||||
class UnaryOpExpression;
|
||||
class WhileStatement;
|
||||
class Variable;
|
||||
} // namespace tint::ast
|
||||
namespace tint::sem {
|
||||
class Builtin;
|
||||
} // namespace tint::sem
|
||||
|
||||
namespace tint::ir {
|
||||
|
||||
/// Builds an ir::Module from a given ast::Program
|
||||
class BuilderImpl {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param program the program to create from
|
||||
explicit BuilderImpl(const Program* program);
|
||||
/// Destructor
|
||||
~BuilderImpl();
|
||||
|
||||
/// Builds an ir::Module from the given Program
|
||||
/// @returns true on success, false otherwise
|
||||
utils::Result<Module> Build();
|
||||
|
||||
/// @returns the diagnostics
|
||||
diag::List Diagnostics() const { return diagnostics_; }
|
||||
|
||||
/// Emits a function to the IR.
|
||||
/// @param func the function to emit
|
||||
void EmitFunction(const ast::Function* func);
|
||||
|
||||
/// Emits a set of statements to the IR.
|
||||
/// @param stmts the statements to emit
|
||||
void EmitStatements(utils::VectorRef<const ast::Statement*> stmts);
|
||||
|
||||
/// Emits a statement to the IR
|
||||
/// @param stmt the statment to emit
|
||||
void EmitStatement(const ast::Statement* stmt);
|
||||
|
||||
/// Emits a block statement to the IR.
|
||||
/// @param block the block to emit
|
||||
void EmitBlock(const ast::BlockStatement* block);
|
||||
|
||||
/// Emits an if control node to the IR.
|
||||
/// @param stmt the if statement
|
||||
void EmitIf(const ast::IfStatement* stmt);
|
||||
|
||||
/// Emits a return node to the IR.
|
||||
/// @param stmt the return AST statement
|
||||
void EmitReturn(const ast::ReturnStatement* stmt);
|
||||
|
||||
/// Emits a loop control node to the IR.
|
||||
/// @param stmt the loop statement
|
||||
void EmitLoop(const ast::LoopStatement* stmt);
|
||||
|
||||
/// Emits a loop control node to the IR.
|
||||
/// @param stmt the while statement
|
||||
void EmitWhile(const ast::WhileStatement* stmt);
|
||||
|
||||
/// Emits a loop control node to the IR.
|
||||
/// @param stmt the for loop statement
|
||||
void EmitForLoop(const ast::ForLoopStatement* stmt);
|
||||
|
||||
/// Emits a switch statement
|
||||
/// @param stmt the switch statement
|
||||
void EmitSwitch(const ast::SwitchStatement* stmt);
|
||||
|
||||
/// Emits a break statement
|
||||
/// @param stmt the break statement
|
||||
void EmitBreak(const ast::BreakStatement* stmt);
|
||||
|
||||
/// Emits a continue statement
|
||||
/// @param stmt the continue statement
|
||||
void EmitContinue(const ast::ContinueStatement* stmt);
|
||||
|
||||
/// Emits a discard statement
|
||||
void EmitDiscard(const ast::DiscardStatement*);
|
||||
|
||||
/// Emits a break-if statement
|
||||
/// @param stmt the break-if statement
|
||||
void EmitBreakIf(const ast::BreakIfStatement* stmt);
|
||||
|
||||
/// Emits an assignment statement
|
||||
/// @param stmt the statement
|
||||
void EmitAssignment(const ast::AssignmentStatement* stmt);
|
||||
|
||||
/// Emits a compound assignment statement
|
||||
/// @param stmt the statement
|
||||
void EmitCompoundAssignment(const ast::CompoundAssignmentStatement* stmt);
|
||||
|
||||
/// Emits an expression
|
||||
/// @param expr the expression to emit
|
||||
/// @returns true if successful, false otherwise
|
||||
utils::Result<Value*> EmitExpression(const ast::Expression* expr);
|
||||
|
||||
/// Emits a variable
|
||||
/// @param var the variable to emit
|
||||
void EmitVariable(const ast::Variable* var);
|
||||
|
||||
/// Emits a Unary expression
|
||||
/// @param expr the unary expression
|
||||
/// @returns the value storing the result if successful, utils::Failure otherwise
|
||||
utils::Result<Value*> EmitUnary(const ast::UnaryOpExpression* expr);
|
||||
|
||||
/// Emits a short-circult binary expression
|
||||
/// @param expr the binary expression
|
||||
/// @returns the value storing the result if successful, utils::Failure otherwise
|
||||
utils::Result<Value*> EmitShortCircuit(const ast::BinaryExpression* expr);
|
||||
|
||||
/// Emits a binary expression
|
||||
/// @param expr the binary expression
|
||||
/// @returns the value storing the result if successful, utils::Failure otherwise
|
||||
utils::Result<Value*> EmitBinary(const ast::BinaryExpression* expr);
|
||||
|
||||
/// Emits a bitcast expression
|
||||
/// @param expr the bitcast expression
|
||||
/// @returns the value storing the result if successful, utils::Failure otherwise
|
||||
utils::Result<Value*> EmitBitcast(const ast::BitcastExpression* expr);
|
||||
|
||||
/// Emits a call expression
|
||||
/// @param stmt the call statement
|
||||
void EmitCall(const ast::CallStatement* stmt);
|
||||
|
||||
/// Emits a call expression
|
||||
/// @param expr the call expression
|
||||
/// @returns the value storing the result if successful, utils::Failure otherwise
|
||||
utils::Result<Value*> EmitCall(const ast::CallExpression* expr);
|
||||
|
||||
/// Emits a literal expression
|
||||
/// @param lit the literal to emit
|
||||
/// @returns true if successful, false otherwise
|
||||
utils::Result<Value*> EmitLiteral(const ast::LiteralExpression* lit);
|
||||
|
||||
/// Emits a set of attributes
|
||||
/// @param attrs the attributes to emit
|
||||
void EmitAttributes(utils::VectorRef<const ast::Attribute*> attrs);
|
||||
|
||||
/// Emits an attribute
|
||||
/// @param attr the attribute to emit
|
||||
void EmitAttribute(const ast::Attribute* attr);
|
||||
|
||||
/// Retrieve the IR Flow node for a given AST node.
|
||||
/// @param n the node to lookup
|
||||
/// @returns the FlowNode for the given ast::Node or nullptr if it doesn't exist.
|
||||
const ir::FlowNode* FlowNodeForAstNode(const ast::Node* n) const {
|
||||
if (ast_to_flow_.count(n) == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
return ast_to_flow_.at(n);
|
||||
}
|
||||
|
||||
/// The stack of flow control blocks.
|
||||
utils::Vector<FlowNode*, 8> flow_stack;
|
||||
|
||||
/// The IR module being built
|
||||
Module mod;
|
||||
/// The IR builder being used by the impl.
|
||||
Builder builder{mod};
|
||||
|
||||
/// The current flow block for expressions
|
||||
Block* current_flow_block = nullptr;
|
||||
|
||||
private:
|
||||
enum class ControlFlags { kNone, kExcludeSwitch };
|
||||
|
||||
void BranchTo(ir::FlowNode* node, utils::VectorRef<Value*> args = {});
|
||||
void BranchToIfNeeded(ir::FlowNode* node);
|
||||
|
||||
FlowNode* FindEnclosingControl(ControlFlags flags);
|
||||
|
||||
void add_error(const Source& s, const std::string& err);
|
||||
|
||||
Symbol CloneSymbol(Symbol sym) const;
|
||||
|
||||
const Program* program_ = nullptr;
|
||||
Function* current_function_ = nullptr;
|
||||
ScopeStack<Symbol, Value*> scopes_;
|
||||
constant::CloneContext clone_ctx_;
|
||||
diag::List diagnostics_;
|
||||
|
||||
/// Map from ast nodes to flow nodes, used to retrieve the flow node for a given AST node.
|
||||
/// Used for testing purposes.
|
||||
std::unordered_map<const ast::Node*, const FlowNode*> ast_to_flow_;
|
||||
};
|
||||
|
||||
} // namespace tint::ir
|
||||
|
||||
#endif // SRC_TINT_IR_BUILDER_IMPL_H_
|
|
@ -24,7 +24,8 @@ using namespace tint::number_suffixes; // NOLINT
|
|||
using IR_ConstantTest = TestHelper;
|
||||
|
||||
TEST_F(IR_ConstantTest, f32) {
|
||||
Builder b;
|
||||
Module mod;
|
||||
Builder b{mod};
|
||||
|
||||
utils::StringStream str;
|
||||
|
||||
|
@ -39,7 +40,8 @@ TEST_F(IR_ConstantTest, f32) {
|
|||
}
|
||||
|
||||
TEST_F(IR_ConstantTest, f16) {
|
||||
Builder b;
|
||||
Module mod;
|
||||
Builder b{mod};
|
||||
|
||||
utils::StringStream str;
|
||||
|
||||
|
@ -54,7 +56,8 @@ TEST_F(IR_ConstantTest, f16) {
|
|||
}
|
||||
|
||||
TEST_F(IR_ConstantTest, i32) {
|
||||
Builder b;
|
||||
Module mod;
|
||||
Builder b{mod};
|
||||
|
||||
utils::StringStream str;
|
||||
|
||||
|
@ -69,7 +72,8 @@ TEST_F(IR_ConstantTest, i32) {
|
|||
}
|
||||
|
||||
TEST_F(IR_ConstantTest, u32) {
|
||||
Builder b;
|
||||
Module mod;
|
||||
Builder b{mod};
|
||||
|
||||
utils::StringStream str;
|
||||
|
||||
|
@ -84,7 +88,8 @@ TEST_F(IR_ConstantTest, u32) {
|
|||
}
|
||||
|
||||
TEST_F(IR_ConstantTest, bool) {
|
||||
Builder b;
|
||||
Module mod;
|
||||
Builder b{mod};
|
||||
|
||||
{
|
||||
utils::StringStream str;
|
||||
|
|
|
@ -22,7 +22,8 @@ namespace {
|
|||
using IR_InstructionTest = TestHelper;
|
||||
|
||||
TEST_F(IR_InstructionTest, Discard) {
|
||||
Builder b;
|
||||
Module mod;
|
||||
Builder b{mod};
|
||||
|
||||
const auto* inst = b.Discard();
|
||||
ASSERT_TRUE(inst->Is<ir::Discard>());
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -24,7 +24,8 @@ using namespace tint::number_suffixes; // NOLINT
|
|||
using IR_InstructionTest = TestHelper;
|
||||
|
||||
TEST_F(IR_InstructionTest, CreateStore) {
|
||||
Builder b;
|
||||
Module mod;
|
||||
Builder b{mod};
|
||||
|
||||
// TODO(dsinclair): This is wrong, but we don't have anything correct to store too at the
|
||||
// moment.
|
||||
|
@ -41,7 +42,8 @@ TEST_F(IR_InstructionTest, CreateStore) {
|
|||
}
|
||||
|
||||
TEST_F(IR_InstructionTest, Store_Usage) {
|
||||
Builder b;
|
||||
Module mod;
|
||||
Builder b{mod};
|
||||
|
||||
auto* to = b.Discard();
|
||||
const auto* inst = b.Store(to, b.Constant(4_i));
|
||||
|
|
|
@ -24,7 +24,8 @@ using namespace tint::number_suffixes; // NOLINT
|
|||
using IR_InstructionTest = TestHelper;
|
||||
|
||||
TEST_F(IR_InstructionTest, CreateAddressOf) {
|
||||
Builder b;
|
||||
Module mod;
|
||||
Builder b{mod};
|
||||
|
||||
// TODO(dsinclair): This would be better as an identifier, but works for now.
|
||||
const auto* inst = b.AddressOf(
|
||||
|
@ -44,7 +45,8 @@ TEST_F(IR_InstructionTest, CreateAddressOf) {
|
|||
}
|
||||
|
||||
TEST_F(IR_InstructionTest, CreateComplement) {
|
||||
Builder b;
|
||||
Module mod;
|
||||
Builder b{mod};
|
||||
const auto* inst = b.Complement(b.ir.types.Get<type::I32>(), b.Constant(4_i));
|
||||
|
||||
ASSERT_TRUE(inst->Is<Unary>());
|
||||
|
@ -57,7 +59,8 @@ TEST_F(IR_InstructionTest, CreateComplement) {
|
|||
}
|
||||
|
||||
TEST_F(IR_InstructionTest, CreateIndirection) {
|
||||
Builder b;
|
||||
Module mod;
|
||||
Builder b{mod};
|
||||
|
||||
// TODO(dsinclair): This would be better as an identifier, but works for now.
|
||||
const auto* inst = b.Indirection(b.ir.types.Get<type::I32>(), b.Constant(4_i));
|
||||
|
@ -72,7 +75,8 @@ TEST_F(IR_InstructionTest, CreateIndirection) {
|
|||
}
|
||||
|
||||
TEST_F(IR_InstructionTest, CreateNegation) {
|
||||
Builder b;
|
||||
Module mod;
|
||||
Builder b{mod};
|
||||
const auto* inst = b.Negation(b.ir.types.Get<type::I32>(), b.Constant(4_i));
|
||||
|
||||
ASSERT_TRUE(inst->Is<Unary>());
|
||||
|
@ -85,7 +89,8 @@ TEST_F(IR_InstructionTest, CreateNegation) {
|
|||
}
|
||||
|
||||
TEST_F(IR_InstructionTest, Unary_Usage) {
|
||||
Builder b;
|
||||
Module mod;
|
||||
Builder b{mod};
|
||||
const auto* inst = b.Negation(b.ir.types.Get<type::I32>(), b.Constant(4_i));
|
||||
|
||||
EXPECT_EQ(inst->kind, Unary::Kind::kNegation);
|
||||
|
|
|
@ -61,7 +61,7 @@ TEST_F(SpvGeneratorImplTest, Type_F16) {
|
|||
}
|
||||
|
||||
TEST_F(SpvGeneratorImplTest, Type_Vec2i) {
|
||||
auto* vec = ir.types.Get<type::Vector>(ir.types.Get<type::I32>(), 2u);
|
||||
auto* vec = b.ir.types.Get<type::Vector>(b.ir.types.Get<type::I32>(), 2u);
|
||||
auto id = generator_.Type(vec);
|
||||
EXPECT_EQ(id, 1u);
|
||||
EXPECT_EQ(DumpTypes(),
|
||||
|
@ -70,7 +70,7 @@ TEST_F(SpvGeneratorImplTest, Type_Vec2i) {
|
|||
}
|
||||
|
||||
TEST_F(SpvGeneratorImplTest, Type_Vec3u) {
|
||||
auto* vec = ir.types.Get<type::Vector>(ir.types.Get<type::U32>(), 3u);
|
||||
auto* vec = b.ir.types.Get<type::Vector>(b.ir.types.Get<type::U32>(), 3u);
|
||||
auto id = generator_.Type(vec);
|
||||
EXPECT_EQ(id, 1u);
|
||||
EXPECT_EQ(DumpTypes(),
|
||||
|
@ -79,7 +79,7 @@ TEST_F(SpvGeneratorImplTest, Type_Vec3u) {
|
|||
}
|
||||
|
||||
TEST_F(SpvGeneratorImplTest, Type_Vec4f) {
|
||||
auto* vec = ir.types.Get<type::Vector>(ir.types.Get<type::F32>(), 4u);
|
||||
auto* vec = b.ir.types.Get<type::Vector>(b.ir.types.Get<type::F32>(), 4u);
|
||||
auto id = generator_.Type(vec);
|
||||
EXPECT_EQ(id, 1u);
|
||||
EXPECT_EQ(DumpTypes(),
|
||||
|
@ -88,7 +88,7 @@ TEST_F(SpvGeneratorImplTest, Type_Vec4f) {
|
|||
}
|
||||
|
||||
TEST_F(SpvGeneratorImplTest, Type_Vec4h) {
|
||||
auto* vec = ir.types.Get<type::Vector>(ir.types.Get<type::F16>(), 2u);
|
||||
auto* vec = b.ir.types.Get<type::Vector>(b.ir.types.Get<type::F16>(), 2u);
|
||||
auto id = generator_.Type(vec);
|
||||
EXPECT_EQ(id, 1u);
|
||||
EXPECT_EQ(DumpTypes(),
|
||||
|
@ -97,7 +97,7 @@ TEST_F(SpvGeneratorImplTest, Type_Vec4h) {
|
|||
}
|
||||
|
||||
TEST_F(SpvGeneratorImplTest, Type_Vec4Bool) {
|
||||
auto* vec = ir.types.Get<type::Vector>(ir.types.Get<type::Bool>(), 4u);
|
||||
auto* vec = b.ir.types.Get<type::Vector>(b.ir.types.Get<type::Bool>(), 4u);
|
||||
auto id = generator_.Type(vec);
|
||||
EXPECT_EQ(id, 1u);
|
||||
EXPECT_EQ(DumpTypes(),
|
||||
|
|
Loading…
Reference in New Issue