Index: src/ia32/macro-assembler-ia32.cc |
diff --git a/src/ia32/macro-assembler-ia32.cc b/src/ia32/macro-assembler-ia32.cc |
index 52e674f9dc035a991b0356ab72148c2a60447f56..365ad3cc0ef40c58313058bca7d9949967196414 100644 |
--- a/src/ia32/macro-assembler-ia32.cc |
+++ b/src/ia32/macro-assembler-ia32.cc |
@@ -2466,6 +2466,17 @@ void MacroAssembler::Pinsrd(XMMRegister dst, const Operand& src, int8_t imm8) { |
} |
+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)); |