Manuscript Offprint

arXiv:2608.24946

MacroAgent: Regularity-Aware Macro Legalization with LLM-Agent-Designed Contour Algorithms

Jiaxi Jiang, Xufeng Yao, Yuxuan Zhao, Yuntao Lu, Peiyu Liao, Zuodong Zhang, Yibo Lin, Bei Yu

JIAXI JIANG, The Chinese University of Hong Kong

XUFENG YAO, The Chinese University of Hong Kong

YUXUAN ZHAO, The Chinese University of Hong Kong

YUNTAO LU, The Chinese University of Hong Kong

PEIYU LIAO, The Chinese University of Hong Kong

ZUODONG ZHANG, Peking University

YIBO LIN, Peking University

BEI YU, The Chinese University of Hong Kong

Macros constitute a large part of the core area in modern very large-scale integration (VLSI) designs. Moreover, macro positions have a significant impact on the final quality of result (QoR), and macro legalization is typically the final step in determining the macro positions. However, existing approaches related to macro legalization either lack robustness or incur substantial computational costs or neglect the regularity between macros. To address these limitations, we introduce MacroAgent. The novel framework is a four-stage approach: clustering, contour generation, template matching, and inter-cluster refinement. We propose leveraging Large Language Models (LLMs) to discover multiple, effective heuristic regularity-aware contour algorithms. This framework successfully generates robust and effective algorithmic solutions for macro legalization. Compared with state-of-the-art macro legalization works, experimental results on TILOS and Chipyard benchmarks demonstrate a 2 to 8 fold improvement in layout regularity, a 3% to 5% reduction in routed wirelength with comparable congestion after global routing, and significantly better robustness with an acceptable runtime. Furthermore, end-to-end evaluation through Cadence Innovus place-and-route confirms that the regularity improvements translate into tangible PPA gains, including 2.9% lower routed wirelength and 68.3% TNS improvement over the DREAMPlace macro legalization baseline; it also achieves 1.8% lower routed wirelength when integrated into the Innovus macro placement flow.

CCS Concepts: • Hardware → Software tools for EDA; Methodologies for EDA.

Additional Key Words and Phrases: Design Automation, Physical Design, Macro Legalization

ACM Reference Format:

Jiaxi Jiang, Xufeng Yao, Yuxuan Zhao, Yuntao Lu, Peiyu Liao, Zuodong Zhang, Yibo Lin, and Bei Yu. 2026. MacroAgent: Regularity-Aware Macro Legalization with LLM-Agent-Designed Contour Algorithms. ACM Trans. Des. Autom. Electron. Syst. 1, 1 (August 2026), 27 pages. https://doi.org/10.1145/XXXXXXX.XXXXXXX

1 INTRODUCTION

Macros in very large-scale integration (VLSI) circuits, such as memory and spatial arrays, are pre-designed giant functional blocks. They have fixed dimensions (e.g., height and width) and optimized structures. Macro placement heavily constrains subsequent standard-cell optimization, which in turn indirectly impacts power, performance, and area by affecting the routed wirelength [1]. Macro

Authors' addresses: Jiaxi Jiang, The Chinese University of Hong Kong; Xufeng Yao, The Chinese University of Hong Kong; Yuxuan Zhao, The Chinese University of Hong Kong; Yuntao Lu, The Chinese University of Hong Kong; Peiyu Liao, The Chinese University of Hong Kong; Zuodong Zhang, Peking University; Yibo Lin, Peking University; Bei Yu, The Chinese University of Hong Kong.

  1. 1084-4309/2026/8-ART $15.00

https://doi.org/doi.org/10.1145/XXXXXXX.XXXXXXX

Traditional Marco Legalization

Figure

Macro Placement

with Overlap

Displacement Optimization with

No Regularity

Legal Macro Placement

Ignoring Regularity

Proposed MarcoAgent Legalization

Macro Placement

with Overlap

LLM Agent

Design

Clustering

Contour

Generation

Template

Matching

Refinement

Regularity-Aware Contour Algorithms

Designed by LLM

Legal Macro Placement

with Engineer-Level Regularity

Fig. 1. The MacroAgent framework consisting of four-stage legalization steps. MacroAgent achieves engineer-level regularity macro legalization results by regularity-aware contour algorithms designed by the LLM agent.

legalization represents the final phase that determines legal macro positions at the end of macro placement process.

Traditionally, the physical design procedure for VLSI circuits is composed of multiple stages, including floorplan, macro placement, standard-cell placement, and routing. Macro placement occupies an early position in the design process and has a significant influence on subsequent phases [2][2]. Moreover, due to the large size of macros, minor position adjustments can significantly impact downstream optimizations [3][3].

The research literature categorizes macro placement into two main categories. The first is mixed-size global placement (placing macros and standard-cells together, rough locations), then macro legalization (overlap removal) [3–9]. During the first step, overlap constraints are relaxed, multiple objectives are considered. Then macro legalization removes remaining overlaps. The second category utilizes layout data structures to directly place macros, optimize customized objectives via simulated annealing [10–14]. The first category is faster than simulated annealing in the second, which is less scalable [5, 15]. In industry practice, macro placement relies on both senior engineers' expertise (e.g., manual placement) and algorithmic efforts [5]. Complex projects may take hours to days [5]. The industrial tool, Innovus, offers a flow similar to the first macro placement method in the research literature, with two commands: place_design -concurrent_macro (mixed-size global placement) and then refine_macro_place (macro legalization) [15].

Current Approaches to Macro Legalization. Most prior works in macro legalization only attempt to minimize the displacement (i.e., the movements of macros). [16] proposes a legalization scheme that computes macro coordinates through the iterative adjustment of two constraint graphs, minimizing displacement by solving the linear programming problem. [4] extracts search points and feasible regions using the Puzzle algorithm, and iteratively places macros. DREAMPlace 2.0 [17] combines the two techniques mentioned above and has been applied in [3, 5, 9]. The work in [6] designed an occupancy-aware macro legalization algorithm that iteratively eliminates overlaps via heuristic approaches. The study in [7] employs integer linear programming or simulated annealing

Figure

Cells Traped in Channel

Large Deadspace

Fig. 2. Consequences of ignoring regularity in macro legalization (red giant rectangles are macros, blue tiny points are cells). Both situations worsen the wirelength.

Figure

Irregular Placement

4 Channel

Figure

Regular Placement

2 Channel

Channel

Macro

Fig. 3. Channel-based macro regularity examples.

to adjust macro positional relationships when initial sequence pairs prove infeasible. Although these techniques can improve the robustness of macro legalization, they still fall short in two aspects: first, they overlook the regularity between macros; second, they lack robustness since only one or two heuristics cannot fit all different testcases in macro legalization.

Regularity-Aware Macro Placement. Among prior works on macro placement, there is a common focus on macro regularity. Studies have confirmed that such regularity reduces wirelength and minimizes deadspace [4], although the definition of regularity in these studies is quite different. [11] uses cost models for macro grouping and regularity penalties, demonstrating a significant reduction in wirelength. [13, 14] exploit RTL hierarchy information to cluster macros and arrange them in regular patterns. [3] defined macro regularity as the necessity for macros to be surrounded by other macros or die boundaries, identify irregular placements and adjust. The MaskRegulate [8] method implements a reinforcement learning policy as a regulator to adjust existing layouts. [4] extract macros of the same type and similar levels, arrange them in array form. They consider regularity during refinement or directly place macros. However, no academic work directly considers regularity in the final legalization stage in macro placement. Only industrial tool Innovus provides an option place_global_align_macro to achieve regular macro legalization [15]. It is important to differentiate our legalization-focused approach from constructive regular placement methods [4, 8, 11, 13, 14]. While constructive methods enforce patterns early, modern mixed-size global placement tends to disrupt these pre-defined patterns during optimization, so they need to keep the macros fixed. Therefore, we do not aim to compete with placement algorithms in generating the initial structure; rather, we propose an essential complementary capability: recovering and enforcing regularity during the final legalization stage, similar to the place_global_align_macro flow in Innovus [15].

Regularity Metrics. Although regularity is essential for macro placement, there is no universally accepted definition. Earlier studies by [4, 13, 14] mainly characterize regularity via array-based placement configurations. [3, 8, 11] define regularity by the proximity of macros to chip boundaries or the presence of other macros in specific vicinities.

We generally adhere to the perspective in [14] that mandating macro placement at the layout periphery is no longer feasible, as this increases the required stack depth of macros. However, in [4, 13, 14], they constrain macros to a strictly array-based form, with no metric to evaluate their regularity.

We introduce a quantitative macro regularity metric by counting channels between macros, aligned with previous studies [4, 13, 14]. This metric reflects these physical design principles: excessive channels increase deadspace and restrict standard-cell placement optimization. As shown in Fig. 2, the cells trapped in the channels between macros are less likely to jump out of the channels, due to the density constraint [3]. It is also evident that the deadspaces between macros increase the wirelength. Our approach assigns peak regularity scores to squares and high scores to rectangles, supporting established array-based placement methods [4, 13, 14]. Fig. 3 indicates the number of channels under irregular and regular placement, which reveals that the number of channels is the smallest in the case of array-based placement. For normalization, after counting the channels, we divide the theoretical smallest possible number of channels by the acquired number. The number is less than 1, where the closer the index value is to 1, the higher the regularity achieved. We achieve a theoretical minimum number of channels when arranging macros in a square array. The following formula can obtain a rough estimation:

a=⌊Nmacro⌋,Cmin=2a−2,(1)a=\lfloor\sqrt{N_{macro}}\rfloor,\quad C_{min}=2a-2, \tag{1}

where NmacroN_{macro} is the number of macros, a is the side length lower bound of the square array, and CminC_{min} is the theoretical minimum number of channels. Intuitively, we need at least a - 1 channels to separate the macros into a rows and another a - 1 channels to separate the macros into a columns. Any irregular placement introduces extra channels. Finally, the regularity index is defined as:

R=Cmin⁡Cactual,(2)R=\frac{C_{\min}}{C_{actual}}, \tag{2}

where CactualC_{actual} is the actual number of channels. To compute CactualC_{actual}, we construct a Hanan grid from all macro vertex coordinates, mark occupied cells, and iteratively merge adjacent empty cells into maximal rectangular strips. An empty cell at a crossing point may participate in merges in both directions simultaneously. The number of resulting strips yields CactualC_{actual}; details are provided in Section 2. Fig. 3 also exhibits that the theoretical minimum number of channels is 2. The regularity indices are 0.5 and 1 for the left and right cases, respectively.

Large Language Models for Algorithm Design. Large Language Models (LLMs) have drawn much research attention for their great performance in various cognitive tasks [18–23]. In Electronic Design Automation (EDA), more researchers are using LLMs as research tools [24–26], in script/RTL generation, circuit design, and QA systems.

Traditional automated algorithm design methods, such as genetic programming (GP) [27], require defining a set of allowed mutation operations (or primitives). Designing such a suitable set of primitives is non-trivial and remains an open challenge in practice [28]. Reinforcement learning (RL) has also been applied to algorithm design, including program superoptimization [29] and discovering faster assembly-level sorting algorithms [30]. However, RL-based approaches require human experts to carefully design the action spaces, and this design becomes difficult for higher-level programming languages [23]. Moreover, RL models are trained on specific tasks and do not readily generalize to other problems. In contrast, LLMs have been trained on vast amounts of code and have learned common patterns and routines from human-designed programs. By leveraging this knowledge together with prompt-provided context, LLMs can generate more effective suggestions than the random mutations typically used in GP [23]. Furthermore, LLMs do not require a predefined action space or mutation operations, offering greater flexibility to explore a larger search space.

Recently, there is growing interest in LLM-based algorithm design [31–34]. LLMs play various roles, such as evaluators and optimization engines. The most promising is using LLMs to directly design algorithm components (heuristic methods) for NP-hard problems [31]. In EDA, the direct use of LLMs for algorithm design is underexplored; only [35] has attempted to enhance global placement algorithms via iterative LLM implementation, using crafted prompts and an LLM-based genetic process, but lacking meaningful feedback (only wirelength). AlphaEvolve [36] combines LLMs with evolutionary search and achieves impressive results in mathematics and algorithm optimization, where LLMs already possess sufficient knowledge from pretraining. However, applying LLMs to specialized fields like EDA, where they lack domain expertise, presents a distinct challenge. SATLUTION [37] targets NP-complete SAT problems and demonstrates that LLMs can handle substantial code generation at scale. Nevertheless, as the authors discuss in the appendix, human guidance is still incorporated to manually direct higher-level algorithmic strategies while leaving the lower-level implementation to the LLM agent. GPU Kernel Scientist [38] tunes existing GPU optimization techniques (e.g., increasing thread block occupancy and resolving shared memory conflicts) to find the best kernel for specific hardware, rather than discovering new algorithms. Our work differs from these approaches in three key aspects: (1) we introduce a domain-agnostic abstraction that reformulates the EDA-specific problem into a geometric problem. Domain-specific decisions such as clustering strategy and optimization objective selection are encoded in the framework by human engineers, while the LLM operates solely on the abstracted geometric subproblem using a general-purpose, off-the-shelf model without any domain-specific fine-tuning. (2) Our LLM autonomously discovers both algorithm ideas and implementations without human strategy guidance in the intermediate process. (3) The manageable scale of macro legalization instances enables us to provide human-crafted solution samples and per-iteration visual feedback to the LLM, allowing it to understand why a solution is good or bad rather than relying solely on scalar metrics.

Despite their promising potential, significant limitations persist in employing LLMs for advanced algorithm design: they struggle with complex algorithm implementations and lack domain-specific expertise for specialized optimization tasks [32].

Motivation. In the EDA domain, the majority of problems are NP-hard. Researchers have historically developed numerous heuristic algorithms to address these challenges. Specifically within macro legalization, previous researchers have designed sophisticated heuristics for macro clustering, placement selection, and perturbation techniques to optimize solution quality. It naturally raises a fundamental question: Can LLMs effectively replace human experts in designing heuristic algorithms for such problems?

Our Contribution. To address these challenges, we propose a robust regularity-aware macro legalization framework with four stages. Our framework decomposes the macro legalization process into four sequential components of clustering, regularity-aware contour generation, template-based macro matching, and inter-cluster refinement as shown in Fig. 1. Compared with the traditional legalization methods, our methods are more robust through the combination of multiple heuristic LLM-designed contour algorithms. It achieves simultaneous regular macro legalization while minimizing the displacement through template matching. To mitigate the limitations of LLMs in EDA domains, we extract a domain-agnostic geometry problem and present LLMs with the engineers' manual macro legalization solutions, which address gaps in domain knowledge and simplify the original problem. This enables fast, automatic, and diverse heuristics findings in an offline manner to fit different input testcases (no human intervention in the intermediate process). Notably, the hard testcases used for final validation are distinct from those utilized to guide LLMs in heuristic discovery, effectively demonstrating the strong generalization capability of LLM generated heuristics. We validate MacroAgent under two experimental flows. In the academic flow (DREAMPlace + HeLEM-GR), MacroAgent reduces routed wirelength by 3%–5% with comparable congestion on both TILOS and Chipyard benchmarks. In the industrial flow (Cadence Innovus place-and-route), MacroAgent achieves 2.9% lower routed wirelength, 68.3% TNS improvement, and comparable power over the DREAMPlace macro legalization baseline; it also achieves 1.8% lower routed wirelength when integrated into the Innovus macro placement flow.

We organize the rest of the paper as follows: Section 2 introduces the rise of LLM agents in algorithm design and the problem definition of macro legalization. Section 3 introduces the proposed macro legalization framework. Section 4 introduces the implementation details of the proposed macro legalization framework. Section 5 presents the experimental results. Section 6 concludes the paper.

References (42)

  • Innovus mixed placer
  • Congestion and timing aware macro placement using machine learning predictions from different data sources: Cross-design model applicability and the discerning ensemble
  • Incrementro: Incremental macro placement refinement
  • Regularity-aware routability-driven macro placement methodology for mixed-size circuits with obstacles
  • Autodmp: Automated dreamplace-based macro placement
  • Pplace-ms: Methodologically faster poisson’s equation-based mixed-size global placement
  • Stronger mixed-size placement backbone considering second-order information
  • Reinforcement learning policy as macro regulator rather than macro placer
  • Regplace: Regularity-aware placement for full-system dnn accelerator designs
  • Mp-trees: A packing-based macro placement algorithm for mixed-size designs
  • A novel damped-wave framework for macro placement
  • Rtl-aware dataflow-driven macro placement
  • Rtl-mp: toward practical, human-quality chip planning and macro placement
  • Hier-rtlmp: A hierarchical automatic macro placer for large-scale complex ip blocks
  • A robust mixed-size legalization and detailed placement algorithm
  • Dreamplace 2.0: Open-source gpu-accelerated global and detailed placement for large-scale vlsi designs
  • GPT-4 Technical Report
  • DeepSeek-R1 incentivizes reasoning in LLMs through reinforcement learning
  • Scientific discovery in the age of artificial intelligence
  • Large language models for mathematical reasoning: Progresses and challenges
  • Metagpt: Meta programming for a multi-agent collaborative framework
  • Mathematical discoveries from program search with large language models
  • Verilogeval: Evaluating large language models for verilog code generation
  • Data is all you need: Finetuning llms for chip design via an automated design-data augmentation framework
  • Gpt4aigchip: Towards next-generation ai accelerator design automation via large language models
  • an introduction: on the automatic evolution of computer programs and its applications
  • Open issues in genetic programming
  • Learning to superoptimize real-world programs
  • Faster sorting algorithms discovered using deep reinforcement learning
  • Evolution of heuristics: Towards efficient automatic algorithm design using large language model
  • A systematic survey on large language models for algorithm design
  • Large language models as optimizers
  • Llm performance predictors are good initializers for architecture search
  • Evoplace: Evolution of optimization algorithms for global placement via large language models
  • AlphaEvolve: A coding agent for scientific and algorithmic discovery
  • Autonomous code evolution meets np-completeness (opens arXiv in a new tab)
  • Gpu kernel scientist: An llm-driven framework for iterative kernel optimization (opens arXiv in a new tab)
  • Routing-aware legal hybrid bonding terminal assignment for 3d face-to-face stacked ics
  • c/ua is the Docker Container for Computer-Use AI Agents
  • Helem-gr: Heterogeneous global routing with linearized exponential multiplier method
  • Assessment of reinforcement learning for macro placement
  • Chipyard: Integrated design, simulation, and implementation framework for custom socs