许多 Rust 编译器目标定义在数据布局中使用 "p270:32:32-p271:32:32-p272:64:64" - 这是什么意思?
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编译器的数据布局字符串,或者更具体地说,底层的LLVM,在上已经基本解决了。不幸的是,有一件事还不清楚。
许多 Rust 编译器目标在其数据布局字符串中包含 p270:32:32-p271:32:32-p272:64:64
。例如 i686-unknown-uefi
、x86_64-uwp_windows-msvc
、x86_64-unknown-uefi
、x86_64-unknown-linux_gnu
、x86_64-fuchsia
或 86_64-apple-darwin
.
(可以在此处找到这些目标 https://github.com/rust-lang/rust/tree/1.52.1/compiler/rustc_target/src/spec.)
p[n]:<size>:<abi>:<pref>:<idx>
This specifies the size of a pointer and its and erred alignments for address space n. The fourth parameter is a size of index that used for address calculation. If not specified, the default index size is equal to the pointer size. All sizes are in bits. The address space, n, is optional, and if not specified, denotes the default address space 0. The value of n must be in the range [1,2^23).
我不明白这个。 p270
到 p272
有什么特别之处?他们指的是哪个“地址 space”?
这些数据布局字符串是 commited to Rust on 2020-01-07. The commit message says "Update data layouts to include new X86 address spaces". After more research I found that the underlying functionality was merged into LLVM in 2019. These new address spaces are MSVC's __ptr32
, __ptr64
, __sptr
, and __uptr
extensions [1]。
引自 LLVM 讨论:
The numbers 270-272 are more or less arbitrary; I picked them because they're near 256-258, which are the current existing address spaces.
如果你查看 X86.h
in LLVM's source code,可以看到这个数字被用作标识符并且是随意选择的,而不是出于技术原因。
几天前,基本了解Rust编译器的数据布局字符串,或者更具体地说,底层的LLVM,在
许多 Rust 编译器目标在其数据布局字符串中包含 p270:32:32-p271:32:32-p272:64:64
。例如 i686-unknown-uefi
、x86_64-uwp_windows-msvc
、x86_64-unknown-uefi
、x86_64-unknown-linux_gnu
、x86_64-fuchsia
或 86_64-apple-darwin
.
(可以在此处找到这些目标 https://github.com/rust-lang/rust/tree/1.52.1/compiler/rustc_target/src/spec.)
p[n]:<size>:<abi>:<pref>:<idx>
This specifies the size of a pointer and its and erred alignments for address space n. The fourth parameter is a size of index that used for address calculation. If not specified, the default index size is equal to the pointer size. All sizes are in bits. The address space, n, is optional, and if not specified, denotes the default address space 0. The value of n must be in the range [1,2^23).
我不明白这个。 p270
到 p272
有什么特别之处?他们指的是哪个“地址 space”?
这些数据布局字符串是 commited to Rust on 2020-01-07. The commit message says "Update data layouts to include new X86 address spaces". After more research I found that the underlying functionality was merged into LLVM in 2019. These new address spaces are MSVC's __ptr32
, __ptr64
, __sptr
, and __uptr
extensions [1]。
引自 LLVM 讨论:
The numbers 270-272 are more or less arbitrary; I picked them because they're near 256-258, which are the current existing address spaces.
如果你查看 X86.h
in LLVM's source code,可以看到这个数字被用作标识符并且是随意选择的,而不是出于技术原因。