Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
3897342
setup the normalize pass
Sh0g0-1758 Sep 20, 2025
5aa301b
reorder instructions
Sh0g0-1758 Sep 24, 2025
dda4e0b
rename op results
Sh0g0-1758 Oct 4, 2025
fe9a6fa
naming scheme
Sh0g0-1758 Oct 4, 2025
1a8ef2f
initial and regular operand renaming
Sh0g0-1758 Oct 4, 2025
48aa67b
rename without folding with hashing
Sh0g0-1758 Oct 4, 2025
8a9efd1
operation folding
Sh0g0-1758 Oct 7, 2025
c94e6e6
nit
Sh0g0-1758 Oct 7, 2025
dab3957
Merge branch 'llvm:main' into mlir-canon
Sh0g0-1758 Oct 7, 2025
8c487ff
operand reordering in alphabetical order
Sh0g0-1758 Oct 7, 2025
9c0e866
refactor impl
Sh0g0-1758 Oct 10, 2025
0836dad
clang-format
Sh0g0-1758 Oct 10, 2025
ad15039
linux build fix
Sh0g0-1758 Oct 10, 2025
1256ff1
add reordering test
Sh0g0-1758 Oct 10, 2025
89218e9
add infinite loop test and fix block/func arg naming
Sh0g0-1758 Oct 10, 2025
f4d0c63
rename constants when used in an initial instruction
Sh0g0-1758 Oct 10, 2025
9ed096d
refactor repeated logic into foldOperations
Sh0g0-1758 Oct 10, 2025
bbbfe21
clang-format
Sh0g0-1758 Oct 10, 2025
22cdd91
fix infinite-loop test
Sh0g0-1758 Oct 10, 2025
76df868
nit
Sh0g0-1758 Oct 10, 2025
8387f1c
nit
Sh0g0-1758 Oct 10, 2025
1823295
test rename
Sh0g0-1758 Oct 10, 2025
7b590b0
adding usedef chain test
anant37289 Oct 10, 2025
9f86026
nit
Sh0g0-1758 Oct 17, 2025
2313810
add docs
Sh0g0-1758 Oct 17, 2025
57c0292
camelCase
Sh0g0-1758 Oct 19, 2025
9d8b682
fix redundant includes and namespacing
Sh0g0-1758 Oct 28, 2025
319bcae
nit
Sh0g0-1758 Oct 28, 2025
137f96c
nit
Sh0g0-1758 Oct 28, 2025
9049f11
nit
Sh0g0-1758 Oct 28, 2025
759e798
nit
Sh0g0-1758 Oct 28, 2025
4cfc8eb
nit
Sh0g0-1758 Oct 28, 2025
f663b14
early break
Sh0g0-1758 Oct 28, 2025
195f88e
use std::distance
Sh0g0-1758 Oct 28, 2025
ac6ce80
walk the module
Sh0g0-1758 Oct 28, 2025
d137381
Add side-effect testcases
anant37289 Oct 28, 2025
c9a742b
Merge branch 'main' into mlir-canon
Sh0g0-1758 Oct 29, 2025
bb41dc4
modify infinite-loop test into 2 variants with tree-like dependencies…
Sh0g0-1758 Oct 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions mlir/include/mlir/Conversion/Normalize/Normalize.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//===- Normalize.h - Conversion from MLIR to its canonical form -*- 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
//
//===----------------------------------------------------------------------===//

#ifndef MLIR_CONVERSION_NORMALIZE_NORMALIZE_H
#define MLIR_CONVERSION_NORMALIZE_NORMALIZE_H

#include <memory>

namespace mlir {
class Pass;

#define GEN_PASS_DECL_NORMALIZE
#include "mlir/Conversion/Passes.h.inc"

} // namespace mlir

#endif // MLIR_CONVERSION_NORMALIZE_NORMALIZE_H
1 change: 1 addition & 0 deletions mlir/include/mlir/Conversion/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#include "mlir/Conversion/MemRefToSPIRV/MemRefToSPIRVPass.h"
#include "mlir/Conversion/NVGPUToNVVM/NVGPUToNVVM.h"
#include "mlir/Conversion/NVVMToLLVM/NVVMToLLVM.h"
#include "mlir/Conversion/Normalize/Normalize.h"
#include "mlir/Conversion/OpenACCToSCF/ConvertOpenACCToSCF.h"
#include "mlir/Conversion/OpenMPToLLVM/ConvertOpenMPToLLVM.h"
#include "mlir/Conversion/PDLToPDLInterp/PDLToPDLInterp.h"
Expand Down
13 changes: 13 additions & 0 deletions mlir/include/mlir/Conversion/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,19 @@ def ConvertShardToMPIPass : Pass<"convert-shard-to-mpi"> {
];
}

//===----------------------------------------------------------------------===//
// Normalize
//===----------------------------------------------------------------------===//
def Normalize : Pass<"normalize", "ModuleOp"> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it required to be a ModuleOp pass? Does it need to be at symbol table scope?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well we do need the top-level module operation to collect all the output operations and thus reorder/rename regular/initial operations if they have not been visited earlier by another output operation using them.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite follow this. I may be missing what you are saying as I think this is true and could work even for functions/doesn't even need to be on top-level ops. But it does need to (correct me if I'm wrong) run sequentially due to rng update ordering.

let summary = "Convert MLIR input to its normalized form";
let description = [{
This pass aims to transform MLIR inputs into a normal form by reordering
and renaming instructions while preserving the same semantics. The pass
makes it easier to spot semantic differences while diffing two modules
which have undergone different passes.
}];
}

//===----------------------------------------------------------------------===//
// NVVMToLLVM
//===----------------------------------------------------------------------===//
Expand Down
1 change: 1 addition & 0 deletions mlir/lib/Conversion/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ add_subdirectory(MemRefToLLVM)
add_subdirectory(MemRefToSPIRV)
add_subdirectory(ShardToMPI)
add_subdirectory(MPIToLLVM)
add_subdirectory(Normalize)
add_subdirectory(NVGPUToNVVM)
add_subdirectory(NVVMToLLVM)
add_subdirectory(OpenACCToSCF)
Expand Down
24 changes: 24 additions & 0 deletions mlir/lib/Conversion/Normalize/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
add_mlir_conversion_library(MLIRNormalize
Normalize.cpp

ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/Conversion/Normalize

DEPENDS
MLIRConversionPassIncGen

LINK_COMPONENTS
Core

LINK_LIBS PUBLIC
MLIRArithDialect
MLIRControlFlowDialect
MLIRFuncDialect
MLIRLLVMDialect
MLIRMathDialect
MLIRPass
MLIRSCFDialect
MLIRTransforms
MLIRVectorDialect
MLIRVectorUtils
)
Loading