Open AntonLydike opened 3 months ago
I'm having a walk around or issues, and I find this one very interesting!
What put me on that path is seeing arith.Constant(IntegerAttr(0, 32), IntegerType(64))
in the first place: you're defining a constant of type i64
with a value of type i32
, what's going on and how is it supposed to make sense?
Looking at MLIR's arith.constant
, it only has one attribute, value
, being a TypedAttr
(i.e., carrying its type (as an attribute)). Our has both value
and type
.
Thing is, MLIR restrict arith.constant
's value
attribute to such TypedAttrs. I just recently implemented the equivalent concept in xDSL:
Which would allow us to do the same: just having one typed value
attribute!
Caveat: I only used TypedAttribute on IntegerAttr for declarative known-type integer syntax support.
This would require to match MLIR on which attributes types are actually typed, to make sure arith.constant
keeps accepting everything we expect!
The printing and parsing of
arith.constant
in custom format is broken, see:will not print the type. Similarly:
(see the return value being subtly changed to i32, the type of the attribute and not of the value.
Both of these issues are due to the printing logic printing the value attribute, not the value's value and then the type.