49
49
#define DEBUG_TYPE " air-to-aie"
50
50
51
51
using namespace mlir ;
52
- using namespace xilinx ;
53
52
54
- namespace {
53
+ // namespace {
54
+ namespace xilinx {
55
+ namespace air {
55
56
56
57
struct AIRToAIEConversionOptions {
57
58
int64_t col_offset;
@@ -166,7 +167,7 @@ AIE::BufferOp allocateBufferOp(uint64_t &BufferId, MemRefType memrefTy,
166
167
}
167
168
168
169
void outlineAIECores (OpBuilder &builder, AIE::DeviceOp aie_device,
169
- xilinx:: air::HerdOp h,
170
+ air::HerdOp h,
170
171
std::map<AIE::TileOp, air::HerdOp> &tileToHerdMap,
171
172
AIRToAIEConversionOptions &options) {
172
173
builder.setInsertionPointToStart (aie_device.getBody ());
@@ -184,8 +185,8 @@ void outlineAIECores(OpBuilder &builder, AIE::DeviceOp aie_device,
184
185
// use the command line offsets unless the attribute is present
185
186
int64_t col_offset = options.col_offset ;
186
187
int64_t row_offset = options.row_offset ;
187
- auto col_name = xilinx:: air::HerdOp::getColOffsetAttrName ();
188
- auto row_name = xilinx:: air::HerdOp::getRowOffsetAttrName ();
188
+ auto col_name = air::HerdOp::getColOffsetAttrName ();
189
+ auto row_name = air::HerdOp::getRowOffsetAttrName ();
189
190
auto ctx = h->getContext ();
190
191
if (auto co = h.getColOffset ())
191
192
col_offset = *co;
@@ -444,7 +445,7 @@ std::vector<AIE::TileOp> getMemtilesFromDeviceOp(AIE::DeviceOp d) {
444
445
}
445
446
446
447
void outlineAIEMemtiles (OpBuilder &builder, AIE::DeviceOp aie_device,
447
- xilinx:: air::SegmentOp seg,
448
+ air::SegmentOp seg,
448
449
AIRToAIEConversionOptions &options) {
449
450
builder.setInsertionPointToStart (aie_device.getBody ());
450
451
@@ -490,15 +491,15 @@ void push_back_if_unique(std::vector<T> &vec, T entry) {
490
491
491
492
void createAIEModulesAndOutlineCores (
492
493
ModuleOp module ,
493
- std::vector<std::pair<AIE::DeviceOp, xilinx:: air::HerdOp>> &aie_modules,
494
+ std::vector<std::pair<AIE::DeviceOp, air::HerdOp>> &aie_modules,
494
495
std::map<AIE::TileOp, air::HerdOp> &tileToHerdMap,
495
496
AIRToAIEConversionOptions &options) {
496
497
497
498
SmallVector<air::SegmentOp> segments;
498
499
SmallVector<air::HerdOp> herds;
499
- module .walk ([&](xilinx:: air::SegmentOp s) { segments.push_back (s); });
500
- module .walk ([&](xilinx:: air::HerdOp h) {
501
- if (h->getParentOfType <xilinx:: air::SegmentOp>())
500
+ module .walk ([&](air::SegmentOp s) { segments.push_back (s); });
501
+ module .walk ([&](air::HerdOp h) {
502
+ if (h->getParentOfType <air::SegmentOp>())
502
503
return ;
503
504
herds.push_back (h);
504
505
});
@@ -519,9 +520,7 @@ void createAIEModulesAndOutlineCores(
519
520
StringAttr::get (builder.getContext (), segment_name));
520
521
AIE::DeviceOp::ensureTerminator (aie_dev.getRegion (), builder,
521
522
aie_dev.getLoc ());
522
- seg.walk ([&](xilinx::air::HerdOp h) {
523
- aie_modules.push_back ({aie_dev, h});
524
- });
523
+ seg.walk ([&](air::HerdOp h) { aie_modules.push_back ({aie_dev, h}); });
525
524
// If the device has memtiles, then outline memtiles
526
525
if (aie_dev.getTargetModel ().getNumMemTileRows ()) {
527
526
outlineAIEMemtiles (builder, aie_dev, seg, options);
@@ -762,7 +761,7 @@ struct LowerScfTokenPattern : public OpRewritePattern<scf::ForOp> {
762
761
Value v =
763
762
fop.getOperand (block_arg.getArgNumber () - fop.getNumInductionVars () +
764
763
fop.getNumControlOperands ());
765
- if (llvm::isa<xilinx:: air::AsyncTokenType>(v.getType ())) {
764
+ if (llvm::isa<air::AsyncTokenType>(v.getType ())) {
766
765
block_arg.replaceAllUsesWith (v);
767
766
iter_args_idx.set (block_arg.getArgNumber ());
768
767
} else {
@@ -795,12 +794,11 @@ struct LowerScfTokenPattern : public OpRewritePattern<scf::ForOp> {
795
794
// use the new for op's results
796
795
int idx = 0 ;
797
796
for (auto r : fop.getResults ()) {
798
- if (llvm::isa<xilinx:: air::AsyncTokenType>(r.getType ()))
797
+ if (llvm::isa<air::AsyncTokenType>(r.getType ()))
799
798
r.replaceAllUsesWith (
800
799
rewriter
801
- .create <xilinx::air::WaitAllOp>(
802
- fop->getLoc (),
803
- xilinx::air::AsyncTokenType::get (fop->getContext ()),
800
+ .create <air::WaitAllOp>(
801
+ fop->getLoc (), air::AsyncTokenType::get (fop->getContext ()),
804
802
SmallVector<Value, 1 >{})
805
803
.getResult (0 ));
806
804
else
@@ -813,13 +811,13 @@ struct LowerScfTokenPattern : public OpRewritePattern<scf::ForOp> {
813
811
SmallVector<Value, 4 > yield_operands;
814
812
SmallVector<Value, 4 > token_operands;
815
813
for (auto o : yield->getOperands ()) {
816
- if (llvm::isa<xilinx:: air::AsyncTokenType>(o.getType ()))
814
+ if (llvm::isa<air::AsyncTokenType>(o.getType ()))
817
815
token_operands.push_back (o);
818
816
else
819
817
yield_operands.push_back (o);
820
818
}
821
- rewriter.create <xilinx:: air::WaitAllOp>(
822
- fop-> getLoc (), SmallVector<Type, 1 >{}, token_operands);
819
+ rewriter.create <air::WaitAllOp>(fop-> getLoc (), SmallVector<Type, 1 >{},
820
+ token_operands);
823
821
rewriter.create <scf::YieldOp>(yield->getLoc (), yield_operands);
824
822
rewriter.eraseOp (yield);
825
823
@@ -1669,12 +1667,11 @@ class AIRToAIEPass : public air::impl::AIRToAIEBase<AIRToAIEPass> {
1669
1667
public:
1670
1668
AIRToAIEPass () = default ;
1671
1669
AIRToAIEPass (const AIRToAIEPass &pass) {}
1672
- AIRToAIEPass (const ::xilinx::air::AIRToAIEOptions &options)
1673
- : AIRToAIEBase(options) {}
1670
+ AIRToAIEPass (const air::AIRToAIEOptions &options) : AIRToAIEBase(options) {}
1674
1671
1675
1672
void getDependentDialects (::mlir::DialectRegistry ®istry) const override {
1676
- registry.insert <xilinx:: air::airDialect>();
1677
- registry.insert <xilinx:: airrt::AIRRtDialect>();
1673
+ registry.insert <air::airDialect>();
1674
+ registry.insert <airrt::AIRRtDialect>();
1678
1675
registry.insert <xilinx::AIE::AIEDialect>();
1679
1676
registry.insert <xilinx::AIEX::AIEXDialect>();
1680
1677
registry.insert <LLVM::LLVMDialect>();
@@ -1890,8 +1887,7 @@ class AIRToAIEPass : public air::impl::AIRToAIEBase<AIRToAIEPass> {
1890
1887
1891
1888
// Unroll scf.parallel
1892
1889
RewritePatternSet patterns (ctx);
1893
- xilinx::air::populateAIRunrollAIRChannelPutGetInScfParallelPatterns (
1894
- patterns);
1890
+ air::populateAIRunrollAIRChannelPutGetInScfParallelPatterns (patterns);
1895
1891
(void )applyPatternsGreedily (aie_device, std::move (patterns));
1896
1892
1897
1893
// Substituting index operands, such as strides and offsets, to constant
@@ -3399,10 +3395,10 @@ class AIRToAIEPass : public air::impl::AIRToAIEBase<AIRToAIEPass> {
3399
3395
std::vector<Operation *> memcpy_ops;
3400
3396
getAIRMemcpyOpInRegion<T>(device.getRegion (), memcpy_ops);
3401
3397
for (auto o : memcpy_ops) {
3402
- auto a = dyn_cast<xilinx:: air::AsyncOpInterface>(o);
3398
+ auto a = dyn_cast<air::AsyncOpInterface>(o);
3403
3399
if (a && a.getAsyncToken ()) {
3404
3400
OpBuilder b (o);
3405
- o->replaceAllUsesWith (b.create <xilinx:: air::WaitAllOp>(
3401
+ o->replaceAllUsesWith (b.create <air::WaitAllOp>(
3406
3402
o->getLoc (), air::AsyncTokenType::get (o->getContext ()),
3407
3403
a.getAsyncDependencies ()));
3408
3404
}
@@ -3586,7 +3582,7 @@ class AIRToAIEPass : public air::impl::AIRToAIEBase<AIRToAIEPass> {
3586
3582
std::set<AIE::DeviceOp> seen;
3587
3583
for (auto &p : aie_devices) {
3588
3584
auto device = std::get<0 >(p);
3589
- xilinx:: air::HerdOp h = std::get<1 >(p);
3585
+ air::HerdOp h = std::get<1 >(p);
3590
3586
auto ctx = device->getContext ();
3591
3587
3592
3588
if (seen.find (device) != seen.end ())
@@ -3839,7 +3835,7 @@ class SplitAIEDevicesPass
3839
3835
removepatterns.add <OpRemovalPattern<airrt::ModuleMetadataOp>>(ctx);
3840
3836
3841
3837
ConversionTarget target (*ctx);
3842
- target.addIllegalDialect <xilinx:: airrt::AIRRtDialect>();
3838
+ target.addIllegalDialect <airrt::AIRRtDialect>();
3843
3839
if (failed (applyPartialConversion (aie_module, target,
3844
3840
std::move (removepatterns))))
3845
3841
signalPassFailure ();
@@ -3958,7 +3954,8 @@ void AIRLinalgToFuncPass::runOnOperation() {
3958
3954
signalPassFailure ();
3959
3955
}
3960
3956
3961
- } // namespace
3957
+ } // namespace air
3958
+ } // namespace xilinx
3962
3959
3963
3960
namespace xilinx {
3964
3961
namespace air {
@@ -3988,14 +3985,12 @@ FailureOr<ModuleOp> convertAIRToAIE(mlir::RewriterBase &rewriter,
3988
3985
/* .trace_size = */ 0 ,
3989
3986
/* .ctrl_packet = */ false ,
3990
3987
/* .device = */ *device};
3991
- std::vector<std::pair<ModuleOp, xilinx::air::HerdOp>> aie_modules;
3992
- p.walk ([&](xilinx::air::HerdOp h) {
3993
- aie_modules.push_back ({aie_module, h});
3994
- });
3988
+ std::vector<std::pair<ModuleOp, air::HerdOp>> aie_modules;
3989
+ p.walk ([&](air::HerdOp h) { aie_modules.push_back ({aie_module, h}); });
3995
3990
std::map<AIE::TileOp, air::HerdOp> tileToHerdMap;
3996
3991
for (auto &p : aie_modules) {
3997
3992
ModuleOp aie_module = std::get<0 >(p);
3998
- xilinx:: air::HerdOp h = std::get<1 >(p);
3993
+ air::HerdOp h = std::get<1 >(p);
3999
3994
rewriter.setInsertionPointToStart (aie_module.getBody ());
4000
3995
auto devOp = rewriter.create <AIE::DeviceOp>(
4001
3996
aie_module.getLoc (),
0 commit comments