Skip to content

Commit

Permalink
Remove singlepass codegen dependence on runtime memory.
Browse files Browse the repository at this point in the history
  • Loading branch information
losfair committed Nov 28, 2019
1 parent 24ead77 commit 513427b
Showing 1 changed file with 18 additions and 34 deletions.
52 changes: 18 additions & 34 deletions lib/singlepass-backend/src/codegen_x64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3482,7 +3482,7 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
let tmp_xmm2 = XMM::XMM9;
let tmp_xmm3 = XMM::XMM10;

static CANONICAL_NAN: u128 = 0x7FC0_0000;
static CANONICAL_NAN: u32 = 0x7FC0_0000;
a.emit_mov(Size::S32, Location::XMM(src1), Location::GPR(tmpg1));
a.emit_mov(Size::S32, Location::XMM(src2), Location::GPR(tmpg2));
a.emit_cmp(Size::S32, Location::GPR(tmpg2), Location::GPR(tmpg1));
Expand All @@ -3501,10 +3501,10 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
// load float canonical nan
a.emit_mov(
Size::S64,
Location::Imm64((&CANONICAL_NAN as *const u128) as u64),
Location::Imm32(CANONICAL_NAN),
Location::GPR(tmpg1),
);
a.emit_mov(Size::S64, Location::Memory(tmpg1, 0), Location::XMM(src2));
a.emit_mov(Size::S64, Location::GPR(tmpg1), Location::XMM(src2));
a.emit_vblendvps(src1, XMMOrMemory::XMM(src2), tmp_xmm1, src1);
match ret {
Location::XMM(x) => {
Expand Down Expand Up @@ -3594,8 +3594,8 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
let tmp_xmm2 = XMM::XMM9;
let tmp_xmm3 = XMM::XMM10;

static NEG_ZERO: u128 = 0x8000_0000;
static CANONICAL_NAN: u128 = 0x7FC0_0000;
static NEG_ZERO: u32 = 0x8000_0000;
static CANONICAL_NAN: u32 = 0x7FC0_0000;
a.emit_mov(Size::S32, Location::XMM(src1), Location::GPR(tmpg1));
a.emit_mov(Size::S32, Location::XMM(src2), Location::GPR(tmpg2));
a.emit_cmp(Size::S32, Location::GPR(tmpg2), Location::GPR(tmpg1));
Expand All @@ -3607,27 +3607,19 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
a.emit_jmp(Condition::None, label2);
a.emit_label(label1);
// load float -0.0
a.emit_mov(
Size::S64,
Location::Imm64((&NEG_ZERO as *const u128) as u64),
Location::GPR(tmpg1),
);
a.emit_mov(
Size::S64,
Location::Memory(tmpg1, 0),
Location::XMM(tmp_xmm2),
);
a.emit_mov(Size::S64, Location::Imm32(NEG_ZERO), Location::GPR(tmpg1));
a.emit_mov(Size::S64, Location::GPR(tmpg1), Location::XMM(tmp_xmm2));
a.emit_label(label2);
a.emit_vcmpeqss(src1, XMMOrMemory::XMM(src2), tmp_xmm3);
a.emit_vblendvps(tmp_xmm3, XMMOrMemory::XMM(tmp_xmm2), tmp_xmm1, tmp_xmm1);
a.emit_vcmpunordss(src1, XMMOrMemory::XMM(src2), src1);
// load float canonical nan
a.emit_mov(
Size::S64,
Location::Imm64((&CANONICAL_NAN as *const u128) as u64),
Location::Imm32(CANONICAL_NAN),
Location::GPR(tmpg1),
);
a.emit_mov(Size::S64, Location::Memory(tmpg1, 0), Location::XMM(src2));
a.emit_mov(Size::S64, Location::GPR(tmpg1), Location::XMM(src2));
a.emit_vblendvps(src1, XMMOrMemory::XMM(src2), tmp_xmm1, src1);
match ret {
Location::XMM(x) => {
Expand Down Expand Up @@ -3906,7 +3898,7 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
let tmp_xmm2 = XMM::XMM9;
let tmp_xmm3 = XMM::XMM10;

static CANONICAL_NAN: u128 = 0x7FF8_0000_0000_0000;
static CANONICAL_NAN: u64 = 0x7FF8_0000_0000_0000;
a.emit_mov(Size::S64, Location::XMM(src1), Location::GPR(tmpg1));
a.emit_mov(Size::S64, Location::XMM(src2), Location::GPR(tmpg2));
a.emit_cmp(Size::S64, Location::GPR(tmpg2), Location::GPR(tmpg1));
Expand All @@ -3925,10 +3917,10 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
// load float canonical nan
a.emit_mov(
Size::S64,
Location::Imm64((&CANONICAL_NAN as *const u128) as u64),
Location::Imm64(CANONICAL_NAN),
Location::GPR(tmpg1),
);
a.emit_mov(Size::S64, Location::Memory(tmpg1, 0), Location::XMM(src2));
a.emit_mov(Size::S64, Location::GPR(tmpg1), Location::XMM(src2));
a.emit_vblendvpd(src1, XMMOrMemory::XMM(src2), tmp_xmm1, src1);
match ret {
Location::XMM(x) => {
Expand Down Expand Up @@ -4018,8 +4010,8 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
let tmp_xmm2 = XMM::XMM9;
let tmp_xmm3 = XMM::XMM10;

static NEG_ZERO: u128 = 0x8000_0000_0000_0000;
static CANONICAL_NAN: u128 = 0x7FF8_0000_0000_0000;
static NEG_ZERO: u64 = 0x8000_0000_0000_0000;
static CANONICAL_NAN: u64 = 0x7FF8_0000_0000_0000;
a.emit_mov(Size::S64, Location::XMM(src1), Location::GPR(tmpg1));
a.emit_mov(Size::S64, Location::XMM(src2), Location::GPR(tmpg2));
a.emit_cmp(Size::S64, Location::GPR(tmpg2), Location::GPR(tmpg1));
Expand All @@ -4031,27 +4023,19 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
a.emit_jmp(Condition::None, label2);
a.emit_label(label1);
// load float -0.0
a.emit_mov(
Size::S64,
Location::Imm64((&NEG_ZERO as *const u128) as u64),
Location::GPR(tmpg1),
);
a.emit_mov(
Size::S64,
Location::Memory(tmpg1, 0),
Location::XMM(tmp_xmm2),
);
a.emit_mov(Size::S64, Location::Imm64(NEG_ZERO), Location::GPR(tmpg1));
a.emit_mov(Size::S64, Location::GPR(tmpg1), Location::XMM(tmp_xmm2));
a.emit_label(label2);
a.emit_vcmpeqsd(src1, XMMOrMemory::XMM(src2), tmp_xmm3);
a.emit_vblendvpd(tmp_xmm3, XMMOrMemory::XMM(tmp_xmm2), tmp_xmm1, tmp_xmm1);
a.emit_vcmpunordsd(src1, XMMOrMemory::XMM(src2), src1);
// load float canonical nan
a.emit_mov(
Size::S64,
Location::Imm64((&CANONICAL_NAN as *const u128) as u64),
Location::Imm64(CANONICAL_NAN),
Location::GPR(tmpg1),
);
a.emit_mov(Size::S64, Location::Memory(tmpg1, 0), Location::XMM(src2));
a.emit_mov(Size::S64, Location::GPR(tmpg1), Location::XMM(src2));
a.emit_vblendvpd(src1, XMMOrMemory::XMM(src2), tmp_xmm1, src1);
match ret {
Location::XMM(x) => {
Expand Down

0 comments on commit 513427b

Please sign in to comment.