Skip to content

Commit 0ddc2d2

Browse files
committed
---
yaml --- r: 50356 b: refs/heads/auto c: bdf81e1 h: refs/heads/master v: v3
1 parent 7879fe7 commit 0ddc2d2

File tree

17 files changed

+236
-168
lines changed

17 files changed

+236
-168
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: ae7e072af756ce256826370ec16f7d51ce1bed86
17+
refs/heads/auto: bdf81e11841da74277e873b9f3ef5bc2105700be
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167

branches/auto/RELEASES.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Version 0.6 (March 2013)
1+
Version 0.6 (April 2013)
22
---------------------------
33

44
* ~2100 changes, numerous bugfixes

branches/auto/src/libcore/str.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,8 @@ pub fn each_split_within<'a>(ss: &'a str,
726726

727727
(B, Cr, UnderLim) => { B }
728728
(B, Cr, OverLim) if (i - last_start + 1) > lim
729-
=> { fail!(~"word longer than limit!") }
729+
=> fail!(fmt!("word starting with %? longer than limit!",
730+
self::slice(ss, last_start, i + 1))),
730731
(B, Cr, OverLim) => { slice(); slice_start = last_start; B }
731732
(B, Ws, UnderLim) => { last_end = i; C }
732733
(B, Ws, OverLim) => { last_end = i; slice(); A }

branches/auto/src/libcore/unstable/lang.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ pub unsafe fn fail_borrowed() {
6464

6565
// FIXME #4942: Make these signatures agree with exchange_alloc's signatures
6666
#[lang="exchange_malloc"]
67+
#[inline(always)]
6768
pub unsafe fn exchange_malloc(td: *c_char, size: uintptr_t) -> *c_char {
6869
transmute(exchange_alloc::malloc(transmute(td), transmute(size)))
6970
}
@@ -72,11 +73,13 @@ pub unsafe fn exchange_malloc(td: *c_char, size: uintptr_t) -> *c_char {
7273
// inside a landing pad may corrupt the state of the exception handler. If a
7374
// problem occurs, call exit instead.
7475
#[lang="exchange_free"]
76+
#[inline(always)]
7577
pub unsafe fn exchange_free(ptr: *c_char) {
7678
exchange_alloc::free(transmute(ptr))
7779
}
7880

7981
#[lang="malloc"]
82+
#[inline(always)]
8083
pub unsafe fn local_malloc(td: *c_char, size: uintptr_t) -> *c_char {
8184
return rustrt::rust_upcall_malloc(td, size);
8285
}
@@ -85,6 +88,7 @@ pub unsafe fn local_malloc(td: *c_char, size: uintptr_t) -> *c_char {
8588
// inside a landing pad may corrupt the state of the exception handler. If a
8689
// problem occurs, call exit instead.
8790
#[lang="free"]
91+
#[inline(always)]
8892
pub unsafe fn local_free(ptr: *c_char) {
8993
rustrt::rust_upcall_free(ptr);
9094
}
@@ -117,6 +121,7 @@ pub unsafe fn check_not_borrowed(a: *u8) {
117121
}
118122

119123
#[lang="strdup_uniq"]
124+
#[inline(always)]
120125
pub unsafe fn strdup_uniq(ptr: *c_uchar, len: uint) -> ~str {
121126
str::raw::from_buf_len(ptr, len)
122127
}

branches/auto/src/librustc/driver/driver.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -762,8 +762,7 @@ pub fn optgroups() -> ~[getopts::groups::OptGroup] {
762762
optflag(~"", ~"test", ~"Build a test harness"),
763763
optopt(~"", ~"target",
764764
~"Target triple cpu-manufacturer-kernel[-os]
765-
to compile for (see
766-
http://sources.redhat.com/autobook/autobook/autobook_17.html
765+
to compile for (see chapter 3.4 of http://www.sourceware.org/autobook/
767766
for detail)", ~"TRIPLE"),
768767
optopt(~"", ~"android-cross-path",
769768
~"The path to the Android NDK", "PATH"),

branches/auto/src/librustc/middle/liveness.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,11 +1306,11 @@ pub impl Liveness {
13061306
self.propagate_through_expr(e, succ)
13071307
}
13081308

1309-
expr_inline_asm(_, ref ins, ref outs, _, _, _) =>{
1310-
let succ = do ins.foldr(succ) |&(_, expr), succ| {
1309+
expr_inline_asm(ref ia) =>{
1310+
let succ = do ia.inputs.foldr(succ) |&(_, expr), succ| {
13111311
self.propagate_through_expr(expr, succ)
13121312
};
1313-
do outs.foldr(succ) |&(_, expr), succ| {
1313+
do ia.outputs.foldr(succ) |&(_, expr), succ| {
13141314
self.propagate_through_expr(expr, succ)
13151315
}
13161316
}
@@ -1580,14 +1580,19 @@ fn check_expr(expr: @expr, &&self: @Liveness, vt: vt<@Liveness>) {
15801580
visit::visit_expr(expr, self, vt);
15811581
}
15821582

1583-
expr_inline_asm(_, ref ins, ref outs, _, _, _) => {
1584-
for ins.each |&(_, in)| {
1583+
expr_inline_asm(ref ia) => {
1584+
for ia.inputs.each |&(_, in)| {
15851585
(vt.visit_expr)(in, self, vt);
15861586
}
15871587

15881588
// Output operands must be lvalues
1589-
for outs.each |&(_, out)| {
1590-
self.check_lvalue(out, vt);
1589+
for ia.outputs.each |&(_, out)| {
1590+
match out.node {
1591+
expr_addr_of(_, inner) => {
1592+
self.check_lvalue(inner, vt);
1593+
}
1594+
_ => {}
1595+
}
15911596
(vt.visit_expr)(out, self, vt);
15921597
}
15931598

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
// Copyright 2012 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.
4+
//
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.
10+
11+
/*!
12+
# Translation of inline assembly.
13+
*/
14+
15+
use core::prelude::*;
16+
17+
use lib;
18+
use middle::trans::build::*;
19+
use middle::trans::callee;
20+
use middle::trans::common::*;
21+
use middle::ty;
22+
23+
use syntax::ast;
24+
25+
// Take an inline assembly expression and splat it out via LLVM
26+
pub fn trans_inline_asm(bcx: block, ia: &ast::inline_asm) -> block {
27+
28+
let mut bcx = bcx;
29+
let mut constraints = ~[];
30+
let mut cleanups = ~[];
31+
let mut aoutputs = ~[];
32+
33+
// Prepare the output operands
34+
let outputs = do ia.outputs.map |&(c, out)| {
35+
constraints.push(copy *c);
36+
37+
let aoutty = ty::arg {
38+
mode: ast::expl(ast::by_copy),
39+
ty: expr_ty(bcx, out)
40+
};
41+
aoutputs.push(unpack_result!(bcx, {
42+
callee::trans_arg_expr(bcx, aoutty, out, &mut cleanups, None, callee::DontAutorefArg)
43+
}));
44+
45+
let e = match out.node {
46+
ast::expr_addr_of(_, e) => e,
47+
_ => fail!(~"Expression must be addr of")
48+
};
49+
50+
let outty = ty::arg {
51+
mode: ast::expl(ast::by_copy),
52+
ty: expr_ty(bcx, e)
53+
};
54+
55+
unpack_result!(bcx, {
56+
callee::trans_arg_expr(bcx, outty, e, &mut cleanups, None, callee::DontAutorefArg)
57+
})
58+
59+
};
60+
61+
for cleanups.each |c| {
62+
revoke_clean(bcx, *c);
63+
}
64+
cleanups.clear();
65+
66+
// Now the input operands
67+
let inputs = do ia.inputs.map |&(c, in)| {
68+
constraints.push(copy *c);
69+
70+
let inty = ty::arg {
71+
mode: ast::expl(ast::by_copy),
72+
ty: expr_ty(bcx, in)
73+
};
74+
75+
unpack_result!(bcx, {
76+
callee::trans_arg_expr(bcx, inty, in, &mut cleanups, None, callee::DontAutorefArg)
77+
})
78+
79+
};
80+
81+
for cleanups.each |c| {
82+
revoke_clean(bcx, *c);
83+
}
84+
85+
let mut constraints = str::connect(constraints, ",");
86+
87+
let mut clobbers = getClobbers();
88+
if *ia.clobbers != ~"" && clobbers != ~"" {
89+
clobbers = *ia.clobbers + ~"," + clobbers;
90+
} else {
91+
clobbers += *ia.clobbers;
92+
};
93+
94+
// Add the clobbers to our constraints list
95+
if clobbers != ~"" && constraints != ~"" {
96+
constraints += ~"," + clobbers;
97+
} else {
98+
constraints += clobbers;
99+
}
100+
101+
debug!("Asm Constraints: %?", constraints);
102+
103+
let numOutputs = outputs.len();
104+
105+
// Depending on how many outputs we have, the return type is different
106+
let output = if numOutputs == 0 {
107+
T_void()
108+
} else if numOutputs == 1 {
109+
val_ty(outputs[0])
110+
} else {
111+
T_struct(outputs.map(|o| val_ty(*o)))
112+
};
113+
114+
let dialect = match ia.dialect {
115+
ast::asm_att => lib::llvm::AD_ATT,
116+
ast::asm_intel => lib::llvm::AD_Intel
117+
};
118+
119+
let r = do str::as_c_str(*ia.asm) |a| {
120+
do str::as_c_str(constraints) |c| {
121+
InlineAsmCall(bcx, a, c, inputs, output, ia.volatile, ia.alignstack, dialect)
122+
}
123+
};
124+
125+
// Again, based on how many outputs we have
126+
if numOutputs == 1 {
127+
let op = PointerCast(bcx, aoutputs[0], T_ptr(val_ty(outputs[0])));
128+
Store(bcx, r, op);
129+
} else {
130+
for aoutputs.eachi |i, o| {
131+
let v = ExtractValue(bcx, r, i);
132+
let op = PointerCast(bcx, *o, T_ptr(val_ty(outputs[i])));
133+
Store(bcx, v, op);
134+
}
135+
}
136+
137+
return bcx;
138+
139+
}
140+
141+
// Default per-arch clobbers
142+
// Basically what clang does
143+
144+
#[cfg(target_arch = "arm")]
145+
#[cfg(target_arch = "mips")]
146+
fn getClobbers() -> ~str {
147+
~""
148+
}
149+
150+
#[cfg(target_arch = "x86")]
151+
#[cfg(target_arch = "x86_64")]
152+
fn getClobbers() -> ~str {
153+
~"~{dirflag},~{fpsr},~{flags}"
154+
}

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

Lines changed: 3 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ use metadata::csearch;
128128
use middle::borrowck::root_map_key;
129129
use middle::trans::_match;
130130
use middle::trans::adt;
131+
use middle::trans::asm;
131132
use middle::trans::base;
132133
use middle::trans::base::*;
133134
use middle::trans::build::*;
@@ -548,108 +549,8 @@ fn trans_rvalue_stmt_unadjusted(bcx: block, expr: @ast::expr) -> block {
548549
ast::expr_paren(a) => {
549550
return trans_rvalue_stmt_unadjusted(bcx, a);
550551
}
551-
ast::expr_inline_asm(asm, ref ins, ref outs,
552-
clobs, volatile, alignstack) => {
553-
let mut constraints = ~[];
554-
let mut cleanups = ~[];
555-
let mut aoutputs = ~[];
556-
557-
let outputs = do outs.map |&(c, out)| {
558-
constraints.push(copy *c);
559-
560-
let aoutty = ty::arg {
561-
mode: ast::expl(ast::by_copy),
562-
ty: expr_ty(bcx, out)
563-
};
564-
aoutputs.push(unpack_result!(bcx, {
565-
callee::trans_arg_expr(bcx, aoutty, out, &mut cleanups,
566-
None, callee::DontAutorefArg)
567-
}));
568-
569-
let e = match out.node {
570-
ast::expr_addr_of(_, e) => e,
571-
_ => fail!(~"Expression must be addr of")
572-
};
573-
574-
let outty = ty::arg {
575-
mode: ast::expl(ast::by_copy),
576-
ty: expr_ty(bcx, e)
577-
};
578-
579-
unpack_result!(bcx, {
580-
callee::trans_arg_expr(bcx, outty, e, &mut cleanups,
581-
None, callee::DontAutorefArg)
582-
})
583-
584-
};
585-
586-
for cleanups.each |c| {
587-
revoke_clean(bcx, *c);
588-
}
589-
cleanups = ~[];
590-
591-
let inputs = do ins.map |&(c, in)| {
592-
constraints.push(copy *c);
593-
594-
let inty = ty::arg {
595-
mode: ast::expl(ast::by_copy),
596-
ty: expr_ty(bcx, in)
597-
};
598-
599-
unpack_result!(bcx, {
600-
callee::trans_arg_expr(bcx, inty, in, &mut cleanups,
601-
None, callee::DontAutorefArg)
602-
})
603-
604-
};
605-
606-
for cleanups.each |c| {
607-
revoke_clean(bcx, *c);
608-
}
609-
610-
let mut constraints = str::connect(constraints, ",");
611-
612-
// Add the clobbers
613-
if *clobs != ~"" {
614-
if constraints == ~"" {
615-
constraints += *clobs;
616-
} else {
617-
constraints += ~"," + *clobs;
618-
}
619-
} else {
620-
constraints += *clobs;
621-
}
622-
623-
debug!("Asm Constraints: %?", constraints);
624-
625-
let output = if outputs.len() == 0 {
626-
T_void()
627-
} else if outputs.len() == 1 {
628-
val_ty(outputs[0])
629-
} else {
630-
T_struct(outputs.map(|o| val_ty(*o)))
631-
};
632-
633-
let r = do str::as_c_str(*asm) |a| {
634-
do str::as_c_str(constraints) |c| {
635-
InlineAsmCall(bcx, a, c, inputs, output, volatile,
636-
alignstack, lib::llvm::AD_ATT)
637-
}
638-
};
639-
640-
if outputs.len() == 1 {
641-
let op = PointerCast(bcx, aoutputs[0],
642-
T_ptr(val_ty(outputs[0])));
643-
Store(bcx, r, op);
644-
} else {
645-
for aoutputs.eachi |i, o| {
646-
let v = ExtractValue(bcx, r, i);
647-
let op = PointerCast(bcx, *o, T_ptr(val_ty(outputs[i])));
648-
Store(bcx, v, op);
649-
}
650-
}
651-
652-
return bcx;
552+
ast::expr_inline_asm(ref a) => {
553+
return asm::trans_inline_asm(bcx, a);
653554
}
654555
_ => {
655556
bcx.tcx().sess.span_bug(

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,11 +360,11 @@ pub fn mark_for_expr(cx: Context, e: @expr) {
360360
mark_for_method_call(cx, e.id, e.callee_id);
361361
}
362362

363-
expr_inline_asm(_, ref ins, ref outs, _, _, _) => {
364-
for ins.each |&(_, in)| {
363+
expr_inline_asm(ref ia) => {
364+
for ia.inputs.each |&(_, in)| {
365365
node_type_needs(cx, use_repr, in.id);
366366
}
367-
for outs.each |&(_, out)| {
367+
for ia.outputs.each |&(_, out)| {
368368
node_type_needs(cx, use_repr, out.id);
369369
}
370370
}

0 commit comments

Comments
 (0)