22#include "llvm/IR/IntrinsicsDirectX.h"
28#define DEBUG_TYPE "dxil-op-lower"
34 switch (
F.getIntrinsicID()) {
35 case Intrinsic::dx_dot2:
36 case Intrinsic::dx_dot3:
37 case Intrinsic::dx_dot4:
45 auto *VecArg = dyn_cast<FixedVectorType>(Arg->
getType());
46 for (
unsigned I = 0;
I < VecArg->getNumElements(); ++
I) {
49 ExtractedElements.
push_back(ExtractedElement);
51 return ExtractedElements;
60 [[maybe_unused]]
auto *VecArg0 = dyn_cast<FixedVectorType>(Arg0->
getType());
63 for (
unsigned I = 1;
I < NumOperands; ++
I) {
65 [[maybe_unused]]
auto *VecArg = dyn_cast<FixedVectorType>(Arg->
getType());
67 assert(VecArg0->getElementType() == VecArg->getElementType());
68 assert(VecArg0->getNumElements() == VecArg->getNumElements());
70 NewOperands.
append(NextOperandList.begin(), NextOperandList.end());
80 CallInst *CI = dyn_cast<CallInst>(U);
85 Value *DXILOpArg =
B.getInt32(
static_cast<unsigned>(DXILOp));
86 Args.emplace_back(DXILOpArg);
90 Args.append(NewArgs.
begin(), NewArgs.
end());
105 bool Updated =
false;
107#define DXIL_OP_INTRINSIC_MAP
108#include "DXILOperation.inc"
109#undef DXIL_OP_INTRINSIC_MAP
112 if (!
F.isDeclaration())
117 auto LowerIt = LowerMap.find(
ID);
118 if (LowerIt == LowerMap.end())
139class DXILOpLoweringLegacy :
public ModulePass {
151char DXILOpLoweringLegacy::ID = 0;
160 return new DXILOpLoweringLegacy();
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static bool isVectorArgExpansion(Function &F)
static SmallVector< Value * > argVectorFlatten(CallInst *Orig, IRBuilder<> &Builder)
static SmallVector< Value * > populateOperands(Value *Arg, IRBuilder<> &Builder)
static bool lowerIntrinsics(Module &M)
static void lowerIntrinsic(dxil::OpCode DXILOp, Function &F, Module &M)
Module.h This file contains the declarations for the Module class.
This header defines various interfaces for pass management in LLVM.
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
A container for analyses that lazily runs them and caches their results.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
User::op_iterator arg_begin()
Return the iterator pointing to the beginning of the argument list.
User::op_iterator arg_end()
Return the iterator pointing to the end of the argument list.
This class represents a function call, abstracting a target machine's calling convention.
This class represents an Operation in the Expression.
Value * CreateExtractElement(Value *Vec, Value *Idx, const Twine &Name="")
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
virtual bool runOnModule(Module &M)=0
runOnModule - Virtual method overriden by subclasses to process the module being operated on.
A Module instance is used to store all the information related to an LLVM module.
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
The instances of the Type class are immutable: once they are created, they are never changed.
static IntegerType * getInt32Ty(LLVMContext &C)
Value * getOperand(unsigned i) const
unsigned getNumOperands() const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
LLVMContext & getContext() const
All values hold a context through their type.
Type * getOverloadTy(dxil::OpCode OpCode, FunctionType *FT)
CallInst * createDXILOpCall(dxil::OpCode OpCode, Type *ReturnTy, Type *OverloadTy, SmallVector< Value * > Args)
Create an instruction that calls DXIL Op with return type, specified opcode, and call arguments.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
PointerTypeMap run(const Module &M)
Compute the PointerTypeMap for the module M.
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
ModulePass * createDXILOpLoweringLegacyPass()
Pass to lowering LLVM intrinsic call to DXIL op function call.
A CRTP mix-in to automatically provide informational APIs needed for passes.