1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include "spirv_opt_extensions.h" 17 18 #include "source/util/make_unique.h" 19 #include "spirv_opt_strip_extensions.h" 20 21 namespace spvtools { 22 23 // This is a private implementation from glslang declared in optimizer.cpp reimplementation here 24 // allows us to register our own modified optimisation passes. 25 struct Optimizer::PassToken::Impl { Implspvtools::Optimizer::PassToken::Impl26 explicit Impl(std::unique_ptr<opt::Pass> p) : pass(std::move(p)) {} 27 std::unique_ptr<opt::Pass> pass; // Internal implementation pass. 28 }; 29 30 } // namespace spvtools 31 RegisterStripPreprocessorDebugInfoPass(std::optional<spvtools::Optimizer> & optimizer)32void RegisterStripPreprocessorDebugInfoPass(std::optional<spvtools::Optimizer>& optimizer) 33 { 34 optimizer->RegisterPass(spvtools::MakeUnique<spvtools::Optimizer::PassToken::Impl>( 35 spvtools::MakeUnique<spvtools::opt::StripPreprocessorDebugInfoPass>())); 36 }