This is an archive of the discontinued LLVM Phabricator instance.

[fir] !fir.tdesc type conversion
ClosedPublic

Authored by clementval on Nov 12 2021, 6:48 AM.

Details

Summary

Add !fir.tdesc type conversion.
!fir.tdesc is converted to a llvm.ptr<i8>.

This patch is part of the upstreaming effort from fir-dev branch.

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>

Diff Detail

Event Timeline

clementval created this revision.Nov 12 2021, 6:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 12 2021, 6:48 AM
Herald added a subscriber: mehdi_amini. · View Herald Transcript
clementval requested review of this revision.Nov 12 2021, 6:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 12 2021, 6:48 AM
awarzynski added inline comments.Nov 12 2021, 7:15 AM
flang/lib/Optimizer/CodeGen/TypeConverter.h
290–291

What's the f18 object?

Nit: Although these are all converted to i8 pointers, it might be good to have a few more tests? I have given a few below.

$ ./bin/fir-opt --fir-to-llvm-ir tdesc.mlir

module {

llvm.func @foo1(!llvm.ptr<i8>) attributes {sym_visibility = "private"}
llvm.func @foo2(!llvm.ptr<i8>) attributes {sym_visibility = "private"}
llvm.func @foo3(!llvm.ptr<i8>) attributes {sym_visibility = "private"}

}

$ cat tdesc.mlir

func private @foo1(%arg : !fir.tdesc<!fir.array<100xf32>>)
func private @foo2(%arg : !fir.tdesc<f32>)
func private @foo3(%arg : !fir.tdesc<!fir.type<derived7{f1:f32,f2:f32}>>)

Nit: Although these are all converted to i8 pointers, it might be good to have a few more tests? I have given a few below.

$ ./bin/fir-opt --fir-to-llvm-ir tdesc.mlir

module {

llvm.func @foo1(!llvm.ptr<i8>) attributes {sym_visibility = "private"}
llvm.func @foo2(!llvm.ptr<i8>) attributes {sym_visibility = "private"}
llvm.func @foo3(!llvm.ptr<i8>) attributes {sym_visibility = "private"}

}

$ cat tdesc.mlir

func private @foo1(%arg : !fir.tdesc<!fir.array<100xf32>>)
func private @foo2(%arg : !fir.tdesc<f32>)
func private @foo3(%arg : !fir.tdesc<!fir.type<derived7{f1:f32,f2:f32}>>)

I'll add your tests.

flang/lib/Optimizer/CodeGen/TypeConverter.h
290–291

Not the original author of this comment but I guess it refers to type vs. class.

Rebase + add tests

schweitz added inline comments.Nov 15 2021, 11:28 AM
flang/lib/Optimizer/CodeGen/TypeConverter.h
290–291

Correct.

An entity of derived type (an object), can need both an "is_a" test (is this object exactly class B) and a subclassing test (is this object of some class D which is or is derived from B).

Clearly a trivial pointer comparison of the type descriptor of the entity/object is insufficient to implement both of these tests.

clementval marked 2 inline comments as done.Nov 17 2021, 2:05 AM
This revision is now accepted and ready to land.Nov 17 2021, 3:50 AM
This revision was automatically updated to reflect the committed changes.