Actually use no or multiple operands properly.

This commit is contained in:
Luqman Aden 2013-03-13 13:21:54 -07:00 committed by Luqman Aden
parent 9ead7dad93
commit e182ac4bbd
2 changed files with 22 additions and 10 deletions

View File

@ -873,7 +873,7 @@ pub fn add_comment(bcx: block, text: &str) {
}
pub fn InlineAsmCall(cx: block, asm: *c_char, cons: *c_char,
inputs: &[ValueRef], output: ValueRef,
inputs: &[ValueRef], output: TypeRef,
volatile: bool, alignstack: bool,
dia: AsmDialect) -> ValueRef {
unsafe {
@ -885,12 +885,12 @@ pub fn InlineAsmCall(cx: block, asm: *c_char, cons: *c_char,
else { lib::llvm::False };
let argtys = do inputs.map |v| {
io::println(fmt!("INPUT TYPE: %?", val_str(cx.ccx().tn, *v)));
debug!("Asm Input Type: %?", val_str(cx.ccx().tn, *v));
val_ty(*v)
};
io::println(fmt!("OUTPUT TYPE: %?", val_str(cx.ccx().tn, output)));
let llfty = T_fn(argtys, val_ty(output));
debug!("Asm Output Type: %?", ty_str(cx.ccx().tn, output));
let llfty = T_fn(argtys, output);
let v = llvm::LLVMInlineAsm(llfty, asm, cons, volatile,
alignstack, dia as c_uint);

View File

@ -629,10 +629,15 @@ fn trans_rvalue_stmt_unadjusted(bcx: block, expr: @ast::expr) -> block {
constraints += *clobs;
}
io::println(fmt!("Constraints: %?\n", constraints));
debug!("Asm Constraints: %?", constraints);
// TODO: Handle >1 outputs
let output = outputs[0];
let output = if outputs.len() == 0 {
T_void()
} else if outputs.len() == 1 {
val_ty(outputs[0])
} else {
T_struct(outputs.map(|o| val_ty(*o)))
};
let r = do str::as_c_str(*asm) |a| {
do str::as_c_str(constraints) |c| {
@ -641,9 +646,16 @@ fn trans_rvalue_stmt_unadjusted(bcx: block, expr: @ast::expr) -> block {
}
};
// TODO: Handle >1 outputs
let op = PointerCast(bcx, aoutputs[0], T_ptr(val_ty(output)));
Store(bcx, r, op);
if outputs.len() == 1 {
let op = PointerCast(bcx, aoutputs[0], T_ptr(val_ty(outputs[0])));
Store(bcx, r, op);
} else {
for aoutputs.eachi |i, o| {
let v = ExtractValue(bcx, r, i);
let op = PointerCast(bcx, *o, T_ptr(val_ty(outputs[i])));
Store(bcx, v, op);
}
}
return bcx;
}