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.
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.
13 use super::machine
::*;
14 use trans
::cabi
::{ArgType, FnType}
;
15 use trans
::type_
::Type
;
17 // Win64 ABI: http://msdn.microsoft.com/en-us/library/zthk2dkh.aspx
19 pub fn compute_abi_info(ccx
: &CrateContext
,
22 ret_def
: bool
) -> FnType
{
23 let mut arg_tys
= Vec
::new();
27 ret_ty
= ArgType
::direct(Type
::void(ccx
), None
, None
, None
);
28 } else if rty
.kind() == Struct
{
29 ret_ty
= match llsize_of_alloc(ccx
, rty
) {
30 1 => ArgType
::direct(rty
, Some(Type
::i8(ccx
)), None
, None
),
31 2 => ArgType
::direct(rty
, Some(Type
::i16(ccx
)), None
, None
),
32 4 => ArgType
::direct(rty
, Some(Type
::i32(ccx
)), None
, None
),
33 8 => ArgType
::direct(rty
, Some(Type
::i64(ccx
)), None
, None
),
34 _
=> ArgType
::indirect(rty
, Some(Attribute
::StructRet
))
37 let attr
= if rty
== Type
::i1(ccx
) { Some(Attribute::ZExt) }
else { None }
;
38 ret_ty
= ArgType
::direct(rty
, None
, None
, attr
);
42 let ty
= match t
.kind() {
44 match llsize_of_alloc(ccx
, t
) {
45 1 => ArgType
::direct(t
, Some(Type
::i8(ccx
)), None
, None
),
46 2 => ArgType
::direct(t
, Some(Type
::i16(ccx
)), None
, None
),
47 4 => ArgType
::direct(t
, Some(Type
::i32(ccx
)), None
, None
),
48 8 => ArgType
::direct(t
, Some(Type
::i64(ccx
)), None
, None
),
49 _
=> ArgType
::indirect(t
, None
)
53 let attr
= if t
== Type
::i1(ccx
) { Some(Attribute::ZExt) }
else { None }
;
54 ArgType
::direct(t
, None
, None
, attr
)