// Copyright (c) 2016 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. #ifndef SOURCE_OPT_DEF_USE_MANAGER_H_ #define SOURCE_OPT_DEF_USE_MANAGER_H_ #include <set> #include <unordered_map> #include <vector> #include "source/opt/instruction.h" #include "source/opt/module.h" #include "spirv-tools/libspirv.hpp" namespace spvtools { namespace opt { namespace analysis { // Definition should never be null. User can be null, however, such an entry // should be used only for searching (e.g. all users of a particular definition) // and never stored in a container. struct UserEntry { … }; inline bool operator==(const UserEntry& lhs, const UserEntry& rhs) { … } // Orders UserEntry for use in associative containers (i.e. less than ordering). // // The definition of an UserEntry is treated as the major key and the users as // the minor key so that all the users of a particular definition are // consecutive in a container. // // A null user always compares less than a real user. This is done to provide // easy values to search for the beginning of the users of a particular // definition (i.e. using {def, nullptr}). struct UserEntryLess { … }; // A class for analyzing and managing defs and uses in an Module. class DefUseManager { … }; } // namespace analysis } // namespace opt } // namespace spvtools #endif // SOURCE_OPT_DEF_USE_MANAGER_H_