23#include "llvm/IR/IntrinsicsDirectX.h"
29#define DEBUG_TYPE "dxil-op-lower"
35 switch (
F.getIntrinsicID()) {
36 case Intrinsic::dx_dot2:
37 case Intrinsic::dx_dot3:
38 case Intrinsic::dx_dot4:
46 auto *VecArg = dyn_cast<FixedVectorType>(Arg->
getType());
47 for (
unsigned I = 0;
I < VecArg->getNumElements(); ++
I) {
50 ExtractedElements.
push_back(ExtractedElement);
52 return ExtractedElements;
61 [[maybe_unused]]
auto *VecArg0 = dyn_cast<FixedVectorType>(Arg0->
getType());
64 for (
unsigned I = 1;
I < NumOperands; ++
I) {
66 [[maybe_unused]]
auto *VecArg = dyn_cast<FixedVectorType>(Arg->
getType());
68 assert(VecArg0->getElementType() == VecArg->getElementType());
69 assert(VecArg0->getNumElements() == VecArg->getNumElements());
71 NewOperands.
append(NextOperandList.begin(), NextOperandList.end());
80 CallInst *CI = dyn_cast<CallInst>(U);
88 Args.append(NewArgs.
begin(), NewArgs.
end());
95 std::string Message(
toString(std::move(E)));
98 M.getContext().diagnose(Diag);
111 bool Updated =
false;
114 if (!
F.isDeclaration())
120#define DXIL_OP_INTRINSIC(OpCode, Intrin) \
122 lowerIntrinsic(OpCode, F, M); \
124#include "DXILOperation.inc"
144class DXILOpLoweringLegacy :
public ModulePass {
156char DXILOpLoweringLegacy::ID = 0;
165 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.
Diagnostic information for unsupported feature in backend.
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
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...
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
const Function * getFunction() const
Return the function this instruction belongs to.
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.
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.
Expected< CallInst * > tryCreateOp(dxil::OpCode Op, ArrayRef< Value * > Args, Type *RetTy=nullptr)
Try to create a call instruction for the given DXIL op.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
std::optional< const char * > toString(const std::optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract a string value from it.
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.