divsi3.c 1.0 KB

123456789101112131415161718192021222324252627282930
  1. //===-- divsi3.c - Implement __divsi3 -------------------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file implements __divsi3 for the compiler_rt library.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #include "int_lib.h"
  13. // Returns: a / b
  14. #define fixint_t si_int
  15. #define fixuint_t su_int
  16. // On CPUs without unsigned hardware division support,
  17. // this calls __udivsi3 (notice the cast to su_int).
  18. // On CPUs with unsigned hardware division support,
  19. // this uses the unsigned division instruction.
  20. #define COMPUTE_UDIV(a, b) ((su_int)(a) / (su_int)(b))
  21. #include "int_div_impl.inc"
  22. COMPILER_RT_ABI si_int __divsi3(si_int a, si_int b) { return __divXi3(a, b); }
  23. #if defined(__ARM_EABI__)
  24. COMPILER_RT_ALIAS(__divsi3, __aeabi_idiv)
  25. #endif