Skip to content

Commit 2d068e2

Browse files
committed
---
yaml --- r: 49965 b: refs/heads/auto c: d8ab47e h: refs/heads/master i: 49963: e3bb737 v: v3
1 parent 6cb37cb commit 2d068e2

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
@@ -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: 6d078db952cf76b35bbd8577fe6a9f5d9e12c566
17+
refs/heads/auto: d8ab47e7f9ed4c30c9ff3d4e2351b19992a380dd
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167

branches/auto/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/auto/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)