diff options
author | Lei Zhang <antiagainst@google.com> | 2016-09-12 12:39:44 -0400 |
---|---|---|
committer | Lei Zhang <antiagainst@google.com> | 2016-09-20 16:40:17 -0400 |
commit | 2cbb2cce3ea1401bf8982c58d0d7dc8a8a0d4f33 (patch) | |
tree | 0255c7590a9f1ae1391da05bd8801509fa8e32b3 /source/opt/pass_manager.cpp | |
parent | 12b57779127a84ec0c9e55dcde0ff732d6fe0c30 (diff) |
Change interface of Pass::Process() to return possible failures.
Diffstat (limited to 'source/opt/pass_manager.cpp')
-rw-r--r-- | source/opt/pass_manager.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/source/opt/pass_manager.cpp b/source/opt/pass_manager.cpp new file mode 100644 index 00000000..18267db6 --- /dev/null +++ b/source/opt/pass_manager.cpp @@ -0,0 +1,35 @@ +// 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. + +#include "pass_manager.h" + +namespace spvtools { +namespace opt { + +Pass::Status PassManager::Run(ir::Module* module) { + auto status = Pass::Status::SuccessWithoutChange; + for (const auto& pass : passes_) { + const auto one_status = pass->Process(module); + if (one_status == Pass::Status::Failure) return one_status; + if (one_status == Pass::Status::SuccessWithChange) status = one_status; + } + // Set the Id bound in the header in case a pass forgot to do so. + if (status == Pass::Status::SuccessWithChange) { + module->SetIdBound(module->ComputeIdBound()); + } + return status; +} + +} // namespace opt +} // namespace spvtools |