Add -output-groups to build with concatenated .cpp files (#5257)

Signed-off-by: Bartłomiej Chmiel <[email protected]>
Signed-off-by: Ryszard Rozak <[email protected]>
Signed-off-by: Arkadiusz Kozdra <[email protected]>
Co-authored-by: Mariusz Glebocki <[email protected]>
Co-authored-by: Arkadiusz Kozdra <[email protected]>
Co-authored-by: Bartłomiej Chmiel <[email protected]>
Co-authored-by: Wilson Snyder <[email protected]>
Co-authored-by: Ryszard Rozak <[email protected]>
This commit is contained in:
Mariusz Glebocki
2024-09-30 21:42:36 -04:00
committed by GitHub
co-authored by Mariusz Glebocki Arkadiusz Kozdra Bartłomiej Chmiel Wilson Snyder Ryszard Rozak
parent 1a31aa5d62
commit 0547108e3f
19 changed files with 840 additions and 78 deletions
+18 -16
View File
@@ -53,11 +53,12 @@ class EmitCModel final : public EmitCFunc {
}
void emitHeader(AstNodeModule* modp) {
UASSERT(!m_ofp, "Output file should not be open");
UASSERT(!ofp(), "Output file should not be open");
const string filename = v3Global.opt.makeDir() + "/" + topClassName() + ".h";
newCFile(filename, /* slow: */ false, /* source: */ false);
m_ofp = v3Global.opt.systemC() ? new V3OutScFile{filename} : new V3OutCFile{filename};
setOutputFile(v3Global.opt.systemC() ? new V3OutScFile{filename}
: new V3OutCFile{filename},
newCFile(filename, /* slow: */ false, /* source: */ false));
ofp()->putsHeader();
puts("// DESCRIPTION: Verilator output: Primary model header\n");
@@ -269,7 +270,7 @@ class EmitCModel final : public EmitCFunc {
ofp()->putsEndGuard();
VL_DO_CLEAR(delete m_ofp, m_ofp = nullptr);
closeOutputFile();
}
void emitConstructorImplementation(AstNodeModule* modp) {
@@ -612,11 +613,12 @@ class EmitCModel final : public EmitCFunc {
}
void emitImplementation(AstNodeModule* modp) {
UASSERT(!m_ofp, "Output file should not be open");
UASSERT(!ofp(), "Output file should not be open");
const string filename = v3Global.opt.makeDir() + "/" + topClassName() + ".cpp";
newCFile(filename, /* slow: */ false, /* source: */ true);
m_ofp = v3Global.opt.systemC() ? new V3OutScFile{filename} : new V3OutCFile{filename};
setOutputFile(v3Global.opt.systemC() ? new V3OutScFile{filename}
: new V3OutCFile{filename},
newCFile(filename, /* slow: */ false, /* source: */ true));
ofp()->putsHeader();
puts("// DESCRIPTION: Verilator output: "
@@ -635,11 +637,11 @@ class EmitCModel final : public EmitCFunc {
if (v3Global.opt.trace()) emitTraceMethods(modp);
if (v3Global.opt.savable()) emitSerializationFunctions();
VL_DO_CLEAR(delete m_ofp, m_ofp = nullptr);
closeOutputFile();
}
void emitDpiExportDispatchers(AstNodeModule* modp) {
UASSERT(!m_ofp, "Output file should not be open");
UASSERT(!ofp(), "Output file should not be open");
// Emit DPI Export dispatchers
for (AstNode* nodep = modp->stmtsp(); nodep; nodep = nodep->nextp()) {
@@ -650,19 +652,19 @@ class EmitCModel final : public EmitCFunc {
// Splitting file, so using parallel build.
v3Global.useParallelBuild(true);
// Close old file
VL_DO_CLEAR(delete m_ofp, m_ofp = nullptr);
closeOutputFile();
}
if (!m_ofp) {
if (!ofp()) {
string filename = v3Global.opt.makeDir() + "/" + topClassName() + "__Dpi_Export";
filename = m_uniqueNames.get(filename);
filename += ".cpp";
newCFile(filename, /* slow: */ false, /* source: */ true);
m_ofp = v3Global.opt.systemC() ? new V3OutScFile{filename}
: new V3OutCFile{filename};
setOutputFile(v3Global.opt.systemC() ? new V3OutScFile{filename}
: new V3OutCFile{filename},
newCFile(filename, /* slow: */ false, /* source: */ true));
splitSizeReset(); // Reset file size tracking
m_lazyDecls.reset();
m_ofp->putsHeader();
ofp()->putsHeader();
puts(
"// DESCRIPTION: Verilator output: Implementation of DPI export functions.\n");
puts("//\n");
@@ -675,7 +677,7 @@ class EmitCModel final : public EmitCFunc {
iterateConst(funcp);
}
if (m_ofp) VL_DO_CLEAR(delete m_ofp, m_ofp = nullptr);
if (ofp()) closeOutputFile();
}
void main(AstNodeModule* modp) {