Skip to content

Commit 18b71a7

Browse files
committed
Add alignstack option for inline asm.
1 parent 7f500ab commit 18b71a7

File tree

5 files changed

+19
-10
lines changed

5 files changed

+19
-10
lines changed

src/librustc/middle/trans/build.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -873,12 +873,19 @@ pub fn add_comment(bcx: block, text: &str) {
873873
}
874874
875875
pub fn InlineAsmCall(cx: block, asm: *c_char, cons: *c_char,
876-
volatile: lib::llvm::Bool, dia: AsmDialect) -> ValueRef {
876+
volatile: bool, alignstack: bool,
877+
dia: AsmDialect) -> ValueRef {
877878
unsafe {
878879
count_insn(cx, "inlineasm");
879880
881+
let volatile = if volatile { lib::llvm::True }
882+
else { lib::llvm::False };
883+
let alignstack = if alignstack { lib::llvm::True }
884+
else { lib::llvm::False };
885+
880886
let llfty = T_fn(~[], T_void());
881-
let v = llvm::LLVMInlineAsm(llfty, asm, cons, volatile, False, dia);
887+
let v = llvm::LLVMInlineAsm(llfty, asm, cons, volatile,
888+
alignstack, dia);
882889
883890
Call(cx, v, ~[])
884891
}

src/librustc/middle/trans/expr.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -691,14 +691,13 @@ fn trans_rvalue_dps_unadjusted(bcx: block, expr: @ast::expr,
691691
ast::expr_assign_op(op, dst, src) => {
692692
return trans_assign_op(bcx, expr, op, dst, src);
693693
}
694-
ast::expr_inline_asm(asm, cons, volatile) => {
694+
ast::expr_inline_asm(asm, cons, volatile, alignstack) => {
695695
// XXX: cons doesn't actual contain ALL the stuff we should
696696
// be passing since the constraints for in/outputs aren't included
697697
do str::as_c_str(*asm) |a| {
698698
do str::as_c_str(*cons) |c| {
699-
let v = if volatile { lib::llvm::True }
700-
else { lib::llvm::False };
701-
InlineAsmCall(bcx, a, c, v, lib::llvm::AD_ATT);
699+
InlineAsmCall(bcx, a, c, volatile, alignstack,
700+
lib::llvm::AD_ATT);
702701
}
703702
}
704703
return bcx;

src/libsyntax/ast.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,8 @@ pub enum expr_ {
601601
expr_ret(Option<@expr>),
602602
expr_log(log_level, @expr, @expr),
603603
604-
/* asm, clobbers + constraints, volatile */
605-
expr_inline_asm(@~str, @~str, bool),
604+
/* asm, clobbers + constraints, volatile, align stack */
605+
expr_inline_asm(@~str, @~str, bool, bool),
606606
607607
expr_mac(mac),
608608

src/libsyntax/ext/asm.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ pub fn expand_asm(cx: ext_ctxt, sp: span, tts: &[ast::token_tree])
5252
let mut inputs = ~[];
5353
let mut cons = ~"";
5454
let mut volatile = false;
55+
let mut alignstack = false;
5556

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

116117
if option == ~"volatile" {
117118
volatile = true;
119+
} else if option == ~"alignstack" {
120+
alignstack = true;
118121
}
119122

120123
if *p.token == token::COMMA {
@@ -153,7 +156,7 @@ pub fn expand_asm(cx: ext_ctxt, sp: span, tts: &[ast::token_tree])
153156
MRExpr(@ast::expr {
154157
id: cx.next_id(),
155158
callee_id: cx.next_id(),
156-
node: ast::expr_inline_asm(@asm, @cons, volatile),
159+
node: ast::expr_inline_asm(@asm, @cons, volatile, alignstack),
157160
span: sp
158161
})
159162
}

src/libsyntax/print/pprust.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1398,7 +1398,7 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) {
13981398
}
13991399
}
14001400
}
1401-
ast::expr_inline_asm(a, c, v) => {
1401+
ast::expr_inline_asm(a, c, v, _) => {
14021402
if v {
14031403
word(s.s, ~"__volatile__ asm!");
14041404
} else {

0 commit comments

Comments
 (0)