Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:29

0001 //===- llvm/Support/DivisionByConstantInfo.h ---------------------*- C++ -*-==//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 ///
0009 /// This file implements support for optimizing divisions by a constant
0010 ///
0011 //===----------------------------------------------------------------------===//
0012 
0013 #ifndef LLVM_SUPPORT_DIVISIONBYCONSTANTINFO_H
0014 #define LLVM_SUPPORT_DIVISIONBYCONSTANTINFO_H
0015 
0016 #include "llvm/ADT/APInt.h"
0017 
0018 namespace llvm {
0019 
0020 /// Magic data for optimising signed division by a constant.
0021 struct SignedDivisionByConstantInfo {
0022   static SignedDivisionByConstantInfo get(const APInt &D);
0023   APInt Magic;          ///< magic number
0024   unsigned ShiftAmount; ///< shift amount
0025 };
0026 
0027 /// Magic data for optimising unsigned division by a constant.
0028 struct UnsignedDivisionByConstantInfo {
0029   static UnsignedDivisionByConstantInfo
0030   get(const APInt &D, unsigned LeadingZeros = 0,
0031       bool AllowEvenDivisorOptimization = true);
0032   APInt Magic;          ///< magic number
0033   bool IsAdd;           ///< add indicator
0034   unsigned PostShift;   ///< post-shift amount
0035   unsigned PreShift;    ///< pre-shift amount
0036 };
0037 
0038 } // namespace llvm
0039 
0040 #endif