diff options
| author | asquared31415 <34665709+asquared31415@users.noreply.github.com> | 2021-03-08 12:16:12 -0500 |
|---|---|---|
| committer | asquared31415 <34665709+asquared31415@users.noreply.github.com> | 2021-03-08 12:16:12 -0500 |
| commit | 05ae66607fe2aaab786e6444f4b674499fd79319 (patch) | |
| tree | 1b093e8bb86e88b70c9ea81774255409b2ec2a40 | |
| parent | 39dcd01bf5e0c69c487f18903f44074f49ef205b (diff) | |
| download | rust-05ae66607fe2aaab786e6444f4b674499fd79319.tar.gz rust-05ae66607fe2aaab786e6444f4b674499fd79319.zip | |
Move default inline asm dialect to Session
| -rw-r--r-- | compiler/rustc_builtin_macros/src/asm.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_session/src/session.rs | 7 |
2 files changed, 9 insertions, 6 deletions
diff --git a/compiler/rustc_builtin_macros/src/asm.rs b/compiler/rustc_builtin_macros/src/asm.rs index bb529f9e5c2..8d8b3f4f6aa 100644 --- a/compiler/rustc_builtin_macros/src/asm.rs +++ b/compiler/rustc_builtin_macros/src/asm.rs @@ -12,7 +12,6 @@ use rustc_span::{ BytePos, }; use rustc_span::{InnerSpan, Span}; -use rustc_target::asm::InlineAsmArch; struct AsmArgs { templates: Vec<P<ast::Expr>>, @@ -403,6 +402,8 @@ fn expand_preparsed_asm(ecx: &mut ExtCtxt<'_>, sp: Span, args: AsmArgs) -> P<ast let mut line_spans = Vec::with_capacity(args.templates.len()); let mut curarg = 0; + let default_dialect = ecx.sess.inline_asm_dialect(); + for template_expr in args.templates.into_iter() { if !template.is_empty() { template.push(ast::InlineAsmTemplatePiece::String("\n".to_string())); @@ -430,11 +431,6 @@ fn expand_preparsed_asm(ecx: &mut ExtCtxt<'_>, sp: Span, args: AsmArgs) -> P<ast let template_snippet = ecx.source_map().span_to_snippet(template_sp).ok(); if let Some(snippet) = &template_snippet { - let default_dialect = match ecx.sess.asm_arch { - Some(InlineAsmArch::X86 | InlineAsmArch::X86_64) => ast::LlvmAsmDialect::Intel, - _ => ast::LlvmAsmDialect::Att, - }; - let snippet = snippet.trim_matches('"'); match default_dialect { ast::LlvmAsmDialect::Intel => { diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index a7ceb9e06a5..83ab066c7c3 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -784,6 +784,13 @@ impl Session { } } + pub fn inline_asm_dialect(&self) -> rustc_ast::LlvmAsmDialect { + match self.asm_arch { + Some(InlineAsmArch::X86 | InlineAsmArch::X86_64) => rustc_ast::LlvmAsmDialect::Intel, + _ => rustc_ast::LlvmAsmDialect::Att, + } + } + pub fn relocation_model(&self) -> RelocModel { self.opts.cg.relocation_model.unwrap_or(self.target.relocation_model) } |
