Skip to content

Commit 8975cee

Browse files
committed
Correct the parameter to use function_ref.
1 parent 395196e commit 8975cee

File tree

3 files changed

+69
-70
lines changed

3 files changed

+69
-70
lines changed

mlir/include/mlir/Transforms/Inliner.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@ class InlinerConfig {
2727
public:
2828
using DefaultPipelineTy = std::function<void(OpPassManager &)>;
2929
using OpPipelinesTy = llvm::StringMap<OpPassManager>;
30-
using CloneCallbackSigTy =
31-
void(*)(OpBuilder &builder, Region *src, Block *inlineBlock,
32-
Block *postInsertBlock, IRMapping &mapper,
33-
bool shouldCloneInlinedRegion);
34-
using CloneCallbackTy =
35-
std::function<CloneCallbackSigTy>;
30+
using CloneCallbackSigTy = void(OpBuilder &builder, Region *src,
31+
Block *inlineBlock, Block *postInsertBlock,
32+
IRMapping &mapper,
33+
bool shouldCloneInlinedRegion);
34+
using CloneCallbackTy = std::function<CloneCallbackSigTy>;
3635

3736
InlinerConfig() = default;
3837
InlinerConfig(DefaultPipelineTy defaultPipeline,

mlir/include/mlir/Transforms/InliningUtils.h

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -254,51 +254,51 @@ class InlinerInterface
254254
/// provided, will be used to update the inlined operations' location
255255
/// information. 'shouldCloneInlinedRegion' corresponds to whether the source
256256
/// region should be cloned into the 'inlinePoint' or spliced directly.
257-
LogicalResult inlineRegion(InlinerInterface &interface,
258-
InlinerConfig::CloneCallbackTy cloneCallback,
259-
Region *src, Operation *inlinePoint,
260-
IRMapping &mapper, ValueRange resultsToReplace,
261-
TypeRange regionResultTypes,
262-
std::optional<Location> inlineLoc = std::nullopt,
263-
bool shouldCloneInlinedRegion = true);
264-
LogicalResult inlineRegion(InlinerInterface &interface,
265-
InlinerConfig::CloneCallbackTy cloneCallback,
266-
Region *src, Block *inlineBlock,
267-
Block::iterator inlinePoint, IRMapping &mapper,
268-
ValueRange resultsToReplace,
269-
TypeRange regionResultTypes,
270-
std::optional<Location> inlineLoc = std::nullopt,
271-
bool shouldCloneInlinedRegion = true);
257+
LogicalResult
258+
inlineRegion(InlinerInterface &interface,
259+
function_ref<InlinerConfig::CloneCallbackSigTy> cloneCallback,
260+
Region *src, Operation *inlinePoint, IRMapping &mapper,
261+
ValueRange resultsToReplace, TypeRange regionResultTypes,
262+
std::optional<Location> inlineLoc = std::nullopt,
263+
bool shouldCloneInlinedRegion = true);
264+
LogicalResult
265+
inlineRegion(InlinerInterface &interface,
266+
function_ref<InlinerConfig::CloneCallbackSigTy> cloneCallback,
267+
Region *src, Block *inlineBlock, Block::iterator inlinePoint,
268+
IRMapping &mapper, ValueRange resultsToReplace,
269+
TypeRange regionResultTypes,
270+
std::optional<Location> inlineLoc = std::nullopt,
271+
bool shouldCloneInlinedRegion = true);
272272

273273
/// This function is an overload of the above 'inlineRegion' that allows for
274274
/// providing the set of operands ('inlinedOperands') that should be used
275275
/// in-favor of the region arguments when inlining.
276-
LogicalResult inlineRegion(InlinerInterface &interface,
277-
InlinerConfig::CloneCallbackTy cloneCallback,
278-
Region *src, Operation *inlinePoint,
279-
ValueRange inlinedOperands,
280-
ValueRange resultsToReplace,
281-
std::optional<Location> inlineLoc = std::nullopt,
282-
bool shouldCloneInlinedRegion = true);
283-
LogicalResult inlineRegion(InlinerInterface &interface,
284-
InlinerConfig::CloneCallbackTy cloneCallback,
285-
Region *src, Block *inlineBlock,
286-
Block::iterator inlinePoint,
287-
ValueRange inlinedOperands,
288-
ValueRange resultsToReplace,
289-
std::optional<Location> inlineLoc = std::nullopt,
290-
bool shouldCloneInlinedRegion = true);
276+
LogicalResult
277+
inlineRegion(InlinerInterface &interface,
278+
function_ref<InlinerConfig::CloneCallbackSigTy> cloneCallback,
279+
Region *src, Operation *inlinePoint, ValueRange inlinedOperands,
280+
ValueRange resultsToReplace,
281+
std::optional<Location> inlineLoc = std::nullopt,
282+
bool shouldCloneInlinedRegion = true);
283+
LogicalResult
284+
inlineRegion(InlinerInterface &interface,
285+
function_ref<InlinerConfig::CloneCallbackSigTy> cloneCallback,
286+
Region *src, Block *inlineBlock, Block::iterator inlinePoint,
287+
ValueRange inlinedOperands, ValueRange resultsToReplace,
288+
std::optional<Location> inlineLoc = std::nullopt,
289+
bool shouldCloneInlinedRegion = true);
291290

292291
/// This function inlines a given region, 'src', of a callable operation,
293292
/// 'callable', into the location defined by the given call operation. This
294293
/// function returns failure if inlining is not possible, success otherwise. On
295294
/// failure, no changes are made to the module. 'shouldCloneInlinedRegion'
296295
/// corresponds to whether the source region should be cloned into the 'call' or
297296
/// spliced directly.
298-
LogicalResult inlineCall(InlinerInterface &interface,
299-
InlinerConfig::CloneCallbackTy cloneCallback,
300-
CallOpInterface call, CallableOpInterface callable,
301-
Region *src, bool shouldCloneInlinedRegion = true);
297+
LogicalResult
298+
inlineCall(InlinerInterface &interface,
299+
function_ref<InlinerConfig::CloneCallbackSigTy> cloneCallback,
300+
CallOpInterface call, CallableOpInterface callable, Region *src,
301+
bool shouldCloneInlinedRegion = true);
302302

303303
} // namespace mlir
304304

mlir/lib/Transforms/Utils/InliningUtils.cpp

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,8 @@ static void handleResultImpl(InlinerInterface &interface, OpBuilder &builder,
247247

248248
static LogicalResult
249249
inlineRegionImpl(InlinerInterface &interface,
250-
InlinerConfig::CloneCallbackTy cloneCallback, Region *src,
251-
Block *inlineBlock, Block::iterator inlinePoint,
250+
function_ref<InlinerConfig::CloneCallbackSigTy> cloneCallback,
251+
Region *src, Block *inlineBlock, Block::iterator inlinePoint,
252252
IRMapping &mapper, ValueRange resultsToReplace,
253253
TypeRange regionResultTypes, std::optional<Location> inlineLoc,
254254
bool shouldCloneInlinedRegion, CallOpInterface call = {}) {
@@ -350,8 +350,8 @@ inlineRegionImpl(InlinerInterface &interface,
350350

351351
static LogicalResult
352352
inlineRegionImpl(InlinerInterface &interface,
353-
InlinerConfig::CloneCallbackTy cloneCallback, Region *src,
354-
Block *inlineBlock, Block::iterator inlinePoint,
353+
function_ref<InlinerConfig::CloneCallbackSigTy> cloneCallback,
354+
Region *src, Block *inlineBlock, Block::iterator inlinePoint,
355355
ValueRange inlinedOperands, ValueRange resultsToReplace,
356356
std::optional<Location> inlineLoc,
357357
bool shouldCloneInlinedRegion, CallOpInterface call = {}) {
@@ -381,45 +381,45 @@ inlineRegionImpl(InlinerInterface &interface,
381381
shouldCloneInlinedRegion, call);
382382
}
383383

384-
LogicalResult mlir::inlineRegion(InlinerInterface &interface,
385-
InlinerConfig::CloneCallbackTy cloneCallback,
386-
Region *src, Operation *inlinePoint,
387-
IRMapping &mapper, ValueRange resultsToReplace,
388-
TypeRange regionResultTypes,
389-
std::optional<Location> inlineLoc,
390-
bool shouldCloneInlinedRegion) {
384+
LogicalResult mlir::inlineRegion(
385+
InlinerInterface &interface,
386+
function_ref<InlinerConfig::CloneCallbackSigTy> cloneCallback, Region *src,
387+
Operation *inlinePoint, IRMapping &mapper, ValueRange resultsToReplace,
388+
TypeRange regionResultTypes, std::optional<Location> inlineLoc,
389+
bool shouldCloneInlinedRegion) {
391390
return inlineRegion(interface, cloneCallback, src, inlinePoint->getBlock(),
392391
++inlinePoint->getIterator(), mapper, resultsToReplace,
393392
regionResultTypes, inlineLoc, shouldCloneInlinedRegion);
394393
}
395394

396395
LogicalResult mlir::inlineRegion(
397-
InlinerInterface &interface, InlinerConfig::CloneCallbackTy cloneCallback,
398-
Region *src, Block *inlineBlock, Block::iterator inlinePoint,
399-
IRMapping &mapper, ValueRange resultsToReplace, TypeRange regionResultTypes,
396+
InlinerInterface &interface,
397+
function_ref<InlinerConfig::CloneCallbackSigTy> cloneCallback, Region *src,
398+
Block *inlineBlock, Block::iterator inlinePoint, IRMapping &mapper,
399+
ValueRange resultsToReplace, TypeRange regionResultTypes,
400400
std::optional<Location> inlineLoc, bool shouldCloneInlinedRegion) {
401401
return inlineRegionImpl(
402402
interface, cloneCallback, src, inlineBlock, inlinePoint, mapper,
403403
resultsToReplace, regionResultTypes, inlineLoc, shouldCloneInlinedRegion);
404404
}
405405

406-
LogicalResult mlir::inlineRegion(InlinerInterface &interface,
407-
InlinerConfig::CloneCallbackTy cloneCallback,
408-
Region *src, Operation *inlinePoint,
409-
ValueRange inlinedOperands,
410-
ValueRange resultsToReplace,
411-
std::optional<Location> inlineLoc,
412-
bool shouldCloneInlinedRegion) {
406+
LogicalResult mlir::inlineRegion(
407+
InlinerInterface &interface,
408+
function_ref<InlinerConfig::CloneCallbackSigTy> cloneCallback, Region *src,
409+
Operation *inlinePoint, ValueRange inlinedOperands,
410+
ValueRange resultsToReplace, std::optional<Location> inlineLoc,
411+
bool shouldCloneInlinedRegion) {
413412
return inlineRegion(interface, cloneCallback, src, inlinePoint->getBlock(),
414413
++inlinePoint->getIterator(), inlinedOperands,
415414
resultsToReplace, inlineLoc, shouldCloneInlinedRegion);
416415
}
417416

418417
LogicalResult mlir::inlineRegion(
419-
InlinerInterface &interface, InlinerConfig::CloneCallbackTy cloneCallback,
420-
Region *src, Block *inlineBlock, Block::iterator inlinePoint,
421-
ValueRange inlinedOperands, ValueRange resultsToReplace,
422-
std::optional<Location> inlineLoc, bool shouldCloneInlinedRegion) {
418+
InlinerInterface &interface,
419+
function_ref<InlinerConfig::CloneCallbackSigTy> cloneCallback, Region *src,
420+
Block *inlineBlock, Block::iterator inlinePoint, ValueRange inlinedOperands,
421+
ValueRange resultsToReplace, std::optional<Location> inlineLoc,
422+
bool shouldCloneInlinedRegion) {
423423
return inlineRegionImpl(interface, cloneCallback, src, inlineBlock,
424424
inlinePoint, inlinedOperands, resultsToReplace,
425425
inlineLoc, shouldCloneInlinedRegion);
@@ -453,11 +453,11 @@ static Value materializeConversion(const DialectInlinerInterface *interface,
453453
/// failure, no changes are made to the module. 'shouldCloneInlinedRegion'
454454
/// corresponds to whether the source region should be cloned into the 'call' or
455455
/// spliced directly.
456-
LogicalResult mlir::inlineCall(InlinerInterface &interface,
457-
InlinerConfig::CloneCallbackTy cloneCallback,
458-
CallOpInterface call,
459-
CallableOpInterface callable, Region *src,
460-
bool shouldCloneInlinedRegion) {
456+
LogicalResult
457+
mlir::inlineCall(InlinerInterface &interface,
458+
function_ref<InlinerConfig::CloneCallbackSigTy> cloneCallback,
459+
CallOpInterface call, CallableOpInterface callable,
460+
Region *src, bool shouldCloneInlinedRegion) {
461461
// We expect the region to have at least one block.
462462
if (src->empty())
463463
return failure();

0 commit comments

Comments
 (0)