tint: Fix Renamer transform with type short-names
Fixed: tint:1783
Change-Id: I0ffd5860405651f15961dc8fe753eeac6edc8434
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/113441
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
diff --git a/src/tint/transform/renamer.cc b/src/tint/transform/renamer.cc
index 0fd1113..a84b004 100644
--- a/src/tint/transform/renamer.cc
+++ b/src/tint/transform/renamer.cc
@@ -21,7 +21,10 @@
#include "src/tint/program_builder.h"
#include "src/tint/sem/call.h"
#include "src/tint/sem/member_accessor_expression.h"
+#include "src/tint/sem/type_conversion.h"
+#include "src/tint/sem/type_initializer.h"
#include "src/tint/text/unicode.h"
+#include "src/tint/type/short_name.h"
TINT_INSTANTIATE_TYPEINFO(tint::transform::Renamer);
TINT_INSTANTIATE_TYPEINFO(tint::transform::Renamer::Data);
@@ -1258,27 +1261,63 @@
ProgramBuilder b;
CloneContext ctx{&b, src, /* auto_clone_symbols */ false};
- // Swizzles, builtin calls and builtin structure members need to keep their
- // symbols preserved.
- utils::Hashset<const ast::IdentifierExpression*, 8> preserve;
- for (auto* node : src->ASTNodes().Objects()) {
- if (auto* member = node->As<ast::MemberAccessorExpression>()) {
- auto* sem = src->Sem().Get(member);
- if (sem->Is<sem::Swizzle>()) {
- preserve.Add(member->member);
- } else if (auto* str_expr = src->Sem().Get(member->structure)) {
- if (auto* ty = str_expr->Type()->UnwrapRef()->As<sem::Struct>()) {
- if (ty->Declaration() == nullptr) { // Builtin structure
- preserve.Add(member->member);
- }
+ // Identifiers that need to keep their symbols preserved.
+ utils::Hashset<const ast::IdentifierExpression*, 8> preserved_identifiers;
+ // Type names that need to keep their symbols preserved.
+ utils::Hashset<const ast::TypeName*, 8> preserved_type_names;
+
+ auto is_type_short_name = [&](const Symbol& symbol) {
+ auto name = src->Symbols().NameFor(symbol);
+ if (type::ParseShortName(name) != type::ShortName::kUndefined) {
+ // Identifier *looks* like a builtin short-name, but check the using actually
+ // shadowing a short-name with a type alias.
+ for (auto* decl : src->AST().TypeDecls()) {
+ if (decl->name == symbol) {
+ return false;
}
}
- } else if (auto* call = node->As<ast::CallExpression>()) {
- auto* sem = src->Sem().Get(call)->UnwrapMaterialize()->As<sem::Call>();
- if (sem->Target()->Is<sem::Builtin>()) {
- preserve.Add(call->target.name);
- }
+ return true;
}
+ return false;
+ };
+
+ for (auto* node : src->ASTNodes().Objects()) {
+ Switch(
+ node,
+ [&](const ast::MemberAccessorExpression* accessor) {
+ auto* sem = src->Sem().Get(accessor);
+ if (sem->Is<sem::Swizzle>()) {
+ preserved_identifiers.Add(accessor->member);
+ } else if (auto* str_expr = src->Sem().Get(accessor->structure)) {
+ if (auto* ty = str_expr->Type()->UnwrapRef()->As<sem::Struct>()) {
+ if (ty->Declaration() == nullptr) { // Builtin structure
+ preserved_identifiers.Add(accessor->member);
+ }
+ }
+ }
+ },
+ [&](const ast::CallExpression* call) {
+ if (auto* ident = call->target.name) {
+ Switch(
+ src->Sem().Get(call)->UnwrapMaterialize()->As<sem::Call>()->Target(),
+ [&](const sem::Builtin*) { preserved_identifiers.Add(ident); },
+ [&](const sem::TypeConversion*) {
+ if (is_type_short_name(ident->symbol)) {
+ preserved_identifiers.Add(ident);
+ }
+ },
+ [&](const sem::TypeInitializer*) {
+ if (is_type_short_name(ident->symbol)) {
+ preserved_identifiers.Add(ident);
+ }
+ });
+ }
+ },
+ [&](const ast::TypeName* type_name) {
+ if (is_type_short_name(type_name->name)) {
+ preserved_type_names.Add(type_name);
+ }
+ });
}
Data::Remappings remappings;
@@ -1335,7 +1374,7 @@
});
ctx.ReplaceAll([&](const ast::IdentifierExpression* ident) -> const ast::IdentifierExpression* {
- if (preserve.Contains(ident)) {
+ if (preserved_identifiers.Contains(ident)) {
auto sym_in = ident->symbol;
auto str = src->Symbols().NameFor(sym_in);
auto sym_out = b.Symbols().Register(str);
@@ -1344,6 +1383,16 @@
return nullptr; // Clone ident. Uses the symbol remapping above.
});
+ ctx.ReplaceAll([&](const ast::TypeName* type_name) -> const ast::TypeName* {
+ if (preserved_type_names.Contains(type_name)) {
+ auto sym_in = type_name->name;
+ auto str = src->Symbols().NameFor(sym_in);
+ auto sym_out = b.Symbols().Register(str);
+ return ctx.dst->create<ast::TypeName>(ctx.Clone(type_name->source), sym_out);
+ }
+ return nullptr; // Clone ident. Uses the symbol remapping above.
+ });
+
ctx.Clone(); // Must come before the std::move()
outputs.Add<Data>(std::move(remappings));
diff --git a/src/tint/transform/renamer_test.cc b/src/tint/transform/renamer_test.cc
index c57dea3..18ee40c 100644
--- a/src/tint/transform/renamer_test.cc
+++ b/src/tint/transform/renamer_test.cc
@@ -18,6 +18,7 @@
#include "gmock/gmock.h"
#include "src/tint/transform/test_helper.h"
+#include "src/tint/type/short_name.h"
namespace tint::transform {
namespace {
@@ -1457,5 +1458,219 @@
// "while" // WGSL reserved keyword
kUnicodeIdentifier));
+const char* ExpandShortName(std::string_view name) {
+ if (name == "vec2f") {
+ return "vec2<f32>";
+ }
+ if (name == "vec2h") {
+ return "vec2<f16>";
+ }
+ if (name == "vec2i") {
+ return "vec2<i32>";
+ }
+ if (name == "vec2u") {
+ return "vec2<u32>";
+ }
+ if (name == "vec3f") {
+ return "vec3<f32>";
+ }
+ if (name == "vec3h") {
+ return "vec3<f16>";
+ }
+ if (name == "vec3i") {
+ return "vec3<i32>";
+ }
+ if (name == "vec3u") {
+ return "vec3<u32>";
+ }
+ if (name == "vec4f") {
+ return "vec4<f32>";
+ }
+ if (name == "vec4h") {
+ return "vec4<f16>";
+ }
+ if (name == "vec4i") {
+ return "vec4<i32>";
+ }
+ if (name == "vec4u") {
+ return "vec4<u32>";
+ }
+ ADD_FAILURE() << "unhandled type short-name: " << name;
+ return "<invalid>";
+}
+
+using RenamerTypeShortNamesTest = TransformTestWithParam<const char*>;
+
+TEST_P(RenamerTypeShortNamesTest, PreserveTypeUsage) {
+ auto expand = [&](const char* source) {
+ auto out = utils::ReplaceAll(source, "$name", GetParam());
+ out = utils::ReplaceAll(out, "$type", ExpandShortName(GetParam()));
+ return out;
+ };
+
+ auto src = expand(R"(
+enable f16;
+
+fn x(v : $name) -> $name {
+ const a : $name = $name();
+ let b : $name = a;
+ var c : $name = b;
+ return c;
+}
+
+struct y {
+ a : $name,
+}
+)");
+
+ auto expect = expand(R"(
+enable f16;
+
+fn tint_symbol(tint_symbol_1 : $name) -> $name {
+ const tint_symbol_2 : $name = $name();
+ let tint_symbol_3 : $name = tint_symbol_2;
+ var tint_symbol_4 : $name = tint_symbol_3;
+ return tint_symbol_4;
+}
+
+struct tint_symbol_5 {
+ tint_symbol_2 : $name,
+}
+)");
+
+ auto got = Run<Renamer>(src);
+
+ EXPECT_EQ(expect, str(got));
+}
+TEST_P(RenamerTypeShortNamesTest, PreserveTypeInitializer) {
+ auto expand = [&](const char* source) {
+ auto out = utils::ReplaceAll(source, "$name", GetParam());
+ out = utils::ReplaceAll(out, "$type", ExpandShortName(GetParam()));
+ return out;
+ };
+
+ auto src = expand(R"(
+enable f16;
+
+@fragment
+fn f() {
+ var v : $type = $name();
+}
+)");
+
+ auto expect = expand(R"(
+enable f16;
+
+@fragment
+fn tint_symbol() {
+ var tint_symbol_1 : $type = $name();
+}
+)");
+
+ auto got = Run<Renamer>(src);
+
+ EXPECT_EQ(expect, str(got));
+}
+
+TEST_P(RenamerTypeShortNamesTest, PreserveTypeConversion) {
+ auto expand = [&](const char* source) {
+ auto out = utils::ReplaceAll(source, "$name", GetParam());
+ out = utils::ReplaceAll(out, "$type", ExpandShortName(GetParam()));
+ return out;
+ };
+
+ auto src = expand(R"(
+enable f16;
+
+@fragment
+fn f() {
+ var v : $type = $name($type());
+}
+)");
+
+ auto expect = expand(R"(
+enable f16;
+
+@fragment
+fn tint_symbol() {
+ var tint_symbol_1 : $type = $name($type());
+}
+)");
+
+ auto got = Run<Renamer>(src);
+
+ EXPECT_EQ(expect, str(got));
+}
+
+TEST_P(RenamerTypeShortNamesTest, RenameShadowedByAlias) {
+ auto expand = [&](const char* source) {
+ auto out = utils::ReplaceAll(source, "$name", GetParam());
+ out = utils::ReplaceAll(out, "$type", ExpandShortName(GetParam()));
+ return out;
+ };
+
+ auto src = expand(R"(
+type $name = i32;
+
+@fragment
+fn f() {
+ var v : i32 = $name();
+}
+)");
+
+ auto expect = expand(R"(
+type tint_symbol = i32;
+
+@fragment
+fn tint_symbol_1() {
+ var tint_symbol_2 : i32 = tint_symbol();
+}
+)");
+
+ auto got = Run<Renamer>(src);
+
+ EXPECT_EQ(expect, str(got));
+}
+
+TEST_P(RenamerTypeShortNamesTest, RenameShadowedByStruct) {
+ auto expand = [&](const char* source) {
+ auto out = utils::ReplaceAll(source, "$name", GetParam());
+ out = utils::ReplaceAll(out, "$type", ExpandShortName(GetParam()));
+ return out;
+ };
+
+ auto src = expand(R"(
+struct $name {
+ i : i32,
+}
+
+@fragment
+fn f() {
+ var a = $name();
+ var b = a.i;
+}
+)");
+
+ auto expect = expand(R"(
+struct tint_symbol {
+ tint_symbol_1 : i32,
+}
+
+@fragment
+fn tint_symbol_2() {
+ var tint_symbol_3 = tint_symbol();
+ var tint_symbol_4 = tint_symbol_3.tint_symbol_1;
+}
+)");
+
+ auto got = Run<Renamer>(src);
+
+ EXPECT_EQ(expect, str(got));
+}
+
+INSTANTIATE_TEST_SUITE_P(RenamerTypeShortNamesTest,
+ RenamerTypeShortNamesTest,
+ testing::ValuesIn(type::kShortNameStrings));
+
} // namespace
} // namespace tint::transform
diff --git a/test/tint/shadowing/short_names/let.wgsl.expected.dxc.hlsl b/test/tint/shadowing/short_names/let.wgsl.expected.dxc.hlsl
index 0e6094b..e4d88a3 100644
--- a/test/tint/shadowing/short_names/let.wgsl.expected.dxc.hlsl
+++ b/test/tint/shadowing/short_names/let.wgsl.expected.dxc.hlsl
@@ -5,8 +5,8 @@
void f() {
{
- const int vec3f = 1;
- const int b = vec3f;
+ const int vec3f_1 = 1;
+ const int b = vec3f_1;
}
const float3 c = (0.0f).xxx;
const float3 d = (0.0f).xxx;
diff --git a/test/tint/shadowing/short_names/let.wgsl.expected.fxc.hlsl b/test/tint/shadowing/short_names/let.wgsl.expected.fxc.hlsl
index 0e6094b..e4d88a3 100644
--- a/test/tint/shadowing/short_names/let.wgsl.expected.fxc.hlsl
+++ b/test/tint/shadowing/short_names/let.wgsl.expected.fxc.hlsl
@@ -5,8 +5,8 @@
void f() {
{
- const int vec3f = 1;
- const int b = vec3f;
+ const int vec3f_1 = 1;
+ const int b = vec3f_1;
}
const float3 c = (0.0f).xxx;
const float3 d = (0.0f).xxx;
diff --git a/test/tint/shadowing/short_names/let.wgsl.expected.glsl b/test/tint/shadowing/short_names/let.wgsl.expected.glsl
index fc24838..36e810e 100644
--- a/test/tint/shadowing/short_names/let.wgsl.expected.glsl
+++ b/test/tint/shadowing/short_names/let.wgsl.expected.glsl
@@ -6,8 +6,8 @@
}
void f() {
{
- int vec3f = 1;
- int b = vec3f;
+ int vec3f_1 = 1;
+ int b = vec3f_1;
}
vec3 c = vec3(0.0f);
vec3 d = vec3(0.0f);
diff --git a/test/tint/shadowing/short_names/let.wgsl.expected.msl b/test/tint/shadowing/short_names/let.wgsl.expected.msl
index 34d9028..cf3c9ce 100644
--- a/test/tint/shadowing/short_names/let.wgsl.expected.msl
+++ b/test/tint/shadowing/short_names/let.wgsl.expected.msl
@@ -3,8 +3,8 @@
using namespace metal;
void f() {
{
- int const vec3f = 1;
- int const b = vec3f;
+ int const vec3f_1 = 1;
+ int const b = vec3f_1;
}
float3 const c = float3(0.0f);
float3 const d = float3(0.0f);
diff --git a/test/tint/shadowing/short_names/renamer/function.wgsl b/test/tint/shadowing/short_names/renamer/function.wgsl
new file mode 100644
index 0000000..b7aaaa4
--- /dev/null
+++ b/test/tint/shadowing/short_names/renamer/function.wgsl
@@ -0,0 +1,10 @@
+// flags: --transform renamer
+
+// Evilness 😈. Don't go getting any ideas!
+fn vec4f() -> i32 { return 0; }
+fn vec2f(i : i32) -> f32 { return f32(i); }
+fn vec2i(f : f32) -> bool { return bool(f); }
+
+@vertex fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
+ return select(vec4<f32>(), vec4<f32>(1), vec2i(vec2f(vec4f())));
+}
diff --git a/test/tint/shadowing/short_names/renamer/function.wgsl.expected.dxc.hlsl b/test/tint/shadowing/short_names/renamer/function.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..b276950
--- /dev/null
+++ b/test/tint/shadowing/short_names/renamer/function.wgsl.expected.dxc.hlsl
@@ -0,0 +1,34 @@
+int vec4f() {
+ return 0;
+}
+
+float vec2f(int i) {
+ return float(i);
+}
+
+bool vec2i(float f) {
+ return bool(f);
+}
+
+struct tint_symbol_1 {
+ uint VertexIndex : SV_VertexID;
+};
+struct tint_symbol_2 {
+ float4 value : SV_Position;
+};
+
+float4 main_inner(uint VertexIndex) {
+ const float4 tint_symbol_3 = (0.0f).xxxx;
+ const float4 tint_symbol_4 = (1.0f).xxxx;
+ const int tint_symbol_5 = vec4f();
+ const float tint_symbol_6 = vec2f(tint_symbol_5);
+ const bool tint_symbol_7 = vec2i(tint_symbol_6);
+ return (tint_symbol_7 ? tint_symbol_4 : tint_symbol_3);
+}
+
+tint_symbol_2 main(tint_symbol_1 tint_symbol) {
+ const float4 inner_result = main_inner(tint_symbol.VertexIndex);
+ tint_symbol_2 wrapper_result = (tint_symbol_2)0;
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
diff --git a/test/tint/shadowing/short_names/renamer/function.wgsl.expected.fxc.hlsl b/test/tint/shadowing/short_names/renamer/function.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..b276950
--- /dev/null
+++ b/test/tint/shadowing/short_names/renamer/function.wgsl.expected.fxc.hlsl
@@ -0,0 +1,34 @@
+int vec4f() {
+ return 0;
+}
+
+float vec2f(int i) {
+ return float(i);
+}
+
+bool vec2i(float f) {
+ return bool(f);
+}
+
+struct tint_symbol_1 {
+ uint VertexIndex : SV_VertexID;
+};
+struct tint_symbol_2 {
+ float4 value : SV_Position;
+};
+
+float4 main_inner(uint VertexIndex) {
+ const float4 tint_symbol_3 = (0.0f).xxxx;
+ const float4 tint_symbol_4 = (1.0f).xxxx;
+ const int tint_symbol_5 = vec4f();
+ const float tint_symbol_6 = vec2f(tint_symbol_5);
+ const bool tint_symbol_7 = vec2i(tint_symbol_6);
+ return (tint_symbol_7 ? tint_symbol_4 : tint_symbol_3);
+}
+
+tint_symbol_2 main(tint_symbol_1 tint_symbol) {
+ const float4 inner_result = main_inner(tint_symbol.VertexIndex);
+ tint_symbol_2 wrapper_result = (tint_symbol_2)0;
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
diff --git a/test/tint/shadowing/short_names/renamer/function.wgsl.expected.glsl b/test/tint/shadowing/short_names/renamer/function.wgsl.expected.glsl
new file mode 100644
index 0000000..5badde0
--- /dev/null
+++ b/test/tint/shadowing/short_names/renamer/function.wgsl.expected.glsl
@@ -0,0 +1,31 @@
+#version 310 es
+
+int vec4f() {
+ return 0;
+}
+
+float vec2f(int i) {
+ return float(i);
+}
+
+bool vec2i(float f) {
+ return bool(f);
+}
+
+vec4 tint_symbol(uint VertexIndex) {
+ vec4 tint_symbol_1 = vec4(0.0f);
+ vec4 tint_symbol_2 = vec4(1.0f);
+ int tint_symbol_3 = vec4f();
+ float tint_symbol_4 = vec2f(tint_symbol_3);
+ bool tint_symbol_5 = vec2i(tint_symbol_4);
+ return (tint_symbol_5 ? tint_symbol_2 : tint_symbol_1);
+}
+
+void main() {
+ gl_PointSize = 1.0;
+ vec4 inner_result = tint_symbol(uint(gl_VertexID));
+ gl_Position = inner_result;
+ gl_Position.y = -(gl_Position.y);
+ gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
+ return;
+}
diff --git a/test/tint/shadowing/short_names/renamer/function.wgsl.expected.msl b/test/tint/shadowing/short_names/renamer/function.wgsl.expected.msl
new file mode 100644
index 0000000..69aef23
--- /dev/null
+++ b/test/tint/shadowing/short_names/renamer/function.wgsl.expected.msl
@@ -0,0 +1,35 @@
+#include <metal_stdlib>
+
+using namespace metal;
+int vec4f() {
+ return 0;
+}
+
+float vec2f(int i) {
+ return float(i);
+}
+
+bool vec2i(float f) {
+ return bool(f);
+}
+
+struct tint_symbol_1 {
+ float4 value [[position]];
+};
+
+float4 tint_symbol_inner(uint VertexIndex) {
+ float4 const tint_symbol_2 = float4(0.0f);
+ float4 const tint_symbol_3 = float4(1.0f);
+ int const tint_symbol_4 = vec4f();
+ float const tint_symbol_5 = vec2f(tint_symbol_4);
+ bool const tint_symbol_6 = vec2i(tint_symbol_5);
+ return select(tint_symbol_2, tint_symbol_3, tint_symbol_6);
+}
+
+vertex tint_symbol_1 tint_symbol(uint VertexIndex [[vertex_id]]) {
+ float4 const inner_result = tint_symbol_inner(VertexIndex);
+ tint_symbol_1 wrapper_result = {};
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
+
diff --git a/test/tint/shadowing/short_names/renamer/function.wgsl.expected.spvasm b/test/tint/shadowing/short_names/renamer/function.wgsl.expected.spvasm
new file mode 100644
index 0000000..b12bd8b
--- /dev/null
+++ b/test/tint/shadowing/short_names/renamer/function.wgsl.expected.spvasm
@@ -0,0 +1,82 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 49
+; Schema: 0
+ OpCapability Shader
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint Vertex %tint_symbol_5 "tint_symbol_5" %tint_symbol_6_1 %value %vertex_point_size
+ OpName %tint_symbol_6_1 "tint_symbol_6_1"
+ OpName %value "value"
+ OpName %vertex_point_size "vertex_point_size"
+ OpName %tint_symbol "tint_symbol"
+ OpName %tint_symbol_1 "tint_symbol_1"
+ OpName %tint_symbol_2 "tint_symbol_2"
+ OpName %tint_symbol_3 "tint_symbol_3"
+ OpName %tint_symbol_4 "tint_symbol_4"
+ OpName %tint_symbol_5_inner "tint_symbol_5_inner"
+ OpName %tint_symbol_6 "tint_symbol_6"
+ OpName %tint_symbol_5 "tint_symbol_5"
+ OpDecorate %tint_symbol_6_1 BuiltIn VertexIndex
+ OpDecorate %value BuiltIn Position
+ OpDecorate %vertex_point_size BuiltIn PointSize
+ %uint = OpTypeInt 32 0
+%_ptr_Input_uint = OpTypePointer Input %uint
+%tint_symbol_6_1 = OpVariable %_ptr_Input_uint Input
+ %float = OpTypeFloat 32
+ %v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+ %8 = OpConstantNull %v4float
+ %value = OpVariable %_ptr_Output_v4float Output %8
+%_ptr_Output_float = OpTypePointer Output %float
+ %11 = OpConstantNull %float
+%vertex_point_size = OpVariable %_ptr_Output_float Output %11
+ %int = OpTypeInt 32 1
+ %12 = OpTypeFunction %int
+ %16 = OpConstantNull %int
+ %17 = OpTypeFunction %float %int
+ %bool = OpTypeBool
+ %22 = OpTypeFunction %bool %float
+ %28 = OpTypeFunction %v4float %uint
+ %float_1 = OpConstant %float 1
+ %33 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
+ %v4bool = OpTypeVector %bool 4
+%_ptr_Function_v4bool = OpTypePointer Function %v4bool
+ %41 = OpConstantNull %v4bool
+ %void = OpTypeVoid
+ %43 = OpTypeFunction %void
+%tint_symbol = OpFunction %int None %12
+ %15 = OpLabel
+ OpReturnValue %16
+ OpFunctionEnd
+%tint_symbol_1 = OpFunction %float None %17
+%tint_symbol_2 = OpFunctionParameter %int
+ %20 = OpLabel
+ %21 = OpConvertSToF %float %tint_symbol_2
+ OpReturnValue %21
+ OpFunctionEnd
+%tint_symbol_3 = OpFunction %bool None %22
+%tint_symbol_4 = OpFunctionParameter %float
+ %26 = OpLabel
+ %27 = OpFUnordNotEqual %bool %tint_symbol_4 %11
+ OpReturnValue %27
+ OpFunctionEnd
+%tint_symbol_5_inner = OpFunction %v4float None %28
+%tint_symbol_6 = OpFunctionParameter %uint
+ %31 = OpLabel
+ %39 = OpVariable %_ptr_Function_v4bool Function %41
+ %34 = OpFunctionCall %int %tint_symbol
+ %35 = OpFunctionCall %float %tint_symbol_1 %34
+ %36 = OpFunctionCall %bool %tint_symbol_3 %35
+ %42 = OpCompositeConstruct %v4bool %36 %36 %36 %36
+ %37 = OpSelect %v4float %42 %33 %8
+ OpReturnValue %37
+ OpFunctionEnd
+%tint_symbol_5 = OpFunction %void None %43
+ %46 = OpLabel
+ %48 = OpLoad %uint %tint_symbol_6_1
+ %47 = OpFunctionCall %v4float %tint_symbol_5_inner %48
+ OpStore %value %47
+ OpStore %vertex_point_size %float_1
+ OpReturn
+ OpFunctionEnd
diff --git a/test/tint/shadowing/short_names/renamer/function.wgsl.expected.wgsl b/test/tint/shadowing/short_names/renamer/function.wgsl.expected.wgsl
new file mode 100644
index 0000000..41ee0e7
--- /dev/null
+++ b/test/tint/shadowing/short_names/renamer/function.wgsl.expected.wgsl
@@ -0,0 +1,16 @@
+fn tint_symbol() -> i32 {
+ return 0;
+}
+
+fn tint_symbol_1(tint_symbol_2 : i32) -> f32 {
+ return f32(tint_symbol_2);
+}
+
+fn tint_symbol_3(tint_symbol_4 : f32) -> bool {
+ return bool(tint_symbol_4);
+}
+
+@vertex
+fn tint_symbol_5(@builtin(vertex_index) tint_symbol_6 : u32) -> @builtin(position) vec4<f32> {
+ return select(vec4<f32>(), vec4<f32>(1), tint_symbol_3(tint_symbol_1(tint_symbol())));
+}
diff --git a/test/tint/shadowing/short_names/renamer/renamer.wgsl b/test/tint/shadowing/short_names/renamer/renamer.wgsl
new file mode 100644
index 0000000..4d7cfbf
--- /dev/null
+++ b/test/tint/shadowing/short_names/renamer/renamer.wgsl
@@ -0,0 +1,5 @@
+// flags: --transform renamer
+
+@vertex fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
+ return vec4f(vec2f(vec2i()), 0.0, 1.0);
+}
diff --git a/test/tint/shadowing/short_names/renamer/renamer.wgsl.expected.dxc.hlsl b/test/tint/shadowing/short_names/renamer/renamer.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..e32fc26
--- /dev/null
+++ b/test/tint/shadowing/short_names/renamer/renamer.wgsl.expected.dxc.hlsl
@@ -0,0 +1,17 @@
+struct tint_symbol_1 {
+ uint VertexIndex : SV_VertexID;
+};
+struct tint_symbol_2 {
+ float4 value : SV_Position;
+};
+
+float4 main_inner(uint VertexIndex) {
+ return float4(0.0f, 0.0f, 0.0f, 1.0f);
+}
+
+tint_symbol_2 main(tint_symbol_1 tint_symbol) {
+ const float4 inner_result = main_inner(tint_symbol.VertexIndex);
+ tint_symbol_2 wrapper_result = (tint_symbol_2)0;
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
diff --git a/test/tint/shadowing/short_names/renamer/renamer.wgsl.expected.fxc.hlsl b/test/tint/shadowing/short_names/renamer/renamer.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..e32fc26
--- /dev/null
+++ b/test/tint/shadowing/short_names/renamer/renamer.wgsl.expected.fxc.hlsl
@@ -0,0 +1,17 @@
+struct tint_symbol_1 {
+ uint VertexIndex : SV_VertexID;
+};
+struct tint_symbol_2 {
+ float4 value : SV_Position;
+};
+
+float4 main_inner(uint VertexIndex) {
+ return float4(0.0f, 0.0f, 0.0f, 1.0f);
+}
+
+tint_symbol_2 main(tint_symbol_1 tint_symbol) {
+ const float4 inner_result = main_inner(tint_symbol.VertexIndex);
+ tint_symbol_2 wrapper_result = (tint_symbol_2)0;
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
diff --git a/test/tint/shadowing/short_names/renamer/renamer.wgsl.expected.glsl b/test/tint/shadowing/short_names/renamer/renamer.wgsl.expected.glsl
new file mode 100644
index 0000000..44f88dc
--- /dev/null
+++ b/test/tint/shadowing/short_names/renamer/renamer.wgsl.expected.glsl
@@ -0,0 +1,14 @@
+#version 310 es
+
+vec4 tint_symbol(uint VertexIndex) {
+ return vec4(0.0f, 0.0f, 0.0f, 1.0f);
+}
+
+void main() {
+ gl_PointSize = 1.0;
+ vec4 inner_result = tint_symbol(uint(gl_VertexID));
+ gl_Position = inner_result;
+ gl_Position.y = -(gl_Position.y);
+ gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
+ return;
+}
diff --git a/test/tint/shadowing/short_names/renamer/renamer.wgsl.expected.msl b/test/tint/shadowing/short_names/renamer/renamer.wgsl.expected.msl
new file mode 100644
index 0000000..db26a6c
--- /dev/null
+++ b/test/tint/shadowing/short_names/renamer/renamer.wgsl.expected.msl
@@ -0,0 +1,18 @@
+#include <metal_stdlib>
+
+using namespace metal;
+struct tint_symbol_1 {
+ float4 value [[position]];
+};
+
+float4 tint_symbol_inner(uint VertexIndex) {
+ return float4(0.0f, 0.0f, 0.0f, 1.0f);
+}
+
+vertex tint_symbol_1 tint_symbol(uint VertexIndex [[vertex_id]]) {
+ float4 const inner_result = tint_symbol_inner(VertexIndex);
+ tint_symbol_1 wrapper_result = {};
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
+
diff --git a/test/tint/shadowing/short_names/renamer/renamer.wgsl.expected.spvasm b/test/tint/shadowing/short_names/renamer/renamer.wgsl.expected.spvasm
new file mode 100644
index 0000000..b646121
--- /dev/null
+++ b/test/tint/shadowing/short_names/renamer/renamer.wgsl.expected.spvasm
@@ -0,0 +1,46 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 24
+; Schema: 0
+ OpCapability Shader
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint Vertex %tint_symbol "tint_symbol" %tint_symbol_1_1 %value %vertex_point_size
+ OpName %tint_symbol_1_1 "tint_symbol_1_1"
+ OpName %value "value"
+ OpName %vertex_point_size "vertex_point_size"
+ OpName %tint_symbol_inner "tint_symbol_inner"
+ OpName %tint_symbol_1 "tint_symbol_1"
+ OpName %tint_symbol "tint_symbol"
+ OpDecorate %tint_symbol_1_1 BuiltIn VertexIndex
+ OpDecorate %value BuiltIn Position
+ OpDecorate %vertex_point_size BuiltIn PointSize
+ %uint = OpTypeInt 32 0
+%_ptr_Input_uint = OpTypePointer Input %uint
+%tint_symbol_1_1 = OpVariable %_ptr_Input_uint Input
+ %float = OpTypeFloat 32
+ %v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+ %8 = OpConstantNull %v4float
+ %value = OpVariable %_ptr_Output_v4float Output %8
+%_ptr_Output_float = OpTypePointer Output %float
+ %11 = OpConstantNull %float
+%vertex_point_size = OpVariable %_ptr_Output_float Output %11
+ %12 = OpTypeFunction %v4float %uint
+ %float_1 = OpConstant %float 1
+ %17 = OpConstantComposite %v4float %11 %11 %11 %float_1
+ %void = OpTypeVoid
+ %18 = OpTypeFunction %void
+%tint_symbol_inner = OpFunction %v4float None %12
+%tint_symbol_1 = OpFunctionParameter %uint
+ %15 = OpLabel
+ OpReturnValue %17
+ OpFunctionEnd
+%tint_symbol = OpFunction %void None %18
+ %21 = OpLabel
+ %23 = OpLoad %uint %tint_symbol_1_1
+ %22 = OpFunctionCall %v4float %tint_symbol_inner %23
+ OpStore %value %22
+ OpStore %vertex_point_size %float_1
+ OpReturn
+ OpFunctionEnd
diff --git a/test/tint/shadowing/short_names/renamer/renamer.wgsl.expected.wgsl b/test/tint/shadowing/short_names/renamer/renamer.wgsl.expected.wgsl
new file mode 100644
index 0000000..0369839
--- /dev/null
+++ b/test/tint/shadowing/short_names/renamer/renamer.wgsl.expected.wgsl
@@ -0,0 +1,4 @@
+@vertex
+fn tint_symbol(@builtin(vertex_index) tint_symbol_1 : u32) -> @builtin(position) vec4f {
+ return vec4f(vec2f(vec2i()), 0.0, 1.0);
+}
diff --git a/test/tint/shadowing/short_names/renamer/type.wgsl b/test/tint/shadowing/short_names/renamer/type.wgsl
new file mode 100644
index 0000000..af2d901
--- /dev/null
+++ b/test/tint/shadowing/short_names/renamer/type.wgsl
@@ -0,0 +1,13 @@
+// flags: --transform renamer
+
+// Evilness 😈. Don't go getting any ideas!
+struct vec4f { i : i32, }
+type vec2f = f32;
+type vec2i = bool;
+
+@vertex fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
+ let s = vec4f(1);
+ let f : f32 = vec2f(s.i);
+ let b : bool = vec2i(f);
+ return select(vec4<f32>(), vec4<f32>(1), b);
+}
diff --git a/test/tint/shadowing/short_names/renamer/type.wgsl.expected.dxc.hlsl b/test/tint/shadowing/short_names/renamer/type.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..170aef3
--- /dev/null
+++ b/test/tint/shadowing/short_names/renamer/type.wgsl.expected.dxc.hlsl
@@ -0,0 +1,23 @@
+struct vec4f {
+ int i;
+};
+struct tint_symbol_1 {
+ uint VertexIndex : SV_VertexID;
+};
+struct tint_symbol_2 {
+ float4 value : SV_Position;
+};
+
+float4 main_inner(uint VertexIndex) {
+ const vec4f s = {1};
+ const float f = float(s.i);
+ const bool b = bool(f);
+ return (b ? (1.0f).xxxx : (0.0f).xxxx);
+}
+
+tint_symbol_2 main(tint_symbol_1 tint_symbol) {
+ const float4 inner_result = main_inner(tint_symbol.VertexIndex);
+ tint_symbol_2 wrapper_result = (tint_symbol_2)0;
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
diff --git a/test/tint/shadowing/short_names/renamer/type.wgsl.expected.fxc.hlsl b/test/tint/shadowing/short_names/renamer/type.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..170aef3
--- /dev/null
+++ b/test/tint/shadowing/short_names/renamer/type.wgsl.expected.fxc.hlsl
@@ -0,0 +1,23 @@
+struct vec4f {
+ int i;
+};
+struct tint_symbol_1 {
+ uint VertexIndex : SV_VertexID;
+};
+struct tint_symbol_2 {
+ float4 value : SV_Position;
+};
+
+float4 main_inner(uint VertexIndex) {
+ const vec4f s = {1};
+ const float f = float(s.i);
+ const bool b = bool(f);
+ return (b ? (1.0f).xxxx : (0.0f).xxxx);
+}
+
+tint_symbol_2 main(tint_symbol_1 tint_symbol) {
+ const float4 inner_result = main_inner(tint_symbol.VertexIndex);
+ tint_symbol_2 wrapper_result = (tint_symbol_2)0;
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
diff --git a/test/tint/shadowing/short_names/renamer/type.wgsl.expected.glsl b/test/tint/shadowing/short_names/renamer/type.wgsl.expected.glsl
new file mode 100644
index 0000000..2c2b003
--- /dev/null
+++ b/test/tint/shadowing/short_names/renamer/type.wgsl.expected.glsl
@@ -0,0 +1,21 @@
+#version 310 es
+
+struct vec4f {
+ int i;
+};
+
+vec4 tint_symbol(uint VertexIndex) {
+ vec4f s = vec4f(1);
+ float f = float(s.i);
+ bool b = bool(f);
+ return (b ? vec4(1.0f) : vec4(0.0f));
+}
+
+void main() {
+ gl_PointSize = 1.0;
+ vec4 inner_result = tint_symbol(uint(gl_VertexID));
+ gl_Position = inner_result;
+ gl_Position.y = -(gl_Position.y);
+ gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
+ return;
+}
diff --git a/test/tint/shadowing/short_names/renamer/type.wgsl.expected.msl b/test/tint/shadowing/short_names/renamer/type.wgsl.expected.msl
new file mode 100644
index 0000000..b247dfa
--- /dev/null
+++ b/test/tint/shadowing/short_names/renamer/type.wgsl.expected.msl
@@ -0,0 +1,25 @@
+#include <metal_stdlib>
+
+using namespace metal;
+struct vec4f {
+ int i;
+};
+
+struct tint_symbol_1 {
+ float4 value [[position]];
+};
+
+float4 tint_symbol_inner(uint VertexIndex) {
+ vec4f const s = vec4f{.i=1};
+ float const f = float(s.i);
+ bool const b = bool(f);
+ return select(float4(0.0f), float4(1.0f), b);
+}
+
+vertex tint_symbol_1 tint_symbol(uint VertexIndex [[vertex_id]]) {
+ float4 const inner_result = tint_symbol_inner(VertexIndex);
+ tint_symbol_1 wrapper_result = {};
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
+
diff --git a/test/tint/shadowing/short_names/renamer/type.wgsl.expected.spvasm b/test/tint/shadowing/short_names/renamer/type.wgsl.expected.spvasm
new file mode 100644
index 0000000..83163db
--- /dev/null
+++ b/test/tint/shadowing/short_names/renamer/type.wgsl.expected.spvasm
@@ -0,0 +1,63 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 38
+; Schema: 0
+ OpCapability Shader
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint Vertex %tint_symbol_4 "tint_symbol_4" %tint_symbol_5_1 %value %vertex_point_size
+ OpName %tint_symbol_5_1 "tint_symbol_5_1"
+ OpName %value "value"
+ OpName %vertex_point_size "vertex_point_size"
+ OpName %tint_symbol_4_inner "tint_symbol_4_inner"
+ OpName %tint_symbol_5 "tint_symbol_5"
+ OpName %tint_symbol "tint_symbol"
+ OpMemberName %tint_symbol 0 "tint_symbol_1"
+ OpName %tint_symbol_4 "tint_symbol_4"
+ OpDecorate %tint_symbol_5_1 BuiltIn VertexIndex
+ OpDecorate %value BuiltIn Position
+ OpDecorate %vertex_point_size BuiltIn PointSize
+ OpMemberDecorate %tint_symbol 0 Offset 0
+ %uint = OpTypeInt 32 0
+%_ptr_Input_uint = OpTypePointer Input %uint
+%tint_symbol_5_1 = OpVariable %_ptr_Input_uint Input
+ %float = OpTypeFloat 32
+ %v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+ %8 = OpConstantNull %v4float
+ %value = OpVariable %_ptr_Output_v4float Output %8
+%_ptr_Output_float = OpTypePointer Output %float
+ %11 = OpConstantNull %float
+%vertex_point_size = OpVariable %_ptr_Output_float Output %11
+ %12 = OpTypeFunction %v4float %uint
+ %int = OpTypeInt 32 1
+%tint_symbol = OpTypeStruct %int
+ %int_1 = OpConstant %int 1
+ %19 = OpConstantComposite %tint_symbol %int_1
+ %bool = OpTypeBool
+ %float_1 = OpConstant %float 1
+ %26 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
+ %v4bool = OpTypeVector %bool 4
+%_ptr_Function_v4bool = OpTypePointer Function %v4bool
+ %30 = OpConstantNull %v4bool
+ %void = OpTypeVoid
+ %32 = OpTypeFunction %void
+%tint_symbol_4_inner = OpFunction %v4float None %12
+%tint_symbol_5 = OpFunctionParameter %uint
+ %15 = OpLabel
+ %28 = OpVariable %_ptr_Function_v4bool Function %30
+ %21 = OpCompositeExtract %int %19 0
+ %20 = OpConvertSToF %float %21
+ %22 = OpFUnordNotEqual %bool %20 %11
+ %31 = OpCompositeConstruct %v4bool %22 %22 %22 %22
+ %24 = OpSelect %v4float %31 %26 %8
+ OpReturnValue %24
+ OpFunctionEnd
+%tint_symbol_4 = OpFunction %void None %32
+ %35 = OpLabel
+ %37 = OpLoad %uint %tint_symbol_5_1
+ %36 = OpFunctionCall %v4float %tint_symbol_4_inner %37
+ OpStore %value %36
+ OpStore %vertex_point_size %float_1
+ OpReturn
+ OpFunctionEnd
diff --git a/test/tint/shadowing/short_names/renamer/type.wgsl.expected.wgsl b/test/tint/shadowing/short_names/renamer/type.wgsl.expected.wgsl
new file mode 100644
index 0000000..05eac3f
--- /dev/null
+++ b/test/tint/shadowing/short_names/renamer/type.wgsl.expected.wgsl
@@ -0,0 +1,15 @@
+struct tint_symbol {
+ tint_symbol_1 : i32,
+}
+
+type tint_symbol_2 = f32;
+
+type tint_symbol_3 = bool;
+
+@vertex
+fn tint_symbol_4(@builtin(vertex_index) tint_symbol_5 : u32) -> @builtin(position) vec4<f32> {
+ let tint_symbol_6 = tint_symbol(1);
+ let tint_symbol_7 : f32 = tint_symbol_2(tint_symbol_6.tint_symbol_1);
+ let tint_symbol_8 : bool = tint_symbol_3(tint_symbol_7);
+ return select(vec4<f32>(), vec4<f32>(1), tint_symbol_8);
+}
diff --git a/test/tint/shadowing/short_names/var.wgsl.expected.dxc.hlsl b/test/tint/shadowing/short_names/var.wgsl.expected.dxc.hlsl
index 8a019ba..c7f6db2 100644
--- a/test/tint/shadowing/short_names/var.wgsl.expected.dxc.hlsl
+++ b/test/tint/shadowing/short_names/var.wgsl.expected.dxc.hlsl
@@ -5,8 +5,8 @@
void f() {
{
- int vec3f = 1;
- int b = vec3f;
+ int vec3f_1 = 1;
+ int b = vec3f_1;
}
float3 c = (0.0f).xxx;
float3 d = (0.0f).xxx;
diff --git a/test/tint/shadowing/short_names/var.wgsl.expected.fxc.hlsl b/test/tint/shadowing/short_names/var.wgsl.expected.fxc.hlsl
index 8a019ba..c7f6db2 100644
--- a/test/tint/shadowing/short_names/var.wgsl.expected.fxc.hlsl
+++ b/test/tint/shadowing/short_names/var.wgsl.expected.fxc.hlsl
@@ -5,8 +5,8 @@
void f() {
{
- int vec3f = 1;
- int b = vec3f;
+ int vec3f_1 = 1;
+ int b = vec3f_1;
}
float3 c = (0.0f).xxx;
float3 d = (0.0f).xxx;
diff --git a/test/tint/shadowing/short_names/var.wgsl.expected.glsl b/test/tint/shadowing/short_names/var.wgsl.expected.glsl
index fc24838..36e810e 100644
--- a/test/tint/shadowing/short_names/var.wgsl.expected.glsl
+++ b/test/tint/shadowing/short_names/var.wgsl.expected.glsl
@@ -6,8 +6,8 @@
}
void f() {
{
- int vec3f = 1;
- int b = vec3f;
+ int vec3f_1 = 1;
+ int b = vec3f_1;
}
vec3 c = vec3(0.0f);
vec3 d = vec3(0.0f);
diff --git a/test/tint/shadowing/short_names/var.wgsl.expected.msl b/test/tint/shadowing/short_names/var.wgsl.expected.msl
index 1446f18..16f68a8 100644
--- a/test/tint/shadowing/short_names/var.wgsl.expected.msl
+++ b/test/tint/shadowing/short_names/var.wgsl.expected.msl
@@ -3,8 +3,8 @@
using namespace metal;
void f() {
{
- int vec3f = 1;
- int b = vec3f;
+ int vec3f_1 = 1;
+ int b = vec3f_1;
}
float3 c = float3(0.0f);
float3 d = float3(0.0f);
diff --git a/test/tint/types/short_names/short_names.wgsl b/test/tint/types/short_names/short_names.wgsl
new file mode 100644
index 0000000..513de4e
--- /dev/null
+++ b/test/tint/types/short_names/short_names.wgsl
@@ -0,0 +1,3 @@
+@vertex fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
+ return vec4f(vec2f(vec2i()), 0.0, 1.0);
+}
diff --git a/test/tint/types/short_names/short_names.wgsl.expected.dxc.hlsl b/test/tint/types/short_names/short_names.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..e32fc26
--- /dev/null
+++ b/test/tint/types/short_names/short_names.wgsl.expected.dxc.hlsl
@@ -0,0 +1,17 @@
+struct tint_symbol_1 {
+ uint VertexIndex : SV_VertexID;
+};
+struct tint_symbol_2 {
+ float4 value : SV_Position;
+};
+
+float4 main_inner(uint VertexIndex) {
+ return float4(0.0f, 0.0f, 0.0f, 1.0f);
+}
+
+tint_symbol_2 main(tint_symbol_1 tint_symbol) {
+ const float4 inner_result = main_inner(tint_symbol.VertexIndex);
+ tint_symbol_2 wrapper_result = (tint_symbol_2)0;
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
diff --git a/test/tint/types/short_names/short_names.wgsl.expected.fxc.hlsl b/test/tint/types/short_names/short_names.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..e32fc26
--- /dev/null
+++ b/test/tint/types/short_names/short_names.wgsl.expected.fxc.hlsl
@@ -0,0 +1,17 @@
+struct tint_symbol_1 {
+ uint VertexIndex : SV_VertexID;
+};
+struct tint_symbol_2 {
+ float4 value : SV_Position;
+};
+
+float4 main_inner(uint VertexIndex) {
+ return float4(0.0f, 0.0f, 0.0f, 1.0f);
+}
+
+tint_symbol_2 main(tint_symbol_1 tint_symbol) {
+ const float4 inner_result = main_inner(tint_symbol.VertexIndex);
+ tint_symbol_2 wrapper_result = (tint_symbol_2)0;
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
diff --git a/test/tint/types/short_names/short_names.wgsl.expected.glsl b/test/tint/types/short_names/short_names.wgsl.expected.glsl
new file mode 100644
index 0000000..44f88dc
--- /dev/null
+++ b/test/tint/types/short_names/short_names.wgsl.expected.glsl
@@ -0,0 +1,14 @@
+#version 310 es
+
+vec4 tint_symbol(uint VertexIndex) {
+ return vec4(0.0f, 0.0f, 0.0f, 1.0f);
+}
+
+void main() {
+ gl_PointSize = 1.0;
+ vec4 inner_result = tint_symbol(uint(gl_VertexID));
+ gl_Position = inner_result;
+ gl_Position.y = -(gl_Position.y);
+ gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
+ return;
+}
diff --git a/test/tint/types/short_names/short_names.wgsl.expected.msl b/test/tint/types/short_names/short_names.wgsl.expected.msl
new file mode 100644
index 0000000..db26a6c
--- /dev/null
+++ b/test/tint/types/short_names/short_names.wgsl.expected.msl
@@ -0,0 +1,18 @@
+#include <metal_stdlib>
+
+using namespace metal;
+struct tint_symbol_1 {
+ float4 value [[position]];
+};
+
+float4 tint_symbol_inner(uint VertexIndex) {
+ return float4(0.0f, 0.0f, 0.0f, 1.0f);
+}
+
+vertex tint_symbol_1 tint_symbol(uint VertexIndex [[vertex_id]]) {
+ float4 const inner_result = tint_symbol_inner(VertexIndex);
+ tint_symbol_1 wrapper_result = {};
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
+
diff --git a/test/tint/types/short_names/short_names.wgsl.expected.spvasm b/test/tint/types/short_names/short_names.wgsl.expected.spvasm
new file mode 100644
index 0000000..78b7de6
--- /dev/null
+++ b/test/tint/types/short_names/short_names.wgsl.expected.spvasm
@@ -0,0 +1,46 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 24
+; Schema: 0
+ OpCapability Shader
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint Vertex %main "main" %VertexIndex_1 %value %vertex_point_size
+ OpName %VertexIndex_1 "VertexIndex_1"
+ OpName %value "value"
+ OpName %vertex_point_size "vertex_point_size"
+ OpName %main_inner "main_inner"
+ OpName %VertexIndex "VertexIndex"
+ OpName %main "main"
+ OpDecorate %VertexIndex_1 BuiltIn VertexIndex
+ OpDecorate %value BuiltIn Position
+ OpDecorate %vertex_point_size BuiltIn PointSize
+ %uint = OpTypeInt 32 0
+%_ptr_Input_uint = OpTypePointer Input %uint
+%VertexIndex_1 = OpVariable %_ptr_Input_uint Input
+ %float = OpTypeFloat 32
+ %v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+ %8 = OpConstantNull %v4float
+ %value = OpVariable %_ptr_Output_v4float Output %8
+%_ptr_Output_float = OpTypePointer Output %float
+ %11 = OpConstantNull %float
+%vertex_point_size = OpVariable %_ptr_Output_float Output %11
+ %12 = OpTypeFunction %v4float %uint
+ %float_1 = OpConstant %float 1
+ %17 = OpConstantComposite %v4float %11 %11 %11 %float_1
+ %void = OpTypeVoid
+ %18 = OpTypeFunction %void
+ %main_inner = OpFunction %v4float None %12
+%VertexIndex = OpFunctionParameter %uint
+ %15 = OpLabel
+ OpReturnValue %17
+ OpFunctionEnd
+ %main = OpFunction %void None %18
+ %21 = OpLabel
+ %23 = OpLoad %uint %VertexIndex_1
+ %22 = OpFunctionCall %v4float %main_inner %23
+ OpStore %value %22
+ OpStore %vertex_point_size %float_1
+ OpReturn
+ OpFunctionEnd
diff --git a/test/tint/types/short_names/short_names.wgsl.expected.wgsl b/test/tint/types/short_names/short_names.wgsl.expected.wgsl
new file mode 100644
index 0000000..c78b01b
--- /dev/null
+++ b/test/tint/types/short_names/short_names.wgsl.expected.wgsl
@@ -0,0 +1,4 @@
+@vertex
+fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
+ return vec4f(vec2f(vec2i()), 0.0, 1.0);
+}