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>(
220 }
222 if (!isa<ConstantPointerNull>(getArgOperand(CoroutineArg)))
223 assert(getCoroutine() == getFunction() && "Don't change coroutine.");
224 setArgOperand(CoroutineArg, getFunction());
225 }
226
227 // Methods to support type inquiry through isa, cast, and dyn_cast:
228 static bool classof(const IntrinsicInst *I) {
229 return I->getIntrinsicID() == Intrinsic::coro_id;
230 }
231 static bool classof(const Value *V) {
233 }
234};
235
236/// This represents either the llvm.coro.id.retcon or
237/// llvm.coro.id.retcon.once instruction.
239 enum { SizeArg, AlignArg, StorageArg, PrototypeArg, AllocArg, DeallocArg };
240
241public:
242 LLVM_ABI void checkWellFormed() const;
243
245 return cast<ConstantInt>(getArgOperand(SizeArg))->getZExtValue();
246 }
247
249 return cast<ConstantInt>(getArgOperand(AlignArg))->getAlignValue();
250 }
251
252 Value *getStorage() const { return getArgOperand(StorageArg); }
253
254 /// Return the prototype for the continuation function. The type,
255 /// attributes, and calling convention of the continuation function(s)
256 /// are taken from this declaration.
258 return cast<Function>(
260 }
261
262 /// Return the function to use for allocating memory.
267
268 /// Return the function to use for deallocating memory.
270 return cast<Function>(
272 }
273
274 // Methods to support type inquiry through isa, cast, and dyn_cast:
275 static bool classof(const IntrinsicInst *I) {
276 auto ID = I->getIntrinsicID();
277 return ID == Intrinsic::coro_id_retcon ||
278 ID == Intrinsic::coro_id_retcon_once;
279 }
280 static bool classof(const Value *V) {
282 }
283};
284
285/// This represents the llvm.coro.id.retcon instruction.
287public:
288 // Methods to support type inquiry through isa, cast, and dyn_cast:
289 static bool classof(const IntrinsicInst *I) {
290 return I->getIntrinsicID() == Intrinsic::coro_id_retcon;
291 }
292 static bool classof(const Value *V) {
294 }
295};
296
297/// This represents the llvm.coro.id.retcon.once instruction.
299public:
300 // Methods to support type inquiry through isa, cast, and dyn_cast:
301 static bool classof(const IntrinsicInst *I) {
302 return I->getIntrinsicID() == Intrinsic::coro_id_retcon_once;
303 }
304 static bool classof(const Value *V) {
306 }
307};
308
309/// This represents the llvm.coro.id.async instruction.
311 enum { SizeArg, AlignArg, StorageArg, AsyncFuncPtrArg };
312
313public:
314 LLVM_ABI void checkWellFormed() const;
315
316 /// The initial async function context size. The fields of which are reserved
317 /// for use by the frontend. The frame will be allocated as a tail of this
318 /// context.
320 return cast<ConstantInt>(getArgOperand(SizeArg))->getZExtValue();
321 }
322
323 /// The alignment of the initial async function context.
325 return cast<ConstantInt>(getArgOperand(AlignArg))->getAlignValue();
326 }
327
328 /// The async context parameter.
329 Value *getStorage() const {
330 return getParent()->getParent()->getArg(getStorageArgumentIndex());
331 }
332
333 unsigned getStorageArgumentIndex() const {
334 auto *Arg = cast<ConstantInt>(getArgOperand(StorageArg));
335 return Arg->getZExtValue();
336 }
337
338 /// Return the async function pointer address. This should be the address of
339 /// a async function pointer struct for the current async function.
340 /// struct async_function_pointer {
341 /// uint32_t context_size;
342 /// uint32_t relative_async_function_pointer;
343 /// };
346 getArgOperand(AsyncFuncPtrArg)->stripPointerCasts());
347 }
348
349 // Methods to support type inquiry through isa, cast, and dyn_cast:
350 static bool classof(const IntrinsicInst *I) {
351 auto ID = I->getIntrinsicID();
352 return ID == Intrinsic::coro_id_async;
353 }
354
355 static bool classof(const Value *V) {
357 }
358};
359
360/// This represents the llvm.coro.context.alloc instruction.
362 enum { AsyncFuncPtrArg };
363
364public:
367 getArgOperand(AsyncFuncPtrArg)->stripPointerCasts());
368 }
369
370 // Methods to support type inquiry through isa, cast, and dyn_cast:
371 static bool classof(const IntrinsicInst *I) {
372 return I->getIntrinsicID() == Intrinsic::coro_async_context_alloc;
373 }
374 static bool classof(const Value *V) {
376 }
377};
378
379/// This represents the llvm.coro.context.dealloc instruction.
381 enum { AsyncContextArg };
382
383public:
385 return getArgOperand(AsyncContextArg)->stripPointerCasts();
386 }
387
388 // Methods to support type inquiry through isa, cast, and dyn_cast:
389 static bool classof(const IntrinsicInst *I) {
390 return I->getIntrinsicID() == Intrinsic::coro_async_context_dealloc;
391 }
392 static bool classof(const Value *V) {
394 }
395};
396
397/// This represents the llvm.coro.async.resume instruction.
398/// During lowering this is replaced by the resume function of a suspend point
399/// (the continuation function).
401public:
402 // Methods to support type inquiry through isa, cast, and dyn_cast:
403 static bool classof(const IntrinsicInst *I) {
404 return I->getIntrinsicID() == Intrinsic::coro_async_resume;
405 }
406 static bool classof(const Value *V) {
408 }
409};
410
411/// This represents the llvm.coro.async.size.replace instruction.
413public:
414 // Methods to support type inquiry through isa, cast, and dyn_cast:
415 static bool classof(const IntrinsicInst *I) {
416 return I->getIntrinsicID() == Intrinsic::coro_async_size_replace;
417 }
418 static bool classof(const Value *V) {
420 }
421};
422
423/// This represents the llvm.coro.frame instruction.
425public:
426 // Methods to support type inquiry through isa, cast, and dyn_cast:
427 static bool classof(const IntrinsicInst *I) {
428 return I->getIntrinsicID() == Intrinsic::coro_frame;
429 }
430 static bool classof(const Value *V) {
432 }
433};
434
435/// This represents the llvm.coro.is_in_ramp instruction.
437public:
438 // Methods to support type inquiry through isa, cast, and dyn_cast:
439 static bool classof(const IntrinsicInst *I) {
440 return I->getIntrinsicID() == Intrinsic::coro_is_in_ramp;
441 }
442 static bool classof(const Value *V) {
444 }
445};
446
447/// This represents the llvm.coro.free instruction.
449 enum { IdArg, FrameArg };
450
451public:
452 Value *getFrame() const { return getArgOperand(FrameArg); }
453
454 // Methods to support type inquiry through isa, cast, and dyn_cast:
455 static bool classof(const IntrinsicInst *I) {
456 return I->getIntrinsicID() == Intrinsic::coro_free;
457 }
458 static bool classof(const Value *V) {
460 }
461};
462
463/// This represents the llvm.coro.dead instruction.
465public:
466 Value *getFrame() const { return getArgOperand(0); }
467
468 // Methods to support type inquiry through isa, cast, and dyn_cast:
469 static bool classof(const IntrinsicInst *I) {
470 return I->getIntrinsicID() == Intrinsic::coro_dead;
471 }
472 static bool classof(const Value *V) {
474 }
475};
476
477/// This class represents the llvm.coro.begin or llvm.coro.begin.custom.abi
478/// instructions.
480 enum { IdArg, MemArg, CustomABIArg };
481
482public:
484 return cast<AnyCoroIdInst>(getArgOperand(IdArg));
485 }
486
487 bool hasCustomABI() const {
488 return getIntrinsicID() == Intrinsic::coro_begin_custom_abi;
489 }
490
491 int getCustomABI() const {
492 return cast<ConstantInt>(getArgOperand(CustomABIArg))->getZExtValue();
493 }
494
495 Value *getMem() const { return getArgOperand(MemArg); }
496
497 // Methods for support type inquiry through isa, cast, and dyn_cast:
498 static bool classof(const IntrinsicInst *I) {
499 return I->getIntrinsicID() == Intrinsic::coro_begin ||
500 I->getIntrinsicID() == Intrinsic::coro_begin_custom_abi;
501 }
502 static bool classof(const Value *V) {
504 }
505};
506
507/// This represents the llvm.coro.save instruction.
509public:
510 // Methods to support type inquiry through isa, cast, and dyn_cast:
511 static bool classof(const IntrinsicInst *I) {
512 return I->getIntrinsicID() == Intrinsic::coro_save;
513 }
514 static bool classof(const Value *V) {
516 }
517};
518
519/// This represents the llvm.coro.promise instruction.
521 enum { FrameArg, AlignArg, FromArg };
522
523public:
524 /// Are we translating from the frame to the promise (false) or from
525 /// the promise to the frame (true)?
526 bool isFromPromise() const {
527 return cast<Constant>(getArgOperand(FromArg))->isOneValue();
528 }
529
530 /// The required alignment of the promise. This must match the
531 /// alignment of the promise alloca in the coroutine.
533 return cast<ConstantInt>(getArgOperand(AlignArg))->getAlignValue();
534 }
535
536 // Methods to support type inquiry through isa, cast, and dyn_cast:
537 static bool classof(const IntrinsicInst *I) {
538 return I->getIntrinsicID() == Intrinsic::coro_promise;
539 }
540 static bool classof(const Value *V) {
542 }
543};
544
546public:
547 CoroSaveInst *getCoroSave() const;
548
549 // Methods to support type inquiry through isa, cast, and dyn_cast:
550 static bool classof(const IntrinsicInst *I) {
551 return I->getIntrinsicID() == Intrinsic::coro_suspend ||
552 I->getIntrinsicID() == Intrinsic::coro_suspend_async ||
553 I->getIntrinsicID() == Intrinsic::coro_suspend_retcon;
554 }
555 static bool classof(const Value *V) {
557 }
558};
559
560/// This represents the llvm.coro.suspend instruction.
562 enum { SaveArg, FinalArg };
563
564public:
566 Value *Arg = getArgOperand(SaveArg);
567 if (auto *SI = dyn_cast<CoroSaveInst>(Arg))
568 return SI;
570 return nullptr;
571 }
572
573 bool isFinal() const {
574 return cast<Constant>(getArgOperand(FinalArg))->isOneValue();
575 }
576
577 // Methods to support type inquiry through isa, cast, and dyn_cast:
578 static bool classof(const IntrinsicInst *I) {
579 return I->getIntrinsicID() == Intrinsic::coro_suspend;
580 }
581 static bool classof(const Value *V) {
583 }
584};
585
587 if (auto Suspend = dyn_cast<CoroSuspendInst>(this))
588 return Suspend->getCoroSave();
589 return nullptr;
590}
591
592/// This represents the llvm.coro.suspend.async instruction.
594public:
595 enum {
600 };
601
602 LLVM_ABI void checkWellFormed() const;
603
604 unsigned getStorageArgumentIndex() const {
606 return Arg->getZExtValue();
607 }
608
613
618
623
624 // Methods to support type inquiry through isa, cast, and dyn_cast:
625 static bool classof(const IntrinsicInst *I) {
626 return I->getIntrinsicID() == Intrinsic::coro_suspend_async;
627 }
628 static bool classof(const Value *V) {
630 }
631};
632
633/// This represents the llvm.coro.suspend.retcon instruction.
635public:
638
640 const_op_iterator value_end() const { return arg_end(); }
641
648
649 // Methods to support type inquiry through isa, cast, and dyn_cast:
650 static bool classof(const IntrinsicInst *I) {
651 return I->getIntrinsicID() == Intrinsic::coro_suspend_retcon;
652 }
653 static bool classof(const Value *V) {
655 }
656};
657
658/// This represents the llvm.coro.size instruction.
660public:
661 // Methods to support type inquiry through isa, cast, and dyn_cast:
662 static bool classof(const IntrinsicInst *I) {
663 return I->getIntrinsicID() == Intrinsic::coro_size;
664 }
665 static bool classof(const Value *V) {
667 }
668};
669
670/// This represents the llvm.coro.align instruction.
672public:
673 // Methods to support type inquiry through isa, cast, and dyn_cast:
674 static bool classof(const IntrinsicInst *I) {
675 return I->getIntrinsicID() == Intrinsic::coro_align;
676 }
677 static bool classof(const Value *V) {
679 }
680};
681
682/// This represents the llvm.end.results instruction.
684public:
687
690
697
698 unsigned numReturns() const {
699 return std::distance(retval_begin(), retval_end());
700 }
701
702 // Methods to support type inquiry through isa, cast, and dyn_cast:
703 static bool classof(const IntrinsicInst *I) {
704 return I->getIntrinsicID() == Intrinsic::coro_end_results;
705 }
706 static bool classof(const Value *V) {
708 }
709};
710
712 enum { FrameArg, UnwindArg, TokenArg };
713
714public:
715 bool isFallthrough() const { return !isUnwind(); }
716 bool isUnwind() const {
717 return cast<Constant>(getArgOperand(UnwindArg))->isOneValue();
718 }
719
720 bool hasResults() const {
721 return !isa<ConstantTokenNone>(getArgOperand(TokenArg));
722 }
723
726 return cast<CoroEndResults>(getArgOperand(TokenArg));
727 }
728
729 // Methods to support type inquiry through isa, cast, and dyn_cast:
730 static bool classof(const IntrinsicInst *I) {
731 auto ID = I->getIntrinsicID();
732 return ID == Intrinsic::coro_end || ID == Intrinsic::coro_end_async;
733 }
734 static bool classof(const Value *V) {
736 }
737};
738
739/// This represents the llvm.coro.end instruction.
741public:
742 // Methods to support type inquiry through isa, cast, and dyn_cast:
743 static bool classof(const IntrinsicInst *I) {
744 return I->getIntrinsicID() == Intrinsic::coro_end;
745 }
746 static bool classof(const Value *V) {
748 }
749};
750
751/// This represents the llvm.coro.end instruction.
753 enum { FrameArg, UnwindArg, MustTailCallFuncArg };
754
755public:
756 LLVM_ABI void checkWellFormed() const;
757
759 if (arg_size() < 3)
760 return nullptr;
761
762 return cast<Function>(
763 getArgOperand(MustTailCallFuncArg)->stripPointerCasts());
764 }
765
766 // Methods to support type inquiry through isa, cast, and dyn_cast:
767 static bool classof(const IntrinsicInst *I) {
768 return I->getIntrinsicID() == Intrinsic::coro_end_async;
769 }
770 static bool classof(const Value *V) {
772 }
773};
774
775/// This represents the llvm.coro.alloca.alloc instruction.
777 enum { SizeArg, AlignArg };
778
779public:
780 Value *getSize() const { return getArgOperand(SizeArg); }
782 return cast<ConstantInt>(getArgOperand(AlignArg))->getAlignValue();
783 }
784
785 // Methods to support type inquiry through isa, cast, and dyn_cast:
786 static bool classof(const IntrinsicInst *I) {
787 return I->getIntrinsicID() == Intrinsic::coro_alloca_alloc;
788 }
789 static bool classof(const Value *V) {
791 }
792};
793
794/// This represents the llvm.coro.alloca.get instruction.
796 enum { AllocArg };
797
798public:
802
803 // Methods to support type inquiry through isa, cast, and dyn_cast:
804 static bool classof(const IntrinsicInst *I) {
805 return I->getIntrinsicID() == Intrinsic::coro_alloca_get;
806 }
807 static bool classof(const Value *V) {
809 }
810};
811
812/// This represents the llvm.coro.alloca.free instruction.
814 enum { AllocArg };
815
816public:
820
821 // Methods to support type inquiry through isa, cast, and dyn_cast:
822 static bool classof(const IntrinsicInst *I) {
823 return I->getIntrinsicID() == Intrinsic::coro_alloca_free;
824 }
825 static bool classof(const Value *V) {
827 }
828};
829
830} // End namespace llvm.
831
832#endif // LLVM_TRANSFORMS_COROUTINES_COROINSTR_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_ABI
Definition Compiler.h:215
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:1585
an instruction to allocate memory on the stack
bool isFallthrough() const
Definition CoroInstr.h:715
static bool classof(const Value *V)
Definition CoroInstr.h:734
bool hasResults() const
Definition CoroInstr.h:720
bool isUnwind() const
Definition CoroInstr.h:716
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:730
CoroEndResults * getResults() const
Definition CoroInstr.h:724
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:238
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:275
Value * getStorage() const
Definition CoroInstr.h:252
Align getStorageAlignment() const
Definition CoroInstr.h:248
Function * getPrototype() const
Return the prototype for the continuation function.
Definition CoroInstr.h:257
uint64_t getStorageSize() const
Definition CoroInstr.h:244
LLVM_ABI void checkWellFormed() const
Function * getAllocFunction() const
Return the function to use for allocating memory.
Definition CoroInstr.h:263
static bool classof(const Value *V)
Definition CoroInstr.h:280
Function * getDeallocFunction() const
Return the function to use for deallocating memory.
Definition CoroInstr.h:269
static bool classof(const Value *V)
Definition CoroInstr.h:555
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:550
CoroSaveInst * getCoroSave() const
Definition CoroInstr.h:586
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:584
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:671
static bool classof(const Value *V)
Definition CoroInstr.h:677
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:674
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:776
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:786
Align getAlignment() const
Definition CoroInstr.h:781
static bool classof(const Value *V)
Definition CoroInstr.h:789
Value * getSize() const
Definition CoroInstr.h:780
This represents the llvm.coro.alloca.free instruction.
Definition CoroInstr.h:813
static bool classof(const Value *V)
Definition CoroInstr.h:825
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:822
CoroAllocaAllocInst * getAlloc() const
Definition CoroInstr.h:817
This represents the llvm.coro.alloca.get instruction.
Definition CoroInstr.h:795
static bool classof(const Value *V)
Definition CoroInstr.h:807
CoroAllocaAllocInst * getAlloc() const
Definition CoroInstr.h:799
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:804
This represents the llvm.coro.context.alloc instruction.
Definition CoroInstr.h:361
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:371
static bool classof(const Value *V)
Definition CoroInstr.h:374
GlobalVariable * getAsyncFunctionPointer() const
Definition CoroInstr.h:365
This represents the llvm.coro.context.dealloc instruction.
Definition CoroInstr.h:380
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:389
static bool classof(const Value *V)
Definition CoroInstr.h:392
This represents the llvm.coro.end instruction.
Definition CoroInstr.h:752
Function * getMustTailCallFunction() const
Definition CoroInstr.h:758
LLVM_ABI void checkWellFormed() const
static bool classof(const Value *V)
Definition CoroInstr.h:770
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:767
This represents the llvm.coro.async.resume instruction.
Definition CoroInstr.h:400
static bool classof(const Value *V)
Definition CoroInstr.h:406
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:403
This represents the llvm.coro.async.size.replace instruction.
Definition CoroInstr.h:412
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:415
static bool classof(const Value *V)
Definition CoroInstr.h:418
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:479
AnyCoroIdInst * getId() const
Definition CoroInstr.h:483
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:498
static bool classof(const Value *V)
Definition CoroInstr.h:502
bool hasCustomABI() const
Definition CoroInstr.h:487
int getCustomABI() const
Definition CoroInstr.h:491
Value * getMem() const
Definition CoroInstr.h:495
This represents the llvm.coro.dead instruction.
Definition CoroInstr.h:464
Value * getFrame() const
Definition CoroInstr.h:466
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:469
static bool classof(const Value *V)
Definition CoroInstr.h:472
This represents the llvm.coro.end instruction.
Definition CoroInstr.h:740
static bool classof(const Value *V)
Definition CoroInstr.h:746
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:743
This represents the llvm.end.results instruction.
Definition CoroInstr.h:683
op_iterator retval_begin()
Definition CoroInstr.h:685
const_op_iterator retval_begin() const
Definition CoroInstr.h:686
iterator_range< const_op_iterator > return_values() const
Definition CoroInstr.h:694
iterator_range< op_iterator > return_values()
Definition CoroInstr.h:691
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:703
const_op_iterator retval_end() const
Definition CoroInstr.h:689
static bool classof(const Value *V)
Definition CoroInstr.h:706
op_iterator retval_end()
Definition CoroInstr.h:688
unsigned numReturns() const
Definition CoroInstr.h:698
This represents the llvm.coro.frame instruction.
Definition CoroInstr.h:424
static bool classof(const Value *V)
Definition CoroInstr.h:430
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:427
This represents the llvm.coro.free instruction.
Definition CoroInstr.h:448
Value * getFrame() const
Definition CoroInstr.h:452
static bool classof(const Value *V)
Definition CoroInstr.h:458
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:455
This represents the llvm.coro.id.async instruction.
Definition CoroInstr.h:310
Align getStorageAlignment() const
The alignment of the initial async function context.
Definition CoroInstr.h:324
uint64_t getStorageSize() const
The initial async function context size.
Definition CoroInstr.h:319
LLVM_ABI void checkWellFormed() const
GlobalVariable * getAsyncFunctionPointer() const
Return the async function pointer address.
Definition CoroInstr.h:344
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:350
Value * getStorage() const
The async context parameter.
Definition CoroInstr.h:329
unsigned getStorageArgumentIndex() const
Definition CoroInstr.h:333
static bool classof(const Value *V)
Definition CoroInstr.h:355
This represents the llvm.coro.id instruction.
Definition CoroInstr.h:148
static bool classof(const Value *V)
Definition CoroInstr.h:231
void setInfo(Constant *C)
Definition CoroInstr.h:215
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:228
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:221
void clearPromise()
Definition CoroInstr.h:159
This represents the llvm.coro.id.retcon instruction.
Definition CoroInstr.h:286
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:289
static bool classof(const Value *V)
Definition CoroInstr.h:292
This represents the llvm.coro.id.retcon.once instruction.
Definition CoroInstr.h:298
static bool classof(const Value *V)
Definition CoroInstr.h:304
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:301
This represents the llvm.coro.is_in_ramp instruction.
Definition CoroInstr.h:436
static bool classof(const Value *V)
Definition CoroInstr.h:442
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:439
This represents the llvm.coro.promise instruction.
Definition CoroInstr.h:520
static bool classof(const Value *V)
Definition CoroInstr.h:540
Align getAlignment() const
The required alignment of the promise.
Definition CoroInstr.h:532
bool isFromPromise() const
Are we translating from the frame to the promise (false) or from the promise to the frame (true)?
Definition CoroInstr.h:526
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:537
This represents the llvm.coro.save instruction.
Definition CoroInstr.h:508
static bool classof(const Value *V)
Definition CoroInstr.h:514
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:511
This represents the llvm.coro.size instruction.
Definition CoroInstr.h:659
static bool classof(const Value *V)
Definition CoroInstr.h:665
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:662
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:593
Function * getAsyncContextProjectionFunction() const
Definition CoroInstr.h:609
static bool classof(const Value *V)
Definition CoroInstr.h:628
unsigned getStorageArgumentIndex() const
Definition CoroInstr.h:604
LLVM_ABI void checkWellFormed() const
CoroAsyncResumeInst * getResumeFunction() const
Definition CoroInstr.h:614
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:625
Function * getMustTailCallFunction() const
Definition CoroInstr.h:619
This represents the llvm.coro.suspend instruction.
Definition CoroInstr.h:561
bool isFinal() const
Definition CoroInstr.h:573
CoroSaveInst * getCoroSave() const
Definition CoroInstr.h:565
static bool classof(const Value *V)
Definition CoroInstr.h:581
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:578
This represents the llvm.coro.suspend.retcon instruction.
Definition CoroInstr.h:634
static bool classof(const Value *V)
Definition CoroInstr.h:653
const_op_iterator value_begin() const
Definition CoroInstr.h:637
const_op_iterator value_end() const
Definition CoroInstr.h:640
iterator_range< const_op_iterator > value_operands() const
Definition CoroInstr.h:645
iterator_range< op_iterator > value_operands()
Definition CoroInstr.h:642
static bool classof(const IntrinsicInst *I)
Definition CoroInstr.h:650
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
LLVM_ABI const Value * stripPointerCastsAndAliases() const
Strip off pointer casts, all-zero GEPs, address space casts, and aliases.
Definition Value.cpp:717
LLVMContext & getContext() const
All values hold a context through their type.
Definition Value.h:258
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