diff --git a/src/maglev/maglev-ir.cc b/src/maglev/maglev-ir.cc index 4aa3d76dc4..f0b162bb29 100644 --- a/src/maglev/maglev-ir.cc +++ b/src/maglev/maglev-ir.cc @@ -876,6 +876,14 @@ void BranchIfTrue::GenerateCode(MaglevCodeGenState* code_gen_state, } } +void BranchIfCompare::AllocateVreg(MaglevVregAllocationState* vreg_state, + const ProcessingState& state) {} +void BranchIfCompare::GenerateCode(MaglevCodeGenState* code_gen_state, + const ProcessingState& state) { + USE(operation_); + UNREACHABLE(); +} + void BranchIfToBooleanTrue::AllocateVreg(MaglevVregAllocationState* vreg_state, const ProcessingState& state) { UseFixed(condition_input(), diff --git a/src/maglev/maglev-ir.h b/src/maglev/maglev-ir.h index a03a4906cd..ad0b7da5e8 100644 --- a/src/maglev/maglev-ir.h +++ b/src/maglev/maglev-ir.h @@ -1324,8 +1324,6 @@ class ConditionalControlNode : public ControlNode { if_true_(if_true_refs), if_false_(if_false_refs) {} - Input& condition_input() { return input(0); } - BasicBlock* if_true() const { return if_true_.block_ptr(); } BasicBlock* if_false() const { return if_false_.block_ptr(); } @@ -1334,10 +1332,10 @@ class ConditionalControlNode : public ControlNode { BasicBlockRef if_false_; }; -template +template class ConditionalControlNodeT : public ConditionalControlNode { STATIC_ASSERT(IsConditionalControlNode(opcode_of)); - static constexpr size_t kInputCount = 1; + static constexpr size_t kInputCount = InputCount; public: // Shadowing for static knowledge. @@ -1398,22 +1396,24 @@ class Return : public ControlNode { void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} }; -class BranchIfTrue : public ConditionalControlNodeT { - using Base = ConditionalControlNodeT; +class BranchIfTrue : public ConditionalControlNodeT<1, BranchIfTrue> { + using Base = ConditionalControlNodeT<1, BranchIfTrue>; public: explicit BranchIfTrue(size_t input_count, BasicBlockRef* if_true_refs, BasicBlockRef* if_false_refs) : Base(input_count, if_true_refs, if_false_refs) {} + Input& condition_input() { return input(0); } + void AllocateVreg(MaglevVregAllocationState*, const ProcessingState&); void GenerateCode(MaglevCodeGenState*, const ProcessingState&); void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} }; class BranchIfToBooleanTrue - : public ConditionalControlNodeT { - using Base = ConditionalControlNodeT; + : public ConditionalControlNodeT<1, BranchIfToBooleanTrue> { + using Base = ConditionalControlNodeT<1, BranchIfToBooleanTrue>; public: explicit BranchIfToBooleanTrue(size_t input_count, @@ -1423,11 +1423,36 @@ class BranchIfToBooleanTrue static constexpr OpProperties kProperties = OpProperties::Call(); + Input& condition_input() { return input(0); } + void AllocateVreg(MaglevVregAllocationState*, const ProcessingState&); void GenerateCode(MaglevCodeGenState*, const ProcessingState&); void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} }; +class BranchIfCompare + : public ConditionalControlNodeT<2, BranchIfToBooleanTrue> { + using Base = ConditionalControlNodeT<2, BranchIfToBooleanTrue>; + + public: + static constexpr int kLeftIndex = 0; + static constexpr int kRightIndex = 1; + Input& left_input() { return NodeBase::input(kLeftIndex); } + Input& right_input() { return NodeBase::input(kRightIndex); } + + explicit BranchIfCompare(size_t input_count, Operation operation, + BasicBlockRef* if_true_refs, + BasicBlockRef* if_false_refs) + : Base(input_count, if_true_refs, if_false_refs), operation_(operation) {} + + void AllocateVreg(MaglevVregAllocationState*, const ProcessingState&); + void GenerateCode(MaglevCodeGenState*, const ProcessingState&); + void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + + private: + Operation operation_; +}; + const OpProperties& NodeBase::properties() const { switch (opcode()) { #define V(Name) \