Skip to content

Commit

Permalink
[FIRRTL] Gate classes behind firrtl version 3.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rwy7 committed Sep 5, 2023
1 parent d5692e2 commit a2fbfdf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 18 deletions.
4 changes: 4 additions & 0 deletions lib/Dialect/FIRRTL/Import/FIRParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4516,6 +4516,10 @@ ParseResult FIRCircuitParser::parseClass(CircuitOp circuit, unsigned indent) {
SmallVector<PortInfo, 8> portList;
SmallVector<SMLoc> 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") ||
Expand Down
4 changes: 0 additions & 4 deletions test/Dialect/FIRRTL/parse-basic.fir
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
16 changes: 2 additions & 14 deletions test/Dialect/FIRRTL/parse-errors.fir
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ circuit invalid_inst :

;// -----

FIRRTL version 3.2.0
circuit class_inst :
class some_class :
module class_inst :
Expand Down Expand Up @@ -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<MyClass>
object x of MyClass
propassign o, x

;// -----
; Lists not yet supported.
Expand Down

0 comments on commit a2fbfdf

Please sign in to comment.