Merge commit 'e8dca3e87d
' into sync_from_cg_gcc
This commit is contained in:
commit
3fac982e07
41 changed files with 7933 additions and 592 deletions
|
@ -13,6 +13,7 @@ use std::borrow::Cow;
|
|||
use crate::builder::Builder;
|
||||
use crate::context::CodegenCx;
|
||||
use crate::type_of::LayoutGccExt;
|
||||
use crate::callee::get_fn;
|
||||
|
||||
|
||||
// Rust asm! and GCC Extended Asm semantics differ substantially.
|
||||
|
@ -116,7 +117,6 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
|
|||
let asm_arch = self.tcx.sess.asm_arch.unwrap();
|
||||
let is_x86 = matches!(asm_arch, InlineAsmArch::X86 | InlineAsmArch::X86_64);
|
||||
let att_dialect = is_x86 && options.contains(InlineAsmOptions::ATT_SYNTAX);
|
||||
let intel_dialect = is_x86 && !options.contains(InlineAsmOptions::ATT_SYNTAX);
|
||||
|
||||
// GCC index of an output operand equals its position in the array
|
||||
let mut outputs = vec![];
|
||||
|
@ -348,9 +348,24 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
|
|||
// processed in the previous pass
|
||||
}
|
||||
|
||||
InlineAsmOperandRef::Const { .. }
|
||||
| InlineAsmOperandRef::SymFn { .. }
|
||||
| InlineAsmOperandRef::SymStatic { .. } => {
|
||||
InlineAsmOperandRef::SymFn { instance } => {
|
||||
inputs.push(AsmInOperand {
|
||||
constraint: "X".into(),
|
||||
rust_idx,
|
||||
val: self.cx.rvalue_as_function(get_fn(self.cx, instance))
|
||||
.get_address(None),
|
||||
});
|
||||
}
|
||||
|
||||
InlineAsmOperandRef::SymStatic { def_id } => {
|
||||
inputs.push(AsmInOperand {
|
||||
constraint: "X".into(),
|
||||
rust_idx,
|
||||
val: self.cx.get_static(def_id).get_address(None),
|
||||
});
|
||||
}
|
||||
|
||||
InlineAsmOperandRef::Const { .. } => {
|
||||
// processed in the previous pass
|
||||
}
|
||||
}
|
||||
|
@ -359,7 +374,7 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
|
|||
// 3. Build the template string
|
||||
|
||||
let mut template_str = String::with_capacity(estimate_template_length(template, constants_len, att_dialect));
|
||||
if !intel_dialect {
|
||||
if att_dialect {
|
||||
template_str.push_str(ATT_SYNTAX_INS);
|
||||
}
|
||||
|
||||
|
@ -444,7 +459,7 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
if !intel_dialect {
|
||||
if att_dialect {
|
||||
template_str.push_str(INTEL_SYNTAX_INS);
|
||||
}
|
||||
|
||||
|
@ -588,7 +603,7 @@ fn reg_to_gcc(reg: InlineAsmRegOrRegClass) -> ConstraintOrRegister {
|
|||
InlineAsmRegClass::X86(X86InlineAsmRegClass::xmm_reg)
|
||||
| InlineAsmRegClass::X86(X86InlineAsmRegClass::ymm_reg) => "x",
|
||||
InlineAsmRegClass::X86(X86InlineAsmRegClass::zmm_reg) => "v",
|
||||
InlineAsmRegClass::X86(X86InlineAsmRegClass::kreg) => unimplemented!(),
|
||||
InlineAsmRegClass::X86(X86InlineAsmRegClass::kreg) => "Yk",
|
||||
InlineAsmRegClass::X86(X86InlineAsmRegClass::kreg0) => unimplemented!(),
|
||||
InlineAsmRegClass::Wasm(WasmInlineAsmRegClass::local) => unimplemented!(),
|
||||
InlineAsmRegClass::X86(
|
||||
|
@ -672,8 +687,8 @@ impl<'gcc, 'tcx> AsmMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
|
|||
let asm_arch = self.tcx.sess.asm_arch.unwrap();
|
||||
|
||||
// Default to Intel syntax on x86
|
||||
let intel_syntax = matches!(asm_arch, InlineAsmArch::X86 | InlineAsmArch::X86_64)
|
||||
&& !options.contains(InlineAsmOptions::ATT_SYNTAX);
|
||||
let att_dialect = matches!(asm_arch, InlineAsmArch::X86 | InlineAsmArch::X86_64)
|
||||
&& options.contains(InlineAsmOptions::ATT_SYNTAX);
|
||||
|
||||
// Build the template string
|
||||
let mut template_str = String::new();
|
||||
|
@ -723,11 +738,11 @@ impl<'gcc, 'tcx> AsmMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
|
|||
}
|
||||
|
||||
let template_str =
|
||||
if intel_syntax {
|
||||
format!("{}\n\t.intel_syntax noprefix", template_str)
|
||||
if att_dialect {
|
||||
format!(".att_syntax\n\t{}\n\t.intel_syntax noprefix", template_str)
|
||||
}
|
||||
else {
|
||||
format!(".att_syntax\n\t{}\n\t.intel_syntax noprefix", template_str)
|
||||
template_str
|
||||
};
|
||||
// NOTE: seems like gcc will put the asm in the wrong section, so set it to .text manually.
|
||||
let template_str = format!(".pushsection .text\n{}\n.popsection", template_str);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue