从CISC到RISC:语言模型引导的汇编转译
From CISC to RISC: language-model guided assembly transpilation
AI总结:
本文提出基于大语言模型的轻量级转译器CRT,实现x86汇编到ARM/RISC-V的自动转换,在保持语义的同时取得高准确率,并在Apple M2上相比Rosetta 2实现显著加速和能效提升。
摘要:
从x86到ARM架构的转变在各个领域日益普遍,主要驱动力是ARM的能效优势及其在传统领域中性能的提升。然而,这种指令集架构(ISA)转变带来了重大挑战,主要是由于x86软件庞大的遗留生态系统以及跨专有生态系统和软件栈的可移植性不足。本文介绍了CRT,一个轻量级的基于大语言模型(LLM)的转译器,可自动将x86汇编转换为ARM汇编。我们的方法弥合了x86基于CISC的计算范式与ARM基于RISC的计算范式之间的根本架构差距,同时保持程序语义并优化性能。我们在多种真实世界应用上对CRT进行了评估,在综合测试套件上实现了从x86到ARMv5的79.25%的翻译准确率,以及从x86到RISC-V的88.68%的准确率。在Apple M2硬件(ARMv8)上的实际部署中,与Apple的Rosetta 2虚拟化引擎相比,我们转译后的代码实现了1.73倍的加速,同时提供了2.41倍的内存效率和1.47倍的更低能耗。通过测试和分析,我们表明CRT成功跨越了CISC/RISC的鸿沟,并在机器“语言”障碍存在的情况下生成了可正确执行的RISC代码。我们在以下地址发布了代码、模型、训练数据集和基准:https://ahmedheakl.github.io/asm2asm/。
英文摘要:
The transition from x86 to ARM architecture is becoming increasingly common across various domains, primarily driven by ARM's energy efficiency and improved performance across traditional sectors. However, this ISA shift poses significant challenges, mainly due to the extensive legacy ecosystem of x86 software and lack of portability across proprietary ecosystems and software stacks. This paper introduces CRT, a lightweight LLM-based transpiler that automatically converts x86 assembly to ARM assembly. Our approach bridges the fundamental architectural gap between x86's CISC-based and ARM's RISC-based computing paradigms while preserving program semantics and optimizing performance. We evaluate CRT on diverse real-world applications, achieving 79.25% translation accuracy from x86 to ARMv5 on our comprehensive test suite, and an 88.68% accuracy from x86 to RISC-V. In practical deployments on Apple M2 hardware (ARMv8), our transpiled code achieves 1.73$\times$ speedup compared to Apple's Rosetta 2 virtualization engine, while delivering 2.41$\times$ memory efficiency and 1.47$\times$ better energy consumption. Through testing and analysis, we show that CRT successfully navigates the CISC/RISC divide and generates correctly executable RISC code despite machine ``language'' barriers. We release our code, models, training datasets, and benchmarks at: \url{https://ahmedheakl.github.io/asm2asm/}.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。