LLVM API Documentation

IntegerDivision.h
Go to the documentation of this file.
00001 //===- llvm/Transforms/Utils/IntegerDivision.h ------------------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file contains an implementation of 32bit and 64bit scalar integer
00011 // division for targets that don't have native support. It's largely derived
00012 // from compiler-rt's implementations of __udivsi3 and __udivmoddi4,
00013 // but hand-tuned for targets that prefer less control flow.
00014 //
00015 //===----------------------------------------------------------------------===//
00016 
00017 #ifndef LLVM_TRANSFORMS_UTILS_INTEGERDIVISION_H
00018 #define LLVM_TRANSFORMS_UTILS_INTEGERDIVISION_H
00019 
00020 namespace llvm {
00021   class BinaryOperator;
00022 }
00023 
00024 namespace llvm {
00025 
00026   /// Generate code to calculate the remainder of two integers, replacing Rem
00027   /// with the generated code. This currently generates code using the udiv
00028   /// expansion, but future work includes generating more specialized code,
00029   /// e.g. when more information about the operands are known. Implements both
00030   /// 32bit and 64bit scalar division.
00031   ///
00032   /// @brief Replace Rem with generated code.
00033   bool expandRemainder(BinaryOperator *Rem);
00034 
00035   /// Generate code to divide two integers, replacing Div with the generated
00036   /// code. This currently generates code similarly to compiler-rt's
00037   /// implementations, but future work includes generating more specialized code
00038   /// when more information about the operands are known. Implements both
00039   /// 32bit and 64bit scalar division.
00040   ///
00041   /// @brief Replace Div with generated code.
00042   bool expandDivision(BinaryOperator* Div);
00043 
00044   /// Generate code to calculate the remainder of two integers, replacing Rem
00045   /// with the generated code. Uses ExpandReminder with a 32bit Rem which
00046   /// makes it useful for targets with little or no support for less than
00047   /// 32 bit arithmetic.
00048   ///
00049   /// @brief Replace Rem with generated code.
00050   bool expandRemainderUpTo32Bits(BinaryOperator *Rem);
00051 
00052   /// Generate code to calculate the remainder of two integers, replacing Rem
00053   /// with the generated code. Uses ExpandReminder with a 64bit Rem.
00054   ///
00055   /// @brief Replace Rem with generated code.
00056   bool expandRemainderUpTo64Bits(BinaryOperator *Rem);
00057 
00058   /// Generate code to divide two integers, replacing Div with the generated
00059   /// code. Uses ExpandDivision with a 32bit Div which makes it useful for
00060   /// targets with little or no support for less than 32 bit arithmetic.
00061   ///
00062   /// @brief Replace Rem with generated code.
00063   bool expandDivisionUpTo32Bits(BinaryOperator *Div);
00064 
00065   /// Generate code to divide two integers, replacing Div with the generated
00066   /// code. Uses ExpandDivision with a 64bit Div.
00067   ///
00068   /// @brief Replace Rem with generated code.
00069   bool expandDivisionUpTo64Bits(BinaryOperator *Div);
00070 
00071 } // End llvm namespace
00072 
00073 #endif