LLVM 22.0.0git
DXILLegalizePass.cpp
Go to the documentation of this file.
1//===- DXILLegalizePass.cpp - Legalizes llvm IR for DXIL ------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===---------------------------------------------------------------------===//
8
9#include "DXILLegalizePass.h"
10#include "DirectX.h"
11#include "llvm/ADT/APInt.h"
12#include "llvm/IR/Constants.h"
13#include "llvm/IR/Function.h"
14#include "llvm/IR/IRBuilder.h"
16#include "llvm/IR/Instruction.h"
18#include "llvm/IR/Module.h"
19#include "llvm/Pass.h"
21#include <functional>
22
23#define DEBUG_TYPE "dxil-legalize"
24
25using namespace llvm;
26
30 auto *FI = dyn_cast<FreezeInst>(&I);
31 if (!FI)
32 return false;
33
34 FI->replaceAllUsesWith(FI->getOperand(0));
35 ToRemove.push_back(FI);
36 return true;
37}
38
41 DenseMap<Value *, Value *> &ReplacedValues) {
42
43 auto ProcessOperands = [&](SmallVector<Value *> &NewOperands) {
44 Type *InstrType = IntegerType::get(I.getContext(), 32);
45
46 for (unsigned OpIdx = 0; OpIdx < I.getNumOperands(); ++OpIdx) {
47 Value *Op = I.getOperand(OpIdx);
48 if (ReplacedValues.count(Op) &&
49 ReplacedValues[Op]->getType()->isIntegerTy())
50 InstrType = ReplacedValues[Op]->getType();
51 }
52
53 for (unsigned OpIdx = 0; OpIdx < I.getNumOperands(); ++OpIdx) {
54 Value *Op = I.getOperand(OpIdx);
55 if (ReplacedValues.count(Op))
56 NewOperands.push_back(ReplacedValues[Op]);
57 else if (auto *Imm = dyn_cast<ConstantInt>(Op)) {
58 APInt Value = Imm->getValue();
59 unsigned NewBitWidth = InstrType->getIntegerBitWidth();
60 // Note: options here are sext or sextOrTrunc.
61 // Since i8 isn't supported, we assume new values
62 // will always have a higher bitness.
63 assert(NewBitWidth > Value.getBitWidth() &&
64 "Replacement's BitWidth should be larger than Current.");
65 APInt NewValue = Value.sext(NewBitWidth);
66 NewOperands.push_back(ConstantInt::get(InstrType, NewValue));
67 } else {
68 assert(!Op->getType()->isIntegerTy(8));
69 NewOperands.push_back(Op);
70 }
71 }
72 };
73 IRBuilder<> Builder(&I);
74 if (auto *Trunc = dyn_cast<TruncInst>(&I)) {
75 if (Trunc->getDestTy()->isIntegerTy(8)) {
76 ReplacedValues[Trunc] = Trunc->getOperand(0);
77 ToRemove.push_back(Trunc);
78 return true;
79 }
80 }
81
82 if (auto *Store = dyn_cast<StoreInst>(&I)) {
83 if (!Store->getValueOperand()->getType()->isIntegerTy(8))
84 return false;
85 SmallVector<Value *> NewOperands;
86 ProcessOperands(NewOperands);
87 Value *NewStore = Builder.CreateStore(NewOperands[0], NewOperands[1]);
88 ReplacedValues[Store] = NewStore;
89 ToRemove.push_back(Store);
90 return true;
91 }
92
93 if (auto *Load = dyn_cast<LoadInst>(&I);
94 Load && I.getType()->isIntegerTy(8)) {
95 SmallVector<Value *> NewOperands;
96 ProcessOperands(NewOperands);
97 Type *ElementType = NewOperands[0]->getType();
98 if (auto *AI = dyn_cast<AllocaInst>(NewOperands[0]))
99 ElementType = AI->getAllocatedType();
100 if (auto *GEP = dyn_cast<GetElementPtrInst>(NewOperands[0])) {
101 ElementType = GEP->getSourceElementType();
102 }
103 if (ElementType->isArrayTy())
104 ElementType = ElementType->getArrayElementType();
105 LoadInst *NewLoad = Builder.CreateLoad(ElementType, NewOperands[0]);
106 ReplacedValues[Load] = NewLoad;
107 ToRemove.push_back(Load);
108 return true;
109 }
110
111 if (auto *Load = dyn_cast<LoadInst>(&I);
112 Load && isa<ConstantExpr>(Load->getPointerOperand())) {
113 auto *CE = dyn_cast<ConstantExpr>(Load->getPointerOperand());
114 if (!(CE->getOpcode() == Instruction::GetElementPtr))
115 return false;
116 auto *GEP = dyn_cast<GEPOperator>(CE);
117 if (!GEP->getSourceElementType()->isIntegerTy(8))
118 return false;
119
120 Type *ElementType = Load->getType();
121 ConstantInt *Offset = dyn_cast<ConstantInt>(GEP->getOperand(1));
122 uint32_t ByteOffset = Offset->getZExtValue();
123 uint32_t ElemSize = Load->getDataLayout().getTypeAllocSize(ElementType);
124 uint32_t Index = ByteOffset / ElemSize;
125
126 Value *PtrOperand = GEP->getPointerOperand();
127 Type *GEPType = GEP->getPointerOperandType();
128
129 if (auto *GV = dyn_cast<GlobalVariable>(PtrOperand))
130 GEPType = GV->getValueType();
131 if (auto *AI = dyn_cast<AllocaInst>(PtrOperand))
132 GEPType = AI->getAllocatedType();
133
134 if (auto *ArrTy = dyn_cast<ArrayType>(GEPType))
135 GEPType = ArrTy;
136 else
137 GEPType = ArrayType::get(ElementType, 1); // its a scalar
138
139 Value *NewGEP = Builder.CreateGEP(
140 GEPType, PtrOperand, {Builder.getInt32(0), Builder.getInt32(Index)},
141 GEP->getName(), GEP->getNoWrapFlags());
142
143 LoadInst *NewLoad = Builder.CreateLoad(ElementType, NewGEP);
144 ReplacedValues[Load] = NewLoad;
145 Load->replaceAllUsesWith(NewLoad);
146 ToRemove.push_back(Load);
147 return true;
148 }
149
150 if (auto *BO = dyn_cast<BinaryOperator>(&I)) {
151 if (!I.getType()->isIntegerTy(8))
152 return false;
153 SmallVector<Value *> NewOperands;
154 ProcessOperands(NewOperands);
155 Value *NewInst =
156 Builder.CreateBinOp(BO->getOpcode(), NewOperands[0], NewOperands[1]);
157 if (auto *OBO = dyn_cast<OverflowingBinaryOperator>(&I)) {
158 auto *NewBO = dyn_cast<BinaryOperator>(NewInst);
159 if (NewBO && OBO->hasNoSignedWrap())
160 NewBO->setHasNoSignedWrap();
161 if (NewBO && OBO->hasNoUnsignedWrap())
162 NewBO->setHasNoUnsignedWrap();
163 }
164 ReplacedValues[BO] = NewInst;
165 ToRemove.push_back(BO);
166 return true;
167 }
168
169 if (auto *Sel = dyn_cast<SelectInst>(&I)) {
170 if (!I.getType()->isIntegerTy(8))
171 return false;
172 SmallVector<Value *> NewOperands;
173 ProcessOperands(NewOperands);
174 Value *NewInst = Builder.CreateSelect(Sel->getCondition(), NewOperands[1],
175 NewOperands[2]);
176 ReplacedValues[Sel] = NewInst;
177 ToRemove.push_back(Sel);
178 return true;
179 }
180
181 if (auto *Cmp = dyn_cast<CmpInst>(&I)) {
182 if (!Cmp->getOperand(0)->getType()->isIntegerTy(8))
183 return false;
184 SmallVector<Value *> NewOperands;
185 ProcessOperands(NewOperands);
186 Value *NewInst =
187 Builder.CreateCmp(Cmp->getPredicate(), NewOperands[0], NewOperands[1]);
188 Cmp->replaceAllUsesWith(NewInst);
189 ReplacedValues[Cmp] = NewInst;
190 ToRemove.push_back(Cmp);
191 return true;
192 }
193
194 if (auto *Cast = dyn_cast<CastInst>(&I)) {
195 if (!Cast->getSrcTy()->isIntegerTy(8))
196 return false;
197
198 ToRemove.push_back(Cast);
199 auto *Replacement = ReplacedValues[Cast->getOperand(0)];
200 if (Cast->getType() == Replacement->getType()) {
201 Cast->replaceAllUsesWith(Replacement);
202 return true;
203 }
204
205 Value *AdjustedCast = nullptr;
206 if (Cast->getOpcode() == Instruction::ZExt)
207 AdjustedCast = Builder.CreateZExtOrTrunc(Replacement, Cast->getType());
208 if (Cast->getOpcode() == Instruction::SExt)
209 AdjustedCast = Builder.CreateSExtOrTrunc(Replacement, Cast->getType());
210
211 if (AdjustedCast)
212 Cast->replaceAllUsesWith(AdjustedCast);
213 }
214 if (auto *GEP = dyn_cast<GetElementPtrInst>(&I)) {
215 if (!GEP->getType()->isPointerTy() ||
216 !GEP->getSourceElementType()->isIntegerTy(8))
217 return false;
218
219 Value *BasePtr = GEP->getPointerOperand();
220 if (ReplacedValues.count(BasePtr))
221 BasePtr = ReplacedValues[BasePtr];
222
223 Type *ElementType = BasePtr->getType();
224
225 if (auto *AI = dyn_cast<AllocaInst>(BasePtr))
226 ElementType = AI->getAllocatedType();
227 if (auto *GV = dyn_cast<GlobalVariable>(BasePtr))
228 ElementType = GV->getValueType();
229
230 Type *GEPType = ElementType;
231 if (auto *ArrTy = dyn_cast<ArrayType>(ElementType))
232 ElementType = ArrTy->getArrayElementType();
233 else
234 GEPType = ArrayType::get(ElementType, 1); // its a scalar
235
236 ConstantInt *Offset = dyn_cast<ConstantInt>(GEP->getOperand(1));
237 // Note: i8 to i32 offset conversion without emitting IR requires constant
238 // ints. Since offset conversion is common, we can safely assume Offset is
239 // always a ConstantInt, so no need to have a conditional bail out on
240 // nullptr, instead assert this is the case.
241 assert(Offset && "Offset is expected to be a ConstantInt");
242 uint32_t ByteOffset = Offset->getZExtValue();
243 uint32_t ElemSize = GEP->getDataLayout().getTypeAllocSize(ElementType);
244 assert(ElemSize > 0 && "ElementSize must be set");
245 uint32_t Index = ByteOffset / ElemSize;
246 Value *NewGEP = Builder.CreateGEP(
247 GEPType, BasePtr, {Builder.getInt32(0), Builder.getInt32(Index)},
248 GEP->getName(), GEP->getNoWrapFlags());
249 ReplacedValues[GEP] = NewGEP;
250 GEP->replaceAllUsesWith(NewGEP);
251 ToRemove.push_back(GEP);
252 return true;
253 }
254 return false;
255}
256
259 DenseMap<Value *, Value *> &ReplacedValues) {
260 auto *AI = dyn_cast<AllocaInst>(&I);
261 if (!AI || !AI->getAllocatedType()->isIntegerTy(8))
262 return false;
263
264 Type *SmallestType = nullptr;
265
266 auto ProcessLoad = [&](LoadInst *Load) {
267 for (User *LU : Load->users()) {
268 CastInst *Cast = dyn_cast<CastInst>(LU);
269 if (!Cast)
270 continue;
271 Type *Ty = Cast->getType();
272
273 if (!SmallestType ||
274 Ty->getPrimitiveSizeInBits() < SmallestType->getPrimitiveSizeInBits())
275 SmallestType = Ty;
276 }
277 };
278
279 for (User *U : AI->users()) {
280 if (auto *Load = dyn_cast<LoadInst>(U))
281 ProcessLoad(Load);
282 else if (auto *GEP = dyn_cast<GetElementPtrInst>(U)) {
283 for (User *GU : GEP->users()) {
284 if (auto *Load = dyn_cast<LoadInst>(GU))
285 ProcessLoad(Load);
286 }
287 }
288 }
289
290 if (!SmallestType)
291 return false; // no valid casts found
292
293 // Replace alloca
294 IRBuilder<> Builder(AI);
295 auto *NewAlloca = Builder.CreateAlloca(SmallestType);
296 ReplacedValues[AI] = NewAlloca;
297 ToRemove.push_back(AI);
298 return true;
299}
300
301static bool
305
306 if (auto *Extract = dyn_cast<ExtractElementInst>(&I)) {
307 Value *Idx = Extract->getIndexOperand();
308 auto *CI = dyn_cast<ConstantInt>(Idx);
309 if (CI && CI->getBitWidth() == 64) {
310 IRBuilder<> Builder(Extract);
311 int64_t IndexValue = CI->getSExtValue();
312 auto *Idx32 =
313 ConstantInt::get(Type::getInt32Ty(I.getContext()), IndexValue);
314 Value *NewExtract = Builder.CreateExtractElement(
315 Extract->getVectorOperand(), Idx32, Extract->getName());
316
317 Extract->replaceAllUsesWith(NewExtract);
318 ToRemove.push_back(Extract);
319 return true;
320 }
321 }
322
323 if (auto *Insert = dyn_cast<InsertElementInst>(&I)) {
324 Value *Idx = Insert->getOperand(2);
325 auto *CI = dyn_cast<ConstantInt>(Idx);
326 if (CI && CI->getBitWidth() == 64) {
327 int64_t IndexValue = CI->getSExtValue();
328 auto *Idx32 =
329 ConstantInt::get(Type::getInt32Ty(I.getContext()), IndexValue);
330 IRBuilder<> Builder(Insert);
331 Value *Insert32Index = Builder.CreateInsertElement(
332 Insert->getOperand(0), Insert->getOperand(1), Idx32,
333 Insert->getName());
334
335 Insert->replaceAllUsesWith(Insert32Index);
336 ToRemove.push_back(Insert);
337 return true;
338 }
339 }
340 return false;
341}
342
346 const Intrinsic::ID ID = I.getOpcode();
347 if (ID != Instruction::FNeg)
348 return false;
349
350 IRBuilder<> Builder(&I);
351 Value *In = I.getOperand(0);
352 Value *Zero = ConstantFP::get(In->getType(), -0.0);
353 I.replaceAllUsesWith(Builder.CreateFSub(Zero, In));
354 ToRemove.push_back(&I);
355 return true;
356}
357
358static bool
361 DenseMap<Value *, Value *> &ReplacedValues) {
362 if (auto *BitCast = dyn_cast<BitCastInst>(&I)) {
363 if (BitCast->getDestTy() ==
364 FixedVectorType::get(Type::getInt32Ty(I.getContext()), 2) &&
365 BitCast->getSrcTy()->isIntegerTy(64)) {
366 ToRemove.push_back(BitCast);
367 ReplacedValues[BitCast] = BitCast->getOperand(0);
368 return true;
369 }
370 }
371
372 if (auto *Extract = dyn_cast<ExtractElementInst>(&I)) {
373 if (!dyn_cast<BitCastInst>(Extract->getVectorOperand()))
374 return false;
375 auto *VecTy = dyn_cast<FixedVectorType>(Extract->getVectorOperandType());
376 if (VecTy && VecTy->getElementType()->isIntegerTy(32) &&
377 VecTy->getNumElements() == 2) {
378 if (auto *Index = dyn_cast<ConstantInt>(Extract->getIndexOperand())) {
379 unsigned Idx = Index->getZExtValue();
380 IRBuilder<> Builder(&I);
381
382 auto *Replacement = ReplacedValues[Extract->getVectorOperand()];
383 assert(Replacement && "The BitCast replacement should have been set "
384 "before working on ExtractElementInst.");
385 if (Idx == 0) {
386 Value *LowBytes = Builder.CreateTrunc(
387 Replacement, Type::getInt32Ty(I.getContext()));
388 ReplacedValues[Extract] = LowBytes;
389 } else {
390 assert(Idx == 1);
391 Value *LogicalShiftRight = Builder.CreateLShr(
392 Replacement,
393 ConstantInt::get(
394 Replacement->getType(),
395 APInt(Replacement->getType()->getIntegerBitWidth(), 32)));
396 Value *HighBytes = Builder.CreateTrunc(
397 LogicalShiftRight, Type::getInt32Ty(I.getContext()));
398 ReplacedValues[Extract] = HighBytes;
399 }
400 ToRemove.push_back(Extract);
401 Extract->replaceAllUsesWith(ReplacedValues[Extract]);
402 return true;
403 }
404 }
405 }
406 return false;
407}
408
409static bool
413
414 Value *PtrOp;
415 unsigned PtrOpIndex;
416 [[maybe_unused]] Type *LoadStoreTy;
417 if (auto *LI = dyn_cast<LoadInst>(&I)) {
418 PtrOp = LI->getPointerOperand();
419 PtrOpIndex = LI->getPointerOperandIndex();
420 LoadStoreTy = LI->getType();
421 } else if (auto *SI = dyn_cast<StoreInst>(&I)) {
422 PtrOp = SI->getPointerOperand();
423 PtrOpIndex = SI->getPointerOperandIndex();
424 LoadStoreTy = SI->getValueOperand()->getType();
425 } else
426 return false;
427
428 // If the load/store is not of a single-value type (i.e., scalar or vector)
429 // then we do not modify it. It shouldn't be a vector either because the
430 // dxil-data-scalarization pass is expected to run before this, but it's not
431 // incorrect to apply this transformation to vector load/stores.
432 if (!LoadStoreTy->isSingleValueType())
433 return false;
434
435 Type *ArrayTy;
436 if (auto *GlobalVarPtrOp = dyn_cast<GlobalVariable>(PtrOp))
437 ArrayTy = GlobalVarPtrOp->getValueType();
438 else if (auto *AllocaPtrOp = dyn_cast<AllocaInst>(PtrOp))
439 ArrayTy = AllocaPtrOp->getAllocatedType();
440 else
441 return false;
442
443 if (!isa<ArrayType>(ArrayTy))
444 return false;
445
446 assert(ArrayTy->getArrayElementType() == LoadStoreTy &&
447 "Expected array element type to be the same as to the scalar load or "
448 "store type");
449
450 Value *Zero = ConstantInt::get(Type::getInt32Ty(I.getContext()), 0);
452 ArrayTy, PtrOp, {Zero, Zero}, GEPNoWrapFlags::all(), "", I.getIterator());
453 I.setOperand(PtrOpIndex, GEP);
454 return true;
455}
456
457namespace {
458class DXILLegalizationPipeline {
459
460public:
461 DXILLegalizationPipeline() { initializeLegalizationPipeline(); }
462
463 bool runLegalizationPipeline(Function &F) {
464 bool MadeChange = false;
466 DenseMap<Value *, Value *> ReplacedValues;
467 for (int Stage = 0; Stage < NumStages; ++Stage) {
468 ToRemove.clear();
469 ReplacedValues.clear();
470 for (auto &I : instructions(F)) {
471 for (auto &LegalizationFn : LegalizationPipeline[Stage])
472 MadeChange |= LegalizationFn(I, ToRemove, ReplacedValues);
473 }
474
475 for (auto *Inst : reverse(ToRemove))
476 Inst->eraseFromParent();
477 }
478 return MadeChange;
479 }
480
481private:
482 enum LegalizationStage { Stage1 = 0, Stage2 = 1, NumStages };
483
484 using LegalizationFnTy =
485 std::function<bool(Instruction &, SmallVectorImpl<Instruction *> &,
486 DenseMap<Value *, Value *> &)>;
487
488 SmallVector<LegalizationFnTy> LegalizationPipeline[NumStages];
489
490 void initializeLegalizationPipeline() {
491 LegalizationPipeline[Stage1].push_back(upcastI8AllocasAndUses);
492 LegalizationPipeline[Stage1].push_back(fixI8UseChain);
493 LegalizationPipeline[Stage1].push_back(legalizeGetHighLowi64Bytes);
494 LegalizationPipeline[Stage1].push_back(legalizeFreeze);
495 LegalizationPipeline[Stage1].push_back(updateFnegToFsub);
496 // Note: legalizeGetHighLowi64Bytes and
497 // downcastI64toI32InsertExtractElements both modify extractelement, so they
498 // must run staggered stages. legalizeGetHighLowi64Bytes runs first b\c it
499 // removes extractelements, reducing the number that
500 // downcastI64toI32InsertExtractElements needs to handle.
501 LegalizationPipeline[Stage2].push_back(
503 LegalizationPipeline[Stage2].push_back(legalizeScalarLoadStoreOnArrays);
504 }
505};
506
507class DXILLegalizeLegacy : public FunctionPass {
508
509public:
510 bool runOnFunction(Function &F) override;
511 DXILLegalizeLegacy() : FunctionPass(ID) {}
512
513 static char ID; // Pass identification.
514};
515} // namespace
516
519 DXILLegalizationPipeline DXLegalize;
520 bool MadeChanges = DXLegalize.runLegalizationPipeline(F);
521 if (!MadeChanges)
522 return PreservedAnalyses::all();
524 return PA;
525}
526
527bool DXILLegalizeLegacy::runOnFunction(Function &F) {
528 DXILLegalizationPipeline DXLegalize;
529 return DXLegalize.runLegalizationPipeline(F);
530}
531
532char DXILLegalizeLegacy::ID = 0;
533
534INITIALIZE_PASS_BEGIN(DXILLegalizeLegacy, DEBUG_TYPE, "DXIL Legalizer", false,
535 false)
536INITIALIZE_PASS_END(DXILLegalizeLegacy, DEBUG_TYPE, "DXIL Legalizer", false,
537 false)
538
540 return new DXILLegalizeLegacy();
541}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file implements a class to represent arbitrary precision integral constant values and operations...
ReachingDefInfo InstSet & ToRemove
Expand Atomic instructions
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static bool fixI8UseChain(Instruction &I, SmallVectorImpl< Instruction * > &ToRemove, DenseMap< Value *, Value * > &ReplacedValues)
static bool downcastI64toI32InsertExtractElements(Instruction &I, SmallVectorImpl< Instruction * > &ToRemove, DenseMap< Value *, Value * > &)
static bool upcastI8AllocasAndUses(Instruction &I, SmallVectorImpl< Instruction * > &ToRemove, DenseMap< Value *, Value * > &ReplacedValues)
static bool legalizeScalarLoadStoreOnArrays(Instruction &I, SmallVectorImpl< Instruction * > &ToRemove, DenseMap< Value *, Value * > &)
static bool legalizeGetHighLowi64Bytes(Instruction &I, SmallVectorImpl< Instruction * > &ToRemove, DenseMap< Value *, Value * > &ReplacedValues)
static bool legalizeFreeze(Instruction &I, SmallVectorImpl< Instruction * > &ToRemove, DenseMap< Value *, Value * >)
static bool updateFnegToFsub(Instruction &I, SmallVectorImpl< Instruction * > &ToRemove, DenseMap< Value *, Value * > &)
static bool runOnFunction(Function &F, bool PostInlining)
#define DEBUG_TYPE
Hexagon Common GEP
Module.h This file contains the declarations for the Module class.
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
MachineInstr unsigned OpIdx
FunctionAnalysisManager FAM
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition PassSupport.h:44
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Definition PassSupport.h:39
Class for arbitrary precision integers.
Definition APInt.h:78
static LLVM_ABI ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
This is the base class for all instructions that perform data casts.
Definition InstrTypes.h:448
This is the shared class of boolean and integer constants.
Definition Constants.h:87
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM)
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
Definition DenseMap.h:174
static LLVM_ABI FixedVectorType * get(Type *ElementType, unsigned NumElts)
Definition Type.cpp:802
FunctionPass class - This class is used to implement most global optimizations.
Definition Pass.h:314
static GEPNoWrapFlags all()
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Definition IRBuilder.h:2788
static LLVM_ABI IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
Definition Type.cpp:318
An instruction for reading from memory.
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition Analysis.h:118
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:45
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
Definition Type.cpp:296
Type * getArrayElementType() const
Definition Type.h:408
bool isSingleValueType() const
Return true if the type is a valid type for a register in codegen.
Definition Type.h:296
LLVM_ABI TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
Definition Type.cpp:197
LLVM Value Representation.
Definition Value.h:75
Type * getType() const
All values are typed, get the type of this value.
Definition Value.h:256
LLVM_ABI void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Definition Value.cpp:546
iterator_range< user_iterator > users()
Definition Value.h:426
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
InstrType
This represents what is and is not supported when finding similarity in Instructions.
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:532
FunctionPass * createDXILLegalizeLegacyPass()
Pass to Legalize DXIL by remove i8 truncations and i64 insert/extract elements.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
auto reverse(ContainerTy &&C)
Definition STLExtras.h:406
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...
Definition Casting.h:547
DWARFExpression::Operation Op
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.