Add avr_target_feature

This commit is contained in:
Taiki Endo 2026-01-09 22:28:05 +09:00
parent 0a13b43612
commit 8cbc623c3a
6 changed files with 48 additions and 4 deletions

View file

@ -373,6 +373,8 @@ declare_features! (
(unstable, async_for_loop, "1.77.0", Some(118898)),
/// Allows `async` trait bound modifier.
(unstable, async_trait_bounds, "1.85.0", Some(62290)),
/// Target features on avr.
(unstable, avr_target_feature, "CURRENT_RUSTC_VERSION", Some(146889)),
/// Allows using Intel AVX10 target features and intrinsics
(unstable, avx10_target_feature, "1.88.0", Some(138843)),
/// Target features on bpf.

View file

@ -577,6 +577,7 @@ symbols! {
automatically_derived,
available_externally,
avr,
avr_target_feature,
avx,
avx10_target_feature,
avx512_target_feature,

View file

@ -898,6 +898,28 @@ static M68K_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
// tidy-alphabetical-end
];
static AVR_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
// tidy-alphabetical-start
("addsubiw", Unstable(sym::avr_target_feature), &[]),
("break", Unstable(sym::avr_target_feature), &[]),
("eijmpcall", Unstable(sym::avr_target_feature), &[]),
("elpm", Unstable(sym::avr_target_feature), &[]),
("elpmx", Unstable(sym::avr_target_feature), &[]),
("ijmpcall", Unstable(sym::avr_target_feature), &[]),
("jmpcall", Unstable(sym::avr_target_feature), &[]),
("lowbytefirst", Unstable(sym::avr_target_feature), &[]),
("lpm", Unstable(sym::avr_target_feature), &[]),
("lpmx", Unstable(sym::avr_target_feature), &[]),
("movw", Unstable(sym::avr_target_feature), &[]),
("mul", Unstable(sym::avr_target_feature), &[]),
("rmw", Unstable(sym::avr_target_feature), &[]),
("spm", Unstable(sym::avr_target_feature), &[]),
("spmx", Unstable(sym::avr_target_feature), &[]),
("sram", Unstable(sym::avr_target_feature), &[]),
("tinyencoding", Unstable(sym::avr_target_feature), &[]),
// tidy-alphabetical-end
];
/// When rustdoc is running, provide a list of all known features so that all their respective
/// primitives may be documented.
///
@ -919,6 +941,7 @@ pub fn all_rust_features() -> impl Iterator<Item = (&'static str, Stability)> {
.chain(IBMZ_FEATURES)
.chain(SPARC_FEATURES)
.chain(M68K_FEATURES)
.chain(AVR_FEATURES)
.cloned()
.map(|(f, s, _)| (f, s))
}
@ -996,8 +1019,8 @@ impl Target {
Arch::S390x => IBMZ_FEATURES,
Arch::Sparc | Arch::Sparc64 => SPARC_FEATURES,
Arch::M68k => M68K_FEATURES,
Arch::Avr => AVR_FEATURES,
Arch::AmdGpu
| Arch::Avr
| Arch::Msp430
| Arch::SpirV
| Arch::Xtensa
@ -1023,11 +1046,11 @@ impl Target {
MIPS_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI
}
Arch::AmdGpu => AMDGPU_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
Arch::Nvptx64 | Arch::Bpf | Arch::M68k => &[], // no vector ABI
Arch::Nvptx64 | Arch::Bpf | Arch::M68k | Arch::Avr => &[], // no vector ABI
Arch::CSky => CSKY_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
// FIXME: for some tier3 targets, we are overly cautious and always give warnings
// when passing args in vector registers.
Arch::Avr | Arch::Msp430 | Arch::SpirV | Arch::Xtensa | Arch::Other(_) => &[],
Arch::Msp430 | Arch::SpirV | Arch::Xtensa | Arch::Other(_) => &[],
}
}

View file

@ -14,6 +14,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
`7e10`
`a`
`aclass`
`addsubiw`
`adx`
`aes`
`altivec`
@ -57,6 +58,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
`bf16`
`bmi1`
`bmi2`
`break`
`bti`
`bulk-memory`
`c`
@ -83,6 +85,9 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
`e2`
`ecv`
`edsp`
`eijmpcall`
`elpm`
`elpmx`
`elrw`
`enhanced-sort`
`ermsb`
@ -148,6 +153,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
`hvxv79`
`hwdiv`
`i8mm`
`ijmpcall`
`isa-68000`
`isa-68010`
`isa-68020`
@ -156,6 +162,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
`isa-68060`
`isa-68881`
`isa-68882`
`jmpcall`
`jsconv`
`kl`
`lahfsahf`
@ -166,6 +173,9 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
`ld-seq-sa`
`leoncasa`
`lor`
`lowbytefirst`
`lpm`
`lpmx`
`lse`
`lse128`
`lse2`
@ -187,11 +197,13 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
`mops`
`movbe`
`movrs`
`movw`
`mp`
`mp1e2`
`msa`
`msync`
`mte`
`mul`
`multivalue`
`mutable-globals`
`neon`
@ -256,6 +268,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
`reference-types`
`relax`
`relaxed-simd`
`rmw`
`rtm`
`rva23u64`
`sb`
@ -308,6 +321,9 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
`sme2p1`
`soft-float`
`spe`
`spm`
`spmx`
`sram`
`ssbs`
`sse`
`sse2`
@ -332,6 +348,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
`tbm`
`thumb-mode`
`thumb2`
`tinyencoding`
`tme`
`transactional-execution`
`trust`

View file

@ -20,6 +20,7 @@
// gate-test-sparc_target_feature
// gate-test-x87_target_feature
// gate-test-m68k_target_feature
// gate-test-avr_target_feature
#[target_feature(enable = "x87")]
//~^ ERROR: currently unstable

View file

@ -1,5 +1,5 @@
error[E0658]: the target feature `x87` is currently unstable
--> $DIR/gate.rs:24:18
--> $DIR/gate.rs:25:18
|
LL | #[target_feature(enable = "x87")]
| ^^^^^^^^^^^^^^