SPIRV-Tools/source/opt/simplification_pass.h
Steven Perron 06cdb96984 Make use of the instruction folder.
Implementation of the simplification pass.

- Create pass that calls the instruction folder on each instruction and
  propagate instructions that fold to a copy.  This will do copy
  propagation as well.

- Did not use the propagator engine because I want to modify the instruction
  as we go along.

- Change folding to not allocate new instructions, but make changes in
  place.  This change had a big impact on compile time.

- Add simplification pass to the legalization passes in place of
  insert-extract elimination.

- Added test cases for new folding rules.

- Added tests for the simplification pass

- Added a method to the CFG to apply a function to the basic blocks in
  reverse post order.

Contributes to #1164.
2018-02-07 23:01:47 -05:00

42 lines
1.3 KiB
C++

// Copyright (c) 2018 Google LLC
//
// 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.
#ifndef LIBSPIRV_OPT_SIMPLIFICATION_PASS_H_
#define LIBSPIRV_OPT_SIMPLIFICATION_PASS_H_
#include "function.h"
#include "ir_context.h"
#include "pass.h"
namespace spvtools {
namespace opt {
// See optimizer.hpp for documentation.
class SimplificationPass : public Pass {
public:
const char* name() const override { return "simplify-instructions"; }
Status Process(ir::IRContext*) override;
private:
// Returns true if the module was changed. The simplifier is called on every
// instruction in |function| until nothing else in the function can be
// simplified.
bool SimplifyFunction(ir::Function* function);
};
} // namespace opt
} // namespace spvtools
#endif // LIBSPIRV_OPT_SIMPLIFICATION_PASS_H_