diff options
| author | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2023-10-09 08:52:46 +0000 |
|---|---|---|
| committer | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2023-10-09 08:52:46 +0000 |
| commit | 169055f2ffef79b453e0d89599d0f0c5dabc0adb (patch) | |
| tree | 15ecc83830f64dd098939b8000c60607c9d61e86 /compiler/rustc_codegen_cranelift/src/global_asm.rs | |
| parent | 093b9d5b295d85e144d0ee7da65ea03987214c06 (diff) | |
| parent | 81dc066758ec150b43822d4a0c84aae20fe10f40 (diff) | |
| download | rust-169055f2ffef79b453e0d89599d0f0c5dabc0adb.tar.gz rust-169055f2ffef79b453e0d89599d0f0c5dabc0adb.zip | |
Merge commit '81dc066758ec150b43822d4a0c84aae20fe10f40' into sync_cg_clif-2023-10-09
Diffstat (limited to 'compiler/rustc_codegen_cranelift/src/global_asm.rs')
| -rw-r--r-- | compiler/rustc_codegen_cranelift/src/global_asm.rs | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/compiler/rustc_codegen_cranelift/src/global_asm.rs b/compiler/rustc_codegen_cranelift/src/global_asm.rs index baadd7a9e81..ebd9b728d90 100644 --- a/compiler/rustc_codegen_cranelift/src/global_asm.rs +++ b/compiler/rustc_codegen_cranelift/src/global_asm.rs @@ -9,16 +9,22 @@ use std::sync::Arc; use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece}; use rustc_hir::{InlineAsmOperand, ItemId}; use rustc_session::config::{OutputFilenames, OutputType}; +use rustc_target::asm::InlineAsmArch; use crate::prelude::*; pub(crate) fn codegen_global_asm_item(tcx: TyCtxt<'_>, global_asm: &mut String, item_id: ItemId) { let item = tcx.hir().item(item_id); if let rustc_hir::ItemKind::GlobalAsm(asm) = item.kind { - if !asm.options.contains(InlineAsmOptions::ATT_SYNTAX) { - global_asm.push_str("\n.intel_syntax noprefix\n"); - } else { - global_asm.push_str("\n.att_syntax\n"); + let is_x86 = + matches!(tcx.sess.asm_arch.unwrap(), InlineAsmArch::X86 | InlineAsmArch::X86_64); + + if is_x86 { + if !asm.options.contains(InlineAsmOptions::ATT_SYNTAX) { + global_asm.push_str("\n.intel_syntax noprefix\n"); + } else { + global_asm.push_str("\n.att_syntax\n"); + } } for piece in asm.template { match *piece { @@ -65,7 +71,11 @@ pub(crate) fn codegen_global_asm_item(tcx: TyCtxt<'_>, global_asm: &mut String, } } } - global_asm.push_str("\n.att_syntax\n\n"); + + global_asm.push('\n'); + if is_x86 { + global_asm.push_str(".att_syntax\n\n"); + } } else { bug!("Expected GlobalAsm found {:?}", item); } @@ -115,11 +125,12 @@ pub(crate) fn compile_global_asm( } // Remove all LLVM style comments - let global_asm = global_asm + let mut global_asm = global_asm .lines() .map(|line| if let Some(index) = line.find("//") { &line[0..index] } else { line }) .collect::<Vec<_>>() .join("\n"); + global_asm.push('\n'); let output_object_file = config.output_filenames.temp_path(OutputType::Object, Some(cgu_name)); |
