forked from github/verilator
Add -P to suppress `line and blanks with preprocessing, bug781.
This commit is contained in:
parent
a1c1ff9981
commit
0eb5a0a539
2
Changes
2
Changes
@ -7,6 +7,8 @@ indicates the contributor was also the author of the fix; Thanks!
|
||||
|
||||
*** Using command line -Wno-{WARNING} now overrides file-local lint_on.
|
||||
|
||||
*** Add -P to suppress `line and blanks with preprocessing, bug781. [Derek Lockhart]
|
||||
|
||||
*** Support SV 2012 package import before port list.
|
||||
|
||||
**** Change SYMRSVDWORD to print as warning rather than error.
|
||||
|
@ -303,6 +303,7 @@ descriptions in the next sections for more information.
|
||||
--output-split <bytes> Split .cpp files into pieces
|
||||
--output-split-cfuncs <statements> Split .cpp functions
|
||||
--output-split-ctrace <statements> Split tracing functions
|
||||
-P Disable line numbers and blanks with -E
|
||||
--pins-bv <bits> Specify types for top level ports
|
||||
--pins-sc-uint Specify types for top level ports
|
||||
--pins-sc-biguint Specify types for top level ports
|
||||
@ -830,6 +831,11 @@ function.
|
||||
Enables splitting trace functions in the output .cpp/.sp files into
|
||||
multiple functions. Defaults to same setting as --output-split-cfuncs.
|
||||
|
||||
=item -P
|
||||
|
||||
With -E, disable generation of `line markers and blank lines, similar to
|
||||
GCC -P flag.
|
||||
|
||||
=item --pins64
|
||||
|
||||
Backward compatible alias for "--pins-bv 65". Note that's a 65, not a 64.
|
||||
|
@ -712,6 +712,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
|
||||
else if ( !strcmp (sw, "-E") ) { m_preprocOnly = true; }
|
||||
else if ( onoff (sw, "-MMD", flag/*ref*/) ) { m_makeDepend = flag; }
|
||||
else if ( onoff (sw, "-MP", flag/*ref*/) ) { m_makePhony = flag; }
|
||||
else if ( !strcmp (sw, "-P") ) { m_preprocNoLine = true; }
|
||||
else if ( onoff (sw, "-assert", flag/*ref*/) ) { m_assert = flag; }
|
||||
else if ( onoff (sw, "-autoflush", flag/*ref*/) ) { m_autoflush = flag; }
|
||||
else if ( onoff (sw, "-bbox-sys", flag/*ref*/) ) { m_bboxSys = flag; }
|
||||
@ -1212,6 +1213,7 @@ V3Options::V3Options() {
|
||||
m_pinsBv = 65;
|
||||
m_profileCFuncs = false;
|
||||
m_preprocOnly = false;
|
||||
m_preprocNoLine = false;
|
||||
m_psl = false;
|
||||
m_public = false;
|
||||
m_savable = false;
|
||||
|
@ -59,6 +59,7 @@ class V3Options {
|
||||
bool m_preprocOnly; // main switch: -E
|
||||
bool m_makeDepend; // main switch: -MMD
|
||||
bool m_makePhony; // main switch: -MP
|
||||
bool m_preprocNoLine;// main switch: -P
|
||||
bool m_assert; // main switch: --assert
|
||||
bool m_autoflush; // main switch: --autoflush
|
||||
bool m_bboxSys; // main switch: --bbox-sys
|
||||
@ -192,6 +193,7 @@ class V3Options {
|
||||
bool preprocOnly() const { return m_preprocOnly; }
|
||||
bool makeDepend() const { return m_makeDepend; }
|
||||
bool makePhony() const { return m_makePhony; }
|
||||
bool preprocNoLine() const { return m_preprocNoLine; }
|
||||
bool underlineZero() const { return m_underlineZero; }
|
||||
string bin() const { return m_bin; }
|
||||
string flags() const { return m_flags; }
|
||||
|
@ -123,6 +123,7 @@ void V3ParseImp::parseFile(FileLine* fileline, const string& modfilename, bool i
|
||||
string vppfilename = v3Global.opt.makeDir()+"/"+v3Global.opt.prefix()+"_"+modname+".vpp";
|
||||
ofstream* ofp = NULL;
|
||||
ostream* osp;
|
||||
bool noblanks = v3Global.opt.preprocOnly() && v3Global.opt.preprocNoLine();
|
||||
if (v3Global.opt.preprocOnly()) {
|
||||
osp = &cout;
|
||||
} else {
|
||||
@ -133,6 +134,13 @@ void V3ParseImp::parseFile(FileLine* fileline, const string& modfilename, bool i
|
||||
return;
|
||||
} else {
|
||||
for (deque<string>::iterator it = m_ppBuffers.begin(); it!=m_ppBuffers.end(); ++it) {
|
||||
if (noblanks) {
|
||||
bool blank = true;
|
||||
for (string::iterator its = it->begin(); its != it->end(); ++its) {
|
||||
if (!isspace(*its) && *its!='\n') { blank=false; break; }
|
||||
}
|
||||
if (blank) continue;
|
||||
}
|
||||
*osp << *it;
|
||||
}
|
||||
if (ofp) {
|
||||
|
@ -71,7 +71,9 @@ public:
|
||||
// These options control how the parsing proceeds
|
||||
static int keepComments() { return 2; } // Return comments, 0=no, 1=yes, 2=callback
|
||||
static bool keepWhitespace() { return false; }
|
||||
static bool lineDirectives() { return true; } // Insert `line directives
|
||||
static bool lineDirectives() { // Insert `line directives
|
||||
return !(v3Global.opt.preprocOnly() && v3Global.opt.preprocNoLine());
|
||||
}
|
||||
static bool pedantic() { return false; } // Obey standard; Don't substitute `error
|
||||
static bool optPsl();
|
||||
|
||||
|
5
test_regress/t/t_preproc_noline.out
Normal file
5
test_regress/t/t_preproc_noline.out
Normal file
@ -0,0 +1,5 @@
|
||||
Hello in t_preproc_psl.v
|
||||
yes
|
||||
Multi text
|
||||
multiline line
|
||||
Line: 20
|
24
test_regress/t/t_preproc_noline.pl
Executable file
24
test_regress/t/t_preproc_noline.pl
Executable file
@ -0,0 +1,24 @@
|
||||
#!/usr/bin/perl
|
||||
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||
#
|
||||
# Copyright 2003-2009 by Wilson Snyder. This program is free software; you can
|
||||
# redistribute it and/or modify it under the terms of either the GNU
|
||||
# Lesser General Public License Version 3 or the Perl Artistic License
|
||||
# Version 2.0.
|
||||
|
||||
$Self->{vlt} or $Self->skip("Verilator only test");
|
||||
|
||||
my $stdout_filename = "$Self->{obj_dir}/$Self->{name}__test.vpp";
|
||||
|
||||
top_filename("t/t_preproc_noline.v");
|
||||
|
||||
compile (
|
||||
verilator_flags2 => ['-E -P'],
|
||||
verilator_make_gcc=>0,
|
||||
stdout_filename => $stdout_filename,
|
||||
);
|
||||
|
||||
ok(files_identical($stdout_filename, "t/$Self->{name}.out"));
|
||||
|
||||
1;
|
20
test_regress/t/t_preproc_noline.v
Normal file
20
test_regress/t/t_preproc_noline.v
Normal file
@ -0,0 +1,20 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2014 by Wilson Snyder.
|
||||
|
||||
`define CHECK text \
|
||||
multiline
|
||||
|
||||
Hello in t_preproc_psl.v
|
||||
|
||||
`ifdef NEVER
|
||||
not
|
||||
`else
|
||||
yes
|
||||
`endif
|
||||
|
||||
Multi `CHECK line
|
||||
|
||||
// Did we end up right?
|
||||
Line: `__LINE__
|
Loading…
Reference in New Issue
Block a user