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.
12 use syntax::abi::{OsWin32, OsMacos};
16 use super::machine::*;
17 use middle::trans::type_::Type;
19 pub fn compute_abi_info(ccx: &CrateContext,
22 ret_def: bool) -> FnType {
23 let mut arg_tys = ~[];
27 ret_ty = ArgType::direct(Type::void(), None, None, None);
28 } else if rty.kind() == Struct {
29 // Returning a structure. Most often, this will use
30 // a hidden first argument. On some platforms, though,
31 // small structs are returned as integers.
34 // http://www.angelcode.com/dev/callconv/callconv.html
35 // Clang's ABI handling is in lib/CodeGen/TargetInfo.cpp
37 enum Strategy { RetValue(Type), RetPointer }
38 let strategy = match ccx.sess.targ_cfg.os {
39 OsWin32 | OsMacos => {
40 match llsize_of_alloc(ccx, rty) {
41 1 => RetValue(Type::i8()),
42 2 => RetValue(Type::i16()),
43 4 => RetValue(Type::i32()),
44 8 => RetValue(Type::i64()),
55 ret_ty = ArgType::direct(rty, Some(t), None, None);
58 ret_ty = ArgType::indirect(rty, Some(StructRetAttribute));
62 ret_ty = ArgType::direct(rty, None, None, None);
65 for &a in atys.iter() {
66 arg_tys.push(ArgType::direct(a, None, None, None));