pub enum Abi {
Default,
SoftFloat,
SoftFp,
SingleFloat,
DoubleFloat,
}Expand description
The variant of the platform ABI that decides where floating point arguments go.
This is a separate field from the environment because on ARM it is genuinely orthogonal to
the libc, and because it is the clearest case of spec/cross-compile/03-target-model.md’s rule: it changes
how a function is called, so it is in the tuple. GCC fuses it into the environment component
as gnueabihf, and crate::TargetTuple reproduces that spelling on output rather than
storing the fused form.
The names are the ones the RISC-V and LoongArch -mabi= flags use, minus the data model
prefix that those flags carry redundantly. -mabi=lp64d is
DataModel::Lp64 plus Abi::DoubleFloat, and splitting it means
the data model is written down once.
Variants§
Default
The psABI default for this target. Resolved by Abi::resolve, which is what code
generation should call rather than matching on this variant.
SoftFloat
Floating point arguments in integer registers, and no FPU assumed. -mfloat-abi=soft,
-mabi=lp64, -mabi=ilp32.
SoftFp
Floating point arguments in integer registers, but FPU instructions are emitted for
arithmetic. ARM’s softfp, which is ABI compatible with soft float and faster.
SingleFloat
Single precision floating point arguments in float registers. -mabi=lp64f. RISC-V
only; no target in the matrix uses it, and it exists because leaving it out would make
the enumeration a lie about the ABI space.
DoubleFloat
Double precision floating point arguments in float registers. -mfloat-abi=hard,
-mabi=lp64d, -mabi=ilp32d.
Implementations§
Source§impl Abi
impl Abi
Sourcepub const fn as_str(self) -> &'static str
pub const fn as_str(self) -> &'static str
The name used in diagnostics, in --print-config and in -mabi= reconstruction.
Sourcepub const fn resolve(
self,
arch: Arch,
sub_arch: SubArch,
os: Os,
env: Env,
) -> Abi
pub const fn resolve( self, arch: Arch, sub_arch: SubArch, os: Os, env: Env, ) -> Abi
The concrete ABI for a target that did not name one.
Every case here is a psABI reading rather than a preference. AArch64, x86-64 and Darwin
have one float ABI so there is nothing to choose. RISC-V and LoongArch Linux are LP64D by
convention and by every distribution’s build. Bare metal ARM is soft float because the
core may have no FPU, and ARM Linux is hard float because every ARM distribution shipping
today is, which is why the matrix rows are all eabihf.
Sourcepub const fn is_valid_for(self, arch: Arch) -> bool
pub const fn is_valid_for(self, arch: Arch) -> bool
Whether this ABI may be named for this architecture.
Naming a float ABI on x86-64 is a spelling error rather than a configuration, because SysV AMD64 has one convention and there is nothing to select. Saying so is the whole point of validating the tuple: the alternative is accepting the flag and ignoring it.