diff --git a/crates/ir/src/global_variable.rs b/crates/ir/src/global_variable.rs index 812657f0..8c80193b 100644 --- a/crates/ir/src/global_variable.rs +++ b/crates/ir/src/global_variable.rs @@ -55,6 +55,12 @@ impl GlobalVariableStore { pub struct GlobalVariable(pub u32); cranelift_entity::entity_impl!(GlobalVariable); +impl GlobalVariable { + pub fn ty(self, module: &ModuleCtx) -> Type { + module.with_gv_store(|s| s.ty(self)) + } +} + impl WriteWithModule for GlobalVariable { fn write(&self, module: &ModuleCtx, w: &mut impl io::Write) -> io::Result<()> { module.with_gv_store(|s| s.gv_data(*self).write(module, w)) diff --git a/crates/ir/src/types.rs b/crates/ir/src/types.rs index 29306ca9..9048a197 100644 --- a/crates/ir/src/types.rs +++ b/crates/ir/src/types.rs @@ -167,6 +167,10 @@ impl Type { Some(ctx.with_ty_store(|s| s.resolve_compound(cmpd).clone())) } + + pub fn to_ptr(self, ctx: &ModuleCtx) -> Type { + ctx.with_ty_store_mut(|s| s.make_ptr(self)) + } } impl cmp::PartialOrd for Type {