DivisionByConstantInfo.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- llvm/Support/DivisionByConstantInfo.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 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 UnsignedDivisionByConstantInfo {
  29. static UnsignedDivisionByConstantInfo
  30. get(const APInt &D, unsigned LeadingZeros = 0,
  31. bool AllowEvenDivisorOptimization = true);
  32. APInt Magic; ///< magic number
  33. bool IsAdd; ///< add indicator
  34. unsigned PostShift; ///< post-shift amount
  35. unsigned PreShift; ///< pre-shift amount
  36. };
  37. } // namespace llvm
  38. #endif
  39. #ifdef __GNUC__
  40. #pragma GCC diagnostic pop
  41. #endif