Skip to content

Commit 040ab7d

Browse files
committed
Add asm label support to THIR
1 parent 93fa857 commit 040ab7d

File tree

5 files changed

+15
-2
lines changed

5 files changed

+15
-2
lines changed

compiler/rustc_middle/src/thir.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,9 @@ pub enum InlineAsmOperand<'tcx> {
565565
SymStatic {
566566
def_id: DefId,
567567
},
568+
Label {
569+
block: BlockId,
570+
},
568571
}
569572

570573
#[derive(Copy, Clone, Debug, PartialEq, HashStable)]

compiler/rustc_middle/src/thir/visit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ pub fn walk_expr<'thir, 'tcx: 'thir, V: Visitor<'thir, 'tcx>>(
162162
| Const { value: _, span: _ }
163163
| SymFn { value: _, span: _ }
164164
| SymStatic { def_id: _ } => {}
165+
Label { block } => visitor.visit_block(&visitor.thir()[*block]),
165166
}
166167
}
167168
}

compiler/rustc_mir_build/src/build/expr/into.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
455455
thir::InlineAsmOperand::SymStatic { def_id } => {
456456
mir::InlineAsmOperand::SymStatic { def_id }
457457
}
458+
thir::InlineAsmOperand::Label { .. } => {
459+
todo!()
460+
}
458461
})
459462
.collect();
460463

compiler/rustc_mir_build/src/thir/cx/expr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -656,8 +656,8 @@ impl<'tcx> Cx<'tcx> {
656656
hir::InlineAsmOperand::SymStatic { path: _, def_id } => {
657657
InlineAsmOperand::SymStatic { def_id }
658658
}
659-
hir::InlineAsmOperand::Label { .. } => {
660-
todo!()
659+
hir::InlineAsmOperand::Label { block } => {
660+
InlineAsmOperand::Label { block: self.mirror_block(block) }
661661
}
662662
})
663663
.collect(),

compiler/rustc_mir_build/src/thir/print.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,12 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
889889
print_indented!(self, format!("def_id: {:?}", def_id), depth_lvl + 1);
890890
print_indented!(self, "}", depth_lvl + 1);
891891
}
892+
InlineAsmOperand::Label { block } => {
893+
print_indented!(self, "InlineAsmOperand::Block {", depth_lvl);
894+
print_indented!(self, "block:", depth_lvl + 1);
895+
self.print_block(*block, depth_lvl + 2);
896+
print_indented!(self, "}", depth_lvl + 1);
897+
}
892898
}
893899
}
894900
}

0 commit comments

Comments
 (0)