Skip to content

Switch to swift calling conv #7237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion include/swift/Runtime/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#ifdef __s390x__
#define SWIFT_USE_SWIFTCALL 1
#else
#define SWIFT_USE_SWIFTCALL 0
#define SWIFT_USE_SWIFTCALL 1
#endif
#endif

Expand Down Expand Up @@ -128,6 +128,11 @@

#define SWIFT_LLVM_CC_RegisterPreservingCC llvm::CallingConv::PreserveMost

#if SWIFT_USE_SWIFTCALL
#define SWIFT_LLVM_CC_SwiftCC llvm::CallingConv::Swift
#else
#define SWIFT_LLVM_CC_SwiftCC llvm::CallingConv::C
#endif

// If defined, it indicates that runtime function wrappers
// should be used on all platforms, even they do not support
Expand Down
6 changes: 2 additions & 4 deletions include/swift/Runtime/HeapObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,10 @@ using BoxPair = TwoWordPair<HeapObject *, OpaqueValue *>;
/// The heap object has an initial retain count of 1, and its metadata is set
/// such that destroying the heap object destroys the contained value.
SWIFT_RUNTIME_EXPORT
BoxPair::Return swift_allocBox(Metadata const *type)
SWIFT_CC(swift);
BoxPair::Return swift_allocBox(Metadata const *type);

SWIFT_RUNTIME_EXPORT
BoxPair::Return (*_swift_allocBox)(Metadata const *type)
SWIFT_CC(swift);
BoxPair::Return (*_swift_allocBox)(Metadata const *type);


// Allocate plain old memory. This is the generalized entry point
Expand Down
5 changes: 3 additions & 2 deletions include/swift/Runtime/Metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,7 @@ const FullOpaqueMetadata METADATA_SYM(BO); // Builtin.UnknownObject
struct HeapMetadataHeaderPrefix {
/// Destroy the object, returning the allocated size of the object
/// or 0 if the object shouldn't be deallocated.
void (*destroy)(HeapObject *);
SWIFT_CC(swift) void (*destroy)(SWIFT_CONTEXT HeapObject *);
};

/// The header present on all heap metadata.
Expand Down Expand Up @@ -1548,7 +1548,7 @@ struct TargetNominalTypeDescriptor {
};
using NominalTypeDescriptor = TargetNominalTypeDescriptor<InProcess>;

typedef void (*ClassIVarDestroyer)(HeapObject *);
typedef SWIFT_CC(swift) void (*ClassIVarDestroyer)(SWIFT_CONTEXT HeapObject *);

/// The structure of all class metadata. This structure is embedded
/// directly within the class's heap metadata structure and therefore
Expand Down Expand Up @@ -3488,6 +3488,7 @@ std::string nameForMetadata(const Metadata *type,

/// Return the superclass, if any. The result is nullptr for root
/// classes and class protocol types.
SWIFT_CC(swift)
SWIFT_RUNTIME_STDLIB_INTERFACE
const Metadata *_swift_class_getSuperclass(const Metadata *theClass);

Expand Down
1 change: 1 addition & 0 deletions include/swift/Runtime/Reflection.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct MirrorReturn {
///
/// Produce a mirror for any value. The runtime produces a mirror that
/// structurally reflects values of any type.
SWIFT_CC(swift)
SWIFT_RUNTIME_EXPORT
MirrorReturn
swift_reflectAny(OpaqueValue *value, const Metadata *T);
Expand Down
2 changes: 1 addition & 1 deletion include/swift/Serialization/ModuleFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const uint16_t VERSION_MAJOR = 0;
/// in source control, you should also update the comment to briefly
/// describe what change you made. The content of this comment isn't important;
/// it just ensures a conflict if two people change the module format.
const uint16_t VERSION_MINOR = 315; // Last change: uniquely identify extensions
const uint16_t VERSION_MINOR = 316; // Last change: Swift calling convention

using DeclID = PointerEmbeddedInt<unsigned, 31>;
using DeclIDField = BCFixed<31>;
Expand Down
10 changes: 0 additions & 10 deletions lib/IRGen/Explosion.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,6 @@ class ExplosionSchema {
return Elements[index];
}

bool requiresIndirectParameter(IRGenModule &IGM) const;
bool requiresIndirectResult(IRGenModule &IGM) const;

typedef SmallVectorImpl<Element>::iterator iterator;
typedef SmallVectorImpl<Element>::const_iterator const_iterator;

Expand All @@ -255,13 +252,6 @@ class ExplosionSchema {
/// - the element type, if the schema contains exactly one element;
/// - an anonymous struct type concatenating those types, otherwise.
llvm::Type *getScalarResultType(IRGenModule &IGM) const;

/// Treating the types in this schema as potential arguments to a
/// function call, add them to the end of the given vector of types.
void addToArgTypes(IRGenModule &IGM,
const TypeInfo &TI,
llvm::AttributeSet &Attrs,
SmallVectorImpl<llvm::Type*> &types) const;
};

} // end namespace irgen
Expand Down
Loading