Skip to content

Commit d4179f6

Browse files
committed
[MLIR] Initial upstream of polygeist dialect
1 parent b687efb commit d4179f6

16 files changed

Lines changed: 811 additions & 0 deletions

File tree

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@
122122
/mlir/lib/Dialect/Vector/Transforms/VectorEmulateNarrowType.cpp @banach-space @dcaballe @MaheshRavishankar @nicolasvasilache
123123
/mlir/**/*EmulateNarrowType* @dcaballe
124124

125+
# Polygeist dialect in MLIR
126+
/mlir/**/*Polygeist* @wsmoses @ftynse @ivanradanov @chelini
127+
125128
# Presburger library in MLIR
126129
/mlir/**/*Presburger* @Groverkss @Superty
127130

mlir/include/mlir/Dialect/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ add_subdirectory(OpenACCMPCommon)
2727
add_subdirectory(OpenMP)
2828
add_subdirectory(PDL)
2929
add_subdirectory(PDLInterp)
30+
add_subdirectory(Polygeist)
3031
add_subdirectory(Ptr)
3132
add_subdirectory(Quant)
3233
add_subdirectory(SCF)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add_subdirectory(IR)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
set(LLVM_TARGET_DEFINITIONS PolygeistOps.td)
2+
add_mlir_dialect(PolygeistOps polygeist)
3+
add_mlir_doc(PolygeistOps PolygeistOps Dialects/ -gen-dialect-doc)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#ifndef MLIR_DIALECT_POLYGEIST_IR_POLYGEIST_H_
2+
#define MLIR_DIALECT_POLYGEIST_IR_POLYGEIST_H_
3+
4+
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
5+
#include "mlir/IR/Dialect.h"
6+
#include "mlir/IR/OpDefinition.h"
7+
#include "mlir/Interfaces/SideEffectInterfaces.h"
8+
#include "mlir/Interfaces/ViewLikeInterface.h"
9+
10+
#include "mlir/Dialect/Polygeist/IR/PolygeistOpsDialect.h.inc"
11+
12+
#define GET_OP_CLASSES
13+
#include "mlir/Dialect/Polygeist/IR/PolygeistOps.h.inc"
14+
15+
#endif // MLIR_DIALECT_POLYGEIST_IR_POLYGEIST_H_
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#ifndef POLYGEIST_BASE
2+
#define POLYGEIST_BASE
3+
4+
include "mlir/IR/OpBase.td"
5+
6+
def Polygeist_Dialect : Dialect {
7+
let name = "polygeist";
8+
let cppNamespace = "::mlir::polygeist";
9+
let summary = "The Polygeist dialect.";
10+
let description = [{
11+
The Polygeist dialect contains operations for raising low-level code to higher-level forms, and performing parallel and device transformations (including polyhedral).
12+
}];
13+
}
14+
15+
#endif // POLYGEIST_BASE
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#ifndef POLYGEIST_OPS
2+
#define POLYGEIST_OPS
3+
4+
include "mlir/IR/OpBase.td"
5+
include "mlir/Interfaces/ViewLikeInterface.td"
6+
include "mlir/Interfaces/SideEffectInterfaces.td"
7+
include "mlir/Dialect/LLVMIR/LLVMOpBase.td"
8+
include "mlir/Dialect/Polygeist/IR/PolygeistBase.td"
9+
10+
def Memref2PointerOp
11+
: Op<Polygeist_Dialect, "memref2pointer", [ViewLikeOpInterface, Pure]> {
12+
let summary = "Extract an LLVM pointer from a MemRef";
13+
14+
let arguments = (ins AnyMemRef:$source);
15+
let results = (outs LLVM_AnyPointer:$result);
16+
17+
let hasFolder = 1;
18+
let hasCanonicalizer = 1;
19+
20+
let extraClassDeclaration = [{
21+
::mlir::Value getViewSource() { return getSource(); }
22+
}];
23+
}
24+
25+
def Pointer2MemrefOp
26+
: Op<Polygeist_Dialect, "pointer2memref", [ViewLikeOpInterface, Pure]> {
27+
let summary = "Upgrade a pointer to a memref";
28+
29+
let arguments = (ins LLVM_AnyPointer:$source);
30+
let results = (outs AnyMemRef:$result);
31+
32+
let hasFolder = 1;
33+
let hasCanonicalizer = 1;
34+
35+
let extraClassDeclaration = [{
36+
::mlir::Value getViewSource() { return getSource(); }
37+
}];
38+
}
39+
40+
#endif // POLYGEIST_OPS

mlir/lib/Dialect/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ add_subdirectory(OpenACCMPCommon)
2727
add_subdirectory(OpenMP)
2828
add_subdirectory(PDL)
2929
add_subdirectory(PDLInterp)
30+
add_subdirectory(Polygeist)
3031
add_subdirectory(Ptr)
3132
add_subdirectory(Quant)
3233
add_subdirectory(SCF)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add_subdirectory(IR)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
add_mlir_dialect_library(MLIRPolygeistDialect
2+
PolygeistOps.cpp
3+
PolygeistDialect.cpp
4+
5+
ADDITIONAL_HEADER_DIRS
6+
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/Polygeist
7+
8+
DEPENDS
9+
MLIRPolygeistOpsIncGen
10+
11+
LINK_LIBS PUBLIC
12+
MLIRDialect
13+
MLIRIR
14+
MLIRMemRefDialect
15+
MLIRLLVMDialect
16+
MLIRArithDialect
17+
MLIRAffineDialect
18+
MLIRSCFDialect
19+
)

0 commit comments

Comments
 (0)