Rollup merge of #94169 - Amanieu:asm_stuff, r=nagisa
Fix several asm! related issues This is a combination of several fixes, each split into a separate commit. Splitting these into PRs is not practical since they conflict with each other. Fixes #92378 Fixes #85247 r? ``@nagisa``
This commit is contained in:
commit
a063e138b6
1 changed files with 11 additions and 9 deletions
|
@ -106,6 +106,7 @@ pub(crate) fn codegen_inline_asm<'tcx>(
|
||||||
let mut asm_gen = InlineAssemblyGenerator {
|
let mut asm_gen = InlineAssemblyGenerator {
|
||||||
tcx: fx.tcx,
|
tcx: fx.tcx,
|
||||||
arch: fx.tcx.sess.asm_arch.unwrap(),
|
arch: fx.tcx.sess.asm_arch.unwrap(),
|
||||||
|
enclosing_def_id: fx.instance.def_id(),
|
||||||
template,
|
template,
|
||||||
operands,
|
operands,
|
||||||
options,
|
options,
|
||||||
|
@ -169,6 +170,7 @@ pub(crate) fn codegen_inline_asm<'tcx>(
|
||||||
struct InlineAssemblyGenerator<'a, 'tcx> {
|
struct InlineAssemblyGenerator<'a, 'tcx> {
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
arch: InlineAsmArch,
|
arch: InlineAsmArch,
|
||||||
|
enclosing_def_id: DefId,
|
||||||
template: &'a [InlineAsmTemplatePiece],
|
template: &'a [InlineAsmTemplatePiece],
|
||||||
operands: &'a [InlineAsmOperand<'tcx>],
|
operands: &'a [InlineAsmOperand<'tcx>],
|
||||||
options: InlineAsmOptions,
|
options: InlineAsmOptions,
|
||||||
|
@ -182,7 +184,12 @@ struct InlineAssemblyGenerator<'a, 'tcx> {
|
||||||
impl<'tcx> InlineAssemblyGenerator<'_, 'tcx> {
|
impl<'tcx> InlineAssemblyGenerator<'_, 'tcx> {
|
||||||
fn allocate_registers(&mut self) {
|
fn allocate_registers(&mut self) {
|
||||||
let sess = self.tcx.sess;
|
let sess = self.tcx.sess;
|
||||||
let map = allocatable_registers(self.arch, &sess.target_features, &sess.target);
|
let map = allocatable_registers(
|
||||||
|
self.arch,
|
||||||
|
sess.relocation_model(),
|
||||||
|
self.tcx.asm_target_features(self.enclosing_def_id),
|
||||||
|
&sess.target,
|
||||||
|
);
|
||||||
let mut allocated = FxHashMap::<_, (bool, bool)>::default();
|
let mut allocated = FxHashMap::<_, (bool, bool)>::default();
|
||||||
let mut regs = vec![None; self.operands.len()];
|
let mut regs = vec![None; self.operands.len()];
|
||||||
|
|
||||||
|
@ -313,14 +320,9 @@ impl<'tcx> InlineAssemblyGenerator<'_, 'tcx> {
|
||||||
let mut new_slot = |x| new_slot_fn(&mut slot_size, x);
|
let mut new_slot = |x| new_slot_fn(&mut slot_size, x);
|
||||||
|
|
||||||
// Allocate stack slots for saving clobbered registers
|
// Allocate stack slots for saving clobbered registers
|
||||||
let abi_clobber = InlineAsmClobberAbi::parse(
|
let abi_clobber = InlineAsmClobberAbi::parse(self.arch, &self.tcx.sess.target, sym::C)
|
||||||
self.arch,
|
.unwrap()
|
||||||
&self.tcx.sess.target_features,
|
.clobbered_regs();
|
||||||
&self.tcx.sess.target,
|
|
||||||
sym::C,
|
|
||||||
)
|
|
||||||
.unwrap()
|
|
||||||
.clobbered_regs();
|
|
||||||
for (i, reg) in self.registers.iter().enumerate().filter_map(|(i, r)| r.map(|r| (i, r))) {
|
for (i, reg) in self.registers.iter().enumerate().filter_map(|(i, r)| r.map(|r| (i, r))) {
|
||||||
let mut need_save = true;
|
let mut need_save = true;
|
||||||
// If the register overlaps with a register clobbered by function call, then
|
// If the register overlaps with a register clobbered by function call, then
|
||||||
|
|
Loading…
Add table
Reference in a new issue