Skip to content

[CIR][WIP] Add ABI lowering pass #1471

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions clang/include/clang/CIR/Dialect/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ std::unique_ptr<Pass> createFlattenCFGPass();
std::unique_ptr<Pass> createHoistAllocasPass();
std::unique_ptr<Pass> createGotoSolverPass();

/// Create a pass to expand ABI-dependent types and operations.
std::unique_ptr<Pass> createABILoweringPass();

/// Create a pass to lower ABI-independent function definitions/calls.
std::unique_ptr<Pass> createCallConvLoweringPass();

Expand Down
21 changes: 21 additions & 0 deletions clang/include/clang/CIR/Dialect/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,27 @@ def LibOpt : Pass<"cir-lib-opt"> {
];
}

def ABILowering : Pass<"cir-abi-lowering"> {
let summary = "Expands ABI-dependent types and operations";
let description = [{
This pass expands ABI-dependent CIR types and operations to more "primitive"
ABI-independent CIR types and operations according to the target ABI
specification.

Some CIR types, such as pointers to members, may have different layouts and
representations under different target ABIs. This pass expands these types
to their underlying representations as specified by the target ABI. For
example, when targeting Itanium ABI, this pass will replace pointers to
member functions with a struct with two ptrdiff_t fields.

Similarly, some CIR operations may also behave differently under different
target ABIs. This pass also expands these operations to more "primitive"
CIR operations as specified by the target ABI.
}];
let constructor = "mlir::createABILoweringPass()";
let dependentDialects = ["cir::CIRDialect"];
}

def CallConvLowering : Pass<"cir-call-conv-lowering"> {
let summary = "Handle calling conventions for CIR functions";
let description = [{
Expand Down
1 change: 1 addition & 0 deletions clang/lib/CIR/CodeGen/CIRPasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ mlir::LogicalResult runCIRToCIRPasses(
namespace mlir {

void populateCIRPreLoweringPasses(OpPassManager &pm, bool useCCLowering) {
pm.addPass(createABILoweringPass());
if (useCCLowering)
pm.addPass(createCallConvLoweringPass());
pm.addPass(createHoistAllocasPass());
Expand Down
Loading
Loading