
This PR upstreams the GotoSolver pass. It works by walking the function and matching each label to a goto. If a label is not matched to a goto, it is removed and not lowered.
97 lines
3.8 KiB
TableGen
97 lines
3.8 KiB
TableGen
//===----------------------------------------------------------------------===//
|
|
//
|
|
// 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 CLANG_CIR_DIALECT_PASSES_TD
|
|
#define CLANG_CIR_DIALECT_PASSES_TD
|
|
|
|
include "mlir/Pass/PassBase.td"
|
|
|
|
def CIRCanonicalize : Pass<"cir-canonicalize"> {
|
|
let summary = "Performs CIR canonicalization";
|
|
let description = [{
|
|
Perform canonicalizations on CIR and removes some redundant operations.
|
|
|
|
This pass performs basic cleanup and canonicalization transformations that
|
|
are not intended to affect CIR-to-source fidelity and high-level code
|
|
analysis passes. Example transformations performed in this pass include
|
|
empty scope cleanup, trivial `try` cleanup, redundant branch cleanup, etc.
|
|
Those more "heavyweight" transformations and those transformations that
|
|
could significantly affect CIR-to-source fidelity are performed in the
|
|
`cir-simplify` pass.
|
|
}];
|
|
|
|
let constructor = "mlir::createCIRCanonicalizePass()";
|
|
let dependentDialects = ["cir::CIRDialect"];
|
|
}
|
|
|
|
def CIRSimplify : Pass<"cir-simplify"> {
|
|
let summary = "Performs CIR simplification and code optimization";
|
|
let description = [{
|
|
The pass performs semantics-preserving code simplifications and optimizations
|
|
on CIR while maintaining strict program correctness.
|
|
|
|
Unlike the `cir-canonicalize` pass, these transformations may reduce the IR's
|
|
structural similarity to the original source code as a trade-off for improved
|
|
code quality. This can affect debugging fidelity by altering intermediate
|
|
representations of folded expressions, hoisted operations, and other
|
|
optimized constructs.
|
|
|
|
Example transformations include ternary expression folding and code hoisting
|
|
while preserving program semantics.
|
|
}];
|
|
let constructor = "mlir::createCIRSimplifyPass()";
|
|
let dependentDialects = ["cir::CIRDialect"];
|
|
}
|
|
|
|
def HoistAllocas : Pass<"cir-hoist-allocas"> {
|
|
let summary = "Hoist allocas to the entry of the function";
|
|
let description = [{
|
|
This pass hoist all non-dynamic allocas to the entry of the function.
|
|
This is helpful for later code generation.
|
|
}];
|
|
let constructor = "mlir::createHoistAllocasPass()";
|
|
let dependentDialects = ["cir::CIRDialect"];
|
|
}
|
|
|
|
def CIRFlattenCFG : Pass<"cir-flatten-cfg"> {
|
|
let summary = "Produces flatten CFG";
|
|
let description = [{
|
|
This pass transforms CIR by inlining all the nested regions. Thus,
|
|
the following conditions are true after the pass applied:
|
|
- there are no nested regions in any function body
|
|
- all the blocks in a function belong to the parent region
|
|
In other words, this pass removes such CIR operations like IfOp, LoopOp,
|
|
ScopeOp and etc. and produces a flat CIR.
|
|
}];
|
|
let constructor = "mlir::createCIRFlattenCFGPass()";
|
|
let dependentDialects = ["cir::CIRDialect"];
|
|
}
|
|
|
|
def GotoSolver : Pass<"cir-goto-solver"> {
|
|
let summary = "Replaces goto operations with branches";
|
|
let description = [{
|
|
This pass transforms CIR and replaces goto-s with branch
|
|
operations to the proper blocks.
|
|
}];
|
|
let constructor = "mlir::createGotoSolverPass()";
|
|
let dependentDialects = ["cir::CIRDialect"];
|
|
}
|
|
|
|
def LoweringPrepare : Pass<"cir-lowering-prepare"> {
|
|
let summary = "Lower to more fine-grained CIR operations before lowering to "
|
|
"other dialects";
|
|
let description = [{
|
|
This pass does preparation work for lowering to other dialects. For example,
|
|
it may expand the global variable initialziation in a more ABI-friendly form.
|
|
}];
|
|
let constructor = "mlir::createLoweringPreparePass()";
|
|
let dependentDialects = ["cir::CIRDialect"];
|
|
}
|
|
|
|
#endif // CLANG_CIR_DIALECT_PASSES_TD
|