Automatic transformation of bit-level C code to support multiple equivalent data layouts

  • Authors:
  • Marius Nita;Dan Grossman

  • Affiliations:
  • Department of Computer Science & Engineering, University of Washington, Seattle, WA;Department of Computer Science & Engineering, University of Washington, Seattle, WA

  • Venue:
  • CC'08/ETAPS'08 Proceedings of the Joint European Conferences on Theory and Practice of Software 17th international conference on Compiler construction
  • Year:
  • 2008

Quantified Score

Hi-index 0.00

Visualization

Abstract

Portable low-level C programs must often support multiple equivalent in-memory layouts of data, due to the byte or bit order of the compiler, architecture, or external data formats. Code that makes assumptions about data layout often consists of multiple highly similar pieces of code, each designed to handle a different layout. Writing and maintaining this code is difficult and bug-prone: Because the differences among data layouts are subtle, implicit, and inherently low-level, it is difficult to understand or change the highly similar pieces of code consistently. We have developed a small extension for C that lets programmers write concise declarative descriptions of how different layouts of the same data relate to each other. Programmers then write code assuming only one layout and rely on our translation to generate code for the others. In this work, we describe our declarative language for specifying data layouts, how we perform the automatic translation of C code to equivalent code assuming a different layout, and our success in applying our approach to simplify the code base of some widely available software.