Add codegen for global_asm! sym operands
This commit is contained in:
parent
dc345d8bff
commit
547405e801
11 changed files with 137 additions and 22 deletions
|
@ -312,11 +312,11 @@ impl<'ll, 'tcx> AsmBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl AsmMethods for CodegenCx<'_, '_> {
|
||||
impl<'tcx> AsmMethods<'tcx> for CodegenCx<'_, 'tcx> {
|
||||
fn codegen_global_asm(
|
||||
&self,
|
||||
template: &[InlineAsmTemplatePiece],
|
||||
operands: &[GlobalAsmOperandRef],
|
||||
operands: &[GlobalAsmOperandRef<'tcx>],
|
||||
options: InlineAsmOptions,
|
||||
_line_spans: &[Span],
|
||||
) {
|
||||
|
@ -342,6 +342,29 @@ impl AsmMethods for CodegenCx<'_, '_> {
|
|||
// here unlike normal inline assembly.
|
||||
template_str.push_str(string);
|
||||
}
|
||||
GlobalAsmOperandRef::SymFn { instance } => {
|
||||
let llval = self.get_fn(instance);
|
||||
self.add_compiler_used_global(llval);
|
||||
let symbol = llvm::build_string(|s| unsafe {
|
||||
llvm::LLVMRustGetMangledName(llval, s);
|
||||
})
|
||||
.expect("symbol is not valid UTF-8");
|
||||
template_str.push_str(&symbol);
|
||||
}
|
||||
GlobalAsmOperandRef::SymStatic { def_id } => {
|
||||
let llval = self
|
||||
.renamed_statics
|
||||
.borrow()
|
||||
.get(&def_id)
|
||||
.copied()
|
||||
.unwrap_or_else(|| self.get_static(def_id));
|
||||
self.add_compiler_used_global(llval);
|
||||
let symbol = llvm::build_string(|s| unsafe {
|
||||
llvm::LLVMRustGetMangledName(llval, s);
|
||||
})
|
||||
.expect("symbol is not valid UTF-8");
|
||||
template_str.push_str(&symbol);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue