Skip to content

Commit 0437a9e

Browse files
committed
[mlir][scf] upstream numba's scf vectorizer
1 parent c9a86fa commit 0437a9e

File tree

3 files changed

+711
-0
lines changed

3 files changed

+711
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//===- SCFVectorize.h - ------------------------------------------*- C++-*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef MLIR_TRANSFORMS_SCFVECTORIZE_H_
10+
#define MLIR_TRANSFORMS_SCFVECTORIZE_H_
11+
12+
#include <memory>
13+
#include <optional>
14+
15+
namespace mlir {
16+
class OpBuilder;
17+
class Pass;
18+
struct LogicalResult;
19+
namespace scf {
20+
class ParallelOp;
21+
}
22+
} // namespace mlir
23+
24+
namespace mlir {
25+
struct SCFVectorizeInfo {
26+
unsigned dim = 0;
27+
unsigned factor = 0;
28+
unsigned count = 0;
29+
bool masked = false;
30+
};
31+
32+
std::optional<SCFVectorizeInfo> getLoopVectorizeInfo(mlir::scf::ParallelOp loop,
33+
unsigned dim,
34+
unsigned vectorBitWidth);
35+
36+
struct SCFVectorizeParams {
37+
unsigned dim = 0;
38+
unsigned factor = 0;
39+
bool masked = false;
40+
};
41+
42+
mlir::LogicalResult vectorizeLoop(mlir::OpBuilder &builder,
43+
mlir::scf::ParallelOp loop,
44+
const SCFVectorizeParams &params);
45+
46+
std::unique_ptr<mlir::Pass> createSCFVectorizePass();
47+
} // namespace mlir
48+
49+
#endif // MLIR_TRANSFORMS_SCFVECTORIZE_H_

mlir/lib/Transforms/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ add_mlir_library(MLIRTransforms
1414
PrintIR.cpp
1515
RemoveDeadValues.cpp
1616
SCCP.cpp
17+
SCFVectorize.cpp
1718
SROA.cpp
1819
StripDebugInfo.cpp
1920
SymbolDCE.cpp

0 commit comments

Comments
 (0)