summary refs log tree commit diff
path: root/compiler/rustc_target/src/callconv
AgeCommit message (Collapse)AuthorLines
2025-03-25make -Zwasm-c-abi=legacy suppress the lintRalf Jung-1/+1
2025-03-25add FCW to warn about wasm ABI transitionRalf Jung-0/+3
2025-03-07Rollup merge of #137363 - workingjubilee:untangle-x86-abi-impl, r=jieyouxuJacob Pratt-23/+89
compiler: factor Windows x86-32 ABI impl into its own file While it shares more than zero code with the SysV x86-32 ABI impl, there is no particular reason to organize wildly different ABIs using if-else in the same function.
2025-03-05compiler: factor Windows x86-32 ABI impl into its own fileJubilee Young-23/+89
While it shares more than zero code with the SysV x86-32 ABI impl, there is no particular reason to organize wildly different ABIs using if-else in the same function.
2025-02-28rename BackendRepr::Vector → SimdVectorRalf Jung-13/+13
2025-02-20Rollup merge of #137318 - bjorn3:cg_clif_abi_workaround, r=workingjubileeJubilee-1/+3
Workaround Cranelift not yet properly supporting vectors smaller than 128bit While it would technically be possible to workaround this in cg_clif, it quickly becomes very messy and would likely cause correctness issues. Working around it in rustc instead is much simper and won't have any negative impact for code running on stable as vectors smaller than 128bit can only be made on nightly using core::simd or #[repr(simd)].
2025-02-20Remove `BackendRepr::Uninhabited`, replaced with an `uninhabited: bool` ↵Zachary S-10/+5
field in `LayoutData`. Also update comments that refered to BackendRepr::Uninhabited.
2025-02-20Workaround Cranelift not yet properly supporting vectors smaller than 128bitbjorn3-1/+3
While it would technically be possible to workaround this in cg_clif, it quickly becomes very messy and would likely cause correctness issues. Working around it in rustc instead is much simper and won't have any negative impact for code running on stable as vectors smaller than 128bit can only be made on nightly using core::simd or #[repr(simd)].
2025-02-19Rollup merge of #137094 - RalfJung:softfloat-means-no-simd, r=tgross35Matthias Krüger-6/+10
x86_win64 ABI: do not use xmm0 with softfloat ABI This adjusts https://github.com/rust-lang/rust/pull/134290 to not apply the new logic to targets marked as "softfloat". That fixes most instances of the issue brought up [here](https://github.com/rust-lang/rust/issues/116558#issuecomment-2661027437). r? `@tgross35`
2025-02-19x86_win64 ABI: do not use xmm0 with softfloat ABIRalf Jung-6/+10
2025-02-18x86-sse2 ABI: use SSE registers for floats and SIMDRalf Jung-47/+85
2025-02-12Rollup merge of #136807 - ↵Jacob Pratt-4/+2
workingjubilee:merge-gpus-to-get-the-arcradeongeforce, r=bjorn3 compiler: internally merge `PtxKernel` into `GpuKernel` r? ``@bjorn3`` for review
2025-02-10compiler: die immediately instead of handling unknown target codegenJubilee Young-22/+3
We cannot produce anything useful if asked to compile unknown targets. We should handle the error immediately at the point of discovery instead of propagating it upward, and preferably in the simplest way: Die. This allows cleaning up our "error-handling" spread across 5 crates.
2025-02-09compiler: internally merge `Conv::PtxKernel` into `GpuKernel`Jubilee Young-4/+2
It is speculated that these two can be conceptually merged, and it can start by ripping out rustc's notion of the PtxKernel call convention. Leave the ExternAbi for now, but the nvptx target now should see it as just a different way to spell Conv::GpuKernel.
2025-02-07compiler: remove reexports from rustc_target::callconvJubilee Young-3/+2
2025-02-07compiler: remove rustc_target::abi entirelyJubilee Young-22/+22
2025-02-06compiler: make rustc_target have less weird reexportsJubilee Young-93/+116
rustc_target has had a lot of weird reexports for various reasons, but now we're at a point where we can actually start reducing their number. We remove weird shadowing-dependent behavior and import directly from rustc_abi instead of doing weird renaming imports. This is only incremental progress and does not entirely fix the crate.
2025-02-05Rollup merge of #133932 - bjorn3:fix_ptx_kernel_abi, r=wesleywiserJubilee-14/+30
Avoid using make_direct_deprecated() in extern "ptx-kernel" This method will be removed in the future as it produces a broken ABI that depends on cg_llvm implementation details. After this PR wasm32-unknown-unknown is the only remaining user of make_direct_deprecated(). Fixes https://github.com/rust-lang/rust/issues/117271 Blocks https://github.com/rust-lang/rust/issues/38788
2025-01-28Auto merge of #134290 - tgross35:windows-i128-callconv, r=bjorn3,wesleywiserbors-7/+13
Windows x86: Change i128 to return via the vector ABI Clang and GCC both return `i128` in xmm0 on windows-msvc and windows-gnu. Currently, Rust returns the type on the stack. Add a calling convention adjustment so we also return scalar `i128`s using the vector ABI, which makes our `i128` compatible with C. In the future, Clang may change to return `i128` on the stack for its `-msvc` targets (more at [1]). If this happens, the change here will need to be adjusted to only affect MinGW. Link: https://github.com/rust-lang/rust/issues/134288 (does not fix) [1] try-job: x86_64-msvc try-job: x86_64-msvc-ext1 try-job: x86_64-mingw-1 try-job: x86_64-mingw-2
2025-01-27Windows x86: Change `i128` to return via the vector ABITrevor Gross-7/+13
Clang and GCC both return `i128` in xmm0 on windows-msvc and windows-gnu. Currently, Rust returns the type on the stack. Add a calling convention adjustment so we also return scalar `i128`s using the vector ABI, which makes our `i128` compatible with C. In the future, Clang may change to return `i128` on the stack for its `-msvc` targets (more at [1]). If this happens, the change here will need to be adjusted to only affect MinGW. Link: https://github.com/rust-lang/rust/issues/134288
2025-01-26Restore previous ABI for f_single_u8_argbjorn3-1/+10
2025-01-26Avoid using make_direct_deprecated() in extern "ptx-kernel"bjorn3-16/+23
This method will be removed in the future as it produces a broken ABI that depends on cg_llvm implementation details. After this PR wasm32-unknown-unknown is the only remaining user of make_direct_deprecated().
2025-01-25Rollup merge of #135785 - folkertdev:s390x-vector-passmode-direct, r=bjorn3Jacob Pratt-3/+11
use `PassMode::Direct` for vector types on `s390x` closes https://github.com/rust-lang/rust/issues/135744 tracking issue: https://github.com/rust-lang/rust/issues/130869 Previously, all vector types were type erased to `Ni8`, now we pass non-wrapped vector types directly. That skips emitting a bunch of casting logic in rustc, that LLVM then has to clean up. The initial LLVM IR is also a bit more readable. This calling convention is tested extensively in `tests/assembly/s390x-vector-abi.rs`, showing that this change has no impact on the ABI in practice. r? ````@taiki-e````
2025-01-22Rollup merge of #134396 - mustartt:byval-pointer-natural-alignment, ↵Matthias Krüger-1/+3
r=wesleywiser AIX: use align 8 for byval parameter On AIX, byval pointer arguments are aligned to 8 bytes based on the 64bit register size. For example, the C callee https://godbolt.org/z/5f4vnG6bh will expect the following argument. ``` ptr nocapture noundef readonly byval(%struct.TwoU64s) align 8 %0 ``` This case is captured by `run-make/extern-fn-explicit-align`
2025-01-20on s390x, use `PassMode::Direct` for vector typesFolkert de Vries-3/+11
2025-01-17Auto merge of #135534 - folkertdev:fix-wasm-i128-f128, r=tgross35bors-0/+12
use indirect return for `i128` and `f128` on wasm32 fixes #135532 Based on https://github.com/WebAssembly/tool-conventions/blob/main/BasicCABI.md we now use an indirect return for `i128`, `u128` and `f128`. That is what LLVM ended up doing anyway. r? `@bjorn3`
2025-01-17Auto merge of #135047 - Flakebi:amdgpu-kernel-cc, r=workingjubileebors-0/+3
Add gpu-kernel calling convention The amdgpu-kernel calling convention was reverted in commit f6b21e90d1ec01081bc2619efb68af6788a63d65 (#120495 and https://github.com/rust-lang/rust-analyzer/pull/16463) due to inactivity in the amdgpu target. Introduce a `gpu-kernel` calling convention that translates to `ptx_kernel` or `amdgpu_kernel`, depending on the target that rust compiles for. Tracking issue: #135467 amdgpu target tracking issue: #135024
2025-01-16use indirect return for `i128` and `f128` on wasm32Folkert de Vries-0/+12
2025-01-16Add gpu-kernel calling conventionFlakebi-0/+3
The amdgpu-kernel calling convention was reverted in commit f6b21e90d1ec01081bc2619efb68af6788a63d65 due to inactivity in the amdgpu target. Introduce a `gpu-kernel` calling convention that translates to `ptx_kernel` or `amdgpu_kernel`, depending on the target that rust compiles for.
2025-01-12on Windows, consistently pass ZST by-refRalf Jung-16/+10
2025-01-10fix ZST handling for Windows ABIs on MSVC targetRalf Jung-23/+30
2024-12-18make no-variant types a dedicated Variants variantRalf Jung-3/+3
2024-12-17byval parameter should have align 8 on aixHenry Jiang-1/+3
2024-12-13Fix powerpc64 big-endian FreeBSD ABITaiki Endo-1/+1
2024-12-02rust_for_linux: -Zreg-struct-return commandline flag for X86 (#116973)Andrew Zhogin-2/+5
2024-11-22Rollup merge of #133102 - RalfJung:aarch64-softfloat, r=davidtwco,wesleywiserMichael Goulet-5/+58
aarch64 softfloat target: always pass floats in int registers This is a part of https://github.com/rust-lang/rust/issues/131058: on softfloat aarch64 targets, the float registers may be unavailable. And yet, LLVM will happily use them to pass float types if the corresponding target features are enabled. That's a problem as it means enabling/disabling `neon` instructions can change the ABI. Other targets have a `soft-float` target feature that forces the use of the soft-float ABI no matter whether float registers are enabled or not; aarch64 has nothing like that. So we follow the aarch64 [softfloat ABI](https://github.com/rust-lang/rust/issues/131058#issuecomment-2385027423) and treat floats like integers for `extern "C"` functions. For the "Rust" ABI, we do the same for scalars, and then just do something reasonable for ScalarPair that avoids the pointer indirection. Cc ```@workingjubilee```
2024-11-20aarch64 softfloat target: always pass floats in int registersRalf Jung-5/+58
2024-11-14Support s390x z13 vector ABITaiki Endo-8/+18
2024-11-08pointee_info_at: fix logic for recursing into enumsRalf Jung-1/+2
2024-10-29compiler: `rustc_abi::Abi` => `BackendRepr`Jubilee Young-65/+81
The initial naming of "Abi" was an awful mistake, conveying wrong ideas about how psABIs worked and even more about what the enum meant. It was only meant to represent the way the value would be described to a codegen backend as it was lowered to that intermediate representation. It was never meant to mean anything about the actual psABI handling! The conflation is because LLVM typically will associate a certain form with a certain ABI, but even that does not hold when the special cases that actually exist arise, plus the IR annotations that modify the ABI. Reframe `rustc_abi::Abi` as the `BackendRepr` of the type, and rename `BackendRepr::Aggregate` as `BackendRepr::Memory`. Unfortunately, due to the persistent misunderstandings, this too is now incorrect: - Scattered ABI-relevant code is entangled with BackendRepr - We do not always pre-compute a correct BackendRepr that reflects how we "actually" want this value to be handled, so we leave the backend interface to also inject various special-cases here - In some cases `BackendRepr::Memory` is a "real" aggregate, but in others it is in fact using memory, and in some cases it is a scalar! Our rustc-to-backend lowering code handles this sort of thing right now. That will eventually be addressed by lifting duplicated lowering code to either rustc_codegen_ssa or rustc_target as appropriate.
2024-10-23Set `signext` or `zeroext` for integer arguments on LoongArch64Asuna-0/+29
2024-10-23Set `signext` or `zeroext` for integer arguments on RISC-VAsuna-0/+28
2024-10-23Introduce `adjust_for_rust_abi` in `rustc_target`Asuna-3/+151
2024-10-18compiler: Revert -Zregparm handling for extern RustJubilee Young-22/+0
2024-10-18rust_for_linux: -Zregparm=<N> commandline flag for X86 (#116972)Andrew Zhogin-49/+99
2024-10-11compiler: Wire `{TyAnd,}Layout` into `rustc_abi`Jubilee Young-247/+2
This finally unites TyAndLayout, Layout, and LayoutS into the same crate, as one might imagine they would be placed. No functional changes.
2024-10-11compiler: Empty out rustc_target::abiJubilee Young-0/+3807