]> git.lizzy.rs Git - rust.git/blob - src/librustc_target/abi/call/msp430.rs
Auto merge of #57770 - Zoxc:no-hash-query, r=michaelwoerister
[rust.git] / src / librustc_target / abi / call / msp430.rs
1 // Reference: MSP430 Embedded Application Binary Interface
2 // http://www.ti.com/lit/an/slaa534/slaa534.pdf
3
4 use crate::abi::call::{ArgType, FnType};
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. (..)"
12 fn classify_ret_ty<Ty>(ret: &mut ArgType<'_, Ty>) {
13     if ret.layout.is_aggregate() && ret.layout.size.bits() > 32 {
14         ret.make_indirect();
15     } else {
16         ret.extend_integer_width_to(16);
17     }
18 }
19
20 fn classify_arg_ty<Ty>(arg: &mut ArgType<'_, Ty>) {
21     if arg.layout.is_aggregate() && arg.layout.size.bits() > 32 {
22         arg.make_indirect();
23     } else {
24         arg.extend_integer_width_to(16);
25     }
26 }
27
28 pub fn compute_abi_info<Ty>(fty: &mut FnType<'_, Ty>) {
29     if !fty.ret.is_ignore() {
30         classify_ret_ty(&mut fty.ret);
31     }
32
33     for arg in &mut fty.args {
34         if arg.is_ignore() {
35             continue;
36         }
37         classify_arg_ty(arg);
38     }
39 }