11#ifndef LLVM_LIB_TRANSFORMS_COROUTINES_COROINTERNAL_H
12#define LLVM_LIB_TRANSFORMS_COROUTINES_COROINTERNAL_H
25 const std::initializer_list<StringRef>);
150 return cast<CoroIdInst>(CoroBegin->
getId());
155 ABI == coro::ABI::RetconOnce);
156 return cast<AnyCoroIdRetconInst>(CoroBegin->
getId());
161 return cast<CoroIdAsyncInst>(CoroBegin->
getId());
166 assert(FrameTy &&
"frame type not assigned");
167 return SwitchLowering.IndexField;
171 assert(FrameTy &&
"frame type not assigned");
172 return cast<IntegerType>(FrameTy->
getElementType(getSwitchIndexField()));
175 return ConstantInt::get(getIndexType(),
Value);
180 assert(FrameTy &&
"frame type not assigned");
181 return cast<PointerType>(FrameTy->
getElementType(SwitchFieldIndex::Resume));
186 case coro::ABI::Switch:
187 return FunctionType::get(Type::getVoidTy(FrameTy->
getContext()),
189 case coro::ABI::Retcon:
190 case coro::ABI::RetconOnce:
191 return RetconLowering.ResumePrototype->getFunctionType();
192 case coro::ABI::Async:
202 ABI == coro::ABI::RetconOnce);
206 if (
auto STy = dyn_cast<StructType>(FTy->getReturnType())) {
207 return STy->elements().slice(1);
215 ABI == coro::ABI::RetconOnce);
218 auto FTy = RetconLowering.ResumePrototype->getFunctionType();
219 return FTy->params().slice(1);
224 case coro::ABI::Switch:
225 return CallingConv::Fast;
227 case coro::ABI::Retcon:
228 case coro::ABI::RetconOnce:
229 return RetconLowering.ResumePrototype->getCallingConv();
230 case coro::ABI::Async:
231 return AsyncLowering.AsyncCC;
237 if (
ABI == coro::ABI::Switch)
238 return SwitchLowering.PromiseAlloca;
243 if (
auto *
I = dyn_cast<Instruction>(
FramePtr))
244 return I->getNextNode();
245 return &cast<Argument>(
FramePtr)->getParent()->getEntryBlock().front();
260 : OptimizeFrame(OptimizeFrame) {
269 const std::function<
bool(
Instruction &)> &MaterializableCallback);
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.
void salvageDebugInfo(SmallDenseMap< Argument *, AllocaInst *, 4 > &ArgToAllocaMap, DbgVariableIntrinsic *DVI, bool OptimizeFrame)
Attempts to rewrite the location operand of debug intrinsics in terms of the coroutine frame pointer,...
void buildCoroutineFrame(Function &F, Shape &Shape, const std::function< bool(Instruction &)> &MaterializableCallback)
@ 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 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
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