Skip to content

Commit 94a858e

Browse files
committed
---
yaml --- r: 49106 b: refs/heads/snap-stage3 c: 63df1e9 h: refs/heads/master v: v3
1 parent 3c301be commit 94a858e

File tree

13 files changed

+230
-139
lines changed

13 files changed

+230
-139
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 3bbcac322669cff3abde5be937cc4ec3860f3985
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 32b8c0eaac8d45145356146060e8bf5af345b0f6
4+
refs/heads/snap-stage3: 63df1e9085c14b80cc86df55b234d16627f09b01
55
refs/heads/try: 2a8fb58d79e685d5ca07b039badcf2ae3ef077ea
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/configure

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,8 @@ case $CFG_OSTYPE in
308308
esac
309309

310310

311+
if [ -z "$CFG_CPUTYPE" ]
312+
then
311313
case $CFG_CPUTYPE in
312314

313315
i386 | i486 | i686 | i786 | x86)
@@ -325,6 +327,7 @@ case $CFG_CPUTYPE in
325327
*)
326328
err "unknown CPU type: $CFG_CPUTYPE"
327329
esac
330+
fi
328331

329332
# Detect 64 bit linux systems with 32 bit userland and force 32 bit compilation
330333
if [ $CFG_OSTYPE = unknown-linux-gnu -a $CFG_CPUTYPE = x86_64 ]

branches/snap-stage3/src/librustc/middle/liveness.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,11 +1346,11 @@ pub impl Liveness {
13461346
self.propagate_through_expr(e, succ)
13471347
}
13481348

1349-
expr_inline_asm(_, ref ins, ref outs, _, _, _) =>{
1350-
let succ = do ins.foldr(succ) |&(_, expr), succ| {
1349+
expr_inline_asm(ref ia) =>{
1350+
let succ = do ia.inputs.foldr(succ) |&(_, expr), succ| {
13511351
self.propagate_through_expr(expr, succ)
13521352
};
1353-
do outs.foldr(succ) |&(_, expr), succ| {
1353+
do ia.outputs.foldr(succ) |&(_, expr), succ| {
13541354
self.propagate_through_expr(expr, succ)
13551355
}
13561356
}
@@ -1620,14 +1620,19 @@ fn check_expr(expr: @expr, &&self: @Liveness, vt: vt<@Liveness>) {
16201620
visit::visit_expr(expr, self, vt);
16211621
}
16221622

1623-
expr_inline_asm(_, ref ins, ref outs, _, _, _) => {
1624-
for ins.each |&(_, in)| {
1623+
expr_inline_asm(ref ia) => {
1624+
for ia.inputs.each |&(_, in)| {
16251625
(vt.visit_expr)(in, self, vt);
16261626
}
16271627

16281628
// Output operands must be lvalues
1629-
for outs.each |&(_, out)| {
1630-
self.check_lvalue(out, vt);
1629+
for ia.outputs.each |&(_, out)| {
1630+
match out.node {
1631+
expr_addr_of(_, inner) => {
1632+
self.check_lvalue(inner, vt);
1633+
}
1634+
_ => {}
1635+
}
16311636
(vt.visit_expr)(out, self, vt);
16321637
}
16331638

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/snap-stage3/src/librustc/middle/trans/expr.rs

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

branches/snap-stage3/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
}

branches/snap-stage3/src/librustc/middle/typeck/check/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2332,13 +2332,13 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
23322332
let region_lb = ty::re_scope(expr.id);
23332333
instantiate_path(fcx, pth, tpt, expr.span, expr.id, region_lb);
23342334
}
2335-
ast::expr_inline_asm(_, ref ins, ref outs, _, _, _) => {
2335+
ast::expr_inline_asm(ref ia) => {
23362336
fcx.require_unsafe(expr.span, ~"use of inline assembly");
23372337

2338-
for ins.each |&(_, in)| {
2338+
for ia.inputs.each |&(_, in)| {
23392339
check_expr(fcx, in);
23402340
}
2341-
for outs.each |&(_, out)| {
2341+
for ia.outputs.each |&(_, out)| {
23422342
check_expr(fcx, out);
23432343
}
23442344
fcx.write_nil(id);

branches/snap-stage3/src/librustc/rustc.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ pub mod middle {
8080
pub mod reachable;
8181
pub mod machine;
8282
pub mod adt;
83+
pub mod asm;
8384
}
8485
pub mod ty;
8586
pub mod resolve;

0 commit comments

Comments
 (0)