LLVM 23.0.0git
CoroInstr.h
Go to the documentation of this file.
1//===-- CoroInstr.h - Coroutine Intrinsics Instruction Wrappers -*- C++ -*-===//
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// This file defines classes that make it really easy to deal with intrinsic
9// functions with the isa/dyncast family of functions. In particular, this
10// allows you to do things like:
11//
12// if (auto *SF = dyn_cast<CoroSubFnInst>(Inst))
13// ... SF->getFrame() ...
14//
15// All intrinsic function calls are instances of the call instruction, so these
16// are all subclasses of the CallInst class. Note that none of these classes
17// has state or virtual methods, which is an important part of this gross/neat
18// hack working.
19//
20// The helpful comment above is borrowed from llvm/IntrinsicInst.h, we keep
21// coroutine intrinsic wrappers here since they are only used by the passes in
22// the Coroutine library.
23//===----------------------------------------------------------------------===//
24
25#ifndef LLVM_TRANSFORMS_COROUTINES_COROINSTR_H
26#define LLVM_TRANSFORMS_COROUTINES_COROINSTR_H
27
32
33namespace llvm {
34
35/// This class represents the llvm.coro.subfn.addr instruction.
37 enum { FrameArg, IndexArg };
38
39public:
48
49 Value *getFrame() const { return getArgOperand(FrameArg); }
51 int64_t Index = getRawIndex()->getValue().getSExtValue();
52 assert(Index >= IndexFirst && Index < IndexLast &&
53 "unexpected CoroSubFnInst index argument");
54 return static_cast<ResumeKind>(Index);
55 }
56
58 return cast<ConstantInt>(getArgOperand(IndexArg));
59 }
60
61 // Methods to support type inquiry through isa, cast, and dyn_cast:
62 static bool classof(const IntrinsicInst *I) {
63 return I->getIntrinsicID() == Intrinsic::coro_subfn_addr;
64 }
65 static bool classof(const Value *V) {
67 }
68};
69
70/// This represents the llvm.coro.alloc instruction.
72public:
73 // Methods to support type inquiry through isa, cast, and dyn_cast:
74 static bool classof(const IntrinsicInst *I) {
75 return I->getIntrinsicID() == Intrinsic::coro_alloc;
76 }
77 static bool classof(const Value *V) {
79 }
80};
81
82/// This represents the llvm.coro.await.suspend.{void,bool,handle} instructions.
83// FIXME: add callback metadata
84// FIXME: make a proper IntrinisicInst. Currently this is not possible,
85// because llvm.coro.await.suspend.* can be invoked.
87 enum { AwaiterArg, FrameArg, WrapperArg };
88
89public:
90 Value *getAwaiter() const { return getArgOperand(AwaiterArg); }
91
92 Value *getFrame() const { return getArgOperand(FrameArg); }
93
95 return cast<Function>(getArgOperand(WrapperArg));
96 }
97
98 // Methods to support type inquiry through isa, cast, and dyn_cast:
99 static bool classof(const CallBase *CB) {
100 if (const Function *CF = CB->getCalledFunction()) {
101 auto IID = CF->getIntrinsicID();
102 return IID == Intrinsic::coro_await_suspend_void ||
103 IID == Intrinsic::coro_await_suspend_bool ||
104 IID == Intrinsic::coro_await_suspend_handle;
105 }
106
107 return false;
108 }
109
110 static bool classof(const Value *V) {
111 return isa<CallBase>(V) && classof(cast<CallBase>(V));
112 }
113};
114
115/// This represents a common base class for llvm.coro.id instructions.
117public:
119 for (User *U : users())
120 if (auto *CA = dyn_cast<CoroAllocInst>(U))
121 return CA;
122 return nullptr;
123 }
124
126 for (User *U : users())
127 if (auto *II = dyn_cast<IntrinsicInst>(U))
128 if (II->getIntrinsicID() == Intrinsic::coro_begin ||
129 II->getIntrinsicID() == Intrinsic::coro_begin_custom_abi)
130 return II;
131 llvm_unreachable("no coro.begin associated with coro.id");
132 }
133
134 // Methods to support type inquiry through isa, cast, and dyn_cast:
135 static bool classof(const IntrinsicInst *I) {
136 auto ID = I->getIntrinsicID();
137 return ID == Intrinsic::coro_id || ID == Intrinsic::coro_id_retcon ||
138 ID == Intrinsic::coro_id_retcon_once ||
139 ID == Intrinsic::coro_id_async;
140 }
141
142 static bool classof(const Value *V) {
144 }
145};
146
147/// This represents the llvm.coro.id instruction.
148class CoroIdInst : public AnyCoroIdInst {
149 enum { AlignArg, PromiseArg, CoroutineArg, InfoArg };
150
151public:
153 Value *Arg = getArgOperand(PromiseArg);
154 return isa<ConstantPointerNull>(Arg)
155 ? nullptr
157 }
158
160 Value *Arg = getArgOperand(PromiseArg);
163 if (isa<AllocaInst>(Arg))
164 return;
166 "unexpected instruction designating the promise");
167 // TODO: Add a check that any remaining users of Inst are after coro.begin
168 // or add code to move the users after coro.begin.
169 auto *Inst = cast<Instruction>(Arg);
170 if (Inst->use_empty()) {
171 Inst->eraseFromParent();
172 return;
173 }
174 Inst->moveBefore(std::next(getCoroBegin()->getIterator()));
175 }
176
177 // Info argument of coro.id is
178 // fresh out of the frontend: null ;
179 // outlined : {Init, Return, Susp1, Susp2, ...} ;
180 // postsplit : [resume, destroy, cleanup] ;
181 //
182 // If parts of the coroutine were outlined to protect against undesirable
183 // code motion, these functions will be stored in a struct literal referred to
184 // by the Info parameter. Note: this is only needed before coroutine is split.
185 //
186 // After coroutine is split, resume functions are stored in an array
187 // referred to by this parameter.
188
189 struct Info {
192
193 bool hasOutlinedParts() const { return OutlinedParts != nullptr; }
194 bool isPostSplit() const { return Resumers != nullptr; }
195 bool isPreSplit() const { return !isPostSplit(); }
196 };
197 Info getInfo() const {
198 Info Result;
200 if (!GV)
201 return Result;
202
203 assert(GV->isConstant() && GV->hasDefinitiveInitializer());
204 Constant *Initializer = GV->getInitializer();
205 if ((Result.OutlinedParts = dyn_cast<ConstantStruct>(Initializer)))
206 return Result;
207
208 Result.Resumers = cast<ConstantArray>(Initializer);
209 return Result;
210 }
213 }
214
215 void setInfo(Constant *C) { setArgOperand(InfoArg, C); }
216
218 return cast<Function>(getArgOperand(CoroutineArg)->stripPointerCasts());
219 }
221 if (!isa<ConstantPointerNull>(getArgOperand(CoroutineArg)))
222 assert(getCoroutine() == getFunction() && "Don't change coroutine.");
223 setArgOperand(CoroutineArg, getFunction());
224 }
225
226 // Methods to support type inquiry through isa, cast, and dyn_cast:
227 static bool classof(const IntrinsicInst *I) {
228 return I->getIntrinsicID() == Intrinsic::coro_id;
229 }
230 static bool classof(const Value *V) {
232 }
233};
234
235/// This represents either the llvm.coro.id.retcon or
236/// llvm.coro.id.retcon.once instruction.
238 enum { SizeArg, AlignArg, StorageArg, PrototypeArg, AllocArg, DeallocArg };
239
240public:
241 LLVM_ABI void checkWellFormed() const;
242
244 return cast<ConstantInt>(getArgOperand(SizeArg))->getZExtValue();
245 }
246
248 return cast<ConstantInt>(getArgOperand(AlignArg))->getAlignValue();
249 }
250
251 Value *getStorage() const { return getArgOperand(StorageArg); }
252
253 /// Return the prototype for the continuation function. The type,
254 /// attributes, and calling convention of the continuation function(s)
255 /// are taken from this declaration.
257 return cast<Function>(getArgOperand(PrototypeArg)->stripPointerCasts());
258 }
259
260 /// Return the function to use for allocating memory.
263 }
264
265 /// Return the function to use for deallocating memory.
267 return cast<Function>(getArgOperand(DeallocArg)->stripPointerCasts());
268 }
269
270 // Methods to support type inquiry through isa, cast, and dyn_cast:
271 static bool classof(const IntrinsicInst *I) {
272 auto ID = I->getIntrinsicID();
273 return ID == Intrinsic::coro_id_retcon ||
274 ID == Intrinsic::coro_id_retcon_once;
275 }
276 static bool classof(const Value *V) {
278 }
279};
280
281/// This represents the llvm.coro.id.retcon instruction.
283public:
284 // Methods to support type inquiry through isa, cast, and dyn_cast:
285 static bool classof(const IntrinsicInst *I) {
286 return I->getIntrinsicID() == Intrinsic::coro_id_retcon;
287 }
288 static bool classof(const Value *V) {
290 }
291};
292
293/// This represents the llvm.coro.id.retcon.once instruction.
295public:
296 // Methods to support type inquiry through isa, cast, and dyn_cast:
297 static bool classof(const IntrinsicInst *I) {
298 return I->getIntrinsicID() == Intrinsic::coro_id_retcon_once;
299 }
300 static bool classof(const Value *V) {
302 }
303};
304
305/// This represents the llvm.coro.id.async instruction.
307 enum { SizeArg, AlignArg, StorageArg, AsyncFuncPtrArg };
308
309public:
310 LLVM_ABI void checkWellFormed() const;
311
312 /// The initial async function context size. The fields of which are reserved
313 /// for use by the frontend. The frame will be allocated as a tail of this
314 /// context.
316 return cast<ConstantInt>(getArgOperand(SizeArg))->getZExtValue();
317 }
318
319 /// The alignment of the initial async function context.
321 return cast<ConstantInt>(getArgOperand(AlignArg))->getAlignValue();
322 }
323
324 /// The async context parameter.
325 Value *getStorage() const {
326 return getParent()->getParent()->getArg(getStorageArgumentIndex());
327 }
328
329 unsigned getStorageArgumentIndex() const {
330 auto *Arg = cast<ConstantInt>(getArgOperand(StorageArg));
331 return Arg->getZExtValue();
332 }
333
334 /// Return the async function pointer address. This should be the address of
335 /// a async function pointer struct for the current async function.
336 /// struct async_function_pointer {
337 /// uint32_t context_size;
338 /// uint32_t relative_async_function_pointer;
339 /// };
342 getArgOperand(AsyncFuncPtrArg)->stripPointerCasts());
343 }
344
345 // Methods to support type inquiry through isa, cast, and dyn_cast:
346 static bool classof(const IntrinsicInst *I) {
347 auto ID = I->getIntrinsicID();
348 return ID == Intrinsic::coro_id_async;
349 }
350
351 static bool classof(const Value *V) {
353 }
354};
355
356/// This represents the llvm.coro.context.alloc instruction.
358 enum { AsyncFuncPtrArg };
359
360public:
363 getArgOperand(AsyncFuncPtrArg)->stripPointerCasts());
364 }
365
366 // Methods to support type inquiry through isa, cast, and dyn_cast:
367 static bool classof(const IntrinsicInst *I) {
368 return I->getIntrinsicID() == Intrinsic::coro_async_context_alloc;
369 }
370 static bool classof(const Value *V) {
372 }
373};
374
375/// This represents the llvm.coro.context.dealloc instruction.
377 enum { AsyncContextArg };
378
379public:
381 return getArgOperand(AsyncContextArg)->stripPointerCasts();
382 }
383
384 // Methods to support type inquiry through isa, cast, and dyn_cast:
385 static bool classof(const IntrinsicInst *I) {
386 return I->getIntrinsicID() == Intrinsic::coro_async_context_dealloc;
387 }
388 static bool classof(const Value *V) {
390 }
391};
392
393/// This represents the llvm.coro.async.resume instruction.
394/// During lowering this is replaced by the resume function of a suspend point
395/// (the continuation function).
397public:
398 // Methods to support type inquiry through isa, cast, and dyn_cast:
399 static bool classof(const IntrinsicInst *I) {
400 return I->getIntrinsicID() == Intrinsic::coro_async_resume;
401 }
402 static bool classof(const Value *V) {
404 }
405};
406
407/// This represents the llvm.coro.async.size.replace instruction.
409public:
410 // Methods to support type inquiry through isa, cast, and dyn_cast:
411 static bool classof(const IntrinsicInst *I) {
412 return I->getIntrinsicID() == Intrinsic::coro_async_size_replace;
413 }
414 static bool classof(const Value *V) {
416 }
417};
418
419/// This represents the llvm.coro.frame instruction.
421public:
422 // Methods to support type inquiry through isa, cast, and dyn_cast:
423 static bool classof(const IntrinsicInst *I) {
424 return I->getIntrinsicID() == Intrinsic::coro_frame;
425 }
426 static bool classof(const Value *V) {
428 }
429};
430
431/// This represents the llvm.coro.is_in_ramp instruction.
433public:
434 // Methods to support type inquiry through isa, cast, and dyn_cast:
435 static bool classof(const IntrinsicInst *I) {
436 return I->getIntrinsicID() == Intrinsic::coro_is_in_ramp;
437 }
438 static bool classof(const Value *V) {
440 }
441};
442
443/// This represents the llvm.coro.free instruction.
445 enum { IdArg, FrameArg };
446
447public:
448 Value *getFrame() const { return getArgOperand(FrameArg); }
449
450 // Methods to support type inquiry through isa, cast, and dyn_cast:
451 static bool classof(const IntrinsicInst *I) {
452 return I->getIntrinsicID() == Intrinsic::coro_free;
453 }
454 static bool classof(const Value *V) {
456 }
457};
458
459/// This represents the llvm.coro.dead instruction.
461public:
462 Value *getFrame() const { return getArgOperand(0); }
463
464 // Methods to support type inquiry through isa, cast, and dyn_cast:
465 static bool classof(const IntrinsicInst *I) {
466 return I->getIntrinsicID() == Intrinsic::coro_dead;
467 }
468 static bool classof(const Value *V) {
470 }
471};
472
473/// This class represents the llvm.coro.begin or llvm.coro.begin.custom.abi
474/// instructions.
476 enum { IdArg, MemArg, CustomABIArg };
477
478public:
480 return cast<AnyCoroIdInst>(getArgOperand(IdArg));
481 }
482
483 bool hasCustomABI() const {
484 return getIntrinsicID() == Intrinsic::coro_begin_custom_abi;
485 }
486
487 int getCustomABI() const {
488 return cast<ConstantInt>(getArgOperand(CustomABIArg))->getZExtValue();
489 }
490
491 Value *getMem() const { return getArgOperand(MemArg); }
492
493 // Methods for support type inquiry through isa, cast, and dyn_cast:
494 static bool classof(const IntrinsicInst *I) {
495 return I->getIntrinsicID() == Intrinsic::coro_begin ||
496 I->getIntrinsicID() == Intrinsic::coro_begin_custom_abi;
497 }
498 static bool classof(const Value *V) {
500 }
501};
502
503/// This represents the llvm.coro.save instruction.
505public:
506 // Methods to support type inquiry through isa, cast, and dyn_cast:
507 static bool classof(const IntrinsicInst *I) {
508 return I->getIntrinsicID() == Intrinsic::coro_save;
509 }
510 static bool classof(const Value *V) {
512 }
513};
514
515/// This represents the llvm.coro.promise instruction.
517 enum { FrameArg, AlignArg, FromArg };
518
519public:
520 /// Are we translating from the frame to the promise (false) or from
521 /// the promise to the frame (true)?
522 bool isFromPromise() const {
523 return cast<Constant>(getArgOperand(FromArg))->isOneValue();
524 }
525
526 /// The required alignment of the promise. This must match the
527 /// alignment of the promise alloca in the coroutine.
529 return cast<ConstantInt>(getArgOperand(AlignArg))->getAlignValue();
530 }
531
532 // Methods to support type inquiry through isa, cast, and dyn_cast:
533 static bool classof(const IntrinsicInst *I) {
534 return I->getIntrinsicID() == Intrinsic::coro_promise;
535 }
536 static bool classof(const Value *V) {
538 }
539};
540
542public:
543 CoroSaveInst *getCoroSave() const;
544
545 // Methods to support type inquiry through isa, cast, and dyn_cast:
546 static bool classof(const IntrinsicInst *I) {
547 return I->getIntrinsicID() == Intrinsic::coro_suspend ||
548 I->getIntrinsicID() == Intrinsic::coro_suspend_async ||
549 I->getIntrinsicID() == Intrinsic::coro_suspend_retcon;
550 }
551 static bool classof(const Value *V) {
553 }
554};
555
556/// This represents the llvm.coro.suspend instruction.
558 enum { SaveArg, FinalArg };
559
560public:
562 Value *Arg = getArgOperand(SaveArg);
563 if (auto *SI = dyn_cast<CoroSaveInst>(Arg))
564 return SI;
566 return nullptr;
567 }
568
569 bool isFinal() const {
570 return cast<Constant>(getArgOperand(FinalArg))->isOneValue();
571 }
572
573 // Methods to support type inquiry through isa, cast, and dyn_cast:
574 static bool classof(const IntrinsicInst *I) {
575 return I->getIntrinsicID() == Intrinsic::coro_suspend;
576 }
577 static bool classof(const Value *V) {
579 }
580};
581
583 if (auto Suspend = dyn_cast<CoroSuspendInst>(this))
584 return Suspend->getCoroSave();
585 return nullptr;
586}
587
588/// This represents the llvm.coro.suspend.async instruction.
590public:
591 enum {
596 };
597
598 LLVM_ABI void checkWellFormed() const;
599
600 unsigned getStorageArgumentIndex() const {
602 return Arg->getZExtValue();
603 }
604
609
614
619
620 // Methods to support type inquiry through isa, cast, and dyn_cast:
621 static bool classof(const IntrinsicInst *I) {
622 return I->getIntrinsicID() == Intrinsic::coro_suspend_async;
623 }
624 static bool classof(const Value *V) {
626 }
627};
628
629/// This represents the llvm.coro.suspend.retcon instruction.
631public:
634
636 const_op_iterator value_end() const { return arg_end(); }
637
644
645 // Methods to support type inquiry through isa, cast, and dyn_cast:
646 static bool classof(const IntrinsicInst *I) {
647 return I->getIntrinsicID() == Intrinsic::coro_suspend_retcon;
648 }
649 static bool classof(const Value *V) {
651 }
652};
653
654/// This represents the llvm.coro.size instruction.
656public:
657 // Methods to support type inquiry through isa, cast, and dyn_cast:
658 static bool classof(const IntrinsicInst *I) {
659 return I->getIntrinsicID() == Intrinsic::coro_size;
660 }
661 static bool classof(const Value *V) {
663 }
664};
665
666/// This represents the llvm.coro.align instruction.
668public:
669 // Methods to support type inquiry through isa, cast, and dyn_cast:
670 static bool classof(const IntrinsicInst *I) {
671 return I->getIntrinsicID() == Intrinsic::coro_align;
672 }
673 static bool classof(const Value *V) {
675 }
676};
677
678/// This represents the llvm.end.results instruction.
680public:
683
686
693
694 unsigned numReturns() const {
695 return std::distance(retval_begin(), retval_end());
696 }
697
698 // Methods to support type inquiry through isa, cast, and dyn_cast:
699 static bool classof(const IntrinsicInst *I) {
700 return I->getIntrinsicID() == Intrinsic::coro_end_results;
701 }
702 static bool classof(const Value *V) {
704 }
705};
706
708 enum { FrameArg, UnwindArg, TokenArg };
709
710public:
711 bool isFallthrough() const { return !isUnwind(); }
712 bool isUnwind() const {
713 return cast<Constant>(getArgOperand(UnwindArg))->isOneValue();
714 }
715
716 bool hasResults() const {
717 return !isa<ConstantTokenNone>(getArgOperand(TokenArg));
718 }
719
722 return cast<CoroEndResults>(getArgOperand(TokenArg));
723 }
724
725 // Methods to support type inquiry through isa, cast, and dyn_cast:
726 static bool classof(const IntrinsicInst *I) {
727 auto ID = I->getIntrinsicID();
728 return ID == Intrinsic::coro_end || ID == Intrinsic::coro_end_async;
729 }
730 static bool classof(const Value *V) {
732 }
733};
734
735/// This represents the llvm.coro.end instruction.
737public:
738 // Methods to support type inquiry through isa, cast, and dyn_cast:
739 static bool classof(const IntrinsicInst *I) {
740 return I->getIntrinsicID() == Intrinsic::coro_end;
741 }
742 static bool classof(const Value *V) {
744 }
745};
746
747/// This represents the llvm.coro.end instruction.
749 enum { FrameArg, UnwindArg, MustTailCallFuncArg };
750
751public:
752 LLVM_ABI void checkWellFormed() const;
753
755 if (arg_size() < 3)
756 return nullptr;
757
758 return cast<Function>(
759 getArgOperand(MustTailCallFuncArg)->stripPointerCasts());
760 }
761
762 // Methods to support type inquiry through isa, cast, and dyn_cast:
763 static bool classof(const IntrinsicInst *I) {
764 return I->getIntrinsicID() == Intrinsic::coro_end_async;
765 }
766 static bool classof(const Value *V) {
768 }
769};
770
771/// This represents the llvm.coro.alloca.alloc instruction.
773 enum { SizeArg, AlignArg };
774
775public:
776 Value *getSize() const { return getArgOperand(SizeArg); }
778 return cast<ConstantInt>(getArgOperand(AlignArg))->getAlignValue();
779 }
780
781 // Methods to support type inquiry through isa, cast, and dyn_cast:
782 static bool classof(const IntrinsicInst *I) {
783 return I->getIntrinsicID() == Intrinsic::coro_alloca_alloc;
784 }
785 static bool classof(const Value *V) {
787 }
788};
789
790/// This represents the llvm.coro.alloca.get instruction.
792 enum { AllocArg };
793
794public:
798
799 // Methods to support type inquiry through isa, cast, and dyn_cast:
800 static bool classof(const IntrinsicInst *I) {
801 return I->getIntrinsicID() == Intrinsic::coro_alloca_get;
802 }
803 static bool classof(const Value *V) {
805 }
806};
807
808/// This represents the llvm.coro.alloca.free instruction.
810 enum { AllocArg };
811
812public:
816
817 // Methods to support type inquiry through isa, cast, and dyn_cast:
818 static bool classof(const IntrinsicInst *I) {
819 return I->getIntrinsicID() == Intrinsic::coro_alloca_free;
820 }
821 static bool classof(const Value *V) {
823 }
824};
825
826} // End namespace llvm.
827
828#endif // LLVM_TRANSFORMS_COROUTINES_COROINSTR_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_ABI
Definition Compiler.h:213
iv users
Definition IVUsers.cpp:48
#define I(x, y, z)
Definition MD5.cpp:57
uint64_t IntrinsicInst * II
int64_t getSExtValue() const
Get sign extended value.
Definition APInt.h:1577
an instruction to allocate memory on the stack
bool isFallthrough() const
Definition CoroInstr.h:711
static bool classof(const Value *V)
Definition CoroInstr.h:730
bool hasResults() const
Definition CoroInstr.h:716
bool isUnwind() const
Definition CoroInstr.h:712
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:726
CoroEndResults * getResults() const
Definition CoroInstr.h:720
This represents a common base class for llvm.coro.id instructions.
Definition CoroInstr.h:116
IntrinsicInst * getCoroBegin()
Definition CoroInstr.h:125
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:135
static bool classof(const Value *V)
Definition CoroInstr.h:142
CoroAllocInst * getCoroAlloc()
Definition CoroInstr.h:118
This represents either the llvm.coro.id.retcon or llvm.coro.id.retcon.once instruction.
Definition CoroInstr.h:237
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:271
Value * getStorage() const
Definition CoroInstr.h:251
Align getStorageAlignment() const
Definition CoroInstr.h:247
Function * getPrototype() const
Return the prototype for the continuation function.
Definition CoroInstr.h:256
uint64_t getStorageSize() const
Definition CoroInstr.h:243
LLVM_ABI void checkWellFormed() const
Function * getAllocFunction() const
Return the function to use for allocating memory.
Definition CoroInstr.h:261
static bool classof(const Value *V)
Definition CoroInstr.h:276
Function * getDeallocFunction() const
Return the function to use for deallocating memory.
Definition CoroInstr.h:266
static bool classof(const Value *V)
Definition CoroInstr.h:551
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:546
CoroSaveInst * getCoroSave() const
Definition CoroInstr.h:582
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
User::op_iterator arg_begin()
Return the iterator pointing to the beginning of the argument list.
CallBase(AttributeList const &A, FunctionType *FT, ArgsTy &&... Args)
Value * getArgOperand(unsigned i) const
void setArgOperand(unsigned i, Value *v)
User::op_iterator arg_end()
Return the iterator pointing to the end of the argument list.
unsigned arg_size() const
ConstantArray - Constant Array Declarations.
Definition Constants.h:576
This is the shared class of boolean and integer constants.
Definition Constants.h:87
const APInt & getValue() const
Return the constant as an APInt value reference.
Definition Constants.h:159
static LLVM_ABI ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
This is an important base class in LLVM.
Definition Constant.h:43
This represents the llvm.coro.align instruction.
Definition CoroInstr.h:667
static bool classof(const Value *V)
Definition CoroInstr.h:673
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:670
This represents the llvm.coro.alloc instruction.
Definition CoroInstr.h:71
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:74
static bool classof(const Value *V)
Definition CoroInstr.h:77
This represents the llvm.coro.alloca.alloc instruction.
Definition CoroInstr.h:772
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:782
Align getAlignment() const
Definition CoroInstr.h:777
static bool classof(const Value *V)
Definition CoroInstr.h:785
Value * getSize() const
Definition CoroInstr.h:776
This represents the llvm.coro.alloca.free instruction.
Definition CoroInstr.h:809
static bool classof(const Value *V)
Definition CoroInstr.h:821
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:818
CoroAllocaAllocInst * getAlloc() const
Definition CoroInstr.h:813
This represents the llvm.coro.alloca.get instruction.
Definition CoroInstr.h:791
static bool classof(const Value *V)
Definition CoroInstr.h:803
CoroAllocaAllocInst * getAlloc() const
Definition CoroInstr.h:795
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:800
This represents the llvm.coro.context.alloc instruction.
Definition CoroInstr.h:357
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:367
static bool classof(const Value *V)
Definition CoroInstr.h:370
GlobalVariable * getAsyncFunctionPointer() const
Definition CoroInstr.h:361
This represents the llvm.coro.context.dealloc instruction.
Definition CoroInstr.h:376
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:385
static bool classof(const Value *V)
Definition CoroInstr.h:388
This represents the llvm.coro.end instruction.
Definition CoroInstr.h:748
Function * getMustTailCallFunction() const
Definition CoroInstr.h:754
LLVM_ABI void checkWellFormed() const
static bool classof(const Value *V)
Definition CoroInstr.h:766
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:763
This represents the llvm.coro.async.resume instruction.
Definition CoroInstr.h:396
static bool classof(const Value *V)
Definition CoroInstr.h:402
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:399
This represents the llvm.coro.async.size.replace instruction.
Definition CoroInstr.h:408
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:411
static bool classof(const Value *V)
Definition CoroInstr.h:414
This represents the llvm.coro.await.suspend.{void,bool,handle} instructions.
Definition CoroInstr.h:86
static bool classof(const CallBase *CB)
Definition CoroInstr.h:99
Value * getFrame() const
Definition CoroInstr.h:92
static bool classof(const Value *V)
Definition CoroInstr.h:110
Value * getAwaiter() const
Definition CoroInstr.h:90
Function * getWrapperFunction() const
Definition CoroInstr.h:94
This class represents the llvm.coro.begin or llvm.coro.begin.custom.abi instructions.
Definition CoroInstr.h:475
AnyCoroIdInst * getId() const
Definition CoroInstr.h:479
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:494
static bool classof(const Value *V)
Definition CoroInstr.h:498
bool hasCustomABI() const
Definition CoroInstr.h:483
int getCustomABI() const
Definition CoroInstr.h:487
Value * getMem() const
Definition CoroInstr.h:491
This represents the llvm.coro.dead instruction.
Definition CoroInstr.h:460
Value * getFrame() const
Definition CoroInstr.h:462
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:465
static bool classof(const Value *V)
Definition CoroInstr.h:468
This represents the llvm.coro.end instruction.
Definition CoroInstr.h:736
static bool classof(const Value *V)
Definition CoroInstr.h:742
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:739
This represents the llvm.end.results instruction.
Definition CoroInstr.h:679
op_iterator retval_begin()
Definition CoroInstr.h:681
const_op_iterator retval_begin() const
Definition CoroInstr.h:682
iterator_range< const_op_iterator > return_values() const
Definition CoroInstr.h:690
iterator_range< op_iterator > return_values()
Definition CoroInstr.h:687
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:699
const_op_iterator retval_end() const
Definition CoroInstr.h:685
static bool classof(const Value *V)
Definition CoroInstr.h:702
op_iterator retval_end()
Definition CoroInstr.h:684
unsigned numReturns() const
Definition CoroInstr.h:694
This represents the llvm.coro.frame instruction.
Definition CoroInstr.h:420
static bool classof(const Value *V)
Definition CoroInstr.h:426
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:423
This represents the llvm.coro.free instruction.
Definition CoroInstr.h:444
Value * getFrame() const
Definition CoroInstr.h:448
static bool classof(const Value *V)
Definition CoroInstr.h:454
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:451
This represents the llvm.coro.id.async instruction.
Definition CoroInstr.h:306
Align getStorageAlignment() const
The alignment of the initial async function context.
Definition CoroInstr.h:320
uint64_t getStorageSize() const
The initial async function context size.
Definition CoroInstr.h:315
LLVM_ABI void checkWellFormed() const
GlobalVariable * getAsyncFunctionPointer() const
Return the async function pointer address.
Definition CoroInstr.h:340
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:346
Value * getStorage() const
The async context parameter.
Definition CoroInstr.h:325
unsigned getStorageArgumentIndex() const
Definition CoroInstr.h:329
static bool classof(const Value *V)
Definition CoroInstr.h:351
This represents the llvm.coro.id instruction.
Definition CoroInstr.h:148
static bool classof(const Value *V)
Definition CoroInstr.h:230
void setInfo(Constant *C)
Definition CoroInstr.h:215
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:227
Info getInfo() const
Definition CoroInstr.h:197
Function * getCoroutine() const
Definition CoroInstr.h:217
Constant * getRawInfo() const
Definition CoroInstr.h:211
AllocaInst * getPromise() const
Definition CoroInstr.h:152
void setCoroutineSelf()
Definition CoroInstr.h:220
void clearPromise()
Definition CoroInstr.h:159
This represents the llvm.coro.id.retcon instruction.
Definition CoroInstr.h:282
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:285
static bool classof(const Value *V)
Definition CoroInstr.h:288
This represents the llvm.coro.id.retcon.once instruction.
Definition CoroInstr.h:294
static bool classof(const Value *V)
Definition CoroInstr.h:300
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:297
This represents the llvm.coro.is_in_ramp instruction.
Definition CoroInstr.h:432
static bool classof(const Value *V)
Definition CoroInstr.h:438
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:435
This represents the llvm.coro.promise instruction.
Definition CoroInstr.h:516
static bool classof(const Value *V)
Definition CoroInstr.h:536
Align getAlignment() const
The required alignment of the promise.
Definition CoroInstr.h:528
bool isFromPromise() const
Are we translating from the frame to the promise (false) or from the promise to the frame (true)?
Definition CoroInstr.h:522
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:533
This represents the llvm.coro.save instruction.
Definition CoroInstr.h:504
static bool classof(const Value *V)
Definition CoroInstr.h:510
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:507
This represents the llvm.coro.size instruction.
Definition CoroInstr.h:655
static bool classof(const Value *V)
Definition CoroInstr.h:661
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:658
This class represents the llvm.coro.subfn.addr instruction.
Definition CoroInstr.h:36
static bool classof(const Value *V)
Definition CoroInstr.h:65
Value * getFrame() const
Definition CoroInstr.h:49
ResumeKind getIndex() const
Definition CoroInstr.h:50
ConstantInt * getRawIndex() const
Definition CoroInstr.h:57
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:62
This represents the llvm.coro.suspend.async instruction.
Definition CoroInstr.h:589
Function * getAsyncContextProjectionFunction() const
Definition CoroInstr.h:605
static bool classof(const Value *V)
Definition CoroInstr.h:624
unsigned getStorageArgumentIndex() const
Definition CoroInstr.h:600
LLVM_ABI void checkWellFormed() const
CoroAsyncResumeInst * getResumeFunction() const
Definition CoroInstr.h:610
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:621
Function * getMustTailCallFunction() const
Definition CoroInstr.h:615
This represents the llvm.coro.suspend instruction.
Definition CoroInstr.h:557
bool isFinal() const
Definition CoroInstr.h:569
CoroSaveInst * getCoroSave() const
Definition CoroInstr.h:561
static bool classof(const Value *V)
Definition CoroInstr.h:577
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:574
This represents the llvm.coro.suspend.retcon instruction.
Definition CoroInstr.h:630
static bool classof(const Value *V)
Definition CoroInstr.h:649
const_op_iterator value_begin() const
Definition CoroInstr.h:633
const_op_iterator value_end() const
Definition CoroInstr.h:636
iterator_range< const_op_iterator > value_operands() const
Definition CoroInstr.h:641
iterator_range< op_iterator > value_operands()
Definition CoroInstr.h:638
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:646
LLVM_ABI const Function * getFunction() const
Return the function this instruction belongs to.
A wrapper class for inspecting calls to intrinsic functions.
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
LLVM Value Representation.
Definition Value.h:75
LLVMContext & getContext() const
All values hold a context through their type.
Definition Value.h:259
LLVM_ABI const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
Definition Value.cpp:713
A range adaptor for a pair of iterators.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
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.
Definition Casting.h:643
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
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
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39
ConstantArray * Resumers
Definition CoroInstr.h:191
bool hasOutlinedParts() const
Definition CoroInstr.h:193
bool isPostSplit() const
Definition CoroInstr.h:194
bool isPreSplit() const
Definition CoroInstr.h:195
ConstantStruct * OutlinedParts
Definition CoroInstr.h:190