14 #include "mlir/IR/Builders.h"
15 #include "mlir/IR/DialectImplementation.h"
18 using namespace circt;
26 SequenceClosureOp::verifySymbolUses(SymbolTableCollection &symbolTable) {
28 symbolTable.lookupNearestSymbolFrom<SequenceOp>(*
this, getSequenceAttr());
31 <<
"'" << getSequence()
32 <<
"' does not reference a valid 'rtg.sequence' operation";
34 if (
seq.getBodyRegion().getArgumentTypes() != getArgs().getTypes())
35 return emitOpError(
"referenced 'rtg.sequence' op's argument types must "
36 "match 'args' types");
45 ParseResult SetCreateOp::parse(OpAsmParser &parser, OperationState &result) {
46 llvm::SmallVector<OpAsmParser::UnresolvedOperand, 16> operands;
49 if (parser.parseOperandList(operands) ||
50 parser.parseOptionalAttrDict(result.attributes) || parser.parseColon() ||
51 parser.parseType(elemType))
54 result.addTypes({
SetType::get(result.getContext(), elemType)});
56 for (
auto operand : operands)
57 if (parser.resolveOperand(operand, elemType, result.operands))
63 void SetCreateOp::print(OpAsmPrinter &p) {
65 p.printOperands(getElements());
66 p.printOptionalAttrDict((*this)->getAttrs());
67 p <<
" : " << getSet().getType().getElementType();
71 if (getElements().size() > 0) {
74 if (getElements()[0].getType() != getSet().getType().getElementType())
75 return emitOpError() <<
"operand types must match set element type";
85 ParseResult BagCreateOp::parse(OpAsmParser &parser, OperationState &result) {
86 llvm::SmallVector<OpAsmParser::UnresolvedOperand, 16> elementOperands,
90 if (!parser.parseOptionalLParen()) {
92 OpAsmParser::UnresolvedOperand elementOperand, multipleOperand;
93 if (parser.parseOperand(multipleOperand) || parser.parseKeyword(
"x") ||
94 parser.parseOperand(elementOperand))
97 elementOperands.push_back(elementOperand);
98 multipleOperands.push_back(multipleOperand);
100 if (parser.parseOptionalComma()) {
101 if (parser.parseRParen())
108 if (parser.parseColon() || parser.parseType(elemType) ||
109 parser.parseOptionalAttrDict(result.attributes))
112 result.addTypes({
BagType::get(result.getContext(), elemType)});
114 for (
auto operand : elementOperands)
115 if (parser.resolveOperand(operand, elemType, result.operands))
118 for (
auto operand : multipleOperands)
119 if (parser.resolveOperand(operand,
IndexType::get(result.getContext()),
126 void BagCreateOp::print(OpAsmPrinter &p) {
128 if (!getElements().
empty())
130 llvm::interleaveComma(llvm::zip(getElements(), getMultiples()), p,
131 [&](
auto elAndMultiple) {
132 auto [el, multiple] = elAndMultiple;
133 p << multiple <<
" x " << el;
135 if (!getElements().
empty())
138 p <<
" : " << getBag().getType().getElementType();
139 p.printOptionalAttrDict((*this)->getAttrs());
143 if (!llvm::all_equal(getElements().getTypes()))
144 return emitOpError() <<
"types of all elements must match";
146 if (getElements().size() > 0)
147 if (getElements()[0].getType() != getBag().getType().getElementType())
148 return emitOpError() <<
"operand types must match bag element type";
157 LogicalResult TestOp::verifyRegions() {
158 if (!getTarget().entryTypesMatch(getBody()->getArgumentTypes()))
159 return emitOpError(
"argument types must match dict entry types");
168 LogicalResult TargetOp::verifyRegions() {
169 if (!getTarget().entryTypesMatch(
170 getBody()->getTerminator()->getOperandTypes()))
171 return emitOpError(
"terminator operand types must match dict entry types");
180 #define GET_OP_CLASSES
181 #include "circt/Dialect/RTG/IR/RTG.cpp.inc"
static InstancePath empty
static LogicalResult verify(Value clock, bool eventExists, mlir::Location loc)
Direction get(bool isOutput)
Returns an output direction if isOutput is true, otherwise returns an input direction.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.