Commit 1e52cd52 authored by zhengxing.li's avatar zhengxing.li Committed by Commit bot

X87: Added Popcnt as an optional operator and implement it on x64 and ia32.

    port 053e280c (r31319).

    original commit message:

BUG=

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

Cr-Commit-Position: refs/heads/master@{#31541}
parent 14541355
......@@ -544,6 +544,9 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
case kX87Lzcnt:
__ Lzcnt(i.OutputRegister(), i.InputOperand(0));
break;
case kX87Popcnt:
__ Popcnt(i.OutputRegister(), i.InputOperand(0));
break;
case kX87LoadFloat64Constant: {
InstructionOperand* source = instr->InputAt(0);
InstructionOperand* destination = instr->Output();
......
......@@ -33,6 +33,7 @@ namespace compiler {
V(X87Sar) \
V(X87Ror) \
V(X87Lzcnt) \
V(X87Popcnt) \
V(X87Float32Cmp) \
V(X87Float32Add) \
V(X87Float32Sub) \
......
......@@ -517,7 +517,10 @@ void InstructionSelector::VisitWord32Clz(Node* node) {
void InstructionSelector::VisitWord32Ctz(Node* node) { UNREACHABLE(); }
void InstructionSelector::VisitWord32Popcnt(Node* node) { UNREACHABLE(); }
void InstructionSelector::VisitWord32Popcnt(Node* node) {
X87OperandGenerator g(this);
Emit(kX87Popcnt, g.DefineAsRegister(node), g.Use(node->InputAt(0)));
}
void InstructionSelector::VisitInt32Add(Node* node) {
......@@ -1371,6 +1374,9 @@ InstructionSelector::SupportedMachineOperatorFlags() {
MachineOperatorBuilder::kFloat64Max |
MachineOperatorBuilder::kFloat64Min |
MachineOperatorBuilder::kWord32ShiftIsSafe;
if (CpuFeatures::IsSupported(POPCNT)) {
flags |= MachineOperatorBuilder::kWord32Popcnt;
}
return flags;
}
......
......@@ -2327,6 +2327,17 @@ void MacroAssembler::Tzcnt(Register dst, const Operand& src) {
}
void MacroAssembler::Popcnt(Register dst, const Operand& src) {
// TODO(intel): Add support for POPCNT (with POPCNT)
// if (CpuFeatures::IsSupported(POPCNT)) {
// CpuFeatureScope scope(this, POPCNT);
// popcnt(dst, src);
// return;
// }
UNREACHABLE();
}
void MacroAssembler::SetCounter(StatsCounter* counter, int value) {
if (FLAG_native_code_counters && counter->Enabled()) {
mov(Operand::StaticVariable(ExternalReference(counter)), Immediate(value));
......
......@@ -812,6 +812,9 @@ class MacroAssembler: public Assembler {
void Tzcnt(Register dst, Register src) { Tzcnt(dst, Operand(src)); }
void Tzcnt(Register dst, const Operand& src);
void Popcnt(Register dst, Register src) { Popcnt(dst, Operand(src)); }
void Popcnt(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