From a2fbfdf79b8faf7873978ea95885b96acf2e27ac Mon Sep 17 00:00:00 2001 From: Robert Young Date: Fri, 25 Aug 2023 11:51:57 -0400 Subject: [PATCH] [FIRRTL] Gate classes behind firrtl version 3.2.0 --- lib/Dialect/FIRRTL/Import/FIRParser.cpp | 4 ++++ test/Dialect/FIRRTL/parse-basic.fir | 4 ---- test/Dialect/FIRRTL/parse-errors.fir | 16 ++-------------- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/lib/Dialect/FIRRTL/Import/FIRParser.cpp b/lib/Dialect/FIRRTL/Import/FIRParser.cpp index b72deecbbdda..47b586834241 100644 --- a/lib/Dialect/FIRRTL/Import/FIRParser.cpp +++ b/lib/Dialect/FIRRTL/Import/FIRParser.cpp @@ -4516,6 +4516,10 @@ ParseResult FIRCircuitParser::parseClass(CircuitOp circuit, unsigned indent) { SmallVector portList; SmallVector portLocs; LocWithInfo info(getToken().getLoc(), this); + + if (requireFeature({3, 2, 0}, "classes")) + return failure(); + consumeToken(FIRToken::kw_class); if (parseId(name, "expected class name") || parseToken(FIRToken::colon, "expected ':' in class definition") || diff --git a/test/Dialect/FIRRTL/parse-basic.fir b/test/Dialect/FIRRTL/parse-basic.fir index 82ba1ba50696..aa49f6281e89 100644 --- a/test/Dialect/FIRRTL/parse-basic.fir +++ b/test/Dialect/FIRRTL/parse-basic.fir @@ -1410,10 +1410,6 @@ circuit MyModule : ; CHECK: firrtl.circuit "MyModule" { ; CHECK-NEXT: firrtl.strictconnect %nonconst_w, [[CAST]] : !firrtl.sint<4> nonconst_w <= s4 - ; CHECK-LABEL firrtl.class @SimpleClass() { } - ; Not version-gated yet, not in spec. - class SimpleClass: - ;// ----- ; CHECK-LABEL: firrtl.circuit "Foo_v3p0p0" diff --git a/test/Dialect/FIRRTL/parse-errors.fir b/test/Dialect/FIRRTL/parse-errors.fir index 68adc4c7df94..eab669ea9799 100644 --- a/test/Dialect/FIRRTL/parse-errors.fir +++ b/test/Dialect/FIRRTL/parse-errors.fir @@ -166,6 +166,7 @@ circuit invalid_inst : ;// ----- +FIRRTL version 3.2.0 circuit class_inst : class some_class : module class_inst : @@ -905,25 +906,12 @@ circuit Top: FIRRTL version 3.0.0 circuit Top: + ; expected-error @below {{classes are a FIRRTL 3.2.0+ feature, but the specified FIRRTL version was 3.0.0}} class MyClass: skip module Top: - ; expected-error @below {{object statements are a FIRRTL 3.2.0+ feature, but the specified FIRRTL version was 3.0.0}} - object x of MyClass - -;// ----- -FIRRTL version 3.0.0 - -circuit Top: - class MyClass: - skip - - module Top: - ; expected-error @below {{Inst types are a FIRRTL 3.2.0+ feature, but the specified FIRRTL version was 3.0.0}} - output o: Inst object x of MyClass - propassign o, x ;// ----- ; Lists not yet supported.