]> git.lizzy.rs Git - rust.git/blob - src/librustc_trans/cabi_arm.rs
Fix checking for missing stability annotations
[rust.git] / src / librustc_trans / cabi_arm.rs
1 // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 use abi::{FnType, ArgType, LayoutExt, Reg, Uniform};
12 use context::CrateContext;
13
14 fn classify_ret_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ret: &mut ArgType<'tcx>) {
15     if !ret.layout.is_aggregate() {
16         ret.extend_integer_width_to(32);
17         return;
18     }
19     let size = ret.layout.size(ccx);
20     let bits = size.bits();
21     if bits <= 32 {
22         let unit = if bits <= 8 {
23             Reg::i8()
24         } else if bits <= 16 {
25             Reg::i16()
26         } else {
27             Reg::i32()
28         };
29         ret.cast_to(ccx, Uniform {
30             unit,
31             total: size
32         });
33         return;
34     }
35     ret.make_indirect(ccx);
36 }
37
38 fn classify_arg_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &mut ArgType<'tcx>) {
39     if !arg.layout.is_aggregate() {
40         arg.extend_integer_width_to(32);
41         return;
42     }
43     let align = arg.layout.align(ccx).abi();
44     let total = arg.layout.size(ccx);
45     arg.cast_to(ccx, Uniform {
46         unit: if align <= 4 { Reg::i32() } else { Reg::i64() },
47         total
48     });
49 }
50
51 pub fn compute_abi_info<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fty: &mut FnType<'tcx>) {
52     if !fty.ret.is_ignore() {
53         classify_ret_ty(ccx, &mut fty.ret);
54     }
55
56     for arg in &mut fty.args {
57         if arg.is_ignore() { continue; }
58         classify_arg_ty(ccx, arg);
59     }
60 }