about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLuqman Aden <me@luqman.ca>2013-03-27 14:42:19 -0700
committerLuqman Aden <me@luqman.ca>2013-03-27 15:41:58 -0700
commitb867fe41defd95d839c96e2b746d1c7560fd338f (patch)
treec033910b4fe02af2fbf765e1e6cfd959fcebc955
parent203d691a6bf6795f3d1f77378696a4506dd550f2 (diff)
downloadrust-b867fe41defd95d839c96e2b746d1c7560fd338f.tar.gz
rust-b867fe41defd95d839c96e2b746d1c7560fd338f.zip
libsyntax: Allow selecting intel style asm.
-rw-r--r--src/librustc/middle/trans/asm.rs7
-rw-r--r--src/libsyntax/ast.rs11
-rw-r--r--src/libsyntax/ext/asm.rs6
-rw-r--r--src/libsyntax/fold.rs5
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
@@ -937,13 +937,22 @@ impl to_bytes::IterBytes for Ty {
 #[auto_encode]
 #[auto_decode]
 #[deriving(Eq)]
+pub enum asm_dialect {
+    asm_att,
+    asm_intel
+}
+
+#[auto_encode]
+#[auto_decode]
+#[deriving(Eq)]
 pub struct inline_asm {
     asm: @~str,
     clobbers: @~str,
     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 @@ pub fn noop_fold_expr(e: &expr_, fld: @ast_fold) -> expr_ {
         }
         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))),