Commit Graph

46 Commits

Author SHA1 Message Date
Michael Gottesman
5648ef219d [+0-all-args] Clean up remains of +1 convention from the runtime. 2018-07-06 23:10:12 -07:00
Davide Italiano
cb8d946cba [Runtime] Remove the dependency on LLVM's Compiler.h
<rdar://problem/35860874>
2018-07-03 13:52:40 -07:00
Davide Italiano
2dfd3d5b00 [Runtime] Remove dependency on Compiler.h from Config.h.
The runtime doesn't really need Compiler.h. It just needs some
visibility macros which can be inlined here instead of pulling
the whole heavyweight header (including its transitive closure,
llvm-config.h). This is becoming more important now that Compiler.h
includes C++ headers (namely, <new>), and swift/Runtime/Config.h
can be included from C or Objective-C files (causing build failures).

<rdar://problem/35860874>
2018-07-03 11:32:12 -07:00
Saleem Abdulrasool
9563022b4a runtime: avoid some pedantic warnings from CPP (NFC)
Expansion of undefined macros is 0.  This results in warnings when
building the runtime on Windows.  Ensure that the macros are defined
when checking the conditions.  NFC.
2018-03-25 21:58:16 -07:00
Greg Parker
e223f1fc9b [IRGen][runtime] Simplify runtime CCs and entry point ABIs (#14175)
* Remove RegisterPreservingCC. It was unused.
* Remove DefaultCC from the runtime. The distinction between C_CC and DefaultCC
  was unused and inconsistently applied. Separate C_CC and DefaultCC are
  still present in the compiler.
* Remove function pointer indirection from runtime functions except those
  that are used by Instruments. The remaining Instruments interface is
  expected to change later due to function pointer liability.
* Remove swift_rt_ wrappers. Function pointers are an ABI liability that we
  don't want, and there are better ways to get nonlazy binding if we need it.
  The fully custom wrappers were only needed for RegisterPreservingCC and
  for optimizing the Instruments function pointers.
2018-01-29 13:22:30 -08:00
Greg Parker
7b9224794e [runtime] Reinstate TwoWordPair hack for swiftcall returns. (#14079)
clang is miscompiling some swiftcall functions on armv7s.
Stop using swiftcall in some places until it is fixed.

Reverts c5bf2ec (#13299).

rdar://35973477
2018-01-23 01:04:01 -08:00
Michael Gottesman
e2c1bcf80f [+0-args][runtime] Add temporary runtime swift convention macros.
These are temporary staging macros to ease having a runtime that supports both
+0 and +1 conventions for functions exposed as Swift level functions in the
stdlib (and thus needing to follow the swift convention). The macros values are
toggled by the argument SWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS and thus have
values described via the following table:

| SWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENT | FALSE                         | TRUE                          |
|-----------------------------------------+-------------------------------+-------------------------------|
| SWIFT_NS_RELEASES_ARGUMENT              | NS_RELEASES_ARGUMENT          | ""                            |
| SWIFT_CC_PLUSONE_GUARD(...)             | do { __VA_ARGS__ ; } while(0) | ""                            |
| SWIFT_CC_PLUSZERO_GUARD(...)            | ""                            | do { __VA_ARGS__ ; } while(0) |

Thus instead of having to write an ugly #ifdef multiple times in each function
(for the arguments, destroys, and retains), we can just use these macros
instead.

In a subsequent commit I am going to cleanup the changes I made in the runtime
already to use these macros. So this is a NFC change.

rdar://34222540
2018-01-16 12:52:09 -08:00
Greg Parker
c677a5dc11 [IRGen][runtime] Prepare to change the is-Swift bit in class metadata. (#13595)
Swift class metadata has a bit to distinguish it from non-Swift Objective-C
classes. The stable ABI will use a different bit so that stable Swift and
pre-stable Swift can be distinguished from each other.

No bits are actually changed yet. Enabling the new bit needs to wait for
other coordination such as libobjc.

rdar://35767811
2017-12-22 00:52:00 -08:00
Thomas Roughton
f10ef1ab9a [runtime] Always use SwiftCC (#13311) 2017-12-12 17:11:38 -08:00
Thomas Roughton
c5bf2ec553 [runtime] Remove TwoWordPair and use the Swift calling convention instead. (#13299) 2017-12-07 19:27:24 -08:00
Arnold Schwaighofer
bc68d51ad8 Use the preserve_most calling convention for the increment slow path
This improves x86-64 code generation to not having any stack operations on the fast path.
2017-09-19 07:16:37 -07:00
Saleem Abdulrasool
635bb00d61 runtime: make LLP64 clean
This is a blanket pass replacing use of `__LP64__` with
`__POINTER_WIDTH__ == 64`.  The latter is more expressive and also LLP64
clean.  This change is needed to enable support for Windows x86_64 which
is a LLP64 environment.
2017-09-17 18:41:10 -07:00
practicalswift
861f70e13d [gardening] Use consistent spacing 2017-04-25 21:03:43 +02:00
Hugh Bellamy
5b017954be Don't use swift calling convention for now with clang-cl on Windows to work around a crasher 2017-03-21 19:18:36 +07:00
Hugh Bellamy
4d45092c34 Cleanup uses of __asm__ in the runtime 2017-03-08 17:32:44 +07:00
practicalswift
1475ab63fb [gardening] Remove duplicate #include:s 2017-03-02 16:19:57 +01:00
Hugh Bellamy
bb34e2a959 Fix attribute fallout from new refcount representation 2017-03-02 19:44:37 +07:00
practicalswift
5b4bf0f74c [gardening] Remove duplicate include. 2017-02-21 14:20:34 +01:00
Hugh Bellamy
a6515200f4 Attempt to fix Linux build - __has_attribute(swiftcall) doesn't work on Linux 2017-02-20 17:58:58 +07:00
Hugh Bellamy
bddebc58b8 Don't define SWIFT_USE_SWIFTCALL if there is no such attribute 2017-02-20 10:16:30 +07:00
Hugh Bellamy
a570f6b87b Merge pull request #7405 from hughbe/visual-studio-bug
Work around Visual Studio bug inferring type of auto
2017-02-18 09:26:40 +07:00
Arnold Schwaighofer
6c35202565 Conditionalize usage of llvm::CallingConv::Swift on SWIFT_USE_SWIFTCALL macro 2017-02-14 12:17:57 -08:00
Arnold Schwaighofer
39fa2f0228 Use the swift calling convention for swift functions
Use the generic type lowering algorithm described in
"docs/CallingConvention.rst#physical-lowering" to map from IRGen's explosion
type to the type expected by the ABI.

Change IRGen to use the swift calling convention (swiftcc) for native swift
functions.

Use the 'swiftself' attribute on self parameters and for closures contexts.

Use the 'swifterror' parameter for swift error parameters.

Change functions in the runtime that are called as native swift functions to use
the swift calling convention.

rdar://19978563
2017-02-14 12:17:57 -08:00
Hugh Bellamy
a94f65cb5e Include llvm/Support/Compiler.h wherever we use __has_attribute 2017-02-12 09:30:22 +07:00
Hugh Bellamy
cdb73ae193 Fix undefined __USER_LABEL_PREFIX compiling swift/LLVMPasses 2017-01-09 21:17:18 +00:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Roman Levenstein
56d55dec2b [swift-runtime] Rename rt_swift_* to swift_rt_*. NFC
Swift uses rt_swift_* functions to call the Swift runtime without using dyld's stubs. These functions are renamed to swift_rt_* to reduce namespace pollution.

rdar://28706212
2016-10-11 09:49:06 -07:00
Dmitri Gribenko
dfb4f56e55 runtime: rename _TMps8Hashable to HashableProtocolDescriptor 2016-08-31 09:53:39 -07:00
Bryan Chan
85fde8b1fb Add support for Linux s390x. LLVM's Swift calling convention support is used to ensure correct operations of C++ code in the runtime. This patch also includes some (incomplete) changes to enum handling to make enums work in most common cases. 2016-05-24 20:03:28 -04:00
John McCall
50d58b2732 Add a lot of calling-convention annotations to the standard library / runtime.
The general rule here is that something needs to be SWIFT_CC(swift)
if it's just declared in Swift code using _silgen_name, as opposed to
importing something via a header.

Of course, SWIFT_CC(swift) expands to nothing by default for now, and
I haven't made an effort yet to add the indirect-result / context
parameter ABI attributes.  This is just a best-effort first pass.

I also took the opportunity to shift a few files to just implement
their shims header and to demote a few things to be private stdlib
interfaces.
2016-05-04 10:31:23 -07:00
Roman Levenstein
b985794992 Prepare IRGen and LLVM passes to use the new preserve_most calling convention, but do not enable it yet.
The convention should be enabled once we can properly build the runtime library using Siwft's own clang/llvm binaries.
2016-04-01 14:19:47 -07:00
Peter Cooper
7ec0e7348f Add more calls to the objc runtime for getting an object’s ISA.
Be more conservative in terms of masking ISAs.  This reduces tight coupling with the objc runtime.  This commit adds the required calls to IRGen and the runtime, and a test case to make sure IRGen is correct.
2016-03-10 15:07:20 -08:00
practicalswift
35dbeef034 [gardening] Fix recently introduced typos
* currnet → current
* accidental double space ("  ") → intentional single space (" ")
* recordinf → recording
2016-03-02 22:25:46 +01:00
practicalswift
3a4968192b [gardening] Fix recently introduced typo: "enrty" → "entry" 2016-03-02 09:33:45 +01:00
Roman Levenstein
b3e60afcc7 Even if we use wrappers, runtime functions should be visible.
In principle, runtime entries could have a hidden visibility, because they are
never called directly from the code produced by IRGen.
But some of the runtime entries are invoked directly from the foundation.
Therefore they should be visible.
2016-02-25 08:51:19 -08:00
Roman Levenstein
2ff5755dc3 Use the "rt_" prefix for all generated wrappers to distinguish them from the actual runtime functions. 2016-02-25 06:00:30 -08:00
Roman Levenstein
99fd8b6080 Rename some macros based on the PR review comments.
- use  the SWIFT prefix for all macros
- make names of some macros shorter
2016-02-25 05:31:00 -08:00
Roman Levenstein
de3b850ce8 Use more descriptive names for calling conventions.
Rename RuntimeCC into DefaultCC
Rename RuntimeCC1 into RegisterPreservingCC
Remove RuntimeCC0 because it was identical to DefaultCC.
2016-02-25 05:31:00 -08:00
Roman Levenstein
fd9a22aca1 Prepare the configuration parameters needed for implementing a new runtime calling convention.
Define a number of macro definitions that will be used for:
- proper auto-generation of LLVM IR level declarations of runtime function using RuntimeFunctions.def
- generation of wrappers for runtime functions
- setting proper calling conventions, visibility and other attributes of runtime functions inside the runtime library.
2016-02-25 05:30:58 -08:00
Joe Groff
f7291b21ec Runtime: Build with -fvisibility=hidden.
...and explicitly mark symbols we export, either for use by executables or for runtime-stdlib interaction. Until the stdlib supports resilience we have to allow programs to link to these SPI symbols.
2016-02-08 08:06:02 -08:00
practicalswift
f91525a10f Consistent placement of "-*- [language] -*-===//" in header. 2016-01-04 09:46:20 +01:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Joe Groff
9b4dc24721 Runtime: (Almost) cleanse of global constructors and destructors.
Configure the runtime to build with -Wglobal-constructors, and Lazy-fy almost everything that gets flagged. (I gave "swift_isaMask" a pass since that's almost definitely hot enough to warrant a static initialization.) Make some improvements to the Lazy wrapper, using aligned_storage to ensure that it's trivially constructed and destructed.

Swift SVN r28199
2015-05-06 04:59:56 +00:00
John McCall
590c25479d Use isa-masking to read the class object pointer from
instances of Swift subclasses of ObjC classes.

We were already doing this in the runtime.  This patch
unhides the runtime's mask word (swift_isaMask) and makes
IR-gen take advantage of it when it can.

Swift SVN r21592
2014-08-29 21:36:53 +00:00
John McCall
7b86817b3c Basic value structure for [weak] and [unowned] references.
Add a bunch of new entrypoints and give them terrible
implementations.

Swift SVN r6322
2013-07-17 09:20:20 +00:00