f50fd075c2
Refactor type memory layouts and ABIs, to be more general and easier to optimize. To combat combinatorial explosion, type layouts are now described through 3 orthogonal properties: * `Variants` describes the plurality of sum types (where applicable) * `Single` is for one inhabited/active variant, including all C `struct`s and `union`s * `Tagged` has its variants discriminated by an integer tag, including C `enum`s * `NicheFilling` uses otherwise-invalid values ("niches") for all but one of its inhabited variants * `FieldPlacement` describes the number and memory offsets of fields (if any) * `Union` has all its fields at offset `0` * `Array` has offsets that are a multiple of its `stride`; guarantees all fields have one type * `Arbitrary` records all the field offsets, which can be out-of-order * `Abi` describes how values of the type should be passed around, including for FFI * `Uninhabited` corresponds to no values, associated with unreachable control-flow * `Scalar` is ABI-identical to its only integer/floating-point/pointer "scalar component" * `ScalarPair` has two "scalar components", but only applies to the Rust ABI * `Vector` is for SIMD vectors, typically `#[repr(simd)]` `struct`s in Rust * `Aggregate` has arbitrary contents, including all non-transparent C `struct`s and `union`s Size optimizations implemented so far: * ignoring uninhabited variants (i.e. containing uninhabited fields), e.g.: * `Option<!>` is 0 bytes * `Result<T, !>` has the same size as `T` * using arbitrary niches, not just `0`, to represent a data-less variant, e.g.: * `Option<bool>`, `Option<Option<bool>>`, `Option<Ordering>` are all 1 byte * `Option<char>` is 4 bytes * using a range of niches to represent *multiple* data-less variants, e.g.: * `enum E { A(bool), B, C, D }` is 1 byte Code generation now takes advantage of `Scalar` and `ScalarPair` to, in more cases, pass around scalar components as immediates instead of indirectly, through pointers into temporary memory, while avoiding LLVM's "first-class aggregates", and there's more untapped potential here. Closes #44426, fixes #5977, fixes #14540, fixes #43278. |
||
---|---|---|
.. | ||
back | ||
debuginfo | ||
mir | ||
abi.rs | ||
allocator.rs | ||
asm.rs | ||
assert_module_sources.rs | ||
attributes.rs | ||
base.rs | ||
build.rs | ||
builder.rs | ||
cabi_aarch64.rs | ||
cabi_arm.rs | ||
cabi_asmjs.rs | ||
cabi_hexagon.rs | ||
cabi_mips64.rs | ||
cabi_mips.rs | ||
cabi_msp430.rs | ||
cabi_nvptx64.rs | ||
cabi_nvptx.rs | ||
cabi_powerpc64.rs | ||
cabi_powerpc.rs | ||
cabi_s390x.rs | ||
cabi_sparc64.rs | ||
cabi_sparc.rs | ||
cabi_x86_64.rs | ||
cabi_x86_win64.rs | ||
cabi_x86.rs | ||
callee.rs | ||
Cargo.toml | ||
common.rs | ||
consts.rs | ||
context.rs | ||
declare.rs | ||
diagnostics.rs | ||
glue.rs | ||
intrinsic.rs | ||
lib.rs | ||
llvm_util.rs | ||
metadata.rs | ||
meth.rs | ||
partitioning.rs | ||
README.md | ||
symbol_names_test.rs | ||
time_graph.rs | ||
trans_item.rs | ||
type_.rs | ||
type_of.rs | ||
value.rs |
NB: This crate is part of the Rust compiler. For an overview of the
compiler as a whole, see
the README.md file found in librustc
.
The trans
crate contains the code to convert from MIR into LLVM IR,
and then from LLVM IR into machine code. In general it contains code
that runs towards the end of the compilation process.