]> git.lizzy.rs Git - rust.git/blob - src/librustc_trans/cabi_x86_win64.rs
Remove the in-tree `flate` crate
[rust.git] / src / librustc_trans / cabi_x86_win64.rs
1 // Copyright 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::{ArgType, FnType, LayoutExt, Reg};
12 use common::CrateContext;
13
14 use rustc::ty::layout::Layout;
15
16 // Win64 ABI: http://msdn.microsoft.com/en-us/library/zthk2dkh.aspx
17
18 pub fn compute_abi_info<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fty: &mut FnType<'tcx>) {
19     let fixup = |a: &mut ArgType<'tcx>| {
20         let size = a.layout.size(ccx);
21         if a.layout.is_aggregate() {
22             match size.bits() {
23                 8 => a.cast_to(ccx, Reg::i8()),
24                 16 => a.cast_to(ccx, Reg::i16()),
25                 32 => a.cast_to(ccx, Reg::i32()),
26                 64 => a.cast_to(ccx, Reg::i64()),
27                 _ => a.make_indirect(ccx)
28             };
29         } else {
30             if let Layout::Vector { .. } = *a.layout {
31                 // FIXME(eddyb) there should be a size cap here
32                 // (probably what clang calls "illegal vectors").
33             } else if size.bytes() > 8 {
34                 a.make_indirect(ccx);
35             } else {
36                 a.extend_integer_width_to(32);
37             }
38         }
39     };
40
41     if !fty.ret.is_ignore() {
42         fixup(&mut fty.ret);
43     }
44     for arg in &mut fty.args {
45         if arg.is_ignore() { continue; }
46         fixup(arg);
47     }
48 }