From 37be5954070ebf2a6ba71a5a1f254ba598a12d5b Mon Sep 17 00:00:00 2001 From: Erik Carstensen Date: Tue, 12 Sep 2023 14:34:15 +0200 Subject: [PATCH] Add PORT_PROXY_ATTRS deprecation --- lib/1.2/dml-builtins.dml | 1 + lib/1.4/dml-builtins.dml | 1 + py/dml/deprecations.py | 15 +++++++++++++++ py/dml/structure.py | 4 +++- .../legacy/T_port_proxy_attrs_disabled.dml | 16 ++++++++++++++++ .../1.4/legacy/T_port_proxy_attrs_enabled.dml | 15 +++++++++++++++ test/1.4/legacy/port_proxy_attrs.dml | 19 +++++++++++++++++++ 7 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 test/1.4/legacy/T_port_proxy_attrs_disabled.dml create mode 100644 test/1.4/legacy/T_port_proxy_attrs_enabled.dml create mode 100644 test/1.4/legacy/port_proxy_attrs.dml diff --git a/lib/1.2/dml-builtins.dml b/lib/1.2/dml-builtins.dml index 8e3fb2b94..c53fd1c9f 100644 --- a/lib/1.2/dml-builtins.dml +++ b/lib/1.2/dml-builtins.dml @@ -207,6 +207,7 @@ template device { parameter simics_api_version auto; parameter _deprecate_port_proxy_ifaces auto; + parameter _deprecate_port_proxy_attrs auto; // automatic parameters parameter obj auto; diff --git a/lib/1.4/dml-builtins.dml b/lib/1.4/dml-builtins.dml index 851302823..26a74952d 100644 --- a/lib/1.4/dml-builtins.dml +++ b/lib/1.4/dml-builtins.dml @@ -544,6 +544,7 @@ template device { param _api_6_or_older = simics_api_version == "6" || _api_5_or_older; param _deprecate_port_proxy_ifaces auto; + param _deprecate_port_proxy_attrs auto; // automatic parameters param obj auto; diff --git a/py/dml/deprecations.py b/py/dml/deprecations.py index 6e220ce01..960d5a392 100644 --- a/py/dml/deprecations.py +++ b/py/dml/deprecations.py @@ -40,3 +40,18 @@ class port_proxy_ifaces(DeprecatedFeature): ''' short = "Don't generate proxy port interfaces for banks and ports" last_api_version = "6" + + +@deprecation +class port_proxy_attrs(DeprecatedFeature): + '''In Simics 5, configuration attributes for `connect`, + `attribute` and `register` objects inside banks and ports were + register on the device object, named like + bankname_attrname. Such proxy + attributes are only created When this deprecation is not enabled. + Proxy attributes are not created for all banks and ports, in the + same manner as documented in the `port_proxy_ifaces` deprecation. + ''' + short = ("Don't generate top-level proxy attributes" + + " for attributes in banks and ports") + last_api_version = "6" diff --git a/py/dml/structure.py b/py/dml/structure.py index ee6a25464..bd12cd8e2 100644 --- a/py/dml/structure.py +++ b/py/dml/structure.py @@ -2605,7 +2605,9 @@ def need_port_proxy_attrs(port): assert port.objtype in {'port', 'bank', 'subdevice'} return (port.objtype in {'port', 'bank'} and port.dimensions <= 1 - and port.parent is dml.globals.device) + and port.parent is dml.globals.device + and (deprecations.port_proxy_attrs + not in dml.globals.enabled_deprecations)) class ConfAttrParentObjectProxyInfoParamExpr(objects.ParamExpr): '''The _parent_obj_proxy_info parameter of a attribute, register, or diff --git a/test/1.4/legacy/T_port_proxy_attrs_disabled.dml b/test/1.4/legacy/T_port_proxy_attrs_disabled.dml new file mode 100644 index 000000000..cb7624b9c --- /dev/null +++ b/test/1.4/legacy/T_port_proxy_attrs_disabled.dml @@ -0,0 +1,16 @@ +/* + © 2023 Intel Corporation + SPDX-License-Identifier: MPL-2.0 +*/ +dml 1.4; + +device test; + +/// DMLC-FLAG --simics-api=6 +/// DMLC-FLAG --deprecate=port_proxy_attrs + +import "port_proxy_attrs.dml"; + +method init() { + test(true); +} diff --git a/test/1.4/legacy/T_port_proxy_attrs_enabled.dml b/test/1.4/legacy/T_port_proxy_attrs_enabled.dml new file mode 100644 index 000000000..6a95f751d --- /dev/null +++ b/test/1.4/legacy/T_port_proxy_attrs_enabled.dml @@ -0,0 +1,15 @@ +/* + © 2023 Intel Corporation + SPDX-License-Identifier: MPL-2.0 +*/ +dml 1.4; + +device test; + +/// DMLC-FLAG --simics-api=6 + +import "port_proxy_attrs.dml"; + +method init() { + test(false); +} diff --git a/test/1.4/legacy/port_proxy_attrs.dml b/test/1.4/legacy/port_proxy_attrs.dml new file mode 100644 index 000000000..34cfd894b --- /dev/null +++ b/test/1.4/legacy/port_proxy_attrs.dml @@ -0,0 +1,19 @@ +/* + © 2023 Intel Corporation + SPDX-License-Identifier: MPL-2.0 +*/ +dml 1.4; + +import "simics/simulator/conf-object.dml"; + +saved bool raised = false; + +port p { + attribute a is uint64_attr; +} + +method test(bool proxies_deprecated) { + assert _deprecate_port_proxy_attrs == proxies_deprecated; + assert SIM_class_has_attribute(SIM_object_class(dev.obj), "p_a") + == !proxies_deprecated; +}