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

Method codegen_inline_asm

crates/rustc_codegen_nvvm/src/asm.rs:115–303  ·  view source on GitHub ↗
(
        &mut self,
        template: &[InlineAsmTemplatePiece],
        operands: &[InlineAsmOperandRef<'tcx, Self>],
        options: rustc_ast::InlineAsmOptions,
        line_spans: &[Span],
     

Source from the content-addressed store, hash-verified

113 }
114
115 fn codegen_inline_asm(
116 &mut self,
117 template: &[InlineAsmTemplatePiece],
118 operands: &[InlineAsmOperandRef<'tcx, Self>],
119 options: rustc_ast::InlineAsmOptions,
120 line_spans: &[Span],
121 _inst: Instance,
122 ) {
123 // Collect the types of output operands
124 let mut constraints = vec![];
125 let mut output_types = vec![];
126 let mut op_idx = FxHashMap::default();
127 for (idx, op) in operands.iter().enumerate() {
128 match *op {
129 InlineAsmOperandRef::Out { reg, late, place } => {
130 let ty = if let Some(ref place) = place {
131 place.layout.llvm_type(self)
132 } else {
133 match reg.reg_class() {
134 InlineAsmRegClass::Nvptx(NvptxInlineAsmRegClass::reg16) => {
135 self.type_i16()
136 }
137 InlineAsmRegClass::Nvptx(NvptxInlineAsmRegClass::reg32) => {
138 self.type_i32()
139 }
140 InlineAsmRegClass::Nvptx(NvptxInlineAsmRegClass::reg64) => {
141 self.type_i64()
142 }
143 _ => unreachable!(),
144 }
145 };
146 output_types.push(ty);
147 op_idx.insert(idx, constraints.len());
148 let prefix = if late { "=" } else { "=&" };
149 constraints.push(format!("{}{}", prefix, reg_to_llvm(reg)));
150 }
151 InlineAsmOperandRef::InOut {
152 reg,
153 late,
154 in_value,
155 out_place,
156 } => {
157 let layout = if let Some(ref out_place) = out_place {
158 &out_place.layout
159 } else {
160 // LLVM required tied operands to have the same type,
161 // so we just use the type of the input.
162 &in_value.layout
163 };
164 let ty = layout.llvm_type(self);
165 output_types.push(ty);
166 op_idx.insert(idx, constraints.len());
167 let prefix = if late { "=" } else { "=&" };
168 constraints.push(format!("{}{}", prefix, reg_to_llvm(reg)));
169 }
170 _ => {}
171 }
172 }

Callers

nothing calls this directly

Calls 15

reg_to_llvmFunction · 0.85
newFunction · 0.85
inline_asm_callFunction · 0.85
iterMethod · 0.80
type_i16Method · 0.80
type_i32Method · 0.80
type_i64Method · 0.80
get_fnMethod · 0.80
type_voidMethod · 0.80
type_structMethod · 0.80
apply_callsiteMethod · 0.80
extract_valueMethod · 0.80

Tested by

no test coverage detected