diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 93e5588146e14..6769b993d5378 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -318,6 +318,7 @@ declare_features! ( (unstable, aarch64_ver_target_feature, "1.27.0", Some(44839)), (unstable, apx_target_feature, "1.88.0", Some(139284)), (unstable, arm_target_feature, "1.27.0", Some(44839)), + (unstable, avr_target_feature, "CURRENT_RUSTC_VERSION", Some(146889)), (unstable, bpf_target_feature, "1.54.0", Some(44839)), (unstable, csky_target_feature, "1.73.0", Some(44839)), (unstable, ermsb_target_feature, "1.49.0", Some(44839)), diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 4fef65f46b1fd..65d94a90aff9b 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -551,6 +551,7 @@ symbols! { autodiff_reverse, automatically_derived, available_externally, + avr_target_feature, avx, avx10_target_feature, avx512_target_feature, @@ -2197,6 +2198,7 @@ symbols! { three_way_compare, thumb2, thumb_mode: "thumb-mode", + tinyencoding, tmm_reg, to_owned_method, to_string, diff --git a/compiler/rustc_target/src/asm/avr.rs b/compiler/rustc_target/src/asm/avr.rs index 55d393c81d3ec..3d20734553a15 100644 --- a/compiler/rustc_target/src/asm/avr.rs +++ b/compiler/rustc_target/src/asm/avr.rs @@ -1,8 +1,10 @@ use std::fmt; -use rustc_span::Symbol; +use rustc_data_structures::fx::FxIndexSet; +use rustc_span::{Symbol, sym}; use super::{InlineAsmArch, InlineAsmType, ModifierInfo}; +use crate::spec::{RelocModel, Target}; def_reg_class! { Avr AvrInlineAsmRegClass { @@ -52,24 +54,44 @@ impl AvrInlineAsmRegClass { } } +pub(crate) fn is_tiny(target_features: &FxIndexSet) -> bool { + target_features.contains(&sym::tinyencoding) +} + +fn not_tiny( + _arch: InlineAsmArch, + _reloc_model: RelocModel, + target_features: &FxIndexSet, + _target: &Target, + _is_clobber: bool, +) -> Result<(), &'static str> { + if is_tiny(target_features) { + Err( + "on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM", + ) + } else { + Ok(()) + } +} + def_regs! { Avr AvrInlineAsmReg AvrInlineAsmRegClass { - r2: reg = ["r2"], - r3: reg = ["r3"], - r4: reg = ["r4"], - r5: reg = ["r5"], - r6: reg = ["r6"], - r7: reg = ["r7"], - r8: reg = ["r8"], - r9: reg = ["r9"], - r10: reg = ["r10"], - r11: reg = ["r11"], - r12: reg = ["r12"], - r13: reg = ["r13"], - r14: reg = ["r14"], - r15: reg = ["r15"], - r16: reg, reg_upper = ["r16"], - r17: reg, reg_upper = ["r17"], + r2: reg = ["r2"] % not_tiny, + r3: reg = ["r3"] % not_tiny, + r4: reg = ["r4"] % not_tiny, + r5: reg = ["r5"] % not_tiny, + r6: reg = ["r6"] % not_tiny, + r7: reg = ["r7"] % not_tiny, + r8: reg = ["r8"] % not_tiny, + r9: reg = ["r9"] % not_tiny, + r10: reg = ["r10"] % not_tiny, + r11: reg = ["r11"] % not_tiny, + r12: reg = ["r12"] % not_tiny, + r13: reg = ["r13"] % not_tiny, + r14: reg = ["r14"] % not_tiny, + r15: reg = ["r15"] % not_tiny, + r16: reg, reg_upper = ["r16"] % not_tiny, + r17: reg, reg_upper = ["r17"] % not_tiny, r18: reg, reg_upper = ["r18"], r19: reg, reg_upper = ["r19"], r20: reg, reg_upper = ["r20"], @@ -83,14 +105,14 @@ def_regs! { r30: reg, reg_upper = ["r30", "ZL"], r31: reg, reg_upper = ["r31", "ZH"], - r3r2: reg_pair = ["r3r2"], - r5r4: reg_pair = ["r5r4"], - r7r6: reg_pair = ["r7r6"], - r9r8: reg_pair = ["r9r8"], - r11r10: reg_pair = ["r11r10"], - r13r12: reg_pair = ["r13r12"], - r15r14: reg_pair = ["r15r14"], - r17r16: reg_pair = ["r17r16"], + r3r2: reg_pair = ["r3r2"] % not_tiny, + r5r4: reg_pair = ["r5r4"] % not_tiny, + r7r6: reg_pair = ["r7r6"] % not_tiny, + r9r8: reg_pair = ["r9r8"] % not_tiny, + r11r10: reg_pair = ["r11r10"] % not_tiny, + r13r12: reg_pair = ["r13r12"] % not_tiny, + r15r14: reg_pair = ["r15r14"] % not_tiny, + r17r16: reg_pair = ["r17r16"] % not_tiny, r19r18: reg_pair = ["r19r18"], r21r20: reg_pair = ["r21r20"], r23r22: reg_pair = ["r23r22"], diff --git a/compiler/rustc_target/src/asm/mod.rs b/compiler/rustc_target/src/asm/mod.rs index e06f881e4b1c7..a1f626dcec08f 100644 --- a/compiler/rustc_target/src/asm/mod.rs +++ b/compiler/rustc_target/src/asm/mod.rs @@ -935,6 +935,7 @@ pub enum InlineAsmClobberAbi { AArch64NoX18, Arm64EC, Avr, + AvrTiny, RiscV, RiscVE, LoongArch, @@ -995,7 +996,11 @@ impl InlineAsmClobberAbi { _ => Err(&["C", "system", "efiapi"]), }, InlineAsmArch::Avr => match name { - "C" | "system" => Ok(InlineAsmClobberAbi::Avr), + "C" | "system" => Ok(if avr::is_tiny(target_features) { + InlineAsmClobberAbi::AvrTiny + } else { + InlineAsmClobberAbi::Avr + }), _ => Err(&["C", "system"]), }, InlineAsmArch::LoongArch32 | InlineAsmArch::LoongArch64 => match name { @@ -1166,6 +1171,13 @@ impl InlineAsmClobberAbi { // is used. } }, + InlineAsmClobberAbi::AvrTiny => clobbered_regs! { + Avr AvrInlineAsmReg { + // Refs: https://gcc.gnu.org/wiki/avr-gcc#Reduced_Tiny + + r20, r21, r22, r23, r24, r25, r26, r27, r30, r31, + } + }, InlineAsmClobberAbi::RiscV => clobbered_regs! { RiscV RiscVInlineAsmReg { // ra diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index dc70089c385fe..6823ffed09846 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -884,6 +884,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. /// @@ -905,6 +927,7 @@ pub fn all_rust_features() -> impl Iterator { .chain(IBMZ_FEATURES) .chain(SPARC_FEATURES) .chain(M68K_FEATURES) + .chain(AVR_FEATURES) .cloned() .map(|(f, s, _)| (f, s)) } @@ -972,6 +995,7 @@ impl Target { "s390x" => IBMZ_FEATURES, "sparc" | "sparc64" => SPARC_FEATURES, "m68k" => M68K_FEATURES, + "avr" => AVR_FEATURES, _ => &[], } } @@ -989,7 +1013,7 @@ impl Target { "sparc" | "sparc64" => SPARC_FEATURES_FOR_CORRECT_VECTOR_ABI, "hexagon" => HEXAGON_FEATURES_FOR_CORRECT_VECTOR_ABI, "mips" | "mips32r6" | "mips64" | "mips64r6" => MIPS_FEATURES_FOR_CORRECT_VECTOR_ABI, - "nvptx64" | "bpf" | "m68k" => &[], // no vector ABI + "nvptx64" | "bpf" | "m68k" | "avr" => &[], // no vector ABI "csky" => CSKY_FEATURES_FOR_CORRECT_VECTOR_ABI, // FIXME: for some tier3 targets, we are overly cautious and always give warnings // when passing args in vector registers. diff --git a/tests/codegen-llvm/asm/avr-clobbers.rs b/tests/codegen-llvm/asm/avr-clobbers.rs index 9451127bf04ab..27af9472c00c4 100644 --- a/tests/codegen-llvm/asm/avr-clobbers.rs +++ b/tests/codegen-llvm/asm/avr-clobbers.rs @@ -1,7 +1,11 @@ //@ add-core-stubs //@ assembly-output: emit-asm -//@ compile-flags: --target avr-none -C target-cpu=atmega328p -//@ needs-llvm-components: avr +//@ revisions: avr avrtiny +//@[avr] compile-flags: --target avr-none -C target-cpu=atmega328p +//@[avr] needs-llvm-components: avr +//@[avrtiny] compile-flags: --target avr-none -C target-cpu=attiny104 +//@[avrtiny] needs-llvm-components: avr +// ignore-tidy-linelength #![crate_type = "rlib"] #![feature(no_core, asm_experimental_arch)] @@ -25,14 +29,16 @@ pub unsafe fn sreg_is_not_clobbered_if_preserve_flags_is_used() { } // CHECK-LABEL: @clobber_abi -// CHECK: asm sideeffect "", "={r18},={r19},={r20},={r21},={r22},={r23},={r24},={r25},={r26},={r27},={r30},={r31},~{sreg}"() +// avr: asm sideeffect "", "={r18},={r19},={r20},={r21},={r22},={r23},={r24},={r25},={r26},={r27},={r30},={r31},~{sreg}"() +// avrtiny: asm sideeffect "", "={r20},={r21},={r22},={r23},={r24},={r25},={r26},={r27},={r30},={r31},~{sreg}"() #[no_mangle] pub unsafe fn clobber_abi() { asm!("", clobber_abi("C"), options(nostack, nomem)); } // CHECK-LABEL: @clobber_abi_with_preserved_flags -// CHECK: asm sideeffect "", "={r18},={r19},={r20},={r21},={r22},={r23},={r24},={r25},={r26},={r27},={r30},={r31}"() +// avr: asm sideeffect "", "={r18},={r19},={r20},={r21},={r22},={r23},={r24},={r25},={r26},={r27},={r30},={r31}"() +// avrtiny: asm sideeffect "", "={r20},={r21},={r22},={r23},={r24},={r25},={r26},={r27},={r30},={r31}"() #[no_mangle] pub unsafe fn clobber_abi_with_preserved_flags() { asm!("", clobber_abi("C"), options(nostack, nomem, preserves_flags)); diff --git a/tests/ui/asm/avr/bad-reg.avr.stderr b/tests/ui/asm/avr/bad-reg.avr.stderr new file mode 100644 index 0000000000000..62c56dbb5c2b7 --- /dev/null +++ b/tests/ui/asm/avr/bad-reg.avr.stderr @@ -0,0 +1,56 @@ +error: invalid register `Y`: the frame pointer cannot be used as an operand for inline asm + --> $DIR/bad-reg.rs:20:18 + | +LL | asm!("", out("Y") _); + | ^^^^^^^^^^ + +error: invalid register `YL`: the frame pointer cannot be used as an operand for inline asm + --> $DIR/bad-reg.rs:22:18 + | +LL | asm!("", out("YL") _); + | ^^^^^^^^^^^ + +error: invalid register `YH`: the frame pointer cannot be used as an operand for inline asm + --> $DIR/bad-reg.rs:24:18 + | +LL | asm!("", out("YH") _); + | ^^^^^^^^^^^ + +error: invalid register `SP`: the stack pointer cannot be used as an operand for inline asm + --> $DIR/bad-reg.rs:26:18 + | +LL | asm!("", out("SP") _); + | ^^^^^^^^^^^ + +error: invalid register `SPL`: the stack pointer cannot be used as an operand for inline asm + --> $DIR/bad-reg.rs:28:18 + | +LL | asm!("", out("SPL") _); + | ^^^^^^^^^^^^ + +error: invalid register `SPH`: the stack pointer cannot be used as an operand for inline asm + --> $DIR/bad-reg.rs:30:18 + | +LL | asm!("", out("SPH") _); + | ^^^^^^^^^^^^ + +error: invalid register `r0`: LLVM reserves r0 (scratch register) and r1 (zero register) + --> $DIR/bad-reg.rs:32:18 + | +LL | asm!("", out("r0") _); + | ^^^^^^^^^^^ + +error: invalid register `r1`: LLVM reserves r0 (scratch register) and r1 (zero register) + --> $DIR/bad-reg.rs:34:18 + | +LL | asm!("", out("r1") _); + | ^^^^^^^^^^^ + +error: invalid register `r1r0`: LLVM reserves r0 (scratch register) and r1 (zero register) + --> $DIR/bad-reg.rs:36:18 + | +LL | asm!("", out("r1r0") _); + | ^^^^^^^^^^^^^ + +error: aborting due to 9 previous errors + diff --git a/tests/ui/asm/avr/bad-reg.avrtiny.stderr b/tests/ui/asm/avr/bad-reg.avrtiny.stderr new file mode 100644 index 0000000000000..11cb5424f5cdd --- /dev/null +++ b/tests/ui/asm/avr/bad-reg.avrtiny.stderr @@ -0,0 +1,200 @@ +error: invalid register `Y`: the frame pointer cannot be used as an operand for inline asm + --> $DIR/bad-reg.rs:20:18 + | +LL | asm!("", out("Y") _); + | ^^^^^^^^^^ + +error: invalid register `YL`: the frame pointer cannot be used as an operand for inline asm + --> $DIR/bad-reg.rs:22:18 + | +LL | asm!("", out("YL") _); + | ^^^^^^^^^^^ + +error: invalid register `YH`: the frame pointer cannot be used as an operand for inline asm + --> $DIR/bad-reg.rs:24:18 + | +LL | asm!("", out("YH") _); + | ^^^^^^^^^^^ + +error: invalid register `SP`: the stack pointer cannot be used as an operand for inline asm + --> $DIR/bad-reg.rs:26:18 + | +LL | asm!("", out("SP") _); + | ^^^^^^^^^^^ + +error: invalid register `SPL`: the stack pointer cannot be used as an operand for inline asm + --> $DIR/bad-reg.rs:28:18 + | +LL | asm!("", out("SPL") _); + | ^^^^^^^^^^^^ + +error: invalid register `SPH`: the stack pointer cannot be used as an operand for inline asm + --> $DIR/bad-reg.rs:30:18 + | +LL | asm!("", out("SPH") _); + | ^^^^^^^^^^^^ + +error: invalid register `r0`: LLVM reserves r0 (scratch register) and r1 (zero register) + --> $DIR/bad-reg.rs:32:18 + | +LL | asm!("", out("r0") _); + | ^^^^^^^^^^^ + +error: invalid register `r1`: LLVM reserves r0 (scratch register) and r1 (zero register) + --> $DIR/bad-reg.rs:34:18 + | +LL | asm!("", out("r1") _); + | ^^^^^^^^^^^ + +error: invalid register `r1r0`: LLVM reserves r0 (scratch register) and r1 (zero register) + --> $DIR/bad-reg.rs:36:18 + | +LL | asm!("", out("r1r0") _); + | ^^^^^^^^^^^^^ + +error: cannot use register `r2`: on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + --> $DIR/bad-reg.rs:40:18 + | +LL | asm!("", out("r2") _); + | ^^^^^^^^^^^ + +error: cannot use register `r3`: on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + --> $DIR/bad-reg.rs:42:18 + | +LL | asm!("", out("r3") _); + | ^^^^^^^^^^^ + +error: cannot use register `r4`: on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + --> $DIR/bad-reg.rs:44:18 + | +LL | asm!("", out("r4") _); + | ^^^^^^^^^^^ + +error: cannot use register `r5`: on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + --> $DIR/bad-reg.rs:46:18 + | +LL | asm!("", out("r5") _); + | ^^^^^^^^^^^ + +error: cannot use register `r6`: on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + --> $DIR/bad-reg.rs:48:18 + | +LL | asm!("", out("r6") _); + | ^^^^^^^^^^^ + +error: cannot use register `r7`: on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + --> $DIR/bad-reg.rs:50:18 + | +LL | asm!("", out("r7") _); + | ^^^^^^^^^^^ + +error: cannot use register `r8`: on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + --> $DIR/bad-reg.rs:52:18 + | +LL | asm!("", out("r8") _); + | ^^^^^^^^^^^ + +error: cannot use register `r9`: on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + --> $DIR/bad-reg.rs:54:18 + | +LL | asm!("", out("r9") _); + | ^^^^^^^^^^^ + +error: cannot use register `r10`: on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + --> $DIR/bad-reg.rs:56:18 + | +LL | asm!("", out("r10") _); + | ^^^^^^^^^^^^ + +error: cannot use register `r11`: on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + --> $DIR/bad-reg.rs:58:18 + | +LL | asm!("", out("r11") _); + | ^^^^^^^^^^^^ + +error: cannot use register `r12`: on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + --> $DIR/bad-reg.rs:60:18 + | +LL | asm!("", out("r12") _); + | ^^^^^^^^^^^^ + +error: cannot use register `r13`: on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + --> $DIR/bad-reg.rs:62:18 + | +LL | asm!("", out("r13") _); + | ^^^^^^^^^^^^ + +error: cannot use register `r14`: on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + --> $DIR/bad-reg.rs:64:18 + | +LL | asm!("", out("r14") _); + | ^^^^^^^^^^^^ + +error: cannot use register `r15`: on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + --> $DIR/bad-reg.rs:66:18 + | +LL | asm!("", out("r15") _); + | ^^^^^^^^^^^^ + +error: cannot use register `r16`: on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + --> $DIR/bad-reg.rs:68:18 + | +LL | asm!("", out("r16") _); + | ^^^^^^^^^^^^ + +error: cannot use register `r17`: on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + --> $DIR/bad-reg.rs:70:18 + | +LL | asm!("", out("r17") _); + | ^^^^^^^^^^^^ + +error: cannot use register `r3r2`: on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + --> $DIR/bad-reg.rs:72:18 + | +LL | asm!("", out("r3r2") _); + | ^^^^^^^^^^^^^ + +error: cannot use register `r5r4`: on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + --> $DIR/bad-reg.rs:74:18 + | +LL | asm!("", out("r5r4") _); + | ^^^^^^^^^^^^^ + +error: cannot use register `r7r6`: on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + --> $DIR/bad-reg.rs:76:18 + | +LL | asm!("", out("r7r6") _); + | ^^^^^^^^^^^^^ + +error: cannot use register `r9r8`: on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + --> $DIR/bad-reg.rs:78:18 + | +LL | asm!("", out("r9r8") _); + | ^^^^^^^^^^^^^ + +error: cannot use register `r11r10`: on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + --> $DIR/bad-reg.rs:80:18 + | +LL | asm!("", out("r11r10") _); + | ^^^^^^^^^^^^^^^ + +error: cannot use register `r13r12`: on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + --> $DIR/bad-reg.rs:82:18 + | +LL | asm!("", out("r13r12") _); + | ^^^^^^^^^^^^^^^ + +error: cannot use register `r15r14`: on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + --> $DIR/bad-reg.rs:84:18 + | +LL | asm!("", out("r15r14") _); + | ^^^^^^^^^^^^^^^ + +error: cannot use register `r17r16`: on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + --> $DIR/bad-reg.rs:86:18 + | +LL | asm!("", out("r17r16") _); + | ^^^^^^^^^^^^^^^ + +error: aborting due to 33 previous errors + diff --git a/tests/ui/asm/avr/bad-reg.rs b/tests/ui/asm/avr/bad-reg.rs new file mode 100644 index 0000000000000..fbfac872f709b --- /dev/null +++ b/tests/ui/asm/avr/bad-reg.rs @@ -0,0 +1,89 @@ +//@ add-core-stubs +//@ revisions: avr avrtiny +//@[avr] compile-flags: --target avr-none -C target-cpu=atmega328p +//@[avr] needs-llvm-components: avr +//@[avrtiny] compile-flags: --target avr-none -C target-cpu=attiny104 +//@[avrtiny] needs-llvm-components: avr +//@ needs-asm-support +// ignore-tidy-linelength + +#![crate_type = "rlib"] +#![feature(no_core, asm_experimental_arch)] +#![no_core] + +extern crate minicore; +use minicore::*; + +fn f() { + unsafe { + // Unsupported registers + asm!("", out("Y") _); + //~^ ERROR the frame pointer cannot be used as an operand for inline asm + asm!("", out("YL") _); + //~^ ERROR the frame pointer cannot be used as an operand for inline asm + asm!("", out("YH") _); + //~^ ERROR the frame pointer cannot be used as an operand for inline asm + asm!("", out("SP") _); + //~^ ERROR the stack pointer cannot be used as an operand for inline asm + asm!("", out("SPL") _); + //~^ ERROR the stack pointer cannot be used as an operand for inline asm + asm!("", out("SPH") _); + //~^ ERROR the stack pointer cannot be used as an operand for inline asm + asm!("", out("r0") _); + //~^ ERROR LLVM reserves r0 (scratch register) and r1 (zero register) + asm!("", out("r1") _); + //~^ ERROR LLVM reserves r0 (scratch register) and r1 (zero register) + asm!("", out("r1r0") _); + //~^ ERROR LLVM reserves r0 (scratch register) and r1 (zero register) + + // Unsupported only on AVRTiny + asm!("", out("r2") _); + //[avrtiny]~^ ERROR on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + asm!("", out("r3") _); + //[avrtiny]~^ ERROR on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + asm!("", out("r4") _); + //[avrtiny]~^ ERROR on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + asm!("", out("r5") _); + //[avrtiny]~^ ERROR on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + asm!("", out("r6") _); + //[avrtiny]~^ ERROR on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + asm!("", out("r7") _); + //[avrtiny]~^ ERROR on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + asm!("", out("r8") _); + //[avrtiny]~^ ERROR on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + asm!("", out("r9") _); + //[avrtiny]~^ ERROR on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + asm!("", out("r10") _); + //[avrtiny]~^ ERROR on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + asm!("", out("r11") _); + //[avrtiny]~^ ERROR on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + asm!("", out("r12") _); + //[avrtiny]~^ ERROR on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + asm!("", out("r13") _); + //[avrtiny]~^ ERROR on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + asm!("", out("r14") _); + //[avrtiny]~^ ERROR on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + asm!("", out("r15") _); + //[avrtiny]~^ ERROR on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + asm!("", out("r16") _); + //[avrtiny]~^ ERROR on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + asm!("", out("r17") _); + //[avrtiny]~^ ERROR on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + asm!("", out("r3r2") _); + //[avrtiny]~^ ERROR on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + asm!("", out("r5r4") _); + //[avrtiny]~^ ERROR on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + asm!("", out("r7r6") _); + //[avrtiny]~^ ERROR on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + asm!("", out("r9r8") _); + //[avrtiny]~^ ERROR on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + asm!("", out("r11r10") _); + //[avrtiny]~^ ERROR on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + asm!("", out("r13r12") _); + //[avrtiny]~^ ERROR on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + asm!("", out("r15r14") _); + //[avrtiny]~^ ERROR on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + asm!("", out("r17r16") _); + //[avrtiny]~^ ERROR on AVRTiny, r[2-15] are unavailable, r16 (scratch register) and r17 (zero register) are reserved by LLVM + } +} diff --git a/tests/ui/check-cfg/target_feature.stderr b/tests/ui/check-cfg/target_feature.stderr index 258f21324661b..66553a2d9dc3d 100644 --- a/tests/ui/check-cfg/target_feature.stderr +++ b/tests/ui/check-cfg/target_feature.stderr @@ -14,6 +14,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `7e10` `a` `aclass` +`addsubiw` `adx` `aes` `altivec` @@ -58,6 +59,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `bf16` `bmi1` `bmi2` +`break` `bti` `bulk-memory` `c` @@ -84,6 +86,9 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `e2` `ecv` `edsp` +`eijmpcall` +`elpm` +`elpmx` `elrw` `enhanced-sort` `ermsb` @@ -134,6 +139,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `hvx-length128b` `hwdiv` `i8mm` +`ijmpcall` `isa-68000` `isa-68010` `isa-68020` @@ -142,6 +148,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `isa-68060` `isa-68881` `isa-68882` +`jmpcall` `jsconv` `kl` `lahfsahf` @@ -152,6 +159,9 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `ld-seq-sa` `leoncasa` `lor` +`lowbytefirst` +`lpm` +`lpmx` `lse` `lse128` `lse2` @@ -173,11 +183,13 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `mops` `movbe` `movrs` +`movw` `mp` `mp1e2` `msa` `msync` `mte` +`mul` `multivalue` `mutable-globals` `neon` @@ -242,6 +254,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `reference-types` `relax` `relaxed-simd` +`rmw` `rtm` `rva23u64` `sb` @@ -294,6 +307,9 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `sme2p1` `soft-float` `spe` +`spm` +`spmx` +`sram` `ssbs` `sse` `sse2` @@ -318,6 +334,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `tbm` `thumb-mode` `thumb2` +`tinyencoding` `tme` `transactional-execution` `trust` diff --git a/tests/ui/target-feature/gate.rs b/tests/ui/target-feature/gate.rs index fc3763820cbec..ea3bbbed273c8 100644 --- a/tests/ui/target-feature/gate.rs +++ b/tests/ui/target-feature/gate.rs @@ -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 diff --git a/tests/ui/target-feature/gate.stderr b/tests/ui/target-feature/gate.stderr index 345dc2006d0bf..b3567c0091c60 100644 --- a/tests/ui/target-feature/gate.stderr +++ b/tests/ui/target-feature/gate.stderr @@ -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")] | ^^^^^^^^^^^^^^