Generate a "raw" constructor that simply constructs, but does not emit the assembly instruction: ```text (decl x64_ _raw ( ) AssemblerOutputs) (extern constructor x64_ _raw x64_ _raw) ``` Using the "raw" constructor, we also generate "emitter" constructors (see [`IsleConstructor`]). E.g., instructions that write to a register will return the register: ```text (decl x64_<in
(f: &mut Formatter, inst: &Inst)
| 530 | /// |
| 531 | /// This function panics if the instruction has no operands. |
| 532 | fn generate_isle_inst_decls(f: &mut Formatter, inst: &Inst) { |
| 533 | let (trap_type, trap_name) = if inst.has_trap { |
| 534 | (Some("TrapCode".to_string()), Some("trap".to_string())) |
| 535 | } else { |
| 536 | (None, None) |
| 537 | }; |
| 538 | |
| 539 | // First declare the "raw" constructor which is implemented in Rust |
| 540 | // with `generate_isle_macro` above. This is an "extern" constructor |
| 541 | // with relatively raw types. This is not intended to be used by |
| 542 | // general lowering rules in ISLE. |
| 543 | let struct_name = inst.name(); |
| 544 | let raw_name = format!("x64_{struct_name}_raw"); |
| 545 | let params = inst |
| 546 | .format |
| 547 | .operands |
| 548 | .iter() |
| 549 | .filter(|o| is_raw_operand_param(o)) |
| 550 | .collect::<Vec<_>>(); |
| 551 | let raw_param_tys = params |
| 552 | .iter() |
| 553 | .map(|o| isle_param_raw(o)) |
| 554 | .chain(trap_type.clone()) |
| 555 | .collect::<Vec<_>>() |
| 556 | .join(" "); |
| 557 | fmtln!(f, "(decl {raw_name} ({raw_param_tys}) AssemblerOutputs)"); |
| 558 | fmtln!(f, "(extern constructor {raw_name} {raw_name})"); |
| 559 | |
| 560 | // Next, for each "emitter" ISLE constructor being generated, synthesize |
| 561 | // a pure-ISLE constructor which delegates appropriately to the `*_raw` |
| 562 | // constructor above. |
| 563 | // |
| 564 | // The main purpose of these constructors is to have faithful type |
| 565 | // signatures for the SSA nature of VCode/ISLE, effectively translating |
| 566 | // x64's type system to ISLE/VCode's type system. |
| 567 | // |
| 568 | // Note that the `params` from above are partitioned into explicit/implicit |
| 569 | // parameters based on the `ctor` we're generating here. That means, for |
| 570 | // example, that a write-only `RegMem` will have one ctor which produces a |
| 571 | // register that takes no argument, but one ctors will take an `Amode` which |
| 572 | // is the address to write to. |
| 573 | for ctor in isle_constructors(&inst.format) { |
| 574 | let suffix = ctor.suffix(); |
| 575 | let rule_name = format!("x64_{struct_name}{suffix}"); |
| 576 | let result_ty = ctor.result_ty(); |
| 577 | let mut explicit_params = Vec::new(); |
| 578 | let mut implicit_params = Vec::new(); |
| 579 | for param in params.iter() { |
| 580 | if param.mutability.is_read() || ctor.includes_write_only_reg_mem() { |
| 581 | explicit_params.push(param); |
| 582 | } else { |
| 583 | implicit_params.push(param); |
| 584 | } |
| 585 | } |
| 586 | assert!(implicit_params.len() <= 1); |
| 587 | let param_tys = explicit_params |
| 588 | .iter() |
| 589 | .map(|o| isle_param_for_ctor(o, ctor)) |
no test coverage detected