forked from EPFL-LAP/dynamatic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRemovePolygeistAttributes.cpp
47 lines (39 loc) · 1.58 KB
/
RemovePolygeistAttributes.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//===- RemovePolygeistAttributes.h - Remove useless attrs -------*- C++ -*-===//
//
// Dynamatic is under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// Removes a couple top-level module and function attributes set by Polygeist
// and which we do not care about.
//
//===----------------------------------------------------------------------===//
#include "dynamatic/Transforms/RemovePolygeistAttributes.h"
#include "dynamatic/Dialect/Handshake/HandshakeOps.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/IR/Attributes.h"
using namespace mlir;
namespace {
/// Simple driver for the pass that removes attributes set by Polygeist.
struct RemovePolygeistAttributesPass
: public dynamatic::impl::RemovePolygeistAttributesBase<
RemovePolygeistAttributesPass> {
void runDynamaticPass() override {
// Remove all attributes from the top-level module
mlir::ModuleOp modOp = getOperation();
for (NamedAttribute attr :
llvm::make_early_inc_range(modOp->getAttrDictionary()))
modOp->removeAttr(attr.getName());
for (func::FuncOp funcOp : modOp.getOps<func::FuncOp>()) {
// Remove the llvm.linkage attribute from functions
funcOp->removeAttr("llvm.linkage");
}
};
};
} // namespace
std::unique_ptr<dynamatic::DynamaticPass>
dynamatic::createRemovePolygeistAttributes() {
return std::make_unique<RemovePolygeistAttributesPass>();
}