Skip to content

Commit da44e3f

Browse files
committed
Start test case for rjmp regression test
This commit introduces a minimal `![no_core]`-test case running on AVR, that contains the MCWE mentioned in [129301]. The test case itself does not have any assertions yet, but it shows the minimal set an language items necessary within the test case. [129301]: #129301 (comment)
1 parent 17a19e6 commit da44e3f

1 file changed

Lines changed: 62 additions & 0 deletions

File tree

‎tests/assembly/avr-rjmp-offsets.rs‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
//@ compile-flags: -Copt-level=s --target=avr-unknown-gnu-atmega328 -C panic=abort
2+
//@ needs-llvm-components: avr
3+
//@ assembly-output: emit-asm
4+
5+
#![feature(
6+
no_core,
7+
lang_items,
8+
intrinsics,
9+
rustc_attrs,
10+
arbitrary_self_types,
11+
asm_experimental_arch
12+
)]
13+
#![crate_type = "rlib"]
14+
#![no_core]
15+
16+
#[rustc_builtin_macro]
17+
macro_rules! asm {
18+
() => {};
19+
}
20+
21+
use minicore::ptr;
22+
23+
// CHECK-LABEL: pin_toggling
24+
#[no_mangle]
25+
pubfnpin_toggling(){
26+
let port_b = 0x25as*mutu8;// the I/O-address of PORTB
27+
loop{
28+
unsafe{ ptr::write_volatile(port_b,1)};
29+
delay(500_0000);
30+
unsafe{ ptr::write_volatile(port_b,2)};
31+
delay(500_0000);
32+
}
33+
}
34+
35+
#[inline(never)]
36+
fndelay(_:u32){
37+
unsafe{asm!("nop")};
38+
}
39+
40+
// FIXME: replace with proper minicore once available (#130693)
41+
mod minicore {
42+
#[lang = "sized"]
43+
pubtraitSized{}
44+
45+
#[lang = "copy"]
46+
pubtraitCopy{}
47+
implCopyforu32{}
48+
implCopyfor&u32{}
49+
impl<T: ?Sized>Copyfor*mutT{}
50+
51+
pubmod ptr {
52+
#[inline]
53+
#[rustc_diagnostic_item = "ptr_write_volatile"]
54+
pubunsafefnwrite_volatile<T>(dst:*mutT,src:T){
55+
extern"rust-intrinsic"{
56+
#[rustc_nounwind]
57+
pubfnvolatile_store<T>(dst:*mutT,val:T);
58+
}
59+
unsafe{volatile_store(dst, src)};
60+
}
61+
}
62+
}

0 commit comments

Comments
 (0)