Skip to content

Commit 3ba467e

Browse files
committed
[mlir][amdgpu] Add Inliner intreface
1 parent 93d3260 commit 3ba467e

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

mlir/lib/Dialect/AMDGPU/IR/AMDGPUDialect.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "mlir/IR/OpImplementation.h"
2727
#include "mlir/IR/PatternMatch.h"
2828
#include "mlir/IR/TypeUtilities.h"
29+
#include "mlir/Transforms/InliningUtils.h"
2930
#include "llvm/ADT/DenseMap.h"
3031
#include "llvm/ADT/SmallVector.h"
3132
#include "llvm/ADT/TypeSwitch.h"
@@ -40,6 +41,15 @@ using namespace mlir::amdgpu;
4041

4142
#include "mlir/Dialect/AMDGPU/IR/AMDGPUDialect.cpp.inc"
4243

44+
namespace {
45+
struct AMDGPUInlinerInterface : public DialectInlinerInterface {
46+
using DialectInlinerInterface::DialectInlinerInterface;
47+
bool isLegalToInline(Operation *, Region *, bool, IRMapping &) const final {
48+
return true;
49+
}
50+
};
51+
} // namespace
52+
4353
void AMDGPUDialect::initialize() {
4454
addOperations<
4555
#define GET_OP_LIST
@@ -49,6 +59,7 @@ void AMDGPUDialect::initialize() {
4959
#define GET_ATTRDEF_LIST
5060
#include "mlir/Dialect/AMDGPU/IR/AMDGPUAttributes.cpp.inc"
5161
>();
62+
addInterfaces<AMDGPUInlinerInterface>();
5263
}
5364

5465
//===----------------------------------------------------------------------===//
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: mlir-opt %s --inline | FileCheck %s
2+
3+
func.func @calee(%arg0 : f32) -> f32 {
4+
%0 = amdgpu.permlane_swap %arg0 32 : f32
5+
func.return %0 : f32
6+
}
7+
8+
// CHECK-LABEL: func @caller
9+
func.func @caller(%arg0 : f32) -> f32 {
10+
// CHECK-NOT: call
11+
// CHECK: amdgpu.permlane_swap
12+
%0 = call @calee(%arg0) : (f32) -> f32
13+
func.return %0 : f32
14+
}

0 commit comments

Comments
 (0)