How do I understand the data-layout strings of Rust compiler targets?

Viewed 272

Inside the Rust compiler, all targets have a data_layout. The string looks really scary and give me nightmares. Examples for it are

e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:32-n8:16:32-a:0:32-S32

and

e-m:e-i64:64-f80:128-n8:16:32:64-S128

What is going on here?

1 Answers

These data layout strings are defined by LLVM and are explained in the docs. You could also try to learn from the Rust compiler code that parses these strings.

Let's take this example:

e-m:e-i64:64-f80:128-n8:16:32:64-S128

  • e: little endiann
  • m:e: ELF mangling
  • i64:64: native support for little endian 64 bit integers
  • f80:128: store 80 bit floats in 128 bits
  • n8:16:32:64: the processor has native registers for 8, 16, 32, and 64 bit
  • S128: natural aligment of the stack in bits

What p270:32:32-p271:32:32-p272:64:64 refers to is explained here: Many of the Rust Compilers target definitions use "p270:32:32-p271:32:32-p272:64:64" inside the data-layout - what does it mean?

Related