Skip to content

Commit 35f138e

Browse files
authored
Merge pull request #1075 from 0xMiden/mooori/lower-const-pointer
feat: add lowering for `hir::ConstantPointer`
2 parents 3906a65 + d11d776 commit 35f138e

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

codegen/masm/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ fn lower_hir_ops(info: &mut midenc_hir::DialectInfo) {
152152
info.register_operation_trait::<hir::Cast, dyn HirLowering>();
153153
info.register_operation_trait::<hir::Bitcast, dyn HirLowering>();
154154
//info.register_operation_trait::<hir::ConstantBytes, dyn HirLowering>();
155+
info.register_operation_trait::<hir::ConstantPointer, dyn HirLowering>();
155156
info.register_operation_trait::<hir::Exec, dyn HirLowering>();
156157
info.register_operation_trait::<hir::Call, dyn HirLowering>();
157158
info.register_operation_trait::<hir::Store, dyn HirLowering>();

codegen/masm/src/lower/lowering.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,14 @@ impl HirLowering for hir::AssertEq {
441441
}
442442
}
443443

444+
impl HirLowering for hir::ConstantPointer {
445+
fn emit(&self, emitter: &mut BlockEmitter<'_>) -> Result<(), Report> {
446+
let addr = self.get_value().addr();
447+
emitter.inst_emitter(self.as_operation()).literal(addr, self.span());
448+
Ok(())
449+
}
450+
}
451+
444452
impl HirLowering for ub::Unreachable {
445453
fn emit(&self, emitter: &mut BlockEmitter<'_>) -> Result<(), Report> {
446454
// This instruction, if reached, must cause the VM to trap, so we emit an assertion that

0 commit comments

Comments
 (0)