MLIR: lib/IR/Unit.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
13#include "llvm/Support/raw_ostream.h"
14#include
15
16using namespace mlir;
17
20 if (!op) {
21 os << "Operation:nullptr";
22 return;
23 }
24 op->print(os, flags);
25}
26
29 if (!region) {
30 os << "Region:nullptr";
31 return;
32 }
33 os << "Region #" << region->getRegionNumber() << " for op ";
35}
36
41 int blockId = std::distance(entry->getIterator(), block->getIterator());
42 os << "Block #" << blockId << " for ";
45 if (!shouldSkipRegions)
47}
48
50 if (auto *op = llvm::dyn_cast_if_present<Operation *>(*this))
51 return printOp(os, op, flags);
52 if (auto *region = llvm::dyn_cast_if_present<Region *>(*this))
54 if (auto *block = llvm::dyn_cast_if_present<Block *>(*this))
56 llvm_unreachable("unknown IRUnit");
57}
58
61 return os;
62}
static void printOp(llvm::raw_ostream &os, Operation *op, OpPrintingFlags &flags)
Definition Unit.cpp:18
static void printRegion(llvm::raw_ostream &os, Region *region, OpPrintingFlags &flags)
Definition Unit.cpp:27
static void printBlock(llvm::raw_ostream &os, Block *block, OpPrintingFlags &flags)
Definition Unit.cpp:37
Block represents an ordered list of Operations.
Region * getParent() const
Provide a 'getParent' method for ilist_node_with_parent methods.
void print(raw_ostream &os)
IRUnit is a union of the different types of IR objects that constitute the IR structure (other than T...
void print(raw_ostream &os, OpPrintingFlags flags=OpPrintingFlags().skipRegions().useLocalScope()) const
Print the IRUnit to the given stream.
Definition Unit.cpp:49
Set of flags used to control the behavior of the various IR print methods (e.g.
bool shouldSkipRegions() const
Return if regions should be skipped.
OpPrintingFlags & skipRegions(bool skip=true)
Skip printing regions.
Operation is the basic unit of execution within MLIR.
void print(raw_ostream &os, const OpPrintingFlags &flags={})
This class contains a list of basic blocks and a link to the parent operation it is attached to.
unsigned getRegionNumber()
Return the number of this region in the parent operation.
Operation * getParentOp()
Return the parent operation this region is attached to.
Include the generated interface declarations.
raw_ostream & operator<<(raw_ostream &os, const AliasResult &result)