// 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. #ifndef SOURCE_TEXT_HANDLER_H_ #define SOURCE_TEXT_HANDLER_H_ #include <iomanip> #include <set> #include <sstream> #include <string> #include <type_traits> #include <unordered_map> #include <utility> #include "source/diagnostic.h" #include "source/instruction.h" #include "source/text.h" #include "spirv-tools/libspirv.h" namespace spvtools { // Structures // This is a lattice for tracking types. enum class IdTypeClass { … }; // Contains ID type information that needs to be tracked across all Ids. // Bitwidth is only valid when type_class is kScalarIntegerType or // kScalarFloatType. struct IdType { … }; // Default equality operator for IdType. Tests if all members are the same. inline bool operator==(const IdType& first, const IdType& second) { … } // Tests whether any member of the IdTypes do not match. inline bool operator!=(const IdType& first, const IdType& second) { … } // A value representing an unknown type. extern const IdType kUnknownType; // Returns true if the type is a scalar integer type. inline bool isScalarIntegral(const IdType& type) { … } // Returns true if the type is a scalar floating point type. inline bool isScalarFloating(const IdType& type) { … } // Returns the number of bits in the type. // This is only valid for bottom, scalar integer, and scalar floating // classes. For bottom, assume 32 bits. inline int assumedBitWidth(const IdType& type) { … } // A templated class with a static member function Clamp, where Clamp // sets a referenced value of type T to 0 if T is an unsigned // integer type, and returns true if it modified the referenced // value. template <typename T, typename = void> class ClampToZeroIfUnsignedType { … }; // The specialization of ClampToZeroIfUnsignedType for unsigned integer // types. ClampToZeroIfUnsignedType<T, typename std::enable_if<std::is_unsigned<T>::value>::type>; // Encapsulates the data used during the assembly of a SPIR-V module. class AssemblyContext { … }; } // namespace spvtools #endif // SOURCE_TEXT_HANDLER_H_