1/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2|* *|
3|* Interface Definitions *|
4|* *|
5|* Automatically generated file, do not edit! *|
6|* *|
7\*===----------------------------------------------------------------------===*/
8
9
10/// For a given destructurable memory slot, returns whether this operation can
11/// rewire its uses of the slot to use the slots generated after
12/// destructuring. This may involve creating new operations.
13///
14/// This method must also register the indices it will access within the
15/// `usedIndices` set. If the accessor generates new slots mapping to
16/// subelements, they must be registered in `mustBeSafelyUsed` to ensure
17/// they are used in a safe manner.
18///
19/// No IR mutation is allowed in this method.
20bool mlir::DestructurableAccessorOpInterface::canRewire(const ::mlir::DestructurableMemorySlot & slot, ::llvm::SmallPtrSetImpl<::mlir::Attribute> & usedIndices, ::mlir::SmallVectorImpl<::mlir::MemorySlot> & mustBeSafelyUsed, const ::mlir::DataLayout & dataLayout) {
21 return getImpl()->canRewire(getImpl(), getOperation(), slot, usedIndices, mustBeSafelyUsed, dataLayout);
22 }
23
24/// Rewires the use of a slot to the generated subslots, without deleting
25/// any operation. Returns whether the accessor should be deleted.
26///
27/// Deletion of operations is not allowed, only the accessor can be
28/// scheduled for deletion by returning the appropriate value.
29::mlir::DeletionKind mlir::DestructurableAccessorOpInterface::rewire(const ::mlir::DestructurableMemorySlot & slot, ::llvm::DenseMap<::mlir::Attribute, ::mlir::MemorySlot> & subslots, ::mlir::OpBuilder & builder, const ::mlir::DataLayout & dataLayout) {
30 return getImpl()->rewire(getImpl(), getOperation(), slot, subslots, builder, dataLayout);
31 }
32
33/// Returns the list of slots for which destructuring should be attempted,
34/// specifying in which way the slot should be destructured into subslots.
35/// The subslots are indexed by attributes. This computes the type of the
36/// pointer for each subslot to be generated. The type of the memory slot
37/// must implement `DestructurableTypeInterface`.
38///
39/// No IR mutation is allowed in this method.
40::llvm::SmallVector<::mlir::DestructurableMemorySlot> mlir::DestructurableAllocationOpInterface::getDestructurableSlots() {
41 return getImpl()->getDestructurableSlots(getImpl(), getOperation());
42 }
43
44/// Destructures this slot into multiple subslots. The newly generated slots
45/// may belong to a different allocator. The original slot must still exist
46/// at the end of this call. Only generates subslots for the indices found in
47/// `usedIndices` since all other subslots are unused.
48///
49/// The builder is located at the beginning of the block where the slot
50/// pointer is defined.
51::llvm::DenseMap<::mlir::Attribute, ::mlir::MemorySlot> mlir::DestructurableAllocationOpInterface::destructure(const ::mlir::DestructurableMemorySlot & slot, const ::llvm::SmallPtrSetImpl<::mlir::Attribute> & usedIndices, ::mlir::OpBuilder & builder, ::mlir::SmallVectorImpl<::mlir::DestructurableAllocationOpInterface> & newAllocators) {
52 return getImpl()->destructure(getImpl(), getOperation(), slot, usedIndices, builder, newAllocators);
53 }
54
55/// Hook triggered once the destructuring of a slot is complete, meaning the
56/// original slot is no longer being referred to and could be deleted.
57/// This will only be called for slots declared by this operation.
58///
59/// Must return a new destructurable allocation op if this hook creates
60/// a new destructurable op, nullopt otherwise.
61::std::optional<::mlir::DestructurableAllocationOpInterface> mlir::DestructurableAllocationOpInterface::handleDestructuringComplete(const ::mlir::DestructurableMemorySlot & slot, ::mlir::OpBuilder & builder) {
62 return getImpl()->handleDestructuringComplete(getImpl(), getOperation(), slot, builder);
63 }
64
65/// Populates `newMemorySlots` with the memory slots this operation
66/// exposes by aliasing `parentSlot` (accessed via
67/// `aliasedSlotPointerOperand`). Each new slot's pointer must be a
68/// result of this operation, and its element type may differ from the
69/// parent's. Leave the vector empty if no alias is exposed. An operation
70/// can expose multiple aliases for the same parent slot.
71///
72/// `parentSlot` is provided so that aliasers using opaque pointers can
73/// derive the new slot's element type from `parentSlot.elemType`.
74///
75/// Exposing an alias requires implementing the two projection methods
76/// below to bridge values between the parent and new slot element types.
77/// If these projections cannot be performed, `newMemorySlots` must be left
78/// empty.
79///
80/// No IR mutation is allowed in this method.
81void mlir::PromotableAliaserInterface::getPromotableSlotAliases(::mlir::OpOperand & aliasedSlotPointerOperand, const ::mlir::MemorySlot & parentSlot, ::llvm::SmallVectorImpl<::mlir::MemorySlot> & newMemorySlots) {
82 return getImpl()->getPromotableSlotAliases(getImpl(), getOperation(), aliasedSlotPointerOperand, parentSlot, newMemorySlots);
83 }
84
85/// Extracts the value of `aliasSlot` from `slotValue` (the value of
86/// `parentSlot`). Mem2Reg invokes this method when a load on the new slot
87/// requires the parent's value to be materialized with the new slot's
88/// element type.
89::mlir::Value mlir::PromotableAliaserInterface::projectSlotValueToAliasValue(::mlir::OpOperand & aliasedSlotPointerOperand, const ::mlir::MemorySlot & parentSlot, const ::mlir::MemorySlot & aliasSlot, ::mlir::Value slotValue, ::mlir::OpBuilder & builder) {
90 return getImpl()->projectSlotValueToAliasValue(getImpl(), getOperation(), aliasedSlotPointerOperand, parentSlot, aliasSlot, slotValue, builder);
91 }
92
93/// Reconstructs the value of `parentSlot` from `aliasValue` (a store to
94/// `aliasSlot`) and `reachingDef` (the parent slot's value immediately
95/// preceding the store). For full aliases, `reachingDef` can be ignored.
96/// For partial sub-aliases, it allows the result to be constructed by
97/// inserting `aliasValue` into `reachingDef`.
98::mlir::Value mlir::PromotableAliaserInterface::projectAliasValueToSlotValue(::mlir::OpOperand & aliasedSlotPointerOperand, const ::mlir::MemorySlot & parentSlot, const ::mlir::MemorySlot & aliasSlot, ::mlir::Value aliasValue, ::mlir::Value reachingDef, ::mlir::OpBuilder & builder) {
99 return getImpl()->projectAliasValueToSlotValue(getImpl(), getOperation(), aliasedSlotPointerOperand, parentSlot, aliasSlot, aliasValue, reachingDef, builder);
100 }
101
102/// Returns a list of memory slots for which promotion should be attempted.
103/// This only considers the local semantics of the allocator, ignoring
104/// whether the slot pointer is properly used or not. This allocator is the
105/// "owner" of the returned slots, meaning no two allocators should return
106/// the same slot. The content of the memory slot must only be reachable
107/// using loads and stores to the provided slot pointer, no aliasing is
108/// allowed.
109///
110/// Promotion of the slot will lead to the slot pointer no longer being
111/// used, leaving the content of the memory slot unreachable.
112///
113/// No IR mutation is allowed in this method.
114::llvm::SmallVector<::mlir::MemorySlot> mlir::PromotableAllocationOpInterface::getPromotableSlots() {
115 return getImpl()->getPromotableSlots(getImpl(), getOperation());
116 }
117
118/// Provides the default Value of this memory slot. The provided Value
119/// will be used as the reaching definition of loads done before any store.
120/// This Value must outlive the promotion and dominate all the uses of this
121/// slot's pointer. The provided builder can be used to create the default
122/// value on the fly.
123///
124/// The builder is located at the beginning of the block where the slot
125/// pointer is defined.
126::mlir::Value mlir::PromotableAllocationOpInterface::getDefaultValue(const ::mlir::MemorySlot & slot, ::mlir::OpBuilder & builder) {
127 return getImpl()->getDefaultValue(getImpl(), getOperation(), slot, builder);
128 }
129
130/// Hook triggered for every new block argument added to a block.
131/// This will only be called for slots declared by this operation.
132/// This function is called after removal of blocking uses, meaning
133/// only operations that will be deleted remain users of the slot.
134///
135/// The builder is located at the beginning of the block on call. All IR
136/// mutations must happen through the builder.
137void mlir::PromotableAllocationOpInterface::handleBlockArgument(const ::mlir::MemorySlot & slot, ::mlir::BlockArgument argument, ::mlir::OpBuilder & builder) {
138 return getImpl()->handleBlockArgument(getImpl(), getOperation(), slot, argument, builder);
139 }
140
141/// Hook triggered once the promotion of a slot is complete. This can
142/// also clean up the created default value if necessary. The default
143/// value may be a null value if no default value was created.
144/// This will only be called for slots declared by this operation.
145///
146/// Must return a new promotable allocation op if this operation produced
147/// multiple promotable slots, nullopt otherwise.
148::std::optional<::mlir::PromotableAllocationOpInterface> mlir::PromotableAllocationOpInterface::handlePromotionComplete(const ::mlir::MemorySlot & slot, ::mlir::Value defaultValue, ::mlir::OpBuilder & builder) {
149 return getImpl()->handlePromotionComplete(getImpl(), getOperation(), slot, defaultValue, builder);
150 }
151
152/// Gets whether this operation loads from the specified slot.
153///
154/// No IR mutation is allowed in this method.
155bool mlir::PromotableMemOpInterface::loadsFrom(const ::mlir::MemorySlot & slot) {
156 return getImpl()->loadsFrom(getImpl(), getOperation(), slot);
157 }
158
159/// Gets whether this operation stores to the specified slot.
160///
161/// No IR mutation is allowed in this method.
162bool mlir::PromotableMemOpInterface::storesTo(const ::mlir::MemorySlot & slot) {
163 return getImpl()->storesTo(getImpl(), getOperation(), slot);
164 }
165
166/// Gets the value stored to the provided memory slot, or returns a null
167/// value if this operation does not store to this slot. An operation
168/// storing a value to a slot must always be able to provide the value it
169/// stores. This method is only called once per slot promotion, and only
170/// on operations that store to the slot according to the `storesTo` method.
171///
172/// The returned value must dominate the memory operation. This ensures
173/// that new uses inserted by `visitReplacedValues` after the memory
174/// operation are properly dominated.
175///
176/// The builder is positioned immediately before the memory operation on
177/// call. No IR deletion is allowed in this method. IR mutations must not
178/// introduce new uses of the memory slot. Existing control flow must not
179/// be modified.
180::mlir::Value mlir::PromotableMemOpInterface::getStored(const ::mlir::MemorySlot & slot, ::mlir::OpBuilder & builder, ::mlir::Value reachingDef, const ::mlir::DataLayout & dataLayout) {
181 return getImpl()->getStored(getImpl(), getOperation(), slot, builder, reachingDef, dataLayout);
182 }
183
184/// Checks that this operation can be promoted to no longer use the provided
185/// blocking uses, in the context of promoting `slot`.
186///
187/// If the removal procedure of the use will require that other uses get
188/// removed, that dependency should be added to the `newBlockingUses`
189/// argument. Dependent uses must only be uses of results of this operation.
190///
191/// No IR mutation is allowed in this method.
192bool mlir::PromotableMemOpInterface::canUsesBeRemoved(const ::mlir::MemorySlot & slot, const ::llvm::SmallPtrSetImpl<::mlir::OpOperand *> & blockingUses, ::llvm::SmallVectorImpl<::mlir::OpOperand *> & newBlockingUses, const ::mlir::DataLayout & datalayout) {
193 return getImpl()->canUsesBeRemoved(getImpl(), getOperation(), slot, blockingUses, newBlockingUses, datalayout);
194 }
195
196/// Transforms IR to ensure that the current operation does not use the
197/// provided memory slot anymore. `reachingDefinition` contains the value
198/// currently stored in the provided memory slot, immediately before the
199/// current operation.
200///
201/// During the transformation, *no operation should be deleted*.
202/// The operation can only schedule its own deletion by returning the
203/// appropriate `DeletionKind`. The deletion must be legal assuming the
204/// blocking uses passed through the `newBlockingUses` list in
205/// `canUseBeRemoved` have been removed.
206///
207/// After calling this method, the blocking uses should have disappeared
208/// or this operation should have scheduled its own deletion.
209///
210/// This method will only be called after ensuring promotion is allowed via
211/// `canUseBeRemoved`. The requested blocking use removal may or may not
212/// have been done at the point of calling this method, but it will be done
213/// eventually.
214///
215/// The builder is located after the promotable operation on call.
216::mlir::DeletionKind mlir::PromotableMemOpInterface::removeBlockingUses(const ::mlir::MemorySlot & slot, const ::llvm::SmallPtrSetImpl<mlir::OpOperand *> & blockingUses, ::mlir::OpBuilder & builder, ::mlir::Value reachingDefinition, const ::mlir::DataLayout & dataLayout) {
217 return getImpl()->removeBlockingUses(getImpl(), getOperation(), slot, blockingUses, builder, reachingDefinition, dataLayout);
218 }
219
220/// Returns whether this operation owns the blocking uses of a single
221/// wrapped `PromotableMemOpInterface` operation. If true, it must have one
222/// single-block region containing only that operation and a terminator.
223/// All blocking uses must belong to the wrapped operation, not this
224/// operation or its terminator. Only a single level of nesting is
225/// supported.
226///
227/// Promotion calls this operation's interface methods with the wrapped
228/// operation's operands in `blockingUses`, without consulting
229/// `PromotableRegionOpInterface` for its region. The builder inserts IR
230/// outside the region, before or after this operation.
231///
232/// The results of this operation must not alias the slot.
233///
234/// No IR mutation is allowed in this method.
235bool mlir::PromotableMemOpInterface::ownsWrappedBlockingUses() {
236 return getImpl()->ownsWrappedBlockingUses(getImpl(), getOperation());
237 }
238
239/// Checks that this operation can be promoted to no longer use the provided
240/// blocking uses, in order to allow optimization.
241///
242/// If the removal procedure of the use will require that other uses get
243/// removed, that dependency should be added to the `newBlockingUses`
244/// argument. Dependent uses must only be uses of results of this operation.
245///
246/// No IR mutation is allowed in this method.
247bool mlir::PromotableOpInterface::canUsesBeRemoved(const ::llvm::SmallPtrSetImpl<::mlir::OpOperand *> & blockingUses, ::llvm::SmallVectorImpl<::mlir::OpOperand *> & newBlockingUses, const ::mlir::DataLayout & datalayout) {
248 return getImpl()->canUsesBeRemoved(getImpl(), getOperation(), blockingUses, newBlockingUses, datalayout);
249 }
250
251/// Transforms IR to ensure that the current operation does not use the
252/// provided blocking uses anymore. In contrast to
253/// `PromotableMemOpInterface`, operations implementing this interface
254/// must not need access to the reaching definition of the content of the
255/// slot.
256///
257/// During the transformation, *no operation should be deleted*.
258/// The operation can only schedule its own deletion by returning the
259/// appropriate `DeletionKind`. The deletion must be legal assuming the
260/// blocking uses passed through the `newBlockingUses` list in
261/// `canUseBeRemoved` have been removed.
262///
263/// After calling this method, the blocking uses should have disappeared
264/// or this operation should have scheduled its own deletion.
265///
266/// This method will only be called after ensuring promotion is allowed via
267/// `canUseBeRemoved`. The requested blocking use removal may or may not
268/// have been done at the point of calling this method, but it will be done
269/// eventually.
270///
271/// The builder is located after the promotable operation on call.
272::mlir::DeletionKind mlir::PromotableOpInterface::removeBlockingUses(const ::llvm::SmallPtrSetImpl<mlir::OpOperand *> & blockingUses, ::mlir::OpBuilder & builder) {
273 return getImpl()->removeBlockingUses(getImpl(), getOperation(), blockingUses, builder);
274 }
275
276/// Indicates whether the promoted operation needs to visit the SSA values
277/// that replace the memory slot.
278///
279/// If true, `visitReplacedValues` will be called once for this operation
280/// after all reaching definitions have been computed but before any
281/// blocking uses are removed.
282///
283/// This should only return true if the intended transformation applies
284/// to all replaced values. Replaced values must not be deleted.
285bool mlir::PromotableOpInterface::requiresReplacedValues() {
286 return getImpl()->requiresReplacedValues(getImpl(), getOperation());
287 }
288
289/// Transforms the IR using the SSA values replacing the memory slot.
290///
291/// Called after all reaching definitions for the slot have been computed
292/// but before any blocking uses are removed, provided
293/// `requiresReplacedValues` returns true. `mutatedDefs` contains the
294/// replacing values. Any new uses of a load result created here will be
295/// automatically redirected to its reaching definition when the load is
296/// replaced.
297///
298/// The builder is positioned after the promotable operation.
299/// No operations may be deleted during this transformation.
300void mlir::PromotableOpInterface::visitReplacedValues(::llvm::ArrayRef<std::pair<::mlir::Operation*, ::mlir::Value>> mutatedDefs, ::mlir::OpBuilder & builder) {
301 return getImpl()->visitReplacedValues(getImpl(), getOperation(), mutatedDefs, builder);
302 }
303
304/// Returns true when the provided region of the operation can be analyzed
305/// for promotion. The provided region must be a child of the operation's
306/// region.
307/// The `hasValueStores` flag indicates whether the region contains
308/// store-like operations that write to the memory slot.
309bool mlir::PromotableRegionOpInterface::isRegionPromotable(const ::mlir::MemorySlot & slot, ::mlir::Region * region, bool hasValueStores) {
310 return getImpl()->isRegionPromotable(getImpl(), getOperation(), slot, region, hasValueStores);
311 }
312
313/// Called before processing the nested regions in the operation.
314///
315/// Based on the `reachingDef` value representing the value in the memory
316/// slot at the entry into the operation, `setupPromotion` fills in the
317/// `regionsToProcess` with the reaching definition at the entry of
318/// all its promotable regions.
319///
320/// `setupPromotion` is allowed to mutate
321/// the operation in place, including its nested regions, but cannot
322/// delete existing operations or modify successor-bearing terminators.
323/// Other mutations are not allowed.
324///
325/// The `hasValueStores` flag indicates whether the regions contain
326/// `store`-like operations that write to the memory slot. This field can be
327/// used to reduce the amount of book-keeping required to track the reaching
328/// definitions.
329void mlir::PromotableRegionOpInterface::setupPromotion(const ::mlir::MemorySlot & slot, ::mlir::Value reachingDef, bool hasValueStores, ::llvm::SmallMapVector<::mlir::Region *, ::mlir::Value, 2> & regionsToProcess) {
330 return getImpl()->setupPromotion(getImpl(), getOperation(), slot, reachingDef, hasValueStores, regionsToProcess);
331 }
332
333/// Called once the reaching definitions have been computed for all the
334/// regions, but before the actual removal of the blocking uses.
335///
336/// Returns the new reaching definition at the exit of the operation. For
337/// this purpose, mutation of the operation is allowed under the following
338/// constraints:
339/// 1. If a region is deleted, all of its content must have been moved out
340/// (not copied) to a new empty region that remains valid after the
341/// deletion.
342/// 2. Mutation must not change control flow within or between existing or
343/// moved regions. This includes adding, removing or reordering blocks.
344/// 3. Mutation must not modify or add operations that interact with the
345/// value of the slot.
346///
347/// As an example, in order to add new results to the region operation, it
348/// is allowed to clone the operation without regions, move (without
349/// copying) the old region content into the new regions, and delete the
350/// original operation.
351///
352/// The `entryReachingDef` is the reaching definition at the entry of the
353/// region operation.
354///
355/// The `reachingAtBlockEnd` map contains the reaching definitions after all
356/// the terminators within the regions of the operation. If a block of the
357/// region is not present in the map, it is either dead code or within a
358/// region that does not interact with the value of the slot.
359///
360/// The `hasValueStores` flag indicates whether the regions contain
361/// `store`-like operations that write to the memory slot. This field can be
362/// used to reduce the amount of book-keeping required to track the reaching
363/// definitions.
364::mlir::Value mlir::PromotableRegionOpInterface::finalizePromotion(const ::mlir::MemorySlot & slot, ::mlir::Value entryReachingDef, bool hasValueStores, const ::llvm::DenseMap<::mlir::Block *, ::mlir::Value> & reachingAtBlockEnd, ::mlir::OpBuilder & builder) {
365 return getImpl()->finalizePromotion(getImpl(), getOperation(), slot, entryReachingDef, hasValueStores, reachingAtBlockEnd, builder);
366 }
367
368/// Returns whether all accesses in this operation to the provided slot are
369/// done in a safe manner. To be safe, the access must only access the slot
370/// inside the bounds that its type implies.
371///
372/// If the safety of the accesses depends on the safety of the accesses to
373/// further memory slots, the result of this method will be conditioned to
374/// the safety of the accesses to the slots added by this method to
375/// `mustBeSafelyUsed`.
376///
377/// No IR mutation is allowed in this method.
378::llvm::LogicalResult mlir::SafeMemorySlotAccessOpInterface::ensureOnlySafeAccesses(const ::mlir::MemorySlot & slot, ::mlir::SmallVectorImpl<::mlir::MemorySlot> & mustBeSafelyUsed, const ::mlir::DataLayout & dataLayout) {
379 return getImpl()->ensureOnlySafeAccesses(getImpl(), getOperation(), slot, mustBeSafelyUsed, dataLayout);
380 }
381