Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/lib/Basic/Targets/AVR.cpp | ||
---|---|---|
385 | The previous way of definition of __AVR_TINY__ is incorrect, it works for -mmcu=<any tiny mcu name>, but does not work if -mmcu=avrtiny is specified. Since this is just a minor fix, I won't make another patch. |
The new implementation of __mulhi3 and __mulqi3 strictly follow libgcc's special ABI.
compiler-rt/lib/builtins/avr/mulhi3.S | ||
---|---|---|
44 | __zero_reg__ is used to store the result and is clobbered. So we have to restore it to zero value (eor __zero_reg__, __zero_reg__) before return. |
Corresponding tests
__mulhi3 : https://github.com/benshi001/avr-test/blob/main/mul_int16.ino
__mulqi3 : https://github.com/benshi001/avr-test/blob/main/mul_int8.ino
Looks good to me. It might be possible to optimize these functions a bit more but that can happen at a later time.
compiler-rt/lib/builtins/avr/mulhi3.S | ||
---|---|---|
44 | __zero_reg__ can be assumed to be zero on function entry so it doesn't have to be cleared here. Both LLVM and avr-gcc use it as a reserved register. Also, writing clr Rd is maybe easier to read than eor Rd, Rd? It is an alias and results in the same machine code. |
Yes. They are far from perfect. We can optimize them according different instruction set, such as using MOVW for int16 copy.
compiler-rt/lib/builtins/avr/mulhi3.S | ||
---|---|---|
44 | I will fix that when committing. |
The previous way of definition of __AVR_TINY__ is incorrect, it works for -mmcu=<any tiny mcu name>, but does not work if -mmcu=avrtiny is specified.
Since this is just a minor fix, I won't make another patch.