]>
Commit | Line | Data |
---|---|---|
476ff2be | 1 | // Reference: MSP430 Embedded Application Binary Interface |
136023e0 | 2 | // https://www.ti.com/lit/an/slaa534a/slaa534a.pdf |
476ff2be | 3 | |
60c5eb7d | 4 | use crate::abi::call::{ArgAbi, FnAbi}; |
476ff2be SL |
5 | |
6 | // 3.5 Structures or Unions Passed and Returned by Reference | |
7 | // | |
8 | // "Structures (including classes) and unions larger than 32 bits are passed and | |
9 | // returned by reference. To pass a structure or union by reference, the caller | |
10 | // places its address in the appropriate location: either in a register or on | |
11 | // the stack, according to its position in the argument list. (..)" | |
60c5eb7d | 12 | fn classify_ret<Ty>(ret: &mut ArgAbi<'_, Ty>) { |
ff7c6d11 XL |
13 | if ret.layout.is_aggregate() && ret.layout.size.bits() > 32 { |
14 | ret.make_indirect(); | |
476ff2be SL |
15 | } else { |
16 | ret.extend_integer_width_to(16); | |
17 | } | |
18 | } | |
19 | ||
60c5eb7d | 20 | fn classify_arg<Ty>(arg: &mut ArgAbi<'_, Ty>) { |
ff7c6d11 XL |
21 | if arg.layout.is_aggregate() && arg.layout.size.bits() > 32 { |
22 | arg.make_indirect(); | |
476ff2be SL |
23 | } else { |
24 | arg.extend_integer_width_to(16); | |
25 | } | |
26 | } | |
27 | ||
60c5eb7d XL |
28 | pub fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) { |
29 | if !fn_abi.ret.is_ignore() { | |
30 | classify_ret(&mut fn_abi.ret); | |
476ff2be SL |
31 | } |
32 | ||
60c5eb7d | 33 | for arg in &mut fn_abi.args { |
476ff2be SL |
34 | if arg.is_ignore() { |
35 | continue; | |
36 | } | |
60c5eb7d | 37 | classify_arg(arg); |
476ff2be SL |
38 | } |
39 | } |