Allow Builder to create function-type constants
A recent change made ConstantOp::build accept a NumericAttr or assert that a generic Attribute is in fact a NumericAttr. The rationale behind the change was that NumericAttrs have a type that can be used as the result type of the constant operation. FunctionAttr also has a type, and it is valid to construct function-typed constants as exercised by the parser.mlir test. Relax ConstantOp::build back to take a generic Attribute. In the overload that only takes an attribute, assert that the Attribute is either a NumericAttr or a FunctionAttr, because it is necessary to extract the type. In the overload that takes both type type and the attribute, delegate the attribute type checking to ConstantOp::verify to prevent non-Builder-based Op construction mechanisms from creating invalid IR. PiperOrigin-RevId: 234798569
Loading
Please sign in to comment