[all-commits] [llvm/llvm-project] bf2dc4: compiler-rt: Add udivmodei5 to builtins and add bi...

Matthias Gehre via All-commits all-commits at lists.llvm.org
Thu Apr 7 23:43:31 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: bf2dc4b37623e1b4f7d39570e1b5a6f3ef5db107
      https://github.com/llvm/llvm-project/commit/bf2dc4b37623e1b4f7d39570e1b5a6f3ef5db107
  Author: Matthias Gehre <matthias.gehre at xilinx.com>
  Date:   2022-04-08 (Fri, 08 Apr 2022)

  Changed paths:
    M compiler-rt/CMakeLists.txt
    M compiler-rt/cmake/builtin-config-ix.cmake
    M compiler-rt/lib/CMakeLists.txt
    A compiler-rt/lib/bitint/CMakeLists.txt
    M compiler-rt/lib/builtins/CMakeLists.txt
    M compiler-rt/lib/builtins/int_lib.h
    A compiler-rt/lib/builtins/udivmodei5.c
    M compiler-rt/test/CMakeLists.txt
    A compiler-rt/test/bitint/CMakeLists.txt
    A compiler-rt/test/bitint/Unit/bitint_test.c
    A compiler-rt/test/bitint/Unit/lit.cfg.py
    A compiler-rt/test/bitint/Unit/lit.site.cfg.py.in
    A compiler-rt/test/builtins/Unit/divmodei5_test.c
    A compiler-rt/test/builtins/Unit/udivmodei5_test.c

  Log Message:
  -----------
  compiler-rt: Add udivmodei5 to builtins and add bitint library

According to the RFC [0], this review contains the compiler-rt parts of large integer divison for _BitInt.

It adds the functions
```
/// Computes the unsigned division of a / b for two large integers
/// composed of n significant words.
/// Writes the quotient to quo and the remainder to rem.
///
/// \param quo The quotient represented by n words. Must be non-null.
/// \param rem The remainder represented by n words. Must be non-null.
/// \param a The dividend represented by n + 1 words. Must be non-null.
/// \param b The divisor represented by n words. Must be non-null.

/// \note The word order is in host endianness.
/// \note Might modify a and b.
/// \note The storage of 'a' needs to hold n + 1 elements because some
///       implementations need extra scratch space in the most significant word.
///       The value of that word is ignored.
COMPILER_RT_ABI void __udivmodei5(su_int *quo, su_int *rem, su_int *a,
                                  su_int *b, unsigned int n);

/// Computes the signed division of a / b.
/// See __udivmodei5 for details.
COMPILER_RT_ABI void __divmodei5(su_int *quo, su_int *rem, su_int *a, su_int *b,
                                 unsigned int words);
```
into builtins.
In addition it introduces a new "bitint" library containing only those new functions,
which is meant as a way to provide those when using libgcc as runtime.

[0] https://discourse.llvm.org/t/rfc-add-support-for-division-of-large-bitint-builtins-selectiondag-globalisel-clang/60329

Differential Revision: https://reviews.llvm.org/D120327




More information about the All-commits mailing list