Skip to content

Commit b331852

Browse files
committed
[FIRRTL] Use type inference for domain anon op
1 parent 2e7cfda commit b331852

File tree

5 files changed

+14
-38
lines changed

5 files changed

+14
-38
lines changed

include/circt/Dialect/FIRRTL/FIRRTLDeclarations.td

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -777,21 +777,18 @@ def ObjectOp : FIRRTLOp<"object", [
777777
}];
778778
}
779779

780-
def DomainCreateAnonOp : FIRRTLOp<"domain.anon", [
781-
ParentOneOf<[
782-
"firrtl::ContractOp",
783-
"firrtl::FModuleOp",
784-
"firrtl::LayerBlockOp",
785-
"firrtl::MatchOp",
786-
"firrtl::WhenOp",
787-
"sv::IfDefOp"
788-
]>,
789-
DeclareOpInterfaceMethods<SymbolUserOpInterface>
790-
]> {
780+
def DomainCreateAnonOp
781+
: FIRRTLOp<"domain.anon",
782+
[ParentOneOf<["firrtl::ContractOp", "firrtl::FModuleOp",
783+
"firrtl::LayerBlockOp", "firrtl::MatchOp",
784+
"firrtl::WhenOp", "sv::IfDefOp"]>,
785+
DeclareOpInterfaceMethods<SymbolUserOpInterface>,
786+
DeclareOpInterfaceMethods<InferTypeOpInterface>,
787+
]> {
791788
let summary = "Create an anonymous domain, without parameters set";
792789
let arguments = (ins FlatSymbolRefAttr:$domain);
793790
let results = (outs DomainType:$result);
794-
let hasCustomAssemblyFormat = 1;
791+
let assemblyFormat = [{ `of` $domain attr-dict }];
795792
}
796793

797794
#endif // CIRCT_DIALECT_FIRRTL_FIRRTLDECLARATIONS_TD

lib/Dialect/FIRRTL/FIRRTLOps.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7043,27 +7043,6 @@ LogicalResult BindOp::verifyInnerRefs(hw::InnerRefNamespace &ns) {
70437043
// Domain operations
70447044
//===----------------------------------------------------------------------===//
70457045

7046-
void DomainCreateAnonOp::print(OpAsmPrinter &p) {
7047-
p.printOptionalAttrDict((*this)->getAttrs(), /*elidedAttrs=*/{"domain"});
7048-
p << " : ";
7049-
p.printType(getType());
7050-
printDomainKind(p, getDomainAttr());
7051-
}
7052-
7053-
ParseResult DomainCreateAnonOp::parse(OpAsmParser &parser,
7054-
OperationState &result) {
7055-
Type type;
7056-
FlatSymbolRefAttr domainKind;
7057-
if (parser.parseOptionalAttrDict(result.attributes) || parser.parseColon() ||
7058-
parser.parseType(type) || parseDomainKind(parser, domainKind))
7059-
return failure();
7060-
7061-
result.getOrAddProperties<Properties>().setDomain(domainKind);
7062-
result.addTypes(type);
7063-
7064-
return success();
7065-
}
7066-
70677046
LogicalResult
70687047
DomainCreateAnonOp::verifySymbolUses(SymbolTableCollection &symbolTable) {
70697048
auto circuitOp = getOperation()->getParentOfType<CircuitOp>();

test/Dialect/FIRRTL/emit-basic.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ firrtl.circuit "Foo" {
10161016
// CHECK-LABEL: module AnonymousDomains :
10171017
firrtl.module @AnonymousDomains() {
10181018
// CHECK-NEXT: inst foo of AnonymousDomains_Foo
1019-
%0 = firrtl.domain.anon : !firrtl.domain of @ClockDomain
1019+
%0 = firrtl.domain.anon of @ClockDomain
10201020
%foo_A = firrtl.instance foo @AnonymousDomains_Foo(
10211021
in A: !firrtl.domain of @ClockDomain
10221022
)

test/Dialect/FIRRTL/errors.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3205,7 +3205,7 @@ firrtl.circuit "AnonDomainPointingAtNonDomain" {
32053205
firrtl.extmodule @Foo()
32063206
firrtl.module @UndefinedDomainInAnonDomain() {
32073207
// expected-error @below {{references undefined domain '@Foo'}}
3208-
%0 = firrtl.domain.anon : !firrtl.domain of @Foo
3208+
%0 = firrtl.domain.anon of @Foo
32093209
}
32103210
}
32113211

@@ -3214,6 +3214,6 @@ firrtl.circuit "AnonDomainPointingAtNonDomain" {
32143214
firrtl.circuit "UndefinedDomainInAnonDomain" {
32153215
firrtl.module @UndefinedDomainInAnonDomain() {
32163216
// expected-error @below {{references undefined domain '@Foo'}}
3217-
%0 = firrtl.domain.anon : !firrtl.domain of @Foo
3217+
%0 = firrtl.domain.anon of @Foo
32183218
}
32193219
}

test/Dialect/FIRRTL/round-trip.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,8 @@ firrtl.module @InstanceChoiceWithDomain(in %A: !firrtl.domain of @ClockDomain, i
279279
// CHECK-LABEL: firrtl.module @CreateAnonDomain
280280
firrtl.extmodule @CreateAnonDomainChild(in A: !firrtl.domain of @ClockDomain)
281281
firrtl.module @CreateAnonDomain() {
282-
// CHECK-NEXT: %0 = firrtl.domain.anon : !firrtl.domain of @ClockDomain
283-
%0 = firrtl.domain.anon : !firrtl.domain of @ClockDomain
282+
// CHECK-NEXT: %0 = firrtl.domain.anon of @ClockDomain
283+
%0 = firrtl.domain.anon of @ClockDomain
284284
%child_A = firrtl.instance child @CreateAnonDomainChild(
285285
in A: !firrtl.domain of @ClockDomain
286286
)

0 commit comments

Comments
 (0)