2014-08-07 23:10:48 -07:00
|
|
|
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
|
|
|
use llvm::*;
|
|
|
|
use super::common::*;
|
|
|
|
use super::machine::*;
|
2016-03-22 19:23:36 +02:00
|
|
|
use abi::{ArgType, FnType};
|
|
|
|
use type_::Type;
|
2014-08-07 23:10:48 -07:00
|
|
|
|
|
|
|
// Win64 ABI: http://msdn.microsoft.com/en-us/library/zthk2dkh.aspx
|
|
|
|
|
2016-02-23 21:55:19 +02:00
|
|
|
pub fn compute_abi_info(ccx: &CrateContext, fty: &mut FnType) {
|
2016-02-25 12:11:02 +02:00
|
|
|
let fixup = |a: &mut ArgType| {
|
2016-02-23 21:55:19 +02:00
|
|
|
if a.ty.kind() == Struct {
|
|
|
|
match llsize_of_alloc(ccx, a.ty) {
|
|
|
|
1 => a.cast = Some(Type::i8(ccx)),
|
|
|
|
2 => a.cast = Some(Type::i16(ccx)),
|
|
|
|
4 => a.cast = Some(Type::i32(ccx)),
|
|
|
|
8 => a.cast = Some(Type::i64(ccx)),
|
2016-02-25 19:35:40 +02:00
|
|
|
_ => a.make_indirect(ccx)
|
2014-08-07 23:10:48 -07:00
|
|
|
}
|
2016-02-17 19:33:27 +13:00
|
|
|
} else {
|
|
|
|
a.extend_integer_width_to(32);
|
2016-02-23 21:55:19 +02:00
|
|
|
}
|
2014-08-07 23:10:48 -07:00
|
|
|
};
|
2016-02-23 21:55:19 +02:00
|
|
|
|
2016-03-06 12:36:39 +02:00
|
|
|
if !fty.ret.is_ignore() {
|
2016-02-25 12:11:02 +02:00
|
|
|
fixup(&mut fty.ret);
|
2016-02-24 19:37:22 +02:00
|
|
|
}
|
2016-02-23 21:55:19 +02:00
|
|
|
for arg in &mut fty.args {
|
2016-03-06 12:36:39 +02:00
|
|
|
if arg.is_ignore() { continue; }
|
2016-02-25 12:11:02 +02:00
|
|
|
fixup(arg);
|
2016-02-23 21:55:19 +02:00
|
|
|
}
|
2014-08-07 23:10:48 -07:00
|
|
|
}
|