DoxigAlpha

stackAlignment

Function parameters

Parameters

#
target:*const Target

Type definitions in this namespace

Types

#

Functions in this namespace

Functions

#
requiresLibC
Does this target require linking libc? This may be the case if the target has an unstable
cCharSignedness
Default signedness of `char` for the native C compiler for this target

Source

Implementation

#
pub fn stackAlignment(target: *const Target) u16 {
    // Overrides for when the stack alignment is not equal to the pointer width.
    switch (target.cpu.arch) {
        .m68k,
        => return 2,
        .amdgcn,
        => return 4,
        .arm,
        .armeb,
        .thumb,
        .thumbeb,
        .lanai,
        .mips,
        .mipsel,
        .sparc,
        => return 8,
        .aarch64,
        .aarch64_be,
        .bpfeb,
        .bpfel,
        .loongarch32,
        .loongarch64,
        .mips64,
        .mips64el,
        .sparc64,
        .ve,
        .wasm32,
        .wasm64,
        => return 16,
        // Some of the following prongs should really be testing the ABI, but our current `Abi` enum
        // can't handle that level of nuance yet.
        .powerpc64,
        .powerpc64le,
        => if (target.os.tag == .linux or target.os.tag == .aix) return 16,
        .riscv32,
        .riscv64,
        => if (!target.cpu.has(.riscv, .e)) return 16,
        .x86 => if (target.os.tag != .windows and target.os.tag != .uefi) return 16,
        .x86_64 => return 16,
        else => {},
    }

    return @divExact(target.ptrBitWidth(), 8);
}