diff options
| author | gatecat <gatecat@ds0.me> | 2022-08-10 10:57:17 +0100 | 
|---|---|---|
| committer | gatecat <gatecat@ds0.me> | 2022-08-10 10:57:46 +0100 | 
| commit | 77c82b0fbf15892b0c8222bac89564f3f024493e (patch) | |
| tree | 8b189e44b65afabfaddb3402ab8aac544df9ba83 /common/kernel | |
| parent | 06ce27ed38279cfa3455e248ea2b2c773cdf6324 (diff) | |
| download | nextpnr-77c82b0fbf15892b0c8222bac89564f3f024493e.tar.gz nextpnr-77c82b0fbf15892b0c8222bac89564f3f024493e.tar.bz2 nextpnr-77c82b0fbf15892b0c8222bac89564f3f024493e.zip | |
refactor: id(stringf(...)) to new idf(...) helper
Signed-off-by: gatecat <gatecat@ds0.me>
Diffstat (limited to 'common/kernel')
| -rw-r--r-- | common/kernel/basectx.cc | 12 | ||||
| -rw-r--r-- | common/kernel/basectx.h | 2 | ||||
| -rw-r--r-- | common/kernel/nextpnr_types.cc | 8 | 
3 files changed, 18 insertions, 4 deletions
| diff --git a/common/kernel/basectx.cc b/common/kernel/basectx.cc index 82cdd835..777d06e1 100644 --- a/common/kernel/basectx.cc +++ b/common/kernel/basectx.cc @@ -26,6 +26,18 @@  NEXTPNR_NAMESPACE_BEGIN +IdString BaseCtx::idf(const char *fmt, ...) const +{ +    std::string string; +    va_list ap; + +    va_start(ap, fmt); +    string = vstringf(fmt, ap); +    va_end(ap); + +    return id(string); +} +  const char *BaseCtx::nameOfBel(BelId bel) const  {      const Context *ctx = getCtx(); diff --git a/common/kernel/basectx.h b/common/kernel/basectx.h index 5775e47f..c8791a2b 100644 --- a/common/kernel/basectx.h +++ b/common/kernel/basectx.h @@ -162,6 +162,8 @@ struct BaseCtx      IdString id(const char *s) const { return IdString(this, s); } +    IdString idf(const char *fmt, ...) const; // create IdString using printf formatting +      Context *getCtx() { return as_ctx; }      const Context *getCtx() const { return as_ctx; } diff --git a/common/kernel/nextpnr_types.cc b/common/kernel/nextpnr_types.cc index 8563eb27..6da37763 100644 --- a/common/kernel/nextpnr_types.cc +++ b/common/kernel/nextpnr_types.cc @@ -152,8 +152,8 @@ void CellInfo::movePortBusTo(IdString old_name, int old_offset, bool old_bracket                               IdString new_name, int new_offset, bool new_brackets, int width)  {      for (int i = 0; i < width; i++) { -        IdString old_port = ctx->id(stringf(old_brackets ? "%s[%d]" : "%s%d", old_name.c_str(ctx), i + old_offset)); -        IdString new_port = ctx->id(stringf(new_brackets ? "%s[%d]" : "%s%d", new_name.c_str(ctx), i + new_offset)); +        IdString old_port = ctx->idf(old_brackets ? "%s[%d]" : "%s%d", old_name.c_str(ctx), i + old_offset); +        IdString new_port = ctx->idf(new_brackets ? "%s[%d]" : "%s%d", new_name.c_str(ctx), i + new_offset);          movePortTo(old_port, new_cell, new_port);      }  } @@ -171,8 +171,8 @@ void CellInfo::copyPortBusTo(IdString old_name, int old_offset, bool old_bracket                               IdString new_name, int new_offset, bool new_brackets, int width)  {      for (int i = 0; i < width; i++) { -        IdString old_port = ctx->id(stringf(old_brackets ? "%s[%d]" : "%s%d", old_name.c_str(ctx), i + old_offset)); -        IdString new_port = ctx->id(stringf(new_brackets ? "%s[%d]" : "%s%d", new_name.c_str(ctx), i + new_offset)); +        IdString old_port = ctx->idf(old_brackets ? "%s[%d]" : "%s%d", old_name.c_str(ctx), i + old_offset); +        IdString new_port = ctx->idf(new_brackets ? "%s[%d]" : "%s%d", new_name.c_str(ctx), i + new_offset);          copyPortTo(old_port, new_cell, new_port);      }  } | 
