Add asm label support to THIR

This commit is contained in:
Gary Guo 2023-12-25 21:19:04 +00:00
parent 93fa8579c6
commit 040ab7d4b6
5 changed files with 15 additions and 2 deletions

View File

@ -565,6 +565,9 @@ pub enum InlineAsmOperand<'tcx> {
SymStatic { SymStatic {
def_id: DefId, def_id: DefId,
}, },
Label {
block: BlockId,
},
} }
#[derive(Copy, Clone, Debug, PartialEq, HashStable)] #[derive(Copy, Clone, Debug, PartialEq, HashStable)]

View File

@ -162,6 +162,7 @@ pub fn walk_expr<'thir, 'tcx: 'thir, V: Visitor<'thir, 'tcx>>(
| Const { value: _, span: _ } | Const { value: _, span: _ }
| SymFn { value: _, span: _ } | SymFn { value: _, span: _ }
| SymStatic { def_id: _ } => {} | SymStatic { def_id: _ } => {}
Label { block } => visitor.visit_block(&visitor.thir()[*block]),
} }
} }
} }

View File

@ -455,6 +455,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
thir::InlineAsmOperand::SymStatic { def_id } => { thir::InlineAsmOperand::SymStatic { def_id } => {
mir::InlineAsmOperand::SymStatic { def_id } mir::InlineAsmOperand::SymStatic { def_id }
} }
thir::InlineAsmOperand::Label { .. } => {
todo!()
}
}) })
.collect(); .collect();

View File

@ -656,8 +656,8 @@ impl<'tcx> Cx<'tcx> {
hir::InlineAsmOperand::SymStatic { path: _, def_id } => { hir::InlineAsmOperand::SymStatic { path: _, def_id } => {
InlineAsmOperand::SymStatic { def_id } InlineAsmOperand::SymStatic { def_id }
} }
hir::InlineAsmOperand::Label { .. } => { hir::InlineAsmOperand::Label { block } => {
todo!() InlineAsmOperand::Label { block: self.mirror_block(block) }
} }
}) })
.collect(), .collect(),

View File

@ -889,6 +889,12 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
print_indented!(self, format!("def_id: {:?}", def_id), depth_lvl + 1); print_indented!(self, format!("def_id: {:?}", def_id), depth_lvl + 1);
print_indented!(self, "}", depth_lvl + 1); print_indented!(self, "}", depth_lvl + 1);
} }
InlineAsmOperand::Label { block } => {
print_indented!(self, "InlineAsmOperand::Block {", depth_lvl);
print_indented!(self, "block:", depth_lvl + 1);
self.print_block(*block, depth_lvl + 2);
print_indented!(self, "}", depth_lvl + 1);
}
} }
} }
} }