You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit follows the same logic as:
- rust-lang#462
- rust-lang#466
I've tested the changes by preparing a simple program:
```rust
fn calc() -> ... {
let x = hint::black_box(4u...); // 4u8, 4u16, 4u32, 4u64, 4u128 + signed
let y = hint::black_box(1u32);
// x >> y
// x << y
}
fn main() -> ! {
let dp = arduino_hal::Peripherals::take().unwrap();
let pins = arduino_hal::pins!(dp);
let mut serial = arduino_hal::default_serial!(dp, pins, 57600);
for b in calc().to_le_bytes() {
_ = ufmt::uwrite!(&mut serial, "{} ", b);
}
_ = ufmt::uwriteln!(&mut serial, "");
loop {
//
}
}
```
... switching types & operators in `calc()`, and observing the results;
what I ended up with was:
```
u32 << u32 - ok
u64 << u32 - ok
u128 << u32 - error (undefined reference to `__ashlti3')
i32 >> u32 - ok
i64 >> u32 - ok
i128 >> u32 - error (undefined reference to `__ashrti3')
u32 >> u32 - ok
u64 >> u32 - ok
u128 >> u32 - error (undefined reference to `__lshrti3')
(where "ok" = compiles and returns correct results)
```
As with multiplication and division, so do in here 128-bit operations
not work, because avr-gcc's standard library doesn't provide them (at
the same time, requiring that specific calling convention, making it
pretty difficult for compiler-builtins to jump in).
I think 128-bit operations non-working on an 8-bit controller is an
acceptable trade-off - :innocent: - and so the entire fix in here is
just about skipping those functions.
0 commit comments