|
| 1 | +; SPIR-V |
| 2 | +; Version: 1.5 |
| 3 | +; Generator: Khronos SPIR-V Tools Assembler; 0 |
| 4 | +; Bound: 50 |
| 5 | +; Schema: 0 |
| 6 | + OpCapability Linkage |
| 7 | + OpCapability Shader |
| 8 | + OpMemoryModel Logical GLSL450 |
| 9 | + OpSource HLSL 630 |
| 10 | + OpName %add_one "add_one" |
| 11 | + OpName %x "x" |
| 12 | + OpName %add_two "add_two" |
| 13 | + OpName %y "y" |
| 14 | + OpName %add_three "add_three" |
| 15 | + OpName %z "z" |
| 16 | + OpDecorate %add_one LinkageAttributes "add_one" Export |
| 17 | + OpDecorate %add_two LinkageAttributes "add_two" Export |
| 18 | + OpDecorate %add_three LinkageAttributes "add_three" Export |
| 19 | + %uint = OpTypeInt 32 0 |
| 20 | + %uint_1 = OpConstant %uint 1 |
| 21 | + %uint_3 = OpConstant %uint 3 |
| 22 | +%_ptr_Function_uint = OpTypePointer Function %uint |
| 23 | + %fn1 = OpTypeFunction %uint %_ptr_Function_uint |
| 24 | + |
| 25 | + %add_one = OpFunction %uint None %fn1 |
| 26 | + %x = OpFunctionParameter %_ptr_Function_uint |
| 27 | + %o_bb = OpLabel |
| 28 | + %o_xv = OpLoad %uint %x |
| 29 | + %o_r = OpIAdd %uint %o_xv %uint_1 |
| 30 | + OpReturnValue %o_r |
| 31 | + OpFunctionEnd |
| 32 | + |
| 33 | +; add_two calls add_one twice (already-emitted callee), and forward-references |
| 34 | +; add_three (callee declared *after* add_two in the module). Both exercise |
| 35 | +; the func.active short-circuit but in different directions. |
| 36 | + |
| 37 | + %add_two = OpFunction %uint None %fn1 |
| 38 | + %y = OpFunctionParameter %_ptr_Function_uint |
| 39 | + %t_bb = OpLabel |
| 40 | + %t_arg1 = OpVariable %_ptr_Function_uint Function |
| 41 | + %t_arg2 = OpVariable %_ptr_Function_uint Function |
| 42 | + %t_arg3 = OpVariable %_ptr_Function_uint Function |
| 43 | + %t_yv = OpLoad %uint %y |
| 44 | + OpStore %t_arg1 %t_yv |
| 45 | + %t_a = OpFunctionCall %uint %add_one %t_arg1 |
| 46 | + OpStore %t_arg2 %t_a |
| 47 | + %t_b = OpFunctionCall %uint %add_one %t_arg2 |
| 48 | + OpStore %t_arg3 %t_b |
| 49 | + %t_r = OpFunctionCall %uint %add_three %t_arg3 |
| 50 | + OpReturnValue %t_r |
| 51 | + OpFunctionEnd |
| 52 | + |
| 53 | + %add_three = OpFunction %uint None %fn1 |
| 54 | + %z = OpFunctionParameter %_ptr_Function_uint |
| 55 | + %r_bb = OpLabel |
| 56 | + %r_zv = OpLoad %uint %z |
| 57 | + %r_r = OpIAdd %uint %r_zv %uint_3 |
| 58 | + OpReturnValue %r_r |
| 59 | + OpFunctionEnd |
0 commit comments