chromium/third_party/spirv-tools/src/source/val/validate_cfg.cpp

// Copyright (c) 2015-2016 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include <cassert>
#include <functional>
#include <iostream>
#include <map>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#include "source/cfa.h"
#include "source/opcode.h"
#include "source/spirv_constant.h"
#include "source/spirv_validator_options.h"
#include "source/val/basic_block.h"
#include "source/val/construct.h"
#include "source/val/function.h"
#include "source/val/validate.h"
#include "source/val/validation_state.h"

namespace spvtools {
namespace val {
namespace {

spv_result_t ValidatePhi(ValidationState_t& _, const Instruction* inst) {}

spv_result_t ValidateBranch(ValidationState_t& _, const Instruction* inst) {}

spv_result_t ValidateBranchConditional(ValidationState_t& _,
                                       const Instruction* inst) {}

spv_result_t ValidateSwitch(ValidationState_t& _, const Instruction* inst) {}

spv_result_t ValidateReturnValue(ValidationState_t& _,
                                 const Instruction* inst) {}

uint32_t operator>>(const spv::LoopControlShift& lhs,
                    const spv::LoopControlShift& rhs) {}

spv_result_t ValidateLoopMerge(ValidationState_t& _, const Instruction* inst) {}

}  // namespace

void printDominatorList(const BasicBlock& b) {}

#define CFG_ASSERT(ASSERT_FUNC, TARGET)

spv_result_t FirstBlockAssert(ValidationState_t& _, uint32_t target) {}

spv_result_t MergeBlockAssert(ValidationState_t& _, uint32_t merge_block) {}

/// Update the continue construct's exit blocks once the backedge blocks are
/// identified in the CFG.
void UpdateContinueConstructExitBlocks(
    Function& function,
    const std::vector<std::pair<uint32_t, uint32_t>>& back_edges) {}

std::tuple<std::string, std::string, std::string> ConstructNames(
    ConstructType type) {}

/// Constructs an error message for construct validation errors
std::string ConstructErrorString(const Construct& construct,
                                 const std::string& header_string,
                                 const std::string& exit_string,
                                 const std::string& dominate_text) {}

// Finds the fall through case construct of |target_block| and records it in
// |case_fall_through|. Returns SPV_ERROR_INVALID_CFG if the case construct
// headed by |target_block| branches to multiple case constructs.
spv_result_t FindCaseFallThrough(
    ValidationState_t& _, BasicBlock* target_block, uint32_t* case_fall_through,
    const BasicBlock* merge, const std::unordered_set<uint32_t>& case_targets,
    Function* function) {}

spv_result_t StructuredSwitchChecks(ValidationState_t& _, Function* function,
                                    const Instruction* switch_inst,
                                    const BasicBlock* header,
                                    const BasicBlock* merge) {}

// Validates that all CFG divergences (i.e. conditional branch or switch) are
// structured correctly. Either divergence is preceded by a merge instruction
// or the divergence introduces at most one unseen label.
spv_result_t ValidateStructuredSelections(
    ValidationState_t& _, const std::vector<const BasicBlock*>& postorder) {}

spv_result_t StructuredControlFlowChecks(
    ValidationState_t& _, Function* function,
    const std::vector<std::pair<uint32_t, uint32_t>>& back_edges,
    const std::vector<const BasicBlock*>& postorder) {}

spv_result_t MaximalReconvergenceChecks(ValidationState_t& _) {}

spv_result_t PerformCfgChecks(ValidationState_t& _) {}

spv_result_t CfgPass(ValidationState_t& _, const Instruction* inst) {}

void ReachabilityPass(ValidationState_t& _) {}

spv_result_t ControlFlowPass(ValidationState_t& _, const Instruction* inst) {}

}  // namespace val
}  // namespace spvtools