-
Notifications
You must be signed in to change notification settings - Fork 10
/
__init__.py
60 lines (52 loc) · 1.61 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
#
# Loader utils
#
# Copyright (c) 2020, Arm Limited. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
#
import collections as co
import itertools as it
from ..glue import Inherit
LOADERS = co.OrderedDict()
def loader(cls):
assert cls.__argname__ not in LOADERS
LOADERS[cls.__argname__] = cls
return cls
from ..outputs import OUTPUTS
class Loader(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, Loader):
return self.name == other.name
else:
return self.name == other
def __lt__(self, other):
if isinstance(other, Loader):
return self.name < other.name
else:
return self.name < other
def constraints(self, constraints):
"""
Allow loaders to override memory constraints requested
during memory allocations.
"""
return constraints
def box(self, box):
super().box(box)
box.text.alloc(box, 'rxp')
box.data.alloc(box, 'rw')
box.bss.alloc(box, 'rw')
# Runtime class imports
# These must be imported here, since they depend on the above utilities
from .noop import NoOpLoader
from .glz import GLZLoader
from .bd import BDLoader
from .fs import FSLoader