Skip to content

Commit 769139e

Browse files
committed
Change --deprecate to --no-compat
This also included some renames and change in polarities; in particular, all deprecated features are now disabled by default, as required by some unit tests.
1 parent eb7b059 commit 769139e

23 files changed

+123
-128
lines changed

MODULEINFO

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ Make: dmlc
4343
$(HOST)/bin/dml/python/dml/c_backend.py
4444
$(HOST)/bin/dml/python/dml/g_backend.py
4545
$(HOST)/bin/dml/python/dml/codegen.py
46+
$(HOST)/bin/dml/python/dml/compat.py
4647
$(HOST)/bin/dml/python/dml/crep.py
4748
$(HOST)/bin/dml/python/dml/ctree.py
48-
$(HOST)/bin/dml/python/dml/deprecations.py
4949
$(HOST)/bin/dml/python/dml/dmllex.py
5050
$(HOST)/bin/dml/python/dml/dmllex12.py
5151
$(HOST)/bin/dml/python/dml/dmllex14.py

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ PYFILES := dml/__init__.py \
1313
dml/c_backend.py \
1414
dml/g_backend.py \
1515
dml/codegen.py \
16+
dml/compat.py \
1617
dml/crep.py \
1718
dml/ctree.py \
1819
dml/template.py \

deprecations_to_md.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
[path_to_dml, header, outfile] = sys.argv[1:]
77
sys.path.append(path_to_dml)
88

9-
from dml.deprecations import deprecations
9+
from dml.compat import features
1010
from dml.env import api_versions
1111

1212
api_map = {v: k for (k, v) in api_versions().items()}
1313
with open(outfile, 'w') as f:
1414
f.write(Path(header).read_text())
15-
for (ver, deps) in deprecations.items():
15+
for (ver, deps) in features.items():
1616
if deps and ver in api_map:
1717
f.write(
1818
f"### Features available up to --simics-api={api_map[ver]}\n")

doc/1.4/deprecations-header.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ some uses, in particular:
6161
DMLC provides a command-line flag `--api-version` to specify the API version to
6262
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`.
6363

64-
DMLC also provides the <code>--deprecate=_tag_</code> flag, which disables the
64+
DMLC also provides the <code>--no-compat=_tag_</code> flag, which disables the
6565
feature represented by _`tag`_. The available tags are listed in the next
6666
section. The tag also controls the name of a global boolean parameter that the
6767
DML program may use to check whether the feature is available. The parameter's
68-
name is the tag name preceded by `_deprecate_`.
68+
name is the tag name preceded by `_compat_`.
6969

7070
## List of deprecated features

lib/1.2/dml-builtins.dml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ template device {
206206

207207
parameter simics_api_version auto;
208208

209-
parameter _deprecate_port_proxy_ifaces auto;
210-
parameter _deprecate_port_proxy_attrs auto;
209+
parameter _compat_port_proxy_ifaces auto;
210+
parameter _compat_port_proxy_attrs auto;
211211

212212
// automatic parameters
213213
parameter obj auto;

lib/1.4/dml-builtins.dml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,8 +543,8 @@ template device {
543543
|| simics_api_version == "4.8";
544544
param _api_6_or_older = simics_api_version == "6" || _api_5_or_older;
545545

546-
param _deprecate_port_proxy_ifaces auto;
547-
param _deprecate_port_proxy_attrs auto;
546+
param _compat_port_proxy_ifaces auto;
547+
param _compat_port_proxy_attrs auto;
548548

549549
// automatic parameters
550550
param obj auto;

py/dml/c_backend.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from pathlib import Path
1414

1515
from . import objects, logging, crep, output, ctree, serialize, structure
16-
from . import traits, deprecations
16+
from . import traits, compat
1717
import dml.globals
1818
from .structure import get_attr_name, port_class_ident, need_port_proxy_attrs
1919
from .logging import *
@@ -888,8 +888,7 @@ def generate_implement(code, device, impl):
888888
# descendants of the device object
889889
if (port.parent is dml.globals.device
890890
and port.objtype in {'port', 'bank'}
891-
and (deprecations.port_proxy_ifaces
892-
not in dml.globals.enabled_deprecations)):
891+
and compat.port_proxy_ifaces in dml.globals.enabled_compat):
893892
if port.local_dimensions() == 0:
894893
code.out("static const %s = %s;\n" % (
895894
ifacetype.declaration('port_iface'),

py/dml/codegen.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import math
1212

1313
from . import objects, crep, ctree, ast, int_register, logging, serialize
14-
from . import dmlparse, output, deprecations
14+
from . import dmlparse, output, compat
1515
from .logging import *
1616
from .expr import *
1717
from .ctree import *
@@ -1079,7 +1079,7 @@ def subast_has_dollar(expr_ast):
10791079
@expression_dispatcher
10801080
def expr_unop(tree, location, scope):
10811081
[op, rh_ast] = tree.args
1082-
if (deprecations.dml12_misc not in dml.globals.enabled_deprecations
1082+
if (compat.dml12_misc in dml.globals.enabled_compat
10831083
and op == 'sizeof' and rh_ast.kind == 'variable_dml12'):
10841084
var = rh_ast.args[0]
10851085
if var in typedefs and scope.lookup(var) is None:
@@ -1120,7 +1120,7 @@ def expr_unop(tree, location, scope):
11201120
return ctree.AddressOfMethod(tree.site, func)
11211121
raise rh.exc()
11221122
if op == '!':
1123-
if deprecations.dml12_not not in dml.globals.enabled_deprecations:
1123+
if compat.dml12_not in dml.globals.enabled_compat:
11241124
t = rh.ctype()
11251125
if isinstance(safe_realtype(t), TInt) and subast_has_dollar(rh_ast):
11261126
# A previous bug caused DMLC to permit expressions on
@@ -1142,7 +1142,7 @@ def expr_unop(tree, location, scope):
11421142
elif op == 'post++': return mkPostInc(tree.site, rh)
11431143
elif op == 'post--': return mkPostDec(tree.site, rh)
11441144
elif op == 'sizeof':
1145-
if (deprecations.dml12_misc in dml.globals.enabled_deprecations
1145+
if (compat.dml12_misc not in dml.globals.enabled_compat
11461146
and not isinstance(rh, ctree.LValue)):
11471147
raise ERVAL(rh.site, 'sizeof')
11481148
return codegen_sizeof(tree.site, rh)
@@ -1319,7 +1319,7 @@ def expr_cast(tree, location, scope):
13191319
for (site, _) in struct_defs:
13201320
report(EANONSTRUCT(site, "'cast' expression"))
13211321

1322-
if (deprecations.dml12_misc not in dml.globals.enabled_deprecations
1322+
if (compat.dml12_misc in dml.globals.enabled_compat
13231323
and isinstance(expr, InterfaceMethodRef)):
13241324
# Workaround for SIMICS-9868
13251325
return mkLit(tree.site, "%s->%s" % (
@@ -1525,7 +1525,7 @@ def eval_type(asttype, site, location, scope, extern=False, typename=None,
15251525
etype = TInt(width, False, members)
15261526
elif tag == 'typeof':
15271527
expr = codegen_expression_maybe_nonvalue(info, location, scope)
1528-
if (deprecations.dml12_misc in dml.globals.enabled_deprecations
1528+
if (compat.dml12_misc not in dml.globals.enabled_compat
15291529
and not isinstance(expr, ctree.LValue)
15301530
# for compatibility with dml-builtins, using 1.2
15311531
and not isinstance(expr, ctree.RegisterWithFields)):
@@ -1981,7 +1981,7 @@ def stmt_local(stmt, location, scope):
19811981
def convert_decl(decl_ast):
19821982
(name, asttype) = decl_ast.args
19831983
if (dml.globals.dml_version == (1, 2)
1984-
and deprecations.dml12_misc in dml.globals.enabled_deprecations):
1984+
and compat.dml12_misc not in dml.globals.enabled_compat):
19851985
check_varname(stmt.site, name)
19861986
(struct_decls, etype) = eval_type(asttype, stmt.site, location, scope)
19871987
stmts.extend(mkStructDefinition(site, t) for (site, t) in struct_decls)
@@ -2545,7 +2545,7 @@ def stmt_assert(stmt, location, scope):
25452545
@statement_dispatcher
25462546
def stmt_goto(stmt, location, scope):
25472547
[label] = stmt.args
2548-
if deprecations.dml12_misc in dml.globals.enabled_deprecations:
2548+
if compat.dml12_misc not in dml.globals.enabled_compat:
25492549
report(ESYNTAX(stmt.site, 'goto', 'goto statement not allowed'))
25502550
return [mkGoto(stmt.site, label)]
25512551

@@ -2998,7 +2998,7 @@ def stmt_select(stmt, location, scope):
29982998
if_chain = mkIf(cond.site, cond, stmt, if_chain)
29992999
return [if_chain]
30003000
raise lst.exc()
3001-
elif (deprecations.dml12_misc not in dml.globals.enabled_deprecations
3001+
elif (compat.dml12_misc in dml.globals.enabled_compat
30023002
and isinstance(lst.ctype(), TVector)):
30033003
itervar = lookup_var(stmt.site, scope, itername)
30043004
if not itervar:
@@ -3272,19 +3272,19 @@ def common_inline(site, method, indices, inargs, outargs):
32723272

32733273
if dml.globals.debuggable:
32743274
if method.fully_typed and (
3275-
deprecations.dml12_inline in dml.globals.enabled_deprecations
3275+
compat.dml12_inline not in dml.globals.enabled_compat
32763276
or all(not arg.constant for arg in inargs)):
32773277
# call method instead of inlining it
32783278
func = method_instance(method)
32793279
else:
32803280
# create a specialized method instance based on parameter
32813281
# types, and call that
3282-
intypes = tuple(arg if ((ptype is None or deprecations.dml12_inline
3283-
not in dml.globals.enabled_deprecations)
3284-
and (arg.constant or undefined(arg)))
3285-
else methfunc_param(ptype, arg)
3286-
for ((pname, ptype), arg)
3287-
in zip(method.inp, inargs))
3282+
intypes = tuple(
3283+
arg if ((ptype is None
3284+
or compat.dml12_inline in dml.globals.enabled_compat)
3285+
and (arg.constant or undefined(arg)))
3286+
else methfunc_param(ptype, arg)
3287+
for ((pname, ptype), arg) in zip(method.inp, inargs))
32883288
outtypes = tuple(methfunc_param(ptype, arg)
32893289
for ((pname, ptype), arg)
32903290
in zip(method.outp, outargs))
@@ -3504,9 +3504,9 @@ def codegen_inline(site, meth_node, indices, inargs, outargs,
35043504

35053505
if inhibit_copyin or undefined(arg):
35063506
param_scope.add(ExpressionSymbol(parmname, arg, arg.site))
3507-
elif arg.constant and (parmtype is None
3508-
or deprecations.dml12_inline
3509-
not in dml.globals.enabled_deprecations):
3507+
elif arg.constant and (
3508+
parmtype is None
3509+
or compat.dml12_inline in dml.globals.enabled_compat):
35103510
# Constants must be passed directly to
35113511
# provide constant folding. Other values are stored in a
35123512
# local variable to improve type checking and variable
@@ -3721,7 +3721,7 @@ def codegen_method_func(func):
37213721
inline_scope = MethodParamScope(global_scope)
37223722
for (name, e) in func.inp:
37233723
if dml.globals.dml_version == (1, 2) and (
3724-
deprecations.dml12_misc in dml.globals.enabled_deprecations):
3724+
compat.dml12_misc not in dml.globals.enabled_compat):
37253725
check_varname(method.site, name)
37263726
if isinstance(e, Expression):
37273727
inlined_arg = (
@@ -3929,7 +3929,7 @@ def codegen_call(site, meth_node, indices, inargs, outargs):
39293929
require_fully_typed(site, meth_node)
39303930
func = method_instance(meth_node)
39313931

3932-
if deprecations.dml12_misc not in dml.globals.enabled_deprecations:
3932+
if compat.dml12_misc in dml.globals.enabled_compat:
39333933
# For backward compatibility. See bug 21367.
39343934
inargs = [mkCast(site, arg, TPtr(TNamed('char')))
39353935
if isinstance(arg, StringConstant) else arg

py/dml/deprecations.py renamed to py/dml/compat.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from . import env
77

88

9-
class DeprecatedFeature(abc.ABC):
9+
class CompatFeature(abc.ABC):
1010
def tag(self):
1111
return self.__class__.__name__
1212

@@ -20,25 +20,25 @@ def short(self): pass
2020
def last_api_version(self): pass
2121

2222

23-
# API version -> tag -> deprecation
24-
deprecations: dict[str, dict[str, DeprecatedFeature]] = {
23+
# API version -> tag -> feature
24+
features: dict[str, dict[str, CompatFeature]] = {
2525
api: {} for api in env.api_versions().values()}
2626

2727

28-
def deprecation(cls: type[DeprecatedFeature]):
29-
assert issubclass(cls, DeprecatedFeature)
28+
def feature(cls: type[CompatFeature]):
29+
assert issubclass(cls, CompatFeature)
3030
singleton = cls()
31-
deprecations[cls.last_api_version][singleton.tag()] = singleton
31+
features[cls.last_api_version][singleton.tag()] = singleton
3232
return singleton
3333

3434

35-
@deprecation
36-
class port_proxy_ifaces(DeprecatedFeature):
35+
@feature
36+
class port_proxy_ifaces(CompatFeature):
3737
'''Version 5 and earlier of Simics relied on interface ports (as
3838
registered by the `SIM_register_port_interface` API function) for
3939
exposing the interfaces of ports and banks. In newer versions of
4040
Simics, interfaces are instead exposed on separate configuration
41-
objects. When this deprecation is not enabled, old-style
41+
objects. When this feature is enabled, old-style
4242
interface ports are created as proxies to the interfaces on the
4343
respective port objects. Such proxies are not created for all
4444
banks and ports; e.g., banks inside groups were not allowed in
@@ -49,23 +49,23 @@ class port_proxy_ifaces(DeprecatedFeature):
4949
last_api_version = 6
5050

5151

52-
@deprecation
53-
class port_proxy_attrs(DeprecatedFeature):
52+
@feature
53+
class port_proxy_attrs(CompatFeature):
5454
'''In Simics 5, configuration attributes for `connect`,
5555
`attribute` and `register` objects inside banks and ports were
5656
register on the device object, named like
5757
<code><em>bankname</em>_<em>attrname</em></code>. Such proxy
58-
attributes are only created When this deprecation is not enabled.
58+
attributes are only created When this feature is enabled.
5959
Proxy attributes are not created for all banks and ports, in the
60-
same manner as documented in the `port_proxy_ifaces` deprecation.
60+
same manner as documented in the `port_proxy_ifaces` feature.
6161
'''
6262
short = ("Don't generate top-level proxy attributes"
6363
+ " for attributes in banks and ports")
6464
last_api_version = 6
6565

6666

67-
@deprecation
68-
class dml12_inline(DeprecatedFeature):
67+
@feature
68+
class dml12_inline(CompatFeature):
6969
'''When inlining a method using `inline` in a DML 1.2 device,
7070
constant parameters passed in typed arguments are also inlined,
7171
unless compiling with `-g`.
@@ -75,24 +75,24 @@ class dml12_inline(DeprecatedFeature):
7575

7676

7777
# separate class only because last_api_version differs
78-
@deprecation
79-
class dml12_not(DeprecatedFeature):
78+
@feature
79+
class dml12_not(CompatFeature):
8080
'''DML 1.2-specific: the operand of the `!` operator is not
8181
type-checked; in particular, negation expressions on the form
8282
`!$reg`, where `reg` is a register, are permitted'''
8383
short = "Disallow ! operator on register references in DML 1.2"
8484
last_api_version = 5
8585

8686

87-
@deprecation
88-
class dml12_misc(DeprecatedFeature):
89-
'''A number of minor language quirks in DML 1.2 were cleaned up in
90-
DML 1.4; enabling this deprecation switches to the DML 1.4
91-
semantics for these. This includes:
87+
@feature
88+
class dml12_misc(CompatFeature):
89+
'''This compatibility feature preserves a number of minor language quirks
90+
that were originally in DML 1.2, but were cleaned up in
91+
DML 1.4. When this feature is enabled, DML 1.2 will permit the following:
9292
93-
* `sizeof(typename)` is permitted with a warning message (`WSIZEOFTYPE`)
93+
* `sizeof(typename)` (see `WSIZEOFTYPE`)
9494
95-
* the `typeof` operator an expression that isn't an lvalue
95+
* the `typeof` operator on an expression that isn't an lvalue
9696
9797
* the `goto` statement
9898

py/dml/crep.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from .logging import *
1111
from .expr_util import *
1212
from .messages import *
13-
from . import deprecations
13+
from . import compat
1414

1515
__all__ = (
1616
'cname',
@@ -75,7 +75,7 @@ def cname(node):
7575
# this is weird... kept for compatibility
7676
name = param_str(node, 'c_name').replace('-', '_')
7777
if name != node.name and (
78-
deprecations.dml12_misc in dml.globals.enabled_deprecations):
78+
compat.dml12_misc not in dml.globals.enabled_compat):
7979
report(WDEPRECATED(param_expr_site(node, 'c_name'),
8080
'parameter c_name'))
8181
return name
@@ -178,7 +178,7 @@ def node_storage_type_dml12(node, site):
178178
else:
179179
return None
180180
elif node.objtype == 'implement':
181-
if deprecations.dml12_misc not in dml.globals.enabled_deprecations:
181+
if compat.dml12_misc in dml.globals.enabled_compat:
182182
typename = param_str(node, 'c_type')
183183
t = TNamed(typename)
184184
t.declaration_site = node.site
@@ -228,7 +228,7 @@ def conf_object(site, node, indices):
228228
cref_portobj(node, indices[:node.dimensions]))
229229

230230
def cloggroup(name):
231-
if deprecations.dml12_misc not in dml.globals.enabled_deprecations:
231+
if compat.dml12_misc in dml.globals.enabled_compat:
232232
return name
233233
else:
234234
return '_dml_loggroup_' + name

0 commit comments

Comments
 (0)