// 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_CONSTANTS_H_ #define SOURCE_OPT_CONSTANTS_H_ #include <cinttypes> #include <map> #include <memory> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> #include "source/opt/module.h" #include "source/opt/type_manager.h" #include "source/opt/types.h" #include "source/util/hex_float.h" #include "source/util/make_unique.h" namespace spvtools { namespace opt { class IRContext; namespace analysis { // Class hierarchy to represent the normal constants defined through // OpConstantTrue, OpConstantFalse, OpConstant, OpConstantNull and // OpConstantComposite instructions. // TODO(qining): Add class for constants defined with OpConstantSampler. class Constant; class ScalarConstant; class IntConstant; class FloatConstant; class BoolConstant; class CompositeConstant; class StructConstant; class VectorConstant; class MatrixConstant; class ArrayConstant; class NullConstant; class ConstantManager; // Abstract class for a SPIR-V constant. It has a bunch of As<subclass> methods, // which is used as a way to probe the actual <subclass> class Constant { … }; // Abstract class for scalar type constants. class ScalarConstant : public Constant { … }; // Integer type constant. class IntConstant : public ScalarConstant { … }; // Float type constant. class FloatConstant : public ScalarConstant { … }; // Bool type constant. class BoolConstant : public ScalarConstant { … }; // Abstract class for composite constants. class CompositeConstant : public Constant { … }; // Struct type constant. class StructConstant : public CompositeConstant { … }; // Vector type constant. class VectorConstant : public CompositeConstant { … }; // Matrix type constant. class MatrixConstant : public CompositeConstant { … }; // Array type constant. class ArrayConstant : public CompositeConstant { … }; // Null type constant. class NullConstant : public Constant { … }; // Hash function for Constant instances. Use the structure of the constant as // the key. struct ConstantHash { … }; // Equality comparison structure for two constants. struct ConstantEqual { … }; // This class represents a pool of constants. class ConstantManager { … }; } // namespace analysis } // namespace opt } // namespace spvtools #endif // SOURCE_OPT_CONSTANTS_H_