Skip to content

Migrate from optparse to argparse #208

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/1.4/dml-builtins.dml
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,9 @@ template device {
param _is_simics_object = true;

param simics_api_version auto;
param _api_5_or_older = simics_api_version == "5"
|| simics_api_version == "4.8";
param _api_6_or_older = simics_api_version == "6" || _api_5_or_older;

// automatic parameters
param obj auto;
Expand All @@ -551,8 +554,7 @@ template device {
param be_bitorder default _be_bitorder;
param log_group = undefined;

param use_io_memory default simics_api_version == "6"
|| simics_api_version == "5" || simics_api_version == "4.8";
param use_io_memory default _api_6_or_older;
// this was available in DML 1.2; defensively reserved in 1.4
param banks = undefined;
// this carried semantics in DML 1.2; deprecated in 1.4
Expand Down Expand Up @@ -1441,8 +1443,7 @@ template port is object {
param _is_simics_object = true;
// limitations for ports are not recognized
param limitations = undefined;
param obj = (simics_api_version == "5" || simics_api_version == "4.8")
#? dev.obj #: _port_obj();
param obj = dev._api_5_or_older #? dev.obj #: _port_obj();

session conf_object_t *_cached_port_obj;
shared method _port_obj() -> (conf_object_t *) {
Expand Down Expand Up @@ -1774,8 +1775,7 @@ template bank is (object, shown_desc) {
// compatibility: referencing 'obj' in a bank method must evaluate to
// dev.obj in code that can compile on both 5 and 6
// TODO: we should probably make obj an immutable session variable
param obj = (simics_api_version == "5" || simics_api_version == "4.8")
#? dev.obj #: _bank_obj();
param obj = dev._api_5_or_older #? dev.obj #: _bank_obj();
param partial : bool;
param overlapping : bool;
param _le_byte_order : bool;
Expand Down
62 changes: 33 additions & 29 deletions py/dml/c_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from . import objects, logging, crep, output, ctree, serialize, structure
from . import traits
import dml.globals
from .structure import get_attr_name, port_class_ident, port_should_get_proxies
from .structure import get_attr_name, port_class_ident, need_port_proxy_attrs
from .logging import *
from .messages import *
from .output import *
Expand Down Expand Up @@ -510,7 +510,7 @@ def check_attribute(node, port, prefix):
report(WNDOC(node, node.logname()))
attrname = get_attr_name(prefix, node)
register_attribute(node.site, port, attrname)
if port and port_should_get_proxies(port):
if port and need_port_proxy_attrs(port):
register_attribute(node.site, None, "%s_%s" % (port.name, attrname))

# dimsizes, loopvars, prefix are relative to port.
Expand Down Expand Up @@ -580,40 +580,44 @@ def generate_attribute_common(initcode, node, port, dimsizes, prefix,

register_attribute(node.site, port, attrname)
if port:
if port.dimensions == 0 and port.objtype in {'port', 'bank'}:
register_attribute(node.site, None, "%s_%s" % (port.name, attrname))
initcode.out(
'_register_port_attr(class, %s, offsetof(%s, %s), %s,'
% (port_class_ident(port),
crep.structtype(dml.globals.device),
crep.cref_portobj(port, ()),
'true' if port.objtype == "bank" else 'false')
+ ' "%s", "%s", %s, %s, %s, "%s", %s);\n'
% (port.name, attrname, getter, setter,
attr_flag, attr_type, doc.read()))
elif port.dimensions == 1 and port.objtype in {'port', 'bank'}:
# Generate an accessor attribute for legacy reasons
register_attribute(node.site, None, "%s_%s" % (port.name, attrname))
member = crep.cref_portobj(
port, (mkLit(port.site, '0', TInt(32, False)),))
(dimsize,) = port.dimsizes
initcode.out(
'_register_port_array_attr(class, %s, offsetof(%s, %s),'
% (port_class_ident(port),
crep.structtype(dml.globals.device),
member)
+ ' %d, %s, "%s", "%s", %s, %s, %s, "%s",'
% (dimsize, 'true' if port.objtype == "bank" else 'false',
port.name, attrname, getter, setter, attr_flag, attr_type)
+ ' %s);\n' % (doc.read(),))
if need_port_proxy_attrs(port):
if port.dimensions == 0:
register_attribute(
node.site, None, "%s_%s" % (port.name, attrname))
initcode.out(
'_register_port_attr(class, %s, offsetof(%s, %s), %s,'
% (port_class_ident(port),
crep.structtype(dml.globals.device),
crep.cref_portobj(port, ()),
'true' if port.objtype == "bank" else 'false')
+ ' "%s", "%s", %s, %s, %s, "%s", %s);\n'
% (port.name, attrname, getter, setter,
attr_flag, attr_type, doc.read()))
else:
assert port.dimensions == 1
# Generate an accessor attribute for legacy reasons
register_attribute(
node.site, None, "%s_%s" % (port.name, attrname))
member = crep.cref_portobj(
port, (mkLit(port.site, '0', TInt(32, False)),))
(dimsize,) = port.dimsizes
initcode.out(
'_register_port_array_attr(class, %s, offsetof(%s, %s),'
% (port_class_ident(port),
crep.structtype(dml.globals.device),
member)
+ ' %d, %s, "%s", "%s", %s, %s, %s, "%s",'
% (dimsize, 'true' if port.objtype == "bank" else 'false',
port.name, attrname, getter, setter, attr_flag,
attr_type)
+ ' %s);\n' % (doc.read(),))
else:
initcode.out(
'_register_port_attr_no_aux(%s,'
' "%s", %s, %s, %s, "%s", %s);\n'
% (port_class_ident(port),
attrname, getter, setter,
attr_flag, attr_type, doc.read()))

else:
initcode.out('SIM_register_typed_attribute(class, "'+attrname+'",'+
'\n '+
Expand Down
Loading