Commit Graph

665 Commits

Author SHA1 Message Date
swift-ci
333320679f Merge remote-tracking branch 'origin/master' into master-next 2019-08-28 19:30:21 -07:00
swift-ci
4e9cf240bd Merge remote-tracking branch 'origin/master' into master-rebranch 2019-08-28 19:24:21 -07:00
Nikolai Vazquez
ba0612f2e9 Add Builtin.isConcrete<T>(T.Type) -> Int1
Returns `true` if `T.Type` is known to refer to a concrete type. The
implementation allows for the optimizer to specialize this at -O and
eliminate conditional code.

Includes `Swift._isConcrete<T>(T.Type) -> Bool` wrapper function.
2019-08-27 16:51:09 -07:00
Davide Italiano
bf2b57bef0 [AST] Catch up with the newly introduced builtin.
Unbreaks master-next.
2019-08-27 15:51:30 -07:00
Arnold Schwaighofer
20efacf2d6 Merge remote-tracking branch 'upstream/master' into master-next 2019-08-26 13:30:41 -07:00
swift-ci
abb9f9b8ab Merge remote-tracking branch 'origin/master' into master-rebranch 2019-08-26 11:05:16 -07:00
Doug Gregor
0f80384942 [AST] Switch builtin creation over to the abstract generic signature request 2019-08-26 09:54:20 -07:00
Brent Royal-Gordon
fb20b503ba Merge branch 'master' into master-rebranch
# Conflicts:
#	lib/ClangImporter/ClangImporter.cpp
#	test/IRGen/builtins.swift
#	test/IRGen/enum.sil
#	tools/driver/autolink_extract_main.cpp
#	utils/build-presets.ini
2019-08-08 17:07:59 -07:00
swift-ci
390e58228d Merge remote-tracking branch 'origin/master' into master-next 2019-07-22 20:30:09 -07:00
Slava Pestov
a532a325e1 AST: Move a few methods from VarDecl down to ParamDecl 2019-07-22 20:19:09 -04:00
Joe Groff
d38a72c4ad Merge branch 'master' into master-next 2019-07-18 13:14:39 -07:00
eeckstein
63a1a42643 Merge pull request #26185 from eeckstein/old-condfail
Support the old single-parameter Builtin.condfail
2019-07-18 13:38:47 +02:00
Michael Gottesman
eb9b24104e Merge pull request #26158 from gottesmm/pr-ed0fb2c51d1ce701156c957f511f6ee3b57f1e7a
[ast] Refactor Builtin printing logic from ASTPrinter -> BuiltinInst.
2019-07-17 11:24:56 -07:00
Erik Eckstein
340b0ed001 Support the old single-parameter Builtin.condfail
We have to be source compatible to be able to parse old swiftinterface files where the old Builtin.condfail is used in inlineable functions.

rdar://problem/53176692
2019-07-17 17:41:59 +02:00
Erik Eckstein
117b1dafe6 Rename the two-parameter Builtin.condfail(c, message) to Builtin.condfail_message(c, message)
This is necessary to also support the old single paramter Builtin.condfail(c)
2019-07-17 17:41:59 +02:00
Michael Gottesman
f952ff0ee4 [ast] Move printing code from ASTPrinter onto a helper on BuiltinType and have ASTPrinter call that instead. 2019-07-16 23:26:01 -07:00
Erik Eckstein
b40ce6b34f SIL: add a failure message operand to Builtin.condfail
The SIL generation for this builtin also changes: instead of generating the cond_fail instructions upfront, let the optimizer generate it, if the operand is a static string literal.
In worst case, if the second operand is not a static string literal, the Builtin.condfail is lowered at the end of the optimization pipeline with a default message: "unknown program error".
2019-07-16 14:44:09 +02:00
Brent Royal-Gordon
d5a2912a26 Revert "Better runtime failure messages (not yet enabled by default)" 2019-07-15 13:42:40 -07:00
Erik Eckstein
3fd7eea96c SIL: add a failure message operand to Builtin.condfail
The SIL generation for this builtin also changes: instead of generating the cond_fail instructions upfront, let the optimizer generate it, if the operand is a static string literal.
In worst case, if the second operand is not a static string literal, the Builtin.condfail is lowered at the end of the optimization pipeline with a default message: "unknown program error".
2019-07-12 14:03:13 +02:00
swift-ci
f1cdb876a4 Merge remote-tracking branch 'origin/master' into master-next 2019-07-03 19:49:53 -07:00
Ravi Kandhadai
5430aa0b17 [Builtin][SILGen][IRGen] Create a new builtin "globalStringTablePointer":
String -> Builtin.RawPointer that given a string constructed from a
literal, returns the address of the string literal in the global string
table of the compiled binary as a pointer.
2019-07-03 16:47:34 -07:00
Saleem Abdulrasool
649db5c6f7 AST: adjust for SVN r363240
A new Intrinsic Info Table type `VecElementArgument` has been introduced
upstream.  Account for it in the covered switch.
2019-06-13 08:46:14 -07:00
Argyrios Kyrtzidis
04992a58d1 [CMake] Provide a way to build the minimum things necessary for the syntax parser library
These changes allow to optionally perform a very fast build that is targeted to only produce the syntax parser library.
Part of addressing rdar://48153331
2019-02-23 11:31:31 -08:00
John McCall
b1be41a1d2 Implement some more LLVM intrinsic type-decoding rules. 2019-02-08 14:22:57 -08:00
Pavel Yaskevich
64fa0ee729 [TypeChecker] Add Builtin operation to trigger/test fallback diagnostic 2019-01-07 10:42:00 -08:00
Jordan Rose
7e8c007757 Remove unused parameter from helper function in Builtins.cpp
Intrinsics never have custom function type ExtInfo anymore. (This used
to be where the "noreturn" bit lived, but now that's represented by
Swift.Never.)

No functionality change.
2018-12-04 11:22:38 -08:00
Jordan Rose
e786431a3b Use proper type for getLLVMIntrinsicID
At one point we were probably trying to avoid including
llvm/IR/Intrinsics.h in Builtins.h but that ship has sailed.

No functionality change.
2018-12-04 11:22:38 -08:00
Jordan Rose
805ae332e1 Cache LLVM attributes for intrinsics
Looking these up is slow because the attribute lists get rebuilt and
reuniqued in the LLVM context each time. Saving them is a single
pointer per IntrinsicInfo and IntrinsicInfos are already cached in
each SILModule.

This shaves about 4s off optimizing the standard library (72s out of a
3:00+ build), and probably has much less effect anywhere else. That
is, it's not /really/ important after all, but it was an easy bit of
the profile to hammer down.
2018-12-04 11:22:37 -08:00
Carl Peto
b914464712 Remove apparently obsolete builtin functions (#20947)
* Remove apparently obsolete builtin functions.

- Remove s_to_u_checked_conversion and u_to_s_checked_conversion functions from builtin AST parsing, SIL/IR generation and from SIL optimisations.

* Remove apparently obsolete builtin functions - unit tests.

- Remove unit tests for SIL transformations relating to s_to_u_checked_conversion and u_to_s_checked_conversion builtin functions.
2018-12-03 07:07:34 -05:00
Marc Rasi
bf18697b4f parsing, typechecking, and SILGen for #assert
`#assert` is a new static assertion statement that will let us write
tests for the new constant evaluation infrastructure that we are working
on. `#assert` works by lowering to a `Builtin.poundAssert` SIL
instruction. The constant evaluation infrastructure will look for these
SIL instructions, const-evaluate their conditions, and emit errors if
the conditions are non-constant or false.

This commit implements parsing, typechecking and SILGen for `#assert`.
2018-11-07 16:34:17 -08:00
John McCall
abdba1d3f4 Change the integer-literal type from Int2048 to IntLiteral.
Part of SR-290.
2018-10-31 23:14:58 -04:00
John McCall
cf511445e2 Basic support for Builtin.IntegerLiteral. 2018-10-31 18:42:34 -04:00
John McCall
3a7c649d3e Mark some builtins as taking an owned argument.
The goal here is for the SILGen of these builtins to receive an owned
value so that it will perform an owned->owned conversion and therefore
produce a +1 result, as generally expected.  Without this, SILGen will
perform a borrowed->borrowed conversion, and the copy of the result (if
it even happens) may happen after the argument's borrow scope has ended.
2018-10-20 00:24:38 -04:00
Joe Groff
93b5de61e7 Implement the final approved syntax for SE-227 identity key paths.
`\.self` is the final chosen syntax. Implement support for this syntax, and remove the stopgap builtin and `WritableKeyPath._identity` property that were in place before.
2018-09-19 11:45:13 -07:00
Saleem Abdulrasool
0f9ec33dce AST, SIL: use llvm::StringSwitch over cascading if/else if
Visual Studio's compiler has a hard limit on the number of if/else if cascading
blocks at 128 elements (https://msdn.microsoft.com/en-us/library/dcda4f64.aspx).
Use `llvm::StringSwitch` which is both easier to read (although less imported in
this case due to the macro generation) and allows us to avoid this limit.
2018-09-13 10:50:29 -07:00
Slava Pestov
c360c82850 AST: Automatically create the 'self' parameter when needed
Parsed declarations would create an untyped 'self' parameter;
synthesized, imported and deserialized declarations would get a
typed one.

In reality the type, if any, depends completely on the properties
of the function in question, so we can just lazily create the
'self' parameter when needed.

If the function already has a type, we give it a type right there;
otherwise, we check if a 'self' was already created when we
compute a function's type and set the type of 'self' then.
2018-08-25 10:44:55 -07:00
Johannes Weiss
bd2de10057 Builtin.isbitwisetakable 2018-08-24 16:03:38 +01:00
Erik Eckstein
7c06d4f8ab Remove the pinning built-ins.
They are not used anymore after removing the pinning adressors.
2018-08-23 12:47:56 -07:00
Joe Groff
d3bd01e8c8 Merge pull request #18804 from jckarter/identity-key-path
Runtime support for identity key paths.
2018-08-20 18:04:17 -07:00
Joe Groff
44b55ae197 Runtime support for identity key paths.
Make sure the implementation can handle a key path with zero components by removing inappropriate assumptions that the number of components is always non-empty. Identity key paths also need some special behavior:

- Appending an identity key path should be an identity operation for the other operand
- Identity key paths have a `MemoryLayout.offset(of:)` zero
- Identity key paths interop with KVC as key paths to `@"self"`

To be able to exercise and test this behavior, add a `Builtin.identityKeyPath()` function and `WritableKeyPath._identity` accessor in lieu of finalized syntax.
2018-08-20 14:00:46 -07:00
Slava Pestov
527ff375dc AST: Rename old form of {Generic,}FunctionType::get() to getOld()
This makes it easier to grep for and eventually remove the
remaining usages.

It also allows you to write FunctionType::get({}, ...) to call the
ArrayRef overload empty parameter list, instead of picking the Type
overload and calling it with an empty Type() value.

While I"m at it, in a few places instead of renaming just clean up
usages where it was completely mechanical to do so.
2018-08-17 19:28:17 -04:00
Slava Pestov
c0e33277f3 AST: Convert builtins to use AnyFunctionType::Param 2018-08-13 21:13:10 -07:00
Slava Pestov
d31d35a788 AST: Remove a few usages of TypeBase::getInOutObjectType() 2018-08-13 21:13:10 -07:00
Slava Pestov
4b258e86e6 AST: Stop setting contextual types on ParamDecls
VarDecl::getType() lazily maps the interface type into context if needed.
2018-08-10 13:33:12 -07:00
swift-ci
d40f3d3ced Merge remote-tracking branch 'origin/master' into master-next 2018-07-23 13:49:26 -07:00
Slava Pestov
106878005e AST: Use AbstractFunctionDecl::computeType() 2018-07-23 02:09:43 -07:00
swift-ci
b4bae42909 Merge remote-tracking branch 'origin/master' into master-next 2018-07-21 13:49:33 -07:00
Slava Pestov
bfc4121971 AST: Rework AbstractFunctionDecl construction away from multiple parameter lists
There are two general constructor forms here:

- One took the number of parameter lists, to be filled in later.
  Now, this takes a boolean indicating if there is an implicit
  'self'.

- The other one took the actual parameter lists and filled them
  in right away. This now takes a separate 'self' ParamDecl and
  ParameterList.

Instead of storing the number of parameter lists, an
AbstractFunctionDecl now only needs to store if there is a 'self'
or not.

I've updated most places that construct AbstractFunctionDecls to
properly use these new forms. In the ClangImporter, there is
more code that remains to be untangled, so we continue to build
multiple ParameterLists and unpack them into a ParamDecl and
ParameterList at the last minute.
2018-07-21 07:30:30 -07:00
swift-ci
a792448233 Merge remote-tracking branch 'origin/master' into master-next 2018-07-17 14:09:53 -07:00
David Zarzycki
b29d2784ed [AST] NFC: Formalize Decl validation tracking via RAII
After this change, RAII ensures that the validation state is accurate as
possible.
2018-07-12 10:30:26 -04:00