[PATCH] D113766: [fir] Add fir.gentypedesc conversion

Eric Schweitz via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 15 11:52:04 PST 2021


schweitz added inline comments.


================
Comment at: flang/lib/Optimizer/CodeGen/CodeGen.cpp:653
 
+/// Lower `fir.gentypedesc` to a global constant.
+struct GenTypeDescOpConversion : public FIROpConversion<fir::GenTypeDescOp> {
----------------
kiranchandramohan wrote:
> Nit: Can you add a bit more documentation on the conversion (global + addressof) and why is it a global (when it was not in FIR).
This prototype lowering is alluding to one possible implementation.

In FIR, one need not know the exact layout and contents of a "type descriptor". It is an abstraction that can be used to perform type tests, like "isa", perform virtual dispatch (for type bound procedures), etc. (This is like the box abstraction, which allows a box to be lowered to any number of "descriptor" formats, depending on the target runtime, etc.)

When lowering from FIR to LLVM, some sort of (constant) data structure must either be present (and referenced) or be created. Initially there was nothing, so the prototype created a dummy implementation, which is what we have here. The front end has since evolved and is generating its own data structures. (These can be found in the FIR dumps of tests with derived types, for example.) It is not entirely clear how this will be brought together.

This prototype could be replaced with a TODO.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113766/new/

https://reviews.llvm.org/D113766



More information about the llvm-commits mailing list