Source/Packages

Platform.AArch64.NativePhysicalELF

packages/hardware/platforms/dgx-spark/src/Platform/AArch64/NativePhysicalELF.alpha

167 lines2 declarations6.3 KiBSHA-256 45295e7acac7

Complete file · line 1

NativePhysicalELF.alpha

Definition view
1module Platform.AArch64.NativePhysicalELF
2
3import Compiler.ELF
4import Compiler.MachineAArch64
5import Compiler.MachineAArch64Assembly
6import Data.Bytes
7import Model.Config
8import Model.Parameter
9import Model.Word32
10import Model.Word64
11import Platform.AArch64.NativePhysicalRuntime
12import Runtime.NativePhysicalImage
13import Runtime.NativePhysicalNativeELF
14import Runtime.NativePhysicalProgram
15import Std.Byte
16import Std.Natural
17
18-- The AArch64 twin of Runtime.NativePhysicalNativeELF's fast path: the same
19-- aligned V3 command image (Runtime.NativePhysicalImage owns the format), the
20-- AArch64 runtime in front of it, and the same static ELF64 container with
21-- e_machine 183.  Everything else in the header -- entry 0x400078, one
22-- PT_LOAD at 0x400000 with a 4 MiB memory extent, 4 KiB alignment -- is the
23-- x86-64 header's, byte for byte.  The result reuses the x86 module's
24-- artifact and telemetry families so a caller can handle either target's
25-- artifact with one eliminator.
26-- The container is Compiler.ELF's, with e_machine 183 and its memory extent
27-- its file extent (Compiler.ELF.wrapMachineCodeExactFor).
28def aarch64WrapMachineCodeSparseLarge = (wrapMachineCodeExactFor elfMachineAArch64)
29
30def aarch64NativePhysicalGenerateELFFast =
31  (lambda unrestricted program : (family NativePhysicalProgram) .
32    (eliminate
33      NativePhysicalImageResult
34      (lambda unrestricted current : (family NativePhysicalImageResult) .
35        (family NativePhysicalNativeELFResult))
36      (nativePhysicalGenerateImageAlignedFast program)
37      (branch
38        NativePhysicalImageGenerated
39        image
40        imageTelemetry
41        .
42        (eliminate
43          NativePhysicalImage
44          (lambda unrestricted current : (family NativePhysicalImage) .
45            (family NativePhysicalNativeELFResult))
46          image
47          (branch
48            NativePhysicalImageValue
49            imageBytes
50            bodyDigest
51            identity
52            commandCount
53            stateExtent
54            resultSlots
55            telemetry
56            .
57            (eliminate
58              AArch64AssemblyResult
59              (lambda unrestricted current : (family AArch64AssemblyResult) .
60                (family NativePhysicalNativeELFResult))
61              aarch64NativePhysicalRuntime
62              (branch
63                AArch64AssemblyEncoded
64                codeBytes
65                .
66                (app
67                  (lambda unrestricted machineBytes : Bytes .
68                    (app
69                      (lambda unrestricted elfBytes : Bytes .
70                        (constructor
71                          NativePhysicalNativeELFResult
72                          NativePhysicalNativeELFGenerated
73                          (constructor
74                            NativePhysicalNativeELFArtifact
75                            NativePhysicalNativeELFArtifactValue
76                            elfBytes
77                            codeBytes
78                            imageBytes
79                            machineBytes
80                            identity
81                            b""
82                            b""
83                            b""
84                            b""
85                            commandCount
86                            (nativePhysicalNativeELFTelemetryFor
87                              codeBytes
88                              imageBytes
89                              machineBytes
90                              elfBytes
91                              identity
92                              b""
93                              b""
94                              b""
95                              b""))
96                          (nativePhysicalNativeELFTelemetryFor
97                            codeBytes
98                            imageBytes
99                            machineBytes
100                            elfBytes
101                            identity
102                            b""
103                            b""
104                            b""
105                            b"")))
106                      (aarch64WrapMachineCodeSparseLarge machineBytes)))
107                  (bytes-append codeBytes imageBytes)))
108              (branch
109                AArch64AssemblyEncodeDuplicateLabel
110                duplicateName
111                .
112                (nativePhysicalNativeELFFail
113                  nativePhysicalNativeELFAssemblyFailurePhase
114                  (constructor
115                    NativePhysicalNativeELFErrorCode
116                    NativePhysicalNativeELFDuplicateLabel
117                    duplicateName)
118                  b""
119                  duplicateName))
120              (branch
121                AArch64AssemblyMissingLabel
122                missingName
123                .
124                (nativePhysicalNativeELFFail
125                  nativePhysicalNativeELFAssemblyFailurePhase
126                  (constructor
127                    NativePhysicalNativeELFErrorCode
128                    NativePhysicalNativeELFMissingLabel
129                    missingName)
130                  b""
131                  missingName))
132              (branch
133                AArch64AssemblyDisplacementOutOfRange
134                distantName
135                .
136                (nativePhysicalNativeELFFail
137                  nativePhysicalNativeELFAssemblyFailurePhase
138                  (constructor
139                    NativePhysicalNativeELFErrorCode
140                    NativePhysicalNativeELFDisplacementOutOfRange
141                    distantName)
142                  b""
143                  distantName))
144              (branch
145                AArch64AssemblyOperandRefused
146                value
147                .
148                (nativePhysicalNativeELFFail
149                  nativePhysicalNativeELFAssemblyFailurePhase
150                  (constructor
151                    NativePhysicalNativeELFErrorCode
152                    NativePhysicalNativeELFAssemblyOffsetOverflow)
153                  b""
154                  b""))))))
155      (branch
156        NativePhysicalImageGenerationFailed
157        imageError
158        failureTelemetry
159        .
160        (nativePhysicalNativeELFFail
161          nativePhysicalNativeELFImageFailurePhase
162          (constructor
163            NativePhysicalNativeELFErrorCode
164            NativePhysicalNativeELFImageGenerationFailed
165            imageError)
166          (nativePhysicalNativeELFEncodeImageFailureTelemetry failureTelemetry)
167          b""))))

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.