LLVM 22.0.0git
AMDGPULibCalls.cpp File Reference

This file does AMD library function optimizations. More...

Go to the source code of this file.

Classes

class  llvm::AMDGPULibCalls
struct  TableEntry

Namespaces

namespace  llvm
 This is an optimization pass for GlobalISel generic memory operations.

Macros

#define DEBUG_TYPE   "amdgpu-simplifylib"
#define MATH_PI   numbers::pi
#define MATH_E   numbers::e
#define MATH_SQRT2   numbers::sqrt2
#define MATH_SQRT1_2   numbers::inv_sqrt2

Typedefs

using TableRef = ArrayRef<TableEntry>

Functions

template<typename IRB>
static CallInstCreateCallEx (IRB &B, FunctionCallee Callee, Value *Arg, const Twine &Name="")
template<typename IRB>
static CallInstCreateCallEx2 (IRB &B, FunctionCallee Callee, Value *Arg1, Value *Arg2, const Twine &Name="")
static FunctionTypegetPownType (FunctionType *FT)
static bool HasNative (AMDGPULibFunc::EFuncId id)
static TableRef getOptTable (AMDGPULibFunc::EFuncId id)
static int getVecSize (const AMDGPULibFunc &FInfo)
static AMDGPULibFunc::EType getArgType (const AMDGPULibFunc &FInfo)
static bool isKnownIntegral (const Value *V, const DataLayout &DL, FastMathFlags FMF)
static double llvm::log2 (double V)

Variables

static cl::opt< boolEnablePreLink ("amdgpu-prelink", cl::desc("Enable pre-link mode optimizations"), cl::init(false), cl::Hidden)
static cl::list< std::stringUseNative ("amdgpu-use-native", cl::desc("Comma separated list of functions to replace with native, or all"), cl::CommaSeparated, cl::ValueOptional, cl::Hidden)
static const TableEntry tbl_acos []
static const TableEntry tbl_acosh []
static const TableEntry tbl_acospi []
static const TableEntry tbl_asin []
static const TableEntry tbl_asinh []
static const TableEntry tbl_asinpi []
static const TableEntry tbl_atan []
static const TableEntry tbl_atanh []
static const TableEntry tbl_atanpi []
static const TableEntry tbl_cbrt []
static const TableEntry tbl_cos []
static const TableEntry tbl_cosh []
static const TableEntry tbl_cospi []
static const TableEntry tbl_erfc []
static const TableEntry tbl_erf []
static const TableEntry tbl_exp []
static const TableEntry tbl_exp2 []
static const TableEntry tbl_exp10 []
static const TableEntry tbl_expm1 []
static const TableEntry tbl_log []
static const TableEntry tbl_log2 []
static const TableEntry tbl_log10 []
static const TableEntry tbl_rsqrt []
static const TableEntry tbl_sin []
static const TableEntry tbl_sinh []
static const TableEntry tbl_sinpi []
static const TableEntry tbl_sqrt []
static const TableEntry tbl_tan []
static const TableEntry tbl_tanh []
static const TableEntry tbl_tanpi []
static const TableEntry tbl_tgamma []

Detailed Description

This file does AMD library function optimizations.

Definition in file AMDGPULibCalls.cpp.

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "amdgpu-simplifylib"

Definition at line 26 of file AMDGPULibCalls.cpp.

◆ MATH_E

#define MATH_E   numbers::e

Definition at line 42 of file AMDGPULibCalls.cpp.

◆ MATH_PI

#define MATH_PI   numbers::pi

Definition at line 41 of file AMDGPULibCalls.cpp.

◆ MATH_SQRT1_2

#define MATH_SQRT1_2   numbers::inv_sqrt2

Definition at line 44 of file AMDGPULibCalls.cpp.

◆ MATH_SQRT2

#define MATH_SQRT2   numbers::sqrt2

Definition at line 43 of file AMDGPULibCalls.cpp.

Typedef Documentation

◆ TableRef

Definition at line 348 of file AMDGPULibCalls.cpp.

Function Documentation

◆ CreateCallEx()

template<typename IRB>
CallInst * CreateCallEx ( IRB & B,
FunctionCallee Callee,
Value * Arg,
const Twine & Name = "" )
static

Definition at line 146 of file AMDGPULibCalls.cpp.

References B(), llvm::dyn_cast(), and F.

◆ CreateCallEx2()

template<typename IRB>
CallInst * CreateCallEx2 ( IRB & B,
FunctionCallee Callee,
Value * Arg1,
Value * Arg2,
const Twine & Name = "" )
static

Definition at line 155 of file AMDGPULibCalls.cpp.

References B(), llvm::dyn_cast(), and F.

◆ getArgType()

AMDGPULibFunc::EType getArgType ( const AMDGPULibFunc & FInfo)
inlinestatic

◆ getOptTable()

TableRef getOptTable ( AMDGPULibFunc::EFuncId id)
static

Definition at line 350 of file AMDGPULibCalls.cpp.

References llvm::AMDGPULibFuncBase::EI_ACOS, llvm::AMDGPULibFuncBase::EI_ACOSH, llvm::AMDGPULibFuncBase::EI_ACOSPI, llvm::AMDGPULibFuncBase::EI_ASIN, llvm::AMDGPULibFuncBase::EI_ASINH, llvm::AMDGPULibFuncBase::EI_ASINPI, llvm::AMDGPULibFuncBase::EI_ATAN, llvm::AMDGPULibFuncBase::EI_ATANH, llvm::AMDGPULibFuncBase::EI_ATANPI, llvm::AMDGPULibFuncBase::EI_CBRT, llvm::AMDGPULibFuncBase::EI_COS, llvm::AMDGPULibFuncBase::EI_COSH, llvm::AMDGPULibFuncBase::EI_COSPI, llvm::AMDGPULibFuncBase::EI_ERF, llvm::AMDGPULibFuncBase::EI_ERFC, llvm::AMDGPULibFuncBase::EI_EXP, llvm::AMDGPULibFuncBase::EI_EXP10, llvm::AMDGPULibFuncBase::EI_EXP2, llvm::AMDGPULibFuncBase::EI_EXPM1, llvm::AMDGPULibFuncBase::EI_LOG, llvm::AMDGPULibFuncBase::EI_LOG10, llvm::AMDGPULibFuncBase::EI_LOG2, llvm::AMDGPULibFuncBase::EI_NCOS, llvm::AMDGPULibFuncBase::EI_NEXP2, llvm::AMDGPULibFuncBase::EI_NLOG2, llvm::AMDGPULibFuncBase::EI_NRSQRT, llvm::AMDGPULibFuncBase::EI_NSIN, llvm::AMDGPULibFuncBase::EI_NSQRT, llvm::AMDGPULibFuncBase::EI_RSQRT, llvm::AMDGPULibFuncBase::EI_SIN, llvm::AMDGPULibFuncBase::EI_SINH, llvm::AMDGPULibFuncBase::EI_SINPI, llvm::AMDGPULibFuncBase::EI_SQRT, llvm::AMDGPULibFuncBase::EI_TAN, llvm::AMDGPULibFuncBase::EI_TANH, llvm::AMDGPULibFuncBase::EI_TANPI, llvm::AMDGPULibFuncBase::EI_TGAMMA, tbl_acos, tbl_acosh, tbl_acospi, tbl_asin, tbl_asinh, tbl_asinpi, tbl_atan, tbl_atanh, tbl_atanpi, tbl_cbrt, tbl_cos, tbl_cosh, tbl_cospi, tbl_erf, tbl_erfc, tbl_exp, tbl_exp10, tbl_exp2, tbl_expm1, tbl_log, tbl_log10, tbl_log2, tbl_rsqrt, tbl_sin, tbl_sinh, tbl_sinpi, tbl_sqrt, tbl_tan, tbl_tanh, tbl_tanpi, and tbl_tgamma.

◆ getPownType()

◆ getVecSize()

int getVecSize ( const AMDGPULibFunc & FInfo)
inlinestatic

◆ HasNative()

◆ isKnownIntegral()

Variable Documentation

◆ EnablePreLink

cl::opt< bool > EnablePreLink("amdgpu-prelink", cl::desc("Enable pre-link mode optimizations"), cl::init(false), cl::Hidden) ( "amdgpu-prelink" ,
cl::desc("Enable pre-link mode optimizations") ,
cl::init(false) ,
cl::Hidden  )
static

◆ tbl_acos

const TableEntry tbl_acos[]
static
Initial value:
= {
{MATH_PI / 2.0, 0.0},
{MATH_PI / 2.0, -0.0},
{0.0, 1.0},
{MATH_PI, -1.0}
}
#define MATH_PI

Definition at line 181 of file AMDGPULibCalls.cpp.

Referenced by getOptTable().

◆ tbl_acosh

const TableEntry tbl_acosh[]
static
Initial value:
= {
{0.0, 1.0}
}

Definition at line 187 of file AMDGPULibCalls.cpp.

Referenced by getOptTable().

◆ tbl_acospi

const TableEntry tbl_acospi[]
static
Initial value:
= {
{0.5, 0.0},
{0.5, -0.0},
{0.0, 1.0},
{1.0, -1.0}
}

Definition at line 190 of file AMDGPULibCalls.cpp.

Referenced by getOptTable().

◆ tbl_asin

const TableEntry tbl_asin[]
static
Initial value:
= {
{0.0, 0.0},
{-0.0, -0.0},
{MATH_PI / 2.0, 1.0},
{-MATH_PI / 2.0, -1.0}
}

Definition at line 196 of file AMDGPULibCalls.cpp.

Referenced by getOptTable().

◆ tbl_asinh

const TableEntry tbl_asinh[]
static
Initial value:
= {
{0.0, 0.0},
{-0.0, -0.0}
}

Definition at line 202 of file AMDGPULibCalls.cpp.

Referenced by getOptTable().

◆ tbl_asinpi

const TableEntry tbl_asinpi[]
static
Initial value:
= {
{0.0, 0.0},
{-0.0, -0.0},
{0.5, 1.0},
{-0.5, -1.0}
}

Definition at line 206 of file AMDGPULibCalls.cpp.

Referenced by getOptTable().

◆ tbl_atan

const TableEntry tbl_atan[]
static
Initial value:
= {
{0.0, 0.0},
{-0.0, -0.0},
{MATH_PI / 4.0, 1.0},
{-MATH_PI / 4.0, -1.0}
}

Definition at line 212 of file AMDGPULibCalls.cpp.

Referenced by getOptTable().

◆ tbl_atanh

const TableEntry tbl_atanh[]
static
Initial value:
= {
{0.0, 0.0},
{-0.0, -0.0}
}

Definition at line 218 of file AMDGPULibCalls.cpp.

Referenced by getOptTable().

◆ tbl_atanpi

const TableEntry tbl_atanpi[]
static
Initial value:
= {
{0.0, 0.0},
{-0.0, -0.0},
{0.25, 1.0},
{-0.25, -1.0}
}

Definition at line 222 of file AMDGPULibCalls.cpp.

Referenced by getOptTable().

◆ tbl_cbrt

const TableEntry tbl_cbrt[]
static
Initial value:
= {
{0.0, 0.0},
{-0.0, -0.0},
{1.0, 1.0},
{-1.0, -1.0},
}

Definition at line 228 of file AMDGPULibCalls.cpp.

Referenced by getOptTable().

◆ tbl_cos

const TableEntry tbl_cos[]
static
Initial value:
= {
{1.0, 0.0},
{1.0, -0.0}
}

Definition at line 234 of file AMDGPULibCalls.cpp.

Referenced by getOptTable().

◆ tbl_cosh

const TableEntry tbl_cosh[]
static
Initial value:
= {
{1.0, 0.0},
{1.0, -0.0}
}

Definition at line 238 of file AMDGPULibCalls.cpp.

Referenced by getOptTable().

◆ tbl_cospi

const TableEntry tbl_cospi[]
static
Initial value:
= {
{1.0, 0.0},
{1.0, -0.0}
}

Definition at line 242 of file AMDGPULibCalls.cpp.

Referenced by getOptTable().

◆ tbl_erf

const TableEntry tbl_erf[]
static
Initial value:
= {
{0.0, 0.0},
{-0.0, -0.0}
}

Definition at line 250 of file AMDGPULibCalls.cpp.

Referenced by getOptTable().

◆ tbl_erfc

const TableEntry tbl_erfc[]
static
Initial value:
= {
{1.0, 0.0},
{1.0, -0.0}
}

Definition at line 246 of file AMDGPULibCalls.cpp.

Referenced by getOptTable().

◆ tbl_exp

const TableEntry tbl_exp[]
static
Initial value:
= {
{1.0, 0.0},
{1.0, -0.0},
{MATH_E, 1.0}
}
#define MATH_E

Definition at line 254 of file AMDGPULibCalls.cpp.

Referenced by getOptTable().

◆ tbl_exp10

const TableEntry tbl_exp10[]
static
Initial value:
= {
{1.0, 0.0},
{1.0, -0.0},
{10.0, 1.0}
}

Definition at line 264 of file AMDGPULibCalls.cpp.

Referenced by getOptTable().

◆ tbl_exp2

const TableEntry tbl_exp2[]
static
Initial value:
= {
{1.0, 0.0},
{1.0, -0.0},
{2.0, 1.0}
}

Definition at line 259 of file AMDGPULibCalls.cpp.

Referenced by getOptTable().

◆ tbl_expm1

const TableEntry tbl_expm1[]
static
Initial value:
= {
{0.0, 0.0},
{-0.0, -0.0}
}

Definition at line 269 of file AMDGPULibCalls.cpp.

Referenced by getOptTable().

◆ tbl_log

const TableEntry tbl_log[]
static
Initial value:
= {
{0.0, 1.0},
{1.0, MATH_E}
}

Definition at line 273 of file AMDGPULibCalls.cpp.

Referenced by getOptTable().

◆ tbl_log10

const TableEntry tbl_log10[]
static
Initial value:
= {
{0.0, 1.0},
{1.0, 10.0}
}

Definition at line 281 of file AMDGPULibCalls.cpp.

Referenced by getOptTable().

◆ tbl_log2

const TableEntry tbl_log2[]
static
Initial value:
= {
{0.0, 1.0},
{1.0, 2.0}
}

Definition at line 277 of file AMDGPULibCalls.cpp.

Referenced by getOptTable().

◆ tbl_rsqrt

const TableEntry tbl_rsqrt[]
static
Initial value:
= {
{1.0, 1.0},
{MATH_SQRT1_2, 2.0}
}
#define MATH_SQRT1_2

Definition at line 285 of file AMDGPULibCalls.cpp.

Referenced by getOptTable().

◆ tbl_sin

const TableEntry tbl_sin[]
static
Initial value:
= {
{0.0, 0.0},
{-0.0, -0.0}
}

Definition at line 289 of file AMDGPULibCalls.cpp.

Referenced by getOptTable().

◆ tbl_sinh

const TableEntry tbl_sinh[]
static
Initial value:
= {
{0.0, 0.0},
{-0.0, -0.0}
}

Definition at line 293 of file AMDGPULibCalls.cpp.

Referenced by getOptTable().

◆ tbl_sinpi

const TableEntry tbl_sinpi[]
static
Initial value:
= {
{0.0, 0.0},
{-0.0, -0.0}
}

Definition at line 297 of file AMDGPULibCalls.cpp.

Referenced by getOptTable().

◆ tbl_sqrt

const TableEntry tbl_sqrt[]
static
Initial value:
= {
{0.0, 0.0},
{1.0, 1.0},
{MATH_SQRT2, 2.0}
}
#define MATH_SQRT2

Definition at line 301 of file AMDGPULibCalls.cpp.

Referenced by getOptTable().

◆ tbl_tan

const TableEntry tbl_tan[]
static
Initial value:
= {
{0.0, 0.0},
{-0.0, -0.0}
}

Definition at line 306 of file AMDGPULibCalls.cpp.

Referenced by getOptTable().

◆ tbl_tanh

const TableEntry tbl_tanh[]
static
Initial value:
= {
{0.0, 0.0},
{-0.0, -0.0}
}

Definition at line 310 of file AMDGPULibCalls.cpp.

Referenced by getOptTable().

◆ tbl_tanpi

const TableEntry tbl_tanpi[]
static
Initial value:
= {
{0.0, 0.0},
{-0.0, -0.0}
}

Definition at line 314 of file AMDGPULibCalls.cpp.

Referenced by getOptTable().

◆ tbl_tgamma

const TableEntry tbl_tgamma[]
static
Initial value:
= {
{1.0, 1.0},
{1.0, 2.0},
{2.0, 3.0},
{6.0, 4.0}
}

Definition at line 318 of file AMDGPULibCalls.cpp.

Referenced by getOptTable().

◆ UseNative

cl::list< std::string > UseNative("amdgpu-use-native", cl::desc("Comma separated list of functions to replace with native, or all"), cl::CommaSeparated, cl::ValueOptional, cl::Hidden) ( "amdgpu-use-native" ,
cl::desc("Comma separated list of functions to replace with native, or all") ,
cl::CommaSeparated ,
cl::ValueOptional ,
cl::Hidden  )
static