Commit Graph

39 Commits

Author SHA1 Message Date
Dario Rexin
81af291c4f [IRGen] Fix computation of spare bits for fixed arrays
rdar://159143492

Previously all bits after the spare bits of the first element were marked as spare bits. This caused enum tags to be stored in bits used by the payload.
2025-08-28 12:27:40 -07:00
Nate Chandler
3078e95074 [InlineArray] Fix outlining metadata collection.
The metadata of the element type is required for outlining.

rdar://158083136
2025-08-12 14:22:50 -07:00
Nate Chandler
6e8170c34d [IRGen] Fix FixedArray of fixedSize 1 elt addring.
When a `FixedArray`'s fixed size is 1, it looks like `[1 x %Ty]`. Given
an array's address, performing an operation on each element's address
entail's indexing into the array to each element's index to produce an
element's address for each index.  That is true even when the array
consists of a single element.  In that case, produce an address for that
single element by indexing to index 0 into each passed-in array.

rdar://151726387
2025-06-16 20:34:41 -07:00
Erik Eckstein
45a78e67db IRGen: remove TypeInfo::allocateVector
It's not needed anymore because the alloc_vector instruction is removed.
2025-02-12 10:51:15 +01:00
Alejandro Alonso
515c64fd55 Use current insertion block as other incoming phi for each array element 2025-01-08 10:37:17 -08:00
Alejandro Alonso
08ce821442 If the element type of a B.FA is empty, set its storage type in LLVM to just the padding 2025-01-08 10:37:16 -08:00
Joe Groff
a184782a38 Introduce a Builtin.FixedArray type.
`Builtin.FixedArray<let N: Int, T: ~Copyable & ~Escapable>` has the layout of `N` elements of type `T` laid out
sequentially in memory (with the tail padding of every element occupied by the array). This provides a primitive
on which the standard library `Vector` type can be built.
2024-10-22 16:21:45 -07:00
Chris Lattner
dc0454e1d2 remove GenArray.{h,cpp} as they are handled by SILGen. Remove getAddrOfLocalFunction.
Swift SVN r4796
2013-04-18 05:12:01 +00:00
Chris Lattner
a8ed1a187f remove CallSite and emitRValueForFunction
Swift SVN r4795
2013-04-18 05:09:38 +00:00
Chris Lattner
03394a29ea remove prepareCall and some various array handling logic now handled by SILGen.
Swift SVN r4793
2013-04-18 04:57:27 +00:00
Joe Groff
a17a812ad6 IRGen: Add 'retain' and 'release' to TypeInfos.
These let SILGen retain and release arbitrary Explosions without having to work around cleanups. Also remove 'transfer' because I'm dumb and didn't realize 'reexplode' already does the same thing.

Swift SVN r3816
2013-01-20 19:50:07 +00:00
Joe Groff
312e4872e9 IRGen: SIL class accessors.
Implement IRGen for RefElementAddr so that class accessors work. Add a loadUnmanaged method to TypeInfo classes so that we can populate Explosions without accruing unwanted cleanups.

Swift SVN r3779
2013-01-16 22:12:21 +00:00
Joe Groff
9b2727005f IRGen: Add a 'transfer' method to TypeInfo.
Transfers values from one Explosion to another similar to 'copy' by transferring ownership instead of copying the values/cleanups.

Swift SVN r3768
2013-01-16 01:20:13 +00:00
Chris Lattner
47dbc4051c update for mainline LLVM header file moves.
Swift SVN r3634
2013-01-02 14:38:42 +00:00
John McCall
ee012c0903 Make IR-gen use canonical types as the basic type currency.
This is kindof a pain in a few places where the type system
doesn't propagate canonicality.  Also, member initializations
are always direct-initializations and so are allowed to use
explicit constructors, which is a hole in our canonicality
tracking.  But overall I like the idea of always working
with canonical types.

Swift SVN r2893
2012-09-21 07:53:08 +00:00
John McCall
9106aa6254 Rewrite the function-call infrastructure. This gets us
a lot closer to successfully emitting the polymorphic-min-over-ranges
example;  the main blocker right now seems to be that the witness
for a static member function is not, in fact, a static member
function at al, but a freestanding function.  That's legitimate,
but it probably needs some shepherding through the witness
system.

Swift SVN r2532
2012-08-03 08:10:47 +00:00
Eli Friedman
a87d83b7b8 Work-in-progress towards getting generic new array expressions working.
Swift SVN r2509
2012-08-02 21:36:33 +00:00
Eli Friedman
84e858da4e Fix static member functions so a member of type T has type "metatype<T> -> () -> ()" instead of "() -> ()".
This is much more convenient for IRGen, and gives us a reasonable representation for a static
polymorphic function on a polymorphic type.

I had to hack up irgen::emitArrayInjectionCall a bit to make the rest of this patch work; John, please
revert those bits once emitCallee is fixed.



Swift SVN r2488
2012-07-28 06:47:25 +00:00
John McCall
ed38caaa04 Support generic return types, as long as they don't differ
by abstraction from the concrete return type.

This basically gets generic calls working totally as long
as there's no remapping required.

Swift SVN r2402
2012-07-23 07:06:28 +00:00
John McCall
6c821ddc1b Support allocating local objects of archetype type, at least in
theory.

Swift SVN r2245
2012-06-25 20:45:04 +00:00
John McCall
770ce0fde7 Refactor to make it easier to keep common information in
the type converter.

Swift SVN r2241
2012-06-25 20:44:59 +00:00
John McCall
e2440ff94c Split TypeInfo into its own header.
Swift SVN r2240
2012-06-25 20:44:51 +00:00
John McCall
72ebeee76f Try to optimize assignment a bit more, and fix assignment
of protocol types to correctly handle self-assignment.
This ends up creating such a large amount of code that it's
worth extracting into its own helper function.  Fortunately,
this can be the same helper function for every protocol type.

Swift SVN r1905
2012-05-19 06:46:05 +00:00
Eli Friedman
1341f19da8 IRGen for varargs tuples.
Swift SVN r1883
2012-05-17 03:22:49 +00:00
John McCall
53d52f6d7d Switch from std::vector back to SmallVector, now that SmallVector
supports move-only types.

Swift SVN r1715
2012-05-02 05:51:32 +00:00
John McCall
ee61610563 Implement IR generation for NewArrayExpr.
Swift SVN r1651
2012-04-26 07:34:04 +00:00
John McCall
b3b71178a5 Fix a pair of bugs with partial updates of logical l-values:
first, we weren't registering the cleanup for the temporary
if it needed materialization, and second, we were potentially
double-consuming cleanups associated with the l-value, e.g.
subscript indices.

Swift SVN r1631
2012-04-25 09:39:22 +00:00
John McCall
bc32a8aedb Fix a bug with returning value that need to be refcounted:
we want to do a take-load out of the return address slot
instead of a normal load, or else we'll end up +1'ing an
already +1 value.

Swift SVN r1564
2012-04-23 17:47:07 +00:00
John McCall
f3e27d90ff Change IR-generation so that it emits metadata objects for the
heap allocations it makes, and switch swift_alloc over to pass
that pointer in as well as the alignment.  Also, compute
whether a type is POD during its generation and cache that in
the object, and introduce a method on TypeInfo to destroy an
object in memory.

Swift SVN r1356
2012-04-10 06:28:22 +00:00
John McCall
ca9f85d694 Add code for associating cleanups with intermediate
evaluation results and then claiming or forwarding the
ownership of such results.

Swift SVN r1337
2012-04-06 07:07:28 +00:00
John McCall
e020724c3d Distinguish between assignment and initialization, and fix
some problems with the data pointer of function types.

Swift SVN r1220
2012-03-16 19:02:25 +00:00
John McCall
53de72a7f1 Pull an unnecessary 'Explosion' out of some names.
Swift SVN r1217
2012-03-16 19:02:22 +00:00
John McCall
d76aaea2b6 Remove the outdated RValue concept; no functionality change.
Swift SVN r1216
2012-03-16 09:26:39 +00:00
John McCall
885783ab76 Start switching things over to using explosions.
Swift SVN r1014
2012-01-12 07:05:49 +00:00
John McCall
c7bcadf450 On further reflection and use, the concept of an RValue is not actually
very useful;  it is much more interesting to divide r-value emission
into "to arguments" and "to memory" models.  To that end, introduce a
new structure for holding an "exploded" r-value.



Swift SVN r1006
2012-01-11 23:59:57 +00:00
John McCall
9b7fb0c227 New l-value representation.
Swift SVN r956
2011-12-22 05:28:33 +00:00
John McCall
3e65b21a68 Provide r-value schemas for various implemented types. Use these to
implement function signature lowering.  Basic setup for IR generation
of functions.  Test that we can properly declare a simple function.



Swift SVN r595
2011-08-24 18:55:54 +00:00
John McCall
97c6ccadfb More IR-generation infrastructure.
Swift SVN r576
2011-08-20 05:55:02 +00:00
John McCall
86f4371478 Basic IR generation of tuple and oneof types.
Swift SVN r573
2011-08-20 01:06:52 +00:00