[flang] Fix printing of constc and parsing of #fir.real
authorDiana Picus <diana.picus@linaro.org>
Wed, 17 Nov 2021 10:29:42 +0000 (10:29 +0000)
committerDiana Picus <diana.picus@linaro.org>
Fri, 19 Nov 2021 09:28:02 +0000 (09:28 +0000)
commitca3795541f49d96371f75a307363baef59478786
tree0661853b0c6b9a68193b0e7768d07c05aea4f7f5
parent85e03cb7ebac50a13a9a9ac92a0b184a3bba9be1
[flang] Fix printing of constc and parsing of  #fir.real

Printing and parsing of constc didn't agree with each other. This patch
treats the parsing of constc as the final word and fixes the printing
accordingly.

More concretely, this patch prints the RealAttrs that make up the
ConstcOp directly instead of casting to mlir::FloatAttr (which blows
up). It also fixes parseFirRealAttr to invoke APFloat's method for
getting the size of a floating point type instead of computing it as
8 * kind (which blows up for BFloat, with kind == 3 and size == 16).

Kudos to Kiran Chandramohan <kiran.chandramohan@arm.com> for noticing
that we were missing tests for constc in fir-ops.fir.

Differential Revision: https://reviews.llvm.org/D114081
flang/lib/Optimizer/Dialect/FIRAttr.cpp
flang/lib/Optimizer/Dialect/FIROps.cpp
flang/test/Fir/fir-ops.fir