Index: src/x64/macro-assembler-x64.cc |
diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc |
index 293b064a448ed7b96cfc87a0999260d9b598139b..12c471c2fface1519c1141ef9ee701a9fb7c80da 100644 |
--- a/src/x64/macro-assembler-x64.cc |
+++ b/src/x64/macro-assembler-x64.cc |
@@ -2886,6 +2886,28 @@ void MacroAssembler::Pinsrd(XMMRegister dst, const Operand& src, int8_t imm8) { |
} |
+void MacroAssembler::Lzcntl(Register dst, Register src) { |
+ // TODO(intel): Add support for LZCNT (BMI1/ABM). |
+ Label not_zero_src; |
+ bsrl(dst, src); |
+ j(not_zero, ¬_zero_src, Label::kNear); |
+ Set(dst, 63); // 63^31 == 32 |
+ bind(¬_zero_src); |
+ xorl(dst, Immediate(31)); // for x in [0..31], 31^x == 31 - x |
+} |
+ |
+ |
+void MacroAssembler::Lzcntl(Register dst, const Operand& src) { |
+ // TODO(intel): Add support for LZCNT (BMI1/ABM). |
+ Label not_zero_src; |
+ bsrl(dst, src); |
+ j(not_zero, ¬_zero_src, Label::kNear); |
+ Set(dst, 63); // 63^31 == 32 |
+ bind(¬_zero_src); |
+ xorl(dst, Immediate(31)); // for x in [0..31], 31^x == 31 - x |
+} |
+ |
+ |
void MacroAssembler::Pushad() { |
Push(rax); |
Push(rcx); |