MCPcopy Create free account
hub / github.com/Rust-GPU/rust-cuda / codegen_global_asm

Method codegen_global_asm

crates/rustc_codegen_nvvm/src/asm.rs:307–343  ·  view source on GitHub ↗
(
        &self,
        template: &[InlineAsmTemplatePiece],
        operands: &[GlobalAsmOperandRef],
        _options: InlineAsmOptions,
        _line_spans: &[Span],
    )

Source from the content-addressed store, hash-verified

305
306impl<'ll, 'tcx> AsmMethods for CodegenCx<'ll, 'tcx> {
307 fn codegen_global_asm(
308 &self,
309 template: &[InlineAsmTemplatePiece],
310 operands: &[GlobalAsmOperandRef],
311 _options: InlineAsmOptions,
312 _line_spans: &[Span],
313 ) {
314 // Build the template string
315 let mut template_str = String::new();
316 for piece in template {
317 match *piece {
318 InlineAsmTemplatePiece::String(ref s) => template_str.push_str(s),
319 InlineAsmTemplatePiece::Placeholder {
320 operand_idx,
321 modifier: _,
322 span: _,
323 } => {
324 match operands[operand_idx] {
325 GlobalAsmOperandRef::Const { ref string } => {
326 // Const operands get injected directly into the
327 // template. Note that we don't need to escape $
328 // here unlike normal inline assembly.
329 template_str.push_str(string);
330 }
331 }
332 }
333 }
334 }
335
336 unsafe {
337 llvm::LLVMRustAppendModuleInlineAsm(
338 self.llmod,
339 template_str.as_ptr().cast(),
340 template_str.len(),
341 );
342 }
343 }
344}
345
346fn reg_to_llvm(reg: InlineAsmRegOrRegClass) -> String {

Callers

nothing calls this directly

Calls 5

newFunction · 0.85
as_ptrMethod · 0.80
castMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected