mirror of https://github.com/llvm/circt.git
[firtool] Move width inference before canonicalization (#1147)
* Move the width inference pass up in the pipeline such that it runs before the canonicalization passes. This is useful since width inference itself does not depend on canonicalization, but in turn enables a lot of canonicalization patterns to run.
This commit is contained in:
parent
abbcaef8dc
commit
e539a7bcfb
|
@ -177,6 +177,16 @@ processBuffer(std::unique_ptr<llvm::MemoryBuffer> ownedBuffer,
|
|||
assert(inputFormat == InputMLIRFile);
|
||||
module = parseSourceFile(sourceMgr, &context);
|
||||
}
|
||||
if (!module)
|
||||
return failure();
|
||||
|
||||
// Allow optimizations to run multithreaded.
|
||||
context.enableMultithreading(isMultithreaded);
|
||||
|
||||
// Width inference creates canonicalization opportunities.
|
||||
if (inferWidths)
|
||||
pm.nest<firrtl::CircuitOp>().addPass(firrtl::createInferWidthsPass());
|
||||
|
||||
// The input mlir file could be firrtl dialect so we might need to clean
|
||||
// things up.
|
||||
if (!disableLowerTypes) {
|
||||
|
@ -186,6 +196,7 @@ processBuffer(std::unique_ptr<llvm::MemoryBuffer> ownedBuffer,
|
|||
if (expandWhens)
|
||||
modulePM.addPass(firrtl::createExpandWhensPass());
|
||||
}
|
||||
|
||||
// If we parsed a FIRRTL file and have optimizations enabled, clean it up.
|
||||
if (!disableOptimization) {
|
||||
auto &modulePM = pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>();
|
||||
|
@ -193,15 +204,6 @@ processBuffer(std::unique_ptr<llvm::MemoryBuffer> ownedBuffer,
|
|||
modulePM.addPass(createSimpleCanonicalizerPass());
|
||||
}
|
||||
|
||||
if (!module)
|
||||
return failure();
|
||||
|
||||
// Allow optimizations to run multithreaded.
|
||||
context.enableMultithreading(isMultithreaded);
|
||||
|
||||
if (inferWidths)
|
||||
pm.nest<firrtl::CircuitOp>().addPass(firrtl::createInferWidthsPass());
|
||||
|
||||
if (inliner)
|
||||
pm.nest<firrtl::CircuitOp>().addPass(firrtl::createInlinerPass());
|
||||
|
||||
|
|
Loading…
Reference in New Issue