DivisionByConstantInfo.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //== llvm/Support/DivisonByConstantInfo.h - division by constant -*- 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 implements support for optimizing divisions by a constant
  15. ///
  16. //===----------------------------------------------------------------------===//
  17. #ifndef LLVM_SUPPORT_DIVISIONBYCONSTANTINFO_H
  18. #define LLVM_SUPPORT_DIVISIONBYCONSTANTINFO_H
  19. #include "llvm/ADT/APInt.h"
  20. namespace llvm {
  21. /// Magic data for optimising signed division by a constant.
  22. struct SignedDivisionByConstantInfo {
  23. static SignedDivisionByConstantInfo get(const APInt &D);
  24. APInt Magic; ///< magic number
  25. unsigned ShiftAmount; ///< shift amount
  26. };
  27. /// Magic data for optimising unsigned division by a constant.
  28. struct UnsignedDivisonByConstantInfo {
  29. static UnsignedDivisonByConstantInfo get(const APInt &D,
  30. unsigned LeadingZeros = 0);
  31. APInt Magic; ///< magic number
  32. bool IsAdd; ///< add indicator
  33. unsigned ShiftAmount; ///< shift amount
  34. };
  35. } // namespace llvm
  36. #endif
  37. #ifdef __GNUC__
  38. #pragma GCC diagnostic pop
  39. #endif