Commit Graph

1309 Commits

Author SHA1 Message Date
Dave Zarzycki
669ca06213 stdlib: mark SignedNumber methods as @transparent
Swift SVN r11757
2013-12-31 01:54:11 +00:00
Dave Zarzycki
9bfa643933 stdlib: abs() should use Builtin.*fabs* on floats
Swift SVN r11745
2013-12-30 21:42:22 +00:00
Doug Gregor
8383a25989 Remove the __less__ hack; use < instead.
Note that we have to work around <rdar://problem/14432081> a bit.

Swift SVN r11726
2013-12-29 21:05:16 +00:00
Doug Gregor
d1054b9e86 Eliminate the __equal__ protocol requirement; use == directly.
This is DaveA's patch, slightly tweaked, which works properly now that
<rdar://problem/15715996> is fixed.

Swift SVN r11725
2013-12-29 20:45:25 +00:00
Dave Abrahams
afbbbd1287 [stdlib] Add a facility for calling "C" functions that take va_list arguments
This code has only been tested on x86_64, but is designed to work on
the other platforms supported by Apple.

Swift SVN r11561
2013-12-22 02:37:33 +00:00
Dave Abrahams
68c47c7121 [stdlib] Remove ObjectPointer.swift; it was not ready for prime-time
Swift SVN r11131
2013-12-11 17:20:06 +00:00
Dave Abrahams
4c98b501a6 [stdlib] Expose NSString.stringWithContentsOfFile on String
Along the way created bridging utilities for ObjectiveC functions that
take "out" arguments and added an fmap for operating on Optionals

Swift SVN r11123
2013-12-11 07:24:05 +00:00
Doug Gregor
a5167f6bac Remove the type-checker performance workaround in <rdar://problem/14925518>
Swift SVN r11118
2013-12-11 03:40:22 +00:00
Dmitri Hrybenko
b55f943d0d stdlib/FixedPoint: fix indentation
Swift SVN r11089
2013-12-10 20:44:03 +00:00
Joe Groff
ab95d6cd11 stdlib: Add a BitwiseOperations protocol.
Collect the bitwise logical operators under a protocol. Add an 'allZeros' static method to produce the 'zero' identity value for the type when used with bitwise operations.

Swift SVN r11068
2013-12-10 04:03:20 +00:00
Jordan Rose
b4fe56eb1c Actually fix the Makefile build for multi-file Swift libraries.
The hack to get the LLVM build system to do what we want is to define a
custom build rule for "XYZ.o" and then add "XYZ" as a dummy source file
to the SOURCES variable, which the LLVM Makefile system uses. To make it
clear that something unusual is going on here, I've changed all existing
instances of this to use "XYZ.o" in SOURCES, rather than having that name
be derived from "XYZ.swift" or whatever.

The actual Swift source files go in SWIFT_SOURCES for the time being
(and possibly forever, since Swift sources will always be built together).

Swift SVN r11058
2013-12-10 00:23:43 +00:00
Anna Zaks
b75cb37cf8 Reapply r10534 in a more convenient form.
Swift SVN r10944
2013-12-06 22:10:52 +00:00
Dave Abrahams
983438948f [stdlib] Rip out mistakenly committed test code
Swift SVN r10920
2013-12-06 06:02:25 +00:00
Dave Abrahams
01b2a39029 [stdlib] Add a length property to NewString
Swift SVN r10919
2013-12-06 06:02:24 +00:00
Dmitri Hrybenko
f08ee12841 stdlib/FloatingPoint: add APIs to handle special floating point values
See IEEEFloatingPointNumber protocol for a full list of new APIs and
documentation.


Swift SVN r10826
2013-12-05 01:36:15 +00:00
Doug Gregor
95ebc6b596 Eliminate the use of the T(x) syntax as type coercion.
Long ago we decided to eliminate the use of this syntax for type
coercion, but we didn't have a good replacement (now we do: x as T)
and the type checker used this ability to handle string
interpolation. Switch string interpolation over to disjunction
constraints.


Swift SVN r10789
2013-12-04 21:11:57 +00:00
Dave Zarzycki
d08712cb35 15242776 stdlib: merge "Array" and "Slice" into Array.swift
The "HArray" name is temporary.

Swift SVN r10708
2013-12-01 08:16:43 +00:00
Dave Abrahams
88b0edaf82 [stdlib] NewString: conversion from string literals
Swift SVN r10651
2013-11-22 00:40:08 +00:00
Dave Zarzycki
18fc62f4eb 15489271 Adopt @transparent on min/max static var min/max decls of the integer types
Swift SVN r10534
2013-11-17 23:16:41 +00:00
Dave Zarzycki
2c24ee6a29 Switch integer min/max static funcs to static vars
Swift SVN r10533
2013-11-17 22:42:54 +00:00
Dmitri Hrybenko
81dc5deee8 Change 'def' keyword back to 'func'
Swift SVN r10522
2013-11-17 07:45:28 +00:00
Anna Zaks
3e8fa762ec Dynamically and statically dianose a conversion of a negative integer to an unsigned int.
Swift SVN r10513
2013-11-16 01:26:54 +00:00
Anna Zaks
0f390c9c54 Add dynamic checking for sign errors(overflows) during signed <-> unsigned conversions for integers of the same type.
Add unsafe alternatives to allow unsafe conversions:
 - asUnsigned()
 - asSigned()

Swift SVN r10476
2013-11-15 00:16:18 +00:00
Dave Zarzycki
16f2b951e6 15466633 _getBuiltinArrayBoundValue should be @transparent
Swift SVN r10459
2013-11-14 08:11:40 +00:00
Chris Lattner
3f0976677f secondary cleanups now that bool is a struct: we can directly access .value
to convert a Bool to i1 and can use the Bool ctor to convert i1 to Bool.



Swift SVN r10437
2013-11-13 23:39:26 +00:00
Anna Zaks
b687c3ce9c Add runtime integer truncation checking to the conversion constructors
Add new builtins(by generalizing, renaming, and extending the builtins used for compile time integer literal checking). These new builtins truncate integers and check for overflow/truncation errors at runtime. Use these for FixedPoint conversion constructors.

Fix a routine in stdlib's String implementation and a test that relied on bitwise behavior of the constructors (and triggered overflows).

TODO:
- Teach CCP about these to get static checking.
- Add special builtins for same size signed <-> unsigned conversions.

Swift SVN r10432
2013-11-13 21:54:34 +00:00
Anna Zaks
084bdfd05f Change the signature of the trunc builtins to return a tuple containing teh overflow bit as well as the result.
This is a first step in generalizing the builtin to handle non-constant int to int truncations.

Swift SVN r10341
2013-11-11 21:20:04 +00:00
Dmitri Hrybenko
e36ebb217c Remove empty files
Swift SVN r10074
2013-11-09 08:01:08 +00:00
Dave Abrahams
38b9e6808f [stdlib] CharacterEncoding.swift => Unicode.swift
Also enshrine the tests in the test suite

Swift SVN r10057
2013-11-08 22:17:50 +00:00
Dave Abrahams
645ce0b664 [stdlib] Add support for bound protocols
Protocols with associated types can't currently be used as existential
types.  Combined with the inability to create type constraints on
generic functions nested in generic types based on the outer type and
the inability to create closures of generic type and the inability to
create protocol constraints that require generic functions and the
inability to create protocols with init() requirements... and this is
what we get.

Swift SVN r10034
2013-11-08 06:29:29 +00:00
Chris Lattner
50054458e7 remove SIMD vector support from the stdlib. I think we all really want this,
but we don't have time right now to make it great.  This shrinks the stdlib
by 9000 lines :-)


Swift SVN r9902
2013-11-03 16:10:57 +00:00
Chris Lattner
68af974227 Remove 'axle' related code and build machinery. It turns out that we
will not be pursuing this project in the immediate future.



Swift SVN r9901
2013-11-03 16:04:27 +00:00
Dave Abrahams
21d196a9ef [stdlib] Implement basic transcoding of UTF8 and UTF16
Swift SVN r9896
2013-11-02 01:32:49 +00:00
Dmitri Hrybenko
91ce21666d Change 'func' keyword to 'def'
I tried hard find all references to 'func' in documentation, comments and
diagnostics, but I am sure that I missed a few.  If you find something, please
let me know.

rdar://15346654


Swift SVN r9886
2013-11-02 01:00:42 +00:00
Greg Parker
beaa56d8e9 Add Builtin.Word and use it to implement swift.Word.
Swift SVN r9864
2013-11-01 00:11:22 +00:00
Greg Parker
b342f68392 Fix Float80 suppression.
Swift SVN r9838
2013-10-31 01:47:27 +00:00
Dmitri Hrybenko
c216a848b9 stdlib/FloatingPoint: port floating point implementation to gyb
No changes in functionality intended.


Swift SVN r9799
2013-10-30 17:14:12 +00:00
Dmitri Hrybenko
462bc95c6a stdlib/FixedPoint: use camel case names in generator script
Swift SVN r9796
2013-10-30 17:06:55 +00:00
Joe Groff
5711ec1626 stdlib: Trap overflows with condfail instead of if { trap }.
Swift SVN r9594
2013-10-22 16:08:33 +00:00
Dave Abrahams
f3053a8bea [stdlib] WIP: prototype the basic data structure of the new string design.
Nothing is tested yet, but it all compiles

Swift SVN r9507
2013-10-19 00:10:02 +00:00
Greg Parker
fbd1c95292 Add support for iOS builds using cmake.
Swift SVN r9499
2013-10-18 21:52:37 +00:00
Dave Zarzycki
62d3b16cd8 Workaround 15254902 -- Simple generic functions aren't inlined
Swift SVN r9464
2013-10-17 21:21:59 +00:00
Jordan Rose
9a4528c904 Move gyb from tools/ to utils/
For consistency with the vague idea that things that are only useful for
compiler developers should go in utils/, not tools/. Unless they need
build system support.

Swift SVN r9433
2013-10-17 00:08:48 +00:00
Howard Hinnant
b78fefdf0b Vector is dead. Long live Array.
Swift SVN r9432
2013-10-16 23:57:29 +00:00
Dmitri Hrybenko
13b834c9c0 stdlib/FixedPoint: move more @transparent annotations to extensions, as
suggested by Anna


Swift SVN r9431
2013-10-16 23:57:16 +00:00
Dmitri Hrybenko
2aed708565 stdlib/FixedPoint, stdlib/Float: mark constructors and comparison functions as @transparent
Swift SVN r9430
2013-10-16 23:35:11 +00:00
Dmitri Hrybenko
381d6ffec2 stdlib/FixedPoint: Fix coding style
Swift SVN r9416
2013-10-16 19:29:21 +00:00
Anna Zaks
740fc0a9d9 Revert "Revert "Reimplement integer arithmetic overflow checking to use special, error on overflow builtins""
(This only fails under -DSWIFT_OPTIMIZED=NO; most likely due to an llvm bug.)

We've decided that it's best to specialize each arithmetic builtin that could overflow, instead of calling a separate generic "staticReport" builtin and passing it enough info to produce the message. The main advantage of this approach is that it would be possible for the compiler to customize the message and better link it to the builtin that overflows. For example, the constants that participated in the computation could be printed. In addition, less code will be generated and the compiler could, in the future, automatically emit the overflow diagnostics/trap at runtime.

This patch introduces new versions of op_with_overflow swift builtins. Which are lowered to llvm.op_with_overflow builtins in IRGen after the static diagnostics. If the last argument to the builtins evaluates to true, the overflow is unintentional. CCP uses the builtins to diagnose the overflow detectable at compile time. FixedPoint is changed to rely on these in implementation of primitive arithmetic operations.

Swift SVN r9328
2013-10-14 21:42:33 +00:00
Mon Ping Wang
00467ba953 Reintroduce "Add support for Axle library." from 9292. Added an dependency to prevent building the
core and axle core at the same time.


Swift SVN r9309
2013-10-14 07:51:19 +00:00
Dmitri Hrybenko
f40ba621a8 Make integer literals 2048-bit. This covers the whole Float64 range.
Swift SVN r9308
2013-10-14 05:18:55 +00:00