//===- DeduceVersionExtensionCapabilityPass.cpp ---------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file implements a pass to deduce minimal version/extension/capability // requirements for a spirv::ModuleOp. // //===----------------------------------------------------------------------===// #include "mlir/Dialect/SPIRV/Transforms/Passes.h" #include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h" #include "mlir/Dialect/SPIRV/IR/SPIRVOps.h" #include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h" #include "mlir/Dialect/SPIRV/IR/TargetAndABI.h" #include "mlir/IR/Builders.h" #include "mlir/IR/Visitors.h" #include "llvm/ADT/SetVector.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/StringExtras.h" #include <optional> namespace mlir { namespace spirv { #define GEN_PASS_DEF_SPIRVUPDATEVCEPASS #include "mlir/Dialect/SPIRV/Transforms/Passes.h.inc" } // namespace spirv } // namespace mlir usingnamespacemlir; namespace { /// Pass to deduce minimal version/extension/capability requirements for a /// spirv::ModuleOp. class UpdateVCEPass final : public spirv::impl::SPIRVUpdateVCEPassBase<UpdateVCEPass> { … }; } // namespace /// Checks that `candidates` extension requirements are possible to be satisfied /// with the given `targetEnv` and updates `deducedExtensions` if so. Emits /// errors attaching to the given `op` on failures. /// /// `candidates` is a vector of vector for extension requirements following /// ((Extension::A OR Extension::B) AND (Extension::C OR Extension::D)) /// convention. static LogicalResult checkAndUpdateExtensionRequirements( Operation *op, const spirv::TargetEnv &targetEnv, const spirv::SPIRVType::ExtensionArrayRefVector &candidates, SetVector<spirv::Extension> &deducedExtensions) { … } /// Checks that `candidates`capability requirements are possible to be satisfied /// with the given `targetEnv` and updates `deducedCapabilities` if so. Emits /// errors attaching to the given `op` on failures. /// /// `candidates` is a vector of vector for capability requirements following /// ((Capability::A OR Capability::B) AND (Capability::C OR Capability::D)) /// convention. static LogicalResult checkAndUpdateCapabilityRequirements( Operation *op, const spirv::TargetEnv &targetEnv, const spirv::SPIRVType::CapabilityArrayRefVector &candidates, SetVector<spirv::Capability> &deducedCapabilities) { … } void UpdateVCEPass::runOnOperation() { … }