Commit c9f5280
committed
fix: Add
This commit follows the same logic as:
- #462
- #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.#[avr_skip] for bit shifts1 parent 23a74de commit c9f5280
1 file changed
+9
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
| 78 | + | |
77 | 79 | | |
78 | 80 | | |
79 | 81 | | |
80 | 82 | | |
81 | 83 | | |
82 | 84 | | |
| 85 | + | |
83 | 86 | | |
84 | 87 | | |
85 | 88 | | |
86 | 89 | | |
| 90 | + | |
87 | 91 | | |
88 | 92 | | |
89 | 93 | | |
90 | 94 | | |
91 | 95 | | |
| 96 | + | |
92 | 97 | | |
93 | 98 | | |
94 | 99 | | |
95 | 100 | | |
96 | 101 | | |
97 | 102 | | |
| 103 | + | |
98 | 104 | | |
99 | 105 | | |
100 | 106 | | |
101 | 107 | | |
| 108 | + | |
102 | 109 | | |
103 | 110 | | |
104 | 111 | | |
105 | 112 | | |
106 | 113 | | |
| 114 | + | |
107 | 115 | | |
108 | 116 | | |
109 | 117 | | |
110 | 118 | | |
111 | 119 | | |
112 | 120 | | |
| 121 | + | |
113 | 122 | | |
114 | 123 | | |
115 | 124 | | |
| |||
0 commit comments