Commit a428b0d5 authored by titzer@chromium.org's avatar titzer@chromium.org

Add a utility method to the ia32 macro assembler to move a double immediate into an XMM register.

R=mstarzinger@chromium.org
BUG=

Review URL: https://codereview.chromium.org/197233011

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20160 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent e134d32f
......@@ -2856,6 +2856,23 @@ void MacroAssembler::Move(Register dst, Immediate imm) {
}
void MacroAssembler::Move(XMMRegister dst, double val) {
// TODO(titzer): recognize double constants with ExternalReferences.
CpuFeatureScope scope(this, SSE2);
uint64_t int_val = BitCast<uint64_t, double>(val);
if (int_val == 0) {
xorps(dst, dst);
} else {
int32_t lower = static_cast<int32_t>(int_val);
int32_t upper = static_cast<int32_t>(int_val >> kBitsPerInt);
push(Immediate(upper));
push(Immediate(lower));
movsd(dst, Operand(esp, 0));
add(esp, Immediate(kDoubleSize));
}
}
void MacroAssembler::SetCounter(StatsCounter* counter, int value) {
if (FLAG_native_code_counters && counter->Enabled()) {
mov(Operand::StaticVariable(ExternalReference(counter)), Immediate(value));
......
......@@ -850,6 +850,9 @@ class MacroAssembler: public Assembler {
// Move a constant into a register using the most efficient encoding.
void Move(Register dst, Immediate imm);
// Move an immediate into an XMM register.
void Move(XMMRegister dst, double val);
// Push a handle value.
void Push(Handle<Object> handle) { push(Immediate(handle)); }
void Push(Smi* smi) { Push(Handle<Smi>(smi, isolate())); }
......
......@@ -123,6 +123,23 @@ TEST(LoadAndStoreWithRepresentation) {
__ j(not_equal, &exit);
// Test 5.
if (CpuFeatures::IsSupported(SSE2)) {
CpuFeatureScope scope(masm, SSE2);
__ mov(eax, Immediate(5)); // Test XMM move immediate.
__ Move(xmm0, 0.0);
__ Move(xmm1, 0.0);
__ ucomisd(xmm0, xmm1);
__ j(not_equal, &exit);
__ Move(xmm2, 991.01);
__ ucomisd(xmm0, xmm2);
__ j(equal, &exit);
__ Move(xmm0, 991.01);
__ ucomisd(xmm0, xmm2);
__ j(not_equal, &exit);
}
// Test 6.
__ mov(eax, Immediate(6));
__ Move(edx, Immediate(0)); // Test Move()
__ cmp(edx, Immediate(0));
__ j(not_equal, &exit);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment