Skip to content

Commit d0c3fee

Browse files
committed
Gate fix behind --no-compat=shared_logs_on_device
1 parent 013ea05 commit d0c3fee

15 files changed

+122
-39
lines changed

RELEASENOTES-1.4.docu

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,4 +518,7 @@
518518
as the log object instead of the configuration object of the nearest
519519
enclosing <tt>device</tt>, <tt>port</tt>, <tt>bank</tt> or
520520
<tt>subdevice</tt> <bug number="SIMICS-11346"/>.
521+
This fix is only enabled by default with Simics API version 7 or above.
522+
With version 6 or below it must be explicitly enabled by passing
523+
<tt>--no-compat=shared_logs_on_device</tt> to DMLC.</add-note></build-id>
521524
</rn>

lib/1.2/dml-builtins.dml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ template device {
210210
parameter _compat_port_proxy_attrs auto;
211211
parameter _compat_port_obj_param auto;
212212
parameter _compat_io_memory auto;
213+
parameter _compat_shared_logs_on_device auto;
213214
parameter _compat_dml12_inline auto;
214215
parameter _compat_dml12_not auto;
215216
parameter _compat_dml12_goto auto;

lib/1.4/dml-builtins.dml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,7 @@ template device {
544544
param _compat_port_proxy_attrs auto;
545545
param _compat_port_obj_param auto;
546546
param _compat_io_memory auto;
547+
param _compat_shared_logs_on_device auto;
547548
param _compat_dml12_inline auto;
548549
param _compat_dml12_not auto;
549550
param _compat_dml12_goto auto;

py/dml/c_backend.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3328,7 +3328,8 @@ def generate_cfile_body(device, footers, full_module, filename_prefix):
33283328
generate_events(device)
33293329
generate_identity_data_decls()
33303330
generate_object_vtables_array()
3331-
generate_log_object_assocs_array()
3331+
if compat.shared_logs_on_device not in dml.globals.enabled_compat:
3332+
generate_log_object_assocs_array()
33323333
generate_class_var_decl()
33333334
generate_startup_calls_entry_function(device)
33343335
generate_init_data_objs(device)

py/dml/codegen.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2647,7 +2647,9 @@ def stmt_log(stmt, location, scope):
26472647
logobj = log_object(site, location.node, location.indices)
26482648
else:
26492649
identity = TraitObjIdentity(site, lookup_var(site, scope, "this"))
2650-
logobj = LogObjectFromObjIdentity(site, identity)
2650+
logobj = (log_object(site, dml.globals.device, ())
2651+
if compat.shared_logs_on_device in dml.globals.enabled_compat
2652+
else LogObjectFromObjIdentity(site, identity))
26512653

26522654
if later_level is not None:
26532655
adjusted_later_level = later_level = ctree.as_int(codegen_expression(

py/dml/compat.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,19 @@ class port_obj_param(CompatFeature):
105105
last_api_version = api_5
106106

107107

108+
@feature
109+
class shared_logs_on_device(CompatFeature):
110+
'''This compatibility feature changes the semantics of log statements
111+
inside shared methods so that they always log on the device object, instead
112+
of the nearest enclosing configuration object like with non-shared methods.
113+
This behaviour was a bug present since the very introduction of shared
114+
methods, which has lead to plenty of script code having become reliant
115+
on it, especially in regards to how banks log. This feature preserves the
116+
bugged behaviour.'''
117+
short = "Make logs inside shared methods always log on the device object"
118+
last_api_version = api_6
119+
120+
108121
@feature
109122
class dml12_inline(CompatFeature):
110123
'''When using `inline` to inline a method in a DML 1.2 device,
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
© 2023 Intel Corporation
3+
SPDX-License-Identifier: MPL-2.0
4+
*/
5+
dml 1.4;
6+
7+
device test;
8+
9+
/// DMLC-FLAG --simics-api=6
10+
/// DMLC-FLAG --no-compat=shared_logs_on_device
11+
12+
template t is _qname {
13+
shared method hello() {
14+
log info: "hello from %s", _qname();
15+
}
16+
}
17+
18+
is t;
19+
group g is t {
20+
in each object { is t; }
21+
22+
group c[i < 2];
23+
24+
subdevice s[i < 3] {
25+
group c[j < 5][k < 7] is t {
26+
subdevice s;
27+
}
28+
}
29+
}
30+
31+
method init() {
32+
/// GREP \[obj info\] hello from test
33+
hello();
34+
/// GREP \[obj info\] hello from g
35+
g.hello();
36+
/// GREP \[obj info\] hello from g.c\[1\]
37+
g.c[1].hello();
38+
/// GREP \[obj\.g\.s\[2\] info\] hello from g\.s\[2\]
39+
g.s[2].hello();
40+
/// GREP \[obj\.g\.s\[2\] info\] hello from g\.s\[2\]\.c\[3\]\[5\]
41+
g.s[2].c[3][5].hello();
42+
/// GREP \[obj\.g\.s\[2\]\.c\[3\]\[5\]\.s info\] hello from g\.s\[2\]\.c\[3\]\[5\]\.s
43+
g.s[2].c[3][5].s.hello();
44+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
© 2023 Intel Corporation
3+
SPDX-License-Identifier: MPL-2.0
4+
*/
5+
dml 1.4;
6+
7+
device test;
8+
9+
/// DMLC-FLAG --simics-api=6
10+
11+
template t is _qname {
12+
shared method hello() {
13+
log info: "hello from %s", _qname();
14+
}
15+
}
16+
17+
is t;
18+
group g is t {
19+
in each object { is t; }
20+
21+
group c[i < 2];
22+
23+
subdevice s[i < 3] {
24+
group c[j < 5][k < 7] is t {
25+
subdevice s;
26+
}
27+
}
28+
}
29+
30+
method init() {
31+
/// GREP \[obj info\] hello from test
32+
hello();
33+
/// GREP \[obj info\] hello from g
34+
g.hello();
35+
/// GREP \[obj info\] hello from g.c\[1\]
36+
g.c[1].hello();
37+
/// GREP \[obj info\] hello from g\.s\[2\]
38+
g.s[2].hello();
39+
/// GREP \[obj info\] hello from g\.s\[2\]\.c\[3\]\[5\]
40+
g.s[2].c[3][5].hello();
41+
/// GREP \[obj info\] hello from g\.s\[2\]\.c\[3\]\[5\]\.s
42+
g.s[2].c[3][5].s.hello();
43+
}

test/1.4/lib/T_map_target_connect.dml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ dml 1.4;
66

77
device test;
88

9+
/// DMLC-FLAG --no-compat=shared_logs_on_device
10+
911
import "utility.dml";
1012
import "simics/simulator-api.dml";
1113

test/1.4/lib/T_unmapped_access.dml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
dml 1.4;
66
device test;
77

8+
/// DMLC-FLAG --no-compat=shared_logs_on_device
9+
810
import "utility.dml";
911

1012
template partially_mapped_register is (register, unmapped) {

0 commit comments

Comments
 (0)