5#ifndef V8_TORQUE_CFG_H_
6#define V8_TORQUE_CFG_H_
11#include <unordered_map>
21class ControlFlowGraph;
43 instruction.TypeInstruction(¤t_stack,
cfg_);
52 size_t id()
const {
return id_; }
59 if (worklist) worklist->
Enqueue(
this);
67 auto& input = input_definitions.
Peek(
i);
68 if (current == input)
continue;
74 if (changed && worklist) worklist->
Enqueue(
this);
109 template <
typename UnaryPredicate>
112 std::forward<UnaryPredicate>(predicate));
116 std::optional<Block*>
end()
const {
return end_; }
124 std::stringstream message;
125 message <<
"expected return type ";
127 message <<
" instead of ";
163 bool is_deferred =
false) {
164 return cfg_.
NewBlock(std::move(input_types), is_deferred);
171 return (cfg_.end() && *cfg_.end() == block) || block->IsComplete();
201 std::optional<const Type*> type);
202 void Print(std::string s);
221 :
assembler_(assembler), saved_block_(block) {
222 saved_stack_ = block->InputTypes();
223 DCHECK(!assembler->CurrentBlockIsComplete());
224 std::swap(saved_block_, assembler->current_block_);
225 std::swap(saved_stack_, assembler->current_stack_);
226 assembler->cfg_.PlaceBlock(block);
231 std::swap(saved_block_,
assembler_->current_block_);
232 std::swap(saved_stack_,
assembler_->current_stack_);
const std::vector< Instruction > & instructions() const
std::optional< Stack< DefinitionLocation > > input_definitions_
const Stack< const Type * > & InputTypes() const
void MergeInputDefinitions(const Stack< DefinitionLocation > &input_definitions, Worklist< Block * > *worklist)
std::vector< Instruction > & instructions()
bool HasInputDefinitions() const
bool HasInputTypes() const
Block(ControlFlowGraph *cfg, size_t id, std::optional< Stack< const Type * > > input_types, bool is_deferred)
void Add(Instruction instruction)
std::optional< Stack< const Type * > > input_types_
const Stack< DefinitionLocation > & InputDefinitions() const
void SetInputTypes(const Stack< const Type * > &input_types)
std::vector< Instruction > instructions_
Stack< const Type * > saved_stack_
CfgAssemblerScopedTemporaryBlock(CfgAssembler *assembler, Block *block)
~CfgAssemblerScopedTemporaryBlock()
CfgAssembler * assembler_
StackRange Peek(StackRange range, std::optional< const Type * > type)
StackRange TopRange(size_t slot_count) const
void AssertionFailure(std::string message)
Stack< const Type * > current_stack_
const Stack< const Type * > & CurrentStack() const
void Branch(Block *if_true, Block *if_false)
void DropTo(BottomOffset new_level)
void ComputeInputDefinitions()
void PrintCurrentStack(std::ostream &s)
bool CfgIsComplete() const
void Poke(StackRange destination, StackRange origin, std::optional< const Type * > type)
bool CurrentBlockIsComplete() const
Block * NewBlock(std::optional< Stack< const Type * > > input_types=std::nullopt, bool is_deferred=false)
void Print(std::string s)
void Emit(Instruction instruction)
const ControlFlowGraph & Result()
void DeleteRange(StackRange range)
CfgAssembler(Stack< const Type * > input_types)
std::vector< Block * > placed_blocks_
std::list< Block > blocks_
std::optional< TypeVector > return_type_
std::size_t ParameterCount() const
Block * NewBlock(std::optional< Stack< const Type * > > input_types, bool is_deferred)
size_t NumberOfBlockIds() const
ControlFlowGraph(Stack< const Type * > input_types)
std::optional< Block * > end_
void UnplaceBlockIf(UnaryPredicate &&predicate)
void SetReturnType(TypeVector t)
void PlaceBlock(Block *block)
const std::vector< Block * > & blocks() const
std::optional< Block * > end() const
static DefinitionLocation Phi(const Block *block, std::size_t index)
BottomOffset AboveTop() const
const T & Peek(BottomOffset from_bottom) const
BytecodeAssembler & assembler_
InstructionOperand destination
void ReportError(Args &&... args)
std::vector< const Type * > TypeVector
void PrintCommaSeparatedList(std::ostream &os, const T &list, C &&transform)
#define DCHECK(condition)
#define DCHECK_EQ(v1, v2)