11#ifndef LLVM_LIB_TRANSFORMS_COROUTINES_COROINTERNAL_H
12#define LLVM_LIB_TRANSFORMS_COROUTINES_COROINTERNAL_H
26 const std::initializer_list<StringRef>);
156 return cast<CoroIdInst>(CoroBegin->
getId());
161 ABI == coro::ABI::RetconOnce);
162 return cast<AnyCoroIdRetconInst>(CoroBegin->
getId());
167 return cast<CoroIdAsyncInst>(CoroBegin->
getId());
172 assert(FrameTy &&
"frame type not assigned");
173 return SwitchLowering.IndexField;
177 assert(FrameTy &&
"frame type not assigned");
178 return cast<IntegerType>(FrameTy->
getElementType(getSwitchIndexField()));
181 return ConstantInt::get(getIndexType(),
Value);
186 assert(FrameTy &&
"frame type not assigned");
187 return cast<PointerType>(FrameTy->
getElementType(SwitchFieldIndex::Resume));
192 case coro::ABI::Switch:
193 return FunctionType::get(Type::getVoidTy(FrameTy->
getContext()),
194 PointerType::getUnqual(FrameTy->
getContext()),
196 case coro::ABI::Retcon:
197 case coro::ABI::RetconOnce:
198 return RetconLowering.ResumePrototype->getFunctionType();
199 case coro::ABI::Async:
209 ABI == coro::ABI::RetconOnce);
213 if (
auto STy = dyn_cast<StructType>(FTy->getReturnType())) {
214 return STy->elements().slice(1);
222 ABI == coro::ABI::RetconOnce);
225 auto FTy = RetconLowering.ResumePrototype->getFunctionType();
226 return FTy->params().slice(1);
231 case coro::ABI::Switch:
232 return CallingConv::Fast;
234 case coro::ABI::Retcon:
235 case coro::ABI::RetconOnce:
236 return RetconLowering.ResumePrototype->getCallingConv();
237 case coro::ABI::Async:
238 return AsyncLowering.AsyncCC;
244 if (
ABI == coro::ABI::Switch)
245 return SwitchLowering.PromiseAlloca;
250 if (
auto *
I = dyn_cast<Instruction>(
FramePtr)) {
255 return cast<Argument>(
FramePtr)->getParent()->getEntryBlock().begin();
270 : OptimizeFrame(OptimizeFrame) {
279 const std::function<
bool(
Instruction &)> &MaterializableCallback);
AMDGPU Lower Kernel Arguments
#define LLVM_LIBRARY_VISIBILITY
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.
InstListType::iterator iterator
Instruction iterators...
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.
Record of a variable value-assignment, aka a non instruction representation of the dbg....
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
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.
void salvageDebugInfo(SmallDenseMap< Argument *, AllocaInst *, 4 > &ArgToAllocaMap, DbgVariableIntrinsic &DVI, bool IsEntryPoint)
Attempts to rewrite the location operand of debug intrinsics in terms of the coroutine frame pointer,...
@ 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...
bool defaultMaterializable(Instruction &V)
Default materializable callback.
bool declaresAnyIntrinsic(const Module &M)
bool declaresIntrinsics(const Module &M, const std::initializer_list< StringRef >)
void buildCoroutineFrame(Function &F, Shape &Shape, TargetTransformInfo &TTI, const std::function< bool(Instruction &)> &MaterializableCallback)
CallInst * createMustTailCall(DebugLoc Loc, Function *MustTailCallFn, TargetTransformInfo &TTI, ArrayRef< Value * > Arguments, IRBuilder<> &)
void replaceCoroFree(CoroIdInst *CoroId, bool Elide)
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
CallInst * makeSubFnCall(Value *Arg, int Index, Instruction *InsertPt)
FunctionType *const ResumeFnType
GlobalVariable * AsyncFuncPointer
Align getContextAlignment() const
uint64_t ContextHeaderSize
uint64_t ContextAlignment
bool IsFrameInlineInStorage
Function * ResumePrototype
AllocaInst * PromiseAlloca
SwitchInst * ResumeSwitch
BasicBlock * ResumeEntryBlock
SmallVector< CallInst *, 2 > SymmetricTransfers
SmallVector< CoroAwaitSuspendInst *, 4 > CoroAwaitSuspends
AsyncLoweringStorage AsyncLowering
FunctionType * getResumeFunctionType() const
IntegerType * getIndexType() const
AnyCoroIdRetconInst * getRetconCoroId() const
PointerType * getSwitchResumePointerType() const
CoroIdInst * getSwitchCoroId() 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
BasicBlock::iterator getInsertPtAfterFramePtr() const
ArrayRef< Type * > getRetconResultTypes() const
RetconLoweringStorage RetconLowering
SmallVector< CoroAlignInst *, 2 > CoroAligns
CoroIdAsyncInst * getAsyncCoroId() const
SmallVector< AnyCoroEndInst *, 4 > CoroEnds
BasicBlock * AllocaSpillBlock
unsigned getSwitchIndexField() const