Skip to content

feat: add ISA feature gating per Cortex-M variant#45

Merged
avrabe merged 1 commit intomainfrom
feat/isa-feature-gating
Mar 17, 2026
Merged

feat: add ISA feature gating per Cortex-M variant#45
avrabe merged 1 commit intomainfrom
feat/isa-feature-gating

Conversation

@avrabe
Copy link
Contributor

@avrabe avrabe commented Mar 17, 2026

Summary

  • Adds ISA capability methods to CortexMVariant (DSP, FPU single/double, TrustZone, Helium)
  • Adds requires_fpu() and requires_double_precision_fpu() classification to ArmOp
  • Adds validate_instructions() pass between instruction selection and encoding
  • Returns actionable UnsupportedInstruction error when targeting platform without ISA features
  • Prevents emitting VFP instructions on non-FPU targets (e.g., Cortex-M3, Cortex-M4)

First step toward provable platform-correct compilation — the compiler now guarantees it never emits an instruction the target can't execute.

File Change
synth-core/src/target.rs +5 ISA capability methods, +2 on TargetSpec
synth-core/src/error.rs +UnsupportedInstruction error variant
synth-synthesis/src/rules.rs +requires_fpu(), requires_double_precision_fpu(), instruction_name()
synth-synthesis/src/instruction_selector.rs +validate_instructions() function
synth-backend/src/arm_backend.rs Wire validation into compilation pipeline

Test plan

  • 18 new tests (7 target, 5 validation, 4 end-to-end, 2 integration)
  • 632 total tests pass (+18 from baseline)
  • cargo clippy clean
  • cargo fmt --check clean
  • CI passes

🤖 Generated with Claude Code

…ions

Add compile-time validation that ensures the compiler never emits ARM
instructions unsupported by the target platform. This is critical for
correctness: e.g., Cortex-M3/M4 (no FPU) must not receive VFP
instructions, and single-precision targets must not receive F64 ops.

Changes:
- Add ISA capability methods to CortexMVariant (has_dsp, has_fpu,
  has_trustzone, has_helium) and TargetSpec (has_single/double_precision)
- Add ArmOp::requires_fpu() and requires_double_precision_fpu() methods
  with human-readable instruction_name() for error messages
- Add validate_instructions() pass between instruction selection and
  encoding in the compilation pipeline
- Add UnsupportedInstruction error variant to synth-core
- Add 18 new tests covering ISA feature queries, instruction validation,
  and end-to-end compilation gating across M3/M4/M4F/M7DP targets

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@avrabe avrabe merged commit 80fecb6 into main Mar 17, 2026
10 checks passed
@avrabe avrabe deleted the feat/isa-feature-gating branch March 17, 2026 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant