• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//===- LoopLikeInterface.td - LoopLike interface -----------*- tablegen -*-===//
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// Defines the interface for loop-like operations.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef MLIR_INTERFACES_LOOPLIKEINTERFACE
14#define MLIR_INTERFACES_LOOPLIKEINTERFACE
15
16include "mlir/IR/OpBase.td"
17
18def LoopLikeOpInterface : OpInterface<"LoopLikeOpInterface"> {
19  let description = [{
20    Encodes properties of a loop. Operations that implement this interface will
21    be considered by loop-invariant code motion.
22  }];
23  let cppNamespace = "::mlir";
24
25  let methods = [
26    InterfaceMethod<[{
27        Returns true if the given value is defined outside of the loop.
28        A sensible implementation could be to check whether the value's defining
29        operation lies outside of the loops body region. If the loop uses
30        explicit capture of dependencies, an implementation could check whether
31        the value corresponds to a captured dependency.
32      }],
33      "bool", "isDefinedOutsideOfLoop", (ins "Value ":$value)
34    >,
35    InterfaceMethod<[{
36        Returns the region that makes up the body of the loop and should be
37        inspected for loop-invariant operations.
38      }],
39      "Region &", "getLoopBody"
40    >,
41    InterfaceMethod<[{
42        Moves the given vector of operations out of the loop. The vector is
43        sorted topologically.
44      }],
45      "LogicalResult", "moveOutOfLoop", (ins "ArrayRef<Operation *>":$ops)
46    >,
47  ];
48}
49
50#endif // MLIR_INTERFACES_LOOPLIKEINTERFACE
51