Skip to content

Commit 69a0bba

Browse files
committed
---
yaml --- r: 48757 b: refs/heads/snap-stage3 c: d8ab47e h: refs/heads/master i: 48755: fc406e5 v: v3
1 parent fc845f7 commit 69a0bba

File tree

3 files changed

+52
-8
lines changed

3 files changed

+52
-8
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: 6d078db952cf76b35bbd8577fe6a9f5d9e12c566
4+
refs/heads/snap-stage3: d8ab47e7f9ed4c30c9ff3d4e2351b19992a380dd
55
refs/heads/try: 2a8fb58d79e685d5ca07b039badcf2ae3ef077ea
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/librustc/middle/trans/build.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,7 @@ pub fn add_comment(bcx: block, text: &str) {
873873
}
874874
875875
pub fn InlineAsmCall(cx: block, asm: *c_char, cons: *c_char,
876+
inputs: &[ValueRef],
876877
volatile: bool, alignstack: bool,
877878
dia: AsmDialect) -> ValueRef {
878879
unsafe {
@@ -883,11 +884,15 @@ pub fn InlineAsmCall(cx: block, asm: *c_char, cons: *c_char,
883884
let alignstack = if alignstack { lib::llvm::True }
884885
else { lib::llvm::False };
885886
886-
let llfty = T_fn(~[], T_void());
887+
let argtys = do inputs.map |v| {
888+
io::println(fmt!("ARG TYPE: %?", val_str(cx.ccx().tn, *v)));
889+
val_ty(*v)
890+
};
891+
let llfty = T_fn(argtys, T_void());
887892
let v = llvm::LLVMInlineAsm(llfty, asm, cons, volatile,
888893
alignstack, dia as c_uint);
889894
890-
Call(cx, v, ~[])
895+
Call(cx, v, inputs)
891896
}
892897
}
893898

branches/snap-stage3/src/librustc/middle/trans/expr.rs

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -558,12 +558,51 @@ fn trans_rvalue_stmt_unadjusted(bcx: block, expr: @ast::expr) -> block {
558558
return trans_rvalue_stmt_unadjusted(bcx, a);
559559
}
560560
ast::expr_inline_asm(asm, ref ins, ref outs,
561-
cons, volatile, alignstack) => {
562-
// XXX: cons doesn't actual contain ALL the stuff we should
563-
// be passing since the constraints for in/outputs aren't included
561+
clobs, volatile, alignstack) => {
562+
let mut constraints = ~[];
563+
let mut cleanups = ~[];
564+
565+
// TODO: Handle outputs
566+
567+
let inputs = do ins.map |&(c, in)| {
568+
569+
constraints.push(copy *c);
570+
571+
let inty = ty::arg {
572+
mode: ast::expl(ast::by_val),
573+
ty: expr_ty(bcx, in)
574+
};
575+
576+
577+
unpack_result!(bcx, {
578+
callee::trans_arg_expr(bcx, inty, in, &mut cleanups,
579+
None, callee::DontAutorefArg)
580+
})
581+
582+
};
583+
584+
for cleanups.each |c| {
585+
revoke_clean(bcx, *c);
586+
}
587+
588+
let mut constraints = str::connect(constraints, ",");
589+
590+
// Add the clobbers
591+
if *clobs != ~"" {
592+
if constraints == ~"" {
593+
constraints += *clobs;
594+
} else {
595+
constraints += ~"," + *clobs;
596+
}
597+
} else {
598+
constraints += *clobs;
599+
}
600+
601+
io::println(fmt!("Inputs: %?\nConstraints: %?\n", ins, constraints));
602+
564603
do str::as_c_str(*asm) |a| {
565-
do str::as_c_str(*cons) |c| {
566-
InlineAsmCall(bcx, a, c, volatile, alignstack,
604+
do str::as_c_str(constraints) |c| {
605+
InlineAsmCall(bcx, a, c, inputs, volatile, alignstack,
567606
lib::llvm::AD_ATT);
568607
}
569608
}

0 commit comments

Comments
 (0)