llvm / llvm/circt

[FIRRTL] Better Annotation Mutation APIs

Open
#2,022 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
2.2k
Forks
524
Avg merge
3d 2h
Merged PRs (30d)
46

Description

The existing `AnnotationSet` and `Annotation` APIs are immensely better than working with raw dictionaries. However, these are difficult to mutate. When you need to mutate these, you usually wind up iterating over the whole `AnnotationSet`, rewriting one field of one annotation, and then creating a new dictionary. This is both tedious and inefficient.

First, we should provide some higher-level APIs for working with `AnnotationSet`. Ideas include:

- `AnnotationSet::map`
- `AnnotationSet::filter`
- `AnnotationSet::filter_map`

More mutable APIs are also reasonable, but I'm not sure exactly what to call them. Behind the scenes these will efficiently rewrite the underlying data structures to avoid dumb stuff like copying everything.

This _may_ require updates to enable better mutation of `DictionaryAttr` in upstream MLIR.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing the existing AnnotationSet and Annotation APIs and how they represent their underlying data. Clarify the desired map, filter, and filter_map semantics, then investigate whether upstream MLIR DictionaryAttr mutation support is required; done means an agreed, efficient mutation API with its behavior defined.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.