Conversation
|
The direct motivation for this new pass is the proper CallConvLowering of the cir.func @test(%arg0: !cir.method) {
// ...
}Following the current lowering approach, which keeps define dso_local @test({ i64, i64 } %0) {
; ...
}But we actually expect the following LLVM IR (note the differences on the function signatures): define dso_local @test(i64 %0, i64 %1) {
; ...
}To achieve this, I have 3 choices:
At the beginning I thought option 1 would be the easiest way. But as I dig through the rabbit hole I found some tricky stuff behind the scene. The problem comes from the CodeGen of function prologue and epilogue. In the prologue, each argument is assigned a stack slot and stored there. For an argument of type The problem of option 3 is that the LoweringPrepare pass is not a conversion pass, which could be really tricky if you want to do type conversion stuff in it. In my case I have to convert every appearances of Anyway, this PR is still very incomplete and under construction, I'd like to hear some early comments about this from the community. |
d2c4ab8 to
8f89224
Compare
352959f to
fc67ccf
Compare
|
Sorry for the delay here, I finally got the bandwidth to update this PR. The primary goal of this PR is to introduce the cir-abi-lowering pass which performs ABI lowering work for globals and inside each function. The cir-abi-lowering pass converts ABI dependent types to more "fundamental" CIR types, and replaces operations that act on these ABI dependent types with more "fundamental" CIR operations. The idea of cir-abi-lowering is to avoid mixing such ABI lowering logic in LLVM lowering code, which could be confusing and make the code more complex. With the introduction of cir-abi-lowering, we got the following benefits:
|
bcardosolopes
left a comment
There was a problem hiding this comment.
I like the direction overall, thanks for working on this. I feel it's a bit confusing to have both cir-abi-lowering and cir-call-conv-lowering being distinct passes. Can we merge cir-call-conv-lowering into the former while keeping a switch to enable/disable the call conv lowering part (should be default to off for now)? It's fine if you do that in a follow up PR, but I'd like to have a plan before we land this.
That makes sense to me, and I'll do that in a follow-up PR. Actually in short term I also plan to migrate part of LoweringPrepare as well, as some ABI lowering code is put there for now (e.g. the handling of |
Yea, since we have no need for postponing some of the ABI decisions we just do it right away, avoiding duplicating AST information to only when necessary |
fc67ccf to
57f037d
Compare
|
Rebased. |
8acaf96 to
58135ea
Compare
This patch adds a new pass cir-abi-lowering to the CIR dialect. This pass runs before the CallConvLowering pass, and it expands all ABI-dependent types and operations inside a function to their ABI-independent equivalences according to the ABI specification. This patch also moves the lowering code of the following types and operations from the LLVM lowering conversion to the new pass: - The pointer-to-data-member type `cir.data_member`; - The pointer-to-member-function type `cir.method`; - All operations working on operands of the above types.
57f037d to
e3e75b0
Compare
|
Rebased. |
bcardosolopes
left a comment
There was a problem hiding this comment.
LGTM, probably good to land once after it lands in upstream, just to make sure we got all in sync
This PR attempts to add a new pass
cir-abi-loweringto the CIR dialect. This pass runs before the CallConvLowering pass, and it expands all ABI-dependent types and operations inside a function to their ABI-independent equivalences according to the ABI specification.The patch also moves the lowering code of the following types and operations from the LLVM lowering conversion to the new pass:
cir.data_member;cir.method;