26 #ifndef LLVM_LIB_TRANSFORMS_COROUTINES_COROINSTR_H 27 #define LLVM_LIB_TRANSFORMS_COROUTINES_COROINSTR_H 36 enum { FrameArg, IndexArg };
45 IndexFirst = RestartTrigger
50 int64_t
Index = getRawIndex()->getValue().getSExtValue();
51 assert(Index >= IndexFirst && Index < IndexLast &&
52 "unexpected CoroSubFnInst index argument");
57 return cast<ConstantInt>(getArgOperand(IndexArg));
65 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
77 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
83 enum { AlignArg, PromiseArg, CoroutineArg, InfoArg };
88 if (
auto *CA = dyn_cast<CoroAllocInst>(U))
95 if (
auto *II = dyn_cast<IntrinsicInst>(U))
102 Value *
Arg = getArgOperand(PromiseArg);
103 return isa<ConstantPointerNull>(
Arg)
109 Value *
Arg = getArgOperand(PromiseArg);
110 setArgOperand(PromiseArg,
112 if (isa<AllocaInst>(Arg))
114 assert((isa<BitCastInst>(Arg) || isa<GetElementPtrInst>(Arg)) &&
115 "unexpected instruction designating the promise");
118 auto *Inst = cast<Instruction>(
Arg);
119 if (Inst->use_empty()) {
120 Inst->eraseFromParent();
123 Inst->moveBefore(getCoroBegin()->getNextNode());
152 assert(GV->isConstant() && GV->hasDefinitiveInitializer());
153 Constant *Initializer = GV->getInitializer();
154 if ((Result.
OutlinedParts = dyn_cast<ConstantStruct>(Initializer)))
157 Result.
Resumers = cast<ConstantArray>(Initializer);
161 return cast<Constant>(getArgOperand(InfoArg)->stripPointerCasts());
167 return cast<Function>(getArgOperand(CoroutineArg)->stripPointerCasts());
170 assert(isa<ConstantPointerNull>(getArgOperand(CoroutineArg)) &&
171 "Coroutine argument is already assigned");
173 setArgOperand(CoroutineArg,
182 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
194 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
200 enum { IdArg, FrameArg };
210 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
216 enum { IdArg, MemArg };
228 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
240 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
246 enum { FrameArg, AlignArg, FromArg };
250 return cast<Constant>(getArgOperand(FromArg))->isOneValue();
253 return cast<ConstantInt>(getArgOperand(AlignArg))->getZExtValue();
261 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
267 enum { SaveArg, FinalArg };
271 Value *
Arg = getArgOperand(SaveArg);
272 if (
auto *
SI = dyn_cast<CoroSaveInst>(Arg))
274 assert(isa<ConstantTokenNone>(Arg));
278 return cast<Constant>(getArgOperand(FinalArg))->isOneValue();
286 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
298 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
304 enum { FrameArg, UnwindArg };
309 return cast<Constant>(getArgOperand(UnwindArg))->isOneValue();
317 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
This represents the llvm.coro.promise instruction.
This represents the llvm.coro.alloc instruction.
This class represents lattice values for constants.
static bool classof(const IntrinsicInst *I)
IntrinsicInst * getCoroBegin()
unsigned getAlignment() const
ConstantInt * getRawIndex() const
static bool classof(const IntrinsicInst *I)
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
This represents the llvm.coro.suspend instruction.
static bool classof(const IntrinsicInst *I)
AllocaInst * getPromise() const
This class represents the llvm.coro.subfn.addr instruction.
ConstantStruct * OutlinedParts
static bool classof(const IntrinsicInst *I)
This represents the llvm.coro.alloc instruction.
static bool classof(const IntrinsicInst *I)
bool isFallthrough() const
static bool classof(const Value *V)
static Function * getFunction(Constant *C)
static Constant * getBitCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
This represents the llvm.coro.size instruction.
static ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
This is an important base class in LLVM.
ResumeKind getIndex() const
static bool classof(const Value *V)
This represents the llvm.coro.end instruction.
bool isFromPromise() const
This represents the llvm.coro.save instruction.
static bool classof(const Value *V)
static bool classof(const Value *V)
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs, and aliases.
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
This represents the llvm.coro.free instruction.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static bool classof(const IntrinsicInst *I)
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
static bool classof(const Value *V)
This is the shared class of boolean and integer constants.
static bool classof(const Value *V)
bool hasOutlinedParts() const
This class represents the llvm.coro.begin instruction.
ConstantArray - Constant Array Declarations.
static bool classof(const IntrinsicInst *I)
amdgpu Simplify well known AMD library false Value Value * Arg
static bool classof(const Value *V)
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
Function * getCoroutine() const
static bool classof(const IntrinsicInst *I)
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
#define LLVM_LIBRARY_VISIBILITY
LLVM_LIBRARY_VISIBILITY - If a class marked with this attribute is linked into a shared library...
CoroIdInst * getId() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This represents the llvm.coro.frame instruction.
LLVM Value Representation.
void setInfo(Constant *C)
CoroAllocInst * getCoroAlloc()
static bool classof(const Value *V)
CoroSaveInst * getCoroSave() const
A wrapper class for inspecting calls to intrinsic functions.
an instruction to allocate memory on the stack
Constant * getRawInfo() const