Commit Graph

30 Commits

Author SHA1 Message Date
Ben Barham
ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00
Slava Pestov
b2ffac54d3 IRGen: Fulfill pack metadata from tuple metadata
When the SelfMetadata in a witness thunk is the tuple type (repeat each Self),
we can fulfill the pack shape and type metadata for Pack{repeat each Self}
from tuple metadata.

The length is trivially projected; the type metadata pack is slightly more
involved, because tuple metadata stores a list of element/offset pairs, so
we must stack allocate a pack and fill it in.
2023-08-24 17:57:10 -04:00
Slava Pestov
8dfeeebeb5 IRGen: Support tuple labels in emitDynamicTupleTypeMetadataRef() 2023-07-27 13:39:52 -04:00
Evan Wilde
250082df25 [NFC] Reformat all the LLVMs
Reformatting everything now that we have `llvm` namespaces. I've
separated this from the main commit to help manage merge-conflicts and
for making it a bit easier to read the mega-patch.
2023-06-27 09:03:52 -07:00
Evan Wilde
f3ff561c6f [NFC] add llvm namespace to Optional and None
This is phase-1 of switching from llvm::Optional to std::optional in the
next rebranch. llvm::Optional was removed from upstream LLVM, so we need
to migrate off rather soon. On Darwin, std::optional, and llvm::Optional
have the same layout, so we don't need to be as concerned about ABI
beyond the name mangling. `llvm::Optional` is only returned from one
function in
```
getStandardTypeSubst(StringRef TypeName,
                     bool allowConcurrencyManglings);
```
It's the return value, so it should not impact the mangling of the
function, and the layout is the same as `std::optional`, so it should be
mostly okay. This function doesn't appear to have users, and the ABI was
already broken 2 years ago for concurrency and no one seemed to notice
so this should be "okay".

I'm doing the migration incrementally so that folks working on main can
cherry-pick back to the release/5.9 branch. Once 5.9 is done and locked
away, then we can go through and finish the replacement. Since `None`
and `Optional` show up in contexts where they are not `llvm::None` and
`llvm::Optional`, I'm preparing the work now by going through and
removing the namespace unwrapping and making the `llvm` namespace
explicit. This should make it fairly mechanical to go through and
replace llvm::Optional with std::optional, and llvm::None with
std::nullopt. It's also a change that can be brought onto the
release/5.9 with minimal impact. This should be an NFC change.
2023-06-27 09:03:52 -07:00
John McCall
159c653780 Add the tuple_pack_element_addr SIL instruction.
This allows dynamically indexing into tuples.  IRGen not yet
implemented.

I think I'm going to need a type_refine_addr instruction in
order to handle substitutions into the operand type that
eliminate the outer layer of tuple-ness.  Gonna handle that
in a follow-up commit.
2023-02-07 23:22:35 -05:00
Erik Eckstein
90501578b0 IRGen: fix statically initialized globals which contain an empty type.
This caused a compiler assert or a miscompile

rdar://problem/34123143
2017-08-29 09:53:18 -07: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
Huon Wilson
25b41906a2 [IRGen] Handle padding in global structs.
Previously there was a mismatch between SIL's concept of a
struct (padding is implicit) and LLVM's (padding is explicit) in IRGen's
constant evaluator. The explicit padding fields need to be given a value
in the IR.

This patch also moves the (currently small) list of constant evaluation
functions into their own file.

Fixes SR-716.
2016-09-29 05:21:49 -07:00
John McCall
83dc7cffe8 RemoteAST: implement member-offset calculations for tuples. 2016-04-27 19:00:30 -07:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Chris Lattner
0f3c949000 inline emitStringLiteral into its only caller.
Swift SVN r9920
2013-11-04 17:43:49 +00:00
John McCall
2ffcef1670 Make a couple minor interfaces traffic in Address instead
of OwnedAddress.

Swift SVN r7349
2013-08-20 00:55:04 +00:00
Dmitri Hrybenko
de59d8dcd4 Remove unneeded llvm:: qualifier for llvm::StringRef and llvm::SmallVector
Swift SVN r7089
2013-08-09 18:41:46 +00:00
Doug Gregor
109290c6f0 Introduce the StringLiteralConvertible formal protocol for string literals.
Swift SVN r5473
2013-06-04 21:35:12 +00:00
Joe Groff
b439e49625 IRGen: Use SILTypes in field projection functions.
Swift SVN r5154
2013-05-10 23:17:08 +00:00
Chris Lattner
d523932d85 remove InitializedObject.
Swift SVN r4844
2013-04-21 06:05:01 +00:00
Chris Lattner
47e508c24d remove LValue, PathComponent, and LValue.h as a whole.
Swift SVN r4792
2013-04-18 04:50:03 +00:00
Chris Lattner
ffe3388aa5 remove the dead logic form GenTuple, RValueInitEmitter, and some
erasure/protocol expr logic.


Swift SVN r4775
2013-04-17 06:34:27 +00:00
Chris Lattner
ade66c8b10 Remove the emitIgnored, emitLValue, and tryEmitAsAddress mechanics and
supporting logic.


Swift SVN r4770
2013-04-17 05:33:23 +00:00
Joe Groff
1459512901 IRGen: SIL tuple helper instructions.
Implement ElementAddrInst for lvalue tuples, and implement the AllocArray, IndexAddr, and IntegerValue insts used to lower variadic tuples. (Actually compiling code that uses variadic tuples still requires support for SpecializeInst and generic functions.)

Swift SVN r3781
2013-01-17 18:17:39 +00:00
Joe Groff
8320df8b9d IRGen: SIL branching and variable allocation.
Implement SIL-to-IR lowering for allocation, deallocation, load, store, and branching instructions so that local variables and branching control flow can be used. Add a Fibonacci loop test to exercise the new instructions.

Swift SVN r3767
2013-01-15 22:32:49 +00:00
Joe Groff
9259c0d912 IRGen: Get "hello world" to compile through SIL.
Add a path through IRGenModule to optionally codegen FuncDecls using their corresponding SIL Functions when constructed with a SILModule. Jury-rig an IRGenSILFunction subclass of IRGenFunction that does the bare minimum necessary to compile "hello world" from SIL. There are some impedance mismatches between irgen and SIL that need to be smoothed out, particularly the AST-dependent way irgen currently handles function calls. Nonetheless, `swift -sil-i hello.swift` works!

Swift SVN r3759
2013-01-14 02:57:11 +00:00
Eli Friedman
d8b84d6cd0 Add ScalarToTupleExpr to represent an implicit conversion from a scalar to a tuple. Part of <rdar://problem/12337042>.
Swift SVN r2887
2012-09-21 00:45:33 +00:00
Eli Friedman
6e69e27975 Kill ScalarToTupleExpr, which is no longer in use.
Swift SVN r1881
2012-05-17 01:50:48 +00:00
Eli Friedman
f75e305a20 Add ScalarToTupleExpr to represent an implicit conversion from a scalar to a tuple, with or without default arguments. Make Sema and IRGen work with them.
I'm not completely sure this is the representation we want, but it isn't much code to rip out if we decide to represent it some other way.

While I'm in the area, also fix a case where tuple->tuple conversion wasn't working.



Swift SVN r1748
2012-05-05 00:50:06 +00:00
John McCall
5ad3782b01 Rework the IR-generation of initialization and teach the
compiler to enter properly-scoped cleanups to destroy local
variables.

Swift SVN r1385
2012-04-11 03:00:08 +00:00
John McCall
0cd849b19c Complete the pattern-matching IR emission logic,
at least for exhaustive patterns.

Swift SVN r1359
2012-04-10 08:28:31 +00:00
John McCall
173d750a02 Switch IR-generation to use ASTVisitor, or more precisely, to
use irgen::ASTVisitor, which is a subclass of the AST version
that always looks through some expressions and asserts that
others (the unchecked/error ones) can't happen.  The main
obstacle to that is access control, because it's quite nice to
have the visitor be a non-local class for nesting purposes,
but that makes it impossible to use private methods anymore.
It's nice to give all the type-specific emitters private
interfaces anyway, though;  that ends up being most of the
patch.

I futzed with GenClosure.cpp while I was in there, but
separating it would have been obnoxious.

Swift SVN r1267
2012-03-26 06:08:19 +00:00