Skip to content

Commit b867fe4

Browse files
committed
libsyntax: Allow selecting intel style asm.
1 parent 203d691 commit b867fe4

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

src/librustc/middle/trans/asm.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,15 @@ pub fn trans_inline_asm(bcx: block, ia: &ast::inline_asm) -> block {
104104
T_struct(outputs.map(|o| val_ty(*o)))
105105
};
106106

107+
let dialect = match ia.dialect {
108+
ast::asm_att => lib::llvm::AD_ATT,
109+
ast::asm_intel => lib::llvm::AD_Intel
110+
};
111+
107112
let r = do str::as_c_str(*ia.asm) |a| {
108113
do str::as_c_str(constraints) |c| {
109114
// XXX: Allow selection of at&t or intel
110-
InlineAsmCall(bcx, a, c, inputs, output, ia.volatile, ia.alignstack, lib::llvm::AD_ATT)
115+
InlineAsmCall(bcx, a, c, inputs, output, ia.volatile, ia.alignstack, dialect)
111116
}
112117
};
113118

src/libsyntax/ast.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,14 @@ impl to_bytes::IterBytes for Ty {
934934
}
935935
}
936936
937+
#[auto_encode]
938+
#[auto_decode]
939+
#[deriving(Eq)]
940+
pub enum asm_dialect {
941+
asm_att,
942+
asm_intel
943+
}
944+
937945
#[auto_encode]
938946
#[auto_decode]
939947
#[deriving(Eq)]
@@ -943,7 +951,8 @@ pub struct inline_asm {
943951
inputs: ~[(@~str, @expr)],
944952
outputs: ~[(@~str, @expr)],
945953
volatile: bool,
946-
alignstack: bool
954+
alignstack: bool,
955+
dialect: asm_dialect
947956
}
948957
949958
#[auto_encode]

src/libsyntax/ext/asm.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ pub fn expand_asm(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree])
5353
let mut cons = ~"";
5454
let mut volatile = false;
5555
let mut alignstack = false;
56+
let mut dialect = ast::asm_att;
5657

5758
let mut state = Asm;
5859
loop outer: {
@@ -125,6 +126,8 @@ pub fn expand_asm(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree])
125126
volatile = true;
126127
} else if option == ~"alignstack" {
127128
alignstack = true;
129+
} else if option == ~"intel" {
130+
dialect = ast::asm_intel;
128131
}
129132

130133
if *p.token == token::COMMA {
@@ -169,7 +172,8 @@ pub fn expand_asm(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree])
169172
inputs: inputs,
170173
outputs: outputs,
171174
volatile: volatile,
172-
alignstack: alignstack
175+
alignstack: alignstack,
176+
dialect: dialect
173177
}),
174178
span: sp
175179
})

src/libsyntax/fold.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -561,12 +561,9 @@ pub fn noop_fold_expr(e: &expr_, fld: @ast_fold) -> expr_ {
561561
}
562562
expr_inline_asm(a) => {
563563
expr_inline_asm(inline_asm {
564-
asm: a.asm,
565-
clobbers: a.clobbers,
566564
inputs: a.inputs.map(|&(c, in)| (c, fld.fold_expr(in))),
567565
outputs: a.outputs.map(|&(c, out)| (c, fld.fold_expr(out))),
568-
volatile: a.volatile,
569-
alignstack: a.alignstack
566+
.. a
570567
})
571568
}
572569
expr_mac(ref mac) => expr_mac(fold_mac((*mac))),

0 commit comments

Comments
 (0)