[llvm] Use DIExpression::foldConstantMath at the result of a Salvaged expression (PR #71721)

Adrian Prantl via llvm-commits llvm-commits at lists.llvm.org
Wed May 22 17:40:25 PDT 2024


adrian-prantl wrote:

To summarize an offline conversation I had with @rastogishubham — I think hardcoding the rules like this is a great starting point.

Going forward (i.e., _after_ this patch) I would like to see us at least explore if we can write the rules in a declarative form where they are compiled into function (similar to the rule bodies right now) and some sort of type signature that conceptually consists of the parameters each rules consumes (e.g.: `uconst, uconst, operator`) and a rewrite system that abstracts the the input DIExpression into its type signature and then matches the rules accordingly, so we don't need to hardcode the application in foldConstantMath(). So for example, the rules themselves could be stored in a tree where the edges are types and the rules are stored in the nodes:
```
          []
  const  / \ op
        []  ...
 const / 
      []
       \ op
       []  all rules that consume const,const,op
 ```
Maybe that tree can be stored in linear fashion and even produced at compile time by tablegen? Maybe this is also over-engineering the problem ;-)

https://github.com/llvm/llvm-project/pull/71721


More information about the llvm-commits mailing list