Skip to content

Commit 85fff3c

Browse files
committed
Update c_backend to use breaking_changes as intended
1 parent 24d6834 commit 85fff3c

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

py/dml/c_backend.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
from . import objects, logging, crep, output, ctree, serialize, structure
1616
from . import traits
17-
from . import breaking_changes as compat
17+
from . import breaking_changes
1818
import dml.globals
1919
from .structure import get_attr_name, port_class_ident, need_port_proxy_attrs
2020
from .logging import *
@@ -261,7 +261,8 @@ def generate_hfile(device, headers, filename):
261261
out("/* Generated by dmlc, do not edit! */\n\n")
262262
emit_guard_start(filename)
263263
out('#define DML_PREFIX(x) '+crep.cname(device)+'_##x\n\n')
264-
legacy_attrs = int(compat.legacy_attributes in dml.globals.enabled_compat)
264+
legacy_attrs = int(breaking_changes.remove_legacy_attributes
265+
not in dml.globals.enabled_breaking)
265266
out(f'#define DML_LEGACY_ATTRS {legacy_attrs}\n')
266267

267268
with allow_linemarks():
@@ -893,7 +894,8 @@ def generate_implement(code, device, impl):
893894
# descendants of the device object
894895
if (port.parent is dml.globals.device
895896
and port.objtype in {'port', 'bank'}
896-
and compat.port_proxy_ifaces in dml.globals.enabled_compat):
897+
and breaking_changes.remove_port_proxy_ifaces
898+
not in dml.globals.enabled_breaking):
897899
if port.local_dimensions() == 0:
898900
code.out("static const %s = %s;\n" % (
899901
ifacetype.declaration('port_iface'),
@@ -1684,7 +1686,7 @@ def generate_pre_delete(device):
16841686
+ 'NULL);\n')
16851687
out('}\n', preindent=-1)
16861688

1687-
if dml.globals.api_version < compat.api_7:
1689+
if dml.globals.api_version < breaking_changes.api_7:
16881690
out(f'{crep.cname(device)}_deinit(_obj);\n')
16891691
out('}\n\n', preindent = -1)
16901692

@@ -1938,7 +1940,7 @@ def generate_init_data_objs(device):
19381940
for (start, end) in [('A', 'Z'), ('a', 'z'), ('0', '9'), ('_', '_')]
19391941
for i in range(ord(start), ord(end) + 1))
19401942
def init_function_name(device, outprefix):
1941-
if dml.globals.api_version <= compat.api_4_8:
1943+
if dml.globals.api_version <= breaking_changes.api_4_8:
19421944
return 'initialize_' + crep.cname(device)
19431945
return '_initialize_' + ''.join(
19441946
(ch if ch in ident_chars else '_') for ch in outprefix)
@@ -1966,7 +1968,7 @@ def generate_init(device, initcode, outprefix):
19661968
out('.init = '+crep.cname(device)+'_init,\n')
19671969
out('.finalize = '+crep.cname(device)+'_finalize,\n')
19681970
out('.objects_finalized = '+crep.cname(device)+'_objects_finalized,\n')
1969-
if dml.globals.api_version >= compat.api_7:
1971+
if dml.globals.api_version >= breaking_changes.api_7:
19701972
out('.deinit = '+crep.cname(device)+'_deinit,\n')
19711973
out('.dealloc = '+crep.cname(device)+'_dealloc,\n')
19721974
out('.description = '+doc.read()+',\n')
@@ -2166,7 +2168,7 @@ def generate_port_object_assocs_array():
21662168
else node.object_parent)
21672169
if (object_node is not dml.globals.device
21682170
# Anonymous banks
2169-
and (compat.dml12_misc not in dml.globals.enabled_compat
2171+
and (breaking_changes.remove_misc_quirks in dml.globals.enabled_breaking
21702172
or object_node.ident is not None)):
21712173
port_obj_offset = (
21722174
f'offsetof({crep.structtype(dml.globals.device)}, '
@@ -3276,8 +3278,9 @@ def generate_cfile(device, footers,
32763278
full_module):
32773279
global c_file
32783280

3279-
sym = 'SIMICS_%s_API' % ('4_8' if dml.globals.api_version == compat.api_4_8
3280-
else dml.globals.api_version.str)
3281+
sym = 'SIMICS_%s_API' % (
3282+
'4_8' if dml.globals.api_version == breaking_changes.api_4_8
3283+
else dml.globals.api_version.str)
32813284
api_define = '#ifndef %s\n#define %s\n#endif\n' % (
32823285
sym, sym)
32833286

@@ -3337,7 +3340,8 @@ def generate_cfile_body(device, footers, full_module, filename_prefix):
33373340
generate_identity_data_decls()
33383341
generate_object_vtables_array()
33393342
if not (dml.globals.dml_version == (1, 2)
3340-
and compat.shared_logs_on_device in dml.globals.enabled_compat):
3343+
and breaking_changes.shared_logs_on_ports
3344+
not in dml.globals.enabled_breaking):
33413345
generate_port_object_assocs_array()
33423346
generate_class_var_decl()
33433347
generate_startup_calls_entry_function(device)
@@ -3470,7 +3474,7 @@ def generate_cfile_body(device, footers, full_module, filename_prefix):
34703474

34713475
if full_module:
34723476
# caught as error earlier on
3473-
assert dml.globals.api_version == compat.api_4_8
3477+
assert dml.globals.api_version == breaking_changes.api_4_8
34743478
out('\n')
34753479
out('EXPORTED void\n')
34763480
out('init_local(void)\n')

0 commit comments

Comments
 (0)