我如何理解 Rust 编译器目标的数据布局字符串? [英] How do I understand the data-layout strings of Rust compiler targets?

查看:79
本文介绍了我如何理解 Rust 编译器目标的数据布局字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 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 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

这里解释了 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆