LLVM 24.0.0git
IntrinsicInst.cpp
Go to the documentation of this file.
1//===-- IntrinsicInst.cpp - Intrinsic Instruction Wrappers ---------------===//
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 file implements methods that make it really easy to deal with intrinsic
10// functions.
11//
12// All intrinsic function calls are instances of the call instruction, so these
13// are all subclasses of the CallInst class. Note that none of these classes
14// has state or virtual methods, which is an important part of this gross/neat
15// hack working.
16//
17// In some cases, arguments to intrinsics need to be generic and are defined as
18// type pointer to empty struct { }*. To access the real item of interest the
19// cast instruction needs to be stripped away.
20//
21//===----------------------------------------------------------------------===//
22
25#include "llvm/IR/Constants.h"
27#include "llvm/IR/Metadata.h"
28#include "llvm/IR/Module.h"
29#include "llvm/IR/Operator.h"
31#include "llvm/IR/Statepoint.h"
32#include <optional>
33
34using namespace llvm;
35
37 switch (IID) {
38 case Intrinsic::objc_autorelease:
39 case Intrinsic::objc_autoreleasePoolPop:
40 case Intrinsic::objc_autoreleasePoolPush:
41 case Intrinsic::objc_autoreleaseReturnValue:
42 case Intrinsic::objc_claimAutoreleasedReturnValue:
43 case Intrinsic::objc_copyWeak:
44 case Intrinsic::objc_destroyWeak:
45 case Intrinsic::objc_initWeak:
46 case Intrinsic::objc_loadWeak:
47 case Intrinsic::objc_loadWeakRetained:
48 case Intrinsic::objc_moveWeak:
49 case Intrinsic::objc_release:
50 case Intrinsic::objc_retain:
51 case Intrinsic::objc_retainAutorelease:
52 case Intrinsic::objc_retainAutoreleaseReturnValue:
53 case Intrinsic::objc_retainAutoreleasedReturnValue:
54 case Intrinsic::objc_retainBlock:
55 case Intrinsic::objc_storeStrong:
56 case Intrinsic::objc_storeWeak:
57 case Intrinsic::objc_unsafeClaimAutoreleasedReturnValue:
58 case Intrinsic::objc_retainedObject:
59 case Intrinsic::objc_unretainedObject:
60 case Intrinsic::objc_unretainedPointer:
61 case Intrinsic::objc_retain_autorelease:
62 case Intrinsic::objc_sync_enter:
63 case Intrinsic::objc_sync_exit:
64 return true;
65 default:
66 return false;
67 }
68}
69
70//===----------------------------------------------------------------------===//
71/// DbgVariableIntrinsic - This is the common base class for debug info
72/// intrinsics for variables.
73///
74
77 assert(MD && "First operand of DbgVariableIntrinsic should be non-null.");
78 // If operand is ValueAsMetadata, return a range over just that operand.
79 if (auto *VAM = dyn_cast<ValueAsMetadata>(MD)) {
80 return {location_op_iterator(VAM), location_op_iterator(VAM + 1)};
81 }
82 // If operand is DIArgList, return a range over its args.
83 if (auto *AL = dyn_cast<DIArgList>(MD))
84 return {location_op_iterator(AL->args_begin()),
85 location_op_iterator(AL->args_end())};
86 // Operand must be an empty metadata tuple, so return empty iterator.
87 return {location_op_iterator(static_cast<ValueAsMetadata *>(nullptr)),
88 location_op_iterator(static_cast<ValueAsMetadata *>(nullptr))};
89}
90
95
99
101 Metadata *MD = getRawLocation();
102 assert(MD && "First operand of DbgVariableIntrinsic should be non-null.");
103 if (auto *AL = dyn_cast<DIArgList>(MD))
104 return AL->getArgs()[OpIdx]->getValue();
105 if (isa<MDNode>(MD))
106 return nullptr;
107 assert(
109 "Attempted to get location operand from DbgVariableIntrinsic with none.");
110 auto *V = cast<ValueAsMetadata>(MD);
111 assert(OpIdx == 0 && "Operand Index must be 0 for a debug intrinsic with a "
112 "single location operand.");
113 return V->getValue();
114}
115
121
123 Value *NewValue,
124 bool AllowEmpty) {
125 // If OldValue is used as the address part of a dbg.assign intrinsic replace
126 // it with NewValue and return true.
127 auto ReplaceDbgAssignAddress = [this, OldValue, NewValue]() -> bool {
128 auto *DAI = dyn_cast<DbgAssignIntrinsic>(this);
129 if (!DAI || OldValue != DAI->getAddress())
130 return false;
131 DAI->setAddress(NewValue);
132 return true;
133 };
134 bool DbgAssignAddrReplaced = ReplaceDbgAssignAddress();
135 (void)DbgAssignAddrReplaced;
136
137 assert(NewValue && "Values must be non-null");
138 auto Locations = location_ops();
139 auto OldIt = find(Locations, OldValue);
140 if (OldIt == Locations.end()) {
141 if (AllowEmpty || DbgAssignAddrReplaced)
142 return;
143 assert(DbgAssignAddrReplaced &&
144 "OldValue must be dbg.assign addr if unused in DIArgList");
145 return;
146 }
147
148 assert(OldIt != Locations.end() && "OldValue must be a current location");
149 if (!hasArgList()) {
150 Value *NewOperand = isa<MetadataAsValue>(NewValue)
151 ? NewValue
153 getContext(), ValueAsMetadata::get(NewValue));
154 return setArgOperand(0, NewOperand);
155 }
157 ValueAsMetadata *NewOperand = getAsMetadata(NewValue);
158 for (auto *VMD : Locations)
159 MDs.push_back(VMD == *OldIt ? NewOperand : getAsMetadata(VMD));
162}
163
164std::optional<uint64_t> DbgVariableIntrinsic::getFragmentSizeInBits() const {
165 if (auto Fragment = getExpression()->getFragmentInfo())
166 return Fragment->SizeInBits;
167 return getVariable()->getSizeInBits();
168}
169
171 auto *MD = getRawAddress();
172 if (auto *V = dyn_cast<ValueAsMetadata>(MD))
173 return V->getValue();
174
175 // When the value goes to null, it gets replaced by an empty MDNode.
176 assert(!cast<MDNode>(MD)->getNumOperands() && "Expected an empty MDNode");
177 return nullptr;
178}
179
183
188
193
196 llvm_unreachable("InstrProfValueProfileInst does not have counters!");
198}
199
202 llvm_unreachable("Please use InstrProfValueProfileInst::getIndex()");
204}
205
210
213 return getArgOperand(4);
214 }
215 const Module *M = getModule();
216 LLVMContext &Context = M->getContext();
217 return ConstantInt::get(Type::getInt64Ty(Context), 1);
218}
219
221
224 setArgOperand(4, Callee);
225}
226
227std::optional<RoundingMode> ConstrainedFPIntrinsic::getRoundingMode() const {
228 unsigned NumOperands = arg_size();
229 Metadata *MD = nullptr;
230 auto *MAV = dyn_cast<MetadataAsValue>(getArgOperand(NumOperands - 2));
231 if (MAV)
232 MD = MAV->getMetadata();
233 if (!MD || !isa<MDString>(MD))
234 return std::nullopt;
235 return convertStrToRoundingMode(cast<MDString>(MD)->getString());
236}
237
238std::optional<fp::ExceptionBehavior>
240 unsigned NumOperands = arg_size();
241 Metadata *MD = nullptr;
242 auto *MAV = dyn_cast<MetadataAsValue>(getArgOperand(NumOperands - 1));
243 if (MAV)
244 MD = MAV->getMetadata();
245 if (!MD || !isa<MDString>(MD))
246 return std::nullopt;
247 return convertStrToExceptionBehavior(cast<MDString>(MD)->getString());
248}
249
251 std::optional<fp::ExceptionBehavior> Except = getExceptionBehavior();
252 if (Except) {
253 if (*Except != fp::ebIgnore)
254 return false;
255 }
256
257 std::optional<RoundingMode> Rounding = getRoundingMode();
258 if (Rounding) {
259 if (*Rounding != RoundingMode::NearestTiesToEven)
260 return false;
261 }
262
263 return true;
264}
265
287
291
293 // All constrained fp intrinsics have "fpexcept" metadata.
294 unsigned NumArgs = arg_size() - 1;
295
296 // Some intrinsics have "round" metadata.
298 NumArgs -= 1;
299
300 // Compare intrinsics take their predicate as metadata.
302 NumArgs -= 1;
303
304 return NumArgs;
305}
306
310
312 auto GetVectorLengthOfType = [](const Type *T) -> ElementCount {
313 const auto *VT = cast<VectorType>(T);
314 auto ElemCount = VT->getElementCount();
315 return ElemCount;
316 };
317
318 Value *VPMask = getMaskParam();
319 if (!VPMask) {
320 assert((getIntrinsicID() == Intrinsic::vp_merge) &&
321 "Unexpected VP intrinsic without mask operand");
322 return GetVectorLengthOfType(getType());
323 }
324 return GetVectorLengthOfType(VPMask->getType());
325}
326
328 if (auto MaskPos = getMaskParamPos(getIntrinsicID()))
329 return getArgOperand(*MaskPos);
330 return nullptr;
331}
332
334 auto MaskPos = getMaskParamPos(getIntrinsicID());
335 setArgOperand(*MaskPos, NewMask);
336}
337
339 if (auto EVLPos = getVectorLengthParamPos(getIntrinsicID()))
340 return getArgOperand(*EVLPos);
341 return nullptr;
342}
343
346 setArgOperand(*EVLPos, NewEVL);
347}
348
349std::optional<unsigned>
351 switch (IntrinsicID) {
352 default:
353 return std::nullopt;
354
355#define BEGIN_REGISTER_VP_INTRINSIC(VPID, MASKPOS, VLENPOS) \
356 case Intrinsic::VPID: \
357 return MASKPOS;
358#include "llvm/IR/VPIntrinsics.def"
359 }
360}
361
362std::optional<unsigned>
364 switch (IntrinsicID) {
365 default:
366 return std::nullopt;
367
368#define BEGIN_REGISTER_VP_INTRINSIC(VPID, MASKPOS, VLENPOS) \
369 case Intrinsic::VPID: \
370 return VLENPOS;
371#include "llvm/IR/VPIntrinsics.def"
372 }
373}
374
375/// \return the alignment of the pointer used by this load/store/gather or
376/// scatter.
378 std::optional<unsigned> PtrParamOpt =
380 assert(PtrParamOpt && "no pointer argument!");
381 return getParamAlign(*PtrParamOpt);
382}
383
384/// \return The pointer operand of this load,store, gather or scatter.
386 if (auto PtrParamOpt = getMemoryPointerParamPos(getIntrinsicID()))
387 return getArgOperand(*PtrParamOpt);
388 return nullptr;
389}
390
391std::optional<unsigned>
393 switch (VPID) {
394 default:
395 return std::nullopt;
396 case Intrinsic::vp_store:
397 case Intrinsic::vp_scatter:
398 case Intrinsic::experimental_vp_strided_store:
399 return 1;
400 case Intrinsic::vp_load:
401 case Intrinsic::vp_load_ff:
402 case Intrinsic::vp_gather:
403 case Intrinsic::experimental_vp_strided_load:
404 return 0;
405 }
406}
407
408/// \return The data (payload) operand of this store or scatter.
410 auto DataParamOpt = getMemoryDataParamPos(getIntrinsicID());
411 if (!DataParamOpt)
412 return nullptr;
413 return getArgOperand(*DataParamOpt);
414}
415
417 switch (VPID) {
418 default:
419 return std::nullopt;
420 case Intrinsic::vp_store:
421 case Intrinsic::vp_scatter:
422 case Intrinsic::experimental_vp_strided_store:
423 return 0;
424 }
425}
426
427constexpr bool isVPIntrinsic(Intrinsic::ID ID) {
428 switch (ID) {
429 default:
430 break;
431#define BEGIN_REGISTER_VP_INTRINSIC(VPID, MASKPOS, VLENPOS) \
432 case Intrinsic::VPID: \
433 return true;
434#include "llvm/IR/VPIntrinsics.def"
435 }
436 return false;
437}
438
440 return ::isVPIntrinsic(ID);
441}
442
443// Equivalent non-predicated opcode
444constexpr static std::optional<unsigned>
446 switch (ID) {
447 default:
448 break;
449#define BEGIN_REGISTER_VP_INTRINSIC(VPID, ...) case Intrinsic::VPID:
450#define VP_PROPERTY_FUNCTIONAL_OPC(OPC) return Instruction::OPC;
451#define END_REGISTER_VP_INTRINSIC(VPID) break;
452#include "llvm/IR/VPIntrinsics.def"
453 }
454 return std::nullopt;
455}
456
457std::optional<unsigned>
459 return ::getFunctionalOpcodeForVP(ID);
460}
461
462// Equivalent non-predicated intrinsic ID
463constexpr static std::optional<Intrinsic::ID>
465 switch (ID) {
466 default:
467 break;
468#define BEGIN_REGISTER_VP_INTRINSIC(VPID, ...) case Intrinsic::VPID:
469#define VP_PROPERTY_FUNCTIONAL_INTRINSIC(INTRIN) return Intrinsic::INTRIN;
470#define END_REGISTER_VP_INTRINSIC(VPID) break;
471#include "llvm/IR/VPIntrinsics.def"
472 }
473 return std::nullopt;
474}
475
476std::optional<Intrinsic::ID>
478 return ::getFunctionalIntrinsicIDForVP(ID);
479}
480
482 switch (ID) {
483 default:
484 break;
485#define BEGIN_REGISTER_VP_INTRINSIC(VPID, ...) case Intrinsic::VPID:
486#define VP_PROPERTY_NO_FUNCTIONAL return true;
487#define END_REGISTER_VP_INTRINSIC(VPID) break;
488#include "llvm/IR/VPIntrinsics.def"
489 }
490 return false;
491}
492
493// All VP intrinsics should have an equivalent non-VP opcode or intrinsic
494// defined, or be marked that they don't have one.
495#define BEGIN_REGISTER_VP_INTRINSIC(VPID, ...) \
496 static_assert(doesVPHaveNoFunctionalEquivalent(Intrinsic::VPID) || \
497 getFunctionalOpcodeForVP(Intrinsic::VPID) || \
498 getFunctionalIntrinsicIDForVP(Intrinsic::VPID));
499#include "llvm/IR/VPIntrinsics.def"
500
502 using namespace PatternMatch;
503
505
506 // No vlen param - no lanes masked-off by it.
507 auto *VLParam = getVectorLengthParam();
508 if (!VLParam)
509 return true;
510
511 // Note that the VP intrinsic causes undefined behavior if the Explicit Vector
512 // Length parameter is strictly greater-than the number of vector elements of
513 // the operation. This function returns true when this is detected statically
514 // in the IR.
515
516 // Check whether "W == vscale * EC.getKnownMinValue()"
517 if (EC.isScalable()) {
518 // Compare vscale patterns
519 uint64_t VScaleFactor;
520 if (match(VLParam, m_Mul(m_VScale(), m_ConstantInt(VScaleFactor))))
521 return VScaleFactor >= EC.getKnownMinValue();
522 return (EC.getKnownMinValue() == 1) && match(VLParam, m_VScale());
523 }
524
525 // standard SIMD operation
526 const auto *VLConst = dyn_cast<ConstantInt>(VLParam);
527 if (!VLConst)
528 return false;
529
530 uint64_t VLNum = VLConst->getZExtValue();
531 if (VLNum >= EC.getKnownMinValue())
532 return true;
533
534 return false;
535}
536
538 Module *M, Intrinsic::ID VPID, Type *ReturnType, ArrayRef<Value *> Params) {
539 assert(isVPIntrinsic(VPID) && "not a VP intrinsic");
540 Function *VPFunc;
541 switch (VPID) {
542 default: {
543 Type *OverloadTy = Params[0]->getType();
545 OverloadTy =
546 Params[*VPReductionIntrinsic::getVectorParamPos(VPID)]->getType();
547
548 VPFunc = Intrinsic::getOrInsertDeclaration(M, VPID, OverloadTy);
549 break;
550 }
551 case Intrinsic::vp_cttz_elts:
553 M, VPID, {ReturnType, Params[0]->getType()});
554 break;
555 case Intrinsic::vp_merge:
556 VPFunc = Intrinsic::getOrInsertDeclaration(M, VPID, {Params[1]->getType()});
557 break;
558 case Intrinsic::vp_load:
560 M, VPID, {ReturnType, Params[0]->getType()});
561 break;
562 case Intrinsic::vp_load_ff:
564 M, VPID, {ReturnType->getStructElementType(0), Params[0]->getType()});
565 break;
566 case Intrinsic::experimental_vp_strided_load:
568 M, VPID, {ReturnType, Params[0]->getType(), Params[1]->getType()});
569 break;
570 case Intrinsic::vp_gather:
572 M, VPID, {ReturnType, Params[0]->getType()});
573 break;
574 case Intrinsic::vp_store:
576 M, VPID, {Params[0]->getType(), Params[1]->getType()});
577 break;
578 case Intrinsic::experimental_vp_strided_store:
580 M, VPID,
581 {Params[0]->getType(), Params[1]->getType(), Params[2]->getType()});
582 break;
583 case Intrinsic::vp_scatter:
585 M, VPID, {Params[0]->getType(), Params[1]->getType()});
586 break;
587 }
588 assert(VPFunc && "Could not declare VP intrinsic");
589 return VPFunc;
590}
591
593 switch (ID) {
594 case Intrinsic::vp_reduce_add:
595 case Intrinsic::vp_reduce_mul:
596 case Intrinsic::vp_reduce_and:
597 case Intrinsic::vp_reduce_or:
598 case Intrinsic::vp_reduce_xor:
599 case Intrinsic::vp_reduce_smax:
600 case Intrinsic::vp_reduce_smin:
601 case Intrinsic::vp_reduce_umax:
602 case Intrinsic::vp_reduce_umin:
603 case Intrinsic::vp_reduce_fmax:
604 case Intrinsic::vp_reduce_fmin:
605 case Intrinsic::vp_reduce_fmaximum:
606 case Intrinsic::vp_reduce_fminimum:
607 case Intrinsic::vp_reduce_fadd:
608 case Intrinsic::vp_reduce_fmul:
609 return true;
610 default:
611 return false;
612 }
613}
614
618
622
623std::optional<unsigned>
625 if (isVPReduction(ID))
626 return 1;
627 return std::nullopt;
628}
629
630std::optional<unsigned>
632 if (isVPReduction(ID))
633 return 0;
634 return std::nullopt;
635}
636
638 switch (getIntrinsicID()) {
639 case Intrinsic::uadd_with_overflow:
640 case Intrinsic::sadd_with_overflow:
641 case Intrinsic::uadd_sat:
642 case Intrinsic::sadd_sat:
643 return Instruction::Add;
644 case Intrinsic::usub_with_overflow:
645 case Intrinsic::ssub_with_overflow:
646 case Intrinsic::usub_sat:
647 case Intrinsic::ssub_sat:
648 return Instruction::Sub;
649 case Intrinsic::umul_with_overflow:
650 case Intrinsic::smul_with_overflow:
651 return Instruction::Mul;
652 default:
653 llvm_unreachable("Invalid intrinsic");
654 }
655}
656
658 switch (getIntrinsicID()) {
659 case Intrinsic::sadd_with_overflow:
660 case Intrinsic::ssub_with_overflow:
661 case Intrinsic::smul_with_overflow:
662 case Intrinsic::sadd_sat:
663 case Intrinsic::ssub_sat:
664 return true;
665 default:
666 return false;
667 }
668}
669
676
678 const Value *Token = getArgOperand(0);
679 if (isa<UndefValue>(Token))
680 return Token;
681
682 // Treat none token as if it was undef here
683 if (isa<ConstantTokenNone>(Token))
684 return UndefValue::get(Token->getType());
685
686 // This takes care both of relocates for call statepoints and relocates
687 // on normal path of invoke statepoint.
688 if (!isa<LandingPadInst>(Token))
689 return cast<GCStatepointInst>(Token);
690
691 // This relocate is on exceptional path of an invoke statepoint
692 const BasicBlock *InvokeBB =
693 cast<Instruction>(Token)->getParent()->getUniquePredecessor();
694
695 assert(InvokeBB && "safepoints should have unique landingpads");
696 assert(InvokeBB->getTerminator() &&
697 "safepoint block should be well formed");
698
699 return cast<GCStatepointInst>(InvokeBB->getTerminator());
700}
701
703 auto Statepoint = getStatepoint();
704 if (isa<UndefValue>(Statepoint))
705 return UndefValue::get(Statepoint->getType());
706 // Handle too few (bundle) arguments to avoid crashes when printing invalid
707 // IR, e.g. in the verifier.
708 auto *GCInst = cast<GCStatepointInst>(Statepoint);
709 if (auto Opt = GCInst->getOperandBundle(LLVMContext::OB_gc_live)) {
710 if (getBasePtrIndex() > Opt->Inputs.size())
711 return nullptr;
712 return *(Opt->Inputs.begin() + getBasePtrIndex());
713 }
714 if (getBasePtrIndex() > GCInst->arg_size())
715 return nullptr;
716 return *(GCInst->arg_begin() + getBasePtrIndex());
717}
718
720 auto *Statepoint = getStatepoint();
721 if (isa<UndefValue>(Statepoint))
722 return UndefValue::get(Statepoint->getType());
723
724 // Handle too few (bundle) arguments to avoid crashes when printing invalid
725 // IR, e.g. in the verifier.
726 auto *GCInst = cast<GCStatepointInst>(Statepoint);
727 if (auto Opt = GCInst->getOperandBundle(LLVMContext::OB_gc_live)) {
728 if (getDerivedPtrIndex() > Opt->Inputs.size())
729 return nullptr;
730 return *(Opt->Inputs.begin() + getDerivedPtrIndex());
731 }
732 if (getDerivedPtrIndex() > GCInst->arg_size())
733 return nullptr;
734 return *(GCInst->arg_begin() + getDerivedPtrIndex());
735}
736
738 Module *M = BB.getModule();
740 M, llvm::Intrinsic::experimental_convergence_anchor);
741 auto *Call = CallInst::Create(Fn, "", BB.getFirstInsertionPt());
743}
744
746 Module *M = BB.getModule();
748 M, llvm::Intrinsic::experimental_convergence_entry);
749 auto *Call = CallInst::Create(Fn, "", BB.getFirstInsertionPt());
751}
752
755 ConvergenceControlInst *ParentToken) {
756 Module *M = BB.getModule();
758 M, llvm::Intrinsic::experimental_convergence_loop);
759 llvm::Value *BundleArgs[] = {ParentToken};
760 llvm::OperandBundleDef OB("convergencectrl", BundleArgs);
761 auto *Call = CallInst::Create(Fn, {}, {OB}, "", BB.getFirstInsertionPt());
763}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static Intrinsic::ID getFunctionalIntrinsicIDForVP(StringRef Name)
static unsigned getFunctionalOpcodeForVP(StringRef Name)
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static ValueAsMetadata * getAsMetadata(Value *V)
Module.h This file contains the declarations for the Module class.
static constexpr bool doesVPHaveNoFunctionalEquivalent(Intrinsic::ID ID)
constexpr bool isVPIntrinsic(Intrinsic::ID ID)
static FCmpInst::Predicate getFPPredicateFromMD(const Value *Op)
#define I(x, y, z)
Definition MD5.cpp:57
This file contains the declarations for metadata subclasses.
#define T
Func getContext().diagnose(DiagnosticInfoUnsupported(Func
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
LLVM Basic Block Representation.
Definition BasicBlock.h:62
LLVM_ABI const_iterator getFirstInsertionPt() const
Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI i...
const Function * getParent() const
Return the enclosing method, or null if none.
Definition BasicBlock.h:213
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction; assumes that the block is well-formed.
Definition BasicBlock.h:237
LLVM_ABI const Module * getModule() const
Return the module owning the function this basic block belongs to, or nullptr if the function does no...
LLVM_ABI unsigned getNoWrapKind() const
Returns one of OBO::NoSignedWrap or OBO::NoUnsignedWrap.
LLVM_ABI bool isSigned() const
Whether the intrinsic is signed or unsigned.
LLVM_ABI Instruction::BinaryOps getBinaryOp() const
Returns the binary operation underlying the intrinsic.
MaybeAlign getParamAlign(unsigned ArgNo) const
Extract the alignment for a call or parameter (0=unknown).
Value * getArgOperand(unsigned i) const
void setArgOperand(unsigned i, Value *v)
unsigned arg_size() const
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition InstrTypes.h:740
@ FCMP_OEQ
0 0 0 1 True if ordered and equal
Definition InstrTypes.h:743
@ FCMP_OLT
0 1 0 0 True if ordered and less than
Definition InstrTypes.h:746
@ FCMP_ULE
1 1 0 1 True if unordered, less than, or equal
Definition InstrTypes.h:755
@ FCMP_OGT
0 0 1 0 True if ordered and greater than
Definition InstrTypes.h:744
@ FCMP_OGE
0 0 1 1 True if ordered and greater than or equal
Definition InstrTypes.h:745
@ FCMP_ULT
1 1 0 0 True if unordered or less than
Definition InstrTypes.h:754
@ FCMP_ONE
0 1 1 0 True if ordered and operands are unequal
Definition InstrTypes.h:748
@ FCMP_UEQ
1 0 0 1 True if unordered or equal
Definition InstrTypes.h:751
@ FCMP_UGT
1 0 1 0 True if unordered or greater than
Definition InstrTypes.h:752
@ FCMP_OLE
0 1 0 1 True if ordered and less than or equal
Definition InstrTypes.h:747
@ FCMP_ORD
0 1 1 1 True if ordered (no nans)
Definition InstrTypes.h:749
@ FCMP_UNE
1 1 1 0 True if unordered or not equal
Definition InstrTypes.h:756
@ FCMP_UGE
1 0 1 1 True if unordered, greater than, or equal
Definition InstrTypes.h:753
@ FCMP_UNO
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
Definition InstrTypes.h:750
This is the shared class of boolean and integer constants.
Definition Constants.h:87
LLVM_ABI FCmpInst::Predicate getPredicate() const
LLVM_ABI std::optional< fp::ExceptionBehavior > getExceptionBehavior() const
LLVM_ABI std::optional< RoundingMode > getRoundingMode() const
LLVM_ABI unsigned getNonMetadataArgCount() const
static LLVM_ABI bool classof(const IntrinsicInst *I)
LLVM_ABI bool isDefaultFPEnvironment() const
Represents calls to the llvm.experimintal.convergence.* intrinsics.
static LLVM_ABI ConvergenceControlInst * CreateAnchor(BasicBlock &BB)
static LLVM_ABI ConvergenceControlInst * CreateLoop(BasicBlock &BB, ConvergenceControlInst *Parent)
static LLVM_ABI ConvergenceControlInst * CreateEntry(BasicBlock &BB)
static LLVM_ABI DIArgList * get(LLVMContext &Context, ArrayRef< ValueAsMetadata * > Args)
LLVM_ABI std::optional< uint64_t > getSizeInBits() const
Determines the size of the variable's type.
LLVM_ABI void setValue(Value *V)
LLVM_ABI void setAssignId(DIAssignID *New)
Metadata * getRawAddress() const
LLVM_ABI Value * getAddress() const
LLVM_ABI void setAddress(Value *V)
LLVM_ABI iterator_range< location_op_iterator > location_ops() const
Get the locations corresponding to the variable referenced by the debug info intrinsic.
LLVM_ABI void replaceVariableLocationOp(Value *OldValue, Value *NewValue, bool AllowEmpty=false)
LLVM_ABI Value * getVariableLocationOp(unsigned OpIdx) const
DILocalVariable * getVariable() const
void setOperand(unsigned i, Value *v)
LLVM_ABI std::optional< uint64_t > getFragmentSizeInBits() const
Get the size (in bits) of the variable, or fragment of the variable that is described.
DIExpression * getExpression() const
void setArgOperand(unsigned i, Value *v)
RawLocationWrapper getWrappedLocation() const
LLVM_ABI const Value * getStatepoint() const
The statepoint with which this gc.relocate is associated.
LLVM_ABI Value * getBasePtr() const
unsigned getBasePtrIndex() const
The index into the associate statepoint's argument list which contains the base pointer of the pointe...
LLVM_ABI Value * getDerivedPtr() const
unsigned getDerivedPtrIndex() const
The index into the associate statepoint's argument list which contains the pointer whose relocation t...
LLVM_ABI void setCallee(Value *Callee)
LLVM_ABI Value * getCallee() const
LLVM_ABI ConstantInt * getIndex() const
LLVM_ABI void setIndex(uint32_t Idx)
LLVM_ABI ConstantInt * getNumCounters() const
static bool classof(const IntrinsicInst *I)
LLVM_ABI Value * getStep() const
static bool classof(const IntrinsicInst *I)
LLVM_ABI const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
static LLVM_ABI bool mayLowerToFunctionCall(Intrinsic::ID IID)
Check if the intrinsic might lower into a regular function call in the course of IR transformations.
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
static LLVM_ABI MetadataAsValue * get(LLVMContext &Context, Metadata *MD)
Definition Metadata.cpp:107
Root of the metadata hierarchy.
Definition Metadata.h:64
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
Metadata * getRawLocation() const
LLVM_ABI iterator_range< location_op_iterator > location_ops() const
Get the locations corresponding to the variable referenced by the debug info intrinsic.
LLVM_ABI Value * getVariableLocationOp(unsigned OpIdx) const
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
A switch()-like statement whose cases are string literals.
StringSwitch & Case(StringLiteral S, T Value)
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
static LLVM_ABI IntegerType * getInt64Ty(LLVMContext &C)
Definition Type.cpp:300
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
Definition Type.cpp:299
static LLVM_ABI UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
unsigned getNumOperands() const
Definition User.h:229
static LLVM_ABI std::optional< unsigned > getMaskParamPos(Intrinsic::ID IntrinsicID)
LLVM_ABI bool canIgnoreVectorLengthParam() const
LLVM_ABI void setMaskParam(Value *)
static LLVM_ABI std::optional< unsigned > getFunctionalOpcodeForVP(Intrinsic::ID ID)
static LLVM_ABI std::optional< unsigned > getMemoryDataParamPos(Intrinsic::ID)
LLVM_ABI Value * getVectorLengthParam() const
static LLVM_ABI std::optional< Intrinsic::ID > getFunctionalIntrinsicIDForVP(Intrinsic::ID ID)
LLVM_ABI void setVectorLengthParam(Value *)
static LLVM_ABI std::optional< unsigned > getVectorLengthParamPos(Intrinsic::ID IntrinsicID)
static LLVM_ABI Function * getOrInsertDeclarationForParams(Module *M, Intrinsic::ID, Type *ReturnType, ArrayRef< Value * > Params)
Declares a llvm.vp.
static LLVM_ABI std::optional< unsigned > getMemoryPointerParamPos(Intrinsic::ID)
static LLVM_ABI bool isVPIntrinsic(Intrinsic::ID)
LLVM_ABI Value * getMemoryDataParam() const
LLVM_ABI Value * getMemoryPointerParam() const
LLVM_ABI MaybeAlign getPointerAlignment() const
LLVM_ABI Value * getMaskParam() const
LLVM_ABI ElementCount getStaticVectorLength() const
static LLVM_ABI bool isVPReduction(Intrinsic::ID ID)
LLVM_ABI unsigned getStartParamPos() const
LLVM_ABI unsigned getVectorParamPos() const
Value wrapper in the Metadata hierarchy.
Definition Metadata.h:471
static LLVM_ABI ValueAsMetadata * get(Value *V)
Definition Metadata.cpp:514
LLVM Value Representation.
Definition Value.h:75
Type * getType() const
All values are typed, get the type of this value.
Definition Value.h:257
A range adaptor for a pair of iterators.
CallInst * Call
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
LLVM_ABI bool hasConstrainedFPRoundingModeOperand(ID QID)
Returns true if the intrinsic ID is for one of the "ConstrainedFloating-Point Intrinsics" that take r...
LLVM_ABI Function * getOrInsertDeclaration(Module *M, ID id, ArrayRef< Type * > OverloadTys={})
Look up the Function declaration of the intrinsic id in the Module M.
LLVM_ABI bool isConstrainedFPIntrinsic(ID QID)
Returns true if the intrinsic ID is for one of the "ConstrainedFloating-Point Intrinsics".
bool match(Val *V, const Pattern &P)
BinaryOp_match< LHS, RHS, Instruction::Mul > m_Mul(const LHS &L, const RHS &R)
auto m_VScale()
Matches a call to llvm.vscale().
auto m_ConstantInt()
Match an arbitrary ConstantInt and ignore it.
@ ebIgnore
This corresponds to "fpexcept.ignore".
Definition FPEnv.h:40
This is an optimization pass for GlobalISel generic memory operations.
auto find(R &&Range, const T &Val)
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1781
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
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
OperandBundleDefT< Value * > OperandBundleDef
Definition AutoUpgrade.h:34
LLVM_ABI std::optional< fp::ExceptionBehavior > convertStrToExceptionBehavior(StringRef)
Returns a valid ExceptionBehavior enumerator when given a string valid as input in constrained intrin...
Definition FPEnv.cpp:59
DWARFExpression::Operation Op
@ NearestTiesToEven
roundTiesToEven.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
LLVM_ABI std::optional< RoundingMode > convertStrToRoundingMode(StringRef)
Returns a valid RoundingMode enumerator when given a string that is valid as input in constrained int...
Definition FPEnv.cpp:25
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Definition Alignment.h:111