LLVM 20.0.0git
Static Public Member Functions | Public Attributes | List of all members
llvm::SignedDivisionByConstantInfo Struct Reference

Magic data for optimising signed division by a constant. More...

#include "llvm/Support/DivisionByConstantInfo.h"

Static Public Member Functions

static SignedDivisionByConstantInfo get (const APInt &D)
 Calculate the magic numbers required to implement a signed integer division by a constant as a sequence of multiplies, adds and shifts.
 

Public Attributes

APInt Magic
 magic number
 
unsigned ShiftAmount
 shift amount
 

Detailed Description

Magic data for optimising signed division by a constant.

Definition at line 21 of file DivisionByConstantInfo.h.

Member Function Documentation

◆ get()

SignedDivisionByConstantInfo SignedDivisionByConstantInfo::get ( const APInt D)
static

Calculate the magic numbers required to implement a signed integer division by a constant as a sequence of multiplies, adds and shifts.

Requires that the divisor not be 0, 1, or -1. Taken from "Hacker's Delight", Henry S. Warren, Jr., Chapter 10.

Definition at line 21 of file DivisionByConstantInfo.cpp.

References assert(), D, llvm::APInt::getSignedMinValue(), llvm::APInt::isZero(), Magic, llvm::APInt::negate(), P, R2, ShiftAmount, llvm::APInt::udivrem(), llvm::APInt::uge(), and llvm::APInt::ult().

Referenced by llvm::TargetLowering::BuildSDIV().

Member Data Documentation

◆ Magic

APInt llvm::SignedDivisionByConstantInfo::Magic

magic number

Definition at line 23 of file DivisionByConstantInfo.h.

Referenced by llvm::TargetLowering::BuildSDIV(), and get().

◆ ShiftAmount

unsigned llvm::SignedDivisionByConstantInfo::ShiftAmount

shift amount

Definition at line 24 of file DivisionByConstantInfo.h.

Referenced by llvm::TargetLowering::BuildSDIV(), and get().


The documentation for this struct was generated from the following files: