mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Fix up all of type-checking, SILGen, IRGen, and the runtime to support checked casts of metatypes. <rdar://problem/16847453> Swift SVN r17719
602 lines
24 KiB
C++
602 lines
24 KiB
C++
//===-- RuntimeFunctions.def - Runtime Functions Database -------*- 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 defines x-macros used for metaprogramming with the set of
|
|
// runtime functions.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// FUNCTION(Id, Name, ReturnTys, ArgTys, CC, Attrs)
|
|
/// Makes available as "Id" the following runtime function:
|
|
/// ReturnTy Name(ArgsTys...);
|
|
/// ReturnTys is a call to RETURNS, which takes a non-empty list
|
|
/// of expressions meant to be looked up in IRGenModule.
|
|
/// ArgTys is either NO_ARGS or a call to ARGS, which takes a non-empty
|
|
/// list of expressions meant to be looked up in IRGenModule.
|
|
/// Attrs is a parenthesized list of attributes.
|
|
///
|
|
/// By default, passes Id to FUNCTION_ID. Therefore, the valid uses of
|
|
/// this database define either:
|
|
/// FUNCTION_ID
|
|
/// or all of the following:
|
|
/// FUNCTION
|
|
/// RETURNS
|
|
/// ARGS
|
|
/// NO_ARGS
|
|
/// ATTRS
|
|
/// NO_ATTRS
|
|
#ifndef FUNCTION
|
|
#define FUNCTION(Id, Name, ReturnTys, ArgTys, CC, Attrs) FUNCTION_ID(Id)
|
|
#endif
|
|
|
|
// struct { RefCounted *box; void *value; } swift_allocBox(Metadata *type);
|
|
FUNCTION(AllocBox, swift_allocBox, RuntimeCC,
|
|
RETURNS(RefCountedPtrTy, OpaquePtrTy),
|
|
ARGS(TypeMetadataPtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// RefCounted *swift_allocObject(Metadata *type, size_t size, size_t align);
|
|
FUNCTION(AllocObject, swift_allocObject, RuntimeCC,
|
|
RETURNS(RefCountedPtrTy),
|
|
ARGS(TypeMetadataPtrTy, SizeTy, SizeTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void swift_deallocObject(RefCounted *obj, size_t size);
|
|
FUNCTION(DeallocObject, swift_deallocObject, RuntimeCC,
|
|
RETURNS(VoidTy),
|
|
ARGS(RefCountedPtrTy, SizeTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void *swift_alloc(SwiftAllocIndex index);
|
|
FUNCTION(Alloc, swift_alloc, RuntimeCC,
|
|
RETURNS(Int8PtrTy),
|
|
ARGS(SizeTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void swift_dealloc(void *ptr, SwiftAllocIndex index);
|
|
FUNCTION(Dealloc, swift_dealloc, RuntimeCC,
|
|
RETURNS(VoidTy),
|
|
ARGS(Int8PtrTy, SizeTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void *swift_slowAlloc(size_t size, size_t flags);
|
|
FUNCTION(SlowAlloc, swift_slowAlloc, RuntimeCC,
|
|
RETURNS(Int8PtrTy),
|
|
ARGS(SizeTy, SizeTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void swift_slowDealloc(void *ptr, size_t size);
|
|
FUNCTION(SlowDealloc, swift_slowDealloc,RuntimeCC,
|
|
RETURNS(VoidTy),
|
|
ARGS(Int8PtrTy, SizeTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void *swift_copyPOD(void *dest, void *src, Metadata *self);
|
|
FUNCTION(CopyPOD, swift_copyPOD, RuntimeCC,
|
|
RETURNS(OpaquePtrTy),
|
|
ARGS(OpaquePtrTy, OpaquePtrTy, TypeMetadataPtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void swift_retain_noresult(void *ptr);
|
|
FUNCTION(RetainNoResult, swift_retain_noresult,RuntimeCC,
|
|
RETURNS(VoidTy),
|
|
ARGS(RefCountedPtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void swift_release(void *ptr);
|
|
FUNCTION(Release, swift_release, RuntimeCC,
|
|
RETURNS(VoidTy),
|
|
ARGS(RefCountedPtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void swift_retainUnowned(void *ptr);
|
|
FUNCTION(RetainUnowned, swift_retainUnowned, RuntimeCC,
|
|
RETURNS(VoidTy),
|
|
ARGS(RefCountedPtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void swift_weakRetain(void *ptr);
|
|
FUNCTION(UnownedRetain, swift_weakRetain, RuntimeCC,
|
|
RETURNS(VoidTy),
|
|
ARGS(RefCountedPtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void swift_weakRelease(void *ptr);
|
|
FUNCTION(UnownedRelease, swift_weakRelease,RuntimeCC,
|
|
RETURNS(VoidTy),
|
|
ARGS(RefCountedPtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void swift_weakDestroy(WeakReference *object);
|
|
FUNCTION(WeakDestroy, swift_weakDestroy, RuntimeCC,
|
|
RETURNS(VoidTy),
|
|
ARGS(WeakReferencePtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void swift_weakInit(WeakReference *object, void *value);
|
|
FUNCTION(WeakInit, swift_weakInit, RuntimeCC,
|
|
RETURNS(VoidTy),
|
|
ARGS(WeakReferencePtrTy, RefCountedPtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void swift_weakAssign(WeakReference *object, void *value);
|
|
FUNCTION(WeakAssign, swift_weakAssign, RuntimeCC,
|
|
RETURNS(VoidTy),
|
|
ARGS(WeakReferencePtrTy, RefCountedPtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void *swift_weakLoadStrong(WeakReference *object);
|
|
FUNCTION(WeakLoadStrong, swift_weakLoadStrong,RuntimeCC,
|
|
RETURNS(RefCountedPtrTy),
|
|
ARGS(WeakReferencePtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void *swift_weakTakeStrong(WeakReference *object);
|
|
FUNCTION(WeakTakeStrong, swift_weakTakeStrong,RuntimeCC,
|
|
RETURNS(RefCountedPtrTy),
|
|
ARGS(WeakReferencePtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void swift_weakCopyInit(WeakReference *dest, WeakReference *src);
|
|
FUNCTION(WeakCopyInit, swift_weakCopyInit, RuntimeCC,
|
|
RETURNS(VoidTy),
|
|
ARGS(WeakReferencePtrTy, WeakReferencePtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void swift_weakTakeInit(WeakReference *dest, WeakReference *src);
|
|
FUNCTION(WeakTakeInit, swift_weakTakeInit, RuntimeCC,
|
|
RETURNS(VoidTy),
|
|
ARGS(WeakReferencePtrTy, WeakReferencePtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void swift_weakCopyAssign(WeakReference *dest, WeakReference *src);
|
|
FUNCTION(WeakCopyAssign, swift_weakCopyAssign,RuntimeCC,
|
|
RETURNS(VoidTy),
|
|
ARGS(WeakReferencePtrTy, WeakReferencePtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void swift_weakTakeAssign(WeakReference *dest, WeakReference *src);
|
|
FUNCTION(WeakTakeAssign, swift_weakTakeAssign,RuntimeCC,
|
|
RETURNS(VoidTy),
|
|
ARGS(WeakReferencePtrTy, WeakReferencePtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void swift_unknownRetainUnowned(void *ptr);
|
|
FUNCTION(UnknownRetainUnowned, swift_unknownRetainUnowned, RuntimeCC,
|
|
RETURNS(VoidTy),
|
|
ARGS(RefCountedPtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void swift_unknownWeakRetain(void *value);
|
|
FUNCTION(UnknownUnownedRetain, swift_unknownWeakRetain, RuntimeCC,
|
|
RETURNS(VoidTy),
|
|
ARGS(RefCountedPtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void swift_unknownWeakRelease(void *value);
|
|
FUNCTION(UnknownUnownedRelease, swift_unknownWeakRelease, RuntimeCC,
|
|
RETURNS(VoidTy),
|
|
ARGS(RefCountedPtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void swift_unknownWeakDestroy(WeakReference *object);
|
|
FUNCTION(UnknownWeakDestroy, swift_unknownWeakDestroy, RuntimeCC,
|
|
RETURNS(VoidTy),
|
|
ARGS(WeakReferencePtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void swift_unknownWeakInit(WeakReference *object, void *value);
|
|
FUNCTION(UnknownWeakInit, swift_unknownWeakInit, RuntimeCC,
|
|
RETURNS(VoidTy),
|
|
ARGS(WeakReferencePtrTy, UnknownRefCountedPtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void swift_unknownWeakAssign(WeakReference *object, void *value);
|
|
FUNCTION(UnknownWeakAssign, swift_unknownWeakAssign, RuntimeCC,
|
|
RETURNS(VoidTy),
|
|
ARGS(WeakReferencePtrTy, UnknownRefCountedPtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void *swift_unknownWeakLoad(WeakReference *object);
|
|
FUNCTION(UnknownWeakLoadStrong, swift_unknownWeakLoadStrong,RuntimeCC,
|
|
RETURNS(UnknownRefCountedPtrTy),
|
|
ARGS(WeakReferencePtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void *swift_unknownWeakTake(WeakReference *object);
|
|
FUNCTION(UnknownWeakTakeStrong, swift_unknownWeakTakeStrong,RuntimeCC,
|
|
RETURNS(UnknownRefCountedPtrTy),
|
|
ARGS(WeakReferencePtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void swift_unknownWeakCopyInit(WeakReference *dest, WeakReference *src);
|
|
FUNCTION(UnknownWeakCopyInit, swift_unknownWeakCopyInit, RuntimeCC,
|
|
RETURNS(VoidTy),
|
|
ARGS(WeakReferencePtrTy, WeakReferencePtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void swift_unknownWeakTakeInit(WeakReference *dest, WeakReference *src);
|
|
FUNCTION(UnknownWeakTakeInit, swift_unknownWeakTakeInit, RuntimeCC,
|
|
RETURNS(VoidTy),
|
|
ARGS(WeakReferencePtrTy, WeakReferencePtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void swift_unknownWeakCopyAssign(WeakReference *dest, WeakReference *src);
|
|
FUNCTION(UnknownWeakCopyAssign, swift_unknownWeakCopyAssign,RuntimeCC,
|
|
RETURNS(VoidTy),
|
|
ARGS(WeakReferencePtrTy, WeakReferencePtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void swift_unknownWeakTakeAssign(WeakReference *dest, WeakReference *src);
|
|
FUNCTION(UnknownWeakTakeAssign, swift_unknownWeakTakeAssign,RuntimeCC,
|
|
RETURNS(VoidTy),
|
|
ARGS(WeakReferencePtrTy, WeakReferencePtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// type_metadata_t *swift_getFunctionTypeMetadata(type_metadata_t *arg,
|
|
// type_metadata_t *result);
|
|
FUNCTION(GetFunctionMetadata, swift_getFunctionTypeMetadata, RuntimeCC,
|
|
RETURNS(TypeMetadataPtrTy),
|
|
ARGS(TypeMetadataPtrTy, TypeMetadataPtrTy),
|
|
ATTRS(NoUnwind, ReadNone))
|
|
|
|
// type_metadata_t *swift_getForeignTypeMetadata(type_metadata_t *nonUnique);
|
|
FUNCTION(GetForeignTypeMetadata, swift_getForeignTypeMetadata, RuntimeCC,
|
|
RETURNS(TypeMetadataPtrTy),
|
|
ARGS(TypeMetadataPtrTy),
|
|
ATTRS(NoUnwind, ReadNone)) // only writes to runtime-private fields
|
|
|
|
// type_metadata_t *swift_getGenericMetadata(type_metadata_pattern_t *pattern,
|
|
// const void *arguments);
|
|
FUNCTION(GetGenericMetadata, swift_getGenericMetadata, RuntimeCC,
|
|
RETURNS(TypeMetadataPtrTy),
|
|
ARGS(TypeMetadataPatternPtrTy, Int8PtrTy),
|
|
ATTRS(NoUnwind, ReadOnly))
|
|
|
|
// type_metadata_t *swift_getGenericMetadata1(type_metadata_pattern_t *pattern,
|
|
// const void *arg0);
|
|
FUNCTION(GetGenericMetadata1, swift_getGenericMetadata1, RuntimeCC,
|
|
RETURNS(TypeMetadataPtrTy),
|
|
ARGS(TypeMetadataPatternPtrTy, Int8PtrTy),
|
|
ATTRS(NoUnwind, ReadNone))
|
|
|
|
// type_metadata_t *swift_getGenericMetadata2(type_metadata_pattern_t *pattern,
|
|
// const void *arg0,
|
|
// const void *arg1);
|
|
FUNCTION(GetGenericMetadata2, swift_getGenericMetadata2, RuntimeCC,
|
|
RETURNS(TypeMetadataPtrTy),
|
|
ARGS(TypeMetadataPatternPtrTy, Int8PtrTy, Int8PtrTy),
|
|
ATTRS(NoUnwind, ReadNone))
|
|
|
|
// type_metadata_t *swift_getGenericMetadata3(type_metadata_pattern_t *pattern,
|
|
// const void *arg0,
|
|
// const void *arg1,
|
|
// const void *arg2);
|
|
FUNCTION(GetGenericMetadata3, swift_getGenericMetadata3, RuntimeCC,
|
|
RETURNS(TypeMetadataPtrTy),
|
|
ARGS(TypeMetadataPatternPtrTy, Int8PtrTy, Int8PtrTy, Int8PtrTy),
|
|
ATTRS(NoUnwind, ReadNone))
|
|
|
|
// type_metadata_t *swift_getGenericMetadata4(type_metadata_pattern_t *pattern,
|
|
// const void *arg0,
|
|
// const void *arg1,
|
|
// const void *arg2,
|
|
// const void *arg3);
|
|
FUNCTION(GetGenericMetadata4, swift_getGenericMetadata4, RuntimeCC,
|
|
RETURNS(TypeMetadataPtrTy),
|
|
ARGS(TypeMetadataPatternPtrTy, Int8PtrTy, Int8PtrTy, Int8PtrTy, Int8PtrTy),
|
|
ATTRS(NoUnwind, ReadNone))
|
|
|
|
// type_metadata_t *swift_getMetatypeMetadata(type_metadata_t *instanceTy);
|
|
FUNCTION(GetMetatypeMetadata, swift_getMetatypeMetadata, RuntimeCC,
|
|
RETURNS(TypeMetadataPtrTy),
|
|
ARGS(TypeMetadataPtrTy),
|
|
ATTRS(NoUnwind, ReadNone))
|
|
|
|
// type_metadata_t *swift_getExistentialMetatypeMetadata(type_metadata_t *instanceTy);
|
|
FUNCTION(GetExistentialMetatypeMetadata,
|
|
swift_getExistentialMetatypeMetadata, RuntimeCC,
|
|
RETURNS(TypeMetadataPtrTy),
|
|
ARGS(TypeMetadataPtrTy),
|
|
ATTRS(NoUnwind, ReadNone))
|
|
|
|
// type_metadata_t *swift_getObjCClassMetadata(struct objc_class *theClass);
|
|
FUNCTION(GetObjCClassMetadata, swift_getObjCClassMetadata, RuntimeCC,
|
|
RETURNS(TypeMetadataPtrTy),
|
|
ARGS(ObjCClassPtrTy),
|
|
ATTRS(NoUnwind, ReadNone))
|
|
|
|
// _Bool swift_objcRespondsToSelector(id, void*);
|
|
FUNCTION(ObjCRespondsToSelector, swift_objcRespondsToSelector, C_CC,
|
|
RETURNS(Int1Ty), ARGS(ObjCPtrTy, Int8PtrTy),
|
|
ATTRS(NoUnwind, ReadOnly))
|
|
|
|
// type_metadata_t *swift_getTupleTypeMetadata(size_t numElements,
|
|
// type_metadata_t * const *elts,
|
|
// const char *labels,
|
|
// value_witness_table_t *proposed);
|
|
FUNCTION(GetTupleMetadata, swift_getTupleTypeMetadata, RuntimeCC,
|
|
RETURNS(TypeMetadataPtrTy),
|
|
ARGS(SizeTy, TypeMetadataPtrTy->getPointerTo(0),
|
|
Int8PtrTy, WitnessTablePtrTy),
|
|
ATTRS(NoUnwind, ReadOnly))
|
|
|
|
// type_metadata_t *swift_getTupleTypeMetadata2(type_metadata_t *elt0,
|
|
// type_metadata_t *elt1,
|
|
// const char *labels,
|
|
// value_witness_table_t *proposed);
|
|
FUNCTION(GetTupleMetadata2, swift_getTupleTypeMetadata2, RuntimeCC,
|
|
RETURNS(TypeMetadataPtrTy),
|
|
ARGS(TypeMetadataPtrTy, TypeMetadataPtrTy,
|
|
Int8PtrTy, WitnessTablePtrTy),
|
|
ATTRS(NoUnwind, ReadOnly))
|
|
|
|
// type_metadata_t *swift_getTupleTypeMetadata3(type_metadata_t *elt0,
|
|
// type_metadata_t *elt1,
|
|
// type_metadata_t *elt2,
|
|
// const char *labels,
|
|
// value_witness_table_t *proposed);
|
|
FUNCTION(GetTupleMetadata3, swift_getTupleTypeMetadata3, RuntimeCC,
|
|
RETURNS(TypeMetadataPtrTy),
|
|
ARGS(TypeMetadataPtrTy, TypeMetadataPtrTy, TypeMetadataPtrTy,
|
|
Int8PtrTy, WitnessTablePtrTy),
|
|
ATTRS(NoUnwind, ReadOnly))
|
|
|
|
// type_metadata_t *swift_getExistentialTypeMetadata(size_t numProtocols,
|
|
// const protocol_descriptor_t * const *protocols);
|
|
FUNCTION(GetExistentialMetadata,
|
|
swift_getExistentialTypeMetadata, RuntimeCC,
|
|
RETURNS(TypeMetadataPtrTy),
|
|
ARGS(SizeTy,
|
|
ProtocolDescriptorPtrTy->getPointerTo()),
|
|
ATTRS(NoUnwind, ReadOnly))
|
|
|
|
// void swift_initClassMetadata_UniversalStrategy(type_metadata_t *self,
|
|
// type_metadata_t *super,
|
|
// size_t numFields,
|
|
// type_metadata_t * const *fieldTypes,
|
|
// size_t *fieldOffsets);
|
|
FUNCTION(InitClassMetadataUniversal,
|
|
swift_initClassMetadata_UniversalStrategy, RuntimeCC,
|
|
RETURNS(VoidTy),
|
|
ARGS(TypeMetadataPtrTy, TypeMetadataPtrTy, SizeTy,
|
|
TypeMetadataPtrTy->getPointerTo(),
|
|
SizeTy->getPointerTo()),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void swift_initStructMetadata_UniversalStrategy(size_t numFields,
|
|
// type_metadata_t * const *fieldTypes,
|
|
// size_t *fieldOffsets,
|
|
// value_witness_table_t *vwtable);
|
|
FUNCTION(InitStructMetadataUniversal,
|
|
swift_initStructMetadata_UniversalStrategy, RuntimeCC,
|
|
RETURNS(VoidTy),
|
|
ARGS(SizeTy, TypeMetadataPtrTy->getPointerTo(),
|
|
SizeTy->getPointerTo(), WitnessTablePtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void swift_initEnumValueWitnessTableSinglePayload(value_witness_table_t *vwt,
|
|
// type_metadata_t *payload,
|
|
// unsigned num_empty_cases);
|
|
FUNCTION(InitEnumValueWitnessTableSinglePayload,
|
|
swift_initEnumValueWitnessTableSinglePayload,
|
|
RuntimeCC,
|
|
RETURNS(VoidTy),
|
|
ARGS(WitnessTablePtrTy, TypeMetadataPtrTy, Int32Ty),
|
|
ATTRS(NoUnwind))
|
|
|
|
// int swift_getEnumCaseSinglePayload(opaque_t *obj,
|
|
// type_metadata_t *payload,
|
|
// unsigned num_empty_cases);
|
|
FUNCTION(GetEnumCaseSinglePayload,
|
|
swift_getEnumCaseSinglePayload,
|
|
RuntimeCC,
|
|
RETURNS(Int32Ty),
|
|
ARGS(OpaquePtrTy, TypeMetadataPtrTy, Int32Ty),
|
|
ATTRS(NoUnwind, ReadOnly))
|
|
|
|
// void swift_storeEnumTagSinglePayload(opaque_t *obj,
|
|
// type_metadata_t *payload,
|
|
// int case_index,
|
|
// unsigned num_empty_cases);
|
|
FUNCTION(StoreEnumTagSinglePayload,
|
|
swift_storeEnumTagSinglePayload,
|
|
RuntimeCC,
|
|
RETURNS(VoidTy),
|
|
ARGS(OpaquePtrTy, TypeMetadataPtrTy, Int32Ty, Int32Ty),
|
|
ATTRS(NoUnwind))
|
|
|
|
// type_metadata_t *swift_staticTypeof(opaque_t *obj, type_metadata_t *self);
|
|
FUNCTION(StaticTypeof, swift_staticTypeof, RuntimeCC,
|
|
RETURNS(TypeMetadataPtrTy),
|
|
ARGS(OpaquePtrTy, TypeMetadataPtrTy),
|
|
ATTRS(NoUnwind, ReadNone))
|
|
|
|
// type_metadata_t *swift_objectTypeof(opaque_t *obj, type_metadata_t *self);
|
|
FUNCTION(ObjectTypeof, swift_objectTypeof, RuntimeCC,
|
|
RETURNS(TypeMetadataPtrTy),
|
|
ARGS(OpaquePtrTy, TypeMetadataPtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// type_metadata_t *swift_objcTypeof(opaque_t *obj, type_metadata_t *self);
|
|
FUNCTION(ObjCTypeof, swift_objcTypeof, RuntimeCC,
|
|
RETURNS(TypeMetadataPtrTy),
|
|
ARGS(OpaquePtrTy, TypeMetadataPtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// Class object_getClass(id object);
|
|
//
|
|
// This is readonly instead of readnone because isa-rewriting can have
|
|
// a noticeable effect.
|
|
FUNCTION(GetObjectClass, object_getClass, C_CC,
|
|
RETURNS(ObjCClassPtrTy),
|
|
ARGS(ObjCPtrTy),
|
|
ATTRS(NoUnwind, ReadOnly))
|
|
|
|
// type_metadata_t *swift_getObjectType(id object);
|
|
//
|
|
// Since this is intended to look through dynamic subclasses, it's
|
|
// invariant across reasonable isa-rewriting schemes and therefore can
|
|
// be readnone.
|
|
FUNCTION(GetObjectType, swift_getObjectType, RuntimeCC,
|
|
RETURNS(TypeMetadataPtrTy),
|
|
ARGS(ObjCPtrTy),
|
|
ATTRS(NoUnwind, ReadNone))
|
|
|
|
// void *swift_dynamicCastClass(void*, void*);
|
|
FUNCTION(DynamicCastClass, swift_dynamicCastClass, RuntimeCC,
|
|
RETURNS(Int8PtrTy),
|
|
ARGS(Int8PtrTy, Int8PtrTy),
|
|
ATTRS(NoUnwind, ReadOnly))
|
|
|
|
// void *swift_dynamicCastClassUnconditional(void*, void*);
|
|
FUNCTION(DynamicCastClassUnconditional, swift_dynamicCastClassUnconditional,
|
|
RuntimeCC,
|
|
RETURNS(Int8PtrTy),
|
|
ARGS(Int8PtrTy, Int8PtrTy),
|
|
ATTRS(NoUnwind, ReadOnly))
|
|
|
|
// type *swift_dynamicCastMetatype(type*, type*);
|
|
FUNCTION(DynamicCastMetatype, swift_dynamicCastMetatype, RuntimeCC,
|
|
RETURNS(TypeMetadataPtrTy),
|
|
ARGS(TypeMetadataPtrTy, TypeMetadataPtrTy),
|
|
ATTRS(NoUnwind, ReadOnly))
|
|
|
|
// type *swift_dynamicCastMetatypeUnconditional(type*, type*);
|
|
FUNCTION(DynamicCastMetatypeUnconditional,
|
|
swift_dynamicCastMetatypeUnconditional, RuntimeCC,
|
|
RETURNS(TypeMetadataPtrTy),
|
|
ARGS(TypeMetadataPtrTy, TypeMetadataPtrTy),
|
|
ATTRS(NoUnwind, ReadOnly))
|
|
|
|
// objc_class *swift_dynamicCastObjCClassMetatype(objc_class*, objc_class*);
|
|
FUNCTION(DynamicCastObjCClassMetatype, swift_dynamicCastMetatype, RuntimeCC,
|
|
RETURNS(ObjCClassPtrTy),
|
|
ARGS(ObjCClassPtrTy, ObjCClassPtrTy),
|
|
ATTRS(NoUnwind, ReadOnly))
|
|
|
|
// objc_class *swift_dynamicCastObjCClassMetatypeUnconditional(objc_class*, objc_class*);
|
|
FUNCTION(DynamicCastObjCClassMetatypeUnconditional,
|
|
swift_dynamicCastMetatypeUnconditional, RuntimeCC,
|
|
RETURNS(ObjCClassPtrTy),
|
|
ARGS(ObjCClassPtrTy, ObjCClassPtrTy),
|
|
ATTRS(NoUnwind, ReadOnly))
|
|
|
|
// void *swift_dynamicCast(void*, void*);
|
|
FUNCTION(DynamicCast, swift_dynamicCast, RuntimeCC,
|
|
RETURNS(Int8PtrTy),
|
|
ARGS(Int8PtrTy, Int8PtrTy),
|
|
ATTRS(NoUnwind, ReadOnly))
|
|
|
|
// void *swift_dynamicCastUnconditional(void*, void*);
|
|
FUNCTION(DynamicCastUnconditional, swift_dynamicCastUnconditional, RuntimeCC,
|
|
RETURNS(Int8PtrTy),
|
|
ARGS(Int8PtrTy, Int8PtrTy),
|
|
ATTRS(NoUnwind, ReadOnly))
|
|
|
|
// opaque *swift_dynamicCastIndirect(opaque*, void*, void*);
|
|
FUNCTION(DynamicCastIndirect, swift_dynamicCastIndirect, RuntimeCC,
|
|
RETURNS(OpaquePtrTy),
|
|
ARGS(OpaquePtrTy, Int8PtrTy, Int8PtrTy),
|
|
ATTRS(NoUnwind, ReadOnly))
|
|
|
|
// opaque *swift_dynamicCastIndirectUnconditional(opaque*, void*, void*);
|
|
FUNCTION(DynamicCastIndirectUnconditional,
|
|
swift_dynamicCastIndirectUnconditional, RuntimeCC,
|
|
RETURNS(OpaquePtrTy),
|
|
ARGS(OpaquePtrTy, Int8PtrTy, Int8PtrTy),
|
|
ATTRS(NoUnwind, ReadOnly))
|
|
|
|
// id swift_dynamicCastObjCProtocolUnconditional(id object,
|
|
// size_t numProtocols,
|
|
// Protocol * const *protocols);
|
|
FUNCTION(DynamicCastObjCProtocolUnconditional,
|
|
swift_dynamicCastObjCProtocolUnconditional, RuntimeCC,
|
|
RETURNS(ObjCPtrTy),
|
|
ARGS(ObjCPtrTy, SizeTy, Int8PtrPtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// id swift_dynamicCastObjCProtocolConditional(id object,
|
|
// size_t numProtocols,
|
|
// Protocol * const *protocols);
|
|
FUNCTION(DynamicCastObjCProtocolConditional,
|
|
swift_dynamicCastObjCProtocolConditional, RuntimeCC,
|
|
RETURNS(ObjCPtrTy),
|
|
ARGS(ObjCPtrTy, SizeTy, Int8PtrPtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void swift_once(swift_once_t *predicate,
|
|
// void (*function_code)(RefCounted*),
|
|
// RefCounted *context);
|
|
FUNCTION(Once, swift_once, RuntimeCC,
|
|
RETURNS(VoidTy),
|
|
ARGS(OnceTy->getPointerTo(), Int8PtrTy, RefCountedPtrTy),
|
|
ATTRS())
|
|
|
|
FUNCTION(ForceInitializeObjCClass, swift_forceInitializeObjCClass, RuntimeCC,
|
|
RETURNS(VoidTy),
|
|
ARGS(TypeMetadataPtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
FUNCTION(ObjCRetain, objc_retain, C_CC,
|
|
RETURNS(ObjCPtrTy), ARGS(ObjCPtrTy), ATTRS(NoUnwind))
|
|
FUNCTION(ObjCRelease, objc_release, C_CC,
|
|
RETURNS(VoidTy), ARGS(ObjCPtrTy), ATTRS(NoUnwind))
|
|
FUNCTION(ObjCAutorelease, objc_autorelease, C_CC,
|
|
RETURNS(ObjCPtrTy), ARGS(ObjCPtrTy), ATTRS(NoUnwind))
|
|
FUNCTION(ObjCRetainAutoreleasedReturnValue,
|
|
objc_retainAutoreleasedReturnValue, C_CC,
|
|
RETURNS(ObjCPtrTy), ARGS(ObjCPtrTy), ATTRS(NoUnwind))
|
|
FUNCTION(ObjCAutoreleaseReturnValue, objc_autoreleaseReturnValue, C_CC,
|
|
RETURNS(ObjCPtrTy), ARGS(ObjCPtrTy), ATTRS(NoUnwind))
|
|
FUNCTION(ObjCMsgSend, objc_msgSend, C_CC,
|
|
RETURNS(VoidTy), NO_ARGS, NO_ATTRS)
|
|
FUNCTION(ObjCMsgSendStret, objc_msgSend_stret, C_CC,
|
|
RETURNS(VoidTy), NO_ARGS, NO_ATTRS)
|
|
FUNCTION(ObjCMsgSendSuper, objc_msgSendSuper, C_CC,
|
|
RETURNS(VoidTy), NO_ARGS, NO_ATTRS)
|
|
FUNCTION(ObjCMsgSendSuperStret, objc_msgSendSuper_stret, C_CC,
|
|
RETURNS(VoidTy), NO_ARGS, NO_ATTRS)
|
|
FUNCTION(ObjCMsgSendSuper2, objc_msgSendSuper2, C_CC,
|
|
RETURNS(VoidTy), NO_ARGS, NO_ATTRS)
|
|
FUNCTION(ObjCMsgSendSuperStret2, objc_msgSendSuper2_stret, C_CC,
|
|
RETURNS(VoidTy), NO_ARGS, NO_ATTRS)
|
|
FUNCTION(ObjCSelRegisterName, sel_registerName, C_CC,
|
|
RETURNS(ObjCSELTy), ARGS(Int8PtrTy), ATTRS(NoUnwind, ReadNone))
|
|
FUNCTION(ClassReplaceMethod, class_replaceMethod, C_CC,
|
|
RETURNS(Int8PtrTy),
|
|
ARGS(ObjCClassPtrTy, Int8PtrTy, Int8PtrTy, Int8PtrTy),
|
|
ATTRS(NoUnwind))
|
|
FUNCTION(ClassAddProtocol, class_addProtocol, C_CC,
|
|
RETURNS(VoidTy),
|
|
ARGS(ObjCClassPtrTy, Int8PtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
// void *_Block_copy(void *block);
|
|
FUNCTION(BlockCopy, _Block_copy, C_CC,
|
|
RETURNS(ObjCBlockPtrTy),
|
|
ARGS(ObjCBlockPtrTy),
|
|
NO_ATTRS)
|
|
// void _Block_release(void *block);
|
|
FUNCTION(BlockRelease, _Block_release, C_CC,
|
|
RETURNS(VoidTy),
|
|
ARGS(ObjCBlockPtrTy),
|
|
ATTRS(NoUnwind))
|
|
|
|
#undef RETURNS
|
|
#undef ARGS
|
|
#undef ATTRS
|
|
#undef NO_ARGS
|
|
#undef NO_ATTRS
|
|
#undef FUNCTION
|
|
#undef FUNCTION_NAME
|