Skip to content

question: add index method for entities #26

Description

@hsqStephenZhang

I wonder if it's better to provide an index method or trait for the Value or BasicBlock since their number starts from a fixed NUMBER could not be created otherwise.
It would be helpful for generating more readable information like Debug trait for Value, or make it indexable for indexmap and so on. Cranelift and rustc both encode these entities in usize starting from 0 afaik.

for example

rustc_index::newtype_index! {
    #[debug_format = "bb{}"]
    pub struct BasicBlock {
        const START_BLOCK = 0;
    }
}

here is a usage when i'm generating dot file for the IR, it would be more readable to have value number starting from 0.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions