This is an archive of the discontinued LLVM Phabricator instance.

[flang] Add fir.dispatch code generation
ClosedPublic

Authored by clementval on Oct 18 2022, 10:59 AM.

Details

Summary

fir.dispatch code generation uses the binding table stored in the
type descriptor. There is no runtime call involved. The binding table
is always build from the parent type so the index of a specific binding
is the same in the parent derived-type or in the extended type.

Follow-up patches will deal cases not present here such as allocatable
polymorphic entities or pointers.

Diff Detail

Event Timeline

clementval created this revision.Oct 18 2022, 10:59 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptOct 18 2022, 10:59 AM
Herald added a subscriber: mehdi_amini. · View Herald Transcript
clementval requested review of this revision.Oct 18 2022, 10:59 AM
clementval edited the summary of this revision. (Show Details)Oct 18 2022, 10:59 AM

Overall looks good, just some questions about points I do not understand.

flang/lib/Optimizer/CodeGen/CodeGen.cpp
960–963

Is this code working if typeDescTy came from a fir::GloablOp and not an mlir::LLVM::GlobalOp above ? I would expect it to have a fir type in that case.

982–983

I do not follow how this is accounting for the pass/nopass and pass position aspects (also below when placing the argument values).

PeteSteinfeld accepted this revision.Oct 18 2022, 1:24 PM

Aside from a few nits, all builds and tests correctly and looks good.

flang/lib/Optimizer/CodeGen/CodeGen.cpp
1000

"Indirect calls"

1010

"Indirect calls"

This revision is now accepted and ready to land.Oct 18 2022, 1:24 PM
clementval added inline comments.Oct 18 2022, 10:24 PM
flang/lib/Optimizer/CodeGen/CodeGen.cpp
960–963

Good point. I'll add a convertType for the fir::GlobalOp case.

982–983

The semantic is giving us the correct list of operand with the passed-object included if needed. We just drop the first operand that represent the passed-object in any case but the passed object is also present at its right position in case of a PASS procedure.

clementval marked 3 inline comments as done.

Address review comments

jeanPerier accepted this revision.Oct 18 2022, 11:49 PM

LGTM

flang/lib/Optimizer/CodeGen/CodeGen.cpp
982–983

That explains, thanks.

This revision was automatically updated to reflect the committed changes.
flang/lib/Optimizer/CodeGen/TypeConverter.h