aykevl added a comment.

@benshi001 I have been looking through the GCC code and I think avr-gcc also 
has a special calling convention for many other functions, including `__mulqi3` 
and `__mulhi3`.

Source:

1. I think this is where the ABI is specified in the compiler: 
https://github.com/gcc-mirror/gcc/blob/releases/gcc-5.4.0/gcc/config/avr/avr.md#L1543-L1549
 You can see that it multiplies R24 with R22 and stores the result in R24, and 
clobbers R22 in the process. But no other registers.
2. In this code sample <https://godbolt.org/z/cPE5ajrbv>, avr-gcc doesn't save 
`char c` (`r20`) across the `__mulqi3` and `__mulhi3` calls.

Therefore, I think we need to be a bit more careful with defining these AVR 
builtins and check the ABI in avr-gcc first.
Also, we can make use of this and optimize the AVR backend more (you can see 
that the Clang generated code is much worse than avr-gcc in the above examples).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123200/new/

https://reviews.llvm.org/D123200

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to