|
1 | 1 | use super::{ArgAttribute, ArgAttributes, ArgExtension, CastTarget}; |
2 | | -use crate::abi::call::{ArgAbi, FnAbi, PassMode, Reg, Size, Uniform}; |
| 2 | +use crate::abi::call::{ArgAbi, FnAbi, Reg, Size, Uniform}; |
3 | 3 | use crate::abi::{HasDataLayout, TyAbiInterface}; |
4 | 4 |
|
5 | 5 | fn classify_ret<Ty>(ret: &mut ArgAbi<'_, Ty>) { |
@@ -53,22 +53,29 @@ where |
53 | 53 | Ty: TyAbiInterface<'a, C> + Copy, |
54 | 54 | C: HasDataLayout, |
55 | 55 | { |
56 | | - if matches!(arg.mode, PassMode::Pair(..)) && (arg.layout.is_adt() || arg.layout.is_tuple()) { |
57 | | - let align_bytes = arg.layout.align.abi.bytes(); |
58 | | - |
59 | | - let unit = match align_bytes { |
60 | | - 1 => Reg::i8(), |
61 | | - 2 => Reg::i16(), |
62 | | - 4 => Reg::i32(), |
63 | | - 8 => Reg::i64(), |
64 | | - 16 => Reg::i128(), |
65 | | - _ => unreachable!("Align is given as power of 2 no larger than 16 bytes"), |
66 | | - }; |
67 | | - arg.cast_to(Uniform::new(unit, Size::from_bytes(2 * align_bytes))); |
68 | | - } else { |
69 | | - // FIXME: find a better way to do this. See https://github.com/rust-lang/rust/issues/117271. |
70 | | - arg.make_direct_deprecated(); |
| 56 | + match arg.mode { |
| 57 | + super::PassMode::Ignore | super::PassMode::Direct(_) => return, |
| 58 | + super::PassMode::Pair(_, _) => {} |
| 59 | + super::PassMode::Cast { .. } => unreachable!(), |
| 60 | + super::PassMode::Indirect { .. } => {} |
71 | 61 | } |
| 62 | + |
| 63 | + // FIXME only allow structs and wide pointers here |
| 64 | + // panic!( |
| 65 | + // "`extern \"ptx-kernel\"` doesn't allow passing types other than primitives and structs" |
| 66 | + // ); |
| 67 | + |
| 68 | + let align_bytes = arg.layout.align.abi.bytes(); |
| 69 | + |
| 70 | + let unit = match align_bytes { |
| 71 | + 1 => Reg::i8(), |
| 72 | + 2 => Reg::i16(), |
| 73 | + 4 => Reg::i32(), |
| 74 | + 8 => Reg::i64(), |
| 75 | + 16 => Reg::i128(), |
| 76 | + _ => unreachable!("Align is given as power of 2 no larger than 16 bytes"), |
| 77 | + }; |
| 78 | + arg.cast_to(Uniform::new(unit, arg.layout.size)); |
72 | 79 | } |
73 | 80 |
|
74 | 81 | pub(crate) fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) { |
|
0 commit comments