no need for virtuals in Concrete network objects

This commit is contained in:
James Cherry 2019-06-28 13:38:56 -07:00
parent 88331ab9b1
commit 93f5f9d664
8 changed files with 92 additions and 89 deletions

View File

@ -60,7 +60,7 @@ deleteLiberty()
LibertyLibrary::LibertyLibrary(const char *name,
const char *filename) :
ConcreteLibrary(name, filename),
ConcreteLibrary(name, filename, true),
units_(new Units()),
delay_model_type_(DelayModelType::cmos_linear), // default
nominal_process_(0.0),
@ -137,7 +137,7 @@ LibertyLibrary::~LibertyLibrary()
LibertyCell *
LibertyLibrary::findLibertyCell(const char *name) const
{
return dynamic_cast<LibertyCell*>(findCell(name));
return static_cast<LibertyCell*>(findCell(name));
}
void
@ -832,7 +832,7 @@ LibertyCellIterator::hasNext()
LibertyCell *
LibertyCellIterator::next()
{
return dynamic_cast<LibertyCell*>(iter_.next());
return static_cast<LibertyCell*>(iter_.next());
}
////////////////////////////////////////////////////////////////
@ -898,7 +898,7 @@ LibertyCell::deleteTimingArcAttrs()
LibertyPort *
LibertyCell::findLibertyPort(const char *name) const
{
return dynamic_cast<LibertyPort*>(findPort(name));
return static_cast<LibertyPort*>(findPort(name));
}
void
@ -1751,7 +1751,7 @@ LibertyCellPortIterator::hasNext()
LibertyPort *
LibertyCellPortIterator::next()
{
return dynamic_cast<LibertyPort*>(iter_.next());
return static_cast<LibertyPort*>(iter_.next());
}
////////////////////////////////////////////////////////////////
@ -1775,7 +1775,7 @@ LibertyCellPortBitIterator::hasNext()
LibertyPort *
LibertyCellPortBitIterator::next()
{
return dynamic_cast<LibertyPort*>(iter_->next());
return static_cast<LibertyPort*>(iter_->next());
}
////////////////////////////////////////////////////////////////
@ -1837,13 +1837,13 @@ LibertyPort::setDirection(PortDirection *dir)
LibertyPort *
LibertyPort::findLibertyMember(int index) const
{
return dynamic_cast<LibertyPort*>(findMember(index));
return static_cast<LibertyPort*>(findMember(index));
}
LibertyPort *
LibertyPort::findLibertyBusBit(int index) const
{
return dynamic_cast<LibertyPort*>(findBusBit(index));
return static_cast<LibertyPort*>(findBusBit(index));
}
void
@ -2299,7 +2299,7 @@ LibertyPortMemberIterator::hasNext()
LibertyPort *
LibertyPortMemberIterator::next()
{
return dynamic_cast<LibertyPort*>(iter_->next());
return static_cast<LibertyPort*>(iter_->next());
}
////////////////////////////////////////////////////////////////

View File

@ -114,7 +114,7 @@ class LibertyLibrary : public ConcreteLibrary
public:
LibertyLibrary(const char *name,
const char *filename);
virtual ~LibertyLibrary();
~LibertyLibrary();
LibertyCell *findLibertyCell(const char *name) const;
void findLibertyCellsMatching(PatternMatch *pattern,
LibertyCellSeq *cells);
@ -383,7 +383,7 @@ public:
LibertyCell(LibertyLibrary *library,
const char *name,
const char *filename);
virtual ~LibertyCell();
~LibertyCell();
LibertyLibrary *libertyLibrary() const { return liberty_library_; }
LibertyLibrary *libertyLibrary() { return liberty_library_; }
LibertyPort *findLibertyPort(const char *name) const;
@ -471,11 +471,11 @@ public:
// Add scaled cell after it is complete.
void addScaledCell(OperatingConditions *op_cond,
LibertyCell *scaled_cell);
virtual unsigned addTimingArcSet(TimingArcSet *set);
unsigned addTimingArcSet(TimingArcSet *set);
void addTimingArcAttrs(TimingArcAttrs *attrs);
virtual void addInternalPower(InternalPower *power);
void addInternalPower(InternalPower *power);
void addInternalPowerAttrs(InternalPowerAttrs *attrs);
virtual void addLeakagePower(LeakagePower *power);
void addLeakagePower(LeakagePower *power);
void setLeakagePower(float leakage);
void setOcvArcDepth(float depth);
void setOcvDerate(OcvDerate *derate);
@ -487,9 +487,9 @@ public:
void setCornerCell(LibertyCell *corner_cell,
int ap_index);
// Call after cell is finished being constructed.
virtual void finish(bool infer_latches,
Report *report,
Debug *debug);
void finish(bool infer_latches,
Report *report,
Debug *debug);
bool isBuffer() const;
// Only valid when isBuffer() returns true.
void bufferPorts(// Return values.
@ -497,7 +497,7 @@ public:
LibertyPort *&output);
protected:
virtual void addPort(ConcretePort *port);
void addPort(ConcretePort *port);
void setHasInternalPorts(bool has_internal);
void setLibertyLibrary(LibertyLibrary *library);
void deleteTimingArcAttrs();
@ -513,8 +513,8 @@ protected:
TimingArcSet *setup_check,
Debug *debug);
void findDefaultCondArcs();
virtual void translatePresetClrCheckRoles();
virtual void inferLatchRoles(Debug *debug);
void translatePresetClrCheckRoles();
void inferLatchRoles(Debug *debug);
void deleteInternalPowerAttrs();
void makeTimingArcMap(Report *report);
void makeTimingArcPortMaps();
@ -750,8 +750,8 @@ protected:
int to_index,
bool is_bundle,
ConcretePortSeq *members);
virtual ~LibertyPort();
virtual void setDirection(PortDirection *dir);
~LibertyPort();
void setDirection(PortDirection *dir);
void setMinPort(LibertyPort *min);
void addScaledPort(OperatingConditions *op_cond,
LibertyPort *scaled_port);

View File

@ -19,8 +19,8 @@
// * code is called at the beginning of a library definition
// * a string attribute named "thingy" is parsed
#include "Machine.hh"
#include <stdio.h>
#include "Machine.hh"
#include "StringUtil.hh"
#include "LibertyReader.hh"
#include "LibertyReaderPvt.hh"
@ -222,7 +222,7 @@ BigcoLibertyReader::visitAttr1(LibertyAttr *attr)
if (thingy) {
printf("Bigco thingy attribute value is %s.\n", thingy);
if (cell_)
dynamic_cast<BigcoCell*>(cell_)->setThingy(thingy);
static_cast<BigcoCell*>(cell_)->setThingy(thingy);
}
}
@ -248,8 +248,6 @@ public:
protected:
virtual LibertyLibrary *readLibertyFile(const char *filename,
bool infer_latches,
Report *report,
Debug *debug,
Network *network);
};
@ -262,12 +260,9 @@ BigcoSta::BigcoSta() :
LibertyLibrary *
Sta::readLibertyFile(const char *filename,
bool infer_latches,
Report *report,
Debug *debug,
Network *network)
{
BigcoLibertyBuilder builder;
BigcoLibertyReader reader(&builder);
return reader.readLibertyFile(filename, infer_latches,
report, debug, network);
return reader.readLibertyFile(filename, infer_latches, network);
}

View File

@ -25,9 +25,11 @@
namespace sta {
ConcreteLibrary::ConcreteLibrary(const char *name,
const char *filename) :
const char *filename,
bool is_liberty) :
name_(stringCopy(name)),
filename_(stringCopy(filename)),
is_liberty_(is_liberty),
bus_brkt_left_('['),
bus_brkt_right_(']')
{

View File

@ -48,22 +48,24 @@ class ConcreteLibrary
{
public:
explicit ConcreteLibrary(const char *name,
const char *filename);
virtual ~ConcreteLibrary();
virtual const char *name() const { return name_; }
const char *filename,
bool is_liberty);
~ConcreteLibrary();
const char *name() const { return name_; }
void setName(const char *name);
virtual const char *filename() const { return filename_; }
bool isLiberty() const { return is_liberty_; }
const char *filename() const { return filename_; }
void addCell(ConcreteCell *cell);
virtual ConcreteCell *makeCell(const char *name,
bool is_leaf,
const char *filename);
ConcreteCell *makeCell(const char *name,
bool is_leaf,
const char *filename);
void deleteCell(ConcreteCell *cell);
ConcreteLibraryCellIterator *cellIterator() const;
virtual ConcreteCell *findCell(const char *name) const;
virtual void findCellsMatching(const PatternMatch *pattern,
CellSeq *cells) const;
virtual char busBrktLeft() { return bus_brkt_left_; }
virtual char busBrktRight() { return bus_brkt_right_; }
ConcreteCell *findCell(const char *name) const;
void findCellsMatching(const PatternMatch *pattern,
CellSeq *cells) const;
char busBrktLeft() { return bus_brkt_left_; }
char busBrktRight() { return bus_brkt_right_; }
void setBusBrkts(char left,
char right);
@ -73,6 +75,7 @@ protected:
const char *name_;
const char *filename_;
bool is_liberty_;
char bus_brkt_left_;
char bus_brkt_right_;
ConcreteCellMap cell_map_;
@ -87,19 +90,19 @@ class ConcreteCell
{
public:
// Use ConcreteLibrary::deleteCell.
virtual ~ConcreteCell();
virtual ConcreteLibrary *library() const { return library_; }
virtual const char *name() const { return name_; }
virtual const char *filename() const { return filename_; }
~ConcreteCell();
ConcreteLibrary *library() const { return library_; }
const char *name() const { return name_; }
const char *filename() const { return filename_; }
LibertyCell *libertyCell() const { return liberty_cell_; }
void setLibertyCell(LibertyCell *cell);
virtual int portBitCount() const { return port_bit_count_; }
virtual ConcretePort *findPort(const char *name) const;
virtual void findPortsMatching(const PatternMatch *pattern,
PortSeq *ports) const;
virtual ConcreteCellPortIterator *portIterator() const;
virtual ConcreteCellPortBitIterator *portBitIterator() const;
virtual bool isLeaf() const { return is_leaf_; }
int portBitCount() const { return port_bit_count_; }
ConcretePort *findPort(const char *name) const;
void findPortsMatching(const PatternMatch *pattern,
PortSeq *ports) const;
ConcreteCellPortIterator *portIterator() const;
ConcreteCellPortBitIterator *portBitIterator() const;
bool isLeaf() const { return is_leaf_; }
void setIsLeaf(bool is_leaf);
// Cell acts as port factory.
@ -116,7 +119,7 @@ public:
const char bus_brkt_right);
size_t portCount() const;
void setName(const char *name);
virtual void addPort(ConcretePort *port);
void addPort(ConcretePort *port);
void addPortBit(ConcretePort *port);
protected:
@ -133,8 +136,8 @@ protected:
int from_index,
int to_index);
// Bus port bit (internal to makeBusPortBits).
virtual ConcretePort *makePort(const char *bit_name,
int bit_index);
ConcretePort *makePort(const char *bit_name,
int bit_index);
void makeBusPortBit(ConcretePort *bus_port,
const char *name,
int index);
@ -161,45 +164,45 @@ private:
class ConcretePort
{
public:
virtual ~ConcretePort();
virtual const char *name() const { return name_; }
virtual const char *busName() const;
virtual Cell *cell() const;
virtual ConcreteLibrary *library() const { return cell_->library(); }
virtual PortDirection *direction() const { return direction_; }
~ConcretePort();
const char *name() const { return name_; }
const char *busName() const;
Cell *cell() const;
ConcreteLibrary *library() const { return cell_->library(); }
PortDirection *direction() const { return direction_; }
LibertyPort *libertyPort() { return liberty_port_; }
void setLibertyPort(LibertyPort *port);
virtual void setDirection(PortDirection *dir);
void setDirection(PortDirection *dir);
// Bundles are groups of related ports that do not use
// bus notation.
virtual bool isBundle() const { return is_bundle_; }
virtual bool isBus() const { return is_bus_; }
bool isBundle() const { return is_bundle_; }
bool isBus() const { return is_bus_; }
// Index of cell bit ports.
// Bus/bundle ports do not have an pin index.
virtual int pinIndex() const { return pin_index_; }
int pinIndex() const { return pin_index_; }
void setPinIndex(int index);
// Size is the bus/bundle member count (1 for non-bus/bundle ports).
virtual int size() const;
virtual int fromIndex() const { return from_index_; }
virtual int toIndex() const { return to_index_; }
int size() const;
int fromIndex() const { return from_index_; }
int toIndex() const { return to_index_; }
// Bus member, bus[subscript].
virtual ConcretePort *findBusBit(int index) const;
ConcretePort *findBusBit(int index) const;
// Predicate to determine if subscript is within bus range.
// (toIndex > fromIndex) && fromIndex <= subscript <= toIndex
// || (fromIndex > toIndex) && fromIndex >= subscript >= toIndex
bool busIndexInRange(int index) const;
// A port has members if it is a bundle or bus.
bool hasMembers() const;
virtual ConcretePort *findMember(int index) const;
virtual ConcretePortMemberIterator *memberIterator() const;
ConcretePort *findMember(int index) const;
ConcretePortMemberIterator *memberIterator() const;
void setBusBitIndex(int index);
// Bus bit port functions.
// Bus bit is one bit of a bus port.
virtual bool isBusBit() const;
bool isBusBit() const;
// Bit index within bus port.
// The bit index of A[3] is 3.
virtual int busBitIndex() const { return to_index_; }
int busBitIndex() const { return to_index_; }
ConcretePortSeq *memberPorts() const { return member_ports_; }
void addPortBit(ConcretePort *port);
@ -208,7 +211,7 @@ protected:
ConcretePort(ConcreteCell *cell,
const char *name,
bool is_bus,
int from_index,
int from_index,
int to_index,
bool is_bundle,
ConcretePortSeq *member_ports);

View File

@ -387,10 +387,12 @@ ConcreteLibertyLibraryIterator::findNext()
next_ = nullptr;
while (iter_.hasNext()) {
ConcreteLibrary *lib = iter_.next();
LibertyLibrary *liberty = dynamic_cast<LibertyLibrary*>(lib);
if (liberty) {
next_ = liberty;
break;
if (lib->isLiberty()) {
LibertyLibrary *liberty = static_cast<LibertyLibrary*>(lib);
if (liberty) {
next_ = liberty;
break;
}
}
}
}
@ -407,7 +409,7 @@ Library *
ConcreteNetwork::makeLibrary(const char *name,
const char *filename)
{
ConcreteLibrary *library = new ConcreteLibrary(name, filename);
ConcreteLibrary *library = new ConcreteLibrary(name, filename, false);
addLibrary(library);
return reinterpret_cast<Library*>(library);
}
@ -454,14 +456,14 @@ LibertyLibrary *
ConcreteNetwork::findLiberty(const char *name)
{
ConcreteLibrary *lib = library_map_.findKey(name);
return dynamic_cast<LibertyLibrary*>(lib);
return static_cast<LibertyLibrary*>(lib);
}
LibertyLibrary *
ConcreteNetwork::libertyLibrary(Library *library) const
{
ConcreteLibrary *lib = reinterpret_cast<ConcreteLibrary*>(library);
return dynamic_cast<LibertyLibrary*>(lib);
ConcreteLibrary *lib = reinterpret_cast<ConcreteLibrary*>(library);
return static_cast<LibertyLibrary*>(lib);
}
Cell *

View File

@ -381,7 +381,7 @@ protected:
DISALLOW_COPY_AND_ASSIGN(ConcreteNet);
ConcreteNet(const char *name,
ConcreteInstance *instance);
virtual ~ConcreteNet();
~ConcreteNet();
private:
const char *name_;

View File

@ -579,10 +579,11 @@ proc get_lib_cells { args } {
$regexp $nocase]
if {$matches != {}} {
set cells [concat $cells $matches]
} else {
if {!$quiet} {
sta_warn "cell '$cell_pattern' not found."
}
}
}
if { $cells == {} } {
if {!$quiet} {
sta_warn "cell '$cell_pattern' not found."
}
}
}