|
3 | 3 |
|
4 | 4 | use std::path::PathBuf; |
5 | 5 |
|
| 6 | +use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece}; |
6 | 7 | use rustc_codegen_ssa::back::linker::LinkerInfo; |
7 | 8 | use rustc_codegen_ssa::{CodegenResults, CompiledModule, CrateInfo, ModuleKind}; |
8 | 9 | use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; |
@@ -125,9 +126,19 @@ fn module_codegen( |
125 | 126 | MonoItem::Static(def_id) => crate::constant::codegen_static(tcx, &mut module, def_id), |
126 | 127 | MonoItem::GlobalAsm(item_id) => { |
127 | 128 | let item = cx.tcx.hir().item(item_id); |
128 | | - if let rustc_hir::ItemKind::GlobalAsm(rustc_hir::GlobalAsm { asm }) = item.kind { |
129 | | - cx.global_asm.push_str(&*asm.as_str()); |
130 | | - cx.global_asm.push_str("\n\n"); |
| 129 | + if let rustc_hir::ItemKind::GlobalAsm(asm) = item.kind { |
| 130 | + if !asm.options.contains(InlineAsmOptions::ATT_SYNTAX) { |
| 131 | + cx.global_asm.push_str("\n.intel_syntax noprefix\n"); |
| 132 | + } else { |
| 133 | + cx.global_asm.push_str("\n.att_syntax\n"); |
| 134 | + } |
| 135 | + for piece in asm.template { |
| 136 | + match *piece { |
| 137 | + InlineAsmTemplatePiece::String(ref s) => cx.global_asm.push_str(s), |
| 138 | + InlineAsmTemplatePiece::Placeholder { .. } => todo!(), |
| 139 | + } |
| 140 | + } |
| 141 | + cx.global_asm.push_str("\n.att_syntax\n\n"); |
131 | 142 | } else { |
132 | 143 | bug!("Expected GlobalAsm found {:?}", item); |
133 | 144 | } |
|
0 commit comments