Skip to content

Commit e182ac4

Browse files
committed
Actually use no or multiple operands properly.
1 parent 9ead7da commit e182ac4

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

src/librustc/middle/trans/build.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -873,7 +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], output: ValueRef,
876+
inputs: &[ValueRef], output: TypeRef,
877877
volatile: bool, alignstack: bool,
878878
dia: AsmDialect) -> ValueRef {
879879
unsafe {
@@ -885,12 +885,12 @@ pub fn InlineAsmCall(cx: block, asm: *c_char, cons: *c_char,
885885
else { lib::llvm::False };
886886
887887
let argtys = do inputs.map |v| {
888-
io::println(fmt!("INPUT TYPE: %?", val_str(cx.ccx().tn, *v)));
888+
debug!("Asm Input Type: %?", val_str(cx.ccx().tn, *v));
889889
val_ty(*v)
890890
};
891891
892-
io::println(fmt!("OUTPUT TYPE: %?", val_str(cx.ccx().tn, output)));
893-
let llfty = T_fn(argtys, val_ty(output));
892+
debug!("Asm Output Type: %?", ty_str(cx.ccx().tn, output));
893+
let llfty = T_fn(argtys, output);
894894
let v = llvm::LLVMInlineAsm(llfty, asm, cons, volatile,
895895
alignstack, dia as c_uint);
896896

src/librustc/middle/trans/expr.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -629,10 +629,15 @@ fn trans_rvalue_stmt_unadjusted(bcx: block, expr: @ast::expr) -> block {
629629
constraints += *clobs;
630630
}
631631
632-
io::println(fmt!("Constraints: %?\n", constraints));
632+
debug!("Asm Constraints: %?", constraints);
633633
634-
// TODO: Handle >1 outputs
635-
let output = outputs[0];
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+
};
636641
637642
let r = do str::as_c_str(*asm) |a| {
638643
do str::as_c_str(constraints) |c| {
@@ -641,9 +646,16 @@ fn trans_rvalue_stmt_unadjusted(bcx: block, expr: @ast::expr) -> block {
641646
}
642647
};
643648
644-
// TODO: Handle >1 outputs
645-
let op = PointerCast(bcx, aoutputs[0], T_ptr(val_ty(output)));
646-
Store(bcx, r, op);
649+
if outputs.len() == 1 {
650+
let op = PointerCast(bcx, aoutputs[0], T_ptr(val_ty(outputs[0])));
651+
Store(bcx, r, op);
652+
} else {
653+
for aoutputs.eachi |i, o| {
654+
let v = ExtractValue(bcx, r, i);
655+
let op = PointerCast(bcx, *o, T_ptr(val_ty(outputs[i])));
656+
Store(bcx, v, op);
657+
}
658+
}
647659
648660
return bcx;
649661
}

0 commit comments

Comments
 (0)