MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / isle_constructors

Function isle_constructors

cranelift/codegen/meta/src/gen_asm.rs:404–502  ·  view source on GitHub ↗

Returns the ISLE constructors that are going to be used when generating this instruction. Note that one instruction might need multiple constructors, such as one for operating on memory and one for operating on registers.

(format: &Format)

Source from the content-addressed store, hash-verified

402/// Note that one instruction might need multiple constructors, such as one
403/// for operating on memory and one for operating on registers.
404fn isle_constructors(format: &Format) -> Vec<IsleConstructor> {
405 use Mutability::*;
406 use OperandKind::*;
407
408 let write_operands = format
409 .operands
410 .iter()
411 .filter(|o| o.mutability.is_write())
412 .collect::<Vec<_>>();
413 match &write_operands[..] {
414 [] => {
415 if format.eflags.is_write() {
416 vec![IsleConstructor::ProducesFlagsSideEffect]
417 } else {
418 vec![IsleConstructor::NoReturnSideEffect]
419 }
420 }
421 [one] => match one.mutability {
422 Read => unreachable!(),
423 ReadWrite | Write => match one.location.kind() {
424 Imm(_) => unreachable!(),
425 // One read/write register output? Output the instruction
426 // and that register.
427 Reg(r) | FixedReg(r) => match r.reg_class().unwrap() {
428 RegClass::Xmm => {
429 assert!(!format.eflags.is_read());
430 vec![IsleConstructor::RetXmm]
431 }
432 RegClass::Gpr => {
433 if format.eflags.is_read() {
434 vec![IsleConstructor::ConsumesFlagsReturnsGpr]
435 } else {
436 vec![IsleConstructor::RetGpr]
437 }
438 }
439 },
440 // One read/write memory operand? Output a side effect.
441 Mem(_) => {
442 assert!(!format.eflags.is_read());
443 vec![IsleConstructor::RetMemorySideEffect]
444 }
445 // One read/write reg-mem output? We need constructors for
446 // both variants.
447 RegMem(rm) => match rm.reg_class().unwrap() {
448 RegClass::Xmm => {
449 assert!(!format.eflags.is_read());
450 vec![
451 IsleConstructor::RetXmm,
452 IsleConstructor::RetMemorySideEffect,
453 ]
454 }
455 RegClass::Gpr => {
456 if format.eflags.is_read() {
457 // FIXME: should expand this to include "consumes
458 // flags plus side effect" to model the
459 // memory-writing variant too. For example this
460 // means there's no memory-writing variant of
461 // `setcc` instructions generated.

Callers 1

generate_isle_inst_declsFunction · 0.85

Calls 6

is_writeMethod · 0.80
is_readMethod · 0.80
iterMethod · 0.45
kindMethod · 0.45
unwrapMethod · 0.45
reg_classMethod · 0.45

Tested by

no test coverage detected