diff --git a/src/tint/intrinsics.def b/src/tint/intrinsics.def index b067e376b2..7853b14873 100644 --- a/src/tint/intrinsics.def +++ b/src/tint/intrinsics.def @@ -542,10 +542,10 @@ fn sqrt(vec) -> vec @const fn step(T, T) -> T @const fn step(vec, vec) -> vec @stage("compute") fn storageBarrier() -fn tan(T) -> T -fn tan(vec) -> vec -fn tanh(T) -> T -fn tanh(vec) -> vec +@const fn tan(T) -> T +@const fn tan(vec) -> vec +@const fn tanh(T) -> T +@const fn tanh(vec) -> vec fn transpose(mat) -> mat fn trunc(T) -> T fn trunc(vec) -> vec diff --git a/src/tint/resolver/const_eval.cc b/src/tint/resolver/const_eval.cc index e1a9f8b022..ab4da9799f 100644 --- a/src/tint/resolver/const_eval.cc +++ b/src/tint/resolver/const_eval.cc @@ -2351,6 +2351,32 @@ ConstEval::Result ConstEval::step(const sem::Type* ty, return TransformElements(builder, ty, transform, args[0], args[1]); } +ConstEval::Result ConstEval::tan(const sem::Type* ty, + utils::VectorRef args, + const Source&) { + auto transform = [&](const sem::Constant* c0) { + auto create = [&](auto i) -> ImplResult { + using NumberT = decltype(i); + return CreateElement(builder, c0->Type(), NumberT(std::tan(i.value))); + }; + return Dispatch_fa_f32_f16(create, c0); + }; + return TransformElements(builder, ty, transform, args[0]); +} + +ConstEval::Result ConstEval::tanh(const sem::Type* ty, + utils::VectorRef args, + const Source&) { + auto transform = [&](const sem::Constant* c0) { + auto create = [&](auto i) -> ImplResult { + using NumberT = decltype(i); + return CreateElement(builder, c0->Type(), NumberT(std::tanh(i.value))); + }; + return Dispatch_fa_f32_f16(create, c0); + }; + return TransformElements(builder, ty, transform, args[0]); +} + ConstEval::Result ConstEval::unpack2x16float(const sem::Type* ty, utils::VectorRef args, const Source& source) { diff --git a/src/tint/resolver/const_eval.h b/src/tint/resolver/const_eval.h index bd93f99153..7b2ee4ea6b 100644 --- a/src/tint/resolver/const_eval.h +++ b/src/tint/resolver/const_eval.h @@ -701,6 +701,24 @@ class ConstEval { utils::VectorRef args, const Source& source); + /// tan builtin + /// @param ty the expression type + /// @param args the input arguments + /// @param source the source location of the conversion + /// @return the result value, or null if the value cannot be calculated + Result tan(const sem::Type* ty, + utils::VectorRef args, + const Source& source); + + /// tanh builtin + /// @param ty the expression type + /// @param args the input arguments + /// @param source the source location of the conversion + /// @return the result value, or null if the value cannot be calculated + Result tanh(const sem::Type* ty, + utils::VectorRef args, + const Source& source); + /// unpack2x16float builtin /// @param ty the expression type /// @param args the input arguments diff --git a/src/tint/resolver/const_eval_builtin_test.cc b/src/tint/resolver/const_eval_builtin_test.cc index fe40cdca36..9437296c88 100644 --- a/src/tint/resolver/const_eval_builtin_test.cc +++ b/src/tint/resolver/const_eval_builtin_test.cc @@ -1607,6 +1607,49 @@ INSTANTIATE_TEST_SUITE_P( // StepCases(), StepCases())))); +template +std::vector TanCases() { + std::vector cases = { + C({-T(0)}, -T(0)), + C({T(0)}, T(0)), + C({T(.75)}, T(0.9315964599)).FloatComp(), + + // Vector test + C({Vec(T(0), -T(0), T(.75))}, Vec(T(0), -T(0), T(0.9315964599))).FloatComp(), + }; + + return cases; +} +INSTANTIATE_TEST_SUITE_P( // + Tan, + ResolverConstEvalBuiltinTest, + testing::Combine(testing::Values(sem::BuiltinType::kTan), + testing::ValuesIn(Concat(TanCases(), // + TanCases(), + TanCases())))); + +template +std::vector TanhCases() { + std::vector cases = { + C({T(0)}, T(0)), + C({-T(0)}, -T(0)), + C({T(1)}, T(0.761594156)).FloatComp(), + C({T(-1)}, -T(0.761594156)).FloatComp(), + + // Vector tests + C({Vec(T(0), -T(0), T(1))}, Vec(T(0), -T(0), T(0.761594156))).FloatComp(), + }; + + return cases; +} +INSTANTIATE_TEST_SUITE_P( // + Tanh, + ResolverConstEvalBuiltinTest, + testing::Combine(testing::Values(sem::BuiltinType::kTanh), + testing::ValuesIn(Concat(TanhCases(), // + TanhCases(), + TanhCases())))); + std::vector Unpack4x8snormCases() { return { C({Val(u32(0x0000'0000))}, Vec(f32(0), f32(0), f32(0), f32(0))), diff --git a/src/tint/resolver/intrinsic_table.inl b/src/tint/resolver/intrinsic_table.inl index 8c200054ea..47335a558a 100644 --- a/src/tint/resolver/intrinsic_table.inl +++ b/src/tint/resolver/intrinsic_table.inl @@ -12657,48 +12657,48 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 1, /* num template types */ 1, /* num template numbers */ 0, - /* template types */ &kTemplateTypes[25], + /* template types */ &kTemplateTypes[24], /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[869], /* return matcher indices */ &kMatcherIndices[1], /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::tan, }, { /* [361] */ /* num parameters */ 1, /* num template types */ 1, /* num template numbers */ 1, - /* template types */ &kTemplateTypes[25], + /* template types */ &kTemplateTypes[24], /* template numbers */ &kTemplateNumbers[5], /* parameters */ &kParameters[999], /* return matcher indices */ &kMatcherIndices[30], /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::tan, }, { /* [362] */ /* num parameters */ 1, /* num template types */ 1, /* num template numbers */ 0, - /* template types */ &kTemplateTypes[25], + /* template types */ &kTemplateTypes[24], /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[993], /* return matcher indices */ &kMatcherIndices[1], /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::tanh, }, { /* [363] */ /* num parameters */ 1, /* num template types */ 1, /* num template numbers */ 1, - /* template types */ &kTemplateTypes[25], + /* template types */ &kTemplateTypes[24], /* template numbers */ &kTemplateNumbers[5], /* parameters */ &kParameters[987], /* return matcher indices */ &kMatcherIndices[30], /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::tanh, }, { /* [364] */ @@ -14531,15 +14531,15 @@ constexpr IntrinsicInfo kBuiltins[] = { }, { /* [76] */ - /* fn tan(T) -> T */ - /* fn tan(vec) -> vec */ + /* fn tan(T) -> T */ + /* fn tan(vec) -> vec */ /* num overloads */ 2, /* overloads */ &kOverloads[360], }, { /* [77] */ - /* fn tanh(T) -> T */ - /* fn tanh(vec) -> vec */ + /* fn tanh(T) -> T */ + /* fn tanh(vec) -> vec */ /* num overloads */ 2, /* overloads */ &kOverloads[362], }, diff --git a/test/tint/builtins/gen/literal/tan/244e2a.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/tan/244e2a.wgsl.expected.dxc.hlsl index c3a9ade754..5e87d82e68 100644 --- a/test/tint/builtins/gen/literal/tan/244e2a.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/tan/244e2a.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void tan_244e2a() { - float4 res = tan((1.0f).xxxx); + float4 res = (1.557407737f).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tan/244e2a.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/tan/244e2a.wgsl.expected.fxc.hlsl index c3a9ade754..5e87d82e68 100644 --- a/test/tint/builtins/gen/literal/tan/244e2a.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/tan/244e2a.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void tan_244e2a() { - float4 res = tan((1.0f).xxxx); + float4 res = (1.557407737f).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tan/244e2a.wgsl.expected.glsl b/test/tint/builtins/gen/literal/tan/244e2a.wgsl.expected.glsl index 42276a14ab..c72c1bc156 100644 --- a/test/tint/builtins/gen/literal/tan/244e2a.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/tan/244e2a.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void tan_244e2a() { - vec4 res = tan(vec4(1.0f)); + vec4 res = vec4(1.557407737f); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void tan_244e2a() { - vec4 res = tan(vec4(1.0f)); + vec4 res = vec4(1.557407737f); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void tan_244e2a() { - vec4 res = tan(vec4(1.0f)); + vec4 res = vec4(1.557407737f); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/tan/244e2a.wgsl.expected.msl b/test/tint/builtins/gen/literal/tan/244e2a.wgsl.expected.msl index e405aaa9df..89614e344b 100644 --- a/test/tint/builtins/gen/literal/tan/244e2a.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/tan/244e2a.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void tan_244e2a() { - float4 res = tan(float4(1.0f)); + float4 res = float4(1.557407737f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tan/244e2a.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/tan/244e2a.wgsl.expected.spvasm index 13ef83a2d0..c22058c539 100644 --- a/test/tint/builtins/gen/literal/tan/244e2a.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/tan/244e2a.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 32 +; Bound: 31 ; Schema: 0 OpCapability Shader - %14 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -31,36 +30,36 @@ %vertex_point_size = OpVariable %_ptr_Output_float Output %8 %void = OpTypeVoid %9 = OpTypeFunction %void - %float_1 = OpConstant %float 1 - %16 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%float_1_55740774 = OpConstant %float 1.55740774 + %14 = OpConstantComposite %v4float %float_1_55740774 %float_1_55740774 %float_1_55740774 %float_1_55740774 %_ptr_Function_v4float = OpTypePointer Function %v4float - %19 = OpTypeFunction %v4float + %17 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %tan_244e2a = OpFunction %void None %9 %12 = OpLabel %res = OpVariable %_ptr_Function_v4float Function %5 - %13 = OpExtInst %v4float %14 Tan %16 - OpStore %res %13 + OpStore %res %14 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %19 - %21 = OpLabel - %22 = OpFunctionCall %void %tan_244e2a +%vertex_main_inner = OpFunction %v4float None %17 + %19 = OpLabel + %20 = OpFunctionCall %void %tan_244e2a OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %24 = OpLabel - %25 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %25 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %void %tan_244e2a + %26 = OpLabel + %27 = OpFunctionCall %void %tan_244e2a OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %30 = OpLabel - %31 = OpFunctionCall %void %tan_244e2a + %29 = OpLabel + %30 = OpFunctionCall %void %tan_244e2a OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/tan/2f030e.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/tan/2f030e.wgsl.expected.dxc.hlsl index 0ad9e4f702..29a7537131 100644 --- a/test/tint/builtins/gen/literal/tan/2f030e.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/tan/2f030e.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void tan_2f030e() { - float res = tan(1.0f); + float res = 1.557407737f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tan/2f030e.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/tan/2f030e.wgsl.expected.fxc.hlsl index 0ad9e4f702..29a7537131 100644 --- a/test/tint/builtins/gen/literal/tan/2f030e.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/tan/2f030e.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void tan_2f030e() { - float res = tan(1.0f); + float res = 1.557407737f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tan/2f030e.wgsl.expected.glsl b/test/tint/builtins/gen/literal/tan/2f030e.wgsl.expected.glsl index 3ce88ec1e3..c91a2de612 100644 --- a/test/tint/builtins/gen/literal/tan/2f030e.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/tan/2f030e.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void tan_2f030e() { - float res = tan(1.0f); + float res = 1.557407737f; } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void tan_2f030e() { - float res = tan(1.0f); + float res = 1.557407737f; } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void tan_2f030e() { - float res = tan(1.0f); + float res = 1.557407737f; } void compute_main() { diff --git a/test/tint/builtins/gen/literal/tan/2f030e.wgsl.expected.msl b/test/tint/builtins/gen/literal/tan/2f030e.wgsl.expected.msl index 71d071f975..61f231d0b6 100644 --- a/test/tint/builtins/gen/literal/tan/2f030e.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/tan/2f030e.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void tan_2f030e() { - float res = tan(1.0f); + float res = 1.557407737f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tan/2f030e.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/tan/2f030e.wgsl.expected.spvasm index 2ae773c835..22ae6e0074 100644 --- a/test/tint/builtins/gen/literal/tan/2f030e.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/tan/2f030e.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 31 +; Bound: 30 ; Schema: 0 OpCapability Shader - %14 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -31,35 +30,35 @@ %vertex_point_size = OpVariable %_ptr_Output_float Output %8 %void = OpTypeVoid %9 = OpTypeFunction %void - %float_1 = OpConstant %float 1 +%float_1_55740774 = OpConstant %float 1.55740774 %_ptr_Function_float = OpTypePointer Function %float - %18 = OpTypeFunction %v4float + %16 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %tan_2f030e = OpFunction %void None %9 %12 = OpLabel %res = OpVariable %_ptr_Function_float Function %8 - %13 = OpExtInst %float %14 Tan %float_1 - OpStore %res %13 + OpStore %res %float_1_55740774 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %18 - %20 = OpLabel - %21 = OpFunctionCall %void %tan_2f030e +%vertex_main_inner = OpFunction %v4float None %16 + %18 = OpLabel + %19 = OpFunctionCall %void %tan_2f030e OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %23 = OpLabel - %24 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %24 + %21 = OpLabel + %22 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %22 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %void %tan_2f030e + %25 = OpLabel + %26 = OpFunctionCall %void %tan_2f030e OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %29 = OpLabel - %30 = OpFunctionCall %void %tan_2f030e + %28 = OpLabel + %29 = OpFunctionCall %void %tan_2f030e OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/tan/311400.wgsl b/test/tint/builtins/gen/literal/tan/311400.wgsl new file mode 100644 index 0000000000..ccc803bf9d --- /dev/null +++ b/test/tint/builtins/gen/literal/tan/311400.wgsl @@ -0,0 +1,43 @@ +// 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. + +//////////////////////////////////////////////////////////////////////////////// +// File generated by tools/src/cmd/gen +// using the template: +// test/tint/builtins/gen/gen.wgsl.tmpl +// +// Do not modify this file directly +//////////////////////////////////////////////////////////////////////////////// + + +// fn tan(fa) -> fa +fn tan_311400() { + var res = tan(1.); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + tan_311400(); + return vec4(); +} + +@fragment +fn fragment_main() { + tan_311400(); +} + +@compute @workgroup_size(1) +fn compute_main() { + tan_311400(); +} diff --git a/test/tint/builtins/gen/literal/tan/311400.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/tan/311400.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..0473e416b3 --- /dev/null +++ b/test/tint/builtins/gen/literal/tan/311400.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void tan_311400() { + float res = 1.557407737f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + tan_311400(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + tan_311400(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + tan_311400(); + return; +} diff --git a/test/tint/builtins/gen/literal/tan/311400.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/tan/311400.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..0473e416b3 --- /dev/null +++ b/test/tint/builtins/gen/literal/tan/311400.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void tan_311400() { + float res = 1.557407737f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + tan_311400(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + tan_311400(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + tan_311400(); + return; +} diff --git a/test/tint/builtins/gen/literal/tan/311400.wgsl.expected.glsl b/test/tint/builtins/gen/literal/tan/311400.wgsl.expected.glsl new file mode 100644 index 0000000000..a3a2a8f642 --- /dev/null +++ b/test/tint/builtins/gen/literal/tan/311400.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void tan_311400() { + float res = 1.557407737f; +} + +vec4 vertex_main() { + tan_311400(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void tan_311400() { + float res = 1.557407737f; +} + +void fragment_main() { + tan_311400(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void tan_311400() { + float res = 1.557407737f; +} + +void compute_main() { + tan_311400(); +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() { + compute_main(); + return; +} diff --git a/test/tint/builtins/gen/literal/tan/311400.wgsl.expected.msl b/test/tint/builtins/gen/literal/tan/311400.wgsl.expected.msl new file mode 100644 index 0000000000..91762c342b --- /dev/null +++ b/test/tint/builtins/gen/literal/tan/311400.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void tan_311400() { + float res = 1.557407737f; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + tan_311400(); + return float4(0.0f); +} + +vertex tint_symbol vertex_main() { + float4 const inner_result = vertex_main_inner(); + tint_symbol wrapper_result = {}; + wrapper_result.value = inner_result; + return wrapper_result; +} + +fragment void fragment_main() { + tan_311400(); + return; +} + +kernel void compute_main() { + tan_311400(); + return; +} + diff --git a/test/tint/builtins/gen/literal/tan/311400.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/tan/311400.wgsl.expected.spvasm new file mode 100644 index 0000000000..38f896c419 --- /dev/null +++ b/test/tint/builtins/gen/literal/tan/311400.wgsl.expected.spvasm @@ -0,0 +1,64 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 30 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %tan_311400 "tan_311400" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void +%float_1_55740774 = OpConstant %float 1.55740774 +%_ptr_Function_float = OpTypePointer Function %float + %16 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 + %tan_311400 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_float Function %8 + OpStore %res %float_1_55740774 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %16 + %18 = OpLabel + %19 = OpFunctionCall %void %tan_311400 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %21 = OpLabel + %22 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %22 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %25 = OpLabel + %26 = OpFunctionCall %void %tan_311400 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %tan_311400 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/tan/311400.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/tan/311400.wgsl.expected.wgsl new file mode 100644 index 0000000000..6efe07399f --- /dev/null +++ b/test/tint/builtins/gen/literal/tan/311400.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn tan_311400() { + var res = tan(1.0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + tan_311400(); + return vec4(); +} + +@fragment +fn fragment_main() { + tan_311400(); +} + +@compute @workgroup_size(1) +fn compute_main() { + tan_311400(); +} diff --git a/test/tint/builtins/gen/literal/tan/539e54.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/tan/539e54.wgsl.expected.dxc.hlsl index 4de5feb396..805462de18 100644 --- a/test/tint/builtins/gen/literal/tan/539e54.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/tan/539e54.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void tan_539e54() { - vector res = tan((float16_t(1.0h)).xxxx); + vector res = (float16_t(1.556640625h)).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tan/539e54.wgsl.expected.glsl b/test/tint/builtins/gen/literal/tan/539e54.wgsl.expected.glsl index 2db4796c5e..6124538c4e 100644 --- a/test/tint/builtins/gen/literal/tan/539e54.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/tan/539e54.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void tan_539e54() { - f16vec4 res = tan(f16vec4(1.0hf)); + f16vec4 res = f16vec4(1.556640625hf); } vec4 vertex_main() { @@ -23,7 +23,7 @@ void main() { precision mediump float; void tan_539e54() { - f16vec4 res = tan(f16vec4(1.0hf)); + f16vec4 res = f16vec4(1.556640625hf); } void fragment_main() { @@ -38,7 +38,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void tan_539e54() { - f16vec4 res = tan(f16vec4(1.0hf)); + f16vec4 res = f16vec4(1.556640625hf); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/tan/539e54.wgsl.expected.msl b/test/tint/builtins/gen/literal/tan/539e54.wgsl.expected.msl index eabcb69bd5..421f63bcae 100644 --- a/test/tint/builtins/gen/literal/tan/539e54.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/tan/539e54.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void tan_539e54() { - half4 res = tan(half4(1.0h)); + half4 res = half4(1.556640625h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tan/539e54.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/tan/539e54.wgsl.expected.spvasm index 5c8e22859b..f4b37a03a0 100644 --- a/test/tint/builtins/gen/literal/tan/539e54.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/tan/539e54.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 36 +; Bound: 34 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %16 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -37,38 +36,37 @@ %9 = OpTypeFunction %void %half = OpTypeFloat 16 %v4half = OpTypeVector %half 4 -%half_0x1p_0 = OpConstant %half 0x1p+0 - %18 = OpConstantComposite %v4half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 +%half_0x1_8e8p_0 = OpConstant %half 0x1.8e8p+0 + %16 = OpConstantComposite %v4half %half_0x1_8e8p_0 %half_0x1_8e8p_0 %half_0x1_8e8p_0 %half_0x1_8e8p_0 %_ptr_Function_v4half = OpTypePointer Function %v4half - %21 = OpConstantNull %v4half - %22 = OpTypeFunction %v4float + %19 = OpConstantNull %v4half + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %tan_539e54 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v4half Function %21 - %13 = OpExtInst %v4half %16 Tan %18 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v4half Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %22 - %24 = OpLabel - %25 = OpFunctionCall %void %tan_539e54 +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %tan_539e54 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %28 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %31 = OpLabel - %32 = OpFunctionCall %void %tan_539e54 + %29 = OpLabel + %30 = OpFunctionCall %void %tan_539e54 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %tan_539e54 + %32 = OpLabel + %33 = OpFunctionCall %void %tan_539e54 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/tan/7be368.wgsl b/test/tint/builtins/gen/literal/tan/7be368.wgsl new file mode 100644 index 0000000000..3fde5d164b --- /dev/null +++ b/test/tint/builtins/gen/literal/tan/7be368.wgsl @@ -0,0 +1,43 @@ +// 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. + +//////////////////////////////////////////////////////////////////////////////// +// File generated by tools/src/cmd/gen +// using the template: +// test/tint/builtins/gen/gen.wgsl.tmpl +// +// Do not modify this file directly +//////////////////////////////////////////////////////////////////////////////// + + +// fn tan(vec<2, fa>) -> vec<2, fa> +fn tan_7be368() { + var res = tan(vec2(1.)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + tan_7be368(); + return vec4(); +} + +@fragment +fn fragment_main() { + tan_7be368(); +} + +@compute @workgroup_size(1) +fn compute_main() { + tan_7be368(); +} diff --git a/test/tint/builtins/gen/literal/tan/7be368.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/tan/7be368.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..8e47663da5 --- /dev/null +++ b/test/tint/builtins/gen/literal/tan/7be368.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void tan_7be368() { + float2 res = (1.557407737f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + tan_7be368(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + tan_7be368(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + tan_7be368(); + return; +} diff --git a/test/tint/builtins/gen/literal/tan/7be368.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/tan/7be368.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..8e47663da5 --- /dev/null +++ b/test/tint/builtins/gen/literal/tan/7be368.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void tan_7be368() { + float2 res = (1.557407737f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + tan_7be368(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + tan_7be368(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + tan_7be368(); + return; +} diff --git a/test/tint/builtins/gen/literal/tan/7be368.wgsl.expected.glsl b/test/tint/builtins/gen/literal/tan/7be368.wgsl.expected.glsl new file mode 100644 index 0000000000..32f4892cbe --- /dev/null +++ b/test/tint/builtins/gen/literal/tan/7be368.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void tan_7be368() { + vec2 res = vec2(1.557407737f); +} + +vec4 vertex_main() { + tan_7be368(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void tan_7be368() { + vec2 res = vec2(1.557407737f); +} + +void fragment_main() { + tan_7be368(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void tan_7be368() { + vec2 res = vec2(1.557407737f); +} + +void compute_main() { + tan_7be368(); +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() { + compute_main(); + return; +} diff --git a/test/tint/builtins/gen/literal/tan/7be368.wgsl.expected.msl b/test/tint/builtins/gen/literal/tan/7be368.wgsl.expected.msl new file mode 100644 index 0000000000..106ec06887 --- /dev/null +++ b/test/tint/builtins/gen/literal/tan/7be368.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void tan_7be368() { + float2 res = float2(1.557407737f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + tan_7be368(); + return float4(0.0f); +} + +vertex tint_symbol vertex_main() { + float4 const inner_result = vertex_main_inner(); + tint_symbol wrapper_result = {}; + wrapper_result.value = inner_result; + return wrapper_result; +} + +fragment void fragment_main() { + tan_7be368(); + return; +} + +kernel void compute_main() { + tan_7be368(); + return; +} + diff --git a/test/tint/builtins/gen/literal/tan/7be368.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/tan/7be368.wgsl.expected.spvasm new file mode 100644 index 0000000000..815423c769 --- /dev/null +++ b/test/tint/builtins/gen/literal/tan/7be368.wgsl.expected.spvasm @@ -0,0 +1,67 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 33 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %tan_7be368 "tan_7be368" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %v2float = OpTypeVector %float 2 +%float_1_55740774 = OpConstant %float 1.55740774 + %15 = OpConstantComposite %v2float %float_1_55740774 %float_1_55740774 +%_ptr_Function_v2float = OpTypePointer Function %v2float + %18 = OpConstantNull %v2float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 + %tan_7be368 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v2float Function %18 + OpStore %res %15 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %tan_7be368 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %tan_7be368 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %31 = OpLabel + %32 = OpFunctionCall %void %tan_7be368 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/tan/7be368.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/tan/7be368.wgsl.expected.wgsl new file mode 100644 index 0000000000..42ea0a08ce --- /dev/null +++ b/test/tint/builtins/gen/literal/tan/7be368.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn tan_7be368() { + var res = tan(vec2(1.0)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + tan_7be368(); + return vec4(); +} + +@fragment +fn fragment_main() { + tan_7be368(); +} + +@compute @workgroup_size(1) +fn compute_main() { + tan_7be368(); +} diff --git a/test/tint/builtins/gen/literal/tan/7ea104.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/tan/7ea104.wgsl.expected.dxc.hlsl index 3bfa5d96e4..15be1b36a3 100644 --- a/test/tint/builtins/gen/literal/tan/7ea104.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/tan/7ea104.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void tan_7ea104() { - float3 res = tan((1.0f).xxx); + float3 res = (1.557407737f).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tan/7ea104.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/tan/7ea104.wgsl.expected.fxc.hlsl index 3bfa5d96e4..15be1b36a3 100644 --- a/test/tint/builtins/gen/literal/tan/7ea104.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/tan/7ea104.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void tan_7ea104() { - float3 res = tan((1.0f).xxx); + float3 res = (1.557407737f).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tan/7ea104.wgsl.expected.glsl b/test/tint/builtins/gen/literal/tan/7ea104.wgsl.expected.glsl index 2efb95c1eb..cc4dcc125a 100644 --- a/test/tint/builtins/gen/literal/tan/7ea104.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/tan/7ea104.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void tan_7ea104() { - vec3 res = tan(vec3(1.0f)); + vec3 res = vec3(1.557407737f); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void tan_7ea104() { - vec3 res = tan(vec3(1.0f)); + vec3 res = vec3(1.557407737f); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void tan_7ea104() { - vec3 res = tan(vec3(1.0f)); + vec3 res = vec3(1.557407737f); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/tan/7ea104.wgsl.expected.msl b/test/tint/builtins/gen/literal/tan/7ea104.wgsl.expected.msl index bd468e30e4..8b61237fe7 100644 --- a/test/tint/builtins/gen/literal/tan/7ea104.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/tan/7ea104.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void tan_7ea104() { - float3 res = tan(float3(1.0f)); + float3 res = float3(1.557407737f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tan/7ea104.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/tan/7ea104.wgsl.expected.spvasm index 89ebac125e..35d875b82e 100644 --- a/test/tint/builtins/gen/literal/tan/7ea104.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/tan/7ea104.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 34 +; Bound: 33 ; Schema: 0 OpCapability Shader - %15 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -32,37 +31,37 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %v3float = OpTypeVector %float 3 - %float_1 = OpConstant %float 1 - %17 = OpConstantComposite %v3float %float_1 %float_1 %float_1 +%float_1_55740774 = OpConstant %float 1.55740774 + %15 = OpConstantComposite %v3float %float_1_55740774 %float_1_55740774 %float_1_55740774 %_ptr_Function_v3float = OpTypePointer Function %v3float - %20 = OpConstantNull %v3float - %21 = OpTypeFunction %v4float + %18 = OpConstantNull %v3float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %tan_7ea104 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v3float Function %20 - %13 = OpExtInst %v3float %15 Tan %17 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v3float Function %18 + OpStore %res %15 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %21 - %23 = OpLabel - %24 = OpFunctionCall %void %tan_7ea104 +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %tan_7ea104 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %27 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %29 = OpLabel - %30 = OpFunctionCall %void %tan_7ea104 + %28 = OpLabel + %29 = OpFunctionCall %void %tan_7ea104 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %32 = OpLabel - %33 = OpFunctionCall %void %tan_7ea104 + %31 = OpLabel + %32 = OpFunctionCall %void %tan_7ea104 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/tan/8ce3e9.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/tan/8ce3e9.wgsl.expected.dxc.hlsl index 72b2654940..2ae30e900f 100644 --- a/test/tint/builtins/gen/literal/tan/8ce3e9.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/tan/8ce3e9.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void tan_8ce3e9() { - float2 res = tan((1.0f).xx); + float2 res = (1.557407737f).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tan/8ce3e9.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/tan/8ce3e9.wgsl.expected.fxc.hlsl index 72b2654940..2ae30e900f 100644 --- a/test/tint/builtins/gen/literal/tan/8ce3e9.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/tan/8ce3e9.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void tan_8ce3e9() { - float2 res = tan((1.0f).xx); + float2 res = (1.557407737f).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tan/8ce3e9.wgsl.expected.glsl b/test/tint/builtins/gen/literal/tan/8ce3e9.wgsl.expected.glsl index 801605f315..de1d43bfc4 100644 --- a/test/tint/builtins/gen/literal/tan/8ce3e9.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/tan/8ce3e9.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void tan_8ce3e9() { - vec2 res = tan(vec2(1.0f)); + vec2 res = vec2(1.557407737f); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void tan_8ce3e9() { - vec2 res = tan(vec2(1.0f)); + vec2 res = vec2(1.557407737f); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void tan_8ce3e9() { - vec2 res = tan(vec2(1.0f)); + vec2 res = vec2(1.557407737f); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/tan/8ce3e9.wgsl.expected.msl b/test/tint/builtins/gen/literal/tan/8ce3e9.wgsl.expected.msl index 53ffb9a889..f90db0d1fe 100644 --- a/test/tint/builtins/gen/literal/tan/8ce3e9.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/tan/8ce3e9.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void tan_8ce3e9() { - float2 res = tan(float2(1.0f)); + float2 res = float2(1.557407737f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tan/8ce3e9.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/tan/8ce3e9.wgsl.expected.spvasm index 8cbcd32f51..beaa457312 100644 --- a/test/tint/builtins/gen/literal/tan/8ce3e9.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/tan/8ce3e9.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 34 +; Bound: 33 ; Schema: 0 OpCapability Shader - %15 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -32,37 +31,37 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %v2float = OpTypeVector %float 2 - %float_1 = OpConstant %float 1 - %17 = OpConstantComposite %v2float %float_1 %float_1 +%float_1_55740774 = OpConstant %float 1.55740774 + %15 = OpConstantComposite %v2float %float_1_55740774 %float_1_55740774 %_ptr_Function_v2float = OpTypePointer Function %v2float - %20 = OpConstantNull %v2float - %21 = OpTypeFunction %v4float + %18 = OpConstantNull %v2float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %tan_8ce3e9 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v2float Function %20 - %13 = OpExtInst %v2float %15 Tan %17 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v2float Function %18 + OpStore %res %15 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %21 - %23 = OpLabel - %24 = OpFunctionCall %void %tan_8ce3e9 +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %tan_8ce3e9 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %27 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %29 = OpLabel - %30 = OpFunctionCall %void %tan_8ce3e9 + %28 = OpLabel + %29 = OpFunctionCall %void %tan_8ce3e9 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %32 = OpLabel - %33 = OpFunctionCall %void %tan_8ce3e9 + %31 = OpLabel + %32 = OpFunctionCall %void %tan_8ce3e9 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/tan/9f7c9c.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/tan/9f7c9c.wgsl.expected.dxc.hlsl index 563a5cc9ce..d4214b65f6 100644 --- a/test/tint/builtins/gen/literal/tan/9f7c9c.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/tan/9f7c9c.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void tan_9f7c9c() { - vector res = tan((float16_t(1.0h)).xx); + vector res = (float16_t(1.556640625h)).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tan/9f7c9c.wgsl.expected.glsl b/test/tint/builtins/gen/literal/tan/9f7c9c.wgsl.expected.glsl index 765a8a1fe2..853566007a 100644 --- a/test/tint/builtins/gen/literal/tan/9f7c9c.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/tan/9f7c9c.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void tan_9f7c9c() { - f16vec2 res = tan(f16vec2(1.0hf)); + f16vec2 res = f16vec2(1.556640625hf); } vec4 vertex_main() { @@ -23,7 +23,7 @@ void main() { precision mediump float; void tan_9f7c9c() { - f16vec2 res = tan(f16vec2(1.0hf)); + f16vec2 res = f16vec2(1.556640625hf); } void fragment_main() { @@ -38,7 +38,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void tan_9f7c9c() { - f16vec2 res = tan(f16vec2(1.0hf)); + f16vec2 res = f16vec2(1.556640625hf); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/tan/9f7c9c.wgsl.expected.msl b/test/tint/builtins/gen/literal/tan/9f7c9c.wgsl.expected.msl index 7780f429f2..c34a6af4a1 100644 --- a/test/tint/builtins/gen/literal/tan/9f7c9c.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/tan/9f7c9c.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void tan_9f7c9c() { - half2 res = tan(half2(1.0h)); + half2 res = half2(1.556640625h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tan/9f7c9c.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/tan/9f7c9c.wgsl.expected.spvasm index ef0a883626..498bb0696e 100644 --- a/test/tint/builtins/gen/literal/tan/9f7c9c.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/tan/9f7c9c.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 36 +; Bound: 34 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %16 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -37,38 +36,37 @@ %9 = OpTypeFunction %void %half = OpTypeFloat 16 %v2half = OpTypeVector %half 2 -%half_0x1p_0 = OpConstant %half 0x1p+0 - %18 = OpConstantComposite %v2half %half_0x1p_0 %half_0x1p_0 +%half_0x1_8e8p_0 = OpConstant %half 0x1.8e8p+0 + %16 = OpConstantComposite %v2half %half_0x1_8e8p_0 %half_0x1_8e8p_0 %_ptr_Function_v2half = OpTypePointer Function %v2half - %21 = OpConstantNull %v2half - %22 = OpTypeFunction %v4float + %19 = OpConstantNull %v2half + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %tan_9f7c9c = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v2half Function %21 - %13 = OpExtInst %v2half %16 Tan %18 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v2half Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %22 - %24 = OpLabel - %25 = OpFunctionCall %void %tan_9f7c9c +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %tan_9f7c9c OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %28 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %31 = OpLabel - %32 = OpFunctionCall %void %tan_9f7c9c + %29 = OpLabel + %30 = OpFunctionCall %void %tan_9f7c9c OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %tan_9f7c9c + %32 = OpLabel + %33 = OpFunctionCall %void %tan_9f7c9c OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/tan/a0966f.wgsl b/test/tint/builtins/gen/literal/tan/a0966f.wgsl new file mode 100644 index 0000000000..2074ffad36 --- /dev/null +++ b/test/tint/builtins/gen/literal/tan/a0966f.wgsl @@ -0,0 +1,43 @@ +// 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. + +//////////////////////////////////////////////////////////////////////////////// +// File generated by tools/src/cmd/gen +// using the template: +// test/tint/builtins/gen/gen.wgsl.tmpl +// +// Do not modify this file directly +//////////////////////////////////////////////////////////////////////////////// + + +// fn tan(vec<4, fa>) -> vec<4, fa> +fn tan_a0966f() { + var res = tan(vec4(1.)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + tan_a0966f(); + return vec4(); +} + +@fragment +fn fragment_main() { + tan_a0966f(); +} + +@compute @workgroup_size(1) +fn compute_main() { + tan_a0966f(); +} diff --git a/test/tint/builtins/gen/literal/tan/a0966f.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/tan/a0966f.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..fcb1fb73d6 --- /dev/null +++ b/test/tint/builtins/gen/literal/tan/a0966f.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void tan_a0966f() { + float4 res = (1.557407737f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + tan_a0966f(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + tan_a0966f(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + tan_a0966f(); + return; +} diff --git a/test/tint/builtins/gen/literal/tan/a0966f.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/tan/a0966f.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..fcb1fb73d6 --- /dev/null +++ b/test/tint/builtins/gen/literal/tan/a0966f.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void tan_a0966f() { + float4 res = (1.557407737f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + tan_a0966f(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + tan_a0966f(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + tan_a0966f(); + return; +} diff --git a/test/tint/builtins/gen/literal/tan/a0966f.wgsl.expected.glsl b/test/tint/builtins/gen/literal/tan/a0966f.wgsl.expected.glsl new file mode 100644 index 0000000000..ffdb3018cb --- /dev/null +++ b/test/tint/builtins/gen/literal/tan/a0966f.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void tan_a0966f() { + vec4 res = vec4(1.557407737f); +} + +vec4 vertex_main() { + tan_a0966f(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void tan_a0966f() { + vec4 res = vec4(1.557407737f); +} + +void fragment_main() { + tan_a0966f(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void tan_a0966f() { + vec4 res = vec4(1.557407737f); +} + +void compute_main() { + tan_a0966f(); +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() { + compute_main(); + return; +} diff --git a/test/tint/builtins/gen/literal/tan/a0966f.wgsl.expected.msl b/test/tint/builtins/gen/literal/tan/a0966f.wgsl.expected.msl new file mode 100644 index 0000000000..958b44bdc0 --- /dev/null +++ b/test/tint/builtins/gen/literal/tan/a0966f.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void tan_a0966f() { + float4 res = float4(1.557407737f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + tan_a0966f(); + return float4(0.0f); +} + +vertex tint_symbol vertex_main() { + float4 const inner_result = vertex_main_inner(); + tint_symbol wrapper_result = {}; + wrapper_result.value = inner_result; + return wrapper_result; +} + +fragment void fragment_main() { + tan_a0966f(); + return; +} + +kernel void compute_main() { + tan_a0966f(); + return; +} + diff --git a/test/tint/builtins/gen/literal/tan/a0966f.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/tan/a0966f.wgsl.expected.spvasm new file mode 100644 index 0000000000..fa5a70e2ae --- /dev/null +++ b/test/tint/builtins/gen/literal/tan/a0966f.wgsl.expected.spvasm @@ -0,0 +1,65 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 31 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %tan_a0966f "tan_a0966f" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void +%float_1_55740774 = OpConstant %float 1.55740774 + %14 = OpConstantComposite %v4float %float_1_55740774 %float_1_55740774 %float_1_55740774 %float_1_55740774 +%_ptr_Function_v4float = OpTypePointer Function %v4float + %17 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 + %tan_a0966f = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v4float Function %5 + OpStore %res %14 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %17 + %19 = OpLabel + %20 = OpFunctionCall %void %tan_a0966f + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %26 = OpLabel + %27 = OpFunctionCall %void %tan_a0966f + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %29 = OpLabel + %30 = OpFunctionCall %void %tan_a0966f + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/tan/a0966f.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/tan/a0966f.wgsl.expected.wgsl new file mode 100644 index 0000000000..3f4686b092 --- /dev/null +++ b/test/tint/builtins/gen/literal/tan/a0966f.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn tan_a0966f() { + var res = tan(vec4(1.0)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + tan_a0966f(); + return vec4(); +} + +@fragment +fn fragment_main() { + tan_a0966f(); +} + +@compute @workgroup_size(1) +fn compute_main() { + tan_a0966f(); +} diff --git a/test/tint/builtins/gen/literal/tan/ae26ae.wgsl b/test/tint/builtins/gen/literal/tan/ae26ae.wgsl new file mode 100644 index 0000000000..a65840241b --- /dev/null +++ b/test/tint/builtins/gen/literal/tan/ae26ae.wgsl @@ -0,0 +1,43 @@ +// 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. + +//////////////////////////////////////////////////////////////////////////////// +// File generated by tools/src/cmd/gen +// using the template: +// test/tint/builtins/gen/gen.wgsl.tmpl +// +// Do not modify this file directly +//////////////////////////////////////////////////////////////////////////////// + + +// fn tan(vec<3, fa>) -> vec<3, fa> +fn tan_ae26ae() { + var res = tan(vec3(1.)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + tan_ae26ae(); + return vec4(); +} + +@fragment +fn fragment_main() { + tan_ae26ae(); +} + +@compute @workgroup_size(1) +fn compute_main() { + tan_ae26ae(); +} diff --git a/test/tint/builtins/gen/literal/tan/ae26ae.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/tan/ae26ae.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..3b0cc0030e --- /dev/null +++ b/test/tint/builtins/gen/literal/tan/ae26ae.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void tan_ae26ae() { + float3 res = (1.557407737f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + tan_ae26ae(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + tan_ae26ae(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + tan_ae26ae(); + return; +} diff --git a/test/tint/builtins/gen/literal/tan/ae26ae.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/tan/ae26ae.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..3b0cc0030e --- /dev/null +++ b/test/tint/builtins/gen/literal/tan/ae26ae.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void tan_ae26ae() { + float3 res = (1.557407737f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + tan_ae26ae(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + tan_ae26ae(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + tan_ae26ae(); + return; +} diff --git a/test/tint/builtins/gen/literal/tan/ae26ae.wgsl.expected.glsl b/test/tint/builtins/gen/literal/tan/ae26ae.wgsl.expected.glsl new file mode 100644 index 0000000000..bebd2774ab --- /dev/null +++ b/test/tint/builtins/gen/literal/tan/ae26ae.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void tan_ae26ae() { + vec3 res = vec3(1.557407737f); +} + +vec4 vertex_main() { + tan_ae26ae(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void tan_ae26ae() { + vec3 res = vec3(1.557407737f); +} + +void fragment_main() { + tan_ae26ae(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void tan_ae26ae() { + vec3 res = vec3(1.557407737f); +} + +void compute_main() { + tan_ae26ae(); +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() { + compute_main(); + return; +} diff --git a/test/tint/builtins/gen/literal/tan/ae26ae.wgsl.expected.msl b/test/tint/builtins/gen/literal/tan/ae26ae.wgsl.expected.msl new file mode 100644 index 0000000000..6f230972ae --- /dev/null +++ b/test/tint/builtins/gen/literal/tan/ae26ae.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void tan_ae26ae() { + float3 res = float3(1.557407737f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + tan_ae26ae(); + return float4(0.0f); +} + +vertex tint_symbol vertex_main() { + float4 const inner_result = vertex_main_inner(); + tint_symbol wrapper_result = {}; + wrapper_result.value = inner_result; + return wrapper_result; +} + +fragment void fragment_main() { + tan_ae26ae(); + return; +} + +kernel void compute_main() { + tan_ae26ae(); + return; +} + diff --git a/test/tint/builtins/gen/literal/tan/ae26ae.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/tan/ae26ae.wgsl.expected.spvasm new file mode 100644 index 0000000000..f1796b018a --- /dev/null +++ b/test/tint/builtins/gen/literal/tan/ae26ae.wgsl.expected.spvasm @@ -0,0 +1,67 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 33 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %tan_ae26ae "tan_ae26ae" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %v3float = OpTypeVector %float 3 +%float_1_55740774 = OpConstant %float 1.55740774 + %15 = OpConstantComposite %v3float %float_1_55740774 %float_1_55740774 %float_1_55740774 +%_ptr_Function_v3float = OpTypePointer Function %v3float + %18 = OpConstantNull %v3float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 + %tan_ae26ae = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v3float Function %18 + OpStore %res %15 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %tan_ae26ae + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %tan_ae26ae + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %31 = OpLabel + %32 = OpFunctionCall %void %tan_ae26ae + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/tan/ae26ae.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/tan/ae26ae.wgsl.expected.wgsl new file mode 100644 index 0000000000..e824816c81 --- /dev/null +++ b/test/tint/builtins/gen/literal/tan/ae26ae.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn tan_ae26ae() { + var res = tan(vec3(1.0)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + tan_ae26ae(); + return vec4(); +} + +@fragment +fn fragment_main() { + tan_ae26ae(); +} + +@compute @workgroup_size(1) +fn compute_main() { + tan_ae26ae(); +} diff --git a/test/tint/builtins/gen/literal/tan/d4d491.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/tan/d4d491.wgsl.expected.dxc.hlsl index 511c901c98..c3bfdc09a8 100644 --- a/test/tint/builtins/gen/literal/tan/d4d491.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/tan/d4d491.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void tan_d4d491() { - float16_t res = tan(float16_t(1.0h)); + float16_t res = float16_t(1.556640625h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tan/d4d491.wgsl.expected.glsl b/test/tint/builtins/gen/literal/tan/d4d491.wgsl.expected.glsl index 05e0766271..8c4e4020f0 100644 --- a/test/tint/builtins/gen/literal/tan/d4d491.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/tan/d4d491.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void tan_d4d491() { - float16_t res = tan(1.0hf); + float16_t res = 1.556640625hf; } vec4 vertex_main() { @@ -23,7 +23,7 @@ void main() { precision mediump float; void tan_d4d491() { - float16_t res = tan(1.0hf); + float16_t res = 1.556640625hf; } void fragment_main() { @@ -38,7 +38,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void tan_d4d491() { - float16_t res = tan(1.0hf); + float16_t res = 1.556640625hf; } void compute_main() { diff --git a/test/tint/builtins/gen/literal/tan/d4d491.wgsl.expected.msl b/test/tint/builtins/gen/literal/tan/d4d491.wgsl.expected.msl index fb3879e21e..f5fb65e674 100644 --- a/test/tint/builtins/gen/literal/tan/d4d491.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/tan/d4d491.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void tan_d4d491() { - half res = tan(1.0h); + half res = 1.556640625h; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tan/d4d491.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/tan/d4d491.wgsl.expected.spvasm index af79640575..1c6617bea1 100644 --- a/test/tint/builtins/gen/literal/tan/d4d491.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/tan/d4d491.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 34 +; Bound: 32 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %15 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -36,37 +35,36 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %half = OpTypeFloat 16 -%half_0x1p_0 = OpConstant %half 0x1p+0 +%half_0x1_8e8p_0 = OpConstant %half 0x1.8e8p+0 %_ptr_Function_half = OpTypePointer Function %half - %19 = OpConstantNull %half - %20 = OpTypeFunction %v4float + %17 = OpConstantNull %half + %18 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %tan_d4d491 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_half Function %19 - %13 = OpExtInst %half %15 Tan %half_0x1p_0 - OpStore %res %13 + %res = OpVariable %_ptr_Function_half Function %17 + OpStore %res %half_0x1_8e8p_0 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %20 - %22 = OpLabel - %23 = OpFunctionCall %void %tan_d4d491 +%vertex_main_inner = OpFunction %v4float None %18 + %20 = OpLabel + %21 = OpFunctionCall %void %tan_d4d491 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %25 = OpLabel - %26 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %26 + %23 = OpLabel + %24 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %24 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %29 = OpLabel - %30 = OpFunctionCall %void %tan_d4d491 + %27 = OpLabel + %28 = OpFunctionCall %void %tan_d4d491 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %32 = OpLabel - %33 = OpFunctionCall %void %tan_d4d491 + %30 = OpLabel + %31 = OpFunctionCall %void %tan_d4d491 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/tan/db0456.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/tan/db0456.wgsl.expected.dxc.hlsl index 5899c367b5..aeb13ade1c 100644 --- a/test/tint/builtins/gen/literal/tan/db0456.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/tan/db0456.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void tan_db0456() { - vector res = tan((float16_t(1.0h)).xxx); + vector res = (float16_t(1.556640625h)).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tan/db0456.wgsl.expected.glsl b/test/tint/builtins/gen/literal/tan/db0456.wgsl.expected.glsl index fe3badef59..73fa5a06fa 100644 --- a/test/tint/builtins/gen/literal/tan/db0456.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/tan/db0456.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void tan_db0456() { - f16vec3 res = tan(f16vec3(1.0hf)); + f16vec3 res = f16vec3(1.556640625hf); } vec4 vertex_main() { @@ -23,7 +23,7 @@ void main() { precision mediump float; void tan_db0456() { - f16vec3 res = tan(f16vec3(1.0hf)); + f16vec3 res = f16vec3(1.556640625hf); } void fragment_main() { @@ -38,7 +38,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void tan_db0456() { - f16vec3 res = tan(f16vec3(1.0hf)); + f16vec3 res = f16vec3(1.556640625hf); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/tan/db0456.wgsl.expected.msl b/test/tint/builtins/gen/literal/tan/db0456.wgsl.expected.msl index 7adab5625d..22a16b81a6 100644 --- a/test/tint/builtins/gen/literal/tan/db0456.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/tan/db0456.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void tan_db0456() { - half3 res = tan(half3(1.0h)); + half3 res = half3(1.556640625h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tan/db0456.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/tan/db0456.wgsl.expected.spvasm index a66872b94f..54521236f9 100644 --- a/test/tint/builtins/gen/literal/tan/db0456.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/tan/db0456.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 36 +; Bound: 34 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %16 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -37,38 +36,37 @@ %9 = OpTypeFunction %void %half = OpTypeFloat 16 %v3half = OpTypeVector %half 3 -%half_0x1p_0 = OpConstant %half 0x1p+0 - %18 = OpConstantComposite %v3half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 +%half_0x1_8e8p_0 = OpConstant %half 0x1.8e8p+0 + %16 = OpConstantComposite %v3half %half_0x1_8e8p_0 %half_0x1_8e8p_0 %half_0x1_8e8p_0 %_ptr_Function_v3half = OpTypePointer Function %v3half - %21 = OpConstantNull %v3half - %22 = OpTypeFunction %v4float + %19 = OpConstantNull %v3half + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %tan_db0456 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v3half Function %21 - %13 = OpExtInst %v3half %16 Tan %18 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v3half Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %22 - %24 = OpLabel - %25 = OpFunctionCall %void %tan_db0456 +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %tan_db0456 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %28 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %31 = OpLabel - %32 = OpFunctionCall %void %tan_db0456 + %29 = OpLabel + %30 = OpFunctionCall %void %tan_db0456 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %tan_db0456 + %32 = OpLabel + %33 = OpFunctionCall %void %tan_db0456 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/tanh/06a4fe.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/tanh/06a4fe.wgsl.expected.dxc.hlsl index 7bd1656acf..d716d36862 100644 --- a/test/tint/builtins/gen/literal/tanh/06a4fe.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/tanh/06a4fe.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void tanh_06a4fe() { - vector res = tanh((float16_t(1.0h)).xxx); + vector res = (float16_t(0.761230469h)).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tanh/06a4fe.wgsl.expected.glsl b/test/tint/builtins/gen/literal/tanh/06a4fe.wgsl.expected.glsl index 3b1ec6b728..99c867ab3f 100644 --- a/test/tint/builtins/gen/literal/tanh/06a4fe.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/tanh/06a4fe.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void tanh_06a4fe() { - f16vec3 res = tanh(f16vec3(1.0hf)); + f16vec3 res = f16vec3(0.761230469hf); } vec4 vertex_main() { @@ -23,7 +23,7 @@ void main() { precision mediump float; void tanh_06a4fe() { - f16vec3 res = tanh(f16vec3(1.0hf)); + f16vec3 res = f16vec3(0.761230469hf); } void fragment_main() { @@ -38,7 +38,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void tanh_06a4fe() { - f16vec3 res = tanh(f16vec3(1.0hf)); + f16vec3 res = f16vec3(0.761230469hf); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/tanh/06a4fe.wgsl.expected.msl b/test/tint/builtins/gen/literal/tanh/06a4fe.wgsl.expected.msl index 7a53efae11..c398ee2819 100644 --- a/test/tint/builtins/gen/literal/tanh/06a4fe.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/tanh/06a4fe.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void tanh_06a4fe() { - half3 res = tanh(half3(1.0h)); + half3 res = half3(0.761230469h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tanh/06a4fe.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/tanh/06a4fe.wgsl.expected.spvasm index 0c187bfd4b..315d386863 100644 --- a/test/tint/builtins/gen/literal/tanh/06a4fe.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/tanh/06a4fe.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 36 +; Bound: 34 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %16 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -37,38 +36,37 @@ %9 = OpTypeFunction %void %half = OpTypeFloat 16 %v3half = OpTypeVector %half 3 -%half_0x1p_0 = OpConstant %half 0x1p+0 - %18 = OpConstantComposite %v3half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 +%half_0x1_85cpn1 = OpConstant %half 0x1.85cp-1 + %16 = OpConstantComposite %v3half %half_0x1_85cpn1 %half_0x1_85cpn1 %half_0x1_85cpn1 %_ptr_Function_v3half = OpTypePointer Function %v3half - %21 = OpConstantNull %v3half - %22 = OpTypeFunction %v4float + %19 = OpConstantNull %v3half + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %tanh_06a4fe = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v3half Function %21 - %13 = OpExtInst %v3half %16 Tanh %18 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v3half Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %22 - %24 = OpLabel - %25 = OpFunctionCall %void %tanh_06a4fe +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %tanh_06a4fe OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %28 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %31 = OpLabel - %32 = OpFunctionCall %void %tanh_06a4fe + %29 = OpLabel + %30 = OpFunctionCall %void %tanh_06a4fe OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %tanh_06a4fe + %32 = OpLabel + %33 = OpFunctionCall %void %tanh_06a4fe OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/tanh/313aa1.wgsl b/test/tint/builtins/gen/literal/tanh/313aa1.wgsl new file mode 100644 index 0000000000..fd8d9271b3 --- /dev/null +++ b/test/tint/builtins/gen/literal/tanh/313aa1.wgsl @@ -0,0 +1,43 @@ +// 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. + +//////////////////////////////////////////////////////////////////////////////// +// File generated by tools/src/cmd/gen +// using the template: +// test/tint/builtins/gen/gen.wgsl.tmpl +// +// Do not modify this file directly +//////////////////////////////////////////////////////////////////////////////// + + +// fn tanh(fa) -> fa +fn tanh_313aa1() { + var res = tanh(1.); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + tanh_313aa1(); + return vec4(); +} + +@fragment +fn fragment_main() { + tanh_313aa1(); +} + +@compute @workgroup_size(1) +fn compute_main() { + tanh_313aa1(); +} diff --git a/test/tint/builtins/gen/literal/tanh/313aa1.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/tanh/313aa1.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..531d03709d --- /dev/null +++ b/test/tint/builtins/gen/literal/tanh/313aa1.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void tanh_313aa1() { + float res = 0.761594176f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + tanh_313aa1(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + tanh_313aa1(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + tanh_313aa1(); + return; +} diff --git a/test/tint/builtins/gen/literal/tanh/313aa1.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/tanh/313aa1.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..531d03709d --- /dev/null +++ b/test/tint/builtins/gen/literal/tanh/313aa1.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void tanh_313aa1() { + float res = 0.761594176f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + tanh_313aa1(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + tanh_313aa1(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + tanh_313aa1(); + return; +} diff --git a/test/tint/builtins/gen/literal/tanh/313aa1.wgsl.expected.glsl b/test/tint/builtins/gen/literal/tanh/313aa1.wgsl.expected.glsl new file mode 100644 index 0000000000..9a6f7ece40 --- /dev/null +++ b/test/tint/builtins/gen/literal/tanh/313aa1.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void tanh_313aa1() { + float res = 0.761594176f; +} + +vec4 vertex_main() { + tanh_313aa1(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void tanh_313aa1() { + float res = 0.761594176f; +} + +void fragment_main() { + tanh_313aa1(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void tanh_313aa1() { + float res = 0.761594176f; +} + +void compute_main() { + tanh_313aa1(); +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() { + compute_main(); + return; +} diff --git a/test/tint/builtins/gen/literal/tanh/313aa1.wgsl.expected.msl b/test/tint/builtins/gen/literal/tanh/313aa1.wgsl.expected.msl new file mode 100644 index 0000000000..36f2eb883b --- /dev/null +++ b/test/tint/builtins/gen/literal/tanh/313aa1.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void tanh_313aa1() { + float res = 0.761594176f; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + tanh_313aa1(); + return float4(0.0f); +} + +vertex tint_symbol vertex_main() { + float4 const inner_result = vertex_main_inner(); + tint_symbol wrapper_result = {}; + wrapper_result.value = inner_result; + return wrapper_result; +} + +fragment void fragment_main() { + tanh_313aa1(); + return; +} + +kernel void compute_main() { + tanh_313aa1(); + return; +} + diff --git a/test/tint/builtins/gen/literal/tanh/313aa1.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/tanh/313aa1.wgsl.expected.spvasm new file mode 100644 index 0000000000..d7ebe58d3b --- /dev/null +++ b/test/tint/builtins/gen/literal/tanh/313aa1.wgsl.expected.spvasm @@ -0,0 +1,64 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 30 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %tanh_313aa1 "tanh_313aa1" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void +%float_0_761594176 = OpConstant %float 0.761594176 +%_ptr_Function_float = OpTypePointer Function %float + %16 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%tanh_313aa1 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_float Function %8 + OpStore %res %float_0_761594176 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %16 + %18 = OpLabel + %19 = OpFunctionCall %void %tanh_313aa1 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %21 = OpLabel + %22 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %22 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %25 = OpLabel + %26 = OpFunctionCall %void %tanh_313aa1 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %tanh_313aa1 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/tanh/313aa1.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/tanh/313aa1.wgsl.expected.wgsl new file mode 100644 index 0000000000..3725f54807 --- /dev/null +++ b/test/tint/builtins/gen/literal/tanh/313aa1.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn tanh_313aa1() { + var res = tanh(1.0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + tanh_313aa1(); + return vec4(); +} + +@fragment +fn fragment_main() { + tanh_313aa1(); +} + +@compute @workgroup_size(1) +fn compute_main() { + tanh_313aa1(); +} diff --git a/test/tint/builtins/gen/literal/tanh/5663c5.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/tanh/5663c5.wgsl.expected.dxc.hlsl index 44023e02dc..4bb249b5d8 100644 --- a/test/tint/builtins/gen/literal/tanh/5663c5.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/tanh/5663c5.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void tanh_5663c5() { - float4 res = tanh((1.0f).xxxx); + float4 res = (0.761594176f).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tanh/5663c5.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/tanh/5663c5.wgsl.expected.fxc.hlsl index 44023e02dc..4bb249b5d8 100644 --- a/test/tint/builtins/gen/literal/tanh/5663c5.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/tanh/5663c5.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void tanh_5663c5() { - float4 res = tanh((1.0f).xxxx); + float4 res = (0.761594176f).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tanh/5663c5.wgsl.expected.glsl b/test/tint/builtins/gen/literal/tanh/5663c5.wgsl.expected.glsl index cfff79f682..58f71df529 100644 --- a/test/tint/builtins/gen/literal/tanh/5663c5.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/tanh/5663c5.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void tanh_5663c5() { - vec4 res = tanh(vec4(1.0f)); + vec4 res = vec4(0.761594176f); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void tanh_5663c5() { - vec4 res = tanh(vec4(1.0f)); + vec4 res = vec4(0.761594176f); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void tanh_5663c5() { - vec4 res = tanh(vec4(1.0f)); + vec4 res = vec4(0.761594176f); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/tanh/5663c5.wgsl.expected.msl b/test/tint/builtins/gen/literal/tanh/5663c5.wgsl.expected.msl index 3c9c45bed3..acc7d705bb 100644 --- a/test/tint/builtins/gen/literal/tanh/5663c5.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/tanh/5663c5.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void tanh_5663c5() { - float4 res = tanh(float4(1.0f)); + float4 res = float4(0.761594176f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tanh/5663c5.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/tanh/5663c5.wgsl.expected.spvasm index ccad998b63..395840fc8c 100644 --- a/test/tint/builtins/gen/literal/tanh/5663c5.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/tanh/5663c5.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 32 +; Bound: 31 ; Schema: 0 OpCapability Shader - %14 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -31,36 +30,36 @@ %vertex_point_size = OpVariable %_ptr_Output_float Output %8 %void = OpTypeVoid %9 = OpTypeFunction %void - %float_1 = OpConstant %float 1 - %16 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%float_0_761594176 = OpConstant %float 0.761594176 + %14 = OpConstantComposite %v4float %float_0_761594176 %float_0_761594176 %float_0_761594176 %float_0_761594176 %_ptr_Function_v4float = OpTypePointer Function %v4float - %19 = OpTypeFunction %v4float + %17 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %tanh_5663c5 = OpFunction %void None %9 %12 = OpLabel %res = OpVariable %_ptr_Function_v4float Function %5 - %13 = OpExtInst %v4float %14 Tanh %16 - OpStore %res %13 + OpStore %res %14 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %19 - %21 = OpLabel - %22 = OpFunctionCall %void %tanh_5663c5 +%vertex_main_inner = OpFunction %v4float None %17 + %19 = OpLabel + %20 = OpFunctionCall %void %tanh_5663c5 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %24 = OpLabel - %25 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %25 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %void %tanh_5663c5 + %26 = OpLabel + %27 = OpFunctionCall %void %tanh_5663c5 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %30 = OpLabel - %31 = OpFunctionCall %void %tanh_5663c5 + %29 = OpLabel + %30 = OpFunctionCall %void %tanh_5663c5 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/tanh/5724b3.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/tanh/5724b3.wgsl.expected.dxc.hlsl index b2cfae5151..852014807e 100644 --- a/test/tint/builtins/gen/literal/tanh/5724b3.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/tanh/5724b3.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void tanh_5724b3() { - float2 res = tanh((1.0f).xx); + float2 res = (0.761594176f).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tanh/5724b3.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/tanh/5724b3.wgsl.expected.fxc.hlsl index b2cfae5151..852014807e 100644 --- a/test/tint/builtins/gen/literal/tanh/5724b3.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/tanh/5724b3.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void tanh_5724b3() { - float2 res = tanh((1.0f).xx); + float2 res = (0.761594176f).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tanh/5724b3.wgsl.expected.glsl b/test/tint/builtins/gen/literal/tanh/5724b3.wgsl.expected.glsl index 1bd2acfc90..89e4115704 100644 --- a/test/tint/builtins/gen/literal/tanh/5724b3.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/tanh/5724b3.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void tanh_5724b3() { - vec2 res = tanh(vec2(1.0f)); + vec2 res = vec2(0.761594176f); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void tanh_5724b3() { - vec2 res = tanh(vec2(1.0f)); + vec2 res = vec2(0.761594176f); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void tanh_5724b3() { - vec2 res = tanh(vec2(1.0f)); + vec2 res = vec2(0.761594176f); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/tanh/5724b3.wgsl.expected.msl b/test/tint/builtins/gen/literal/tanh/5724b3.wgsl.expected.msl index d2b6b1b3f6..4467340b07 100644 --- a/test/tint/builtins/gen/literal/tanh/5724b3.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/tanh/5724b3.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void tanh_5724b3() { - float2 res = tanh(float2(1.0f)); + float2 res = float2(0.761594176f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tanh/5724b3.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/tanh/5724b3.wgsl.expected.spvasm index 7adc88a301..3159ae31f5 100644 --- a/test/tint/builtins/gen/literal/tanh/5724b3.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/tanh/5724b3.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 34 +; Bound: 33 ; Schema: 0 OpCapability Shader - %15 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -32,37 +31,37 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %v2float = OpTypeVector %float 2 - %float_1 = OpConstant %float 1 - %17 = OpConstantComposite %v2float %float_1 %float_1 +%float_0_761594176 = OpConstant %float 0.761594176 + %15 = OpConstantComposite %v2float %float_0_761594176 %float_0_761594176 %_ptr_Function_v2float = OpTypePointer Function %v2float - %20 = OpConstantNull %v2float - %21 = OpTypeFunction %v4float + %18 = OpConstantNull %v2float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %tanh_5724b3 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v2float Function %20 - %13 = OpExtInst %v2float %15 Tanh %17 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v2float Function %18 + OpStore %res %15 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %21 - %23 = OpLabel - %24 = OpFunctionCall %void %tanh_5724b3 +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %tanh_5724b3 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %27 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %29 = OpLabel - %30 = OpFunctionCall %void %tanh_5724b3 + %28 = OpLabel + %29 = OpFunctionCall %void %tanh_5724b3 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %32 = OpLabel - %33 = OpFunctionCall %void %tanh_5724b3 + %31 = OpLabel + %32 = OpFunctionCall %void %tanh_5724b3 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/tanh/5b19af.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/tanh/5b19af.wgsl.expected.dxc.hlsl index 0beb95e61e..5cb27b6a15 100644 --- a/test/tint/builtins/gen/literal/tanh/5b19af.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/tanh/5b19af.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void tanh_5b19af() { - float16_t res = tanh(float16_t(1.0h)); + float16_t res = float16_t(0.761230469h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tanh/5b19af.wgsl.expected.glsl b/test/tint/builtins/gen/literal/tanh/5b19af.wgsl.expected.glsl index 107a42c1a1..75ca68545c 100644 --- a/test/tint/builtins/gen/literal/tanh/5b19af.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/tanh/5b19af.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void tanh_5b19af() { - float16_t res = tanh(1.0hf); + float16_t res = 0.761230469hf; } vec4 vertex_main() { @@ -23,7 +23,7 @@ void main() { precision mediump float; void tanh_5b19af() { - float16_t res = tanh(1.0hf); + float16_t res = 0.761230469hf; } void fragment_main() { @@ -38,7 +38,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void tanh_5b19af() { - float16_t res = tanh(1.0hf); + float16_t res = 0.761230469hf; } void compute_main() { diff --git a/test/tint/builtins/gen/literal/tanh/5b19af.wgsl.expected.msl b/test/tint/builtins/gen/literal/tanh/5b19af.wgsl.expected.msl index 74ce3f2a32..c6bc3914b8 100644 --- a/test/tint/builtins/gen/literal/tanh/5b19af.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/tanh/5b19af.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void tanh_5b19af() { - half res = tanh(1.0h); + half res = 0.761230469h; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tanh/5b19af.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/tanh/5b19af.wgsl.expected.spvasm index a7669f7ce9..3dc57f3c1e 100644 --- a/test/tint/builtins/gen/literal/tanh/5b19af.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/tanh/5b19af.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 34 +; Bound: 32 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %15 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -36,37 +35,36 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %half = OpTypeFloat 16 -%half_0x1p_0 = OpConstant %half 0x1p+0 +%half_0x1_85cpn1 = OpConstant %half 0x1.85cp-1 %_ptr_Function_half = OpTypePointer Function %half - %19 = OpConstantNull %half - %20 = OpTypeFunction %v4float + %17 = OpConstantNull %half + %18 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %tanh_5b19af = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_half Function %19 - %13 = OpExtInst %half %15 Tanh %half_0x1p_0 - OpStore %res %13 + %res = OpVariable %_ptr_Function_half Function %17 + OpStore %res %half_0x1_85cpn1 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %20 - %22 = OpLabel - %23 = OpFunctionCall %void %tanh_5b19af +%vertex_main_inner = OpFunction %v4float None %18 + %20 = OpLabel + %21 = OpFunctionCall %void %tanh_5b19af OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %25 = OpLabel - %26 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %26 + %23 = OpLabel + %24 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %24 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %29 = OpLabel - %30 = OpFunctionCall %void %tanh_5b19af + %27 = OpLabel + %28 = OpFunctionCall %void %tanh_5b19af OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %32 = OpLabel - %33 = OpFunctionCall %void %tanh_5b19af + %30 = OpLabel + %31 = OpFunctionCall %void %tanh_5b19af OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/tanh/6289fd.wgsl b/test/tint/builtins/gen/literal/tanh/6289fd.wgsl new file mode 100644 index 0000000000..9eccf5b781 --- /dev/null +++ b/test/tint/builtins/gen/literal/tanh/6289fd.wgsl @@ -0,0 +1,43 @@ +// 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. + +//////////////////////////////////////////////////////////////////////////////// +// File generated by tools/src/cmd/gen +// using the template: +// test/tint/builtins/gen/gen.wgsl.tmpl +// +// Do not modify this file directly +//////////////////////////////////////////////////////////////////////////////// + + +// fn tanh(vec<3, fa>) -> vec<3, fa> +fn tanh_6289fd() { + var res = tanh(vec3(1.)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + tanh_6289fd(); + return vec4(); +} + +@fragment +fn fragment_main() { + tanh_6289fd(); +} + +@compute @workgroup_size(1) +fn compute_main() { + tanh_6289fd(); +} diff --git a/test/tint/builtins/gen/literal/tanh/6289fd.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/tanh/6289fd.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..b804dc3076 --- /dev/null +++ b/test/tint/builtins/gen/literal/tanh/6289fd.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void tanh_6289fd() { + float3 res = (0.761594176f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + tanh_6289fd(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + tanh_6289fd(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + tanh_6289fd(); + return; +} diff --git a/test/tint/builtins/gen/literal/tanh/6289fd.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/tanh/6289fd.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..b804dc3076 --- /dev/null +++ b/test/tint/builtins/gen/literal/tanh/6289fd.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void tanh_6289fd() { + float3 res = (0.761594176f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + tanh_6289fd(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + tanh_6289fd(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + tanh_6289fd(); + return; +} diff --git a/test/tint/builtins/gen/literal/tanh/6289fd.wgsl.expected.glsl b/test/tint/builtins/gen/literal/tanh/6289fd.wgsl.expected.glsl new file mode 100644 index 0000000000..b883e60488 --- /dev/null +++ b/test/tint/builtins/gen/literal/tanh/6289fd.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void tanh_6289fd() { + vec3 res = vec3(0.761594176f); +} + +vec4 vertex_main() { + tanh_6289fd(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void tanh_6289fd() { + vec3 res = vec3(0.761594176f); +} + +void fragment_main() { + tanh_6289fd(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void tanh_6289fd() { + vec3 res = vec3(0.761594176f); +} + +void compute_main() { + tanh_6289fd(); +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() { + compute_main(); + return; +} diff --git a/test/tint/builtins/gen/literal/tanh/6289fd.wgsl.expected.msl b/test/tint/builtins/gen/literal/tanh/6289fd.wgsl.expected.msl new file mode 100644 index 0000000000..491a4dac48 --- /dev/null +++ b/test/tint/builtins/gen/literal/tanh/6289fd.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void tanh_6289fd() { + float3 res = float3(0.761594176f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + tanh_6289fd(); + return float4(0.0f); +} + +vertex tint_symbol vertex_main() { + float4 const inner_result = vertex_main_inner(); + tint_symbol wrapper_result = {}; + wrapper_result.value = inner_result; + return wrapper_result; +} + +fragment void fragment_main() { + tanh_6289fd(); + return; +} + +kernel void compute_main() { + tanh_6289fd(); + return; +} + diff --git a/test/tint/builtins/gen/literal/tanh/6289fd.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/tanh/6289fd.wgsl.expected.spvasm new file mode 100644 index 0000000000..620d06cdc2 --- /dev/null +++ b/test/tint/builtins/gen/literal/tanh/6289fd.wgsl.expected.spvasm @@ -0,0 +1,67 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 33 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %tanh_6289fd "tanh_6289fd" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %v3float = OpTypeVector %float 3 +%float_0_761594176 = OpConstant %float 0.761594176 + %15 = OpConstantComposite %v3float %float_0_761594176 %float_0_761594176 %float_0_761594176 +%_ptr_Function_v3float = OpTypePointer Function %v3float + %18 = OpConstantNull %v3float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%tanh_6289fd = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v3float Function %18 + OpStore %res %15 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %tanh_6289fd + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %tanh_6289fd + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %31 = OpLabel + %32 = OpFunctionCall %void %tanh_6289fd + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/tanh/6289fd.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/tanh/6289fd.wgsl.expected.wgsl new file mode 100644 index 0000000000..3635deffde --- /dev/null +++ b/test/tint/builtins/gen/literal/tanh/6289fd.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn tanh_6289fd() { + var res = tanh(vec3(1.0)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + tanh_6289fd(); + return vec4(); +} + +@fragment +fn fragment_main() { + tanh_6289fd(); +} + +@compute @workgroup_size(1) +fn compute_main() { + tanh_6289fd(); +} diff --git a/test/tint/builtins/gen/literal/tanh/6d105a.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/tanh/6d105a.wgsl.expected.dxc.hlsl index f4cb76aa0a..aae259dbc7 100644 --- a/test/tint/builtins/gen/literal/tanh/6d105a.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/tanh/6d105a.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void tanh_6d105a() { - vector res = tanh((float16_t(1.0h)).xx); + vector res = (float16_t(0.761230469h)).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tanh/6d105a.wgsl.expected.glsl b/test/tint/builtins/gen/literal/tanh/6d105a.wgsl.expected.glsl index b4a21cd9c0..c0a57afe04 100644 --- a/test/tint/builtins/gen/literal/tanh/6d105a.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/tanh/6d105a.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void tanh_6d105a() { - f16vec2 res = tanh(f16vec2(1.0hf)); + f16vec2 res = f16vec2(0.761230469hf); } vec4 vertex_main() { @@ -23,7 +23,7 @@ void main() { precision mediump float; void tanh_6d105a() { - f16vec2 res = tanh(f16vec2(1.0hf)); + f16vec2 res = f16vec2(0.761230469hf); } void fragment_main() { @@ -38,7 +38,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void tanh_6d105a() { - f16vec2 res = tanh(f16vec2(1.0hf)); + f16vec2 res = f16vec2(0.761230469hf); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/tanh/6d105a.wgsl.expected.msl b/test/tint/builtins/gen/literal/tanh/6d105a.wgsl.expected.msl index b16a5a598c..b4c20c4356 100644 --- a/test/tint/builtins/gen/literal/tanh/6d105a.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/tanh/6d105a.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void tanh_6d105a() { - half2 res = tanh(half2(1.0h)); + half2 res = half2(0.761230469h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tanh/6d105a.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/tanh/6d105a.wgsl.expected.spvasm index 95167d380a..29cb3d3060 100644 --- a/test/tint/builtins/gen/literal/tanh/6d105a.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/tanh/6d105a.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 36 +; Bound: 34 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %16 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -37,38 +36,37 @@ %9 = OpTypeFunction %void %half = OpTypeFloat 16 %v2half = OpTypeVector %half 2 -%half_0x1p_0 = OpConstant %half 0x1p+0 - %18 = OpConstantComposite %v2half %half_0x1p_0 %half_0x1p_0 +%half_0x1_85cpn1 = OpConstant %half 0x1.85cp-1 + %16 = OpConstantComposite %v2half %half_0x1_85cpn1 %half_0x1_85cpn1 %_ptr_Function_v2half = OpTypePointer Function %v2half - %21 = OpConstantNull %v2half - %22 = OpTypeFunction %v4float + %19 = OpConstantNull %v2half + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %tanh_6d105a = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v2half Function %21 - %13 = OpExtInst %v2half %16 Tanh %18 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v2half Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %22 - %24 = OpLabel - %25 = OpFunctionCall %void %tanh_6d105a +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %tanh_6d105a OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %28 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %31 = OpLabel - %32 = OpFunctionCall %void %tanh_6d105a + %29 = OpLabel + %30 = OpFunctionCall %void %tanh_6d105a OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %tanh_6d105a + %32 = OpLabel + %33 = OpFunctionCall %void %tanh_6d105a OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/tanh/9f9fb9.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/tanh/9f9fb9.wgsl.expected.dxc.hlsl index 21cc8d3743..7a66c836ed 100644 --- a/test/tint/builtins/gen/literal/tanh/9f9fb9.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/tanh/9f9fb9.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void tanh_9f9fb9() { - float3 res = tanh((1.0f).xxx); + float3 res = (0.761594176f).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tanh/9f9fb9.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/tanh/9f9fb9.wgsl.expected.fxc.hlsl index 21cc8d3743..7a66c836ed 100644 --- a/test/tint/builtins/gen/literal/tanh/9f9fb9.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/tanh/9f9fb9.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void tanh_9f9fb9() { - float3 res = tanh((1.0f).xxx); + float3 res = (0.761594176f).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tanh/9f9fb9.wgsl.expected.glsl b/test/tint/builtins/gen/literal/tanh/9f9fb9.wgsl.expected.glsl index d065337103..74d1a8f3ea 100644 --- a/test/tint/builtins/gen/literal/tanh/9f9fb9.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/tanh/9f9fb9.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void tanh_9f9fb9() { - vec3 res = tanh(vec3(1.0f)); + vec3 res = vec3(0.761594176f); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void tanh_9f9fb9() { - vec3 res = tanh(vec3(1.0f)); + vec3 res = vec3(0.761594176f); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void tanh_9f9fb9() { - vec3 res = tanh(vec3(1.0f)); + vec3 res = vec3(0.761594176f); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/tanh/9f9fb9.wgsl.expected.msl b/test/tint/builtins/gen/literal/tanh/9f9fb9.wgsl.expected.msl index 326f3c41aa..7b21791fdc 100644 --- a/test/tint/builtins/gen/literal/tanh/9f9fb9.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/tanh/9f9fb9.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void tanh_9f9fb9() { - float3 res = tanh(float3(1.0f)); + float3 res = float3(0.761594176f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tanh/9f9fb9.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/tanh/9f9fb9.wgsl.expected.spvasm index 63ec832c44..07dcea7b8f 100644 --- a/test/tint/builtins/gen/literal/tanh/9f9fb9.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/tanh/9f9fb9.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 34 +; Bound: 33 ; Schema: 0 OpCapability Shader - %15 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -32,37 +31,37 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %v3float = OpTypeVector %float 3 - %float_1 = OpConstant %float 1 - %17 = OpConstantComposite %v3float %float_1 %float_1 %float_1 +%float_0_761594176 = OpConstant %float 0.761594176 + %15 = OpConstantComposite %v3float %float_0_761594176 %float_0_761594176 %float_0_761594176 %_ptr_Function_v3float = OpTypePointer Function %v3float - %20 = OpConstantNull %v3float - %21 = OpTypeFunction %v4float + %18 = OpConstantNull %v3float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %tanh_9f9fb9 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v3float Function %20 - %13 = OpExtInst %v3float %15 Tanh %17 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v3float Function %18 + OpStore %res %15 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %21 - %23 = OpLabel - %24 = OpFunctionCall %void %tanh_9f9fb9 +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %tanh_9f9fb9 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %27 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %29 = OpLabel - %30 = OpFunctionCall %void %tanh_9f9fb9 + %28 = OpLabel + %29 = OpFunctionCall %void %tanh_9f9fb9 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %32 = OpLabel - %33 = OpFunctionCall %void %tanh_9f9fb9 + %31 = OpLabel + %32 = OpFunctionCall %void %tanh_9f9fb9 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/tanh/ac5d33.wgsl b/test/tint/builtins/gen/literal/tanh/ac5d33.wgsl new file mode 100644 index 0000000000..c7a601e466 --- /dev/null +++ b/test/tint/builtins/gen/literal/tanh/ac5d33.wgsl @@ -0,0 +1,43 @@ +// 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. + +//////////////////////////////////////////////////////////////////////////////// +// File generated by tools/src/cmd/gen +// using the template: +// test/tint/builtins/gen/gen.wgsl.tmpl +// +// Do not modify this file directly +//////////////////////////////////////////////////////////////////////////////// + + +// fn tanh(vec<4, fa>) -> vec<4, fa> +fn tanh_ac5d33() { + var res = tanh(vec4(1.)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + tanh_ac5d33(); + return vec4(); +} + +@fragment +fn fragment_main() { + tanh_ac5d33(); +} + +@compute @workgroup_size(1) +fn compute_main() { + tanh_ac5d33(); +} diff --git a/test/tint/builtins/gen/literal/tanh/ac5d33.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/tanh/ac5d33.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..1b0ad2864c --- /dev/null +++ b/test/tint/builtins/gen/literal/tanh/ac5d33.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void tanh_ac5d33() { + float4 res = (0.761594176f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + tanh_ac5d33(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + tanh_ac5d33(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + tanh_ac5d33(); + return; +} diff --git a/test/tint/builtins/gen/literal/tanh/ac5d33.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/tanh/ac5d33.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..1b0ad2864c --- /dev/null +++ b/test/tint/builtins/gen/literal/tanh/ac5d33.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void tanh_ac5d33() { + float4 res = (0.761594176f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + tanh_ac5d33(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + tanh_ac5d33(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + tanh_ac5d33(); + return; +} diff --git a/test/tint/builtins/gen/literal/tanh/ac5d33.wgsl.expected.glsl b/test/tint/builtins/gen/literal/tanh/ac5d33.wgsl.expected.glsl new file mode 100644 index 0000000000..698681db0c --- /dev/null +++ b/test/tint/builtins/gen/literal/tanh/ac5d33.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void tanh_ac5d33() { + vec4 res = vec4(0.761594176f); +} + +vec4 vertex_main() { + tanh_ac5d33(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void tanh_ac5d33() { + vec4 res = vec4(0.761594176f); +} + +void fragment_main() { + tanh_ac5d33(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void tanh_ac5d33() { + vec4 res = vec4(0.761594176f); +} + +void compute_main() { + tanh_ac5d33(); +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() { + compute_main(); + return; +} diff --git a/test/tint/builtins/gen/literal/tanh/ac5d33.wgsl.expected.msl b/test/tint/builtins/gen/literal/tanh/ac5d33.wgsl.expected.msl new file mode 100644 index 0000000000..a6e681d803 --- /dev/null +++ b/test/tint/builtins/gen/literal/tanh/ac5d33.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void tanh_ac5d33() { + float4 res = float4(0.761594176f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + tanh_ac5d33(); + return float4(0.0f); +} + +vertex tint_symbol vertex_main() { + float4 const inner_result = vertex_main_inner(); + tint_symbol wrapper_result = {}; + wrapper_result.value = inner_result; + return wrapper_result; +} + +fragment void fragment_main() { + tanh_ac5d33(); + return; +} + +kernel void compute_main() { + tanh_ac5d33(); + return; +} + diff --git a/test/tint/builtins/gen/literal/tanh/ac5d33.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/tanh/ac5d33.wgsl.expected.spvasm new file mode 100644 index 0000000000..fd98e9493f --- /dev/null +++ b/test/tint/builtins/gen/literal/tanh/ac5d33.wgsl.expected.spvasm @@ -0,0 +1,65 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 31 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %tanh_ac5d33 "tanh_ac5d33" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void +%float_0_761594176 = OpConstant %float 0.761594176 + %14 = OpConstantComposite %v4float %float_0_761594176 %float_0_761594176 %float_0_761594176 %float_0_761594176 +%_ptr_Function_v4float = OpTypePointer Function %v4float + %17 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%tanh_ac5d33 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v4float Function %5 + OpStore %res %14 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %17 + %19 = OpLabel + %20 = OpFunctionCall %void %tanh_ac5d33 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %26 = OpLabel + %27 = OpFunctionCall %void %tanh_ac5d33 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %29 = OpLabel + %30 = OpFunctionCall %void %tanh_ac5d33 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/tanh/ac5d33.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/tanh/ac5d33.wgsl.expected.wgsl new file mode 100644 index 0000000000..6e0b2b9833 --- /dev/null +++ b/test/tint/builtins/gen/literal/tanh/ac5d33.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn tanh_ac5d33() { + var res = tanh(vec4(1.0)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + tanh_ac5d33(); + return vec4(); +} + +@fragment +fn fragment_main() { + tanh_ac5d33(); +} + +@compute @workgroup_size(1) +fn compute_main() { + tanh_ac5d33(); +} diff --git a/test/tint/builtins/gen/literal/tanh/c15fdb.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/tanh/c15fdb.wgsl.expected.dxc.hlsl index ab6b249ef0..2d81f93313 100644 --- a/test/tint/builtins/gen/literal/tanh/c15fdb.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/tanh/c15fdb.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void tanh_c15fdb() { - float res = tanh(1.0f); + float res = 0.761594176f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tanh/c15fdb.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/tanh/c15fdb.wgsl.expected.fxc.hlsl index ab6b249ef0..2d81f93313 100644 --- a/test/tint/builtins/gen/literal/tanh/c15fdb.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/tanh/c15fdb.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void tanh_c15fdb() { - float res = tanh(1.0f); + float res = 0.761594176f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tanh/c15fdb.wgsl.expected.glsl b/test/tint/builtins/gen/literal/tanh/c15fdb.wgsl.expected.glsl index a76821c452..e0391d5983 100644 --- a/test/tint/builtins/gen/literal/tanh/c15fdb.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/tanh/c15fdb.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void tanh_c15fdb() { - float res = tanh(1.0f); + float res = 0.761594176f; } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void tanh_c15fdb() { - float res = tanh(1.0f); + float res = 0.761594176f; } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void tanh_c15fdb() { - float res = tanh(1.0f); + float res = 0.761594176f; } void compute_main() { diff --git a/test/tint/builtins/gen/literal/tanh/c15fdb.wgsl.expected.msl b/test/tint/builtins/gen/literal/tanh/c15fdb.wgsl.expected.msl index c71c1f6bb6..c10991ef54 100644 --- a/test/tint/builtins/gen/literal/tanh/c15fdb.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/tanh/c15fdb.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void tanh_c15fdb() { - float res = tanh(1.0f); + float res = 0.761594176f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tanh/c15fdb.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/tanh/c15fdb.wgsl.expected.spvasm index 8c45d42a47..4f9122c8dd 100644 --- a/test/tint/builtins/gen/literal/tanh/c15fdb.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/tanh/c15fdb.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 31 +; Bound: 30 ; Schema: 0 OpCapability Shader - %14 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -31,35 +30,35 @@ %vertex_point_size = OpVariable %_ptr_Output_float Output %8 %void = OpTypeVoid %9 = OpTypeFunction %void - %float_1 = OpConstant %float 1 +%float_0_761594176 = OpConstant %float 0.761594176 %_ptr_Function_float = OpTypePointer Function %float - %18 = OpTypeFunction %v4float + %16 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %tanh_c15fdb = OpFunction %void None %9 %12 = OpLabel %res = OpVariable %_ptr_Function_float Function %8 - %13 = OpExtInst %float %14 Tanh %float_1 - OpStore %res %13 + OpStore %res %float_0_761594176 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %18 - %20 = OpLabel - %21 = OpFunctionCall %void %tanh_c15fdb +%vertex_main_inner = OpFunction %v4float None %16 + %18 = OpLabel + %19 = OpFunctionCall %void %tanh_c15fdb OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %23 = OpLabel - %24 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %24 + %21 = OpLabel + %22 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %22 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %void %tanh_c15fdb + %25 = OpLabel + %26 = OpFunctionCall %void %tanh_c15fdb OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %29 = OpLabel - %30 = OpFunctionCall %void %tanh_c15fdb + %28 = OpLabel + %29 = OpFunctionCall %void %tanh_c15fdb OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/tanh/c48aa6.wgsl b/test/tint/builtins/gen/literal/tanh/c48aa6.wgsl new file mode 100644 index 0000000000..7d9c13fce0 --- /dev/null +++ b/test/tint/builtins/gen/literal/tanh/c48aa6.wgsl @@ -0,0 +1,43 @@ +// 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. + +//////////////////////////////////////////////////////////////////////////////// +// File generated by tools/src/cmd/gen +// using the template: +// test/tint/builtins/gen/gen.wgsl.tmpl +// +// Do not modify this file directly +//////////////////////////////////////////////////////////////////////////////// + + +// fn tanh(vec<2, fa>) -> vec<2, fa> +fn tanh_c48aa6() { + var res = tanh(vec2(1.)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + tanh_c48aa6(); + return vec4(); +} + +@fragment +fn fragment_main() { + tanh_c48aa6(); +} + +@compute @workgroup_size(1) +fn compute_main() { + tanh_c48aa6(); +} diff --git a/test/tint/builtins/gen/literal/tanh/c48aa6.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/tanh/c48aa6.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..39bb4dfa50 --- /dev/null +++ b/test/tint/builtins/gen/literal/tanh/c48aa6.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void tanh_c48aa6() { + float2 res = (0.761594176f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + tanh_c48aa6(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + tanh_c48aa6(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + tanh_c48aa6(); + return; +} diff --git a/test/tint/builtins/gen/literal/tanh/c48aa6.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/tanh/c48aa6.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..39bb4dfa50 --- /dev/null +++ b/test/tint/builtins/gen/literal/tanh/c48aa6.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void tanh_c48aa6() { + float2 res = (0.761594176f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + tanh_c48aa6(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + tanh_c48aa6(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + tanh_c48aa6(); + return; +} diff --git a/test/tint/builtins/gen/literal/tanh/c48aa6.wgsl.expected.glsl b/test/tint/builtins/gen/literal/tanh/c48aa6.wgsl.expected.glsl new file mode 100644 index 0000000000..fe899fae04 --- /dev/null +++ b/test/tint/builtins/gen/literal/tanh/c48aa6.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void tanh_c48aa6() { + vec2 res = vec2(0.761594176f); +} + +vec4 vertex_main() { + tanh_c48aa6(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void tanh_c48aa6() { + vec2 res = vec2(0.761594176f); +} + +void fragment_main() { + tanh_c48aa6(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void tanh_c48aa6() { + vec2 res = vec2(0.761594176f); +} + +void compute_main() { + tanh_c48aa6(); +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() { + compute_main(); + return; +} diff --git a/test/tint/builtins/gen/literal/tanh/c48aa6.wgsl.expected.msl b/test/tint/builtins/gen/literal/tanh/c48aa6.wgsl.expected.msl new file mode 100644 index 0000000000..49ccdba2fb --- /dev/null +++ b/test/tint/builtins/gen/literal/tanh/c48aa6.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void tanh_c48aa6() { + float2 res = float2(0.761594176f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + tanh_c48aa6(); + return float4(0.0f); +} + +vertex tint_symbol vertex_main() { + float4 const inner_result = vertex_main_inner(); + tint_symbol wrapper_result = {}; + wrapper_result.value = inner_result; + return wrapper_result; +} + +fragment void fragment_main() { + tanh_c48aa6(); + return; +} + +kernel void compute_main() { + tanh_c48aa6(); + return; +} + diff --git a/test/tint/builtins/gen/literal/tanh/c48aa6.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/tanh/c48aa6.wgsl.expected.spvasm new file mode 100644 index 0000000000..8a9dc92ceb --- /dev/null +++ b/test/tint/builtins/gen/literal/tanh/c48aa6.wgsl.expected.spvasm @@ -0,0 +1,67 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 33 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %tanh_c48aa6 "tanh_c48aa6" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %v2float = OpTypeVector %float 2 +%float_0_761594176 = OpConstant %float 0.761594176 + %15 = OpConstantComposite %v2float %float_0_761594176 %float_0_761594176 +%_ptr_Function_v2float = OpTypePointer Function %v2float + %18 = OpConstantNull %v2float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%tanh_c48aa6 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v2float Function %18 + OpStore %res %15 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %tanh_c48aa6 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %tanh_c48aa6 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %31 = OpLabel + %32 = OpFunctionCall %void %tanh_c48aa6 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/tanh/c48aa6.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/tanh/c48aa6.wgsl.expected.wgsl new file mode 100644 index 0000000000..faa88677c4 --- /dev/null +++ b/test/tint/builtins/gen/literal/tanh/c48aa6.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn tanh_c48aa6() { + var res = tanh(vec2(1.0)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + tanh_c48aa6(); + return vec4(); +} + +@fragment +fn fragment_main() { + tanh_c48aa6(); +} + +@compute @workgroup_size(1) +fn compute_main() { + tanh_c48aa6(); +} diff --git a/test/tint/builtins/gen/literal/tanh/e8efb3.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/tanh/e8efb3.wgsl.expected.dxc.hlsl index 6af0a2f3be..19315cc4fd 100644 --- a/test/tint/builtins/gen/literal/tanh/e8efb3.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/tanh/e8efb3.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void tanh_e8efb3() { - vector res = tanh((float16_t(1.0h)).xxxx); + vector res = (float16_t(0.761230469h)).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tanh/e8efb3.wgsl.expected.glsl b/test/tint/builtins/gen/literal/tanh/e8efb3.wgsl.expected.glsl index 040f77b625..53cdc2c8ac 100644 --- a/test/tint/builtins/gen/literal/tanh/e8efb3.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/tanh/e8efb3.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void tanh_e8efb3() { - f16vec4 res = tanh(f16vec4(1.0hf)); + f16vec4 res = f16vec4(0.761230469hf); } vec4 vertex_main() { @@ -23,7 +23,7 @@ void main() { precision mediump float; void tanh_e8efb3() { - f16vec4 res = tanh(f16vec4(1.0hf)); + f16vec4 res = f16vec4(0.761230469hf); } void fragment_main() { @@ -38,7 +38,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void tanh_e8efb3() { - f16vec4 res = tanh(f16vec4(1.0hf)); + f16vec4 res = f16vec4(0.761230469hf); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/tanh/e8efb3.wgsl.expected.msl b/test/tint/builtins/gen/literal/tanh/e8efb3.wgsl.expected.msl index 1d1ac71912..215aedb313 100644 --- a/test/tint/builtins/gen/literal/tanh/e8efb3.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/tanh/e8efb3.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void tanh_e8efb3() { - half4 res = tanh(half4(1.0h)); + half4 res = half4(0.761230469h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/tanh/e8efb3.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/tanh/e8efb3.wgsl.expected.spvasm index 230071b236..07995e6ebc 100644 --- a/test/tint/builtins/gen/literal/tanh/e8efb3.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/tanh/e8efb3.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 36 +; Bound: 34 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %16 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -37,38 +36,37 @@ %9 = OpTypeFunction %void %half = OpTypeFloat 16 %v4half = OpTypeVector %half 4 -%half_0x1p_0 = OpConstant %half 0x1p+0 - %18 = OpConstantComposite %v4half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 +%half_0x1_85cpn1 = OpConstant %half 0x1.85cp-1 + %16 = OpConstantComposite %v4half %half_0x1_85cpn1 %half_0x1_85cpn1 %half_0x1_85cpn1 %half_0x1_85cpn1 %_ptr_Function_v4half = OpTypePointer Function %v4half - %21 = OpConstantNull %v4half - %22 = OpTypeFunction %v4float + %19 = OpConstantNull %v4half + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %tanh_e8efb3 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v4half Function %21 - %13 = OpExtInst %v4half %16 Tanh %18 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v4half Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %22 - %24 = OpLabel - %25 = OpFunctionCall %void %tanh_e8efb3 +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %tanh_e8efb3 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %28 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %31 = OpLabel - %32 = OpFunctionCall %void %tanh_e8efb3 + %29 = OpLabel + %30 = OpFunctionCall %void %tanh_e8efb3 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %tanh_e8efb3 + %32 = OpLabel + %33 = OpFunctionCall %void %tanh_e8efb3 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/var/tan/311400.wgsl b/test/tint/builtins/gen/var/tan/311400.wgsl new file mode 100644 index 0000000000..24599500c1 --- /dev/null +++ b/test/tint/builtins/gen/var/tan/311400.wgsl @@ -0,0 +1,44 @@ +// 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. + +//////////////////////////////////////////////////////////////////////////////// +// File generated by tools/src/cmd/gen +// using the template: +// test/tint/builtins/gen/gen.wgsl.tmpl +// +// Do not modify this file directly +//////////////////////////////////////////////////////////////////////////////// + + +// fn tan(fa) -> fa +fn tan_311400() { + const arg_0 = 1.; + var res = tan(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + tan_311400(); + return vec4(); +} + +@fragment +fn fragment_main() { + tan_311400(); +} + +@compute @workgroup_size(1) +fn compute_main() { + tan_311400(); +} diff --git a/test/tint/builtins/gen/var/tan/311400.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/tan/311400.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..0473e416b3 --- /dev/null +++ b/test/tint/builtins/gen/var/tan/311400.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void tan_311400() { + float res = 1.557407737f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + tan_311400(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + tan_311400(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + tan_311400(); + return; +} diff --git a/test/tint/builtins/gen/var/tan/311400.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/tan/311400.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..0473e416b3 --- /dev/null +++ b/test/tint/builtins/gen/var/tan/311400.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void tan_311400() { + float res = 1.557407737f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + tan_311400(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + tan_311400(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + tan_311400(); + return; +} diff --git a/test/tint/builtins/gen/var/tan/311400.wgsl.expected.glsl b/test/tint/builtins/gen/var/tan/311400.wgsl.expected.glsl new file mode 100644 index 0000000000..a3a2a8f642 --- /dev/null +++ b/test/tint/builtins/gen/var/tan/311400.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void tan_311400() { + float res = 1.557407737f; +} + +vec4 vertex_main() { + tan_311400(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void tan_311400() { + float res = 1.557407737f; +} + +void fragment_main() { + tan_311400(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void tan_311400() { + float res = 1.557407737f; +} + +void compute_main() { + tan_311400(); +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() { + compute_main(); + return; +} diff --git a/test/tint/builtins/gen/var/tan/311400.wgsl.expected.msl b/test/tint/builtins/gen/var/tan/311400.wgsl.expected.msl new file mode 100644 index 0000000000..91762c342b --- /dev/null +++ b/test/tint/builtins/gen/var/tan/311400.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void tan_311400() { + float res = 1.557407737f; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + tan_311400(); + return float4(0.0f); +} + +vertex tint_symbol vertex_main() { + float4 const inner_result = vertex_main_inner(); + tint_symbol wrapper_result = {}; + wrapper_result.value = inner_result; + return wrapper_result; +} + +fragment void fragment_main() { + tan_311400(); + return; +} + +kernel void compute_main() { + tan_311400(); + return; +} + diff --git a/test/tint/builtins/gen/var/tan/311400.wgsl.expected.spvasm b/test/tint/builtins/gen/var/tan/311400.wgsl.expected.spvasm new file mode 100644 index 0000000000..38f896c419 --- /dev/null +++ b/test/tint/builtins/gen/var/tan/311400.wgsl.expected.spvasm @@ -0,0 +1,64 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 30 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %tan_311400 "tan_311400" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void +%float_1_55740774 = OpConstant %float 1.55740774 +%_ptr_Function_float = OpTypePointer Function %float + %16 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 + %tan_311400 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_float Function %8 + OpStore %res %float_1_55740774 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %16 + %18 = OpLabel + %19 = OpFunctionCall %void %tan_311400 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %21 = OpLabel + %22 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %22 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %25 = OpLabel + %26 = OpFunctionCall %void %tan_311400 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %tan_311400 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/tan/311400.wgsl.expected.wgsl b/test/tint/builtins/gen/var/tan/311400.wgsl.expected.wgsl new file mode 100644 index 0000000000..2551b48bc4 --- /dev/null +++ b/test/tint/builtins/gen/var/tan/311400.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn tan_311400() { + const arg_0 = 1.0; + var res = tan(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + tan_311400(); + return vec4(); +} + +@fragment +fn fragment_main() { + tan_311400(); +} + +@compute @workgroup_size(1) +fn compute_main() { + tan_311400(); +} diff --git a/test/tint/builtins/gen/var/tan/7be368.wgsl b/test/tint/builtins/gen/var/tan/7be368.wgsl new file mode 100644 index 0000000000..9f65208ece --- /dev/null +++ b/test/tint/builtins/gen/var/tan/7be368.wgsl @@ -0,0 +1,44 @@ +// 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. + +//////////////////////////////////////////////////////////////////////////////// +// File generated by tools/src/cmd/gen +// using the template: +// test/tint/builtins/gen/gen.wgsl.tmpl +// +// Do not modify this file directly +//////////////////////////////////////////////////////////////////////////////// + + +// fn tan(vec<2, fa>) -> vec<2, fa> +fn tan_7be368() { + const arg_0 = vec2(1.); + var res = tan(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + tan_7be368(); + return vec4(); +} + +@fragment +fn fragment_main() { + tan_7be368(); +} + +@compute @workgroup_size(1) +fn compute_main() { + tan_7be368(); +} diff --git a/test/tint/builtins/gen/var/tan/7be368.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/tan/7be368.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..8e47663da5 --- /dev/null +++ b/test/tint/builtins/gen/var/tan/7be368.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void tan_7be368() { + float2 res = (1.557407737f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + tan_7be368(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + tan_7be368(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + tan_7be368(); + return; +} diff --git a/test/tint/builtins/gen/var/tan/7be368.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/tan/7be368.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..8e47663da5 --- /dev/null +++ b/test/tint/builtins/gen/var/tan/7be368.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void tan_7be368() { + float2 res = (1.557407737f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + tan_7be368(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + tan_7be368(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + tan_7be368(); + return; +} diff --git a/test/tint/builtins/gen/var/tan/7be368.wgsl.expected.glsl b/test/tint/builtins/gen/var/tan/7be368.wgsl.expected.glsl new file mode 100644 index 0000000000..32f4892cbe --- /dev/null +++ b/test/tint/builtins/gen/var/tan/7be368.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void tan_7be368() { + vec2 res = vec2(1.557407737f); +} + +vec4 vertex_main() { + tan_7be368(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void tan_7be368() { + vec2 res = vec2(1.557407737f); +} + +void fragment_main() { + tan_7be368(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void tan_7be368() { + vec2 res = vec2(1.557407737f); +} + +void compute_main() { + tan_7be368(); +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() { + compute_main(); + return; +} diff --git a/test/tint/builtins/gen/var/tan/7be368.wgsl.expected.msl b/test/tint/builtins/gen/var/tan/7be368.wgsl.expected.msl new file mode 100644 index 0000000000..106ec06887 --- /dev/null +++ b/test/tint/builtins/gen/var/tan/7be368.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void tan_7be368() { + float2 res = float2(1.557407737f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + tan_7be368(); + return float4(0.0f); +} + +vertex tint_symbol vertex_main() { + float4 const inner_result = vertex_main_inner(); + tint_symbol wrapper_result = {}; + wrapper_result.value = inner_result; + return wrapper_result; +} + +fragment void fragment_main() { + tan_7be368(); + return; +} + +kernel void compute_main() { + tan_7be368(); + return; +} + diff --git a/test/tint/builtins/gen/var/tan/7be368.wgsl.expected.spvasm b/test/tint/builtins/gen/var/tan/7be368.wgsl.expected.spvasm new file mode 100644 index 0000000000..815423c769 --- /dev/null +++ b/test/tint/builtins/gen/var/tan/7be368.wgsl.expected.spvasm @@ -0,0 +1,67 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 33 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %tan_7be368 "tan_7be368" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %v2float = OpTypeVector %float 2 +%float_1_55740774 = OpConstant %float 1.55740774 + %15 = OpConstantComposite %v2float %float_1_55740774 %float_1_55740774 +%_ptr_Function_v2float = OpTypePointer Function %v2float + %18 = OpConstantNull %v2float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 + %tan_7be368 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v2float Function %18 + OpStore %res %15 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %tan_7be368 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %tan_7be368 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %31 = OpLabel + %32 = OpFunctionCall %void %tan_7be368 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/tan/7be368.wgsl.expected.wgsl b/test/tint/builtins/gen/var/tan/7be368.wgsl.expected.wgsl new file mode 100644 index 0000000000..678628e4a7 --- /dev/null +++ b/test/tint/builtins/gen/var/tan/7be368.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn tan_7be368() { + const arg_0 = vec2(1.0); + var res = tan(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + tan_7be368(); + return vec4(); +} + +@fragment +fn fragment_main() { + tan_7be368(); +} + +@compute @workgroup_size(1) +fn compute_main() { + tan_7be368(); +} diff --git a/test/tint/builtins/gen/var/tan/a0966f.wgsl b/test/tint/builtins/gen/var/tan/a0966f.wgsl new file mode 100644 index 0000000000..4927177467 --- /dev/null +++ b/test/tint/builtins/gen/var/tan/a0966f.wgsl @@ -0,0 +1,44 @@ +// 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. + +//////////////////////////////////////////////////////////////////////////////// +// File generated by tools/src/cmd/gen +// using the template: +// test/tint/builtins/gen/gen.wgsl.tmpl +// +// Do not modify this file directly +//////////////////////////////////////////////////////////////////////////////// + + +// fn tan(vec<4, fa>) -> vec<4, fa> +fn tan_a0966f() { + const arg_0 = vec4(1.); + var res = tan(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + tan_a0966f(); + return vec4(); +} + +@fragment +fn fragment_main() { + tan_a0966f(); +} + +@compute @workgroup_size(1) +fn compute_main() { + tan_a0966f(); +} diff --git a/test/tint/builtins/gen/var/tan/a0966f.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/tan/a0966f.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..fcb1fb73d6 --- /dev/null +++ b/test/tint/builtins/gen/var/tan/a0966f.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void tan_a0966f() { + float4 res = (1.557407737f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + tan_a0966f(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + tan_a0966f(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + tan_a0966f(); + return; +} diff --git a/test/tint/builtins/gen/var/tan/a0966f.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/tan/a0966f.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..fcb1fb73d6 --- /dev/null +++ b/test/tint/builtins/gen/var/tan/a0966f.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void tan_a0966f() { + float4 res = (1.557407737f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + tan_a0966f(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + tan_a0966f(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + tan_a0966f(); + return; +} diff --git a/test/tint/builtins/gen/var/tan/a0966f.wgsl.expected.glsl b/test/tint/builtins/gen/var/tan/a0966f.wgsl.expected.glsl new file mode 100644 index 0000000000..ffdb3018cb --- /dev/null +++ b/test/tint/builtins/gen/var/tan/a0966f.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void tan_a0966f() { + vec4 res = vec4(1.557407737f); +} + +vec4 vertex_main() { + tan_a0966f(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void tan_a0966f() { + vec4 res = vec4(1.557407737f); +} + +void fragment_main() { + tan_a0966f(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void tan_a0966f() { + vec4 res = vec4(1.557407737f); +} + +void compute_main() { + tan_a0966f(); +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() { + compute_main(); + return; +} diff --git a/test/tint/builtins/gen/var/tan/a0966f.wgsl.expected.msl b/test/tint/builtins/gen/var/tan/a0966f.wgsl.expected.msl new file mode 100644 index 0000000000..958b44bdc0 --- /dev/null +++ b/test/tint/builtins/gen/var/tan/a0966f.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void tan_a0966f() { + float4 res = float4(1.557407737f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + tan_a0966f(); + return float4(0.0f); +} + +vertex tint_symbol vertex_main() { + float4 const inner_result = vertex_main_inner(); + tint_symbol wrapper_result = {}; + wrapper_result.value = inner_result; + return wrapper_result; +} + +fragment void fragment_main() { + tan_a0966f(); + return; +} + +kernel void compute_main() { + tan_a0966f(); + return; +} + diff --git a/test/tint/builtins/gen/var/tan/a0966f.wgsl.expected.spvasm b/test/tint/builtins/gen/var/tan/a0966f.wgsl.expected.spvasm new file mode 100644 index 0000000000..fa5a70e2ae --- /dev/null +++ b/test/tint/builtins/gen/var/tan/a0966f.wgsl.expected.spvasm @@ -0,0 +1,65 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 31 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %tan_a0966f "tan_a0966f" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void +%float_1_55740774 = OpConstant %float 1.55740774 + %14 = OpConstantComposite %v4float %float_1_55740774 %float_1_55740774 %float_1_55740774 %float_1_55740774 +%_ptr_Function_v4float = OpTypePointer Function %v4float + %17 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 + %tan_a0966f = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v4float Function %5 + OpStore %res %14 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %17 + %19 = OpLabel + %20 = OpFunctionCall %void %tan_a0966f + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %26 = OpLabel + %27 = OpFunctionCall %void %tan_a0966f + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %29 = OpLabel + %30 = OpFunctionCall %void %tan_a0966f + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/tan/a0966f.wgsl.expected.wgsl b/test/tint/builtins/gen/var/tan/a0966f.wgsl.expected.wgsl new file mode 100644 index 0000000000..701eda95f3 --- /dev/null +++ b/test/tint/builtins/gen/var/tan/a0966f.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn tan_a0966f() { + const arg_0 = vec4(1.0); + var res = tan(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + tan_a0966f(); + return vec4(); +} + +@fragment +fn fragment_main() { + tan_a0966f(); +} + +@compute @workgroup_size(1) +fn compute_main() { + tan_a0966f(); +} diff --git a/test/tint/builtins/gen/var/tan/ae26ae.wgsl b/test/tint/builtins/gen/var/tan/ae26ae.wgsl new file mode 100644 index 0000000000..a86a1497fa --- /dev/null +++ b/test/tint/builtins/gen/var/tan/ae26ae.wgsl @@ -0,0 +1,44 @@ +// 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. + +//////////////////////////////////////////////////////////////////////////////// +// File generated by tools/src/cmd/gen +// using the template: +// test/tint/builtins/gen/gen.wgsl.tmpl +// +// Do not modify this file directly +//////////////////////////////////////////////////////////////////////////////// + + +// fn tan(vec<3, fa>) -> vec<3, fa> +fn tan_ae26ae() { + const arg_0 = vec3(1.); + var res = tan(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + tan_ae26ae(); + return vec4(); +} + +@fragment +fn fragment_main() { + tan_ae26ae(); +} + +@compute @workgroup_size(1) +fn compute_main() { + tan_ae26ae(); +} diff --git a/test/tint/builtins/gen/var/tan/ae26ae.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/tan/ae26ae.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..3b0cc0030e --- /dev/null +++ b/test/tint/builtins/gen/var/tan/ae26ae.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void tan_ae26ae() { + float3 res = (1.557407737f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + tan_ae26ae(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + tan_ae26ae(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + tan_ae26ae(); + return; +} diff --git a/test/tint/builtins/gen/var/tan/ae26ae.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/tan/ae26ae.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..3b0cc0030e --- /dev/null +++ b/test/tint/builtins/gen/var/tan/ae26ae.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void tan_ae26ae() { + float3 res = (1.557407737f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + tan_ae26ae(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + tan_ae26ae(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + tan_ae26ae(); + return; +} diff --git a/test/tint/builtins/gen/var/tan/ae26ae.wgsl.expected.glsl b/test/tint/builtins/gen/var/tan/ae26ae.wgsl.expected.glsl new file mode 100644 index 0000000000..bebd2774ab --- /dev/null +++ b/test/tint/builtins/gen/var/tan/ae26ae.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void tan_ae26ae() { + vec3 res = vec3(1.557407737f); +} + +vec4 vertex_main() { + tan_ae26ae(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void tan_ae26ae() { + vec3 res = vec3(1.557407737f); +} + +void fragment_main() { + tan_ae26ae(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void tan_ae26ae() { + vec3 res = vec3(1.557407737f); +} + +void compute_main() { + tan_ae26ae(); +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() { + compute_main(); + return; +} diff --git a/test/tint/builtins/gen/var/tan/ae26ae.wgsl.expected.msl b/test/tint/builtins/gen/var/tan/ae26ae.wgsl.expected.msl new file mode 100644 index 0000000000..6f230972ae --- /dev/null +++ b/test/tint/builtins/gen/var/tan/ae26ae.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void tan_ae26ae() { + float3 res = float3(1.557407737f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + tan_ae26ae(); + return float4(0.0f); +} + +vertex tint_symbol vertex_main() { + float4 const inner_result = vertex_main_inner(); + tint_symbol wrapper_result = {}; + wrapper_result.value = inner_result; + return wrapper_result; +} + +fragment void fragment_main() { + tan_ae26ae(); + return; +} + +kernel void compute_main() { + tan_ae26ae(); + return; +} + diff --git a/test/tint/builtins/gen/var/tan/ae26ae.wgsl.expected.spvasm b/test/tint/builtins/gen/var/tan/ae26ae.wgsl.expected.spvasm new file mode 100644 index 0000000000..f1796b018a --- /dev/null +++ b/test/tint/builtins/gen/var/tan/ae26ae.wgsl.expected.spvasm @@ -0,0 +1,67 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 33 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %tan_ae26ae "tan_ae26ae" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %v3float = OpTypeVector %float 3 +%float_1_55740774 = OpConstant %float 1.55740774 + %15 = OpConstantComposite %v3float %float_1_55740774 %float_1_55740774 %float_1_55740774 +%_ptr_Function_v3float = OpTypePointer Function %v3float + %18 = OpConstantNull %v3float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 + %tan_ae26ae = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v3float Function %18 + OpStore %res %15 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %tan_ae26ae + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %tan_ae26ae + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %31 = OpLabel + %32 = OpFunctionCall %void %tan_ae26ae + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/tan/ae26ae.wgsl.expected.wgsl b/test/tint/builtins/gen/var/tan/ae26ae.wgsl.expected.wgsl new file mode 100644 index 0000000000..898c9e82f2 --- /dev/null +++ b/test/tint/builtins/gen/var/tan/ae26ae.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn tan_ae26ae() { + const arg_0 = vec3(1.0); + var res = tan(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + tan_ae26ae(); + return vec4(); +} + +@fragment +fn fragment_main() { + tan_ae26ae(); +} + +@compute @workgroup_size(1) +fn compute_main() { + tan_ae26ae(); +} diff --git a/test/tint/builtins/gen/var/tanh/313aa1.wgsl b/test/tint/builtins/gen/var/tanh/313aa1.wgsl new file mode 100644 index 0000000000..2492207f2d --- /dev/null +++ b/test/tint/builtins/gen/var/tanh/313aa1.wgsl @@ -0,0 +1,44 @@ +// 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. + +//////////////////////////////////////////////////////////////////////////////// +// File generated by tools/src/cmd/gen +// using the template: +// test/tint/builtins/gen/gen.wgsl.tmpl +// +// Do not modify this file directly +//////////////////////////////////////////////////////////////////////////////// + + +// fn tanh(fa) -> fa +fn tanh_313aa1() { + const arg_0 = 1.; + var res = tanh(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + tanh_313aa1(); + return vec4(); +} + +@fragment +fn fragment_main() { + tanh_313aa1(); +} + +@compute @workgroup_size(1) +fn compute_main() { + tanh_313aa1(); +} diff --git a/test/tint/builtins/gen/var/tanh/313aa1.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/tanh/313aa1.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..531d03709d --- /dev/null +++ b/test/tint/builtins/gen/var/tanh/313aa1.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void tanh_313aa1() { + float res = 0.761594176f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + tanh_313aa1(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + tanh_313aa1(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + tanh_313aa1(); + return; +} diff --git a/test/tint/builtins/gen/var/tanh/313aa1.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/tanh/313aa1.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..531d03709d --- /dev/null +++ b/test/tint/builtins/gen/var/tanh/313aa1.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void tanh_313aa1() { + float res = 0.761594176f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + tanh_313aa1(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + tanh_313aa1(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + tanh_313aa1(); + return; +} diff --git a/test/tint/builtins/gen/var/tanh/313aa1.wgsl.expected.glsl b/test/tint/builtins/gen/var/tanh/313aa1.wgsl.expected.glsl new file mode 100644 index 0000000000..9a6f7ece40 --- /dev/null +++ b/test/tint/builtins/gen/var/tanh/313aa1.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void tanh_313aa1() { + float res = 0.761594176f; +} + +vec4 vertex_main() { + tanh_313aa1(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void tanh_313aa1() { + float res = 0.761594176f; +} + +void fragment_main() { + tanh_313aa1(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void tanh_313aa1() { + float res = 0.761594176f; +} + +void compute_main() { + tanh_313aa1(); +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() { + compute_main(); + return; +} diff --git a/test/tint/builtins/gen/var/tanh/313aa1.wgsl.expected.msl b/test/tint/builtins/gen/var/tanh/313aa1.wgsl.expected.msl new file mode 100644 index 0000000000..36f2eb883b --- /dev/null +++ b/test/tint/builtins/gen/var/tanh/313aa1.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void tanh_313aa1() { + float res = 0.761594176f; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + tanh_313aa1(); + return float4(0.0f); +} + +vertex tint_symbol vertex_main() { + float4 const inner_result = vertex_main_inner(); + tint_symbol wrapper_result = {}; + wrapper_result.value = inner_result; + return wrapper_result; +} + +fragment void fragment_main() { + tanh_313aa1(); + return; +} + +kernel void compute_main() { + tanh_313aa1(); + return; +} + diff --git a/test/tint/builtins/gen/var/tanh/313aa1.wgsl.expected.spvasm b/test/tint/builtins/gen/var/tanh/313aa1.wgsl.expected.spvasm new file mode 100644 index 0000000000..d7ebe58d3b --- /dev/null +++ b/test/tint/builtins/gen/var/tanh/313aa1.wgsl.expected.spvasm @@ -0,0 +1,64 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 30 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %tanh_313aa1 "tanh_313aa1" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void +%float_0_761594176 = OpConstant %float 0.761594176 +%_ptr_Function_float = OpTypePointer Function %float + %16 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%tanh_313aa1 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_float Function %8 + OpStore %res %float_0_761594176 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %16 + %18 = OpLabel + %19 = OpFunctionCall %void %tanh_313aa1 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %21 = OpLabel + %22 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %22 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %25 = OpLabel + %26 = OpFunctionCall %void %tanh_313aa1 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %tanh_313aa1 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/tanh/313aa1.wgsl.expected.wgsl b/test/tint/builtins/gen/var/tanh/313aa1.wgsl.expected.wgsl new file mode 100644 index 0000000000..4c498d9bc0 --- /dev/null +++ b/test/tint/builtins/gen/var/tanh/313aa1.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn tanh_313aa1() { + const arg_0 = 1.0; + var res = tanh(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + tanh_313aa1(); + return vec4(); +} + +@fragment +fn fragment_main() { + tanh_313aa1(); +} + +@compute @workgroup_size(1) +fn compute_main() { + tanh_313aa1(); +} diff --git a/test/tint/builtins/gen/var/tanh/6289fd.wgsl b/test/tint/builtins/gen/var/tanh/6289fd.wgsl new file mode 100644 index 0000000000..95f7e87bfb --- /dev/null +++ b/test/tint/builtins/gen/var/tanh/6289fd.wgsl @@ -0,0 +1,44 @@ +// 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. + +//////////////////////////////////////////////////////////////////////////////// +// File generated by tools/src/cmd/gen +// using the template: +// test/tint/builtins/gen/gen.wgsl.tmpl +// +// Do not modify this file directly +//////////////////////////////////////////////////////////////////////////////// + + +// fn tanh(vec<3, fa>) -> vec<3, fa> +fn tanh_6289fd() { + const arg_0 = vec3(1.); + var res = tanh(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + tanh_6289fd(); + return vec4(); +} + +@fragment +fn fragment_main() { + tanh_6289fd(); +} + +@compute @workgroup_size(1) +fn compute_main() { + tanh_6289fd(); +} diff --git a/test/tint/builtins/gen/var/tanh/6289fd.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/tanh/6289fd.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..b804dc3076 --- /dev/null +++ b/test/tint/builtins/gen/var/tanh/6289fd.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void tanh_6289fd() { + float3 res = (0.761594176f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + tanh_6289fd(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + tanh_6289fd(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + tanh_6289fd(); + return; +} diff --git a/test/tint/builtins/gen/var/tanh/6289fd.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/tanh/6289fd.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..b804dc3076 --- /dev/null +++ b/test/tint/builtins/gen/var/tanh/6289fd.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void tanh_6289fd() { + float3 res = (0.761594176f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + tanh_6289fd(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + tanh_6289fd(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + tanh_6289fd(); + return; +} diff --git a/test/tint/builtins/gen/var/tanh/6289fd.wgsl.expected.glsl b/test/tint/builtins/gen/var/tanh/6289fd.wgsl.expected.glsl new file mode 100644 index 0000000000..b883e60488 --- /dev/null +++ b/test/tint/builtins/gen/var/tanh/6289fd.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void tanh_6289fd() { + vec3 res = vec3(0.761594176f); +} + +vec4 vertex_main() { + tanh_6289fd(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void tanh_6289fd() { + vec3 res = vec3(0.761594176f); +} + +void fragment_main() { + tanh_6289fd(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void tanh_6289fd() { + vec3 res = vec3(0.761594176f); +} + +void compute_main() { + tanh_6289fd(); +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() { + compute_main(); + return; +} diff --git a/test/tint/builtins/gen/var/tanh/6289fd.wgsl.expected.msl b/test/tint/builtins/gen/var/tanh/6289fd.wgsl.expected.msl new file mode 100644 index 0000000000..491a4dac48 --- /dev/null +++ b/test/tint/builtins/gen/var/tanh/6289fd.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void tanh_6289fd() { + float3 res = float3(0.761594176f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + tanh_6289fd(); + return float4(0.0f); +} + +vertex tint_symbol vertex_main() { + float4 const inner_result = vertex_main_inner(); + tint_symbol wrapper_result = {}; + wrapper_result.value = inner_result; + return wrapper_result; +} + +fragment void fragment_main() { + tanh_6289fd(); + return; +} + +kernel void compute_main() { + tanh_6289fd(); + return; +} + diff --git a/test/tint/builtins/gen/var/tanh/6289fd.wgsl.expected.spvasm b/test/tint/builtins/gen/var/tanh/6289fd.wgsl.expected.spvasm new file mode 100644 index 0000000000..620d06cdc2 --- /dev/null +++ b/test/tint/builtins/gen/var/tanh/6289fd.wgsl.expected.spvasm @@ -0,0 +1,67 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 33 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %tanh_6289fd "tanh_6289fd" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %v3float = OpTypeVector %float 3 +%float_0_761594176 = OpConstant %float 0.761594176 + %15 = OpConstantComposite %v3float %float_0_761594176 %float_0_761594176 %float_0_761594176 +%_ptr_Function_v3float = OpTypePointer Function %v3float + %18 = OpConstantNull %v3float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%tanh_6289fd = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v3float Function %18 + OpStore %res %15 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %tanh_6289fd + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %tanh_6289fd + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %31 = OpLabel + %32 = OpFunctionCall %void %tanh_6289fd + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/tanh/6289fd.wgsl.expected.wgsl b/test/tint/builtins/gen/var/tanh/6289fd.wgsl.expected.wgsl new file mode 100644 index 0000000000..7fa6f0248e --- /dev/null +++ b/test/tint/builtins/gen/var/tanh/6289fd.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn tanh_6289fd() { + const arg_0 = vec3(1.0); + var res = tanh(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + tanh_6289fd(); + return vec4(); +} + +@fragment +fn fragment_main() { + tanh_6289fd(); +} + +@compute @workgroup_size(1) +fn compute_main() { + tanh_6289fd(); +} diff --git a/test/tint/builtins/gen/var/tanh/ac5d33.wgsl b/test/tint/builtins/gen/var/tanh/ac5d33.wgsl new file mode 100644 index 0000000000..972b2a1ba1 --- /dev/null +++ b/test/tint/builtins/gen/var/tanh/ac5d33.wgsl @@ -0,0 +1,44 @@ +// 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. + +//////////////////////////////////////////////////////////////////////////////// +// File generated by tools/src/cmd/gen +// using the template: +// test/tint/builtins/gen/gen.wgsl.tmpl +// +// Do not modify this file directly +//////////////////////////////////////////////////////////////////////////////// + + +// fn tanh(vec<4, fa>) -> vec<4, fa> +fn tanh_ac5d33() { + const arg_0 = vec4(1.); + var res = tanh(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + tanh_ac5d33(); + return vec4(); +} + +@fragment +fn fragment_main() { + tanh_ac5d33(); +} + +@compute @workgroup_size(1) +fn compute_main() { + tanh_ac5d33(); +} diff --git a/test/tint/builtins/gen/var/tanh/ac5d33.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/tanh/ac5d33.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..1b0ad2864c --- /dev/null +++ b/test/tint/builtins/gen/var/tanh/ac5d33.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void tanh_ac5d33() { + float4 res = (0.761594176f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + tanh_ac5d33(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + tanh_ac5d33(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + tanh_ac5d33(); + return; +} diff --git a/test/tint/builtins/gen/var/tanh/ac5d33.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/tanh/ac5d33.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..1b0ad2864c --- /dev/null +++ b/test/tint/builtins/gen/var/tanh/ac5d33.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void tanh_ac5d33() { + float4 res = (0.761594176f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + tanh_ac5d33(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + tanh_ac5d33(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + tanh_ac5d33(); + return; +} diff --git a/test/tint/builtins/gen/var/tanh/ac5d33.wgsl.expected.glsl b/test/tint/builtins/gen/var/tanh/ac5d33.wgsl.expected.glsl new file mode 100644 index 0000000000..698681db0c --- /dev/null +++ b/test/tint/builtins/gen/var/tanh/ac5d33.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void tanh_ac5d33() { + vec4 res = vec4(0.761594176f); +} + +vec4 vertex_main() { + tanh_ac5d33(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void tanh_ac5d33() { + vec4 res = vec4(0.761594176f); +} + +void fragment_main() { + tanh_ac5d33(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void tanh_ac5d33() { + vec4 res = vec4(0.761594176f); +} + +void compute_main() { + tanh_ac5d33(); +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() { + compute_main(); + return; +} diff --git a/test/tint/builtins/gen/var/tanh/ac5d33.wgsl.expected.msl b/test/tint/builtins/gen/var/tanh/ac5d33.wgsl.expected.msl new file mode 100644 index 0000000000..a6e681d803 --- /dev/null +++ b/test/tint/builtins/gen/var/tanh/ac5d33.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void tanh_ac5d33() { + float4 res = float4(0.761594176f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + tanh_ac5d33(); + return float4(0.0f); +} + +vertex tint_symbol vertex_main() { + float4 const inner_result = vertex_main_inner(); + tint_symbol wrapper_result = {}; + wrapper_result.value = inner_result; + return wrapper_result; +} + +fragment void fragment_main() { + tanh_ac5d33(); + return; +} + +kernel void compute_main() { + tanh_ac5d33(); + return; +} + diff --git a/test/tint/builtins/gen/var/tanh/ac5d33.wgsl.expected.spvasm b/test/tint/builtins/gen/var/tanh/ac5d33.wgsl.expected.spvasm new file mode 100644 index 0000000000..fd98e9493f --- /dev/null +++ b/test/tint/builtins/gen/var/tanh/ac5d33.wgsl.expected.spvasm @@ -0,0 +1,65 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 31 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %tanh_ac5d33 "tanh_ac5d33" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void +%float_0_761594176 = OpConstant %float 0.761594176 + %14 = OpConstantComposite %v4float %float_0_761594176 %float_0_761594176 %float_0_761594176 %float_0_761594176 +%_ptr_Function_v4float = OpTypePointer Function %v4float + %17 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%tanh_ac5d33 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v4float Function %5 + OpStore %res %14 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %17 + %19 = OpLabel + %20 = OpFunctionCall %void %tanh_ac5d33 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %26 = OpLabel + %27 = OpFunctionCall %void %tanh_ac5d33 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %29 = OpLabel + %30 = OpFunctionCall %void %tanh_ac5d33 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/tanh/ac5d33.wgsl.expected.wgsl b/test/tint/builtins/gen/var/tanh/ac5d33.wgsl.expected.wgsl new file mode 100644 index 0000000000..ba8a138a7b --- /dev/null +++ b/test/tint/builtins/gen/var/tanh/ac5d33.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn tanh_ac5d33() { + const arg_0 = vec4(1.0); + var res = tanh(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + tanh_ac5d33(); + return vec4(); +} + +@fragment +fn fragment_main() { + tanh_ac5d33(); +} + +@compute @workgroup_size(1) +fn compute_main() { + tanh_ac5d33(); +} diff --git a/test/tint/builtins/gen/var/tanh/c48aa6.wgsl b/test/tint/builtins/gen/var/tanh/c48aa6.wgsl new file mode 100644 index 0000000000..f189900ad5 --- /dev/null +++ b/test/tint/builtins/gen/var/tanh/c48aa6.wgsl @@ -0,0 +1,44 @@ +// 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. + +//////////////////////////////////////////////////////////////////////////////// +// File generated by tools/src/cmd/gen +// using the template: +// test/tint/builtins/gen/gen.wgsl.tmpl +// +// Do not modify this file directly +//////////////////////////////////////////////////////////////////////////////// + + +// fn tanh(vec<2, fa>) -> vec<2, fa> +fn tanh_c48aa6() { + const arg_0 = vec2(1.); + var res = tanh(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + tanh_c48aa6(); + return vec4(); +} + +@fragment +fn fragment_main() { + tanh_c48aa6(); +} + +@compute @workgroup_size(1) +fn compute_main() { + tanh_c48aa6(); +} diff --git a/test/tint/builtins/gen/var/tanh/c48aa6.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/tanh/c48aa6.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..39bb4dfa50 --- /dev/null +++ b/test/tint/builtins/gen/var/tanh/c48aa6.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void tanh_c48aa6() { + float2 res = (0.761594176f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + tanh_c48aa6(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + tanh_c48aa6(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + tanh_c48aa6(); + return; +} diff --git a/test/tint/builtins/gen/var/tanh/c48aa6.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/tanh/c48aa6.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..39bb4dfa50 --- /dev/null +++ b/test/tint/builtins/gen/var/tanh/c48aa6.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void tanh_c48aa6() { + float2 res = (0.761594176f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + tanh_c48aa6(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + tanh_c48aa6(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + tanh_c48aa6(); + return; +} diff --git a/test/tint/builtins/gen/var/tanh/c48aa6.wgsl.expected.glsl b/test/tint/builtins/gen/var/tanh/c48aa6.wgsl.expected.glsl new file mode 100644 index 0000000000..fe899fae04 --- /dev/null +++ b/test/tint/builtins/gen/var/tanh/c48aa6.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void tanh_c48aa6() { + vec2 res = vec2(0.761594176f); +} + +vec4 vertex_main() { + tanh_c48aa6(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void tanh_c48aa6() { + vec2 res = vec2(0.761594176f); +} + +void fragment_main() { + tanh_c48aa6(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void tanh_c48aa6() { + vec2 res = vec2(0.761594176f); +} + +void compute_main() { + tanh_c48aa6(); +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() { + compute_main(); + return; +} diff --git a/test/tint/builtins/gen/var/tanh/c48aa6.wgsl.expected.msl b/test/tint/builtins/gen/var/tanh/c48aa6.wgsl.expected.msl new file mode 100644 index 0000000000..49ccdba2fb --- /dev/null +++ b/test/tint/builtins/gen/var/tanh/c48aa6.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void tanh_c48aa6() { + float2 res = float2(0.761594176f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + tanh_c48aa6(); + return float4(0.0f); +} + +vertex tint_symbol vertex_main() { + float4 const inner_result = vertex_main_inner(); + tint_symbol wrapper_result = {}; + wrapper_result.value = inner_result; + return wrapper_result; +} + +fragment void fragment_main() { + tanh_c48aa6(); + return; +} + +kernel void compute_main() { + tanh_c48aa6(); + return; +} + diff --git a/test/tint/builtins/gen/var/tanh/c48aa6.wgsl.expected.spvasm b/test/tint/builtins/gen/var/tanh/c48aa6.wgsl.expected.spvasm new file mode 100644 index 0000000000..8a9dc92ceb --- /dev/null +++ b/test/tint/builtins/gen/var/tanh/c48aa6.wgsl.expected.spvasm @@ -0,0 +1,67 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 33 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %tanh_c48aa6 "tanh_c48aa6" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %v2float = OpTypeVector %float 2 +%float_0_761594176 = OpConstant %float 0.761594176 + %15 = OpConstantComposite %v2float %float_0_761594176 %float_0_761594176 +%_ptr_Function_v2float = OpTypePointer Function %v2float + %18 = OpConstantNull %v2float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%tanh_c48aa6 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v2float Function %18 + OpStore %res %15 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %tanh_c48aa6 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %tanh_c48aa6 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %31 = OpLabel + %32 = OpFunctionCall %void %tanh_c48aa6 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/tanh/c48aa6.wgsl.expected.wgsl b/test/tint/builtins/gen/var/tanh/c48aa6.wgsl.expected.wgsl new file mode 100644 index 0000000000..c272b36fc8 --- /dev/null +++ b/test/tint/builtins/gen/var/tanh/c48aa6.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn tanh_c48aa6() { + const arg_0 = vec2(1.0); + var res = tanh(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + tanh_c48aa6(); + return vec4(); +} + +@fragment +fn fragment_main() { + tanh_c48aa6(); +} + +@compute @workgroup_size(1) +fn compute_main() { + tanh_c48aa6(); +}