pub enum Abi {
Plain,
Sext,
Zext,
ByVal {
size: u64,
align: u32,
},
Sret {
size: u64,
align: u32,
},
}Expand description
How one parameter or one return value travels, beyond what its type says.
The IR’s types are the machine’s and not C’s, so a ptr parameter says nothing about
whether the pointer is the argument or whether the object it points at is, and an i8 says
nothing about which half of the register above it the callee may read. Both are the ABI’s
answer rather than the type’s, which is why they are here and not on Type.
A signature carrying one of these has already had the ABI applied to it. What the walk to
the IR builds first is the C-level form, where every parameter is Abi::Plain, and the
classification in rucc-target is what turns one into the other.
Variants§
Plain
The value itself, in the type it is written as.
Sext
An integer narrower than a register, with the bits above it its own sign.
Which of these an ABI asks for is not a property of the value: unsigned char is
Abi::Sext on the Darwin ABIs and Abi::Zext elsewhere, and on SysV neither the
caller nor the callee may assume anything about those bits at all.
Zext
An integer narrower than a register, with zeroes above it.
ByVal
The bytes of the object the pointer points at, in the argument area, with no address travelling anywhere.
The caller makes the copy the callee is free to write to, which is what makes this a C call by value rather than a pointer the callee must not keep.
Fields
Sret
Somewhere for the return value to go, whose address the caller passes as the first argument because the value does not fit in the registers a return comes back in.