Skip to content

Commit 2c0f959

Browse files
committed
Generate params for all breaking changes
1 parent d8f7bb6 commit 2c0f959

File tree

8 files changed

+223
-45
lines changed

8 files changed

+223
-45
lines changed

lib/1.2/dml-builtins.dml

Lines changed: 59 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -209,27 +209,65 @@ template device {
209209

210210
parameter simics_api_version auto;
211211

212-
parameter _compat_broken_unused_types auto;
213-
parameter _compat_broken_conditional_is auto;
214-
parameter _compat_port_proxy_ifaces auto;
215-
parameter _compat_port_proxy_attrs auto;
216-
parameter _compat_optional_version_statement auto;
217-
parameter _compat_function_in_extern_struct auto;
218-
parameter _compat_port_obj_param auto;
219-
parameter _compat_io_memory auto;
220-
parameter _compat_shared_logs_on_device auto;
221-
parameter _compat_suppress_WLOGMIXUP auto;
222-
parameter _compat_legacy_attributes auto;
223-
parameter _compat_lenient_typechecking auto;
224-
parameter _compat_no_method_index_asserts auto;
225-
parameter _compat_meaningless_log_levels auto;
226-
parameter _compat_dml12_inline auto;
227-
parameter _compat_dml12_not auto;
228-
parameter _compat_dml12_goto auto;
229-
parameter _compat_dml12_misc auto;
230-
parameter _compat_dml12_int auto;
231-
parameter _compat_experimental_vect auto;
232-
parameter _compat_warning_statement auto;
212+
parameter _compat_broken_unused_types
213+
= !$_breaking_change_dml_forbid_broken_unused_types;
214+
parameter _compat_broken_conditional_is
215+
= !$_breaking_change_dml_forbid_broken_conditional_is;
216+
parameter _compat_port_proxy_ifaces
217+
= !$_breaking_change_dml_remove_port_proxy_ifaces;
218+
parameter _compat_port_proxy_attrs
219+
= !$_breaking_change_dml_remove_port_proxy_attrs;
220+
parameter _compat_function_in_extern_struct
221+
= !$_breaking_change_dml_forbid_function_in_extern_struct;
222+
parameter _compat_optional_version_statement
223+
= !$_breaking_change_dml_require_version_statement;
224+
parameter _compat_io_memory = !$_breaking_change_dml_transaction_by_default;
225+
parameter _compat_port_obj_param
226+
= !$_breaking_change_dml_remove_port_obj_param;
227+
parameter _compat_shared_logs_on_device
228+
= !$_breaking_change_dml_shared_logs_locally;
229+
parameter _compat_suppress_WLOGMIXUP
230+
= !$_breaking_change_dml_enable_WLOGMIXUP;
231+
parameter _compat_legacy_attributes
232+
= !$_breaking_change_dml_remove_legacy_attributes;
233+
parameter _compat_lenient_typechecking
234+
= !$_breaking_change_dml_strict_typechecking;
235+
parameter _compat_no_method_index_asserts
236+
= !$_breaking_change_dml_range_check_method_indices;
237+
parameter _compat_meaningless_log_levels
238+
= !$_breaking_change_dml_restrict_log_levels;
239+
parameter _compat_dml12_inline
240+
= !$_breaking_change_dml12_disable_inline_constants;
241+
parameter _compat_dml12_not = !$_breaking_change_dml12_not_typecheck;
242+
parameter _compat_dml12_misc = !$_breaking_change_dml12_remove_misc_quirks;
243+
parameter _compat_dml12_goto = !$_breaking_change_dml12_remove_goto;
244+
parameter _compat_dml12_int = !$_breaking_change_dml12_fix_int_quirks;
245+
parameter _compat_experimental_vect
246+
= !$_breaking_change_dml_forbid_experimental_vect;
247+
parameter _compat_warning_statement
248+
= !$_breaking_change_dml_forbid_warning_statement;
249+
250+
parameter _breaking_change_dml_forbid_broken_unused_types auto;
251+
parameter _breaking_change_dml_forbid_broken_conditional_is auto;
252+
parameter _breaking_change_dml_remove_port_proxy_ifaces auto;
253+
parameter _breaking_change_dml_remove_port_proxy_attrs auto;
254+
parameter _breaking_change_dml_forbid_function_in_extern_struct auto;
255+
parameter _breaking_change_dml_require_version_statement auto;
256+
parameter _breaking_change_dml_transaction_by_default auto;
257+
parameter _breaking_change_dml_remove_port_obj_param auto;
258+
parameter _breaking_change_dml_shared_logs_locally auto;
259+
parameter _breaking_change_dml_enable_WLOGMIXUP auto;
260+
parameter _breaking_change_dml_remove_legacy_attributes auto;
261+
parameter _breaking_change_dml_strict_typechecking auto;
262+
parameter _breaking_change_dml_range_check_method_indices auto;
263+
parameter _breaking_change_dml_restrict_log_levels auto;
264+
parameter _breaking_change_dml12_disable_inline_constants auto;
265+
parameter _breaking_change_dml12_not_typecheck auto;
266+
parameter _breaking_change_dml12_remove_misc_quirks auto;
267+
parameter _breaking_change_dml12_remove_goto auto;
268+
parameter _breaking_change_dml12_fix_int_quirks auto;
269+
parameter _breaking_change_dml_forbid_experimental_vect auto;
270+
parameter _breaking_change_dml_forbid_warning_statement auto;
233271

234272
// automatic parameters
235273
parameter obj auto;

lib/1.4/dml-builtins.dml

Lines changed: 58 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -635,27 +635,64 @@ template device {
635635

636636
param simics_api_version auto;
637637

638-
param _compat_broken_unused_types auto;
639-
param _compat_broken_conditional_is auto;
640-
param _compat_port_proxy_ifaces auto;
641-
param _compat_port_proxy_attrs auto;
642-
param _compat_function_in_extern_struct auto;
643-
param _compat_optional_version_statement auto;
644-
param _compat_port_obj_param auto;
645-
param _compat_io_memory auto;
646-
param _compat_shared_logs_on_device auto;
647-
param _compat_suppress_WLOGMIXUP auto;
648-
param _compat_legacy_attributes auto;
649-
param _compat_lenient_typechecking auto;
650-
param _compat_no_method_index_asserts auto;
651-
param _compat_meaningless_log_levels auto;
652-
param _compat_dml12_inline auto;
653-
param _compat_dml12_not auto;
654-
param _compat_dml12_goto auto;
655-
param _compat_dml12_misc auto;
656-
param _compat_dml12_int auto;
657-
param _compat_experimental_vect auto;
658-
param _compat_warning_statement auto;
638+
// legacy aliases
639+
param _compat_broken_unused_types
640+
= !_breaking_change_dml_forbid_broken_unused_types;
641+
param _compat_broken_conditional_is
642+
= !_breaking_change_dml_forbid_broken_conditional_is;
643+
param _compat_port_proxy_ifaces
644+
= !_breaking_change_dml_remove_port_proxy_ifaces;
645+
param _compat_port_proxy_attrs
646+
= !_breaking_change_dml_remove_port_proxy_attrs;
647+
param _compat_function_in_extern_struct
648+
= !_breaking_change_dml_forbid_function_in_extern_struct;
649+
param _compat_optional_version_statement
650+
= !_breaking_change_dml_require_version_statement;
651+
param _compat_io_memory = !_breaking_change_dml_transaction_by_default;
652+
param _compat_port_obj_param = !_breaking_change_dml_remove_port_obj_param;
653+
param _compat_shared_logs_on_device
654+
= !_breaking_change_dml_shared_logs_locally;
655+
param _compat_suppress_WLOGMIXUP = !_breaking_change_dml_enable_WLOGMIXUP;
656+
param _compat_legacy_attributes
657+
= !_breaking_change_dml_remove_legacy_attributes;
658+
param _compat_lenient_typechecking
659+
= !_breaking_change_dml_strict_typechecking;
660+
param _compat_no_method_index_asserts
661+
= !_breaking_change_dml_range_check_method_indices;
662+
param _compat_meaningless_log_levels
663+
= !_breaking_change_dml_restrict_log_levels;
664+
param _compat_dml12_inline
665+
= !_breaking_change_dml12_disable_inline_constants;
666+
param _compat_dml12_not = !_breaking_change_dml12_not_typecheck;
667+
param _compat_dml12_misc = !_breaking_change_dml12_remove_misc_quirks;
668+
param _compat_dml12_goto = !_breaking_change_dml12_remove_goto;
669+
param _compat_dml12_int = !_breaking_change_dml12_fix_int_quirks;
670+
param _compat_experimental_vect
671+
= !_breaking_change_dml_forbid_experimental_vect;
672+
param _compat_warning_statement
673+
= !_breaking_change_dml_forbid_warning_statement;
674+
675+
param _breaking_change_dml_forbid_broken_unused_types auto;
676+
param _breaking_change_dml_forbid_broken_conditional_is auto;
677+
param _breaking_change_dml_remove_port_proxy_ifaces auto;
678+
param _breaking_change_dml_remove_port_proxy_attrs auto;
679+
param _breaking_change_dml_forbid_function_in_extern_struct auto;
680+
param _breaking_change_dml_require_version_statement auto;
681+
param _breaking_change_dml_transaction_by_default auto;
682+
param _breaking_change_dml_remove_port_obj_param auto;
683+
param _breaking_change_dml_shared_logs_locally auto;
684+
param _breaking_change_dml_enable_WLOGMIXUP auto;
685+
param _breaking_change_dml_remove_legacy_attributes auto;
686+
param _breaking_change_dml_strict_typechecking auto;
687+
param _breaking_change_dml_range_check_method_indices auto;
688+
param _breaking_change_dml_restrict_log_levels auto;
689+
param _breaking_change_dml12_disable_inline_constants auto;
690+
param _breaking_change_dml12_not_typecheck auto;
691+
param _breaking_change_dml12_remove_misc_quirks auto;
692+
param _breaking_change_dml12_remove_goto auto;
693+
param _breaking_change_dml12_fix_int_quirks auto;
694+
param _breaking_change_dml_forbid_experimental_vect auto;
695+
param _breaking_change_dml_forbid_warning_statement auto;
659696

660697
// automatic parameters
661698
param obj auto;

py/dml/breaking_changes.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ class BreakingChange(abc.ABC):
3030
def tag(self) -> str:
3131
return self.__class__.__name__.replace('_', '-')
3232

33+
def ident(self) -> str:
34+
return self.tag().replace('-', '_')
35+
3336
@property
3437
def enabled(self):
3538
# `None` happens in unit tests; assume everything is enabled

py/dml/structure.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,9 +1143,9 @@ def make_autoparams(obj, index_var_asts):
11431143
mkBoolConstant(site, site.bitorder() == 'be'))
11441144
autoparams['simics_api_version'] = SimpleParamExpr(
11451145
mkStringConstant(site, dml.globals.api_version.str))
1146-
for tag in compat.compat_features:
1147-
autoparams[f'_compat_{tag}'] = SimpleParamExpr(
1148-
mkBoolConstant(site, tag in dml.globals.enabled_compat))
1146+
for change in compat.changes.values():
1147+
autoparams[f'_breaking_change_{change.ident()}'] = SimpleParamExpr(
1148+
mkBoolConstant(site, change.enabled))
11491149
dml.globals.device = obj
11501150

11511151
elif obj.objtype == 'bank':
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
© 2025 Intel Corporation
3+
SPDX-License-Identifier: MPL-2.0
4+
*/
5+
6+
// 1.2 because some breaking changes are auto-enabled in DML 1.4
7+
dml 1.2;
8+
9+
device test;
10+
11+
/// COMPILE-ONLY
12+
/// API-VERSION 5
13+
/// DMLC-FLAG --breaking-change=dml-remove-port-obj-param,dml12-not-typecheck
14+
15+
import "breaking_changes.dml";
16+
17+
parameter enabled_5 = true;
18+
parameter enabled_6 = false;
19+
parameter enabled_7 = false;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
© 2025 Intel Corporation
3+
SPDX-License-Identifier: MPL-2.0
4+
*/
5+
6+
dml 1.4;
7+
8+
device test;
9+
10+
/// COMPILE-ONLY
11+
/// API-VERSION 6
12+
/// DMLC-FLAG --breaking-change=dml-transaction-by-default,dml-shared-logs-locally,dml-enable-WLOGMIXUP,dml12-disable-inline-constants,dml12-remove-misc-quirks,dml12-remove-goto,dml12-fix-int-quirks
13+
14+
import "breaking_changes.dml";
15+
16+
param enabled_5 = true;
17+
param enabled_6 = true;
18+
param enabled_7 = false;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
© 2025 Intel Corporation
3+
SPDX-License-Identifier: MPL-2.0
4+
*/
5+
6+
dml 1.4;
7+
8+
device test;
9+
10+
/// COMPILE-ONLY
11+
/// API-VERSION 7
12+
/// DMLC-FLAG --breaking-change=dml-forbid-broken-unused-types,dml-forbid-broken-conditional-is,dml-remove-port-proxy-ifaces,dml-remove-port-proxy-attrs,dml-forbid-function-in-extern-struct,dml-require-version-statement,dml-remove-legacy-attributes,dml-strict-typechecking,dml-range-check-method-indices,dml-restrict-log-levels,dml-forbid-experimental-vect,dml-forbid-warning-statement
13+
14+
import "breaking_changes.dml";
15+
16+
parameter enabled_5 = true;
17+
parameter enabled_6 = true;
18+
parameter enabled_7 = true;
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
© 2025 Intel Corporation
3+
SPDX-License-Identifier: MPL-2.0
4+
*/
5+
6+
dml 1.4;
7+
8+
// Test that the legacy compat params still work: For each API,
9+
// we partition the set of compat features for that version
10+
// in two sets A and B, each set explicitly disabled by one
11+
// of the tests of that API.
12+
13+
param enabled_5;
14+
param enabled_6;
15+
param enabled_7;
16+
17+
#if (_breaking_change_dml_remove_port_obj_param != enabled_5
18+
|| _breaking_change_dml12_not_typecheck != enabled_5) {
19+
error;
20+
}
21+
22+
#if (_breaking_change_dml_transaction_by_default != enabled_6
23+
|| _breaking_change_dml_shared_logs_locally != enabled_6
24+
|| _breaking_change_dml_enable_WLOGMIXUP != enabled_6
25+
|| _breaking_change_dml12_disable_inline_constants != enabled_6
26+
|| _breaking_change_dml12_remove_misc_quirks != enabled_6
27+
|| _breaking_change_dml12_remove_goto != enabled_6
28+
|| _breaking_change_dml12_fix_int_quirks != enabled_6) {
29+
error;
30+
}
31+
32+
#if (_breaking_change_dml_forbid_broken_unused_types != enabled_7
33+
|| _breaking_change_dml_forbid_broken_conditional_is != enabled_7
34+
|| _breaking_change_dml_remove_port_proxy_ifaces != enabled_7
35+
|| _breaking_change_dml_remove_port_proxy_attrs != enabled_7
36+
|| _breaking_change_dml_forbid_function_in_extern_struct != enabled_7
37+
|| _breaking_change_dml_require_version_statement != enabled_7
38+
|| _breaking_change_dml_remove_legacy_attributes != enabled_7
39+
|| _breaking_change_dml_strict_typechecking != enabled_7
40+
|| _breaking_change_dml_range_check_method_indices != enabled_7
41+
|| _breaking_change_dml_restrict_log_levels != enabled_7
42+
|| _breaking_change_dml_forbid_experimental_vect != enabled_7
43+
|| _breaking_change_dml_forbid_warning_statement != enabled_7) {
44+
error;
45+
}

0 commit comments

Comments
 (0)