12 #include "mlir/IR/Builders.h"
13 #include "mlir/IR/DialectImplementation.h"
14 #include "llvm/ADT/TypeSwitch.h"
17 using namespace circt;
18 using namespace firrtl;
20 #define GET_ATTRDEF_CLASSES
21 #include "circt/Dialect/FIRRTL/FIRRTLAttributes.cpp.inc"
34 llvm_unreachable(
"unknown direction");
37 mlir::DenseBoolArrayAttr
40 SmallVector<bool> dirs;
41 dirs.reserve(directions.size());
42 for (
auto d : directions)
48 ArrayRef<bool> directions) {
53 SmallVector<Direction>
55 SmallVector<Direction> result;
56 result.reserve(directions.size());
57 for (
auto d : directions.asArrayRef())
67 void FIRRTLDialect::registerAttributes() {
69 #define GET_ATTRDEF_LIST
70 #include "circt/Dialect/FIRRTL/FIRRTLAttributes.cpp.inc"
78 Attribute ParamDeclAttr::parse(AsmParser &p, Type trailing) {
85 if (p.parseLess() || p.parseString(&name) || p.parseColonType(type))
88 if (succeeded(p.parseOptionalEqual())) {
89 if (p.parseAttribute(value, type))
101 void ParamDeclAttr::print(AsmPrinter &p)
const {
102 p <<
"<" <<
getName() <<
": " << getType();
105 p.printAttributeWithoutType(getValue());
Direction get(bool isOutput)
Returns an output direction if isOutput is true, otherwise returns an input direction.
mlir::DenseBoolArrayAttr packAttribute(MLIRContext *context, ArrayRef< Direction > directions)
Return a DenseBoolArrayAttr containing the packed representation of an array of directions.
Direction flip(Direction direction)
Flip a port direction.
SmallVector< Direction > unpackAttribute(mlir::DenseBoolArrayAttr directions)
Turn a packed representation of port attributes into a vector that can be worked with.
static Direction get(bool isOutput)
Return an output direction if isOutput is true, otherwise return an input direction.
static StringRef toString(Direction direction)
Direction
This represents the direction of a single port.
llvm::raw_ostream & operator<<(llvm::raw_ostream &os, const InstanceInfo::LatticeValue &value)
StringAttr getName(ArrayAttr names, size_t idx)
Return the name at the specified index of the ArrayAttr or null if it cannot be determined.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.