Commit Graph

6605 Commits

Author SHA1 Message Date
Chris Lattner
a299747d01 get the makefile build unbroken.
Swift SVN r11979
2014-01-07 04:36:58 +00:00
Jordan Rose
84ce8bbe74 Add a skeleton for swift2objc, a tool to generate headers from Swift modules.
This is primarily intended for testing use, but the general mechanism of
generating headers from Swift ASTs is how we plan to get Swift modules into
Clang. The final implementation will be some kind of Clang plugin that's
invoked when a module can't be loaded. The use of header files keeps us
from having to rev-lock Swift and Clang for as long as possible.

Swift SVN r11970
2014-01-07 01:02:28 +00:00
Michael Gottesman
0100b2a75c [sil-sroa] SIL Scalar Replacement of Aggregates.
Swift SVN r11918
2014-01-06 03:44:54 +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
Doug Gregor
c18d10fe20 CMake: Make built Xcode projects put binaries in a more Makefile-like structure.
Previously, the CMake-built Xcode projects for LLVM, Clang, and Xcode
would put binaries into bin/Debug, lib/Debug, bin/Release, etc., which
differed from the makefile build's Debug/bin, Debug/lib, Release/bin,
etc. We installed a few weird-looking symlinks to paper over the
differences.

Mainline LLVM and Clang recently changed to use the makefile layout,
breaking the build of Xcode projects for Swift. Do the same for
Swift's build.


Swift SVN r11819
2014-01-02 18:23:17 +00:00
Michael Gottesman
612d622290 Rename current SILSROA => SILLowerAggregateInstrs.
Swift SVN r11739
2013-12-30 08:21:19 +00:00
Michael Gottesman
d6bf276e88 [sil-sroa] Very initial simple initial commit of SILSROA. Currently only lowers
copy_addr, destroy_addr into their constituant parts without performing any
chopping to unblock Nadav.

The plan is to use type lowering to chop these up and then rewrite afterwards.
But for now I want to unblock Nadav.

Swift SVN r11728
2013-12-30 00:17:37 +00:00
Michael Gottesman
b6f8bd9a55 Initial simple cost based performance inliner.
This is a very initial version mostly to get machinery in place before we start
considering more interesting things.

Specifically we do not:

1. Inline functions with any substitutions.
2. Inline functions that are not thin.
3. Inline functions in any recursive manner (i.e. we just follow the call tree
and inline until we run out of cost).
4. Remove functions that we have completely inlined as a good citizen should.

Additionally the cost model is purposely simplistic and assumes that every SIL
instruction is one to one with an LLVM instruction (when many do not become any
LLVM instruction and others become 2). The idea is simply to put a cost on the
total increase in code size we allow due to inlining in a specific function.
Thus we just continually inline until we run out our inlining budget.

Even with the current limitations we inline 1248 apply inst in the stdlib when
setting a cost threshold of 225.

Swift SVN r11596
2013-12-23 06:00:57 +00:00
Greg Parker
0e360cb26e Install stdlib into /usr/lib/swift/<OS name>/.
This reinstates r11411 with fixes for the autoconf+make build.


Swift SVN r11494
2013-12-20 01:01:35 +00:00
Connor Wakamo
28d579fd1d [frontend] Add support for running SIL optimization passes in the integrated frontend if the optimization level is not zero.
Swift SVN r11483
2013-12-19 21:40:05 +00:00
Connor Wakamo
53a0acad66 [frontend] Added temporary support for setting MainInputFilename, Triple, and OutputFilename in IRGenOptions.
MainInputFilename and OutputFilename are pulled from the FrontendOptions, while Triple is parsed directly from the ArgList.
Eventually, MainInputFilename and OutputFilename should likely be removed from IRGenOptions, in favor of the values in FrontendOptions, while Triple will be in a separate TargetOptions class.

Swift SVN r11455
2013-12-18 23:42:53 +00:00
Connor Wakamo
8b808311b3 [frontend] Added support for parsing -O.
Swift SVN r11452
2013-12-18 23:42:52 +00:00
Connor Wakamo
39bb2bf2a2 [frontend] Added proper support for parsing -l and -framework.
Moved the responsibility for storing LinkLibraries from CompilerInvocation to the invocation’s IRGenOpts.
Moved the handling of -l and -framework into ParseIRGenArgs.

Swift SVN r11450
2013-12-18 23:42:51 +00:00
Connor Wakamo
9f113b59ca [frontend] In frontend_main(), switch from using a local IRGenOptions to using the CompilerInvocation's.
Swift SVN r11448
2013-12-18 23:42:50 +00:00
Chris Lattner
a0c6d05b14 build sil-extract
Swift SVN r11415
2013-12-18 04:41:49 +00:00
Chris Lattner
073974dca4 revert r11411, which completely broke the makefile build.
Swift SVN r11414
2013-12-18 04:33:58 +00:00
Greg Parker
9032632299 Install stdlib into /usr/lib/swift/<OS name>/.
Swift SVN r11411
2013-12-18 02:19:29 +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
Michael Gottesman
259f657562 [sil-extract] Fix header.
Swift SVN r11395
2013-12-17 22:22:14 +00:00
Connor Wakamo
b0092c4717 [frontend] Initial support for performing non-EmitObject actions in the integrated frontend.
The integrated frontend now supports:
  - Parse
  - DumpParse
  - DumpAST
  - PrintAST
  - EmitSILGen
  - EmitSIL
  - EmitIR
  - EmitBC
  - EmitAssembly
  - EmitObject

Moved the code for compiling into a separate performCompile() function in frontend_main.cpp, to facilitate using early returns while still supporting the diagnostic verifier.
Added some error output for the REPL, Immediate, and EmitModuleOnly actions, as the integrated frontend does not yet support these actions.

Swift SVN r11387
2013-12-17 18:35:00 +00:00
Connor Wakamo
425807ce95 Move runSILDiagnosticPasses and runSILOptimizationPasses into swiftSILPasses.
Added a new Passes.cpp file to swiftSILPasses, which contains the general SIL pass-related functions.
Moved runSILDiagnosticPasses and runSILOptimizationPasses from tools/swift/Helpers.cpp to lib/SILPasses/Passes.cpp so that the functions can be shared by swift and swift_driver.

Swift SVN r11382
2013-12-17 05:15:34 +00:00
John McCall
7173cec9db Thread contextual information about parsing the top-level
through various bits and use that to globally discriminate.

Swift SVN r11379
2013-12-17 04:31:40 +00:00
Michael Gottesman
33b2564d70 [sil-extract] Instead of deleting functions, just make them have no basic blocks (i.e. be external).
This gives us as a lot of brevity and simplicity. I plan on adding a trivial
remove globals pass to sil-extract to clean these up.

The mechanism that I am using to do this is:

1. Split the entry basic block at its entrance, insert an unreachable terminator.
2. Use DCE to remove all of the original basic blocks. Thus the function will
only consist of 1 BB whose only instruction is a terminator.
3. Go through and clear the functions basic block list.

The key thing about this approach is that it leaves all of the heavy lifting to
DCE.

Swift SVN r11347
2013-12-16 11:50:43 +00:00
Dmitri Hrybenko
036f80a90e There is no need to link sil-opt with CoreFoundation and libedit either.
Swift SVN r11346
2013-12-16 10:06:23 +00:00
Dmitri Hrybenko
fdaecc05ed There is no need to link sil-extract with CoreFoundation and libedit
Swift SVN r11345
2013-12-16 10:02:19 +00:00
Michael Gottesman
73ad8921b4 Add in a simple SIL Extract utility that currently only handles functions.
This utility is similar to llvm-extract, a tool in LLVM that makes it simpler to
reduce test case by stripping out any global which matches a criteria. Currently
we only deal with functions and the only criteria is an exact name match.

Swift SVN r11343
2013-12-16 09:33:27 +00:00
Connor Wakamo
04b98c7d67 [driver] Move execution of Jobs from main() to Compilation.
Actual execution of Jobs is still performed under-the-covers by JobList::run(), but this abstraction will allow the Compilation to execute Jobs in parallel.

Swift SVN r11334
2013-12-15 21:47:36 +00:00
Connor Wakamo
620b5abc20 [frontend] Add support for -disable-diagnostic-passes.
Swift SVN r11322
2013-12-15 00:58:23 +00:00
Connor Wakamo
0d3369be03 [frontend] Add support for -help and --help-hidden.
Added PrintHelp and PrintHelpHidden to FrontendOptions.
Marked both -help and --help-hidden with the FrontendOption flag.
Updated ParseFrontendArgs to parse -help and --help-hidden.
Updated frontend_main() so that it prints the help for the frontend options.

Swift SVN r11320
2013-12-14 23:52:15 +00:00
Connor Wakamo
a1266393cd [frontend] Implemented support for verifying diagnostics with the integrated frontend.
Added a new DiagnosticOptions class to swiftBasic, and added a DiagnosticOptions member to CompilerInvocation.
Added a static ParseDiagnosticArgs function to parse diagnostic-related arguments.
Added -verify to FrontendOptions.td, and added support for parsing -verify in ParseDiagnosticArgs.
Updated frontend_main() to enable and trigger the DiagnosticVerifier when -verify is passed.

Swift SVN r11318
2013-12-14 22:08:08 +00:00
Connor Wakamo
debe69032e [frontend] Restructured frontend_main() so that SILGen, SILPasses, and IRGen are not attempted if earlier stages generated errors.
Swift SVN r11317
2013-12-14 21:22:16 +00:00
Dmitri Hrybenko
adf13e4a0a Don't link swift driver against CoreFoundation -- there is no need for this at the moment
Swift SVN r11309
2013-12-14 11:04:47 +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
Connor Wakamo
e6b0f16ad0 [frontend] Add support for -print-stats.
Swift SVN r11190
2013-12-12 17:44:51 +00:00
Nadav Rotem
d0c96e4eeb Implement a very very basic SIL Mem2Reg pass that promotes write-only and single-basicblock allocas.
This pass removes 1/4 of the allocas in the standard library.



Swift SVN r11189
2013-12-12 17:42:50 +00:00
Connor Wakamo
0e81e109b2 [frontend] In frontend_main(), fall back to SWIFT_MODULES_SDK if -sdk is not passed to the frontend.
This works around <rdar://problem/15639860>, which covers properly handling a missing -sdk argument at either the driver or frontend level (or at both levels).

Swift SVN r11153
2013-12-11 23:13:36 +00:00
Connor Wakamo
42c61e2df1 [frontend] Return immediately from frontend_main() if CompilerInvocation::parseArgs() failed.
Swift SVN r11109
2013-12-11 01:29:16 +00:00
Chris Lattner
4bed0d6fce more added dependencies, this really doesn't seem right.
Swift SVN r11093
2013-12-10 21:20:27 +00:00
Chris Lattner
46893b2a90 another build unbreaker. CompilerInvocation::parseArgs is calling
driver::createDriverOptTable.  I'm not sure if this is a layering
violation or not, but someone should think about it.


Swift SVN r11092
2013-12-10 21:19:06 +00:00
Connor Wakamo
02c1532d27 Initial support for an integrated frontend in swift_driver.
- Added support for invoking the Swift frontend via "swift_driver -frontend".
- Added frontend_main.cpp, which implements the main entry point for the
  integrated frontend. (Currently, this supports compiling an input Swift file
  into an object file.)
- Removed lib/Frontend/FrontendOptions.td, and replaced its functionality with
  options in include/Swift/Driver/Options.td and a new
  include/Swift/Driver/FrontendOptions.td. Options supported by the frontend
  are denoted by the FrontendOption flag; options which are not supported by
  the driver are denoted by the NoDriverOption flag.
- Updated CompilerInvocation::parseArgs() to use the option table returned from
  createDriverOptTable(), including renaming a handful of options. (-triple is
  now -target, and -Xclang is now -Xcc.)

Swift SVN r11082
2013-12-10 18:06:54 +00:00
Jordan Rose
b4e4b551bd Rename CompilerInstance::doIt to performParse.
'doIt' is semantically meaningless, and doesn't mention the fact that nothing
has actually been compiled yet (to SIL, to IR, or to machine code).
'performParse' matches the compiler flag -parse, which stops after
type-checking.

No functionality change.

Swift SVN r10951
2013-12-07 00:13:58 +00:00
Connor Wakamo
ed2038585f Initial set of changes to add a new 'swift_driver' executable.
- Added a couple of new targets:
  - libswiftDriver, which contains most of the driver implementation
  - swift_driver, which produces the actual executable

- Added centralized version information into libswiftBasic.

- Added a new "Driver Design & Internals" document, which currently describes
  the high-level design of the Swift driver.

- Implemented an early version of the functionality of the driver, including
  versions of the Parse, Pipeline, Bind, Translate, and Execute driver stages.
  Parse, Pipeline, and Bind are largely implemented; Translate and Execute are
  early placeholders. (Translate produces "swift_driver --version" and "ld -v"
  commands, while Execute performs all subtasks sequentially, rather than in
  parallel.)

This is just the starting point for the Swift driver. Tests for the existing
behavior are forthcoming.

Swift SVN r10933
2013-12-06 21:23:01 +00:00
Nadav Rotem
ccf3a127f2 Add a simple generic specialization pass.
Swift SVN r10885
2013-12-05 22:20:05 +00:00
Michael Gottesman
4379283013 Remove inclusion of SILPasses/Passes.h into Subsystems.h and update all relevant files.
Swift SVN r10880
2013-12-05 19:58:21 +00:00
Michael Gottesman
32c34303b6 [cse] Move cse to be before SILCombine as per Chris's suggestion.
Swift SVN r10851
2013-12-05 08:24:21 +00:00
Jordan Rose
417b5d3982 Merge TranslationUnit into Module, and eliminate the term "translation unit".
This completes the FileUnit refactoring. A module consists of multiple
FileUnits, which provide decls from various file-like sources. I say
"file-like" because the Builtin module is implemented with a single
BuiltinUnit, and imported Clang modules are just a single FileUnit source
within a module.

Most modules, therefore, contain a single file unit; only the main module
will contain multiple source files (and eventually partial AST files).

The term "translation unit" has been scrubbed from the project. To refer
to the context of declarations outside of any other declarations, use
"top-level" or "module scope". To refer to a .swift file or its DeclContext,
use "source file". To refer to a single unit of compilation, use "module",
since the model is that an entire module will be compiled with a single
driver call. (It will still be possible to compile a single source file
through the direct-to-frontend interface, but only in the context of the
whole module.)

Swift SVN r10837
2013-12-05 01:51:15 +00:00
Jordan Rose
8b8cc8ee62 Turn SerializedModule into SerializedASTFile.
Part of the FileUnit restructuring. A serialized module is now represented as
a TranslationUnit containing a single SerializedASTFile.

As part of this change, the FileUnit interface has been made virtual, rather
than switching on the Kind in every accessor. We think the operations
performed on files are sufficiently high-level that this shouldn't affect us.

A nice side effect of all this is that we now properly model the visibility
of modules imported into source files. Previously, we would always consider
the top-level imports of all files within a target, whether re-exported or
not.

We may still end up wanting to distinguish properties of a complete Swift
module file from a partial AST file, but we can do that within
SerializedModuleLoader.

Swift SVN r10832
2013-12-05 01:51:09 +00:00
Jordan Rose
eede5ec4f9 Begin refactoring for mixed file kinds within a single module.
The goal of this series of commits is to allow the main module to consist
of both source files and AST files, where the AST files represent files
that were already built and don't need to be rebuilt, or of Swift source
files and imported Clang headers that share a module (because they are in
the same target).

Currently modules are divided into different kinds, and that defines how
decls are looked up, how imports are managed, etc. In order to achieve the
goal above, that polymorphism should be pushed down to the individual units
within a module, so that instead of TranslationUnit, BuiltinModule,
SerializedModule, and ClangModule, we have SourceFile, BuiltinUnit,
SerializedFile, and ClangUnit. (Better names welcome.) At that point we can
hopefully collapse TranslationUnit into Module and make Module non-polymorphic.

This commit makes SourceFile the subclass of an abstract FileUnit, and
makes TranslationUnit hold an array of FileUnits instead of SourceFiles.
To demonstrate that this is actually working, the Builtin module has also
been converted to FileUnit: it is now a TranslationUnit containing a single
BuiltinUnit.

Swift SVN r10830
2013-12-05 01:51:03 +00:00
Michael Gottesman
f2b8c0991d [cse] Initial implementation of EarlyCSE Port.
This patch contains an initial implementation of CSE for SIL ported from LLVM's
earlycse pass. It follows the overall general structure using
ScopedHashTables/DominatorTrees to perform the computation.

Currently it only handles integer literals to ease with the initial review. Once
this gets in I will be spending some time extending the pass to handle other
instructions.

Even with just handling integers this reduces the size of the stdlib in SIL by
~300 lines.

Swift SVN r10794
2013-12-04 21:49:37 +00:00