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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
pub use self::ArgKind::*;
use llvm::Attribute;
use std::option;
use trans::context::CrateContext;
use trans::cabi_x86;
use trans::cabi_x86_64;
use trans::cabi_x86_win64;
use trans::cabi_arm;
use trans::cabi_mips;
use trans::type_::Type;
#[deriving(Clone, PartialEq)]
pub enum ArgKind {
Direct,
Indirect,
Ignore,
}
#[deriving(Clone)]
pub struct ArgType {
pub kind: ArgKind,
pub ty: Type,
pub cast: option::Option<Type>,
pub pad: option::Option<Type>,
pub attr: option::Option<Attribute>
}
impl ArgType {
pub fn direct(ty: Type, cast: option::Option<Type>,
pad: option::Option<Type>,
attr: option::Option<Attribute>) -> ArgType {
ArgType {
kind: Direct,
ty: ty,
cast: cast,
pad: pad,
attr: attr
}
}
pub fn indirect(ty: Type, attr: option::Option<Attribute>) -> ArgType {
ArgType {
kind: Indirect,
ty: ty,
cast: option::None,
pad: option::None,
attr: attr
}
}
pub fn ignore(ty: Type) -> ArgType {
ArgType {
kind: Ignore,
ty: ty,
cast: None,
pad: None,
attr: None,
}
}
pub fn is_indirect(&self) -> bool {
return self.kind == Indirect;
}
pub fn is_ignore(&self) -> bool {
return self.kind == Ignore;
}
}
pub struct FnType {
pub arg_tys: Vec<ArgType> ,
pub ret_ty: ArgType,
}
pub fn compute_abi_info(ccx: &CrateContext,
atys: &[Type],
rty: Type,
ret_def: bool) -> FnType {
match ccx.sess().target.target.arch.as_slice() {
"x86" => cabi_x86::compute_abi_info(ccx, atys, rty, ret_def),
"x86_64" => if ccx.sess().target.target.options.is_like_windows {
cabi_x86_win64::compute_abi_info(ccx, atys, rty, ret_def)
} else {
cabi_x86_64::compute_abi_info(ccx, atys, rty, ret_def)
},
"arm" => cabi_arm::compute_abi_info(ccx, atys, rty, ret_def),
"mips" => cabi_mips::compute_abi_info(ccx, atys, rty, ret_def),
a => ccx.sess().fatal((format!("unrecognized arch \"{}\" in target specification", a))
.as_slice()),
}
}