mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
unconditional_dynamic_cast_addr instruction. Also, fix some major semantic problems with the existing specialization of unconditional dynamic casts by handling optional types and being much more conservative about deciding that a cast is infeasible. This commit regresses specialization slightly by failing to turn indirect dynamic casts into scalar ones when possible; we can fix that easily enough in a follow-up. Swift SVN r19044
64 lines
2.1 KiB
C++
64 lines
2.1 KiB
C++
//===--- DynamicsCasts.h - SIL dynamic-cast utilities -----------*- C++ -*-===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See http://swift.org/LICENSE.txt for license information
|
|
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file provides basic utilities for working with subtyping
|
|
// relationships.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef SWIFT_SIL_SUBTYPING_H
|
|
#define SWIFT_SIL_SUBTYPING_H
|
|
|
|
namespace swift {
|
|
|
|
class CanType;
|
|
class Module;
|
|
class SILBuilder;
|
|
class SILLocation;
|
|
class SILValue;
|
|
class SILType;
|
|
enum class CastConsumptionKind : unsigned char;
|
|
|
|
enum class DynamicCastFeasibility {
|
|
/// The cast will always succeed.
|
|
WillSucceed,
|
|
|
|
/// The cast can succeed for some values.
|
|
MaySucceed,
|
|
|
|
/// The cast cannot succeed.
|
|
WillFail,
|
|
};
|
|
|
|
/// Classify the feasibility of a dynamic cast. The source and target
|
|
/// types should be unlowered formal types.
|
|
DynamicCastFeasibility classifyDynamicCast(Module *context,
|
|
CanType sourceType,
|
|
CanType targetType);
|
|
|
|
SILValue emitSuccessfulScalarUnconditionalCast(SILBuilder &B, Module *M,
|
|
SILLocation loc, SILValue value,
|
|
SILType loweredTargetType,
|
|
CanType formalSourceType,
|
|
CanType formalTargetType);
|
|
|
|
void emitSuccessfulIndirectUnconditionalCast(SILBuilder &B, Module *M,
|
|
SILLocation loc,
|
|
CastConsumptionKind consumption,
|
|
SILValue src, CanType sourceType,
|
|
SILValue dest, CanType targetType);
|
|
|
|
} // end namespace swift
|
|
|
|
#endif
|
|
|