1//===- llvm/Support/DivisionByConstantInfo.h ---------------------*- C++ -*-==//
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 support for optimizing divisions by a constant
10///
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_SUPPORT_DIVISIONBYCONSTANTINFO_H
14#define LLVM_SUPPORT_DIVISIONBYCONSTANTINFO_H
15
16#include "llvm/ADT/APInt.h"
17
18namespace llvm {
19
20/// Magic data for optimising signed division by a constant.
21struct SignedDivisionByConstantInfo {
22 static SignedDivisionByConstantInfo get(const APInt &D);
23 APInt Magic; ///< magic number
24 unsigned ShiftAmount; ///< shift amount
25};
26
27/// Magic data for optimising unsigned division by a constant.
28struct 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
38} // namespace llvm
39
40#endif
41

source code of llvm/include/llvm/Support/DivisionByConstantInfo.h