Returns true if we believe this `OpcodeSignature` should compile correctly for the given target triple. We currently have a range of known issues with specific lowerings on specific backends, and we don't want to get fuzz bug reports for those. Over time our goal is to eliminate all of these exceptions.
(triple: &Triple, op: Opcode, args: &[Type], rets: &[Type])
| 475 | /// fuzz bug reports for those. Over time our goal is to eliminate all of these |
| 476 | /// exceptions. |
| 477 | fn valid_for_target(triple: &Triple, op: Opcode, args: &[Type], rets: &[Type]) -> bool { |
| 478 | // Rule out invalid combinations that we don't yet have a good way of rejecting with the |
| 479 | // instruction DSL type constraints. |
| 480 | match op { |
| 481 | Opcode::FcvtToUintSat | Opcode::FcvtToSintSat => { |
| 482 | assert_eq!(args.len(), 1); |
| 483 | assert_eq!(rets.len(), 1); |
| 484 | |
| 485 | let arg = args[0]; |
| 486 | let ret = rets[0]; |
| 487 | |
| 488 | // Vector arguments must produce vector results, and scalar arguments must produce |
| 489 | // scalar results. |
| 490 | if arg.is_vector() != ret.is_vector() { |
| 491 | return false; |
| 492 | } |
| 493 | |
| 494 | if arg.is_vector() && ret.is_vector() { |
| 495 | // Vector conversions must have the same number of lanes, and the lanes must be the |
| 496 | // same bit-width. |
| 497 | if arg.lane_count() != ret.lane_count() { |
| 498 | return false; |
| 499 | } |
| 500 | |
| 501 | if arg.lane_of().bits() != ret.lane_of().bits() { |
| 502 | return false; |
| 503 | } |
| 504 | } |
| 505 | } |
| 506 | |
| 507 | Opcode::Bitcast => { |
| 508 | assert_eq!(args.len(), 1); |
| 509 | assert_eq!(rets.len(), 1); |
| 510 | |
| 511 | let arg = args[0]; |
| 512 | let ret = rets[0]; |
| 513 | |
| 514 | // The opcode generator still allows bitcasts between different sized types, but these |
| 515 | // are rejected in the verifier. |
| 516 | if arg.bits() != ret.bits() { |
| 517 | return false; |
| 518 | } |
| 519 | } |
| 520 | |
| 521 | // This requires precise runtime integration so it's not supported at |
| 522 | // all in fuzzgen just yet. |
| 523 | Opcode::StackSwitch => return false, |
| 524 | |
| 525 | _ => {} |
| 526 | } |
| 527 | |
| 528 | match triple.architecture { |
| 529 | Architecture::X86_64 => { |
| 530 | exceptions!( |
| 531 | op, |
| 532 | args, |
| 533 | rets, |
| 534 | (Opcode::UmulOverflow | Opcode::SmulOverflow, &[I128, I128]), |
no test coverage detected