rust/compiler/rustc_ast_lowering/src
bors 2f8eeb2bba Auto merge of #143182 - xdoardo:more-addrspace, r=workingjubilee
Allow custom default address spaces and parse `p-` specifications in the datalayout string

Some targets, such as CHERI, use as default an address space different from the "normal" default address space `0` (in the case of CHERI, [200 is used](https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-877.pdf)). Currently, `rustc` does not allow to specify custom address spaces and does not take into consideration [`p-` specifications in the datalayout string](https://llvm.org/docs/LangRef.html#langref-datalayout).

This patch tries to mitigate these problems by allowing targets to define a custom default address space (while keeping the default value to address space `0`) and adding the code to parse the `p-` specifications in `rustc_abi`. The main changes are that `TargetDataLayout` now uses functions to refer to pointer-related informations, instead of having specific fields for the size and alignment of pointers in the default address space; furthermore, the two `pointer_size` and `pointer_align` fields in `TargetDataLayout` are replaced with an `FxHashMap` that holds info for all the possible address spaces, as parsed by the `p-` specifications.

The potential performance drawbacks of not having ad-hoc fields for the default address space will be tested in this PR's CI run.

r? workingjubilee
2025-07-07 17:28:14 +00:00
..
asm.rs Stabilize asm_goto 2025-03-17 11:12:10 +00:00
block.rs Implement super let. 2025-04-04 09:44:19 +02:00
delegation.rs Add visit_id to ast Visitor 2025-06-01 02:38:24 +00:00
errors.rs Reject union default field values 2025-06-17 07:27:58 +08:00
expr.rs Introduce ByteSymbol. 2025-06-30 20:42:27 +10:00
format.rs compiler: Parse p- specs in datalayout string, allow definition of custom default data address space 2025-07-07 09:04:53 +02:00
index.rs Reorder fields in hir::ItemKind variants. 2025-05-30 02:23:20 +10:00
item.rs Port #[target_feature] to the new attribute parsing infrastructure 2025-07-03 07:54:19 +02:00
lib.rs compiler: rename {ast,hir}::BareFn* to FnPtr* 2025-07-06 15:03:08 -07:00
pat.rs Introduce ByteSymbol. 2025-06-30 20:42:27 +10:00
path.rs Overhaul UsePath. 2025-06-03 08:23:21 +10:00
stability.rs compiler: remove misleading 'c' from abi_c_cmse_nonsecure_call feature 2025-06-25 00:52:10 -07:00