Skip to content

Commit

Permalink
Cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
losfair committed Nov 10, 2019
1 parent 7d5699c commit 03a9d1a
Show file tree
Hide file tree
Showing 3 changed files with 165 additions and 59 deletions.
18 changes: 12 additions & 6 deletions lib/runtime-core/src/fault.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,12 +561,18 @@ pub unsafe fn get_fault_info(siginfo: *const c_void, ucontext: *mut c_void) -> F
known_registers[X64Register::XMM(XMM::XMM7).to_index().0] = Some(read_xmm(&fpregs._xmm[7]));
known_registers[X64Register::XMM(XMM::XMM8).to_index().0] = Some(read_xmm(&fpregs._xmm[8]));
known_registers[X64Register::XMM(XMM::XMM9).to_index().0] = Some(read_xmm(&fpregs._xmm[9]));
known_registers[X64Register::XMM(XMM::XMM10).to_index().0] = Some(read_xmm(&fpregs._xmm[10]));
known_registers[X64Register::XMM(XMM::XMM11).to_index().0] = Some(read_xmm(&fpregs._xmm[11]));
known_registers[X64Register::XMM(XMM::XMM12).to_index().0] = Some(read_xmm(&fpregs._xmm[12]));
known_registers[X64Register::XMM(XMM::XMM13).to_index().0] = Some(read_xmm(&fpregs._xmm[13]));
known_registers[X64Register::XMM(XMM::XMM14).to_index().0] = Some(read_xmm(&fpregs._xmm[14]));
known_registers[X64Register::XMM(XMM::XMM15).to_index().0] = Some(read_xmm(&fpregs._xmm[15]));
known_registers[X64Register::XMM(XMM::XMM10).to_index().0] =
Some(read_xmm(&fpregs._xmm[10]));
known_registers[X64Register::XMM(XMM::XMM11).to_index().0] =
Some(read_xmm(&fpregs._xmm[11]));
known_registers[X64Register::XMM(XMM::XMM12).to_index().0] =
Some(read_xmm(&fpregs._xmm[12]));
known_registers[X64Register::XMM(XMM::XMM13).to_index().0] =
Some(read_xmm(&fpregs._xmm[13]));
known_registers[X64Register::XMM(XMM::XMM14).to_index().0] =
Some(read_xmm(&fpregs._xmm[14]));
known_registers[X64Register::XMM(XMM::XMM15).to_index().0] =
Some(read_xmm(&fpregs._xmm[15]));
}

FaultInfo {
Expand Down
190 changes: 141 additions & 49 deletions lib/singlepass-backend/src/emitter_x64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,33 +192,81 @@ pub trait Emitter {
fn emit_homomorphic_host_redirection(&mut self, target: GPR);
fn emit_inline_breakpoint(&mut self, ty: InlineBreakpointType);

fn arch_has_itruncf(&self) -> bool { false }
fn arch_emit_i32_trunc_sf32(&mut self, _src: XMM, _dst: GPR) { unimplemented!() }
fn arch_emit_i32_trunc_sf64(&mut self, _src: XMM, _dst: GPR) { unimplemented!() }
fn arch_emit_i32_trunc_uf32(&mut self, _src: XMM, _dst: GPR) { unimplemented!() }
fn arch_emit_i32_trunc_uf64(&mut self, _src: XMM, _dst: GPR) { unimplemented!() }
fn arch_emit_i64_trunc_sf32(&mut self, _src: XMM, _dst: GPR) { unimplemented!() }
fn arch_emit_i64_trunc_sf64(&mut self, _src: XMM, _dst: GPR) { unimplemented!() }
fn arch_emit_i64_trunc_uf32(&mut self, _src: XMM, _dst: GPR) { unimplemented!() }
fn arch_emit_i64_trunc_uf64(&mut self, _src: XMM, _dst: GPR) { unimplemented!() }

fn arch_has_fconverti(&self) -> bool { false }
fn arch_emit_f32_convert_si32(&mut self, _src: GPR, _dst: XMM) { unimplemented!() }
fn arch_emit_f32_convert_si64(&mut self, _src: GPR, _dst: XMM) { unimplemented!() }
fn arch_emit_f32_convert_ui32(&mut self, _src: GPR, _dst: XMM) { unimplemented!() }
fn arch_emit_f32_convert_ui64(&mut self, _src: GPR, _dst: XMM) { unimplemented!() }
fn arch_emit_f64_convert_si32(&mut self, _src: GPR, _dst: XMM) { unimplemented!() }
fn arch_emit_f64_convert_si64(&mut self, _src: GPR, _dst: XMM) { unimplemented!() }
fn arch_emit_f64_convert_ui32(&mut self, _src: GPR, _dst: XMM) { unimplemented!() }
fn arch_emit_f64_convert_ui64(&mut self, _src: GPR, _dst: XMM) { unimplemented!() }

fn arch_has_fneg(&self) -> bool { false }
fn arch_emit_f32_neg(&mut self, _src: XMM, _dst: XMM) { unimplemented!() }
fn arch_emit_f64_neg(&mut self, _src: XMM, _dst: XMM) { unimplemented!() }

fn arch_has_xzcnt(&self) -> bool { false }
fn arch_emit_lzcnt(&mut self, _sz: Size, _src: Location, _dst: Location) { unimplemented!() }
fn arch_emit_tzcnt(&mut self, _sz: Size, _src: Location, _dst: Location) { unimplemented!() }
fn arch_has_itruncf(&self) -> bool {
false
}
fn arch_emit_i32_trunc_sf32(&mut self, _src: XMM, _dst: GPR) {
unimplemented!()
}
fn arch_emit_i32_trunc_sf64(&mut self, _src: XMM, _dst: GPR) {
unimplemented!()
}
fn arch_emit_i32_trunc_uf32(&mut self, _src: XMM, _dst: GPR) {
unimplemented!()
}
fn arch_emit_i32_trunc_uf64(&mut self, _src: XMM, _dst: GPR) {
unimplemented!()
}
fn arch_emit_i64_trunc_sf32(&mut self, _src: XMM, _dst: GPR) {
unimplemented!()
}
fn arch_emit_i64_trunc_sf64(&mut self, _src: XMM, _dst: GPR) {
unimplemented!()
}
fn arch_emit_i64_trunc_uf32(&mut self, _src: XMM, _dst: GPR) {
unimplemented!()
}
fn arch_emit_i64_trunc_uf64(&mut self, _src: XMM, _dst: GPR) {
unimplemented!()
}

fn arch_has_fconverti(&self) -> bool {
false
}
fn arch_emit_f32_convert_si32(&mut self, _src: GPR, _dst: XMM) {
unimplemented!()
}
fn arch_emit_f32_convert_si64(&mut self, _src: GPR, _dst: XMM) {
unimplemented!()
}
fn arch_emit_f32_convert_ui32(&mut self, _src: GPR, _dst: XMM) {
unimplemented!()
}
fn arch_emit_f32_convert_ui64(&mut self, _src: GPR, _dst: XMM) {
unimplemented!()
}
fn arch_emit_f64_convert_si32(&mut self, _src: GPR, _dst: XMM) {
unimplemented!()
}
fn arch_emit_f64_convert_si64(&mut self, _src: GPR, _dst: XMM) {
unimplemented!()
}
fn arch_emit_f64_convert_ui32(&mut self, _src: GPR, _dst: XMM) {
unimplemented!()
}
fn arch_emit_f64_convert_ui64(&mut self, _src: GPR, _dst: XMM) {
unimplemented!()
}

fn arch_has_fneg(&self) -> bool {
false
}
fn arch_emit_f32_neg(&mut self, _src: XMM, _dst: XMM) {
unimplemented!()
}
fn arch_emit_f64_neg(&mut self, _src: XMM, _dst: XMM) {
unimplemented!()
}

fn arch_has_xzcnt(&self) -> bool {
false
}
fn arch_emit_lzcnt(&mut self, _sz: Size, _src: Location, _dst: Location) {
unimplemented!()
}
fn arch_emit_tzcnt(&mut self, _sz: Size, _src: Location, _dst: Location) {
unimplemented!()
}
}

fn _dummy(a: &mut Assembler) {
Expand Down Expand Up @@ -753,14 +801,18 @@ impl Emitter for Assembler {
match (sz, src) {
(Size::S64, Location::Imm32(src)) => dynasm!(self ; push src as i32),
(Size::S64, Location::GPR(src)) => dynasm!(self ; push Rq(src as u8)),
(Size::S64, Location::Memory(src, disp)) => dynasm!(self ; push QWORD [Rq(src as u8) + disp]),
(Size::S64, Location::Memory(src, disp)) => {
dynasm!(self ; push QWORD [Rq(src as u8) + disp])
}
_ => panic!("singlepass can't emit PUSH {:?} {:?}", sz, src),
}
}
fn emit_pop(&mut self, sz: Size, dst: Location) {
match (sz, dst) {
(Size::S64, Location::GPR(dst)) => dynasm!(self ; pop Rq(dst as u8)),
(Size::S64, Location::Memory(dst, disp)) => dynasm!(self ; pop QWORD [Rq(dst as u8) + disp]),
(Size::S64, Location::Memory(dst, disp)) => {
dynasm!(self ; pop QWORD [Rq(dst as u8) + disp])
}
_ => panic!("singlepass can't emit POP {:?} {:?}", sz, dst),
}
}
Expand All @@ -782,13 +834,21 @@ impl Emitter for Assembler {
fn emit_neg(&mut self, sz: Size, value: Location) {
match (sz, value) {
(Size::S8, Location::GPR(value)) => dynasm!(self ; neg Rb(value as u8)),
(Size::S8, Location::Memory(value, disp)) => dynasm!(self ; neg [Rq(value as u8) + disp]),
(Size::S8, Location::Memory(value, disp)) => {
dynasm!(self ; neg [Rq(value as u8) + disp])
}
(Size::S16, Location::GPR(value)) => dynasm!(self ; neg Rw(value as u8)),
(Size::S16, Location::Memory(value, disp)) => dynasm!(self ; neg [Rq(value as u8) + disp]),
(Size::S16, Location::Memory(value, disp)) => {
dynasm!(self ; neg [Rq(value as u8) + disp])
}
(Size::S32, Location::GPR(value)) => dynasm!(self ; neg Rd(value as u8)),
(Size::S32, Location::Memory(value, disp)) => dynasm!(self ; neg [Rq(value as u8) + disp]),
(Size::S32, Location::Memory(value, disp)) => {
dynasm!(self ; neg [Rq(value as u8) + disp])
}
(Size::S64, Location::GPR(value)) => dynasm!(self ; neg Rq(value as u8)),
(Size::S64, Location::Memory(value, disp)) => dynasm!(self ; neg [Rq(value as u8) + disp]),
(Size::S64, Location::Memory(value, disp)) => {
dynasm!(self ; neg [Rq(value as u8) + disp])
}
_ => panic!("singlepass can't emit NEG {:?} {:?}", sz, value),
}
}
Expand Down Expand Up @@ -1041,18 +1101,30 @@ impl Emitter for Assembler {

fn emit_vmovaps(&mut self, src: XMMOrMemory, dst: XMMOrMemory) {
match (src, dst) {
(XMMOrMemory::XMM(src), XMMOrMemory::XMM(dst)) => dynasm!(self ; movaps Rx(dst as u8), Rx(src as u8)),
(XMMOrMemory::Memory(base, disp), XMMOrMemory::XMM(dst)) => dynasm!(self ; movaps Rx(dst as u8), [Rq(base as u8) + disp]),
(XMMOrMemory::XMM(src), XMMOrMemory::Memory(base, disp)) => dynasm!(self ; movaps [Rq(base as u8) + disp], Rx(src as u8)),
(XMMOrMemory::XMM(src), XMMOrMemory::XMM(dst)) => {
dynasm!(self ; movaps Rx(dst as u8), Rx(src as u8))
}
(XMMOrMemory::Memory(base, disp), XMMOrMemory::XMM(dst)) => {
dynasm!(self ; movaps Rx(dst as u8), [Rq(base as u8) + disp])
}
(XMMOrMemory::XMM(src), XMMOrMemory::Memory(base, disp)) => {
dynasm!(self ; movaps [Rq(base as u8) + disp], Rx(src as u8))
}
_ => panic!("singlepass can't emit VMOVAPS {:?} {:?}", src, dst),
};
}

fn emit_vmovapd(&mut self, src: XMMOrMemory, dst: XMMOrMemory) {
match (src, dst) {
(XMMOrMemory::XMM(src), XMMOrMemory::XMM(dst)) => dynasm!(self ; movapd Rx(dst as u8), Rx(src as u8)),
(XMMOrMemory::Memory(base, disp), XMMOrMemory::XMM(dst)) => dynasm!(self ; movapd Rx(dst as u8), [Rq(base as u8) + disp]),
(XMMOrMemory::XMM(src), XMMOrMemory::Memory(base, disp)) => dynasm!(self ; movapd [Rq(base as u8) + disp], Rx(src as u8)),
(XMMOrMemory::XMM(src), XMMOrMemory::XMM(dst)) => {
dynasm!(self ; movapd Rx(dst as u8), Rx(src as u8))
}
(XMMOrMemory::Memory(base, disp), XMMOrMemory::XMM(dst)) => {
dynasm!(self ; movapd Rx(dst as u8), [Rq(base as u8) + disp])
}
(XMMOrMemory::XMM(src), XMMOrMemory::Memory(base, disp)) => {
dynasm!(self ; movapd [Rq(base as u8) + disp], Rx(src as u8))
}
_ => panic!("singlepass can't emit VMOVAPD {:?} {:?}", src, dst),
};
}
Expand Down Expand Up @@ -1124,57 +1196,77 @@ impl Emitter for Assembler {

fn emit_vblendvps(&mut self, src1: XMM, src2: XMMOrMemory, mask: XMM, dst: XMM) {
match src2 {
XMMOrMemory::XMM(src2) => dynasm!(self ; vblendvps Rx(dst as u8), Rx(mask as u8), Rx(src2 as u8), Rx(src1 as u8)),
XMMOrMemory::Memory(base, disp) => dynasm!(self ; vblendvps Rx(dst as u8), Rx(mask as u8), [Rq(base as u8) + disp], Rx(src1 as u8)),
XMMOrMemory::XMM(src2) => {
dynasm!(self ; vblendvps Rx(dst as u8), Rx(mask as u8), Rx(src2 as u8), Rx(src1 as u8))
}
XMMOrMemory::Memory(base, disp) => {
dynasm!(self ; vblendvps Rx(dst as u8), Rx(mask as u8), [Rq(base as u8) + disp], Rx(src1 as u8))
}
}
}

fn emit_vblendvpd(&mut self, src1: XMM, src2: XMMOrMemory, mask: XMM, dst: XMM) {
match src2 {
XMMOrMemory::XMM(src2) => dynasm!(self ; vblendvpd Rx(dst as u8), Rx(mask as u8), Rx(src2 as u8), Rx(src1 as u8)),
XMMOrMemory::Memory(base, disp) => dynasm!(self ; vblendvpd Rx(dst as u8), Rx(mask as u8), [Rq(base as u8) + disp], Rx(src1 as u8)),
XMMOrMemory::XMM(src2) => {
dynasm!(self ; vblendvpd Rx(dst as u8), Rx(mask as u8), Rx(src2 as u8), Rx(src1 as u8))
}
XMMOrMemory::Memory(base, disp) => {
dynasm!(self ; vblendvpd Rx(dst as u8), Rx(mask as u8), [Rq(base as u8) + disp], Rx(src1 as u8))
}
}
}

fn emit_ucomiss(&mut self, src: XMMOrMemory, dst: XMM) {
match src {
XMMOrMemory::XMM(x) => dynasm!(self ; ucomiss Rx(dst as u8), Rx(x as u8)),
XMMOrMemory::Memory(base, disp) => dynasm!(self ; ucomiss Rx(dst as u8), [Rq(base as u8) + disp]),
XMMOrMemory::Memory(base, disp) => {
dynasm!(self ; ucomiss Rx(dst as u8), [Rq(base as u8) + disp])
}
}
}

fn emit_ucomisd(&mut self, src: XMMOrMemory, dst: XMM) {
match src {
XMMOrMemory::XMM(x) => dynasm!(self ; ucomisd Rx(dst as u8), Rx(x as u8)),
XMMOrMemory::Memory(base, disp) => dynasm!(self ; ucomisd Rx(dst as u8), [Rq(base as u8) + disp]),
XMMOrMemory::Memory(base, disp) => {
dynasm!(self ; ucomisd Rx(dst as u8), [Rq(base as u8) + disp])
}
}
}

fn emit_cvttss2si_32(&mut self, src: XMMOrMemory, dst: GPR) {
match src {
XMMOrMemory::XMM(x) => dynasm!(self ; cvttss2si Rd(dst as u8), Rx(x as u8)),
XMMOrMemory::Memory(base, disp) => dynasm!(self ; cvttss2si Rd(dst as u8), [Rq(base as u8) + disp]),
XMMOrMemory::Memory(base, disp) => {
dynasm!(self ; cvttss2si Rd(dst as u8), [Rq(base as u8) + disp])
}
}
}

fn emit_cvttss2si_64(&mut self, src: XMMOrMemory, dst: GPR) {
match src {
XMMOrMemory::XMM(x) => dynasm!(self ; cvttss2si Rq(dst as u8), Rx(x as u8)),
XMMOrMemory::Memory(base, disp) => dynasm!(self ; cvttss2si Rq(dst as u8), [Rq(base as u8) + disp]),
XMMOrMemory::Memory(base, disp) => {
dynasm!(self ; cvttss2si Rq(dst as u8), [Rq(base as u8) + disp])
}
}
}

fn emit_cvttsd2si_32(&mut self, src: XMMOrMemory, dst: GPR) {
match src {
XMMOrMemory::XMM(x) => dynasm!(self ; cvttsd2si Rd(dst as u8), Rx(x as u8)),
XMMOrMemory::Memory(base, disp) => dynasm!(self ; cvttsd2si Rd(dst as u8), [Rq(base as u8) + disp]),
XMMOrMemory::Memory(base, disp) => {
dynasm!(self ; cvttsd2si Rd(dst as u8), [Rq(base as u8) + disp])
}
}
}

fn emit_cvttsd2si_64(&mut self, src: XMMOrMemory, dst: GPR) {
match src {
XMMOrMemory::XMM(x) => dynasm!(self ; cvttsd2si Rq(dst as u8), Rx(x as u8)),
XMMOrMemory::Memory(base, disp) => dynasm!(self ; cvttsd2si Rq(dst as u8), [Rq(base as u8) + disp]),
XMMOrMemory::Memory(base, disp) => {
dynasm!(self ; cvttsd2si Rq(dst as u8), [Rq(base as u8) + disp])
}
}
}

Expand Down
16 changes: 12 additions & 4 deletions lib/singlepass-backend/src/translator_aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,9 @@ impl Emitter for Assembler {
fn emit_bsf(&mut self, sz: Size, src: Location, dst: Location) {
unimplemented!("aarch64: bsf");
}
fn arch_has_xzcnt(&self) -> bool { true }
fn arch_has_xzcnt(&self) -> bool {
true
}
fn arch_emit_lzcnt(&mut self, sz: Size, src: Location, dst: Location) {
emit_clz_variant(self, sz, &src, &dst, false);
}
Expand Down Expand Up @@ -1461,7 +1463,9 @@ impl Emitter for Assembler {
avx_fn_unop!(frintz, D, emit_vroundsd_trunc); // toward zero
avx_fn_cvt!(fcvt, D, S, emit_vcvtsd2ss);

fn arch_has_itruncf(&self) -> bool { true }
fn arch_has_itruncf(&self) -> bool {
true
}
fn arch_emit_i32_trunc_sf32(&mut self, src: XMM, dst: GPR) {
dynasm!(self ; fcvtzs W(map_gpr(dst).x()), S(map_xmm(src).v()));
}
Expand All @@ -1487,7 +1491,9 @@ impl Emitter for Assembler {
dynasm!(self ; fcvtzu X(map_gpr(dst).x()), D(map_xmm(src).v()));
}

fn arch_has_fconverti(&self) -> bool { true }
fn arch_has_fconverti(&self) -> bool {
true
}
fn arch_emit_f32_convert_si32(&mut self, src: GPR, dst: XMM) {
dynasm!(self ; scvtf S(map_xmm(dst).v()), W(map_gpr(src).x()));
}
Expand All @@ -1513,7 +1519,9 @@ impl Emitter for Assembler {
dynasm!(self ; ucvtf D(map_xmm(dst).v()), X(map_gpr(src).x()));
}

fn arch_has_fneg(&self) -> bool { true }
fn arch_has_fneg(&self) -> bool {
true
}
fn arch_emit_f32_neg(&mut self, src: XMM, dst: XMM) {
dynasm!(self ; fneg S(map_xmm(dst).v()), S(map_xmm(src).v()));
}
Expand Down

0 comments on commit 03a9d1a

Please sign in to comment.