Clean up header dependency.
authorLei Zhang <antiagainst@google.com>
Wed, 21 Sep 2016 21:16:31 +0000 (17:16 -0400)
committerLei Zhang <antiagainst@google.com>
Thu, 22 Sep 2016 22:15:23 +0000 (18:15 -0400)
22 files changed:
source/binary.cpp
source/binary.h
source/diagnostic.h
source/libspirv.cpp
source/message.h
source/opt/build_module.h
source/opt/constants.h
source/opt/def_use_manager.cpp
source/opt/def_use_manager.h
source/opt/fold_spec_constant_op_and_composite_pass.cpp
source/opt/fold_spec_constant_op_and_composite_pass.h
source/opt/instruction.cpp
source/opt/ir_loader.h
source/opt/iterator.h
source/opt/log.h
source/opt/pass.h
source/opt/pass_manager.h
source/opt/set_spec_constant_default_value_pass.cpp
source/opt/type_manager.cpp
source/opt/type_manager.h
source/table.cpp
source/table.h

index c8b7c38..689937f 100644 (file)
 #include <iterator>
 #include <limits>
 #include <unordered_map>
+#include <vector>
 
 #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"
 
index dd48258..375e010 100644 (file)
@@ -16,7 +16,6 @@
 #define LIBSPIRV_BINARY_H_
 
 #include "spirv-tools/libspirv.h"
-#include "spirv/1.1/spirv.h"
 #include "spirv_definition.h"
 
 // Functions
index 72d537a..78f9a5b 100644 (file)
@@ -16,7 +16,7 @@
 #define LIBSPIRV_DIAGNOSTIC_H_
 
 #include <sstream>
-#include <utility>
+#include <string>
 
 #include "spirv-tools/libspirv.hpp"
 
index 9afb9cb..02e87ea 100644 (file)
@@ -14,7 +14,6 @@
 
 #include "spirv-tools/libspirv.hpp"
 
-#include "message.h"
 #include "table.h"
 
 namespace spvtools {
index 1489090..60f5d56 100644 (file)
@@ -17,7 +17,7 @@
 
 #include <string>
 
-#include "spirv-tools/libspirv.hpp"
+#include "spirv-tools/libspirv.h"
 
 namespace spvtools {
 
index 1dc2c11..d396a3a 100644 (file)
@@ -17,7 +17,6 @@
 
 #include <memory>
 #include <string>
-#include <vector>
 
 #include "module.h"
 #include "spirv-tools/libspirv.hpp"
index 24574fc..d6199e8 100644 (file)
@@ -15,8 +15,8 @@
 #ifndef LIBSPIRV_OPT_CONSTANTS_H_
 #define LIBSPIRV_OPT_CONSTANTS_H_
 
-#include <cassert>
 #include <memory>
+#include <utility>
 #include <vector>
 
 #include "make_unique.h"
index 19178eb..2d0e79a 100644 (file)
 
 #include "def_use_manager.h"
 
-#include <functional>
-
-#include "instruction.h"
 #include "log.h"
-#include "module.h"
 #include "reflect.h"
 
 namespace spvtools {
index 41c405a..cd779d5 100644 (file)
 
 #include <list>
 #include <unordered_map>
-#include <utility>
 #include <vector>
 
 #include "instruction.h"
-#include "message.h"
 #include "module.h"
+#include "spirv-tools/libspirv.hpp"
 
 namespace spvtools {
 namespace opt {
index 0170dcb..8424814 100644 (file)
 
 #include "fold_spec_constant_op_and_composite_pass.h"
 
+#include <algorithm>
 #include <initializer_list>
-#include <memory>
 #include <tuple>
-#include <unordered_map>
 
 #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;
index 8bca3e5..6e2eea1 100644 (file)
@@ -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 <algorithm>
 #include <memory>
 #include <unordered_map>
 #include <vector>
@@ -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
index 40e2951..bccac12 100644 (file)
@@ -14,7 +14,6 @@
 
 #include "instruction.h"
 
-#include <cassert>
 #include <initializer_list>
 
 #include "reflect.h"
index c5c7359..bcb55f1 100644 (file)
@@ -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 {
index ba25fea..0430638 100644 (file)
@@ -15,6 +15,7 @@
 #ifndef LIBSPIRV_OPT_ITERATOR_H_
 #define LIBSPIRV_OPT_ITERATOR_H_
 
+#include <cstddef>  // for ptrdiff_t
 #include <iterator>
 #include <memory>
 #include <type_traits>
@@ -29,10 +30,9 @@ namespace ir {
 // std::vector<|ValueType|>.
 template <typename ValueType, bool IsConst = false>
 class UptrVectorIterator
-    : public std::iterator<
-          std::random_access_iterator_tag,
-          typename std::conditional<IsConst, const ValueType, ValueType>::type,
-          ptrdiff_t> {
+    : public std::iterator<std::random_access_iterator_tag,
+                           typename std::conditional<IsConst, const ValueType,
+                                                     ValueType>::type> {
  public:
   using super = std::iterator<
       std::random_access_iterator_tag,
index 0d5ce4b..717a362 100644 (file)
@@ -20,7 +20,7 @@
 #include <utility>
 #include <vector>
 
-#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
index 7449bc1..6e5df74 100644 (file)
 #ifndef LIBSPIRV_OPT_PASS_H_
 #define LIBSPIRV_OPT_PASS_H_
 
-#include <memory>
+#include <utility>
 
-#include "message.h"
 #include "module.h"
+#include "spirv-tools/libspirv.hpp"
 
 namespace spvtools {
 namespace opt {
index e1bdc7a..0bf29f7 100644 (file)
 #include <vector>
 
 #include "log.h"
-#include "message.h"
 #include "module.h"
 #include "pass.h"
 
+#include "spirv-tools/libspirv.hpp"
+
 namespace spvtools {
 namespace opt {
 
index 2e9f36f..d49e2f1 100644 (file)
 
 #include <cctype>
 #include <cstring>
-#include <string>
 #include <tuple>
-#include <unordered_map>
 #include <vector>
 
-#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 {
index ce4b676..ed8a13c 100644 (file)
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-#include <algorithm>
+#include "type_manager.h"
+
+#include <utility>
 
 #include "log.h"
 #include "reflect.h"
-#include "type_manager.h"
 
 namespace spvtools {
 namespace opt {
index 48fa212..fa04d80 100644 (file)
 #include <memory>
 #include <unordered_map>
 #include <unordered_set>
+#include <vector>
 
-#include "message.h"
 #include "module.h"
+#include "spirv-tools/libspirv.hpp"
 #include "types.h"
 
 namespace spvtools {
index 24ab520..8f85802 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "table.h"
 
-#include <cstdlib>
+#include <utility>
 
 spv_context spvContextCreate(spv_target_env env) {
   switch (env) {
index 6b86313..4b21587 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "enum_set.h"
 #include "message.h"
-#include "spirv-tools/libspirv.h"
+#include "spirv-tools/libspirv.hpp"
 
 namespace libspirv {