12#include "mlir/IR/Builders.h"
13#include "mlir/IR/DialectImplementation.h"
14#include "llvm/ADT/TypeSwitch.h"
18using namespace firrtl;
20#define GET_ATTRDEF_CLASSES
21#include "circt/Dialect/FIRRTL/FIRRTLAttributes.cpp.inc"
30 return Direction::Out;
34 llvm_unreachable(
"unknown direction");
37mlir::DenseBoolArrayAttr
40 SmallVector<bool> dirs;
41 dirs.reserve(directions.size());
42 for (
auto d : directions)
43 dirs.push_back(d == Direction::Out);
44 return mlir::DenseBoolArrayAttr::get(context, dirs);
48 ArrayRef<bool> directions) {
50 return mlir::DenseBoolArrayAttr::get(context, directions);
55 SmallVector<Direction> result;
56 result.reserve(directions.size());
57 for (
auto d : directions.asArrayRef())
67void FIRRTLDialect::registerAttributes() {
69#define GET_ATTRDEF_LIST
70#include "circt/Dialect/FIRRTL/FIRRTLAttributes.cpp.inc"
78Attribute 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))
97 return ParamDeclAttr::get(name, value);
98 return ParamDeclAttr::get(name, type);
101void ParamDeclAttr::print(AsmPrinter &p)
const {
102 p <<
"<" <<
getName() <<
": " << getType();
105 p.printAttributeWithoutType(getValue());
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.