Skip to content

Commit b4ea61e

Browse files
committed
---
yaml --- r: 83059 b: refs/heads/auto c: 2e1df8e h: refs/heads/master i: 83057: f501a92 83055: 2703882 v: v3
1 parent ef162ef commit b4ea61e

File tree

19 files changed

+729
-501
lines changed

19 files changed

+729
-501
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 95fc31ae9bf8e9f859e6a7ceb43d645ebef33905
16+
refs/heads/auto: 2e1df8e35bb0185dc35f5e7976c0b46608c32404
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/doc/rustpkg.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ and builds it in any workspace(s) where it finds one.
137137
Supposing such packages are found in workspaces X, Y, and Z,
138138
the command leaves behind files in `X`'s, `Y`'s, and `Z`'s `build` directories,
139139
but not in their `lib` or `bin` directories.
140+
(The exception is when rustpkg fetches a package `foo`'s sources from a remote repository.
141+
In that case, it stores both the sources *and* the build artifacts for `foo`
142+
in the workspace that `foo` will install to (see ##install below)).
140143

141144
## clean
142145

@@ -148,7 +151,11 @@ but not in their `lib` or `bin` directories.
148151
If `RUST_PATH` is declared as an environment variable, then rustpkg installs the
149152
libraries and executables into the `lib` and `bin` subdirectories
150153
of the first entry in `RUST_PATH`.
151-
Otherwise, it installs them into `foo`'s `lib` and `bin` directories.
154+
Otherwise, if the current working directory CWD is a workspace,
155+
it installs them into CWD's `lib` and `bin` subdirectories.
156+
Otherwise, if the current working directory is CWD,
157+
it installs them into the .rust/lib and .rust/bin subdirectories of CWD
158+
(creating them if necessary).
152159

153160
## test
154161

branches/auto/src/librustc/middle/trans/cabi.rs

Lines changed: 17 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -18,62 +18,10 @@ use middle::trans::cabi_mips;
1818
use middle::trans::type_::Type;
1919
use syntax::abi::{X86, X86_64, Arm, Mips};
2020

21-
#[deriving(Clone, Eq)]
22-
pub enum ArgKind {
23-
/// Pass the argument directly using the normal converted
24-
/// LLVM type or by coercing to another specified type
25-
Direct,
26-
/// Pass the argument indirectly via a hidden pointer
27-
Indirect
28-
}
29-
30-
/// Information about how a specific C type
31-
/// should be passed to or returned from a function
32-
///
33-
/// This is borrowed from clang's ABIInfo.h
3421
#[deriving(Clone)]
35-
pub struct ArgType {
36-
kind: ArgKind,
37-
/// Original LLVM type
38-
ty: Type,
39-
/// Coerced LLVM Type
40-
cast: option::Option<Type>,
41-
/// Dummy argument, which is emitted before the real argument
42-
pad: option::Option<Type>,
43-
/// LLVM attribute of argument
44-
attr: option::Option<Attribute>
45-
}
46-
47-
impl ArgType {
48-
pub fn direct(ty: Type, cast: option::Option<Type>,
49-
pad: option::Option<Type>,
50-
attr: option::Option<Attribute>) -> ArgType {
51-
ArgType {
52-
kind: Direct,
53-
ty: ty,
54-
cast: cast,
55-
pad: pad,
56-
attr: attr
57-
}
58-
}
59-
60-
pub fn indirect(ty: Type, attr: option::Option<Attribute>) -> ArgType {
61-
ArgType {
62-
kind: Indirect,
63-
ty: ty,
64-
cast: option::None,
65-
pad: option::None,
66-
attr: attr
67-
}
68-
}
69-
70-
pub fn is_direct(&self) -> bool {
71-
return self.kind == Direct;
72-
}
73-
74-
pub fn is_indirect(&self) -> bool {
75-
return self.kind == Indirect;
76-
}
22+
pub struct LLVMType {
23+
cast: bool,
24+
ty: Type
7725
}
7826

7927
/// Metadata describing how the arguments to a native function
@@ -82,11 +30,22 @@ impl ArgType {
8230
/// I will do my best to describe this structure, but these
8331
/// comments are reverse-engineered and may be inaccurate. -NDM
8432
pub struct FnType {
85-
/// The LLVM types of each argument.
86-
arg_tys: ~[ArgType],
33+
/// The LLVM types of each argument. If the cast flag is true,
34+
/// then the argument should be cast, typically because the
35+
/// official argument type will be an int and the rust type is i8
36+
/// or something like that.
37+
arg_tys: ~[LLVMType],
38+
39+
/// A list of attributes to be attached to each argument (parallel
40+
/// the `arg_tys` array). If the attribute for a given is Some,
41+
/// then the argument should be passed by reference.
42+
attrs: ~[option::Option<Attribute>],
8743

8844
/// LLVM return type.
89-
ret_ty: ArgType,
45+
ret_ty: LLVMType,
46+
47+
/// If true, then an implicit pointer should be added for the result.
48+
sret: bool
9049
}
9150

9251
pub fn compute_abi_info(ccx: &mut CrateContext,

branches/auto/src/librustc/middle/trans/cabi_arm.rs

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
#[allow(non_uppercase_pattern_statics)];
1212

1313
use lib::llvm::{llvm, Integer, Pointer, Float, Double, Struct, Array};
14-
use lib::llvm::StructRetAttribute;
15-
use middle::trans::cabi::{FnType, ArgType};
14+
use lib::llvm::{Attribute, StructRetAttribute};
15+
use middle::trans::cabi::{FnType, LLVMType};
1616
use middle::trans::context::CrateContext;
1717

1818
use middle::trans::type_::Type;
1919

2020
use std::num;
21-
use std::option::{None, Some};
21+
use std::option::{Option, None, Some};
2222

2323
fn align_up_to(off: uint, a: uint) -> uint {
2424
return (off + a - 1u) / a * a;
@@ -85,9 +85,9 @@ fn ty_size(ty: Type) -> uint {
8585
}
8686
}
8787

88-
fn classify_ret_ty(ty: Type) -> ArgType {
88+
fn classify_ret_ty(ty: Type) -> (LLVMType, Option<Attribute>) {
8989
if is_reg_ty(ty) {
90-
return ArgType::direct(ty, None, None, None);
90+
return (LLVMType { cast: false, ty: ty }, None);
9191
}
9292
let size = ty_size(ty);
9393
if size <= 4 {
@@ -98,14 +98,14 @@ fn classify_ret_ty(ty: Type) -> ArgType {
9898
} else {
9999
Type::i32()
100100
};
101-
return ArgType::direct(ty, Some(llty), None, None);
101+
return (LLVMType { cast: true, ty: llty }, None);
102102
}
103-
ArgType::indirect(ty, Some(StructRetAttribute))
103+
(LLVMType { cast: false, ty: ty.ptr_to() }, Some(StructRetAttribute))
104104
}
105105

106-
fn classify_arg_ty(ty: Type) -> ArgType {
106+
fn classify_arg_ty(ty: Type) -> (LLVMType, Option<Attribute>) {
107107
if is_reg_ty(ty) {
108-
return ArgType::direct(ty, None, None, None);
108+
return (LLVMType { cast: false, ty: ty }, None);
109109
}
110110
let align = ty_align(ty);
111111
let size = ty_size(ty);
@@ -114,7 +114,7 @@ fn classify_arg_ty(ty: Type) -> ArgType {
114114
} else {
115115
Type::array(&Type::i64(), ((size + 7) / 8) as u64)
116116
};
117-
ArgType::direct(ty, Some(llty), None, None)
117+
(LLVMType { cast: true, ty: llty }, None)
118118
}
119119

120120
fn is_reg_ty(ty: Type) -> bool {
@@ -132,19 +132,32 @@ pub fn compute_abi_info(_ccx: &mut CrateContext,
132132
rty: Type,
133133
ret_def: bool) -> FnType {
134134
let mut arg_tys = ~[];
135+
let mut attrs = ~[];
135136
for &aty in atys.iter() {
136-
let ty = classify_arg_ty(aty);
137+
let (ty, attr) = classify_arg_ty(aty);
137138
arg_tys.push(ty);
139+
attrs.push(attr);
138140
}
139141

140-
let ret_ty = if ret_def {
142+
let (ret_ty, ret_attr) = if ret_def {
141143
classify_ret_ty(rty)
142144
} else {
143-
ArgType::direct(Type::void(), None, None, None)
145+
(LLVMType { cast: false, ty: Type::void() }, None)
144146
};
145147

148+
let mut ret_ty = ret_ty;
149+
150+
let sret = ret_attr.is_some();
151+
if sret {
152+
arg_tys.unshift(ret_ty);
153+
attrs.unshift(ret_attr);
154+
ret_ty = LLVMType { cast: false, ty: Type::void() };
155+
}
156+
146157
return FnType {
147158
arg_tys: arg_tys,
148159
ret_ty: ret_ty,
160+
attrs: attrs,
161+
sret: sret
149162
};
150163
}

branches/auto/src/librustc/middle/trans/cabi_mips.rs

Lines changed: 48 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212

1313
use std::libc::c_uint;
1414
use std::num;
15+
use std::vec;
1516
use lib::llvm::{llvm, Integer, Pointer, Float, Double, Struct, Array};
16-
use lib::llvm::StructRetAttribute;
17+
use lib::llvm::{Attribute, StructRetAttribute};
1718
use middle::trans::context::CrateContext;
1819
use middle::trans::context::task_llcx;
1920
use middle::trans::cabi::*;
@@ -85,15 +86,15 @@ fn ty_size(ty: Type) -> uint {
8586
}
8687
}
8788

88-
fn classify_ret_ty(ty: Type) -> ArgType {
89-
if is_reg_ty(ty) {
90-
ArgType::direct(ty, None, None, None)
89+
fn classify_ret_ty(ty: Type) -> (LLVMType, Option<Attribute>) {
90+
return if is_reg_ty(ty) {
91+
(LLVMType { cast: false, ty: ty }, None)
9192
} else {
92-
ArgType::indirect(ty, Some(StructRetAttribute))
93-
}
93+
(LLVMType { cast: false, ty: ty.ptr_to() }, Some(StructRetAttribute))
94+
};
9495
}
9596

96-
fn classify_arg_ty(ty: Type, offset: &mut uint) -> ArgType {
97+
fn classify_arg_ty(ty: Type, offset: &mut uint) -> (LLVMType, Option<Attribute>) {
9798
let orig_offset = *offset;
9899
let size = ty_size(ty) * 8;
99100
let mut align = ty_align(ty);
@@ -102,16 +103,20 @@ fn classify_arg_ty(ty: Type, offset: &mut uint) -> ArgType {
102103
*offset = align_up_to(*offset, align);
103104
*offset += align_up_to(size, align * 8) / 8;
104105

105-
if is_reg_ty(ty) {
106-
ArgType::direct(ty, None, None, None)
106+
let padding = padding_ty(align, orig_offset);
107+
return if !is_reg_ty(ty) {
108+
(LLVMType {
109+
cast: true,
110+
ty: struct_ty(ty, padding, true)
111+
}, None)
112+
} else if padding.is_some() {
113+
(LLVMType {
114+
cast: true,
115+
ty: struct_ty(ty, padding, false)
116+
}, None)
107117
} else {
108-
ArgType::direct(
109-
ty,
110-
Some(struct_ty(ty)),
111-
padding_ty(align, orig_offset),
112-
None
113-
)
114-
}
118+
(LLVMType { cast: false, ty: ty }, None)
119+
};
115120
}
116121

117122
fn is_reg_ty(ty: Type) -> bool {
@@ -152,33 +157,54 @@ fn coerce_to_int(size: uint) -> ~[Type] {
152157
args
153158
}
154159

155-
fn struct_ty(ty: Type) -> Type {
160+
fn struct_ty(ty: Type,
161+
padding: Option<Type>,
162+
coerce: bool) -> Type {
156163
let size = ty_size(ty) * 8;
157-
let fields = coerce_to_int(size);
164+
let mut fields = padding.map_default(~[], |p| ~[p]);
165+
166+
if coerce {
167+
fields = vec::append(fields, coerce_to_int(size));
168+
} else {
169+
fields.push(ty);
170+
}
171+
158172
return Type::struct_(fields, false);
159173
}
160174

161175
pub fn compute_abi_info(_ccx: &mut CrateContext,
162176
atys: &[Type],
163177
rty: Type,
164178
ret_def: bool) -> FnType {
165-
let ret_ty = if ret_def {
179+
let (ret_ty, ret_attr) = if ret_def {
166180
classify_ret_ty(rty)
167181
} else {
168-
ArgType::direct(Type::void(), None, None, None)
182+
(LLVMType { cast: false, ty: Type::void() }, None)
169183
};
170184

171-
let sret = ret_ty.is_indirect();
185+
let mut ret_ty = ret_ty;
186+
187+
let sret = ret_attr.is_some();
172188
let mut arg_tys = ~[];
189+
let mut attrs = ~[];
173190
let mut offset = if sret { 4 } else { 0 };
174191

175192
for aty in atys.iter() {
176-
let ty = classify_arg_ty(*aty, &mut offset);
193+
let (ty, attr) = classify_arg_ty(*aty, &mut offset);
177194
arg_tys.push(ty);
195+
attrs.push(attr);
178196
};
179197

198+
if sret {
199+
arg_tys = vec::append(~[ret_ty], arg_tys);
200+
attrs = vec::append(~[ret_attr], attrs);
201+
ret_ty = LLVMType { cast: false, ty: Type::void() };
202+
}
203+
180204
return FnType {
181205
arg_tys: arg_tys,
182206
ret_ty: ret_ty,
207+
attrs: attrs,
208+
sret: sret
183209
};
184210
}

0 commit comments

Comments
 (0)