diff options
| author | bors <bors@rust-lang.org> | 2025-02-06 06:45:07 +0000 | 
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-02-06 06:45:07 +0000 | 
| commit | 59588250ad973ce69bd15879314c9769e65f36b3 (patch) | |
| tree | 25e49a356546f6a242f6ea26a94071b3f1a96ad1 /compiler/rustc_target/src | |
| parent | c753cb9b42e530950204dd0367525cce12811cdd (diff) | |
| parent | c549268a4a64c0a2c2288c6eee74173cdd7ad37e (diff) | |
| download | rust-59588250ad973ce69bd15879314c9769e65f36b3.tar.gz rust-59588250ad973ce69bd15879314c9769e65f36b3.zip | |
Auto merge of #136613 - workingjubilee:rollup-ry6rw0m, r=workingjubilee
Rollup of 13 pull requests Successful merges: - #133932 (Avoid using make_direct_deprecated() in extern "ptx-kernel") - #136269 (Pass spans around new solver) - #136550 (Fix `rustc_hidden_type_of_opaques` for RPITITs with no default body) - #136558 (Document minimum supported host tooling on macOS) - #136563 (Clean up `Trivial*Impls` macros) - #136566 (Fix link in from_fn.rs) - #136573 (Document why some "type mismatches" exist) - #136583 (Only highlight unmatchable parameters at the definition site) - #136587 (Update browser-ui-test version to `0.20.2`) - #136590 (Implement RustcInternal for RawPtrKind) - #136591 (Add `rustc_hir_pretty::expr_to_string` function) - #136595 (Fix `unreachable_pub` lint for hermit target) - #136611 (cg_llvm: Remove the `mod llvm_` hack, which should no longer be necessary) Failed merges: - #136565 (compiler: Clean up weird `rustc_abi` reexports) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_target/src')
| -rw-r--r-- | compiler/rustc_target/src/callconv/nvptx64.rs | 44 | 
1 files changed, 30 insertions, 14 deletions
| diff --git a/compiler/rustc_target/src/callconv/nvptx64.rs b/compiler/rustc_target/src/callconv/nvptx64.rs index 2e8b16d3a93..c64164372a1 100644 --- a/compiler/rustc_target/src/callconv/nvptx64.rs +++ b/compiler/rustc_target/src/callconv/nvptx64.rs @@ -1,5 +1,5 @@ use super::{ArgAttribute, ArgAttributes, ArgExtension, CastTarget}; -use crate::abi::call::{ArgAbi, FnAbi, PassMode, Reg, Size, Uniform}; +use crate::abi::call::{ArgAbi, FnAbi, Reg, Size, Uniform}; use crate::abi::{HasDataLayout, TyAbiInterface}; fn classify_ret<Ty>(ret: &mut ArgAbi<'_, Ty>) { @@ -53,21 +53,37 @@ where Ty: TyAbiInterface<'a, C> + Copy, C: HasDataLayout, { - if matches!(arg.mode, PassMode::Pair(..)) && (arg.layout.is_adt() || arg.layout.is_tuple()) { - let align_bytes = arg.layout.align.abi.bytes(); + match arg.mode { + super::PassMode::Ignore | super::PassMode::Direct(_) => return, + super::PassMode::Pair(_, _) => {} + super::PassMode::Cast { .. } => unreachable!(), + super::PassMode::Indirect { .. } => {} + } + + // FIXME only allow structs and wide pointers here + // panic!( + // "`extern \"ptx-kernel\"` doesn't allow passing types other than primitives and structs" + // ); + + let align_bytes = arg.layout.align.abi.bytes(); - let unit = match align_bytes { - 1 => Reg::i8(), - 2 => Reg::i16(), - 4 => Reg::i32(), - 8 => Reg::i64(), - 16 => Reg::i128(), - _ => unreachable!("Align is given as power of 2 no larger than 16 bytes"), - }; - arg.cast_to(Uniform::new(unit, Size::from_bytes(2 * align_bytes))); + let unit = match align_bytes { + 1 => Reg::i8(), + 2 => Reg::i16(), + 4 => Reg::i32(), + 8 => Reg::i64(), + 16 => Reg::i128(), + _ => unreachable!("Align is given as power of 2 no larger than 16 bytes"), + }; + if arg.layout.size.bytes() / align_bytes == 1 { + // Make sure we pass the struct as array at the LLVM IR level and not as a single integer. + arg.cast_to(CastTarget { + prefix: [Some(unit), None, None, None, None, None, None, None], + rest: Uniform::new(unit, Size::ZERO), + attrs: ArgAttributes::new(), + }); } else { - // FIXME: find a better way to do this. See https://github.com/rust-lang/rust/issues/117271. - arg.make_direct_deprecated(); + arg.cast_to(Uniform::new(unit, arg.layout.size)); } } | 
