Commit cef57b95 authored by Victor Gomes's avatar Victor Gomes Committed by V8 LUCI CQ

[maglev] Prepare BranchIfCompare

Define dummy BranchIfCompare, a conditional control node
that accepts more than one input node.

Bug: v8:7700
Change-Id: If29b6e9531e8a75a4e94fb2057d8e8d36cf0d9ee
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3506376
Auto-Submit: Victor Gomes <victorgomes@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79399}
parent cc828bb4
...@@ -876,6 +876,14 @@ void BranchIfTrue::GenerateCode(MaglevCodeGenState* code_gen_state, ...@@ -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, void BranchIfToBooleanTrue::AllocateVreg(MaglevVregAllocationState* vreg_state,
const ProcessingState& state) { const ProcessingState& state) {
UseFixed(condition_input(), UseFixed(condition_input(),
......
...@@ -1324,8 +1324,6 @@ class ConditionalControlNode : public ControlNode { ...@@ -1324,8 +1324,6 @@ class ConditionalControlNode : public ControlNode {
if_true_(if_true_refs), if_true_(if_true_refs),
if_false_(if_false_refs) {} if_false_(if_false_refs) {}
Input& condition_input() { return input(0); }
BasicBlock* if_true() const { return if_true_.block_ptr(); } BasicBlock* if_true() const { return if_true_.block_ptr(); }
BasicBlock* if_false() const { return if_false_.block_ptr(); } BasicBlock* if_false() const { return if_false_.block_ptr(); }
...@@ -1334,10 +1332,10 @@ class ConditionalControlNode : public ControlNode { ...@@ -1334,10 +1332,10 @@ class ConditionalControlNode : public ControlNode {
BasicBlockRef if_false_; BasicBlockRef if_false_;
}; };
template <class Derived> template <size_t InputCount, class Derived>
class ConditionalControlNodeT : public ConditionalControlNode { class ConditionalControlNodeT : public ConditionalControlNode {
STATIC_ASSERT(IsConditionalControlNode(opcode_of<Derived>)); STATIC_ASSERT(IsConditionalControlNode(opcode_of<Derived>));
static constexpr size_t kInputCount = 1; static constexpr size_t kInputCount = InputCount;
public: public:
// Shadowing for static knowledge. // Shadowing for static knowledge.
...@@ -1398,22 +1396,24 @@ class Return : public ControlNode { ...@@ -1398,22 +1396,24 @@ class Return : public ControlNode {
void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} void PrintParams(std::ostream&, MaglevGraphLabeller*) const {}
}; };
class BranchIfTrue : public ConditionalControlNodeT<BranchIfTrue> { class BranchIfTrue : public ConditionalControlNodeT<1, BranchIfTrue> {
using Base = ConditionalControlNodeT<BranchIfTrue>; using Base = ConditionalControlNodeT<1, BranchIfTrue>;
public: public:
explicit BranchIfTrue(size_t input_count, BasicBlockRef* if_true_refs, explicit BranchIfTrue(size_t input_count, BasicBlockRef* if_true_refs,
BasicBlockRef* if_false_refs) BasicBlockRef* if_false_refs)
: Base(input_count, if_true_refs, if_false_refs) {} : Base(input_count, if_true_refs, if_false_refs) {}
Input& condition_input() { return input(0); }
void AllocateVreg(MaglevVregAllocationState*, const ProcessingState&); void AllocateVreg(MaglevVregAllocationState*, const ProcessingState&);
void GenerateCode(MaglevCodeGenState*, const ProcessingState&); void GenerateCode(MaglevCodeGenState*, const ProcessingState&);
void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} void PrintParams(std::ostream&, MaglevGraphLabeller*) const {}
}; };
class BranchIfToBooleanTrue class BranchIfToBooleanTrue
: public ConditionalControlNodeT<BranchIfToBooleanTrue> { : public ConditionalControlNodeT<1, BranchIfToBooleanTrue> {
using Base = ConditionalControlNodeT<BranchIfToBooleanTrue>; using Base = ConditionalControlNodeT<1, BranchIfToBooleanTrue>;
public: public:
explicit BranchIfToBooleanTrue(size_t input_count, explicit BranchIfToBooleanTrue(size_t input_count,
...@@ -1423,9 +1423,34 @@ class BranchIfToBooleanTrue ...@@ -1423,9 +1423,34 @@ class BranchIfToBooleanTrue
static constexpr OpProperties kProperties = OpProperties::Call(); 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 AllocateVreg(MaglevVregAllocationState*, const ProcessingState&);
void GenerateCode(MaglevCodeGenState*, const ProcessingState&); void GenerateCode(MaglevCodeGenState*, const ProcessingState&);
void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} void PrintParams(std::ostream&, MaglevGraphLabeller*) const {}
private:
Operation operation_;
}; };
const OpProperties& NodeBase::properties() const { const OpProperties& NodeBase::properties() const {
......
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