5#ifndef V8_MAGLEV_MAGLEV_REGALLOC_H_
6#define V8_MAGLEV_MAGLEV_REGALLOC_H_
20class MaglevCompilationInfo;
21class MaglevPrintingVisitor;
22class MergePointRegisterState;
33 absl::flat_hash_map<BasicBlock::Id, RegallocLoopInfo>
loop_info_;
56template <
typename RegisterT>
60 std::is_same<Register, RegisterT>();
62 std::is_same<DoubleRegister, RegisterT>();
65 "RegisterFrameState should be used only for Register and "
85 template <
typename Function>
97 RegTList list = node->ClearRegisters<RegisterT>();
107 node->AddRegister(
reg);
126 ValueNode* GetValueMaybeFreeButBlocked(RegisterT
reg)
const {
203 template <
typename RegisterT>
207 template <
typename RegisterT>
211 template <
typename RegisterT>
226 template <
typename RegisterT>
233 template <
typename RegisterT>
236 template <
typename RegisterT>
239 template <
typename RegisterT>
241 if constexpr (std::is_same<RegisterT, Register>::value) {
248 template <
typename RegisterT>
251 template <
typename RegisterT>
256 template <
typename RegisterT>
258 RegisterT
reg,
bool force_spill =
false);
266 template <
typename RegisterT>
273 template <
typename Function>
285 bool AllUsedRegistersLiveAt(
BasicBlock* target);
288 template <
typename RegisterT>
constexpr void set(RegisterT reg)
constexpr bool is_empty() const
constexpr bool has(RegisterT reg) const
constexpr void clear(RegisterT reg)
MaglevGraphLabeller * graph_labeller() const
compiler::AllocatedOperand AllocateRegister(ValueNode *node, const compiler::InstructionOperand &hint=compiler::InstructionOperand())
void RemoveFromFree(RegisterT reg)
ValueNode * GetValue(RegisterT reg) const
void AddToFree(RegisterT reg)
bool UnblockedFreeIsEmpty() const
ValueNode * values_[RegisterT::kNumRegisters]
void SetValue(RegisterT reg, ValueNode *node)
void unblock(RegisterT reg)
compiler::InstructionOperand TryChooseInputRegister(ValueNode *node, const compiler::InstructionOperand &hint=compiler::InstructionOperand())
void AddToFree(RegTList list)
compiler::InstructionOperand TryChooseUnblockedInputRegister(ValueNode *node)
static constexpr bool kIsGeneralRegister
static constexpr bool kIsDoubleRegister
RegTList unblocked_free() const
static constexpr RegTList kEmptyRegList
void block(RegisterT reg)
bool is_blocked(RegisterT reg)
void SetValueWithoutBlocking(RegisterT reg, ValueNode *node)
void FreeRegistersUsedBy(ValueNode *node)
static constexpr RegTList kAllocatableRegisters
void ForEachUsedRegister(Function &&f) const
void PrintLiveRegs() const
compiler::AllocatedOperand AllocateRegisterAtEnd(ValueNode *node)
BlockConstIterator block_it_
void AssignFixedInput(Input &input)
void DropRegisterValueAtEnd(RegisterT reg, bool force_spill=false)
RegisterT PickRegisterToFree(RegListBase< RegisterT > reserved)
void SpillAndClearRegisters()
StraightForwardRegisterAllocator(MaglevCompilationInfo *compilation_info, Graph *graph, RegallocInfo *regalloc_info)
void AssignAnyInput(Input &input)
void TryAllocateToInput(Phi *phi)
void FreeRegistersUsedBy(ValueNode *node)
void DropRegisterValue(RegisterFrameState< RegisterT > ®isters, RegisterT reg, bool force_spill=false)
void ForEachMergePointRegisterState(MergePointRegisterState &merge_point_state, Function &&f)
void InitializeBranchTargetRegisterValues(ControlNode *source, BasicBlock *target)
RegisterT FreeUnblockedRegister(RegListBase< RegisterT > reserved=RegListBase< RegisterT >())
void AllocateNodeResult(ValueNode *node)
RegisterFrameState< DoubleRegister > double_registers_
void VerifyRegisterState()
compiler::AllocatedOperand AllocateRegister(ValueNode *node, const compiler::InstructionOperand &hint=compiler::InstructionOperand())
MaglevCompilationInfo * compilation_info_
std::unique_ptr< MaglevPrintingVisitor > printing_visitor_
void ComputePostDominatingHoles()
void InitializeEmptyBlockRegisterValues(ControlNode *source, BasicBlock *target)
void AllocateControlNode(ControlNode *node, BasicBlock *block)
bool IsCurrentNodeLastUseOf(ValueNode *node)
void MarkAsClobbered(ValueNode *node, const compiler::AllocatedOperand &location)
void AssignArbitraryTemporaries(RegisterFrameState< RegisterT > ®isters, NodeBase *node)
void VerifyInputs(NodeBase *node)
compiler::AllocatedOperand ForceAllocate(RegisterFrameState< RegisterT > ®isters, RegisterT reg, ValueNode *node)
RegisterFrameState< RegisterT > & GetRegisterFrameState()
RegisterFrameState< Register > general_registers_
~StraightForwardRegisterAllocator()
ZoneVector< BlockPatch > patches_
void ClearRegisterValues()
void UpdateUse(Input *input)
void HoistLoopReloads(BasicBlock *target, RegisterFrameState< RegisterT > ®isters)
void SaveRegisterSnapshot(NodeBase *node)
void InitializeBranchTargetPhis(int predecessor_id, BasicBlock *target)
void Spill(ValueNode *node)
void InitializeConditionalBranchTarget(ConditionalControlNode *source, BasicBlock *target)
void ApplyPatches(BasicBlock *block)
RegallocInfo * regalloc_info_
void AddMoveBeforeCurrentNode(ValueNode *node, compiler::InstructionOperand source, compiler::AllocatedOperand target)
void EnsureFreeRegisterAtEnd(const compiler::InstructionOperand &hint=compiler::InstructionOperand())
void AllocateNode(Node *node)
void AllocateLazyDeopt(const LazyDeoptInfo &deopt_info)
MaglevGraphLabeller * graph_labeller() const
void SetLoopPhiRegisterHint(Phi *phi, RegisterT reg)
void MergeRegisterValues(ControlNode *control, BasicBlock *target, int predecessor_id)
void AllocateSpillSlot(ValueNode *node)
void InitializeRegisterValues(MergePointRegisterState &target_state)
void AssignFixedTemporaries(RegisterFrameState< RegisterT > ®isters, NodeBase *node)
void AssignArbitraryRegisterInput(NodeBase *result_node, Input &input)
void AllocateEagerDeopt(const EagerDeoptInfo &deopt_info)
void AssignInputs(NodeBase *node)
void HoistLoopSpills(BasicBlock *target)
void AddRegister(Register reg)
RegListBase< RegisterT > registers
ZoneVector< Node * >::iterator NodeIterator
#define DCHECK_NOT_NULL(val)
#define DCHECK(condition)
#define DCHECK_EQ(v1, v2)
ZonePtrList< ValueNode > reload_hints_
ZonePtrList< ValueNode > spill_hints_
RegallocLoopInfo(Zone *zone)
absl::flat_hash_map< BasicBlock::Id, RegallocLoopInfo > loop_info_
NodeIdT freed_at_position
SpillSlotInfo(uint32_t slot_index, NodeIdT freed_at_position, bool double_slot)
std::vector< SpillSlotInfo > free_slots