[Mlir-commits] [mlir] Reimplementing target description concept using DLTI Attributes (PR #91670)
Niranjan Hasabnis
llvmlistbot at llvm.org
Fri May 10 07:53:04 PDT 2024
================
@@ -59,6 +75,41 @@ struct Canonicalizer : public impl::CanonicalizerBase<Canonicalizer> {
return success();
}
void runOnOperation() override {
+ Operation *op = getOperation();
+ uint32_t cpuID = 0;
+
+ if (isa<ModuleOp>(op)) {
+ if (std::optional<int64_t> v =
+ DataLayout(llvm::dyn_cast<ModuleOp>(*op))
+ .getCanonicalizerMaxIterations(cpuID)) {
+ config.maxIterations = *v;
+ }
+ } else {
+ ModuleOp moduleOp = op->getParentOfType<ModuleOp>();
+ if (std::optional<int64_t> v =
+ DataLayout(moduleOp).getCanonicalizerMaxIterations(cpuID)) {
+ config.maxIterations = *v;
+ }
+ }
+
+ if (isa<ModuleOp>(op)) {
+ if (std::optional<int64_t> v =
+ DataLayout(llvm::dyn_cast<ModuleOp>(*op))
+ .getCanonicalizerMaxNumRewrites(cpuID)) {
+ config.maxNumRewrites = *v;
+ }
+ } else {
+ ModuleOp moduleOp = op->getParentOfType<ModuleOp>();
+ if (std::optional<int64_t> v =
+ DataLayout(moduleOp).getCanonicalizerMaxNumRewrites(cpuID)) {
+ config.maxNumRewrites = *v;
+ }
+ }
+ LLVM_DEBUG(llvm::dbgs() << "[CostModel] Canonicalizer MaxIterations (new):"
+ << config.maxIterations << "\n");
+ LLVM_DEBUG(llvm::dbgs() << "[CostModel] Canonicalizer MaxNumRewrites (new):"
+ << config.maxNumRewrites << "\n");
----------------
nhasabni wrote:
This was just for demo purpose. I wanted to demo the infra that I am building using some hardcoded constants - hence chose these. Exactly which properties of target devices to capture looks a separate topic to me. BTW, I've shown other example of a device property in this PR also.
https://github.com/llvm/llvm-project/pull/91670
More information about the Mlir-commits
mailing list