1 //===- llvm/Transforms/Utils/IntegerDivision.h ------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains an implementation of 32bit and 64bit scalar integer
11 // division for targets that don't have native support. It's largely derived
12 // from compiler-rt's implementations of __udivsi3 and __udivmoddi4,
13 // but hand-tuned for targets that prefer less control flow.
15 //===----------------------------------------------------------------------===//
17 #ifndef LLVM_TRANSFORMS_UTILS_INTEGERDIVISION_H
18 #define LLVM_TRANSFORMS_UTILS_INTEGERDIVISION_H
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. Implements both
30 /// 32bit and 64bit scalar division.
32 /// @brief Replace Rem with generated code.
33 bool expandRemainder(BinaryOperator *Rem);
35 /// Generate code to divide two integers, replacing Div with the generated
36 /// code. This currently generates code similarly to compiler-rt's
37 /// implementations, but future work includes generating more specialized code
38 /// when more information about the operands are known. Implements both
39 /// 32bit and 64bit scalar division.
41 /// @brief Replace Div with generated code.
42 bool expandDivision(BinaryOperator* Div);
44 /// Generate code to calculate the remainder of two integers, replacing Rem
45 /// with the generated code. Uses ExpandReminder with a 32bit Rem which
46 /// makes it useful for targets with little or no support for less than
47 /// 32 bit arithmetic.
49 /// @brief Replace Rem with generated code.
50 bool expandRemainderUpTo32Bits(BinaryOperator *Rem);
52 /// Generate code to calculate the remainder of two integers, replacing Rem
53 /// with the generated code. Uses ExpandReminder with a 64bit Rem.
55 /// @brief Replace Rem with generated code.
56 bool expandRemainderUpTo64Bits(BinaryOperator *Rem);
58 /// Generate code to divide two integers, replacing Div with the generated
59 /// code. Uses ExpandDivision with a 32bit Div which makes it useful for
60 /// targets with little or no support for less than 32 bit arithmetic.
62 /// @brief Replace Rem with generated code.
63 bool expandDivisionUpTo32Bits(BinaryOperator *Div);
65 /// Generate code to divide two integers, replacing Div with the generated
66 /// code. Uses ExpandDivision with a 64bit Div.
68 /// @brief Replace Rem with generated code.
69 bool expandDivisionUpTo64Bits(BinaryOperator *Div);
71 } // End llvm namespace