Table use make_shared

Signed-off-by: James Cherry <cherry@parallaxsw.com>
This commit is contained in:
James Cherry 2023-01-18 10:23:03 -07:00
parent 6b8ab8aa9c
commit 0b4018e45d
8 changed files with 37 additions and 72 deletions

View File

@ -179,7 +179,7 @@ public:
float wire_delay) const;
// Check for supported axis variables.
// Return true if axes are supported.
static bool checkSlewDegradationAxes(Table *table);
static bool checkSlewDegradationAxes(TablePtr table);
float defaultInputPinCap() const { return default_input_pin_cap_; }
void setDefaultInputPinCap(float cap);
@ -1050,18 +1050,18 @@ public:
OcvDerate(const char *name);
~OcvDerate();
const char *name() const { return name_; }
Table *derateTable(const RiseFall *rf,
const EarlyLate *early_late,
PathType path_type);
TablePtr derateTable(const RiseFall *rf,
const EarlyLate *early_late,
PathType path_type);
void setDerateTable(const RiseFall *rf,
const EarlyLate *early_late,
PathType path_type,
Table *derate);
TablePtr derate);
private:
const char *name_;
// [rf_type][derate_type][path_type]
Table *derate_[RiseFall::index_count][EarlyLate::index_count][path_type_count];
TablePtr derate_[RiseFall::index_count][EarlyLate::index_count][path_type_count];
};
// Power/ground port.

View File

@ -68,6 +68,7 @@ typedef std::pair<const LibertyPort*,const LibertyPort*> LibertyPortPair;
typedef Set<LibertyCell*> LibertyCellSet;
typedef Vector<float> FloatSeq;
typedef Vector<FloatSeq*> FloatTable;
typedef std::shared_ptr<Table> TablePtr;
typedef std::shared_ptr<TimingArcAttrs> TimingArcAttrsPtr;
typedef std::shared_ptr<TableAxis> TableAxisPtr;

View File

@ -74,7 +74,7 @@ public:
const TableModel *slewModel() const { return slew_model_; }
// Check the axes before making the model.
// Return true if the model axes are supported.
static bool checkAxes(const Table *table);
static bool checkAxes(const TablePtr table);
protected:
void maxCapSlew(const LibertyCell *cell,
@ -147,7 +147,7 @@ public:
// Check the axes before making the model.
// Return true if the model axes are supported.
static bool checkAxes(const Table *table);
static bool checkAxes(const TablePtr table);
protected:
virtual void setIsScaled(bool is_scaled);
@ -190,11 +190,10 @@ protected:
class TableModel
{
public:
TableModel(Table *table,
TableModel(TablePtr table,
TableTemplate *tbl_template,
ScaleFactorType scale_factor_type,
RiseFall *rf);
~TableModel();
void setScaleFactorType(ScaleFactorType type);
int order() const;
TableTemplate *tblTemplate() const { return tbl_template_; }
@ -239,7 +238,7 @@ protected:
int digits,
string *result) const;
Table *table_;
TablePtr table_;
TableTemplate *tbl_template_;
// ScaleFactorType gcc barfs if this is dcl'd.
unsigned scale_factor_type_:scale_factor_bits;

View File

@ -373,7 +373,7 @@ LibertyLibrary::degradeWireSlew(const LibertyCell *cell,
// Check for supported axis variables.
// Return true if axes are supported.
bool
LibertyLibrary::checkSlewDegradationAxes(Table *table)
LibertyLibrary::checkSlewDegradationAxes(TablePtr table)
{
switch (table->order()) {
case 0:
@ -2964,28 +2964,9 @@ OcvDerate::OcvDerate(const char *name) :
OcvDerate::~OcvDerate()
{
stringDelete(name_);
// Derating table models can be shared in multiple places in derate_;
// Collect them in a set to avoid duplicate deletes.
Set<Table*> models;
for (auto el_index : EarlyLate::rangeIndex()) {
for (auto tr_index : RiseFall::rangeIndex()) {
Table *derate;
derate = derate_[tr_index][el_index][int(PathType::clk)];
if (derate)
models.insert(derate);
derate = derate_[tr_index][el_index][int(PathType::data)];
if (derate)
models.insert(derate);
}
}
Set<Table*>::Iterator model_iter(models);
while (model_iter.hasNext()) {
Table *model = model_iter.next();
delete model;
}
}
Table *
TablePtr
OcvDerate::derateTable(const RiseFall *rf,
const EarlyLate *early_late,
PathType path_type)
@ -2997,7 +2978,7 @@ void
OcvDerate::setDerateTable(const RiseFall *rf,
const EarlyLate *early_late,
const PathType path_type,
Table *derate)
TablePtr derate)
{
derate_[rf->index()][early_late->index()][int(path_type)] = derate;
}

View File

@ -44,6 +44,8 @@ extern int LibertyParse_debug;
namespace sta {
using std::make_shared;
static void
scaleFloats(FloatSeq *floats,
float scale);
@ -3803,10 +3805,8 @@ LibertyReader::endCellRiseFall(LibertyGroup *group)
scale_factor_type_, rf_);
timing_->setCell(rf_, table_model);
}
else {
else
libWarn(118, group, "unsupported model axis.");
delete table_;
}
}
endTableModel();
}
@ -3832,10 +3832,8 @@ LibertyReader::endRiseFallTransition(LibertyGroup *group)
scale_factor_type_, rf_);
timing_->setTransition(rf_, table_model);
}
else {
else
libWarn(119, group, "unsupported model axis.");
delete table_;
}
}
endTableModel();
}
@ -3863,10 +3861,8 @@ LibertyReader::endRiseFallConstraint(LibertyGroup *group)
scale_factor_type_, rf_);
timing_->setConstraint(rf_, table_model);
}
else {
else
libWarn(120, group, "unsupported model axis.");
delete table_;
}
}
endTableModel();
}
@ -3900,10 +3896,8 @@ LibertyReader::endRiseFallTransitionDegredation(LibertyGroup *group)
scale_factor_type_, rf_);
library_->setWireSlewDegradationTable(table_model, rf_);
}
else {
else
libWarn(121, group, "unsupported model axis.");
delete table_;
}
}
endTableModel();
}
@ -4004,27 +3998,27 @@ LibertyReader::makeTable(LibertyAttr *attr,
FloatTable *table = makeFloatTable(attr,
axis_[0]->size()*axis_[1]->size(),
axis_[2]->size(), scale);
table_ = new Table3(table, axis_[0], axis_[1], axis_[2]);
table_ = make_shared<Table3>(table, axis_[0], axis_[1], axis_[2]);
}
else if (axis_[0] && axis_[1]) {
// Row variable1/axis[0]
// Column variable2/axis[1]
FloatTable *table = makeFloatTable(attr, axis_[0]->size(),
axis_[1]->size(), scale);
table_ = new Table2(table, axis_[0], axis_[1]);
table_ = make_shared<Table2>(table, axis_[0], axis_[1]);
}
else if (axis_[0]) {
FloatTable *table = makeFloatTable(attr, 1, axis_[0]->size(), scale);
FloatSeq *values = (*table)[0];
delete table;
table_ = new Table1(values, axis_[0]);
table_ = make_shared<Table1>(values, axis_[0]);
}
else {
FloatTable *table = makeFloatTable(attr, 1, 1, scale);
float value = (*(*table)[0])[0];
delete (*table)[0];
delete table;
table_ = new Table0(value);
table_ = make_shared<Table0>(value);
}
}
else
@ -4819,10 +4813,8 @@ LibertyReader::endOcvSigmaCell(LibertyGroup *group)
else
timing_->setDelaySigma(rf_, sigma_type_->asMinMax(), table_model);
}
else {
else
libWarn(152, group, "unsupported model axis.");
delete table_;
}
}
endTableModel();
}
@ -4853,10 +4845,8 @@ LibertyReader::endOcvSigmaTransition(LibertyGroup *group)
else
timing_->setSlewSigma(rf_, sigma_type_->asMinMax(), table_model);
}
else {
else
libWarn(153, group, "unsupported model axis.");
delete table_;
}
}
endTableModel();
}
@ -4887,10 +4877,8 @@ LibertyReader::endOcvSigmaConstraint(LibertyGroup *group)
else
timing_->setConstraintSigma(rf_, sigma_type_->asMinMax(), table_model);
}
else {
else
libWarn(154, group, "unsupported model axis.");
delete table_;
}
}
endTableModel();
}

View File

@ -575,7 +575,7 @@ protected:
LibertyPgPort *pg_port_;
ScaleFactorType scale_factor_type_;
TableAxisPtr axis_[3];
Table *table_;
TablePtr table_;
float table_model_scale_;
ModeDef *mode_def_;
ModeValueDef *mode_value_;

View File

@ -320,7 +320,7 @@ GateTableModel::axisValue(TableAxisPtr axis,
}
bool
GateTableModel::checkAxes(const Table *table)
GateTableModel::checkAxes(const TablePtr table)
{
TableAxisPtr axis1 = table->axis1();
TableAxisPtr axis2 = table->axis2();
@ -529,7 +529,7 @@ CheckTableModel::axisValue(TableAxisPtr axis,
}
bool
CheckTableModel::checkAxes(const Table *table)
CheckTableModel::checkAxes(const TablePtr table)
{
TableAxisPtr axis1 = table->axis1();
TableAxisPtr axis2 = table->axis2();
@ -555,7 +555,7 @@ CheckTableModel::checkAxis(TableAxisPtr axis)
////////////////////////////////////////////////////////////////
TableModel::TableModel(Table *table,
TableModel::TableModel(TablePtr table,
TableTemplate *tbl_template,
ScaleFactorType scale_factor_type,
RiseFall *rf) :
@ -567,11 +567,6 @@ TableModel::TableModel(Table *table,
{
}
TableModel::~TableModel()
{
delete table_;
}
int
TableModel::order() const
{

View File

@ -43,6 +43,7 @@
namespace sta {
using std::max;
using std::make_shared;
MakeTimingModel::MakeTimingModel(const Corner *corner,
Sta *sta) :
@ -500,7 +501,7 @@ MakeTimingModel::makeScalarCheckModel(float value,
ScaleFactorType scale_factor_type,
RiseFall *rf)
{
Table *table = new Table0(value);
TablePtr table = make_shared<Table0>(value);
TableTemplate *tbl_template =
library_->findTableTemplate("scalar", TableTemplateType::delay);
TableModel *table_model = new TableModel(table, tbl_template,
@ -514,8 +515,8 @@ MakeTimingModel::makeGateModelScalar(Delay delay,
Slew slew,
RiseFall *rf)
{
Table *delay_table = new Table0(delayAsFloat(delay));
Table *slew_table = new Table0(delayAsFloat(slew));
TablePtr delay_table = make_shared<Table0>(delayAsFloat(delay));
TablePtr slew_table = make_shared<Table0>(delayAsFloat(slew));
TableTemplate *tbl_template =
library_->findTableTemplate("scalar", TableTemplateType::delay);
TableModel *delay_model = new TableModel(delay_table, tbl_template,
@ -590,8 +591,8 @@ MakeTimingModel::makeGateModelTable(const Pin *output_pin,
std::make_shared<TableAxis>(TableAxisVariable::total_output_net_capacitance,
axis_values);
Table *delay_table = new Table1(load_values, load_axis);
Table *slew_table = new Table1(slew_values, load_axis);
TablePtr delay_table = make_shared<Table1>(load_values, load_axis);
TablePtr slew_table = make_shared<Table1>(slew_values, load_axis);
string template_name = "template_";
template_name += std::to_string(tbl_template_index_++);