1 //===- SideEffectUtils.h - Side Effect Utils --------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef MLIR_TRANSFORMS_SIDEFFECTUTILS_H 10 #define MLIR_TRANSFORMS_SIDEFFECTUTILS_H 11 12 namespace mlir { 13 14 class Operation; 15 16 /// Returns true if the given operation is side-effect free. 17 /// 18 /// An operation is side-effect free if its implementation of 19 /// `MemoryEffectOpInterface` indicates that it has no memory effects. For 20 /// example, it may implement `NoSideEffect` in ODS. Alternatively, if the 21 /// operation `HasRecursiveSideEffects`, then it is side-effect free if all of 22 /// its nested operations are side-effect free. 23 /// 24 /// If the operation has both, then it is side-effect free if both conditions 25 /// are satisfied. 26 bool isSideEffectFree(Operation *op); 27 28 } // end namespace mlir 29 30 #endif // MLIR_TRANSFORMS_SIDEFFECTUTILS_H 31