CUDApp
CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.
Brought by drakestapleton
CUDApp / om / components / artifact_parse.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Byte-at-a-time memory-shell parser. 0 continue, 1 end accepted, 2 reject, 3 component. |
| 3 | note Modes 0 field text, 1 lowercase digest, 2 decimal comma list, 3 semantic version. |
| 4 | note State: digits, accumulator, component, expected components, emitted value, total bytes. |
| 5 | fn artifact_parse mode ulong ch ulong s edit ulong 8 to ulong |
| 6 | if eq mode 4 |
| 7 | hi = shr ch 4 |
| 8 | lo = and ch 15 |
| 9 | if lt hi 10 |
| 10 | hi = add hi 48 |
| 11 | else |
| 12 | hi = add hi 87 |
| 13 | end |
| 14 | if lt lo 10 |
| 15 | lo = add lo 48 |
| 16 | else |
| 17 | lo = add lo 87 |
| 18 | end |
| 19 | ret or hi shl lo 8 |
| 20 | end |
| 21 | if eq mode 0 |
| 22 | if eq ch 0 |
| 23 | ret 1 |
| 24 | end |
| 25 | if or lt ch 32 eq ch 127 |
| 26 | ret 2 |
| 27 | end |
| 28 | ret 0 |
| 29 | end |
| 30 | if eq mode 1 |
| 31 | if eq ch 0 |
| 32 | if eq get s 0 64 |
| 33 | ret 1 |
| 34 | end |
| 35 | ret 2 |
| 36 | end |
| 37 | if ge get s 0 64 |
| 38 | ret 2 |
| 39 | end |
| 40 | valid = and ge ch 48 le ch 57 |
| 41 | if and ge ch 97 le ch 102 |
| 42 | valid = true |
| 43 | end |
| 44 | if not valid |
| 45 | ret 2 |
| 46 | end |
| 47 | put s 0 add get s 0 1 |
| 48 | ret 0 |
| 49 | end |
| 50 | if and ne mode 2 ne mode 3 |
| 51 | ret 2 |
| 52 | end |
| 53 | if eq mode 2 |
| 54 | if ge get s 5 63 |
| 55 | if ne ch 0 |
| 56 | ret 2 |
| 57 | end |
| 58 | end |
| 59 | end |
| 60 | put s 5 add get s 5 1 |
| 61 | if and ge ch 48 le ch 57 |
| 62 | if ge get s 0 9 |
| 63 | ret 2 |
| 64 | end |
| 65 | put s 0 add get s 0 1 |
| 66 | put s 1 add mul get s 1 10 sub ch 48 |
| 67 | ret 0 |
| 68 | end |
| 69 | if eq get s 0 0 |
| 70 | ret 2 |
| 71 | end |
| 72 | if eq ch 0 |
| 73 | if ne add get s 2 1 get s 3 |
| 74 | ret 2 |
| 75 | end |
| 76 | put s 4 get s 1 |
| 77 | ret 1 |
| 78 | end |
| 79 | sep = ulong 44 |
| 80 | if eq mode 3 |
| 81 | sep = 46 |
| 82 | end |
| 83 | if ne ch sep |
| 84 | ret 2 |
| 85 | end |
| 86 | if ge add get s 2 1 get s 3 |
| 87 | ret 2 |
| 88 | end |
| 89 | put s 4 get s 1 |
| 90 | put s 0 0 |
| 91 | put s 1 0 |
| 92 | put s 2 add get s 2 1 |
| 93 | ret 3 |
| 94 | end |