Merge remote-tracking branch 'upstream/master' into sta_latest_merge_strings

This commit is contained in:
dsengupta0628
2026-03-30 16:22:27 +00:00
179 changed files with 4275 additions and 4779 deletions
+9 -8
View File
@@ -25,6 +25,7 @@
#pragma once
#include <string>
#include <string_view>
#include <vector>
#include <map>
@@ -103,12 +104,12 @@ protected:
ArcDcalcArg
makeArcDcalcArg(const char *inst_name,
const char *in_port_name,
const char *in_rf_name,
const char *drvr_port_name,
const char *drvr_rf_name,
const char *input_delay_str,
makeArcDcalcArg(std::string_view inst_name,
std::string_view in_port_name,
std::string_view in_rf_name,
std::string_view drvr_port_name,
std::string_view drvr_rf_name,
std::string_view input_delay_str,
const StaState *sta);
// Arc delay calc result.
@@ -161,7 +162,7 @@ public:
ArcDelayCalc(StaState *sta);
virtual ~ArcDelayCalc() {}
virtual ArcDelayCalc *copy() = 0;
virtual const char *name() const = 0;
virtual std::string_view name() const = 0;
// Find the parasitic for drvr_pin that is acceptable to the delay
// calculator by probing parasitics_.
@@ -252,7 +253,7 @@ public:
virtual std::string reportCheckDelay(const Pin *check_pin,
const TimingArc *arc,
const Slew &from_slew,
const char *from_slew_annotation,
std::string_view from_slew_annotation,
const Slew &to_slew,
float related_out_cap,
const Scene *scene,
+9 -16
View File
@@ -41,7 +41,7 @@ class Clock : public SdcCmdComment
{
public:
~Clock();
const char *name() const { return name_; }
const std::string &name() const { return name_; }
float period() const { return period_; }
// Virtual clocks have no pins.
bool isVirtual() const;
@@ -135,14 +135,14 @@ public:
protected:
// Private to Sdc::makeClock.
Clock(const char *name,
Clock(std::string_view name,
int index,
const Network *network);
void initClk(PinSet *pins,
bool add_to_pins,
float period,
FloatSeq *waveform,
const char *comment,
std::string_view comment,
const Network *network);
void initGeneratedClk(PinSet *pins,
bool add_to_pins,
@@ -156,7 +156,7 @@ protected:
IntSeq *edges,
FloatSeq *edge_shifts,
bool is_propagated,
const char *comment,
std::string_view comment,
const Network *network);
void setPins(PinSet *pins,
const Network *network);
@@ -168,7 +168,7 @@ protected:
float scale);
void generateEdgesClk(const Clock *src_clk);
const char *name_;
std::string name_;
PinSet pins_;
bool add_to_pins_;
// Hierarchical pins in pins_ become driver pins through the pin.
@@ -241,7 +241,10 @@ class ClockNameLess
{
public:
bool operator()(const Clock *clk1,
const Clock *clk2);
const Clock *clk2) const
{
return clk1->name() < clk2->name();
}
};
////////////////////////////////////////////////////////////////
@@ -282,16 +285,6 @@ public:
const InterClockUncertainty *inter2) const;
};
class ClkNameLess
{
public:
bool operator()(const Clock *clk1,
const Clock *clk2) const
{
return stringLess(clk1->name(), clk2->name());
}
};
ClockSeq
sortByName(ClockSet *set);
int
+1 -1
View File
@@ -39,7 +39,7 @@ public:
bool physically_exclusive,
bool asynchronous,
bool allow_paths,
const char *comment);
std::string comment);
~ClockGroups();
void makeClockGroup(ClockSet *clks);
const std::string &name() const { return name_; }
+31 -32
View File
@@ -25,6 +25,7 @@
#pragma once
#include <functional>
#include <string_view>
#include <vector>
#include <map>
@@ -45,9 +46,9 @@ class PatternMatch;
class LibertyCell;
class LibertyPort;
using ConcreteCellMap = std::map<std::string, ConcreteCell*>;
using ConcreteCellMap = std::map<std::string, ConcreteCell*, std::less<>>;
using ConcretePortSeq = std::vector<ConcretePort*>;
using ConcretePortMap = std::map<std::string, ConcretePort*>;
using ConcretePortMap = std::map<std::string, ConcretePort*, std::less<>>;
using ConcreteLibraryCellIterator = MapIterator<ConcreteCellMap, ConcreteCell*>;
using ConcreteCellPortIterator = VectorIterator<ConcretePortSeq, ConcretePort*>;
using ConcretePortMemberIterator = VectorIterator<ConcretePortSeq, ConcretePort*>;
@@ -55,22 +56,21 @@ using ConcretePortMemberIterator = VectorIterator<ConcretePortSeq, ConcretePort*
class ConcreteLibrary
{
public:
ConcreteLibrary(const char *name,
const char *filename,
ConcreteLibrary(std::string name,
std::string filename,
bool is_liberty);
virtual ~ConcreteLibrary();
const char *name() const { return name_.c_str(); }
void setName(const char *name);
const std::string &name() const { return name_; }
ObjectId id() const { return id_; }
bool isLiberty() const { return is_liberty_; }
const char *filename() const { return filename_.c_str(); }
const std::string &filename() const { return filename_; }
void addCell(ConcreteCell *cell);
ConcreteCell *makeCell(const char *name,
ConcreteCell *makeCell(std::string_view name,
bool is_leaf,
const char *filename);
std::string_view filename);
void deleteCell(ConcreteCell *cell);
ConcreteLibraryCellIterator *cellIterator() const;
ConcreteCell *findCell(const char *name) const;
ConcreteCell *findCell(std::string_view name) const;
CellSeq findCellsMatching(const PatternMatch *pattern) const;
char busBrktLeft() const { return bus_brkt_left_; }
char busBrktRight() const { return bus_brkt_right_; }
@@ -78,8 +78,7 @@ public:
char right);
protected:
void renameCell(ConcreteCell *cell,
const char *cell_name);
void removeCell(ConcreteCell *cell);
std::string name_;
ObjectId id_;
@@ -98,62 +97,62 @@ class ConcreteCell
public:
// Use ConcreteLibrary::deleteCell.
virtual ~ConcreteCell();
const char *name() const { return name_.c_str(); }
const std::string &name() const { return name_; }
ObjectId id() const { return id_; }
const char *filename() const { return filename_.c_str(); }
const std::string &filename() const { return filename_; }
ConcreteLibrary *library() const { return library_; }
LibertyCell *libertyCell() const { return liberty_cell_; }
void setLibertyCell(LibertyCell *cell);
void *extCell() const { return ext_cell_; }
void setExtCell(void *ext_cell);
int portBitCount() const { return port_bit_count_; }
ConcretePort *findPort(const char *name) const;
ConcretePort *findPort(std::string_view name) const;
PortSeq findPortsMatching(const PatternMatch *pattern) const;
ConcreteCellPortIterator *portIterator() const;
ConcreteCellPortBitIterator *portBitIterator() const;
bool isLeaf() const { return is_leaf_; }
void setIsLeaf(bool is_leaf);
void setAttribute(const std::string &key,
const std::string &value);
std::string getAttribute(const std::string &key) const;
void setAttribute(std::string_view key,
std::string_view value);
std::string getAttribute(std::string_view key) const;
const AttributeMap &attributeMap() const { return attribute_map_; }
// Cell acts as port factory.
ConcretePort *makePort(const char *name);
ConcretePort *makePort(std::string_view name);
// Bus port.
ConcretePort *makeBusPort(const char *name,
ConcretePort *makeBusPort(std::string_view name,
int from_index,
int to_index);
// Bundle port.
ConcretePort *makeBundlePort(const char *name,
ConcretePort *makeBundlePort(std::string_view name,
ConcretePortSeq *members);
// Group previously defined bus bit ports together.
void groupBusPorts(const char bus_brkt_left,
const char bus_brkt_right,
std::function<bool(const char*)> port_msb_first);
std::function<bool(std::string_view)> port_msb_first);
size_t portCount() const;
void setName(const char *name);
void setName(std::string_view name);
void addPort(ConcretePort *port);
void addPortBit(ConcretePort *port);
protected:
ConcreteCell(const char *name,
const char *filename,
ConcreteCell(std::string_view name,
std::string_view filename,
bool is_leaf,
ConcreteLibrary *library);
ConcretePort *makeBusPort(const char *name,
ConcretePort *makeBusPort(std::string_view name,
int from_index,
int to_index,
ConcretePortSeq *members);
void makeBusPortBits(ConcretePort *bus_port,
const char *name,
std::string_view bus_name,
int from_index,
int to_index);
// Bus port bit (internal to makeBusPortBits).
ConcretePort *makePort(const char *bit_name,
ConcretePort *makePort(std::string bit_name,
int bit_index);
void makeBusPortBit(ConcretePort *bus_port,
const char *name,
std::string_view bus_name,
int index);
std::string name_;
@@ -181,9 +180,9 @@ class ConcretePort
{
public:
virtual ~ConcretePort();
const char *name() const { return name_.c_str(); }
const std::string &name() const { return name_; }
ObjectId id() const { return id_; }
const char *busName() const;
std::string busName() const;
Cell *cell() const;
ConcreteLibrary *library() const { return cell_->library(); }
PortDirection *direction() const { return direction_; }
@@ -231,7 +230,7 @@ public:
protected:
// Constructors for factory in cell class.
ConcretePort(const char *name,
ConcretePort(std::string_view name,
bool is_bus,
int from_index,
int to_index,
+57 -57
View File
@@ -25,6 +25,7 @@
#pragma once
#include <functional>
#include <string_view>
#include <vector>
#include <map>
#include <set>
@@ -47,9 +48,9 @@ class ConcreteBindingTbl;
class ConcreteLibertyLibraryIterator;
using ConcreteLibrarySeq = std::vector<ConcreteLibrary*>;
using ConcreteLibraryMap = std::map<const char*, ConcreteLibrary*, CharPtrLess>;
using ConcreteInstanceChildMap = std::map<const char *, ConcreteInstance*, CharPtrLess>;
using ConcreteInstanceNetMap = std::map<const char *, ConcreteNet*, CharPtrLess>;
using ConcreteLibraryMap = std::map<std::string, ConcreteLibrary*, std::less<>>;
using ConcreteInstanceChildMap = std::map<std::string, ConcreteInstance*, std::less<>>;
using ConcreteInstanceNetMap = std::map<std::string, ConcreteNet*, std::less<>>;
using ConcreteNetSeq = std::vector<ConcreteNet*>;
using ConcretePinSeq = std::vector<ConcretePin*>;
using CellNetworkViewMap = std::map<Cell*, Instance*>;
@@ -63,26 +64,26 @@ public:
ConcreteNetwork();
~ConcreteNetwork();
void clear() override;
bool linkNetwork(const char *top_cell_name,
bool linkNetwork(std::string_view top_cell_name,
bool make_black_boxes,
Report *report) override;
Instance *topInstance() const override;
const char *name(const Library *library) const override;
std::string name(const Library *library) const override;
ObjectId id(const Library *library) const override;
LibraryIterator *libraryIterator() const override;
LibertyLibraryIterator *libertyLibraryIterator() const override;
Library *findLibrary(const char *name) override;
LibertyLibrary *findLiberty(const char *name) override;
Library *findLibrary(std::string_view name) override;
LibertyLibrary *findLiberty(std::string_view name) override;
Cell *findCell(const Library *library,
const char *name) const override;
Cell *findAnyCell(const char *name) override;
std::string_view name) const override;
Cell *findAnyCell(std::string_view name) override;
CellSeq findCellsMatching(const Library *library,
const PatternMatch *pattern) const override;
const char *name(const Cell *cell) const override;
std::string name(const Cell *cell) const override;
std::string getAttribute(const Cell *cell,
const std::string &key) const override;
std::string_view key) const override;
const AttributeMap &attributeMap(const Cell *cell) const override;
ObjectId id(const Cell *cell) const override;
Library *library(const Cell *cell) const override;
@@ -90,15 +91,15 @@ public:
const LibertyCell *libertyCell(const Cell *cell) const override;
Cell *cell(LibertyCell *cell) const override;
const Cell *cell(const LibertyCell *cell) const override;
const char *filename(const Cell *cell) override;
std::string_view filename(const Cell *cell) const override;
Port *findPort(const Cell *cell,
const char *name) const override;
std::string_view name) const override;
bool isLeaf(const Cell *cell) const override;
CellPortIterator *portIterator(const Cell *cell) const override;
CellPortBitIterator *portBitIterator(const Cell *cell) const override;
int portBitCount(const Cell *cell) const override;
const char *name(const Port *port) const override;
std::string name(const Port *port) const override;
ObjectId id(const Port *port) const override;
Cell *cell(const Port *port) const override;
LibertyPort *libertyPort(const Port *port) const override;
@@ -108,7 +109,7 @@ public:
bool isBus(const Port *port) const override;
int size(const Port *port) const override;
const char *busName(const Port *port) const override;
std::string busName(const Port *port) const override;
Port *findBusBit(const Port *port,
int index) const override;
int fromIndex(const Port *port) const override;
@@ -117,18 +118,18 @@ public:
int index) const override;
PortMemberIterator *memberIterator(const Port *port) const override;
const char *name(const Instance *instance) const override;
std::string name(const Instance *instance) const override;
std::string getAttribute(const Instance *inst,
const std::string &key) const override;
std::string_view key) const override;
const AttributeMap &attributeMap(const Instance *inst) const override;
ObjectId id(const Instance *instance) const override;
Cell *cell(const Instance *instance) const override;
Instance *parent(const Instance *instance) const override;
bool isLeaf(const Instance *instance) const override;
Instance *findChild(const Instance *parent,
const char *name) const override;
std::string_view name) const override;
Pin *findPin(const Instance *instance,
const char *port_name) const override;
std::string_view port_name) const override;
Pin *findPin(const Instance *instance,
const Port *port) const override;
@@ -153,10 +154,10 @@ public:
Net *net(const Term *term) const override;
Pin *pin(const Term *term) const override;
const char *name(const Net *net) const override;
std::string name(const Net *net) const override;
ObjectId id(const Net *net) const override;
Net *findNet(const Instance *instance,
const char *net_name) const override;
std::string_view net_name) const override;
void findInstNetsMatching(const Instance *instance,
const PatternMatch *pattern,
NetSeq &matches) const override;
@@ -174,44 +175,44 @@ public:
LogicValue value) override;
// Edit methods.
Library *makeLibrary(const char *name,
const char *filename) override;
LibertyLibrary *makeLibertyLibrary(const char *name,
const char *filename) override;
Library *makeLibrary(std::string_view name,
std::string_view filename) override;
LibertyLibrary *makeLibertyLibrary(std::string_view name,
std::string_view filename) override;
void deleteLibrary(Library *library) override;
Cell *makeCell(Library *library,
const char *name,
std::string_view name,
bool is_leaf,
const char *filename) override;
std::string_view filename) override;
void deleteCell(Cell *cell) override;
void setName(Cell *cell,
const char *name) override;
std::string_view name) override;
void setIsLeaf(Cell *cell,
bool is_leaf) override;
void setAttribute(Cell *cell,
const std::string &key,
const std::string &value) override;
std::string_view key,
std::string_view value) override;
Port *makePort(Cell *cell,
const char *name) override;
std::string_view name) override;
Port *makeBusPort(Cell *cell,
const char *name,
std::string_view name,
int from_index,
int to_index) override;
void groupBusPorts(Cell *cell,
std::function<bool(const char*)> port_msb_first) override;
std::function<bool(std::string_view)> port_msb_first) override;
Port *makeBundlePort(Cell *cell,
const char *name,
std::string_view name,
PortSeq *members) override;
void setDirection(Port *port,
PortDirection *dir) override;
// For NetworkEdit.
Instance *makeInstance(LibertyCell *cell,
const char *name,
std::string_view name,
Instance *parent) override;
void makePins(Instance *inst) override;
// For linking.
Instance *makeInstance(Cell *cell,
const char *name,
std::string_view name,
Instance *parent) override;
void replaceCell(Instance *inst,
Cell *cell) override;
@@ -223,11 +224,11 @@ public:
LibertyPort *port,
Net *net) override;
void setAttribute(Instance *inst,
const std::string &key,
const std::string &value) override;
std::string_view key,
std::string_view value) override;
void disconnectPin(Pin *pin) override;
void deletePin(Pin *pin) override;
Net *makeNet(const char *name,
Net *makeNet(std::string_view name,
Instance *parent) override;
void deleteNet(Net *net) override;
@@ -263,13 +264,13 @@ public:
protected:
void addLibrary(ConcreteLibrary *library);
void setName(const char *name);
void setName(std::string_view name);
void clearConstantNets();
void visitConnectedPins(const Net *net,
PinVisitor &visitor,
NetSet &visited_nets) const override;
Instance *makeConcreteInstance(ConcreteCell *cell,
const char *name,
std::string_view name,
Instance *parent);
void disconnectNetPin(ConcreteNet *cnet,
ConcretePin *cpin);
@@ -292,40 +293,40 @@ private:
class ConcreteInstance
{
public:
const char *name() const { return name_; }
std::string_view name() const { return name_; }
ObjectId id() const { return id_; }
Cell *cell() const;
ConcreteInstance *parent() const { return parent_; }
ConcretePin *findPin(const char *port_name) const;
ConcretePin *findPin(std::string_view port_name) const;
ConcretePin *findPin(const Port *port) const;
ConcreteNet *findNet(const char *net_name) const;
ConcreteNet *findNet(std::string_view net_name) const;
void findNetsMatching(const PatternMatch *pattern,
NetSeq &matches) const;
InstanceNetIterator *netIterator() const;
Instance *findChild(const char *name) const;
Instance *findChild(std::string_view name) const;
InstanceChildIterator *childIterator() const;
void setAttribute(const std::string &key,
const std::string &value);
std::string getAttribute(const std::string &key) const;
void setAttribute(std::string_view key,
std::string_view value);
std::string getAttribute(std::string_view key) const;
const AttributeMap &attributeMap() const { return attribute_map_; }
void addChild(ConcreteInstance *child);
void deleteChild(ConcreteInstance *child);
void addPin(ConcretePin *pin);
void deletePin(ConcretePin *pin);
void addNet(ConcreteNet *net);
void addNet(const char *name,
void addNet(std::string_view name,
ConcreteNet *net);
void deleteNet(ConcreteNet *net);
void setCell(ConcreteCell *cell);
void initPins();
protected:
ConcreteInstance(const char *name,
ConcreteInstance(std::string_view name,
ConcreteCell *cell,
ConcreteInstance *parent);
~ConcreteInstance();
const char *name_;
std::string name_;
ObjectId id_;
ConcreteCell *cell_;
ConcreteInstance *parent_;
@@ -343,7 +344,7 @@ private:
class ConcretePin
{
public:
const char *name() const;
std::string_view name() const;
ConcreteInstance *instance() const { return instance_; }
ConcreteNet *net() const { return net_; }
ConcretePort *port() const { return port_; }
@@ -377,7 +378,7 @@ private:
class ConcreteTerm
{
public:
const char *name() const;
std::string_view name() const;
ObjectId id() const { return id_; }
ConcreteNet *net() const { return net_; }
ConcretePin *pin() const { return pin_; }
@@ -402,7 +403,7 @@ private:
class ConcreteNet
{
public:
const char *name() const { return name_; }
std::string_view name() const { return name_; }
ObjectId id() const { return id_; }
ConcreteInstance *instance() const { return instance_; }
void addPin(ConcretePin *pin);
@@ -413,10 +414,9 @@ public:
ConcreteNet *mergedInto() { return merged_into_; }
protected:
ConcreteNet(const char *name,
ConcreteNet(std::string_view name,
ConcreteInstance *instance);
~ConcreteNet();
const char *name_;
std::string name_;
ObjectId id_;
ConcreteInstance *instance_;
// Pointer to head of linked list of pins.
+47 -19
View File
@@ -143,7 +143,7 @@ struct find_return<C, false>
};
// Find an pointer value in a reference to a contaiiner of pointers.
// Find a pointer value in a reference to a contaiiner of pointers.
// Return nullptr if not found.
template<typename AssocContainer>
auto
@@ -166,29 +166,24 @@ findKey(const AssocContainer& c,
return *it; // set
}
// Find an pointer value in a pointer to a contaiiner of pointers.
// Find a pointer value in a reference to a map that uses strings as keys.
// Return nullptr if not found.
template<typename AssocContainer>
auto
findKey(const AssocContainer *c,
typename AssocContainer::key_type key)
findStringKey(const AssocContainer& c,
std::string_view key)
-> typename find_return<AssocContainer>::type
{
using ReturnType = typename find_return<AssocContainer>::type;
static_assert(std::is_pointer_v<ReturnType>,
"findKey requires pointer types");
"findStringKey requires pointer types");
auto it = c->find(key);
if (it == c->end())
auto it = c.find(key);
if (it == c.end())
return nullptr;
if constexpr (has_mapped_type<AssocContainer>::value)
// map
return it->second;
else
// set
return *it;
return it->second;
}
////////////////////////////////////////////////////////////////
@@ -212,7 +207,7 @@ findKeyValue(const AssocContainer& c,
return empty;
}
// Find an value reference in a reference to a contaiiner of objects.
// Find a value reference in a reference to a contaiiner of objects.
// Return exists.
template<typename AssocContainer>
void
@@ -239,7 +234,7 @@ findKeyValue(const AssocContainer& c,
}
}
// Find an value reference in a pointer to a contaiiner of objects.
// Find a value reference in a pointer to a contaiiner of objects.
// Return exists.
template<typename AssocContainer>
void
@@ -268,7 +263,8 @@ findKeyValue(const AssocContainer *c,
////////////////////////////////////////////////////////////////
// Find an value pointer in a reference to a contaiiner of objects.
// Find a value pointer in a reference to a contaiiner of objects.
// Return nullptr if not found.
template<typename AssocContainer>
auto
findKeyValuePtr(AssocContainer& c,
@@ -283,17 +279,17 @@ findKeyValuePtr(AssocContainer& c,
// map
return &it->second;
else
// set
// sett
return *it;
}
// Find an pointger to a value in a const reference to a contaiiner objects.
// Find a value pointer in a reference to a contaiiner of objects.
// Return nullptr if not found.
template<typename AssocContainer>
auto
findKeyValuePtr(const AssocContainer& c,
typename AssocContainer::key_type key)
-> const typename find_return<AssocContainer>::type*
-> typename find_return<AssocContainer>::type const*
{
auto it = c.find(key);
if (it == c.end())
@@ -307,6 +303,38 @@ findKeyValuePtr(const AssocContainer& c,
return *it;
}
// Find a pointer to a value in a reference to a contaiiner of objects
// using std::string as the key.
// Return nullptr if not found.
template<typename AssocContainer>
auto
findStringValuePtr(AssocContainer& c,
std::string_view key)
-> typename find_return<AssocContainer>::type*
{
auto it = c.find(key);
if (it == c.end())
return nullptr;
else
return &it->second;
}
// Find a const pointer to a value in a const reference to a contaiiner objects
// using std::string as the key.
// Return nullptr if not found.
template<typename AssocContainer>
auto
findStringValuePtr(const AssocContainer& c,
std::string_view key)
-> typename find_return<AssocContainer>::type const*
{
auto it = c.find(key);
if (it == c.end())
return nullptr;
else
return &it->second;
}
////////////////////////////////////////////////////////////////
// Determine if two std::set's intersect.
+5 -5
View File
@@ -38,20 +38,20 @@ namespace sta {
class Report;
class Pin;
using DebugMap = std::map<std::string, int>;
using DebugMap = std::map<std::string, int, std::less<>>;
class Debug
{
public:
Debug(Report *report);
int level(const char *what);
void setLevel(const char *what,
int level(std::string_view what);
void setLevel(std::string_view what,
int level);
bool check(const char *what,
bool check(std::string_view what,
int level) const;
int statsLevel() const { return stats_level_; }
template <typename... Args>
void report(const char *what,
void report(std::string_view what,
std::string_view fmt,
Args &&...args)
{
+4 -3
View File
@@ -25,6 +25,7 @@
#pragma once
#include <string>
#include <string_view>
#include "StringUtil.hh"
@@ -40,10 +41,10 @@ void
registerDelayCalcs();
// Register a delay calculator for the set_delay_calc command.
void
registerDelayCalc(const std::string &name,
registerDelayCalc(std::string_view name,
MakeArcDelayCalc maker);
bool
isDelayCalcName(const std::string &name);
isDelayCalcName(std::string_view name);
StringSeq
delayCalcNames();
void
@@ -51,7 +52,7 @@ deleteDelayCalcs();
// Make a registered delay calculator by name.
ArcDelayCalc *
makeDelayCalc(const std::string &name,
makeDelayCalc(std::string_view name,
StaState *sta);
} // namespace
+12 -10
View File
@@ -35,17 +35,17 @@ class EnumNameMap
{
public:
EnumNameMap(std::initializer_list<std::pair<const ENUM, std::string>> enum_names);
const char *find(ENUM key) const;
ENUM find(std::string name,
const std::string &find(ENUM key) const;
ENUM find(std::string_view name,
ENUM unknown_key) const;
void find(std::string name,
void find(std::string_view name,
// Return values.
ENUM &key,
bool &exists) const;
private:
std::map<ENUM, std::string> enum_map_;
std::map<std::string, ENUM> name_map_;
std::map<std::string, ENUM, std::less<>> name_map_;
};
template <class ENUM>
@@ -57,19 +57,21 @@ EnumNameMap<ENUM>::EnumNameMap(std::initializer_list<std::pair<const ENUM,std::s
}
template <class ENUM>
const char *
const std::string&
EnumNameMap<ENUM>::find(ENUM key) const
{
auto find_iter = enum_map_.find(key);
if (find_iter != enum_map_.end())
return find_iter->second.c_str();
else
return nullptr;
return find_iter->second;
else {
static std::string null_ref;
return null_ref;
}
}
template <class ENUM>
void
EnumNameMap<ENUM>::find(std::string name,
EnumNameMap<ENUM>::find(std::string_view name,
// Return values.
ENUM &key,
bool &exists) const
@@ -85,7 +87,7 @@ EnumNameMap<ENUM>::find(std::string name,
template <class ENUM>
ENUM
EnumNameMap<ENUM>::find(std::string name,
EnumNameMap<ENUM>::find(std::string_view name,
ENUM unknown_key) const
{
auto find_iter = name_map_.find(name);
+7 -9
View File
@@ -37,7 +37,7 @@ class Exception : public std::exception
public:
Exception();
virtual ~Exception() {}
virtual const char *what() const noexcept = 0;
const char *what() const noexcept override = 0;
};
class ExceptionMsg : public Exception
@@ -45,8 +45,8 @@ class ExceptionMsg : public Exception
public:
ExceptionMsg(const std::string &msg,
const bool suppressed);
virtual const char *what() const noexcept;
virtual bool suppressed() const { return suppressed_; }
const char *what() const noexcept override;
bool suppressed() const { return suppressed_; }
private:
std::string msg_;
@@ -68,11 +68,10 @@ protected:
class FileNotReadable : public Exception
{
public:
FileNotReadable(std::string filename);
virtual const char *what() const noexcept;
FileNotReadable(std::string_view filename);
const char *what() const noexcept override;
protected:
std::string filename_;
std::string msg_;
};
@@ -80,11 +79,10 @@ protected:
class FileNotWritable : public Exception
{
public:
FileNotWritable(std::string filename);
virtual const char *what() const noexcept;
FileNotWritable(std::string_view filename);
const char *what() const noexcept override;
protected:
std::string filename_;
std::string msg_;
};
+10 -9
View File
@@ -25,6 +25,7 @@
#pragma once
#include <string>
#include <string_view>
#include <vector>
#include "Error.hh"
@@ -57,7 +58,7 @@ public:
const MinMaxAll *min_max,
bool own_pts,
int priority,
const char *comment);
std::string_view comment);
virtual ~ExceptionPath();
size_t id() const { return id_; }
void setId(size_t id);
@@ -128,7 +129,7 @@ public:
virtual bool useEndClk() const { return false; }
virtual int pathMultiplier() const { return 0; }
virtual float delay() const { return 0.0; }
virtual std::string name() const { return ""; }
virtual std::string_view name() const { return {}; }
virtual bool isDefault() const { return false; }
virtual bool ignoreClkLatency() const { return false; }
virtual bool breakPath() const { return false; }
@@ -157,14 +158,14 @@ public:
ExceptionTo *to,
const MinMaxAll *min_max,
bool own_pts,
const char *comment);
std::string_view comment);
FalsePath(ExceptionFrom *from,
ExceptionThruSeq *thrus,
ExceptionTo *to,
const MinMaxAll *min_max,
bool own_pts,
int priority,
const char *comment);
std::string_view comment);
ExceptionPath *clone(ExceptionFrom *from,
ExceptionThruSeq *thrus,
ExceptionTo *to,
@@ -203,7 +204,7 @@ public:
bool break_path,
float delay,
bool own_pts,
const char *comment);
std::string_view comment);
ExceptionPath *clone(ExceptionFrom *from,
ExceptionThruSeq *thrus,
ExceptionTo *to,
@@ -237,7 +238,7 @@ public:
bool use_end_clk,
int path_multiplier,
bool own_pts,
const char *comment);
std::string_view comment);
ExceptionPath *clone(ExceptionFrom *from,
ExceptionThruSeq *thrus,
ExceptionTo *to,
@@ -293,13 +294,13 @@ public:
class GroupPath : public ExceptionPath
{
public:
GroupPath(const std::string &name,
GroupPath(std::string_view name,
bool is_default,
ExceptionFrom *from,
ExceptionThruSeq *thrus,
ExceptionTo *to,
bool own_pts,
const char *comment);
std::string_view comment);
~GroupPath() override;
ExceptionPath *clone(ExceptionFrom *from,
ExceptionThruSeq *thrus,
@@ -312,7 +313,7 @@ public:
bool overrides(ExceptionPath *exception) const override;
int typePriority() const override;
bool tighterThan(ExceptionPath *exception) const override;
std::string name() const override { return name_; }
std::string_view name() const override { return name_; }
bool isDefault() const override { return is_default_; }
protected:
+2 -2
View File
@@ -220,7 +220,7 @@ protected:
PinVertexMap pin_bidirect_drvr_vertex_map_;
DcalcAPIndex ap_count_;
// Sdf period check annotations.
PeriodCheckAnnotations *period_check_annotations_;
PeriodCheckAnnotations period_check_annotations_;
// Register/latch clock vertices to search from.
VertexSet reg_clk_vertices_;
@@ -241,7 +241,7 @@ public:
// Pin path with load/driver suffix for bidirects.
std::string to_string(const StaState *sta) const;
// compatibility
const char *name(const Network *network) const;
std::string name(const Network *network) const;
[[nodiscard]] bool isBidirectDriver() const { return is_bidirect_drvr_; }
[[nodiscard]] bool isDriver(const Network *network) const;
Level level() const { return level_; }
+2 -1
View File
@@ -26,6 +26,7 @@
#include <cstdint>
#include <cstddef>
#include <string_view>
namespace sta {
@@ -56,7 +57,7 @@ nextMersenne(size_t n)
// Sadly necessary until c++ std::hash works for char *.
size_t
hashString(const char *str);
hashString(std::string_view str);
// Pointer hashing is strongly discouraged because it causes results to change
// from run to run. Use Network::id functions instead.
+73 -76
View File
@@ -31,6 +31,7 @@
#include <set>
#include <map>
#include <string>
#include <string_view>
#include <vector>
#include "ContainerHelpers.hh"
@@ -68,7 +69,7 @@ class DriverWaveform;
class ModeValueDef
{
public:
ModeValueDef(std::string value, FuncExpr *cond, std::string sdf_cond);
ModeValueDef(std::string value);
ModeValueDef(ModeValueDef &&other) noexcept;
~ModeValueDef();
const std::string &value() const { return value_; }
@@ -115,14 +116,14 @@ private:
TimingArcSet *setup_check_;
};
using TableTemplateMap = std::map<std::string, TableTemplate>;
using TableTemplateMap = std::map<std::string, TableTemplate, std::less<>>;
using TableTemplateSeq = std::vector<TableTemplate*>;
using BusDclMap = std::map<std::string, BusDcl>;
using BusDclMap = std::map<std::string, BusDcl, std::less<>>;
using BusDclSeq = std::vector<BusDcl*>;
using ScaleFactorsMap = std::map<std::string, ScaleFactors>;
using WireloadMap = std::map<std::string, Wireload>;
using WireloadSelectionMap = std::map<std::string, WireloadSelection>;
using OperatingConditionsMap = std::map<std::string, OperatingConditions>;
using ScaleFactorsMap = std::map<std::string, ScaleFactors, std::less<>>;
using WireloadMap = std::map<std::string, Wireload, std::less<>>;
using WireloadSelectionMap = std::map<std::string, WireloadSelection, std::less<>>;
using OperatingConditionsMap = std::map<std::string, OperatingConditions, std::less<>>;
using PortToSequentialMap = std::map<LibertyPort*, size_t>;
using TimingArcSetSeq = std::vector<TimingArcSet*>;
using TimingArcSetSet = std::set<TimingArcSet*, TimingArcSetLess>;
@@ -135,13 +136,13 @@ using PortInternalPowerMap = std::map<const LibertyPort *, InternalPowerIndexSeq
using LeakagePowerSeq = std::vector<LeakagePower>;
using ScaledCellMap = std::map<const OperatingConditions*, LibertyCell*>;
using ScaledPortMap = std::map<const OperatingConditions*, LibertyPort*>;
using ModeDefMap = std::map<std::string, ModeDef>;
using ModeValueMap = std::map<std::string, ModeValueDef>;
using ModeDefMap = std::map<std::string, ModeDef, std::less<>>;
using ModeValueMap = std::map<std::string, ModeValueDef, std::less<>>;
using LatchEnableIndexMap = std::map<const TimingArcSet*, size_t>;
using LatchEnableSeq = std::vector<LatchEnable>;
using OcvDerateMap = std::map<std::string, OcvDerate>;
using SupplyVoltageMap = std::map<std::string, float>;
using DriverWaveformMap = std::map<std::string, DriverWaveform>;
using OcvDerateMap = std::map<std::string, OcvDerate, std::less<>>;
using SupplyVoltageMap = std::map<std::string, float, std::less<>>;
using DriverWaveformMap = std::map<std::string, DriverWaveform, std::less<>>;
using SceneSeq = std::vector<Scene*>;
enum class ClockGateType { none, latch_posedge, latch_negedge, other };
@@ -175,13 +176,13 @@ void
deleteLiberty();
ScaleFactorPvt
findScaleFactorPvt(const char *name);
const char *
findScaleFactorPvt(std::string_view name);
const std::string&
scaleFactorPvtName(ScaleFactorPvt pvt);
ScaleFactorType
findScaleFactorType(const char *name);
const char *
findScaleFactorType(std::string_view name);
const std::string&
scaleFactorTypeName(ScaleFactorType type);
bool
scaleFactorTypeRiseFallSuffix(ScaleFactorType type);
@@ -191,7 +192,7 @@ bool
scaleFactorTypeLowHighSuffix(ScaleFactorType type);
// Timing sense as a string.
const char *
const std::string&
to_string(TimingSense sense);
// Opposite timing sense.
@@ -203,10 +204,10 @@ timingSenseOpposite(TimingSense sense);
class LibertyLibrary : public ConcreteLibrary
{
public:
LibertyLibrary(const char *name,
const char *filename);
LibertyLibrary(std::string name,
std::string filename);
virtual ~LibertyLibrary();
LibertyCell *findLibertyCell(const char *name) const;
LibertyCell *findLibertyCell(std::string_view name) const;
LibertyCellSeq findLibertyCellsMatching(PatternMatch *pattern);
// Liberty cells that are buffers.
LibertyCellSeq *buffers();
@@ -214,12 +215,14 @@ public:
DelayModelType delayModelType() const { return delay_model_type_; }
void setDelayModelType(DelayModelType type);
BusDcl *makeBusDcl(std::string name, int from, int to);
BusDcl *findBusDcl(const char *name) const;
BusDcl *makeBusDcl(std::string name,
int from,
int to);
BusDcl *findBusDcl(std::string_view name);
BusDclSeq busDcls() const;
TableTemplate *makeTableTemplate(std::string name,
TableTemplateType type);
TableTemplate *findTableTemplate(const char *name,
TableTemplate *findTableTemplate(std::string_view name,
TableTemplateType type);
TableTemplateSeq tableTemplates() const;
TableTemplateSeq tableTemplates(TableTemplateType type) const;
@@ -232,8 +235,8 @@ public:
void setScaleFactors(ScaleFactors *scales);
// Make named scale factor group. Returns pointer to the inserted element.
ScaleFactors *makeScaleFactors(const char *name);
ScaleFactors *findScaleFactors(const char *name);
ScaleFactors *makeScaleFactors(std::string name);
ScaleFactors *findScaleFactors(std::string_view name);
ScaleFactors *scaleFactors() const { return scale_factors_; }
float scaleFactor(ScaleFactorType type,
const Pvt *pvt) const;
@@ -334,18 +337,18 @@ public:
const Units *units() const { return units_; }
Wireload *makeWireload(std::string name);
const Wireload *findWireload(const char *name) const;
const Wireload *findWireload(std::string_view name);
void setDefaultWireload(const Wireload *wireload);
const Wireload *defaultWireload() const;
WireloadSelection *makeWireloadSelection(std::string name);
const WireloadSelection *findWireloadSelection(const char *name) const;
const WireloadSelection *findWireloadSelection(std::string_view name) const;
const WireloadSelection *defaultWireloadSelection() const;
WireloadMode defaultWireloadMode() const;
void setDefaultWireloadMode(WireloadMode mode);
void setDefaultWireloadSelection(const WireloadSelection *selection);
OperatingConditions *makeOperatingConditions(std::string name);
OperatingConditions *findOperatingConditions(const char *name);
OperatingConditions *findOperatingConditions(std::string_view name);
OperatingConditions *defaultOperatingConditions() const;
void setDefaultOperatingConditions(OperatingConditions *op_cond);
@@ -356,18 +359,18 @@ public:
OcvDerate *defaultOcvDerate() const;
void setDefaultOcvDerate(OcvDerate *derate);
OcvDerate *makeOcvDerate(std::string name);
OcvDerate *findOcvDerate(const char *derate_name);
void addSupplyVoltage(const char *suppy_name,
OcvDerate *findOcvDerate(std::string_view derate_name);
void addSupplyVoltage(std::string suppy_name,
float voltage);
bool supplyExists(const char *suppy_name) const;
void supplyVoltage(const char *supply_name,
bool supplyExists(std::string_view supply_name) const;
void supplyVoltage(std::string_view supply_name,
// Return value.
float &voltage,
bool &exists) const;
// Make scaled cell. Call LibertyCell::addScaledCell after it is complete.
LibertyCell *makeScaledCell(const char *name,
const char *filename);
LibertyCell *makeScaledCell(std::string name,
std::string filename);
static void
makeSceneMap(LibertyLibrary *lib,
@@ -390,9 +393,9 @@ public:
const SceneSeq &scenes,
Report *report);
DriverWaveform *findDriverWaveform(const char *name);
DriverWaveform *findDriverWaveform(std::string_view name);
DriverWaveform *driverWaveformDefault() { return findDriverWaveform(""); }
DriverWaveform *makeDriverWaveform(const std::string &name,
DriverWaveform *makeDriverWaveform(std::string name,
TablePtr waveforms);
protected:
@@ -471,18 +474,18 @@ class LibertyCell : public ConcreteCell
{
public:
LibertyCell(LibertyLibrary *library,
const char *name,
const char *filename);
std::string name,
std::string filename);
virtual ~LibertyCell();
LibertyLibrary *libertyLibrary() const { return liberty_library_; }
LibertyLibrary *libertyLibrary() { return liberty_library_; }
LibertyPort *findLibertyPort(const char *name) const;
LibertyPort *findLibertyPort(std::string_view name) const;
LibertyPortSeq findLibertyPortsMatching(PatternMatch *pattern) const;
bool hasInternalPorts() const { return has_internal_ports_; }
ScaleFactors *scaleFactors() const { return scale_factors_; }
void setScaleFactors(ScaleFactors *scale_factors);
ModeDef *makeModeDef(std::string name);
const ModeDef *findModeDef(const char *name) const;
const ModeDef *findModeDef(std::string_view name) const;
float area() const { return area_; }
void setArea(float area);
@@ -541,8 +544,10 @@ public:
const Statetable *statetable() const { return statetable_; }
// Find bus declaration local to this cell.
BusDcl *makeBusDcl(std::string name, int from, int to);
BusDcl *findBusDcl(const char *name) const;
BusDcl *makeBusDcl(std::string name,
int from,
int to);
BusDcl *findBusDcl(std::string_view name);
// True when TimingArcSetBuilder::makeRegLatchArcs infers register
// timing arcs.
bool hasInferedRegTimingArcs() const { return has_infered_reg_timing_arcs_; }
@@ -561,7 +566,7 @@ public:
float ocvArcDepth() const;
OcvDerate *ocvDerate() const;
OcvDerate *makeOcvDerate(std::string name);
OcvDerate *findOcvDerate(const char *derate_name);
OcvDerate *findOcvDerate(std::string_view derate_name);
// Build helpers.
void makeSequential(int size,
@@ -614,10 +619,10 @@ public:
// for all the defined scenes.
static void checkLibertyScenes();
void ensureVoltageWaveforms(const SceneSeq &scenes);
const char *footprint() const;
void setFootprint(const char *footprint);
const char *userFunctionClass() const;
void setUserFunctionClass(const char *user_function_class);
const std::string &footprint() const { return footprint_; }
void setFootprint(std::string footprint);
const std::string &userFunctionClass() const { return user_function_class_; }
void setUserFunctionClass(std::string user_function_class);
protected:
void addPort(ConcretePort *port);
@@ -752,8 +757,8 @@ public:
bool isPwrGnd() const;
PwrGndType pwrGndType() const { return pwr_gnd_type_; }
void setPwrGndType(PwrGndType type);
const char *voltageName() const { return voltage_name_.c_str(); }
void setVoltageName(const char *voltage_name);
const std::string &voltageName() const { return voltage_name_; }
void setVoltageName(std::string voltage_name);
////////////////////////////////////////////////////////////////
ScanSignalType scanSignalType() const { return scan_signal_type_; }
@@ -876,10 +881,10 @@ public:
const LibertyPort *scenePort(int ap_index) const;
void setScenePort(LibertyPort *scene_port,
int ap_index);
const char *relatedGroundPin() const;
void setRelatedGroundPin(const char *related_ground_pin);
const char *relatedPowerPin() const;
void setRelatedPowerPin(const char *related_power_pin);
LibertyPort *relatedGroundPort() const { return related_ground_port_; }
void setRelatedGroundPort(LibertyPort *related_ground_port);
LibertyPort *relatedPowerPort() const { return related_power_port_; }
void setRelatedPowerPort(LibertyPort *related_power_port);
const ReceiverModel *receiverModel() const { return receiver_model_.get(); }
void setReceiverModel(ReceiverModelPtr receiver_model);
DriverWaveform *driverWaveform(const RiseFall *rf) const;
@@ -901,7 +906,7 @@ public:
protected:
// Constructor is internal to LibertyBuilder.
LibertyPort(LibertyCell *cell,
const char *name,
std::string name,
bool is_bus,
BusDcl *bus_dcl,
int from_index,
@@ -942,8 +947,8 @@ protected:
float min_pulse_width_[RiseFall::index_count];
const RiseFall *pulse_clk_trigger_;
const RiseFall *pulse_clk_sense_;
std::string related_ground_pin_;
std::string related_power_pin_;
LibertyPort *related_ground_port_;
LibertyPort *related_power_port_;
std::vector<LibertyPort*> scene_ports_;
ReceiverModelPtr receiver_model_;
DriverWaveform *driver_waveform_[RiseFall::index_count];
@@ -1011,13 +1016,8 @@ protected:
class OperatingConditions : public Pvt
{
public:
OperatingConditions(const char *name);
OperatingConditions(const char *name,
float process,
float voltage,
float temperature,
WireloadTree wire_load_tree);
const char *name() const { return name_.c_str(); }
OperatingConditions(std::string name);
const std::string &name() const { return name_; }
WireloadTree wireloadTree() const { return wire_load_tree_; }
void setWireloadTree(WireloadTree tree);
@@ -1029,8 +1029,8 @@ protected:
class ScaleFactors
{
public:
ScaleFactors(const char *name);
const char *name() const { return name_.c_str(); }
ScaleFactors(std::string name);
const std::string &name() const { return name_; }
float scale(ScaleFactorType type,
ScaleFactorPvt pvt,
const RiseFall *rf);
@@ -1073,14 +1073,11 @@ protected:
class ModeDef
{
public:
ModeDef(std::string name);
const std::string &name() const { return name_; }
ModeValueDef *defineValue(const char *value,
FuncExpr *cond,
const char *sdf_cond);
const ModeValueDef *findValueDef(const char *value) const;
const ModeValueMap *values() const { return &values_; }
explicit ModeDef(std::string name);
ModeValueDef *defineValue(std::string value);
const ModeValueDef *findValueDef(std::string_view value) const;
const ModeValueMap &values() const { return values_; }
protected:
std::string name_;
@@ -1152,12 +1149,12 @@ private:
};
std::string
portLibertyToSta(const char *port_name);
const char *
portLibertyToSta(std::string_view port_name);
const std::string &
scanSignalTypeName(ScanSignalType scan_type);
const char *
const std::string &
pwrGndTypeName(PwrGndType pwr_gnd_type);
PwrGndType
findPwrGndType(const char *pg_name);
findPwrGndType(std::string_view pg_name);
} // namespace
+1 -1
View File
@@ -76,7 +76,7 @@ public:
PocvMode pocv_mode) const override;
std::string reportCheckDelay(const Pvt *pvt,
float from_slew,
const char *from_slew_annotation,
std::string_view from_slew_annotation,
float to_slew,
float related_out_cap,
const MinMax *min_max,
+1 -1
View File
@@ -42,7 +42,7 @@ using PathGroupSeq = std::vector<PathGroup*>;
class Mode : public StaState
{
public:
Mode(const std::string &name,
Mode(std::string_view name,
size_t mode_index,
StaState *sta);
virtual ~Mode();
+66 -69
View File
@@ -26,6 +26,8 @@
#include <functional>
#include <map>
#include <string>
#include <string_view>
#include "StringUtil.hh"
#include "LibertyClass.hh"
@@ -39,11 +41,11 @@ class Report;
class PatternMatch;
class PinVisitor;
using LibertyLibraryMap = std::map<const char*, LibertyLibrary*, CharPtrLess>;
using LibertyLibraryMap = std::map<std::string, LibertyLibrary*, std::less<>>;
// Link network function returns top level instance.
// Return nullptr if link fails.
using LinkNetworkFunc = std::function<Instance* (const char *top_cell_name,
bool make_black_boxes)>;
using LinkNetworkFunc = std::function<Instance* (std::string_view top_cell_name,
bool make_black_boxes)>;
using NetDrvrPinsMap = std::map<const Net*, PinSet*>;
// The Network class defines the network API used by sta.
@@ -100,7 +102,7 @@ public:
// has been linked. When the network interfaces to an external database,
// linking is not necessary because the network has already been expanded.
// Return true if successful.
virtual bool linkNetwork(const char *top_cell_name,
virtual bool linkNetwork(std::string_view top_cell_name,
bool make_black_boxes,
Report *report) = 0;
virtual bool isLinked() const;
@@ -108,23 +110,23 @@ public:
////////////////////////////////////////////////////////////////
// Library functions.
virtual const char *name(const Library *library) const = 0;
virtual std::string name(const Library *library) const = 0;
virtual ObjectId id(const Library *library) const = 0;
virtual LibraryIterator *libraryIterator() const = 0;
virtual LibertyLibraryIterator *libertyLibraryIterator() const = 0;
virtual Library *findLibrary(const char *name) = 0;
virtual LibertyLibrary *findLiberty(const char *name) = 0;
virtual Library *findLibrary(std::string_view name) = 0;
virtual LibertyLibrary *findLiberty(std::string_view name) = 0;
// Find liberty library by filename.
virtual LibertyLibrary *findLibertyFilename(const char *filename);
virtual LibertyLibrary *findLibertyFilename(std::string_view filename);
virtual Cell *findCell(const Library *library,
const char *name) const = 0;
std::string_view name) const = 0;
// Search the design (non-liberty) libraries for cells matching pattern.
virtual CellSeq findCellsMatching(const Library *library,
const PatternMatch *pattern) const = 0;
// Search liberty libraries for cell name.
virtual LibertyCell *findLibertyCell(const char *name) const;
virtual LibertyLibrary *makeLibertyLibrary(const char *name,
const char *filename) = 0;
virtual LibertyCell *findLibertyCell(std::string_view name) const;
virtual LibertyLibrary *makeLibertyLibrary(std::string_view name,
std::string_view filename) = 0;
// Hook for network after reading liberty library.
virtual void readLibertyAfter(LibertyLibrary *library);
// First liberty library read is used to look up defaults.
@@ -139,7 +141,7 @@ public:
////////////////////////////////////////////////////////////////
// Cell functions.
virtual const char *name(const Cell *cell) const = 0;
virtual std::string name(const Cell *cell) const = 0;
virtual ObjectId id(const Cell *cell) const = 0;
virtual Library *library(const Cell *cell) const = 0;
virtual LibertyLibrary *libertyLibrary(const Cell *cell) const;
@@ -149,14 +151,13 @@ public:
virtual const Cell *cell(const LibertyCell *cell) const = 0;
virtual Cell *cell(LibertyCell *cell) const = 0;
// Filename may return null.
virtual const char *filename(const Cell *cell) = 0;
// Attributes can be null
virtual std::string_view filename(const Cell *cell) const = 0;
virtual std::string getAttribute(const Cell *cell,
const std::string &key) const = 0;
std::string_view key) const = 0;
virtual const AttributeMap &attributeMap(const Cell *cell) const = 0;
// Name can be a simple, bundle, bus, or bus bit name.
virtual Port *findPort(const Cell *cell,
const char *name) const = 0;
std::string_view name) const = 0;
virtual PortSeq findPortsMatching(const Cell *cell,
const PatternMatch *pattern) const;
virtual bool isLeaf(const Cell *cell) const = 0;
@@ -168,7 +169,7 @@ public:
////////////////////////////////////////////////////////////////
// Port functions
virtual const char *name(const Port *port) const = 0;
virtual std::string name(const Port *port) const = 0;
virtual ObjectId id(const Port *port) const = 0;
virtual Cell *cell(const Port *port) const = 0;
virtual LibertyPort *libertyPort(const Port *port) const = 0;
@@ -179,7 +180,7 @@ public:
// Size is the bus/bundle member count (1 for non-bus/bundle ports).
virtual int size(const Port *port) const = 0;
// Bus range bus[from:to].
virtual const char *busName(const Port *port) const = 0;
virtual std::string busName(const Port *port) const = 0;
// Bus member, bus[subscript].
virtual Port *findBusBit(const Port *port,
int index) const = 0;
@@ -202,25 +203,25 @@ public:
////////////////////////////////////////////////////////////////
// Instance functions
// Name local to containing cell/instance.
virtual const char *name(const Instance *instance) const = 0;
virtual std::string name(const Instance *instance) const = 0;
virtual ObjectId id(const Instance *instance) const = 0;
// Top level instance of the design (defined after link).
virtual Instance *topInstance() const = 0;
virtual bool isTopInstance(const Instance *inst) const;
virtual Instance *findInstance(const char *path_name) const;
virtual Instance *findInstance(std::string_view path_name) const;
// Find instance relative to hierarchical instance.
virtual Instance *findInstanceRelative(const Instance *inst,
const char *path_name) const;
std::string_view path_name) const;
// Default implementation uses linear search.
virtual InstanceSeq findInstancesMatching(const Instance *context,
const PatternMatch *pattern) const;
virtual InstanceSeq findInstancesHierMatching(const Instance *instance,
const PatternMatch *pattern) const;
virtual std::string getAttribute(const Instance *inst,
const std::string &key) const = 0;
std::string_view key) const = 0;
virtual const AttributeMap &attributeMap(const Instance *inst) const = 0;
// Hierarchical path name.
virtual const char *pathName(const Instance *instance) const;
virtual std::string pathName(const Instance *instance) const;
bool pathNameLess(const Instance *inst1,
const Instance *inst2) const;
int pathNameCmp(const Instance *inst1,
@@ -230,14 +231,14 @@ public:
// Return value.
InstanceSeq &path) const;
virtual Cell *cell(const Instance *instance) const = 0;
virtual const char *cellName(const Instance *instance) const;
virtual std::string cellName(const Instance *instance) const;
virtual LibertyLibrary *libertyLibrary(const Instance *instance) const;
virtual LibertyCell *libertyCell(const Instance *instance) const;
virtual Instance *parent(const Instance *instance) const = 0;
virtual bool isLeaf(const Instance *instance) const = 0;
virtual bool isHierarchical(const Instance *instance) const;
virtual Instance *findChild(const Instance *parent,
const char *name) const = 0;
std::string_view name) const = 0;
virtual void findChildrenMatching(const Instance *parent,
const PatternMatch *pattern,
// Return value.
@@ -270,18 +271,18 @@ public:
////////////////////////////////////////////////////////////////
// Pin functions
// Name is instance_name/port_name (the same as path name).
virtual const char *name(const Pin *pin) const;
virtual std::string name(const Pin *pin) const;
virtual ObjectId id(const Pin *pin) const = 0;
virtual Pin *findPin(const char *path_name) const;
virtual Pin *findPin(std::string_view path_name) const;
virtual Pin *findPin(const Instance *instance,
const char *port_name) const = 0;
std::string_view port_name) const = 0;
virtual Pin *findPin(const Instance *instance,
const Port *port) const;
virtual Pin *findPin(const Instance *instance,
const LibertyPort *port) const;
// Find pin relative to hierarchical instance.
Pin *findPinRelative(const Instance *inst,
const char *path_name) const;
std::string_view path_name) const;
// Default implementation uses linear search.
virtual PinSeq findPinsMatching(const Instance *instance,
const PatternMatch *pattern) const;
@@ -289,9 +290,9 @@ public:
// pattern of the form instance_name/port_name.
virtual PinSeq findPinsHierMatching(const Instance *instance,
const PatternMatch *pattern) const;
virtual const char *portName(const Pin *pin) const;
virtual std::string portName(const Pin *pin) const;
// Path name is instance_name/port_name.
virtual const char *pathName(const Pin *pin) const;
virtual std::string pathName(const Pin *pin) const;
bool pathNameLess(const Pin *pin1,
const Pin *pin2) const;
int pathNameCmp(const Pin *pin1,
@@ -349,27 +350,27 @@ public:
////////////////////////////////////////////////////////////////
// Terminal functions
// Name is instance_name/port_name (the same as path name).
virtual const char *name(const Term *term) const;
virtual std::string name(const Term *term) const;
virtual ObjectId id(const Term *term) const = 0;
virtual const char *portName(const Term *term) const;
virtual std::string portName(const Term *term) const;
// Path name is instance_name/port_name (pin name).
virtual const char *pathName(const Term *term) const;
virtual std::string pathName(const Term *term) const;
virtual Net *net(const Term *term) const = 0;
virtual Pin *pin(const Term *term) const = 0;
////////////////////////////////////////////////////////////////
// Net functions
virtual const char *name(const Net *net) const = 0; // no hierarchy prefix
virtual std::string name(const Net *net) const = 0; // no hierarchy prefix
virtual ObjectId id(const Net *net) const = 0;
virtual Net *findNet(const char *path_name) const;
virtual Net *findNet(std::string_view path_name) const;
// Find net relative to hierarchical instance.
virtual Net *findNetRelative(const Instance *inst,
const char *path_name) const;
std::string_view path_name) const;
// Default implementation uses linear search.
virtual NetSeq findNetsMatching(const Instance *context,
const PatternMatch *pattern) const;
virtual Net *findNet(const Instance *instance,
const char *net_name) const = 0;
std::string_view net_name) const = 0;
// Traverse the hierarchy from instance down and find nets matching
// pattern of the form instance_name/net_name.
virtual NetSeq findNetsHierMatching(const Instance *instance,
@@ -378,7 +379,7 @@ public:
virtual void findInstNetsMatching(const Instance *instance,
const PatternMatch *pattern,
NetSeq &matches) const = 0;
virtual const char *pathName(const Net *net) const;
virtual std::string pathName(const Net *net) const;
bool pathNameLess(const Net *net1,
const Net *net2) const;
int pathNameCmp(const Net *net1,
@@ -424,17 +425,13 @@ public:
////////////////////////////////////////////////////////////////
// Parse path into first/tail (first hierarchy divider separated token).
// first and tail are both null if there are no dividers in path.
// Caller must delete first and tail.
void pathNameFirst(const char *path_name,
char *&first,
char *&tail) const;
void pathNameFirst(std::string_view path_name,
std::string &first,
std::string &tail) const;
// Parse path into head/last (last hierarchy divider separated token).
// head and last are both null if there are no dividers in path.
// Caller must delete head and last.
void pathNameLast(const char *path_name,
char *&head,
char *&last) const;
void pathNameLast(std::string_view path_name,
std::string &head,
std::string &last) const;
// Divider between instance names in a hierarchical path name.
virtual char pathDivider() const { return divider_; }
@@ -445,7 +442,7 @@ public:
protected:
Pin *findPinLinear(const Instance *instance,
const char *port_name) const;
std::string_view port_name) const;
void findInstancesMatching1(const Instance *context,
size_t context_name_length,
const PatternMatch *pattern,
@@ -484,7 +481,7 @@ protected:
PinSeq &matches) const;
// findNet using linear search.
Net *findNetLinear(const Instance *instance,
const char *net_name) const;
std::string_view net_name) const;
// findNetsMatching using linear search.
NetSeq findNetsMatchingLinear(const Instance *instance,
const PatternMatch *pattern) const;
@@ -506,7 +503,7 @@ public:
NetworkEdit();
virtual bool isEditable() const { return true; }
virtual Instance *makeInstance(LibertyCell *cell,
const char *name,
std::string_view name,
Instance *parent) = 0;
virtual void makePins(Instance *inst) = 0;
virtual void replaceCell(Instance *inst,
@@ -523,7 +520,7 @@ public:
// Disconnect pin from net.
virtual void disconnectPin(Pin *pin) = 0;
virtual void deletePin(Pin *pin) = 0;
virtual Net *makeNet(const char *name,
virtual Net *makeNet(std::string_view name,
Instance *parent) = 0;
// Deleting net disconnects (but does not delete) net pins.
virtual void deleteNet(Net *net) = 0;
@@ -540,39 +537,39 @@ public:
// Called before reading a netlist to delete any previously linked network.
virtual void readNetlistBefore() = 0;
virtual void setLinkFunc(LinkNetworkFunc link) = 0;
virtual Library *makeLibrary(const char *name,
const char *filename) = 0;
virtual Library *makeLibrary(std::string_view name,
std::string_view filename) = 0;
virtual void deleteLibrary(Library *library) = 0;
// Search the libraries in read order for a cell by name.
virtual Cell *findAnyCell(const char *name) = 0;
virtual Cell *findAnyCell(std::string_view name) = 0;
virtual Cell *makeCell(Library *library,
const char *name,
std::string_view name,
bool is_leaf,
const char *filename) = 0;
std::string_view filename) = 0;
virtual void deleteCell(Cell *cell) = 0;
virtual void setName(Cell *cell,
const char *name) = 0;
std::string_view name) = 0;
virtual void setIsLeaf(Cell *cell,
bool is_leaf) = 0;
virtual void setAttribute(Cell *cell,
const std::string &key,
const std::string &value) = 0;
std::string_view key,
std::string_view value) = 0;
virtual void setAttribute(Instance *instance,
const std::string &key,
const std::string &value) = 0;
std::string_view key,
std::string_view value) = 0;
virtual Port *makePort(Cell *cell,
const char *name) = 0;
std::string_view name) = 0;
virtual Port *makeBusPort(Cell *cell,
const char *name,
std::string_view name,
int from_index,
int to_index) = 0;
virtual void groupBusPorts(Cell *cell,
std::function<bool(const char*)> port_msb_first) = 0;
std::function<bool(std::string_view)> port_msb_first) = 0;
virtual Port *makeBundlePort(Cell *cell,
const char *name,
std::string_view name,
PortSeq *members) = 0;
virtual Instance *makeInstance(Cell *cell,
const char *name,
std::string_view name,
Instance *parent) = 0;
virtual Pin *makePin(Instance *inst,
Port *port,
+1 -1
View File
@@ -74,7 +74,7 @@ using ConnectedPinIterator = Iterator<const Pin*>;
using NetConnectedPinIterator = ConnectedPinIterator;
using PinConnectedPinIterator = ConnectedPinIterator;
using ObjectId = uint32_t;
using AttributeMap = std::map<std::string, std::string>;
using AttributeMap = std::map<std::string, std::string, std::less<>>;
enum class LogicValue : unsigned { zero, one, unknown, rise, fall };
+1 -1
View File
@@ -185,7 +185,7 @@ public:
// Increment the grounded capacitance on node.
virtual void incrCap(ParasiticNode *node,
float cap) = 0;
virtual const char *name(const ParasiticNode *node) const = 0;
virtual std::string name(const ParasiticNode *node) const = 0;
virtual const Pin *pin(const ParasiticNode *node) const = 0;
virtual const Net *net(const ParasiticNode *node,
const Network *network) const = 0;
+12 -11
View File
@@ -25,6 +25,7 @@
#pragma once
#include <string>
#include <string_view>
#include <vector>
#include <map>
#include <mutex>
@@ -50,7 +51,7 @@ class PathGroup
{
public:
// Path group that compares compare slacks.
static PathGroup *makePathGroupArrival(const char *name,
static PathGroup *makePathGroupArrival(std::string_view name,
int group_path_count,
int endpoint_path_count,
bool unique_pins,
@@ -58,7 +59,7 @@ public:
const MinMax *min_max,
const StaState *sta);
// Path group that compares arrival time, sorted by min_max.
static PathGroup *makePathGroupSlack(const char *name,
static PathGroup *makePathGroupSlack(std::string_view name,
int group_path_count,
int endpoint_path_count,
bool unique_pins,
@@ -82,7 +83,7 @@ public:
static int group_path_count_max;
protected:
PathGroup(const char *name,
PathGroup(std::string_view name,
int group_path_count,
int endpoint_path_count,
bool unique_pins,
@@ -147,10 +148,10 @@ public:
PathGroupSeq pathGroups(const PathEnd *path_end) const;
static StringSeq pathGroupNames(const PathEnd *path_end,
const StaState *sta);
static const char *asyncPathGroupName() { return async_group_name_; }
static const char *pathDelayGroupName() { return path_delay_group_name_; }
static const char *gatedClkGroupName() { return gated_clk_group_name_; }
static const char *unconstrainedGroupName() { return unconstrained_group_name_; }
static std::string_view asyncPathGroupName() { return async_group_name_; }
static std::string_view pathDelayGroupName() { return path_delay_group_name_; }
static std::string_view gatedClkGroupName() { return gated_clk_group_name_; }
static std::string_view unconstrainedGroupName() { return unconstrained_group_name_; }
protected:
void makeGroupPathEnds(ExceptionTo *to,
@@ -219,10 +220,10 @@ protected:
// Unconstrained paths.
PathGroup *unconstrained_[MinMax::index_count];
static const char *path_delay_group_name_;
static const char *gated_clk_group_name_;
static const char *async_group_name_;
static const char *unconstrained_group_name_;
static constexpr std::string_view path_delay_group_name_ = "path delay";
static constexpr std::string_view gated_clk_group_name_ = "gated clock";
static constexpr std::string_view async_group_name_ = "asynchronous";
static constexpr std::string_view unconstrained_group_name_ = "unconstrained";
};
} // namespace
+14 -16
View File
@@ -25,6 +25,7 @@
#pragma once
#include <string>
#include <string_view>
#include "Error.hh"
@@ -45,20 +46,17 @@ public:
// Regular expressions are always anchored.
// If nocase is true, ignore case in the pattern.
// Tcl_Interp is optional for reporting regexp compile errors.
PatternMatch(const char *pattern,
PatternMatch(std::string_view pattern,
bool is_regexp,
bool nocase,
Tcl_Interp *interp);
// Use unix glob style matching.
PatternMatch(const char *pattern);
PatternMatch(const char *pattern,
PatternMatch(std::string_view pattern);
PatternMatch(std::string_view pattern,
const PatternMatch *inherit_from);
PatternMatch(const std::string &pattern,
const PatternMatch *inherit_from);
bool match(const char *str) const;
bool match(const std::string &str) const;
bool matchNoCase(const char *str) const;
const char *pattern() const { return pattern_; }
bool match(std::string_view str) const;
bool matchNoCase(std::string_view str) const;
const std::string &pattern() const { return pattern_; }
bool isRegexp() const { return is_regexp_; }
bool nocase() const { return nocase_; }
Tcl_Interp *tclInterp() const { return interp_; }
@@ -67,7 +65,7 @@ public:
private:
void compileRegexp();
const char *pattern_;
std::string pattern_;
bool is_regexp_;
bool nocase_;
Tcl_Interp *interp_;
@@ -78,7 +76,7 @@ private:
class RegexpCompileError : public Exception
{
public:
RegexpCompileError(const char *pattern);
RegexpCompileError(std::string_view pattern);
virtual ~RegexpCompileError() noexcept {}
virtual const char *what() const noexcept;
@@ -90,14 +88,14 @@ private:
// '*' matches zero or more characters
// '?' matches any character
bool
patternMatch(const char *pattern,
const char *str);
patternMatch(std::string_view pattern,
std::string_view str);
bool
patternMatchNoCase(const char *pattern,
const char *str,
patternMatchNoCase(std::string_view pattern,
std::string_view str,
bool nocase);
// Predicate to find out if there are wildcard characters in the pattern.
bool
patternWildcards(const char *pattern);
patternWildcards(std::string_view pattern);
} // namespace
+4 -2
View File
@@ -24,13 +24,15 @@
#pragma once
#include <string>
namespace sta {
enum class PocvMode { scalar, normal, skew_normal };
const char *
const std::string &
pocvModeName(PocvMode mode);
PocvMode
findPocvMode(const char *mode_name);
findPocvMode(std::string_view mode_name);
} // namespace
+1 -1
View File
@@ -43,7 +43,7 @@ public:
static PortDirection *power() { return power_; }
static PortDirection *unknown() { return unknown_; }
static PortDirection *find(const char *dir_name);
const char *name() const { return name_; }
std::string_view name() const { return name_; }
int index() const { return index_; }
bool isInput() const { return this == input_; }
// Input or bidirect.
+1 -1
View File
@@ -58,7 +58,7 @@ public:
void setDuty(float duty);
PwrActivityOrigin origin() const { return origin_; }
void setOrigin(PwrActivityOrigin origin);
const char *originName() const;
const std::string &originName() const;
void set(float density,
float duty,
PwrActivityOrigin origin);
+26 -23
View File
@@ -51,12 +51,12 @@ public:
void defineProperty(std::string_view property,
PropertyHandler handler);
PropertyValue getProperty(TYPE object,
const std::string &property,
const char *type_name,
std::string_view property,
std::string_view type_name,
Sta *sta);
private:
std::map<std::string, PropertyHandler> registry_;
std::map<std::string, PropertyHandler, std::less<>> registry_;
};
class Properties
@@ -66,33 +66,33 @@ public:
virtual ~Properties() {}
PropertyValue getProperty(const Library *lib,
const std::string &property);
std::string_view property);
PropertyValue getProperty(const LibertyLibrary *lib,
const std::string &property);
std::string_view property);
PropertyValue getProperty(const Cell *cell,
const std::string &property);
std::string_view property);
PropertyValue getProperty(const LibertyCell *cell,
const std::string &property);
std::string_view property);
PropertyValue getProperty(const Port *port,
const std::string &property);
std::string_view property);
PropertyValue getProperty(const LibertyPort *port,
const std::string &property);
std::string_view property);
PropertyValue getProperty(const Instance *inst,
const std::string &property);
std::string_view property);
PropertyValue getProperty(const Pin *pin,
const std::string &property);
std::string_view property);
PropertyValue getProperty(const Net *net,
const std::string &property);
std::string_view property);
PropertyValue getProperty(Edge *edge,
const std::string &property);
std::string_view property);
PropertyValue getProperty(const Clock *clk,
const std::string &property);
std::string_view property);
PropertyValue getProperty(PathEnd *end,
const std::string &property);
std::string_view property);
PropertyValue getProperty(Path *path,
const std::string &property);
std::string_view property);
PropertyValue getProperty(TimingArcSet *arc_set,
const std::string &property);
std::string_view property);
// Define handler for external property.
// properties->defineProperty("foo",
@@ -160,7 +160,7 @@ protected:
};
// Adding a new property type
// value union
// value union (string values use std::string* so the union stays trivial)
// enum Type
// constructor
// copy constructor switch clause
@@ -178,11 +178,11 @@ public:
instance, pin, pins, net,
clk, clks, paths, pwr_activity };
PropertyValue();
PropertyValue(const char *value);
PropertyValue(std::string &value);
PropertyValue(std::string_view value);
PropertyValue(std::string value);
PropertyValue(float value,
const Unit *unit);
explicit PropertyValue(bool value);
PropertyValue(bool value);
PropertyValue(const Library *value);
PropertyValue(const Cell *value);
PropertyValue(const Port *value);
@@ -209,7 +209,7 @@ public:
const Unit *unit() const { return unit_; }
std::string to_string(const Network *network) const;
const char *stringValue() const; // valid for type string
const std::string &stringValue() const; // valid for type string
float floatValue() const; // valid for type float
bool boolValue() const; // valid for type bool
const LibertyLibrary *libertyLibrary() const { return liberty_library_; }
@@ -233,9 +233,12 @@ public:
PropertyValue &operator=(PropertyValue &&) noexcept;
private:
void destroyActive();
Type type_;
union {
const char *string_;
// Use heap string to simplify initialization/destrucction.
std::string *string_;
float float_;
bool bool_;
const Library *library_;
+3 -3
View File
@@ -177,13 +177,13 @@ public:
}
// Log output to filename until logEnd is called.
virtual void logBegin(std::string filename);
virtual void logBegin(std::string_view filename);
virtual void logEnd();
// Redirect output to filename until redirectFileEnd is called.
virtual void redirectFileBegin(std::string filename);
virtual void redirectFileBegin(std::string_view filename);
// Redirect append output to filename until redirectFileEnd is called.
virtual void redirectFileAppendBegin(std::string filename);
virtual void redirectFileAppendBegin(std::string_view filename);
virtual void redirectFileEnd();
// Redirect output to a string until redirectStringEnd is called.
virtual void redirectStringBegin();
+3 -3
View File
@@ -44,10 +44,10 @@ class ReportTcl : public Report
public:
ReportTcl();
virtual ~ReportTcl();
void logBegin(std::string filename) override;
void logBegin(std::string_view filename) override;
void logEnd() override;
void redirectFileBegin(std::string filename) override;
void redirectFileAppendBegin(std::string filename) override;
void redirectFileBegin(std::string_view filename) override;
void redirectFileAppendBegin(std::string_view filename) override;
void redirectFileEnd() override;
void redirectStringBegin() override;
const char *redirectStringEnd() override;
+16 -15
View File
@@ -28,6 +28,7 @@
#include <map>
#include <unordered_map>
#include <mutex>
#include <string_view>
#include "StringUtil.hh"
#include "MinMax.hh"
@@ -131,7 +132,7 @@ private:
bool subtract_pin_cap_[MinMax::index_count];
};
using ClockNameMap = std::map<const char*,Clock*, CharPtrLess>;
using ClockNameMap = std::map<std::string ,Clock*, std::less<>>;
using ClockPinMap = std::unordered_map<const Pin*, ClockSet*, PinIdHash>;
using InputDelaySet = std::set<InputDelay*>;
using InputDelaysPinMap = std::map<const Pin*, InputDelaySet*, PinIdLess>;
@@ -179,11 +180,11 @@ using InstDeratingFactorsMap = std::map<const Instance*, DeratingFactorsCell*>;
using CellDeratingFactorsMap = std::map<const LibertyCell*, DeratingFactorsCell*>;
using ClockGroupsSet = std::set<ClockGroups*>;
using ClockGroupsClkMap = std::map<const Clock*, ClockGroupsSet*>;
using ClockGroupsNameMap = std::map<std::string, ClockGroups*>;
using ClockGroupsNameMap = std::map<std::string, ClockGroups*, std::less<>>;
using ClockSenseMap = std::map<PinClockPair, ClockSense, PinClockPairLess>;
using ClkHpinDisables = std::set<ClkHpinDisable*, ClkHpinDisableLess>;
using GroupPathSet = std::set<GroupPath*, ExceptionPathLess>;
using GroupPathMap = std::map<std::string, GroupPathSet*>;
using GroupPathMap = std::map<std::string, GroupPathSet*, std::less<>>;
using ClockPairSet = std::set<ClockPair, ClockPairLess>;
using NetVoltageMap = std::map<const Net*, MinMaxFloatValues>;
@@ -377,14 +378,14 @@ public:
float fanout);
void setMaxArea(float area);
float maxArea() const;
Clock *makeClock(const char *name,
Clock *makeClock(std::string_view name,
PinSet *pins,
bool add_to_pins,
float period,
FloatSeq *waveform,
const char *comment);
std::string_view comment);
// edges size must be 3.
Clock *makeGeneratedClock(const char *name,
Clock *makeGeneratedClock(std::string_view name,
PinSet *pins,
bool add_to_pins,
Pin *src_pin,
@@ -396,7 +397,7 @@ public:
bool combinational,
IntSeq *edges,
FloatSeq *edge_shifts,
const char *comment);
std::string_view comment);
// Invalidate all generated clock waveforms.
void invalidateGeneratedClks() const;
void removeClock(Clock *clk);
@@ -504,7 +505,7 @@ public:
bool physically_exclusive,
bool asynchronous,
bool allow_paths,
const char *comment);
std::string comment);
void makeClockGroup(ClockGroups *clk_groups,
ClockSet *clks);
void removeClockGroups(const std::string &name);
@@ -730,7 +731,7 @@ public:
ExceptionThruSeq *thrus,
ExceptionTo *to,
const MinMaxAll *min_max,
const char *comment);
std::string_view comment);
// Loop paths are false paths used to disable paths around
// combinational loops when dynamic loop breaking is enabled.
void makeLoopExceptions();
@@ -742,7 +743,7 @@ public:
const MinMaxAll *min_max,
bool use_end_clk,
int path_multiplier,
const char *comment);
std::string_view comment);
void makePathDelay(ExceptionFrom *from,
ExceptionThruSeq *thrus,
ExceptionTo *to,
@@ -750,7 +751,7 @@ public:
bool ignore_clk_latency,
bool break_path,
float delay,
const char *comment);
std::string_view comment);
bool pathDelaysWithoutTo() const { return path_delays_without_to_; }
// Delete matching false/multicycle/path_delay exceptions.
// Caller owns from, thrus, to exception points (and must delete them).
@@ -758,13 +759,13 @@ public:
ExceptionThruSeq *thrus,
ExceptionTo *to,
const MinMaxAll *min_max);
void makeGroupPath(const std::string &name,
void makeGroupPath(std::string_view name,
bool is_default,
ExceptionFrom *from,
ExceptionThruSeq *thrus,
ExceptionTo *to,
const char *comment);
bool isGroupPathName(const char *group_name) const;
std::string_view comment);
bool isGroupPathName(std::string_view group_name) const;
const GroupPathMap &groupPaths() const { return group_path_map_; }
void addException(ExceptionPath *exception);
// The pin/clk/instance/net set arguments passed into the following
@@ -833,7 +834,7 @@ public:
const MinMax *min_max,
float voltage);
InputDrive *findInputDrive(Port *port) const;
Clock *findClock(const char *name) const;
Clock *findClock(std::string_view name) const;
ClockSeq findClocksMatching(PatternMatch *pattern) const;
// True if pin is defined as a clock source (pin may be hierarchical).
bool isClock(const Pin *pin) const;
+10 -4
View File
@@ -24,22 +24,28 @@
#pragma once
#include <string>
#include <string_view>
namespace sta {
class SdcCmdComment
{
public:
SdcCmdComment();
SdcCmdComment(const char *comment);
const char *comment() { return comment_; }
void setComment(const char *comment);
SdcCmdComment(std::string comment);
SdcCmdComment(std::string_view comment);
const std::string &comment() { return comment_; }
const std::string &comment() const { return comment_; }
void setComment(std::string comment);
void setComment(std::string_view comment);
protected:
// Destructor is protected to prevent deletion of a derived
// class with a pointer to this base class.
~SdcCmdComment();
char *comment_;
std::string comment_;
};
} // namespace
+51 -42
View File
@@ -25,6 +25,8 @@
#pragma once
#include <functional>
#include <string>
#include <string_view>
#include "Network.hh"
@@ -36,26 +38,26 @@ class NetworkNameAdapter : public NetworkEdit
{
public:
NetworkNameAdapter(Network *network);
bool linkNetwork(const char *top_cell_name,
bool linkNetwork(std::string_view top_cell_name,
bool make_black_boxes,
Report *report) override;
const char *name(const Library *library) const override;
std::string name(const Library *library) const override;
ObjectId id(const Library *library) const override;
LibertyLibrary *defaultLibertyLibrary() const override;
LibraryIterator *libraryIterator() const override;
LibertyLibraryIterator *libertyLibraryIterator() const override;
Library *findLibrary(const char *name) override;
LibertyLibrary *findLibertyFilename(const char *filename) override;
LibertyLibrary *findLiberty(const char *name) override;
Library *findLibrary(std::string_view name) override;
LibertyLibrary *findLibertyFilename(std::string_view filename) override;
LibertyLibrary *findLiberty(std::string_view name) override;
Cell *findCell(const Library *library,
const char *name) const override;
std::string_view name) const override;
CellSeq findCellsMatching(const Library *library,
const PatternMatch *pattern) const override;
const char *name(const Cell *cell) const override;
std::string name(const Cell *cell) const override;
std::string getAttribute(const Cell *cell,
const std::string &key) const override;
std::string_view key) const override;
const AttributeMap &attributeMap(const Cell *cell) const override;
ObjectId id(const Cell *cell) const override;
Library *library(const Cell *cell) const override;
@@ -63,9 +65,9 @@ public:
const LibertyCell *libertyCell(const Cell *cell) const override;
Cell *cell(LibertyCell *cell) const override;
const Cell *cell(const LibertyCell *cell) const override;
const char *filename(const Cell *cell) override;
std::string_view filename(const Cell *cell) const override;
Port *findPort(const Cell *cell,
const char *name) const override;
std::string_view name) const override;
PortSeq findPortsMatching(const Cell *cell,
const PatternMatch *pattern) const override;
bool isLeaf(const Cell *cell) const override;
@@ -73,7 +75,7 @@ public:
CellPortBitIterator *portBitIterator(const Cell *cell) const override;
int portBitCount(const Cell *cell) const override;
const char *name(const Port *port) const override;
std::string name(const Port *port) const override;
ObjectId id(const Port *port) const override;
Cell *cell(const Port *port) const override;
LibertyPort *libertyPort(const Port *port) const override;
@@ -81,7 +83,7 @@ public:
bool isBundle(const Port *port) const override;
bool isBus(const Port *port) const override;
int size(const Port *port) const override;
const char *busName(const Port *port) const override;
std::string busName(const Port *port) const override;
Port *findBusBit(const Port *port,
int index) const override;
int fromIndex(const Port *port) const override;
@@ -93,7 +95,7 @@ public:
ObjectId id(const Instance *instance) const override;
std::string getAttribute(const Instance *inst,
const std::string &key) const override;
std::string_view key) const override;
const AttributeMap &attributeMap(const Instance *inst) const override;
Instance *topInstance() const override;
Cell *cell(const Instance *instance) const override;
@@ -145,15 +147,15 @@ public:
void setPathEscape(char escape) override;
bool isEditable() const override;
LibertyLibrary *makeLibertyLibrary(const char *name,
const char *filename) override;
LibertyLibrary *makeLibertyLibrary(std::string_view name,
std::string_view filename) override;
Instance *makeInstance(LibertyCell *cell,
const char *name,
std::string_view name,
Instance *parent) override;
void makePins(Instance *inst) override;
void replaceCell(Instance *inst,
Cell *to_cell) override;
Net *makeNet(const char *name,
Net *makeNet(std::string_view name,
Instance *parent) override;
Pin *connect(Instance *inst,
Port *port,
@@ -195,47 +197,47 @@ public:
SdcNetwork(Network *network);
Port *findPort(const Cell *cell,
const char *name) const override;
std::string_view name) const override;
PortSeq findPortsMatching(const Cell *cell,
const PatternMatch *pattern) const override;
const char *name(const Port *port) const override;
const char *busName(const Port *port) const override;
std::string name(const Port *port) const override;
std::string busName(const Port *port) const override;
const char *name(const Instance *instance) const override;
const char *pathName(const Instance *instance) const override;
const char *pathName(const Pin *pin) const override;
const char *portName(const Pin *pin) const override;
std::string name(const Instance *instance) const override;
std::string pathName(const Instance *instance) const override;
std::string pathName(const Pin *pin) const override;
std::string portName(const Pin *pin) const override;
const char *name(const Net *net) const override;
const char *pathName(const Net *net) const override;
std::string name(const Net *net) const override;
std::string pathName(const Net *net) const override;
Instance *findInstance(const char *path_name) const override;
Instance *findInstance(std::string_view path_name) const override;
Instance *findInstanceRelative(const Instance *inst,
const char *path_name) const override;
std::string_view path_name) const override;
InstanceSeq findInstancesMatching(const Instance *context,
const PatternMatch *pattern) const override;
Net *findNet(const char *path_name) const override;
Net *findNet(std::string_view path_name) const override;
Net *findNetRelative(const Instance *instance,
const char *net_name) const override;
std::string_view net_name) const override;
Net *findNet(const Instance *instance,
const char *net_name) const override;
std::string_view net_name) const override;
NetSeq findNetsMatching(const Instance *parent,
const PatternMatch *pattern) const override;
void findInstNetsMatching(const Instance *instance,
const PatternMatch *pattern,
NetSeq &nets) const override;
Instance *findChild(const Instance *parent,
const char *name) const override;
Pin *findPin(const char *path_name) const override;
std::string_view name) const override;
Pin *findPin(std::string_view path_name) const override;
Pin *findPin(const Instance *instance,
const char *port_name) const override;
std::string_view port_name) const override;
PinSeq findPinsMatching(const Instance *instance,
const PatternMatch *pattern) const override;
Instance *makeInstance(LibertyCell *cell,
const char *name,
std::string_view name,
Instance *parent) override;
Net *makeNet(const char *name,
Net *makeNet(std::string_view name,
Instance *parent) override;
// The following member functions are inherited from the
@@ -247,21 +249,21 @@ public:
using Network::findPin;
protected:
void parsePath(const char *path,
void parsePath(std::string_view path,
// Return values.
Instance *&inst,
const char *&path_tail) const;
void scanPath(const char *path,
std::string &path_tail) const;
void scanPath(std::string_view path,
// Return values.
// Unescaped divider count.
int &divider_count,
int &path_length) const;
void parsePath(const char *path,
void parsePath(std::string_view path,
int divider_count,
int path_length,
// Return values.
Instance *&inst,
const char *&path_tail) const;
std::string &path_tail) const;
bool visitMatches(const Instance *parent,
const PatternMatch *pattern,
std::function<bool (const Instance *instance,
@@ -274,11 +276,18 @@ protected:
const PatternMatch *pattern,
InstanceSeq &matches) const;
const char *staToSdc(std::string_view sta_name) const;
std::string staToSdc(std::string_view sta_name) const;
};
// Encapsulate a network to map names to/from the sdc namespace.
Network *
makeSdcNetwork(Network *network);
std::string
escapeDividers(std::string_view name,
const Network *network);
std::string
escapeBrackets(std::string_view name,
const Network *network);
} // namespace
-1
View File
@@ -57,7 +57,6 @@ class VertexPathIterator;
class MinPulseWidthCheck;
class MinPeriodCheck;
class MaxSkewCheck;
class CharPtrLess;
class SearchPred;
class BfsFwdIterator;
class ClkDelays;
+42 -38
View File
@@ -75,7 +75,7 @@ class EquivCells;
class StaSimObserver;
class GraphLoop;
using ModeNameMap = std::map<std::string, Mode*>;
using ModeNameMap = std::map<std::string, Mode*, std::less<>>;
using SceneNameMap = std::map<std::string, Scene*>;
using SlowDrvrIterator = Iterator<Instance*>;
using CheckError = StringSeq;
@@ -143,12 +143,12 @@ public:
Mode *cmdMode() const { return cmd_scene_->mode(); }
const std::string &cmdModeName();
void setCmdMode(const std::string &mode_name);
Mode *findMode(const std::string &mode_name) const;
void setCmdMode(std::string_view mode_name);
Mode *findMode(std::string_view mode_name) const;
ModeSeq findModes(const std::string &mode_name) const;
Sdc *cmdSdc() const;
virtual LibertyLibrary *readLiberty(const char *filename,
virtual LibertyLibrary *readLiberty(std::string_view filename,
Scene *scene,
const MinMaxAll *min_max,
bool infer_latches);
@@ -156,7 +156,7 @@ public:
void readLibertyAfter(LibertyLibrary *liberty,
Scene *scene,
const MinMax *min_max);
bool readVerilog(const char *filename);
bool readVerilog(std::string_view filename);
// Network readers call this to notify the Sta to delete any previously
// linked network.
void readNetlistBefore();
@@ -164,6 +164,13 @@ public:
bool linkDesign(const char *top_cell_name,
bool make_black_boxes);
bool readSdf(std::string_view filename,
std::string_view path,
Scene *scene,
bool unescaped_dividers,
bool incremental_only,
MinMaxAll *cond_use);
// SDC Swig API.
Instance *currentInstance() const;
void setCurrentInstance(Instance *inst);
@@ -340,15 +347,15 @@ public:
void setMaxArea(float area,
Sdc *sdc);
void makeClock(const char *name,
void makeClock(std::string_view name,
PinSet *pins,
bool add_to_pins,
float period,
FloatSeq *waveform,
char *comment,
std::string_view comment,
const Mode *mode);
// edges size must be 3.
void makeGeneratedClock(const char *name,
void makeGeneratedClock(std::string_view name,
PinSet *pins,
bool add_to_pins,
Pin *src_pin,
@@ -360,7 +367,7 @@ public:
bool combinational,
IntSeq *edges,
FloatSeq *edge_shifts,
char *comment,
std::string_view comment,
const Mode *mode);
void removeClock(Clock *clk,
Sdc *sdc);
@@ -439,7 +446,7 @@ public:
bool physically_exclusive,
bool asynchronous,
bool allow_paths,
const char *comment,
std::string comment,
Sdc *sdc);
void removeClockGroupsLogicallyExclusive(Sdc *sdc);
void removeClockGroupsLogicallyExclusive(const std::string &name,
@@ -623,7 +630,7 @@ public:
ExceptionThruSeq *thrus,
ExceptionTo *to,
const MinMaxAll *min_max,
const char *comment,
std::string_view comment,
Sdc *sdc);
void makeMulticyclePath(ExceptionFrom *from,
ExceptionThruSeq *thrus,
@@ -631,7 +638,7 @@ public:
const MinMaxAll *min_max,
bool use_end_clk,
int path_multiplier,
const char *comment,
std::string_view comment,
Sdc *sdc);
void makePathDelay(ExceptionFrom *from,
ExceptionThruSeq *thrus,
@@ -640,19 +647,19 @@ public:
bool ignore_clk_latency,
bool break_path,
float delay,
const char *comment,
std::string_view comment,
Sdc *sdc);
void makeGroupPath(const std::string &name,
void makeGroupPath(std::string_view name,
bool is_default,
ExceptionFrom *from,
ExceptionThruSeq *thrus,
ExceptionTo *to,
const char *comment,
std::string_view comment,
Sdc *sdc);
// Deprecated 10/24/2025
bool isGroupPathName(const char *group_name,
bool isGroupPathName(std::string_view group_name,
const Sdc *sdc) __attribute__ ((deprecated));
bool isPathGroupName(const char *group_name,
bool isPathGroupName(std::string_view group_name,
const Sdc *sdc) const;
StringSeq pathGroupNames(const Sdc *sdc) const;
void resetPath(ExceptionFrom *from,
@@ -667,7 +674,7 @@ public:
const RiseFallBoth *from_rf,
const Sdc *sdc);
void checkExceptionFromPins(ExceptionFrom *from,
const char *file,
std::string_view filename,
int line,
const Sdc *sdc) const;
void deleteExceptionFrom(ExceptionFrom *from);
@@ -892,7 +899,7 @@ public:
const MinMaxAll *min_max,
const RiseFallBoth *rf,
float slew);
void writeSdf(const char *filename,
void writeSdf(std::string_view filename,
const Scene *scene,
char divider,
bool include_typ,
@@ -986,7 +993,7 @@ public:
bool report_fanout,
bool report_variation,
bool report_src_attr);
ReportField *findReportPathField(const char *name);
ReportField *findReportPathField(std::string_view name);
void setReportPathDigits(int digits);
void setReportPathNoSplit(bool no_split);
void reportPathEnd(PathEnd *end);
@@ -1038,7 +1045,7 @@ public:
const MinMax *min_max,
int digits);
void writeSdc(const Sdc *sdc,
const char *filename,
std::string_view filename,
// Map hierarchical pins and instances to leaf pins and instances.
bool leaf,
// Replace non-sdc get functions with OpenSTA equivalents.
@@ -1128,7 +1135,7 @@ public:
Slack (&slacks)[RiseFall::index_count][MinMax::index_count]);
// Worst slack for an endpoint in a path group.
Slack endpointSlack(const Pin *pin,
const std::string &path_group_name,
std::string_view path_group_name,
const MinMax *min_max);
void reportArrivalWrtClks(const Pin *pin,
@@ -1193,8 +1200,8 @@ public:
// networks (dspf) are reduced and deleted after reading each net
// with reduce_to and delete_after_reduce.
// Return true if successful.
bool readSpef(const std::string &name,
const std::string &filename,
bool readSpef(std::string_view name,
std::string_view filename,
Instance *instance,
Scene *scene,
const MinMaxAll *min_max,
@@ -1333,7 +1340,7 @@ public:
void searchPreamble();
// Define the delay calculator implementation.
void setArcDelayCalc(const char *delay_calc_name);
void setArcDelayCalc(std::string_view delay_calc_name);
void setDebugLevel(const char *what,
int level);
@@ -1381,9 +1388,9 @@ public:
PwrActivity activity(const Pin *pin,
const Scene *scene);
void writeTimingModel(const char *lib_name,
const char *cell_name,
const char *filename,
void writeTimingModel(std::string_view lib_name,
std::string_view cell_name,
std::string_view filename,
const Scene *scene);
// Find equivalent cells in equiv_libs.
@@ -1393,12 +1400,12 @@ public:
LibertyCellSeq *equivCells(LibertyCell *cell);
void writePathSpice(const Path *path,
const char *spice_filename,
const char *subckt_filename,
const char *lib_subckt_filename,
const char *model_filename,
const char *power_name,
const char *gnd_name,
std::string_view spice_filename,
std::string_view subckt_filename,
std::string_view lib_subckt_filename,
std::string_view model_filename,
std::string_view power_name,
std::string_view gnd_name,
CircuitSim ckt_sim);
////////////////////////////////////////////////////////////////
@@ -1490,13 +1497,10 @@ protected:
virtual void makeObservers();
NetworkEdit *networkCmdEdit();
LibertyLibrary *readLibertyFile(const char *filename,
LibertyLibrary *readLibertyFile(std::string_view filename,
Scene *scene,
const MinMaxAll *min_max,
bool infer_latches);
// Allow external Liberty reader to parse forms not used by Sta.
virtual LibertyLibrary *readLibertyFile(const char *filename,
bool infer_latches);
void delayCalcPreamble();
void delaysInvalidFrom(const Port *port);
void delaysInvalidFromFanin(const Port *port);
+4 -2
View File
@@ -24,6 +24,8 @@
#pragma once
#include <string_view>
struct Tcl_Interp;
namespace sta {
@@ -58,11 +60,11 @@ unencode(const char *inits[]);
bool
findCmdLineFlag(int &argc,
char *argv[],
const char *flag);
std::string_view flag);
char *
findCmdLineKey(int &argc,
char *argv[],
const char *key);
std::string_view key);
int
parseThreadsArg(int &argc,
+20 -82
View File
@@ -24,9 +24,12 @@
#pragma once
#include <algorithm>
#include <cstdarg>
#include <cstring>
#include <string>
#include <string_view>
#include <strings.h> // for strncasecmp
#include <vector>
#include <set>
@@ -53,14 +56,6 @@ stringEq(const char *str1,
return strncmp(str1, str2, length) == 0;
}
inline bool
stringEqIf(const char *str1,
const char *str2)
{
return (str1 == nullptr && str2 == nullptr)
|| (str1 && str2 && strcmp(str1, str2) == 0);
}
// Case sensitive compare the beginning of str1 to str2.
inline bool
stringBeginEq(const char *str1,
@@ -71,78 +66,24 @@ stringBeginEq(const char *str1,
// Case insensitive compare the beginning of str1 to str2.
inline bool
stringBeginEqual(const char *str1,
const char *str2)
stringBeginEqual(std::string_view str,
std::string_view prefix)
{
return strncasecmp(str1, str2, strlen(str2)) == 0;
if (str.size() < prefix.size())
return false;
return strncasecmp(str.data(), prefix.data(), prefix.size()) == 0;
}
// Case insensitive compare.
inline bool
stringEqual(const char *str1,
const char *str2)
stringEqual(std::string_view s1,
std::string_view s2)
{
return strcasecmp(str1, str2) == 0;
return std::ranges::equal(s1, s2, [](unsigned char c1, unsigned char c2) {
return std::tolower(c1) == std::tolower(c2);
});
}
inline bool
stringEqualIf(const char *str1,
const char *str2)
{
return (str1 == nullptr && str2 == nullptr)
|| (str1 && str2 && strcasecmp(str1, str2) == 0);
}
inline bool
stringLess(const char *str1,
const char *str2)
{
return strcmp(str1, str2) < 0;
}
inline bool
stringLessIf(const char *str1,
const char *str2)
{
return (str1 == nullptr && str2 != nullptr)
|| (str1 != nullptr && str2 != nullptr && strcmp(str1, str2) < 0);
}
class CharPtrLess
{
public:
bool operator()(const char *string1,
const char *string2) const
{
return stringLess(string1, string2);
}
};
// Case insensitive comparision.
class CharPtrCaseLess
{
public:
bool operator()(const char *string1,
const char *string2) const
{
return strcasecmp(string1, string2) < 0;
}
};
class StringLessIf
{
public:
bool operator()(const char *string1,
const char *string2) const
{
return stringLessIf(string1, string2);
}
};
// strdup using new instead of malloc so delete can be used on the strings.
char *
stringCopy(const char *str);
void
stringDeleteCheck(const char *str);
@@ -153,17 +94,14 @@ stringDelete(const char *str)
delete [] str;
}
std::pair<float, bool>
stringFloat(const std::string &str);
bool
isDigits(const char *str);
char *
makeTmpString(size_t length);
char *
makeTmpString(std::string &str);
bool
isTmpString(const char *str);
void
deleteTmpStrings();
isDigits(std::string_view str);
////////////////////////////////////////////////////////////////
@@ -171,9 +109,9 @@ deleteTmpStrings();
void
trimRight(std::string &str);
// Spit text into delimiter separated tokens and skip whitepace.
// Parse text into delimiter separated tokens and skip whitepace.
StringSeq
parseTokens(const std::string &s,
const char delimiter);
parseTokens(const std::string &text,
std::string_view delims = " \t");
} // namespace
+22 -21
View File
@@ -27,6 +27,7 @@
#include <array>
#include <memory>
#include <string>
#include <string_view>
#include <vector>
#include "MinMax.hh"
@@ -54,8 +55,8 @@ using Waveform = Table;
using TableModelsEarlyLate = std::array<TableModel*, EarlyLate::index_count>;
TableAxisVariable
stringTableAxisVariable(const char *variable);
const char *
stringTableAxisVariable(std::string_view variable);
std::string_view
tableVariableString(TableAxisVariable variable);
const Unit *
tableVariableUnit(TableAxisVariable variable,
@@ -121,7 +122,7 @@ protected:
float in_slew,
float load_cap,
float related_out_cap) const;
std::string reportTableLookup(const char *result_name,
std::string reportTableLookup(std::string_view result_name,
const Pvt *pvt,
const TableModel *model,
float in_slew,
@@ -158,7 +159,7 @@ public:
PocvMode pocv_mode) const override;
std::string reportCheckDelay(const Pvt *pvt,
float from_slew,
const char *from_slew_annotation,
std::string_view from_slew_annotation,
float to_slew,
float related_out_cap,
const MinMax *min_max,
@@ -189,11 +190,11 @@ protected:
float load_cap,
float in_slew,
float related_out_cap) const;
std::string reportTableDelay(const char *result_name,
std::string reportTableDelay(std::string_view result_name,
const Pvt *pvt,
const TableModel *model,
float from_slew,
const char *from_slew_annotation,
std::string_view from_slew_annotation,
float to_slew,
float related_out_cap,
int digits) const;
@@ -208,7 +209,7 @@ public:
TableAxis(TableAxisVariable variable,
FloatSeq &&values);
TableAxisVariable variable() const { return variable_; }
const char *variableString() const;
std::string_view variableString() const;
const Unit *unit(const Units *units);
size_t size() const { return values_.size(); }
bool inBounds(float value) const;
@@ -287,11 +288,11 @@ public:
float axis_value2,
float axis_value3) const;
std::string reportValue(const char *result_name,
std::string reportValue(std::string_view result_name,
const LibertyCell *cell,
const Pvt *pvt,
float value1,
const char *comment1,
std::string_view comment1,
float value2,
float value3,
const Unit *table_unit,
@@ -309,30 +310,30 @@ private:
void clear();
float findValueOrder2(float axis_value1, float axis_value2) const;
float findValueOrder3(float axis_value1, float axis_value2, float axis_value3) const;
std::string reportValueOrder0(const char *result_name,
const char *comment1,
std::string reportValueOrder0(std::string_view result_name,
std::string_view comment1,
const Unit *table_unit,
int digits) const;
std::string reportValueOrder1(const char *result_name,
std::string reportValueOrder1(std::string_view result_name,
const LibertyCell *cell,
float value1,
const char *comment1,
std::string_view comment1,
float value2,
float value3,
const Unit *table_unit,
int digits) const;
std::string reportValueOrder2(const char *result_name,
std::string reportValueOrder2(std::string_view result_name,
const LibertyCell *cell,
float value1,
const char *comment1,
std::string_view comment1,
float value2,
float value3,
const Unit *table_unit,
int digits) const;
std::string reportValueOrder3(const char *result_name,
std::string reportValueOrder3(std::string_view result_name,
const LibertyCell *cell,
float value1,
const char *comment1,
std::string_view comment1,
float value2,
float value3,
const Unit *table_unit,
@@ -379,11 +380,11 @@ public:
float value1,
float value2,
float value3) const;
std::string reportValue(const char *result_name,
std::string reportValue(std::string_view result_name,
const LibertyCell *cell,
const Pvt *pvt,
float value1,
const char *comment1,
std::string_view comment1,
float value2,
float value3,
const Unit *table_unit,
@@ -535,9 +536,9 @@ private:
class DriverWaveform
{
public:
DriverWaveform(const std::string &name,
DriverWaveform(std::string name,
TablePtr waveforms);
const char *name() const { return name_.c_str(); }
std::string_view name() const { return name_; }
Table waveform(float slew);
private:
+6 -6
View File
@@ -34,14 +34,14 @@ namespace sta {
#endif
StringSeq
tclListSeqStdString(Tcl_Obj *const source,
Tcl_Interp *interp);
tclListStringSeq(Tcl_Obj *const source,
Tcl_Interp *interp);
StringSeq *
tclListSeqStdStringPtr(Tcl_Obj *const source,
Tcl_Interp *interp);
StringSet *
tclListSetStdString(Tcl_Obj *const source,
tclListStringSeqPtr(Tcl_Obj *const source,
Tcl_Interp *interp);
StringSet *
tclListStringSet(Tcl_Obj *const source,
Tcl_Interp *interp);
void
tclArgError(Tcl_Interp *interp,
+7 -7
View File
@@ -83,10 +83,10 @@ enum class TimingType {
unknown
};
const char *
std::string_view
to_string(TimingType type);
TimingType
findTimingType(const char *string);
findTimingType(std::string_view string);
bool
timingTypeIsCheck(TimingType type);
ScaleFactorType
@@ -107,15 +107,15 @@ public:
FuncExpr *cond() const { return cond_; }
void setCond(FuncExpr *cond);
const std::string &sdfCond() const { return sdf_cond_; }
void setSdfCond(const std::string &cond);
void setSdfCond(std::string cond);
const std::string &sdfCondStart() const { return sdf_cond_start_; }
void setSdfCondStart(const std::string &cond);
void setSdfCondStart(std::string cond);
const std::string &sdfCondEnd() const { return sdf_cond_end_; }
void setSdfCondEnd(const std::string &cond);
void setSdfCondEnd(std::string cond);
const std::string &modeName() const { return mode_name_; }
void setModeName(const std::string &name);
void setModeName(std::string name);
const std::string &modeValue() const { return mode_value_; }
void setModeValue(const std::string &value);
void setModeValue(std::string value);
TimingModel *model(const RiseFall *rf) const;
void setModel(const RiseFall *rf,
TimingModel *model);
+2 -1
View File
@@ -25,6 +25,7 @@
#pragma once
#include <string>
#include <string_view>
#include "Delay.hh"
#include "LibertyClass.hh"
@@ -88,7 +89,7 @@ public:
PocvMode pocv_mode) const = 0;
virtual std::string reportCheckDelay(const Pvt *pvt,
float from_slew,
const char *from_slew_annotation,
std::string_view from_slew_annotation,
float to_slew,
float related_out_cap,
const MinMax *min_max,
+17 -16
View File
@@ -25,8 +25,9 @@
#pragma once
#include <array>
#include <vector>
#include <functional>
#include <map>
#include <vector>
#include "Iterator.hh"
#include "StringUtil.hh"
@@ -37,7 +38,7 @@ class Transition;
class RiseFall;
class RiseFallBoth;
using TransitionMap = std::map<const std::string, const Transition*>;
using TransitionMap = std::map<std::string, const Transition*, std::less<>>;
// Rise/fall transition.
class RiseFall
@@ -49,14 +50,14 @@ public:
static int riseIndex() { return rise_.sdf_triple_index_; }
static int fallIndex() { return fall_.sdf_triple_index_; }
const std::string &to_string(bool use_short = false) const;
const char *name() const { return name_.c_str(); }
const char *shortName() const { return short_name_.c_str(); }
const std::string &name() const { return name_; }
const std::string &shortName() const { return short_name_; }
int index() const { return sdf_triple_index_; }
const RiseFallBoth *asRiseFallBoth();
const RiseFallBoth *asRiseFallBoth() const;
const Transition *asTransition() const;
// Find transition corresponding to rf_str.
static const RiseFall *find(const char *rf_str);
static const RiseFall *find(std::string_view rf_str);
// Find transition from index.
static const RiseFall *find(int index);
const RiseFall *opposite() const;
@@ -71,8 +72,8 @@ public:
static const int index_bit_count = 1;
protected:
RiseFall(const char *name,
const char *short_name,
RiseFall(std::string_view name,
std::string_view short_name,
int sdf_triple_index);
const std::string name_;
@@ -94,14 +95,14 @@ public:
static const RiseFallBoth *fall() { return &fall_; }
static const RiseFallBoth *riseFall() { return &rise_fall_; }
const std::string &to_string(bool use_short = false) const;
const char *name() const { return name_.c_str(); }
const char *shortName() const { return short_name_.c_str(); }
const std::string &name() const { return name_; }
const std::string &shortName() const { return short_name_; }
int index() const { return sdf_triple_index_; }
bool matches(const RiseFall *rf) const;
bool matches(const Transition *tr) const;
const RiseFall *asRiseFall() const { return as_rise_fall_; }
// Find transition corresponding to string.
static const RiseFallBoth *find(const char *tr_str);
static const RiseFallBoth *find(std::string_view tr_str);
// for (const auto rf : rf->range()) {}
const std::vector<const RiseFall*> &range() const { return range_; }
// for (const auto rf_index : rf->rangeIndex()) {}
@@ -112,8 +113,8 @@ public:
static const int index_bit_count = 2;
protected:
RiseFallBoth(const char *name,
const char *short_name,
RiseFallBoth(std::string_view name,
std::string_view short_name,
int sdf_triple_index,
const RiseFall *as_rise_fall,
std::vector<const RiseFall*> range,
@@ -152,19 +153,19 @@ public:
static const Transition *riseFall() { return &rise_fall_; }
const std::string &to_string() const { return name_; }
// As initial/final value pair.
const char *asInitFinalString() const { return init_final_.c_str(); }
const std::string &asInitFinalString() const { return init_final_; }
int sdfTripleIndex() const { return sdf_triple_index_; }
int index() const { return sdf_triple_index_; }
const RiseFall *asRiseFall() const { return as_rise_fall_; }
const RiseFallBoth *asRiseFallBoth() const;
bool matches(const Transition *tr) const;
// Find transition corresponding to string.
static const Transition *find(const char *tr_str);
static const Transition *find(std::string_view tr_str);
static int maxIndex() { return max_index_; }
private:
Transition(const char *name,
const char *init_final,
Transition(std::string_view name,
std::string_view init_final,
const RiseFall *as_rise_fall,
int sdf_triple_index);
+1 -1
View File
@@ -75,7 +75,7 @@ class Units
{
public:
Units();
Unit *find(const char *unit_name);
Unit *find(std::string_view unit_name);
void operator=(const Units &units);
Unit *timeUnit() { return &time_unit_; }
const Unit *timeUnit() const { return &time_unit_; }
+23 -47
View File
@@ -74,7 +74,7 @@ public:
std::string_view msg,
bool warn);
const char *msg() const { return msg_.c_str(); }
const char *filename() const { return filename_.c_str(); }
std::string_view filename() const { return filename_; }
int id() const { return id_; }
int line() const { return line_; }
bool warn() const { return warn_; }
@@ -102,14 +102,14 @@ class VerilogReader
public:
VerilogReader(NetworkReader *network);
~VerilogReader();
bool read(const char *filename);
bool read(std::string_view filename);
void makeModule(const std::string *module_name,
void makeModule(std::string &&module_name,
VerilogNetSeq *ports,
VerilogStmtSeq *stmts,
VerilogAttrStmtSeq *attr_stmts,
int line);
void makeModule(const std::string *module_name,
void makeModule(std::string &&module_name,
VerilogStmtSeq *port_dcls,
VerilogStmtSeq *stmts,
VerilogAttrStmtSeq *attr_stmts,
@@ -122,7 +122,7 @@ public:
VerilogDclArg *arg,
VerilogAttrStmtSeq *attr_stmts,
int line);
VerilogDclArg *makeDclArg(const std::string *net_name);
VerilogDclArg *makeDclArg(std::string &&net_name);
VerilogDclArg*makeDclArg(VerilogAssign *assign);
VerilogDclBus *makeDclBus(PortDirection *dir,
int from_index,
@@ -136,43 +136,43 @@ public:
VerilogDclArgSeq *args,
VerilogAttrStmtSeq *attr_stmts,
int line);
VerilogInst *makeModuleInst(const std::string *module_name,
const std::string *inst_name,
VerilogInst *makeModuleInst(std::string &&module_name,
std::string &&inst_name,
VerilogNetSeq *pins,
VerilogAttrStmtSeq *attr_stmts,
const int line);
VerilogAssign *makeAssign(VerilogNet *lhs,
VerilogNet *rhs,
int line);
VerilogNetScalar *makeNetScalar(const std::string *name);
VerilogNetPortRef *makeNetNamedPortRefScalarNet(const std::string *port_vname);
VerilogNetPortRef *makeNetNamedPortRefScalarNet(const std::string *port_name,
const std::string *net_name);
VerilogNetPortRef *makeNetNamedPortRefBitSelect(const std::string *port_name,
const std::string *bus_name,
VerilogNetScalar *makeNetScalar(std::string &&name);
VerilogNetPortRef *makeNetNamedPortRefScalarNet(std::string &&port_vname);
VerilogNetPortRef *makeNetNamedPortRefScalarNet(std::string &&port_name,
std::string &&net_name);
VerilogNetPortRef *makeNetNamedPortRefBitSelect(std::string &&port_name,
std::string &&bus_name,
int index);
VerilogNetPortRef *makeNetNamedPortRefScalar(const std::string *port_name,
VerilogNetPortRef *makeNetNamedPortRefScalar(std::string &&port_name,
VerilogNet *net);
VerilogNetPortRef *makeNetNamedPortRefBit(const std::string *port_name,
VerilogNetPortRef *makeNetNamedPortRefBit(std::string &&port_name,
int index,
VerilogNet *net);
VerilogNetPortRef *makeNetNamedPortRefPart(const std::string *port_name,
VerilogNetPortRef *makeNetNamedPortRefPart(std::string &&port_name,
int from_index,
int to_index,
VerilogNet *net);
VerilogNetConcat *makeNetConcat(VerilogNetSeq *nets);
VerilogNetConstant *makeNetConstant(const std::string *constant,
int line);
VerilogNetBitSelect *makeNetBitSelect(const std::string *name,
VerilogNetConstant *makeNetConstant(std::string &&constant,
int line);
VerilogNetBitSelect *makeNetBitSelect(std::string &&name,
int index);
VerilogNetPartSelect *makeNetPartSelect(const std::string *name,
VerilogNetPartSelect *makeNetPartSelect(std::string &&name,
int from_index,
int to_index);
VerilogModule *module(Cell *cell);
Instance *linkNetwork(const char *top_cell_name,
Instance *linkNetwork(std::string_view top_cell_name,
bool make_black_boxes,
bool delete_modules);
const char *filename() const { return filename_.c_str(); }
std::string_view filename() const { return filename_; }
void incrLine();
Report *report() const { return report_; }
template <typename... Args>
@@ -196,11 +196,10 @@ public:
const std::string &zeroNetName() const { return zero_net_name_; }
const std::string &oneNetName() const { return one_net_name_; }
void deleteModules();
void reportStmtCounts();
const std::string &constant10Max() const { return constant10_max_; }
protected:
void init(const char *filename);
void init(std::string_view filename);
void makeCellPorts(Cell *cell,
VerilogModule *module,
VerilogNetSeq *ports);
@@ -315,29 +314,6 @@ protected:
const std::string one_net_name_;
std::string constant10_max_;
ViewType *view_type_;
bool report_stmt_stats_;
int module_count_;
int inst_mod_count_;
int inst_lib_count_;
int inst_lib_net_arrays_;
int port_names_;
int inst_module_names_;
int inst_names_;
int dcl_count_;
int dcl_bus_count_;
int dcl_arg_count_;
int net_scalar_count_;
int net_scalar_names_;
int net_bus_names_;
int net_part_select_count_;
int net_bit_select_count_;
int net_port_ref_scalar_count_;
int net_port_ref_scalar_net_count_;
int net_port_ref_bit_count_;
int net_port_ref_part_count_;
int net_constant_count_;
int assign_count_;
int concat_count_;
};
} // namespace sta
+11 -9
View File
@@ -24,6 +24,8 @@
#pragma once
#include <string>
#include <string_view>
#include <utility>
#include <vector>
@@ -40,26 +42,26 @@ using WireloadForAreaSeq = std::vector<WireloadForArea*>;
const char *
wireloadTreeString(WireloadTree tree);
WireloadTree
stringWireloadTree(const char *tree);
stringWireloadTree(std::string_view tree);
const char *
wireloadModeString(WireloadMode wire_load_mode);
WireloadMode
stringWireloadMode(const char *wire_load_mode);
stringWireloadMode(std::string_view wire_load_mode);
class Wireload
{
public:
Wireload(const char *name,
Wireload(std::string name,
LibertyLibrary *library);
Wireload(const char *name,
Wireload(std::string name,
LibertyLibrary *library,
float area,
float resistance,
float capacitance,
float slope);
virtual ~Wireload();
const char *name() const { return name_; }
const std::string &name() const { return name_; }
void setArea(float area);
void setResistance(float res);
void setCapacitance(float cap);
@@ -73,7 +75,7 @@ public:
float &res) const;
protected:
const char *name_;
std::string name_;
LibertyLibrary *library_;
float area_;
float resistance_;
@@ -86,16 +88,16 @@ protected:
class WireloadSelection
{
public:
WireloadSelection(const char *name);
WireloadSelection(std::string name);
~WireloadSelection();
const char *name() const { return name_; }
const std::string &name() const { return name_; }
void addWireloadFromArea(float min_area,
float max_area,
const Wireload *wireload);
const Wireload *findWireload(float area) const;
private:
const char *name_;
const std::string name_;
WireloadForAreaSeq wireloads_;
};