18 using namespace circt;
19 using namespace firrtl;
25 auto clazz = anno.getAs<StringAttr>(
"class").getValue();
26 auto *context = anno.getContext();
27 ImplicitLocOpBuilder builder(target.
ref.
getOp()->getLoc(), context);
31 if (
auto portTarget = dyn_cast<PortAnnoTarget>(target.
ref)) {
32 auto portNum = portTarget.getImpl().getPortNo();
33 if (
auto module = dyn_cast<FModuleOp>(portTarget.getOp())) {
35 builder.setInsertionPointToStart(module.getBodyBlock());
37 builder.setInsertionPointToEnd(module.getBodyBlock());
41 }
else if (
auto ext = dyn_cast<FExtModuleOp>(portTarget.getOp())) {
45 if (paths.size() > 1) {
46 mlir::emitError(state.
circuit.getLoc())
47 <<
"cannot resolve a unique instance path from the "
48 "external module target "
52 inst = cast<InstanceOp>(paths[0].leaf());
54 inst = cast<InstanceOp>(target.
instances.back());
57 builder.setInsertionPointAfter(inst);
61 return mlir::emitError(state.
circuit.getLoc())
62 <<
"Annotation has invalid target: " << anno;
64 }
else if (
auto opResult = dyn_cast<OpAnnoTarget>(target.
ref)) {
65 if (target.
isOpOfType<WireOp, RegOp, RegResetOp>()) {
66 auto *targetBase = opResult.getOp();
67 builder.setInsertionPointAfter(targetBase);
71 return mlir::emitError(state.
circuit.getLoc())
72 <<
"Annotation targets non-wireable operation: " << anno;
75 return mlir::emitError(state.
circuit.getLoc())
76 <<
"Annotation has invalid target: " << anno;
80 auto pin = anno.getAs<StringAttr>(
"pin");
82 return mlir::emitError(state.
circuit.getLoc())
83 <<
"Annotation does not have an associated pin name: " << anno;
92 return mlir::emitError(state.
circuit.getLoc())
94 <<
" defined for pin " << pin;
constexpr const char * wiringSinkAnnoClass
constexpr const char * wiringSourceAnnoClass
LogicalResult applyWiring(const AnnoPathValue &target, DictionaryAttr anno, ApplyState &state)
Consume SourceAnnotation and SinkAnnotation, storing into state.
Value getValueByFieldID(ImplicitLocOpBuilder builder, Value value, unsigned fieldID)
This gets the value targeted by a field id.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
SmallVector< InstanceOp > instances
Operation * getOp() const
State threaded through functions for resolving and applying annotations.
DenseSet< InstanceOp > wiringProblemInstRefs
DenseMap< StringAttr, LegacyWiringProblem > legacyWiringProblems
InstancePathCache & instancePathCache
ArrayRef< InstancePath > getAbsolutePaths(ModuleOpInterface op)