Internals: clang-format cleanup. No functional change.
This commit is contained in:
parent
dcde026bac
commit
aef2b7ea3c
|
|
@ -32,6 +32,7 @@ class UnrollStateful {
|
|||
// MEMBERS
|
||||
UnrollVisitor* m_unrollerp;
|
||||
VL_UNCOPYABLE(UnrollStateful);
|
||||
|
||||
public:
|
||||
// CONSTRUCTORS
|
||||
UnrollStateful();
|
||||
|
|
|
|||
|
|
@ -37,13 +37,11 @@
|
|||
//######################################################################
|
||||
// VlcOptions
|
||||
|
||||
void VlcOptions::addReadFile(const string& filename) {
|
||||
m_readFiles.insert(filename);
|
||||
}
|
||||
void VlcOptions::addReadFile(const string& filename) { m_readFiles.insert(filename); }
|
||||
|
||||
string VlcOptions::version() {
|
||||
string ver = DTVERSION;
|
||||
ver += " rev "+cvtToStr(DTVERSION_rev);
|
||||
ver += " rev " + cvtToStr(DTVERSION_rev);
|
||||
return ver;
|
||||
}
|
||||
|
||||
|
|
@ -52,10 +50,17 @@ bool VlcOptions::onoff(const char* sw, const char* arg, bool& flag) {
|
|||
// if sw=="-no-arg", then return true (found it), and flag=false
|
||||
// if sw=="-noarg", then return true (found it), and flag=false
|
||||
// else return false
|
||||
if (arg[0]!='-') v3fatalSrc("OnOff switches must have leading dash.");
|
||||
if (0==strcmp(sw, arg)) { flag = true; return true; }
|
||||
else if (0==strncmp(sw, "-no", 3) && (0==strcmp(sw+3, arg+1))) { flag = false; return true; }
|
||||
else if (0==strncmp(sw, "-no-", 4) && (0==strcmp(sw+4, arg+1))) { flag = false; return true; }
|
||||
if (arg[0] != '-') v3fatalSrc("OnOff switches must have leading dash.");
|
||||
if (0 == strcmp(sw, arg)) {
|
||||
flag = true;
|
||||
return true;
|
||||
} else if (0 == strncmp(sw, "-no", 3) && (0 == strcmp(sw + 3, arg + 1))) {
|
||||
flag = false;
|
||||
return true;
|
||||
} else if (0 == strncmp(sw, "-no-", 4) && (0 == strcmp(sw + 4, arg + 1))) {
|
||||
flag = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -64,57 +69,52 @@ void VlcOptions::parseOptsList(int argc, char** argv) {
|
|||
// Note argc and argv DO NOT INCLUDE the filename in [0]!!!
|
||||
// May be called recursively when there are -f files.
|
||||
#define shift { ++i; }
|
||||
for (int i=0; i<argc; ) {
|
||||
UINFO(9, " Option: "<<argv[i]<<endl);
|
||||
if (argv[i][0]=='-') {
|
||||
for (int i = 0; i < argc;) {
|
||||
UINFO(9, " Option: " << argv[i] << endl);
|
||||
if (argv[i][0] == '-') {
|
||||
const char* sw = argv[i];
|
||||
bool flag = true;
|
||||
// Allow gnu -- switches
|
||||
if (sw[0]=='-' && sw[1]=='-') ++sw;
|
||||
if (0) {}
|
||||
if (sw[0] == '-' && sw[1] == '-') ++sw;
|
||||
// Single switches
|
||||
else if (onoff (sw, "-annotate-all", flag/*ref*/) ) { m_annotateAll = flag; }
|
||||
else if (onoff (sw, "-rank", flag/*ref*/) ) { m_rank = flag; }
|
||||
else if (onoff (sw, "-unlink", flag/*ref*/) ) { m_unlink = flag; }
|
||||
else if (onoff(sw, "-annotate-all", flag /*ref*/)) {
|
||||
m_annotateAll = flag;
|
||||
} else if (onoff(sw, "-rank", flag /*ref*/)) {
|
||||
m_rank = flag;
|
||||
} else if (onoff(sw, "-unlink", flag /*ref*/)) {
|
||||
m_unlink = flag;
|
||||
}
|
||||
// Parameterized switches
|
||||
else if (!strcmp(sw, "-annotate-min") && (i+1)<argc ) {
|
||||
else if (!strcmp(sw, "-annotate-min") && (i + 1) < argc) {
|
||||
shift;
|
||||
m_annotateMin = atoi(argv[i]);
|
||||
}
|
||||
else if (!strcmp(sw, "-annotate") && (i+1)<argc ) {
|
||||
} else if (!strcmp(sw, "-annotate") && (i + 1) < argc) {
|
||||
shift;
|
||||
m_annotateOut = argv[i];
|
||||
}
|
||||
else if (!strcmp(sw, "-debug") ) {
|
||||
} else if (!strcmp(sw, "-debug")) {
|
||||
V3Error::debugDefault(3);
|
||||
}
|
||||
else if (!strcmp(sw, "-debugi") && (i+1)<argc ) {
|
||||
} else if (!strcmp(sw, "-debugi") && (i + 1) < argc) {
|
||||
shift;
|
||||
V3Error::debugDefault(atoi(argv[i]));
|
||||
}
|
||||
else if (!strcmp(sw, "-V") ) {
|
||||
} else if (!strcmp(sw, "-V")) {
|
||||
showVersion(true);
|
||||
exit(0);
|
||||
}
|
||||
else if (!strcmp(sw, "-version") ) {
|
||||
} else if (!strcmp(sw, "-version")) {
|
||||
showVersion(false);
|
||||
exit(0);
|
||||
}
|
||||
else if (!strcmp(sw, "-write") && (i+1)<argc ) {
|
||||
} else if (!strcmp(sw, "-write") && (i + 1) < argc) {
|
||||
shift;
|
||||
m_writeFile = argv[i];
|
||||
}
|
||||
else {
|
||||
v3fatal("Invalid option: "<<argv[i]);
|
||||
} else {
|
||||
v3fatal("Invalid option: " << argv[i]);
|
||||
}
|
||||
shift;
|
||||
} // - options
|
||||
else if (1) {
|
||||
addReadFile(argv[i]);
|
||||
shift;
|
||||
}
|
||||
else {
|
||||
v3fatal("Invalid argument: "<<argv[i]);
|
||||
} else {
|
||||
v3fatal("Invalid argument: " << argv[i]);
|
||||
shift;
|
||||
}
|
||||
}
|
||||
|
|
@ -122,17 +122,17 @@ void VlcOptions::parseOptsList(int argc, char** argv) {
|
|||
}
|
||||
|
||||
void VlcOptions::showVersion(bool verbose) {
|
||||
cout <<version();
|
||||
cout <<endl;
|
||||
cout << version();
|
||||
cout << endl;
|
||||
if (!verbose) return;
|
||||
|
||||
cout <<endl;
|
||||
cout << endl;
|
||||
cout << "Copyright 2003-2020 by Wilson Snyder. Verilator is free software; you can\n";
|
||||
cout << "redistribute it and/or modify the Verilator internals under the terms of\n";
|
||||
cout << "either the GNU Lesser General Public License Version 3 or the Perl Artistic\n";
|
||||
cout << "License Version 2.0.\n";
|
||||
|
||||
cout <<endl;
|
||||
cout << endl;
|
||||
cout << "See https://verilator.org for documentation\n";
|
||||
}
|
||||
|
||||
|
|
@ -145,11 +145,9 @@ int main(int argc, char** argv, char** env) {
|
|||
VlcTop top;
|
||||
|
||||
// Command option parsing
|
||||
top.opt.parseOptsList(argc-1, argv+1);
|
||||
top.opt.parseOptsList(argc - 1, argv + 1);
|
||||
|
||||
if (top.opt.readFiles().empty()) {
|
||||
top.opt.addReadFile("vlt_coverage.dat");
|
||||
}
|
||||
if (top.opt.readFiles().empty()) top.opt.addReadFile("vlt_coverage.dat");
|
||||
|
||||
{
|
||||
const VlStringSet& readFiles = top.opt.readFiles();
|
||||
|
|
@ -165,9 +163,7 @@ int main(int argc, char** argv, char** env) {
|
|||
}
|
||||
|
||||
V3Error::abortIfWarnings();
|
||||
if (!top.opt.annotateOut().empty()) {
|
||||
top.annotate(top.opt.annotateOut());
|
||||
}
|
||||
if (!top.opt.annotateOut().empty()) top.annotate(top.opt.annotateOut());
|
||||
|
||||
if (top.opt.rank()) {
|
||||
top.rank();
|
||||
|
|
@ -189,7 +185,7 @@ int main(int argc, char** argv, char** env) {
|
|||
// Final writing shouldn't throw warnings, but...
|
||||
V3Error::abortIfWarnings();
|
||||
|
||||
UINFO(1,"Done, Exiting...\n");
|
||||
UINFO(1, "Done, Exiting...\n");
|
||||
}
|
||||
|
||||
// Local Variables:
|
||||
|
|
|
|||
|
|
@ -26,11 +26,11 @@
|
|||
//######################################################################
|
||||
|
||||
void VlcTop::readCoverage(const string& filename, bool nonfatal) {
|
||||
UINFO(2,"readCoverage "<<filename<<endl);
|
||||
UINFO(2, "readCoverage " << filename << endl);
|
||||
|
||||
std::ifstream is(filename.c_str());
|
||||
if (!is) {
|
||||
if (!nonfatal) v3fatal("Can't read "<<filename);
|
||||
if (!nonfatal) v3fatal("Can't read " << filename);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -39,15 +39,15 @@ void VlcTop::readCoverage(const string& filename, bool nonfatal) {
|
|||
|
||||
while (!is.eof()) {
|
||||
string line = V3Os::getline(is);
|
||||
//UINFO(9," got "<<line<<endl);
|
||||
// UINFO(9," got "<<line<<endl);
|
||||
if (line[0] == 'C') {
|
||||
string::size_type secspace = 3;
|
||||
for (; secspace<line.length(); secspace++) {
|
||||
if (line[secspace]=='\'' && line[secspace+1]==' ') break;
|
||||
for (; secspace < line.length(); secspace++) {
|
||||
if (line[secspace] == '\'' && line[secspace + 1] == ' ') break;
|
||||
}
|
||||
string point = line.substr(3, secspace-3);
|
||||
vluint64_t hits = atoll(line.c_str()+secspace+1);
|
||||
//UINFO(9," point '"<<point<<"'"<<" "<<hits<<endl);
|
||||
string point = line.substr(3, secspace - 3);
|
||||
vluint64_t hits = atoll(line.c_str() + secspace + 1);
|
||||
// UINFO(9," point '"<<point<<"'"<<" "<<hits<<endl);
|
||||
|
||||
vluint64_t pointnum = points().findAddPoint(point, hits);
|
||||
if (pointnum) {} // Prevent unused
|
||||
|
|
@ -62,25 +62,25 @@ void VlcTop::readCoverage(const string& filename, bool nonfatal) {
|
|||
}
|
||||
|
||||
void VlcTop::writeCoverage(const string& filename) {
|
||||
UINFO(2,"writeCoverage "<<filename<<endl);
|
||||
UINFO(2, "writeCoverage " << filename << endl);
|
||||
|
||||
std::ofstream os(filename.c_str());
|
||||
if (!os) {
|
||||
v3fatal("Can't write "<<filename);
|
||||
v3fatal("Can't write " << filename);
|
||||
return;
|
||||
}
|
||||
|
||||
os << "# SystemC::Coverage-3" << endl;
|
||||
for (VlcPoints::ByName::const_iterator it = m_points.begin(); it != m_points.end(); ++it) {
|
||||
const VlcPoint& point = m_points.pointNumber(it->second);
|
||||
os <<"C '"<<point.name()<<"' " << point.count()<<endl;
|
||||
os << "C '" << point.name() << "' " << point.count() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
//********************************************************************
|
||||
|
||||
struct CmpComputrons {
|
||||
inline bool operator() (const VlcTest* lhsp, const VlcTest* rhsp) const {
|
||||
inline bool operator()(const VlcTest* lhsp, const VlcTest* rhsp) const {
|
||||
if (lhsp->computrons() != rhsp->computrons()) {
|
||||
return lhsp->computrons() < rhsp->computrons();
|
||||
}
|
||||
|
|
@ -89,7 +89,7 @@ struct CmpComputrons {
|
|||
};
|
||||
|
||||
void VlcTop::rank() {
|
||||
UINFO(2,"rank...\n");
|
||||
UINFO(2, "rank...\n");
|
||||
vluint64_t nextrank = 1;
|
||||
|
||||
// Sort by computrons, so fast tests get selected first
|
||||
|
|
@ -106,7 +106,7 @@ void VlcTop::rank() {
|
|||
for (VlcPoints::ByName::const_iterator it = m_points.begin(); it != m_points.end(); ++it) {
|
||||
VlcPoint* pointp = &points().pointNumber(it->second);
|
||||
// If any tests hit this point, then we'll need to cover it.
|
||||
if (pointp->testsCovering()) { remaining.addData(pointp->pointNum(), 1); }
|
||||
if (pointp->testsCovering()) remaining.addData(pointp->pointNum(), 1);
|
||||
}
|
||||
|
||||
// Additional Greedy algorithm
|
||||
|
|
@ -114,10 +114,10 @@ void VlcTop::rank() {
|
|||
// then hierarchically solve a small subset of tests, and take resulting
|
||||
// solution and move up to larger subset of tests. (Aka quick sort.)
|
||||
while (1) {
|
||||
if (debug()) { UINFO(9,"Left on iter"<<nextrank<<": "); remaining.dump(); }
|
||||
if (debug()) { UINFO(9, "Left on iter" << nextrank << ": "); remaining.dump(); }
|
||||
VlcTest* bestTestp = NULL;
|
||||
vluint64_t bestRemain = 0;
|
||||
for (std::vector<VlcTest*>::iterator it=bytime.begin(); it!=bytime.end(); ++it) {
|
||||
for (std::vector<VlcTest*>::iterator it = bytime.begin(); it != bytime.end(); ++it) {
|
||||
VlcTest* testp = *it;
|
||||
if (!testp->rank()) {
|
||||
vluint64_t remain = testp->buckets().dataPopCount(remaining);
|
||||
|
|
@ -145,13 +145,13 @@ void VlcTop::annotateCalc() {
|
|||
const VlcPoint& point = m_points.pointNumber(it->second);
|
||||
string filename = point.filename();
|
||||
int lineno = point.lineno();
|
||||
if (!filename.empty() && lineno!=0) {
|
||||
if (!filename.empty() && lineno != 0) {
|
||||
int column = point.column();
|
||||
VlcSource& source = sources().findNewSource(filename);
|
||||
string threshStr = point.thresh();
|
||||
unsigned thresh = (!threshStr.empty()) ? atoi(threshStr.c_str()) : opt.annotateMin();
|
||||
bool ok = (point.count() >= thresh);
|
||||
UINFO(9, "AnnoCalc count "<<filename<<" "<<lineno<<" "<<point.count()<<endl);
|
||||
UINFO(9, "AnnoCalc count " << filename << " " << lineno << " " << point.count() << endl);
|
||||
source.incCount(lineno, column, point.count(), ok);
|
||||
}
|
||||
}
|
||||
|
|
@ -162,17 +162,16 @@ void VlcTop::annotateCalcNeeded() {
|
|||
// coverage in all categories
|
||||
int totCases = 0;
|
||||
int totOk = 0;
|
||||
for (VlcSources::NameMap::iterator sit=m_sources.begin(); sit!=m_sources.end(); ++sit) {
|
||||
for (VlcSources::NameMap::iterator sit = m_sources.begin(); sit != m_sources.end(); ++sit) {
|
||||
VlcSource& source = sit->second;
|
||||
//UINFO(1,"Source "<<source.name()<<endl);
|
||||
// UINFO(1,"Source "<<source.name()<<endl);
|
||||
if (opt.annotateAll()) source.needed(true);
|
||||
VlcSource::LinenoMap& lines = source.lines();
|
||||
for (VlcSource::LinenoMap::iterator lit = lines.begin(); lit != lines.end(); ++lit) {
|
||||
VlcSource::ColumnMap& cmap = lit->second;
|
||||
for (VlcSource::ColumnMap::iterator cit = cmap.begin(); cit != cmap.end();
|
||||
++cit) {
|
||||
for (VlcSource::ColumnMap::iterator cit = cmap.begin(); cit != cmap.end(); ++cit) {
|
||||
VlcSourceCount& col = cit->second;
|
||||
//UINFO(0,"Source "<<source.name()<<":"<<col.lineno()<<":"<<col.column()<<endl);
|
||||
// UINFO(0,"Source "<<source.name()<<":"<<col.lineno()<<":"<<col.column()<<endl);
|
||||
++totCases;
|
||||
if (col.ok()) {
|
||||
++totOk;
|
||||
|
|
@ -182,36 +181,36 @@ void VlcTop::annotateCalcNeeded() {
|
|||
}
|
||||
}
|
||||
}
|
||||
float pct = totCases ? (100*totOk / totCases) : 0;
|
||||
cout<<"Total coverage ("<<totOk<<"/"<<totCases<<") "
|
||||
<<std::fixed<<std::setw(3)<<std::setprecision(2)<<pct<<"%"<<endl;
|
||||
if (totOk != totCases) cout<<"See lines with '%00' in "<<opt.annotateOut()<<endl;
|
||||
float pct = totCases ? (100 * totOk / totCases) : 0;
|
||||
cout << "Total coverage (" << totOk << "/" << totCases << ") ";
|
||||
cout << std::fixed << std::setw(3) << std::setprecision(2) << pct << "%" << endl;
|
||||
if (totOk != totCases) cout << "See lines with '%00' in " << opt.annotateOut() << endl;
|
||||
}
|
||||
|
||||
void VlcTop::annotateOutputFiles(const string& dirname) {
|
||||
// Create if uncreated, ignore errors
|
||||
V3Os::createDir(dirname);
|
||||
for (VlcSources::NameMap::iterator sit=m_sources.begin(); sit!=m_sources.end(); ++sit) {
|
||||
for (VlcSources::NameMap::iterator sit = m_sources.begin(); sit != m_sources.end(); ++sit) {
|
||||
VlcSource& source = sit->second;
|
||||
if (!source.needed()) continue;
|
||||
string filename = source.name();
|
||||
string outfilename = dirname+"/"+V3Os::filenameNonDir(filename);
|
||||
string outfilename = dirname + "/" + V3Os::filenameNonDir(filename);
|
||||
|
||||
UINFO(1,"annotateOutputFile "<<filename<<" -> "<<outfilename<<endl);
|
||||
UINFO(1, "annotateOutputFile " << filename << " -> " << outfilename << endl);
|
||||
|
||||
std::ifstream is(filename.c_str());
|
||||
if (!is) {
|
||||
v3error("Can't read "<<filename);
|
||||
v3error("Can't read " << filename);
|
||||
return;
|
||||
}
|
||||
|
||||
std::ofstream os(outfilename.c_str());
|
||||
if (!os) {
|
||||
v3fatal("Can't write "<<outfilename);
|
||||
v3fatal("Can't write " << outfilename);
|
||||
return;
|
||||
}
|
||||
|
||||
os << "\t// verilator_coverage annotation"<<endl;
|
||||
os << "\t// verilator_coverage annotation" << endl;
|
||||
|
||||
int lineno = 0;
|
||||
while (!is.eof()) {
|
||||
|
|
@ -221,22 +220,21 @@ void VlcTop::annotateOutputFiles(const string& dirname) {
|
|||
bool first = true;
|
||||
|
||||
VlcSource::LinenoMap& lines = source.lines();
|
||||
VlcSource::LinenoMap::iterator lit=lines.find(lineno);
|
||||
VlcSource::LinenoMap::iterator lit = lines.find(lineno);
|
||||
if (lit != lines.end()) {
|
||||
VlcSource::ColumnMap& cmap = lit->second;
|
||||
for (VlcSource::ColumnMap::iterator cit = cmap.begin(); cit != cmap.end();
|
||||
++cit) {
|
||||
for (VlcSource::ColumnMap::iterator cit = cmap.begin(); cit != cmap.end(); ++cit) {
|
||||
VlcSourceCount& col = cit->second;
|
||||
//UINFO(0,"Source "<<source.name()<<":"<<col.lineno()<<":"<<col.column()<<endl);
|
||||
os<<(col.ok()?" ":"%")
|
||||
<<std::setfill('0')<<std::setw(6)<<col.count()
|
||||
<<"\t"<<line<<endl;
|
||||
// UINFO(0,"Source
|
||||
// "<<source.name()<<":"<<col.lineno()<<":"<<col.column()<<endl);
|
||||
os << (col.ok() ? " " : "%") << std::setfill('0') << std::setw(6)
|
||||
<< col.count() << "\t" << line << endl;
|
||||
if (first) {
|
||||
first = false;
|
||||
// Multiple columns on same line; print line just once
|
||||
string indent;
|
||||
for (string::const_iterator pos=line.begin();
|
||||
pos!=line.end() && isspace(*pos); ++pos) {
|
||||
for (string::const_iterator pos = line.begin();
|
||||
pos != line.end() && isspace(*pos); ++pos) {
|
||||
indent += *pos;
|
||||
}
|
||||
line = indent + "verilator_coverage: (next point on previous line)\n";
|
||||
|
|
@ -244,9 +242,7 @@ void VlcTop::annotateOutputFiles(const string& dirname) {
|
|||
}
|
||||
}
|
||||
|
||||
if (first) {
|
||||
os<<"\t"<<line<<endl;
|
||||
}
|
||||
if (first) os << "\t" << line << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue