-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy path__init__.py
70 lines (62 loc) · 2.35 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#
# Runtime util
#
# Copyright (c) 2020, Arm Limited. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
#
import builtins
import collections as co
import itertools as it
from ..glue import Inherit
RUNTIMES = co.OrderedDict()
def runtime(cls):
assert cls.__argname__ not in RUNTIMES
RUNTIMES[cls.__argname__] = cls
return cls
from ..outputs import OUTPUTS
class Runtime(Inherit(
['%s%s%s%s' % (op, level, output, order)
for op, level, output, order in it.product(
['box', 'build'],
['_root', '_muxer', '_parent', ''],
['_'+Output.__argname__ for Output in OUTPUTS.values()] + [''],
['_prologue', '', '_epilogue'])])):
def __init__(self):
super().__init__()
self.name = self.__argname__
def __eq__(self, other):
if isinstance(other, Runtime):
return self.name == other.name
else:
return self.name == other
def __lt__(self, other):
if isinstance(other, Runtime):
return self.name < other.name
else:
return self.name < other
def box(self, box):
super().box(box)
self.data_init_hook = box.addimport(
'__box_data_init', 'fn() -> void',
scope=box.name, source=self.__argname__, weak=True,
doc="Artificial hook to indicate who's taking care of "
"initializing the data section. Some loaders take care of "
"initialization implicitly, otherwise its left up to the "
"runtime. Not actually called.")
self.bss_init_hook = box.addimport(
'__box_bss_init', 'fn() -> void',
scope=box.name, source=self.__argname__, weak=True,
doc="Artificial hook to indicate who's taking care of "
"initializing the bss section. Some loaders take care of "
"initialization implicitly, otherwise its left up to the "
"runtime. Not actually called.")
# Runtime class imports
# These must be imported here, since they depend on the above utilities
from .jumptable import JumptableRuntime
from .armv7m_sys import ARMv7MSysRuntime
from .armv8m_sys import ARMv8MSysRuntime
from .armv7m_mpu import ARMv7MMPURuntime
from .armv8m_mpu import ARMv8MMPURuntime
from .awsm import aWsmRuntime
from .wamr import WamrRuntime
from .wasm3 import Wasm3Runtime