diff --git a/source/binary.cpp b/source/binary.cpp index c8b7c38c2..689937f02 100644 --- a/source/binary.cpp +++ b/source/binary.cpp @@ -20,13 +20,14 @@ #include #include #include +#include #include "assembly_grammar.h" #include "diagnostic.h" #include "ext_inst.h" #include "opcode.h" #include "operand.h" -#include "spirv-tools/libspirv.h" +#include "spirv/1.1/spirv.h" #include "spirv_constant.h" #include "spirv_endian.h" diff --git a/source/binary.h b/source/binary.h index dd48258fa..375e0105b 100644 --- a/source/binary.h +++ b/source/binary.h @@ -16,7 +16,6 @@ #define LIBSPIRV_BINARY_H_ #include "spirv-tools/libspirv.h" -#include "spirv/1.1/spirv.h" #include "spirv_definition.h" // Functions diff --git a/source/diagnostic.h b/source/diagnostic.h index 72d537aed..78f9a5b65 100644 --- a/source/diagnostic.h +++ b/source/diagnostic.h @@ -16,7 +16,7 @@ #define LIBSPIRV_DIAGNOSTIC_H_ #include -#include +#include #include "spirv-tools/libspirv.hpp" diff --git a/source/libspirv.cpp b/source/libspirv.cpp index 9afb9cb1d..02e87ea5e 100644 --- a/source/libspirv.cpp +++ b/source/libspirv.cpp @@ -14,7 +14,6 @@ #include "spirv-tools/libspirv.hpp" -#include "message.h" #include "table.h" namespace spvtools { diff --git a/source/message.h b/source/message.h index 1489090b8..60f5d5632 100644 --- a/source/message.h +++ b/source/message.h @@ -17,7 +17,7 @@ #include -#include "spirv-tools/libspirv.hpp" +#include "spirv-tools/libspirv.h" namespace spvtools { diff --git a/source/opt/build_module.h b/source/opt/build_module.h index 1dc2c11ab..d396a3a9e 100644 --- a/source/opt/build_module.h +++ b/source/opt/build_module.h @@ -17,7 +17,6 @@ #include #include -#include #include "module.h" #include "spirv-tools/libspirv.hpp" diff --git a/source/opt/constants.h b/source/opt/constants.h index 24574fc92..d6199e8f4 100644 --- a/source/opt/constants.h +++ b/source/opt/constants.h @@ -15,8 +15,8 @@ #ifndef LIBSPIRV_OPT_CONSTANTS_H_ #define LIBSPIRV_OPT_CONSTANTS_H_ -#include #include +#include #include #include "make_unique.h" diff --git a/source/opt/def_use_manager.cpp b/source/opt/def_use_manager.cpp index 19178ebfa..2d0e79a57 100644 --- a/source/opt/def_use_manager.cpp +++ b/source/opt/def_use_manager.cpp @@ -14,11 +14,7 @@ #include "def_use_manager.h" -#include - -#include "instruction.h" #include "log.h" -#include "module.h" #include "reflect.h" namespace spvtools { diff --git a/source/opt/def_use_manager.h b/source/opt/def_use_manager.h index 41c405a5f..cd779d533 100644 --- a/source/opt/def_use_manager.h +++ b/source/opt/def_use_manager.h @@ -17,12 +17,11 @@ #include #include -#include #include #include "instruction.h" -#include "message.h" #include "module.h" +#include "spirv-tools/libspirv.hpp" namespace spvtools { namespace opt { diff --git a/source/opt/fold_spec_constant_op_and_composite_pass.cpp b/source/opt/fold_spec_constant_op_and_composite_pass.cpp index 0170dcb0d..84248146a 100644 --- a/source/opt/fold_spec_constant_op_and_composite_pass.cpp +++ b/source/opt/fold_spec_constant_op_and_composite_pass.cpp @@ -14,10 +14,9 @@ #include "fold_spec_constant_op_and_composite_pass.h" +#include #include -#include #include -#include #include "constants.h" #include "make_unique.h" @@ -249,6 +248,20 @@ FoldSpecConstantOpAndCompositePass::FoldSpecConstantOpAndCompositePass() type_mgr_(nullptr), id_to_const_val_() {} +Pass::Status FoldSpecConstantOpAndCompositePass::Process(ir::Module* module) { + Initialize(module); + return ProcessImpl(module); +} + +void FoldSpecConstantOpAndCompositePass::Initialize(ir::Module* module) { + type_mgr_.reset(new analysis::TypeManager(consumer(), *module)); + def_use_mgr_.reset(new analysis::DefUseManager(consumer(), module)); + for (const auto& id_def : def_use_mgr_->id_to_defs()) { + max_id_ = std::max(max_id_, id_def.first); + } + module_ = module; +}; + Pass::Status FoldSpecConstantOpAndCompositePass::ProcessImpl( ir::Module* module) { bool modified = false; diff --git a/source/opt/fold_spec_constant_op_and_composite_pass.h b/source/opt/fold_spec_constant_op_and_composite_pass.h index 8bca3e559..6e2eea109 100644 --- a/source/opt/fold_spec_constant_op_and_composite_pass.h +++ b/source/opt/fold_spec_constant_op_and_composite_pass.h @@ -15,7 +15,6 @@ #ifndef LIBSPIRV_OPT_FOLD_SPEC_CONSTANT_OP_AND_COMPOSITE_PASS_H_ #define LIBSPIRV_OPT_FOLD_SPEC_CONSTANT_OP_AND_COMPOSITE_PASS_H_ -#include #include #include #include @@ -35,22 +34,13 @@ class FoldSpecConstantOpAndCompositePass : public Pass { FoldSpecConstantOpAndCompositePass(); const char* name() const override { return "fold-spec-const-op-composite"; } - Status Process(ir::Module* module) override { - Initialize(module); - return ProcessImpl(module); - }; + + Status Process(ir::Module* module) override; private: // Initializes the type manager, def-use manager and get the maximal id used // in the module. - void Initialize(ir::Module* module) { - type_mgr_.reset(new analysis::TypeManager(consumer(), *module)); - def_use_mgr_.reset(new analysis::DefUseManager(consumer(), module)); - for (const auto& id_def : def_use_mgr_->id_to_defs()) { - max_id_ = std::max(max_id_, id_def.first); - } - module_ = module; - }; + void Initialize(ir::Module* module); // The real entry of processing. Iterates through the types-constants-globals // section of the given module, finds the Spec Constants defined with diff --git a/source/opt/instruction.cpp b/source/opt/instruction.cpp index 40e2951aa..bccac1211 100644 --- a/source/opt/instruction.cpp +++ b/source/opt/instruction.cpp @@ -14,7 +14,6 @@ #include "instruction.h" -#include #include #include "reflect.h" diff --git a/source/opt/ir_loader.h b/source/opt/ir_loader.h index c5c735996..bcb55f1e3 100644 --- a/source/opt/ir_loader.h +++ b/source/opt/ir_loader.h @@ -19,9 +19,8 @@ #include "basic_block.h" #include "instruction.h" -#include "message.h" #include "module.h" -#include "spirv-tools/libspirv.h" +#include "spirv-tools/libspirv.hpp" namespace spvtools { namespace ir { diff --git a/source/opt/iterator.h b/source/opt/iterator.h index ba25feae1..0430638ca 100644 --- a/source/opt/iterator.h +++ b/source/opt/iterator.h @@ -15,6 +15,7 @@ #ifndef LIBSPIRV_OPT_ITERATOR_H_ #define LIBSPIRV_OPT_ITERATOR_H_ +#include // for ptrdiff_t #include #include #include @@ -29,10 +30,9 @@ namespace ir { // std::vector<|ValueType|>. template class UptrVectorIterator - : public std::iterator< - std::random_access_iterator_tag, - typename std::conditional::type, - ptrdiff_t> { + : public std::iterator::type> { public: using super = std::iterator< std::random_access_iterator_tag, diff --git a/source/opt/log.h b/source/opt/log.h index 0d5ce4b9a..717a3625a 100644 --- a/source/opt/log.h +++ b/source/opt/log.h @@ -20,7 +20,7 @@ #include #include -#include "message.h" +#include "spirv-tools/libspirv.hpp" // Asserts the given condition is true. Otherwise, sends a message to the // consumer and exits the problem with failure code. Accepts the following diff --git a/source/opt/pass.h b/source/opt/pass.h index 7449bc11e..6e5df74d4 100644 --- a/source/opt/pass.h +++ b/source/opt/pass.h @@ -15,10 +15,10 @@ #ifndef LIBSPIRV_OPT_PASS_H_ #define LIBSPIRV_OPT_PASS_H_ -#include +#include -#include "message.h" #include "module.h" +#include "spirv-tools/libspirv.hpp" namespace spvtools { namespace opt { diff --git a/source/opt/pass_manager.h b/source/opt/pass_manager.h index e1bdc7aaf..0bf29f7ae 100644 --- a/source/opt/pass_manager.h +++ b/source/opt/pass_manager.h @@ -19,10 +19,11 @@ #include #include "log.h" -#include "message.h" #include "module.h" #include "pass.h" +#include "spirv-tools/libspirv.hpp" + namespace spvtools { namespace opt { diff --git a/source/opt/set_spec_constant_default_value_pass.cpp b/source/opt/set_spec_constant_default_value_pass.cpp index 2e9f36fe7..d49e2f156 100644 --- a/source/opt/set_spec_constant_default_value_pass.cpp +++ b/source/opt/set_spec_constant_default_value_pass.cpp @@ -16,18 +16,15 @@ #include #include -#include #include -#include #include -#include "spirv-tools/libspirv.h" -#include "util/parse_number.h" - #include "def_use_manager.h" #include "make_unique.h" +#include "spirv-tools/libspirv.h" #include "type_manager.h" #include "types.h" +#include "util/parse_number.h" namespace spvtools { namespace opt { diff --git a/source/opt/type_manager.cpp b/source/opt/type_manager.cpp index ce4b6764b..ed8a13c78 100644 --- a/source/opt/type_manager.cpp +++ b/source/opt/type_manager.cpp @@ -12,11 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include +#include "type_manager.h" + +#include #include "log.h" #include "reflect.h" -#include "type_manager.h" namespace spvtools { namespace opt { diff --git a/source/opt/type_manager.h b/source/opt/type_manager.h index 48fa21223..fa04d8082 100644 --- a/source/opt/type_manager.h +++ b/source/opt/type_manager.h @@ -18,9 +18,10 @@ #include #include #include +#include -#include "message.h" #include "module.h" +#include "spirv-tools/libspirv.hpp" #include "types.h" namespace spvtools { diff --git a/source/table.cpp b/source/table.cpp index 24ab52056..8f8580245 100644 --- a/source/table.cpp +++ b/source/table.cpp @@ -14,7 +14,7 @@ #include "table.h" -#include +#include spv_context spvContextCreate(spv_target_env env) { switch (env) { diff --git a/source/table.h b/source/table.h index 6b8631345..4b2158705 100644 --- a/source/table.h +++ b/source/table.h @@ -19,7 +19,7 @@ #include "enum_set.h" #include "message.h" -#include "spirv-tools/libspirv.h" +#include "spirv-tools/libspirv.hpp" namespace libspirv {