brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.5 KiB · cc47a55 Raw
63 lines · c
1//===- CoroInternal.h - Internal Coroutine interfaces ---------*- 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-exception6//7//===----------------------------------------------------------------------===//8// Common definitions/declarations used internally by coroutine lowering passes.9//===----------------------------------------------------------------------===//10 11#ifndef LLVM_LIB_TRANSFORMS_COROUTINES_COROINTERNAL_H12#define LLVM_LIB_TRANSFORMS_COROUTINES_COROINTERNAL_H13 14#include "llvm/Analysis/TargetTransformInfo.h"15#include "llvm/IR/IRBuilder.h"16#include "llvm/Transforms/Coroutines/CoroInstr.h"17#include "llvm/Transforms/Coroutines/CoroShape.h"18 19namespace llvm::coro {20 21bool isSuspendBlock(BasicBlock *BB);22bool declaresAnyIntrinsic(const Module &M);23bool declaresIntrinsics(const Module &M, ArrayRef<Intrinsic::ID> List);24void replaceCoroFree(CoroIdInst *CoroId, bool Elide);25 26/// Replaces all @llvm.coro.alloc intrinsics calls associated with a given27/// call @llvm.coro.id instruction with boolean value false.28void suppressCoroAllocs(CoroIdInst *CoroId);29/// Replaces CoroAllocs with boolean value false.30void suppressCoroAllocs(LLVMContext &Context,31                        ArrayRef<CoroAllocInst *> CoroAllocs);32 33/// Attempts to rewrite the location operand of debug records in terms of34/// the coroutine frame pointer, folding pointer offsets into the DIExpression35/// of the intrinsic.36/// If the frame pointer is an Argument, store it into an alloca to enhance the37/// debugability.38void salvageDebugInfo(39    SmallDenseMap<Argument *, AllocaInst *, 4> &ArgToAllocaMap,40    DbgVariableRecord &DVR, bool UseEntryValue);41 42// Keeps data and helper functions for lowering coroutine intrinsics.43struct LowererBase {44  Module &TheModule;45  LLVMContext &Context;46  PointerType *const Int8Ptr;47  FunctionType *const ResumeFnType;48  ConstantPointerNull *const NullPtr;49 50  LowererBase(Module &M);51  CallInst *makeSubFnCall(Value *Arg, int Index, Instruction *InsertPt);52};53 54bool defaultMaterializable(Instruction &V);55void normalizeCoroutine(Function &F, coro::Shape &Shape,56                        TargetTransformInfo &TTI);57CallInst *createMustTailCall(DebugLoc Loc, Function *MustTailCallFn,58                             TargetTransformInfo &TTI,59                             ArrayRef<Value *> Arguments, IRBuilder<> &);60} // End namespace llvm::coro61 62#endif63