From 763907b0e583f6609cf573b58dddd626d0a92f54 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 6 Jan 2022 15:24:20 +0100 Subject: [PATCH] Add a typedef for `std::vector` `std::vector` is used for signal array dimensions. As such it is used in quite a few places. Add a typedef that can be used as a shorthand to refer to it. This helps to keep lines where this is used from growing to overly long. The new type is called `netranges_t`. Signed-off-by: Lars-Peter Clausen --- PExpr.h | 4 ++-- PWire.h | 4 ++-- Statement.h | 2 +- design_dump.cc | 7 +++---- elab_expr.cc | 18 +++++++++--------- elab_lval.cc | 10 +++++----- elab_sig.cc | 12 ++++++------ elab_type.cc | 8 ++++---- elaborate.cc | 6 +++--- eval_tree.cc | 4 ++-- netenum.cc | 2 +- netenum.h | 2 +- netlist.cc | 8 ++++---- netlist.h | 8 ++++---- netmisc.cc | 32 +++++++++++++++----------------- netmisc.h | 2 +- netparray.cc | 10 +++++----- netparray.h | 26 ++++++++++---------------- netstruct.cc | 4 ++-- netstruct.h | 2 +- nettypes.cc | 18 ++++++++---------- nettypes.h | 15 ++++++++------- netvector.cc | 2 +- netvector.h | 13 ++++++------- t-dll-api.cc | 6 +++--- t-dll.cc | 4 ++-- t-dll.h | 2 +- 27 files changed, 110 insertions(+), 121 deletions(-) diff --git a/PExpr.h b/PExpr.h index a70a6f1e7..3217cbe39 100644 --- a/PExpr.h +++ b/PExpr.h @@ -217,7 +217,7 @@ class PEAssignPattern : public PExpr { NetExpr* elaborate_expr_packed_(Design *des, NetScope *scope, ivl_variable_type_t base_type, unsigned int width, - const std::vector &dims, + const netranges_t &dims, unsigned int cur_dim, bool need_const) const; NetExpr* elaborate_expr_struct_(Design *des, NetScope *scope, @@ -228,7 +228,7 @@ class PEAssignPattern : public PExpr { bool need_const, bool up) const; NetExpr* elaborate_expr_uarray_(Design *des, NetScope *scope, const netuarray_t *uarray_type, - const std::vector &dims, + const netranges_t &dims, unsigned int cur_dim, bool need_const) const; diff --git a/PWire.h b/PWire.h index 8b47fc214..f9178d11c 100644 --- a/PWire.h +++ b/PWire.h @@ -134,10 +134,10 @@ class PWire : public PNamedItem { PWire& operator= (const PWire&); ivl_type_t elaborate_type(Design*des, NetScope*scope, - const std::vector&packed_dimensions) const; + const netranges_t &packed_dimensions) const; ivl_type_t elaborate_darray_type(Design*des, NetScope*scope, const char *darray_type, - const std::vector&packed_dimensions) + const netranges_t &packed_dimensions) const; }; diff --git a/Statement.h b/Statement.h index 6aa2e9bca..d540fb881 100644 --- a/Statement.h +++ b/Statement.h @@ -499,7 +499,7 @@ class PForeach : public Statement { private: NetProc* elaborate_static_array_(Design*des, NetScope*scope, - const std::vector&dims) const; + const netranges_t&dims) const; private: perm_string array_var_; diff --git a/design_dump.cc b/design_dump.cc index 7e8f50f7a..533abf6c4 100644 --- a/design_dump.cc +++ b/design_dump.cc @@ -418,9 +418,9 @@ ostream&operator<<(ostream&out, const list&rlist) return out; } -ostream&operator<<(ostream&out, const vector&rlist) +ostream&operator<<(ostream&out, const netranges_t&rlist) { - for (vector::const_iterator cur = rlist.begin() + for (netranges_t::const_iterator cur = rlist.begin() ; cur != rlist.end() ; ++cur) { out << *cur; } @@ -1936,8 +1936,7 @@ void NetESignal::dump(ostream&o) const o << "+"; o << name(); if (word_) o << "[word=" << *word_ << "]"; - vectortmp = net_->net_type()->slice_dimensions(); - o << tmp; + o << net_->net_type()->slice_dimensions(); } void NetETernary::dump(ostream&o) const diff --git a/elab_expr.cc b/elab_expr.cc index 06395e5ca..1e8e2e502 100644 --- a/elab_expr.cc +++ b/elab_expr.cc @@ -312,7 +312,7 @@ NetExpr* PEAssignPattern::elaborate_expr_array_(Design *des, NetScope *scope, NetExpr* PEAssignPattern::elaborate_expr_uarray_(Design *des, NetScope *scope, const netuarray_t *uarray_type, - const std::vector &dims, + const netranges_t &dims, unsigned int cur_dim, bool need_const) const { @@ -381,7 +381,7 @@ NetExpr* PEAssignPattern::elaborate_expr_uarray_(Design *des, NetScope *scope, NetExpr* PEAssignPattern::elaborate_expr_packed_(Design *des, NetScope *scope, ivl_variable_type_t base_type, unsigned int width, - const std::vector &dims, + const netranges_t &dims, unsigned int cur_dim, bool need_const) const { @@ -2522,7 +2522,7 @@ static NetExpr* check_for_struct_members(const LineInfo*li, // kind of array cannot be a struct. if (!member_comp.index.empty()) { // These are the dimensions defined by the type - const vector&mem_packed_dims = mem_vec->packed_dims(); + const netranges_t&mem_packed_dims = mem_vec->packed_dims(); if (member_comp.index.size() > mem_packed_dims.size()) { cerr << li->get_fileline() << ": error: " @@ -2594,7 +2594,7 @@ static NetExpr* check_for_struct_members(const LineInfo*li, ivl_assert(*li, !member_comp.index.empty()); // These are the dimensions defined by the type - const vector&mem_packed_dims = array->static_dimensions(); + const netranges_t&mem_packed_dims = array->static_dimensions(); if (member_comp.index.size() != mem_packed_dims.size()) { cerr << li->get_fileline() << ": error: " @@ -2790,7 +2790,7 @@ NetExpr* PEIdent::elaborate_expr_class_field_(Design*des, NetScope*scope, NetExpr *canon_index = nullptr; ivl_type_t tmp_type = class_type->get_prop_type(pidx); if (const netuarray_t *tmp_ua = dynamic_cast(tmp_type)) { - const std::vector &dims = tmp_ua->static_dimensions(); + const auto &dims = tmp_ua->static_dimensions(); if (debug_elaborate) { cerr << get_fileline() << ": PEIdent::elaborate_expr_class_member_: " @@ -5997,7 +5997,7 @@ NetExpr* PEIdent::elaborate_expr_net_idx_up_(Design*des, NetScope*scope, long lsv = base_c->value().as_long(); long rel_base = 0; // Get the signal range. - const vector&packed = net->sig()->packed_dims(); + const netranges_t&packed = net->sig()->packed_dims(); if (prefix_indices.size()+1 < net->sig()->packed_dims().size()) { // Here we are selecting one or more sub-arrays. // Make this work by finding the indexed sub-arrays and @@ -6144,7 +6144,7 @@ NetExpr* PEIdent::elaborate_expr_net_idx_do_(Design*des, NetScope*scope, long lsv = base_c->value().as_long(); long rel_base = 0; // Get the signal range. - const vector&packed = net->sig()->packed_dims(); + const netranges_t&packed = net->sig()->packed_dims(); if (prefix_indices.size()+1 < net->sig()->packed_dims().size()) { // Here we are selecting one or more sub-arrays. // Make this work by finding the indexed sub-arrays and @@ -6331,7 +6331,7 @@ NetExpr* PEIdent::elaborate_expr_net_bit_(Design*des, NetScope*scope, long msv = msc->value().as_long(); - const vector& sig_packed = net->sig()->packed_dims(); + const netranges_t& sig_packed = net->sig()->packed_dims(); if (prefix_indices.size()+2 <= sig_packed.size()) { // Special case: this is a slice of a multi-dimensional // packed array. For example: @@ -6438,7 +6438,7 @@ NetExpr* PEIdent::elaborate_expr_net_bit_(Design*des, NetScope*scope, return res; } - const vector& sig_packed = net->sig()->packed_dims(); + const netranges_t& sig_packed = net->sig()->packed_dims(); if (prefix_indices.size()+2 <= sig_packed.size()) { // Special case: this is a slice of a multi-dimensional // packed array. For example: diff --git a/elab_lval.cc b/elab_lval.cc index 10d24a1e0..77b7829bb 100644 --- a/elab_lval.cc +++ b/elab_lval.cc @@ -749,7 +749,7 @@ bool PEIdent::elaborate_lval_net_part_(Design*des, } } - const vector&packed = reg->packed_dims(); + const netranges_t&packed = reg->packed_dims(); long loff, moff; long wid; @@ -874,7 +874,7 @@ bool PEIdent::elaborate_lval_net_idx_(Design*des, long lsv = base_c->value().as_long(); long rel_base = 0; // Get the signal range. - const vector&packed = reg->packed_dims(); + const netranges_t&packed = reg->packed_dims(); if (prefix_indices.size()+1 < reg->packed_dims().size()) { // Here we are selecting one or more sub-arrays. // Make this work by finding the indexed sub-arrays and @@ -1114,7 +1114,7 @@ NetAssign_* PEIdent::elaborate_lval_net_class_member_(Design*des, NetScope*scope } if (const netuarray_t *tmp_ua = dynamic_cast(ptype)) { - const std::vector &dims = tmp_ua->static_dimensions(); + const auto &dims = tmp_ua->static_dimensions(); if (debug_elaborate) { cerr << get_fileline() << ": PEIdent::elaborate_lval_method_class_member_: " @@ -1313,7 +1313,7 @@ bool PEIdent::elaborate_lval_net_packed_member_(Design*des, NetScope*scope, // kind of array cannot be a struct. if (!member_comp.index.empty()) { // These are the dimensions defined by the type - const vector&mem_packed_dims = mem_vec->packed_dims(); + const netranges_t&mem_packed_dims = mem_vec->packed_dims(); if (member_comp.index.size() > mem_packed_dims.size()) { cerr << get_fileline() << ": error: " @@ -1382,7 +1382,7 @@ bool PEIdent::elaborate_lval_net_packed_member_(Design*des, NetScope*scope, ivl_assert(*this, !member_comp.index.empty()); // These are the dimensions defined by the type - const vector&mem_packed_dims = array->static_dimensions(); + const netranges_t&mem_packed_dims = array->static_dimensions(); if (member_comp.index.size() != mem_packed_dims.size()) { cerr << get_fileline() << ": error: " diff --git a/elab_sig.cc b/elab_sig.cc index fd76900b6..fd5b92427 100644 --- a/elab_sig.cc +++ b/elab_sig.cc @@ -936,13 +936,13 @@ void PWhile::elaborate_sig(Design*des, NetScope*scope) const statement_->elaborate_sig(des, scope); } -bool test_ranges_eeq(const vector&lef, const vector&rig) +bool test_ranges_eeq(const netranges_t&lef, const netranges_t&rig) { if (lef.size() != rig.size()) return false; - vector::const_iterator lcur = lef.begin(); - vector::const_iterator rcur = rig.begin(); + netranges_t::const_iterator lcur = lef.begin(); + netranges_t::const_iterator rcur = rig.begin(); while (lcur != lef.end()) { if (lcur->get_msb() != rcur->get_msb()) return false; @@ -957,7 +957,7 @@ bool test_ranges_eeq(const vector&lef, const vector&rig) } ivl_type_t PWire::elaborate_type(Design*des, NetScope*scope, - const std::vector&packed_dimensions) const + const netranges_t &packed_dimensions) const { vector_type_t *vec_type = dynamic_cast(set_data_type_.get()); if (set_data_type_ && !vec_type) { @@ -1028,7 +1028,7 @@ NetNet* PWire::elaborate_sig(Design*des, NetScope*scope) const } unsigned wid = 1; - vectorpacked_dimensions; + netranges_t packed_dimensions; des->errors += error_cnt_; @@ -1051,7 +1051,7 @@ NetNet* PWire::elaborate_sig(Design*des, NetScope*scope) const } bool dimensions_ok = true; - vector plist, nlist; + netranges_t plist, nlist; /* If they exist get the port definition MSB and LSB */ if (port_set_ && !port_.empty()) { if (debug_elaborate) { diff --git a/elab_type.cc b/elab_type.cc index a6c0767e0..7ae224836 100644 --- a/elab_type.cc +++ b/elab_type.cc @@ -168,7 +168,7 @@ ivl_type_t enum_type_t::elaborate_type_raw(Design *des, NetScope *scope) const ivl_type_t vector_type_t::elaborate_type_raw(Design*des, NetScope*scope) const { - vector packed; + netranges_t packed; if (pdims.get()) evaluate_ranges(des, scope, this, packed, *pdims); @@ -198,7 +198,7 @@ ivl_type_t string_type_t::elaborate_type_raw(Design*, NetScope*) const ivl_type_t parray_type_t::elaborate_type_raw(Design*des, NetScope*scope) const { - vectorpacked; + netranges_t packed; if (dims.get()) evaluate_ranges(des, scope, this, packed, *dims); @@ -322,7 +322,7 @@ static ivl_type_t elaborate_queue_type(Design *des, NetScope *scope, // return the base type. Also check that we actually support the base type. static ivl_type_t elaborate_static_array_type(Design *des, const LineInfo &li, ivl_type_t base_type, - std::vector &dims) + netranges_t &dims) { if (dims.empty()) return base_type; @@ -354,7 +354,7 @@ ivl_type_t elaborate_array_type(Design *des, NetScope *scope, const list &dims) { const long warn_dimension_size = 1 << 30; - std::vector dimensions; + netranges_t dimensions; dimensions.reserve(dims.size()); ivl_type_t type = base_type; diff --git a/elaborate.cc b/elaborate.cc index 02a1fd47b..1467fa7f1 100644 --- a/elaborate.cc +++ b/elaborate.cc @@ -5414,7 +5414,7 @@ NetProc* PForeach::elaborate(Design*des, NetScope*scope) const return 0; } - const std::vector&dims = atype->static_dimensions(); + const netranges_t&dims = atype->static_dimensions(); if (dims.size() < index_vars_.size()) { cerr << get_fileline() << ": error: " << "class " << class_scope->get_name() @@ -5447,7 +5447,7 @@ NetProc* PForeach::elaborate(Design*des, NetScope*scope) const << " packed dimensions." << endl; } - std::vectordims = array_sig->unpacked_dims(); + netranges_t dims = array_sig->unpacked_dims(); if (array_sig->packed_dimensions() > 0) { dims.insert(dims.end(), array_sig->packed_dims().begin(), array_sig->packed_dims().end()); } @@ -5523,7 +5523,7 @@ NetProc* PForeach::elaborate(Design*des, NetScope*scope) const * and possibly do some optimizations. */ NetProc* PForeach::elaborate_static_array_(Design*des, NetScope*scope, - const vector&dims) const + const netranges_t&dims) const { if (debug_elaborate) { cerr << get_fileline() << ": PForeach::elaborate_static_array_: " diff --git a/eval_tree.cc b/eval_tree.cc index 991d1c685..04e9975e3 100644 --- a/eval_tree.cc +++ b/eval_tree.cc @@ -2197,12 +2197,12 @@ static bool get_array_info(const NetExpr*arg, long dim, if (dim > (pdims + updims)) return true; /* Get the appropriate unpacked or packed dimension information. */ if (dim > updims) { - const vector&dim_vals = sig->packed_dims(); + const netranges_t&dim_vals = sig->packed_dims(); const netrange_t&range = dim_vals[dim-updims-1]; left = range.get_msb(); right = range.get_lsb(); } else { - const vector&dim_vals = sig->unpacked_dims(); + const netranges_t&dim_vals = sig->unpacked_dims(); const netrange_t&range = dim_vals[dim-1]; left = range.get_msb(); right = range.get_lsb(); diff --git a/netenum.cc b/netenum.cc index 1cedf2e85..b7ceff55b 100644 --- a/netenum.cc +++ b/netenum.cc @@ -56,7 +56,7 @@ long netenum_t::packed_width() const return base_type_->packed_width(); } -vector netenum_t::slice_dimensions() const +netranges_t netenum_t::slice_dimensions() const { return base_type_->slice_dimensions(); } diff --git a/netenum.h b/netenum.h index b2d64397a..6d5b7196e 100644 --- a/netenum.h +++ b/netenum.h @@ -39,7 +39,7 @@ class netenum_t : public LineInfo, public ivl_type_s { virtual ivl_variable_type_t base_type() const; virtual bool packed() const; virtual long packed_width() const; - std::vector slice_dimensions() const; + netranges_t slice_dimensions() const; bool get_signed() const; bool get_isint() const; diff --git a/netlist.cc b/netlist.cc index f0d600257..e3c232d1e 100644 --- a/netlist.cc +++ b/netlist.cc @@ -557,7 +557,7 @@ void NetNet::calculate_slice_widths_from_packed_dims_(void) ivl_assert(*this, ! slice_wids_.empty()); slice_wids_[0] = netrange_width(slice_dims_); - vector::const_iterator cur = slice_dims_.begin(); + netranges_t::const_iterator cur = slice_dims_.begin(); for (size_t idx = 1 ; idx < slice_wids_.size() ; idx += 1, ++cur) { slice_wids_[idx] = slice_wids_[idx-1] / cur->width(); } @@ -775,7 +775,7 @@ long NetNet::sb_to_idx(const list&indices, long sb) const { ivl_assert(*this, indices.size()+1 == packed_dims().size()); - vector::const_iterator pcur = packed_dims().end(); + netranges_t::const_iterator pcur = packed_dims().end(); -- pcur; long acc_off; @@ -2453,14 +2453,14 @@ NetNet* NetESignal::sig() */ long NetESignal::lsi() const { - const vector&packed = net_->packed_dims(); + const netranges_t&packed = net_->packed_dims(); ivl_assert(*this, packed.size() == 1); return packed.back().get_lsb(); } long NetESignal::msi() const { - const vector&packed = net_->packed_dims(); + const netranges_t&packed = net_->packed_dims(); ivl_assert(*this, packed.size() == 1); return packed.back().get_msb(); } diff --git a/netlist.h b/netlist.h index 996767f70..d242363eb 100644 --- a/netlist.h +++ b/netlist.h @@ -723,9 +723,9 @@ class NetNet : public NetObj, public PortType { first range in the list (front) is the left-most range in the Verilog declaration. These packed dims are compressed to represent the dimensions of all the subtypes. */ - const std::vector& packed_dims() const { return slice_dims_; } + const netranges_t& packed_dims() const { return slice_dims_; } - const std::vector& unpacked_dims() const { return unpacked_dims_; } + const netranges_t& unpacked_dims() const { return unpacked_dims_; } /* The vector_width returns the bit width of the packed array, vector or scalar that is this NetNet object. */ @@ -813,7 +813,7 @@ class NetNet : public NetObj, public PortType { // Whether the net is variable declared with the const keyword. bool is_const_ = false; - std::vector unpacked_dims_; + netranges_t unpacked_dims_; // These are the widths of the various slice depths. There is // one entry in this vector for each packed dimension. The @@ -821,7 +821,7 @@ class NetNet : public NetObj, public PortType { // // For example: slice_wids_[0] is vector_width(). void calculate_slice_widths_from_packed_dims_(void); - std::vector slice_dims_; + netranges_t slice_dims_; std::vector slice_wids_; unsigned eref_count_; diff --git a/netmisc.cc b/netmisc.cc index 8f3f89b84..99f28cb44 100644 --- a/netmisc.cc +++ b/netmisc.cc @@ -415,7 +415,7 @@ NetExpr *normalize_variable_base(NetExpr *base, NetExpr *normalize_variable_bit_base(const list&indices, NetExpr*base, const NetNet*reg) { - const vector&packed_dims = reg->packed_dims(); + const netranges_t&packed_dims = reg->packed_dims(); ivl_assert(*base, indices.size()+1 == packed_dims.size()); // Get the canonical offset of the slice within which we are @@ -431,7 +431,7 @@ NetExpr *normalize_variable_part_base(const list&indices, NetExpr*base, const NetNet*reg, unsigned long wid, bool is_up) { - const vector&packed_dims = reg->packed_dims(); + const netranges_t&packed_dims = reg->packed_dims(); ivl_assert(*base, indices.size()+1 == packed_dims.size()); // Get the canonical offset of the slice within which we are @@ -446,10 +446,10 @@ NetExpr *normalize_variable_part_base(const list&indices, NetExpr*base, NetExpr *normalize_variable_slice_base(const list&indices, NetExpr*base, const NetNet*reg, unsigned long&lwid) { - const vector&packed_dims = reg->packed_dims(); + const netranges_t&packed_dims = reg->packed_dims(); ivl_assert(*base, indices.size() < packed_dims.size()); - vector::const_iterator pcur = packed_dims.end(); + netranges_t::const_iterator pcur = packed_dims.end(); for (size_t idx = indices.size() ; idx < packed_dims.size(); idx += 1) { -- pcur; } @@ -563,8 +563,7 @@ void indices_to_expressions(Design*des, NetScope*scope, } } -static void make_strides(const vector&dims, - vector&stride) +static void make_strides(const netranges_t&dims, vector&stride) { stride[dims.size()-1] = 1; for (size_t idx = stride.size()-1 ; idx > 0 ; --idx) { @@ -581,7 +580,7 @@ static void make_strides(const vector&dims, * word. If any of the indices are out of bounds, return nil instead * of an expression. */ -static NetExpr* normalize_variable_unpacked(const vector&dims, list&indices) +static NetExpr* normalize_variable_unpacked(const netranges_t&dims, list&indices) { // Make strides for each index. The stride is the distance (in // words) to the next element in the canonical array. @@ -614,17 +613,17 @@ static NetExpr* normalize_variable_unpacked(const vector&dims, list< NetExpr* normalize_variable_unpacked(const NetNet*net, list&indices) { - const vector&dims = net->unpacked_dims(); + const netranges_t&dims = net->unpacked_dims(); return normalize_variable_unpacked(dims, indices); } NetExpr* normalize_variable_unpacked(const netsarray_t*stype, list&indices) { - const vector&dims = stype->static_dimensions(); + const netranges_t&dims = stype->static_dimensions(); return normalize_variable_unpacked(dims, indices); } -NetExpr* normalize_variable_unpacked(const LineInfo&loc, const vector&dims, list&indices) +NetExpr* normalize_variable_unpacked(const LineInfo&loc, const netranges_t&dims, list&indices) { // Make strides for each index. The stride is the distance (in // words) to the next element in the canonical array. @@ -711,13 +710,13 @@ NetExpr* normalize_variable_unpacked(const LineInfo&loc, const vector&indices) { - const vector&dims = net->unpacked_dims(); + const netranges_t&dims = net->unpacked_dims(); return normalize_variable_unpacked(*net, dims, indices); } NetExpr* normalize_variable_unpacked(const LineInfo&loc, const netsarray_t*stype, list&indices) { - const vector&dims = stype->static_dimensions(); + const netranges_t&dims = stype->static_dimensions(); return normalize_variable_unpacked(loc, dims, indices); } @@ -1159,8 +1158,7 @@ bool evaluate_range(Design*des, NetScope*scope, const LineInfo*li, } bool evaluate_ranges(Design*des, NetScope*scope, const LineInfo*li, - vector&llist, - const list&rlist) + netranges_t&llist, const list&rlist) { bool dimensions_ok = true; @@ -1587,8 +1585,8 @@ NetExpr*collapse_array_exprs(Design*des, NetScope*scope, return *exprs.begin(); } - const std::vector&pdims = net->packed_dims(); - std::vector::const_iterator pcur = pdims.begin(); + const netranges_t&pdims = net->packed_dims(); + netranges_t::const_iterator pcur = pdims.begin(); list::iterator ecur = exprs.begin(); NetExpr* base = 0; @@ -1881,7 +1879,7 @@ bool calculate_param_range(const LineInfo&line, ivl_type_t par_type, } ivl_assert(line, vector_type->packed()); - const std::vector& packed_dims = vector_type->packed_dims(); + const netranges_t& packed_dims = vector_type->packed_dims(); // This is a netvector_t with 0 dimensions, then the parameter was // declared with a statement like this: diff --git a/netmisc.h b/netmisc.h index d6f7ad94b..13dbcaee2 100644 --- a/netmisc.h +++ b/netmisc.h @@ -418,7 +418,7 @@ extern bool evaluate_range(Design*des, NetScope*scope, const LineInfo*li, long&index_l, long&index_r); extern bool evaluate_ranges(Design*des, NetScope*scope, const LineInfo*li, - std::vector&llist, + netranges_t&llist, const std::list&rlist); /* * This procedure evaluates an expression and if the evaluation is diff --git a/netparray.cc b/netparray.cc index 8819db183..daafab208 100644 --- a/netparray.cc +++ b/netparray.cc @@ -46,13 +46,13 @@ long netparray_t::packed_width(void) const element_type()->packed_width()); } -vector netparray_t::slice_dimensions() const +netranges_t netparray_t::slice_dimensions() const { - const vector&packed_dims = static_dimensions(); + const netranges_t&packed_dims = static_dimensions(); - vector elem_dims = element_type()->slice_dimensions(); + netranges_t elem_dims = element_type()->slice_dimensions(); - vector res (packed_dims.size() + elem_dims.size()); + netranges_t res (packed_dims.size() + elem_dims.size()); for (size_t idx = 0 ; idx < packed_dims.size() ; idx += 1) res[idx] = packed_dims[idx]; @@ -76,7 +76,7 @@ netuarray_t::~netuarray_t() { } -vector netuarray_t::slice_dimensions() const +netranges_t netuarray_t::slice_dimensions() const { return static_dimensions(); } diff --git a/netparray.h b/netparray.h index cb122e5b4..d2f1d8c1e 100644 --- a/netparray.h +++ b/netparray.h @@ -30,24 +30,22 @@ class netsarray_t : public netarray_t { public: - explicit netsarray_t(const std::vector&packed, - ivl_type_t etype); + explicit netsarray_t(const netranges_t&packed, ivl_type_t etype); ~netsarray_t(); public: // Virtual methods from the ivl_type_s type... public: - inline const std::vector& static_dimensions() const + inline const netranges_t& static_dimensions() const { return dims_; } private: - std::vector dims_; + netranges_t dims_; }; -inline netsarray_t::netsarray_t(const std::vector&pd, - ivl_type_t etype) +inline netsarray_t::netsarray_t(const netranges_t&pd, ivl_type_t etype) : netarray_t(etype), dims_(pd) { } @@ -58,23 +56,21 @@ inline netsarray_t::netsarray_t(const std::vector&pd, class netparray_t : public netsarray_t { public: - explicit netparray_t(const std::vector&packed, - ivl_type_t etype); + explicit netparray_t(const netranges_t&packed, ivl_type_t etype); ~netparray_t(); public: // Virtual methods from the ivl_type_s type... bool packed(void) const; long packed_width(void) const; - std::vector slice_dimensions() const; + netranges_t slice_dimensions() const; private: bool test_compatibility(ivl_type_t that) const; bool test_equivalence(ivl_type_t that) const; }; -inline netparray_t::netparray_t(const std::vector&pd, - ivl_type_t etype) +inline netparray_t::netparray_t(const netranges_t&pd, ivl_type_t etype) : netsarray_t(pd, etype) { } @@ -85,20 +81,18 @@ inline netparray_t::netparray_t(const std::vector&pd, class netuarray_t : public netsarray_t { public: - explicit netuarray_t(const std::vector&packed, - ivl_type_t etype); + explicit netuarray_t(const netranges_t&packed, ivl_type_t etype); ~netuarray_t(); public: // Virtual methods from the ivl_type_s type... - std::vector slice_dimensions() const; + netranges_t slice_dimensions() const; private: bool test_equivalence(ivl_type_t that) const; }; -inline netuarray_t::netuarray_t(const std::vector&pd, - ivl_type_t etype) +inline netuarray_t::netuarray_t(const netranges_t&pd, ivl_type_t etype) : netsarray_t(pd, etype) { } diff --git a/netstruct.cc b/netstruct.cc index 8d465c082..3c3dc13f7 100644 --- a/netstruct.cc +++ b/netstruct.cc @@ -115,9 +115,9 @@ long netstruct_t::packed_width(void) const return res; } -vector netstruct_t::slice_dimensions() const +netranges_t netstruct_t::slice_dimensions() const { - vector tmp; + netranges_t tmp; tmp .push_back(netrange_t(packed_width()-1, 0)); return tmp; } diff --git a/netstruct.h b/netstruct.h index b277a84ac..99be27456 100644 --- a/netstruct.h +++ b/netstruct.h @@ -70,7 +70,7 @@ class netstruct_t : public LineInfo, public ivl_type_s { // Return the width (in bits) of the packed record, or -1 if // the record is not packed. long packed_width() const; - std::vector slice_dimensions() const; + netranges_t slice_dimensions() const; // Return the base type of the packed record, or // IVL_VT_NO_TYPE if the record is not packed. diff --git a/nettypes.cc b/nettypes.cc index a426cc5fc..cb36b6f66 100644 --- a/nettypes.cc +++ b/nettypes.cc @@ -42,9 +42,9 @@ long ivl_type_s::packed_width(void) const return 1; } -vector ivl_type_s::slice_dimensions() const +netranges_t ivl_type_s::slice_dimensions() const { - return vector(); + return netranges_t(); } ivl_variable_type_t ivl_type_s::base_type() const @@ -97,11 +97,11 @@ ivl_variable_type_t netarray_t::base_type() const return element_type_->base_type(); } -unsigned long netrange_width(const vector&packed, +unsigned long netrange_width(const netranges_t &packed, unsigned int base_width) { unsigned wid = base_width; - for (vector::const_iterator cur = packed.begin() + for (netranges_t::const_iterator cur = packed.begin() ; cur != packed.end() ; ++cur) { unsigned use_wid = cur->width(); wid *= use_wid; @@ -110,8 +110,7 @@ unsigned long netrange_width(const vector&packed, return wid; } -bool netrange_equivalent(const std::vector &a, - const std::vector &b) +bool netrange_equivalent(const netranges_t &a, const netranges_t &b) { if (a.size() != b.size()) return false; @@ -130,9 +129,8 @@ bool netrange_equivalent(const std::vector &a, * and width of the resulting slice. In this case, the "sb" argument * is an extra index of the prefix. */ -bool prefix_to_slice(const std::vector&dims, - const std::list&prefix, long sb, - long&loff, unsigned long&lwid) +bool prefix_to_slice(const netranges_t&dims, const std::list&prefix, + long sb, long&loff, unsigned long&lwid) { assert(prefix.size() < dims.size()); @@ -143,7 +141,7 @@ bool prefix_to_slice(const std::vector&dims, // this by multiplying the widths of the dims that are NOT // accounted for by the prefix or sb indices. size_t acc_wid = 1; - vector::const_iterator pcur = dims.end(); + netranges_t::const_iterator pcur = dims.end(); for (size_t idx = prefix.size()+1 ; idx < dims.size() ; idx += 1) { -- pcur; acc_wid *= pcur->width(); diff --git a/nettypes.h b/nettypes.h index df2cf457b..6362b6de4 100644 --- a/nettypes.h +++ b/nettypes.h @@ -29,6 +29,8 @@ class netrange_t; class LineInfo; +typedef std::vector netranges_t; + /* * This is a fully abstract type that is a type that can be attached * to a NetNet object. @@ -38,7 +40,7 @@ class ivl_type_s { virtual ~ivl_type_s() =0; virtual bool packed(void) const; virtual long packed_width(void) const; - virtual std::vector slice_dimensions() const; + virtual netranges_t slice_dimensions() const; // Some types have a base variable type. This is the bit type // for packed data types, or IVL_VT_DARRAY or IVL_VT_CLASS for @@ -67,7 +69,7 @@ class ivl_type_s { * Convenience functions for making ivl_type_t objects from various inputs. */ extern ivl_type_t make_ivl_type(ivl_variable_type_t vt, - const std::vector&packed_dimensions, + const netranges_t&packed_dimensions, bool signed_flag =false, bool isint_flag =false); /* @@ -147,12 +149,11 @@ class netrange_t { }; extern std::ostream&operator << (std::ostream&out, const std::list&rlist); -extern std::ostream&operator << (std::ostream&out, const std::vector&rlist); +extern std::ostream&operator << (std::ostream&out, const netranges_t&rlist); -extern unsigned long netrange_width(const std::vector&dims, +extern unsigned long netrange_width(const netranges_t &dims, unsigned int base_width = 1); -extern bool netrange_equivalent(const std::vector &a, - const std::vector &b); +extern bool netrange_equivalent(const netranges_t &a, const netranges_t &b); /* * There are a few cases where we need to know about the single-level @@ -168,7 +169,7 @@ extern bool calculate_param_range(const LineInfo&line, ivl_type_t par_type, * indices, and calculate the offset/width of the resulting slice into * the packed array. */ -extern bool prefix_to_slice(const std::vector&dims, +extern bool prefix_to_slice(const netranges_t&dims, const std::list&prefix, long sb, long&loff, unsigned long&lwid); diff --git a/netvector.cc b/netvector.cc index bc8d83d49..f5b0d6825 100644 --- a/netvector.cc +++ b/netvector.cc @@ -82,7 +82,7 @@ long netvector_t::packed_width() const return netrange_width(packed_dims_); } -vector netvector_t::slice_dimensions() const +netranges_t netvector_t::slice_dimensions() const { return packed_dims_; } diff --git a/netvector.h b/netvector.h index 97778d5d0..e2ea71152 100644 --- a/netvector.h +++ b/netvector.h @@ -26,8 +26,7 @@ class netvector_t : public ivl_type_s { public: - explicit netvector_t(const std::vector&packed, - ivl_variable_type_t type); + explicit netvector_t(const netranges_t&packed, ivl_variable_type_t type); // This is a variant of the vector form. Some code processes // the list of packed ranges as a list, but we will store them @@ -60,11 +59,11 @@ class netvector_t : public ivl_type_s { bool get_implicit() const { return implicit_; } ivl_variable_type_t base_type() const; - const std::vector&packed_dims() const; + const netranges_t&packed_dims() const; bool packed(void) const; long packed_width() const; - std::vector slice_dimensions() const; + netranges_t slice_dimensions() const; std::ostream& debug_dump(std::ostream&) const; @@ -89,20 +88,20 @@ class netvector_t : public ivl_type_s { bool test_equivalence(ivl_type_t that) const; private: - std::vector packed_dims_; + netranges_t packed_dims_; ivl_variable_type_t type_; bool signed_ : 1; bool isint_ : 1; // original type of integer bool implicit_ : 1; }; -inline netvector_t::netvector_t(const std::vector&pd, +inline netvector_t::netvector_t(const netranges_t &pd, ivl_variable_type_t type) : packed_dims_(pd), type_(type), signed_(false), isint_(false), implicit_(false) { } -inline const std::vector& netvector_t::packed_dims() const +inline const netranges_t& netvector_t::packed_dims() const { return packed_dims_; } diff --git a/t-dll-api.cc b/t-dll-api.cc index 17ff59b3d..acb0e6935 100644 --- a/t-dll-api.cc +++ b/t-dll-api.cc @@ -3257,14 +3257,14 @@ extern "C" unsigned ivl_type_packed_width(ivl_type_t net) extern "C" unsigned ivl_type_packed_dimensions(ivl_type_t net) { assert(net); - vector slice = net->slice_dimensions(); + netranges_t slice = net->slice_dimensions(); return slice.size(); } extern "C" int ivl_type_packed_lsb(ivl_type_t net, unsigned dim) { assert(net); - vector slice = net->slice_dimensions(); + netranges_t slice = net->slice_dimensions(); assert(dim < slice.size()); return slice[dim].get_lsb(); } @@ -3272,7 +3272,7 @@ extern "C" int ivl_type_packed_lsb(ivl_type_t net, unsigned dim) extern "C" int ivl_type_packed_msb(ivl_type_t net, unsigned dim) { assert(net); - vector slice = net->slice_dimensions(); + netranges_t slice = net->slice_dimensions(); assert(dim < slice.size()); return slice[dim].get_msb(); } diff --git a/t-dll.cc b/t-dll.cc index feecb3d2b..db9bf3905 100644 --- a/t-dll.cc +++ b/t-dll.cc @@ -2601,7 +2601,7 @@ void dll_target::signal(const NetNet*net) ivl_signal_t object. */ { size_t idx = 0; - vector::const_iterator cur; + netranges_t::const_iterator cur; obj->packed_dims.resize(net->packed_dims().size()); for (cur = net->packed_dims().begin(), idx = 0 ; cur != net->packed_dims().end() ; ++cur, idx += 1) { @@ -2717,7 +2717,7 @@ void dll_target::signal(const NetNet*net) next encounter the nexus. */ if (obj->array_dimensions_ == 1) { - const vector& dims = net->unpacked_dims(); + const netranges_t& dims = net->unpacked_dims(); if (dims[0].get_msb() < dims[0].get_lsb()) { obj->array_base = dims[0].get_msb(); obj->array_addr_swapped = false; diff --git a/t-dll.h b/t-dll.h index 15f727117..9ae6fd58a 100644 --- a/t-dll.h +++ b/t-dll.h @@ -759,7 +759,7 @@ struct ivl_signal_s { /* These encode the declared packed dimensions for the signal, in case they are needed by the run-time */ - std::vector packed_dims; + netranges_t packed_dims; perm_string name_; ivl_scope_t scope_;