Index: src/x64/assembler-x64.cc |
diff --git a/src/x64/assembler-x64.cc b/src/x64/assembler-x64.cc |
index 13cbf8ca343c7e0d0bbb92aa5d3fc03cce2db273..489732e0b79e733059b71b65f8062c06004885bf 100644 |
--- a/src/x64/assembler-x64.cc |
+++ b/src/x64/assembler-x64.cc |
@@ -27,12 +27,19 @@ void CpuFeatures::ProbeImpl(bool cross_compile) { |
if (cpu.has_sse41() && FLAG_enable_sse4_1) supported_ |= 1u << SSE4_1; |
if (cpu.has_sse3() && FLAG_enable_sse3) supported_ |= 1u << SSE3; |
// SAHF is not generally available in long mode. |
- if (cpu.has_sahf() && FLAG_enable_sahf) supported_|= 1u << SAHF; |
+ if (cpu.has_sahf() && FLAG_enable_sahf) supported_ |= 1u << SAHF; |
+ if (cpu.has_avx() && FLAG_enable_avx) supported_ |= 1u << AVX; |
+ if (cpu.has_fma3() && FLAG_enable_fma3) supported_ |= 1u << FMA3; |
} |
void CpuFeatures::PrintTarget() { } |
-void CpuFeatures::PrintFeatures() { } |
+void CpuFeatures::PrintFeatures() { |
+ printf("SSE3=%d SSE4_1=%d SAHF=%d AVX=%d FMA3=%d\n", |
+ CpuFeatures::IsSupported(SSE3), CpuFeatures::IsSupported(SSE4_1), |
+ CpuFeatures::IsSupported(SAHF), CpuFeatures::IsSupported(AVX), |
+ CpuFeatures::IsSupported(FMA3)); |
+} |
// ----------------------------------------------------------------------------- |
@@ -2638,6 +2645,104 @@ void Assembler::movapd(XMMRegister dst, XMMRegister src) { |
} |
+void Assembler::addss(XMMRegister dst, XMMRegister src) { |
+ EnsureSpace ensure_space(this); |
+ emit(0xF3); |
+ emit_optional_rex_32(dst, src); |
+ emit(0x0F); |
+ emit(0x58); |
+ emit_sse_operand(dst, src); |
+} |
+ |
+ |
+void Assembler::addss(XMMRegister dst, const Operand& src) { |
+ EnsureSpace ensure_space(this); |
+ emit(0xF3); |
+ emit_optional_rex_32(dst, src); |
+ emit(0x0F); |
+ emit(0x58); |
+ emit_sse_operand(dst, src); |
+} |
+ |
+ |
+void Assembler::subss(XMMRegister dst, XMMRegister src) { |
+ EnsureSpace ensure_space(this); |
+ emit(0xF3); |
+ emit_optional_rex_32(dst, src); |
+ emit(0x0F); |
+ emit(0x5C); |
+ emit_sse_operand(dst, src); |
+} |
+ |
+ |
+void Assembler::subss(XMMRegister dst, const Operand& src) { |
+ EnsureSpace ensure_space(this); |
+ emit(0xF3); |
+ emit_optional_rex_32(dst, src); |
+ emit(0x0F); |
+ emit(0x5C); |
+ emit_sse_operand(dst, src); |
+} |
+ |
+ |
+void Assembler::mulss(XMMRegister dst, XMMRegister src) { |
+ EnsureSpace ensure_space(this); |
+ emit(0xF3); |
+ emit_optional_rex_32(dst, src); |
+ emit(0x0F); |
+ emit(0x59); |
+ emit_sse_operand(dst, src); |
+} |
+ |
+ |
+void Assembler::mulss(XMMRegister dst, const Operand& src) { |
+ EnsureSpace ensure_space(this); |
+ emit(0xF3); |
+ emit_optional_rex_32(dst, src); |
+ emit(0x0F); |
+ emit(0x59); |
+ emit_sse_operand(dst, src); |
+} |
+ |
+ |
+void Assembler::divss(XMMRegister dst, XMMRegister src) { |
+ EnsureSpace ensure_space(this); |
+ emit(0xF3); |
+ emit_optional_rex_32(dst, src); |
+ emit(0x0F); |
+ emit(0x5E); |
+ emit_sse_operand(dst, src); |
+} |
+ |
+ |
+void Assembler::divss(XMMRegister dst, const Operand& src) { |
+ EnsureSpace ensure_space(this); |
+ emit(0xF3); |
+ emit_optional_rex_32(dst, src); |
+ emit(0x0F); |
+ emit(0x5E); |
+ emit_sse_operand(dst, src); |
+} |
+ |
+ |
+void Assembler::ucomiss(XMMRegister dst, XMMRegister src) { |
+ EnsureSpace ensure_space(this); |
+ emit_optional_rex_32(dst, src); |
+ emit(0x0f); |
+ emit(0x2e); |
+ emit_sse_operand(dst, src); |
+} |
+ |
+ |
+void Assembler::ucomiss(XMMRegister dst, const Operand& src) { |
+ EnsureSpace ensure_space(this); |
+ emit_optional_rex_32(dst, src); |
+ emit(0x0f); |
+ emit(0x2e); |
+ emit_sse_operand(dst, src); |
+} |
+ |
+ |
void Assembler::movss(XMMRegister dst, const Operand& src) { |
EnsureSpace ensure_space(this); |
emit(0xF3); // single |
@@ -3077,6 +3182,86 @@ void Assembler::pcmpeqd(XMMRegister dst, XMMRegister src) { |
} |
+// byte 1 of 3-byte VEX |
+void Assembler::emit_vex3_byte1(XMMRegister reg, XMMRegister rm, byte m) { |
+ DCHECK(1 <= m && m <= 3); |
+ byte rxb = ~((reg.high_bit() << 2) | rm.high_bit()) << 5; |
+ emit(rxb | m); |
+} |
+ |
+ |
+// byte 1 of 3-byte VEX |
+void Assembler::emit_vex3_byte1(XMMRegister reg, const Operand& rm, byte m) { |
+ DCHECK(1 <= m && m <= 3); |
+ byte rxb = ~((reg.high_bit() << 2) | rm.rex_) << 5; |
+ emit(rxb | m); |
+} |
+ |
+ |
+// byte 1 of 2-byte VEX |
+void Assembler::emit_vex2_byte1(XMMRegister reg, XMMRegister v, byte lpp) { |
+ DCHECK(lpp <= 3); |
+ byte rv = ~((reg.high_bit() << 4) | v.code()) << 3; |
+ emit(rv | lpp); |
+} |
+ |
+ |
+// byte 2 of 3-byte VEX |
+void Assembler::emit_vex3_byte2(byte w, XMMRegister v, byte lpp) { |
+ DCHECK(w <= 1); |
+ DCHECK(lpp <= 3); |
+ emit((w << 7) | ((~v.code() & 0xf) << 3) | lpp); |
+} |
+ |
+ |
+void Assembler::vfmasd(byte op, XMMRegister dst, XMMRegister src1, |
+ XMMRegister src2) { |
+ DCHECK(IsEnabled(FMA3)); |
+ EnsureSpace ensure_space(this); |
+ emit_vex3_byte0(); |
+ emit_vex3_byte1(dst, src2, 0x02); |
+ emit_vex3_byte2(0x1, src1, 0x01); |
+ emit(op); |
+ emit_sse_operand(dst, src2); |
+} |
+ |
+ |
+void Assembler::vfmasd(byte op, XMMRegister dst, XMMRegister src1, |
+ const Operand& src2) { |
+ DCHECK(IsEnabled(FMA3)); |
+ EnsureSpace ensure_space(this); |
+ emit_vex3_byte0(); |
+ emit_vex3_byte1(dst, src2, 0x02); |
+ emit_vex3_byte2(0x1, src1, 0x01); |
+ emit(op); |
+ emit_sse_operand(dst, src2); |
+} |
+ |
+ |
+void Assembler::vfmass(byte op, XMMRegister dst, XMMRegister src1, |
+ XMMRegister src2) { |
+ DCHECK(IsEnabled(FMA3)); |
+ EnsureSpace ensure_space(this); |
+ emit_vex3_byte0(); |
+ emit_vex3_byte1(dst, src2, 0x02); |
+ emit_vex3_byte2(0x0, src1, 0x01); |
+ emit(op); |
+ emit_sse_operand(dst, src2); |
+} |
+ |
+ |
+void Assembler::vfmass(byte op, XMMRegister dst, XMMRegister src1, |
+ const Operand& src2) { |
+ DCHECK(IsEnabled(FMA3)); |
+ EnsureSpace ensure_space(this); |
+ emit_vex3_byte0(); |
+ emit_vex3_byte1(dst, src2, 0x02); |
+ emit_vex3_byte2(0x0, src1, 0x01); |
+ emit(op); |
+ emit_sse_operand(dst, src2); |
+} |
+ |
+ |
void Assembler::emit_sse_operand(XMMRegister reg, const Operand& adr) { |
Register ireg = { reg.code() }; |
emit_operand(ireg, adr); |