1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use llvm::*;
use super::common::*;
use super::machine::*;
use abi::{ArgType, FnType};
use type_::Type;
pub fn compute_abi_info(ccx: &CrateContext, fty: &mut FnType) {
let fixup = |a: &mut ArgType| {
match 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)),
_ => a.make_indirect(ccx)
},
Integer => match llsize_of_alloc(ccx, a.ty) {
1 ... 8 => a.extend_integer_width_to(32),
16 => a.make_indirect(ccx),
_ => bug!(),
},
_ => (),
}
};
if !fty.ret.is_ignore() {
fixup(&mut fty.ret);
}
for arg in &mut fty.args {
if arg.is_ignore() { continue; }
fixup(arg);
}
}