Deduplicate constant folding logic in ConstantFold and GreedyPatternRewriteDriver
authorLei Zhang <antiagainst@google.com>
Thu, 4 Apr 2019 18:40:57 +0000 (11:40 -0700)
committerMehdi Amini <joker.eph@gmail.com>
Fri, 5 Apr 2019 14:41:32 +0000 (07:41 -0700)
commit4e40c8329151755bf7374951f6812126434a96ed
treee6cf9af8c136d2a0a61f49bed0345981d973a299
parent6fa3181329eeab7e0b5d5ac8df9d6456da1b9c4e
Deduplicate constant folding logic in ConstantFold and GreedyPatternRewriteDriver

    There are two places containing constant folding logic right now: the ConstantFold
    pass and the GreedyPatternRewriteDriver. The logic was not shared and started to
    drift apart. We were testing constant folding logic using the ConstantFold pass,
    but lagged behind the GreedyPatternRewriteDriver, where we really want the constant
    folding to happen.

    This CL pulled the logic into utility functions and classes for sharing between
    these two places. A new ConstantFoldHelper class is created to help constant fold
    and de-duplication.

    Also, renamed the ConstantFold pass to TestConstantFold to make it clear that it is
    intended for testing purpose.

--

PiperOrigin-RevId: 241971681
mlir/include/mlir/IR/Matchers.h
mlir/include/mlir/Transforms/ConstantFoldUtils.h [new file with mode: 0644]
mlir/include/mlir/Transforms/Passes.h
mlir/lib/ExecutionEngine/ExecutionEngine.cpp
mlir/lib/Transforms/ConstantFold.cpp [deleted file]
mlir/lib/Transforms/TestConstantFold.cpp [new file with mode: 0644]
mlir/lib/Transforms/Utils/ConstantFoldUtils.cpp [new file with mode: 0644]
mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp
mlir/test/Transforms/constant-fold.mlir