[PATCH] D78662: [builtins] Support architectures with 16-bit int

Ayke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 22 12:30:52 PDT 2020


aykevl created this revision.
aykevl added reviewers: MaskRay, kamleshbhalui, luismarques.
Herald added subscribers: Sanitizers, dylanmckay.
Herald added a project: Sanitizers.
aykevl added a child revision: D78663: [builtins] Add 32-bit shift builtins.
aykevl edited the summary of this revision.

This is the first patch in a series to add support for the AVR target. This patch includes changes to make compiler-rt more target independent by not relying on the width of an int or long.

---

Some notes:

- I changed the integer types used in many builtins (`si_int`, `du_int`, etc) to specific integer widths. My rationale is that even though the libgcc documentation <https://gcc.gnu.org/onlinedocs/gccint/Integer-library-routines.html> uses types such as `int` / `long` / `long long`, I believe their bit width is actually much more strictly defined. For example: LLVM has a file RuntimeLibcalls.def <https://github.com/llvm/llvm-project/blob/master/llvm/include/llvm/IR/RuntimeLibcalls.def> where it uses very specific bit widths for all these builtins.
- I changed some parameters and return types from `si_int` to just `int` when they are used for a number of bits (such as in shift instructions). Affected functions: `__ashldi3`, `__ashrdi3`, `__ctzdi2`, `__ffsdi2`, `__ffssi2`, `__lshrdi3`, `__popcountdi2`.
- I changed some bare `int`/`unsigned int` types to a more specific `si_int`/`su_int`. I think this has always been an issue but nobody noticed because they used to be the same. Affected functions: `__floatsidf`, `__floatunsidf`.
- I changed a few zero-counting builtin calls (`__builtin_clz`, `__builtin_ctzl`, etc) to use a bigger integer width. This seems to work, but perhaps it's better to define macros for these in int_lib.h: this change may have performance implications.

For context: I have a branch here <https://github.com/llvm/llvm-project/compare/master...aykevl:avr-compiler-rt> where I collect all the patches needed to add support for AVR in the compiler-rt builtins. Some commits are already upstream, some are still in review, and some need some cleanup before I can post them on Phabricator.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78662

Files:
  compiler-rt/lib/builtins/absvsi2.c
  compiler-rt/lib/builtins/ashldi3.c
  compiler-rt/lib/builtins/ashrdi3.c
  compiler-rt/lib/builtins/clzdi2.c
  compiler-rt/lib/builtins/ctzdi2.c
  compiler-rt/lib/builtins/ffsdi2.c
  compiler-rt/lib/builtins/ffssi2.c
  compiler-rt/lib/builtins/floatdisf.c
  compiler-rt/lib/builtins/floatsidf.c
  compiler-rt/lib/builtins/floatundisf.c
  compiler-rt/lib/builtins/floatunsidf.c
  compiler-rt/lib/builtins/fp_extend.h
  compiler-rt/lib/builtins/fp_lib.h
  compiler-rt/lib/builtins/int_div_impl.inc
  compiler-rt/lib/builtins/int_types.h
  compiler-rt/lib/builtins/lshrdi3.c
  compiler-rt/lib/builtins/popcountdi2.c
  compiler-rt/lib/builtins/udivmoddi4.c
  compiler-rt/test/builtins/Unit/ashldi3_test.c
  compiler-rt/test/builtins/Unit/ashrdi3_test.c
  compiler-rt/test/builtins/Unit/ctzdi2_test.c
  compiler-rt/test/builtins/Unit/ffsdi2_test.c
  compiler-rt/test/builtins/Unit/ffssi2_test.c
  compiler-rt/test/builtins/Unit/lshrdi3_test.c
  compiler-rt/test/builtins/Unit/popcountdi2_test.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78662.259347.patch
Type: text/x-patch
Size: 16235 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200422/31b58ab3/attachment-0001.bin>


More information about the llvm-commits mailing list