LLVM 24.0.0git
DXILIntrinsicExpansion.cpp File Reference
#include "DirectX.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/IntrinsicsDirectX.h"
#include "llvm/IR/MatrixBuilder.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PassManager.h"
#include "llvm/IR/Type.h"
#include "llvm/Pass.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"

Go to the source code of this file.

Classes

class  DXILIntrinsicExpansionLegacy

Macros

#define DEBUG_TYPE   "dxil-intrinsic-expansion"

Functions

static bool resourceAccessNeeds64BitExpansion (Module *M, Type *OverloadTy, bool IsRaw)
static Value * expand16BitIsInf (CallInst *Orig)
static Value * expand16BitIsNaN (CallInst *Orig)
static Value * expand16BitIsFinite (CallInst *Orig)
static Value * expand16BitIsNormal (CallInst *Orig)
static bool shouldExpandFloatDotIntrinsic (Function &F)
static bool isIntrinsicExpansion (Function &F)
static Value * expandUsubSat (CallInst *Orig)
static Value * createMulHighUnsigned (IRBuilder<> &Builder, Value *A, Value *B, Type *Ty, unsigned BW)
static Value * expandMulWithOverflow (CallInst *Orig, bool Signed)
static Value * expandVecReduceAdd (CallInst *Orig, Intrinsic::ID IntrinsicId)
static Value * expandVecReduceAndOr (CallInst *Orig, Intrinsic::ID IntrinsicId)
static Value * expandAbs (CallInst *Orig)
static Value * expandFloatDotChunk (CallInst *Orig, Value *A, Value *B)
static Value * expandFloatDotIntrinsic (CallInst *Orig)
static Value * expandIntegerDotIntrinsic (CallInst *Orig, Intrinsic::ID DotIntrinsic)
static Value * expandExpIntrinsic (CallInst *Orig)
static Value * expandIsFPClass (CallInst *Orig)
static Value * expandLogIntrinsic (CallInst *Orig, float LogConstVal=numbers::ln2f)
static Value * expandLog10Intrinsic (CallInst *Orig)
static Value * expandAtan2Intrinsic (CallInst *Orig)
template<bool LeftFunnel>
static Value * expandFunnelShiftIntrinsic (CallInst *Orig)
static Value * expandPowIntrinsic (CallInst *Orig, Intrinsic::ID IntrinsicId)
static Value * combineI32Pairs (IRBuilder<> &Builder, Value *I32Vec, Value *Result, unsigned Base)
 Recombine the lo/hi i32 pairs in I32Vec into double or i64 values.
static Value * splitIntoI32Pairs (IRBuilder<> &Builder, Value *Val)
 Split the double or i64 scalar or vector Val into a vector of i32 that holds the low and high halves of each element in turn.
static Value * expandSinCosIntrinsic (CallInst *Orig)
static bool expandBufferLoadIntrinsic (CallInst *Orig, bool IsRaw)
static bool expandTextureLoadIntrinsic (CallInst *Orig)
 Split a 64-bit llvm.dx.resource.load.level into a load of lo/hi i32 pairs on the same texture, forwarding the coordinates, mip level and offsets.
static bool expandTextureStoreIntrinsic (CallInst *Orig)
 Split a 64-bit llvm.dx.resource.store.texture into a store of lo/hi i32 pairs to the same texture, forwarding the coordinates.
static bool expandBufferStoreIntrinsic (CallInst *Orig, bool IsRaw)
static Intrinsic::ID getMaxForClamp (Intrinsic::ID ClampIntrinsic)
static Intrinsic::ID getMinForClamp (Intrinsic::ID ClampIntrinsic)
static Value * expandClampIntrinsic (CallInst *Orig, Intrinsic::ID ClampIntrinsic)
static Value * expandSignIntrinsic (CallInst *Orig)
static Value * expandCopySignIntrinsic (CallInst *Orig)
static Value * expandMatrixMultiply (CallInst *Orig)
static Value * expandMatrixTranspose (CallInst *Orig)
static bool expandStoreOutput (CallInst *Orig)
static Value * expandLoadInput (CallInst *Orig)
static Value * expandQuadAll (CallInst *Orig)
static bool expandIntrinsic (Function &F, CallInst *Orig)
static bool expansionIntrinsics (Module &M)
 INITIALIZE_PASS_BEGIN (DXILIntrinsicExpansionLegacy, DEBUG_TYPE, "DXIL Intrinsic Expansion", false, false) INITIALIZE_PASS_END(DXILIntrinsicExpansionLegacy

Variables

 DEBUG_TYPE
DXIL Intrinsic Expansion
DXIL Intrinsic false

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "dxil-intrinsic-expansion"

Definition at line 34 of file DXILIntrinsicExpansion.cpp.

Function Documentation

◆ combineI32Pairs()

Value * combineI32Pairs ( IRBuilder<> & Builder,
Value * I32Vec,
Value * Result,
unsigned Base )
static

Recombine the lo/hi i32 pairs in I32Vec into double or i64 values.

If Result is a vector, they are inserted into it from element Base on and the updated vector is returned; otherwise the single combined scalar is returned.

Definition at line 775 of file DXILIntrinsicExpansion.cpp.

References llvm::sampleprof::Base, llvm::cast(), llvm::Value::getType(), llvm::Hi, I, and Lo.

Referenced by expandBufferLoadIntrinsic(), and expandTextureLoadIntrinsic().

◆ createMulHighUnsigned()

Value * createMulHighUnsigned ( IRBuilder<> & Builder,
Value * A,
Value * B,
Type * Ty,
unsigned BW )
static

Definition at line 291 of file DXILIntrinsicExpansion.cpp.

References A(), assert(), B(), llvm::APInt::getLowBitsSet(), T, and llvm::V1.

Referenced by expandMulWithOverflow().

◆ expand16BitIsFinite()

◆ expand16BitIsInf()

◆ expand16BitIsNaN()

◆ expand16BitIsNormal()

◆ expandAbs()

◆ expandAtan2Intrinsic()

◆ expandBufferLoadIntrinsic()

◆ expandBufferStoreIntrinsic()

◆ expandClampIntrinsic()

Value * expandClampIntrinsic ( CallInst * Orig,
Intrinsic::ID ClampIntrinsic )
static

Definition at line 1075 of file DXILIntrinsicExpansion.cpp.

References getMaxForClamp(), getMinForClamp(), llvm::User::getOperand(), and X.

Referenced by expandIntrinsic().

◆ expandCopySignIntrinsic()

◆ expandExpIntrinsic()

◆ expandFloatDotChunk()

◆ expandFloatDotIntrinsic()

◆ expandFunnelShiftIntrinsic()

template<bool LeftFunnel>
Value * expandFunnelShiftIntrinsic ( CallInst * Orig)
static

◆ expandIntegerDotIntrinsic()

Value * expandIntegerDotIntrinsic ( CallInst * Orig,
Intrinsic::ID DotIntrinsic )
static

◆ expandIntrinsic()

◆ expandIsFPClass()

◆ expandLoadInput()

◆ expandLog10Intrinsic()

Value * expandLog10Intrinsic ( CallInst * Orig)
static

◆ expandLogIntrinsic()

◆ expandMatrixMultiply()

◆ expandMatrixTranspose()

Value * expandMatrixTranspose ( CallInst * Orig)
static

Definition at line 1253 of file DXILIntrinsicExpansion.cpp.

References llvm::cast(), llvm::CallBase::getArgOperand(), and I.

Referenced by expandIntrinsic().

◆ expandMulWithOverflow()

◆ expandPowIntrinsic()

◆ expandQuadAll()

Value * expandQuadAll ( CallInst * Orig)
static

◆ expandSignIntrinsic()

◆ expandSinCosIntrinsic()

◆ expandStoreOutput()

◆ expandTextureLoadIntrinsic()

bool expandTextureLoadIntrinsic ( CallInst * Orig)
static

Split a 64-bit llvm.dx.resource.load.level into a load of lo/hi i32 pairs on the same texture, forwarding the coordinates, mip level and offsets.

Definition at line 963 of file DXILIntrinsicExpansion.cpp.

References llvm::CallBase::args(), assert(), combineI32Pairs(), llvm::dyn_cast(), llvm::Instruction::eraseFromParent(), llvm::FixedVectorType::get(), llvm::PoisonValue::get(), llvm::Value::getType(), llvm::Load, and llvm::Value::replaceAllUsesWith().

Referenced by expandIntrinsic().

◆ expandTextureStoreIntrinsic()

bool expandTextureStoreIntrinsic ( CallInst * Orig)
static

Split a 64-bit llvm.dx.resource.store.texture into a store of lo/hi i32 pairs to the same texture, forwarding the coordinates.

Definition at line 985 of file DXILIntrinsicExpansion.cpp.

References assert(), llvm::cast(), llvm::Data, llvm::Instruction::eraseFromParent(), llvm::CallBase::getArgOperand(), and splitIntoI32Pairs().

Referenced by expandIntrinsic().

◆ expandUsubSat()

Value * expandUsubSat ( CallInst * Orig)
static

Definition at line 275 of file DXILIntrinsicExpansion.cpp.

References A(), B(), llvm::CallBase::getArgOperand(), llvm::Sub, and Zero.

Referenced by expandIntrinsic().

◆ expandVecReduceAdd()

Value * expandVecReduceAdd ( CallInst * Orig,
Intrinsic::ID IntrinsicId )
static

◆ expandVecReduceAndOr()

Value * expandVecReduceAndOr ( CallInst * Orig,
Intrinsic::ID IntrinsicId )
static

Definition at line 412 of file DXILIntrinsicExpansion.cpp.

References assert(), llvm::cast(), llvm::CallBase::getArgOperand(), I, uint64_t, and X.

Referenced by expandIntrinsic().

◆ expansionIntrinsics()

◆ getMaxForClamp()

Intrinsic::ID getMaxForClamp ( Intrinsic::ID ClampIntrinsic)
static

Definition at line 1057 of file DXILIntrinsicExpansion.cpp.

References assert().

Referenced by expandClampIntrinsic().

◆ getMinForClamp()

Intrinsic::ID getMinForClamp ( Intrinsic::ID ClampIntrinsic)
static

Definition at line 1066 of file DXILIntrinsicExpansion.cpp.

References assert().

Referenced by expandClampIntrinsic().

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( DXILIntrinsicExpansionLegacy ,
DEBUG_TYPE ,
"DXIL Intrinsic Expansion" ,
false ,
false  )

References DEBUG_TYPE.

◆ isIntrinsicExpansion()

bool isIntrinsicExpansion ( Function & F)
static

◆ resourceAccessNeeds64BitExpansion()

bool resourceAccessNeeds64BitExpansion ( Module * M,
Type * OverloadTy,
bool IsRaw )
static

◆ shouldExpandFloatDotIntrinsic()

bool shouldExpandFloatDotIntrinsic ( Function & F)
static

Definition at line 200 of file DXILIntrinsicExpansion.cpp.

References assert(), llvm::cast(), and F.

Referenced by isIntrinsicExpansion().

◆ splitIntoI32Pairs()

Value * splitIntoI32Pairs ( IRBuilder<> & Builder,
Value * Val )
static

Variable Documentation

◆ DEBUG_TYPE

DEBUG_TYPE

Definition at line 1521 of file DXILIntrinsicExpansion.cpp.

◆ Expansion

◆ false

DXIL Intrinsic false

Definition at line 1522 of file DXILIntrinsicExpansion.cpp.