Skip to content

Commit

Permalink
Rollup merge of #125154 - FractalFir:fnabi_doc, r=compiler-errors
Browse files Browse the repository at this point in the history
Small improvements to the documentaion of FnAbi

I have updated the documentation of  `FnAbi`.

The `arg` and `ret` fields are no longer LLVM types, but Rust types(`ArgAbi` contains a `TyAndLayout` and a `PassMode`), so I changed the documentation to reflect that.

Besides that, I also added documentation to other fields, and added a clarification about the differences between `FnAbi` and `FnSig`, since this is not something that is immediately obvious.
  • Loading branch information
fmease authored May 15, 2024
2 parents 0915629 + 257d222 commit 601e5d1
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions compiler/rustc_target/src/abi/call/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -779,26 +779,31 @@ impl RiscvInterruptKind {
/// Metadata describing how the arguments to a native function
/// should be passed in order to respect the native ABI.
///
/// The signature represented by this type may not match the MIR function signature.
/// Certain attributes, like `#[track_caller]` can introduce additional arguments, which are present in [`FnAbi`], but not in `FnSig`.
/// While this difference is rarely relevant, it should still be kept in mind.
///
/// I will do my best to describe this structure, but these
/// comments are reverse-engineered and may be inaccurate. -NDM
#[derive(Clone, PartialEq, Eq, Hash, HashStable_Generic)]
pub struct FnAbi<'a, Ty> {
/// The LLVM types of each argument.
/// The type, layout, and information about how each argument is passed.
pub args: Box<[ArgAbi<'a, Ty>]>,

/// LLVM return type.
/// The layout, type, and the way a value is returned from this function.
pub ret: ArgAbi<'a, Ty>,

/// Marks this function as variadic (accepting a variable number of arguments).
pub c_variadic: bool,

/// The count of non-variadic arguments.
///
/// Should only be different from args.len() when c_variadic is true.
/// This can be used to know whether an argument is variadic or not.
pub fixed_count: u32,

/// The calling convention of this function.
pub conv: Conv,

/// Indicates if an unwind may happen across a call to this function.
pub can_unwind: bool,
}

Expand Down

0 comments on commit 601e5d1

Please sign in to comment.