llvm/llvm/include/llvm/Transforms/Coroutines/CoroInstr.h

//===-- CoroInstr.h - Coroutine Intrinsics Instruction Wrappers -*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// This file defines classes that make it really easy to deal with intrinsic
// functions with the isa/dyncast family of functions.  In particular, this
// allows you to do things like:
//
//     if (auto *SF = dyn_cast<CoroSubFnInst>(Inst))
//        ... SF->getFrame() ...
//
// All intrinsic function calls are instances of the call instruction, so these
// are all subclasses of the CallInst class.  Note that none of these classes
// has state or virtual methods, which is an important part of this gross/neat
// hack working.
//
// The helpful comment above is borrowed from llvm/IntrinsicInst.h, we keep
// coroutine intrinsic wrappers here since they are only used by the passes in
// the Coroutine library.
//===----------------------------------------------------------------------===//

#ifndef LLVM_TRANSFORMS_COROUTINES_COROINSTR_H
#define LLVM_TRANSFORMS_COROUTINES_COROINSTR_H

#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/Support/raw_ostream.h"

namespace llvm {

/// This class represents the llvm.coro.subfn.addr instruction.
class CoroSubFnInst : public IntrinsicInst {};

/// This represents the llvm.coro.alloc instruction.
class CoroAllocInst : public IntrinsicInst {};

/// This represents the llvm.coro.await.suspend.{void,bool,handle} instructions.
// FIXME: add callback metadata
// FIXME: make a proper IntrinisicInst. Currently this is not possible,
// because llvm.coro.await.suspend.* can be invoked.
class CoroAwaitSuspendInst : public CallBase {};

/// This represents a common base class for llvm.coro.id instructions.
class AnyCoroIdInst : public IntrinsicInst {};

/// This represents the llvm.coro.id instruction.
class CoroIdInst : public AnyCoroIdInst {};

/// This represents either the llvm.coro.id.retcon or
/// llvm.coro.id.retcon.once instruction.
class AnyCoroIdRetconInst : public AnyCoroIdInst {};

/// This represents the llvm.coro.id.retcon instruction.
class CoroIdRetconInst : public AnyCoroIdRetconInst {};

/// This represents the llvm.coro.id.retcon.once instruction.
class CoroIdRetconOnceInst : public AnyCoroIdRetconInst {};

/// This represents the llvm.coro.id.async instruction.
class CoroIdAsyncInst : public AnyCoroIdInst {};

/// This represents the llvm.coro.context.alloc instruction.
class CoroAsyncContextAllocInst : public IntrinsicInst {};

/// This represents the llvm.coro.context.dealloc instruction.
class CoroAsyncContextDeallocInst : public IntrinsicInst {};

/// This represents the llvm.coro.async.resume instruction.
/// During lowering this is replaced by the resume function of a suspend point
/// (the continuation function).
class CoroAsyncResumeInst : public IntrinsicInst {};

/// This represents the llvm.coro.async.size.replace instruction.
class CoroAsyncSizeReplace : public IntrinsicInst {};

/// This represents the llvm.coro.frame instruction.
class CoroFrameInst : public IntrinsicInst {};

/// This represents the llvm.coro.free instruction.
class CoroFreeInst : public IntrinsicInst {};

/// This class represents the llvm.coro.begin or llvm.coro.begin.custom.abi
/// instructions.
class CoroBeginInst : public IntrinsicInst {};

/// This represents the llvm.coro.save instruction.
class CoroSaveInst : public IntrinsicInst {};

/// This represents the llvm.coro.promise instruction.
class CoroPromiseInst : public IntrinsicInst {};

class AnyCoroSuspendInst : public IntrinsicInst {};

/// This represents the llvm.coro.suspend instruction.
class CoroSuspendInst : public AnyCoroSuspendInst {};

inline CoroSaveInst *AnyCoroSuspendInst::getCoroSave() const {}

/// This represents the llvm.coro.suspend.async instruction.
class CoroSuspendAsyncInst : public AnyCoroSuspendInst {};

/// This represents the llvm.coro.suspend.retcon instruction.
class CoroSuspendRetconInst : public AnyCoroSuspendInst {};

/// This represents the llvm.coro.size instruction.
class CoroSizeInst : public IntrinsicInst {};

/// This represents the llvm.coro.align instruction.
class CoroAlignInst : public IntrinsicInst {};

/// This represents the llvm.end.results instruction.
class CoroEndResults : public IntrinsicInst {};

class AnyCoroEndInst : public IntrinsicInst {};

/// This represents the llvm.coro.end instruction.
class CoroEndInst : public AnyCoroEndInst {};

/// This represents the llvm.coro.end instruction.
class CoroAsyncEndInst : public AnyCoroEndInst {};

/// This represents the llvm.coro.alloca.alloc instruction.
class CoroAllocaAllocInst : public IntrinsicInst {};

/// This represents the llvm.coro.alloca.get instruction.
class CoroAllocaGetInst : public IntrinsicInst {};

/// This represents the llvm.coro.alloca.free instruction.
class CoroAllocaFreeInst : public IntrinsicInst {};

} // End namespace llvm.

#endif // LLVM_TRANSFORMS_COROUTINES_COROINSTR_H