-
Notifications
You must be signed in to change notification settings - Fork 48
Create provisional and compat features around the vect type #328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3d817de
dbc0d50
66e27a7
3835a44
fbfceab
0ee40d8
97cff78
6ca7575
4d17335
8e97202
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
© 2024 Intel Corporation | ||
SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
|
||
dml 1.4; | ||
|
||
device test; | ||
|
||
/// DMLC-FLAG --simics-api=7 | ||
/// DMLC-FLAG --no-compat=experimental_vect | ||
/// ERROR EOLDVECT | ||
typedef int vect x; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
/* | ||
© 2021 Intel Corporation | ||
© 2024 Intel Corporation | ||
SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
dml 1.4; | ||
|
||
/// COMPILE-ONLY | ||
dml 1.4; | ||
|
||
device test; | ||
|
||
/// COMPILE-ONLY | ||
/// DMLC-FLAG --simics-api=7 | ||
/// WARNING WEXPERIMENTAL | ||
session int vect x; | ||
typedef int vect x; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<!-- | ||
© 2024 Intel Corporation | ||
SPDX-License-Identifier: MPL-2.0 | ||
--> | ||
|
||
# Managing deprecated language features | ||
|
||
As the DML language evolves, we sometimes need to change the language in | ||
incompatible ways, which requires DML users to migrate their code. This | ||
appendix describes the mechanisms we provide to make this migration process | ||
smooth for users with large DML code bases. | ||
|
||
In DML, deprecations can come in many forms. Deprecations in the form of | ||
removed or renamed symbols in libraries are rather easy to manage, since they | ||
give clear compile errors that often are straightforward to fix. A slightly | ||
harder type of deprecation is when some language construct or API function | ||
adjusts its semantics; this can make the model behave differently without | ||
signalling error messages. A third kind of deprecation is when DML changes how | ||
compiled models appear in Simics, typically to adjust changes in the Simics | ||
API. Such changes add another dimension because they typically affect the | ||
end-users of the DML models, rather than the authors of the models. Thus, as an | ||
author of a model you may need to synchronize your migration of such features | ||
with your end-users, to ease their transition to a new major version. | ||
|
||
## Deprecation mechanisms | ||
|
||
The simplest deprecation mechanism is Simics API versions: Each deprecated DML | ||
feature is associated with a Simics API version, and each Simics version | ||
supports a number of such API versions. Features reach end-of-life when moving | ||
to a new Simics major version, the features belonging to a previous Simics API | ||
version are dropped. Since Simics is currently the primary distribution channel | ||
for DML, this deprecation scheme is used for DML features as well. | ||
|
||
This scheme allows users with a large code base to smoothly migrate from one | ||
Simics major version, N, to the next, N+1: | ||
* First, while still using version N, make sure all Simics modules are updated | ||
to use API version N. Modules can be migrated one by one. | ||
* Second, update the Simics version to N+1. This should normally have no | ||
effect on DML, but may come with other challenges. | ||
* Third, update modules to API N+1, one by one. Simics version N+1 will always | ||
offers full support for API N, so there is no rush to update, but changing | ||
the API version early makes sure deprecated features are not introduced in | ||
new code. | ||
|
||
In addition to the API version, DML offers some compiler flags for selectively | ||
disabling deprecated features that are normally part of the used API. This has | ||
some uses, in particular: | ||
* During migration to a new API version, disabling one deprecated feature at a | ||
time can allow a smoother, more gradual, migration. | ||
* If a legacy feature is still fully supported in the latest API version, then | ||
it cannot be disabled by selecting an API version, so selectively disabling | ||
it is the only way to turn it off. There are reasons to do this, e.g.: | ||
* Disabling a feature before it is deprecated guarantees that it is not | ||
relied upon in new code, which eases later migration. | ||
* Avoiding a feature that has a newer replacement makes the code base | ||
cleaner and more consistent. | ||
* Some legacy features can also bloat models, by exposing features in a | ||
redundant manner. This can also have a negative impact on performance. | ||
|
||
## Controlling deprecation on the DML command-line | ||
DMLC provides a command-line flag `--api-version` to specify the API version to | ||
be used for a model. When building with the standard Simics build system, this | ||
is controlled by the `SIMICS_API_VERSION` variable in `make`, or the | ||
`SIMICS_API`/`MODULE_SIMICS_API` variable in `CMake`. | ||
|
||
DMLC also provides the <code>--no-compat=_tag_</code> flag, which disables the | ||
feature represented by _`tag`_. The available tags are listed in the next | ||
section. The tag also controls the name of a global boolean parameter that the | ||
DML program may use to check whether the feature is available. The parameter's | ||
name is the tag name preceded by `_compat_`. | ||
|
||
## List of deprecated features |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<!-- | ||
© 2024 Intel Corporation | ||
SPDX-License-Identifier: MPL-2.0 | ||
--> | ||
|
||
# Provisional language features | ||
|
||
Sometimes, we may choose to extend the DML compiler with a feature before it is | ||
ready to be fully incorporated into the language. This can happen for different | ||
reasons, e.g. if the design is not fully evaluated or if the feature is | ||
backward incompatible. Currently, all provisional features are enabled on a | ||
per-file basis, by adding <code>provisional <em>feature_name</em>, | ||
<em>other_feature_name</em>;</code> just after the `dml 1.2;` statement. | ||
|
||
Provisional features can come in two flavours: | ||
|
||
* _Stable_ provisional features have a proven design and are | ||
expected to remain pretty stable over time. Details in semantics may | ||
still change between versions, but if we decide to make a | ||
significant incompatible change to a supported provisional, then we | ||
will create a second version of the provisional, under a new name, | ||
and keep both versions in parallel for some time. It can make sense | ||
to use supported provisional features in production code. | ||
|
||
* _Unstable_ provisional features are expected to undergo significant | ||
incompatible changes over time, and are generally exposed to allow a | ||
dedicated team of modelers to evaluate an early design. It can be used | ||
to play around with, but should not be used in production code without | ||
first communicating with the DML team. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
*/ | ||
|
||
dml 1.2; | ||
provisional simics_util_vect; | ||
|
||
template _reg_or_field { | ||
parameter is_register = ($objtype == "register"); | ||
|
@@ -169,9 +170,16 @@ template write_only { | |
log spec_viol, log_level, Register_Read: | ||
"Read from write-only register %s (returning 0).", $qname; | ||
log_level = 2; | ||
} else { | ||
} else if ($dev._compat_warning_statement) { | ||
// note: this can be parsed because the .dmlast is generated with | ||
// warning_statement compatibility enabled. We'll want to remove | ||
// this compatibility support When API 7 goes EOL, but luckily we'll | ||
// also be able to remove this statement at that time. | ||
_warning "The write_only template only makes sense on registers." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't get why this works. Why don't you get There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Haha, it's because we suppress the warning while building dml-builtins.dmlast. After that the parser will not look at dml-builtins.dml again. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh good lord. So you're saying this code is only meaningful because we can leverage dmlast. Let me see if I get this right:
Is that correct? That's...
would work in general, when the fact is it only works due to extremely niche circumstances. Worse yet, they may extrapolate to expect that pattern would work for other syntactical features controlled by a compatibility feature. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You must at the very least add a comment about this. This should be treated as a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, I can add a comment.
If you are in search of inspiration, then visiting to DML 1.2 code is strongly discouraged. Not good for your health. (I would also have been concerned about the hackiness of this code if this wasn't dying code) |
||
+ " For fields, use read_zero instead."; | ||
} else { | ||
error "The write_only template only makes sense on registers." | ||
+ " For fields, use read_zero instead."; | ||
} | ||
value = 0; | ||
} | ||
|
@@ -541,8 +549,18 @@ template _unimpl_base_write_warn { | |
} | ||
$this = value; | ||
if (defined ($reg.limitations) | ||
&& $reg.limitations == "Not implemented.") | ||
_warning "unimplemented template used in both field and register"; | ||
&& $reg.limitations == "Not implemented.") { | ||
if ($dev._compat_warning_statement) { | ||
// note: this can be parsed because the .dmlast is | ||
// generated with warning_statement compatibility | ||
// enabled. We'll want to remove this compatibility support | ||
// When API 7 goes EOL, but luckily we'll also be able to | ||
// remove this statement at that time. | ||
_warning "unimplemented template used in both field and register"; | ||
mandolaerik marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} else { | ||
error "unimplemented template used in both field and register"; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.