Commit Graph

224 Commits

Author SHA1 Message Date
Roman Levenstein
03dba709f3 [stdlib-code-size] Do not produce useless partial specializations for the shift operations on integers
This reduces the stdlib binary size by 200KB.
2017-08-07 17:12:26 -07:00
Nate Cook
1698fd388b [stdlib] Manually propagate integer documentation 2017-08-01 15:17:20 -05:00
Nate Cook
781f6326bd [stdlib] Various documentation revisions and fixes
- Revisions to unsafeDowncast and withVaList
- Fix the Int64/UInt64 discussion
- Buffer pointer revisions
- Fix Optional example to use new integer methods
- Revise and correct some UnsafeRawBufferPointer docs
- Fix symmetricDifference examples
- Fix wording in FloatingPoint.nextDown
- Update ImplicitlyUnwrappedOptional
- Clarify elementsEqual
- Minor integer doc fixes
- Comment for _AppendKeyPath
- Clarification re collection indices
- Revise RangeExpression.relative(to:)
- Codable revisions
2017-07-31 10:56:53 -05:00
Maxim Moiseev
52259b714b Merge pull request #11193 from xwu/lossless-integers
[stdlib] Conform fixed-width integer types to LosslessStringConvertible
2017-07-28 20:10:07 -07:00
Max Moiseev
5563ed1999 [stdlib] Remove reintroduced extendingOrtruncating call 2017-07-28 12:16:56 -07:00
Nate Cook
a7ce287a53 Merge branch 'master' into integers-revised 2017-07-28 12:23:48 -05:00
Maxim Moiseev
47e78c071a Merge pull request #11044 from apple/rationalize-bitshifting
[stdlib] Rationalize bitshifting in protocols
2017-07-27 14:50:14 -07:00
Max Moiseev
1c3e597928 [stdlib] Get rid of ArithmeticOverflow type 2017-07-26 11:09:36 -07:00
Maxim Moiseev
5d47a0d98d [stdlib] init<T : FloatingPoint> ==> init<T : BinaryFloatingPoint> 2017-07-26 11:09:36 -07:00
Maxim Moiseev
a5ff35cd41 [stdlib] extendingOrTruncating: => truncatingIfNeeded: 2017-07-26 11:09:36 -07:00
Xiaodi Wu
f817803d01 Conform fixed-width integer types to LosslessStringConvertible 2017-07-25 21:57:42 -05:00
swift-ci
92898618cb Merge pull request #10982 from apple/stdlib-swift4-modernization 2017-07-20 18:56:23 -07:00
Dave Abrahams
33e9ec4690 [stdlib] Rationalize bitshifting in protocols
Only FixedWidthInteger, not BinaryInteger, should have masking shifts.
BinaryInteger should have a non-masking shift requirement.

Removed some dead code.
2017-07-18 16:00:44 -07:00
Dave Abrahams
fb35257511 [stdlib] Drop some @available(introduced:...)
These annotations make it hard to write code that works in both Swift 3 and Swift 4, so if they aren't needed we should remove them.
2017-07-16 07:22:09 -07:00
Dave Abrahams
c497969987 [stdlib] Swift4 Modernizations Compatible with Swift 3.2 2017-07-14 17:54:33 -07:00
Károly Lőrentey
9996d071c4 [stdlib] Define custom Words types for each standard fixed with integer
This adds 8 more collection views, but makes integer definitions
more consistent across all the available bit widths and
between 32-bit and 64-bit platforms.
2017-07-11 04:53:23 +02:00
Károly Lőrentey
735fe97242 [stdlib] Fix sign extension in word -> multi-word integer conversions
This fixes integer conversion issues on 32-bit platforms.
2017-07-11 04:33:14 +02:00
Károly Lőrentey
e975445b70 [stdlib] Make UInt.Words.var internal
We don’t need Words’ members to be @_transparent;
simple conversions use _lowWord instead.
2017-07-11 03:26:20 +02:00
Károly Lőrentey
1dccb45278 [stdlib] Revert @_transparent to prevent SIL size explosion 2017-07-11 03:17:56 +02:00
Károly Lőrentey
826f8daf4a [stdlib] _lowUWord => _lowWord 2017-07-10 22:40:52 +02:00
Károly Lőrentey
c8d4fd4242 [stdlib] Remove BinaryInteger._word(at:)
Removes BinaryInteger's _word(at:) requirement and its
countOfRepresentedWords property, making the words property the
sole way to access an integer's words.

This is a better fix for https://bugs.swift.org/browse/SR-5275.
2017-07-10 22:40:52 +02:00
Károly Lőrentey
7836268d45 [stdlib] Implement BinaryInteger.words in standard integer types.
Introduces the following new collection types as lightweight
views of a corresponding integer value:

- UInt.Words
- UInt64.Words (on 32-bit platforms)
- DoubleWidth.Words

The rest of the standard integer types define Words as a typealias
to one of the first two of these, based on their width.
2017-07-10 19:03:34 +02:00
Xiaodi Wu
3916380e7c Prefix countRepresentedWords with underscore [NFC]
Per comments, `countRepresentedWords` is slated for eventual removal along with `_words(at:)`; it's not a part of SE-0104, so let's show users that it's not intended for public consumption.
2017-06-21 20:01:14 -05:00
Max Moiseev
42e8491080 [stdlib] Default implementation for BinaryInteger._word(at:)
Temporarily addresses https://bugs.swift.org/browse/SR-5275
2017-06-21 13:46:16 -07:00
Maxim Moiseev
651aaa8b54 Merge pull request #10206 from moiseev/unambiguous-bitpattern
[stdlib] Resolve the ambiguity for Int32.init(bitPattern:)
2017-06-14 11:34:32 -07:00
Max Moiseev
90a20ea015 [stdlib] Resolve the ambiguity for Int32.init(bitPattern:)
When this initializer is invoked with an integer literal, the expression
is ambiguous, since both UIn32 and Float are
RepresentableByIntegerLiteral.

Fixes: https://bugs.swift.org/browse/SR-5176
2017-06-13 17:28:19 -07:00
Nate Cook
b7af9bfe83 [stdlib] Remove SeeAlso tags 2017-06-13 11:23:51 -05:00
Nate Cook
6133adc413 [stdlib] Move DoubleWidth into its own file 2017-06-06 08:54:15 -07:00
Maxim Moiseev
0c108340d1 Merge pull request #9367 from natecook1000/nc-doublewidth
[stdlib] DoubleWidth Implementation
2017-06-05 10:03:42 -07:00
Roman Levenstein
00d663d172 [sil-generic-specializer] Add @_semantics("optimize.sil.specialize.generic.partial.never") to disable partial specialization on functions
This new @_semantics is used to annotate some very big functions in the standard library. It reduced the code size of the stdlib by 2%.
2017-06-01 16:33:18 -07:00
Nate Cook
42efcdb246 One more from @xwu + 80-column fixes 2017-06-01 12:53:05 -05:00
Max Moiseev
53004a1015 [stdlib] Renames and tests for Swift 3 compatibility mode
Addresses <rdar://problem/32432481>
2017-05-26 16:28:11 -07:00
Nate Cook
2612e00eaf Additional notes from @xwu 2017-05-26 08:46:42 -05:00
Nate Cook
2f9bf3cb1c Add an abstract for DoubleWidth 2017-05-25 18:38:45 -05:00
Nate Cook
1149eeac16 Incorporate feedback from @moiseev
- Also clean up some 80-column issues
- And improve some tests from before literal expressibility
2017-05-25 18:32:15 -05:00
Nate Cook
237d8775dc Catch overflow into high bit in signed multiplication 2017-05-25 15:04:34 -05:00
Nate Cook
e5fb87128e Revert multipliedFullWidth for 64-bit ints on 32-bit platforms 2017-05-25 03:47:52 -05:00
Nate Cook
5ab34bf6f0 Add floating-point initializers and tests 2017-05-24 19:16:26 -05:00
Nate Cook
06490e6a44 Shortcut on binary division 2017-05-24 19:16:26 -05:00
Nate Cook
7353042a4f Fix overflow issue 2017-05-24 19:16:26 -05:00
Nate Cook
1e59f65a91 Implement tricky full-width multiply/divides 2017-05-24 19:16:26 -05:00
Nate Cook
2edbb085d0 Fix overflow issues 2017-05-24 19:16:26 -05:00
Nate Cook
788f4e81b6 Add recursive constraints for integer Magnitude 2017-05-24 19:16:26 -05:00
Nate Cook
b935be828c Remove endian operations from fixed-width ints 2017-05-24 19:16:26 -05:00
Nate Cook
b72449bc72 Provide implementations or masking bitshift operators 2017-05-24 19:16:26 -05:00
Nate Cook
a539919052 Add negation operator/method to DoubleWidth 2017-05-24 19:16:26 -05:00
Nate Cook
c866bcf3d4 Convert endian symbols to default implementations 2017-05-24 19:16:26 -05:00
Nate Cook
b2676f90ca Use literals instead of DoubleWidth inits 2017-05-24 19:16:26 -05:00
Nate Cook
8926df9bbc [stdlib] Partial implementation of DoubleWidth 2017-05-24 19:16:26 -05:00
Xiaodi Wu
afa4e12fa6 Refine wording in doc comment 2017-05-23 21:10:04 -05:00