diff options
| author | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2023-02-05 18:42:30 +0000 |
|---|---|---|
| committer | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2023-02-05 18:48:40 +0000 |
| commit | 178e267977c646e34a1440cb10e32e0716e2241e (patch) | |
| tree | 21fa3bee05342d462d89cf05c2ca775a7dcad3a1 | |
| parent | df6b06790057ca32584a6ed6bfdd02045594137d (diff) | |
| download | rust-178e267977c646e34a1440cb10e32e0716e2241e.tar.gz rust-178e267977c646e34a1440cb10e32e0716e2241e.zip | |
Implement sym operands for global asm
| -rw-r--r-- | src/global_asm.rs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/global_asm.rs b/src/global_asm.rs index 9aee4908c5c..46c78ce6a1e 100644 --- a/src/global_asm.rs +++ b/src/global_asm.rs @@ -39,8 +39,22 @@ pub(crate) fn codegen_global_asm_item(tcx: TyCtxt<'_>, global_asm: &mut String, ); global_asm.push_str(&string); } - InlineAsmOperand::SymFn { anon_const: _ } => todo!(), - InlineAsmOperand::SymStatic { path: _, def_id: _ } => todo!(), + InlineAsmOperand::SymFn { anon_const } => { + let ty = tcx.typeck_body(anon_const.body).node_type(anon_const.hir_id); + let instance = match ty.kind() { + &ty::FnDef(def_id, substs) => Instance::new(def_id, substs), + _ => span_bug!(op_sp, "asm sym is not a function"), + }; + let symbol = tcx.symbol_name(instance); + // FIXME handle the case where the function was made private to the + // current codegen unit + global_asm.push_str(symbol.name); + } + InlineAsmOperand::SymStatic { path: _, def_id } => { + let instance = Instance::mono(tcx, def_id).polymorphize(tcx); + let symbol = tcx.symbol_name(instance); + global_asm.push_str(symbol.name); + } InlineAsmOperand::In { .. } | InlineAsmOperand::Out { .. } | InlineAsmOperand::InOut { .. } |
