35#include "llvm/IR/IntrinsicsARM.h"
47#define DEBUG_TYPE "arm-mve-gather-scatter-lowering"
62 return "MVE gather/scatter lowering";
77 bool isLegalTypeAndAlignment(
unsigned NumElements,
unsigned ElemSize,
80 void lookThroughBitcast(
Value *&Ptr);
93 int computeScale(
unsigned GEPElemSize,
unsigned MemoryElemSize);
96 std::optional<int64_t> getIfConst(
const Value *
V);
100 std::pair<Value *, int64_t> getVarAndConst(
Value *Inst,
int TypeScale);
137 Value *Ptr,
unsigned TypeScale,
148 void pushOutAdd(
PHINode *&Phi,
Value *OffsSecondOperand,
unsigned StartIndex);
150 void pushOutMulShl(
unsigned Opc,
PHINode *&Phi,
Value *IncrementPerRound,
151 Value *OffsSecondOperand,
unsigned LoopIncrement,
157char MVEGatherScatterLowering::ID = 0;
160 "MVE gather/scattering lowering pass",
false,
false)
163 return new MVEGatherScatterLowering();
166bool MVEGatherScatterLowering::isLegalTypeAndAlignment(
unsigned NumElements,
169 if (((NumElements == 4 &&
170 (ElemSize == 32 || ElemSize == 16 || ElemSize == 8)) ||
171 (NumElements == 8 && (ElemSize == 16 || ElemSize == 8)) ||
172 (NumElements == 16 && ElemSize == 8)) &&
173 Alignment >= ElemSize / 8)
175 LLVM_DEBUG(
dbgs() <<
"masked gathers/scatters: instruction does not have "
176 <<
"valid alignment or vector type \n");
191 unsigned TargetElemSize = 128 / TargetElemCount;
194 ->getScalarSizeInBits();
195 if (OffsetElemSize != TargetElemSize || OffsetElemSize != 32) {
199 int64_t TargetElemMaxSize = (1ULL << TargetElemSize);
200 auto CheckValueSize = [TargetElemMaxSize](
Value *OffsetElem) {
205 if (SExtValue >= TargetElemMaxSize || SExtValue < 0)
210 for (
unsigned i = 0; i < TargetElemCount; i++) {
215 if (!CheckValueSize(ConstOff))
222Value *MVEGatherScatterLowering::decomposePtr(
Value *Ptr,
Value *&Offsets,
223 int &Scale, FixedVectorType *Ty,
229 computeScale(
DL->getTypeAllocSizeInBits(
GEP->getSourceElementType()),
231 return Scale == -1 ? nullptr :
V;
249Value *MVEGatherScatterLowering::decomposeGEP(
Value *&Offsets,
251 GetElementPtrInst *
GEP,
254 LLVM_DEBUG(
dbgs() <<
"masked gathers/scatters: no getelementpointer "
258 LLVM_DEBUG(
dbgs() <<
"masked gathers/scatters: getelementpointer found."
259 <<
" Looking at intrinsic for base + vector of offsets\n");
260 Value *GEPPtr =
GEP->getPointerOperand();
266 if (
GEP->getNumOperands() != 2) {
267 LLVM_DEBUG(
dbgs() <<
"masked gathers/scatters: getelementptr with too many"
268 <<
" operands. Expanding.\n");
272 unsigned OffsetsElemCount =
286 ->getScalarSizeInBits() != 32)
292 if (Ty !=
Offsets->getType()) {
301 LLVM_DEBUG(
dbgs() <<
"masked gathers/scatters: found correct offsets\n");
305void MVEGatherScatterLowering::lookThroughBitcast(
Value *&Ptr) {
310 if (BCTy->getNumElements() == BCSrcTy->getNumElements()) {
313 Ptr = BitCast->getOperand(0);
318int MVEGatherScatterLowering::computeScale(
unsigned GEPElemSize,
319 unsigned MemoryElemSize) {
322 if (GEPElemSize == 32 && MemoryElemSize == 32)
324 else if (GEPElemSize == 16 && MemoryElemSize == 16)
326 else if (GEPElemSize == 8)
328 LLVM_DEBUG(
dbgs() <<
"masked gathers/scatters: incorrect scale. Can't "
329 <<
"create intrinsic\n");
333std::optional<int64_t> MVEGatherScatterLowering::getIfConst(
const Value *
V) {
335 if (
C &&
C->getSplatValue())
336 return std::optional<int64_t>{
C->getUniqueInteger().getSExtValue()};
338 return std::optional<int64_t>{};
341 if (
I->getOpcode() == Instruction::Add ||
I->getOpcode() == Instruction::Or ||
342 I->getOpcode() == Instruction::Mul ||
343 I->getOpcode() == Instruction::Shl) {
344 std::optional<int64_t> Op0 = getIfConst(
I->getOperand(0));
345 std::optional<int64_t> Op1 = getIfConst(
I->getOperand(1));
347 return std::optional<int64_t>{};
348 if (
I->getOpcode() == Instruction::Add)
349 return std::optional<int64_t>{*Op0 + *Op1};
350 if (
I->getOpcode() == Instruction::Mul)
351 return std::optional<int64_t>{*Op0 * *Op1};
352 if (
I->getOpcode() == Instruction::Shl)
353 return std::optional<int64_t>{*Op0 << *Op1};
354 if (
I->getOpcode() == Instruction::Or)
355 return std::optional<int64_t>{*Op0 | *Op1};
357 return std::optional<int64_t>{};
363 return I->getOpcode() == Instruction::Or &&
367std::pair<Value *, int64_t>
368MVEGatherScatterLowering::getVarAndConst(
Value *Inst,
int TypeScale) {
369 std::pair<Value *, int64_t> ReturnFalse =
370 std::pair<Value *, int64_t>(
nullptr, 0);
374 if (
Add ==
nullptr ||
379 std::optional<int64_t>
Const;
381 if ((Const = getIfConst(
Add->getOperand(0))))
382 Summand =
Add->getOperand(1);
383 else if ((Const = getIfConst(
Add->getOperand(1))))
384 Summand =
Add->getOperand(0);
389 int64_t Immediate = *
Const << TypeScale;
390 if (Immediate > 512 || Immediate < -512 || Immediate % 4 != 0)
393 return std::pair<Value *, int64_t>(Summand, Immediate);
396Instruction *MVEGatherScatterLowering::lowerGather(IntrinsicInst *
I) {
397 using namespace PatternMatch;
398 LLVM_DEBUG(
dbgs() <<
"masked gathers: checking transform preconditions\n"
405 Value *Ptr =
I->getArgOperand(0);
408 Value *PassThru =
I->getArgOperand(2);
413 lookThroughBitcast(Ptr);
421 Load = tryCreateMaskedGatherOffset(
I, Ptr, Root, Builder);
423 Load = tryCreateMaskedGatherBase(
I, Ptr, Builder);
428 LLVM_DEBUG(
dbgs() <<
"masked gathers: found non-trivial passthru - "
429 <<
"creating select\n");
439 I->eraseFromParent();
441 LLVM_DEBUG(
dbgs() <<
"masked gathers: successfully built masked gather\n"
446Instruction *MVEGatherScatterLowering::tryCreateMaskedGatherBase(
448 using namespace PatternMatch;
450 LLVM_DEBUG(
dbgs() <<
"masked gathers: loading from vector of pointers\n");
457 Intrinsic::arm_mve_vldr_gather_base, {Ty, Ptr->
getType()},
460 Intrinsic::arm_mve_vldr_gather_base_predicated,
465Instruction *MVEGatherScatterLowering::tryCreateMaskedGatherBaseWB(
467 using namespace PatternMatch;
469 LLVM_DEBUG(
dbgs() <<
"masked gathers: loading from vector of pointers with "
477 Intrinsic::arm_mve_vldr_gather_base_wb, {Ty, Ptr->
getType()},
480 Intrinsic::arm_mve_vldr_gather_base_wb_predicated,
485Instruction *MVEGatherScatterLowering::tryCreateMaskedGatherOffset(
487 using namespace PatternMatch;
489 Type *MemoryTy =
I->getType();
490 Type *ResultTy = MemoryTy;
496 bool TruncResult =
false;
498 if (
I->hasOneUse()) {
504 User->getType()->getPrimitiveSizeInBits() == 128) {
508 ResultTy =
User->getType();
511 User->getType()->getPrimitiveSizeInBits() == 128) {
513 << *ResultTy <<
"\n");
515 ResultTy =
User->getType();
526 LLVM_DEBUG(
dbgs() <<
"masked gathers: Small input type, truncing to: "
527 << *ResultTy <<
"\n");
532 LLVM_DEBUG(
dbgs() <<
"masked gathers: Extend needed but not provided "
533 "from the correct type. Expanding\n");
550 Intrinsic::arm_mve_vldr_gather_offset_predicated,
556 Intrinsic::arm_mve_vldr_gather_offset,
562 Load = TruncInst::Create(Instruction::Trunc,
Load, MemoryTy);
568Instruction *MVEGatherScatterLowering::lowerScatter(IntrinsicInst *
I) {
569 using namespace PatternMatch;
570 LLVM_DEBUG(
dbgs() <<
"masked scatters: checking transform preconditions\n"
577 Value *Ptr =
I->getArgOperand(1);
585 lookThroughBitcast(Ptr);
591 Store = tryCreateMaskedScatterOffset(
I, Ptr, Builder);
593 Store = tryCreateMaskedScatterBase(
I, Ptr, Builder);
597 LLVM_DEBUG(
dbgs() <<
"masked scatters: successfully built masked scatter\n"
599 I->eraseFromParent();
603Instruction *MVEGatherScatterLowering::tryCreateMaskedScatterBase(
605 using namespace PatternMatch;
615 LLVM_DEBUG(
dbgs() <<
"masked scatters: storing to a vector of pointers\n");
618 Intrinsic::arm_mve_vstr_scatter_base,
622 Intrinsic::arm_mve_vstr_scatter_base_predicated,
627Instruction *MVEGatherScatterLowering::tryCreateMaskedScatterBaseWB(
629 using namespace PatternMatch;
632 LLVM_DEBUG(
dbgs() <<
"masked scatters: storing to a vector of pointers "
633 <<
"with writeback\n");
640 Intrinsic::arm_mve_vstr_scatter_base_wb,
644 Intrinsic::arm_mve_vstr_scatter_base_wb_predicated,
649Instruction *MVEGatherScatterLowering::tryCreateMaskedScatterOffset(
651 using namespace PatternMatch;
655 Type *MemoryTy = InputTy;
657 LLVM_DEBUG(
dbgs() <<
"masked scatters: getelementpointer found. Storing"
658 <<
" to base + vector of offsets\n");
666 InputTy = PreTruncTy;
669 bool ExtendInput =
false;
679 LLVM_DEBUG(
dbgs() <<
"masked scatters: Small input type, will extend:\n"
683 LLVM_DEBUG(
dbgs() <<
"masked scatters: cannot create scatters for "
684 "non-standard input types. Expanding.\n");
699 Intrinsic::arm_mve_vstr_scatter_offset_predicated,
706 Intrinsic::arm_mve_vstr_scatter_offset,
713Instruction *MVEGatherScatterLowering::tryCreateIncrementingGatScat(
716 if (
I->getIntrinsicID() == Intrinsic::masked_gather)
736 LLVM_DEBUG(
dbgs() <<
"masked gathers/scatters: trying to build incrementing "
737 "wb gather/scatter\n");
742 computeScale(
DL->getTypeAllocSizeInBits(
GEP->getSourceElementType()),
743 DL->getTypeSizeInBits(
GEP->getType()) /
748 if (
GEP->hasOneUse()) {
752 if (
auto *
Load = tryCreateIncrementingWBGatScat(
I, BasePtr, Offsets,
757 LLVM_DEBUG(
dbgs() <<
"masked gathers/scatters: trying to build incrementing "
758 "non-wb gather/scatter\n");
760 std::pair<Value *, int64_t>
Add = getVarAndConst(Offsets, TypeScale);
761 if (
Add.first ==
nullptr)
764 int64_t Immediate =
Add.second;
768 Instruction::Shl, OffsetsIncoming,
771 "ScaledIndex",
I->getIterator());
774 Instruction::Add, ScaledOffsets,
780 "StartIndex",
I->getIterator());
782 if (
I->getIntrinsicID() == Intrinsic::masked_gather)
783 return tryCreateMaskedGatherBase(
I, OffsetsIncoming, Builder, Immediate);
785 return tryCreateMaskedScatterBase(
I, OffsetsIncoming, Builder, Immediate);
788Instruction *MVEGatherScatterLowering::tryCreateIncrementingWBGatScat(
789 IntrinsicInst *
I,
Value *BasePtr,
Value *Offsets,
unsigned TypeScale,
797 if (Phi ==
nullptr ||
Phi->getNumIncomingValues() != 2 ||
798 Phi->getParent() !=
L->getHeader() || !
Phi->hasNUses(2))
805 unsigned IncrementIndex =
806 Phi->getIncomingBlock(0) ==
L->getLoopLatch() ? 0 : 1;
808 Offsets =
Phi->getIncomingValue(IncrementIndex);
810 std::pair<Value *, int64_t>
Add = getVarAndConst(Offsets, TypeScale);
811 if (
Add.first ==
nullptr)
814 int64_t Immediate =
Add.second;
815 if (OffsetsIncoming != Phi)
826 Instruction::Shl,
Phi->getIncomingValue(1 - IncrementIndex),
829 Phi->getIncomingBlock(1 - IncrementIndex)->back().getIterator());
832 Instruction::Add, ScaledOffsets,
839 Phi->getIncomingBlock(1 - IncrementIndex)->back().getIterator());
842 Instruction::Sub, OffsetsIncoming,
844 "PreIncrementStartIndex",
845 Phi->getIncomingBlock(1 - IncrementIndex)->back().getIterator());
846 Phi->setIncomingValue(1 - IncrementIndex, OffsetsIncoming);
852 if (
I->getIntrinsicID() == Intrinsic::masked_gather) {
854 Value *
Load = tryCreateMaskedGatherBaseWB(
I, Phi, Builder, Immediate);
859 Builder.
Insert(EndResult);
860 Builder.
Insert(NewInduction);
863 EndResult = NewInduction =
864 tryCreateMaskedScatterBaseWB(
I, Phi, Builder, Immediate);
869 Phi->setIncomingValue(IncrementIndex, NewInduction);
874void MVEGatherScatterLowering::pushOutAdd(PHINode *&Phi,
875 Value *OffsSecondOperand,
876 unsigned StartIndex) {
877 LLVM_DEBUG(
dbgs() <<
"masked gathers/scatters: optimising add instruction\n");
878 assert(
Phi->getNumIncomingValues() == 2);
879 BasicBlock *NewIndexBlock =
Phi->getIncomingBlock(StartIndex);
883 Instruction::Add,
Phi->getIncomingValue(StartIndex), OffsSecondOperand,
884 "PushedOutAdd", InsertionPoint);
885 unsigned IncrementIndex = StartIndex == 0 ? 1 : 0;
888 Value *IncrementIndexValue =
Phi->getIncomingValue(IncrementIndex);
889 BasicBlock *IncrementIndexBlock =
Phi->getIncomingBlock(IncrementIndex);
890 Phi->setIncomingValue(0, NewIndex);
891 Phi->setIncomingBlock(0, NewIndexBlock);
892 Phi->setIncomingValue(1, IncrementIndexValue);
893 Phi->setIncomingBlock(1, IncrementIndexBlock);
896void MVEGatherScatterLowering::pushOutMulShl(
unsigned Opcode, PHINode *&Phi,
897 Value *IncrementPerRound,
898 Value *OffsSecondOperand,
899 unsigned LoopIncrement,
901 LLVM_DEBUG(
dbgs() <<
"masked gathers/scatters: optimising mul instruction\n");
902 assert(
Phi->getNumIncomingValues() == 2);
907 Phi->getIncomingBlock(LoopIncrement == 1 ? 0 : 1);
913 Phi->getIncomingValue(LoopIncrement == 1 ? 0 : 1),
914 OffsSecondOperand,
"PushedOutMul", InsertionPoint);
918 OffsSecondOperand,
"Product", InsertionPoint);
919 BasicBlock *NewIncrementBlock =
Phi->getIncomingBlock(LoopIncrement);
922 NewIncrInsertPt = std::prev(NewIncrInsertPt);
926 Instruction::Add, Phi, Product,
"IncrementPushedOutMul", NewIncrInsertPt);
928 Phi->setIncomingValue(0, StartIndex);
929 Phi->setIncomingBlock(0, StartIndexBlock);
930 Phi->setIncomingValue(1, NewIncrement);
931 Phi->setIncomingBlock(1, NewIncrementBlock);
937 if (
I->use_empty()) {
946 unsigned OpCode = U->getOpcode();
947 if ((OpCode == Instruction::Add || OpCode == Instruction::Mul ||
958bool MVEGatherScatterLowering::optimiseOffsets(
Value *Offsets, BasicBlock *BB,
960 LLVM_DEBUG(
dbgs() <<
"masked gathers/scatters: trying to optimize: "
961 << *Offsets <<
"\n");
1011 if (
Phi->getParent() !=
L->getHeader())
1015 BinaryOperator *IncInstruction;
1018 IncInstruction->
getOpcode() != Instruction::Add)
1021 int IncrementingBlock =
Phi->getIncomingValue(0) == IncInstruction ? 0 : 1;
1026 if (IncrementPerRound->
getType() != OffsSecondOperand->
getType() ||
1027 !
L->isLoopInvariant(OffsSecondOperand))
1049 NewPhi->
addIncoming(
Phi->getIncomingValue(IncrementingBlock == 1 ? 0 : 1),
1050 Phi->getIncomingBlock(IncrementingBlock == 1 ? 0 : 1));
1053 IncrementPerRound,
"LoopIncrement", IncInstruction->
getIterator());
1055 Phi->getIncomingBlock(IncrementingBlock));
1056 IncrementingBlock = 1;
1063 case Instruction::Add:
1064 case Instruction::Or:
1065 pushOutAdd(NewPhi, OffsSecondOperand, IncrementingBlock == 1 ? 0 : 1);
1067 case Instruction::Mul:
1068 case Instruction::Shl:
1069 pushOutMulShl(Offs->
getOpcode(), NewPhi, IncrementPerRound,
1070 OffsSecondOperand, IncrementingBlock, Builder);
1075 LLVM_DEBUG(
dbgs() <<
"masked gathers/scatters: simplified loop variable "
1100 if (
N < (
unsigned)(1 << (TargetElemSize - 1))) {
1101 NonVectorVal = Builder.CreateVectorSplat(
1114 if (XElType && !YElType) {
1115 FixSummands(XElType,
Y);
1117 }
else if (YElType && !XElType) {
1118 FixSummands(YElType,
X);
1120 }
else if (!XElType && !YElType)
1122 assert(XElType && YElType &&
"Unknown vector types");
1124 if (XElType != YElType) {
1125 LLVM_DEBUG(
dbgs() <<
"masked gathers/scatters: incompatible gep offsets\n");
1134 if (!ConstX || !ConstY)
1142 if (!ConstXEl || !ConstYEl ||
1145 (
unsigned)(1 << (TargetElemSize - 1)))
1150 Value *XScale = Builder.CreateVectorSplat(
1153 Value *YScale = Builder.CreateVectorSplat(
1156 Value *
Add = Builder.CreateAdd(Builder.CreateMul(
X, XScale),
1157 Builder.CreateMul(
Y, YScale));
1165Value *MVEGatherScatterLowering::foldGEP(GetElementPtrInst *
GEP,
1166 Value *&Offsets,
unsigned &Scale,
1168 Value *GEPPtr =
GEP->getPointerOperand();
1170 Scale =
DL->getTypeAllocSize(
GEP->getSourceElementType());
1177 Value *BaseBasePtr = foldGEP(BaseGEP, Offsets, Scale, Builder);
1181 Offsets, Scale,
GEP->getOperand(1),
1182 DL->getTypeAllocSize(
GEP->getSourceElementType()), Builder);
1183 if (Offsets ==
nullptr)
1191bool MVEGatherScatterLowering::optimiseAddress(
Value *
Address, BasicBlock *BB,
1207 assert(Scale == 1 &&
"Expected to fold GEP to a scale of 1");
1213 "gep.merged",
GEP->getIterator());
1215 <<
"\n new : " << *NewAddress <<
"\n");
1216 GEP->replaceAllUsesWith(
1222 Changed |= optimiseOffsets(
GEP->getOperand(1),
GEP->getParent(), LI);
1226bool MVEGatherScatterLowering::runOnFunction(
Function &
F) {
1227 auto &TPC = getAnalysis<TargetPassConfig>();
1228 auto &TM = TPC.getTM<TargetMachine>();
1229 auto *
ST = &TM.getSubtarget<ARMSubtarget>(
F);
1230 if (!
ST->getCLOpts().maskedgatscat || !
ST->hasMVEIntegerOps())
1232 LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
1233 DL = &
F.getDataLayout();
1239 for (BasicBlock &BB :
F) {
1242 for (Instruction &
I : BB) {
1244 if (
II &&
II->getIntrinsicID() == Intrinsic::masked_gather &&
1247 Changed |= optimiseAddress(
II->getArgOperand(0),
II->getParent(), LI);
1248 }
else if (
II &&
II->getIntrinsicID() == Intrinsic::masked_scatter &&
1251 Changed |= optimiseAddress(
II->getArgOperand(1),
II->getParent(), LI);
1255 for (IntrinsicInst *
I : Gathers) {
1265 for (IntrinsicInst *
I : Scatters) {
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static Decomposition decomposeGEP(GEPOperator &GEP, ConstraintInfo &Info, bool IsSigned, const DataLayout &DL)
static bool runOnFunction(Function &F, bool PostInlining)
static bool isAddLikeOr(Instruction *I, const DataLayout &DL)
static bool hasAllGatScatUsers(Instruction *I, const DataLayout &DL)
static bool checkOffsetSize(Value *Offsets, unsigned TargetElemCount)
static Value * CheckAndCreateOffsetAdd(Value *X, unsigned ScaleX, Value *Y, unsigned ScaleY, IRBuilder<> &Builder)
uint64_t IntrinsicInst * II
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
This file describes how to lower LLVM code to machine code.
Target-Independent Code Generator Pass Configuration Options pass.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
LLVM_ABI void setPreservesCFG()
This function should be called by the pass, iff they do not:
LLVM Basic Block Representation.
const Instruction & back() const
InstListType::iterator iterator
Instruction iterators...
BinaryOps getOpcode() const
static LLVM_ABI BinaryOperator * Create(BinaryOps Op, Value *S1, Value *S2, const Twine &Name=Twine(), InsertPosition InsertBefore=nullptr)
Construct a binary instruction, given the opcode and the two operands.
Type * getDestTy() const
Return the destination type, as a convenience.
This is the shared class of boolean and integer constants.
int64_t getSExtValue() const
Return the constant as a 64-bit integer value after it has been sign extended as appropriate for the ...
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
This is an important base class in LLVM.
LLVM_ABI Constant * getAggregateElement(unsigned Elt) const
For aggregates (struct/array/vector) return the constant that corresponds to the specified element if...
A parsed version of the target data layout string in and methods for querying it.
Class to represent fixed width SIMD vectors.
unsigned getNumElements() const
static LLVM_ABI FixedVectorType * get(Type *ElementType, unsigned NumElts)
FunctionPass class - This class is used to implement most global optimizations.
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
LLVM_ABI CallInst * CreateIntrinsicWithoutFolding(Intrinsic::ID ID, ArrayRef< Type * > OverloadTypes, ArrayRef< Value * > Args, FMFSource FMFSource={}, const Twine &Name="", ArrayRef< OperandBundleDef > OpBundles={})
Create a call to intrinsic ID with Args, mangled using OverloadTypes.
LLVM_ABI Value * CreateVectorSplat(unsigned NumElts, Value *V, const Twine &Name="")
Return a vector value that contains.
Value * CreateIntToPtr(Value *V, Type *DestTy, const Twine &Name="")
void SetCurrentDebugLocation(const DebugLoc &L)
Set location information used by debugging information.
IntegerType * getInt32Ty()
Fetch the type representing a 32-bit integer.
ConstantInt * getInt32(uint32_t C)
Get a constant 32-bit value.
InstTy * Insert(InstTy *I, const Twine &Name="") const
Insert and return the specified instruction.
Value * CreateBitCast(Value *V, Type *DestTy, const Twine &Name="")
Value * CreateZExt(Value *V, Type *DestTy, const Twine &Name="", bool IsNonNeg=false)
Value * CreatePtrToInt(Value *V, Type *DestTy, const Twine &Name="")
Value * CreateTrunc(Value *V, Type *DestTy, const Twine &Name="", bool IsNUW=false, bool IsNSW=false)
PointerType * getPtrTy(unsigned AddrSpace=0)
Fetch the type representing a pointer.
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block.
IntegerType * getInt8Ty()
Fetch the type representing an 8-bit integer.
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.
LLVM_ABI InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
A wrapper class for inspecting calls to intrinsic functions.
LoopT * getLoopFor(const BlockT *BB) const
Return the inner most loop that BB lives in.
The legacy pass manager's analysis pass to compute loop information.
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructors - NumReservedValues is a hint for the number of incoming edges that this phi node will h...
static LLVM_ABI PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Pass interface - Implemented by all 'passes'.
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
static SelectInst * Create(Value *C, Value *S1, Value *S2, const Twine &NameStr="", InsertPosition InsertBefore=nullptr, const Instruction *MDFrom=nullptr)
void push_back(const T &Elt)
Represent a constant reference to a string, i.e.
Target-Independent Code Generator Pass Configuration Options.
The instances of the Type class are immutable: once they are created, they are never changed.
bool isVectorTy() const
True if this is an instance of VectorType.
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
LLVM_ABI TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
LLVM_ABI Type * getWithNewBitWidth(unsigned NewBitWidth) const
Given an integer or vector type, change the lane bitwidth to NewBitwidth, whilst keeping the old numb...
Value * getOperand(unsigned i) const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
bool hasOneUse() const
Return true if there is exactly one use of this value.
LLVM_ABI void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Type * getElementType() const
const ParentTy * getParent() const
self_iterator getIterator()
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
@ BasicBlock
Various leaf nodes.
bool match(Val *V, const Pattern &P)
cst_pred_ty< is_one > m_One()
Match an integer 1 or a vector with all elements equal to 1.
is_zero< true > m_Zero()
Match any null constant or a vector with all elements equal to 0.
@ User
could "use" a pointer
NodeAddr< PhiNode * > Phi
friend class Instruction
Iterator for Instructions in a `BasicBlock.
unsigned getNumElements(Type *Ty)
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI bool haveNoCommonBitsSet(const WithCache< const Value * > &LHSCache, const WithCache< const Value * > &RHSCache, const SimplifyQuery &SQ)
Return true if LHS and RHS have no common bits set.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
@ Load
The value being inserted comes from a load (InsertElement only).
@ Store
The extracted value is stored (ExtractElement only).
Pass * createMVEGatherScatterLoweringPass()
LLVM_ABI bool SimplifyInstructionsInBlock(BasicBlock *BB, const TargetLibraryInfo *TLI=nullptr)
Scan the specified basic block and try to simplify any instructions in it and recursively delete dead...
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
LLVM_ABI bool matchSimpleRecurrence(const PHINode *P, BinaryOperator *&BO, Value *&Start, Value *&Step)
Attempt to match a simple first order recurrence cycle of the form: iv = phi Ty [Start,...
bool isGatherScatter(IntrinsicInst *IntInst)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
IRBuilder(LLVMContext &, FolderTy, InserterTy) -> IRBuilder< FolderTy, InserterTy >
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
void initializeMVEGatherScatterLoweringPass(PassRegistry &)
@ Increment
Incrementally increasing token ID.
This struct is a compact representation of a valid (non-zero power of two) alignment.