MCPcopy Create free account
hub / github.com/Rust-GPU/rust-gpu / codegen_asm

Method codegen_asm

crates/rustc_codegen_spirv/src/builder/spirv_asm.rs:409–498  ·  view source on GitHub ↗
(
        &mut self,
        id_map: &mut FxHashMap<&'a str, Word>,
        defined_ids: &mut FxHashSet<Word>,
        id_to_type_map: &mut FxHashMap<Word, Word>,
        asm_block: &mut AsmBlock,
   

Source from the content-addressed store, hash-verified

407 }
408
409 fn codegen_asm<'a>(
410 &mut self,
411 id_map: &mut FxHashMap<&'a str, Word>,
412 defined_ids: &mut FxHashSet<Word>,
413 id_to_type_map: &mut FxHashMap<Word, Word>,
414 asm_block: &mut AsmBlock,
415 mut tokens: impl Iterator<Item = Token<'a, 'cx, 'tcx>>,
416 ) where
417 'cx: 'a,
418 'tcx: 'a,
419 {
420 let mut first_token = match tokens.next() {
421 Some(tok) => tok,
422 None => return,
423 };
424 // Parse result_id in front of instruction:
425 // %z = OpAdd %ty %x %y
426 let out_register = if match first_token {
427 Token::Placeholder(_, _) => true,
428 Token::Word(id_str) if id_str.starts_with('%') => true,
429 Token::Word(_) | Token::String(_) | Token::Typeof(_, _, _) => false,
430 } {
431 let result_id = match self.parse_id_out(id_map, defined_ids, first_token) {
432 Some(result_id) => result_id,
433 None => return,
434 };
435 if let Some(Token::Word("=")) = tokens.next() {
436 } else {
437 self.err("expected equals after result id specifier");
438 return;
439 }
440 first_token = if let Some(tok) = tokens.next() {
441 tok
442 } else {
443 self.err("expected instruction after equals");
444 return;
445 };
446 Some(result_id)
447 } else {
448 None
449 };
450 let inst_name = match first_token {
451 Token::Word(inst_name) => inst_name,
452 Token::String(_) => {
453 self.err("cannot use a string as an instruction");
454 return;
455 }
456 Token::Placeholder(_, span) | Token::Typeof(_, span, _) => {
457 self.tcx
458 .sess
459 .span_err(span, "cannot use a dynamic value as an instruction type");
460 return;
461 }
462 };
463 let inst_class = inst_name
464 .strip_prefix("Op")
465 .and_then(|n| self.instruction_table.table.get(n));
466 let inst_class = if let Some(inst) = inst_class {

Callers 1

codegen_inline_asmMethod · 0.80

Calls 11

parse_id_outMethod · 0.80
errMethod · 0.80
idMethod · 0.80
parse_operandsMethod · 0.80
insertMethod · 0.80
insert_instMethod · 0.80
nextMethod · 0.45
getMethod · 0.45
emitMethod · 0.45
storeMethod · 0.45
defMethod · 0.45

Tested by

no test coverage detected