LLVM 24.0.0git
FunctionLoweringInfo.cpp
Go to the documentation of this file.
1//===-- FunctionLoweringInfo.cpp ------------------------------------------===//
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// This implements routines for translating functions from LLVM IR into
10// Machine IR.
11//
12//===----------------------------------------------------------------------===//
13
15#include "llvm/ADT/APInt.h"
28#include "llvm/IR/Constants.h"
29#include "llvm/IR/DataLayout.h"
32#include "llvm/IR/Function.h"
35#include "llvm/IR/Intrinsics.h"
36#include "llvm/IR/Module.h"
37#include "llvm/Support/Debug.h"
41#include <algorithm>
42using namespace llvm;
43
44#define DEBUG_TYPE "function-lowering-info"
45
46/// isUsedOutsideOfDefiningBlock - Return true if this instruction is used by
47/// PHI nodes or outside of the basic block that defines it, or used by a
48/// switch or atomic instruction, which may expand to multiple basic blocks.
50 if (I->use_empty()) return false;
51 if (isa<PHINode>(I)) return true;
52 const BasicBlock *BB = I->getParent();
53 for (const User *U : I->users())
54 if (cast<Instruction>(U)->getParent() != BB || isa<PHINode>(U))
55 return true;
56
57 return false;
58}
59
61 // For the users of the source value being used for compare instruction, if
62 // the number of signed predicate is greater than unsigned predicate, we
63 // prefer to use SIGN_EXTEND.
64 //
65 // With this optimization, we would be able to reduce some redundant sign or
66 // zero extension instruction, and eventually more machine CSE opportunities
67 // can be exposed.
69 unsigned NumOfSigned = 0, NumOfUnsigned = 0;
70 for (const Use &U : I->uses()) {
71 if (const auto *CI = dyn_cast<CmpInst>(U.getUser())) {
72 NumOfSigned += CI->isSigned();
73 NumOfUnsigned += CI->isUnsigned();
74 }
75 if (const auto *CallI = dyn_cast<CallBase>(U.getUser())) {
76 if (!CallI->isArgOperand(&U))
77 continue;
78 unsigned ArgNo = CallI->getArgOperandNo(&U);
79 NumOfUnsigned += CallI->paramHasAttr(ArgNo, Attribute::ZExt);
80 NumOfSigned += CallI->paramHasAttr(ArgNo, Attribute::SExt);
81 }
82 }
83 if (NumOfSigned > NumOfUnsigned)
85
86 return ExtendKind;
87}
88
90 SelectionDAG *DAG) {
91 Fn = &fn;
92 MF = &mf;
93 TLI = MF->getSubtarget().getTargetLowering();
94 RegInfo = &MF->getRegInfo();
95 const TargetFrameLowering *TFI = MF->getSubtarget().getFrameLowering();
96 UA = DAG->getUniformityInfo();
97 ExceptionModel = Fn->getParent()->getExceptionModel();
98
99 // Check whether the function can return without sret-demotion.
101 CallingConv::ID CC = Fn->getCallingConv();
102
103 GetReturnInfo(CC, Fn->getReturnType(), Fn->getAttributes(), Outs, *TLI,
104 mf.getDataLayout());
106 TLI->CanLowerReturn(CC, *MF, Fn->isVarArg(), Outs, Fn->getContext(), Fn->getReturnType());
107
108 // If this personality uses funclets, we need to do a bit more work.
111 Fn->hasPersonalityFn() ? Fn->getPersonalityFn() : nullptr);
112 if (isFuncletEHPersonality(Personality)) {
113 // Calculate state numbers if we haven't already.
114 WinEHFuncInfo &EHInfo = *MF->getWinEHFuncInfo();
115 if (Personality == EHPersonality::MSVC_CXX)
117 else if (isAsynchronousEHPersonality(Personality))
118 calculateSEHStateNumbers(&fn, EHInfo);
119 else if (Personality == EHPersonality::CoreCLR)
120 calculateClrEHStateNumbers(&fn, EHInfo);
121
122 // Map all BB references in the WinEH data to MBBs.
123 for (WinEHTryBlockMapEntry &TBME : EHInfo.TryBlockMap) {
124 for (WinEHHandlerType &H : TBME.HandlerArray) {
125 if (const AllocaInst *AI = H.CatchObj.Alloca)
126 CatchObjects[AI].push_back(&H.CatchObj.FrameIndex);
127 else
128 H.CatchObj.FrameIndex = INT_MAX;
129 }
130 }
131 }
132
133 // Initialize the mapping of values to registers. This is only set up for
134 // instruction values that are used outside of the block that defines
135 // them.
136 const Align StackAlign = TFI->getStackAlign();
137 for (const BasicBlock &BB : *Fn) {
138 for (const Instruction &I : BB) {
139 if (const AllocaInst *AI = dyn_cast<AllocaInst>(&I)) {
140 Align Alignment = AI->getAlign();
141
142 // Static allocas can be folded into the initial stack frame
143 // adjustment. For targets that don't realign the stack, don't
144 // do this if there is an extra alignment requirement.
145 if (AI->isStaticAlloca() &&
146 (TFI->isStackRealignable() || (Alignment <= StackAlign))) {
147 TypeSize AllocaSize = AI->getAllocationSize(MF->getDataLayout())
148 .value_or(TypeSize::getZero());
149 uint64_t TySize = AllocaSize.getKnownMinValue();
150 if (TySize == 0)
151 TySize = 1; // Don't create zero-sized stack objects.
152 int FrameIndex = INT_MAX;
153 auto Iter = CatchObjects.find(AI);
154 if (Iter != CatchObjects.end() && TLI->needsFixedCatchObjects()) {
155 FrameIndex = MF->getFrameInfo().CreateFixedObject(
156 TySize, 0, /*IsImmutable=*/false, /*isAliased=*/true);
157 MF->getFrameInfo().setObjectAlignment(FrameIndex, Alignment);
158 } else {
159 FrameIndex = MF->getFrameInfo().CreateStackObject(TySize, Alignment,
160 false, AI);
161 }
162
163 // Scalable vectors and structures that contain scalable vectors may
164 // need a special StackID to distinguish them from other (fixed size)
165 // stack objects.
166 if (AllocaSize.isScalable())
167 MF->getFrameInfo().setStackID(FrameIndex,
169
170 StaticAllocaMap[AI] = FrameIndex;
171 // Update the catch handler information.
172 if (Iter != CatchObjects.end()) {
173 for (int *CatchObjPtr : Iter->second)
174 *CatchObjPtr = FrameIndex;
175 }
176 } else {
177 // FIXME: Overaligned static allocas should be grouped into
178 // a single dynamic allocation instead of using a separate
179 // stack allocation for each one.
180 // Inform the Frame Information that we have variable-sized objects.
181 MF->getFrameInfo().CreateVariableSizedObject(
182 Alignment <= StackAlign ? Align(1) : Alignment, AI);
183 }
184 } else if (auto *Call = dyn_cast<CallBase>(&I)) {
185 // Look for inline asm that clobbers the SP register.
186 if (Call->isInlineAsm()) {
187 Register SP = TLI->getStackPointerRegisterToSaveRestore();
188 const TargetRegisterInfo *TRI = MF->getSubtarget().getRegisterInfo();
189 std::vector<TargetLowering::AsmOperandInfo> Ops =
190 TLI->ParseConstraints(Fn->getDataLayout(), TRI,
191 *Call);
193 if (Op.Type == InlineAsm::isClobber) {
194 // Clobbers don't have SDValue operands, hence SDValue().
195 TLI->ComputeConstraintToUse(Op, SDValue(), DAG);
196 std::pair<unsigned, const TargetRegisterClass *> PhysReg =
197 TLI->getRegForInlineAsmConstraint(TRI, Op.ConstraintCode,
198 Op.ConstraintVT);
199 if (PhysReg.first == SP)
200 MF->getFrameInfo().setHasOpaqueSPAdjustment(true);
201 }
202 }
203 }
204 if (const auto *II = dyn_cast<IntrinsicInst>(&I)) {
205 switch (II->getIntrinsicID()) {
206 case Intrinsic::vastart:
207 // Look for calls to the @llvm.va_start intrinsic. We can omit
208 // some prologue boilerplate for variadic functions that don't
209 // examine their arguments.
210 MF->getFrameInfo().setHasVAStart(true);
211 break;
212 case Intrinsic::fake_use:
213 // Look for llvm.fake.uses, so that we can remove loads into fake
214 // uses later if necessary.
215 MF->setHasFakeUses(true);
216 break;
217 default:
218 break;
219 }
220 }
221
222 // If we have a musttail call in a variadic function, we need to ensure
223 // we forward implicit register parameters.
224 if (const auto *CI = dyn_cast<CallInst>(&I)) {
225 if (CI->isMustTailCall() && Fn->isVarArg())
226 MF->getFrameInfo().setHasMustTailInVarArgFunc(true);
227 }
228
229 // Determine if there is a call to setjmp in the machine function.
230 if (Call->hasFnAttr(Attribute::ReturnsTwice))
231 MF->setExposesReturnsTwice(true);
232 }
233
234 // Mark values used outside their block as exported, by allocating
235 // a virtual register for them.
239
240 // Decide the preferred extend type for a value. This iterates over all
241 // users and therefore isn't cheap, so don't do this at O0.
244 }
245 }
246
247 // Create an initial MachineBasicBlock for each LLVM BasicBlock in F. This
248 // also creates the initial PHI MachineInstrs, though none of the input
249 // operands are populated.
250 MBBMap.resize(Fn->getMaxBlockNumber());
251 for (const BasicBlock &BB : *Fn) {
252 // Don't create MachineBasicBlocks for imaginary EH pad blocks. These blocks
253 // are really data, and no instructions can live here.
254 if (BB.isEHPad()) {
255 BasicBlock::const_iterator PadInst = BB.getFirstNonPHIIt();
256 // If this is a non-landingpad EH pad, mark this function as using
257 // funclets.
258 // FIXME: SEH catchpads do not create EH scope/funclets, so we could avoid
259 // setting this in such cases in order to improve frame layout.
260 if (!isa<LandingPadInst>(PadInst)) {
261 MF->setHasEHScopes(true);
262 MF->setHasEHFunclets(true);
263 MF->getFrameInfo().setHasOpaqueSPAdjustment(true);
264 }
265 if (isa<CatchSwitchInst>(PadInst)) {
266 assert(BB.begin() == PadInst &&
267 "WinEHPrepare failed to remove PHIs from imaginary BBs");
268 continue;
269 }
270 if (isa<FuncletPadInst>(PadInst) &&
271 Personality != EHPersonality::Wasm_CXX &&
272 Personality != EHPersonality::Wasm_D)
273 assert(BB.begin() == PadInst && "WinEHPrepare failed to demote PHIs");
274 }
275
277 MBBMap[BB.getNumber()] = MBB;
278 MF->push_back(MBB);
279
280 // Transfer the address-taken flag. This is necessary because there could
281 // be multiple MachineBasicBlocks corresponding to one BasicBlock, and only
282 // the first one should be marked.
283 // Only mark the block if the BlockAddress actually has users. The
284 // hasAddressTaken flag may be stale if the BlockAddress was optimized away
285 // but the constant still exists in the uniquing table.
286 if (BB.hasAddressTaken()) {
287 if (BlockAddress *BA = BlockAddress::lookup(&BB))
288 if (!BA->hasZeroLiveUses())
289 MBB->setAddressTakenIRBlock(const_cast<BasicBlock *>(&BB));
290 }
291
292 // Mark landing pad blocks.
293 if (BB.isEHPad())
294 MBB->setIsEHPad();
295
296 // Create Machine PHI nodes for LLVM PHI nodes, lowering them as
297 // appropriate.
298 for (const PHINode &PN : BB.phis()) {
299 if (PN.use_empty())
300 continue;
301
302 // Skip empty types
303 if (PN.getType()->isEmptyTy())
304 continue;
305
306 DebugLoc DL = PN.getDebugLoc();
307 Register PHIReg = ValueMap[&PN];
308 assert(PHIReg && "PHI node does not have an assigned virtual register!");
309
310 SmallVector<EVT, 4> ValueVTs;
311 ComputeValueVTs(*TLI, MF->getDataLayout(), PN.getType(), ValueVTs);
312 for (EVT VT : ValueVTs) {
313 unsigned NumRegisters = TLI->getNumRegisters(Fn->getContext(), VT);
314 const TargetInstrInfo *TII = MF->getSubtarget().getInstrInfo();
315 for (unsigned i = 0; i != NumRegisters; ++i)
316 BuildMI(MBB, DL, TII->get(TargetOpcode::PHI), PHIReg + i);
317 PHIReg += NumRegisters;
318 }
319 }
320 }
321
322 if (isFuncletEHPersonality(Personality)) {
323 WinEHFuncInfo &EHInfo = *MF->getWinEHFuncInfo();
324
325 // Map all BB references in the WinEH data to MBBs.
326 for (WinEHTryBlockMapEntry &TBME : EHInfo.TryBlockMap) {
327 for (WinEHHandlerType &H : TBME.HandlerArray) {
328 if (H.Handler)
329 H.Handler = getMBB(cast<const BasicBlock *>(H.Handler));
330 }
331 }
332 for (CxxUnwindMapEntry &UME : EHInfo.CxxUnwindMap)
333 if (UME.Cleanup)
335 for (SEHUnwindMapEntry &UME : EHInfo.SEHUnwindMap)
336 UME.Handler = getMBB(cast<const BasicBlock *>(UME.Handler));
337 for (ClrEHUnwindMapEntry &CME : EHInfo.ClrEHUnwindMap)
339 }
340}
341
342/// clear - Clear out all the function-specific state. This returns this
343/// FunctionLoweringInfo to an empty state, ready to be used for a
344/// different function.
346 MBBMap.clear();
347 ValueMap.clear();
348 VirtReg2Value.clear();
349 StaticAllocaMap.clear();
350 LiveOutRegInfo.clear();
351 VisitedBBs.clear();
352 ArgDbgValues.clear();
353 DescribedArgs.clear();
354 ByValArgFrameIndexMap.clear();
355 RegFixups.clear();
356 RegsWithFixups.clear();
357 StatepointStackSlots.clear();
359 PreferredExtendType.clear();
361}
362
363/// CreateReg - Allocate a single virtual register for the given type.
365 return RegInfo->createVirtualRegister(TLI->getRegClassFor(VT, isDivergent));
366}
367
368/// CreateRegs - Allocate the appropriate number of virtual registers of
369/// the correctly promoted or expanded types. Assign these registers
370/// consecutive vreg numbers and return the first assigned number.
371///
372/// In the case that the given value has struct or array type, this function
373/// will assign registers for each member or element.
374///
376 SmallVector<EVT, 4> ValueVTs;
377 ComputeValueVTs(*TLI, MF->getDataLayout(), Ty, ValueVTs);
378
379 Register FirstReg;
380 for (EVT ValueVT : ValueVTs) {
381 MVT RegisterVT = TLI->getRegisterType(Ty->getContext(), ValueVT);
382
383 unsigned NumRegs = TLI->getNumRegisters(Ty->getContext(), ValueVT);
384 for (unsigned i = 0; i != NumRegs; ++i) {
385 Register R = CreateReg(RegisterVT, isDivergent);
386 if (!FirstReg) FirstReg = R;
387 }
388 }
389 return FirstReg;
390}
391
393 return CreateRegs(V->getType(), UA && UA->isDivergentAtDef(V) &&
394 !TLI->requiresUniformRegister(*MF, V));
395}
396
398 // Tokens live in vregs only when used for convergence control.
399 if (V->getType()->isTokenTy() && !isa<ConvergenceControlInst>(V))
400 return 0;
401 Register &R = ValueMap[V];
402 assert(R == Register() && "Already initialized this value register!");
403 assert(VirtReg2Value.empty());
404 return R = CreateRegs(V);
405}
406
407/// GetLiveOutRegInfo - Gets LiveOutInfo for a register, returning NULL if the
408/// register is a PHI destination and the PHI's LiveOutInfo is not valid. If
409/// the register's LiveOutInfo is for a smaller bit width, it is extended to
410/// the larger bit width by zero extension. The bit width must be no smaller
411/// than the LiveOutInfo's existing bit width.
414 if (!LiveOutRegInfo.inBounds(Reg))
415 return nullptr;
416
417 LiveOutInfo *LOI = &LiveOutRegInfo[Reg];
418 if (!LOI->IsValid)
419 return nullptr;
420
421 if (BitWidth > LOI->Known.getBitWidth()) {
422 LOI->NumSignBits = 1;
423 LOI->Known = LOI->Known.anyext(BitWidth);
424 }
425
426 return LOI;
427}
428
429/// ComputePHILiveOutRegInfo - Compute LiveOutInfo for a PHI's destination
430/// register based on the LiveOutInfo of its operands.
432 Type *Ty = PN->getType();
433 if (!Ty->isIntegerTy())
434 return;
435
436 SmallVector<EVT, 1> ValueVTs;
437 ComputeValueVTs(*TLI, MF->getDataLayout(), Ty, ValueVTs);
438 assert(ValueVTs.size() == 1 &&
439 "PHIs with non-vector integer types should have a single VT.");
440 EVT IntVT = ValueVTs[0];
441
442 unsigned NumRegisters = TLI->getNumRegisters(PN->getContext(), IntVT);
443 // FIXME: Support multiple registers for big endian targets.
444 if (NumRegisters != 1 && MF->getDataLayout().isBigEndian())
445 return;
446 IntVT = TLI->getRegisterType(PN->getContext(), IntVT);
447 unsigned BitWidth = IntVT.getSizeInBits();
448
449 auto It = ValueMap.find(PN);
450 if (It == ValueMap.end())
451 return;
452
453 Register BaseReg = It->second;
454 if (!BaseReg)
455 return;
456 assert(BaseReg.isVirtual() && "Expected a virtual reg");
457
458 for (unsigned RegIdx = 0; RegIdx < NumRegisters; ++RegIdx) {
459 // Split registers are assigned sequentially.
460 Register DestReg = BaseReg.id() + RegIdx;
461 LiveOutRegInfo.grow(DestReg);
462 LiveOutInfo &DestLOI = LiveOutRegInfo[DestReg];
463
464 Value *V = PN->getIncomingValue(0);
465 if (isa<UndefValue>(V) || isa<ConstantExpr>(V)) {
466 DestLOI.NumSignBits = 1;
467 DestLOI.Known = KnownBits(BitWidth);
468 continue;
469 }
470
471 if (ConstantInt *CI = dyn_cast<ConstantInt>(V)) {
472 APInt Val;
473 if (TLI->signExtendConstant(CI))
474 Val = CI->getValue().sext(BitWidth * NumRegisters);
475 else
476 Val = CI->getValue().zext(BitWidth * NumRegisters);
477 APInt Extracted = Val.extractBits(BitWidth, BitWidth * RegIdx);
478 DestLOI.NumSignBits = Extracted.getNumSignBits();
479 DestLOI.Known = KnownBits::makeConstant(Extracted);
480 } else {
481 assert(ValueMap.count(V) &&
482 "V should have been placed in ValueMap when its"
483 "CopyToReg node was created.");
484 Register SrcReg = ValueMap[V];
485 if (!SrcReg.isVirtual()) {
486 DestLOI.IsValid = false;
487 continue;
488 }
489 // Split registers are assigned sequentially.
490 SrcReg = SrcReg.id() + RegIdx;
491 const LiveOutInfo *SrcLOI = GetLiveOutRegInfo(SrcReg, BitWidth);
492 if (!SrcLOI) {
493 DestLOI.IsValid = false;
494 continue;
495 }
496 DestLOI = *SrcLOI;
497 }
498
499 assert(DestLOI.Known.Zero.getBitWidth() == BitWidth &&
500 DestLOI.Known.One.getBitWidth() == BitWidth &&
501 "Masks should have the same bit width as the type.");
502
503 for (unsigned i = 1, e = PN->getNumIncomingValues(); i != e; ++i) {
504 Value *V = PN->getIncomingValue(i);
505 if (isa<UndefValue>(V) || isa<ConstantExpr>(V)) {
506 DestLOI.NumSignBits = 1;
507 DestLOI.Known = KnownBits(BitWidth);
508 break;
509 }
510
511 if (ConstantInt *CI = dyn_cast<ConstantInt>(V)) {
512 APInt Val;
513 if (TLI->signExtendConstant(CI))
514 Val = CI->getValue().sext(BitWidth * NumRegisters);
515 else
516 Val = CI->getValue().zext(BitWidth * NumRegisters);
517 APInt Extracted = Val.extractBits(BitWidth, BitWidth * RegIdx);
518 DestLOI.NumSignBits =
519 std::min(DestLOI.NumSignBits, Extracted.getNumSignBits());
520 DestLOI.Known =
521 DestLOI.Known.intersectWith(KnownBits::makeConstant(Extracted));
522 continue;
523 }
524
525 assert(ValueMap.count(V) && "V should have been placed in ValueMap when "
526 "its CopyToReg node was created.");
527 Register SrcReg = ValueMap[V];
528 if (!SrcReg.isVirtual()) {
529 DestLOI.IsValid = false;
530 break;
531 }
532 // Split registers are assigned sequentially.
533 SrcReg = SrcReg.id() + RegIdx;
534 const LiveOutInfo *SrcLOI = GetLiveOutRegInfo(SrcReg, BitWidth);
535 if (!SrcLOI) {
536 DestLOI.IsValid = false;
537 break;
538 }
539 DestLOI.NumSignBits = std::min(DestLOI.NumSignBits, SrcLOI->NumSignBits);
540 DestLOI.Known = DestLOI.Known.intersectWith(SrcLOI->Known);
541 }
542 }
543}
544
545/// setArgumentFrameIndex - Record frame index for the byval
546/// argument. This overrides previous frame index entry for this argument,
547/// if any.
552
553/// getArgumentFrameIndex - Get frame index for the byval argument.
554/// If the argument does not have any assigned frame index then 0 is
555/// returned.
557 auto I = ByValArgFrameIndexMap.find(A);
558 if (I != ByValArgFrameIndexMap.end())
559 return I->second;
560 LLVM_DEBUG(dbgs() << "Argument does not have assigned frame index!\n");
561 return INT_MAX;
562}
563
565 const Value *CPI, const TargetRegisterClass *RC) {
566 MachineRegisterInfo &MRI = MF->getRegInfo();
567 auto I = CatchPadExceptionPointers.insert({CPI, 0});
568 Register &VReg = I.first->second;
569 if (I.second)
570 VReg = MRI.createVirtualRegister(RC);
571 assert(VReg && "null vreg in exception pointer table!");
572 return VReg;
573}
574
575const Value *
577 if (VirtReg2Value.empty()) {
578 SmallVector<EVT, 4> ValueVTs;
579 for (auto &P : ValueMap) {
580 ValueVTs.clear();
581 ComputeValueVTs(*TLI, Fn->getDataLayout(),
582 P.first->getType(), ValueVTs);
583 Register Reg = P.second;
584 for (EVT VT : ValueVTs) {
585 unsigned NumRegisters = TLI->getNumRegisters(Fn->getContext(), VT);
586 for (unsigned i = 0, e = NumRegisters; i != e; ++i)
587 VirtReg2Value[Reg++] = P.first;
588 }
589 }
590 }
591 return VirtReg2Value.lookup(Vreg);
592}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file implements a class to represent arbitrary precision integral constant values and operations...
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static const Function * getParent(const Value *V)
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static ISD::NodeType getPreferredExtendForValue(const Instruction *I)
static bool isUsedOutsideOfDefiningBlock(const Instruction *I)
isUsedOutsideOfDefiningBlock - Return true if this instruction is used by PHI nodes or outside of the...
const HexagonInstrInfo * TII
Module.h This file contains the declarations for the Module class.
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
#define I(x, y, z)
Definition MD5.cpp:57
#define H(x, y, z)
Definition MD5.cpp:56
Register const TargetRegisterInfo * TRI
Promote Memory to Register
Definition Mem2Reg.cpp:110
uint64_t IntrinsicInst * II
#define P(N)
RISCVCC::CondCode CC
MachineRegisterInfo & MRI
#define LLVM_DEBUG(...)
Definition Debug.h:119
This file describes how to lower LLVM code to machine code.
LLVM IR instance of the generic uniformity analysis.
TTI::PartialReductionExtendKind ExtendKind
Class for arbitrary precision integers.
Definition APInt.h:78
LLVM_ABI APInt zext(unsigned width) const
Zero extend to a new width.
Definition APInt.cpp:1057
unsigned getBitWidth() const
Return the number of bits in the APInt.
Definition APInt.h:1508
unsigned getNumSignBits() const
Computes the number of leading bits of this APInt that are equal to its sign bit.
Definition APInt.h:1648
LLVM_ABI APInt sext(unsigned width) const
Sign extend to a new width.
Definition APInt.cpp:1030
LLVM_ABI APInt extractBits(unsigned numBits, unsigned bitPosition) const
Return an APInt with the extracted bits [bitPosition,bitPosition+numBits).
Definition APInt.cpp:478
an instruction to allocate memory on the stack
This class represents an incoming formal argument to a Function.
Definition Argument.h:32
LLVM Basic Block Representation.
Definition BasicBlock.h:62
InstListType::const_iterator const_iterator
Definition BasicBlock.h:171
The address of a basic block.
Definition Constants.h:1088
static LLVM_ABI BlockAddress * lookup(const BasicBlock *BB)
Lookup an existing BlockAddress constant for the given BasicBlock.
This is the shared class of boolean and integer constants.
Definition Constants.h:87
A debug info location.
Definition DebugLoc.h:126
iterator find(const_arg_type_t< KeyT > Val)
Definition DenseMap.h:766
iterator end()
Definition DenseMap.h:686
LLVM_ABI Register CreateRegs(const Value *V)
SmallPtrSet< const DbgVariableRecord *, 8 > PreprocessedDVRDeclares
Collection of dbg_declare instructions handled after argument lowering and before ISel proper.
LLVM_ABI void clear()
clear - Clear out all the function-specific state.
MachineBasicBlock * getMBB(const BasicBlock *BB) const
DenseSet< Register > RegsWithFixups
LLVM_ABI void setArgumentFrameIndex(const Argument *A, int FI)
setArgumentFrameIndex - Record frame index for the byval argument.
SmallVector< bool > VisitedBBs
The set of basic blocks visited thus far by instruction selection.
BitVector DescribedArgs
Bitvector with a bit set if corresponding argument is described in ArgDbgValues.
DenseMap< const AllocaInst *, int > StaticAllocaMap
StaticAllocaMap - Keep track of frame indices for fixed sized allocas in the entry block.
DenseMap< const Instruction *, StatepointSpillMapTy > StatepointRelocationMaps
LLVM_ABI int getArgumentFrameIndex(const Argument *A)
getArgumentFrameIndex - Get frame index for the byval argument.
const LiveOutInfo * GetLiveOutRegInfo(Register Reg)
GetLiveOutRegInfo - Gets LiveOutInfo for a register, returning NULL if the register is a PHI destinat...
LLVM_ABI Register InitializeRegForValue(const Value *V)
DenseMap< const Value *, Register > ValueMap
ValueMap - Since we emit code for the function a basic block at a time, we must remember which virtua...
SmallVector< unsigned, 50 > StatepointStackSlots
StatepointStackSlots - A list of temporary stack slots (frame indices) used to spill values at a stat...
LLVM_ABI void set(const Function &Fn, MachineFunction &MF, SelectionDAG *DAG)
set - Initialize this FunctionLoweringInfo with the given Function and its associated MachineFunction...
MachineBasicBlock * MBB
MBB - The current block.
ExceptionHandling ExceptionModel
The exception model in effect, resolved once per function.
DenseMap< const Argument *, int > ByValArgFrameIndexMap
ByValArgFrameIndexMap - Keep track of frame indices for byval arguments.
DenseMap< Register, Register > RegFixups
RegFixups - Registers which need to be replaced after isel is done.
SmallVector< MachineInstr *, 8 > ArgDbgValues
ArgDbgValues - A list of DBG_VALUE instructions created during isel for function arguments that are i...
LLVM_ABI void ComputePHILiveOutRegInfo(const PHINode *)
ComputePHILiveOutRegInfo - Compute LiveOutInfo for a PHI's destination register based on the LiveOutI...
SmallVector< MachineBasicBlock * > MBBMap
A mapping from LLVM basic block number to their machine block.
LLVM_ABI const Value * getValueFromVirtualReg(Register Vreg)
This method is called from TargetLowerinInfo::isSDNodeSourceOfDivergence to get the Value correspondi...
DenseMap< Register, const Value * > VirtReg2Value
VirtReg2Value map is needed by the Divergence Analysis driven instruction selection.
MachineRegisterInfo * RegInfo
LLVM_ABI Register CreateReg(MVT VT, bool isDivergent=false)
CreateReg - Allocate a single virtual register for the given type.
bool CanLowerReturn
CanLowerReturn - true iff the function's return value can be lowered to registers.
DenseMap< const Value *, ISD::NodeType > PreferredExtendType
Record the preferred extend type (ISD::SIGN_EXTEND or ISD::ZERO_EXTEND) for a value.
LLVM_ABI Register getCatchPadExceptionPointerVReg(const Value *CPI, const TargetRegisterClass *RC)
DenseMap< const Value *, Register > CatchPadExceptionPointers
Track virtual registers created for exception pointers.
Machine Value Type.
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *BB=nullptr, std::optional< UniqueBBID > BBID=std::nullopt)
CreateMachineInstr - Allocate a new MachineInstr.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
unsigned getNumIncomingValues() const
Return the number of incoming edges.
Wrapper class representing virtual and physical registers.
Definition Register.h:20
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
Definition Register.h:79
constexpr unsigned id() const
Definition Register.h:100
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
const UniformityInfo * getUniformityInfo() const
CodeGenOptLevel getOptLevel() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Information about stack frame layout on the target.
bool isStackRealignable() const
isStackRealignable - This method returns whether the stack can be realigned.
virtual TargetStackID::Value getStackIDForScalableVectors() const
Returns the StackID that scalable vectors should be associated with.
Align getStackAlign() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
TargetInstrInfo - Interface to description of machine instruction set.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
static constexpr TypeSize getZero()
Definition TypeSize.h:358
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
A Use represents the edge between a Value definition and its users.
Definition Use.h:35
LLVM Value Representation.
Definition Value.h:75
Type * getType() const
All values are typed, get the type of this value.
Definition Value.h:257
LLVMContext & getContext() const
All values hold a context through their type.
Definition Value.h:260
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
Definition TypeSize.h:169
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
Definition TypeSize.h:166
CallInst * Call
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
Definition ISDOpcodes.h:43
@ ANY_EXTEND
ANY_EXTEND - Used for integer types. The high bits are undefined.
Definition ISDOpcodes.h:879
@ SIGN_EXTEND
Conversion operators.
Definition ISDOpcodes.h:870
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void GetReturnInfo(CallingConv::ID CC, Type *ReturnType, AttributeList attr, SmallVectorImpl< ISD::OutputArg > &Outs, const TargetLowering &TLI, const DataLayout &DL)
Given an LLVM IR type and return type attributes, compute the return value EVTs and flags,...
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
LLVM_ABI void ComputeValueVTs(const TargetLowering &TLI, const DataLayout &DL, Type *Ty, SmallVectorImpl< EVT > &ValueVTs, SmallVectorImpl< EVT > *MemVTs=nullptr, SmallVectorImpl< TypeSize > *Offsets=nullptr, TypeSize StartingOffset=TypeSize::getZero())
ComputeValueVTs - Given an LLVM IR type, compute a sequence of EVTs that represent all the individual...
Definition Analysis.cpp:121
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
LLVM_ABI void calculateWinCXXEHStateNumbers(const Function *ParentFn, WinEHFuncInfo &FuncInfo)
Analyze the IR in ParentFn and it's handlers to build WinEHFuncInfo, which describes the state number...
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:209
LLVM_ABI EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
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
bool isFuncletEHPersonality(EHPersonality Pers)
Returns true if this is a personality function that invokes handler funclets (which must return to it...
LLVM_ABI void calculateSEHStateNumbers(const Function *ParentFn, WinEHFuncInfo &FuncInfo)
DWARFExpression::Operation Op
bool isAsynchronousEHPersonality(EHPersonality Pers)
Returns true if this personality function catches asynchronous exceptions.
constexpr unsigned BitWidth
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
LLVM_ABI void calculateClrEHStateNumbers(const Function *Fn, WinEHFuncInfo &FuncInfo)
MCRegisterClass TargetRegisterClass
Definition FastISel.h:58
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39
MBBOrBasicBlock Cleanup
Extended Value Type.
Definition ValueTypes.h:35
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
Definition ValueTypes.h:396
static KnownBits makeConstant(const APInt &C)
Create known bits from a known constant.
Definition KnownBits.h:315
unsigned getBitWidth() const
Get the bit width of this value.
Definition KnownBits.h:44
KnownBits intersectWith(const KnownBits &RHS) const
Returns KnownBits information that is known to be true for both this and RHS.
Definition KnownBits.h:325
KnownBits anyext(unsigned BitWidth) const
Return known bits for an "any" extension of the value we're tracking, where we don't know anything ab...
Definition KnownBits.h:171
Similar to CxxUnwindMapEntry, but supports SEH filters.
This contains information for each constraint that we are lowering.
SmallVector< SEHUnwindMapEntry, 4 > SEHUnwindMap
SmallVector< ClrEHUnwindMapEntry, 4 > ClrEHUnwindMap
SmallVector< WinEHTryBlockMapEntry, 4 > TryBlockMap
SmallVector< CxxUnwindMapEntry, 4 > CxxUnwindMap
SmallVector< WinEHHandlerType, 1 > HandlerArray