MLIR: include/mlir/IR/BlockSupport.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13 #ifndef MLIR_IR_BLOCKSUPPORT_H

14 #define MLIR_IR_BLOCKSUPPORT_H

15

17 #include "llvm/ADT/PointerUnion.h"

18 #include "llvm/ADT/ilist.h"

19 #include "llvm/ADT/ilist_node.h"

20

21 namespace mlir {

23

24

25

26

27

28

29

31 public:

33

34

36

37

39 };

40

41

42

43

44

45

46

47

48

50 : public llvm::mapped_iterator<ValueUseIterator,

51 Block *(*)(BlockOperand &)> {

53

54 public:

55

61

62

64 };

65

66

67

68

69

70

73 SuccessorRange, BlockOperand *, Block *, Block *, Block *> {

74 public:

75 using RangeBaseT::RangeBaseT;

79

80 private:

81

83 return object + index;

84 }

85

86 static Block *dereference_iterator(BlockOperand *object, ptrdiff_t index) {

87 return object[index].get();

88 }

89

90

91 friend RangeBaseT;

92 };

93

94

95

96

97

98

99

100

101

102

105 BlockRange, llvm::PointerUnion<BlockOperand *, Block *const *>,

106 Block *, Block *, Block *> {

107 public:

108 using RangeBaseT::RangeBaseT;

111 template <typename Arg, typename = std::enable_if_t<std::is_constructible<

115 BlockRange(std::initializer_list<Block *> blocks LLVM_LIFETIME_BOUND)

117

118 private:

119

120

121

123

124

125 static OwnerT offset_base(OwnerT object, ptrdiff_t index);

126

127

128 static Block *dereference_iterator(OwnerT object, ptrdiff_t index);

129

130

131 friend RangeBaseT;

132 };

133

134

135

136

137

138 namespace detail {

139

140 template <typename OpT, typename IteratorT>

142 : public llvm::filter_iterator<IteratorT, bool (*)(Operation &)> {

143 static bool filter(Operation &op) { return llvm::isa(op); }

144

145 public:

147 : llvm::filter_iterator<IteratorT, bool (*)(Operation &)>(it, end,

148 &filter) {}

149

150

151 operator const IteratorT &() const { return this->wrapped(); }

152 };

153

154

155

156 template <typename OpT, typename IteratorT>

158 : public llvm::mapped_iterator<op_filter_iterator<OpT, IteratorT>,

159 OpT (*)(Operation &)> {

160 static OpT unwrap(Operation &op) { return cast(op); }

161

162 public:

163

166 OpT (*)(Operation &)>(it, &unwrap) {}

167

168

169 operator const IteratorT &() const { return this->wrapped(); }

170 };

171 }

172 }

173

174 namespace llvm {

175

176

177 template <>

182 }

186 }

188 return llvm::hash_combine_range(value);

189 }

191 if (rhs.getBase() == getEmptyKey().getBase())

192 return lhs.getBase() == getEmptyKey().getBase();

193 if (rhs.getBase() == getTombstoneKey().getBase())

194 return lhs.getBase() == getTombstoneKey().getBase();

195 return lhs == rhs;

196 }

197 };

198

199

200

201

202

203 namespace ilist_detail {

204

205

206

207

208 template <>

209 struct SpecificNodeAccess<

211 protected:

212 using OptionsT = typename compute_node_optionsmlir::Operation::type;

213 using pointer = typename OptionsT::pointer;

216

219

222 };

223 }

224

225 template <>

228 using op_iterator = simple_ilist::iterator;

229

230 static void deleteNode(Operation *op);

231 void addNodeToList(Operation *op);

232 void removeNodeFromList(Operation *op);

233 void transferNodesFromList(ilist_traits &otherList,

235

236 private:

238 };

239

240

241

242

243

244 template <>

248

249 void addNodeToList(Block *block);

250 void removeNodeFromList(Block *block);

251 void transferNodesFromList(ilist_traits &otherList,

253

254 private:

256 };

257

258 }

259

260 #endif

static Value getBase(Value v)

Looks through known "view-like" ops to find the base memref.

A block operand represents an operand that holds a reference to a Block, e.g.

unsigned getOperandNumber()

Return which operand this is in the BlockOperand list of the Operation.

static IRObjectWithUseList< BlockOperand > * getUseList(Block *value)

Provide the use list that is attached to the given block.

This class provides an abstraction over the different types of ranges over Blocks.

BlockRange(ArrayRef< Block * > blocks=std::nullopt)

BlockRange(Arg &&arg LLVM_LIFETIME_BOUND)

BlockRange(std::initializer_list< Block * > blocks LLVM_LIFETIME_BOUND)

Block represents an ordered list of Operations.

A reference to a value, suitable for use as an operand of an operation.

Operation is the basic unit of execution within MLIR.

Implement a predecessor iterator for blocks.

PredecessorIterator(ValueUseIterator< BlockOperand > it)

Initializes the operand type iterator to the specified operand iterator.

PredecessorIterator(BlockOperand *operand)

unsigned getSuccessorIndex() const

Get the successor number in the predecessor terminator.

This class contains a list of basic blocks and a link to the parent operation it is attached to.

This class implements the successor iterators for Block.

An iterator class that allows for iterating over the uses of an IR operand type.

A utility iterator that filters out operations that are not 'OpT'.

op_filter_iterator(IteratorT it, IteratorT end)

This class provides iteration over the held operations of a block for a specific operation type.

op_iterator(op_filter_iterator< OpT, IteratorT > it)

Initializes the iterator to the specified filter iterator.

mlir::Diagnostic & unwrap(MlirDiagnostic diagnostic)

The OpAsmOpInterface, see OpAsmInterface.td for more details.

Include the generated interface declarations.

static bool isEqual(mlir::SuccessorRange lhs, mlir::SuccessorRange rhs)

static mlir::SuccessorRange getTombstoneKey()

static unsigned getHashValue(mlir::SuccessorRange value)

static mlir::SuccessorRange getEmptyKey()

typename OptionsT::const_pointer const_pointer

ilist_node_impl< OptionsT > node_type

static node_type * getNodePtr(pointer N)

static const node_type * getNodePtr(const_pointer N)

typename OptionsT::pointer pointer

typename compute_node_options< mlir::Operation >::type OptionsT

static pointer getValuePtr(node_type *N)

static const_pointer getValuePtr(const node_type *N)

simple_ilist<::mlir::Block >::iterator block_iterator

simple_ilist< Operation >::iterator op_iterator