Files
swift-mirror/include/swift/AST/SILThunkKind.h
Konrad `ktoso` Malawski 8c4dea9802 Revert "[concurrency] Add support for HopToMainActorIfNeededThunk." (#79938)
* Revert "[concurrency] Add support for HopToMainActorIfNeededThunk."

This reverts commit 0e0665bfbd.

* remove some last bits of 0e0665b
2025-03-13 06:48:03 +09:00

78 lines
2.4 KiB
C++

//===--- SILThunkKind.h ---------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2024 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
///
/// \file This file contains a kind that defines the types of thunks that can be
/// generated using a thunk inst. It provides an AST level interface that lets
/// one generate the derived function kind and is also used to make adding such
/// kinds to the mangler trivial.
///
//===----------------------------------------------------------------------===//
#ifndef SWIFT_AST_SILTHUNKKIND_H
#define SWIFT_AST_SILTHUNKKIND_H
#include "swift/AST/Types.h"
namespace swift {
class SILType;
struct SILThunkKind {
enum InnerTy {
Invalid = 0,
/// A thunk that just calls the passed in function. Used for testing
/// purposes of the underlying thunking machinery.
Identity = 1,
MaxValue = Identity,
};
InnerTy innerTy;
SILThunkKind() : innerTy(InnerTy::Invalid) {}
SILThunkKind(InnerTy innerTy) : innerTy(innerTy) {}
SILThunkKind(unsigned inputInnerTy) : innerTy(InnerTy(inputInnerTy)) {
assert(inputInnerTy <= MaxValue && "Invalid value");
}
operator InnerTy() const { return innerTy; }
/// Given the current enum state returned the derived output function from
/// \p inputFunction.
///
/// Defined in Instructions.cpp
CanSILFunctionType getDerivedFunctionType(SILFunction *fn,
CanSILFunctionType inputFunction,
SubstitutionMap subMap) const;
/// Given the current enum state returned the derived output function from
/// \p inputFunction.
///
/// Defined in Instructions.cpp
SILType getDerivedFunctionType(SILFunction *fn, SILType inputFunctionType,
SubstitutionMap subMap) const;
Demangle::MangledSILThunkKind getMangledKind() const {
switch (innerTy) {
case Invalid:
return Demangle::MangledSILThunkKind::Invalid;
case Identity:
return Demangle::MangledSILThunkKind::Identity;
}
}
};
} // namespace swift
#endif