arXiv:2506.14606cs.CLcs.AR2025-06EMNLP

用大模型生成指令集转换代码,并通过测试保证正确性。

Guaranteed Guess: A Language Modeling Approach for CISC-to-RISC Transpilation with Testing Guarantees

  • 结合大模型生成与软件测试框架,实现跨指令集翻译
  • 在HumanEval上达99%正确率,BringupBench上49%正确率
  • 适合需要高可靠性指令集转换的研究者与开发者

硬件生态快速演进,对低级程序在不同指令集架构(ISA)间快速、灵活且正确地移植的需求日益增长,以提升代码可移植性和寿命。尤其困难的是复杂指令集(CISC)到精简指令集(RISC)之间的转换,因其在指令复杂度、内存模型和执行范式上的根本差异。本文提出GG(Guaranteed Guess),一种面向ISA的转换流水线,将预训练大语言模型(LLM)的翻译能力与成熟的软件测试机制相结合。方法利用LLM从一种ISA生成候选转换代码,并将其嵌入软件测试框架中,建立可量化的转换信心。我们在两个多样化数据集上评估,单元测试覆盖率超过98%,在HumanEval程序上实现99%的功能/语义正确性,在BringupBench程序上为49%。与苹果Apple Silicon上的最新技术Rosetta 2相比,我们的方法在运行时性能提升1.73倍,能效提高1.47倍,内存使用降低2.41倍,证明了GG在真实世界CISC-to-RISC转换任务中的有效性。代码、数据、模型和基准将开源,以建立指令集级代码转换研究的公共基础。

原文摘要 · Abstract (English)

The hardware ecosystem is rapidly evolving, with increasing interest in translating low-level programs across different instruction set architectures (ISAs) in a quick, flexible, and correct way to enhance the portability and longevity of existing code. A particularly challenging class of this transpilation problem is translating between complex- (CISC) and reduced- (RISC) hardware architectures, due to fundamental differences in instruction complexity, memory models, and execution paradigms. In this work, we introduce GG (Guaranteed Guess), an ISA-centric transpilation pipeline that combines the translation power of pre-trained large language models (LLMs) with the rigor of established software testing constructs. Our method generates candidate translations using an LLM from one ISA to another, and embeds such translations within a software-testing framework to build quantifiable confidence in the translation. We evaluate our GG approach over two diverse datasets, enforce high code coverage (>98%) across unit tests, and achieve functional/semantic correctness of 99% on HumanEval programs and 49% on BringupBench programs, respectively. Further, we compare our approach to the state-of-the-art Rosetta 2 framework on Apple Silicon, showcasing 1.73x faster runtime performance, 1.47x better energy efficiency, and 2.41x better memory usage for our transpiled code, demonstrating the effectiveness of GG for real-world CISC-to-RISC translation tasks. We will open-source our codes, data, models, and benchmarks to establish a common foundation for ISA-level code translation research.

指令集转换大模型代码验证编译器

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。