This is an archive of the discontinued LLVM Phabricator instance.

[fir] Add complex operations conversion from FIR LLVM IR
ClosedPublic

Authored by clementval on Nov 8 2021, 1:44 PM.

Details

Summary

This patch add conversion for primitive operations on complex types.

  • fir.addc
  • fir.subc
  • fir.mulc
  • fir.divc
  • fir.negc

This adds also the type conversion for !fir.complex<KIND> type.

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

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

Diff Detail

Event Timeline

clementval created this revision.Nov 8 2021, 1:44 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 8 2021, 1:44 PM
Herald added a subscriber: mehdi_amini. · View Herald Transcript
clementval requested review of this revision.Nov 8 2021, 1:44 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 8 2021, 1:44 PM
rovka accepted this revision.Nov 9 2021, 12:45 AM

LGTM

flang/lib/Optimizer/CodeGen/CodeGen.cpp
532

Nit: s/*/+

547

Nit: s/*/-

flang/test/Fir/convert-to-llvm.fir
383

s/*/+

408

s/*/-

This revision is now accepted and ready to land.Nov 9 2021, 12:45 AM

What triple will this assume by default? Does it depend on the platform that it runs? Will this fail on AArch64? I think tco assumed x86_64 if not specified.

flang/lib/Optimizer/CodeGen/TypeConverter.h
221

Nit: should the bfloat type be here?

flang/test/Fir/types-to-llvm.fir
91

Nit: kind 3, 10 are not handled.

clementval updated this revision to Diff 385737.Nov 9 2021, 1:58 AM
clementval marked 5 inline comments as done.

Address review comments + rebase

What triple will this assume by default? Does it depend on the platform that it runs? Will this fail on AArch64? I think tco assumed x86_64 if not specified.

The conversion is the same for all target on this. complexMemoryType is shared for all targets.

flang/test/Fir/types-to-llvm.fir
91

Added. bf16 was needed in fromRealTypeID for kind 3

clementval marked an inline comment as done.Nov 9 2021, 2:01 AM

What triple will this assume by default? Does it depend on the platform that it runs? Will this fail on AArch64? I think tco assumed x86_64 if not specified.

The conversion is the same for all target on this. complexMemoryType is shared for all targets.

func @fir_complex_add(%a: !fir.complex<16>, %b: !fir.complex<16>) -> !fir.complex<16> {

What triple will this assume by default? Does it depend on the platform that it runs? Will this fail on AArch64? I think tco assumed x86_64 if not specified.

The conversion is the same for all target on this. complexMemoryType is shared for all targets.

I might be confused here. But aren't the arguments converted by complexArgumentType which is dependent on the target?

clementval reopened this revision.Nov 9 2021, 4:30 AM
This revision is now accepted and ready to land.Nov 9 2021, 4:30 AM
clementval updated this revision to Diff 385779.Nov 9 2021, 4:33 AM

Add target option to the pass.

kiranchandramohan accepted this revision.Nov 9 2021, 5:01 AM

LGTM. Passes on AArch64