Index: src/x87/macro-assembler-x87.cc |
diff --git a/src/x87/macro-assembler-x87.cc b/src/x87/macro-assembler-x87.cc |
index fc067348e4626ee2e6dd5b2f19a00c03e96af995..b6befebf67ecefe251a4b0446143f17775136898 100644 |
--- a/src/x87/macro-assembler-x87.cc |
+++ b/src/x87/macro-assembler-x87.cc |
@@ -2355,6 +2355,17 @@ void MacroAssembler::Move(const Operand& dst, const Immediate& x) { |
} |
+void MacroAssembler::Lzcnt(Register dst, const Operand& src) { |
+ // TODO(intel): Add support for LZCNT (with ABM/BMI1). |
+ Label not_zero_src; |
+ bsr(dst, src); |
+ j(not_zero, ¬_zero_src, Label::kNear); |
+ Move(dst, Immediate(63)); // 63^31 == 32 |
+ bind(¬_zero_src); |
+ xor_(dst, Immediate(31)); // for x in [0..31], 31^x == 31-x. |
+} |
+ |
+ |
void MacroAssembler::SetCounter(StatsCounter* counter, int value) { |
if (FLAG_native_code_counters && counter->Enabled()) { |
mov(Operand::StaticVariable(ExternalReference(counter)), Immediate(value)); |