Skip to content

Commit b365a43

Browse files
cheliniwsmoses
andauthored
bump LLVM (#166)
* bump LLVM * fix * more fixes * fix * Fix build * Use actual llvm hash Co-authored-by: William S. Moses <gh@wsmoses.com>
1 parent d4180c7 commit b365a43

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+440
-435
lines changed

include/polygeist/Dialect.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def Polygeist_Dialect : Dialect {
2525
// Base BFV operation definition.
2626
//===----------------------------------------------------------------------===//
2727

28-
class Polygeist_Op<string mnemonic, list<OpTrait> traits = []>
28+
class Polygeist_Op<string mnemonic, list<Trait> traits = []>
2929
: Op<Polygeist_Dialect, mnemonic, traits>;
3030

3131
#endif // POLYGEIST_DIALECT

include/polygeist/Passes/Passes.td

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33

44
include "mlir/Pass/PassBase.td"
55

6-
def AffineCFG : FunctionPass<"affine-cfg"> {
6+
def AffineCFG : Pass<"affine-cfg", "FuncOp"> {
77
let summary = "Replace scf.if and similar with affine.if";
88
let constructor = "mlir::polygeist::replaceAffineCFGPass()";
99
}
1010

11-
def Mem2Reg : FunctionPass<"mem2reg"> {
11+
def Mem2Reg : Pass<"mem2reg", "FuncOp"> {
1212
let summary = "Replace scf.if and similar with affine.if";
1313
let constructor = "mlir::polygeist::createMem2RegPass()";
1414
}
@@ -20,12 +20,12 @@ def ParallelLower : Pass<"parallel-lower", "mlir::ModuleOp"> {
2020
let constructor = "mlir::polygeist::createParallelLowerPass()";
2121
}
2222

23-
def AffineReduction : FunctionPass<"detect-reduction"> {
23+
def AffineReduction : Pass<"detect-reduction", "FuncOp"> {
2424
let summary = "Detect reductions in affine.for";
2525
let constructor = "mlir::polygeist::detectReductionPass()";
2626
}
2727

28-
def SCFCPUify : FunctionPass<"cpuify"> {
28+
def SCFCPUify : Pass<"cpuify", "FuncOp"> {
2929
let summary = "remove scf.barrier";
3030
let constructor = "mlir::polygeist::createCPUifyPass()";
3131
let dependentDialects =
@@ -35,29 +35,29 @@ def SCFCPUify : FunctionPass<"cpuify"> {
3535
];
3636
}
3737

38-
def SCFBarrierRemovalContinuation : FunctionPass<"barrier-removal-continuation"> {
38+
def SCFBarrierRemovalContinuation : Pass<"barrier-removal-continuation", "FuncOp"> {
3939
let summary = "Remove scf.barrier using continuations";
4040
let constructor = "mlir::polygeist::createBarrierRemovalContinuation()";
4141
let dependentDialects = ["memref::MemRefDialect", "StandardOpsDialect"];
4242
}
4343

44-
def SCFRaiseToAffine : FunctionPass<"raise-scf-to-affine"> {
44+
def SCFRaiseToAffine : Pass<"raise-scf-to-affine", "FuncOp"> {
4545
let summary = "Raise SCF to affine";
4646
let constructor = "mlir::polygeist::createRaiseSCFToAffinePass()";
4747
let dependentDialects = ["AffineDialect"];
4848
}
4949

50-
def SCFCanonicalizeFor : FunctionPass<"canonicalize-scf-for"> {
50+
def SCFCanonicalizeFor : Pass<"canonicalize-scf-for", "FuncOp"> {
5151
let summary = "Run some additional canonicalization for scf::for";
5252
let constructor = "mlir::polygeist::createCanonicalizeForPass()";
5353
}
5454

55-
def LoopRestructure : FunctionPass<"loop-restructure"> {
55+
def LoopRestructure : Pass<"loop-restructure", "FuncOp"> {
5656
let constructor = "mlir::polygeist::createLoopRestructurePass()";
5757
let dependentDialects = ["::mlir::scf::SCFDialect"];
5858
}
5959

60-
def RemoveTrivialUse : FunctionPass<"trivialuse"> {
60+
def RemoveTrivialUse : Pass<"trivialuse", "FuncOp"> {
6161
let constructor = "mlir::polygeist::createRemoveTrivialUsePass()";
6262
}
6363

lib/polygeist/Ops.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "polygeist/Ops.h"
10+
#include "mlir/Dialect/Arithmetic/IR/Arithmetic.h"
1011
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
1112
#include "mlir/Dialect/LLVMIR/LLVMTypes.h"
1213
#include "mlir/IR/Builders.h"
1314
#include "mlir/IR/OpImplementation.h"
1415
#include "mlir/Interfaces/SideEffectInterfaces.h"
1516
#include "polygeist/Dialect.h"
16-
#include <mlir/Dialect/Arithmetic/IR/Arithmetic.h>
1717

1818
#define GET_OP_CLASSES
1919
#include "polygeist/PolygeistOps.cpp.inc"
2020

2121
#include "mlir/Dialect/Affine/IR/AffineOps.h"
22+
#include "mlir/Dialect/Arithmetic/Utils/Utils.h"
2223
#include "mlir/Dialect/MemRef/IR/MemRef.h"
24+
#include "mlir/Dialect/SCF/SCF.h"
2325
#include "mlir/Dialect/StandardOps/IR/Ops.h"
24-
#include "mlir/Dialect/StandardOps/Utils/Utils.h"
2526
#include "mlir/IR/BlockAndValueMapping.h"
26-
#include <mlir/Dialect/SCF/SCF.h>
2727

2828
using namespace mlir;
2929
using namespace polygeist;
@@ -161,8 +161,8 @@ class SubToCast final : public OpRewritePattern<SubIndexOp> {
161161
if (cidx.value() != 0)
162162
return failure();
163163

164-
rewriter.replaceOpWithNewOp<memref::CastOp>(subViewOp, subViewOp.source(),
165-
post);
164+
rewriter.replaceOpWithNewOp<memref::CastOp>(subViewOp, post,
165+
subViewOp.source());
166166
return success();
167167
}
168168

@@ -724,7 +724,7 @@ MutableOperandRange LoadSelect<LLVM::LoadOp>::ptrMutable(LLVM::LoadOp op) {
724724
return op.getAddrMutable();
725725
}
726726

727-
void SubIndexOp::getCanonicalizationPatterns(OwningRewritePatternList &results,
727+
void SubIndexOp::getCanonicalizationPatterns(RewritePatternSet &results,
728728
MLIRContext *context) {
729729
results.insert<CastOfSubIndex, SubIndex2, SubToCast, SimplifySubViewUsers,
730730
SimplifySubIndexUsers, SelectOfCast, SelectOfSubIndex,
@@ -870,8 +870,8 @@ class CopySimplification final : public OpRewritePattern<T> {
870870
op.getLoc(), c0,
871871
rewriter.create<arith::DivUIOp>(
872872
op.getLoc(),
873-
rewriter.create<arith::IndexCastOp>(op.getLoc(), op.getLen(),
874-
rewriter.getIndexType()),
873+
rewriter.create<arith::IndexCastOp>(
874+
op.getLoc(), rewriter.getIndexType(), op.getLen()),
875875
rewriter.create<arith::ConstantIndexOp>(op.getLoc(), width)),
876876
c1);
877877

@@ -918,8 +918,8 @@ OpFoldResult Memref2PointerOp::fold(ArrayRef<Attribute> operands) {
918918
return nullptr;
919919
}
920920

921-
void Memref2PointerOp::getCanonicalizationPatterns(
922-
OwningRewritePatternList &results, MLIRContext *context) {
921+
void Memref2PointerOp::getCanonicalizationPatterns(RewritePatternSet &results,
922+
MLIRContext *context) {
923923
results.insert<Memref2Pointer2MemrefCast, Memref2PointerIndex,
924924
CopySimplification<LLVM::MemcpyOp>,
925925
CopySimplification<LLVM::MemmoveOp>>(context);
@@ -1021,16 +1021,16 @@ class MetaPointer2Memref final : public OpRewritePattern<Op> {
10211021
auto shape = mt.getShape();
10221022
for (size_t i = 0; i < shape.size(); i++) {
10231023
auto off = computeIndex(op, i, rewriter);
1024-
auto cur =
1025-
rewriter.create<IndexCastOp>(op.getLoc(), rewriter.getI32Type(), off);
1024+
auto cur = rewriter.create<arith::IndexCastOp>(
1025+
op.getLoc(), rewriter.getI32Type(), off);
10261026
if (idx == nullptr) {
10271027
idx = cur;
10281028
} else {
10291029
idx = rewriter.create<AddIOp>(
10301030
op.getLoc(),
1031-
rewriter.create<MulIOp>(
1032-
op.getLoc(), idx,
1033-
rewriter.create<ConstantIntOp>(op.getLoc(), shape[i], 32)),
1031+
rewriter.create<MulIOp>(op.getLoc(), idx,
1032+
rewriter.create<arith::ConstantIntOp>(
1033+
op.getLoc(), shape[i], 32)),
10341034
cur);
10351035
}
10361036
}
@@ -1433,8 +1433,8 @@ struct MoveIntoIfs : public OpRewritePattern<scf::IfOp> {
14331433
}
14341434
};
14351435

1436-
void Pointer2MemrefOp::getCanonicalizationPatterns(
1437-
OwningRewritePatternList &results, MLIRContext *context) {
1436+
void Pointer2MemrefOp::getCanonicalizationPatterns(RewritePatternSet &results,
1437+
MLIRContext *context) {
14381438
results.insert<
14391439
Pointer2MemrefCast, Pointer2Memref2PointerCast,
14401440
MetaPointer2Memref<memref::LoadOp>, MetaPointer2Memref<memref::StoreOp>,
@@ -1517,7 +1517,7 @@ struct TypeSizeCanonicalize : public OpRewritePattern<TypeSizeOp> {
15171517
}
15181518
};
15191519

1520-
void TypeSizeOp::getCanonicalizationPatterns(OwningRewritePatternList &results,
1520+
void TypeSizeOp::getCanonicalizationPatterns(RewritePatternSet &results,
15211521
MLIRContext *context) {
15221522
results.insert<TypeSizeCanonicalize>(context);
15231523
}

lib/polygeist/Passes/AffineCFG.cpp

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ void fully2ComposeIntegerSetAndOperands(IntegerSet *set,
501501

502502
namespace {
503503
struct AffineCFGPass : public AffineCFGBase<AffineCFGPass> {
504-
void runOnFunction() override;
504+
void runOnOperation() override;
505505
};
506506
} // namespace
507507

@@ -561,9 +561,9 @@ struct SimplfyIntegerCastMath : public OpRewritePattern<IndexCastOp> {
561561
setLocationAfter(b2, iadd.getOperand(1));
562562
rewriter.replaceOpWithNewOp<AddIOp>(
563563
op,
564-
b.create<IndexCastOp>(op.getLoc(), iadd.getOperand(0), op.getType()),
565-
b2.create<IndexCastOp>(op.getLoc(), iadd.getOperand(1),
566-
op.getType()));
564+
b.create<IndexCastOp>(op.getLoc(), op.getType(), iadd.getOperand(0)),
565+
b2.create<IndexCastOp>(op.getLoc(), op.getType(),
566+
iadd.getOperand(1)));
567567
return success();
568568
}
569569
if (auto iadd = op.getOperand().getDefiningOp<SubIOp>()) {
@@ -573,9 +573,10 @@ struct SimplfyIntegerCastMath : public OpRewritePattern<IndexCastOp> {
573573
setLocationAfter(b2, iadd.getOperand(1));
574574
rewriter.replaceOpWithNewOp<SubIOp>(
575575
op,
576-
b.create<IndexCastOp>(op.getLoc(), iadd.getOperand(0), op.getType()),
577-
b2.create<IndexCastOp>(op.getLoc(), iadd.getOperand(1),
578-
op.getType()));
576+
b.create<arith::IndexCastOp>(op.getLoc(), op.getType(),
577+
iadd.getOperand(0)),
578+
b2.create<arith::IndexCastOp>(op.getLoc(), op.getType(),
579+
iadd.getOperand(1)));
579580
return success();
580581
}
581582
if (auto iadd = op.getOperand().getDefiningOp<MulIOp>()) {
@@ -585,9 +586,9 @@ struct SimplfyIntegerCastMath : public OpRewritePattern<IndexCastOp> {
585586
setLocationAfter(b2, iadd.getOperand(1));
586587
rewriter.replaceOpWithNewOp<MulIOp>(
587588
op,
588-
b.create<IndexCastOp>(op.getLoc(), iadd.getOperand(0), op.getType()),
589-
b2.create<IndexCastOp>(op.getLoc(), iadd.getOperand(1),
590-
op.getType()));
589+
b.create<IndexCastOp>(op.getLoc(), op.getType(), iadd.getOperand(0)),
590+
b2.create<IndexCastOp>(op.getLoc(), op.getType(),
591+
iadd.getOperand(1)));
591592
return success();
592593
}
593594
if (auto iadd = op.getOperand().getDefiningOp<DivUIOp>()) {
@@ -597,9 +598,10 @@ struct SimplfyIntegerCastMath : public OpRewritePattern<IndexCastOp> {
597598
setLocationAfter(b2, iadd.getOperand(1));
598599
rewriter.replaceOpWithNewOp<DivUIOp>(
599600
op,
600-
b.create<IndexCastOp>(op.getLoc(), iadd.getOperand(0), op.getType()),
601-
b2.create<IndexCastOp>(op.getLoc(), iadd.getOperand(1),
602-
op.getType()));
601+
b.create<arith::IndexCastOp>(op.getLoc(), op.getType(),
602+
iadd.getOperand(0)),
603+
b2.create<arith::IndexCastOp>(op.getLoc(), op.getType(),
604+
iadd.getOperand(1)));
603605
return success();
604606
}
605607
if (auto iadd = op.getOperand().getDefiningOp<DivSIOp>()) {
@@ -609,9 +611,10 @@ struct SimplfyIntegerCastMath : public OpRewritePattern<IndexCastOp> {
609611
setLocationAfter(b2, iadd.getOperand(1));
610612
rewriter.replaceOpWithNewOp<DivSIOp>(
611613
op,
612-
b.create<IndexCastOp>(op.getLoc(), iadd.getOperand(0), op.getType()),
613-
b2.create<IndexCastOp>(op.getLoc(), iadd.getOperand(1),
614-
op.getType()));
614+
b.create<arith::IndexCastOp>(op.getLoc(), op.getType(),
615+
iadd.getOperand(0)),
616+
b2.create<arith::IndexCastOp>(op.getLoc(), op.getType(),
617+
iadd.getOperand(1)));
615618
return success();
616619
}
617620
return failure();
@@ -753,17 +756,17 @@ bool handle(OpBuilder &b, CmpIOp cmpi, SmallVectorImpl<AffineExpr> &exprs,
753756
}
754757
SmallVector<Value, 4> lhspack = {cmpi.getLhs()};
755758
if (!lhspack[0].getType().isa<IndexType>()) {
756-
auto op = b.create<IndexCastOp>(cmpi.getLoc(), lhspack[0],
757-
IndexType::get(cmpi.getContext()));
759+
auto op = b.create<arith::IndexCastOp>(
760+
cmpi.getLoc(), IndexType::get(cmpi.getContext()), lhspack[0]);
758761
lhspack[0] = op;
759762
}
760763

761764
AffineMap rhsmap =
762765
AffineMap::get(0, 1, getAffineSymbolExpr(0, cmpi.getContext()));
763766
SmallVector<Value, 4> rhspack = {cmpi.getRhs()};
764767
if (!rhspack[0].getType().isa<IndexType>()) {
765-
auto op = b.create<IndexCastOp>(cmpi.getLoc(), rhspack[0],
766-
IndexType::get(cmpi.getContext()));
768+
auto op = b.create<arith::IndexCastOp>(
769+
cmpi.getLoc(), IndexType::get(cmpi.getContext()), rhspack[0]);
767770
rhspack[0] = op;
768771
}
769772

@@ -1131,16 +1134,15 @@ struct MoveIfToAffine : public OpRewritePattern<scf::IfOp> {
11311134
}
11321135
};
11331136

1134-
void AffineCFGPass::runOnFunction() {
1135-
mlir::RewritePatternSet rpl(getFunction().getContext());
1137+
void AffineCFGPass::runOnOperation() {
1138+
mlir::RewritePatternSet rpl(getOperation().getContext());
11361139
rpl.add<SimplfyIntegerCastMath, CanonicalizeAffineApply,
11371140
CanonicalizeIndexCast, IndexCastMovement, AffineFixup<AffineLoadOp>,
11381141
AffineFixup<AffineStoreOp>, CanonicalizIfBounds, MoveStoreToAffine,
11391142
MoveIfToAffine, MoveLoadToAffine, CanonicalieForBounds>(
1140-
getFunction().getContext());
1143+
getOperation().getContext());
11411144
GreedyRewriteConfig config;
1142-
(void)applyPatternsAndFoldGreedily(getFunction().getOperation(),
1143-
std::move(rpl), config);
1145+
(void)applyPatternsAndFoldGreedily(getOperation(), std::move(rpl), config);
11441146
}
11451147

11461148
std::unique_ptr<OperationPass<FuncOp>> mlir::polygeist::replaceAffineCFGPass() {

lib/polygeist/Passes/AffineReduction.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ using namespace polygeist;
1313

1414
namespace {
1515
struct AffineReductionPass : public AffineReductionBase<AffineReductionPass> {
16-
void runOnFunction() override;
16+
void runOnOperation() override;
1717
};
1818
} // end namespace.
1919

@@ -254,12 +254,11 @@ struct AffineForReductionIter : public OpRewritePattern<AffineForOp> {
254254

255255
} // end namespace.
256256

257-
void AffineReductionPass::runOnFunction() {
258-
mlir::RewritePatternSet rpl(getFunction().getContext());
259-
rpl.add<AffineForReductionIter>(getFunction().getContext());
257+
void AffineReductionPass::runOnOperation() {
258+
mlir::RewritePatternSet rpl(getOperation().getContext());
259+
rpl.add<AffineForReductionIter>(getOperation().getContext());
260260
GreedyRewriteConfig config;
261-
(void)applyPatternsAndFoldGreedily(getFunction().getOperation(),
262-
std::move(rpl), config);
261+
(void)applyPatternsAndFoldGreedily(getOperation(), std::move(rpl), config);
263262
}
264263

265264
namespace mlir {

lib/polygeist/Passes/BarrierRemovalContinuation.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313

1414
#include "PassDetails.h"
1515

16-
#include "mlir/Conversion/SCFToStandard/SCFToStandard.h"
16+
#include "mlir/Conversion/SCFToControlFlow/SCFToControlFlow.h"
17+
#include "mlir/Dialect/Arithmetic/IR/Arithmetic.h"
18+
#include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.h"
1719
#include "mlir/Dialect/MemRef/IR/MemRef.h"
1820
#include "mlir/Dialect/SCF/Passes.h"
1921
#include "mlir/Dialect/SCF/SCF.h"
@@ -27,7 +29,6 @@
2729
#include "mlir/Transforms/DialectConversion.h"
2830
#include "polygeist/BarrierUtils.h"
2931
#include "polygeist/Passes/Passes.h"
30-
#include <mlir/Dialect/Arithmetic/IR/Arithmetic.h>
3132

3233
using namespace mlir;
3334
using namespace mlir::arith;
@@ -72,7 +73,7 @@ static void wrapPersistingLoopBodies(FuncOp function) {
7273
/// Convert SCF constructs except parallel ops with immediate barriers to a CFG.
7374
static LogicalResult applyCFGConversion(FuncOp function) {
7475
RewritePatternSet patterns(function.getContext());
75-
populateLoopToStdConversionPatterns(patterns);
76+
populateSCFToControlFlowConversionPatterns(patterns);
7677

7778
// Configure the target to preserve parallel ops with barriers, unless those
7879
// barriers are nested in deeper parallel ops.
@@ -104,7 +105,7 @@ static void splitBlocksWithBarrier(Region &region) {
104105
Block *original = op->getBlock();
105106
Block *block = original->splitBlock(op->getNextNode());
106107
auto builder = OpBuilder::atBlockEnd(original);
107-
builder.create<BranchOp>(builder.getUnknownLoc(), block);
108+
builder.create<cf::BranchOp>(builder.getUnknownLoc(), block);
108109
}
109110
}
110111

@@ -225,8 +226,8 @@ replicateIntoRegion(Region &region, Value storage, ValueRange ivs,
225226

226227
// Branch from the entry block to the first cloned block.
227228
builder.setInsertionPointToEnd(entryBlock);
228-
builder.create<BranchOp>(builder.getUnknownLoc(),
229-
mapping.lookup(blocks.front()));
229+
builder.create<cf::BranchOp>(builder.getUnknownLoc(),
230+
mapping.lookup(blocks.front()));
230231

231232
// Now that the block structure is created, clone the operations and introduce
232233
// the flow between continuations.
@@ -244,7 +245,7 @@ replicateIntoRegion(Region &region, Value storage, ValueRange ivs,
244245
// blocks are assumed to branch to the entry block of another subgraph.
245246
// They are replaced with storing the correspnding continuation ID and a
246247
// yield.
247-
if (auto branch = dyn_cast<BranchOp>(&op)) {
248+
if (auto branch = dyn_cast<cf::BranchOp>(&op)) {
248249
// if (!blocks.contains(branch.dest())) {
249250
if (isa_and_nonnull<polygeist::BarrierOp>(branch->getPrevNode())) {
250251
auto it = llvm::find(subgraphEntryPoints, branch.getDest());
@@ -603,8 +604,8 @@ static void createContinuations(FuncOp func) {
603604
namespace {
604605
struct BarrierRemoval
605606
: public SCFBarrierRemovalContinuationBase<BarrierRemoval> {
606-
void runOnFunction() override {
607-
auto f = getFunction();
607+
void runOnOperation() override {
608+
FuncOp f = getOperation();
608609
if (failed(convertToCFG(f)))
609610
return;
610611
if (failed(splitBlocksWithBarrier(f)))

0 commit comments

Comments
 (0)