AgRefactor: Self-Evolving Agentic Workflow for HLS Compatibility and Performance
06:00 · July 1, 2026 · arXiv cs.AI RSS

High-Level Synthesis (HLS) provides a fast path from concepts to silicon, but converting real-world software into synthesizable HLS code remains challenging due to restrictive language support and the gap between software and hardware programming practices. Existing automated and LLM-based refactoring approaches partially address this problem, yet they often lack flexibility, struggle to scale, and incur high computational costs. We introduce AgRefactor, an LLM-based multi-agent workflow for refactoring software into HLS-compatible programs. AgRefactor incorporates a self-evolving memory system that accumulates and retrieves factual and strategic knowledge across tasks, improving robustness and efficiency on unseen programs. To reduce cost and enhance scalability, it integrates automated refactoring tools, enabling agents to balance LLM-driven rewrites with efficient tool-based transformations. On 9 out of 11 challenging real-world benchmarks, which are 5-10x longer than the most complex cases studied in prior work, AgRefactor outperforms or matches the state-of-the-art automated refactoring tool and a strong LLM-based baseline built on the same framework backbone. Further agentic performance optimization yields a 6.51x geometric mean speedup over the SoTA pragma tuning tool and a 1.20x speedup over optimized open-source designs with less than 20% extra resources. AgRefactor is fully-automated and open-sourced.
Summary
High-Level Synthesis tools aim to bridge software concepts and hardware implementations by accepting C/C++ input, yet real-world codebases rarely meet the strict syntactic and structural requirements for synthesis. The gap arises from unsupported language features, external libraries, complex data structures, and pointer operations that diverge from hardware-oriented design practices. Prior automated refactoring systems rely on fixed templates and struggle with generalizability, while pure LLM-based agents incur high costs, exhibit output variance, and scale poorly beyond small examples.
AgRefactor addresses these constraints through an LLM-driven multi-agent workflow augmented by a self-evolving memory store. The memory component extracts and retrieves both factual knowledge and strategic patterns from successive refactoring tasks, allowing the system to improve robustness on previously unseen programs without manual RAG construction. To control cost and improve throughput, the agents selectively invoke an existing algorithmic tool, HeteroRefactor, for transformations it can handle reliably, reserving LLM rewrites for constructs outside the tool’s scope. This hybrid approach yields a workflow that remains fully automated and open-source.
Evaluated on eleven real-world benchmarks drawn from codecs, cryptography, and genomics—each five to ten times longer than cases examined in earlier studies—AgRefactor matches or exceeds both the leading automated refactoring tool and a comparable LLM baseline on nine of the eleven programs. Subsequent agent-guided performance tuning produces a geometric-mean speedup of 6.51 times relative to state-of-the-art pragma tuning and a 1.20 times improvement over hand-optimized open-source HLS designs, while adding less than 20 percent extra hardware resources.
Why it matters
This research is highly relevant for Dutch AI and semiconductor researchers focusing on AI hardware acceleration. The open-source, LLM-driven approach to HLS optimization offers actionable methodologies for designing efficient AI chips, aligning with the Netherlands' strategic position in the European semiconductor ecosystem.

