Commit f1c0a861 authored by zhengxing.li's avatar zhengxing.li Committed by Commit bot

X87: CTZ instruction implemented as optional operator.

    port b3334087 (r31313).

    original commit message:

BUG=

Review URL: https://codereview.chromium.org/1412893006

Cr-Commit-Position: refs/heads/master@{#31516}
parent 20df4b7f
......@@ -1178,6 +1178,14 @@ void Assembler::bsr(Register dst, const Operand& src) {
}
void Assembler::bsf(Register dst, const Operand& src) {
EnsureSpace ensure_space(this);
EMIT(0x0F);
EMIT(0xBC);
emit_operand(dst, src);
}
void Assembler::hlt() {
EnsureSpace ensure_space(this);
EMIT(0xF4);
......
......@@ -771,6 +771,8 @@ class Assembler : public AssemblerBase {
void bts(const Operand& dst, Register src);
void bsr(Register dst, Register src) { bsr(dst, Operand(src)); }
void bsr(Register dst, const Operand& src);
void bsf(Register dst, Register src) { bsf(dst, Operand(src)); }
void bsf(Register dst, const Operand& src);
// Miscellaneous
void hlt();
......
......@@ -2317,6 +2317,16 @@ void MacroAssembler::Lzcnt(Register dst, const Operand& src) {
}
void MacroAssembler::Tzcnt(Register dst, const Operand& src) {
// TODO(intel): Add support for TZCNT (with ABM/BMI1).
Label not_zero_src;
bsf(dst, src);
j(not_zero, &not_zero_src, Label::kNear);
Move(dst, Immediate(32)); // The result of tzcnt is 32 if src = 0.
bind(&not_zero_src);
}
void MacroAssembler::SetCounter(StatsCounter* counter, int value) {
if (FLAG_native_code_counters && counter->Enabled()) {
mov(Operand::StaticVariable(ExternalReference(counter)), Immediate(value));
......
......@@ -809,6 +809,9 @@ class MacroAssembler: public Assembler {
void Lzcnt(Register dst, Register src) { Lzcnt(dst, Operand(src)); }
void Lzcnt(Register dst, const Operand& src);
void Tzcnt(Register dst, Register src) { Tzcnt(dst, Operand(src)); }
void Tzcnt(Register dst, const Operand& src);
// Emit call to the code we are currently generating.
void CallSelf() {
Handle<Code> self(reinterpret_cast<Code**>(CodeObject().location()));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment