Commit e093b6d3 authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Cache more common operators.

R=svenpanne@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#27260}
parent 257ff489
......@@ -125,6 +125,15 @@ size_t ProjectionIndexOf(const Operator* const op) {
V(OsrLoopEntry, Operator::kFoldable, 0, 1, 1, 0, 1, 1)
#define CACHED_EFFECT_PHI_LIST(V) \
V(1) \
V(2) \
V(3) \
V(4) \
V(5) \
V(6)
#define CACHED_LOOP_LIST(V) \
V(1) \
V(2)
......@@ -151,6 +160,40 @@ size_t ProjectionIndexOf(const Operator* const op) {
V(6)
#define CACHED_PHI_LIST(V) \
V(kMachAnyTagged, 1) \
V(kMachAnyTagged, 2) \
V(kMachAnyTagged, 3) \
V(kMachAnyTagged, 4) \
V(kMachAnyTagged, 5) \
V(kMachAnyTagged, 6) \
V(kMachBool, 2) \
V(kMachFloat64, 2) \
V(kMachInt32, 2)
#define CACHED_PROJECTION_LIST(V) \
V(0) \
V(1)
#define CACHED_STATE_VALUES_LIST(V) \
V(0) \
V(1) \
V(2) \
V(3) \
V(4) \
V(5) \
V(6) \
V(7) \
V(8) \
V(10) \
V(11) \
V(12) \
V(13) \
V(14)
struct CommonOperatorGlobalCache FINAL {
#define CACHED(Name, properties, value_input_count, effect_input_count, \
control_input_count, value_output_count, effect_output_count, \
......@@ -179,6 +222,19 @@ struct CommonOperatorGlobalCache FINAL {
BranchOperator<BranchHint::kTrue> kBranchTrueOperator;
BranchOperator<BranchHint::kFalse> kBranchFalseOperator;
template <int kEffectInputCount>
struct EffectPhiOperator FINAL : public Operator {
EffectPhiOperator()
: Operator( // --
IrOpcode::kEffectPhi, Operator::kPure, // opcode
"EffectPhi", // name
0, kEffectInputCount, 1, 0, 1, 0) {} // counts
};
#define CACHED_EFFECT_PHI(input_count) \
EffectPhiOperator<input_count> kEffectPhi##input_count##Operator;
CACHED_EFFECT_PHI_LIST(CACHED_EFFECT_PHI)
#undef CACHED_EFFECT_PHI
template <size_t kInputCount>
struct LoopOperator FINAL : public Operator {
LoopOperator()
......@@ -205,6 +261,20 @@ struct CommonOperatorGlobalCache FINAL {
CACHED_MERGE_LIST(CACHED_MERGE)
#undef CACHED_MERGE
template <MachineType kType, int kInputCount>
struct PhiOperator FINAL : public Operator1<MachineType> {
PhiOperator()
: Operator1<MachineType>( //--
IrOpcode::kPhi, Operator::kPure, // opcode
"Phi", // name
kInputCount, 0, 1, 1, 0, 0, // counts
kType) {} // parameter
};
#define CACHED_PHI(type, input_count) \
PhiOperator<type, input_count> kPhi##type##input_count##Operator;
CACHED_PHI_LIST(CACHED_PHI)
#undef CACHED_PHI
template <int kIndex>
struct ParameterOperator FINAL : public Operator1<int> {
ParameterOperator()
......@@ -218,6 +288,35 @@ struct CommonOperatorGlobalCache FINAL {
ParameterOperator<index> kParameter##index##Operator;
CACHED_PARAMETER_LIST(CACHED_PARAMETER)
#undef CACHED_PARAMETER
template <size_t kIndex>
struct ProjectionOperator FINAL : public Operator1<size_t> {
ProjectionOperator()
: Operator1<size_t>( // --
IrOpcode::kProjection, // opcode
Operator::kFoldable | Operator::kNoThrow, // flags
"Projection", // name
1, 0, 0, 1, 0, 0, // counts,
kIndex) {} // parameter
};
#define CACHED_PROJECTION(index) \
ProjectionOperator<index> kProjection##index##Operator;
CACHED_PROJECTION_LIST(CACHED_PROJECTION)
#undef CACHED_PROJECTION
template <int kInputCount>
struct StateValuesOperator FINAL : public Operator {
StateValuesOperator()
: Operator( // --
IrOpcode::kStateValues, // opcode
Operator::kPure, // flags
"StateValues", // name
kInputCount, 0, 0, 1, 0, 0) {} // counts
};
#define CACHED_STATE_VALUES(input_count) \
StateValuesOperator<input_count> kStateValues##input_count##Operator;
CACHED_STATE_VALUES_LIST(CACHED_STATE_VALUES)
#undef CACHED_STATE_VALUES
};
......@@ -423,22 +522,40 @@ const Operator* CommonOperatorBuilder::Select(MachineType type,
}
const Operator* CommonOperatorBuilder::Phi(MachineType type, int arguments) {
DCHECK(arguments > 0); // Disallow empty phis.
const Operator* CommonOperatorBuilder::Phi(MachineType type,
int value_input_count) {
DCHECK(value_input_count > 0); // Disallow empty phis.
#define CACHED_PHI(kType, kValueInputCount) \
if (kType == type && kValueInputCount == value_input_count) { \
return &cache_.kPhi##kType##kValueInputCount##Operator; \
}
CACHED_PHI_LIST(CACHED_PHI)
#undef CACHED_PHI
// Uncached.
return new (zone()) Operator1<MachineType>( // --
IrOpcode::kPhi, Operator::kPure, // opcode
"Phi", // name
arguments, 0, 1, 1, 0, 0, // counts
value_input_count, 0, 1, 1, 0, 0, // counts
type); // parameter
}
const Operator* CommonOperatorBuilder::EffectPhi(int arguments) {
DCHECK(arguments > 0); // Disallow empty phis.
const Operator* CommonOperatorBuilder::EffectPhi(int effect_input_count) {
DCHECK(effect_input_count > 0); // Disallow empty effect phis.
switch (effect_input_count) {
#define CACHED_EFFECT_PHI(input_count) \
case input_count: \
return &cache_.kEffectPhi##input_count##Operator;
CACHED_EFFECT_PHI_LIST(CACHED_EFFECT_PHI)
#undef CACHED_EFFECT_PHI
default:
break;
}
// Uncached.
return new (zone()) Operator( // --
IrOpcode::kEffectPhi, Operator::kPure, // opcode
"EffectPhi", // name
0, arguments, 1, 0, 1, 0); // counts
0, effect_input_count, 1, 0, 1, 0); // counts
}
......@@ -470,6 +587,16 @@ const Operator* CommonOperatorBuilder::Finish(int arguments) {
const Operator* CommonOperatorBuilder::StateValues(int arguments) {
switch (arguments) {
#define CACHED_STATE_VALUES(arguments) \
case arguments: \
return &cache_.kStateValues##arguments##Operator;
CACHED_STATE_VALUES_LIST(CACHED_STATE_VALUES)
#undef CACHED_STATE_VALUES
default:
break;
}
// Uncached.
return new (zone()) Operator( // --
IrOpcode::kStateValues, Operator::kPure, // opcode
"StateValues", // name
......@@ -510,6 +637,16 @@ const Operator* CommonOperatorBuilder::Call(const CallDescriptor* descriptor) {
const Operator* CommonOperatorBuilder::Projection(size_t index) {
switch (index) {
#define CACHED_PROJECTION(index) \
case index: \
return &cache_.kProjection##index##Operator;
CACHED_PROJECTION_LIST(CACHED_PROJECTION)
#undef CACHED_PROJECTION
default:
break;
}
// Uncached.
return new (zone()) Operator1<size_t>( // --
IrOpcode::kProjection, // opcode
Operator::kFoldable | Operator::kNoThrow, // flags
......
......@@ -199,8 +199,8 @@ class CommonOperatorBuilder FINAL : public ZoneObject {
const Operator* HeapConstant(const Unique<HeapObject>&);
const Operator* Select(MachineType, BranchHint = BranchHint::kNone);
const Operator* Phi(MachineType type, int arguments);
const Operator* EffectPhi(int arguments);
const Operator* Phi(MachineType type, int value_input_count);
const Operator* EffectPhi(int effect_input_count);
const Operator* EffectSet(int arguments);
const Operator* ValueEffect(int arguments);
const Operator* Finish(int arguments);
......
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