我如何理解 Rust 编译器目标的数据布局字符串? [英] How do I understand the data-layout strings of Rust compiler targets?
问题描述
在 Rust 编译器中,所有目标都有一个 data_layout
.绳子看起来真的很吓人,让我做噩梦.它的例子是
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
和
e-m:e-i64:64-f80:128-n8:16:32:64-S128
这里发生了什么?
推荐答案
这些数据布局字符串由 LLVM 定义并且是 在文档中解释.你也可以尝试学习 解析这些字符串的 Rust 编译器代码.
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
:小端m:e
:ELF 修改i64:64
:对小端 64 位整数的原生支持f80:128
:在 128 位中存储 80 位浮点数n8:16:32:64
:处理器具有用于 8、16、32 和 64 位的本机寄存器S128
:以位为单位的堆栈自然对齐
e
: little endiannm:e
: ELF manglingi64:64
: native support for little endian 64 bit integersf80:128
: store 80 bit floats in 128 bitsn8:16:32:64
: the processor has native registers for 8, 16, 32, and 64 bitS128
: natural aligment of the stack in bits
这里解释了 p270:32:32-p271:32:32-p272:64:64
所指的内容:许多 Rust 编译器目标定义使用p270:32:32-p271:32:32-p272:64:64"在数据布局中 - 这是什么意思?
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?
这篇关于我如何理解 Rust 编译器目标的数据布局字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!