Skip to content

Commit

Permalink
[HW] Move the CombDataFlow op interface from FIRRTL to HW (#7195)
Browse files Browse the repository at this point in the history
Move the `CombDataFlow` op interface from `FIRRTL` to `HW` dialect.
The op interface is better suited to reside in the `HW` dialect, along with
 other interfaces like the `HWModuleLike`.
This makes it more convenient for non-`FIRRTL` dialects to implement ops using
 this interface, without introducing a new dependence on the `FIRRTL` dialect,
 assuming  `HW` dependence already exists.
  • Loading branch information
prithayan authored Jun 18, 2024
1 parent f2d4bb5 commit 6cbca83
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 23 deletions.
1 change: 0 additions & 1 deletion include/circt/Dialect/FIRRTL/FIRRTLOpInterfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "circt/Dialect/HW/HWAttributes.h"
#include "circt/Dialect/HW/HWOpInterfaces.h"
#include "circt/Dialect/HW/InnerSymbolTable.h"
#include "circt/Support/FieldRef.h"
#include "mlir/IR/Attributes.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/OpDefinition.h"
Expand Down
21 changes: 0 additions & 21 deletions include/circt/Dialect/FIRRTL/FIRRTLOpInterfaces.td
Original file line number Diff line number Diff line change
Expand Up @@ -522,25 +522,4 @@ def Forceable : OpInterface<"Forceable"> {
return detail::verifyForceableOp(cast<::circt::firrtl::Forceable>($_op));
}];
}

def CombDataflow : OpInterface<"CombDataFlow"> {
let cppNamespace = "circt::firrtl";
let description = [{
This interface is used for specifying the combinational dataflow that exists
in the results and operands of an operation.
Any operation that doesn't implement this interface is assumed to have a
combinational dependence from each operand to each result.
}];
let methods = [
InterfaceMethod<"Get the combinational dataflow relations between the"
"operands and the results. This returns a pair of fieldrefs. The first"
"element is the destination and the second is the source of the dependence."
"The default implementation returns an empty list, which implies that the"
"operation is not combinational.",
"SmallVector<std::pair<circt::FieldRef, circt::FieldRef>>",
"computeDataFlow", (ins), [{}], /*defaultImplementation=*/[{
return {};
}]>,
];
}
#endif // CIRCT_DIALECT_FIRRTL_FIRRTLOPINTERFACES_TD
1 change: 1 addition & 0 deletions include/circt/Dialect/HW/HWOpInterfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "circt/Dialect/HW/HWInstanceImplementation.h"
#include "circt/Dialect/HW/HWTypes.h"
#include "circt/Dialect/HW/InnerSymbolTable.h"
#include "circt/Support/FieldRef.h"
#include "circt/Support/InstanceGraphInterface.h"
#include "circt/Support/LLVM.h"
#include "mlir/IR/OpDefinition.h"
Expand Down
22 changes: 22 additions & 0 deletions include/circt/Dialect/HW/HWOpInterfaces.td
Original file line number Diff line number Diff line change
Expand Up @@ -547,4 +547,26 @@ def InnerRefUserOpInterface : OpInterface<"InnerRefUserOpInterface"> {
];
}

def CombDataflow : OpInterface<"CombDataFlow"> {
let cppNamespace = "circt::hw";
let description = [{
This interface is used for specifying the combinational dataflow that exists
in the results and operands of an operation.
Any operation that doesn't implement this interface is assumed to have a
combinational dependence from each operand to each result.
}];
let methods = [
InterfaceMethod<"Get the combinational dataflow relations between the"
"operands and the results. This returns a pair of ground type fieldrefs."
"The first element is the destination and the second is the source of"
"the dependence."
"The default implementation returns an empty list, which implies that the"
"operation is not combinational.",
"SmallVector<std::pair<circt::FieldRef, circt::FieldRef>>",
"computeDataFlow", (ins), [{}], /*defaultImplementation=*/[{
return {};
}]>,
];
}

#endif
2 changes: 1 addition & 1 deletion lib/Dialect/FIRRTL/Transforms/CheckCombLoops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class DiscoverLoops {

walk(module, [&](Operation *op) {
llvm::TypeSwitch<Operation *>(op)
.Case<CombDataFlow>([&](CombDataFlow df) {
.Case<hw::CombDataFlow>([&](hw::CombDataFlow df) {
// computeDataFlow returns a pair of FieldRefs, first element is the
// destination and the second is the source.
for (auto &dep : df.computeDataFlow())
Expand Down

0 comments on commit 6cbca83

Please sign in to comment.