Skip to content

Commit

Permalink
Implement sym operands for global asm
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed Feb 5, 2023
1 parent c5a7b6b commit 2d4141d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/global_asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,20 @@ 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);
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 { .. }
Expand Down

0 comments on commit 2d4141d

Please sign in to comment.