1 //== llvm/Support/DivisonByConstantInfo.h - division by constant -*- C++ -*-==//
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
7 //===----------------------------------------------------------------------===//
9 /// This file implements support for optimizing divisions by a constant
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_SUPPORT_DIVISIONBYCONSTANTINFO_H
14 #define LLVM_SUPPORT_DIVISIONBYCONSTANTINFO_H
16 #include "llvm/ADT/APInt.h"
20 /// Magic data for optimising signed division by a constant.
21 struct SignedDivisionByConstantInfo {
22 static SignedDivisionByConstantInfo get(const APInt &D);
23 APInt Magic; ///< magic number
24 unsigned ShiftAmount; ///< shift amount
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