Skip to content

Commit e65adf7

Browse files
committed
Deprecate the _warning statement
1 parent 308479b commit e65adf7

10 files changed

+60
-3
lines changed

RELEASENOTES.md

+3
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,6 @@
200200
syntax is only permitted when this feature is enabled. his feature will be
201201
disabled in Simics API versions \> 7, where all uses of `vect` instead require
202202
explicit `provisional` declarations.
203+
- `note 6` The rarely used `_warning` statement has been deprecated, through
204+
the introduction of a new compatibility feature `warning_statement`.
205+
Warning statements will be illegal when Simics API 8 or newer is used.

dmlast.py

+3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ def create_dmlasts(dmlc_path, dmlast_path, dml_path, depfile):
88
sys.path.append(str(dmlc_path))
99
from dml.toplevel import produce_dmlast
1010
from dml.logging import ignore_warning
11+
import dml.globals
12+
from dml import compat
1113

1214
ignore_warning('WEXPERIMENTAL')
15+
dml.globals.enabled_compat.add(compat.warning_statement)
1316
dml_files_abs = list(dml_path.rglob('*.dml'))
1417
dml_files = [p.relative_to(dml_path) for p in dml_files_abs]
1518
assert dml_files

lib/1.2/dml-builtins.dml

+1
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ template device {
224224
parameter _compat_dml12_misc auto;
225225
parameter _compat_dml12_int auto;
226226
parameter _compat_c_vect_without_provisional auto;
227+
parameter _compat_warning_statement auto;
227228

228229
// automatic parameters
229230
parameter obj auto;

lib/1.2/utility.dml

+11-3
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,12 @@ template write_only {
169169
log spec_viol, log_level, Register_Read:
170170
"Read from write-only register %s (returning 0).", $qname;
171171
log_level = 2;
172-
} else {
172+
} else if ($dev._compat_warning_statement) {
173173
_warning "The write_only template only makes sense on registers."
174174
+ " For fields, use read_zero instead.";
175+
} else {
176+
error "The write_only template only makes sense on registers."
177+
+ " For fields, use read_zero instead.";
175178
}
176179
value = 0;
177180
}
@@ -541,8 +544,13 @@ template _unimpl_base_write_warn {
541544
}
542545
$this = value;
543546
if (defined ($reg.limitations)
544-
&& $reg.limitations == "Not implemented.")
545-
_warning "unimplemented template used in both field and register";
547+
&& $reg.limitations == "Not implemented.") {
548+
if ($dev._compat_warning_statement) {
549+
_warning "unimplemented template used in both field and register";
550+
} else {
551+
error "unimplemented template used in both field and register";
552+
}
553+
}
546554
}
547555
}
548556
}

lib/1.4/dml-builtins.dml

+1
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,7 @@ template device {
626626
param _compat_dml12_misc auto;
627627
param _compat_dml12_int auto;
628628
param _compat_c_vect_without_provisional auto;
629+
param _compat_warning_statement auto;
629630

630631
// automatic parameters
631632
param obj auto;

py/dml/compat.py

+9
Original file line numberDiff line numberDiff line change
@@ -392,3 +392,12 @@ class c_vect_without_provisional(CompatFeature):
392392
'''
393393
short = "Permit vect syntax without 'provisional c_vect'"
394394
last_api_version = api_7
395+
396+
397+
@feature
398+
class warning_statement(CompatFeature):
399+
'''This compatibility feature enables the `_warning` statement.
400+
This turned out to not be very useful, so in Simics API 8 and
401+
newer the feature is no longer allowed.'''
402+
short = "Allow the `_warning` statement"
403+
last_api_version = api_7

py/dml/dmlparse.py

+2
Original file line numberDiff line numberDiff line change
@@ -2498,6 +2498,8 @@ def warning_statement(t):
24982498
@prod
24992499
def warning_stmt(t):
25002500
'warning_stmt : _WARNING bracketed_string_literal SEMI'
2501+
if compat.warning_statement not in dml.globals.enabled_compat:
2502+
raise ESYNTAX(site(t), '_warning', 'deprecated _warning statement')
25012503
report(WEXPERIMENTAL(site(t), "_warning statement"))
25022504
t[0] = ast.warning(site(t), t[2])
25032505

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
© 2024 Intel Corporation
3+
SPDX-License-Identifier: MPL-2.0
4+
*/
5+
dml 1.4;
6+
device test;
7+
8+
/// DMLC-FLAG --simics-api=7
9+
/// DMLC-FLAG --no-compat=warning_statement
10+
11+
method m() {
12+
/// ERROR ESYNTAX
13+
_warning "foo";
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
© 2024 Intel Corporation
3+
SPDX-License-Identifier: MPL-2.0
4+
*/
5+
dml 1.4;
6+
device test;
7+
8+
/// COMPILE-ONLY
9+
/// DMLC-FLAG --simics-api=7
10+
11+
method m() {
12+
// method is dead, so no WWRNSTMT
13+
/// WARNING WEXPERIMENTAL
14+
_warning "foo";
15+
}

test/tests.py

+1
Original file line numberDiff line numberDiff line change
@@ -1452,6 +1452,7 @@ def test(self):
14521452
('utility.dml', None, 'PRENAME_TEMPLATE'),
14531453
('utility.dml', None, 'PABSTRACT_TEMPLATE'),
14541454
('utility.dml', None, 'PHASH'),
1455+
('utility.dml', None, 'PHASHELSE'),
14551456
('utility.dml', None, 'PIFAND'),
14561457
('utility.dml', None, 'PANDOR'),
14571458
('utility.dml', None, 'PCHANGE_INARGS'),

0 commit comments

Comments
 (0)