[FIRRTL] enable properties for inherent attributes

This enables properties in the FIRRTL dialect. Some op parsers which
called `inferReturnTypes` had to be updated to store inherent attributes
as properties on the OperationState, as the call to `inferReturnTypes`
expects properties to have already been populated.  This is a change
that we should make for all operation parsers and builders, to make
things faster, but is not strictly necessary at this time.
This commit is contained in:
Andrew Young 2024-10-29 19:21:29 -07:00
parent fd56341db4
commit f22f11aa40
3 changed files with 10 additions and 13 deletions

View File

@ -34,9 +34,6 @@ def FIRRTLDialect : Dialect {
let useDefaultTypePrinterParser = 0;
let useDefaultAttributePrinterParser = 1;
// Opt-out of properties for now, must migrate by LLVM 19. #5273.
let usePropertiesForAttributes = 0;
let dependentDialects = [
"circt::hw::HWDialect",
"circt::om::OMDialect",

View File

@ -4499,8 +4499,7 @@ ParseResult parseSubfieldLikeOp(OpAsmParser &parser, OperationState &result) {
"unknown field " + fieldName + " in bundle type ")
<< bundleType;
result.addAttribute(
"fieldIndex",
result.getOrAddProperties<typename OpTy::Properties>().setFieldIndex(
IntegerAttr::get(IntegerType::get(context, 32), *fieldIndex));
SmallVector<Type> inferredReturnTypes;
@ -4540,8 +4539,7 @@ ParseResult SubtagOp::parse(OpAsmParser &parser, OperationState &result) {
"unknown field " + fieldName + " in enum type ")
<< enumType;
result.addAttribute(
"fieldIndex",
result.getOrAddProperties<Properties>().setFieldIndex(
IntegerAttr::get(IntegerType::get(context, 32), *fieldIndex));
SmallVector<Type> inferredReturnTypes;
@ -4869,8 +4867,8 @@ ParseResult ObjectSubfieldOp::parse(OpAsmParser &parser,
return parser.emitError(parser.getNameLoc(),
"unknown field " + fieldName + " in class type ")
<< inputType;
result.addAttribute("index",
IntegerAttr::get(IntegerType::get(context, 32), *index));
result.getOrAddProperties<Properties>().setIndex(
IntegerAttr::get(IntegerType::get(context, 32), *index));
SmallVector<Type> inferredReturnTypes;
if (failed(inferReturnTypes(context, result.location, result.operands,

View File

@ -13,12 +13,14 @@ firrtl.circuit "Foo" attributes {rawAnnotations = [
}
}
// CHECK-LABEL: "firrtl.extmodule"() ({
// CHECK: }) {
// CHECK-LABEL: "firrtl.extmodule"() <
// CHECK-SAME: portAnnotations = {{['[']['[']}}{class = "circt.test", data = "a"}]]
// CHECK-SAME: > ({
// CHECK: }) {
// CHECK-SAME: sym_name = "Bar"
// CHECK-LABEL: "firrtl.module"() ({
// CHECK: }) {
// CHECK-LABEL: "firrtl.module"() <
// CHECK-SAME: portAnnotations = {{['[']['[']}}{class = "circt.test", data = "b"}]]
// CHECK-SAME: > ({
// CHECK: }) {
// CHECK-SAME: sym_name = "Foo"