Skip to content

Commit c374d26

Browse files
committed
---
yaml --- r: 50350 b: refs/heads/auto c: 36909c7 h: refs/heads/master v: v3
1 parent efe38b8 commit c374d26

File tree

13 files changed

+144
-228
lines changed

13 files changed

+144
-228
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: f81459211d0cf2738ed02f5c7fe24f56c8032960
17+
refs/heads/auto: 36909c7575e2ddfe2925423aceb62d82ae8208b2
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167

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

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

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

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

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

Lines changed: 0 additions & 154 deletions
This file was deleted.

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

Lines changed: 102 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ 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;
132131
use middle::trans::base;
133132
use middle::trans::base::*;
134133
use middle::trans::build::*;
@@ -549,8 +548,108 @@ fn trans_rvalue_stmt_unadjusted(bcx: block, expr: @ast::expr) -> block {
549548
ast::expr_paren(a) => {
550549
return trans_rvalue_stmt_unadjusted(bcx, a);
551550
}
552-
ast::expr_inline_asm(ref a) => {
553-
return asm::trans_inline_asm(bcx, a);
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;
554653
}
555654
_ => {
556655
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 ia) => {
364-
for ia.inputs.each |&(_, in)| {
363+
expr_inline_asm(_, ref ins, ref outs, _, _, _) => {
364+
for ins.each |&(_, in)| {
365365
node_type_needs(cx, use_repr, in.id);
366366
}
367-
for ia.outputs.each |&(_, out)| {
367+
for outs.each |&(_, out)| {
368368
node_type_needs(cx, use_repr, out.id);
369369
}
370370
}

branches/auto/src/librustc/middle/typeck/check/mod.rs

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

2342-
for ia.inputs.each |&(_, in)| {
2342+
for ins.each |&(_, in)| {
23432343
check_expr(fcx, in);
23442344
}
2345-
for ia.outputs.each |&(_, out)| {
2345+
for outs.each |&(_, out)| {
23462346
check_expr(fcx, out);
23472347
}
23482348
fcx.write_nil(id);

branches/auto/src/librustc/rustc.rc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ pub mod middle {
8080
pub mod reachable;
8181
pub mod machine;
8282
pub mod adt;
83-
pub mod asm;
8483
}
8584
pub mod ty;
8685
pub mod resolve;

branches/auto/src/libsyntax/ast.rs

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,10 @@ pub enum expr_ {
593593
expr_ret(Option<@expr>),
594594
expr_log(@expr, @expr),
595595
596-
expr_inline_asm(inline_asm),
596+
expr_inline_asm(@~str, // asm
597+
~[(@~str, @expr)], // inputs
598+
~[(@~str, @expr)], // outputs
599+
@~str, bool, bool), // clobbers, volatile, align stack
597600
598601
expr_mac(mac),
599602
@@ -927,27 +930,6 @@ impl to_bytes::IterBytes for Ty {
927930
}
928931
}
929932
930-
#[auto_encode]
931-
#[auto_decode]
932-
#[deriving(Eq)]
933-
pub enum asm_dialect {
934-
asm_att,
935-
asm_intel
936-
}
937-
938-
#[auto_encode]
939-
#[auto_decode]
940-
#[deriving(Eq)]
941-
pub struct inline_asm {
942-
asm: @~str,
943-
clobbers: @~str,
944-
inputs: ~[(@~str, @expr)],
945-
outputs: ~[(@~str, @expr)],
946-
volatile: bool,
947-
alignstack: bool,
948-
dialect: asm_dialect
949-
}
950-
951933
#[auto_encode]
952934
#[auto_decode]
953935
#[deriving(Eq)]

0 commit comments

Comments
 (0)