Code Translation with Compiler Representations

06/30/2022
by   Marc Szafraniec, et al.
0

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 pair with greedy decoding. With beam search, it increases the number of correct translations by 5.5 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.

READ FULL TEXT
research
12/04/2020

Quality Estimation Interpretability for Code Translation

Recently, the automated translation of source code from one programming ...
research
08/04/2018

code2seq: Generating Sequences from Structured Representations of Code

The ability to generate natural language sequences from source code snip...
research
08/09/2023

Evaluating and Optimizing the Effectiveness of Neural Machine Translation in Supporting Code Retrieval Models: A Study on the CAT Benchmark

Neural Machine Translation (NMT) is widely applied in software engineeri...
research
01/03/2023

Boosting Neural Networks to Decompile Optimized Binaries

Decompilation aims to transform a low-level program language (LPL) (eg.,...
research
05/20/2019

Towards Neural Decompilation

We address the problem of automatic decompilation, converting a program ...
research
08/17/2023

On the Evaluation of Neural Code Translation: Taxonomy and Benchmark

In recent years, neural code translation has gained increasing attention...
research
09/08/2020

On Architecture to Architecture Mapping for Concurrency

Mapping programs from one architecture to another plays a key role in te...

Please sign up or login with your details

Forgot password? Click here to reset