tint/intrinsics.def: Add @test_value() annotation

Specifies the value to use for argument values when generating end-to-end tests.

Use this to provide a legal value for atanh().

Change-Id: I008050c856f9d687ab918c68e90678c4e74f3a1d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106887
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton 2022-10-25 13:08:45 +00:00
parent c3adc78cbc
commit 95dd428c75
69 changed files with 394 additions and 313 deletions

View File

@ -423,8 +423,8 @@ fn asinh<N: num, T: f32_f16>(vec<N, T>) -> vec<N, T>
@const fn atan<N: num, T: fa_f32_f16>(vec<N, T>) -> vec<N, T> @const fn atan<N: num, T: fa_f32_f16>(vec<N, T>) -> vec<N, T>
@const fn atan2<T: fa_f32_f16>(T, T) -> T @const fn atan2<T: fa_f32_f16>(T, T) -> T
@const fn atan2<T: fa_f32_f16, N: num>(vec<N, T>, vec<N, T>) -> vec<N, T> @const fn atan2<T: fa_f32_f16, N: num>(vec<N, T>, vec<N, T>) -> vec<N, T>
fn atanh<T: f32_f16>(T) -> T fn atanh<T: f32_f16>(@test_value(0.5) T) -> T
fn atanh<N: num, T: f32_f16>(vec<N, T>) -> vec<N, T> fn atanh<N: num, T: f32_f16>(@test_value(0.5) vec<N, T>) -> vec<N, T>
fn ceil<T: f32_f16>(T) -> T fn ceil<T: f32_f16>(T) -> T
fn ceil<N: num, T: f32_f16>(vec<N, T>) -> vec<N, T> fn ceil<N: num, T: f32_f16>(vec<N, T>) -> vec<N, T>
@const fn clamp<T: fia_fiu32_f16>(T, T, T) -> T @const fn clamp<T: fia_fiu32_f16>(T, T, T) -> T

View File

@ -13997,8 +13997,8 @@ constexpr IntrinsicInfo kBuiltins[] = {
}, },
{ {
/* [10] */ /* [10] */
/* fn atanh<T : f32_f16>(T) -> T */ /* fn atanh<T : f32_f16>(@test_value(0.5) T) -> T */
/* fn atanh<N : num, T : f32_f16>(vec<N, T>) -> vec<N, T> */ /* fn atanh<N : num, T : f32_f16>(@test_value(0.5) vec<N, T>) -> vec<N, T> */
/* num overloads */ 2, /* num overloads */ 2,
/* overloads */ &kOverloads[404], /* overloads */ &kOverloads[404],
}, },

View File

@ -265,17 +265,22 @@ enable f16;
{{- /* Returns a value that can be used for the parameter argument */ -}} {{- /* Returns a value that can be used for the parameter argument */ -}}
{{- /* ------------------------------------------------------------------ */ -}} {{- /* ------------------------------------------------------------------ */ -}}
{{- $ty := .Type -}} {{- $ty := .Type -}}
{{- if eq $ty.Target.Name "i32" -}}1i {{- $value := printf "%v" .TestValue }}
{{- else if eq $ty.Target.Name "u32" -}}1u {{- /* $float_value is $value with a '.' suffix (if it wasn't a float already) */ -}}
{{- else if eq $ty.Target.Name "f32" -}}1.f {{- $float_value := $value }}
{{- else if eq $ty.Target.Name "fa" -}}1 {{- if not (Contains $value ".") }}{{$float_value = printf "%v." $value}}{{end}}
{{- else if eq $ty.Target.Name "ia" -}}1.0 {{- /* emit the value with any necessary suffixes */ -}}
{{- if eq $ty.Target.Name "i32" -}}{{$value}}i
{{- else if eq $ty.Target.Name "u32" -}}{{$value}}u
{{- else if eq $ty.Target.Name "f32" -}}{{$float_value}}f
{{- else if eq $ty.Target.Name "fa" -}}{{$value}}
{{- else if eq $ty.Target.Name "ia" -}}{{$float_value}}0
{{- else if eq $ty.Target.Name "bool" -}}true {{- else if eq $ty.Target.Name "bool" -}}true
{{- else if eq $ty.Target.Name "vec" -}} {{- else if eq $ty.Target.Name "vec" -}}
{{- $el := Eval "ArgumentValue" "Type" (ElementType .Type) "Name" ""}} {{- $el := Eval "ArgumentValue" "Type" (ElementType .Type) "Name" "" "TestValue" .TestValue }}
{{- template "Type" $ty}}({{$el}}) {{- template "Type" $ty}}({{$el}})
{{- else if eq $ty.Target.Name "mat" -}}{{template "Type" $ty}}( {{- else if eq $ty.Target.Name "mat" -}}{{template "Type" $ty}}(
{{- $el := Eval "ArgumentValue" "Type" (ElementType .Type) "Name" ""}} {{- $el := Eval "ArgumentValue" "Type" (ElementType .Type) "Name" "" "TestValue" .TestValue }}
{{- range $col := Iterate (index $ty.TemplateArguments 0) }} {{- range $col := Iterate (index $ty.TemplateArguments 0) }}
{{- range $row := Iterate (index $ty.TemplateArguments 1) }} {{- range $row := Iterate (index $ty.TemplateArguments 1) }}
{{- if or $col $row -}}, {{end}}{{$el}} {{- if or $col $row -}}, {{end}}{{$el}}

View File

@ -23,7 +23,7 @@
// fn atanh(vec<3, f32>) -> vec<3, f32> // fn atanh(vec<3, f32>) -> vec<3, f32>
fn atanh_440cca() { fn atanh_440cca() {
var res: vec3<f32> = atanh(vec3<f32>(1.f)); var res: vec3<f32> = atanh(vec3<f32>(0.5f));
} }
@vertex @vertex

View File

@ -3,7 +3,7 @@ float3 tint_atanh(float3 x) {
} }
void atanh_440cca() { void atanh_440cca() {
float3 res = tint_atanh((1.0f).xxx); float3 res = tint_atanh((0.5f).xxx);
} }
struct tint_symbol { struct tint_symbol {

View File

@ -3,7 +3,7 @@ float3 tint_atanh(float3 x) {
} }
void atanh_440cca() { void atanh_440cca() {
float3 res = tint_atanh((1.0f).xxx); float3 res = tint_atanh((0.5f).xxx);
} }
struct tint_symbol { struct tint_symbol {

View File

@ -5,7 +5,7 @@ vec3 tint_atanh(vec3 x) {
} }
void atanh_440cca() { void atanh_440cca() {
vec3 res = tint_atanh(vec3(1.0f)); vec3 res = tint_atanh(vec3(0.5f));
} }
vec4 vertex_main() { vec4 vertex_main() {
@ -29,7 +29,7 @@ vec3 tint_atanh(vec3 x) {
} }
void atanh_440cca() { void atanh_440cca() {
vec3 res = tint_atanh(vec3(1.0f)); vec3 res = tint_atanh(vec3(0.5f));
} }
void fragment_main() { void fragment_main() {
@ -47,7 +47,7 @@ vec3 tint_atanh(vec3 x) {
} }
void atanh_440cca() { void atanh_440cca() {
vec3 res = tint_atanh(vec3(1.0f)); vec3 res = tint_atanh(vec3(0.5f));
} }
void compute_main() { void compute_main() {

View File

@ -6,7 +6,7 @@ float3 tint_atanh(float3 x) {
} }
void atanh_440cca() { void atanh_440cca() {
float3 res = tint_atanh(float3(1.0f)); float3 res = tint_atanh(float3(0.5f));
} }
struct tint_symbol { struct tint_symbol {

View File

@ -1,7 +1,7 @@
; SPIR-V ; SPIR-V
; Version: 1.3 ; Version: 1.3
; Generator: Google Tint Compiler; 0 ; Generator: Google Tint Compiler; 0
; Bound: 43 ; Bound: 45
; Schema: 0 ; Schema: 0
OpCapability Shader OpCapability Shader
%22 = OpExtInstImport "GLSL.std.450" %22 = OpExtInstImport "GLSL.std.450"
@ -40,8 +40,10 @@
%20 = OpConstantNull %v3float %20 = OpConstantNull %v3float
%void = OpTypeVoid %void = OpTypeVoid
%23 = OpTypeFunction %void %23 = OpTypeFunction %void
%float_0_5 = OpConstant %float 0.5
%29 = OpConstantComposite %v3float %float_0_5 %float_0_5 %float_0_5
%_ptr_Function_v3float = OpTypePointer Function %v3float %_ptr_Function_v3float = OpTypePointer Function %v3float
%30 = OpTypeFunction %v4float %32 = OpTypeFunction %v4float
%tint_atanh = OpFunction %v3float None %9 %tint_atanh = OpFunction %v3float None %9
%x = OpFunctionParameter %v3float %x = OpFunctionParameter %v3float
%13 = OpLabel %13 = OpLabel
@ -53,29 +55,29 @@
%atanh_440cca = OpFunction %void None %23 %atanh_440cca = OpFunction %void None %23
%26 = OpLabel %26 = OpLabel
%res = OpVariable %_ptr_Function_v3float Function %20 %res = OpVariable %_ptr_Function_v3float Function %20
%27 = OpFunctionCall %v3float %tint_atanh %16 %27 = OpFunctionCall %v3float %tint_atanh %29
OpStore %res %27 OpStore %res %27
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%vertex_main_inner = OpFunction %v4float None %30 %vertex_main_inner = OpFunction %v4float None %32
%32 = OpLabel %34 = OpLabel
%33 = OpFunctionCall %void %atanh_440cca %35 = OpFunctionCall %void %atanh_440cca
OpReturnValue %5 OpReturnValue %5
OpFunctionEnd OpFunctionEnd
%vertex_main = OpFunction %void None %23 %vertex_main = OpFunction %void None %23
%35 = OpLabel %37 = OpLabel
%36 = OpFunctionCall %v4float %vertex_main_inner %38 = OpFunctionCall %v4float %vertex_main_inner
OpStore %value %36 OpStore %value %38
OpStore %vertex_point_size %float_1 OpStore %vertex_point_size %float_1
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%fragment_main = OpFunction %void None %23 %fragment_main = OpFunction %void None %23
%38 = OpLabel %40 = OpLabel
%39 = OpFunctionCall %void %atanh_440cca %41 = OpFunctionCall %void %atanh_440cca
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%compute_main = OpFunction %void None %23 %compute_main = OpFunction %void None %23
%41 = OpLabel %43 = OpLabel
%42 = OpFunctionCall %void %atanh_440cca %44 = OpFunctionCall %void %atanh_440cca
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd

View File

@ -1,5 +1,5 @@
fn atanh_440cca() { fn atanh_440cca() {
var res : vec3<f32> = atanh(vec3<f32>(1.0f)); var res : vec3<f32> = atanh(vec3<f32>(0.5f));
} }
@vertex @vertex

View File

@ -23,7 +23,7 @@
// fn atanh(f32) -> f32 // fn atanh(f32) -> f32
fn atanh_7997d8() { fn atanh_7997d8() {
var res: f32 = atanh(1.f); var res: f32 = atanh(0.5f);
} }
@vertex @vertex

View File

@ -3,7 +3,7 @@ float tint_atanh(float x) {
} }
void atanh_7997d8() { void atanh_7997d8() {
float res = tint_atanh(1.0f); float res = tint_atanh(0.5f);
} }
struct tint_symbol { struct tint_symbol {

View File

@ -3,7 +3,7 @@ float tint_atanh(float x) {
} }
void atanh_7997d8() { void atanh_7997d8() {
float res = tint_atanh(1.0f); float res = tint_atanh(0.5f);
} }
struct tint_symbol { struct tint_symbol {

View File

@ -5,7 +5,7 @@ float tint_atanh(float x) {
} }
void atanh_7997d8() { void atanh_7997d8() {
float res = tint_atanh(1.0f); float res = tint_atanh(0.5f);
} }
vec4 vertex_main() { vec4 vertex_main() {
@ -29,7 +29,7 @@ float tint_atanh(float x) {
} }
void atanh_7997d8() { void atanh_7997d8() {
float res = tint_atanh(1.0f); float res = tint_atanh(0.5f);
} }
void fragment_main() { void fragment_main() {
@ -47,7 +47,7 @@ float tint_atanh(float x) {
} }
void atanh_7997d8() { void atanh_7997d8() {
float res = tint_atanh(1.0f); float res = tint_atanh(0.5f);
} }
void compute_main() { void compute_main() {

View File

@ -6,7 +6,7 @@ float tint_atanh(float x) {
} }
void atanh_7997d8() { void atanh_7997d8() {
float res = tint_atanh(1.0f); float res = tint_atanh(0.5f);
} }
struct tint_symbol { struct tint_symbol {

View File

@ -1,7 +1,7 @@
; SPIR-V ; SPIR-V
; Version: 1.3 ; Version: 1.3
; Generator: Google Tint Compiler; 0 ; Generator: Google Tint Compiler; 0
; Bound: 39 ; Bound: 40
; Schema: 0 ; Schema: 0
OpCapability Shader OpCapability Shader
%18 = OpExtInstImport "GLSL.std.450" %18 = OpExtInstImport "GLSL.std.450"
@ -36,8 +36,9 @@
%bool = OpTypeBool %bool = OpTypeBool
%void = OpTypeVoid %void = OpTypeVoid
%19 = OpTypeFunction %void %19 = OpTypeFunction %void
%float_0_5 = OpConstant %float 0.5
%_ptr_Function_float = OpTypePointer Function %float %_ptr_Function_float = OpTypePointer Function %float
%26 = OpTypeFunction %v4float %27 = OpTypeFunction %v4float
%tint_atanh = OpFunction %float None %9 %tint_atanh = OpFunction %float None %9
%x = OpFunctionParameter %float %x = OpFunctionParameter %float
%12 = OpLabel %12 = OpLabel
@ -49,29 +50,29 @@
%atanh_7997d8 = OpFunction %void None %19 %atanh_7997d8 = OpFunction %void None %19
%22 = OpLabel %22 = OpLabel
%res = OpVariable %_ptr_Function_float Function %8 %res = OpVariable %_ptr_Function_float Function %8
%23 = OpFunctionCall %float %tint_atanh %float_1 %23 = OpFunctionCall %float %tint_atanh %float_0_5
OpStore %res %23 OpStore %res %23
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%vertex_main_inner = OpFunction %v4float None %26 %vertex_main_inner = OpFunction %v4float None %27
%28 = OpLabel %29 = OpLabel
%29 = OpFunctionCall %void %atanh_7997d8 %30 = OpFunctionCall %void %atanh_7997d8
OpReturnValue %5 OpReturnValue %5
OpFunctionEnd OpFunctionEnd
%vertex_main = OpFunction %void None %19 %vertex_main = OpFunction %void None %19
%31 = OpLabel %32 = OpLabel
%32 = OpFunctionCall %v4float %vertex_main_inner %33 = OpFunctionCall %v4float %vertex_main_inner
OpStore %value %32 OpStore %value %33
OpStore %vertex_point_size %float_1 OpStore %vertex_point_size %float_1
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%fragment_main = OpFunction %void None %19 %fragment_main = OpFunction %void None %19
%34 = OpLabel %35 = OpLabel
%35 = OpFunctionCall %void %atanh_7997d8 %36 = OpFunctionCall %void %atanh_7997d8
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%compute_main = OpFunction %void None %19 %compute_main = OpFunction %void None %19
%37 = OpLabel %38 = OpLabel
%38 = OpFunctionCall %void %atanh_7997d8 %39 = OpFunctionCall %void %atanh_7997d8
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd

View File

@ -1,5 +1,5 @@
fn atanh_7997d8() { fn atanh_7997d8() {
var res : f32 = atanh(1.0f); var res : f32 = atanh(0.5f);
} }
@vertex @vertex

View File

@ -23,7 +23,7 @@
// fn atanh(vec<2, f32>) -> vec<2, f32> // fn atanh(vec<2, f32>) -> vec<2, f32>
fn atanh_c0e634() { fn atanh_c0e634() {
var res: vec2<f32> = atanh(vec2<f32>(1.f)); var res: vec2<f32> = atanh(vec2<f32>(0.5f));
} }
@vertex @vertex

View File

@ -3,7 +3,7 @@ float2 tint_atanh(float2 x) {
} }
void atanh_c0e634() { void atanh_c0e634() {
float2 res = tint_atanh((1.0f).xx); float2 res = tint_atanh((0.5f).xx);
} }
struct tint_symbol { struct tint_symbol {

View File

@ -3,7 +3,7 @@ float2 tint_atanh(float2 x) {
} }
void atanh_c0e634() { void atanh_c0e634() {
float2 res = tint_atanh((1.0f).xx); float2 res = tint_atanh((0.5f).xx);
} }
struct tint_symbol { struct tint_symbol {

View File

@ -5,7 +5,7 @@ vec2 tint_atanh(vec2 x) {
} }
void atanh_c0e634() { void atanh_c0e634() {
vec2 res = tint_atanh(vec2(1.0f)); vec2 res = tint_atanh(vec2(0.5f));
} }
vec4 vertex_main() { vec4 vertex_main() {
@ -29,7 +29,7 @@ vec2 tint_atanh(vec2 x) {
} }
void atanh_c0e634() { void atanh_c0e634() {
vec2 res = tint_atanh(vec2(1.0f)); vec2 res = tint_atanh(vec2(0.5f));
} }
void fragment_main() { void fragment_main() {
@ -47,7 +47,7 @@ vec2 tint_atanh(vec2 x) {
} }
void atanh_c0e634() { void atanh_c0e634() {
vec2 res = tint_atanh(vec2(1.0f)); vec2 res = tint_atanh(vec2(0.5f));
} }
void compute_main() { void compute_main() {

View File

@ -6,7 +6,7 @@ float2 tint_atanh(float2 x) {
} }
void atanh_c0e634() { void atanh_c0e634() {
float2 res = tint_atanh(float2(1.0f)); float2 res = tint_atanh(float2(0.5f));
} }
struct tint_symbol { struct tint_symbol {

View File

@ -1,7 +1,7 @@
; SPIR-V ; SPIR-V
; Version: 1.3 ; Version: 1.3
; Generator: Google Tint Compiler; 0 ; Generator: Google Tint Compiler; 0
; Bound: 43 ; Bound: 45
; Schema: 0 ; Schema: 0
OpCapability Shader OpCapability Shader
%22 = OpExtInstImport "GLSL.std.450" %22 = OpExtInstImport "GLSL.std.450"
@ -40,8 +40,10 @@
%20 = OpConstantNull %v2float %20 = OpConstantNull %v2float
%void = OpTypeVoid %void = OpTypeVoid
%23 = OpTypeFunction %void %23 = OpTypeFunction %void
%float_0_5 = OpConstant %float 0.5
%29 = OpConstantComposite %v2float %float_0_5 %float_0_5
%_ptr_Function_v2float = OpTypePointer Function %v2float %_ptr_Function_v2float = OpTypePointer Function %v2float
%30 = OpTypeFunction %v4float %32 = OpTypeFunction %v4float
%tint_atanh = OpFunction %v2float None %9 %tint_atanh = OpFunction %v2float None %9
%x = OpFunctionParameter %v2float %x = OpFunctionParameter %v2float
%13 = OpLabel %13 = OpLabel
@ -53,29 +55,29 @@
%atanh_c0e634 = OpFunction %void None %23 %atanh_c0e634 = OpFunction %void None %23
%26 = OpLabel %26 = OpLabel
%res = OpVariable %_ptr_Function_v2float Function %20 %res = OpVariable %_ptr_Function_v2float Function %20
%27 = OpFunctionCall %v2float %tint_atanh %16 %27 = OpFunctionCall %v2float %tint_atanh %29
OpStore %res %27 OpStore %res %27
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%vertex_main_inner = OpFunction %v4float None %30 %vertex_main_inner = OpFunction %v4float None %32
%32 = OpLabel %34 = OpLabel
%33 = OpFunctionCall %void %atanh_c0e634 %35 = OpFunctionCall %void %atanh_c0e634
OpReturnValue %5 OpReturnValue %5
OpFunctionEnd OpFunctionEnd
%vertex_main = OpFunction %void None %23 %vertex_main = OpFunction %void None %23
%35 = OpLabel %37 = OpLabel
%36 = OpFunctionCall %v4float %vertex_main_inner %38 = OpFunctionCall %v4float %vertex_main_inner
OpStore %value %36 OpStore %value %38
OpStore %vertex_point_size %float_1 OpStore %vertex_point_size %float_1
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%fragment_main = OpFunction %void None %23 %fragment_main = OpFunction %void None %23
%38 = OpLabel %40 = OpLabel
%39 = OpFunctionCall %void %atanh_c0e634 %41 = OpFunctionCall %void %atanh_c0e634
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%compute_main = OpFunction %void None %23 %compute_main = OpFunction %void None %23
%41 = OpLabel %43 = OpLabel
%42 = OpFunctionCall %void %atanh_c0e634 %44 = OpFunctionCall %void %atanh_c0e634
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd

View File

@ -1,5 +1,5 @@
fn atanh_c0e634() { fn atanh_c0e634() {
var res : vec2<f32> = atanh(vec2<f32>(1.0f)); var res : vec2<f32> = atanh(vec2<f32>(0.5f));
} }
@vertex @vertex

View File

@ -23,7 +23,7 @@
// fn atanh(vec<4, f32>) -> vec<4, f32> // fn atanh(vec<4, f32>) -> vec<4, f32>
fn atanh_f3e01b() { fn atanh_f3e01b() {
var res: vec4<f32> = atanh(vec4<f32>(1.f)); var res: vec4<f32> = atanh(vec4<f32>(0.5f));
} }
@vertex @vertex

View File

@ -3,7 +3,7 @@ float4 tint_atanh(float4 x) {
} }
void atanh_f3e01b() { void atanh_f3e01b() {
float4 res = tint_atanh((1.0f).xxxx); float4 res = tint_atanh((0.5f).xxxx);
} }
struct tint_symbol { struct tint_symbol {

View File

@ -3,7 +3,7 @@ float4 tint_atanh(float4 x) {
} }
void atanh_f3e01b() { void atanh_f3e01b() {
float4 res = tint_atanh((1.0f).xxxx); float4 res = tint_atanh((0.5f).xxxx);
} }
struct tint_symbol { struct tint_symbol {

View File

@ -5,7 +5,7 @@ vec4 tint_atanh(vec4 x) {
} }
void atanh_f3e01b() { void atanh_f3e01b() {
vec4 res = tint_atanh(vec4(1.0f)); vec4 res = tint_atanh(vec4(0.5f));
} }
vec4 vertex_main() { vec4 vertex_main() {
@ -29,7 +29,7 @@ vec4 tint_atanh(vec4 x) {
} }
void atanh_f3e01b() { void atanh_f3e01b() {
vec4 res = tint_atanh(vec4(1.0f)); vec4 res = tint_atanh(vec4(0.5f));
} }
void fragment_main() { void fragment_main() {
@ -47,7 +47,7 @@ vec4 tint_atanh(vec4 x) {
} }
void atanh_f3e01b() { void atanh_f3e01b() {
vec4 res = tint_atanh(vec4(1.0f)); vec4 res = tint_atanh(vec4(0.5f));
} }
void compute_main() { void compute_main() {

View File

@ -6,7 +6,7 @@ float4 tint_atanh(float4 x) {
} }
void atanh_f3e01b() { void atanh_f3e01b() {
float4 res = tint_atanh(float4(1.0f)); float4 res = tint_atanh(float4(0.5f));
} }
struct tint_symbol { struct tint_symbol {

View File

@ -1,7 +1,7 @@
; SPIR-V ; SPIR-V
; Version: 1.3 ; Version: 1.3
; Generator: Google Tint Compiler; 0 ; Generator: Google Tint Compiler; 0
; Bound: 41 ; Bound: 43
; Schema: 0 ; Schema: 0
OpCapability Shader OpCapability Shader
%20 = OpExtInstImport "GLSL.std.450" %20 = OpExtInstImport "GLSL.std.450"
@ -38,8 +38,10 @@
%v4bool = OpTypeVector %bool 4 %v4bool = OpTypeVector %bool 4
%void = OpTypeVoid %void = OpTypeVoid
%21 = OpTypeFunction %void %21 = OpTypeFunction %void
%float_0_5 = OpConstant %float 0.5
%27 = OpConstantComposite %v4float %float_0_5 %float_0_5 %float_0_5 %float_0_5
%_ptr_Function_v4float = OpTypePointer Function %v4float %_ptr_Function_v4float = OpTypePointer Function %v4float
%28 = OpTypeFunction %v4float %30 = OpTypeFunction %v4float
%tint_atanh = OpFunction %v4float None %9 %tint_atanh = OpFunction %v4float None %9
%x = OpFunctionParameter %v4float %x = OpFunctionParameter %v4float
%12 = OpLabel %12 = OpLabel
@ -51,29 +53,29 @@
%atanh_f3e01b = OpFunction %void None %21 %atanh_f3e01b = OpFunction %void None %21
%24 = OpLabel %24 = OpLabel
%res = OpVariable %_ptr_Function_v4float Function %5 %res = OpVariable %_ptr_Function_v4float Function %5
%25 = OpFunctionCall %v4float %tint_atanh %15 %25 = OpFunctionCall %v4float %tint_atanh %27
OpStore %res %25 OpStore %res %25
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%vertex_main_inner = OpFunction %v4float None %28 %vertex_main_inner = OpFunction %v4float None %30
%30 = OpLabel %32 = OpLabel
%31 = OpFunctionCall %void %atanh_f3e01b %33 = OpFunctionCall %void %atanh_f3e01b
OpReturnValue %5 OpReturnValue %5
OpFunctionEnd OpFunctionEnd
%vertex_main = OpFunction %void None %21 %vertex_main = OpFunction %void None %21
%33 = OpLabel %35 = OpLabel
%34 = OpFunctionCall %v4float %vertex_main_inner %36 = OpFunctionCall %v4float %vertex_main_inner
OpStore %value %34 OpStore %value %36
OpStore %vertex_point_size %float_1 OpStore %vertex_point_size %float_1
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%fragment_main = OpFunction %void None %21 %fragment_main = OpFunction %void None %21
%36 = OpLabel %38 = OpLabel
%37 = OpFunctionCall %void %atanh_f3e01b %39 = OpFunctionCall %void %atanh_f3e01b
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%compute_main = OpFunction %void None %21 %compute_main = OpFunction %void None %21
%39 = OpLabel %41 = OpLabel
%40 = OpFunctionCall %void %atanh_f3e01b %42 = OpFunctionCall %void %atanh_f3e01b
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd

View File

@ -1,5 +1,5 @@
fn atanh_f3e01b() { fn atanh_f3e01b() {
var res : vec4<f32> = atanh(vec4<f32>(1.0f)); var res : vec4<f32> = atanh(vec4<f32>(0.5f));
} }
@vertex @vertex

View File

@ -23,7 +23,7 @@
// fn atanh(vec<3, f32>) -> vec<3, f32> // fn atanh(vec<3, f32>) -> vec<3, f32>
fn atanh_440cca() { fn atanh_440cca() {
var arg_0 = vec3<f32>(1.f); var arg_0 = vec3<f32>(0.5f);
var res: vec3<f32> = atanh(arg_0); var res: vec3<f32> = atanh(arg_0);
} }

View File

@ -3,7 +3,7 @@ float3 tint_atanh(float3 x) {
} }
void atanh_440cca() { void atanh_440cca() {
float3 arg_0 = (1.0f).xxx; float3 arg_0 = (0.5f).xxx;
float3 res = tint_atanh(arg_0); float3 res = tint_atanh(arg_0);
} }

View File

@ -3,7 +3,7 @@ float3 tint_atanh(float3 x) {
} }
void atanh_440cca() { void atanh_440cca() {
float3 arg_0 = (1.0f).xxx; float3 arg_0 = (0.5f).xxx;
float3 res = tint_atanh(arg_0); float3 res = tint_atanh(arg_0);
} }

View File

@ -5,7 +5,7 @@ vec3 tint_atanh(vec3 x) {
} }
void atanh_440cca() { void atanh_440cca() {
vec3 arg_0 = vec3(1.0f); vec3 arg_0 = vec3(0.5f);
vec3 res = tint_atanh(arg_0); vec3 res = tint_atanh(arg_0);
} }
@ -30,7 +30,7 @@ vec3 tint_atanh(vec3 x) {
} }
void atanh_440cca() { void atanh_440cca() {
vec3 arg_0 = vec3(1.0f); vec3 arg_0 = vec3(0.5f);
vec3 res = tint_atanh(arg_0); vec3 res = tint_atanh(arg_0);
} }
@ -49,7 +49,7 @@ vec3 tint_atanh(vec3 x) {
} }
void atanh_440cca() { void atanh_440cca() {
vec3 arg_0 = vec3(1.0f); vec3 arg_0 = vec3(0.5f);
vec3 res = tint_atanh(arg_0); vec3 res = tint_atanh(arg_0);
} }

View File

@ -6,7 +6,7 @@ float3 tint_atanh(float3 x) {
} }
void atanh_440cca() { void atanh_440cca() {
float3 arg_0 = float3(1.0f); float3 arg_0 = float3(0.5f);
float3 res = tint_atanh(arg_0); float3 res = tint_atanh(arg_0);
} }

View File

@ -1,7 +1,7 @@
; SPIR-V ; SPIR-V
; Version: 1.3 ; Version: 1.3
; Generator: Google Tint Compiler; 0 ; Generator: Google Tint Compiler; 0
; Bound: 45 ; Bound: 47
; Schema: 0 ; Schema: 0
OpCapability Shader OpCapability Shader
%22 = OpExtInstImport "GLSL.std.450" %22 = OpExtInstImport "GLSL.std.450"
@ -41,8 +41,10 @@
%20 = OpConstantNull %v3float %20 = OpConstantNull %v3float
%void = OpTypeVoid %void = OpTypeVoid
%23 = OpTypeFunction %void %23 = OpTypeFunction %void
%float_0_5 = OpConstant %float 0.5
%28 = OpConstantComposite %v3float %float_0_5 %float_0_5 %float_0_5
%_ptr_Function_v3float = OpTypePointer Function %v3float %_ptr_Function_v3float = OpTypePointer Function %v3float
%32 = OpTypeFunction %v4float %34 = OpTypeFunction %v4float
%tint_atanh = OpFunction %v3float None %9 %tint_atanh = OpFunction %v3float None %9
%x = OpFunctionParameter %v3float %x = OpFunctionParameter %v3float
%13 = OpLabel %13 = OpLabel
@ -55,31 +57,31 @@
%26 = OpLabel %26 = OpLabel
%arg_0 = OpVariable %_ptr_Function_v3float Function %20 %arg_0 = OpVariable %_ptr_Function_v3float Function %20
%res = OpVariable %_ptr_Function_v3float Function %20 %res = OpVariable %_ptr_Function_v3float Function %20
OpStore %arg_0 %16 OpStore %arg_0 %28
%30 = OpLoad %v3float %arg_0 %32 = OpLoad %v3float %arg_0
%29 = OpFunctionCall %v3float %tint_atanh %30 %31 = OpFunctionCall %v3float %tint_atanh %32
OpStore %res %29 OpStore %res %31
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%vertex_main_inner = OpFunction %v4float None %32 %vertex_main_inner = OpFunction %v4float None %34
%34 = OpLabel %36 = OpLabel
%35 = OpFunctionCall %void %atanh_440cca %37 = OpFunctionCall %void %atanh_440cca
OpReturnValue %5 OpReturnValue %5
OpFunctionEnd OpFunctionEnd
%vertex_main = OpFunction %void None %23 %vertex_main = OpFunction %void None %23
%37 = OpLabel %39 = OpLabel
%38 = OpFunctionCall %v4float %vertex_main_inner %40 = OpFunctionCall %v4float %vertex_main_inner
OpStore %value %38 OpStore %value %40
OpStore %vertex_point_size %float_1 OpStore %vertex_point_size %float_1
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%fragment_main = OpFunction %void None %23 %fragment_main = OpFunction %void None %23
%40 = OpLabel %42 = OpLabel
%41 = OpFunctionCall %void %atanh_440cca %43 = OpFunctionCall %void %atanh_440cca
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%compute_main = OpFunction %void None %23 %compute_main = OpFunction %void None %23
%43 = OpLabel %45 = OpLabel
%44 = OpFunctionCall %void %atanh_440cca %46 = OpFunctionCall %void %atanh_440cca
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd

View File

@ -1,5 +1,5 @@
fn atanh_440cca() { fn atanh_440cca() {
var arg_0 = vec3<f32>(1.0f); var arg_0 = vec3<f32>(0.5f);
var res : vec3<f32> = atanh(arg_0); var res : vec3<f32> = atanh(arg_0);
} }

View File

@ -23,7 +23,7 @@
// fn atanh(f32) -> f32 // fn atanh(f32) -> f32
fn atanh_7997d8() { fn atanh_7997d8() {
var arg_0 = 1.f; var arg_0 = 0.5f;
var res: f32 = atanh(arg_0); var res: f32 = atanh(arg_0);
} }

View File

@ -3,7 +3,7 @@ float tint_atanh(float x) {
} }
void atanh_7997d8() { void atanh_7997d8() {
float arg_0 = 1.0f; float arg_0 = 0.5f;
float res = tint_atanh(arg_0); float res = tint_atanh(arg_0);
} }

View File

@ -3,7 +3,7 @@ float tint_atanh(float x) {
} }
void atanh_7997d8() { void atanh_7997d8() {
float arg_0 = 1.0f; float arg_0 = 0.5f;
float res = tint_atanh(arg_0); float res = tint_atanh(arg_0);
} }

View File

@ -5,7 +5,7 @@ float tint_atanh(float x) {
} }
void atanh_7997d8() { void atanh_7997d8() {
float arg_0 = 1.0f; float arg_0 = 0.5f;
float res = tint_atanh(arg_0); float res = tint_atanh(arg_0);
} }
@ -30,7 +30,7 @@ float tint_atanh(float x) {
} }
void atanh_7997d8() { void atanh_7997d8() {
float arg_0 = 1.0f; float arg_0 = 0.5f;
float res = tint_atanh(arg_0); float res = tint_atanh(arg_0);
} }
@ -49,7 +49,7 @@ float tint_atanh(float x) {
} }
void atanh_7997d8() { void atanh_7997d8() {
float arg_0 = 1.0f; float arg_0 = 0.5f;
float res = tint_atanh(arg_0); float res = tint_atanh(arg_0);
} }

View File

@ -6,7 +6,7 @@ float tint_atanh(float x) {
} }
void atanh_7997d8() { void atanh_7997d8() {
float arg_0 = 1.0f; float arg_0 = 0.5f;
float res = tint_atanh(arg_0); float res = tint_atanh(arg_0);
} }

View File

@ -1,7 +1,7 @@
; SPIR-V ; SPIR-V
; Version: 1.3 ; Version: 1.3
; Generator: Google Tint Compiler; 0 ; Generator: Google Tint Compiler; 0
; Bound: 41 ; Bound: 42
; Schema: 0 ; Schema: 0
OpCapability Shader OpCapability Shader
%18 = OpExtInstImport "GLSL.std.450" %18 = OpExtInstImport "GLSL.std.450"
@ -37,8 +37,9 @@
%bool = OpTypeBool %bool = OpTypeBool
%void = OpTypeVoid %void = OpTypeVoid
%19 = OpTypeFunction %void %19 = OpTypeFunction %void
%float_0_5 = OpConstant %float 0.5
%_ptr_Function_float = OpTypePointer Function %float %_ptr_Function_float = OpTypePointer Function %float
%28 = OpTypeFunction %v4float %29 = OpTypeFunction %v4float
%tint_atanh = OpFunction %float None %9 %tint_atanh = OpFunction %float None %9
%x = OpFunctionParameter %float %x = OpFunctionParameter %float
%12 = OpLabel %12 = OpLabel
@ -51,31 +52,31 @@
%22 = OpLabel %22 = OpLabel
%arg_0 = OpVariable %_ptr_Function_float Function %8 %arg_0 = OpVariable %_ptr_Function_float Function %8
%res = OpVariable %_ptr_Function_float Function %8 %res = OpVariable %_ptr_Function_float Function %8
OpStore %arg_0 %float_1 OpStore %arg_0 %float_0_5
%26 = OpLoad %float %arg_0 %27 = OpLoad %float %arg_0
%25 = OpFunctionCall %float %tint_atanh %26 %26 = OpFunctionCall %float %tint_atanh %27
OpStore %res %25 OpStore %res %26
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%vertex_main_inner = OpFunction %v4float None %28 %vertex_main_inner = OpFunction %v4float None %29
%30 = OpLabel %31 = OpLabel
%31 = OpFunctionCall %void %atanh_7997d8 %32 = OpFunctionCall %void %atanh_7997d8
OpReturnValue %5 OpReturnValue %5
OpFunctionEnd OpFunctionEnd
%vertex_main = OpFunction %void None %19 %vertex_main = OpFunction %void None %19
%33 = OpLabel %34 = OpLabel
%34 = OpFunctionCall %v4float %vertex_main_inner %35 = OpFunctionCall %v4float %vertex_main_inner
OpStore %value %34 OpStore %value %35
OpStore %vertex_point_size %float_1 OpStore %vertex_point_size %float_1
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%fragment_main = OpFunction %void None %19 %fragment_main = OpFunction %void None %19
%36 = OpLabel %37 = OpLabel
%37 = OpFunctionCall %void %atanh_7997d8 %38 = OpFunctionCall %void %atanh_7997d8
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%compute_main = OpFunction %void None %19 %compute_main = OpFunction %void None %19
%39 = OpLabel %40 = OpLabel
%40 = OpFunctionCall %void %atanh_7997d8 %41 = OpFunctionCall %void %atanh_7997d8
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd

View File

@ -1,5 +1,5 @@
fn atanh_7997d8() { fn atanh_7997d8() {
var arg_0 = 1.0f; var arg_0 = 0.5f;
var res : f32 = atanh(arg_0); var res : f32 = atanh(arg_0);
} }

View File

@ -23,7 +23,7 @@
// fn atanh(vec<2, f32>) -> vec<2, f32> // fn atanh(vec<2, f32>) -> vec<2, f32>
fn atanh_c0e634() { fn atanh_c0e634() {
var arg_0 = vec2<f32>(1.f); var arg_0 = vec2<f32>(0.5f);
var res: vec2<f32> = atanh(arg_0); var res: vec2<f32> = atanh(arg_0);
} }

View File

@ -3,7 +3,7 @@ float2 tint_atanh(float2 x) {
} }
void atanh_c0e634() { void atanh_c0e634() {
float2 arg_0 = (1.0f).xx; float2 arg_0 = (0.5f).xx;
float2 res = tint_atanh(arg_0); float2 res = tint_atanh(arg_0);
} }

View File

@ -3,7 +3,7 @@ float2 tint_atanh(float2 x) {
} }
void atanh_c0e634() { void atanh_c0e634() {
float2 arg_0 = (1.0f).xx; float2 arg_0 = (0.5f).xx;
float2 res = tint_atanh(arg_0); float2 res = tint_atanh(arg_0);
} }

View File

@ -5,7 +5,7 @@ vec2 tint_atanh(vec2 x) {
} }
void atanh_c0e634() { void atanh_c0e634() {
vec2 arg_0 = vec2(1.0f); vec2 arg_0 = vec2(0.5f);
vec2 res = tint_atanh(arg_0); vec2 res = tint_atanh(arg_0);
} }
@ -30,7 +30,7 @@ vec2 tint_atanh(vec2 x) {
} }
void atanh_c0e634() { void atanh_c0e634() {
vec2 arg_0 = vec2(1.0f); vec2 arg_0 = vec2(0.5f);
vec2 res = tint_atanh(arg_0); vec2 res = tint_atanh(arg_0);
} }
@ -49,7 +49,7 @@ vec2 tint_atanh(vec2 x) {
} }
void atanh_c0e634() { void atanh_c0e634() {
vec2 arg_0 = vec2(1.0f); vec2 arg_0 = vec2(0.5f);
vec2 res = tint_atanh(arg_0); vec2 res = tint_atanh(arg_0);
} }

View File

@ -6,7 +6,7 @@ float2 tint_atanh(float2 x) {
} }
void atanh_c0e634() { void atanh_c0e634() {
float2 arg_0 = float2(1.0f); float2 arg_0 = float2(0.5f);
float2 res = tint_atanh(arg_0); float2 res = tint_atanh(arg_0);
} }

View File

@ -1,7 +1,7 @@
; SPIR-V ; SPIR-V
; Version: 1.3 ; Version: 1.3
; Generator: Google Tint Compiler; 0 ; Generator: Google Tint Compiler; 0
; Bound: 45 ; Bound: 47
; Schema: 0 ; Schema: 0
OpCapability Shader OpCapability Shader
%22 = OpExtInstImport "GLSL.std.450" %22 = OpExtInstImport "GLSL.std.450"
@ -41,8 +41,10 @@
%20 = OpConstantNull %v2float %20 = OpConstantNull %v2float
%void = OpTypeVoid %void = OpTypeVoid
%23 = OpTypeFunction %void %23 = OpTypeFunction %void
%float_0_5 = OpConstant %float 0.5
%28 = OpConstantComposite %v2float %float_0_5 %float_0_5
%_ptr_Function_v2float = OpTypePointer Function %v2float %_ptr_Function_v2float = OpTypePointer Function %v2float
%32 = OpTypeFunction %v4float %34 = OpTypeFunction %v4float
%tint_atanh = OpFunction %v2float None %9 %tint_atanh = OpFunction %v2float None %9
%x = OpFunctionParameter %v2float %x = OpFunctionParameter %v2float
%13 = OpLabel %13 = OpLabel
@ -55,31 +57,31 @@
%26 = OpLabel %26 = OpLabel
%arg_0 = OpVariable %_ptr_Function_v2float Function %20 %arg_0 = OpVariable %_ptr_Function_v2float Function %20
%res = OpVariable %_ptr_Function_v2float Function %20 %res = OpVariable %_ptr_Function_v2float Function %20
OpStore %arg_0 %16 OpStore %arg_0 %28
%30 = OpLoad %v2float %arg_0 %32 = OpLoad %v2float %arg_0
%29 = OpFunctionCall %v2float %tint_atanh %30 %31 = OpFunctionCall %v2float %tint_atanh %32
OpStore %res %29 OpStore %res %31
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%vertex_main_inner = OpFunction %v4float None %32 %vertex_main_inner = OpFunction %v4float None %34
%34 = OpLabel %36 = OpLabel
%35 = OpFunctionCall %void %atanh_c0e634 %37 = OpFunctionCall %void %atanh_c0e634
OpReturnValue %5 OpReturnValue %5
OpFunctionEnd OpFunctionEnd
%vertex_main = OpFunction %void None %23 %vertex_main = OpFunction %void None %23
%37 = OpLabel %39 = OpLabel
%38 = OpFunctionCall %v4float %vertex_main_inner %40 = OpFunctionCall %v4float %vertex_main_inner
OpStore %value %38 OpStore %value %40
OpStore %vertex_point_size %float_1 OpStore %vertex_point_size %float_1
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%fragment_main = OpFunction %void None %23 %fragment_main = OpFunction %void None %23
%40 = OpLabel %42 = OpLabel
%41 = OpFunctionCall %void %atanh_c0e634 %43 = OpFunctionCall %void %atanh_c0e634
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%compute_main = OpFunction %void None %23 %compute_main = OpFunction %void None %23
%43 = OpLabel %45 = OpLabel
%44 = OpFunctionCall %void %atanh_c0e634 %46 = OpFunctionCall %void %atanh_c0e634
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd

View File

@ -1,5 +1,5 @@
fn atanh_c0e634() { fn atanh_c0e634() {
var arg_0 = vec2<f32>(1.0f); var arg_0 = vec2<f32>(0.5f);
var res : vec2<f32> = atanh(arg_0); var res : vec2<f32> = atanh(arg_0);
} }

View File

@ -23,7 +23,7 @@
// fn atanh(vec<4, f32>) -> vec<4, f32> // fn atanh(vec<4, f32>) -> vec<4, f32>
fn atanh_f3e01b() { fn atanh_f3e01b() {
var arg_0 = vec4<f32>(1.f); var arg_0 = vec4<f32>(0.5f);
var res: vec4<f32> = atanh(arg_0); var res: vec4<f32> = atanh(arg_0);
} }

View File

@ -3,7 +3,7 @@ float4 tint_atanh(float4 x) {
} }
void atanh_f3e01b() { void atanh_f3e01b() {
float4 arg_0 = (1.0f).xxxx; float4 arg_0 = (0.5f).xxxx;
float4 res = tint_atanh(arg_0); float4 res = tint_atanh(arg_0);
} }

View File

@ -3,7 +3,7 @@ float4 tint_atanh(float4 x) {
} }
void atanh_f3e01b() { void atanh_f3e01b() {
float4 arg_0 = (1.0f).xxxx; float4 arg_0 = (0.5f).xxxx;
float4 res = tint_atanh(arg_0); float4 res = tint_atanh(arg_0);
} }

View File

@ -5,7 +5,7 @@ vec4 tint_atanh(vec4 x) {
} }
void atanh_f3e01b() { void atanh_f3e01b() {
vec4 arg_0 = vec4(1.0f); vec4 arg_0 = vec4(0.5f);
vec4 res = tint_atanh(arg_0); vec4 res = tint_atanh(arg_0);
} }
@ -30,7 +30,7 @@ vec4 tint_atanh(vec4 x) {
} }
void atanh_f3e01b() { void atanh_f3e01b() {
vec4 arg_0 = vec4(1.0f); vec4 arg_0 = vec4(0.5f);
vec4 res = tint_atanh(arg_0); vec4 res = tint_atanh(arg_0);
} }
@ -49,7 +49,7 @@ vec4 tint_atanh(vec4 x) {
} }
void atanh_f3e01b() { void atanh_f3e01b() {
vec4 arg_0 = vec4(1.0f); vec4 arg_0 = vec4(0.5f);
vec4 res = tint_atanh(arg_0); vec4 res = tint_atanh(arg_0);
} }

View File

@ -6,7 +6,7 @@ float4 tint_atanh(float4 x) {
} }
void atanh_f3e01b() { void atanh_f3e01b() {
float4 arg_0 = float4(1.0f); float4 arg_0 = float4(0.5f);
float4 res = tint_atanh(arg_0); float4 res = tint_atanh(arg_0);
} }

View File

@ -1,7 +1,7 @@
; SPIR-V ; SPIR-V
; Version: 1.3 ; Version: 1.3
; Generator: Google Tint Compiler; 0 ; Generator: Google Tint Compiler; 0
; Bound: 43 ; Bound: 45
; Schema: 0 ; Schema: 0
OpCapability Shader OpCapability Shader
%20 = OpExtInstImport "GLSL.std.450" %20 = OpExtInstImport "GLSL.std.450"
@ -39,8 +39,10 @@
%v4bool = OpTypeVector %bool 4 %v4bool = OpTypeVector %bool 4
%void = OpTypeVoid %void = OpTypeVoid
%21 = OpTypeFunction %void %21 = OpTypeFunction %void
%float_0_5 = OpConstant %float 0.5
%26 = OpConstantComposite %v4float %float_0_5 %float_0_5 %float_0_5 %float_0_5
%_ptr_Function_v4float = OpTypePointer Function %v4float %_ptr_Function_v4float = OpTypePointer Function %v4float
%30 = OpTypeFunction %v4float %32 = OpTypeFunction %v4float
%tint_atanh = OpFunction %v4float None %9 %tint_atanh = OpFunction %v4float None %9
%x = OpFunctionParameter %v4float %x = OpFunctionParameter %v4float
%12 = OpLabel %12 = OpLabel
@ -53,31 +55,31 @@
%24 = OpLabel %24 = OpLabel
%arg_0 = OpVariable %_ptr_Function_v4float Function %5 %arg_0 = OpVariable %_ptr_Function_v4float Function %5
%res = OpVariable %_ptr_Function_v4float Function %5 %res = OpVariable %_ptr_Function_v4float Function %5
OpStore %arg_0 %15 OpStore %arg_0 %26
%28 = OpLoad %v4float %arg_0 %30 = OpLoad %v4float %arg_0
%27 = OpFunctionCall %v4float %tint_atanh %28 %29 = OpFunctionCall %v4float %tint_atanh %30
OpStore %res %27 OpStore %res %29
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%vertex_main_inner = OpFunction %v4float None %30 %vertex_main_inner = OpFunction %v4float None %32
%32 = OpLabel %34 = OpLabel
%33 = OpFunctionCall %void %atanh_f3e01b %35 = OpFunctionCall %void %atanh_f3e01b
OpReturnValue %5 OpReturnValue %5
OpFunctionEnd OpFunctionEnd
%vertex_main = OpFunction %void None %21 %vertex_main = OpFunction %void None %21
%35 = OpLabel %37 = OpLabel
%36 = OpFunctionCall %v4float %vertex_main_inner %38 = OpFunctionCall %v4float %vertex_main_inner
OpStore %value %36 OpStore %value %38
OpStore %vertex_point_size %float_1 OpStore %vertex_point_size %float_1
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%fragment_main = OpFunction %void None %21 %fragment_main = OpFunction %void None %21
%38 = OpLabel %40 = OpLabel
%39 = OpFunctionCall %void %atanh_f3e01b %41 = OpFunctionCall %void %atanh_f3e01b
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%compute_main = OpFunction %void None %21 %compute_main = OpFunction %void None %21
%41 = OpLabel %43 = OpLabel
%42 = OpFunctionCall %void %atanh_f3e01b %44 = OpFunctionCall %void %atanh_f3e01b
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd

View File

@ -1,5 +1,5 @@
fn atanh_f3e01b() { fn atanh_f3e01b() {
var arg_0 = vec4<f32>(1.0f); var arg_0 = vec4<f32>(0.5f);
var res : vec4<f32> = atanh(arg_0); var res : vec4<f32> = atanh(arg_0);
} }

View File

@ -303,6 +303,7 @@ func (g *generator) bindAndParse(t *template.Template, text string) error {
"Title": strings.Title, "Title": strings.Title,
"PascalCase": pascalCase, "PascalCase": pascalCase,
"SplitDisplayName": gen.SplitDisplayName, "SplitDisplayName": gen.SplitDisplayName,
"Contains": strings.Contains,
"HasPrefix": strings.HasPrefix, "HasPrefix": strings.HasPrefix,
"HasSuffix": strings.HasSuffix, "HasSuffix": strings.HasSuffix,
"TrimPrefix": strings.TrimPrefix, "TrimPrefix": strings.TrimPrefix,

View File

@ -367,7 +367,7 @@ func (l *Attributes) Take(name string) *Attribute {
type Attribute struct { type Attribute struct {
Source tok.Source Source tok.Source
Name string Name string
Values []string Values []any
} }
// Format implements the fmt.Formatter interface // Format implements the fmt.Formatter interface

View File

@ -83,9 +83,10 @@ func (p *Permuter) Permute(overload *sem.Overload) ([]Permutation, error) {
return nil return nil
} }
o.Parameters = append(o.Parameters, sem.Parameter{ o.Parameters = append(o.Parameters, sem.Parameter{
Name: p.Name, Name: p.Name,
Type: ty, Type: ty,
IsConst: p.IsConst, IsConst: p.IsConst,
TestValue: p.TestValue,
}) })
} }
if overload.ReturnType != nil { if overload.ReturnType != nil {

View File

@ -104,7 +104,23 @@ func (l *lexer) lex() error {
case unicode.IsLetter(l.peek(0)) || l.peek(0) == '_': case unicode.IsLetter(l.peek(0)) || l.peek(0) == '_':
l.tok(l.count(alphaNumericOrUnderscore), tok.Identifier) l.tok(l.count(alphaNumericOrUnderscore), tok.Identifier)
case unicode.IsNumber(l.peek(0)): case unicode.IsNumber(l.peek(0)):
l.tok(l.count(unicode.IsNumber), tok.Integer) isFloat := false
pred := func(r rune) bool {
if unicode.IsNumber(r) {
return true
}
if !isFloat && r == '.' {
isFloat = true
return true
}
return false
}
n := l.count(pred)
if isFloat {
l.tok(n, tok.Float)
} else {
l.tok(n, tok.Integer)
}
case l.match("&&", tok.AndAnd): case l.match("&&", tok.AndAnd):
case l.match("&", tok.And): case l.match("&", tok.And):
case l.match("||", tok.OrOr): case l.match("||", tok.OrOr):

View File

@ -20,12 +20,13 @@ import (
"dawn.googlesource.com/dawn/tools/src/tint/intrinsic/lexer" "dawn.googlesource.com/dawn/tools/src/tint/intrinsic/lexer"
"dawn.googlesource.com/dawn/tools/src/tint/intrinsic/tok" "dawn.googlesource.com/dawn/tools/src/tint/intrinsic/tok"
"github.com/google/go-cmp/cmp"
) )
func TestLexTokens(t *testing.T) { func TestLexTokens(t *testing.T) {
type test struct { type test struct {
src string src string
expect tok.Token expect []tok.Token
} }
filepath := "test.txt" filepath := "test.txt"
@ -34,144 +35,153 @@ func TestLexTokens(t *testing.T) {
} }
for _, test := range []test{ for _, test := range []test{
{"ident", tok.Token{Kind: tok.Identifier, Runes: []rune("ident"), Source: tok.Source{ {"ident", []tok.Token{{Kind: tok.Identifier, Runes: []rune("ident"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 6, 5), S: loc(1, 1, 0), E: loc(1, 6, 5),
}}}, }}}},
{"ident_123", tok.Token{Kind: tok.Identifier, Runes: []rune("ident_123"), Source: tok.Source{ {"ident_123", []tok.Token{{Kind: tok.Identifier, Runes: []rune("ident_123"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 10, 9), S: loc(1, 1, 0), E: loc(1, 10, 9),
}}}, }}}},
{"_ident_", tok.Token{Kind: tok.Identifier, Runes: []rune("_ident_"), Source: tok.Source{ {"_ident_", []tok.Token{{Kind: tok.Identifier, Runes: []rune("_ident_"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 8, 7), S: loc(1, 1, 0), E: loc(1, 8, 7),
}}}, }}}},
{"123456789", tok.Token{Kind: tok.Integer, Runes: []rune("123456789"), Source: tok.Source{ {"123456789", []tok.Token{{Kind: tok.Integer, Runes: []rune("123456789"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 10, 9), S: loc(1, 1, 0), E: loc(1, 10, 9),
}}}, }}}},
{"match", tok.Token{Kind: tok.Match, Runes: []rune("match"), Source: tok.Source{ {"1234.56789", []tok.Token{{Kind: tok.Float, Runes: []rune("1234.56789"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 11, 10),
}}}},
{"123.456.789", []tok.Token{
{Kind: tok.Float, Runes: []rune("123.456"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 8, 7),
}},
{Kind: tok.Dot, Runes: []rune("."), Source: tok.Source{
S: loc(1, 8, 7), E: loc(1, 9, 8),
}},
{Kind: tok.Integer, Runes: []rune("789"), Source: tok.Source{
S: loc(1, 9, 8), E: loc(1, 12, 11),
}},
}},
{"match", []tok.Token{{Kind: tok.Match, Runes: []rune("match"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 6, 5), S: loc(1, 1, 0), E: loc(1, 6, 5),
}}}, }}}},
{"fn", tok.Token{Kind: tok.Function, Runes: []rune("fn"), Source: tok.Source{ {"fn", []tok.Token{{Kind: tok.Function, Runes: []rune("fn"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 3, 2), S: loc(1, 1, 0), E: loc(1, 3, 2),
}}}, }}}},
{"op", tok.Token{Kind: tok.Operator, Runes: []rune("op"), Source: tok.Source{ {"op", []tok.Token{{Kind: tok.Operator, Runes: []rune("op"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 3, 2), S: loc(1, 1, 0), E: loc(1, 3, 2),
}}}, }}}},
{"type", tok.Token{Kind: tok.Type, Runes: []rune("type"), Source: tok.Source{ {"type", []tok.Token{{Kind: tok.Type, Runes: []rune("type"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 5, 4), S: loc(1, 1, 0), E: loc(1, 5, 4),
}}}, }}}},
{"init", tok.Token{Kind: tok.Initializer, Runes: []rune("init"), Source: tok.Source{ {"init", []tok.Token{{Kind: tok.Initializer, Runes: []rune("init"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 5, 4), S: loc(1, 1, 0), E: loc(1, 5, 4),
}}}, }}}},
{"conv", tok.Token{Kind: tok.Converter, Runes: []rune("conv"), Source: tok.Source{ {"conv", []tok.Token{{Kind: tok.Converter, Runes: []rune("conv"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 5, 4), S: loc(1, 1, 0), E: loc(1, 5, 4),
}}}, }}}},
{"enum", tok.Token{Kind: tok.Enum, Runes: []rune("enum"), Source: tok.Source{ {"enum", []tok.Token{{Kind: tok.Enum, Runes: []rune("enum"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 5, 4), S: loc(1, 1, 0), E: loc(1, 5, 4),
}}}, }}}},
{":", tok.Token{Kind: tok.Colon, Runes: []rune(":"), Source: tok.Source{ {":", []tok.Token{{Kind: tok.Colon, Runes: []rune(":"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 2, 1), S: loc(1, 1, 0), E: loc(1, 2, 1),
}}}, }}}},
{",", tok.Token{Kind: tok.Comma, Runes: []rune(","), Source: tok.Source{ {",", []tok.Token{{Kind: tok.Comma, Runes: []rune(","), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 2, 1), S: loc(1, 1, 0), E: loc(1, 2, 1),
}}}, }}}},
{"<", tok.Token{Kind: tok.Lt, Runes: []rune("<"), Source: tok.Source{ {"<", []tok.Token{{Kind: tok.Lt, Runes: []rune("<"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 2, 1), S: loc(1, 1, 0), E: loc(1, 2, 1),
}}}, }}}},
{">", tok.Token{Kind: tok.Gt, Runes: []rune(">"), Source: tok.Source{ {">", []tok.Token{{Kind: tok.Gt, Runes: []rune(">"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 2, 1), S: loc(1, 1, 0), E: loc(1, 2, 1),
}}}, }}}},
{"{", tok.Token{Kind: tok.Lbrace, Runes: []rune("{"), Source: tok.Source{ {"{", []tok.Token{{Kind: tok.Lbrace, Runes: []rune("{"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 2, 1), S: loc(1, 1, 0), E: loc(1, 2, 1),
}}}, }}}},
{"}", tok.Token{Kind: tok.Rbrace, Runes: []rune("}"), Source: tok.Source{ {"}", []tok.Token{{Kind: tok.Rbrace, Runes: []rune("}"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 2, 1), S: loc(1, 1, 0), E: loc(1, 2, 1),
}}}, }}}},
{"&&", tok.Token{Kind: tok.AndAnd, Runes: []rune("&&"), Source: tok.Source{ {"&&", []tok.Token{{Kind: tok.AndAnd, Runes: []rune("&&"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 3, 2), S: loc(1, 1, 0), E: loc(1, 3, 2),
}}}, }}}},
{"&", tok.Token{Kind: tok.And, Runes: []rune("&"), Source: tok.Source{ {"&", []tok.Token{{Kind: tok.And, Runes: []rune("&"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 2, 1), S: loc(1, 1, 0), E: loc(1, 2, 1),
}}}, }}}},
{"||", tok.Token{Kind: tok.OrOr, Runes: []rune("||"), Source: tok.Source{ {"||", []tok.Token{{Kind: tok.OrOr, Runes: []rune("||"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 3, 2), S: loc(1, 1, 0), E: loc(1, 3, 2),
}}}, }}}},
{"|", tok.Token{Kind: tok.Or, Runes: []rune("|"), Source: tok.Source{ {"|", []tok.Token{{Kind: tok.Or, Runes: []rune("|"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 2, 1), S: loc(1, 1, 0), E: loc(1, 2, 1),
}}}, }}}},
{"!", tok.Token{Kind: tok.Not, Runes: []rune("!"), Source: tok.Source{ {"!", []tok.Token{{Kind: tok.Not, Runes: []rune("!"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 2, 1), S: loc(1, 1, 0), E: loc(1, 2, 1),
}}}, }}}},
{"!=", tok.Token{Kind: tok.NotEqual, Runes: []rune("!="), Source: tok.Source{ {"!=", []tok.Token{{Kind: tok.NotEqual, Runes: []rune("!="), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 3, 2), S: loc(1, 1, 0), E: loc(1, 3, 2),
}}}, }}}},
{"==", tok.Token{Kind: tok.Equal, Runes: []rune("=="), Source: tok.Source{ {"==", []tok.Token{{Kind: tok.Equal, Runes: []rune("=="), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 3, 2), S: loc(1, 1, 0), E: loc(1, 3, 2),
}}}, }}}},
{"=", tok.Token{Kind: tok.Assign, Runes: []rune("="), Source: tok.Source{ {"=", []tok.Token{{Kind: tok.Assign, Runes: []rune("="), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 2, 1), S: loc(1, 1, 0), E: loc(1, 2, 1),
}}}, }}}},
{"<<", tok.Token{Kind: tok.Shl, Runes: []rune("<<"), Source: tok.Source{ {"<<", []tok.Token{{Kind: tok.Shl, Runes: []rune("<<"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 3, 2), S: loc(1, 1, 0), E: loc(1, 3, 2),
}}}, }}}},
{"<=", tok.Token{Kind: tok.Le, Runes: []rune("<="), Source: tok.Source{ {"<=", []tok.Token{{Kind: tok.Le, Runes: []rune("<="), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 3, 2), S: loc(1, 1, 0), E: loc(1, 3, 2),
}}}, }}}},
{"<", tok.Token{Kind: tok.Lt, Runes: []rune("<"), Source: tok.Source{ {"<", []tok.Token{{Kind: tok.Lt, Runes: []rune("<"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 2, 1), S: loc(1, 1, 0), E: loc(1, 2, 1),
}}}, }}}},
{">=", tok.Token{Kind: tok.Ge, Runes: []rune(">="), Source: tok.Source{ {">=", []tok.Token{{Kind: tok.Ge, Runes: []rune(">="), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 3, 2), S: loc(1, 1, 0), E: loc(1, 3, 2),
}}}, }}}},
{">>", tok.Token{Kind: tok.Shr, Runes: []rune(">>"), Source: tok.Source{ {">>", []tok.Token{{Kind: tok.Shr, Runes: []rune(">>"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 3, 2), S: loc(1, 1, 0), E: loc(1, 3, 2),
}}}, }}}},
{">", tok.Token{Kind: tok.Gt, Runes: []rune(">"), Source: tok.Source{ {">", []tok.Token{{Kind: tok.Gt, Runes: []rune(">"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 2, 1), S: loc(1, 1, 0), E: loc(1, 2, 1),
}}}, }}}},
{"@", tok.Token{Kind: tok.Attr, Runes: []rune("@"), Source: tok.Source{ {"@", []tok.Token{{Kind: tok.Attr, Runes: []rune("@"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 2, 1), S: loc(1, 1, 0), E: loc(1, 2, 1),
}}}, }}}},
{"(", tok.Token{Kind: tok.Lparen, Runes: []rune("("), Source: tok.Source{ {"(", []tok.Token{{Kind: tok.Lparen, Runes: []rune("("), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 2, 1), S: loc(1, 1, 0), E: loc(1, 2, 1),
}}}, }}}},
{")", tok.Token{Kind: tok.Rparen, Runes: []rune(")"), Source: tok.Source{ {")", []tok.Token{{Kind: tok.Rparen, Runes: []rune(")"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 2, 1), S: loc(1, 1, 0), E: loc(1, 2, 1),
}}}, }}}},
{"|", tok.Token{Kind: tok.Or, Runes: []rune("|"), Source: tok.Source{ {"|", []tok.Token{{Kind: tok.Or, Runes: []rune("|"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 2, 1), S: loc(1, 1, 0), E: loc(1, 2, 1),
}}}, }}}},
{"*", tok.Token{Kind: tok.Star, Runes: []rune("*"), Source: tok.Source{ {"*", []tok.Token{{Kind: tok.Star, Runes: []rune("*"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 2, 1), S: loc(1, 1, 0), E: loc(1, 2, 1),
}}}, }}}},
{"->", tok.Token{Kind: tok.Arrow, Runes: []rune("->"), Source: tok.Source{ {"->", []tok.Token{{Kind: tok.Arrow, Runes: []rune("->"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 3, 2), S: loc(1, 1, 0), E: loc(1, 3, 2),
}}}, }}}},
{"x // y ", tok.Token{Kind: tok.Identifier, Runes: []rune("x"), Source: tok.Source{ {"x // y ", []tok.Token{{Kind: tok.Identifier, Runes: []rune("x"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 2, 1), S: loc(1, 1, 0), E: loc(1, 2, 1),
}}}, }}}},
{`"abc"`, tok.Token{Kind: tok.String, Runes: []rune("abc"), Source: tok.Source{ {`"abc"`, []tok.Token{{Kind: tok.String, Runes: []rune("abc"), Source: tok.Source{
S: loc(1, 2, 1), E: loc(1, 5, 4), S: loc(1, 2, 1), E: loc(1, 5, 4),
}}}, }}}},
{` {`
// //
ident ident
`, tok.Token{Kind: tok.Identifier, Runes: []rune("ident"), Source: tok.Source{ `, []tok.Token{{Kind: tok.Identifier, Runes: []rune("ident"), Source: tok.Source{
S: loc(3, 4, 10), E: loc(3, 9, 15), S: loc(3, 4, 10), E: loc(3, 9, 15),
}}}, }}}},
} { } {
got, err := lexer.Lex([]rune(test.src), filepath) got, err := lexer.Lex([]rune(test.src), filepath)
name := fmt.Sprintf(`Lex("%v")`, test.src) name := fmt.Sprintf(`Lex("%v")`, test.src)
switch { if err != nil {
case err != nil:
t.Errorf("%v returned error: %v", name, err) t.Errorf("%v returned error: %v", name, err)
case len(got) != 1: continue
t.Errorf("%v returned %d tokens: %v", name, len(got), got) }
case got[0].Kind != test.expect.Kind: if diff := cmp.Diff(got, test.expect); diff != "" {
t.Errorf(`%v returned unexpected token kind: got "%+v", expected "%+v"`, name, got[0], test.expect) t.Errorf(`%v: %v`, name, diff)
case string(got[0].Runes) != string(test.expect.Runes):
t.Errorf(`%v returned unexpected token runes: got "%+v", expected "%+v"`, name, string(got[0].Runes), string(test.expect.Runes))
case got[0].Source != test.expect.Source:
t.Errorf(`%v returned unexpected token source: got %+v, expected %+v`, name, got[0].Source, test.expect.Source)
} }
} }
} }

View File

@ -18,6 +18,7 @@ package parser
import ( import (
"fmt" "fmt"
"strconv"
"dawn.googlesource.com/dawn/tools/src/tint/intrinsic/ast" "dawn.googlesource.com/dawn/tools/src/tint/intrinsic/ast"
"dawn.googlesource.com/dawn/tools/src/tint/intrinsic/lexer" "dawn.googlesource.com/dawn/tools/src/tint/intrinsic/lexer"
@ -145,10 +146,26 @@ func (p *parser) attributes() ast.Attributes {
var out ast.Attributes var out ast.Attributes
for p.match(tok.Attr) != nil && p.err == nil { for p.match(tok.Attr) != nil && p.err == nil {
name := p.expect(tok.Identifier, "attribute name") name := p.expect(tok.Identifier, "attribute name")
values := []string{} var values []any
if p.match(tok.Lparen) != nil { if p.match(tok.Lparen) != nil {
loop:
for p.err == nil { for p.err == nil {
values = append(values, string(p.next().Runes)) t := p.next()
switch t.Kind {
case tok.Rparen:
break loop
case tok.String:
values = append(values, string(t.Runes))
case tok.Integer:
i, _ := strconv.ParseInt(string(t.Runes), 10, 64)
values = append(values, int(i))
case tok.Float:
f, _ := strconv.ParseFloat(string(t.Runes), 64)
values = append(values, f)
default:
p.err = fmt.Errorf("%v invalid attribute value kind: %v", t.Source, t.Kind)
return nil
}
if p.match(tok.Comma) == nil { if p.match(tok.Comma) == nil {
break break
} }

View File

@ -52,7 +52,7 @@ func TestParser(t *testing.T) {
{ {
Attributes: ast.Attributes{{ Attributes: ast.Attributes{{
Name: "attr", Name: "attr",
Values: []string{}, Values: nil,
}}, }},
Name: "B", Name: "B",
}, },
@ -85,7 +85,7 @@ func TestParser(t *testing.T) {
ast.AST{ ast.AST{
Types: []ast.TypeDecl{{ Types: []ast.TypeDecl{{
Attributes: ast.Attributes{ Attributes: ast.Attributes{
{Name: "attr", Values: []string{}}, {Name: "attr", Values: nil},
}, },
Name: "T", Name: "T",
}}, }},
@ -96,8 +96,8 @@ func TestParser(t *testing.T) {
ast.AST{ ast.AST{
Types: []ast.TypeDecl{{ Types: []ast.TypeDecl{{
Attributes: ast.Attributes{ Attributes: ast.Attributes{
{Name: "attr_a", Values: []string{}}, {Name: "attr_a", Values: nil},
{Name: "attr_b", Values: []string{}}, {Name: "attr_b", Values: nil},
}, },
Name: "T", Name: "T",
}}, }},
@ -107,17 +107,17 @@ func TestParser(t *testing.T) {
`@attr("a", "b") type T`, ast.AST{ `@attr("a", "b") type T`, ast.AST{
Types: []ast.TypeDecl{{ Types: []ast.TypeDecl{{
Attributes: ast.Attributes{ Attributes: ast.Attributes{
{Name: "attr", Values: []string{"a", "b"}}, {Name: "attr", Values: []any{"a", "b"}},
}, },
Name: "T", Name: "T",
}}, }},
}, },
}, { /////////////////////////////////////////////////////////////////// }, { ///////////////////////////////////////////////////////////////////
utils.ThisLine(), utils.ThisLine(),
`@attr(1, "x") type T`, ast.AST{ `@attr(1, "x", 2.0) type T`, ast.AST{
Types: []ast.TypeDecl{{ Types: []ast.TypeDecl{{
Attributes: ast.Attributes{ Attributes: ast.Attributes{
{Name: "attr", Values: []string{"1", "x"}}, {Name: "attr", Values: []any{1, "x", 2.0}},
}, },
Name: "T", Name: "T",
}}, }},
@ -194,7 +194,7 @@ func TestParser(t *testing.T) {
Kind: ast.Builtin, Kind: ast.Builtin,
Name: "F", Name: "F",
Attributes: ast.Attributes{ Attributes: ast.Attributes{
{Name: "attr", Values: []string{}}, {Name: "attr", Values: nil},
}, },
Parameters: ast.Parameters{}, Parameters: ast.Parameters{},
}}, }},
@ -318,7 +318,7 @@ func TestParser(t *testing.T) {
Kind: ast.Operator, Kind: ast.Operator,
Name: "F", Name: "F",
Attributes: ast.Attributes{ Attributes: ast.Attributes{
{Name: "attr", Values: []string{}}, {Name: "attr", Values: nil},
}, },
Parameters: ast.Parameters{}, Parameters: ast.Parameters{},
}}, }},
@ -344,7 +344,7 @@ func TestParser(t *testing.T) {
Name: "F", Name: "F",
Parameters: ast.Parameters{ Parameters: ast.Parameters{
{ {
Attributes: ast.Attributes{{Name: "blah", Values: []string{}}}, Attributes: ast.Attributes{{Name: "blah", Values: nil}},
Type: ast.TemplatedName{Name: "a"}}, Type: ast.TemplatedName{Name: "a"}},
}, },
}}, }},
@ -456,7 +456,7 @@ func TestParser(t *testing.T) {
Kind: ast.Initializer, Kind: ast.Initializer,
Name: "F", Name: "F",
Attributes: ast.Attributes{ Attributes: ast.Attributes{
{Name: "attr", Values: []string{}}, {Name: "attr", Values: nil},
}, },
Parameters: ast.Parameters{}, Parameters: ast.Parameters{},
}}, }},
@ -580,7 +580,7 @@ func TestParser(t *testing.T) {
Kind: ast.Converter, Kind: ast.Converter,
Name: "F", Name: "F",
Attributes: ast.Attributes{ Attributes: ast.Attributes{
{Name: "attr", Values: []string{}}, {Name: "attr", Values: nil},
}, },
Parameters: ast.Parameters{}, Parameters: ast.Parameters{},
}}, }},

View File

@ -17,7 +17,6 @@ package resolver
import ( import (
"fmt" "fmt"
"sort" "sort"
"strconv"
"dawn.googlesource.com/dawn/tools/src/container" "dawn.googlesource.com/dawn/tools/src/container"
"dawn.googlesource.com/dawn/tools/src/tint/intrinsic/ast" "dawn.googlesource.com/dawn/tools/src/tint/intrinsic/ast"
@ -184,15 +183,15 @@ func (r *resolver) ty(a ast.TypeDecl) error {
if len(d.Values) != 1 { if len(d.Values) != 1 {
return fmt.Errorf("%v expected a single value for 'display' attribute", d.Source) return fmt.Errorf("%v expected a single value for 'display' attribute", d.Source)
} }
t.DisplayName = d.Values[0] t.DisplayName = fmt.Sprint(d.Values[0])
} }
if d := a.Attributes.Take("precedence"); d != nil { if d := a.Attributes.Take("precedence"); d != nil {
if len(d.Values) != 1 { if len(d.Values) != 1 {
return fmt.Errorf("%v expected a single integer value for 'precedence' attribute", d.Source) return fmt.Errorf("%v expected a single integer value for 'precedence' attribute", d.Source)
} }
n, err := strconv.Atoi(d.Values[0]) n, ok := d.Values[0].(int)
if err != nil { if !ok {
return fmt.Errorf("%v %v", d.Source, err) return fmt.Errorf("%v @precedence value must be an integer", d.Source)
} }
t.Precedence = n t.Precedence = n
} }
@ -358,7 +357,11 @@ func (r *resolver) intrinsic(
overload.ConstEvalFunction = "Conv" overload.ConstEvalFunction = "Conv"
} }
case 1: case 1:
overload.ConstEvalFunction = constEvalFn.Values[0] fn, ok := constEvalFn.Values[0].(string)
if !ok {
return fmt.Errorf("%v optional @const value must be a string", constEvalFn.Source)
}
overload.ConstEvalFunction = fn
default: default:
return fmt.Errorf("%v too many values for @const attribute", constEvalFn.Source) return fmt.Errorf("%v too many values for @const attribute", constEvalFn.Source)
} }
@ -405,13 +408,25 @@ func (r *resolver) intrinsic(
if attribute := p.Attributes.Take("const"); attribute != nil { if attribute := p.Attributes.Take("const"); attribute != nil {
isConst = true isConst = true
} }
testValue := 1.0
if attribute := p.Attributes.Take("test_value"); attribute != nil {
switch v := attribute.Values[0].(type) {
case int:
testValue = float64(v)
case float64:
testValue = v
default:
return fmt.Errorf("%v @test_value must be an integer or float", p.Attributes[0].Source)
}
}
if len(p.Attributes) != 0 { if len(p.Attributes) != 0 {
return fmt.Errorf("%v unknown attribute", p.Attributes[0].Source) return fmt.Errorf("%v unknown attribute", p.Attributes[0].Source)
} }
overload.Parameters[i] = sem.Parameter{ overload.Parameters[i] = sem.Parameter{
Name: p.Name, Name: p.Name,
Type: usage, Type: usage,
IsConst: isConst, IsConst: isConst,
TestValue: testValue,
} }
} }

View File

@ -242,9 +242,10 @@ func (o Overload) Format(w fmt.State, verb rune) {
// Parameter describes a single parameter of a function overload // Parameter describes a single parameter of a function overload
type Parameter struct { type Parameter struct {
Name string Name string
Type FullyQualifiedName Type FullyQualifiedName
IsConst bool // Did this parameter have a @const attribute? IsConst bool // Did this parameter have a @const attribute?
TestValue float64 // Value to use for end-to-end tests
} }
// Format implements the fmt.Formatter interface // Format implements the fmt.Formatter interface

View File

@ -26,6 +26,7 @@ const (
InvalidToken Kind = "<invalid>" InvalidToken Kind = "<invalid>"
Identifier Kind = "ident" Identifier Kind = "ident"
Integer Kind = "integer" Integer Kind = "integer"
Float Kind = "float"
String Kind = "string" String Kind = "string"
Match Kind = "match" Match Kind = "match"
Function Kind = "fn" Function Kind = "fn"