mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-02 07:22:42 +00:00
Move default inline asm dialect to Session
This commit is contained in:
parent
39dcd01bf5
commit
05ae66607f
@ -12,7 +12,6 @@ use rustc_span::{
|
|||||||
BytePos,
|
BytePos,
|
||||||
};
|
};
|
||||||
use rustc_span::{InnerSpan, Span};
|
use rustc_span::{InnerSpan, Span};
|
||||||
use rustc_target::asm::InlineAsmArch;
|
|
||||||
|
|
||||||
struct AsmArgs {
|
struct AsmArgs {
|
||||||
templates: Vec<P<ast::Expr>>,
|
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 line_spans = Vec::with_capacity(args.templates.len());
|
||||||
let mut curarg = 0;
|
let mut curarg = 0;
|
||||||
|
|
||||||
|
let default_dialect = ecx.sess.inline_asm_dialect();
|
||||||
|
|
||||||
for template_expr in args.templates.into_iter() {
|
for template_expr in args.templates.into_iter() {
|
||||||
if !template.is_empty() {
|
if !template.is_empty() {
|
||||||
template.push(ast::InlineAsmTemplatePiece::String("\n".to_string()));
|
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();
|
let template_snippet = ecx.source_map().span_to_snippet(template_sp).ok();
|
||||||
|
|
||||||
if let Some(snippet) = &template_snippet {
|
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('"');
|
let snippet = snippet.trim_matches('"');
|
||||||
match default_dialect {
|
match default_dialect {
|
||||||
ast::LlvmAsmDialect::Intel => {
|
ast::LlvmAsmDialect::Intel => {
|
||||||
|
@ -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 {
|
pub fn relocation_model(&self) -> RelocModel {
|
||||||
self.opts.cg.relocation_model.unwrap_or(self.target.relocation_model)
|
self.opts.cg.relocation_model.unwrap_or(self.target.relocation_model)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user