|
@@ -1,64 +1,85 @@
|
|
// Run: %dxc -T vs_6_0 -E main
|
|
// Run: %dxc -T vs_6_0 -E main
|
|
|
|
|
|
struct S {
|
|
struct S {
|
|
- float a;
|
|
|
|
- float3 b;
|
|
|
|
-
|
|
|
|
- // Not referencing members
|
|
|
|
- float fn_no_ref() {
|
|
|
|
- return 4.2;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // Referencing members
|
|
|
|
- float fn_ref() {
|
|
|
|
- return a + this.b[0];
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // Calling a method defined later
|
|
|
|
- float fn_call(float c) {
|
|
|
|
- return fn_param(c);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // Passing in parameters
|
|
|
|
- float fn_param(float c) {
|
|
|
|
- return a + c;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // Unused method
|
|
|
|
- float fn_unused() {
|
|
|
|
- return 2.4;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // Static method
|
|
|
|
- static float fn_static() {
|
|
|
|
- return 3.5;
|
|
|
|
- }
|
|
|
|
|
|
+ float a;
|
|
|
|
+ float3 b;
|
|
|
|
+
|
|
|
|
+ // Not referencing members
|
|
|
|
+ float fn_no_ref() {
|
|
|
|
+ return 4.2;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Referencing members
|
|
|
|
+ float fn_ref() {
|
|
|
|
+ return a + this.b[0];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Calling a method defined later
|
|
|
|
+ float fn_call(float c) {
|
|
|
|
+ return fn_param(c);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Passing in parameters
|
|
|
|
+ float fn_param(float c) {
|
|
|
|
+ return a + c;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Unused method
|
|
|
|
+ float fn_unused() {
|
|
|
|
+ return 2.4;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Static method
|
|
|
|
+ static float fn_static() {
|
|
|
|
+ return 3.5;
|
|
|
|
+ }
|
|
};
|
|
};
|
|
|
|
|
|
struct T {
|
|
struct T {
|
|
- S s;
|
|
|
|
|
|
+ S s;
|
|
|
|
+
|
|
|
|
+ // Calling method in nested struct
|
|
|
|
+ float fn_nested() {
|
|
|
|
+ return s.fn_ref();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Static method with the same name as S
|
|
|
|
+ static float fn_static() {
|
|
|
|
+ return 6.7;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Get inner object
|
|
|
|
+ S get_S() {
|
|
|
|
+ return s;
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
|
|
- // Calling method in nested struct
|
|
|
|
- float fn_nested() {
|
|
|
|
- return s.fn_ref();
|
|
|
|
- }
|
|
|
|
|
|
+T foo() {
|
|
|
|
+ T t;
|
|
|
|
+ return t;
|
|
|
|
+}
|
|
|
|
|
|
- // Static method with the same name as S
|
|
|
|
- static float fn_static() {
|
|
|
|
- return 6.7;
|
|
|
|
- }
|
|
|
|
-};
|
|
|
|
|
|
+// CHECK: [[ft_f32:%\d+]] = OpTypeFunction %float
|
|
|
|
+// CHECK: [[ft_S:%\d+]] = OpTypeFunction %float %_ptr_Function_S
|
|
|
|
+// CHECK: [[ft_S_f32:%\d+]] = OpTypeFunction %float %_ptr_Function_S %_ptr_Function_float
|
|
|
|
+// CHECK: [[ft_T:%\d+]] = OpTypeFunction %float %_ptr_Function_T
|
|
|
|
+// CHECK: [[fooFnType:%\d+]] = OpTypeFunction %T
|
|
|
|
+// CHECK: [[getSFntype:%\d+]] = OpTypeFunction %S %_ptr_Function_T
|
|
|
|
|
|
-// CHECK: [[ft_f32:%\d+]] = OpTypeFunction %float
|
|
|
|
-// CHECK: [[ft_S:%\d+]] = OpTypeFunction %float %_ptr_Function_S
|
|
|
|
-// CHECK: [[ft_S_f32:%\d+]] = OpTypeFunction %float %_ptr_Function_S %_ptr_Function_float
|
|
|
|
-// CHECK: [[ft_T:%\d+]] = OpTypeFunction %float %_ptr_Function_T
|
|
|
|
|
|
+float main() : A {
|
|
|
|
|
|
// CHECK-LABEL: %src_main = OpFunction
|
|
// CHECK-LABEL: %src_main = OpFunction
|
|
// CHECK-NEXT: %bb_entry = OpLabel
|
|
// CHECK-NEXT: %bb_entry = OpLabel
|
|
// CHECK-NEXT: %s = OpVariable %_ptr_Function_S Function
|
|
// CHECK-NEXT: %s = OpVariable %_ptr_Function_S Function
|
|
// CHECK-NEXT: %t = OpVariable %_ptr_Function_T Function
|
|
// CHECK-NEXT: %t = OpVariable %_ptr_Function_T Function
|
|
|
|
+// CHECK-NEXT: %f1 = OpVariable %_ptr_Function_float Function
|
|
// CHECK-NEXT: %param_var_c = OpVariable %_ptr_Function_float Function
|
|
// CHECK-NEXT: %param_var_c = OpVariable %_ptr_Function_float Function
|
|
|
|
+// CHECK-NEXT: %f2 = OpVariable %_ptr_Function_float Function
|
|
|
|
+// CHECK-NEXT: %temp_var_T = OpVariable %_ptr_Function_T Function
|
|
|
|
+// CHECK-NEXT: %temp_var_S = OpVariable %_ptr_Function_S Function
|
|
|
|
+ S s;
|
|
|
|
+ T t;
|
|
|
|
+
|
|
// CHECK: {{%\d+}} = OpFunctionCall %float %S_fn_no_ref %s
|
|
// CHECK: {{%\d+}} = OpFunctionCall %float %S_fn_no_ref %s
|
|
// CHECK: {{%\d+}} = OpFunctionCall %float %S_fn_ref %s
|
|
// CHECK: {{%\d+}} = OpFunctionCall %float %S_fn_ref %s
|
|
// CHECK: {{%\d+}} = OpFunctionCall %float %S_fn_call %s %param_var_c
|
|
// CHECK: {{%\d+}} = OpFunctionCall %float %S_fn_call %s %param_var_c
|
|
@@ -67,12 +88,18 @@ struct T {
|
|
// CHECK: {{%\d+}} = OpFunctionCall %float %T_fn_static
|
|
// CHECK: {{%\d+}} = OpFunctionCall %float %T_fn_static
|
|
// CHECK: {{%\d+}} = OpFunctionCall %float %S_fn_static
|
|
// CHECK: {{%\d+}} = OpFunctionCall %float %S_fn_static
|
|
// CHECK: {{%\d+}} = OpFunctionCall %float %T_fn_static
|
|
// CHECK: {{%\d+}} = OpFunctionCall %float %T_fn_static
|
|
|
|
+ float f1 = s.fn_no_ref() + s.fn_ref() + s.fn_call(5.0) + t.fn_nested() +
|
|
|
|
+ s.fn_static() + t.fn_static() + S::fn_static() + T::fn_static();
|
|
|
|
+
|
|
|
|
+// CHECK: [[temp_T:%\d+]] = OpFunctionCall %T %foo
|
|
|
|
+// CHECK-NEXT: OpStore %temp_var_T [[temp_T]]
|
|
|
|
+// CHECK-NEXT: [[temp_S:%\d+]] = OpFunctionCall %S %T_get_S %temp_var_T
|
|
|
|
+// CHECK-NEXT: OpStore %temp_var_S [[temp_S]]
|
|
|
|
+// CHECK-NEXT: {{%\d+}} = OpFunctionCall %float %S_fn_ref %temp_var_S
|
|
|
|
+ float f2 = foo().get_S().fn_ref();
|
|
|
|
+
|
|
|
|
+ return f1;
|
|
// CHECK: OpFunctionEnd
|
|
// CHECK: OpFunctionEnd
|
|
-float main() : A {
|
|
|
|
- S s;
|
|
|
|
- T t;
|
|
|
|
- return s.fn_no_ref() + s.fn_ref() + s.fn_call(5.0) + t.fn_nested() +
|
|
|
|
- s.fn_static() + t.fn_static() + S::fn_static() + T::fn_static();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
// CHECK: %S_fn_no_ref = OpFunction %float None [[ft_S]]
|
|
// CHECK: %S_fn_no_ref = OpFunction %float None [[ft_S]]
|
|
@@ -114,10 +141,18 @@ float main() : A {
|
|
// CHECK-NEXT: %bb_entry_5 = OpLabel
|
|
// CHECK-NEXT: %bb_entry_5 = OpLabel
|
|
// CHECK: OpFunctionEnd
|
|
// CHECK: OpFunctionEnd
|
|
|
|
|
|
|
|
+// CHECK: %foo = OpFunction %T None [[fooFnType]]
|
|
|
|
+// CHECK-NEXT: %bb_entry_6 = OpLabel
|
|
|
|
+// CHECK: OpFunctionEnd
|
|
|
|
+
|
|
|
|
+// CHECK: %T_get_S = OpFunction %S None [[getSFntype]]
|
|
|
|
+// CHECK-NEXT: %param_this_3 = OpFunctionParameter %_ptr_Function_T
|
|
|
|
+// CHECK-NEXT: %bb_entry_7 = OpLabel
|
|
|
|
+// CHECK: OpFunctionEnd
|
|
|
|
|
|
// CHECK: %S_fn_param = OpFunction %float None [[ft_S_f32]]
|
|
// CHECK: %S_fn_param = OpFunction %float None [[ft_S_f32]]
|
|
-// CHECK-NEXT: %param_this_3 = OpFunctionParameter %_ptr_Function_S
|
|
|
|
|
|
+// CHECK-NEXT: %param_this_4 = OpFunctionParameter %_ptr_Function_S
|
|
// CHECK-NEXT: %c_0 = OpFunctionParameter %_ptr_Function_float
|
|
// CHECK-NEXT: %c_0 = OpFunctionParameter %_ptr_Function_float
|
|
-// CHECK-NEXT: %bb_entry_6 = OpLabel
|
|
|
|
-// CHECK: {{%\d+}} = OpAccessChain %_ptr_Function_float %param_this_3 %int_0
|
|
|
|
|
|
+// CHECK-NEXT: %bb_entry_8 = OpLabel
|
|
|
|
+// CHECK: {{%\d+}} = OpAccessChain %_ptr_Function_float %param_this_4 %int_0
|
|
// CHECK: OpFunctionEnd
|
|
// CHECK: OpFunctionEnd
|