Skip to content

Commit 4232955

Browse files
committed
explain PassMode::Cast
1 parent 5ede940 commit 4232955

File tree

1 file changed

+9
-3
lines changed
  • compiler/rustc_target/src/abi/call

1 file changed

+9
-3
lines changed

compiler/rustc_target/src/abi/call/mod.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ pub enum PassMode {
4545
///
4646
/// The argument has a layout abi of `ScalarPair`.
4747
Pair(ArgAttributes, ArgAttributes),
48-
/// Pass the argument after casting it, to either a single uniform or a
49-
/// pair of registers. The bool indicates if a `Reg::i32()` dummy argument
50-
/// is emitted before the real argument.
48+
/// Pass the argument after casting it. See the `CastTarget` docs for details. The bool
49+
/// indicates if a `Reg::i32()` dummy argument is emitted before the real argument.
5150
Cast(Box<CastTarget>, bool),
5251
/// Pass the argument indirectly via a hidden pointer.
5352
/// The `extra_attrs` value, if any, is for the extra data (vtable or length)
@@ -255,6 +254,13 @@ impl Uniform {
255254
}
256255
}
257256

257+
/// Describes the type used for `PassMode::Cast`.
258+
///
259+
/// Passing arguments in this mode works as follows: the registers in the `prefix` (the ones that
260+
/// are `Some`) get laid out one after the other (using `repr(C)` layout rules). Then the
261+
/// `rest.unit` register type gets repeated often enough to cover `rest.size`. This describes the
262+
/// actual type used for the call; the Rust type of the argument is then transmuted to this ABI type
263+
/// (and all data in the padding between the registers is dropped).
258264
#[derive(Clone, PartialEq, Eq, Hash, Debug, HashStable_Generic)]
259265
pub struct CastTarget {
260266
pub prefix: [Option<Reg>; 8],

0 commit comments

Comments
 (0)