summaryrefslogtreecommitdiffstats
path: root/mlir/lib/Transforms/SimplifyAffineStructures.cpp
diff options
context:
space:
mode:
authorRiver Riddle <riverriddle@google.com>2019-01-28 21:23:53 -0800
committerjpienaar <jpienaar@google.com>2019-03-29 15:59:30 -0700
commit755538328b0651661323bee33cf18b4ea76ee92a (patch)
treeb4cd47428968e0c9c7684671bfae757582ddd3d3 /mlir/lib/Transforms/SimplifyAffineStructures.cpp
parent39d81f246a556ef02a26ee239cb097f6d1aec64a (diff)
downloadbcm5719-llvm-755538328b0651661323bee33cf18b4ea76ee92a.tar.gz
bcm5719-llvm-755538328b0651661323bee33cf18b4ea76ee92a.zip
Recommit: Define a AffineOps dialect as well as an AffineIfOp operation. Replace all instances of IfInst with AffineIfOp and delete IfInst.
PiperOrigin-RevId: 231342063
Diffstat (limited to 'mlir/lib/Transforms/SimplifyAffineStructures.cpp')
-rw-r--r--mlir/lib/Transforms/SimplifyAffineStructures.cpp37
1 files changed, 12 insertions, 25 deletions
diff --git a/mlir/lib/Transforms/SimplifyAffineStructures.cpp b/mlir/lib/Transforms/SimplifyAffineStructures.cpp
index bd39e47786a..ba59123c700 100644
--- a/mlir/lib/Transforms/SimplifyAffineStructures.cpp
+++ b/mlir/lib/Transforms/SimplifyAffineStructures.cpp
@@ -28,7 +28,6 @@
#define DEBUG_TYPE "simplify-affine-structure"
using namespace mlir;
-using llvm::report_fatal_error;
namespace {
@@ -42,9 +41,6 @@ struct SimplifyAffineStructures : public FunctionPass {
PassResult runOnFunction(Function *f) override;
- void visitIfInst(IfInst *ifInst);
- void visitOperationInst(OperationInst *opInst);
-
static char passID;
};
@@ -66,28 +62,19 @@ static IntegerSet simplifyIntegerSet(IntegerSet set) {
return set;
}
-void SimplifyAffineStructures::visitIfInst(IfInst *ifInst) {
- auto set = ifInst->getCondition().getIntegerSet();
- ifInst->setIntegerSet(simplifyIntegerSet(set));
-}
-
-void SimplifyAffineStructures::visitOperationInst(OperationInst *opInst) {
- for (auto attr : opInst->getAttrs()) {
- if (auto mapAttr = attr.second.dyn_cast<AffineMapAttr>()) {
- MutableAffineMap mMap(mapAttr.getValue());
- mMap.simplify();
- auto map = mMap.getAffineMap();
- opInst->setAttr(attr.first, AffineMapAttr::get(map));
- }
- }
-}
-
PassResult SimplifyAffineStructures::runOnFunction(Function *f) {
- f->walkInsts([&](Instruction *inst) {
- if (auto *opInst = dyn_cast<OperationInst>(inst))
- visitOperationInst(opInst);
- if (auto *ifInst = dyn_cast<IfInst>(inst))
- visitIfInst(ifInst);
+ f->walkOps([&](OperationInst *opInst) {
+ for (auto attr : opInst->getAttrs()) {
+ if (auto mapAttr = attr.second.dyn_cast<AffineMapAttr>()) {
+ MutableAffineMap mMap(mapAttr.getValue());
+ mMap.simplify();
+ auto map = mMap.getAffineMap();
+ opInst->setAttr(attr.first, AffineMapAttr::get(map));
+ } else if (auto setAttr = attr.second.dyn_cast<IntegerSetAttr>()) {
+ auto simplified = simplifyIntegerSet(setAttr.getValue());
+ opInst->setAttr(attr.first, IntegerSetAttr::get(simplified));
+ }
+ }
});
return success();
OpenPOWER on IntegriCloud