Commit Graph

130 Commits

Author SHA1 Message Date
Jordan Rose
41700b03da Add a new (hidden) option -autolink-force-load.
This option puts a special symbol into the generated object files that other
object files can reference to force the library to be loaded.

The next commit will modify the way we serialize autolinking information so
that importers of this module will always emit a reference to this symbol.
This means the library will be linked into the final binary even if no other
symbols are used (which happens for some of our overlays that just add
category methods to Objective-C classes).

Part of <rdar://problem/16829587>

Swift SVN r17750
2014-05-09 01:07:07 +00:00
Argyrios Kyrtzidis
78b4efdb50 [IRGen] In IRGenModule::fatal_unimplemented, pass the specific error message to report_fatal_error().
Swift SVN r16065
2014-04-08 18:49:30 +00:00
Joe Groff
2189947cb0 Use report_fatal_error instead of exit(1) after unrecoverable problems in SILGen or IRGen.
Swift SVN r16059
2014-04-08 17:33:21 +00:00
Joe Groff
36cc5ab4fa IRGen: Set up definitions for block structures.
In preparation for implementing calls into blocks.

Swift SVN r13900
2014-02-14 05:15:31 +00:00
Mark Lacey
5c696fda8b Make IR generation take an explicit LLVMContext.
Prior to r13134, the modules being constructed for IRGen always used the
LLVM global context due to <rdar://problem/15283227>, but the interface
should really take this as a parameter rather than baking the behavior
into IRGen.

Swift SVN r13260
2014-02-01 01:07:14 +00:00
Mark Lacey
088d7b5f20 IRGenModule users shouldn't need to know about clang::CodeGenerator.
Swift SVN r13179
2014-01-30 22:59:00 +00:00
Mark Lacey
d69b305200 Generate IR for inline functions from Clang modules.
Currently only inline functions referenced from Swift source files, or
from the REPL, will get IR generated for them. Inline functions
referenced by other inline functions will require additional effort to
generate properly.

With this change we use the clang::CodeGenerator-created llvm::Module
for all IR generation in Swift. This is perhaps undesirable, but
unavoidable given the interface the public Clang APIs expose, which do
not allow for building a ModuleBuilder that borrows an existing
llvm::Module.

Also unfortunate is the hack to generate a UsedAttr for each imported
inline function, but the public Clang APIs do not provide a way to only
emit deferred decls without emitting other things (e.g. module flags
that conflict with what the Swift IRGen emits). Note that we do not do
IRGen for every inline function in the module - only the ones that the
importer pulls in, which appears to be only those transitively
referenced from Swift code.

Swift SVN r13134
2014-01-30 02:33:37 +00:00
John McCall
cd26f3ebae Use a constant null pointer instead of &objc_empty_vtable
when compiling for the simulator.

The simulator doesn't support absolute symbols correctly,
and the ObjC runtime's workaround doesn't visit generic class
patterns.

Swift SVN r12896
2014-01-24 02:32:36 +00:00
Jordan Rose
11008f0ed1 Split diagnostics out into separate files.
Thanks to the way we've set up our diagnostics engine, there's not actually
a reason for /everything/ to get rebuilt when /one/ diagnostic changes.
I've split them up into five categories for now: Parse, Sema, SIL, IRGen,
and Frontend, plus a set of "Common" diagnostics that are used in multiple
areas of the compiler. We can massage this later.

No functionality change, but should speed up compile times!

Swift SVN r12438
2014-01-17 00:15:12 +00:00
Jordan Rose
b1b50a134e Autolinking: include all imported modules.
Although Cocoa.framework re-exports AppKit, Foundation, and CoreData, an
arbitrary library does not re-export most of its imports. Normally this
would be fine, but the Clang importer can pull in types too eagerly and
then generate thunks and wrappers for things we don't care about. At least
for now, return to the behavior of autolinking /anything/ that gets visibly
imported.

<rdar://problem/15705923>

Swift SVN r11844
2014-01-03 01:21:11 +00:00
Joe Groff
9929f25f74 IRGen: Build correct TypeInfos for thin and thick function types.
Derive the appropriate ExtraData for a SILFunctionType from its thinness and calling convention. Consider @!thin @cc(witness_method) as having ExtraData::Metatype. This should eliminate all of the unspoken gentleperson's agreements that let thin and witness functions survive IRGen currently when we can turn on SIL witness tables.

Swift SVN r11446
2013-12-18 23:03:39 +00:00
Connor Wakamo
59f18f9fc0 Renamed irgen::Options and irgen::OutputKind to IRGenOptions and IRGenOutputKind, and move both out of the irgen namespace now that they're in swiftAST.
Swift SVN r11405
2013-12-18 01:17:09 +00:00
Connor Wakamo
3e81830385 Move "include/swift/IRGen/Options.h" to "include/swift/AST/IRGenOptions.h".
This commit only moves the header file; updating the class so that it is no longer in the irgen namespace will be handled separately.

Swift SVN r11404
2013-12-18 01:17:09 +00:00
Mark Lacey
a7f6f9e006 Handle indirect returns in @objc methods properly.
Reapply r11184 with fixes for makefile builds.

Use CodeGenABITypes to determine which return values should be indirect
in @objc methods.

Swift SVN r11226
2013-12-13 00:39:24 +00:00
Mark Lacey
dffef5d02b Revert "Handle indirect returns in @objc methods properly."
This reverts r11184, which broke some builds due to a missing library.

Swift SVN r11186
2013-12-12 09:11:39 +00:00
Mark Lacey
973ece4dc9 Handle indirect returns in @objc methods properly.
Use CodeGenABITypes to determine which return values should be indirect
in @objc methods.

Swift SVN r11184
2013-12-12 07:22:12 +00:00
Adrian Prantl
7fca2d8142 Debug info: Encode the provenance of types imported from Objective-C in
the debug info.
<rdar://problem/15414884> Debug information must indicate location of Objective-C types

Swift SVN r10580
2013-11-20 03:38:21 +00:00
John McCall
f2edd610cb Don't give IRGenDebugInfo privileged access to the TypeConverter.
Now that it's using the public routines for getting a TypeInfo,
make sure it's actually lowering types appropriately.

Swift SVN r10571
2013-11-20 00:14:19 +00:00
John McCall
20e58dcf93 Change the type of function values in SIL to SILFunctionType.
Perform major abstraction remappings in SILGen.  Introduce
thunking functions as necessary to map between abstraction
patterns.

Swift SVN r10562
2013-11-19 22:55:09 +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
Joe Groff
bbddf41693 IRGen: Instantiate existential metadata through the runtime.
When we need a reference to protocol or protocol composition type metadata, ask for it through the runtime, instead of referencing statically-emitted protocol metadata.

Swift SVN r9871
2013-11-01 17:13:49 +00:00
Joe Groff
a0c4486808 IRGen: Emit protocol descriptors.
Produce protocol descriptors when we see a protocol definition in the current module. If the protocol is @objc, go through the existing path for generating full Protocol* metadata for objc objects; otherwise, emit our layout-compatible but strong-external-linkage Swift protocol descriptor record.

Swift SVN r9867
2013-11-01 04:28:43 +00:00
Jordan Rose
4a90ab0a4f [IRGen] Separate out SourceFile-specific processing from whole-module stuff.
We're going to want to emit multiple SourceFiles and one SILModule in one
IRGenModule.

Swift SVN r9670
2013-10-25 17:30:39 +00:00
Jordan Rose
49cd5b1680 Use SourceFile in IRGen.
The only real change here is that module-wide IR (autolinking and ObjC
runtime flags) have been pushed up from emitTranslationUnit (now
emitSourceFile) to its only caller, performIRGeneration.

Swift SVN r9075
2013-10-09 18:38:24 +00:00
Pete Cooper
f9c6bf0630 Initial framework for generating Axle metadata. This currently only supports the function level metadata. Argument and result metadata to come later
Swift SVN r9061
2013-10-09 16:54:28 +00:00
Adrian Prantl
ba105c5705 Debug info: Emit byref parameter types as reference types.
Also scan store instructions for byref arguments.

Swift SVN r8209
2013-09-13 20:58:23 +00:00
Joe Groff
c3d1f0d661 IRGen: Sketch out a SwiftTargetInfo class with fun facts about pointers.
Start out with pointer spare bits, heap object alignment, null page size, and ObjC reserved bits, and provide static values for X86-64 and for a worst-case generic platform.

Swift SVN r7833
2013-08-31 17:01:02 +00:00
Joe Groff
a94489473c IRGen: Add ValueWitness enumerators for union layout and access.
These value witness table entries will be conditionally available for types that support specialized union representation through extra inhabitants and/or spare bits and for union value witnesses:

- storeExtraInhabitant, to store an extra inhabitant representation;
- getExtraInhabitantIndex, to recognize an extra inhabitant representation;
- getUnionTag, to get a union's discriminator; and
- inplaceProjectUnionData, to extract the value in place from a union.

This just sets up the enumerators and related IR types and mangling; nothing emits these witnesses yet.

Swift SVN r7234
2013-08-14 21:01:21 +00:00
Dmitri Hrybenko
e1c4ae3174 Wrap llvm::SourceMgr in swift::SourceManager so that we can add new members
to the source manager.


Swift SVN r6815
2013-08-01 20:39:22 +00:00
Adrian Prantl
aecfb851cd Wire clang::TargetInfo into swift::IRGenDebugInfo so we have access to
the target size of types, which may be different from the LLVM storage size.

Swift SVN r6774
2013-07-31 18:08:38 +00:00
Bill Wendling
d1d584a1ef Using an attribute builder to is more efficient than adding attributes one by one.
Swift SVN r6659
2013-07-26 22:44:35 +00:00
John McCall
7b86817b3c Basic value structure for [weak] and [unowned] references.
Add a bunch of new entrypoints and give them terrible
implementations.

Swift SVN r6322
2013-07-17 09:20:20 +00:00
Adrian Prantl
39cef650cd Create parameter types with their actual size and alignment parameters
instead of hardcoded values.

Swift SVN r6297
2013-07-16 21:07:33 +00:00
John McCall
075539b0f5 Generate runtime functions from an xmacro database.
Swift SVN r6266
2013-07-15 18:33:45 +00:00
John McCall
65342ac19a Change %swift.refcounted to correctly model HeapObject as of r5873.
Swift SVN r5958
2013-07-01 23:29:15 +00:00
Adrian Prantl
5cf577282d Debug Info: Wire up more compile unit metadata and clean up the code a bit.
Swift SVN r5794
2013-06-25 00:19:32 +00:00
Chris Lattner
d7f74cc949 silence a -Wreorder warning.
Swift SVN r5775
2013-06-23 18:08:52 +00:00
Adrian Prantl
0f7533dc7e Debug Info! Add basic support for line tables, compilation units, files,
and lexical scopes, which can be enabled through the new -g option.
When -g is enabled, line tables and scopes compile all the way
down to DWARF.

Changes to SIL:
- In addition to a SILLocation, every instruction now also has a pointer
  to a SILDebugScope (its containing lexical scope).
- Added LexicalScope, which is to be used for all Scopes we want to show
  up in the debug info.

Swift SVN r5772
2013-06-23 00:09:17 +00:00
Joe Groff
470cb9eae0 IRGen: Implement opaque archetype/existential casts.
Use the new swift_dynamicCastIndirect runtime functions to implement casts from opaque archetype and existential types to concrete types.

Swift SVN r5684
2013-06-19 18:56:14 +00:00
Joe Groff
24c8e9b147 IRGen: Get correct type metadata address for empty tuple.
We were using _TMdT_ as a type metadata pointer, but it's really a full metadata symbol we need to offset to get the type metadata address.

Swift SVN r5376
2013-05-29 17:37:56 +00:00
Doug Gregor
b2bd4d49b0 Make IRGen and the runtime agree on the name swift_getFunctionTypeMetadata.
Fixes <rdar://problem/13942390>.


Swift SVN r5253
2013-05-21 16:21:40 +00:00
Chris Lattner
803aa24b3e Switch getGetObjectClassFn to use getRuntimeFn.
Swift SVN r5172
2013-05-15 21:01:32 +00:00
Chris Lattner
de60776e2a rearrange how getRuntimeFunction works. Instead of using a creation
method to handle function attributes, just pass in a list of function
attributes.  Among other things, things that were formerly calling
createReadnoneRuntimeFunction to get nounwond, now make it explicit.


Swift SVN r5170
2013-05-15 18:31:40 +00:00
John McCall
c7f579e8dc Add nounwind to most of the runtime functions.
Swift SVN r5085
2013-05-08 00:48:52 +00:00
Chris Lattner
ca0091a445 add a few "optimized" runtime entrypoints for swift_getTupleTypeMetadata
that handle the 2/3 element cases specially.  These are not actually
optimized at the moment (they just call into swift_getTupleTypeMetadata)
but this could be done at some point.

This is a win for a couple reasons: this reduces the amount of code generated
inline and it allows swift_getTupleTypeMetadata2/3 to be marked readnone,
enabling CSE.  As a driveby, optimize metadata refs of zero element tuples
to directly use _TMdT_, eliminating a branch from swift_getTupleTypeMetadata.



Swift SVN r5070
2013-05-06 23:19:31 +00:00
Joe Groff
2be26b31a5 Make the deallocating destructor actually deallocate.
Emit the deallocObject runtime call inside the deallocating destructor for a heap object, instead of inside swift_release. This will allow for heap objects with known size to directly call fast deallocator entry points and potentially custom deallocators in the future.

Swift SVN r5027
2013-05-02 20:37:12 +00:00
Joe Groff
08b6f87524 Add 'typeof' to value witness tables.
To be able to get the dynamic type of a generic value, the 'typeof' operation needs to be part of the value witness for the type. Add 'typeof' to the value witness table layout, and in the runtime, provide standard typeof witnesses for static, Swift class, and ObjC class values.

Swift SVN r5013
2013-05-01 18:49:25 +00:00
John McCall
1fec73a8d2 Untested support for tuples with generically-sized elements.
Swift SVN r4926
2013-04-26 21:33:24 +00:00
Joe Groff
8bdccdd418 IRGen: Clear up dtor special cases in SIL-IRGen.
Change the destroying destructor entry point ABI to take 'this' as the appropriate type instead of as %swift.refcounted. Emit the deallocating destructor in IRGen when we see the ClassDecl, not when we see the SILFunction for the destructor. This frees us from having to worry about whether a SILFunction came from a destructor decl. We won't be able to reconstruct that once SILFunctions are pre-mangled.

While we're here, repaint some bikesheds so it's clearer that SIL and SILGen work with the destroying destructor.

Swift SVN r4908
2013-04-25 19:50:58 +00:00
Chris Lattner
e3d6a489af remove the Cleanup subclasses.
Swift SVN r4839
2013-04-21 05:06:52 +00:00