From b867fe41defd95d839c96e2b746d1c7560fd338f Mon Sep 17 00:00:00 2001 From: Luqman Aden Date: Wed, 27 Mar 2013 14:42:19 -0700 Subject: [PATCH] libsyntax: Allow selecting intel style asm. --- src/librustc/middle/trans/asm.rs | 7 ++++++- src/libsyntax/ast.rs | 11 ++++++++++- src/libsyntax/ext/asm.rs | 6 +++++- src/libsyntax/fold.rs | 5 +---- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/librustc/middle/trans/asm.rs b/src/librustc/middle/trans/asm.rs index a658908f978..5ad7299e1e5 100644 --- a/src/librustc/middle/trans/asm.rs +++ b/src/librustc/middle/trans/asm.rs @@ -104,10 +104,15 @@ pub fn trans_inline_asm(bcx: block, ia: &ast::inline_asm) -> block { T_struct(outputs.map(|o| val_ty(*o))) }; + let dialect = match ia.dialect { + ast::asm_att => lib::llvm::AD_ATT, + ast::asm_intel => lib::llvm::AD_Intel + }; + let r = do str::as_c_str(*ia.asm) |a| { do str::as_c_str(constraints) |c| { // XXX: Allow selection of at&t or intel - InlineAsmCall(bcx, a, c, inputs, output, ia.volatile, ia.alignstack, lib::llvm::AD_ATT) + InlineAsmCall(bcx, a, c, inputs, output, ia.volatile, ia.alignstack, dialect) } }; diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 05c5f447993..c70288902a3 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -934,6 +934,14 @@ fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { } } +#[auto_encode] +#[auto_decode] +#[deriving(Eq)] +pub enum asm_dialect { + asm_att, + asm_intel +} + #[auto_encode] #[auto_decode] #[deriving(Eq)] @@ -943,7 +951,8 @@ pub struct inline_asm { inputs: ~[(@~str, @expr)], outputs: ~[(@~str, @expr)], volatile: bool, - alignstack: bool + alignstack: bool, + dialect: asm_dialect } #[auto_encode] diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs index c3faf4f1e09..b070948d405 100644 --- a/src/libsyntax/ext/asm.rs +++ b/src/libsyntax/ext/asm.rs @@ -53,6 +53,7 @@ pub fn expand_asm(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree]) let mut cons = ~""; let mut volatile = false; let mut alignstack = false; + let mut dialect = ast::asm_att; let mut state = Asm; loop outer: { @@ -125,6 +126,8 @@ pub fn expand_asm(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree]) volatile = true; } else if option == ~"alignstack" { alignstack = true; + } else if option == ~"intel" { + dialect = ast::asm_intel; } if *p.token == token::COMMA { @@ -169,7 +172,8 @@ pub fn expand_asm(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree]) inputs: inputs, outputs: outputs, volatile: volatile, - alignstack: alignstack + alignstack: alignstack, + dialect: dialect }), span: sp }) diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 6ba629a24e1..e54c495323f 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -561,12 +561,9 @@ fn fold_field_(field: field, fld: @ast_fold) -> field { } expr_inline_asm(a) => { expr_inline_asm(inline_asm { - asm: a.asm, - clobbers: a.clobbers, inputs: a.inputs.map(|&(c, in)| (c, fld.fold_expr(in))), outputs: a.outputs.map(|&(c, out)| (c, fld.fold_expr(out))), - volatile: a.volatile, - alignstack: a.alignstack + .. a }) } expr_mac(ref mac) => expr_mac(fold_mac((*mac))),