IntegerDivision.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. //===- llvm/Transforms/Utils/IntegerDivision.h ------------------*- C++ -*-===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. //
  10. // This file contains an implementation of 32bit and 64bit scalar integer
  11. // division for targets that don't have native support. It's largely derived
  12. // from compiler-rt's implementations of __udivsi3 and __udivmoddi4,
  13. // but hand-tuned for targets that prefer less control flow.
  14. //
  15. //===----------------------------------------------------------------------===//
  16. #ifndef LLVM_TRANSFORMS_UTILS_INTEGERDIVISION_H
  17. #define LLVM_TRANSFORMS_UTILS_INTEGERDIVISION_H
  18. namespace llvm {
  19. class BinaryOperator;
  20. }
  21. namespace llvm {
  22. /// Generate code to calculate the remainder of two integers, replacing Rem
  23. /// with the generated code. This currently generates code using the udiv
  24. /// expansion, but future work includes generating more specialized code,
  25. /// e.g. when more information about the operands are known. Implements both
  26. /// 32bit and 64bit scalar division.
  27. ///
  28. /// @brief Replace Rem with generated code.
  29. bool expandRemainder(BinaryOperator *Rem);
  30. /// Generate code to divide two integers, replacing Div with the generated
  31. /// code. This currently generates code similarly to compiler-rt's
  32. /// implementations, but future work includes generating more specialized code
  33. /// when more information about the operands are known. Implements both
  34. /// 32bit and 64bit scalar division.
  35. ///
  36. /// @brief Replace Div with generated code.
  37. bool expandDivision(BinaryOperator* Div);
  38. /// Generate code to calculate the remainder of two integers, replacing Rem
  39. /// with the generated code. Uses ExpandReminder with a 32bit Rem which
  40. /// makes it useful for targets with little or no support for less than
  41. /// 32 bit arithmetic.
  42. ///
  43. /// @brief Replace Rem with generated code.
  44. bool expandRemainderUpTo32Bits(BinaryOperator *Rem);
  45. /// Generate code to calculate the remainder of two integers, replacing Rem
  46. /// with the generated code. Uses ExpandReminder with a 64bit Rem.
  47. ///
  48. /// @brief Replace Rem with generated code.
  49. bool expandRemainderUpTo64Bits(BinaryOperator *Rem);
  50. /// Generate code to divide two integers, replacing Div with the generated
  51. /// code. Uses ExpandDivision with a 32bit Div which makes it useful for
  52. /// targets with little or no support for less than 32 bit arithmetic.
  53. ///
  54. /// @brief Replace Rem with generated code.
  55. bool expandDivisionUpTo32Bits(BinaryOperator *Div);
  56. /// Generate code to divide two integers, replacing Div with the generated
  57. /// code. Uses ExpandDivision with a 64bit Div.
  58. ///
  59. /// @brief Replace Rem with generated code.
  60. bool expandDivisionUpTo64Bits(BinaryOperator *Div);
  61. } // End llvm namespace
  62. #endif