-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
enhancementNew feature or requestNew feature or request
Milestone
Description
Summary
Add cranelift-entity dependency to trunk-ir and implement the core arena-based IR infrastructure.
Scope
- Add
cranelift-entitytocrates/trunk-ir/Cargo.toml - Define typed indices:
OpRef,ValueRef,BlockRef,RegionRef(viaentity_impl!) - Implement
IrContextwithPrimaryMap-backed storage for all node types - Implement CRUD operations:
create_op,remove_op,create_block,create_region, etc. - Implement use-chain tracking in
ValueData(SmallVec<[Use; 4]>) - Implement
replace_all_uses(old, new)(RAUW) with O(uses) complexity - Auto-maintain use-chains on op create/remove
Key Types
pub struct OpRef(u32);
entity_impl!(OpRef, "op");
pub struct Use { pub user: OpRef, pub operand_index: u32 }
pub struct ValueData {
pub def: ValueDef,
pub ty: TypeRef,
pub uses: SmallVec<[Use; 4]>,
}
pub struct OperationData {
pub dialect: Symbol,
pub name: Symbol,
pub operands: EntityList<ValueRef>,
pub results: EntityList<ValueRef>,
pub attributes: BTreeMap<Symbol, Attribute>,
pub regions: SmallVec<[RegionRef; 1]>,
pub successors: SmallVec<[BlockRef; 2]>,
pub location: Location,
pub parent_block: Option<BlockRef>,
}Key Files
crates/trunk-ir/Cargo.tomlcrates/trunk-ir/src/arena/(new module)
Acceptance Criteria
-
cranelift-entityadded as dependency - All typed refs defined with
entity_impl! -
IrContextsupports create/read/remove for ops, values, blocks, regions - Use-chain automatically maintained on create/remove
-
replace_all_usesworks correctly - Unit tests for CRUD and RAUW
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request