11#ifndef LLVM_LIB_TRANSFORMS_COROUTINES_COROINTERNAL_H
12#define LLVM_LIB_TRANSFORMS_COROUTINES_COROINTERNAL_H
25 const std::initializer_list<StringRef>);
148 return cast<CoroIdInst>(CoroBegin->
getId());
153 ABI == coro::ABI::RetconOnce);
154 return cast<AnyCoroIdRetconInst>(CoroBegin->
getId());
159 return cast<CoroIdAsyncInst>(CoroBegin->
getId());
164 assert(FrameTy &&
"frame type not assigned");
165 return SwitchLowering.IndexField;
169 assert(FrameTy &&
"frame type not assigned");
170 return cast<IntegerType>(FrameTy->
getElementType(getSwitchIndexField()));
173 return ConstantInt::get(getIndexType(),
Value);
178 assert(FrameTy &&
"frame type not assigned");
179 return cast<PointerType>(FrameTy->
getElementType(SwitchFieldIndex::Resume));
184 case coro::ABI::Switch:
185 return FunctionType::get(Type::getVoidTy(FrameTy->
getContext()),
187 case coro::ABI::Retcon:
188 case coro::ABI::RetconOnce:
189 return RetconLowering.ResumePrototype->getFunctionType();
190 case coro::ABI::Async:
200 ABI == coro::ABI::RetconOnce);
204 if (
auto STy = dyn_cast<StructType>(FTy->getReturnType())) {
205 return STy->elements().slice(1);
213 ABI == coro::ABI::RetconOnce);
216 auto FTy = RetconLowering.ResumePrototype->getFunctionType();
217 return FTy->params().slice(1);
222 case coro::ABI::Switch:
223 return CallingConv::Fast;
225 case coro::ABI::Retcon:
226 case coro::ABI::RetconOnce:
227 return RetconLowering.ResumePrototype->getCallingConv();
228 case coro::ABI::Async:
229 return AsyncLowering.AsyncCC;
235 if (
ABI == coro::ABI::Switch)
236 return SwitchLowering.PromiseAlloca;
241 if (
auto *
I = dyn_cast<Instruction>(
FramePtr))
242 return I->getNextNode();
243 return &cast<Argument>(
FramePtr)->getParent()->getEntryBlock().front();
258 : OptimizeFrame(OptimizeFrame) {
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
AMDGPU Lower Kernel Arguments
#define LLVM_LIBRARY_VISIBILITY
LLVM_LIBRARY_VISIBILITY - If a class marked with this attribute is linked into a shared library,...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static const unsigned FramePtr
an instruction to allocate memory on the stack
This represents either the llvm.coro.id.retcon or llvm.coro.id.retcon.once instruction.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
LLVM Basic Block Representation.
The basic data container for the call graph of a Module of IR.
This class represents a function call, abstracting a target machine's calling convention.
This is the shared class of boolean and integer constants.
A constant pointer value that points to null.
This class represents the llvm.coro.begin instruction.
AnyCoroIdInst * getId() const
This represents the llvm.coro.id.async instruction.
This represents the llvm.coro.id instruction.
This is the common base class for debug info intrinsics for variables.
Class to represent function types.
FunctionType * getFunctionType() const
Returns the FunctionType for me.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
const Function * getFunction() const
Return the function this instruction belongs to.
Class to represent integer types.
This is an important class for using LLVM in a threaded context.
A Module instance is used to store all the information related to an LLVM module.
Class to represent pointers.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Class to represent struct types.
Type * getElementType(unsigned N) const
PointerType * getPointerTo(unsigned AddrSpace=0) const
Return a pointer to the current type.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
LLVM Value Representation.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ Async
The "async continuation" lowering, where each suspend point creates a single continuation function.
@ RetconOnce
The "unique returned-continuation" lowering, where each suspend point creates a single continuation f...
@ Retcon
The "returned-continuation" lowering, where each suspend point creates a single continuation function...
@ Switch
The "resume-switch" lowering, where there are separate resume and destroy functions that are shared b...
void salvageDebugInfo(SmallDenseMap< llvm::Value *, llvm::AllocaInst *, 4 > &DbgPtrAllocaCache, DbgVariableIntrinsic *DVI, bool OptimizeFrame)
Recover a dbg.declare prepared by the frontend and emit an alloca holding a pointer to the coroutine ...
void buildCoroutineFrame(Function &F, Shape &Shape)
bool declaresAnyIntrinsic(const Module &M)
bool declaresIntrinsics(const Module &M, const std::initializer_list< StringRef >)
void replaceCoroFree(CoroIdInst *CoroId, bool Elide)
CallInst * createMustTailCall(DebugLoc Loc, Function *MustTailCallFn, ArrayRef< Value * > Arguments, IRBuilder<> &)
This is an optimization pass for GlobalISel generic memory operations.
This struct is a compact representation of a valid (non-zero power of two) alignment.
PointerType *const Int8Ptr
ConstantPointerNull *const NullPtr
Value * makeSubFnCall(Value *Arg, int Index, Instruction *InsertPt)
FunctionType *const ResumeFnType
GlobalVariable * AsyncFuncPointer
Align getContextAlignment() const
uint64_t ContextHeaderSize
uint64_t ContextAlignment
FunctionType * AsyncFuncTy
bool IsFrameInlineInStorage
Function * ResumePrototype
AllocaInst * PromiseAlloca
SwitchInst * ResumeSwitch
BasicBlock * ResumeEntryBlock
AsyncLoweringStorage AsyncLowering
FunctionType * getResumeFunctionType() const
IntegerType * getIndexType() const
AnyCoroIdRetconInst * getRetconCoroId() const
PointerType * getSwitchResumePointerType() const
CoroIdInst * getSwitchCoroId() const
Instruction * getInsertPtAfterFramePtr() const
SmallVector< CoroSizeInst *, 2 > CoroSizes
CallingConv::ID getResumeFunctionCC() const
ArrayRef< Type * > getRetconResumeTypes() const
SmallVector< AnyCoroSuspendInst *, 4 > CoroSuspends
Shape(Function &F, bool OptimizeFrame=false)
SmallVector< CallInst *, 2 > SwiftErrorOps
ConstantInt * getIndex(uint64_t Value) const
AllocaInst * getPromiseAlloca() const
bool OptimizeFrame
This would only be true if optimization are enabled.
SwitchLoweringStorage SwitchLowering
CoroBeginInst * CoroBegin
ArrayRef< Type * > getRetconResultTypes() const
RetconLoweringStorage RetconLowering
SmallVector< CoroAlignInst *, 2 > CoroAligns
CoroIdAsyncInst * getAsyncCoroId() const
SmallVector< AnyCoroEndInst *, 4 > CoroEnds
BasicBlock * AllocaSpillBlock
unsigned getSwitchIndexField() const