Internals: clang-format files needed for #2249.
This commit is contained in:
parent
08b74e5ab9
commit
1b94e3b0e2
|
|
@ -16,33 +16,9 @@ clang-format -i examples/make_hello_sc/sc_main.cpp
|
|||
#clang-format -i examples/make_protect_lib/sim_main.cpp
|
||||
clang-format -i examples/make_tracing_c/sim_main.cpp
|
||||
clang-format -i examples/make_tracing_sc/sc_main.cpp
|
||||
clang-format -i include/verilated.cpp
|
||||
clang-format -i include/verilated.h
|
||||
clang-format -i include/*.cpp
|
||||
clang-format -i include/*.h
|
||||
clang-format -i include/verilated_config.h.in
|
||||
clang-format -i include/verilated_cov.cpp
|
||||
clang-format -i include/verilated_cov.h
|
||||
clang-format -i include/verilated_cov_key.h
|
||||
clang-format -i include/verilated_dpi.cpp
|
||||
clang-format -i include/verilated_dpi.h
|
||||
clang-format -i include/verilated_fst_c.cpp
|
||||
clang-format -i include/verilated_fst_c.h
|
||||
clang-format -i include/verilated_heavy.h
|
||||
clang-format -i include/verilated_imp.h
|
||||
clang-format -i include/verilated_save.cpp
|
||||
clang-format -i include/verilated_save.h
|
||||
clang-format -i include/verilated_sc.h
|
||||
clang-format -i include/verilated_sym_props.h
|
||||
clang-format -i include/verilated_syms.h
|
||||
clang-format -i include/verilated_threads.cpp
|
||||
clang-format -i include/verilated_threads.h
|
||||
clang-format -i include/verilated_unordered_set_map.h
|
||||
clang-format -i include/verilated_vcd_c.cpp
|
||||
clang-format -i include/verilated_vcd_c.h
|
||||
clang-format -i include/verilated_vcd_sc.cpp
|
||||
clang-format -i include/verilated_vcd_sc.h
|
||||
clang-format -i include/verilated_vpi.cpp
|
||||
clang-format -i include/verilated_vpi.h
|
||||
clang-format -i include/verilatedos.h
|
||||
clang-format -i nodist/fuzzer/wrapper.cpp
|
||||
clang-format -i src/V3Active.cpp
|
||||
clang-format -i src/V3Active.h
|
||||
|
|
@ -107,7 +83,7 @@ clang-format -i src/V3EmitC.h
|
|||
clang-format -i src/V3EmitCInlines.cpp
|
||||
##clang-format -i src/V3EmitCMake.cpp
|
||||
clang-format -i src/V3EmitCMake.h
|
||||
##clang-format -i src/V3EmitCSyms.cpp
|
||||
clang-format -i src/V3EmitCSyms.cpp
|
||||
##clang-format -i src/V3EmitMk.cpp
|
||||
clang-format -i src/V3EmitMk.h
|
||||
##clang-format -i src/V3EmitV.cpp
|
||||
|
|
@ -175,12 +151,12 @@ clang-format -i src/V3Name.h
|
|||
##clang-format -i src/V3Number.cpp
|
||||
##clang-format -i src/V3Number.h
|
||||
clang-format -i src/V3Number_test.cpp
|
||||
##clang-format -i src/V3Options.cpp
|
||||
##clang-format -i src/V3Options.h
|
||||
clang-format -i src/V3Options.cpp
|
||||
clang-format -i src/V3Options.h
|
||||
##clang-format -i src/V3Order.cpp
|
||||
clang-format -i src/V3Order.h
|
||||
clang-format -i src/V3OrderGraph.h
|
||||
##clang-format -i src/V3Os.cpp
|
||||
clang-format -i src/V3Os.cpp
|
||||
clang-format -i src/V3Os.h
|
||||
##clang-format -i src/V3Param.cpp
|
||||
clang-format -i src/V3Param.h
|
||||
|
|
@ -248,7 +224,7 @@ clang-format -i src/V3Unroll.h
|
|||
clang-format -i src/V3Width.h
|
||||
clang-format -i src/V3WidthCommit.h
|
||||
##clang-format -i src/V3WidthSel.cpp
|
||||
##clang-format -i src/Verilator.cpp
|
||||
clang-format -i src/Verilator.cpp
|
||||
clang-format -i src/VlcBucket.h
|
||||
clang-format -i src/VlcMain.cpp
|
||||
clang-format -i src/VlcOptions.h
|
||||
|
|
|
|||
|
|
@ -39,20 +39,37 @@ class EmitCSyms : EmitCBaseVisitor {
|
|||
AstUser1InUse m_inuser1;
|
||||
|
||||
// TYPES
|
||||
struct ScopeData { string m_symName; string m_prettyName; string m_type;
|
||||
struct ScopeData {
|
||||
string m_symName;
|
||||
string m_prettyName;
|
||||
string m_type;
|
||||
ScopeData(const string& symName, const string& prettyName, const string& type)
|
||||
: m_symName(symName), m_prettyName(prettyName), m_type(type) {}
|
||||
: m_symName(symName)
|
||||
, m_prettyName(prettyName)
|
||||
, m_type(type) {}
|
||||
};
|
||||
struct ScopeFuncData { AstScopeName* m_scopep; AstCFunc* m_funcp; AstNodeModule* m_modp;
|
||||
struct ScopeFuncData {
|
||||
AstScopeName* m_scopep;
|
||||
AstCFunc* m_funcp;
|
||||
AstNodeModule* m_modp;
|
||||
ScopeFuncData(AstScopeName* scopep, AstCFunc* funcp, AstNodeModule* modp)
|
||||
: m_scopep(scopep), m_funcp(funcp), m_modp(modp) {}
|
||||
: m_scopep(scopep)
|
||||
, m_funcp(funcp)
|
||||
, m_modp(modp) {}
|
||||
};
|
||||
struct ScopeVarData { string m_scopeName; string m_varBasePretty; AstVar* m_varp;
|
||||
AstNodeModule* m_modp; AstScope* m_scopep;
|
||||
ScopeVarData(const string& scopeName, const string& varBasePretty,
|
||||
AstVar* varp, AstNodeModule* modp, AstScope* scopep)
|
||||
: m_scopeName(scopeName), m_varBasePretty(varBasePretty)
|
||||
, m_varp(varp), m_modp(modp), m_scopep(scopep) {}
|
||||
struct ScopeVarData {
|
||||
string m_scopeName;
|
||||
string m_varBasePretty;
|
||||
AstVar* m_varp;
|
||||
AstNodeModule* m_modp;
|
||||
AstScope* m_scopep;
|
||||
ScopeVarData(const string& scopeName, const string& varBasePretty, AstVar* varp,
|
||||
AstNodeModule* modp, AstScope* scopep)
|
||||
: m_scopeName(scopeName)
|
||||
, m_varBasePretty(varBasePretty)
|
||||
, m_varp(varp)
|
||||
, m_modp(modp)
|
||||
, m_scopep(scopep) {}
|
||||
};
|
||||
typedef std::map<string, ScopeFuncData> ScopeFuncs;
|
||||
typedef std::map<string, ScopeVarData> ScopeVars;
|
||||
|
|
@ -115,8 +132,10 @@ class EmitCSyms : EmitCBaseVisitor {
|
|||
// Generally V3Name should find all of these and throw SYMRSVDWORD.
|
||||
// We'll still check here because the compiler errors
|
||||
// resulting if we miss this warning are SO nasty
|
||||
nodep->v3error("Symbol matching "+rsvd+" reserved word reached emitter,"
|
||||
" should have hit SYMRSVDWORD: "<<nodep->prettyNameQ());
|
||||
nodep->v3error("Symbol matching " + rsvd
|
||||
+ " reserved word reached emitter,"
|
||||
" should have hit SYMRSVDWORD: "
|
||||
<< nodep->prettyNameQ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -124,17 +143,11 @@ class EmitCSyms : EmitCBaseVisitor {
|
|||
string scopeSymString(const string& scpname) {
|
||||
string out = scpname;
|
||||
string::size_type pos;
|
||||
while ((pos = out.find("__PVT__")) != string::npos) {
|
||||
out.replace(pos, 7, "");
|
||||
}
|
||||
while ((pos = out.find("__PVT__")) != string::npos) out.replace(pos, 7, "");
|
||||
if (out.substr(0, 10) == "TOP__DOT__") out.replace(0, 10, "");
|
||||
if (out.substr(0, 4) == "TOP.") out.replace(0, 4, "");
|
||||
while ((pos = out.find('.')) != string::npos) {
|
||||
out.replace(pos, 1, "__");
|
||||
}
|
||||
while ((pos = out.find("__DOT__")) != string::npos) {
|
||||
out.replace(pos, 7, "__");
|
||||
}
|
||||
while ((pos = out.find('.')) != string::npos) out.replace(pos, 1, "__");
|
||||
while ((pos = out.find("__DOT__")) != string::npos) out.replace(pos, 7, "__");
|
||||
return out;
|
||||
}
|
||||
|
||||
|
|
@ -174,11 +187,12 @@ class EmitCSyms : EmitCBaseVisitor {
|
|||
// We didn't have all m_scopes loaded when we encountered variables, so expand them now
|
||||
// It would be less code if each module inserted its own variables.
|
||||
// Someday. For now public isn't common.
|
||||
for (std::vector<ScopeModPair>::iterator itsc = m_scopes.begin();
|
||||
itsc != m_scopes.end(); ++itsc) {
|
||||
AstScope* scopep = itsc->first; AstNodeModule* smodp = itsc->second;
|
||||
for (std::vector<ModVarPair>::iterator it = m_modVars.begin();
|
||||
it != m_modVars.end(); ++it) {
|
||||
for (std::vector<ScopeModPair>::iterator itsc = m_scopes.begin(); itsc != m_scopes.end();
|
||||
++itsc) {
|
||||
AstScope* scopep = itsc->first;
|
||||
AstNodeModule* smodp = itsc->second;
|
||||
for (std::vector<ModVarPair>::iterator it = m_modVars.begin(); it != m_modVars.end();
|
||||
++it) {
|
||||
AstNodeModule* modp = it->first;
|
||||
AstVar* varp = it->second;
|
||||
if (modp == smodp) {
|
||||
|
|
@ -197,17 +211,16 @@ class EmitCSyms : EmitCBaseVisitor {
|
|||
} else {
|
||||
varBase = whole;
|
||||
}
|
||||
//UINFO(9,"For "<<scopep->name()<<" - "<<varp->name()<<" Scp "<<scpName<<" Var "<<varBase<<endl);
|
||||
// UINFO(9,"For "<<scopep->name()<<" - "<<varp->name()<<" Scp "<<scpName<<"
|
||||
// Var "<<varBase<<endl);
|
||||
string varBasePretty = AstNode::prettyName(varBase);
|
||||
string scpPretty = AstNode::prettyName(scpName);
|
||||
string scpSym = scopeSymString(scpName);
|
||||
// UINFO(9," scnameins sp "<<scpName<<" sp "<<scpPretty<<" ss "<<scpSym<<endl);
|
||||
if (v3Global.opt.vpi()) {
|
||||
varHierarchyScopes(scpName);
|
||||
}
|
||||
if (v3Global.opt.vpi()) varHierarchyScopes(scpName);
|
||||
if (m_scopeNames.find(scpSym) == m_scopeNames.end()) {
|
||||
m_scopeNames.insert(make_pair(scpSym, ScopeData(scpSym, scpPretty,
|
||||
"SCOPE_OTHER")));
|
||||
m_scopeNames.insert(
|
||||
make_pair(scpSym, ScopeData(scpSym, scpPretty, "SCOPE_OTHER")));
|
||||
}
|
||||
m_scopeVars.insert(
|
||||
make_pair(scpSym + " " + varp->name(),
|
||||
|
|
@ -218,7 +231,8 @@ class EmitCSyms : EmitCBaseVisitor {
|
|||
}
|
||||
|
||||
void buildVpiHierarchy() {
|
||||
for (ScopeNames::const_iterator it = m_scopeNames.begin(); it != m_scopeNames.end(); ++it) {
|
||||
for (ScopeNames::const_iterator it = m_scopeNames.begin(); it != m_scopeNames.end();
|
||||
++it) {
|
||||
if (it->second.m_type != "SCOPE_MODULE") continue;
|
||||
|
||||
string name = it->second.m_prettyName;
|
||||
|
|
@ -244,9 +258,7 @@ class EmitCSyms : EmitCBaseVisitor {
|
|||
iterateChildren(nodep);
|
||||
varsExpand();
|
||||
|
||||
if (v3Global.opt.vpi()) {
|
||||
buildVpiHierarchy();
|
||||
}
|
||||
if (v3Global.opt.vpi()) buildVpiHierarchy();
|
||||
|
||||
// Sort by names, so line/process order matters less
|
||||
stable_sort(m_scopes.begin(), m_scopes.end(), CmpName());
|
||||
|
|
@ -274,12 +286,11 @@ class EmitCSyms : EmitCBaseVisitor {
|
|||
}
|
||||
virtual void visit(AstCellInline* nodep) VL_OVERRIDE {
|
||||
if (v3Global.opt.vpi()) {
|
||||
string type = (nodep->origModName() == "__BEGIN__") ? "SCOPE_OTHER"
|
||||
: "SCOPE_MODULE";
|
||||
string type = (nodep->origModName() == "__BEGIN__") ? "SCOPE_OTHER" : "SCOPE_MODULE";
|
||||
string name = nodep->scopep()->name() + "__DOT__" + nodep->name();
|
||||
string name_dedot = AstNode::dedotName(name);
|
||||
m_vpiScopeCandidates.insert(make_pair(name, ScopeData(scopeSymString(name),
|
||||
name_dedot, type)));
|
||||
m_vpiScopeCandidates.insert(
|
||||
make_pair(name, ScopeData(scopeSymString(name), name_dedot, type)));
|
||||
}
|
||||
}
|
||||
virtual void visit(AstScope* nodep) VL_OVERRIDE {
|
||||
|
|
@ -290,28 +301,28 @@ class EmitCSyms : EmitCBaseVisitor {
|
|||
|
||||
if (v3Global.opt.vpi() && !nodep->isTop()) {
|
||||
string name_dedot = AstNode::dedotName(nodep->shortName());
|
||||
m_vpiScopeCandidates.insert(make_pair(nodep->name(),
|
||||
ScopeData(scopeSymString(nodep->name()),
|
||||
name_dedot, "SCOPE_MODULE")));
|
||||
m_vpiScopeCandidates.insert(
|
||||
make_pair(nodep->name(),
|
||||
ScopeData(scopeSymString(nodep->name()), name_dedot, "SCOPE_MODULE")));
|
||||
}
|
||||
}
|
||||
virtual void visit(AstScopeName* nodep) VL_OVERRIDE {
|
||||
string name = nodep->scopeSymName();
|
||||
//UINFO(9,"scnameins sp "<<nodep->name()<<" sp "<<nodep->scopePrettySymName()<<" ss "<<name<<endl);
|
||||
// UINFO(9,"scnameins sp "<<nodep->name()<<" sp "<<nodep->scopePrettySymName()<<" ss
|
||||
// "<<name<<endl);
|
||||
if (m_scopeNames.find(name) == m_scopeNames.end()) {
|
||||
m_scopeNames.insert(make_pair(name, ScopeData(name, nodep->scopePrettySymName(),
|
||||
"SCOPE_OTHER")));
|
||||
m_scopeNames.insert(
|
||||
make_pair(name, ScopeData(name, nodep->scopePrettySymName(), "SCOPE_OTHER")));
|
||||
}
|
||||
if (nodep->dpiExport()) {
|
||||
UASSERT_OBJ(m_funcp, nodep, "ScopeName not under DPI function");
|
||||
m_scopeFuncs.insert(make_pair(name + " " + m_funcp->name(),
|
||||
ScopeFuncData(nodep, m_funcp, m_modp)));
|
||||
m_scopeFuncs.insert(
|
||||
make_pair(name + " " + m_funcp->name(), ScopeFuncData(nodep, m_funcp, m_modp)));
|
||||
} else {
|
||||
if (m_scopeNames.find(nodep->scopeDpiName()) == m_scopeNames.end()) {
|
||||
m_scopeNames.insert(make_pair(nodep->scopeDpiName(),
|
||||
ScopeData(nodep->scopeDpiName(),
|
||||
nodep->scopePrettyDpiName(),
|
||||
"SCOPE_OTHER")));
|
||||
m_scopeNames.insert(make_pair(
|
||||
nodep->scopeDpiName(),
|
||||
ScopeData(nodep->scopeDpiName(), nodep->scopePrettyDpiName(), "SCOPE_OTHER")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -319,7 +330,9 @@ class EmitCSyms : EmitCBaseVisitor {
|
|||
nameCheck(nodep);
|
||||
iterateChildren(nodep);
|
||||
if (nodep->isSigUserRdPublic()
|
||||
&& !nodep->isParam()) { // The VPI functions require a pointer to allow modification, but parameters are constants
|
||||
// The VPI functions require a pointer to allow modification,
|
||||
// but parameters are constants
|
||||
&& !nodep->isParam()) {
|
||||
m_modVars.push_back(make_pair(m_modp, nodep));
|
||||
}
|
||||
}
|
||||
|
|
@ -331,9 +344,7 @@ class EmitCSyms : EmitCBaseVisitor {
|
|||
}
|
||||
virtual void visit(AstCFunc* nodep) VL_OVERRIDE {
|
||||
nameCheck(nodep);
|
||||
if (nodep->dpiImport() || nodep->dpiExportWrapper()) {
|
||||
m_dpis.push_back(nodep);
|
||||
}
|
||||
if (nodep->dpiImport() || nodep->dpiExportWrapper()) m_dpis.push_back(nodep);
|
||||
m_funcp = nodep;
|
||||
iterateChildren(nodep);
|
||||
m_funcp = NULL;
|
||||
|
|
@ -368,7 +379,8 @@ void EmitCSyms::emitSymHdr() {
|
|||
}
|
||||
|
||||
ofp()->putsHeader();
|
||||
puts("// DESCR" "IPTION: Verilator output: Symbol table internal header\n");
|
||||
puts("// DESCR"
|
||||
"IPTION: Verilator output: Symbol table internal header\n");
|
||||
puts("//\n");
|
||||
puts("// Internal details; most calling programs do not need this header,\n");
|
||||
puts("// unless using verilator public meta comments.\n");
|
||||
|
|
@ -410,7 +422,9 @@ void EmitCSyms::emitSymHdr() {
|
|||
ofp()->putsPrivate(false); // public:
|
||||
|
||||
puts("\n// LOCAL STATE\n");
|
||||
puts("const char* __Vm_namep;\n"); // Must be before subcells, as constructor order needed before _vlCoverInsert.
|
||||
// Must be before subcells, as constructor order needed before _vlCoverInsert.
|
||||
puts("const char* __Vm_namep;\n");
|
||||
|
||||
if (v3Global.needTraceDumper()) {
|
||||
// __Vm_dumperp is local, otherwise we wouldn't know what design's eval()
|
||||
// should call a global dumpperp
|
||||
|
|
@ -462,8 +476,7 @@ void EmitCSyms::emitSymHdr() {
|
|||
puts(symClassName() + "(" + topClassName() + "* topp, const char* namep);\n");
|
||||
puts(string("~") + symClassName() + "() {}\n");
|
||||
|
||||
for (std::map<int,bool>::iterator it = m_usesVfinal.begin();
|
||||
it != m_usesVfinal.end(); ++it) {
|
||||
for (std::map<int, bool>::iterator it = m_usesVfinal.begin(); it != m_usesVfinal.end(); ++it) {
|
||||
puts("void " + symClassName() + "_" + cvtToStr(it->first) + "(");
|
||||
if (it->second) {
|
||||
puts("int __Vfinal");
|
||||
|
|
@ -476,7 +489,8 @@ void EmitCSyms::emitSymHdr() {
|
|||
puts("\n// METHODS\n");
|
||||
puts("inline const char* name() { return __Vm_namep; }\n");
|
||||
if (v3Global.opt.trace()) {
|
||||
puts("inline bool getClearActivity() { bool r=__Vm_activity; __Vm_activity=false; return r; }\n");
|
||||
puts("inline bool getClearActivity() { bool r=__Vm_activity; "
|
||||
"__Vm_activity=false; return r; }\n");
|
||||
}
|
||||
if (v3Global.opt.savable()) {
|
||||
puts("void " + protect("__Vserialize") + "(VerilatedSerialize& os);\n");
|
||||
|
|
@ -497,11 +511,14 @@ void EmitCSyms::closeSplit() {
|
|||
}
|
||||
|
||||
void EmitCSyms::checkSplit(bool usesVfinal) {
|
||||
if (m_ofp && (!v3Global.opt.outputSplitCFuncs() ||
|
||||
m_numStmts < v3Global.opt.outputSplitCFuncs())) return;
|
||||
if (m_ofp
|
||||
&& (!v3Global.opt.outputSplitCFuncs() || m_numStmts < v3Global.opt.outputSplitCFuncs())) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_numStmts = 0;
|
||||
string filename = v3Global.opt.makeDir()+"/"+symClassName()+"__"+cvtToStr(++m_funcNum)+".cpp";
|
||||
string filename
|
||||
= v3Global.opt.makeDir() + "/" + symClassName() + "__" + cvtToStr(++m_funcNum) + ".cpp";
|
||||
AstCFile* cfilep = newCFile(filename, true /*slow*/, true /*source*/);
|
||||
cfilep->support(true);
|
||||
m_usesVfinal[m_funcNum] = usesVfinal;
|
||||
|
|
@ -533,7 +550,8 @@ void EmitCSyms::checkSplit(bool usesVfinal) {
|
|||
|
||||
void EmitCSyms::emitSymImpPreamble() {
|
||||
ofp()->putsHeader();
|
||||
puts("// DESCR" "IPTION: Verilator output: Symbol table implementation internals\n");
|
||||
puts("// DESCR"
|
||||
"IPTION: Verilator output: Symbol table implementation internals\n");
|
||||
puts("\n");
|
||||
|
||||
// Includes
|
||||
|
|
@ -571,20 +589,20 @@ void EmitCSyms::emitSymImp() {
|
|||
string funcname = de ? "__Vdeserialize" : "__Vserialize";
|
||||
string op = de ? ">>" : "<<";
|
||||
// NOLINTNEXTLINE(performance-inefficient-string-concatenation)
|
||||
puts("void "+symClassName()+"::"+protect(funcname)+"("+classname+"& os) {\n");
|
||||
puts("void " + symClassName() + "::" + protect(funcname) + "(" + classname
|
||||
+ "& os) {\n");
|
||||
puts("// LOCAL STATE\n");
|
||||
// __Vm_namep presumably already correct
|
||||
if (v3Global.opt.trace()) {
|
||||
puts( "os"+op+"__Vm_activity;\n");
|
||||
}
|
||||
if (v3Global.opt.trace()) { puts("os" + op + "__Vm_activity;\n"); }
|
||||
puts("os" + op + "__Vm_didInit;\n");
|
||||
puts("// SUBCELL STATE\n");
|
||||
for (std::vector<ScopeModPair>::iterator it = m_scopes.begin();
|
||||
it != m_scopes.end(); ++it) {
|
||||
AstScope* scopep = it->first; AstNodeModule* modp = it->second;
|
||||
for (std::vector<ScopeModPair>::iterator it = m_scopes.begin(); it != m_scopes.end();
|
||||
++it) {
|
||||
AstScope* scopep = it->first;
|
||||
AstNodeModule* modp = it->second;
|
||||
if (!modp->isTop()) {
|
||||
puts(protectIf(scopep->nameDotless(), scopep->protect())
|
||||
+"."+protect(funcname)+"(os);\n");
|
||||
puts(protectIf(scopep->nameDotless(), scopep->protect()) + "."
|
||||
+ protect(funcname) + "(os);\n");
|
||||
}
|
||||
}
|
||||
puts("}\n");
|
||||
|
|
@ -594,7 +612,8 @@ void EmitCSyms::emitSymImp() {
|
|||
puts("\n");
|
||||
|
||||
puts("\n// FUNCTIONS\n");
|
||||
puts(symClassName()+"::"+symClassName()+"("+topClassName()+"* topp, const char* namep)\n");
|
||||
puts(symClassName() + "::" + symClassName() + "(" + topClassName()
|
||||
+ "* topp, const char* namep)\n");
|
||||
puts(" // Setup locals\n");
|
||||
puts(" : __Vm_namep(namep)\n"); // No leak, as gets destroyed when the top is destroyed
|
||||
if (v3Global.needTraceDumper()) {
|
||||
|
|
@ -631,9 +650,7 @@ void EmitCSyms::emitSymImp() {
|
|||
checkSplit(false);
|
||||
string arrow = scopep->name();
|
||||
string::size_type pos;
|
||||
while ((pos = arrow.find('.')) != string::npos) {
|
||||
arrow.replace(pos, 1, "->");
|
||||
}
|
||||
while ((pos = arrow.find('.')) != string::npos) arrow.replace(pos, 1, "->");
|
||||
if (arrow.substr(0, 5) == "TOP->") arrow.replace(0, 5, "TOPp->");
|
||||
ofp()->puts(protectWordsIf(arrow, scopep->protect()));
|
||||
puts(" = &");
|
||||
|
|
@ -652,10 +669,8 @@ void EmitCSyms::emitSymImp() {
|
|||
// first is used by AstCoverDecl's call to __vlCoverInsert
|
||||
bool first = !modp->user1();
|
||||
modp->user1(true);
|
||||
puts(protectIf(scopep->nameDotless(), scopep->protect())
|
||||
+"."+protect("__Vconfigure")+"(this, "
|
||||
+(first?"true":"false")
|
||||
+");\n");
|
||||
puts(protectIf(scopep->nameDotless(), scopep->protect()) + "."
|
||||
+ protect("__Vconfigure") + "(this, " + (first ? "true" : "false") + ");\n");
|
||||
++m_numStmts;
|
||||
}
|
||||
}
|
||||
|
|
@ -664,8 +679,7 @@ void EmitCSyms::emitSymImp() {
|
|||
puts("// Setup scopes\n");
|
||||
for (ScopeNames::iterator it = m_scopeNames.begin(); it != m_scopeNames.end(); ++it) {
|
||||
checkSplit(false);
|
||||
puts(protect("__Vscope_"+it->second.m_symName)
|
||||
+".configure(this, name(), ");
|
||||
puts(protect("__Vscope_" + it->second.m_symName) + ".configure(this, name(), ");
|
||||
putsQuoted(protectWordsIf(it->second.m_prettyName, true));
|
||||
puts(", ");
|
||||
putsQuoted(protect(scopeDecodeIdentifier(it->second.m_prettyName)));
|
||||
|
|
@ -676,8 +690,8 @@ void EmitCSyms::emitSymImp() {
|
|||
|
||||
if (v3Global.opt.vpi()) {
|
||||
puts("\n// Setup scope hierarchy\n");
|
||||
for (ScopeNames::const_iterator it = m_scopeNames.begin();
|
||||
it != m_scopeNames.end(); ++it) {
|
||||
for (ScopeNames::const_iterator it = m_scopeNames.begin(); it != m_scopeNames.end();
|
||||
++it) {
|
||||
string name = it->second.m_prettyName;
|
||||
if (it->first == "TOP") continue;
|
||||
name = name.replace(0, 4, ""); // Remove the "TOP."
|
||||
|
|
@ -688,8 +702,8 @@ void EmitCSyms::emitSymImp() {
|
|||
|
||||
for (ScopeNameHierarchy::const_iterator it = m_vpiScopeHierarchy.begin();
|
||||
it != m_vpiScopeHierarchy.end(); ++it) {
|
||||
for (ScopeNameList::const_iterator lit = it->second.begin();
|
||||
lit != it->second.end(); ++lit) {
|
||||
for (ScopeNameList::const_iterator lit = it->second.begin(); lit != it->second.end();
|
||||
++lit) {
|
||||
string fromname = scopeSymString(it->first);
|
||||
string toname = scopeSymString(*lit);
|
||||
ScopeNames::const_iterator from = m_scopeNames.find(fromname);
|
||||
|
|
@ -740,19 +754,29 @@ void EmitCSyms::emitSymImp() {
|
|||
if (AstBasicDType* basicp = varp->basicp()) {
|
||||
// Range is always first, it's not in "C" order
|
||||
if (basicp->isRanged()) {
|
||||
bounds += " ,"; bounds += cvtToStr(basicp->msb());
|
||||
bounds += ","; bounds += cvtToStr(basicp->lsb());
|
||||
bounds += " ,";
|
||||
bounds += cvtToStr(basicp->msb());
|
||||
bounds += ",";
|
||||
bounds += cvtToStr(basicp->lsb());
|
||||
pdim++;
|
||||
}
|
||||
for (AstNodeDType* dtypep = varp->dtypep(); dtypep;) {
|
||||
dtypep = dtypep->skipRefp(); // Skip AstRefDType/AstTypedef, or return same node
|
||||
dtypep
|
||||
= dtypep->skipRefp(); // Skip AstRefDType/AstTypedef, or return same node
|
||||
if (const AstNodeArrayDType* adtypep = VN_CAST(dtypep, NodeArrayDType)) {
|
||||
bounds += " ,"; bounds += cvtToStr(adtypep->msb());
|
||||
bounds += ","; bounds += cvtToStr(adtypep->lsb());
|
||||
if (VN_IS(dtypep, PackArrayDType)) pdim++; else udim++;
|
||||
dtypep = adtypep->subDTypep();
|
||||
bounds += " ,";
|
||||
bounds += cvtToStr(adtypep->msb());
|
||||
bounds += ",";
|
||||
bounds += cvtToStr(adtypep->lsb());
|
||||
if (VN_IS(dtypep, PackArrayDType)) {
|
||||
pdim++;
|
||||
} else {
|
||||
udim++;
|
||||
}
|
||||
dtypep = adtypep->subDTypep();
|
||||
} else {
|
||||
break; // AstBasicDType - nothing below, 1
|
||||
}
|
||||
else break; // AstBasicDType - nothing below, 1
|
||||
}
|
||||
}
|
||||
//
|
||||
|
|
@ -799,7 +823,8 @@ void EmitCSyms::emitDpiHdr() {
|
|||
m_ofp = &hf;
|
||||
|
||||
m_ofp->putsHeader();
|
||||
puts("// DESCR" "IPTION: Verilator output: Prototypes for DPI import and export functions.\n");
|
||||
puts("// DESCR"
|
||||
"IPTION: Verilator output: Prototypes for DPI import and export functions.\n");
|
||||
puts("//\n");
|
||||
puts("// Verilator includes this file in all generated .cpp files that use DPI functions.\n");
|
||||
puts("// Manually include this file where DPI .c import functions are declared to ensure\n");
|
||||
|
|
@ -819,14 +844,13 @@ void EmitCSyms::emitDpiHdr() {
|
|||
if (nodep->dpiExportWrapper()) {
|
||||
if (!firstExp++) puts("\n// DPI EXPORTS\n");
|
||||
puts("// DPI export" + ifNoProtect(" at " + nodep->fileline()->ascii()) + "\n");
|
||||
puts("extern "+nodep->rtnTypeVoid()+" "+nodep->nameProtect()
|
||||
+"("+cFuncArgs(nodep)+");\n");
|
||||
}
|
||||
else if (nodep->dpiImport()) {
|
||||
puts("extern " + nodep->rtnTypeVoid() + " " + nodep->nameProtect() + "("
|
||||
+ cFuncArgs(nodep) + ");\n");
|
||||
} else if (nodep->dpiImport()) {
|
||||
if (!firstImp++) puts("\n// DPI IMPORTS\n");
|
||||
puts("// DPI import" + ifNoProtect(" at " + nodep->fileline()->ascii()) + "\n");
|
||||
puts("extern "+nodep->rtnTypeVoid()+" "+nodep->nameProtect()
|
||||
+"("+cFuncArgs(nodep)+");\n");
|
||||
puts("extern " + nodep->rtnTypeVoid() + " " + nodep->nameProtect() + "("
|
||||
+ cFuncArgs(nodep) + ");\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -847,7 +871,8 @@ void EmitCSyms::emitDpiImp() {
|
|||
m_ofp = &hf;
|
||||
|
||||
m_ofp->putsHeader();
|
||||
puts("// DESCR" "IPTION: Verilator output: Implementation of DPI export functions.\n");
|
||||
puts("// DESCR"
|
||||
"IPTION: Verilator output: Implementation of DPI export functions.\n");
|
||||
puts("//\n");
|
||||
puts("// Verilator compiles this file in when DPI functions are used.\n");
|
||||
puts("// If you have multiple Verilated designs with the same DPI exported\n");
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
#include "V3File.h"
|
||||
#include "V3PreShell.h"
|
||||
|
||||
// clang-format off
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#ifndef _WIN32
|
||||
|
|
@ -43,6 +44,7 @@
|
|||
#if defined(_WIN32) || defined(__MINGW32__)
|
||||
# include <io.h> // open, close
|
||||
#endif
|
||||
// clang-format on
|
||||
|
||||
//######################################################################
|
||||
// V3 Internal state
|
||||
|
|
@ -74,7 +76,8 @@ public:
|
|||
}
|
||||
}
|
||||
void addIncDirFallback(const string& incdir) {
|
||||
if (m_incDirUserSet.find(incdir) == m_incDirUserSet.end()) { // User has priority over Fallback
|
||||
if (m_incDirUserSet.find(incdir)
|
||||
== m_incDirUserSet.end()) { // User has priority over Fallback
|
||||
if (m_incDirFallbackSet.find(incdir) == m_incDirFallbackSet.end()) {
|
||||
// cppcheck-suppress stlFindInsert // cppcheck 1.90 bug
|
||||
m_incDirFallbackSet.insert(incdir);
|
||||
|
|
@ -117,18 +120,12 @@ V3LangCode::V3LangCode(const char* textp) {
|
|||
//######################################################################
|
||||
// V3Options class functions
|
||||
|
||||
void V3Options::addIncDirUser(const string& incdir) {
|
||||
m_impp->addIncDirUser(incdir);
|
||||
}
|
||||
void V3Options::addIncDirFallback(const string& incdir) {
|
||||
m_impp->addIncDirFallback(incdir);
|
||||
}
|
||||
void V3Options::addIncDirUser(const string& incdir) { m_impp->addIncDirUser(incdir); }
|
||||
void V3Options::addIncDirFallback(const string& incdir) { m_impp->addIncDirFallback(incdir); }
|
||||
void V3Options::addLangExt(const string& langext, const V3LangCode& lc) {
|
||||
m_impp->addLangExt(langext, lc);
|
||||
}
|
||||
void V3Options::addLibExtV(const string& libext) {
|
||||
m_impp->addLibExtV(libext);
|
||||
}
|
||||
void V3Options::addLibExtV(const string& libext) { m_impp->addLibExtV(libext); }
|
||||
void V3Options::addDefine(const string& defline, bool allowPlus) {
|
||||
// Split +define+foo=value into the appropriate parts and parse
|
||||
// Optional + says to allow multiple defines on the line
|
||||
|
|
@ -198,51 +195,33 @@ void V3Options::checkParameters() {
|
|||
}
|
||||
}
|
||||
|
||||
void V3Options::addCppFile(const string& filename) {
|
||||
m_cppFiles.insert(filename);
|
||||
}
|
||||
void V3Options::addCFlags(const string& filename) {
|
||||
m_cFlags.push_back(filename);
|
||||
}
|
||||
void V3Options::addLdLibs(const string& filename) {
|
||||
m_ldLibs.push_back(filename);
|
||||
}
|
||||
void V3Options::addFuture(const string& flag) {
|
||||
m_futures.insert(flag);
|
||||
}
|
||||
void V3Options::addCppFile(const string& filename) { m_cppFiles.insert(filename); }
|
||||
void V3Options::addCFlags(const string& filename) { m_cFlags.push_back(filename); }
|
||||
void V3Options::addLdLibs(const string& filename) { m_ldLibs.push_back(filename); }
|
||||
void V3Options::addFuture(const string& flag) { m_futures.insert(flag); }
|
||||
bool V3Options::isFuture(const string& flag) const {
|
||||
return m_futures.find(flag) != m_futures.end();
|
||||
}
|
||||
bool V3Options::isLibraryFile(const string& filename) const {
|
||||
return m_libraryFiles.find(filename) != m_libraryFiles.end();
|
||||
}
|
||||
void V3Options::addLibraryFile(const string& filename) {
|
||||
m_libraryFiles.insert(filename);
|
||||
}
|
||||
void V3Options::addLibraryFile(const string& filename) { m_libraryFiles.insert(filename); }
|
||||
bool V3Options::isClocker(const string& signame) const {
|
||||
return m_clockers.find(signame) != m_clockers.end();
|
||||
}
|
||||
void V3Options::addClocker(const string& signame) {
|
||||
m_clockers.insert(signame);
|
||||
}
|
||||
void V3Options::addClocker(const string& signame) { m_clockers.insert(signame); }
|
||||
bool V3Options::isNoClocker(const string& signame) const {
|
||||
return m_noClockers.find(signame) != m_noClockers.end();
|
||||
}
|
||||
void V3Options::addNoClocker(const string& signame) {
|
||||
m_noClockers.insert(signame);
|
||||
}
|
||||
void V3Options::addNoClocker(const string& signame) { m_noClockers.insert(signame); }
|
||||
void V3Options::addVFile(const string& filename) {
|
||||
// We use a list for v files, because it's legal to have includes
|
||||
// in a specific order and multiple of them.
|
||||
m_vFiles.push_back(filename);
|
||||
}
|
||||
void V3Options::addForceInc(const string& filename) {
|
||||
m_forceIncs.push_back(filename);
|
||||
}
|
||||
void V3Options::addForceInc(const string& filename) { m_forceIncs.push_back(filename); }
|
||||
|
||||
void V3Options::addArg(const string& arg) {
|
||||
m_impp->m_allArgs.push_back(arg);
|
||||
}
|
||||
void V3Options::addArg(const string& arg) { m_impp->m_allArgs.push_back(arg); }
|
||||
|
||||
string V3Options::allArgsString() {
|
||||
string out;
|
||||
|
|
@ -303,10 +282,7 @@ string V3Options::fileExists(const string& filename) {
|
|||
std::set<string>* setp = &(diriter->second);
|
||||
|
||||
if (DIR* dirp = opendir(dir.c_str())) {
|
||||
while (struct dirent* direntp = readdir(dirp)) {
|
||||
|
||||
setp->insert(direntp->d_name);
|
||||
}
|
||||
while (struct dirent* direntp = readdir(dirp)) setp->insert(direntp->d_name);
|
||||
closedir(dirp);
|
||||
}
|
||||
}
|
||||
|
|
@ -375,7 +351,8 @@ void V3Options::filePathLookedMsg(FileLine* fl, const string& modname) {
|
|||
} else if (!shown_notfound_msg) {
|
||||
shown_notfound_msg = true;
|
||||
if (m_impp->m_incDirUsers.empty()) {
|
||||
fl->v3error("This may be because there's no search path specified with -I<dir>."<<endl);
|
||||
fl->v3error("This may be because there's no search path specified with -I<dir>."
|
||||
<< endl);
|
||||
}
|
||||
std::cerr << V3Error::warnMore() << "... Looked in:" << endl;
|
||||
for (std::list<string>::iterator dirIter = m_impp->m_incDirUsers.begin();
|
||||
|
|
@ -407,30 +384,33 @@ V3LangCode V3Options::fileLanguage(const string &filename) {
|
|||
if ((pos = ext.rfind('.')) != string::npos) {
|
||||
ext.erase(0, pos + 1);
|
||||
std::map<string, V3LangCode>::iterator it = m_impp->m_langExts.find(ext);
|
||||
if (it != m_impp->m_langExts.end()) {
|
||||
return it->second;
|
||||
}
|
||||
if (it != m_impp->m_langExts.end()) return it->second;
|
||||
}
|
||||
return m_defaultLanguage;
|
||||
}
|
||||
|
||||
|
||||
//######################################################################
|
||||
// Environment
|
||||
|
||||
string V3Options::getenvBuiltins(const string& var) {
|
||||
if (var == "PERL") return getenvPERL();
|
||||
else if (var == "SYSTEMC") return getenvSYSTEMC();
|
||||
else if (var == "SYSTEMC_ARCH") return getenvSYSTEMC_ARCH();
|
||||
else if (var == "SYSTEMC_INCLUDE") return getenvSYSTEMC_INCLUDE();
|
||||
else if (var == "SYSTEMC_LIBDIR") return getenvSYSTEMC_LIBDIR();
|
||||
else if (var == "VERILATOR_ROOT") return getenvVERILATOR_ROOT();
|
||||
else {
|
||||
if (var == "PERL") {
|
||||
return getenvPERL();
|
||||
} else if (var == "SYSTEMC") {
|
||||
return getenvSYSTEMC();
|
||||
} else if (var == "SYSTEMC_ARCH") {
|
||||
return getenvSYSTEMC_ARCH();
|
||||
} else if (var == "SYSTEMC_INCLUDE") {
|
||||
return getenvSYSTEMC_INCLUDE();
|
||||
} else if (var == "SYSTEMC_LIBDIR") {
|
||||
return getenvSYSTEMC_LIBDIR();
|
||||
} else if (var == "VERILATOR_ROOT") {
|
||||
return getenvVERILATOR_ROOT();
|
||||
} else {
|
||||
return V3Os::getenvStr(var, "");
|
||||
}
|
||||
}
|
||||
|
||||
string V3Options::getenvPERL() {
|
||||
string V3Options::getenvPERL() { //
|
||||
return V3Os::getenvStr("PERL", "perl");
|
||||
}
|
||||
|
||||
|
|
@ -462,9 +442,13 @@ string V3Options::getenvSYSTEMC_ARCH() {
|
|||
struct utsname uts;
|
||||
uname(&uts);
|
||||
string sysname = VString::downcase(uts.sysname); // aka 'uname -s'
|
||||
if (VString::wildmatch(sysname.c_str(), "*solaris*")) { var = "gccsparcOS5"; }
|
||||
else if (VString::wildmatch(sysname.c_str(), "*cygwin*")) { var = "cygwin"; }
|
||||
else { var = "linux"; }
|
||||
if (VString::wildmatch(sysname.c_str(), "*solaris*")) {
|
||||
var = "gccsparcOS5";
|
||||
} else if (VString::wildmatch(sysname.c_str(), "*cygwin*")) {
|
||||
var = "cygwin";
|
||||
} else {
|
||||
var = "linux";
|
||||
}
|
||||
#endif
|
||||
V3Os::setenvStr("SYSTEMC_ARCH", var, "From sysname '" + sysname + "'");
|
||||
}
|
||||
|
|
@ -518,9 +502,7 @@ string V3Options::getenvVERILATOR_ROOT() {
|
|||
var = DEFENV_VERILATOR_ROOT;
|
||||
V3Os::setenvStr("VERILATOR_ROOT", var, "Hardcoded at build time");
|
||||
}
|
||||
if (var == "") {
|
||||
v3fatal("$VERILATOR_ROOT needs to be in environment\n");
|
||||
}
|
||||
if (var == "") v3fatal("$VERILATOR_ROOT needs to be in environment\n");
|
||||
return var;
|
||||
}
|
||||
|
||||
|
|
@ -529,26 +511,20 @@ string V3Options::getenvVERILATOR_ROOT() {
|
|||
|
||||
void V3Options::notify() {
|
||||
// Notify that all arguments have been passed and final modification can be made.
|
||||
if (!outFormatOk()
|
||||
&& !cdc()
|
||||
&& !dpiHdrOnly()
|
||||
&& !lintOnly()
|
||||
&& !preprocOnly()
|
||||
&& !xmlOnly()) {
|
||||
v3fatal("verilator: Need --cc, --sc, --cdc, --dpi-hdr-only, --lint-only, --xml-only or --E option");
|
||||
if (!outFormatOk() && !cdc() && !dpiHdrOnly() && !lintOnly() && !preprocOnly() && !xmlOnly()) {
|
||||
v3fatal("verilator: Need --cc, --sc, --cdc, --dpi-hdr-only, --lint-only, "
|
||||
"--xml-only or --E option");
|
||||
}
|
||||
|
||||
// Make sure at least one make system is enabled
|
||||
if (!m_gmake && !m_cmake) {
|
||||
m_gmake = true;
|
||||
}
|
||||
if (!m_gmake && !m_cmake) m_gmake = true;
|
||||
|
||||
if (protectIds()) {
|
||||
FileLine* cmdfl = new FileLine(FileLine::commandLineFilename());
|
||||
if (allPublic()) {
|
||||
// We always call protect() on names, we don't check if public or not
|
||||
// Hence any external references wouldn't be able to find the refed public object.
|
||||
cmdfl->v3error("Unsupported: Using --protect-ids with --public\n"
|
||||
cmdfl->v3error("Unsupported: Using --protect-ids with --public\n" //
|
||||
+ V3Error::warnMore() + "... Suggest remove --public.");
|
||||
}
|
||||
if (trace()) {
|
||||
|
|
@ -565,19 +541,19 @@ void V3Options::notify() {
|
|||
|
||||
// Default some options if not turned on or off
|
||||
if (v3Global.opt.skipIdentical().isDefault()) {
|
||||
v3Global.opt.m_skipIdentical.setTrueOrFalse(
|
||||
!v3Global.opt.cdc()
|
||||
&& !v3Global.opt.dpiHdrOnly()
|
||||
&& !v3Global.opt.lintOnly()
|
||||
&& !v3Global.opt.preprocOnly()
|
||||
v3Global.opt.m_skipIdentical.setTrueOrFalse( //
|
||||
!v3Global.opt.cdc() //
|
||||
&& !v3Global.opt.dpiHdrOnly() //
|
||||
&& !v3Global.opt.lintOnly() //
|
||||
&& !v3Global.opt.preprocOnly() //
|
||||
&& !v3Global.opt.xmlOnly());
|
||||
}
|
||||
if (v3Global.opt.makeDepend().isDefault()) {
|
||||
v3Global.opt.m_makeDepend.setTrueOrFalse(
|
||||
!v3Global.opt.cdc()
|
||||
&& !v3Global.opt.dpiHdrOnly()
|
||||
&& !v3Global.opt.lintOnly()
|
||||
&& !v3Global.opt.preprocOnly()
|
||||
v3Global.opt.m_makeDepend.setTrueOrFalse( //
|
||||
!v3Global.opt.cdc() //
|
||||
&& !v3Global.opt.dpiHdrOnly() //
|
||||
&& !v3Global.opt.lintOnly() //
|
||||
&& !v3Global.opt.preprocOnly() //
|
||||
&& !v3Global.opt.xmlOnly());
|
||||
}
|
||||
}
|
||||
|
|
@ -603,7 +579,9 @@ string V3Options::protectKeyDefaulted() {
|
|||
|
||||
void V3Options::throwSigsegv() {
|
||||
#if !(defined(VL_CPPCHECK) || defined(__clang_analyzer__))
|
||||
char* zp=NULL; *zp=0; // Intentional core dump, ignore warnings here
|
||||
// clang-format off
|
||||
{ char* zp = NULL; *zp = 0; } // Intentional core dump, ignore warnings here
|
||||
// clang-format on
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -632,7 +610,8 @@ void V3Options::parseOpts(FileLine* fl, int argc, char** argv) {
|
|||
// Detailed error, since this is what we often get when run with minimal arguments
|
||||
const V3StringList& vFilesList = vFiles();
|
||||
if (vFilesList.empty()) {
|
||||
v3fatal("verilator: No Input Verilog file specified on command line, see verilator --help for more information\n");
|
||||
v3fatal("verilator: No Input Verilog file specified on command line, "
|
||||
"see verilator --help for more information\n");
|
||||
}
|
||||
|
||||
// Default prefix to the filename
|
||||
|
|
@ -654,9 +633,16 @@ bool V3Options::onoff(const char* sw, const char* arg, bool& flag) {
|
|||
// 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 (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;
|
||||
}
|
||||
bool V3Options::onoffb(const char* sw, const char* arg, VOptionBool& flagr) {
|
||||
|
|
@ -681,18 +667,18 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
|
|||
for (int i = 0; i < argc; ++i) {
|
||||
addArg(argv[i]); // -f's really should be inserted in the middle, but this is for debug
|
||||
}
|
||||
#define shift { ++i; }
|
||||
#define shift \
|
||||
{ ++i; }
|
||||
for (int i = 0; i < argc;) {
|
||||
UINFO(9, " Option: " << argv[i] << endl);
|
||||
// + options
|
||||
if (argv[i][0] == '+') {
|
||||
char* sw = argv[i];
|
||||
if (!strncmp(sw, "+define+", 8)) {
|
||||
addDefine(string(sw + strlen("+define+")), true);
|
||||
}
|
||||
else if (!strncmp (sw, "+incdir+", 8)) {
|
||||
} else if (!strncmp(sw, "+incdir+", 8)) {
|
||||
addIncDirUser(parseFileArg(optdir, string(sw + strlen("+incdir+"))));
|
||||
}
|
||||
else if (parseLangExt(sw, "+systemverilogext+", V3LangCode::L1800_2017)
|
||||
} else if (parseLangExt(sw, "+systemverilogext+", V3LangCode::L1800_2017)
|
||||
|| parseLangExt(sw, "+verilog1995ext+", V3LangCode::L1364_1995)
|
||||
|| parseLangExt(sw, "+verilog2001ext+", V3LangCode::L1364_2001)
|
||||
|| parseLangExt(sw, "+1364-1995ext+", V3LangCode::L1364_1995)
|
||||
|
|
@ -704,8 +690,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
|
|||
|| parseLangExt(sw, "+1800-2017ext+", V3LangCode::L1800_2017)) {
|
||||
// Nothing to do here - all done in the test
|
||||
|
||||
}
|
||||
else if (!strncmp (sw, "+libext+", 8)) {
|
||||
} else if (!strncmp(sw, "+libext+", 8)) {
|
||||
string exts = string(sw + strlen("+libext+"));
|
||||
string::size_type pos;
|
||||
while ((pos = exts.find('+')) != string::npos) {
|
||||
|
|
@ -713,16 +698,14 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
|
|||
exts = exts.substr(pos + 1);
|
||||
}
|
||||
addLibExtV(exts);
|
||||
}
|
||||
else if (!strcmp(sw, "+librescan")) { // NOP
|
||||
}
|
||||
else if (!strcmp(sw, "+notimingchecks")) { // NOP
|
||||
}
|
||||
else {
|
||||
} else if (!strcmp(sw, "+librescan")) { // NOP
|
||||
} else if (!strcmp(sw, "+notimingchecks")) { // NOP
|
||||
} else {
|
||||
fl->v3fatal("Invalid Option: " << argv[i]);
|
||||
}
|
||||
shift;
|
||||
} // + options
|
||||
}
|
||||
// - options
|
||||
else if (argv[i][0] == '-') {
|
||||
const char* sw = argv[i];
|
||||
bool flag = true;
|
||||
|
|
@ -731,6 +714,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
|
|||
if (sw[0] == '-' && sw[1] == '-') ++sw;
|
||||
bool hadSwitchPart1 = true;
|
||||
// Single switches
|
||||
// clang-format off
|
||||
if (!strcmp(sw, "-E")) { m_preprocOnly = true; }
|
||||
else if ( onoffb(sw, "-MMD", bflag/*ref*/)) { m_makeDepend = bflag; }
|
||||
else if ( onoff (sw, "-MP", flag/*ref*/)) { m_makePhony = flag; }
|
||||
|
|
@ -804,9 +788,11 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
|
|||
else if ( onoff (sw, "-x-initial-edge", flag/*ref*/)) { m_xInitialEdge = flag; }
|
||||
else if ( onoff (sw, "-xml-only", flag/*ref*/)) { m_xmlOnly = flag; } // Undocumented, still experimental
|
||||
else { hadSwitchPart1 = false; }
|
||||
if (hadSwitchPart1) {}
|
||||
// clang-format on
|
||||
|
||||
if (hadSwitchPart1) {
|
||||
} else if (!strncmp(sw, "-O", 2)) {
|
||||
// Optimization
|
||||
else if (!strncmp (sw, "-O", 2)) {
|
||||
for (const char* cp = sw + strlen("-O"); *cp; ++cp) {
|
||||
flag = isupper(*cp);
|
||||
switch (tolower(*cp)) {
|
||||
|
|
@ -824,7 +810,9 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
|
|||
case 'i': m_oInline = flag; break;
|
||||
case 'k': m_oSubstConst = flag; break;
|
||||
case 'l': m_oLife = flag; break;
|
||||
case 'p': m_public = !flag; break; // With -Op so flag=0, we want public on so few optimizations done
|
||||
case 'p':
|
||||
m_public = !flag;
|
||||
break; // With -Op so flag=0, we want public on so few optimizations done
|
||||
case 'r': m_oReorder = flag; break;
|
||||
case 's': m_oSplit = flag; break;
|
||||
case 't': m_oLifePost = flag; break;
|
||||
|
|
@ -841,98 +829,75 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
|
|||
else if (!strcmp(sw, "-CFLAGS") && (i + 1) < argc) {
|
||||
shift;
|
||||
addCFlags(argv[i]);
|
||||
}
|
||||
else if (!strcmp(sw, "-comp-limit-blocks") && (i+1)<argc) { // Undocumented
|
||||
} else if (!strcmp(sw, "-comp-limit-blocks") && (i + 1) < argc) { // Undocumented
|
||||
shift;
|
||||
m_compLimitBlocks = atoi(argv[i]);
|
||||
}
|
||||
else if (!strcmp(sw, "-comp-limit-members") && (i+1)<argc) { // Undocumented
|
||||
} else if (!strcmp(sw, "-comp-limit-members") && (i + 1) < argc) { // Undocumented
|
||||
shift;
|
||||
m_compLimitMembers = atoi(argv[i]); // Ideally power-of-two so structs stay aligned
|
||||
}
|
||||
else if (!strcmp(sw, "-comp-limit-parens") && (i+1)<argc) { // Undocumented
|
||||
m_compLimitMembers
|
||||
= atoi(argv[i]); // Ideally power-of-two so structs stay aligned
|
||||
} else if (!strcmp(sw, "-comp-limit-parens") && (i + 1) < argc) { // Undocumented
|
||||
shift;
|
||||
m_compLimitParens = atoi(argv[i]);
|
||||
}
|
||||
else if (!strcmp(sw, "-comp-limit-syms") && (i+1)<argc) { // Undocumented
|
||||
} else if (!strcmp(sw, "-comp-limit-syms") && (i + 1) < argc) { // Undocumented
|
||||
shift;
|
||||
VName::maxLength(atoi(argv[i]));
|
||||
}
|
||||
else if (!strcmp(sw, "-converge-limit") && (i+1)<argc) {
|
||||
} else if (!strcmp(sw, "-converge-limit") && (i + 1) < argc) {
|
||||
shift;
|
||||
m_convergeLimit = atoi(argv[i]);
|
||||
}
|
||||
else if (!strncmp (sw, "-D", 2)) {
|
||||
} else if (!strncmp(sw, "-D", 2)) {
|
||||
addDefine(string(sw + strlen("-D")), false);
|
||||
}
|
||||
else if (!strcmp(sw, "-debug")) {
|
||||
} else if (!strcmp(sw, "-debug")) {
|
||||
setDebugMode(3);
|
||||
}
|
||||
else if (!strcmp(sw, "-debugi") && (i+1)<argc) {
|
||||
} else if (!strcmp(sw, "-debugi") && (i + 1) < argc) {
|
||||
shift;
|
||||
setDebugMode(atoi(argv[i]));
|
||||
}
|
||||
else if (!strncmp (sw, "-debugi-", strlen("-debugi-"))) {
|
||||
} else if (!strncmp(sw, "-debugi-", strlen("-debugi-"))) {
|
||||
const char* src = sw + strlen("-debugi-");
|
||||
shift;
|
||||
setDebugSrcLevel(src, atoi(argv[i]));
|
||||
}
|
||||
else if (!strcmp(sw, "-dump-treei") && (i+1)<argc) {
|
||||
} else if (!strcmp(sw, "-dump-treei") && (i + 1) < argc) {
|
||||
shift;
|
||||
m_dumpTree = atoi(argv[i]);
|
||||
}
|
||||
else if (!strncmp (sw, "-dump-treei-", strlen("-dump-treei-"))) {
|
||||
} else if (!strncmp(sw, "-dump-treei-", strlen("-dump-treei-"))) {
|
||||
const char* src = sw + strlen("-dump-treei-");
|
||||
shift;
|
||||
setDumpTreeLevel(src, atoi(argv[i]));
|
||||
}
|
||||
else if (!strcmp(sw, "-error-limit") && (i+1)<argc) {
|
||||
} else if (!strcmp(sw, "-error-limit") && (i + 1) < argc) {
|
||||
shift;
|
||||
V3Error::errorLimit(atoi(argv[i]));
|
||||
}
|
||||
else if (!strcmp(sw, "-FI") && (i+1)<argc) {
|
||||
} else if (!strcmp(sw, "-FI") && (i + 1) < argc) {
|
||||
shift;
|
||||
addForceInc(parseFileArg(optdir, string(argv[i])));
|
||||
}
|
||||
else if (!strncmp (sw, "-G", strlen("-G"))) {
|
||||
} else if (!strncmp(sw, "-G", strlen("-G"))) {
|
||||
addParameter(string(sw + strlen("-G")), false);
|
||||
}
|
||||
else if (!strcmp(sw, "-gate-stmts") && (i+1)<argc) {
|
||||
} else if (!strcmp(sw, "-gate-stmts") && (i + 1) < argc) {
|
||||
shift;
|
||||
m_gateStmts = atoi(argv[i]);
|
||||
}
|
||||
else if (!strcmp(sw, "-generate-key")) {
|
||||
} else if (!strcmp(sw, "-generate-key")) {
|
||||
cout << protectKeyDefaulted() << endl;
|
||||
exit(0);
|
||||
}
|
||||
else if (!strcmp(sw, "-getenv") && (i+1)<argc) {
|
||||
} else if (!strcmp(sw, "-getenv") && (i + 1) < argc) {
|
||||
shift;
|
||||
cout << V3Options::getenvBuiltins(argv[i]) << endl;
|
||||
exit(0);
|
||||
}
|
||||
else if (!strncmp (sw, "-I", 2)) {
|
||||
} else if (!strncmp(sw, "-I", 2)) {
|
||||
addIncDirUser(parseFileArg(optdir, string(sw + strlen("-I"))));
|
||||
}
|
||||
else if (!strcmp(sw, "-if-depth") && (i+1)<argc) {
|
||||
} else if (!strcmp(sw, "-if-depth") && (i + 1) < argc) {
|
||||
shift;
|
||||
m_ifDepth = atoi(argv[i]);
|
||||
}
|
||||
else if (!strcmp(sw, "-inline-mult") && (i+1)<argc) {
|
||||
} else if (!strcmp(sw, "-inline-mult") && (i + 1) < argc) {
|
||||
shift;
|
||||
m_inlineMult = atoi(argv[i]);
|
||||
}
|
||||
else if (!strcmp(sw, "-LDFLAGS") && (i+1)<argc) {
|
||||
} else if (!strcmp(sw, "-LDFLAGS") && (i + 1) < argc) {
|
||||
shift;
|
||||
addLdLibs(argv[i]);
|
||||
}
|
||||
else if (!strcmp(sw, "-l2-name") && (i+1)<argc) {
|
||||
} else if (!strcmp(sw, "-l2-name") && (i + 1) < argc) {
|
||||
shift;
|
||||
m_l2Name = argv[i];
|
||||
}
|
||||
else if (!strcmp(sw, "-l2name")) { // Historical and undocumented
|
||||
} else if (!strcmp(sw, "-l2name")) { // Historical and undocumented
|
||||
m_l2Name = "v";
|
||||
}
|
||||
else if (!strcmp(sw, "-make")) {
|
||||
} else if (!strcmp(sw, "-make")) {
|
||||
shift;
|
||||
if (!strcmp(argv[i], "cmake")) {
|
||||
m_cmake = true;
|
||||
|
|
@ -941,15 +906,12 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
|
|||
} else {
|
||||
fl->v3fatal("Unknown --make system specified: '" << argv[i] << "'");
|
||||
}
|
||||
}
|
||||
else if (!strcmp(sw, "-max-num-width")) {
|
||||
} else if (!strcmp(sw, "-max-num-width")) {
|
||||
shift;
|
||||
m_maxNumWidth = atoi(argv[i]);
|
||||
}
|
||||
else if (!strcmp(sw, "-no-l2name")) { // Historical and undocumented
|
||||
} else if (!strcmp(sw, "-no-l2name")) { // Historical and undocumented
|
||||
m_l2Name = "";
|
||||
}
|
||||
else if ((!strcmp(sw, "-language") && (i+1)<argc)
|
||||
} else if ((!strcmp(sw, "-language") && (i + 1) < argc)
|
||||
|| (!strcmp(sw, "-default-language") && (i + 1) < argc)) {
|
||||
shift;
|
||||
V3LangCode optval = V3LangCode(argv[i]);
|
||||
|
|
@ -958,152 +920,120 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
|
|||
} else {
|
||||
fl->v3fatal("Unknown language specified: " << argv[i]);
|
||||
}
|
||||
}
|
||||
else if (!strcmp(sw, "-Mdir") && (i+1)<argc) {
|
||||
shift; m_makeDir = argv[i];
|
||||
} else if (!strcmp(sw, "-Mdir") && (i + 1) < argc) {
|
||||
shift;
|
||||
m_makeDir = argv[i];
|
||||
addIncDirFallback(m_makeDir); // Need to find generated files there too
|
||||
}
|
||||
else if (!strcmp(sw, "-o") && (i+1)<argc) {
|
||||
shift; m_exeName = argv[i];
|
||||
}
|
||||
else if (!strcmp(sw, "-output-split") && (i+1)<argc) {
|
||||
} else if (!strcmp(sw, "-o") && (i + 1) < argc) {
|
||||
shift;
|
||||
m_exeName = argv[i];
|
||||
} else if (!strcmp(sw, "-output-split") && (i + 1) < argc) {
|
||||
shift;
|
||||
m_outputSplit = atoi(argv[i]);
|
||||
}
|
||||
else if (!strcmp(sw, "-output-split-cfuncs") && (i+1)<argc) {
|
||||
} else if (!strcmp(sw, "-output-split-cfuncs") && (i + 1) < argc) {
|
||||
shift;
|
||||
m_outputSplitCFuncs = atoi(argv[i]);
|
||||
if (m_outputSplitCFuncs && (!m_outputSplitCTrace
|
||||
|| m_outputSplitCTrace>m_outputSplitCFuncs)) {
|
||||
if (m_outputSplitCFuncs
|
||||
&& (!m_outputSplitCTrace || m_outputSplitCTrace > m_outputSplitCFuncs)) {
|
||||
m_outputSplitCTrace = m_outputSplitCFuncs;
|
||||
}
|
||||
}
|
||||
else if (!strcmp(sw, "-output-split-ctrace")) { // Undocumented optimization tweak
|
||||
} else if (!strcmp(sw, "-output-split-ctrace")) { // Undocumented optimization tweak
|
||||
shift;
|
||||
m_outputSplitCTrace = atoi(argv[i]);
|
||||
}
|
||||
else if (!strcmp(sw, "-protect-lib") && (i+1)<argc) {
|
||||
shift; m_protectLib = argv[i];
|
||||
} else if (!strcmp(sw, "-protect-lib") && (i + 1) < argc) {
|
||||
shift;
|
||||
m_protectLib = argv[i];
|
||||
m_protectIds = true;
|
||||
}
|
||||
else if (!strcmp(sw, "-trace-fst")) {
|
||||
} else if (!strcmp(sw, "-trace-fst")) {
|
||||
m_trace = true;
|
||||
m_traceFormat = TraceFormat::FST;
|
||||
addLdLibs("-lz");
|
||||
}
|
||||
else if (!strcmp(sw, "-trace-fst-thread")) {
|
||||
} else if (!strcmp(sw, "-trace-fst-thread")) {
|
||||
m_trace = true;
|
||||
m_traceFormat = TraceFormat::FST_THREAD;
|
||||
addLdLibs("-lz");
|
||||
}
|
||||
else if (!strcmp(sw, "-trace-depth") && (i+1)<argc) {
|
||||
} else if (!strcmp(sw, "-trace-depth") && (i + 1) < argc) {
|
||||
shift;
|
||||
m_traceDepth = atoi(argv[i]);
|
||||
}
|
||||
else if (!strcmp(sw, "-trace-max-array") && (i+1)<argc) {
|
||||
} else if (!strcmp(sw, "-trace-max-array") && (i + 1) < argc) {
|
||||
shift;
|
||||
m_traceMaxArray = atoi(argv[i]);
|
||||
}
|
||||
else if (!strcmp(sw, "-trace-max-width") && (i+1)<argc) {
|
||||
} else if (!strcmp(sw, "-trace-max-width") && (i + 1) < argc) {
|
||||
shift;
|
||||
m_traceMaxWidth = atoi(argv[i]);
|
||||
}
|
||||
else if (!strncmp (sw, "-U", 2)) {
|
||||
} else if (!strncmp(sw, "-U", 2)) {
|
||||
V3PreShell::undef(string(sw + strlen("-U")));
|
||||
}
|
||||
else if (!strcmp(sw, "-unroll-count")) { // Undocumented optimization tweak
|
||||
} else if (!strcmp(sw, "-unroll-count")) { // Undocumented optimization tweak
|
||||
shift;
|
||||
m_unrollCount = atoi(argv[i]);
|
||||
}
|
||||
else if (!strcmp(sw, "-unroll-stmts")) { // Undocumented optimization tweak
|
||||
} else if (!strcmp(sw, "-unroll-stmts")) { // Undocumented optimization tweak
|
||||
shift;
|
||||
m_unrollStmts = atoi(argv[i]);
|
||||
}
|
||||
else if (!strcmp(sw, "-v") && (i+1)<argc) {
|
||||
} else if (!strcmp(sw, "-v") && (i + 1) < argc) {
|
||||
shift;
|
||||
V3Options::addLibraryFile(parseFileArg(optdir, argv[i]));
|
||||
}
|
||||
else if (!strcmp(sw, "-clk") && (i+1)<argc) {
|
||||
} else if (!strcmp(sw, "-clk") && (i + 1) < argc) {
|
||||
shift;
|
||||
V3Options::addClocker(argv[i]);
|
||||
}
|
||||
else if (!strcmp(sw, "-no-clk") && (i+1)<argc) {
|
||||
} else if (!strcmp(sw, "-no-clk") && (i + 1) < argc) {
|
||||
shift;
|
||||
V3Options::addNoClocker(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, "-Wall")) {
|
||||
} else if (!strcmp(sw, "-Wall")) {
|
||||
FileLine::globalWarnLintOff(false);
|
||||
FileLine::globalWarnStyleOff(false);
|
||||
}
|
||||
else if (!strncmp (sw, "-Werror-", strlen("-Werror-"))) {
|
||||
} else if (!strncmp(sw, "-Werror-", strlen("-Werror-"))) {
|
||||
string msg = sw + strlen("-Werror-");
|
||||
V3ErrorCode code(msg.c_str());
|
||||
if (code == V3ErrorCode::EC_ERROR) {
|
||||
if (!isFuture(msg)) {
|
||||
fl->v3fatal("Unknown warning specified: "<<sw);
|
||||
}
|
||||
if (!isFuture(msg)) { fl->v3fatal("Unknown warning specified: " << sw); }
|
||||
} else {
|
||||
V3Error::pretendError(code, true);
|
||||
}
|
||||
}
|
||||
else if (!strncmp (sw, "-Wfuture-", strlen("-Wfuture-"))) {
|
||||
} else if (!strncmp(sw, "-Wfuture-", strlen("-Wfuture-"))) {
|
||||
string msg = sw + strlen("-Wfuture-");
|
||||
// Note it may not be a future option, but one that is currently implemented.
|
||||
addFuture(msg);
|
||||
}
|
||||
else if (!strncmp (sw, "-Wno-", 5)) {
|
||||
} else if (!strncmp(sw, "-Wno-", 5)) {
|
||||
if (!strcmp(sw, "-Wno-context")) {
|
||||
m_context = false;
|
||||
}
|
||||
else if (!strcmp(sw, "-Wno-fatal")) {
|
||||
} else if (!strcmp(sw, "-Wno-fatal")) {
|
||||
V3Error::warnFatal(false);
|
||||
}
|
||||
else if (!strcmp(sw, "-Wno-lint")) {
|
||||
} else if (!strcmp(sw, "-Wno-lint")) {
|
||||
FileLine::globalWarnLintOff(true);
|
||||
FileLine::globalWarnStyleOff(true);
|
||||
}
|
||||
else if (!strcmp(sw, "-Wno-style")) {
|
||||
} else if (!strcmp(sw, "-Wno-style")) {
|
||||
FileLine::globalWarnStyleOff(true);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
string msg = sw + strlen("-Wno-");
|
||||
if (!(FileLine::globalWarnOff(msg, true))) {
|
||||
fl->v3fatal("Unknown warning specified: " << sw);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!strncmp (sw, "-Wwarn-", 5)) {
|
||||
} else if (!strncmp(sw, "-Wwarn-", 5)) {
|
||||
if (!strcmp(sw, "-Wwarn-lint")) {
|
||||
FileLine::globalWarnLintOff(false);
|
||||
}
|
||||
else if (!strcmp(sw, "-Wwarn-style")) {
|
||||
} else if (!strcmp(sw, "-Wwarn-style")) {
|
||||
FileLine::globalWarnStyleOff(false);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
string msg = sw + strlen("-Wwarn-");
|
||||
V3ErrorCode code(msg.c_str());
|
||||
if (code == V3ErrorCode::EC_ERROR) {
|
||||
if (!isFuture(msg)) {
|
||||
fl->v3fatal("Unknown warning specified: "<<sw);
|
||||
}
|
||||
if (!isFuture(msg)) { fl->v3fatal("Unknown warning specified: " << sw); }
|
||||
} else {
|
||||
FileLine::globalWarnOff(code, false);
|
||||
V3Error::pretendError(code, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!strcmp(sw, "-bin") && (i+1)<argc) {
|
||||
shift; m_bin = argv[i];
|
||||
}
|
||||
else if (!strcmp(sw, "-compiler") && (i+1)<argc) {
|
||||
} else if (!strcmp(sw, "-bin") && (i + 1) < argc) {
|
||||
shift;
|
||||
m_bin = argv[i];
|
||||
} else if (!strcmp(sw, "-compiler") && (i + 1) < argc) {
|
||||
shift;
|
||||
if (!strcmp(argv[i], "clang")) {
|
||||
m_compLimitBlocks = 80; // limit unknown
|
||||
|
|
@ -1120,99 +1050,100 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
|
|||
} else {
|
||||
fl->v3fatal("Unknown setting for --compiler: " << argv[i]);
|
||||
}
|
||||
}
|
||||
else if (!strcmp(sw, "-F") && (i+1)<argc) {
|
||||
} else if (!strcmp(sw, "-F") && (i + 1) < argc) {
|
||||
shift;
|
||||
parseOptsFile(fl, parseFileArg(optdir, argv[i]), true);
|
||||
}
|
||||
else if (!strcmp(sw, "-f") && (i+1)<argc) {
|
||||
} else if (!strcmp(sw, "-f") && (i + 1) < argc) {
|
||||
shift;
|
||||
parseOptsFile(fl, parseFileArg(optdir, argv[i]), false);
|
||||
}
|
||||
else if (!strcmp(sw, "-gdb")) {
|
||||
} else if (!strcmp(sw, "-gdb")) {
|
||||
// Used only in perl shell
|
||||
}
|
||||
else if (!strcmp(sw, "-rr")) {
|
||||
} else if (!strcmp(sw, "-rr")) {
|
||||
// Used only in perl shell
|
||||
}
|
||||
else if (!strcmp(sw, "-gdbbt")) {
|
||||
} else if (!strcmp(sw, "-gdbbt")) {
|
||||
// Used only in perl shell
|
||||
}
|
||||
else if (!strcmp(sw, "-quiet-exit")) {
|
||||
} else if (!strcmp(sw, "-quiet-exit")) {
|
||||
// Used only in perl shell
|
||||
}
|
||||
else if (!strcmp(sw, "-mod-prefix") && (i+1)<argc) {
|
||||
shift; m_modPrefix = argv[i];
|
||||
}
|
||||
else if (!strcmp(sw, "-pins-bv") && (i+1)<argc) {
|
||||
shift; m_pinsBv = atoi(argv[i]);
|
||||
} else if (!strcmp(sw, "-mod-prefix") && (i + 1) < argc) {
|
||||
shift;
|
||||
m_modPrefix = argv[i];
|
||||
} else if (!strcmp(sw, "-pins-bv") && (i + 1) < argc) {
|
||||
shift;
|
||||
m_pinsBv = atoi(argv[i]);
|
||||
if (m_pinsBv > 65) fl->v3fatal("--pins-bv maximum is 65: " << argv[i]);
|
||||
}
|
||||
else if (!strcmp(sw, "-pipe-filter") && (i+1)<argc) {
|
||||
shift; m_pipeFilter = argv[i];
|
||||
}
|
||||
else if (!strcmp(sw, "-prefix") && (i+1)<argc) {
|
||||
shift; m_prefix = argv[i];
|
||||
} else if (!strcmp(sw, "-pipe-filter") && (i + 1) < argc) {
|
||||
shift;
|
||||
m_pipeFilter = argv[i];
|
||||
} else if (!strcmp(sw, "-prefix") && (i + 1) < argc) {
|
||||
shift;
|
||||
m_prefix = argv[i];
|
||||
if (m_modPrefix == "") m_modPrefix = m_prefix;
|
||||
}
|
||||
else if (!strcmp(sw, "-protect-key") && (i+1)<argc) {
|
||||
shift; m_protectKey = argv[i];
|
||||
}
|
||||
else if (!strcmp(sw, "-no-threads")) { m_threads = 0; } // Undocumented until functional
|
||||
else if (!strcmp(sw, "-threads") && (i+1)<argc) { // Undocumented until functional
|
||||
shift; m_threads = atoi(argv[i]);
|
||||
} else if (!strcmp(sw, "-protect-key") && (i + 1) < argc) {
|
||||
shift;
|
||||
m_protectKey = argv[i];
|
||||
} else if (!strcmp(sw, "-no-threads")) {
|
||||
m_threads = 0;
|
||||
} else if (!strcmp(sw, "-threads") && (i + 1) < argc) {
|
||||
shift;
|
||||
m_threads = atoi(argv[i]);
|
||||
if (m_threads < 0) fl->v3fatal("--threads must be >= 0: " << argv[i]);
|
||||
}
|
||||
else if (!strcmp(sw, "-threads-dpi") && (i+1)<argc) {
|
||||
} else if (!strcmp(sw, "-threads-dpi") && (i + 1) < argc) {
|
||||
shift;
|
||||
if (!strcmp(argv[i], "all")) {
|
||||
m_threadsDpiPure = true; m_threadsDpiUnpure = true;
|
||||
m_threadsDpiPure = true;
|
||||
m_threadsDpiUnpure = true;
|
||||
} else if (!strcmp(argv[i], "none")) {
|
||||
m_threadsDpiPure = false; m_threadsDpiUnpure = false;
|
||||
m_threadsDpiPure = false;
|
||||
m_threadsDpiUnpure = false;
|
||||
} else if (!strcmp(argv[i], "pure")) {
|
||||
m_threadsDpiPure = true; m_threadsDpiUnpure = false;
|
||||
m_threadsDpiPure = true;
|
||||
m_threadsDpiUnpure = false;
|
||||
} else {
|
||||
fl->v3fatal("Unknown setting for --threads-dpi: " << argv[i]);
|
||||
}
|
||||
}
|
||||
else if (!strcmp(sw, "-threads-max-mtasks")) {
|
||||
shift; m_threadsMaxMTasks = atoi(argv[i]);
|
||||
} else if (!strcmp(sw, "-threads-max-mtasks")) {
|
||||
shift;
|
||||
m_threadsMaxMTasks = atoi(argv[i]);
|
||||
if (m_threadsMaxMTasks < 1)
|
||||
fl->v3fatal("--threads-max-mtasks must be >= 1: " << argv[i]);
|
||||
}
|
||||
else if (!strcmp(sw, "-top-module") && (i+1)<argc) {
|
||||
shift; m_topModule = argv[i];
|
||||
}
|
||||
else if (!strcmp(sw, "-unused-regexp") && (i+1)<argc) {
|
||||
shift; m_unusedRegexp = argv[i];
|
||||
}
|
||||
else if (!strcmp(sw, "-x-assign") && (i+1)<argc) {
|
||||
} else if (!strcmp(sw, "-top-module") && (i + 1) < argc) {
|
||||
shift;
|
||||
if (!strcmp(argv[i], "0")) { m_xAssign = "0"; }
|
||||
else if (!strcmp(argv[i], "1")) { m_xAssign = "1"; }
|
||||
else if (!strcmp(argv[i], "fast")) { m_xAssign = "fast"; }
|
||||
else if (!strcmp(argv[i], "unique")) { m_xAssign = "unique"; }
|
||||
else {
|
||||
m_topModule = argv[i];
|
||||
} else if (!strcmp(sw, "-unused-regexp") && (i + 1) < argc) {
|
||||
shift;
|
||||
m_unusedRegexp = argv[i];
|
||||
} else if (!strcmp(sw, "-x-assign") && (i + 1) < argc) {
|
||||
shift;
|
||||
if (!strcmp(argv[i], "0")) {
|
||||
m_xAssign = "0";
|
||||
} else if (!strcmp(argv[i], "1")) {
|
||||
m_xAssign = "1";
|
||||
} else if (!strcmp(argv[i], "fast")) {
|
||||
m_xAssign = "fast";
|
||||
} else if (!strcmp(argv[i], "unique")) {
|
||||
m_xAssign = "unique";
|
||||
} else {
|
||||
fl->v3fatal("Unknown setting for --x-assign: " << argv[i]);
|
||||
}
|
||||
}
|
||||
else if (!strcmp(sw, "-x-initial") && (i+1)<argc) {
|
||||
} else if (!strcmp(sw, "-x-initial") && (i + 1) < argc) {
|
||||
shift;
|
||||
if (!strcmp(argv[i], "0")) { m_xInitial = "0"; }
|
||||
else if (!strcmp(argv[i], "fast")) { m_xInitial = "fast"; }
|
||||
else if (!strcmp(argv[i], "unique")) { m_xInitial = "unique"; }
|
||||
else {
|
||||
if (!strcmp(argv[i], "0")) {
|
||||
m_xInitial = "0";
|
||||
} else if (!strcmp(argv[i], "fast")) {
|
||||
m_xInitial = "fast";
|
||||
} else if (!strcmp(argv[i], "unique")) {
|
||||
m_xInitial = "unique";
|
||||
} else {
|
||||
fl->v3fatal("Unknown setting for --x-initial: " << argv[i]);
|
||||
}
|
||||
}
|
||||
else if (!strcmp(sw, "-xml-output") && (i+1)<argc) {
|
||||
shift; m_xmlOutput = argv[i];
|
||||
} else if (!strcmp(sw, "-xml-output") && (i + 1) < argc) {
|
||||
shift;
|
||||
m_xmlOutput = argv[i];
|
||||
m_xmlOnly = true;
|
||||
}
|
||||
else if (!strcmp(sw, "-y") && (i+1)<argc) {
|
||||
shift; addIncDirUser(parseFileArg(optdir, string(argv[i])));
|
||||
}
|
||||
else {
|
||||
} else if (!strcmp(sw, "-y") && (i + 1) < argc) {
|
||||
shift;
|
||||
addIncDirUser(parseFileArg(optdir, string(argv[i])));
|
||||
} else {
|
||||
fl->v3fatal("Invalid Option: " << argv[i]);
|
||||
}
|
||||
shift;
|
||||
|
|
@ -1220,19 +1151,17 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
|
|||
else {
|
||||
// Filename
|
||||
string filename = parseFileArg(optdir, argv[i]);
|
||||
if (suffixed(filename, ".cpp")
|
||||
|| suffixed(filename, ".cxx")
|
||||
|| suffixed(filename, ".cc")
|
||||
|| suffixed(filename, ".c")
|
||||
if (suffixed(filename, ".cpp") //
|
||||
|| suffixed(filename, ".cxx") //
|
||||
|| suffixed(filename, ".cc") //
|
||||
|| suffixed(filename, ".c") //
|
||||
|| suffixed(filename, ".sp")) {
|
||||
V3Options::addCppFile(filename);
|
||||
}
|
||||
else if (suffixed(filename, ".a")
|
||||
|| suffixed(filename, ".o")
|
||||
} else if (suffixed(filename, ".a") //
|
||||
|| suffixed(filename, ".o") //
|
||||
|| suffixed(filename, ".so")) {
|
||||
V3Options::addLdLibs(filename);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
V3Options::addVFile(filename);
|
||||
}
|
||||
shift;
|
||||
|
|
@ -1293,16 +1222,12 @@ void V3Options::parseOptsFile(FileLine* fl, const string& filename, bool rel) {
|
|||
std::vector<string> args;
|
||||
|
||||
// Parse file using a state machine, taking into account quoted strings and escaped chars
|
||||
enum state {ST_IN_OPTION,
|
||||
ST_ESCAPED_CHAR,
|
||||
ST_IN_QUOTED_STR,
|
||||
ST_IN_DOUBLE_QUOTED_STR};
|
||||
enum state { ST_IN_OPTION, ST_ESCAPED_CHAR, ST_IN_QUOTED_STR, ST_IN_DOUBLE_QUOTED_STR };
|
||||
|
||||
state st = ST_IN_OPTION;
|
||||
state last_st = ST_IN_OPTION;
|
||||
string arg;
|
||||
for (string::size_type pos = 0;
|
||||
pos < whole_file.length(); ++pos) {
|
||||
for (string::size_type pos = 0; pos < whole_file.length(); ++pos) {
|
||||
char curr_char = whole_file[pos];
|
||||
switch (st) {
|
||||
case ST_IN_OPTION: // Get all chars up to a white space or a "="
|
||||
|
|
@ -1371,7 +1296,8 @@ void V3Options::parseOptsFile(FileLine* fl, const string& filename, bool rel) {
|
|||
string optdir = (rel ? V3Os::filenameDir(filename) : ".");
|
||||
|
||||
// Convert to argv style arg list and parse them
|
||||
std::vector<char*> argv; argv.reserve(args.size()+1);
|
||||
std::vector<char*> argv;
|
||||
argv.reserve(args.size() + 1);
|
||||
for (std::vector<std::string>::const_iterator it = args.begin(); it != args.end(); ++it) {
|
||||
argv.push_back(const_cast<char*>(it->c_str()));
|
||||
}
|
||||
|
|
@ -1383,9 +1309,7 @@ void V3Options::parseOptsFile(FileLine* fl, const string& filename, bool rel) {
|
|||
|
||||
string V3Options::parseFileArg(const string& optdir, const string& relfilename) {
|
||||
string filename = V3Os::filenameSubstitute(relfilename);
|
||||
if (optdir != "." && V3Os::filenameIsRel(filename)) {
|
||||
filename = optdir + "/" + filename;
|
||||
}
|
||||
if (optdir != "." && V3Os::filenameIsRel(filename)) filename = optdir + "/" + filename;
|
||||
return filename;
|
||||
}
|
||||
|
||||
|
|
@ -1437,7 +1361,8 @@ void V3Options::showVersion(bool verbose) {
|
|||
cout << " SYSTEMC_INCLUDE = " << V3Os::getenvStr("SYSTEMC_INCLUDE", "") << endl;
|
||||
cout << " SYSTEMC_LIBDIR = " << V3Os::getenvStr("SYSTEMC_LIBDIR", "") << endl;
|
||||
cout << " VERILATOR_ROOT = " << V3Os::getenvStr("VERILATOR_ROOT", "") << endl;
|
||||
cout << " VERILATOR_BIN = " << V3Os::getenvStr("VERILATOR_BIN","")<<endl; // wrapper uses this
|
||||
// wrapper uses this:
|
||||
cout << " VERILATOR_BIN = " << V3Os::getenvStr("VERILATOR_BIN", "") << endl;
|
||||
}
|
||||
|
||||
//======================================================================
|
||||
|
|
@ -1553,9 +1478,7 @@ V3Options::V3Options() {
|
|||
addIncDirFallback("."); // Looks better than {long_cwd_path}/...
|
||||
}
|
||||
|
||||
V3Options::~V3Options() {
|
||||
VL_DO_CLEAR(delete m_impp, m_impp = NULL);
|
||||
}
|
||||
V3Options::~V3Options() { VL_DO_CLEAR(delete m_impp, m_impp = NULL); }
|
||||
|
||||
void V3Options::setDebugMode(int level) {
|
||||
V3Error::debugDefault(level);
|
||||
|
|
|
|||
|
|
@ -37,18 +37,15 @@ class VOptionBool {
|
|||
// Class to track options that are either not specified (and default
|
||||
// true/false), versus user setting the option to true or false
|
||||
public:
|
||||
enum en {
|
||||
OPT_DEFAULT_FALSE = 0,
|
||||
OPT_DEFAULT_TRUE,
|
||||
OPT_TRUE,
|
||||
OPT_FALSE,
|
||||
_ENUM_END
|
||||
};
|
||||
enum en { OPT_DEFAULT_FALSE = 0, OPT_DEFAULT_TRUE, OPT_TRUE, OPT_FALSE, _ENUM_END };
|
||||
enum en m_e;
|
||||
inline VOptionBool() : m_e(OPT_DEFAULT_FALSE) {}
|
||||
inline VOptionBool()
|
||||
: m_e(OPT_DEFAULT_FALSE) {}
|
||||
// cppcheck-suppress noExplicitConstructor
|
||||
inline VOptionBool(en _e) : m_e(_e) {}
|
||||
explicit inline VOptionBool(int _e) : m_e(static_cast<en>(_e)) {}
|
||||
inline VOptionBool(en _e)
|
||||
: m_e(_e) {}
|
||||
explicit inline VOptionBool(int _e)
|
||||
: m_e(static_cast<en>(_e)) {}
|
||||
operator en() const { return m_e; }
|
||||
bool isDefault() const { return m_e == OPT_DEFAULT_FALSE || m_e == OPT_DEFAULT_TRUE; }
|
||||
bool isTrue() const { return m_e == OPT_TRUE || m_e == OPT_DEFAULT_TRUE; }
|
||||
|
|
@ -57,9 +54,9 @@ public:
|
|||
bool isSetFalse() const { return m_e == OPT_FALSE; }
|
||||
void setTrueOrFalse(bool flag) { m_e = flag ? OPT_TRUE : OPT_FALSE; }
|
||||
const char* ascii() const {
|
||||
static const char* const names[] = {
|
||||
"DEFAULT_FALSE", "DEFAULT_TRUE", "TRUE", "FALSE"};
|
||||
return names[m_e]; }
|
||||
static const char* const names[] = {"DEFAULT_FALSE", "DEFAULT_TRUE", "TRUE", "FALSE"};
|
||||
return names[m_e];
|
||||
}
|
||||
};
|
||||
inline bool operator==(const VOptionBool& lhs, const VOptionBool& rhs) {
|
||||
return lhs.m_e == rhs.m_e;
|
||||
|
|
@ -74,31 +71,21 @@ inline std::ostream& operator<<(std::ostream& os, const VOptionBool& rhs) {
|
|||
|
||||
class TraceFormat {
|
||||
public:
|
||||
enum en {
|
||||
VCD = 0,
|
||||
FST,
|
||||
FST_THREAD
|
||||
} m_e;
|
||||
enum en { VCD = 0, FST, FST_THREAD } m_e;
|
||||
// cppcheck-suppress noExplicitConstructor
|
||||
inline TraceFormat(en _e = VCD) : m_e(_e) {}
|
||||
explicit inline TraceFormat(int _e) : m_e(static_cast<en>(_e)) {}
|
||||
inline TraceFormat(en _e = VCD)
|
||||
: m_e(_e) {}
|
||||
explicit inline TraceFormat(int _e)
|
||||
: m_e(static_cast<en>(_e)) {}
|
||||
operator en() const { return m_e; }
|
||||
bool fstFlavor() const { return m_e == FST || m_e == FST_THREAD; }
|
||||
bool threaded() const { return m_e == FST_THREAD; }
|
||||
string classBase() const {
|
||||
static const char* const names[] = {
|
||||
"VerilatedVcd",
|
||||
"VerilatedFst",
|
||||
"VerilatedFst"
|
||||
};
|
||||
static const char* const names[] = {"VerilatedVcd", "VerilatedFst", "VerilatedFst"};
|
||||
return names[m_e];
|
||||
}
|
||||
string sourceName() const {
|
||||
static const char* const names[] = {
|
||||
"verilated_vcd",
|
||||
"verilated_fst",
|
||||
"verilated_fst"
|
||||
};
|
||||
static const char* const names[] = {"verilated_vcd", "verilated_fst", "verilated_fst"};
|
||||
return names[m_e];
|
||||
}
|
||||
};
|
||||
|
|
@ -116,7 +103,6 @@ typedef std::set<string> V3StringSet;
|
|||
|
||||
class V3Options {
|
||||
public:
|
||||
|
||||
private:
|
||||
// TYPES
|
||||
typedef std::map<string, int> DebugSrcMap;
|
||||
|
|
@ -124,6 +110,7 @@ class V3Options {
|
|||
// MEMBERS (general options)
|
||||
V3OptionsImp* m_impp; // Slow hidden options
|
||||
|
||||
// clang-format off
|
||||
V3StringSet m_cppFiles; // argument: C++ files to link against
|
||||
V3StringList m_cFlags; // argument: user CFLAGS
|
||||
V3StringList m_ldLibs; // argument: user LDFLAGS
|
||||
|
|
@ -137,7 +124,6 @@ class V3Options {
|
|||
DebugSrcMap m_dumpTrees; // argument: --dump-treei-<srcfile>=<level>
|
||||
std::map<string,string> m_parameters; // Parameters
|
||||
|
||||
|
||||
bool m_preprocOnly; // main switch: -E
|
||||
bool m_makePhony; // main switch: -MP
|
||||
bool m_preprocNoLine;// main switch: -P
|
||||
|
|
@ -268,6 +254,7 @@ class V3Options {
|
|||
bool m_oSubst; // main switch: -Ou: substitute expression temp values
|
||||
bool m_oSubstConst; // main switch: -Ok: final constant substitution
|
||||
bool m_oTable; // main switch: -Oa: lookup table creation
|
||||
// clang-format on
|
||||
|
||||
private:
|
||||
// METHODS
|
||||
|
|
@ -291,6 +278,7 @@ class V3Options {
|
|||
|
||||
// CONSTRUCTORS
|
||||
VL_UNCOPYABLE(V3Options);
|
||||
|
||||
public:
|
||||
V3Options();
|
||||
~V3Options();
|
||||
|
|
@ -499,8 +487,8 @@ class V3Options {
|
|||
|
||||
// METHODS (file utilities using these options)
|
||||
string fileExists(const string& filename);
|
||||
string filePath(FileLine* fl, const string& modname,
|
||||
const string& lastpath, const string& errmsg);
|
||||
string filePath(FileLine* fl, const string& modname, const string& lastpath,
|
||||
const string& errmsg);
|
||||
void filePathLookedMsg(FileLine* fl, const string& modname);
|
||||
V3LangCode fileLanguage(const string& filename);
|
||||
static bool fileStatDir(const string& filename);
|
||||
|
|
|
|||
60
src/V3Os.cpp
60
src/V3Os.cpp
|
|
@ -14,6 +14,7 @@
|
|||
//
|
||||
//*************************************************************************
|
||||
|
||||
// clang-format off
|
||||
#if defined(_WIN32) || defined(__MINGW32__)
|
||||
# ifndef PSAPI_VERSION
|
||||
# define PSAPI_VERSION 1 // Needed for compatibility with Windows 7
|
||||
|
|
@ -22,6 +23,7 @@
|
|||
#if defined(__MINGW32__)
|
||||
# define MINGW_HAS_SECURE_API 1 // Needed to expose a "secure" POSIX-like API
|
||||
#endif
|
||||
// clang-format on
|
||||
|
||||
#include "config_build.h"
|
||||
#include "verilatedos.h"
|
||||
|
|
@ -42,6 +44,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
// clang-format off
|
||||
#if defined(_WIN32) || defined(__MINGW32__)
|
||||
# include <windows.h> // LONG for bcrypt.h on MINGW
|
||||
# include <bcrypt.h> // BCryptGenRandom
|
||||
|
|
@ -53,7 +56,7 @@
|
|||
# include <sys/time.h>
|
||||
# include <unistd.h> // usleep
|
||||
#endif
|
||||
|
||||
// clang-format on
|
||||
|
||||
//######################################################################
|
||||
// Environment
|
||||
|
|
@ -101,8 +104,11 @@ void V3Os::setenvStr(const string& envvar, const string& value, const string& wh
|
|||
|
||||
string V3Os::filenameFromDirBase(const string& dir, const string& basename) {
|
||||
// Don't return ./{filename} because if filename was absolute, that makes it relative
|
||||
if (dir == ".") return basename;
|
||||
else return dir+"/"+basename;
|
||||
if (dir == ".") {
|
||||
return basename;
|
||||
} else {
|
||||
return dir + "/" + basename;
|
||||
}
|
||||
}
|
||||
|
||||
string V3Os::filenameDir(const string& filename) {
|
||||
|
|
@ -126,9 +132,7 @@ string V3Os::filenameNonDir(const string& filename) {
|
|||
string V3Os::filenameNonExt(const string& filename) {
|
||||
string base = filenameNonDir(filename);
|
||||
string::size_type pos;
|
||||
if ((pos = base.find('.')) != string::npos) {
|
||||
base.erase(pos);
|
||||
}
|
||||
if ((pos = base.find('.')) != string::npos) base.erase(pos);
|
||||
return base;
|
||||
}
|
||||
|
||||
|
|
@ -144,15 +148,15 @@ string V3Os::filenameSubstitute(const string& filename) {
|
|||
}
|
||||
if (brackets != NONE) pos = pos + 1;
|
||||
string::size_type endpos = pos + 1;
|
||||
while (((endpos+1) < filename.length()) &&
|
||||
(((brackets==NONE) && (isalnum(filename[endpos+1])
|
||||
|| filename[endpos+1]=='_'))
|
||||
while (((endpos + 1) < filename.length())
|
||||
&& (((brackets == NONE)
|
||||
&& (isalnum(filename[endpos + 1]) || filename[endpos + 1] == '_'))
|
||||
|| ((brackets == CURLY) && (filename[endpos + 1] != '}'))
|
||||
|| ((brackets == PAREN) && (filename[endpos + 1] != ')'))))
|
||||
++endpos;
|
||||
// Catch bracket errors
|
||||
if (((brackets==CURLY) && (filename[endpos+1]!='}')) ||
|
||||
((brackets==PAREN) && (filename[endpos+1]!=')'))) {
|
||||
if (((brackets == CURLY) && (filename[endpos + 1] != '}'))
|
||||
|| ((brackets == PAREN) && (filename[endpos + 1] != ')'))) {
|
||||
v3fatal("Unmatched brackets in variable substitution in file: " + filename);
|
||||
}
|
||||
string envvar = filename.substr(pos + 1, endpos - pos);
|
||||
|
|
@ -160,8 +164,11 @@ string V3Os::filenameSubstitute(const string& filename) {
|
|||
if (!envvar.empty()) envvalue = getenvStr(envvar, "");
|
||||
if (!envvalue.empty()) {
|
||||
out += envvalue;
|
||||
if (brackets==NONE) pos = endpos;
|
||||
else pos = endpos+1;
|
||||
if (brackets == NONE) {
|
||||
pos = endpos;
|
||||
} else {
|
||||
pos = endpos + 1;
|
||||
}
|
||||
} else {
|
||||
out += filename[pos]; // *pos == '$'
|
||||
}
|
||||
|
|
@ -170,7 +177,6 @@ string V3Os::filenameSubstitute(const string& filename) {
|
|||
}
|
||||
}
|
||||
return out;
|
||||
|
||||
}
|
||||
|
||||
string V3Os::filenameRealPath(const string& filename) {
|
||||
|
|
@ -243,8 +249,7 @@ vluint64_t V3Os::rand64(vluint64_t* statep) {
|
|||
// Xoroshiro128+ algorithm
|
||||
vluint64_t result = statep[0] + statep[1];
|
||||
statep[1] ^= statep[0];
|
||||
statep[0] = (((statep[0] << 55) | (statep[0] >> 9))
|
||||
^ statep[1] ^ (statep[1] << 14));
|
||||
statep[0] = (((statep[0] << 55) | (statep[0] >> 9)) ^ statep[1] ^ (statep[1] << 14));
|
||||
statep[1] = (statep[1] << 36) | (statep[1] >> 28);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -255,16 +260,16 @@ string V3Os::trueRandom(size_t size) {
|
|||
// Note: std::string.data() returns a non-const Char* from C++17 onwards.
|
||||
// For pre-C++17, this cast is OK in practice, even though it's UB.
|
||||
#if defined(_WIN32) || defined(__MINGW32__)
|
||||
NTSTATUS hr = BCryptGenRandom(NULL, reinterpret_cast<BYTE*>(data), size, BCRYPT_USE_SYSTEM_PREFERRED_RNG);
|
||||
if (!BCRYPT_SUCCESS(hr)) {
|
||||
v3fatal("Could not acquire random data.");
|
||||
}
|
||||
NTSTATUS hr = BCryptGenRandom(NULL, reinterpret_cast<BYTE*>(data), size,
|
||||
BCRYPT_USE_SYSTEM_PREFERRED_RNG);
|
||||
if (!BCRYPT_SUCCESS(hr)) { v3fatal("Could not acquire random data."); }
|
||||
#else
|
||||
std::ifstream is("/dev/urandom", std::ios::in | std::ios::binary);
|
||||
// This read uses the size of the buffer.
|
||||
// Flawfinder: ignore
|
||||
if (!is.read(data, size)) {
|
||||
v3fatal("Could not open /dev/urandom, no source of randomness. Try specifying a key instead.");
|
||||
v3fatal("Could not open /dev/urandom, no source of randomness. "
|
||||
"Try specifying a key instead.");
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
|
|
@ -280,7 +285,8 @@ uint64_t V3Os::timeUsecs() {
|
|||
|
||||
FILETIME ft; // contains number of 0.1us intervals since the beginning of 1601 UTC.
|
||||
GetSystemTimeAsFileTime(&ft);
|
||||
uint64_t us = ((static_cast<uint64_t>(ft.dwHighDateTime) << 32) + ft.dwLowDateTime + 5ull) / 10ull;
|
||||
uint64_t us
|
||||
= ((static_cast<uint64_t>(ft.dwHighDateTime) << 32) + ft.dwLowDateTime + 5ull) / 10ull;
|
||||
return us - EPOCH_DIFFERENCE_USECS;
|
||||
#else
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
|
||||
|
|
@ -303,12 +309,12 @@ uint64_t V3Os::memUsageBytes() {
|
|||
// Highly unportable. Sorry
|
||||
const char* const statmFilename = "/proc/self/statm";
|
||||
FILE* fp = fopen(statmFilename, "r");
|
||||
if (!fp) {
|
||||
return 0;
|
||||
}
|
||||
if (!fp) return 0;
|
||||
vluint64_t size, resident, share, text, lib, data, dt; // All in pages
|
||||
if (7 != fscanf(fp, "%" VL_PRI64 "u %" VL_PRI64 "u %" VL_PRI64 "u %"
|
||||
VL_PRI64 "u %" VL_PRI64 "u %" VL_PRI64 "u %" VL_PRI64 "u",
|
||||
if (7
|
||||
!= fscanf(fp,
|
||||
"%" VL_PRI64 "u %" VL_PRI64 "u %" VL_PRI64 "u %" VL_PRI64 "u %" VL_PRI64
|
||||
"u %" VL_PRI64 "u %" VL_PRI64 "u",
|
||||
&size, &resident, &share, &text, &lib, &data, &dt)) {
|
||||
fclose(fp);
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -144,9 +144,7 @@ static void process() {
|
|||
|
||||
// Coverage insertion
|
||||
// Before we do dead code elimination and inlining, or we'll lose it.
|
||||
if (v3Global.opt.coverage()) {
|
||||
V3Coverage::coverage(v3Global.rootp());
|
||||
}
|
||||
if (v3Global.opt.coverage()) V3Coverage::coverage(v3Global.rootp());
|
||||
|
||||
// Push constants, but only true constants preserving liveness
|
||||
// so V3Undriven sees variables to be eliminated, ie "if (0 && foo) ..."
|
||||
|
|
@ -262,9 +260,7 @@ static void process() {
|
|||
// Push constants across variables and remove redundant assignments
|
||||
V3Const::constifyAll(v3Global.rootp());
|
||||
|
||||
if (v3Global.opt.oLife()) {
|
||||
V3Life::lifeAll(v3Global.rootp());
|
||||
}
|
||||
if (v3Global.opt.oLife()) V3Life::lifeAll(v3Global.rootp());
|
||||
|
||||
// Make large low-fanin logic blocks into lookup tables
|
||||
// This should probably be done much later, once we have common logic elimination.
|
||||
|
|
@ -282,15 +278,11 @@ static void process() {
|
|||
V3Active::activeAll(v3Global.rootp());
|
||||
|
||||
// Split single ALWAYS blocks into multiple blocks for better ordering chances
|
||||
if (v3Global.opt.oSplit()) {
|
||||
V3Split::splitAlwaysAll(v3Global.rootp());
|
||||
}
|
||||
if (v3Global.opt.oSplit()) V3Split::splitAlwaysAll(v3Global.rootp());
|
||||
V3SplitAs::splitAsAll(v3Global.rootp());
|
||||
|
||||
// Create tracing sample points, before we start eliminating signals
|
||||
if (v3Global.opt.trace()) {
|
||||
V3TraceDecl::traceDeclAll(v3Global.rootp());
|
||||
}
|
||||
if (v3Global.opt.trace()) V3TraceDecl::traceDeclAll(v3Global.rootp());
|
||||
|
||||
// Gate-based logic elimination; eliminate signals and push constant across cell boundaries
|
||||
// Instant propagation makes lots-o-constant reduction possibilities.
|
||||
|
|
@ -298,13 +290,12 @@ static void process() {
|
|||
V3Gate::gateAll(v3Global.rootp());
|
||||
// V3Gate calls constant propagation itself.
|
||||
} else {
|
||||
v3info("Command Line disabled gate optimization with -Og/-O0. This may cause ordering problems.");
|
||||
v3info("Command Line disabled gate optimization with -Og/-O0. "
|
||||
"This may cause ordering problems.");
|
||||
}
|
||||
|
||||
// Combine COVERINCs with duplicate terms
|
||||
if (v3Global.opt.coverage()) {
|
||||
V3CoverageJoin::coverageJoin(v3Global.rootp());
|
||||
}
|
||||
if (v3Global.opt.coverage()) V3CoverageJoin::coverageJoin(v3Global.rootp());
|
||||
|
||||
// Remove unused vars
|
||||
V3Const::constifyAll(v3Global.rootp());
|
||||
|
|
@ -318,9 +309,7 @@ static void process() {
|
|||
}
|
||||
|
||||
// Reorder assignments in pipelined blocks
|
||||
if (v3Global.opt.oReorder()) {
|
||||
V3Split::splitReorderAll(v3Global.rootp());
|
||||
}
|
||||
if (v3Global.opt.oReorder()) V3Split::splitReorderAll(v3Global.rootp());
|
||||
|
||||
// Create delayed assignments
|
||||
// This creates lots of duplicate ACTIVES so ActiveTop needs to be after this step
|
||||
|
|
@ -349,9 +338,7 @@ static void process() {
|
|||
V3Const::constifyAll(v3Global.rootp());
|
||||
V3Life::lifeAll(v3Global.rootp());
|
||||
}
|
||||
if (v3Global.opt.oLifePost()) {
|
||||
V3LifePost::lifepostAll(v3Global.rootp());
|
||||
}
|
||||
if (v3Global.opt.oLifePost()) V3LifePost::lifepostAll(v3Global.rootp());
|
||||
|
||||
// Remove unused vars
|
||||
V3Const::constifyAll(v3Global.rootp());
|
||||
|
|
@ -364,9 +351,7 @@ static void process() {
|
|||
// Note past this point, we presume traced variables won't move between CFuncs
|
||||
// (It's OK if untraced temporaries move around, or vars
|
||||
// "effectively" activate the same way.)
|
||||
if (v3Global.opt.trace()) {
|
||||
V3Trace::traceAll(v3Global.rootp());
|
||||
}
|
||||
if (v3Global.opt.trace()) V3Trace::traceAll(v3Global.rootp());
|
||||
|
||||
if (v3Global.opt.stats()) V3Stats::statsStageAll(v3Global.rootp(), "Scoped");
|
||||
|
||||
|
|
@ -383,14 +368,10 @@ static void process() {
|
|||
}
|
||||
|
||||
// Move BLOCKTEMPS from class to local variables
|
||||
if (v3Global.opt.oLocalize()) {
|
||||
V3Localize::localizeAll(v3Global.rootp());
|
||||
}
|
||||
if (v3Global.opt.oLocalize()) V3Localize::localizeAll(v3Global.rootp());
|
||||
|
||||
// Icache packing; combine common code in each module's functions into subroutines
|
||||
if (v3Global.opt.oCombine()) {
|
||||
V3Combine::combineAll(v3Global.rootp());
|
||||
}
|
||||
if (v3Global.opt.oCombine()) V3Combine::combineAll(v3Global.rootp());
|
||||
}
|
||||
|
||||
V3Error::abortIfErrors();
|
||||
|
|
@ -414,38 +395,30 @@ static void process() {
|
|||
}
|
||||
|
||||
// Expand macros and wide operators into C++ primitives
|
||||
if (!v3Global.opt.lintOnly()
|
||||
&& !v3Global.opt.xmlOnly()
|
||||
&& v3Global.opt.oExpand()) {
|
||||
if (!v3Global.opt.lintOnly() && !v3Global.opt.xmlOnly() && v3Global.opt.oExpand()) {
|
||||
V3Expand::expandAll(v3Global.rootp());
|
||||
}
|
||||
|
||||
// Propagate constants across WORDSEL arrayed temporaries
|
||||
if (!v3Global.opt.xmlOnly()
|
||||
&& v3Global.opt.oSubst()) {
|
||||
if (!v3Global.opt.xmlOnly() && v3Global.opt.oSubst()) {
|
||||
// Constant folding of expanded stuff
|
||||
V3Const::constifyCpp(v3Global.rootp());
|
||||
V3Subst::substituteAll(v3Global.rootp());
|
||||
}
|
||||
|
||||
if (!v3Global.opt.xmlOnly()
|
||||
&& v3Global.opt.oSubstConst()) {
|
||||
if (!v3Global.opt.xmlOnly() && v3Global.opt.oSubstConst()) {
|
||||
// Constant folding of substitutions
|
||||
V3Const::constifyCpp(v3Global.rootp());
|
||||
|
||||
V3Dead::deadifyAll(v3Global.rootp());
|
||||
}
|
||||
|
||||
if (!v3Global.opt.lintOnly()
|
||||
&& !v3Global.opt.xmlOnly()
|
||||
&& v3Global.opt.oReloop()) {
|
||||
if (!v3Global.opt.lintOnly() && !v3Global.opt.xmlOnly() && v3Global.opt.oReloop()) {
|
||||
// Reform loops to reduce code size
|
||||
// Must be after all Sel/array index based optimizations
|
||||
V3Reloop::reloopAll(v3Global.rootp());
|
||||
}
|
||||
|
||||
if (!v3Global.opt.lintOnly()
|
||||
&& !v3Global.opt.xmlOnly()) {
|
||||
if (!v3Global.opt.lintOnly() && !v3Global.opt.xmlOnly()) {
|
||||
// Fix very deep expressions
|
||||
// Mark evaluation functions as member functions, if needed.
|
||||
V3Depth::depthAll(v3Global.rootp());
|
||||
|
|
@ -459,15 +432,12 @@ static void process() {
|
|||
}
|
||||
|
||||
V3Error::abortIfErrors();
|
||||
if (!v3Global.opt.lintOnly()
|
||||
&& !v3Global.opt.xmlOnly()) {
|
||||
if (!v3Global.opt.lintOnly() && !v3Global.opt.xmlOnly()) { //
|
||||
V3CCtors::cctorsAll();
|
||||
}
|
||||
|
||||
// Output the text
|
||||
if (!v3Global.opt.lintOnly()
|
||||
&& !v3Global.opt.xmlOnly()
|
||||
&& !v3Global.opt.dpiHdrOnly()) {
|
||||
if (!v3Global.opt.lintOnly() && !v3Global.opt.xmlOnly() && !v3Global.opt.dpiHdrOnly()) {
|
||||
// Create AstCUse to determine what class forward declarations/#includes needed in C
|
||||
// Must be before V3EmitC
|
||||
V3CUse::cUseAll(v3Global.rootp());
|
||||
|
|
@ -479,8 +449,7 @@ static void process() {
|
|||
} else if (v3Global.opt.dpiHdrOnly()) {
|
||||
V3EmitC::emitcSyms(true);
|
||||
}
|
||||
if (!v3Global.opt.xmlOnly()
|
||||
&& v3Global.opt.mtasks()) {
|
||||
if (!v3Global.opt.xmlOnly() && v3Global.opt.mtasks()) {
|
||||
// Finalize our MTask cost estimates and pack the mtasks into
|
||||
// threads. Must happen pre-EmitC which relies on the packing
|
||||
// order. Must happen post-V3LifePost which changes the relative
|
||||
|
|
@ -493,8 +462,7 @@ static void process() {
|
|||
}
|
||||
if (v3Global.opt.xmlOnly()
|
||||
// Check XML when debugging to make sure no missing node types
|
||||
|| (v3Global.opt.debugCheck() && !v3Global.opt.lintOnly()
|
||||
&& !v3Global.opt.dpiHdrOnly())) {
|
||||
|| (v3Global.opt.debugCheck() && !v3Global.opt.lintOnly() && !v3Global.opt.dpiHdrOnly())) {
|
||||
V3EmitXml::emitxml();
|
||||
}
|
||||
|
||||
|
|
@ -511,14 +479,12 @@ static void process() {
|
|||
V3Stats::statsReport();
|
||||
}
|
||||
|
||||
if (!v3Global.opt.lintOnly()
|
||||
&& !v3Global.opt.xmlOnly()
|
||||
&& !v3Global.opt.dpiHdrOnly()) {
|
||||
if (!v3Global.opt.lintOnly() && !v3Global.opt.xmlOnly() && !v3Global.opt.dpiHdrOnly()) {
|
||||
// Makefile must be after all other emitters
|
||||
if (v3Global.opt.cmake()) {
|
||||
if (v3Global.opt.cmake()) { //
|
||||
V3EmitCMake::emit();
|
||||
}
|
||||
if (v3Global.opt.gmake()) {
|
||||
if (v3Global.opt.gmake()) { //
|
||||
V3EmitMk::emitmk();
|
||||
}
|
||||
}
|
||||
|
|
@ -546,8 +512,7 @@ int main(int argc, char** argv, char** env) {
|
|||
// Command option parsing
|
||||
v3Global.opt.bin(argv[0]);
|
||||
string argString = V3Options::argString(argc - 1, argv + 1);
|
||||
v3Global.opt.parseOpts(new FileLine(FileLine::commandLineFilename()),
|
||||
argc-1, argv+1);
|
||||
v3Global.opt.parseOpts(new FileLine(FileLine::commandLineFilename()), argc - 1, argv + 1);
|
||||
|
||||
// Validate settings (aka Boost.Program_options)
|
||||
v3Global.opt.notify();
|
||||
|
|
@ -558,7 +523,8 @@ int main(int argc, char** argv, char** env) {
|
|||
V3File::addSrcDepend(v3Global.opt.bin());
|
||||
if (v3Global.opt.skipIdentical().isTrue()
|
||||
&& V3File::checkTimes(v3Global.opt.makeDir() + "/" + v3Global.opt.prefix()
|
||||
+ "__verFiles.dat", argString)) {
|
||||
+ "__verFiles.dat",
|
||||
argString)) {
|
||||
UINFO(1, "--skip-identical: No change to any source files, exiting\n");
|
||||
exit(0);
|
||||
}
|
||||
|
|
@ -591,7 +557,7 @@ int main(int argc, char** argv, char** env) {
|
|||
v3Global.readFiles();
|
||||
|
||||
// Link, etc, if needed
|
||||
if (!v3Global.opt.preprocOnly()) {
|
||||
if (!v3Global.opt.preprocOnly()) { //
|
||||
process();
|
||||
}
|
||||
|
||||
|
|
@ -603,7 +569,8 @@ int main(int argc, char** argv, char** env) {
|
|||
V3File::writeDepend(v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + "__ver.d");
|
||||
}
|
||||
if (v3Global.opt.protectIds()) {
|
||||
VIdProtect::writeMapFile(v3Global.opt.makeDir()+"/"+v3Global.opt.prefix()+"__idmap.xml");
|
||||
VIdProtect::writeMapFile(v3Global.opt.makeDir() + "/" + v3Global.opt.prefix()
|
||||
+ "__idmap.xml");
|
||||
}
|
||||
if (v3Global.opt.skipIdentical().isTrue() || v3Global.opt.makeDepend().isTrue()) {
|
||||
V3File::writeTimes(v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + "__verFiles.dat",
|
||||
|
|
|
|||
Loading…
Reference in New Issue