1//===- Unit.h - IR Unit definition--------------------*- 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_IR_UNIT_H
10#define MLIR_IR_UNIT_H
11
12#include "mlir/IR/OperationSupport.h"
13#include "llvm/ADT/PointerUnion.h"
14#include "llvm/Support/raw_ostream.h"
15
16namespace llvm {
17class raw_ostream;
18} // namespace llvm
19namespace mlir {
20class Operation;
21class Region;
22class Block;
23class Value;
24
25/// IRUnit is a union of the different types of IR objects that consistute the
26/// IR structure (other than Type and Attribute), that is Operation, Region, and
27/// Block.
28class IRUnit : public PointerUnion<Operation *, Region *, Block *, Value> {
29public:
30 using PointerUnion::PointerUnion;
31
32 /// Print the IRUnit to the given stream.
33 void print(raw_ostream &os,
34 OpPrintingFlags flags =
35 OpPrintingFlags().skipRegions().useLocalScope()) const;
36};
37
38raw_ostream &operator<<(raw_ostream &os, const IRUnit &unit);
39
40} // end namespace mlir
41
42namespace llvm {
43
44// Allow llvm::cast style functions.
45template <typename To>
46struct CastInfo<To, mlir::IRUnit>
47 : public CastInfo<To, mlir::IRUnit::PointerUnion> {};
48
49template <typename To>
50struct CastInfo<To, const mlir::IRUnit>
51 : public CastInfo<To, const mlir::IRUnit::PointerUnion> {};
52
53} // namespace llvm
54
55#endif // MLIR_IR_UNIT_H
56

source code of mlir/include/mlir/IR/Unit.h