Skip to content

tcl: brace every remaining expr, drop unbraced-expr from the tclint ignore - #4916

Draft
oharboe wants to merge 2 commits into
The-OpenROAD-Project:masterfrom
oharboe:tcl-braced-expr-all
Draft

oharboe wants to merge 2 commits into
The-OpenROAD-Project:masterfrom
oharboe:tcl-braced-expr-all

Conversation

@oharboe

@oharboe oharboe commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Independent of #4914; overlaps #4913. #4914 braces the nine expr sites in flow/scripts and flow/platforms and adds the contract line "Every expr is braced"; this PR braces the rest. unbraced-expr stays in the tclint.toml ignore here, so this PR is green on its own; removing it is a one-line follow-up once both have landed. #4913 (eq/ne) touches the same lines in flow/util/cell-veneer/lefdef.tcl and wrap_stdcells.tcl; whichever lands second is rebased.

What

255 unbraced expr calls in 60 files, found by tclint 0.9.0 with the ignore removed:

  • 52 constraint.sdc files (plus ariane.sdc, bsg_chip.sdc, mempool_group.sdc, microwatt): set_input_delay [expr $clk_period * $clk_io_pct] ... becomes [expr { $clk_period * $clk_io_pct }].
  • flow/util/cell-veneer/{lefdef,wrap_stdcells,wrap}.tcl.
  • tclint.toml is unchanged: "unbraced-expr" stays ignored until tcl: brace every expr in flow/scripts and platforms #4914 and this PR have both landed.

Mechanical otherwise. Two things beyond bracing: a nested [expr round(...)] inside an already braced expr is plain round(...) (tclint flags it as redundant), and a handful of lines went over the 100 column limit and are wrapped. tclfmt 0.9.0 is applied.

Why

  • Easier to read: one idiom, so nobody has to ask which expr is the safe kind.
  • Hard, early failures: a braced expr does not substitute twice, so a value with an operator or a space in it fails at the expr instead of quietly computing something else.
  • Fewer squirrels for AI to chase: an unbraced expr in a constraint file is a "is this a bug?" detour for a human or an agent reading it. All of them are gone.

Double substitution

Checked every site for reliance on it. None: every operand is a number (clk_period, clk_io_pct, DEF units, LEF coordinates), none is a string holding an operator.

Test evidence

  • tclint . and tclfmt --check . (0.9.0) are clean over the whole repo with the ignore removed, except the nine tcl: brace every expr in flow/scripts and platforms #4914 sites.
  • The 57 changed .sdc files, run under tclsh with every unknown command recorded with its arguments: identical log before and after for all 57.
  • make floorplan before/after on eight designs, one or more per platform (nangate45 gcd, asap7 gcd/uart/ethmac, sky130hd gcd, sky130hs gcd, ihp-sg13g2 gcd, gf180 gcd): the SDC OpenROAD writes at every stage (2_*.sdc) is byte-identical, and logs and stage metrics have no differences beyond run-specific paths. Only the copy of the source SDC (1_2_yosys.sdc) differs, as it should.
  • cell-veneer: wrap.tcl -macro and the standard-cell wrapper path (move_m2_pins_to_edge, test_harness) run on small synthetic LEFs (right/left/blocked padding cases): generated LEF and DEF are byte-identical before and after. (build_wrappers calls move_m2_pins_to_edge with a wrong argument count on master; unrelated, left alone.)

🤖 Generated with Claude Code

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request removes the 'unbraced-expr' ignore rule from the tclint configuration and updates various SDC and Tcl files to use braced expressions, improving performance and linting compliance. The review feedback suggests simplifying several of the newly modified multi-line expressions in 'flow/util/cell-veneer/wrap_stdcells.tcl' to improve readability and remove unnecessary line continuations.

Comment thread flow/util/cell-veneer/wrap_stdcells.tcl Resolved
Comment thread flow/util/cell-veneer/wrap_stdcells.tcl Resolved
Comment thread flow/util/cell-veneer/wrap_stdcells.tcl Resolved
Comment thread flow/util/cell-veneer/wrap_stdcells.tcl Resolved
…gnore

Brace the ~250 remaining unbraced `expr` calls: the designs'
constraint.sdc files, the ariane, bsg_chip and mempool_group SDCs, and
flow/util/cell-veneer/{lefdef,wrap_stdcells,wrap}.tcl. Then remove
"unbraced-expr" from the ignore list in tclint.toml, so tclint keeps
the rule from here on.

A braced expression is compiled once and is not substituted twice. No
site relied on the double substitution: every value is a number.

Sites in flow/scripts and flow/platforms are braced by the sibling pull
request; this one is meant to be merged after it, until then tclint
reports those.

Two lines are touched beyond bracing: a nested `[expr round(...)]`
inside another braced expr is now plain `round(...)` (tclint reports
it as redundant), and a few long lines are wrapped to the 100 column
limit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Øyvind Harboe <[email protected]>
…lands

The nine sites The-OpenROAD-Project#4914 braces still trip the check here, so this PR
leaves the ignore in place and stays green on its own; dropping it is a
one-line follow-up once both have merged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Øyvind Harboe <[email protected]>
@openroad-ci

openroad-ci commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

🔍 QoR check

Metrics reflect the PR merge build — i.e. what will land on the target branch.

Commit 003b2f6 · Jenkins build #3 · Baseline: build · View build on dashboard

62 design(s) checked — 0 with regression(s), 0 without a comparable baseline.

✅ QoR is compared against the master build at this PR's merge base 58710a4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants