1module Runtime.NativeBranch
2
3import Runtime.NativePhysicalProgram
4import Runtime.NativePhysicalProgramComposer
5import Runtime.NativeLaunchRecipeLoad
6
7-- The branch's distance is derived from its actual command body. Counts refer
8-- to records, so packed and aligned images share the same control semantics.
9-- The image validator rejects a body which enters or leaves a repeat frame.
10def nativeWhenEqual =
11 (lambda unrestricted left : (family NativePhysicalOperand) .
12 (lambda unrestricted right : (family NativePhysicalOperand) .
13 (lambda unrestricted label : Bytes .
14 (lambda unrestricted body : (family NativePhysicalCommands) .
15 (lambda unrestricted tail : (family NativePhysicalCommands) .
16 (nativeLaunchRecipeCommand
17 (constructor
18 NativePhysicalOperation
19 NativePhysicalSkipUnlessEqual
20 left
21 right
22 (nativeLaunchRecipeWord (nativePhysicalCommandsLength body)))
23 label
24 (nativePhysicalProgramComposeCommandsAppend body tail)))))))
25
26-- The first guard skips the true body and its following forward jump. That
27-- jump skips the false body. Nested choices retain the surrounding loop's
28-- iteration coordinate, unlike encoding each guard as a counted loop.
29def nativeIfEqual =
30 (lambda unrestricted left : (family NativePhysicalOperand) .
31 (lambda unrestricted right : (family NativePhysicalOperand) .
32 (lambda unrestricted label : Bytes .
33 (lambda unrestricted whenEqual : (family NativePhysicalCommands) .
34 (lambda unrestricted whenDifferent : (family NativePhysicalCommands) .
35 (lambda unrestricted tail : (family NativePhysicalCommands) .
36 (nativeLaunchRecipeCommand
37 (constructor
38 NativePhysicalOperation
39 NativePhysicalSkipUnlessEqual
40 left
41 right
42 (nativeLaunchRecipeWord (succ (nativePhysicalCommandsLength whenEqual))))
43 (bytes-append label b":choose")
44 (nativePhysicalProgramComposeCommandsAppend
45 whenEqual
46 (nativeWhenEqual
47 (nativeLaunchRecipeImmediate 0)
48 (nativeLaunchRecipeImmediate 1)
49 (bytes-append label b":join")
50 whenDifferent
51 tail)))))))))The compiler supplied declaration spans and resolved links from this source snapshot. This page does not assert that this file belongs to a checked closure.