#include "src/tint/lang/msl/writer/ast_printer/ast_printer.h"
#include <cmath>
#include <iomanip>
#include <limits>
#include <utility>
#include <vector>
#include "src/tint/api/common/binding_point.h"
#include "src/tint/lang/core/constant/splat.h"
#include "src/tint/lang/core/constant/value.h"
#include "src/tint/lang/core/fluent_types.h"
#include "src/tint/lang/core/type/array.h"
#include "src/tint/lang/core/type/atomic.h"
#include "src/tint/lang/core/type/bool.h"
#include "src/tint/lang/core/type/depth_multisampled_texture.h"
#include "src/tint/lang/core/type/depth_texture.h"
#include "src/tint/lang/core/type/f16.h"
#include "src/tint/lang/core/type/f32.h"
#include "src/tint/lang/core/type/i32.h"
#include "src/tint/lang/core/type/matrix.h"
#include "src/tint/lang/core/type/multisampled_texture.h"
#include "src/tint/lang/core/type/pointer.h"
#include "src/tint/lang/core/type/sampled_texture.h"
#include "src/tint/lang/core/type/storage_texture.h"
#include "src/tint/lang/core/type/texture_dimension.h"
#include "src/tint/lang/core/type/u32.h"
#include "src/tint/lang/core/type/vector.h"
#include "src/tint/lang/core/type/void.h"
#include "src/tint/lang/msl/writer/ast_raise/module_scope_var_to_entry_point_param.h"
#include "src/tint/lang/msl/writer/ast_raise/packed_vec3.h"
#include "src/tint/lang/msl/writer/ast_raise/pixel_local.h"
#include "src/tint/lang/msl/writer/ast_raise/quad_swap.h"
#include "src/tint/lang/msl/writer/ast_raise/subgroup_ballot.h"
#include "src/tint/lang/msl/writer/common/option_helpers.h"
#include "src/tint/lang/msl/writer/common/printer_support.h"
#include "src/tint/lang/wgsl/ast/alias.h"
#include "src/tint/lang/wgsl/ast/bool_literal_expression.h"
#include "src/tint/lang/wgsl/ast/call_statement.h"
#include "src/tint/lang/wgsl/ast/float_literal_expression.h"
#include "src/tint/lang/wgsl/ast/interpolate_attribute.h"
#include "src/tint/lang/wgsl/ast/transform/array_length_from_uniform.h"
#include "src/tint/lang/wgsl/ast/transform/binding_remapper.h"
#include "src/tint/lang/wgsl/ast/transform/builtin_polyfill.h"
#include "src/tint/lang/wgsl/ast/transform/canonicalize_entry_point_io.h"
#include "src/tint/lang/wgsl/ast/transform/demote_to_helper.h"
#include "src/tint/lang/wgsl/ast/transform/disable_uniformity_analysis.h"
#include "src/tint/lang/wgsl/ast/transform/expand_compound_assignment.h"
#include "src/tint/lang/wgsl/ast/transform/fold_constants.h"
#include "src/tint/lang/wgsl/ast/transform/manager.h"
#include "src/tint/lang/wgsl/ast/transform/multiplanar_external_texture.h"
#include "src/tint/lang/wgsl/ast/transform/preserve_padding.h"
#include "src/tint/lang/wgsl/ast/transform/promote_initializers_to_let.h"
#include "src/tint/lang/wgsl/ast/transform/promote_side_effects_to_decl.h"
#include "src/tint/lang/wgsl/ast/transform/remove_continue_in_switch.h"
#include "src/tint/lang/wgsl/ast/transform/remove_phonies.h"
#include "src/tint/lang/wgsl/ast/transform/robustness.h"
#include "src/tint/lang/wgsl/ast/transform/simplify_pointers.h"
#include "src/tint/lang/wgsl/ast/transform/unshadow.h"
#include "src/tint/lang/wgsl/ast/transform/vectorize_scalar_matrix_initializers.h"
#include "src/tint/lang/wgsl/ast/transform/zero_init_workgroup_memory.h"
#include "src/tint/lang/wgsl/ast/variable_decl_statement.h"
#include "src/tint/lang/wgsl/helpers/check_supported_extensions.h"
#include "src/tint/lang/wgsl/sem/call.h"
#include "src/tint/lang/wgsl/sem/function.h"
#include "src/tint/lang/wgsl/sem/member_accessor_expression.h"
#include "src/tint/lang/wgsl/sem/module.h"
#include "src/tint/lang/wgsl/sem/struct.h"
#include "src/tint/lang/wgsl/sem/switch_statement.h"
#include "src/tint/lang/wgsl/sem/value_constructor.h"
#include "src/tint/lang/wgsl/sem/value_conversion.h"
#include "src/tint/lang/wgsl/sem/variable.h"
#include "src/tint/utils/containers/map.h"
#include "src/tint/utils/macros/defer.h"
#include "src/tint/utils/macros/scoped_assignment.h"
#include "src/tint/utils/rtti/switch.h"
#include "src/tint/utils/text/string_stream.h"
usingnamespacetint::core::fluent_types;
namespace tint::msl::writer {
namespace {
bool last_is_break(const ast::BlockStatement* stmts) { … }
class ScopedBitCast { … };
}
SanitizedResult::SanitizedResult() = default;
SanitizedResult::~SanitizedResult() = default;
SanitizedResult::SanitizedResult(SanitizedResult&&) = default;
SanitizedResult Sanitize(const Program& in, const Options& options) { … }
ASTPrinter::ASTPrinter(const Program& program) : … { … }
ASTPrinter::~ASTPrinter() = default;
bool ASTPrinter::Generate() { … }
bool ASTPrinter::EmitTypeDecl(const core::type::Type* ty) { … }
bool ASTPrinter::EmitIndexAccessor(StringStream& out, const ast::IndexAccessorExpression* expr) { … }
bool ASTPrinter::EmitBitcastCall(StringStream& out, const ast::CallExpression* call) { … }
bool ASTPrinter::EmitAssign(const ast::AssignmentStatement* stmt) { … }
bool ASTPrinter::EmitBinary(StringStream& out, const ast::BinaryExpression* expr) { … }
bool ASTPrinter::EmitBreak(const ast::BreakStatement*) { … }
bool ASTPrinter::EmitBreakIf(const ast::BreakIfStatement* b) { … }
bool ASTPrinter::EmitCall(StringStream& out, const ast::CallExpression* expr) { … }
bool ASTPrinter::EmitFunctionCall(StringStream& out,
const sem::Call* call,
const sem::Function* fn) { … }
bool ASTPrinter::EmitBuiltinCall(StringStream& out,
const sem::Call* call,
const sem::BuiltinFn* builtin) { … }
bool ASTPrinter::EmitTypeConversion(StringStream& out,
const sem::Call* call,
const sem::ValueConversion* conv) { … }
bool ASTPrinter::EmitTypeInitializer(StringStream& out,
const sem::Call* call,
const sem::ValueConstructor* ctor) { … }
bool ASTPrinter::EmitAtomicCall(StringStream& out,
const ast::CallExpression* expr,
const sem::BuiltinFn* builtin) { … }
bool ASTPrinter::EmitTextureCall(StringStream& out,
const sem::Call* call,
const sem::BuiltinFn* builtin) { … }
bool ASTPrinter::EmitDotCall(StringStream& out,
const ast::CallExpression* expr,
const sem::BuiltinFn* builtin) { … }
bool ASTPrinter::EmitDot4I8PackedCall(StringStream& out,
const ast::CallExpression* expr,
const sem::BuiltinFn* builtin) { … }
bool ASTPrinter::EmitDot4U8PackedCall(StringStream& out,
const ast::CallExpression* expr,
const sem::BuiltinFn* builtin) { … }
bool ASTPrinter::EmitModfCall(StringStream& out,
const ast::CallExpression* expr,
const sem::BuiltinFn* builtin) { … }
bool ASTPrinter::EmitFrexpCall(StringStream& out,
const ast::CallExpression* expr,
const sem::BuiltinFn* builtin) { … }
bool ASTPrinter::EmitDegreesCall(StringStream& out,
const ast::CallExpression* expr,
const sem::BuiltinFn* builtin) { … }
bool ASTPrinter::EmitRadiansCall(StringStream& out,
const ast::CallExpression* expr,
const sem::BuiltinFn* builtin) { … }
std::string ASTPrinter::generate_builtin_name(const sem::BuiltinFn* builtin) { … }
bool ASTPrinter::EmitCase(const ast::CaseStatement* stmt) { … }
bool ASTPrinter::EmitContinue(const ast::ContinueStatement*) { … }
bool ASTPrinter::EmitZeroValue(StringStream& out, const core::type::Type* type) { … }
bool ASTPrinter::EmitConstant(StringStream& out, const core::constant::Value* constant) { … }
bool ASTPrinter::EmitLiteral(StringStream& out, const ast::LiteralExpression* lit) { … }
bool ASTPrinter::EmitExpression(StringStream& out, const ast::Expression* expr) { … }
void ASTPrinter::EmitStage(StringStream& out, ast::PipelineStage stage) { … }
bool ASTPrinter::EmitFunction(const ast::Function* func) { … }
bool ASTPrinter::EmitEntryPointFunction(const ast::Function* func) { … }
bool ASTPrinter::EmitIdentifier(StringStream& out, const ast::IdentifierExpression* expr) { … }
bool ASTPrinter::EmitLoop(const ast::LoopStatement* stmt) { … }
bool ASTPrinter::EmitForLoop(const ast::ForLoopStatement* stmt) { … }
bool ASTPrinter::EmitWhile(const ast::WhileStatement* stmt) { … }
bool ASTPrinter::EmitDiscard(const ast::DiscardStatement*) { … }
bool ASTPrinter::EmitIf(const ast::IfStatement* stmt) { … }
bool ASTPrinter::EmitMemberAccessor(StringStream& out, const ast::MemberAccessorExpression* expr) { … }
bool ASTPrinter::EmitReturn(const ast::ReturnStatement* stmt) { … }
bool ASTPrinter::EmitBlock(const ast::BlockStatement* stmt) { … }
bool ASTPrinter::EmitStatement(const ast::Statement* stmt) { … }
bool ASTPrinter::EmitStatements(VectorRef<const ast::Statement*> stmts) { … }
bool ASTPrinter::EmitStatementsWithIndent(VectorRef<const ast::Statement*> stmts) { … }
bool ASTPrinter::EmitSwitch(const ast::SwitchStatement* stmt) { … }
bool ASTPrinter::EmitType(StringStream& out, const core::type::Type* type) { … }
bool ASTPrinter::EmitTypeAndName(StringStream& out,
const core::type::Type* type,
const std::string& name) { … }
bool ASTPrinter::EmitAddressSpace(StringStream& out, core::AddressSpace sc) { … }
bool ASTPrinter::EmitStructType(TextBuffer* b, const core::type::Struct* str) { … }
bool ASTPrinter::EmitUnaryOp(StringStream& out, const ast::UnaryOpExpression* expr) { … }
bool ASTPrinter::EmitVar(const ast::Var* var) { … }
bool ASTPrinter::EmitLet(const ast::Let* let) { … }
std::string ASTPrinter::IsolateUB() { … }
template <typename F>
bool ASTPrinter::CallBuiltinHelper(StringStream& out,
const ast::CallExpression* call,
const sem::BuiltinFn* builtin,
F&& build) { … }
const std::string& ASTPrinter::ArrayType() { … }
std::string ASTPrinter::StructName(const core::type::Struct* s) { … }
std::string ASTPrinter::UniqueIdentifier(const std::string& prefix ) { … }
}