IntegerDivision.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- llvm/Transforms/Utils/IntegerDivision.h ------------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This file contains an implementation of 32bit and 64bit scalar integer
  15. // division for targets that don't have native support. It's largely derived
  16. // from compiler-rt's implementations of __udivsi3 and __udivmoddi4,
  17. // but hand-tuned for targets that prefer less control flow.
  18. //
  19. //===----------------------------------------------------------------------===//
  20. #ifndef LLVM_TRANSFORMS_UTILS_INTEGERDIVISION_H
  21. #define LLVM_TRANSFORMS_UTILS_INTEGERDIVISION_H
  22. namespace llvm {
  23. class BinaryOperator;
  24. }
  25. namespace llvm {
  26. /// Generate code to calculate the remainder of two integers, replacing Rem
  27. /// with the generated code. This currently generates code using the udiv
  28. /// expansion, but future work includes generating more specialized code,
  29. /// e.g. when more information about the operands are known. Implements both
  30. /// 32bit and 64bit scalar division.
  31. ///
  32. /// Replace Rem with generated code.
  33. bool expandRemainder(BinaryOperator *Rem);
  34. /// Generate code to divide two integers, replacing Div with the generated
  35. /// code. This currently generates code similarly to compiler-rt's
  36. /// implementations, but future work includes generating more specialized code
  37. /// when more information about the operands are known. Implements both
  38. /// 32bit and 64bit scalar division.
  39. ///
  40. /// Replace Div with generated code.
  41. bool expandDivision(BinaryOperator* Div);
  42. /// Generate code to calculate the remainder of two integers, replacing Rem
  43. /// with the generated code. Uses ExpandReminder with a 32bit Rem which
  44. /// makes it useful for targets with little or no support for less than
  45. /// 32 bit arithmetic.
  46. ///
  47. /// Replace Rem with generated code.
  48. bool expandRemainderUpTo32Bits(BinaryOperator *Rem);
  49. /// Generate code to calculate the remainder of two integers, replacing Rem
  50. /// with the generated code. Uses ExpandReminder with a 64bit Rem.
  51. ///
  52. /// Replace Rem with generated code.
  53. bool expandRemainderUpTo64Bits(BinaryOperator *Rem);
  54. /// Generate code to divide two integers, replacing Div with the generated
  55. /// code. Uses ExpandDivision with a 32bit Div which makes it useful for
  56. /// targets with little or no support for less than 32 bit arithmetic.
  57. ///
  58. /// Replace Rem with generated code.
  59. bool expandDivisionUpTo32Bits(BinaryOperator *Div);
  60. /// Generate code to divide two integers, replacing Div with the generated
  61. /// code. Uses ExpandDivision with a 64bit Div.
  62. ///
  63. /// Replace Rem with generated code.
  64. bool expandDivisionUpTo64Bits(BinaryOperator *Div);
  65. } // End llvm namespace
  66. #endif
  67. #ifdef __GNUC__
  68. #pragma GCC diagnostic pop
  69. #endif