Skip to content

Commit

Permalink
Add alignstack option for inline asm.
Browse files Browse the repository at this point in the history
  • Loading branch information
luqmana committed Mar 12, 2013
1 parent 7f500ab commit 18b71a7
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
11 changes: 9 additions & 2 deletions src/librustc/middle/trans/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -873,12 +873,19 @@ pub fn add_comment(bcx: block, text: &str) {
}
pub fn InlineAsmCall(cx: block, asm: *c_char, cons: *c_char,
volatile: lib::llvm::Bool, dia: AsmDialect) -> ValueRef {
volatile: bool, alignstack: bool,
dia: AsmDialect) -> ValueRef {
unsafe {
count_insn(cx, "inlineasm");
let volatile = if volatile { lib::llvm::True }
else { lib::llvm::False };
let alignstack = if alignstack { lib::llvm::True }
else { lib::llvm::False };
let llfty = T_fn(~[], T_void());
let v = llvm::LLVMInlineAsm(llfty, asm, cons, volatile, False, dia);
let v = llvm::LLVMInlineAsm(llfty, asm, cons, volatile,
alignstack, dia);
Call(cx, v, ~[])
}
Expand Down
7 changes: 3 additions & 4 deletions src/librustc/middle/trans/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -691,14 +691,13 @@ fn trans_rvalue_dps_unadjusted(bcx: block, expr: @ast::expr,
ast::expr_assign_op(op, dst, src) => {
return trans_assign_op(bcx, expr, op, dst, src);
}
ast::expr_inline_asm(asm, cons, volatile) => {
ast::expr_inline_asm(asm, cons, volatile, alignstack) => {
// XXX: cons doesn't actual contain ALL the stuff we should
// be passing since the constraints for in/outputs aren't included
do str::as_c_str(*asm) |a| {
do str::as_c_str(*cons) |c| {
let v = if volatile { lib::llvm::True }
else { lib::llvm::False };
InlineAsmCall(bcx, a, c, v, lib::llvm::AD_ATT);
InlineAsmCall(bcx, a, c, volatile, alignstack,
lib::llvm::AD_ATT);
}
}
return bcx;
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -601,8 +601,8 @@ pub enum expr_ {
expr_ret(Option<@expr>),
expr_log(log_level, @expr, @expr),
/* asm, clobbers + constraints, volatile */
expr_inline_asm(@~str, @~str, bool),
/* asm, clobbers + constraints, volatile, align stack */
expr_inline_asm(@~str, @~str, bool, bool),
expr_mac(mac),
Expand Down
5 changes: 4 additions & 1 deletion src/libsyntax/ext/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pub fn expand_asm(cx: ext_ctxt, sp: span, tts: &[ast::token_tree])
let mut inputs = ~[];
let mut cons = ~"";
let mut volatile = false;
let mut alignstack = false;

let mut state = Asm;
loop outer: {
Expand Down Expand Up @@ -115,6 +116,8 @@ pub fn expand_asm(cx: ext_ctxt, sp: span, tts: &[ast::token_tree])

if option == ~"volatile" {
volatile = true;
} else if option == ~"alignstack" {
alignstack = true;
}

if *p.token == token::COMMA {
Expand Down Expand Up @@ -153,7 +156,7 @@ pub fn expand_asm(cx: ext_ctxt, sp: span, tts: &[ast::token_tree])
MRExpr(@ast::expr {
id: cx.next_id(),
callee_id: cx.next_id(),
node: ast::expr_inline_asm(@asm, @cons, volatile),
node: ast::expr_inline_asm(@asm, @cons, volatile, alignstack),
span: sp
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/print/pprust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1398,7 +1398,7 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) {
}
}
}
ast::expr_inline_asm(a, c, v) => {
ast::expr_inline_asm(a, c, v, _) => {
if v {
word(s.s, ~"__volatile__ asm!");
} else {
Expand Down

5 comments on commit 18b71a7

@bors
Copy link
Contributor

@bors bors commented on 18b71a7 Mar 12, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from graydon
at luqmana@18b71a7

@bors
Copy link
Contributor

@bors bors commented on 18b71a7 Mar 12, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging luqmana/rust/inline-asm = 18b71a7 into auto

@bors
Copy link
Contributor

@bors bors commented on 18b71a7 Mar 12, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

luqmana/rust/inline-asm = 18b71a7 merged ok, testing candidate = 34aaf35

@bors
Copy link
Contributor

@bors bors commented on 18b71a7 Mar 12, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 18b71a7 Mar 12, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding incoming to auto = 34aaf35

Please sign in to comment.