Commit Graph

116 Commits

Author SHA1 Message Date
Joe Groff
584009d27e SIL: Remove copy_value's result.
We won't have any types where copying has an effect on the bit pattern (except for blocks, which need special handling anyway), and copy_value having a result makes optimizations more complex, so remove it.

Swift SVN r15640
2014-03-30 03:40:45 +00:00
Joe Groff
99704ce69f IRGen: Build field type vector accessor functions.
As part of the nominal type descriptor for a struct or class, build a function that lazily generates the vector of type metadata for the fields of the nominal type given an instantiation of the type's metadata. To cache this for nongeneric types, produce a global variable we can stash the result in, or for generic types, reserve some space in the metadata template so that generic metadata instantiation naturally provides a space for every instance of the type.

Reapplying now that the missing Float80 builtin metadata is available.

Swift SVN r15260
2014-03-20 02:03:57 +00:00
Joe Groff
9b6a217bca Revert "IRGen: Build field type vector accessor functions."
This reverts commit r15256, which is producing phantom references to 'Float80'
that need investigating.

Swift SVN r15258
2014-03-20 01:41:38 +00:00
Joe Groff
891cdaf312 IRGen: Build field type vector accessor functions.
As part of the nominal type descriptor for a struct or class, build a function that lazily generates the vector of type metadata for the fields of the nominal type given an instantiation of the type's metadata. To cache this for nongeneric types, produce a global variable we can stash the result in, or for generic types, reserve some space in the metadata template so that generic metadata instantiation naturally provides a space for every instance of the type.

Swift SVN r15256
2014-03-20 00:41:00 +00:00
Jordan Rose
934121914c Use -emit-ir instead of -emit-llvm, for better parity with -emit-bc.
-emit-llvm in Clang is a modifier on the -S and -c actions. In Swift,
it's a separate action equivalent to "-S -emit-llvm". Be less ambiguous.

Part of the migration to the new driver.

Swift SVN r13029
2014-01-28 01:42:44 +00:00
Jordan Rose
0c92cc0fe4 Use '-target' instead of '-triple', for consistency with Clang and GCC.
Part of the migration to the new driver.

Swift SVN r13028
2014-01-28 01:42:41 +00:00
Joe Groff
03011aaf93 IRGen: Improve EnumImplStrategy's layout querying functionality with feedback from Enrico.
Only claim spare bits we actually use as tag bits in the result of getTagBitsForPayloadCases(), and fix up some crashers in corner cases. Add some assertions so these APIs get tested as part of normal compiler runs, and some DEBUG() macros so interested compiler users can see what enum layout is doing with -debug-only=enum-layout. This should also lead to slightly better codegen for some multi-payload enums because we don't pointlessly try to gather spare bits from the entire payload anymore, only the bits we actually need to discern the tag.

Swift SVN r12314
2014-01-15 05:11:25 +00:00
Joe Groff
9b38c4b5db IRGen: Forward spare bits through aggregates.
When doing struct layout for fixed-layout structs or tuples, combine the spare bit masks of their elements to form the spare bit mask of the aggregate, treating padding between elements as spare bits as well.

For now, disable using these spare bits to form extra inhabitants for structs and tuples; we would need additional runtime work to expose these extra inhabitants for correct generic runtime behavior. This puts us in a weird situation where 'enum { case A(Struct), B, C }' spills a bit but 'enum { case A(Struct), B(Struct), C }' doesn't, but the work to make the former happen isn't immediately critical for String optimization.

Swift SVN r12165
2014-01-10 23:15:34 +00:00
Joe Groff
3e30cbcfef SILGen/IRGen: Don't emit top_level_code for libraries.
If there's no script-mode file in a module, don't produce a top_level_code SILFunction for it, and don't consider emitting an LLVM global_ctor for it. We should never emit static constructors from user code anymore.

Swift SVN r11644
2013-12-26 00:18:29 +00:00
Joe Groff
a7f18cfad1 Update enum_value_semantics test for fix in r11431.
Swift SVN r11436
2013-12-18 21:21:19 +00:00
Joe Groff
554abf2d7a IRGen/Runtime: Expose extra inhabitants of class types.
Start using null-page values as extra inhabitants when laying out single-payload enums that contain class pointers as their payload type. Don't use inhabitants that set the lowest bit, to avoid trampling potential ObjC tagged pointer representations. This means that 'T?' for class type T now has a null pointer representation. Enums with multiple empty cases, as well as nested enums like 'T??', should now have optimal representations for class type T as well.

Note that we don't yet expose extra inhabitants for aggregates that contain heap object references, such as structs with class fields, Swift function types, or class-bounded existentials (even when the existential has no witness tables).

Swift SVN r10061
2013-11-09 00:43:40 +00:00
Joe Groff
b8c75769b3 IRGen: Emit nominal type descriptors in struct and enum metadata.
Build a nominal type descriptor when we emit the metadata or generic metadata pattern for a nominal type, and put a reference into the formerly null slot in the struct or enum metadata. We need to make a place for them in class metadata; that'll come next.

Swift SVN r9492
2013-10-18 21:04:58 +00:00
Chris Lattner
a476f65471 Abolish the old attribute syntax for type attributes (and SIL type attrs)
- Change type attribute printing logic (in astprinter and the demangler) 
  to print in the new syntax
- Change the swift parser to only accept type attributes in the new syntax.
- Update canParseTypeTupleBody to lookahead over new-syntax type attributes.
- Update the testsuite to use the new syntax.



Swift SVN r9273
2013-10-13 05:39:46 +00:00
Joe Groff
99a0c64b5a IRGen: More robustly lay out enums with payloads.
John noted that LLVM's ABI rules for Integers of Unusual Size cause them to be aligned like the largest native integer type even inside packed structs, making them unsuited for byte-accurate layout in cases where the payload is a non-power-of-two size, so we have to bite the bullet and lay them out as arrays of i8, bitcasting to the payload type to load and store the payload and tag parts.

This still colors outside of the lines a bit because loading or storing e.g. an i72 is going to touch an i128's worth of memory. Baby steps. It'd be nice to be able to load and reconsistute the i72 without having to load and mask together all of the individual bytes.

Swift SVN r9058
2013-10-09 05:07:51 +00:00
Joe Groff
3eb220da26 IRGen: Fix layout bug with payloaded enums.
If the enum gets laid out with a non-power-of-two payload and an extra tag, such as { i72, i2 }, then LLVM's natural location for the extra tag is going to be different from where we actually want it, so let's do our own byte offset calculation by bitcasting to i8* and gepping instead of trying to gep the struct directly.

Swift SVN r9023
2013-10-08 04:34:42 +00:00
Joe Groff
6740964db8 Rename IRGen 'union' tests to 'enum' tests.
Swift SVN r8773
2013-09-30 15:22:44 +00:00