Merge pull request #2833 from abrown/2826

x64: fix Inst::store to understand all scalar types
This commit is contained in:
Chris Fallin
2021-04-13 15:36:41 -07:00
committed by GitHub
2 changed files with 5 additions and 31 deletions

View File

@@ -1126,16 +1126,7 @@ impl Inst {
pub(crate) fn store(ty: Type, from_reg: Reg, to_addr: impl Into<SyntheticAmode>) -> Inst { pub(crate) fn store(ty: Type, from_reg: Reg, to_addr: impl Into<SyntheticAmode>) -> Inst {
let rc = from_reg.get_class(); let rc = from_reg.get_class();
match rc { match rc {
RegClass::I64 => Inst::mov_r_m( RegClass::I64 => Inst::mov_r_m(OperandSize::from_ty(ty), from_reg, to_addr),
match ty {
types::B1 => OperandSize::Size8,
types::I32 | types::R32 => OperandSize::Size32,
types::I64 | types::R64 => OperandSize::Size64,
_ => unimplemented!("integer store of type: {}", ty),
},
from_reg,
to_addr,
),
RegClass::V128 => { RegClass::V128 => {
let opcode = match ty { let opcode = match ty {
types::F32 => SseOpcode::Movss, types::F32 => SseOpcode::Movss,

View File

@@ -4822,28 +4822,11 @@ fn lower_insn_to_regs<C: LowerCtx<I = Inst>>(
if elem_ty == types::I128 { if elem_ty == types::I128 {
let srcs = put_input_in_regs(ctx, inputs[0]); let srcs = put_input_in_regs(ctx, inputs[0]);
ctx.emit(Inst::mov_r_m( ctx.emit(Inst::store(types::I64, srcs.regs()[0], addr.clone()));
OperandSize::Size64, ctx.emit(Inst::store(types::I64, srcs.regs()[1], addr.offset(8)));
srcs.regs()[0],
addr.clone(),
));
ctx.emit(Inst::mov_r_m(
OperandSize::Size64,
srcs.regs()[1],
addr.offset(8),
));
} else { } else {
let src = put_input_in_reg(ctx, inputs[0]); let src = put_input_in_reg(ctx, inputs[0]);
ctx.emit(Inst::store(elem_ty, src, addr));
ctx.emit(match elem_ty {
types::F32 => Inst::xmm_mov_r_m(SseOpcode::Movss, src, addr),
types::F64 => Inst::xmm_mov_r_m(SseOpcode::Movsd, src, addr),
_ if elem_ty.is_vector() && elem_ty.bits() == 128 => {
// TODO Specialize for different types: MOVUPD, MOVDQU, etc.
Inst::xmm_mov_r_m(SseOpcode::Movups, src, addr)
}
_ => Inst::mov_r_m(OperandSize::from_ty(elem_ty), src, addr),
});
} }
} }
@@ -4947,7 +4930,7 @@ fn lower_insn_to_regs<C: LowerCtx<I = Inst>>(
let ty_access = ctx.input_ty(insn, 0); let ty_access = ctx.input_ty(insn, 0);
assert!(is_valid_atomic_transaction_ty(ty_access)); assert!(is_valid_atomic_transaction_ty(ty_access));
ctx.emit(Inst::mov_r_m(OperandSize::from_ty(ty_access), data, addr)); ctx.emit(Inst::store(ty_access, data, addr));
ctx.emit(Inst::Fence { ctx.emit(Inst::Fence {
kind: FenceKind::MFence, kind: FenceKind::MFence,
}); });