Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mlir][MemRef] Add patterns to extract address computations
This patch adds patterns to rewrite memory accesses such that the resulting accesses are only using a base pointer. E.g., ```mlir memref.load %base[%off0, ...] ``` Will be rewritten in: ```mlir %new_base = memref.subview %base[%off0,...][1,...][1,...] memref.load %new_base[%c0,...] ``` The idea behind these patterns is to offer a way to more gradually lower address computations. These patterns are the exact opposite of FoldMemRefAliasOps. I've implemented the support of only five operations in this patch: - memref.load - memref.store - nvgpu.ldmatrix - vector.transfer_read - vector.transfer_write Going forward we may want to provide an interface for these rewritings (and the ones in FoldMemRefAliasOps.) One step at a time! Differential Revision: https://reviews.llvm.org/D146724
- Loading branch information
Showing
8 changed files
with
830 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
//===- Transforms.h - MemRef Dialect transformations ------------*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
/// This header declares functions that assit transformations in the MemRef | ||
/// dialect. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef MLIR_DIALECT_MEMREF_TRANSFORMS_TRANSFORMS_H | ||
#define MLIR_DIALECT_MEMREF_TRANSFORMS_TRANSFORMS_H | ||
|
||
namespace mlir { | ||
class RewritePatternSet; | ||
|
||
namespace memref { | ||
/// Appends patterns for extracting address computations from the instructions | ||
/// with memory accesses such that these memory accesses use only a base | ||
/// pointer. | ||
/// | ||
/// For instance, | ||
/// ```mlir | ||
/// memref.load %base[%off0, ...] | ||
/// ``` | ||
/// | ||
/// Will be rewritten in: | ||
/// ```mlir | ||
/// %new_base = memref.subview %base[%off0,...][1,...][1,...] | ||
/// memref.load %new_base[%c0,...] | ||
/// ``` | ||
void populateExtractAddressComputationsPatterns(RewritePatternSet &patterns); | ||
|
||
} // namespace memref | ||
} // namespace mlir | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.