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

// Copyright (c) 2018 Google 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.

// Validates correctness of extension SPIR-V instructions.
#include <cstdlib>
#include <sstream>
#include <string>
#include <vector>

#include "NonSemanticShaderDebugInfo100.h"
#include "OpenCLDebugInfo100.h"
#include "source/common_debug_info.h"
#include "source/enum_string_mapping.h"
#include "source/extensions.h"
#include "source/latest_version_glsl_std_450_header.h"
#include "source/latest_version_opencl_std_header.h"
#include "source/spirv_constant.h"
#include "source/val/instruction.h"
#include "source/val/validate.h"
#include "source/val/validation_state.h"
#include "spirv/unified1/NonSemanticClspvReflection.h"

namespace spvtools {
namespace val {
namespace {

std::string ReflectionInstructionName(ValidationState_t& _,
                                      const Instruction* inst) {}

uint32_t GetSizeTBitWidth(const ValidationState_t& _) {}

bool IsIntScalar(ValidationState_t& _, uint32_t id, bool must_len32,
                 bool must_unsigned) {}

bool IsUint32Constant(ValidationState_t& _, uint32_t id) {}

uint32_t GetUint32Constant(ValidationState_t& _, uint32_t id) {}

// Check that the operand of a debug info instruction |inst| at |word_index|
// is a result id of an instruction with |expected_opcode|.
spv_result_t ValidateOperandForDebugInfo(
    ValidationState_t& _, const std::string& operand_name,
    spv::Op expected_opcode, const Instruction* inst, uint32_t word_index,
    const std::function<std::string()>& ext_inst_name) {}

// For NonSemantic.Shader.DebugInfo.100 check that the operand of a debug info
// instruction |inst| at |word_index| is a result id of a 32-bit integer
// OpConstant instruction. For OpenCL.DebugInfo.100 the parameter is a literal
// word so cannot be validated.
spv_result_t ValidateUint32ConstantOperandForDebugInfo(
    ValidationState_t& _, const std::string& operand_name,
    const Instruction* inst, uint32_t word_index,
    const std::function<std::string()>& ext_inst_name) {}

#define CHECK_OPERAND(NAME, opcode, index)

#define CHECK_CONST_UINT_OPERAND(NAME, index)

// True if the operand of a debug info instruction |inst| at |word_index|
// satisfies |expectation| that is given as a function. Otherwise,
// returns false.
bool DoesDebugInfoOperandMatchExpectation(
    const ValidationState_t& _,
    const std::function<bool(CommonDebugInfoInstructions)>& expectation,
    const Instruction* inst, uint32_t word_index) {}

// Overload for NonSemanticShaderDebugInfo100Instructions.
bool DoesDebugInfoOperandMatchExpectation(
    const ValidationState_t& _,
    const std::function<bool(NonSemanticShaderDebugInfo100Instructions)>&
        expectation,
    const Instruction* inst, uint32_t word_index) {}

// Check that the operand of a debug info instruction |inst| at |word_index|
// is a result id of an debug info instruction whose debug instruction type
// is |expected_debug_inst|.
spv_result_t ValidateDebugInfoOperand(
    ValidationState_t& _, const std::string& debug_inst_name,
    CommonDebugInfoInstructions expected_debug_inst, const Instruction* inst,
    uint32_t word_index, const std::function<std::string()>& ext_inst_name) {}

#define CHECK_DEBUG_OPERAND(NAME, debug_opcode, index)

// Check that the operand of a debug info instruction |inst| at |word_index|
// is a result id of an debug info instruction with DebugTypeBasic.
spv_result_t ValidateOperandBaseType(
    ValidationState_t& _, const Instruction* inst, uint32_t word_index,
    const std::function<std::string()>& ext_inst_name) {}

// Check that the operand of a debug info instruction |inst| at |word_index|
// is a result id of a debug lexical scope instruction which is one of
// DebugCompilationUnit, DebugFunction, DebugLexicalBlock, or
// DebugTypeComposite.
spv_result_t ValidateOperandLexicalScope(
    ValidationState_t& _, const std::string& debug_inst_name,
    const Instruction* inst, uint32_t word_index,
    const std::function<std::string()>& ext_inst_name) {}

// Check that the operand of a debug info instruction |inst| at |word_index|
// is a result id of a debug type instruction (See DebugTypeXXX in
// "4.3. Type instructions" section of OpenCL.DebugInfo.100 spec.
spv_result_t ValidateOperandDebugType(
    ValidationState_t& _, const std::string& debug_inst_name,
    const Instruction* inst, uint32_t word_index,
    const std::function<std::string()>& ext_inst_name,
    bool allow_template_param) {}

spv_result_t ValidateClspvReflectionKernel(ValidationState_t& _,
                                           const Instruction* inst,
                                           uint32_t version) {}

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

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

spv_result_t ValidateArgInfo(ValidationState_t& _, const Instruction* inst,
                             uint32_t info_index) {}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

spv_result_t ValidateClspvReflectionInstruction(ValidationState_t& _,
                                                const Instruction* inst,
                                                uint32_t version) {}

bool IsConstIntScalarTypeWith32Or64Bits(ValidationState_t& _,
                                        Instruction* instr) {}

bool IsConstWithIntScalarType(ValidationState_t& _, const Instruction* inst,
                              uint32_t word_index) {}

bool IsDebugVariableWithIntScalarType(ValidationState_t& _,
                                      const Instruction* inst,
                                      uint32_t word_index) {}

}  // anonymous namespace

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

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

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

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

}  // namespace val
}  // namespace spvtools