Enabling Top Down Traversal


I am trying to change the traversal order of operations from default bottom up to top down.

As per the information available, this can be done by defining an object of GreedyRewriteConfig class and setting the “useTopDownTraversal” bool variable to true as shown below:

// Use TopDownTraversal for compile time reasons
GreedyRewriteConfig grc;
grc.useTopDownTraversal = true;

However, I am getting below error on using the above steps

error: unknown type name 'GreedyRewriteConfig'

I am not even able to locate the GreedyRewriteConfig class in mlir code base.
Am I missing anything in my code base?

Request you to please guide how the top down traversal can be enabled.

Thanks and Regards


1 Like

Should be defined in here: llvm-project/GreedyPatternRewriteDriver.h at da1cac7d19c4f3f2dcc27083dc3b28d171610508 · llvm/llvm-project · GitHub

Are you including that file?

The canonicalizer pass is a simple example usage if that helps: llvm-project/Canonicalizer.cpp at main · llvm/llvm-project · GitHub

– River

Thank you for your prompt response.

I am surprised as the GreedyRewriteConfig class declaration is missing in my local copy of “GreedyPatternRewriteDriver.h”. Will try to update my code base and check again.


In general this indicates that you’re reading docs on the website, but not using the HEAD of the repo and a previous release instead.

edit: seems like our messages crossed, updating your codebase should help! Let us know if you have any other issues :slight_smile:

Sure, thank you :slight_smile: