Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line | 
|---|---|---|---|
| 14 | pmbaty | 1 | //===- llvm/Transforms/Utils/IntegerDivision.h ------------------*- C++ -*-===// | 
| 2 | // | ||
| 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 | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | // | ||
| 9 | // This file contains an implementation of 32bit and 64bit scalar integer | ||
| 10 | // division for targets that don't have native support. It's largely derived | ||
| 11 | // from compiler-rt's implementations of __udivsi3 and __udivmoddi4, | ||
| 12 | // but hand-tuned for targets that prefer less control flow. | ||
| 13 | // | ||
| 14 | //===----------------------------------------------------------------------===// | ||
| 15 | |||
| 16 | #ifndef LLVM_TRANSFORMS_UTILS_INTEGERDIVISION_H | ||
| 17 | #define LLVM_TRANSFORMS_UTILS_INTEGERDIVISION_H | ||
| 18 | |||
| 19 | namespace llvm { | ||
| 20 | class BinaryOperator; | ||
| 21 | } | ||
| 22 | |||
| 23 | namespace llvm { | ||
| 24 | |||
| 25 |   /// Generate code to calculate the remainder of two integers, replacing Rem | ||
| 26 |   /// with the generated code. This currently generates code using the udiv | ||
| 27 |   /// expansion, but future work includes generating more specialized code, | ||
| 28 |   /// e.g. when more information about the operands are known. Implements both | ||
| 29 |   /// 32bit and 64bit scalar division. | ||
| 30 |   /// | ||
| 31 |   /// Replace Rem with generated code. | ||
| 32 | bool expandRemainder(BinaryOperator *Rem); | ||
| 33 | |||
| 34 |   /// Generate code to divide two integers, replacing Div with the generated | ||
| 35 |   /// code. This currently generates code similarly to compiler-rt's | ||
| 36 |   /// implementations, but future work includes generating more specialized code | ||
| 37 |   /// when more information about the operands are known. Implements both | ||
| 38 |   /// 32bit and 64bit scalar division. | ||
| 39 |   /// | ||
| 40 |   /// Replace Div with generated code. | ||
| 41 | bool expandDivision(BinaryOperator* Div); | ||
| 42 | |||
| 43 |   /// Generate code to calculate the remainder of two integers, replacing Rem | ||
| 44 |   /// with the generated code. Uses ExpandReminder with a 32bit Rem which | ||
| 45 |   /// makes it useful for targets with little or no support for less than | ||
| 46 |   /// 32 bit arithmetic. | ||
| 47 |   /// | ||
| 48 |   /// Replace Rem with generated code. | ||
| 49 | bool expandRemainderUpTo32Bits(BinaryOperator *Rem); | ||
| 50 | |||
| 51 |   /// Generate code to calculate the remainder of two integers, replacing Rem | ||
| 52 |   /// with the generated code. Uses ExpandReminder with a 64bit Rem. | ||
| 53 |   /// | ||
| 54 |   /// Replace Rem with generated code. | ||
| 55 | bool expandRemainderUpTo64Bits(BinaryOperator *Rem); | ||
| 56 | |||
| 57 |   /// Generate code to divide two integers, replacing Div with the generated | ||
| 58 |   /// code. Uses ExpandDivision with a 32bit Div which makes it useful for | ||
| 59 |   /// targets with little or no support for less than 32 bit arithmetic. | ||
| 60 |   /// | ||
| 61 |   /// Replace Rem with generated code. | ||
| 62 | bool expandDivisionUpTo32Bits(BinaryOperator *Div); | ||
| 63 | |||
| 64 |   /// Generate code to divide two integers, replacing Div with the generated | ||
| 65 |   /// code. Uses ExpandDivision with a 64bit Div. | ||
| 66 |   /// | ||
| 67 |   /// Replace Rem with generated code. | ||
| 68 | bool expandDivisionUpTo64Bits(BinaryOperator *Div); | ||
| 69 | |||
| 70 | } // End llvm namespace | ||
| 71 | |||
| 72 | #endif |