Home | History | Annotate | Download | only in Utils
      1 //===- llvm/Transforms/Utils/IntegerDivision.h ------------------*- C++ -*-===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 //
     10 // This file contains an implementation of 32bit integer division for targets
     11 // that don't have native support. It's largely derived from compiler-rt's
     12 // implementation of __udivsi3, but hand-tuned for targets that prefer less
     13 // control flow.
     14 //
     15 //===----------------------------------------------------------------------===//
     16 
     17 #ifndef LLVM_TRANSFORMS_UTILS_INTEGERDIVISION_H
     18 #define LLVM_TRANSFORMS_UTILS_INTEGERDIVISION_H
     19 
     20 namespace llvm {
     21   class BinaryOperator;
     22 }
     23 
     24 namespace llvm {
     25 
     26   /// Generate code to calculate the remainder of two integers, replacing Rem
     27   /// with the generated code. This currently generates code using the udiv
     28   /// expansion, but future work includes generating more specialized code,
     29   /// e.g. when more information about the operands are known. Currently only
     30   /// implements 32bit scalar division (due to udiv's limitation), but future
     31   /// work is removing this limitation.
     32   ///
     33   /// @brief Replace Rem with generated code.
     34   bool expandRemainder(BinaryOperator *Rem);
     35 
     36   /// Generate code to divide two integers, replacing Div with the generated
     37   /// code. This currently generates code similarly to compiler-rt's
     38   /// implementations, but future work includes generating more specialized code
     39   /// when more information about the operands are known. Currently only
     40   /// implements 32bit scalar division, but future work is removing this
     41   /// limitation.
     42   ///
     43   /// @brief Replace Div with generated code.
     44   bool expandDivision(BinaryOperator* Div);
     45 
     46   /// Generate code to calculate the remainder of two integers, replacing Rem
     47   /// with the generated code. Uses the above 32bit routine, therefore adequate
     48   /// for targets with little or no support for less than 32 bit arithmetic.
     49   ///
     50   /// @brief Replace Rem with generated code.
     51   bool expandRemainderUpTo32Bits(BinaryOperator *Rem);
     52 
     53   /// Generate code to divide two integers, replacing Div with the generated
     54   /// code. Uses the above 32bit routine, therefore adequate for targets with
     55   /// little or no support for less than 32 bit arithmetic.
     56   ///
     57   /// @brief Replace Rem with generated code.
     58   bool expandDivisionUpTo32Bits(BinaryOperator *Div);
     59 
     60 } // End llvm namespace
     61 
     62 #endif
     63