[mlir][DenseElementsAttr] Add support for ComplexType elements
authorRiver Riddle <riddleriver@gmail.com>
Tue, 5 May 2020 19:39:12 +0000 (12:39 -0700)
committerRiver Riddle <riddleriver@gmail.com>
Tue, 5 May 2020 19:42:37 +0000 (12:42 -0700)
commitda2a6f4e3b5235d871c2e81ae1b0577002733653
treee324627b56e4dea073819fc89515cb05d51e5e97
parentc296d2dc53d5c11ce0de307ae17fc3404f7de80d
[mlir][DenseElementsAttr] Add support for ComplexType elements

This revision adds support for storing ComplexType elements inside of a DenseElementsAttr. We store complex objects as an array of two elements, matching the  definition of std::complex. There is no current attribute storage for ComplexType, but DenseElementsAttr provides API for access/creation using std::complex<>. Given that the internal implementation of DenseElementsAttr is already fairly opaque, the only real complexity here is in the printing/parsing. This revision keeps it simple for now and always uses hex when printing complex elements. A followup will add prettier syntax for this.

Differential Revision: https://reviews.llvm.org/D79281
mlir/include/mlir/IR/Attributes.h
mlir/lib/IR/AsmPrinter.cpp
mlir/lib/IR/AttributeDetail.h
mlir/lib/IR/Attributes.cpp
mlir/lib/Parser/Parser.cpp
mlir/test/IR/dense-elements-hex.mlir
mlir/unittests/IR/AttributeTest.cpp