55#include "llvm/IR/IntrinsicsX86.h"
69#define DEBUG_TYPE "x86-lower-amx-type"
85 if (
II->getType()->isX86_AMXTy())
88 if (
V->getType()->isX86_AMXTy())
98 if (
I.getType()->isX86_AMXTy())
110 unsigned AllocaAS =
DL.getAllocaAddrSpace();
112 new AllocaInst(Ty, AllocaAS,
"",
F.getEntryBlock().begin());
126 Value *RealRow =
nullptr;
144 RealRow = Builder.CreateUDiv(
V, Builder.getInt16(4));
158 Value *Row =
nullptr, *Col =
nullptr;
159 switch (
II->getIntrinsicID()) {
162 case Intrinsic::x86_tileloadd64_internal:
163 case Intrinsic::x86_tileloaddt164_internal:
164 case Intrinsic::x86_tilestored64_internal:
165 case Intrinsic::x86_tileloaddrs64_internal:
166 case Intrinsic::x86_tileloaddrst164_internal: {
167 Row =
II->getArgOperand(0);
168 Col =
II->getArgOperand(1);
173 case Intrinsic::x86_tcmmimfp16ps_internal:
174 case Intrinsic::x86_tcmmrlfp16ps_internal:
175 case Intrinsic::x86_tdpbssd_internal:
176 case Intrinsic::x86_tdpbsud_internal:
177 case Intrinsic::x86_tdpbusd_internal:
178 case Intrinsic::x86_tdpbuud_internal:
179 case Intrinsic::x86_tdpbf16ps_internal:
180 case Intrinsic::x86_tdpfp16ps_internal:
181 case Intrinsic::x86_tdpbf8ps_internal:
182 case Intrinsic::x86_tdpbhf8ps_internal:
183 case Intrinsic::x86_tdphbf8ps_internal:
184 case Intrinsic::x86_tdphf8ps_internal: {
187 Row =
II->getArgOperand(0);
188 Col =
II->getArgOperand(1);
191 Row =
II->getArgOperand(0);
192 Col =
II->getArgOperand(2);
196 Col =
II->getArgOperand(1);
201 case Intrinsic::x86_tcvtrowd2ps_internal:
202 case Intrinsic::x86_tcvtrowps2bf16h_internal:
203 case Intrinsic::x86_tcvtrowps2bf16l_internal:
204 case Intrinsic::x86_tcvtrowps2phh_internal:
205 case Intrinsic::x86_tcvtrowps2phl_internal:
206 case Intrinsic::x86_tilemovrow_internal: {
207 assert(OpNo == 2 &&
"Illegal Operand Number.");
208 Row =
II->getArgOperand(0);
209 Col =
II->getArgOperand(1);
214 return std::make_pair(Row, Col);
218 Use &U = *(Phi->use_begin());
220 User *
V = U.getUser();
229 Use &U = *(
V->use_begin());
230 OpNo = U.getOperandNo();
237 Use &U = *(
V->use_begin());
244 return std::make_pair(
nullptr,
nullptr);
248class X86LowerAMXType {
254 std::map<Value *, Value *> Col2Row;
259 void combineLoadBitcast(LoadInst *LD, BitCastInst *Bitcast);
260 void combineBitcastStore(BitCastInst *Bitcast, StoreInst *ST);
261 bool transformBitcast(BitCastInst *Bitcast);
270 Value *Row =
nullptr, *Col =
nullptr;
272 unsigned OpNo =
U.getOperandNo();
277 Value *Stride = Builder.getInt64(64);
278 Value *I8Ptr =
LD->getOperand(0);
279 std::array<Value *, 4>
Args = {Row, Col, I8Ptr, Stride};
282 Builder.CreateIntrinsic(Intrinsic::x86_tileloadd64_internal, Args);
283 Bitcast->replaceAllUsesWith(NewInst);
293void X86LowerAMXType::combineBitcastStore(BitCastInst *Bitcast, StoreInst *ST) {
299 Value *Row =
II->getOperand(0);
300 Value *Col =
II->getOperand(1);
304 Value *Stride = Builder.getInt64(64);
305 Value *I8Ptr =
ST->getOperand(1);
306 std::array<Value *, 5>
Args = {Row, Col, I8Ptr, Stride, Tile};
307 Builder.CreateIntrinsic(Intrinsic::x86_tilestored64_internal, Args);
319 Value *Vec = Builder.CreateLoad(
Bitcast->getType(),
ST->getOperand(1));
320 Bitcast->replaceAllUsesWith(Vec);
324bool X86LowerAMXType::transformBitcast(BitCastInst *Bitcast) {
326 AllocaInst *AllocaAddr;
327 Value *I8Ptr, *Stride;
328 auto *Src =
Bitcast->getOperand(0);
330 auto Prepare = [&](
Type *MemTy) {
333 Stride = Builder.getInt64(64);
336 if (
Bitcast->getType()->isX86_AMXTy()) {
346 unsigned OpNo =
U.getOperandNo();
350 Prepare(
Bitcast->getOperand(0)->getType());
351 Builder.CreateStore(Src, AllocaAddr);
353 Value *Row =
nullptr, *Col =
nullptr;
355 std::array<Value *, 4>
Args = {Row, Col, I8Ptr, Stride};
357 Builder.CreateIntrinsic(Intrinsic::x86_tileloadd64_internal, Args);
358 Bitcast->replaceAllUsesWith(NewInst);
371 Value *Row =
II->getOperand(0);
372 Value *Col =
II->getOperand(1);
373 std::array<Value *, 5>
Args = {Row, Col, I8Ptr, Stride, Src};
374 Builder.CreateIntrinsic(Intrinsic::x86_tilestored64_internal, Args);
375 Value *NewInst = Builder.CreateLoad(
Bitcast->getType(), AllocaAddr);
376 Bitcast->replaceAllUsesWith(NewInst);
382bool X86LowerAMXType::visit() {
383 SmallVector<Instruction *, 8> DeadInsts;
393 if (
Bitcast->getType()->isX86_AMXTy()) {
400 if (transformBitcast(Bitcast))
420 combineLoadBitcast(LD, Bitcast);
424 }
else if (Src->getType()->isX86_AMXTy()) {
429 StoreInst *
ST =
nullptr;
430 for (Use &U :
Bitcast->uses()) {
436 if (transformBitcast(Bitcast))
460 combineBitcastStore(Bitcast, ST);
468 bool C = !DeadInsts.
empty();
470 for (
auto *Inst : DeadInsts)
471 Inst->eraseFromParent();
481 unsigned AllocaAS =
DL.getAllocaAddrSpace();
484 new AllocaInst(V256I32Ty, AllocaAS,
"",
F->getEntryBlock().begin());
487 Builder.SetInsertPoint(&*Iter);
488 Value *I8Ptr = Builder.CreateBitCast(AllocaRes, Builder.getPtrTy());
496 assert(
II &&
"Not tile intrinsic!");
497 Value *Row =
II->getOperand(0);
498 Value *Col =
II->getOperand(1);
502 Value *Stride = Builder.getInt64(64);
503 std::array<Value *, 5> Args = {Row, Col, Ptr, Stride, TileDef};
505 Instruction *TileStore = Builder.CreateIntrinsicWithoutFolding(
506 Intrinsic::x86_tilestored64_internal, Args);
512 assert(
V->getType()->isX86_AMXTy() &&
"Not define tile!");
522 Value *Row =
II->getOperand(0);
523 Value *Col =
II->getOperand(1);
527 Value *Stride = Builder.getInt64(64);
528 std::array<Value *, 4> Args = {Row, Col, Ptr, Stride};
531 Builder.CreateIntrinsic(Intrinsic::x86_tileloadd64_internal, Args);
536 for (
Use &U :
I->uses()) {
537 User *
V = U.getUser();
547class X86VolatileTileData {
552 Value *updatePhiIncomings(BasicBlock *BB,
553 SmallVector<Instruction *, 2> &Incomings);
554 void replacePhiDefWithLoad(Instruction *
PHI,
Value *StorePtr);
555 bool volatileTileData();
556 void volatileTilePHI(PHINode *
PHI);
557 void volatileTileNonPHI(Instruction *
I);
560Value *X86VolatileTileData::updatePhiIncomings(
561 BasicBlock *BB, SmallVector<Instruction *, 2> &Incomings) {
564 for (
auto *
I : Incomings) {
568 for (Use &U :
I->uses()) {
578void X86VolatileTileData::replacePhiDefWithLoad(Instruction *
PHI,
580 for (Use &U :
PHI->uses())
582 PHI->eraseFromParent();
640void X86VolatileTileData::volatileTilePHI(PHINode *
PHI) {
642 SmallVector<Instruction *, 2> Incomings;
644 for (
unsigned I = 0,
E =
PHI->getNumIncomingValues();
I !=
E; ++
I) {
647 assert(Inst &&
"We shouldn't fold AMX instruction!");
651 Value *StorePtr = updatePhiIncomings(BB, Incomings);
652 replacePhiDefWithLoad(
PHI, StorePtr);
671void X86VolatileTileData::volatileTileNonPHI(Instruction *
I) {
677 for (Use &U :
I->uses()) {
697bool X86VolatileTileData::volatileTileData() {
699 for (BasicBlock &BB :
F) {
700 SmallVector<Instruction *, 2> PHIInsts;
701 SmallVector<Instruction *, 8> AMXDefInsts;
703 for (Instruction &
I : BB) {
704 if (!
I.getType()->isX86_AMXTy())
713 for (Instruction *
I : AMXDefInsts) {
716 volatileTileNonPHI(
I);
720 for (Instruction *
I : PHIInsts) {
732class X86LowerAMXCast {
734 std::unique_ptr<DominatorTree> DT;
738 bool combineCastStore(IntrinsicInst *Cast, StoreInst *ST);
739 bool combineLoadCast(IntrinsicInst *Cast, LoadInst *LD);
740 bool combineTilezero(IntrinsicInst *Cast);
741 bool combineLdSt(SmallVectorImpl<Instruction *> &Casts);
742 bool combineAMXcast(TargetLibraryInfo *
TLI);
743 bool transformAMXCast(IntrinsicInst *AMXCast);
744 bool transformAllAMXCast();
745 bool optimizeAMXCastFromPhi(IntrinsicInst *CI, PHINode *PN,
746 SmallSetVector<Instruction *, 16> &DeadInst);
750 SmallSetVector<Instruction *, 16> &WorkList,
751 const TargetLibraryInfo *
TLI) {
758 for (
unsigned i = 0, e =
I->getNumOperands(); i != e; ++i) {
759 Value *OpV =
I->getOperand(i);
760 I->setOperand(i,
nullptr);
774 I->eraseFromParent();
788bool X86LowerAMXCast::optimizeAMXCastFromPhi(
789 IntrinsicInst *CI, PHINode *PN,
790 SmallSetVector<Instruction *, 16> &DeadInst) {
793 Type *SrcTy = Src->getType();
797 SmallSetVector<PHINode *, 4> OldPhiNodes;
805 while (!PhiWorklist.
empty()) {
807 for (
unsigned I = 0;
I < OldPN->getNumOperands(); ++
I) {
808 Value *IncValue = OldPN->getIncomingValue(
I);
815 Value *Row =
nullptr, *Col =
nullptr;
816 std::tie(Row, Col) =
getShape(OldPN);
822 auto *
Block = OldPN->getIncomingBlock(
I);
824 Instruction *NewInst = Builder.CreateIntrinsicWithoutFolding(
825 Intrinsic::x86_tilezero_internal, {}, {Row, Col});
827 NewInst = Builder.CreateIntrinsicWithoutFolding(
828 Intrinsic::x86_cast_tile_to_vector, {IncValue->
getType()},
832 OldPN->setIncomingValue(
I, NewInst);
837 if (OldPhiNodes.
insert(PNode))
846 if (TyA != DestTy || TyB != SrcTy)
856 for (
auto *OldPN : OldPhiNodes) {
857 for (User *
V : OldPN->users()) {
863 if (TyA != DestTy || TyB != SrcTy)
884 if (OldPhiNodes.count(
PHI) == 0)
892 SmallDenseMap<PHINode *, PHINode *> NewPNodes;
893 for (
auto *OldPN : OldPhiNodes) {
894 Builder.SetInsertPoint(OldPN);
895 PHINode *NewPN = Builder.CreatePHI(DestTy, OldPN->getNumOperands());
896 NewPNodes[OldPN] = NewPN;
900 for (
auto *OldPN : OldPhiNodes) {
901 PHINode *NewPN = NewPNodes[OldPN];
902 for (
unsigned j = 0, e = OldPN->getNumOperands(); j != e; ++j) {
903 Value *
V = OldPN->getOperand(j);
904 Value *NewV =
nullptr;
910 NewV = NewPNodes[PrevPN];
912 NewPN->
addIncoming(NewV, OldPN->getIncomingBlock(j));
924 for (
auto *OldPN : OldPhiNodes) {
925 PHINode *NewPN = NewPNodes[OldPN];
931 assert(TyA == DestTy && TyB == SrcTy);
953bool X86LowerAMXCast::combineCastStore(IntrinsicInst *Cast, StoreInst *ST) {
956 assert(Tile->getType()->isX86_AMXTy() &&
"Not Tile Operand!");
959 if (!Tile->hasOneUse())
965 Value *Row =
II->getOperand(0);
966 Value *Col =
II->getOperand(1);
971 Value *Stride = Builder.CreateSExt(Col, Builder.getInt64Ty());
972 Value *I8Ptr = Builder.CreateBitCast(
ST->getOperand(1), Builder.getPtrTy());
973 std::array<Value *, 5>
Args = {Row, Col, I8Ptr, Stride, Tile};
974 Builder.CreateIntrinsic(Intrinsic::x86_tilestored64_internal, Args);
983bool X86LowerAMXCast::combineLoadCast(IntrinsicInst *Cast, LoadInst *LD) {
984 bool EraseLoad =
true;
985 Value *Row =
nullptr, *Col =
nullptr;
987 unsigned OpNo =
U.getOperandNo();
999 DT.reset(
new DominatorTree(Func));
1000 if (!DT->dominates(Row, LD) || !DT->dominates(Col, LD)) {
1004 Builder.SetInsertPoint(&*std::next(
LD->getIterator()));
1005 Builder.CreateStore(LD, AllocaAddr);
1007 Builder.SetInsertPoint(Cast);
1008 I8Ptr = Builder.CreateBitCast(AllocaAddr, Builder.getPtrTy());
1011 I8Ptr = Builder.CreateBitCast(
LD->getOperand(0), Builder.getPtrTy());
1014 Value *Stride = Builder.CreateSExt(Col, Builder.getInt64Ty());
1015 std::array<Value *, 4>
Args = {Row, Col, I8Ptr, Stride};
1018 Builder.CreateIntrinsic(Intrinsic::x86_tileloadd64_internal, Args);
1027bool X86LowerAMXCast::combineTilezero(IntrinsicInst *Cast) {
1028 Value *Row =
nullptr, *Col =
nullptr;
1030 unsigned OpNo =
U.getOperandNo();
1039 Builder.CreateIntrinsic(Intrinsic::x86_tilezero_internal, {}, {Row, Col});
1044bool X86LowerAMXCast::combineLdSt(SmallVectorImpl<Instruction *> &Casts) {
1045 bool Change =
false;
1046 for (
auto *Cast : Casts) {
1053 if (
II->getIntrinsicID() == Intrinsic::x86_cast_tile_to_vector) {
1054 SmallVector<Instruction *, 2> DeadStores;
1055 for (User *U : Cast->
users()) {
1064 for (
auto *
Store : DeadStores)
1065 Store->eraseFromParent();
1086 Load->eraseFromParent();
1094bool X86LowerAMXCast::combineAMXcast(TargetLibraryInfo *
TLI) {
1095 bool Change =
false;
1097 SmallVector<Instruction *, 8> Vec2TileInsts;
1098 SmallVector<Instruction *, 8> Tile2VecInsts;
1099 SmallVector<Instruction *, 8> PhiCastWorkList;
1100 SmallSetVector<Instruction *, 16> DeadInst;
1101 for (BasicBlock &BB : Func) {
1102 for (Instruction &
I : BB) {
1113 auto Convert = [&](SmallVectorImpl<Instruction *> &Insts,
Intrinsic::ID IID) {
1114 for (
auto *Inst : Insts) {
1115 for (User *U : Inst->users()) {
1117 if (!
II ||
II->getIntrinsicID() != IID)
1126 II->replaceAllUsesWith(Inst->getOperand(0));
1132 Convert(Vec2TileInsts, Intrinsic::x86_cast_tile_to_vector);
1133 Convert(Tile2VecInsts, Intrinsic::x86_cast_vector_to_tile);
1135 SmallVector<Instruction *, 8> LiveCasts;
1136 auto EraseInst = [&](SmallVectorImpl<Instruction *> &Insts) {
1137 for (
auto *Inst : Insts) {
1138 if (Inst->use_empty()) {
1139 Inst->eraseFromParent();
1147 EraseInst(Vec2TileInsts);
1148 EraseInst(Tile2VecInsts);
1149 LLVM_DEBUG(
dbgs() <<
"[LowerAMXTYpe][combineAMXcast] IR dump after combine "
1150 "Vec2Tile and Tile2Vec:\n";
1152 Change |= combineLdSt(LiveCasts);
1153 EraseInst(LiveCasts);
1154 LLVM_DEBUG(
dbgs() <<
"[LowerAMXTYpe][combineAMXcast] IR dump after combine "
1155 "AMXCast and load/store:\n";
1159 for (BasicBlock &BB : Func) {
1160 for (Instruction &
I : BB) {
1167 for (
auto *
I : PhiCastWorkList) {
1180 while (!DeadInst.
empty()) {
1184 LLVM_DEBUG(
dbgs() <<
"[LowerAMXTYpe][combineAMXcast] IR dump after "
1185 "optimizeAMXCastFromPhi:\n";
1192bool X86LowerAMXCast::transformAMXCast(IntrinsicInst *AMXCast) {
1194 AllocaInst *AllocaAddr;
1195 Value *I8Ptr, *Stride;
1198 auto Prepare = [&](
Type *MemTy) {
1200 I8Ptr = Builder.CreateBitCast(AllocaAddr, Builder.getPtrTy());
1201 Stride = Builder.getInt64(64);
1222 unsigned OpNo =
U.getOperandNo();
1227 Builder.CreateStore(Src, AllocaAddr);
1229 Value *Row =
nullptr, *Col =
nullptr;
1231 std::array<Value *, 4>
Args = {
1232 Row, Col, I8Ptr, Builder.CreateSExt(Col, Builder.getInt64Ty())};
1234 Builder.CreateIntrinsic(Intrinsic::x86_tileloadd64_internal, Args);
1249 Value *Row =
II->getOperand(0);
1250 Value *Col =
II->getOperand(1);
1251 std::array<Value *, 5>
Args = {
1252 Row, Col, I8Ptr, Builder.CreateSExt(Col, Builder.getInt64Ty()), Src};
1253 Builder.CreateIntrinsic(Intrinsic::x86_tilestored64_internal, Args);
1254 Value *NewInst = Builder.CreateLoad(AMXCast->
getType(), AllocaAddr);
1262bool X86LowerAMXCast::transformAllAMXCast() {
1263 bool Change =
false;
1265 SmallVector<Instruction *, 8> WorkLists;
1266 for (BasicBlock &BB : Func) {
1267 for (Instruction &
I : BB) {
1273 for (
auto *Inst : WorkLists) {
1280bool lowerAmxType(
Function &
F,
const TargetMachine *TM,
1281 TargetLibraryInfo *
TLI) {
1291 X86LowerAMXCast LAC(
F);
1292 C |= LAC.combineAMXcast(
TLI);
1295 C |= LAC.transformAllAMXCast();
1297 X86LowerAMXType LAT(
F);
1308 if (!
F.hasFnAttribute(Attribute::OptimizeNone)) {
1309 X86VolatileTileData VTD(
F);
1310 C = VTD.volatileTileData() ||
C;
1342 &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(
F);
1343 return lowerAmxType(
F, TM,
TLI);
1346 void getAnalysisUsage(AnalysisUsage &AU)
const override {
1355static const char PassName[] =
"Lower AMX type for load/store";
1356char X86LowerAMXTypeLegacyPass::ID = 0;
1365 return new X86LowerAMXTypeLegacyPass();
const TargetLowering & TLI
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")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static bool DCEInstruction(Instruction *I, SmallSetVector< Instruction *, 16 > &WorkList, const TargetLibraryInfo *TLI)
static bool runOnFunction(Function &F, bool PostInlining)
This header defines various interfaces for pass management in LLVM.
uint64_t IntrinsicInst * II
FunctionAnalysisManager FAM
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
This file builds on the ADT/GraphTraits.h file to build a generic graph post order iterator.
static void visit(BasicBlock &Start, std::function< bool(BasicBlock *)> op)
This file implements a set that has insertion order iteration characteristics.
Target-Independent Code Generator Pass Configuration Options pass.
static ShapeT getShape(MachineRegisterInfo *MRI, Register TileReg)
static const char PassName[]
static bool isAMXCast(Instruction *II)
static Value * getRowFromCol(Instruction *II, Value *V, unsigned Granularity)
static void replaceWithTileLoad(Use &U, Value *Ptr, bool IsPHI=false)
static Instruction * createTileStore(Instruction *TileDef, Value *Ptr)
static Value * getAllocaPos(BasicBlock *BB)
static bool containsAMXCode(Function &F)
std::pair< Value *, Value * > getShape(IntrinsicInst *II, unsigned OpNo)
static bool isIncomingOfPHI(Instruction *I)
static bool isAMXIntrinsic(Value *I)
static Instruction * getFirstNonAllocaInTheEntryBlock(Function &F)
static AllocaInst * createAllocaInstAtEntry(IRBuilder<> &Builder, BasicBlock *BB, Type *Ty)
an instruction to allocate memory on the stack
void setAlignment(Align Align)
AnalysisUsage & addRequired()
LLVM_ABI void setPreservesCFG()
This function should be called by the pass, iff they do not:
LLVM Basic Block Representation.
const Function * getParent() const
Return the enclosing method, or null if none.
InstListType::iterator iterator
Instruction iterators...
This class represents a no-op cast from one type to another.
Represents analyses that only rely on functions' control flow.
A parsed version of the target data layout string in and methods for querying it.
FunctionPass class - This class is used to implement most global optimizations.
Value * CreateUDiv(Value *LHS, Value *RHS, const Twine &Name="", bool isExact=false)
ConstantInt * getInt16(uint16_t C)
Get a constant 16-bit value.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
LLVM_ABI void moveBefore(InstListType::iterator InsertPos)
Unlink this instruction from its current basic block and insert it into the basic block that MovePos ...
LLVM_ABI InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
iterator_range< user_iterator > users()
A wrapper class for inspecting calls to intrinsic functions.
This is an important class for using LLVM in a threaded context.
An instruction for reading from memory.
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
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.
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
bool contains(const_arg_type key) const
Check if the SetVector contains the given key.
bool empty() const
Determine if the SetVector is empty or not.
bool insert(const value_type &X)
Insert a new element into the SetVector.
value_type pop_back_val()
void push_back(const T &Elt)
Analysis pass providing the TargetLibraryInfo.
Provides information about what library functions are available for the current target.
Primary interface to the complete machine description for the target machine.
CodeGenOptLevel getOptLevel() const
Returns the optimization level: None, Less, Default, or Aggressive.
Target-Independent Code Generator Pass Configuration Options.
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI Type * getX86_AMXTy(LLVMContext &C)
bool isX86_AMXTy() const
Return true if this is X86 AMX.
A Use represents the edge between a Value definition and its users.
LLVM_ABI unsigned getOperandNo() const
Return the operand # of this use in its User.
void setOperand(unsigned i, Value *Val)
LLVM_ABI bool replaceUsesOfWith(Value *From, Value *To)
Replace uses of one Value with another.
Value * getOperand(unsigned i) const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
LLVM_ABI void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
static LLVM_ABI VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM)
const ParentTy * getParent() const
self_iterator getIterator()
Pass manager infrastructure for declaring and invalidating analyses.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
@ BasicBlock
Various leaf nodes.
@ Bitcast
Perform the operation on a different, but equivalently sized type.
bool match(Val *V, const Pattern &P)
auto m_Value()
Match an arbitrary value and ignore it.
auto m_Intrinsic(const Ts &...Ops)
Match intrinsic calls like this: m_Intrinsic<Intrinsic::fabs>(m_Value(X))
@ User
could "use" a pointer
NodeAddr< UseNode * > Use
NodeAddr< FuncNode * > Func
friend class Instruction
Iterator for Instructions in a `BasicBlock.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI void salvageDebugInfo(const MachineRegisterInfo &MRI, MachineInstr &MI)
Assuming the instruction MI is going to be deleted, attempt to salvage debug users of MI by writing t...
@ Load
The value being inserted comes from a load (InsertElement only).
@ Store
The extracted value is stored (ExtractElement only).
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...
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
LLVM_ABI bool isInstructionTriviallyDead(Instruction *I, const TargetLibraryInfo *TLI=nullptr)
Return true if the result produced by the instruction is not used, and the instruction will return.
auto reverse(ContainerTy &&C)
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...
auto post_order(const T &G)
Post-order traversal of a graph.
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...
LLVM_ABI bool salvageKnowledge(Instruction *I, AssumptionCache *AC=nullptr, DominatorTree *DT=nullptr)
Calls BuildAssumeFromInst and if the resulting llvm.assume is valid insert if before I.
DWARFExpression::Operation Op
FunctionPass * createX86LowerAMXTypeLegacyPass()
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.