Skip to content

Commit 9d984f5

Browse files
committed
---
yaml --- r: 273246 b: refs/heads/beta c: ac60318 h: refs/heads/master
1 parent 2f5bc3e commit 9d984f5

File tree

11 files changed

+180
-181
lines changed

11 files changed

+180
-181
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: 03942056aac826c89a94d47239244277cc360714
26+
refs/heads/beta: ac60318cf52946027050c18ad68ec85e52555853
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/librustc_trans/trans/abi.rs

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -72,44 +72,22 @@ pub struct ArgType {
7272
}
7373

7474
impl ArgType {
75-
pub fn direct(ty: Type, cast: Option<Type>,
76-
pad: Option<Type>,
77-
attr: Option<llvm::Attribute>) -> ArgType {
75+
fn new(ty: Type) -> ArgType {
7876
ArgType {
7977
kind: Direct,
8078
ty: ty,
81-
cast: cast,
82-
pad: pad,
83-
attr: attr
84-
}
85-
}
86-
87-
pub fn indirect(ty: Type, attr: Option<llvm::Attribute>) -> ArgType {
88-
ArgType {
89-
kind: Indirect,
90-
ty: ty,
91-
cast: Option::None,
92-
pad: Option::None,
93-
attr: attr
94-
}
95-
}
96-
97-
pub fn ignore(ty: Type) -> ArgType {
98-
ArgType {
99-
kind: Ignore,
100-
ty: ty,
10179
cast: None,
10280
pad: None,
103-
attr: None,
81+
attr: None
10482
}
10583
}
10684

10785
pub fn is_indirect(&self) -> bool {
108-
return self.kind == Indirect;
86+
self.kind == Indirect
10987
}
11088

11189
pub fn is_ignore(&self) -> bool {
112-
return self.kind == Ignore;
90+
self.kind == Ignore
11391
}
11492
}
11593

@@ -200,17 +178,15 @@ impl FnType {
200178
for ty in inputs.iter().chain(extra_args.iter()) {
201179
let llty = c_type_of(ccx, ty);
202180
if type_is_fat_ptr(ccx.tcx(), ty) {
203-
args.extend(llty.field_types().into_iter().map(|llty| {
204-
ArgType::direct(llty, None, None, None)
205-
}));
181+
args.extend(llty.field_types().into_iter().map(ArgType::new));
206182
} else {
207-
args.push(ArgType::direct(llty, None, None, None));
183+
args.push(ArgType::new(llty));
208184
}
209185
}
210186

211187
let mut fty = FnType {
212188
args: args,
213-
ret: ArgType::direct(rty, None, None, None),
189+
ret: ArgType::new(rty),
214190
variadic: sig.variadic,
215191
cconv: cconv
216192
};

branches/beta/src/librustc_trans/trans/cabi_aarch64.rs

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#![allow(non_upper_case_globals)]
1212

1313
use llvm::{Integer, Pointer, Float, Double, Struct, Array, Vector, Attribute};
14-
use trans::abi::{FnType, ArgType};
14+
use trans::abi::{FnType, ArgType, Indirect};
1515
use trans::context::CrateContext;
1616
use trans::type_::Type;
1717

@@ -161,16 +161,18 @@ fn is_homogenous_aggregate_ty(ty: Type) -> Option<(Type, u64)> {
161161
})
162162
}
163163

164-
fn classify_ret_ty(ccx: &CrateContext, ty: Type) -> ArgType {
165-
if is_reg_ty(ty) {
166-
let attr = if ty == Type::i1(ccx) { Some(Attribute::ZExt) } else { None };
167-
return ArgType::direct(ty, None, None, attr);
164+
fn classify_ret_ty(ccx: &CrateContext, ret: &mut ArgType) {
165+
if is_reg_ty(ret.ty) {
166+
if ret.ty == Type::i1(ccx) {
167+
ret.attr = Some(Attribute::ZExt)
168+
}
169+
return;
168170
}
169-
if let Some((base_ty, members)) = is_homogenous_aggregate_ty(ty) {
170-
let llty = Type::array(&base_ty, members);
171-
return ArgType::direct(ty, Some(llty), None, None);
171+
if let Some((base_ty, members)) = is_homogenous_aggregate_ty(ret.ty) {
172+
ret.cast = Some(Type::array(&base_ty, members));
173+
return;
172174
}
173-
let size = ty_size(ty);
175+
let size = ty_size(ret.ty);
174176
if size <= 16 {
175177
let llty = if size <= 1 {
176178
Type::i8(ccx)
@@ -183,21 +185,25 @@ fn classify_ret_ty(ccx: &CrateContext, ty: Type) -> ArgType {
183185
} else {
184186
Type::array(&Type::i64(ccx), ((size + 7 ) / 8 ) as u64)
185187
};
186-
return ArgType::direct(ty, Some(llty), None, None);
188+
ret.cast = Some(llty);
189+
return;
187190
}
188-
ArgType::indirect(ty, Some(Attribute::StructRet))
191+
ret.kind = Indirect;
192+
ret.attr = Some(Attribute::StructRet);
189193
}
190194

191-
fn classify_arg_ty(ccx: &CrateContext, ty: Type) -> ArgType {
192-
if is_reg_ty(ty) {
193-
let attr = if ty == Type::i1(ccx) { Some(Attribute::ZExt) } else { None };
194-
return ArgType::direct(ty, None, None, attr);
195+
fn classify_arg_ty(ccx: &CrateContext, arg: &mut ArgType) {
196+
if is_reg_ty(arg.ty) {
197+
if arg.ty == Type::i1(ccx) {
198+
arg.attr = Some(Attribute::ZExt);
199+
}
200+
return;
195201
}
196-
if let Some((base_ty, members)) = is_homogenous_aggregate_ty(ty) {
197-
let llty = Type::array(&base_ty, members);
198-
return ArgType::direct(ty, Some(llty), None, None);
202+
if let Some((base_ty, members)) = is_homogenous_aggregate_ty(arg.ty) {
203+
arg.cast = Some(Type::array(&base_ty, members));
204+
return;
199205
}
200-
let size = ty_size(ty);
206+
let size = ty_size(arg.ty);
201207
if size <= 16 {
202208
let llty = if size == 0 {
203209
Type::array(&Type::i64(ccx), 0)
@@ -212,9 +218,10 @@ fn classify_arg_ty(ccx: &CrateContext, ty: Type) -> ArgType {
212218
} else {
213219
Type::array(&Type::i64(ccx), ((size + 7 ) / 8 ) as u64)
214220
};
215-
return ArgType::direct(ty, Some(llty), None, None);
221+
arg.cast = Some(llty);
222+
return;
216223
}
217-
ArgType::indirect(ty, None)
224+
arg.kind = Indirect;
218225
}
219226

220227
fn is_reg_ty(ty: Type) -> bool {
@@ -230,10 +237,10 @@ fn is_reg_ty(ty: Type) -> bool {
230237

231238
pub fn compute_abi_info(ccx: &CrateContext, fty: &mut FnType) {
232239
if fty.ret.ty != Type::void(ccx) {
233-
fty.ret = classify_ret_ty(ccx, fty.ret.ty);
240+
classify_ret_ty(ccx, &mut fty.ret);
234241
}
235242

236243
for arg in &mut fty.args {
237-
*arg = classify_arg_ty(ccx, arg.ty);
244+
classify_arg_ty(ccx, arg);
238245
}
239246
}

branches/beta/src/librustc_trans/trans/cabi_arm.rs

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#![allow(non_upper_case_globals)]
1212

1313
use llvm::{Integer, Pointer, Float, Double, Struct, Array, Vector, Attribute};
14-
use trans::abi::{FnType, ArgType};
14+
use trans::abi::{FnType, ArgType, Indirect};
1515
use trans::context::CrateContext;
1616
use trans::type_::Type;
1717

@@ -129,12 +129,14 @@ fn ty_size(ty: Type, align_fn: TyAlignFn) -> usize {
129129
}
130130
}
131131

132-
fn classify_ret_ty(ccx: &CrateContext, ty: Type, align_fn: TyAlignFn) -> ArgType {
133-
if is_reg_ty(ty) {
134-
let attr = if ty == Type::i1(ccx) { Some(Attribute::ZExt) } else { None };
135-
return ArgType::direct(ty, None, None, attr);
132+
fn classify_ret_ty(ccx: &CrateContext, ret: &mut ArgType, align_fn: TyAlignFn) {
133+
if is_reg_ty(ret.ty) {
134+
if ret.ty == Type::i1(ccx) {
135+
ret.attr = Some(Attribute::ZExt);
136+
}
137+
return;
136138
}
137-
let size = ty_size(ty, align_fn);
139+
let size = ty_size(ret.ty, align_fn);
138140
if size <= 4 {
139141
let llty = if size <= 1 {
140142
Type::i8(ccx)
@@ -143,24 +145,28 @@ fn classify_ret_ty(ccx: &CrateContext, ty: Type, align_fn: TyAlignFn) -> ArgType
143145
} else {
144146
Type::i32(ccx)
145147
};
146-
return ArgType::direct(ty, Some(llty), None, None);
148+
ret.cast = Some(llty);
149+
return;
147150
}
148-
ArgType::indirect(ty, Some(Attribute::StructRet))
151+
ret.kind = Indirect;
152+
ret.attr = Some(Attribute::StructRet);
149153
}
150154

151-
fn classify_arg_ty(ccx: &CrateContext, ty: Type, align_fn: TyAlignFn) -> ArgType {
152-
if is_reg_ty(ty) {
153-
let attr = if ty == Type::i1(ccx) { Some(Attribute::ZExt) } else { None };
154-
return ArgType::direct(ty, None, None, attr);
155+
fn classify_arg_ty(ccx: &CrateContext, arg: &mut ArgType, align_fn: TyAlignFn) {
156+
if is_reg_ty(arg.ty) {
157+
if arg.ty == Type::i1(ccx) {
158+
arg.attr = Some(Attribute::ZExt);
159+
}
160+
return;
155161
}
156-
let align = align_fn(ty);
157-
let size = ty_size(ty, align_fn);
162+
let align = align_fn(arg.ty);
163+
let size = ty_size(arg.ty, align_fn);
158164
let llty = if align <= 4 {
159165
Type::array(&Type::i32(ccx), ((size + 3) / 4) as u64)
160166
} else {
161167
Type::array(&Type::i64(ccx), ((size + 7) / 8) as u64)
162168
};
163-
ArgType::direct(ty, Some(llty), None, None)
169+
arg.cast = Some(llty);
164170
}
165171

166172
fn is_reg_ty(ty: Type) -> bool {
@@ -181,10 +187,10 @@ pub fn compute_abi_info(ccx: &CrateContext, fty: &mut FnType, flavor: Flavor) {
181187
};
182188

183189
if fty.ret.ty != Type::void(ccx) {
184-
fty.ret = classify_ret_ty(ccx, fty.ret.ty, align_fn);
190+
classify_ret_ty(ccx, &mut fty.ret, align_fn);
185191
}
186192

187193
for arg in &mut fty.args {
188-
*arg = classify_arg_ty(ccx, arg.ty, align_fn);
194+
classify_arg_ty(ccx, arg, align_fn);
189195
}
190196
}

branches/beta/src/librustc_trans/trans/cabi_asmjs.rs

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#![allow(non_upper_case_globals)]
1212

1313
use llvm::{Struct, Array, Attribute};
14-
use trans::abi::{FnType, ArgType};
14+
use trans::abi::{FnType, ArgType, Indirect};
1515
use trans::context::CrateContext;
1616
use trans::type_::Type;
1717

@@ -20,41 +20,46 @@ use trans::type_::Type;
2020
// See the https://github.com/kripken/emscripten-fastcomp-clang repository.
2121
// The class `EmscriptenABIInfo` in `/lib/CodeGen/TargetInfo.cpp` contains the ABI definitions.
2222

23-
fn classify_ret_ty(ccx: &CrateContext, ty: Type) -> ArgType {
24-
match ty.kind() {
23+
fn classify_ret_ty(ccx: &CrateContext, ret: &mut ArgType) {
24+
match ret.ty.kind() {
2525
Struct => {
26-
let field_types = ty.field_types();
26+
let field_types = ret.ty.field_types();
2727
if field_types.len() == 1 {
28-
ArgType::direct(ty, Some(field_types[0]), None, None)
28+
ret.cast = Some(field_types[0]);
2929
} else {
30-
ArgType::indirect(ty, Some(Attribute::StructRet))
30+
ret.kind = Indirect;
31+
ret.attr = Some(Attribute::StructRet);
3132
}
3233
},
3334
Array => {
34-
ArgType::indirect(ty, Some(Attribute::StructRet))
35+
ret.kind = Indirect;
36+
ret.attr = Some(Attribute::StructRet);
3537
},
3638
_ => {
37-
let attr = if ty == Type::i1(ccx) { Some(Attribute::ZExt) } else { None };
38-
ArgType::direct(ty, None, None, attr)
39+
if ret.ty == Type::i1(ccx) {
40+
ret.attr = Some(Attribute::ZExt);
41+
}
3942
}
4043
}
4144
}
4245

43-
fn classify_arg_ty(ccx: &CrateContext, ty: Type) -> ArgType {
44-
if ty.is_aggregate() {
45-
ArgType::indirect(ty, Some(Attribute::ByVal))
46+
fn classify_arg_ty(ccx: &CrateContext, arg: &mut ArgType) {
47+
if arg.ty.is_aggregate() {
48+
arg.kind = Indirect;
49+
arg.attr = Some(Attribute::ByVal);
4650
} else {
47-
let attr = if ty == Type::i1(ccx) { Some(Attribute::ZExt) } else { None };
48-
ArgType::direct(ty, None, None, attr)
51+
if arg.ty == Type::i1(ccx) {
52+
arg.attr = Some(Attribute::ZExt);
53+
}
4954
}
5055
}
5156

5257
pub fn compute_abi_info(ccx: &CrateContext, fty: &mut FnType) {
5358
if fty.ret.ty != Type::void(ccx) {
54-
fty.ret = classify_ret_ty(ccx, fty.ret.ty);
59+
classify_ret_ty(ccx, &mut fty.ret);
5560
}
5661

5762
for arg in &mut fty.args {
58-
*arg = classify_arg_ty(ccx, arg.ty);
63+
classify_arg_ty(ccx, arg);
5964
}
6065
}

0 commit comments

Comments
 (0)