From ecccc0d649088720a8c4af86e1722b9a26ca31dc Mon Sep 17 00:00:00 2001 From: Luqman Aden Date: Sat, 9 Mar 2013 22:37:50 -0800 Subject: Parse inline assembly. --- src/libsyntax/ast.rs | 2 ++ src/libsyntax/fold.rs | 1 + src/libsyntax/parse/parser.rs | 10 +++++++++- src/libsyntax/parse/token.rs | 1 + src/libsyntax/print/pprust.rs | 8 ++++++++ src/libsyntax/visit.rs | 1 + 6 files changed, 22 insertions(+), 1 deletion(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 27dba9c2b5e..b7c30360613 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -600,6 +600,8 @@ pub enum expr_ { expr_again(Option), expr_ret(Option<@expr>), expr_log(log_level, @expr, @expr), + + expr_inline_asm(@~str /* asm */, @~str /* constraints */), expr_mac(mac), diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 427760c920f..15097f57b02 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -560,6 +560,7 @@ pub fn noop_fold_expr(e: &expr_, fld: @ast_fold) -> expr_ { fld.fold_expr(e) ) } + expr_inline_asm(*) => copy *e, expr_mac(ref mac) => expr_mac(fold_mac((*mac))), expr_struct(path, ref fields, maybe_expr) => { expr_struct( diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 99c1c2cb1fe..6076ad0ce0e 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -27,7 +27,7 @@ use ast::{expr_field, expr_fn_block, expr_if, expr_index}; use ast::{expr_lit, expr_log, expr_loop, expr_loop_body, expr_mac}; use ast::{expr_method_call, expr_paren, expr_path, expr_repeat}; use ast::{expr_ret, expr_swap, expr_struct, expr_tup, expr_unary}; -use ast::{expr_vec, expr_vstore, expr_vstore_mut_box}; +use ast::{expr_vec, expr_vstore, expr_vstore_mut_box, expr_inline_asm}; use ast::{expr_vstore_fixed, expr_vstore_slice, expr_vstore_box}; use ast::{expr_vstore_mut_slice, expr_while, extern_fn, field, fn_decl}; use ast::{expr_vstore_uniq, TyClosure, TyBareFn, Onceness, Once, Many}; @@ -1184,6 +1184,14 @@ pub impl Parser { } } hi = self.span.hi; + } else if self.eat_keyword(&~"__asm__") { + self.expect(&token::LPAREN); + let asm = self.parse_str(); + self.expect(&token::COMMA); + let cons = self.parse_str(); + ex = expr_inline_asm(asm, cons); + hi = self.span.hi; + self.expect(&token::RPAREN); } else if self.eat_keyword(&~"log") { self.expect(&token::LPAREN); let lvl = self.parse_expr(); diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 81aacbf173d..5cfe0bef9b8 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -488,6 +488,7 @@ pub fn temporary_keyword_table() -> HashMap<~str, ()> { pub fn strict_keyword_table() -> HashMap<~str, ()> { let words = HashMap(); let keys = ~[ + ~"__asm__", ~"as", ~"assert", ~"break", ~"const", ~"copy", diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 62f593f15c1..350ab0cf9b2 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1398,6 +1398,14 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) { } } } + ast::expr_inline_asm(a, c) => { + word(s.s, ~"__asm__"); + popen(s); + print_string(s, *a); + word_space(s, ~", "); + print_string(s, *c); + pclose(s); + } ast::expr_mac(ref m) => print_mac(s, (*m)), ast::expr_paren(e) => { popen(s); diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index f04894729bd..95ab603f584 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -562,6 +562,7 @@ pub fn visit_expr(ex: @expr, e: E, v: vt) { } expr_mac(ref mac) => visit_mac((*mac), e, v), expr_paren(x) => (v.visit_expr)(x, e, v), + expr_inline_asm(*) => (), } (v.visit_expr_post)(ex, e, v); } -- cgit 1.4.1-3-g733a5 From 666e1b463600841ae593a1468a837dc59bb7cab5 Mon Sep 17 00:00:00 2001 From: Luqman Aden Date: Sun, 10 Mar 2013 22:08:38 -0700 Subject: Create asm! syntax extension. --- src/libsyntax/ext/asm.rs | 54 +++++++++++++++++++++++++++++++++++++++++++ src/libsyntax/ext/base.rs | 2 ++ src/libsyntax/print/pprust.rs | 2 +- src/libsyntax/syntax.rc | 1 + 4 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 src/libsyntax/ext/asm.rs (limited to 'src/libsyntax') diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs new file mode 100644 index 00000000000..bbf42389907 --- /dev/null +++ b/src/libsyntax/ext/asm.rs @@ -0,0 +1,54 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + + +/* + * Inline assembly support. + */ + +use core::prelude::*; + +use ast; +use codemap::span; +use ext::base; +use ext::base::*; + +pub fn expand_asm(cx: ext_ctxt, sp: span, tts: &[ast::token_tree]) + -> base::MacResult { + let args = get_exprs_from_tts(cx, tts); + if args.len() == 0 { + cx.span_fatal(sp, "ast! takes at least 1 argument."); + } + let asm = + expr_to_str(cx, args[0], + ~"inline assembly must be a string literal."); + let cons = if args.len() > 1 { + expr_to_str(cx, args[1], + ~"constraints must be a string literal.") + } else { ~"" }; + + MRExpr(@ast::expr { + id: cx.next_id(), + callee_id: cx.next_id(), + node: ast::expr_inline_asm(@asm, @cons), + span: sp + }) +} + +// +// Local Variables: +// mode: rust +// fill-column: 78; +// indent-tabs-mode: nil +// c-basic-offset: 4 +// buffer-file-coding-system: utf-8-unix +// End: +// diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 23cabc09946..1eae4b84cc9 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -198,6 +198,8 @@ pub fn syntax_expander_table() -> SyntaxEnv { ext::source_util::expand_mod)); syntax_expanders.insert(@~"proto", builtin_item_tt(ext::pipes::expand_proto)); + syntax_expanders.insert(@~"asm", + builtin_normal_tt(ext::asm::expand_asm)); syntax_expanders.insert( @~"trace_macros", builtin_normal_tt(ext::trace_macros::expand_trace_macros)); diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 350ab0cf9b2..25c18adb2fb 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1402,7 +1402,7 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) { word(s.s, ~"__asm__"); popen(s); print_string(s, *a); - word_space(s, ~", "); + word_space(s, ~","); print_string(s, *c); pclose(s); } diff --git a/src/libsyntax/syntax.rc b/src/libsyntax/syntax.rc index 7f84d6a3010..e13ef976d97 100644 --- a/src/libsyntax/syntax.rc +++ b/src/libsyntax/syntax.rc @@ -60,6 +60,7 @@ pub mod print { } pub mod ext { + pub mod asm; pub mod base; pub mod expand; -- cgit 1.4.1-3-g733a5 From 885d0d3d3369bef72590a4d5671c0de83e968dda Mon Sep 17 00:00:00 2001 From: Luqman Aden Date: Sun, 10 Mar 2013 22:34:25 -0700 Subject: Stop parsing __asm__. --- src/etc/vim/syntax/rust.vim | 2 +- src/libsyntax/parse/parser.rs | 8 -------- src/libsyntax/parse/token.rs | 1 - 3 files changed, 1 insertion(+), 10 deletions(-) (limited to 'src/libsyntax') diff --git a/src/etc/vim/syntax/rust.vim b/src/etc/vim/syntax/rust.vim index ccd1ddc2430..f811fbf5855 100644 --- a/src/etc/vim/syntax/rust.vim +++ b/src/etc/vim/syntax/rust.vim @@ -11,7 +11,7 @@ elseif exists("b:current_syntax") endif syn match rustAssert "\ HashMap<~str, ()> { pub fn strict_keyword_table() -> HashMap<~str, ()> { let words = HashMap(); let keys = ~[ - ~"__asm__", ~"as", ~"assert", ~"break", ~"const", ~"copy", -- cgit 1.4.1-3-g733a5 From 5aa734d6a1946e526832bb602e1bb271bf26c0b1 Mon Sep 17 00:00:00 2001 From: Luqman Aden Date: Tue, 12 Mar 2013 00:01:09 -0700 Subject: Parse operands properly and add a way to indicate volatile asm. --- src/librustc/middle/trans/build.rs | 4 +- src/librustc/middle/trans/expr.rs | 8 ++- src/libsyntax/ast.rs | 3 +- src/libsyntax/ext/asm.rs | 140 ++++++++++++++++++++++++++++++++++--- src/libsyntax/print/pprust.rs | 8 ++- 5 files changed, 145 insertions(+), 18 deletions(-) (limited to 'src/libsyntax') diff --git a/src/librustc/middle/trans/build.rs b/src/librustc/middle/trans/build.rs index ad86b6c9245..2e6b0c5f782 100644 --- a/src/librustc/middle/trans/build.rs +++ b/src/librustc/middle/trans/build.rs @@ -873,12 +873,12 @@ pub fn add_comment(bcx: block, text: &str) { } pub fn InlineAsmCall(cx: block, asm: *c_char, cons: *c_char, - dia: AsmDialect) -> ValueRef { + volatile: lib::llvm::Bool, dia: AsmDialect) -> ValueRef { unsafe { count_insn(cx, "inlineasm"); let llfty = T_fn(~[], T_void()); - let v = llvm::LLVMInlineAsm(llfty, asm, cons, False, False, dia); + let v = llvm::LLVMInlineAsm(llfty, asm, cons, volatile, False, dia); Call(cx, v, ~[]) } diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index 737dd8c758a..0539dadca8e 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -691,10 +691,14 @@ 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) => { + ast::expr_inline_asm(asm, cons, volatile) => { + // 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| { - InlineAsmCall(bcx, a, c, lib::llvm::AD_ATT); + let v = if volatile { lib::llvm::True } + else { lib::llvm::False }; + InlineAsmCall(bcx, a, c, v, lib::llvm::AD_ATT); } } return bcx; diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index b7c30360613..dab5de47aa6 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -601,7 +601,8 @@ pub enum expr_ { expr_ret(Option<@expr>), expr_log(log_level, @expr, @expr), - expr_inline_asm(@~str /* asm */, @~str /* constraints */), + /* asm, clobbers + constraints, volatile */ + expr_inline_asm(@~str, @~str, bool), expr_mac(mac), diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs index bbf42389907..229d1d2a95e 100644 --- a/src/libsyntax/ext/asm.rs +++ b/src/libsyntax/ext/asm.rs @@ -20,29 +20,147 @@ use ast; use codemap::span; use ext::base; use ext::base::*; +use parse; +use parse::token; + +enum State { + Asm, + Outputs, + Inputs, + Clobbers, + Options +} + +fn next_state(s: State) -> Option { + match s { + Asm => Some(Outputs), + Outputs => Some(Inputs), + Inputs => Some(Clobbers), + Clobbers => Some(Options), + Options => None + } +} pub fn expand_asm(cx: ext_ctxt, sp: span, tts: &[ast::token_tree]) -> base::MacResult { - let args = get_exprs_from_tts(cx, tts); - if args.len() == 0 { - cx.span_fatal(sp, "ast! takes at least 1 argument."); + + let p = parse::new_parser_from_tts(cx.parse_sess(), cx.cfg(), + vec::from_slice(tts)); + + let mut asm = ~""; + let mut outputs = ~[]; + let mut inputs = ~[]; + let mut cons = ~""; + let mut volatile = false; + + let mut state = Asm; + loop outer: { + + match state { + Asm => { + asm = expr_to_str(cx, p.parse_expr(), + ~"inline assembly must be a string literal."); + } + Outputs => { + while *p.token != token::EOF && + *p.token != token::COLON && + *p.token != token::MOD_SEP { + + if outputs.len() != 0 { + p.eat(&token::COMMA); + } + + let constraint = p.parse_str(); + p.expect(&token::LPAREN); + let out = p.parse_expr(); + p.expect(&token::RPAREN); + + outputs.push((constraint, out)); + } + } + Inputs => { + while *p.token != token::EOF && + *p.token != token::COLON && + *p.token != token::MOD_SEP { + + if inputs.len() != 0 { + p.eat(&token::COMMA); + } + + let constraint = p.parse_str(); + p.expect(&token::LPAREN); + let in = p.parse_expr(); + p.expect(&token::RPAREN); + + inputs.push((constraint, in)); + } + } + Clobbers => { + let mut clobs = ~[]; + while *p.token != token::EOF && + *p.token != token::COLON && + *p.token != token::MOD_SEP { + + if clobs.len() != 0 { + p.eat(&token::COMMA); + } + + let clob = ~"~{" + *p.parse_str() + ~"}"; + clobs.push(clob); + } + + cons = str::connect(clobs, ","); + } + Options => { + let option = *p.parse_str(); + + if option == ~"volatile" { + volatile = true; + } + + if *p.token == token::COMMA { + p.eat(&token::COMMA); + } + } + } + + while *p.token == token::COLON || + *p.token == token::MOD_SEP || + *p.token == token::EOF { + state = if *p.token == token::COLON { + p.bump(); + match next_state(state) { + Some(x) => x, + None => break outer + } + } else if *p.token == token::MOD_SEP { + p.bump(); + let s = match next_state(state) { + Some(x) => x, + None => break outer + }; + match next_state(s) { + Some(x) => x, + None => break outer + } + } else if *p.token == token::EOF { + break outer; + } else { + state + }; + } } - let asm = - expr_to_str(cx, args[0], - ~"inline assembly must be a string literal."); - let cons = if args.len() > 1 { - expr_to_str(cx, args[1], - ~"constraints must be a string literal.") - } else { ~"" }; MRExpr(@ast::expr { id: cx.next_id(), callee_id: cx.next_id(), - node: ast::expr_inline_asm(@asm, @cons), + node: ast::expr_inline_asm(@asm, @cons, volatile), span: sp }) } + + // // Local Variables: // mode: rust diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 25c18adb2fb..6b1a72b92ff 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1398,8 +1398,12 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) { } } } - ast::expr_inline_asm(a, c) => { - word(s.s, ~"__asm__"); + ast::expr_inline_asm(a, c, v) => { + if v { + word(s.s, ~"__volatile__ asm!"); + } else { + word(s.s, ~"asm!"); + } popen(s); print_string(s, *a); word_space(s, ~","); -- cgit 1.4.1-3-g733a5 From 7f500ab4c1303723192952f9ae1f09290bc1fe1e Mon Sep 17 00:00:00 2001 From: Luqman Aden Date: Tue, 12 Mar 2013 00:09:53 -0700 Subject: Keep everything tidy. --- src/librustc/middle/typeck/check/mod.rs | 2 +- src/libsyntax/ast.rs | 2 +- src/libsyntax/ext/asm.rs | 17 ++++++++--------- 3 files changed, 10 insertions(+), 11 deletions(-) (limited to 'src/libsyntax') diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index e59dc1398a0..445cab4ba95 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -2303,7 +2303,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, let region_lb = ty::re_scope(expr.id); instantiate_path(fcx, pth, tpt, expr.span, expr.id, region_lb); } - ast::expr_inline_asm(*) => { + ast::expr_inline_asm(*) => { fcx.require_unsafe(expr.span, ~"use of inline assembly"); fcx.write_nil(id); } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index dab5de47aa6..7b4b382393f 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -600,7 +600,7 @@ pub enum expr_ { expr_again(Option), expr_ret(Option<@expr>), expr_log(log_level, @expr, @expr), - + /* asm, clobbers + constraints, volatile */ expr_inline_asm(@~str, @~str, bool), diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs index 229d1d2a95e..3f1aea59ab5 100644 --- a/src/libsyntax/ext/asm.rs +++ b/src/libsyntax/ext/asm.rs @@ -55,7 +55,6 @@ pub fn expand_asm(cx: ext_ctxt, sp: span, tts: &[ast::token_tree]) let mut state = Asm; loop outer: { - match state { Asm => { asm = expr_to_str(cx, p.parse_expr(), @@ -65,11 +64,11 @@ pub fn expand_asm(cx: ext_ctxt, sp: span, tts: &[ast::token_tree]) while *p.token != token::EOF && *p.token != token::COLON && *p.token != token::MOD_SEP { - + if outputs.len() != 0 { p.eat(&token::COMMA); } - + let constraint = p.parse_str(); p.expect(&token::LPAREN); let out = p.parse_expr(); @@ -82,11 +81,11 @@ pub fn expand_asm(cx: ext_ctxt, sp: span, tts: &[ast::token_tree]) while *p.token != token::EOF && *p.token != token::COLON && *p.token != token::MOD_SEP { - + if inputs.len() != 0 { p.eat(&token::COMMA); } - + let constraint = p.parse_str(); p.expect(&token::LPAREN); let in = p.parse_expr(); @@ -100,11 +99,11 @@ pub fn expand_asm(cx: ext_ctxt, sp: span, tts: &[ast::token_tree]) while *p.token != token::EOF && *p.token != token::COLON && *p.token != token::MOD_SEP { - + if clobs.len() != 0 { p.eat(&token::COMMA); } - + let clob = ~"~{" + *p.parse_str() + ~"}"; clobs.push(clob); } @@ -113,7 +112,7 @@ pub fn expand_asm(cx: ext_ctxt, sp: span, tts: &[ast::token_tree]) } Options => { let option = *p.parse_str(); - + if option == ~"volatile" { volatile = true; } @@ -146,7 +145,7 @@ pub fn expand_asm(cx: ext_ctxt, sp: span, tts: &[ast::token_tree]) } else if *p.token == token::EOF { break outer; } else { - state + state }; } } -- cgit 1.4.1-3-g733a5 From 18b71a78314505b4dd3816f9662709860aafaf4c Mon Sep 17 00:00:00 2001 From: Luqman Aden Date: Tue, 12 Mar 2013 01:02:58 -0700 Subject: Add alignstack option for inline asm. --- src/librustc/middle/trans/build.rs | 11 +++++++++-- src/librustc/middle/trans/expr.rs | 7 +++---- src/libsyntax/ast.rs | 4 ++-- src/libsyntax/ext/asm.rs | 5 ++++- src/libsyntax/print/pprust.rs | 2 +- 5 files changed, 19 insertions(+), 10 deletions(-) (limited to 'src/libsyntax') diff --git a/src/librustc/middle/trans/build.rs b/src/librustc/middle/trans/build.rs index 2e6b0c5f782..50a7669a1be 100644 --- a/src/librustc/middle/trans/build.rs +++ b/src/librustc/middle/trans/build.rs @@ -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, ~[]) } diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index 0539dadca8e..c163183bfc8 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -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; diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 7b4b382393f..b22018c4c76 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -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), diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs index 3f1aea59ab5..8051a67d8fd 100644 --- a/src/libsyntax/ext/asm.rs +++ b/src/libsyntax/ext/asm.rs @@ -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: { @@ -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 { @@ -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 }) } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 6b1a72b92ff..92883123782 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -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 { -- cgit 1.4.1-3-g733a5