forked from llvm/circt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[HandshakeToFIRRTL] Add top module inference and instance cycle detec…
…tion (llvm#2056) * [HandshakeToFIRRTL] Add top module inference and instance cycle detection In preparation for supporting `handshake.instance` lowering, this commit introduces top module inference and instance cycle detection. The IR is topologically sorted based on `handshake.instance` usage. During this, we check for instance cycles (and report them to the user) as well as top-module detection. For now, if multiple top modules are available, an error is thrown. Furthermore, the `firrtl.circuit` op is now created outside of the `handshake.func` operation lowering, based on the inferred top-level name.
- Loading branch information
Showing
2 changed files
with
141 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// RUN: circt-opt -lower-handshake-to-firrtl -verify-diagnostics -split-input-file %s | ||
|
||
// Test cycle through a component | ||
// expected-error @+1 {{'builtin.module' op cannot lower handshake program - cycle detected in instance graph (bar->baz->foo->bar).}} | ||
module { | ||
handshake.func @bar(%ctrl : none) -> (none) { | ||
%0 = handshake.instance @baz(%ctrl) : (none) -> (none) | ||
handshake.return %0: none | ||
} | ||
|
||
handshake.func @foo(%ctrl : none) -> (none) { | ||
%0 = handshake.instance @bar(%ctrl) : (none) -> (none) | ||
handshake.return %0: none | ||
} | ||
|
||
handshake.func @baz(%ctrl : none) -> (none) { | ||
%0 = handshake.instance @foo(%ctrl) : (none) -> (none) | ||
handshake.return %0: none | ||
} | ||
} | ||
|
||
// ----- | ||
|
||
// test multiple candidate top components | ||
// expected-error @+1 {{'builtin.module' op multiple candidate top-level modules detected (bar, foo). Please remove one of these from the source program.}} | ||
module { | ||
handshake.func @bar(%ctrl : none) -> (none) { | ||
%0 = handshake.instance @baz(%ctrl) : (none) -> (none) | ||
handshake.return %0: none | ||
} | ||
|
||
handshake.func @foo(%ctrl : none) -> (none) { | ||
%0 = handshake.instance @baz(%ctrl) : (none) -> (none) | ||
handshake.return %0: none | ||
} | ||
|
||
handshake.func @baz(%ctrl : none) -> (none) { | ||
handshake.return %ctrl: none | ||
} | ||
} |