Add support for hexadecimal float literals
authorAlex Zinenko <zinenko@google.com>
Tue, 30 Jul 2019 21:05:49 +0000 (14:05 -0700)
committerA. Unique TensorFlower <gardener@tensorflow.org>
Tue, 30 Jul 2019 21:06:26 +0000 (14:06 -0700)
commit3b207d3691a61184d7159604effbf5d70dd62efd
tree57175e36d5d173fe588ad754f78d84a6093b7ea1
parent32f78fe3f26792914eaa48e2fd748a34b31acb86
Add support for hexadecimal float literals

MLIR does not have support for parsing special floating point values such as
infinities and NaNs.  If programmatically constructed, these values are printed
as NaN and (+-)Inf and cannot be parsed back.  Add parser support for
hexadecimal literals in float attributes, following LLVM IR.  The literal
corresponds to the in-memory representation of the floating point value.
IEEE 754 defines a range of possible values for NaNs, storing the bitwise
representation allows MLIR to properly roundtrip NaNs with different bit values
of significands.

The initial version of this commit was missing support for float literals that
used to be printed in decimal notation as a fallback, but ended up being
printed in hexadecimal format which became the fallback for special values.
The decimal fallback behavior was not exercised by tests.  It is currently
reinstated and tested by the newly added test @f32_potential_precision_loss in
parser.mlir.

PiperOrigin-RevId: 260790900
mlir/g3doc/LangRef.md
mlir/lib/IR/AsmPrinter.cpp
mlir/lib/Parser/Parser.cpp
mlir/test/IR/invalid.mlir
mlir/test/IR/parser.mlir