chromium/third_party/spirv-tools/src/source/opt/scalar_analysis.h

// 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 SOURCE_OPT_SCALAR_ANALYSIS_H_
#define SOURCE_OPT_SCALAR_ANALYSIS_H_

#include <algorithm>
#include <cstdint>
#include <map>
#include <memory>
#include <unordered_set>
#include <utility>
#include <vector>

#include "source/opt/basic_block.h"
#include "source/opt/instruction.h"
#include "source/opt/scalar_analysis_nodes.h"

namespace spvtools {
namespace opt {

class IRContext;
class Loop;

// Manager for the Scalar Evolution analysis. Creates and maintains a DAG of
// scalar operations generated from analysing the use def graph from incoming
// instructions. Each node is hashed as it is added so like node (for instance,
// two induction variables i=0,i++ and j=0,j++) become the same node. After
// creating a DAG with AnalyzeInstruction it can the be simplified into a more
// usable form with SimplifyExpression.
class ScalarEvolutionAnalysis {};

// Wrapping class to manipulate SENode pointer using + - * / operators.
class SExpression {};

inline SExpression SExpression::operator+(SENode* rhs) const {}

template <typename T,
          typename std::enable_if<std::is_integral<T>::value, int>::type>
inline SExpression SExpression::operator+(T integer) const {}

inline SExpression SExpression::operator+(SExpression rhs) const {}

inline SExpression SExpression::operator-() const {}

inline SExpression SExpression::operator-(SENode* rhs) const {}

template <typename T,
          typename std::enable_if<std::is_integral<T>::value, int>::type>
inline SExpression SExpression::operator-(T integer) const {}

inline SExpression SExpression::operator-(SExpression rhs) const {}

inline SExpression SExpression::operator*(SENode* rhs) const {}

template <typename T,
          typename std::enable_if<std::is_integral<T>::value, int>::type>
inline SExpression SExpression::operator*(T integer) const {}

inline SExpression SExpression::operator*(SExpression rhs) const {}

template <typename T,
          typename std::enable_if<std::is_integral<T>::value, int>::type>
inline std::pair<SExpression, int64_t> SExpression::operator/(T integer) const {}

template <typename T,
          typename std::enable_if<std::is_integral<T>::value, int>::type>
inline SExpression operator+(T lhs, SExpression rhs) {}
inline SExpression operator+(SENode* lhs, SExpression rhs) {}

template <typename T,
          typename std::enable_if<std::is_integral<T>::value, int>::type>
inline SExpression operator-(T lhs, SExpression rhs) {}
inline SExpression operator-(SENode* lhs, SExpression rhs) {}

template <typename T,
          typename std::enable_if<std::is_integral<T>::value, int>::type>
inline SExpression operator*(T lhs, SExpression rhs) {}
inline SExpression operator*(SENode* lhs, SExpression rhs) {}

template <typename T,
          typename std::enable_if<std::is_integral<T>::value, int>::type>
inline std::pair<SExpression, int64_t> operator/(T lhs, SExpression rhs) {}
inline std::pair<SExpression, int64_t> operator/(SENode* lhs, SExpression rhs) {}

}  // namespace opt
}  // namespace spvtools
#endif  // SOURCE_OPT_SCALAR_ANALYSIS_H_