From 779cf9248a71e318143fc8a0a29dd51082ebcd5a Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Mon, 11 Nov 2024 22:22:06 -0500 Subject: [PATCH] Cleanup/standardize configuration file string handling --- docs/guide/exe_verilator.rst | 17 +++-- src/verilog.y | 138 ++++++++++++++++++++++------------- 2 files changed, 96 insertions(+), 59 deletions(-) diff --git a/docs/guide/exe_verilator.rst b/docs/guide/exe_verilator.rst index 4108f76e4..59061613c 100644 --- a/docs/guide/exe_verilator.rst +++ b/docs/guide/exe_verilator.rst @@ -2088,7 +2088,7 @@ The grammar of configuration commands is as follows: .. option:: lint_off [-rule ] [-file "" [-lines [ - ]]] -.. option:: lint_off [-rule ] [-file ""] [-match ""] +.. option:: lint_off [-rule ] [-file ""] [-match ""] Enable/disables the specified lint warning, in the specified filename (or wildcard with '\*' or '?', or all files if omitted) and range of @@ -2097,17 +2097,18 @@ The grammar of configuration commands is as follows: With lint_off using "\*" will override any lint_on directives in the source, i.e. the warning will still not be printed. - If the -rule is omitted, all lint warnings (see list in + If the :code:`-rule` is omitted, all lint warnings (see list in :vlopt:`-Wno-lint`) are enabled/disabled. This will override all later lint warning enables for the specified region. - If -match is set, the linter warnings are matched against this - (wildcard) string and are waived in case they match, provided with the - rule and file also match. + If :code:`-match` is provided, the linter warnings are matched against + the given wildcard (with '\*' or '?'), and are waived in case they + match, provided the :code:`-rule` and :code:`-file` + also match. The wildcard is compared across the entire multi-line + message; see :vlopt:`--waiver-multiline`. - In previous versions -rule was named -msg. The latter is deprecated, but - still works with a deprecation info; it may be removed in future - versions. + Before version 4.026, :code:`-rule` was named :code:`-msg`, and + :code:`-msg` remained a deprecated alias until Version 5.000. .. option:: public [-module ""] [-task/-function ""] -var "" diff --git a/src/verilog.y b/src/verilog.y index 9854644fd..3819a316a 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -7559,77 +7559,77 @@ colon: // Generic colon that isn't making a label (e.g. // VLT Files vltItem: - + // // TODO support arbitrary order of arguments vltOffFront { V3Config::addIgnore($1, false, "*", 0, 0); } - | vltOffFront yVLT_D_FILE yaSTRING - { V3Config::addIgnore($1, false, *$3, 0, 0); } - | vltOffFront yVLT_D_FILE yaSTRING yVLT_D_LINES yaINTNUM - { V3Config::addIgnore($1, false, *$3, $5->toUInt(), $5->toUInt() + 1); } - | vltOffFront yVLT_D_FILE yaSTRING yVLT_D_LINES yaINTNUM '-' yaINTNUM - { V3Config::addIgnore($1, false, *$3, $5->toUInt(), $7->toUInt() + 1); } - | vltOffFront yVLT_D_SCOPE yaSTRING - { if ($1 != V3ErrorCode::I_TRACING) { - $1->v3error("Argument -scope only supported for tracing_on/off"); - } else { - V3Config::addScopeTraceOn(false, *$3, 0); - }} - | vltOffFront yVLT_D_SCOPE yaSTRING yVLT_D_LEVELS yaINTNUM - { if ($1 != V3ErrorCode::I_TRACING) { - $1->v3error("Argument -scope only supported for tracing_on/off_off"); - } else { - V3Config::addScopeTraceOn(false, *$3, $5->toUInt()); - }} - | vltOffFront yVLT_D_FILE yaSTRING yVLT_D_MATCH yaSTRING + | vltOffFront vltDFile + { V3Config::addIgnore($1, false, *$2, 0, 0); } + | vltOffFront vltDFile yVLT_D_LINES yaINTNUM + { V3Config::addIgnore($1, false, *$2, $4->toUInt(), $4->toUInt() + 1); } + | vltOffFront vltDFile yVLT_D_LINES yaINTNUM '-' yaINTNUM + { V3Config::addIgnore($1, false, *$2, $4->toUInt(), $6->toUInt() + 1); } + | vltOffFront vltDFile vltDMatch { if (($1 == V3ErrorCode::I_COVERAGE) || ($1 == V3ErrorCode::I_TRACING)) { $1->v3error("Argument -match only supported for lint_off"); } else { - V3Config::addIgnoreMatch($1, *$3, *$5); + V3Config::addIgnoreMatch($1, *$2, *$3); }} - | vltOnFront - { V3Config::addIgnore($1, true, "*", 0, 0); } - | vltOnFront yVLT_D_FILE yaSTRING - { V3Config::addIgnore($1, true, *$3, 0, 0); } - | vltOnFront yVLT_D_FILE yaSTRING yVLT_D_LINES yaINTNUM - { V3Config::addIgnore($1, true, *$3, $5->toUInt(), $5->toUInt() + 1); } - | vltOnFront yVLT_D_FILE yaSTRING yVLT_D_LINES yaINTNUM '-' yaINTNUM - { V3Config::addIgnore($1, true, *$3, $5->toUInt(), $7->toUInt() + 1); } - | vltOnFront yVLT_D_SCOPE yaSTRING + | vltOffFront vltDScope { if ($1 != V3ErrorCode::I_TRACING) { $1->v3error("Argument -scope only supported for tracing_on/off"); } else { - V3Config::addScopeTraceOn(true, *$3, 0); + V3Config::addScopeTraceOn(false, *$2, 0); }} - | vltOnFront yVLT_D_SCOPE yaSTRING yVLT_D_LEVELS yaINTNUM + | vltOffFront vltDScope vltDLevels { if ($1 != V3ErrorCode::I_TRACING) { $1->v3error("Argument -scope only supported for tracing_on/off_off"); } else { - V3Config::addScopeTraceOn(true, *$3, $5->toUInt()); + V3Config::addScopeTraceOn(false, *$2, $3->toUInt()); + }} + | vltOnFront + { V3Config::addIgnore($1, true, "*", 0, 0); } + | vltOnFront vltDFile + { V3Config::addIgnore($1, true, *$2, 0, 0); } + | vltOnFront vltDFile yVLT_D_LINES yaINTNUM + { V3Config::addIgnore($1, true, *$2, $4->toUInt(), $4->toUInt() + 1); } + | vltOnFront vltDFile yVLT_D_LINES yaINTNUM '-' yaINTNUM + { V3Config::addIgnore($1, true, *$2, $4->toUInt(), $6->toUInt() + 1); } + | vltOnFront vltDScope + { if ($1 != V3ErrorCode::I_TRACING) { + $1->v3error("Argument -scope only supported for tracing_on/off"); + } else { + V3Config::addScopeTraceOn(true, *$2, 0); + }} + | vltOnFront vltDScope vltDLevels + { if ($1 != V3ErrorCode::I_TRACING) { + $1->v3error("Argument -scope only supported for tracing_on/off_off"); + } else { + V3Config::addScopeTraceOn(true, *$2, $3->toUInt()); }} | vltVarAttrFront vltDModuleE vltDFTaskE vltVarAttrVarE attr_event_controlE { V3Config::addVarAttr($1, *$2, *$3, *$4, $1, $5); } | vltInlineFront vltDModuleE vltDFTaskE { V3Config::addInline($1, *$2, *$3, $1); } - | yVLT_COVERAGE_BLOCK_OFF yVLT_D_FILE yaSTRING - { V3Config::addCoverageBlockOff(*$3, 0); } - | yVLT_COVERAGE_BLOCK_OFF yVLT_D_FILE yaSTRING yVLT_D_LINES yaINTNUM - { V3Config::addCoverageBlockOff(*$3, $5->toUInt()); } - | yVLT_COVERAGE_BLOCK_OFF yVLT_D_MODULE yaSTRING yVLT_D_BLOCK yaSTRING - { V3Config::addCoverageBlockOff(*$3, *$5); } - | yVLT_FULL_CASE yVLT_D_FILE yaSTRING - { V3Config::addCaseFull(*$3, 0); } - | yVLT_FULL_CASE yVLT_D_FILE yaSTRING yVLT_D_LINES yaINTNUM - { V3Config::addCaseFull(*$3, $5->toUInt()); } + | yVLT_COVERAGE_BLOCK_OFF vltDFile + { V3Config::addCoverageBlockOff(*$2, 0); } + | yVLT_COVERAGE_BLOCK_OFF vltDFile yVLT_D_LINES yaINTNUM + { V3Config::addCoverageBlockOff(*$2, $4->toUInt()); } + | yVLT_COVERAGE_BLOCK_OFF vltDModule vltDBlock + { V3Config::addCoverageBlockOff(*$2, *$3); } + | yVLT_FULL_CASE vltDFile + { V3Config::addCaseFull(*$2, 0); } + | yVLT_FULL_CASE vltDFile yVLT_D_LINES yaINTNUM + { V3Config::addCaseFull(*$2, $4->toUInt()); } | yVLT_HIER_BLOCK vltDModuleE { V3Config::addModulePragma(*$2, VPragmaType::HIER_BLOCK); } | yVLT_HIER_PARAMS vltDModuleE { V3Config::addModulePragma(*$2, VPragmaType::HIER_PARAMS); } - | yVLT_PARALLEL_CASE yVLT_D_FILE yaSTRING - { V3Config::addCaseParallel(*$3, 0); } - | yVLT_PARALLEL_CASE yVLT_D_FILE yaSTRING yVLT_D_LINES yaINTNUM - { V3Config::addCaseParallel(*$3, $5->toUInt()); } - | yVLT_PROFILE_DATA yVLT_D_MODEL yaSTRING yVLT_D_MTASK yaSTRING yVLT_D_COST yaINTNUM - { V3Config::addProfileData($1, *$3, *$5, $7->toUQuad()); } + | yVLT_PARALLEL_CASE vltDFile + { V3Config::addCaseParallel(*$2, 0); } + | yVLT_PARALLEL_CASE vltDFile yVLT_D_LINES yaINTNUM + { V3Config::addCaseParallel(*$2, $4->toUInt()); } + | yVLT_PROFILE_DATA vltDModel vltDMtask vltDCost + { V3Config::addProfileData($1, *$2, *$3, $4->toUQuad()); } ; vltOffFront: @@ -7656,9 +7656,45 @@ vltOnFront: if ($$ == V3ErrorCode::EC_ERROR) { $1->v3error("Unknown error code: '" << *$3 << "'"); } } ; -vltDModuleE: +vltDBlock: // --block + yVLT_D_BLOCK str { $$ = $2; } + ; + +vltDCost: // --cost + yVLT_D_COST yaINTNUM { $$ = $2; } + ; + +vltDFile: // --file + yVLT_D_FILE str { $$ = $2; } + ; + +vltDLevels: // --levels + yVLT_D_LEVELS yaINTNUM { $$ = $2; } + ; + +vltDMatch: // --match + yVLT_D_MATCH str { $$ = $2; } + ; + +vltDModel: // --model + yVLT_D_MODEL str { $$ = $2; } + ; + +vltDMtask: // --mtask + yVLT_D_MTASK str { $$ = $2; } + ; + +vltDModule: // --module + yVLT_D_MODULE str { $$ = $2; } + ; + +vltDModuleE: // [--module ] /* empty */ { static string unit = "__024unit"; $$ = &unit; } - | yVLT_D_MODULE str { $$ = $2; } + | vltDModule { $$ = $1; } + ; + +vltDScope: // --scope + yVLT_D_SCOPE str { $$ = $2; } ; vltDFTaskE: