We gratefully acknowledge support from
the Simons Foundation and member institutions.
Full-text links:

Download:

Current browse context:

cs.PL

Change to browse by:

References & Citations

DBLP - CS Bibliography

Bookmark

(what is this?)
CiteULike logo BibSonomy logo Mendeley logo del.icio.us logo Digg logo Reddit logo

Computer Science > Programming Languages

Title: Code Translation with Compiler Representations

Abstract: In this paper, we leverage low-level compiler intermediate representations (IR) to improve code translation. Traditional transpilers rely on syntactic information and handcrafted rules, which limits their applicability and produces unnatural-looking code. Applying neural machine translation (NMT) approaches to code has successfully broadened the set of programs on which one can get a natural-looking translation. However, they treat the code as sequences of text tokens, and still do not differentiate well enough between similar pieces of code which have different semantics in different languages. The consequence is low quality translation, reducing the practicality of NMT, and stressing the need for an approach significantly increasing its accuracy. Here we propose to augment code translation with IRs, specifically LLVM IR, with results on the C++, Java, Rust, and Go languages. Our method improves upon the state of the art for unsupervised code translation, increasing the number of correct translations by 11% on average, and up to 79% for the Java -> Rust pair with greedy decoding. We extend previous test sets for code translation, by adding hundreds of Go and Rust functions. Additionally, we train models with high performance on the problem of IR decompilation, generating programming source code from IR, and study using IRs as intermediary pivot for translation.
Comments: 9 pages
Subjects: Programming Languages (cs.PL); Computation and Language (cs.CL); Machine Learning (cs.LG)
Cite as: arXiv:2207.03578 [cs.PL]
  (or arXiv:2207.03578v5 [cs.PL] for this version)

Submission history

From: Marc Szafraniec [view email]
[v1] Thu, 30 Jun 2022 14:21:57 GMT (1655kb,D)
[v2] Wed, 13 Jul 2022 08:37:30 GMT (1655kb,D)
[v3] Tue, 18 Oct 2022 10:58:28 GMT (1712kb,D)
[v4] Wed, 19 Apr 2023 11:37:46 GMT (1151kb,D)
[v5] Mon, 24 Apr 2023 10:12:18 GMT (1148kb,D)

Link back to: arXiv, form interface, contact.