Index: test/cctest/test-macro-assembler-x64.cc |
diff --git a/test/cctest/test-macro-assembler-x64.cc b/test/cctest/test-macro-assembler-x64.cc |
index 612f9e88a3d96e5808064a037707f1f0b88c3eb9..cfdb75d1e869f84f25b8f2270ad074c19fd593f7 100644 |
--- a/test/cctest/test-macro-assembler-x64.cc |
+++ b/test/cctest/test-macro-assembler-x64.cc |
@@ -55,7 +55,10 @@ using i::carry; |
using i::greater; |
using i::greater_equal; |
using i::kIntSize; |
+using i::kFloatSize; |
+using i::kDoubleSize; |
using i::kPointerSize; |
+using i::kSimd128Size; |
using i::kSmiTagMask; |
using i::kSmiValueSize; |
using i::less_equal; |
@@ -79,6 +82,22 @@ using i::rdi; |
using i::rdx; |
using i::rsi; |
using i::rsp; |
+using i::xmm0; |
+using i::xmm1; |
+using i::xmm2; |
+using i::xmm3; |
+using i::xmm4; |
+using i::xmm5; |
+using i::xmm6; |
+using i::xmm7; |
+using i::xmm8; |
+using i::xmm9; |
+using i::xmm10; |
+using i::xmm11; |
+using i::xmm12; |
+using i::xmm13; |
+using i::xmm14; |
+using i::xmm15; |
using i::times_pointer_size; |
// Test the x64 assembler by compiling some simple functions into |
@@ -2728,5 +2747,159 @@ TEST(LoadAndStoreWithRepresentation) { |
CHECK_EQ(0, result); |
} |
+void TestFloat32x4Abs(MacroAssembler* masm, Label* exit, float x, float y, |
+ float z, float w) { |
+ __ subq(rsp, Immediate(kSimd128Size)); |
+ |
+ __ Move(xmm1, x); |
+ __ Movss(Operand(rsp, 0 * kFloatSize), xmm1); |
+ __ Move(xmm2, y); |
+ __ Movss(Operand(rsp, 1 * kFloatSize), xmm2); |
+ __ Move(xmm3, z); |
+ __ Movss(Operand(rsp, 2 * kFloatSize), xmm3); |
+ __ Move(xmm4, w); |
+ __ Movss(Operand(rsp, 3 * kFloatSize), xmm4); |
+ __ Movups(xmm0, Operand(rsp, 0)); |
+ |
+ __ Absps(xmm0); |
+ __ Movups(Operand(rsp, 0), xmm0); |
+ |
+ __ incq(rax); |
+ __ Move(xmm1, fabsf(x)); |
+ __ Ucomiss(xmm1, Operand(rsp, 0 * kFloatSize)); |
+ __ j(not_equal, exit); |
+ __ incq(rax); |
+ __ Move(xmm2, fabsf(y)); |
+ __ Ucomiss(xmm2, Operand(rsp, 1 * kFloatSize)); |
+ __ j(not_equal, exit); |
+ __ incq(rax); |
+ __ Move(xmm3, fabsf(z)); |
+ __ Ucomiss(xmm3, Operand(rsp, 2 * kFloatSize)); |
+ __ j(not_equal, exit); |
+ __ incq(rax); |
+ __ Move(xmm4, fabsf(w)); |
+ __ Ucomiss(xmm4, Operand(rsp, 3 * kFloatSize)); |
+ __ j(not_equal, exit); |
+ |
+ __ addq(rsp, Immediate(kSimd128Size)); |
+} |
+ |
+void TestFloat32x4Neg(MacroAssembler* masm, Label* exit, float x, float y, |
+ float z, float w) { |
+ __ subq(rsp, Immediate(kSimd128Size)); |
+ |
+ __ Move(xmm1, x); |
+ __ Movss(Operand(rsp, 0 * kFloatSize), xmm1); |
+ __ Move(xmm2, y); |
+ __ Movss(Operand(rsp, 1 * kFloatSize), xmm2); |
+ __ Move(xmm3, z); |
+ __ Movss(Operand(rsp, 2 * kFloatSize), xmm3); |
+ __ Move(xmm4, w); |
+ __ Movss(Operand(rsp, 3 * kFloatSize), xmm4); |
+ __ Movups(xmm0, Operand(rsp, 0)); |
+ |
+ __ Negps(xmm0); |
+ __ Movups(Operand(rsp, 0), xmm0); |
+ |
+ __ incq(rax); |
+ __ Move(xmm1, -x); |
+ __ Ucomiss(xmm1, Operand(rsp, 0 * kFloatSize)); |
+ __ j(not_equal, exit); |
+ __ incq(rax); |
+ __ Move(xmm2, -y); |
+ __ Ucomiss(xmm2, Operand(rsp, 1 * kFloatSize)); |
+ __ j(not_equal, exit); |
+ __ incq(rax); |
+ __ Move(xmm3, -z); |
+ __ Ucomiss(xmm3, Operand(rsp, 2 * kFloatSize)); |
+ __ j(not_equal, exit); |
+ __ incq(rax); |
+ __ Move(xmm4, -w); |
+ __ Ucomiss(xmm4, Operand(rsp, 3 * kFloatSize)); |
+ __ j(not_equal, exit); |
+ |
+ __ addq(rsp, Immediate(kSimd128Size)); |
+} |
+ |
+void TestFloat64x2Abs(MacroAssembler* masm, Label* exit, double x, double y) { |
+ __ subq(rsp, Immediate(kSimd128Size)); |
+ |
+ __ Move(xmm1, x); |
+ __ Movsd(Operand(rsp, 0 * kDoubleSize), xmm1); |
+ __ Move(xmm2, y); |
+ __ Movsd(Operand(rsp, 1 * kDoubleSize), xmm2); |
+ __ Movupd(xmm0, Operand(rsp, 0)); |
+ |
+ __ Abspd(xmm0); |
+ __ Movupd(Operand(rsp, 0), xmm0); |
+ |
+ __ incq(rax); |
+ __ Move(xmm1, fabs(x)); |
+ __ Ucomisd(xmm1, Operand(rsp, 0 * kDoubleSize)); |
+ __ j(not_equal, exit); |
+ __ incq(rax); |
+ __ Move(xmm2, fabs(y)); |
+ __ Ucomisd(xmm2, Operand(rsp, 1 * kDoubleSize)); |
+ __ j(not_equal, exit); |
+ |
+ __ addq(rsp, Immediate(kSimd128Size)); |
+} |
+ |
+void TestFloat64x2Neg(MacroAssembler* masm, Label* exit, double x, double y) { |
+ __ subq(rsp, Immediate(kSimd128Size)); |
+ |
+ __ Move(xmm1, x); |
+ __ Movsd(Operand(rsp, 0 * kDoubleSize), xmm1); |
+ __ Move(xmm2, y); |
+ __ Movsd(Operand(rsp, 1 * kDoubleSize), xmm2); |
+ __ Movupd(xmm0, Operand(rsp, 0)); |
+ |
+ __ Negpd(xmm0); |
+ __ Movupd(Operand(rsp, 0), xmm0); |
+ |
+ __ incq(rax); |
+ __ Move(xmm1, -x); |
+ __ Ucomisd(xmm1, Operand(rsp, 0 * kDoubleSize)); |
+ __ j(not_equal, exit); |
+ __ incq(rax); |
+ __ Move(xmm2, -y); |
+ __ Ucomisd(xmm2, Operand(rsp, 1 * kDoubleSize)); |
+ __ j(not_equal, exit); |
+ |
+ __ addq(rsp, Immediate(kSimd128Size)); |
+} |
+ |
+TEST(SIMDMacros) { |
+ // Allocate an executable page of memory. |
+ size_t actual_size; |
+ byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( |
+ Assembler::kMinimalBufferSize * 2, &actual_size, true)); |
+ CHECK(buffer); |
+ Isolate* isolate = CcTest::i_isolate(); |
+ HandleScope handles(isolate); |
+ MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size), |
+ v8::internal::CodeObjectRequired::kYes); |
+ |
+ MacroAssembler* masm = &assembler; |
+ EntryCode(masm); |
+ Label exit; |
+ |
+ __ xorq(rax, rax); |
+ TestFloat32x4Abs(masm, &exit, 1.5, -1.5, 0.5, -0.5); |
+ TestFloat32x4Neg(masm, &exit, 1.5, -1.5, 0.5, -0.5); |
+ TestFloat64x2Abs(masm, &exit, 1.75, -1.75); |
+ TestFloat64x2Neg(masm, &exit, 1.75, -1.75); |
+ |
+ __ xorq(rax, rax); // Success. |
+ __ bind(&exit); |
+ ExitCode(masm); |
+ __ ret(0); |
+ |
+ CodeDesc desc; |
+ masm->GetCode(&desc); |
+ // Call the function from C++. |
+ int result = FUNCTION_CAST<F0>(buffer)(); |
+ CHECK_EQ(0, result); |
+} |
#undef __ |