feat: add ISA feature gating per Cortex-M variant#45
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CortexMVariant(DSP, FPU single/double, TrustZone, Helium)requires_fpu()andrequires_double_precision_fpu()classification toArmOpvalidate_instructions()pass between instruction selection and encodingUnsupportedInstructionerror when targeting platform without ISA featuresFirst step toward provable platform-correct compilation — the compiler now guarantees it never emits an instruction the target can't execute.
synth-core/src/target.rsTargetSpecsynth-core/src/error.rsUnsupportedInstructionerror variantsynth-synthesis/src/rules.rsrequires_fpu(),requires_double_precision_fpu(),instruction_name()synth-synthesis/src/instruction_selector.rsvalidate_instructions()functionsynth-backend/src/arm_backend.rsTest plan
cargo clippycleancargo fmt --checkclean🤖 Generated with Claude Code