#include "source/opt/loop_descriptor.h"
#include <algorithm>
#include <limits>
#include <stack>
#include <utility>
#include <vector>
#include "source/opt/cfg.h"
#include "source/opt/constants.h"
#include "source/opt/dominator_tree.h"
#include "source/opt/ir_context.h"
#include "source/opt/iterator.h"
#include "source/opt/tree_iterator.h"
#include "source/util/make_unique.h"
namespace spvtools {
namespace opt {
Instruction* Loop::GetInductionStepOperation(
const Instruction* induction) const { … }
bool Loop::IsSupportedStepOp(spv::Op step) const { … }
bool Loop::IsSupportedCondition(spv::Op condition) const { … }
int64_t Loop::GetResidualConditionValue(spv::Op condition,
int64_t initial_value,
int64_t step_value,
size_t number_of_iterations,
size_t factor) { … }
Instruction* Loop::GetConditionInst() const { … }
bool Loop::GetInductionInitValue(const Instruction* induction,
int64_t* value) const { … }
Loop::Loop(IRContext* context, DominatorAnalysis* dom_analysis,
BasicBlock* header, BasicBlock* continue_target,
BasicBlock* merge_target)
: … { … }
BasicBlock* Loop::FindLoopPreheader(DominatorAnalysis* dom_analysis) { … }
bool Loop::IsInsideLoop(Instruction* inst) const { … }
bool Loop::IsBasicBlockInLoopSlow(const BasicBlock* bb) { … }
BasicBlock* Loop::GetOrCreatePreHeaderBlock() { … }
void Loop::SetContinueBlock(BasicBlock* continue_block) { … }
void Loop::SetLatchBlock(BasicBlock* latch) { … }
void Loop::SetMergeBlock(BasicBlock* merge) { … }
void Loop::SetPreHeaderBlock(BasicBlock* preheader) { … }
BasicBlock* Loop::FindLatchBlock() { … }
void Loop::GetExitBlocks(std::unordered_set<uint32_t>* exit_blocks) const { … }
void Loop::GetMergingBlocks(
std::unordered_set<uint32_t>* merging_blocks) const { … }
namespace {
inline bool IsBasicBlockSafeToClone(IRContext* context, BasicBlock* bb) { … }
}
bool Loop::IsSafeToClone() const { … }
bool Loop::IsLCSSA() const { … }
bool Loop::ShouldHoistInstruction(const Instruction& inst) const { … }
bool Loop::AreAllOperandsOutsideLoop(const Instruction& inst) const { … }
void Loop::ComputeLoopStructuredOrder(
std::vector<BasicBlock*>* ordered_loop_blocks, bool include_pre_header,
bool include_merge) const { … }
LoopDescriptor::LoopDescriptor(IRContext* context, const Function* f)
: … { … }
LoopDescriptor::~LoopDescriptor() { … }
void LoopDescriptor::PopulateList(IRContext* context, const Function* f) { … }
std::vector<Loop*> LoopDescriptor::GetLoopsInBinaryLayoutOrder() { … }
BasicBlock* Loop::FindConditionBlock() const { … }
bool Loop::FindNumberOfIterations(const Instruction* induction,
const Instruction* branch_inst,
size_t* iterations_out,
int64_t* step_value_out,
int64_t* init_value_out) const { … }
int64_t Loop::GetIterations(spv::Op condition, int64_t condition_value,
int64_t init_value, int64_t step_value) const { … }
void Loop::GetInductionVariables(
std::vector<Instruction*>& induction_variables) const { … }
Instruction* Loop::FindConditionVariable(
const BasicBlock* condition_block) const { … }
bool LoopDescriptor::CreatePreHeaderBlocksIfMissing() { … }
void LoopDescriptor::PostModificationCleanup() { … }
void LoopDescriptor::ClearLoops() { … }
Loop* LoopDescriptor::AddLoopNest(std::unique_ptr<Loop> new_loop) { … }
void LoopDescriptor::RemoveLoop(Loop* loop) { … }
}
}