Skip to content

Commit 01c8185

Browse files
committed
---
yaml --- r: 101343 b: refs/heads/master c: 464b2e2 h: refs/heads/master i: 101341: bbc2c0e 101339: ca065d9 101335: b7ab71b 101327: 0a883dd 101311: f9f430e v: v3
1 parent 6e78834 commit 01c8185

File tree

23 files changed

+388
-474
lines changed

23 files changed

+388
-474
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 83f0f6ef6cb44d9fbba24372f223561a75a50c18
2+
refs/heads/master: 464b2e2364919f4555d6f8c5025273afd4277366
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 6e7f170fedd3c526a643c0b2d13863acd982be02
55
refs/heads/try: a97642026c18a624ff6ea01075dd9550f8ed07ff

trunk/doc/rustdoc.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,9 @@ that one can still write things like `#[deriving(Eq)]`).
139139

140140
~~~
141141
```rust
142-
# /!\ The three following lines are comments, which are usually stripped off by
143-
# the doc-generating tool. In order to display them anyway in this particular
144-
# case, the character following the leading '#' is not a usual space like in
145-
# these first five lines but a non breakable one.
146-
#
147-
# // showing 'fib' in this documentation would just be tedious and detracts from
148-
# // what's actualy being documented.
149-
# fn fib(n: int) { n + 2 }
142+
# // showing 'fib' in this documentation would just be tedious and detracts from
143+
# // what's actualy being documented.
144+
# fn fib(n: int) { n + 2 }
150145
151146
do spawn { fib(200); }
152147
```

trunk/doc/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ match mypoint {
646646
## Enums
647647

648648
Enums are datatypes that have several alternate representations. For
649-
example, consider the following type:
649+
example, consider the type shown earlier:
650650

651651
~~~~
652652
# struct Point { x: f64, y: f64 }

trunk/src/librustc/back/link.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ pub mod write {
9696
use lib::llvm::llvm;
9797
use lib::llvm::{ModuleRef, TargetMachineRef, PassManagerRef};
9898
use lib;
99-
use syntax::abi;
10099
use util::common::time;
101100

102101
use std::c_str::ToCStr;
@@ -130,10 +129,7 @@ pub mod write {
130129
let use_softfp = sess.opts.debugging_opts & session::USE_SOFTFP != 0;
131130

132131
// FIXME: #11906: Omitting frame pointers breaks retrieving the value of a parameter.
133-
// FIXME: #11954: mac64 unwinding may not work with fp elim
134-
let no_fp_elim = sess.opts.debuginfo ||
135-
(sess.targ_cfg.os == abi::OsMacos &&
136-
sess.targ_cfg.arch == abi::X86_64);
132+
let no_fp_elim = sess.opts.debuginfo;
137133

138134
let tm = sess.targ_cfg.target_strs.target_triple.with_c_str(|T| {
139135
sess.opts.target_cpu.with_c_str(|CPU| {

trunk/src/librustc/middle/const_eval.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111

1212
use metadata::csearch;
1313
use middle::astencode;
14-
1514
use middle::ty;
16-
use middle::typeck::astconv;
1715
use middle;
1816

1917
use syntax::{ast, ast_map, ast_util};
@@ -447,17 +445,8 @@ pub fn eval_const_expr_partial<T: ty::ExprTyProvider>(tcx: &T, e: &Expr)
447445
_ => Err(~"Bad operands for binary")
448446
}
449447
}
450-
ExprCast(base, target_ty) => {
451-
// This tends to get called w/o the type actually having been
452-
// populated in the ctxt, which was causing things to blow up
453-
// (#5900). Fall back to doing a limited lookup to get past it.
454-
let ety = ty::expr_ty_opt(tcx.ty_ctxt(), e)
455-
.or_else(|| astconv::ast_ty_to_prim_ty(tcx.ty_ctxt(), target_ty))
456-
.unwrap_or_else(|| tcx.ty_ctxt().sess.span_fatal(
457-
target_ty.span,
458-
format!("Target type not found for const cast")
459-
));
460-
448+
ExprCast(base, _) => {
449+
let ety = tcx.expr_ty(e);
461450
let base = eval_const_expr_partial(tcx, base);
462451
match base {
463452
Err(_) => base,

trunk/src/librustc/middle/trans/intrinsic.rs

Lines changed: 58 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -29,68 +29,27 @@ use util::ppaux::ty_to_str;
2929
use middle::trans::machine::llsize_of;
3030
use middle::trans::type_::Type;
3131

32-
pub fn get_simple_intrinsic(ccx: @CrateContext, item: &ast::ForeignItem) -> Option<ValueRef> {
33-
let nm = ccx.sess.str_of(item.ident);
34-
let name = nm.as_slice();
35-
36-
match name {
37-
"sqrtf32" => Some(ccx.intrinsics.get_copy(&("llvm.sqrt.f32"))),
38-
"sqrtf64" => Some(ccx.intrinsics.get_copy(&("llvm.sqrt.f64"))),
39-
"powif32" => Some(ccx.intrinsics.get_copy(&("llvm.powi.f32"))),
40-
"powif64" => Some(ccx.intrinsics.get_copy(&("llvm.powi.f64"))),
41-
"sinf32" => Some(ccx.intrinsics.get_copy(&("llvm.sin.f32"))),
42-
"sinf64" => Some(ccx.intrinsics.get_copy(&("llvm.sin.f64"))),
43-
"cosf32" => Some(ccx.intrinsics.get_copy(&("llvm.cos.f32"))),
44-
"cosf64" => Some(ccx.intrinsics.get_copy(&("llvm.cos.f64"))),
45-
"powf32" => Some(ccx.intrinsics.get_copy(&("llvm.pow.f32"))),
46-
"powf64" => Some(ccx.intrinsics.get_copy(&("llvm.pow.f64"))),
47-
"expf32" => Some(ccx.intrinsics.get_copy(&("llvm.exp.f32"))),
48-
"expf64" => Some(ccx.intrinsics.get_copy(&("llvm.exp.f64"))),
49-
"exp2f32" => Some(ccx.intrinsics.get_copy(&("llvm.exp2.f32"))),
50-
"exp2f64" => Some(ccx.intrinsics.get_copy(&("llvm.exp2.f64"))),
51-
"logf32" => Some(ccx.intrinsics.get_copy(&("llvm.log.f32"))),
52-
"logf64" => Some(ccx.intrinsics.get_copy(&("llvm.log.f64"))),
53-
"log10f32" => Some(ccx.intrinsics.get_copy(&("llvm.log10.f32"))),
54-
"log10f64" => Some(ccx.intrinsics.get_copy(&("llvm.log10.f64"))),
55-
"log2f32" => Some(ccx.intrinsics.get_copy(&("llvm.log2.f32"))),
56-
"log2f64" => Some(ccx.intrinsics.get_copy(&("llvm.log2.f64"))),
57-
"fmaf32" => Some(ccx.intrinsics.get_copy(&("llvm.fma.f32"))),
58-
"fmaf64" => Some(ccx.intrinsics.get_copy(&("llvm.fma.f64"))),
59-
"fabsf32" => Some(ccx.intrinsics.get_copy(&("llvm.fabs.f32"))),
60-
"fabsf64" => Some(ccx.intrinsics.get_copy(&("llvm.fabs.f64"))),
61-
"copysignf32" => Some(ccx.intrinsics.get_copy(&("llvm.copysign.f32"))),
62-
"copysignf64" => Some(ccx.intrinsics.get_copy(&("llvm.copysign.f64"))),
63-
"floorf32" => Some(ccx.intrinsics.get_copy(&("llvm.floor.f32"))),
64-
"floorf64" => Some(ccx.intrinsics.get_copy(&("llvm.floor.f64"))),
65-
"ceilf32" => Some(ccx.intrinsics.get_copy(&("llvm.ceil.f32"))),
66-
"ceilf64" => Some(ccx.intrinsics.get_copy(&("llvm.ceil.f64"))),
67-
"truncf32" => Some(ccx.intrinsics.get_copy(&("llvm.trunc.f32"))),
68-
"truncf64" => Some(ccx.intrinsics.get_copy(&("llvm.trunc.f64"))),
69-
"rintf32" => Some(ccx.intrinsics.get_copy(&("llvm.rint.f32"))),
70-
"rintf64" => Some(ccx.intrinsics.get_copy(&("llvm.rint.f64"))),
71-
"nearbyintf32" => Some(ccx.intrinsics.get_copy(&("llvm.nearbyint.f32"))),
72-
"nearbyintf64" => Some(ccx.intrinsics.get_copy(&("llvm.nearbyint.f64"))),
73-
"roundf32" => Some(ccx.intrinsics.get_copy(&("llvm.round.f32"))),
74-
"roundf64" => Some(ccx.intrinsics.get_copy(&("llvm.round.f64"))),
75-
"ctpop8" => Some(ccx.intrinsics.get_copy(&("llvm.ctpop.i8"))),
76-
"ctpop16" => Some(ccx.intrinsics.get_copy(&("llvm.ctpop.i16"))),
77-
"ctpop32" => Some(ccx.intrinsics.get_copy(&("llvm.ctpop.i32"))),
78-
"ctpop64" => Some(ccx.intrinsics.get_copy(&("llvm.ctpop.i64"))),
79-
"bswap16" => Some(ccx.intrinsics.get_copy(&("llvm.bswap.i16"))),
80-
"bswap32" => Some(ccx.intrinsics.get_copy(&("llvm.bswap.i32"))),
81-
"bswap64" => Some(ccx.intrinsics.get_copy(&("llvm.bswap.i64"))),
82-
_ => None
83-
}
84-
}
85-
8632
pub fn trans_intrinsic(ccx: @CrateContext,
8733
decl: ValueRef,
8834
item: &ast::ForeignItem,
8935
path: ast_map::Path,
9036
substs: @param_substs,
37+
_attributes: &[ast::Attribute],
9138
ref_id: Option<ast::NodeId>) {
9239
debug!("trans_intrinsic(item.ident={})", ccx.sess.str_of(item.ident));
9340

41+
fn simple_llvm_intrinsic(bcx: &Block, name: &'static str, num_args: uint) {
42+
assert!(num_args <= 4);
43+
let mut args = [0 as ValueRef, ..4];
44+
let first_real_arg = bcx.fcx.arg_pos(0u);
45+
for i in range(0u, num_args) {
46+
args[i] = get_param(bcx.fcx.llfn, first_real_arg + i);
47+
}
48+
let llfn = bcx.ccx().intrinsics.get_copy(&name);
49+
let llcall = Call(bcx, llfn, args.slice(0, num_args), []);
50+
Ret(bcx, llcall);
51+
}
52+
9453
fn with_overflow_instrinsic(bcx: &Block, name: &'static str, t: ty::t) {
9554
let first_real_arg = bcx.fcx.arg_pos(0u);
9655
let a = get_param(bcx.fcx.llfn, first_real_arg);
@@ -472,6 +431,48 @@ pub fn trans_intrinsic(ccx: @CrateContext,
472431
"copy_nonoverlapping_memory" => copy_intrinsic(bcx, false, substs.tys[0]),
473432
"copy_memory" => copy_intrinsic(bcx, true, substs.tys[0]),
474433
"set_memory" => memset_intrinsic(bcx, substs.tys[0]),
434+
"sqrtf32" => simple_llvm_intrinsic(bcx, "llvm.sqrt.f32", 1),
435+
"sqrtf64" => simple_llvm_intrinsic(bcx, "llvm.sqrt.f64", 1),
436+
"powif32" => simple_llvm_intrinsic(bcx, "llvm.powi.f32", 2),
437+
"powif64" => simple_llvm_intrinsic(bcx, "llvm.powi.f64", 2),
438+
"sinf32" => simple_llvm_intrinsic(bcx, "llvm.sin.f32", 1),
439+
"sinf64" => simple_llvm_intrinsic(bcx, "llvm.sin.f64", 1),
440+
"cosf32" => simple_llvm_intrinsic(bcx, "llvm.cos.f32", 1),
441+
"cosf64" => simple_llvm_intrinsic(bcx, "llvm.cos.f64", 1),
442+
"powf32" => simple_llvm_intrinsic(bcx, "llvm.pow.f32", 2),
443+
"powf64" => simple_llvm_intrinsic(bcx, "llvm.pow.f64", 2),
444+
"expf32" => simple_llvm_intrinsic(bcx, "llvm.exp.f32", 1),
445+
"expf64" => simple_llvm_intrinsic(bcx, "llvm.exp.f64", 1),
446+
"exp2f32" => simple_llvm_intrinsic(bcx, "llvm.exp2.f32", 1),
447+
"exp2f64" => simple_llvm_intrinsic(bcx, "llvm.exp2.f64", 1),
448+
"logf32" => simple_llvm_intrinsic(bcx, "llvm.log.f32", 1),
449+
"logf64" => simple_llvm_intrinsic(bcx, "llvm.log.f64", 1),
450+
"log10f32" => simple_llvm_intrinsic(bcx, "llvm.log10.f32", 1),
451+
"log10f64" => simple_llvm_intrinsic(bcx, "llvm.log10.f64", 1),
452+
"log2f32" => simple_llvm_intrinsic(bcx, "llvm.log2.f32", 1),
453+
"log2f64" => simple_llvm_intrinsic(bcx, "llvm.log2.f64", 1),
454+
"fmaf32" => simple_llvm_intrinsic(bcx, "llvm.fma.f32", 3),
455+
"fmaf64" => simple_llvm_intrinsic(bcx, "llvm.fma.f64", 3),
456+
"fabsf32" => simple_llvm_intrinsic(bcx, "llvm.fabs.f32", 1),
457+
"fabsf64" => simple_llvm_intrinsic(bcx, "llvm.fabs.f64", 1),
458+
"copysignf32" => simple_llvm_intrinsic(bcx, "llvm.copysign.f32", 2),
459+
"copysignf64" => simple_llvm_intrinsic(bcx, "llvm.copysign.f64", 2),
460+
"floorf32" => simple_llvm_intrinsic(bcx, "llvm.floor.f32", 1),
461+
"floorf64" => simple_llvm_intrinsic(bcx, "llvm.floor.f64", 1),
462+
"ceilf32" => simple_llvm_intrinsic(bcx, "llvm.ceil.f32", 1),
463+
"ceilf64" => simple_llvm_intrinsic(bcx, "llvm.ceil.f64", 1),
464+
"truncf32" => simple_llvm_intrinsic(bcx, "llvm.trunc.f32", 1),
465+
"truncf64" => simple_llvm_intrinsic(bcx, "llvm.trunc.f64", 1),
466+
"rintf32" => simple_llvm_intrinsic(bcx, "llvm.rint.f32", 1),
467+
"rintf64" => simple_llvm_intrinsic(bcx, "llvm.rint.f64", 1),
468+
"nearbyintf32" => simple_llvm_intrinsic(bcx, "llvm.nearbyint.f32", 1),
469+
"nearbyintf64" => simple_llvm_intrinsic(bcx, "llvm.nearbyint.f64", 1),
470+
"roundf32" => simple_llvm_intrinsic(bcx, "llvm.round.f32", 1),
471+
"roundf64" => simple_llvm_intrinsic(bcx, "llvm.round.f64", 1),
472+
"ctpop8" => simple_llvm_intrinsic(bcx, "llvm.ctpop.i8", 1),
473+
"ctpop16" => simple_llvm_intrinsic(bcx, "llvm.ctpop.i16", 1),
474+
"ctpop32" => simple_llvm_intrinsic(bcx, "llvm.ctpop.i32", 1),
475+
"ctpop64" => simple_llvm_intrinsic(bcx, "llvm.ctpop.i64", 1),
475476
"ctlz8" => count_zeros_intrinsic(bcx, "llvm.ctlz.i8"),
476477
"ctlz16" => count_zeros_intrinsic(bcx, "llvm.ctlz.i16"),
477478
"ctlz32" => count_zeros_intrinsic(bcx, "llvm.ctlz.i32"),
@@ -480,6 +481,9 @@ pub fn trans_intrinsic(ccx: @CrateContext,
480481
"cttz16" => count_zeros_intrinsic(bcx, "llvm.cttz.i16"),
481482
"cttz32" => count_zeros_intrinsic(bcx, "llvm.cttz.i32"),
482483
"cttz64" => count_zeros_intrinsic(bcx, "llvm.cttz.i64"),
484+
"bswap16" => simple_llvm_intrinsic(bcx, "llvm.bswap.i16", 1),
485+
"bswap32" => simple_llvm_intrinsic(bcx, "llvm.bswap.i32", 1),
486+
"bswap64" => simple_llvm_intrinsic(bcx, "llvm.bswap.i64", 1),
483487

484488
"volatile_load" => volatile_load_intrinsic(bcx),
485489
"volatile_store" => volatile_store_intrinsic(bcx),

trunk/src/librustc/middle/trans/monomorphize.rs

Lines changed: 78 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -223,95 +223,90 @@ pub fn monomorphic_fn(ccx: @CrateContext,
223223
};
224224

225225
let lldecl = match map_node {
226-
ast_map::NodeItem(i, _) => {
227-
match *i {
228-
ast::Item {
229-
node: ast::ItemFn(decl, _, _, _, body),
230-
..
231-
} => {
226+
ast_map::NodeItem(i, _) => {
227+
match *i {
228+
ast::Item {
229+
node: ast::ItemFn(decl, _, _, _, body),
230+
..
231+
} => {
232+
let d = mk_lldecl();
233+
set_llvm_fn_attrs(i.attrs, d);
234+
trans_fn(ccx, pt, decl, body, d, Some(psubsts), fn_id.node, []);
235+
d
236+
}
237+
_ => {
238+
ccx.tcx.sess.bug("Can't monomorphize this kind of item")
239+
}
240+
}
241+
}
242+
ast_map::NodeForeignItem(i, _, _, _) => {
243+
let d = mk_lldecl();
244+
intrinsic::trans_intrinsic(ccx, d, i, pt, psubsts, i.attrs,
245+
ref_id);
246+
d
247+
}
248+
ast_map::NodeVariant(v, enum_item, _) => {
249+
let tvs = ty::enum_variants(ccx.tcx, local_def(enum_item.id));
250+
let this_tv = *tvs.iter().find(|tv| { tv.id.node == fn_id.node}).unwrap();
251+
let d = mk_lldecl();
252+
set_inline_hint(d);
253+
match v.node.kind {
254+
ast::TupleVariantKind(ref args) => {
255+
trans_enum_variant(ccx,
256+
enum_item.id,
257+
v,
258+
(*args).clone(),
259+
this_tv.disr_val,
260+
Some(psubsts),
261+
d);
262+
}
263+
ast::StructVariantKind(_) =>
264+
ccx.tcx.sess.bug("can't monomorphize struct variants"),
265+
}
266+
d
267+
}
268+
ast_map::NodeMethod(mth, _, _) => {
269+
let d = mk_lldecl();
270+
set_llvm_fn_attrs(mth.attrs, d);
271+
trans_fn(ccx, pt, mth.decl, mth.body, d, Some(psubsts), mth.id, []);
272+
d
273+
}
274+
ast_map::NodeTraitMethod(method, _, pt) => {
275+
match *method {
276+
ast::Provided(mth) => {
232277
let d = mk_lldecl();
233-
set_llvm_fn_attrs(i.attrs, d);
234-
trans_fn(ccx, pt, decl, body, d, Some(psubsts), fn_id.node, []);
278+
set_llvm_fn_attrs(mth.attrs, d);
279+
trans_fn(ccx, (*pt).clone(), mth.decl, mth.body,
280+
d, Some(psubsts), mth.id, []);
235281
d
236282
}
237283
_ => {
238-
ccx.tcx.sess.bug("Can't monomorphize this kind of item")
284+
ccx.tcx.sess.bug(format!("Can't monomorphize a {:?}",
285+
map_node))
239286
}
240-
}
241-
}
242-
ast_map::NodeForeignItem(i, _, _, _) => {
243-
let simple = intrinsic::get_simple_intrinsic(ccx, i);
244-
match simple {
245-
Some(decl) => decl,
246-
None => {
247-
let d = mk_lldecl();
248-
intrinsic::trans_intrinsic(ccx, d, i, pt, psubsts, ref_id);
249-
d
250-
}
251-
}
252-
}
253-
ast_map::NodeVariant(v, enum_item, _) => {
254-
let tvs = ty::enum_variants(ccx.tcx, local_def(enum_item.id));
255-
let this_tv = *tvs.iter().find(|tv| { tv.id.node == fn_id.node}).unwrap();
256-
let d = mk_lldecl();
257-
set_inline_hint(d);
258-
match v.node.kind {
259-
ast::TupleVariantKind(ref args) => {
260-
trans_enum_variant(ccx,
261-
enum_item.id,
262-
v,
263-
(*args).clone(),
264-
this_tv.disr_val,
265-
Some(psubsts),
266-
d);
267-
}
268-
ast::StructVariantKind(_) =>
269-
ccx.tcx.sess.bug("can't monomorphize struct variants"),
270-
}
271-
d
272-
}
273-
ast_map::NodeMethod(mth, _, _) => {
274-
let d = mk_lldecl();
275-
set_llvm_fn_attrs(mth.attrs, d);
276-
trans_fn(ccx, pt, mth.decl, mth.body, d, Some(psubsts), mth.id, []);
277-
d
278-
}
279-
ast_map::NodeTraitMethod(method, _, pt) => {
280-
match *method {
281-
ast::Provided(mth) => {
282-
let d = mk_lldecl();
283-
set_llvm_fn_attrs(mth.attrs, d);
284-
trans_fn(ccx, (*pt).clone(), mth.decl, mth.body,
285-
d, Some(psubsts), mth.id, []);
286-
d
287-
}
288-
_ => {
289-
ccx.tcx.sess.bug(format!("Can't monomorphize a {:?}",
290-
map_node))
291-
}
292-
}
293-
}
294-
ast_map::NodeStructCtor(struct_def, _, _) => {
295-
let d = mk_lldecl();
296-
set_inline_hint(d);
297-
base::trans_tuple_struct(ccx,
298-
struct_def.fields,
299-
struct_def.ctor_id.expect("ast-mapped tuple struct \
300-
didn't have a ctor id"),
301-
Some(psubsts),
302-
d);
303-
d
304-
}
287+
}
288+
}
289+
ast_map::NodeStructCtor(struct_def, _, _) => {
290+
let d = mk_lldecl();
291+
set_inline_hint(d);
292+
base::trans_tuple_struct(ccx,
293+
struct_def.fields,
294+
struct_def.ctor_id.expect("ast-mapped tuple struct \
295+
didn't have a ctor id"),
296+
Some(psubsts),
297+
d);
298+
d
299+
}
305300

306-
// Ugh -- but this ensures any new variants won't be forgotten
307-
ast_map::NodeExpr(..) |
308-
ast_map::NodeStmt(..) |
309-
ast_map::NodeArg(..) |
310-
ast_map::NodeBlock(..) |
311-
ast_map::NodeCalleeScope(..) |
312-
ast_map::NodeLocal(..) => {
313-
ccx.tcx.sess.bug(format!("Can't monomorphize a {:?}", map_node))
314-
}
301+
// Ugh -- but this ensures any new variants won't be forgotten
302+
ast_map::NodeExpr(..) |
303+
ast_map::NodeStmt(..) |
304+
ast_map::NodeArg(..) |
305+
ast_map::NodeBlock(..) |
306+
ast_map::NodeCalleeScope(..) |
307+
ast_map::NodeLocal(..) => {
308+
ccx.tcx.sess.bug(format!("Can't monomorphize a {:?}", map_node))
309+
}
315310
};
316311

317312
{

0 commit comments

Comments
 (0)