Skip to content

Commit ab50d42

Browse files
committed
Add asm label support to THIR
1 parent 30ba978 commit ab50d42

File tree

5 files changed

+15
-2
lines changed

5 files changed

+15
-2
lines changed

compiler/rustc_middle/src/thir.rs

+3
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,9 @@ pub enum InlineAsmOperand<'tcx> {
574574
SymStatic {
575575
def_id: DefId,
576576
},
577+
Label {
578+
block: BlockId,
579+
},
577580
}
578581

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

compiler/rustc_middle/src/thir/visit.rs

+1
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

+3
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
449449
thir::InlineAsmOperand::SymStatic { def_id } => {
450450
mir::InlineAsmOperand::SymStatic { def_id }
451451
}
452+
thir::InlineAsmOperand::Label { .. } => {
453+
todo!()
454+
}
452455
})
453456
.collect();
454457

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -650,8 +650,8 @@ impl<'tcx> Cx<'tcx> {
650650
hir::InlineAsmOperand::SymStatic { path: _, def_id } => {
651651
InlineAsmOperand::SymStatic { def_id }
652652
}
653-
hir::InlineAsmOperand::Label { .. } => {
654-
todo!()
653+
hir::InlineAsmOperand::Label { block } => {
654+
InlineAsmOperand::Label { block: self.mirror_block(block) }
655655
}
656656
})
657657
.collect(),

compiler/rustc_mir_build/src/thir/print.rs

+6
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,12 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
910910
print_indented!(self, format!("def_id: {:?}", def_id), depth_lvl + 1);
911911
print_indented!(self, "}", depth_lvl + 1);
912912
}
913+
InlineAsmOperand::Label { block } => {
914+
print_indented!(self, "InlineAsmOperand::Block {", depth_lvl);
915+
print_indented!(self, "block:", depth_lvl + 1);
916+
self.print_block(*block, depth_lvl + 2);
917+
print_indented!(self, "}", depth_lvl + 1);
918+
}
913919
}
914920
}
915921
}

0 commit comments

Comments
 (0)