1// Copyright (c) 2016 Google Inc. 2// 3// Permission is hereby granted, free of charge, to any person obtaining a 4// copy of this software and/or associated documentation files (the 5// "Materials"), to deal in the Materials without restriction, including 6// without limitation the rights to use, copy, modify, merge, publish, 7// distribute, sublicense, and/or sell copies of the Materials, and to 8// permit persons to whom the Materials are furnished to do so, subject to 9// the following conditions: 10// 11// The above copyright notice and this permission notice shall be included 12// in all copies or substantial portions of the Materials. 13// 14// MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS 15// KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS 16// SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT 17// https://www.khronos.org/registry/ 18// 19// THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25// MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. 26 27#ifndef LIBSPIRV_OPT_PASSES_H_ 28#define LIBSPIRV_OPT_PASSES_H_ 29 30#include <memory> 31 32#include "module.h" 33 34namespace spvtools { 35namespace opt { 36 37// A pass. All analysis and transformation is done via the Process() method. 38class Pass { 39 public: 40 // Returns a descriptive name for this pass. 41 virtual const char* name() const = 0; 42 // Processes the given |module| and returns true if the given |module| is 43 // modified for optimization. 44 virtual bool Process(ir::Module* module) = 0; 45}; 46 47// A null pass that does nothing. 48class NullPass : public Pass { 49 const char* name() const override { return "Null"; } 50 bool Process(ir::Module*) override { return false; } 51}; 52 53// The optimization pass for removing debug instructions (as documented in 54// Section 3.32.2 of the SPIR-V spec). 55class StripDebugInfoPass : public Pass { 56 public: 57 const char* name() const override { return "StripDebugInfo"; } 58 bool Process(ir::Module* module) override; 59}; 60 61} // namespace opt 62} // namespace spvtools 63 64#endif // LIBSPIRV_OPT_PASSES_H_ 65