Commit Graph

13406 Commits

Author SHA1 Message Date
Valeriy Van
9821976c69 Removes redundant buffer zeroing in CGColorSpace.swift by using `init(unsafeUninitializedCapacity:initializingWith:) (#30134)
* Removes redundant buffer zeroing

* Fix compile error
2020-04-13 19:49:17 -07:00
Saleem Abdulrasool
41958f95fc Merge pull request #30992 from compnerd/the-impossible-future
build: explicitly execute `line-directive-tool` with Python3
2020-04-13 17:11:19 -07:00
Saleem Abdulrasool
850cd86909 Merge pull request #30997 from compnerd/svelte-fp
stdlib: android does not support FP80
2020-04-13 14:50:06 -07:00
Dario Rexin
20b2fec8a9 Merge pull request #30978 from compnerd/variants
build: duplicate and rename the `_add_variant_*` functions
2020-04-13 13:55:47 -07:00
Saleem Abdulrasool
d0048ccc61 stdlib: android does not support FP80
Correct the maximal floating point width.  Although technically, Android
could support FP128 on AArch64, Swift does not currently support FP128.
For now, ensure that we use FP64 on Android.
2020-04-13 12:23:26 -07:00
Saleem Abdulrasool
cba8723d61 build: explicitly execute line-directive-tool with Python3
The `line-directive-tool` is Python3 compliant.  Use the Python3
interpreter to execute this tool.
2020-04-13 09:53:50 -07:00
Saleem Abdulrasool
f069371083 Merge pull request #30988 from compnerd/constantly-improving
WinSDK: add some constants for the SDK overlay
2020-04-13 08:53:08 -07:00
Saleem Abdulrasool
fa4b7ead4e Merge pull request #30990 from compnerd/shellcore
Platform: add ShellCore to WinSDK modulemap
2020-04-13 08:52:23 -07:00
Saleem Abdulrasool
b9e3109fe8 Platform: add ShellCore to WinSDK modulemap
Add the ShellCore module to the Windows SDK modulemap.
2020-04-12 21:37:41 -07:00
Saleem Abdulrasool
24617651e5 WinSDK: add some constants for the SDK overlay
Unfortunately, the types are not imported through the clang importer.
Add them to the overlay for use in applications.
2020-04-12 16:08:47 -07:00
Robert Widmann
763875aea7 Merge pull request #15108 from darquro/fast-path-ad-hoc-printing-of-strings
[stdlib][SR-7136] Fast-path ad-hoc printing of Strings
2020-04-12 09:30:52 -07:00
Robert Widmann
22b0526917 Merge pull request #30082 from 3405691582/OpenBSD_Port_Build
Build system recognizes OpenBSD.
2020-04-12 09:30:17 -07:00
Saleem Abdulrasool
87cbb3132d build: duplicate and rename the _add_variant_* functions
This allows us to start splitting up the swift and C/C++ specific paths.
2020-04-11 13:24:31 -07:00
Saleem Abdulrasool
b7654f158b Merge pull request #30885 from compnerd/android-fp80
stdlib: android does not support fp80
2020-04-11 10:13:52 -07:00
Michael Ilseman
c1ab69e2db Merge pull request #30729 from milseman/merge_me_if_available
[string] String(decoding:as:) fast path for withContiguousStorageIfAvailable
2020-04-10 16:10:06 -07:00
Dan Zheng
a864a57c9a [AutoDiff upstream] Add Differentiable.withDerivative(_:). (#30945)
Add `Differentiable.withDerivative(_:)`, a "derivative surgery" API.

`Differentiable.withDerivative(_:)` is an identity function returning `self`.
It takes a closure and applies it to the derivative of the return value, in
contexts where the return value is differentiated with respect to.
2020-04-10 12:22:56 -07:00
Michael Ilseman
38fce16254 [string] Convert IR tests to SIL tests 2020-04-10 11:39:22 -07:00
Michael Ilseman
d02f5bc509 [string] Move wCSIA check higher than _HasContiguousBytes 2020-04-10 11:39:03 -07:00
Saleem Abdulrasool
29085464b2 Merge pull request #30940 from compnerd/magic-numbers-are-good
Platform: alias math constants on Windows
2020-04-10 07:29:46 -07:00
Dan Zheng
3ef8360f3e [AutoDiff] Add AnyDifferentiable. (#30928)
Add `AnyDifferentiable`, a type-erased wrapper for `Differentiable`-conforming types.
2020-04-09 22:49:55 -07:00
Saleem Abdulrasool
600d90dbed Platform: alias math constants on Windows
The non-C/C++ standard defined math constants require
`-Xcc -D_USE_MATH_DEFINES` when using the `ucrt` module.  Instead,
provide them through the wrapper `MSVCRT` module as aliases so that the
user does not need to be aware of this in practice.

Repairs the Windows build of `_Differentiation`.
2020-04-09 19:13:10 -07:00
Saleem Abdulrasool
e7ffea78b1 Merge pull request #30927 from compnerd/undefined-is-the-only-desired-behaviour
runtime: fix a UBSAN issue
2020-04-09 15:29:23 -07:00
marcrasi
ddef9292a6 [AutoDiff upstream] DifferentiationUnittest and some e2e tests (#30915)
Adds 2 simple e2e tests and some lit subsitutions and unittest libraries
necessary to support them.
2020-04-09 14:25:31 -07:00
Michael Ilseman
ae224cacdb [string] Restore _HasContiguousBytes for untyped storage
UnsafeRawBufferPointer cannot implement
withContiguousStorageIfAvailable because doing so would potentially
create a typed pointer from untyped data.
2020-04-09 13:38:28 -07:00
Michael Ilseman
e536ad2342 [string] Outline cold path from initializer
Outline the cold, non-contiguous UTF-8 path from String(decoding:as:),
saving ~40 bytes (33%) of code size (x86_64 and arm64) from every call
site where the contiguity check cannot be constant folded away.
2020-04-09 13:38:28 -07:00
Michael Ilseman
c2631004d7 [string] _HasContiguousBytes -> withContiguousStorageIfAvailable
Switch String(decoding:as) and other entry points to call
withContiguousStorageIfAvailable rather than use _HasContiguousBytes.
2020-04-09 13:38:28 -07:00
Michael Ilseman
19b332c8e2 [gardening] Delete Trailing Whitespace 2020-04-09 13:38:27 -07:00
Saleem Abdulrasool
c8e8b177fa runtime: fix a UBSAN issue
This was identified by UBSAN: signed-integer-overflow.  Explicitly mark
the value as unsigned to ensure that the value does not overflow.  There
is a second instance of a raw literal, however, because it is a `*=` the
value is implicitly understood to be unsigned.
2020-04-09 12:21:20 -07:00
Dan Zheng
d4ff5847d0 [AutoDiff upstream] Add AnyDerivative.
Add `AnyDerivative`, a type-erased wrapper for `Differentiable.TangentVector`
associated type implementations.
2020-04-09 11:52:59 -07:00
Dan Zheng
65ab642b1a [AutoDiff upstream] Add Differentiable.zeroTangentVector.
Add `Differentiable.zeroTangentVectorInitializer` protocol requirement and
`Differentiable.zeroTangentVector` default implementation.
2020-04-09 11:15:18 -07:00
tbkka
110e5136c1 Float16 optimal formatting (#30862)
Extend SwiftDtoa to provide optimal formatting for Float16 and use that for `Float16.description` and `Float16.debugDescription`.

Notes on signaling NaNs: LLVM's Float16 support passes Float16s on x86
by legalizing to Float32.  This works well for most purposes but incidentally
loses the signaling marker from any NaN (because it's a conversion as far
as the hardware is concerned), with a side effect that the print code never
actually sees a true sNaN.  This is similar to what happens with Float and
Double on i386 backends.  The earlier code here tried to detect sNaN in a
different way, but that approach isn't guaranteed to work so we decided to
make this code use the correct detection logic -- sNaN printing will just be
broken until we can get a better argument passing convention.

Resolves rdar://61414101
2020-04-09 09:37:38 -04:00
Dan Zheng
75548c30be Merge pull request #30875 from apple/autodiff-upstream-stdlib-differentiation
[AutoDiff upstream] Add stdlib `Differentiable` conformances and derivatives.
2020-04-08 22:31:47 -07:00
Saleem Abdulrasool
368d66af21 Merge pull request #30888 from compnerd/android-shims
runtime: provide AEABI shims for floating point conversion
2020-04-08 19:48:23 -07:00
Dan Zheng
01db90dd61 Merge branch 'master' of github.com:apple/swift into autodiff-upstream-stdlib-differentiation 2020-04-08 14:12:03 -07:00
Dan Zheng
2eb460de4d [AutoDiff upstream] Add forward-mode differentiation. (#30878)
JVP functions are forward-mode derivative functions. They take original
arguments and return original results and a differential function. Differential
functions take derivatives wrt arguments and return derivatives wrt results.

`JVPEmitter` is a cloner that emits JVP and differential functions at the same
time. In JVP functions, function applications are replaced with JVP function
applications. In differential functions, function applications are replaced
with differential function applications.

In JVP functions, each basic block takes a differential struct containing callee
differentials. These structs are consumed by differential functions.
2020-04-08 11:29:21 -07:00
Saleem Abdulrasool
dce9614bf4 runtime: provide AEABI shims for floating point conversion
Android NDK <r21 does not provide the AEABI mandated `__aeabi_d2h`
functions in the compiler runtime.  Add shims to ensure that the
functions are available for building the standard library.
2020-04-08 11:16:40 -07:00
Saleem Abdulrasool
3fe5b1531c stdlib: android does not support fp80
Like Windows, Android does not support FP80.  Ensure that we do not emit
these even on x86 and x86_64.
2020-04-08 10:07:50 -07:00
Dan Zheng
d599105715 [AutoDiff upstream] Fix stdlib differentiation tests.
Temporarily disable not-yet-supported differentiation tests:

- Forward-mode differentiation.
  - TF-1237: to be upstreamed.
- `Differentiable.zeroTangentVector`.
  - TF-1238: to be upstreamed.
- `SIMD.sum` differentiation.
  - TF-1103: `@_alwaysEmitIntoClient` derivative registration.
2020-04-08 02:50:43 -07:00
Dan Zheng
2c112141dd [AutoDiff upstream] Deduplicate floating-point Differentiable conformances.
Move `Differentiable` conformances out of Differentiable.swift.
All `Differentiable` conformances exist in separate files.
2020-04-08 02:49:21 -07:00
Dan Zheng
ece4fb75b0 [AutoDiff upstream] Add Float16 derivatives.
Add `@available` attributes for declarations using `Float16`.
2020-04-08 02:49:18 -07:00
Dan Zheng
e377436169 Merge branch 'master' of github.com:apple/swift into autodiff_upstream_conformances_derivatives_master 2020-04-08 02:49:17 -07:00
Dan Zheng
da36555aa5 [AutoDiff upstream] Gardening.
- Standardize filenames: `XXXDifferentiation.swift`.
  - Use Pascal or snake case consistently.
- Formatting changes.
2020-04-08 02:49:12 -07:00
Joe Groff
5a3d2a9e8f Merge pull request #30866 from jckarter/objc_getClass_compat_hook_main_only
Compatibility50: Install objc_getClass hook only in main executable
2020-04-07 19:25:22 -07:00
Joe Groff
4c92234662 Compatibility50: Install objc_getClass hook only in main executable
Xcode and other build systems currently link the compatibility libraries into every executable
or dynamic library, which can cause a chain of objc_getClass compatibility hacks to pile up if
a program loads a lot of dynamic libraries. In the static constructor that installs the
objc_getClass compatibility shim, check whether it's running on behalf of the main executable
before installing the shim.
2020-04-07 16:23:29 -07:00
Ravi Kandhadai
4264b39b23 Merge pull request #26969 from ravikandhadai/oslog-user-model
[Sema Diagnostics] Add Miscellaneous Sema diagnostics to enforce that the new os log APIs and atomics are passed constants for certain arguments
2020-04-07 13:23:10 -07:00
Xi Ge
516b4d4ca5 Revert "[build] Don't reset 'swiftlib_link_flags_all' unnecessarily" 2020-04-06 21:18:07 -07:00
Dario Rexin
999b93bfdb Merge pull request #30815 from ktoso/wip-mangledTypeName
Improve usability of _mangledTypeName with Any.Type arguments
2020-04-06 20:49:13 -07:00
Ravi Kandhadai
b57a1d7c0e [Sema] Add miscellaneous sema diagnostics to check that the new os log
APIs and atomic operations are passed compile-time constants for
certain arguments.
2020-04-06 18:41:13 -07:00
Saleem Abdulrasool
905341321b Merge pull request #30020 from buttaface/link_flags
[build] Don't reset 'swiftlib_link_flags_all' unnecessarily
2020-04-06 15:47:36 -07:00
Stephen Canon
248c554524 Add Float16 to stdlib (#30130)
Add Float16 (IEEE 754 binary16) to the standard library, plus assorted runtime support operations.

Swift Evolution thread: https://forums.swift.org/t/se-0277-float16/33546
2020-04-06 17:57:44 -04:00