LLVM  6.0.0svn
Macros | Functions
IntegerDivision.cpp File Reference
#include "llvm/Transforms/Utils/IntegerDivision.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Intrinsics.h"
#include <utility>
Include dependency graph for IntegerDivision.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "integer-division"
 

Functions

static ValuegenerateSignedRemainderCode (Value *Dividend, Value *Divisor, IRBuilder<> &Builder)
 Generate code to compute the remainder of two signed integers. More...
 
static ValuegeneratedUnsignedRemainderCode (Value *Dividend, Value *Divisor, IRBuilder<> &Builder)
 Generate code to compute the remainder of two unsigned integers. More...
 
static ValuegenerateSignedDivisionCode (Value *Dividend, Value *Divisor, IRBuilder<> &Builder)
 Generate code to divide two signed integers. More...
 
static ValuegenerateUnsignedDivisionCode (Value *Dividend, Value *Divisor, IRBuilder<> &Builder)
 Generates code to divide two unsigned scalar 32-bit or 64-bit integers. More...
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "integer-division"

Definition at line 26 of file IntegerDivision.cpp.

Function Documentation

◆ generatedUnsignedRemainderCode()

static Value* generatedUnsignedRemainderCode ( Value Dividend,
Value Divisor,
IRBuilder<> &  Builder 
)
static

Generate code to compute the remainder of two unsigned integers.

Returns the remainder. Builder's insert point should be pointing where the caller wants code generated, e.g. at the urem instruction. This will generate a udiv in the process, and Builder's insert point will be pointing at the udiv (if present, i.e. not folded), ready to be expanded if the user wishes

Definition at line 80 of file IntegerDivision.cpp.

References llvm::IRBuilder< T, Inserter >::CreateMul(), llvm::IRBuilder< T, Inserter >::CreateSub(), llvm::IRBuilder< T, Inserter >::CreateUDiv(), and llvm::IRBuilderBase::SetInsertPoint().

Referenced by llvm::expandRemainder().

◆ generateSignedDivisionCode()

static Value* generateSignedDivisionCode ( Value Dividend,
Value Divisor,
IRBuilder<> &  Builder 
)
static

Generate code to divide two signed integers.

Returns the quotient, rounded towards 0. Builder's insert point should be pointing where the caller wants code generated, e.g. at the sdiv instruction. This will generate a udiv in the process, and Builder's insert point will be pointing at the udiv (if present, i.e. not folded), ready to be expanded if the user wishes.

Definition at line 104 of file IntegerDivision.cpp.

References assert(), llvm::IRBuilder< T, Inserter >::CreateAShr(), llvm::IRBuilder< T, Inserter >::CreateSub(), llvm::IRBuilder< T, Inserter >::CreateUDiv(), llvm::IRBuilder< T, Inserter >::CreateXor(), llvm::IRBuilderBase::getInt32(), llvm::IRBuilderBase::getInt64(), llvm::Type::getIntegerBitWidth(), llvm::Value::getType(), and llvm::IRBuilderBase::SetInsertPoint().

Referenced by llvm::expandDivision().

◆ generateSignedRemainderCode()

static Value* generateSignedRemainderCode ( Value Dividend,
Value Divisor,
IRBuilder<> &  Builder 
)
static

Generate code to compute the remainder of two signed integers.

Returns the remainder, which will have the sign of the dividend. Builder's insert point should be pointing where the caller wants code generated, e.g. at the srem instruction. This will generate a urem in the process, and Builder's insert point will be pointing at the uren (if present, i.e. not folded), ready to be expanded if the user wishes

Definition at line 34 of file IntegerDivision.cpp.

References assert(), llvm::IRBuilder< T, Inserter >::CreateAShr(), llvm::IRBuilder< T, Inserter >::CreateSub(), llvm::IRBuilder< T, Inserter >::CreateURem(), llvm::IRBuilder< T, Inserter >::CreateXor(), llvm::IRBuilderBase::getInt32(), llvm::IRBuilderBase::getInt64(), llvm::Type::getIntegerBitWidth(), llvm::Value::getType(), and llvm::IRBuilderBase::SetInsertPoint().

Referenced by llvm::expandRemainder().

◆ generateUnsignedDivisionCode()

static Value* generateUnsignedDivisionCode ( Value Dividend,
Value Divisor,
IRBuilder<> &  Builder 
)
static

Generates code to divide two unsigned scalar 32-bit or 64-bit integers.

Returns the quotient, rounded towards 0. Builder's insert point should point where the caller wants code generated, e.g. at the udiv instruction.

Definition at line 151 of file IntegerDivision.cpp.

References llvm::PHINode::addIncoming(), assert(), llvm::BasicBlock::begin(), llvm::BasicBlock::Create(), llvm::IRBuilder< T, Inserter >::CreateAdd(), llvm::IRBuilder< T, Inserter >::CreateAnd(), llvm::IRBuilder< T, Inserter >::CreateAShr(), llvm::IRBuilder< T, Inserter >::CreateBr(), llvm::IRBuilder< T, Inserter >::CreateCall(), llvm::IRBuilder< T, Inserter >::CreateCondBr(), llvm::IRBuilder< T, Inserter >::CreateICmpEQ(), llvm::IRBuilder< T, Inserter >::CreateICmpUGT(), llvm::IRBuilder< T, Inserter >::CreateLShr(), llvm::IRBuilder< T, Inserter >::CreateOr(), llvm::IRBuilder< T, Inserter >::CreatePHI(), llvm::IRBuilder< T, Inserter >::CreateSelect(), llvm::IRBuilder< T, Inserter >::CreateShl(), llvm::IRBuilder< T, Inserter >::CreateSub(), llvm::ISD::CTLZ, llvm::WebAssembly::End, llvm::Instruction::eraseFromParent(), F(), llvm::IntegerType::getBitWidth(), llvm::IRBuilderBase::getContext(), llvm::Intrinsic::getDeclaration(), llvm::IRBuilderBase::GetInsertBlock(), llvm::IRBuilderBase::GetInsertPoint(), llvm::IRBuilderBase::getInt32(), llvm::IRBuilderBase::getInt64(), llvm::BasicBlock::getParent(), llvm::GlobalValue::getParent(), llvm::ConstantInt::getSigned(), llvm::BasicBlock::getTerminator(), llvm::IRBuilderBase::getTrue(), llvm::Value::getType(), llvm::IRBuilderBase::SetInsertPoint(), and llvm::Value::setName().

Referenced by llvm::expandDivision().