Commit Graph

649 Commits

Author SHA1 Message Date
Connor Wakamo
11a6121caa [driver] Updated OutputMode to include the module name.
This is centralized, as many Commands need to reference the module name.

Swift SVN r12496
2014-01-17 19:39:23 +00:00
Connor Wakamo
f892b1a544 [driver] Implemented support for adding an additional output for a swiftmodule to the CommandOutput of frontend Commands.
Adjusted Driver::buildJobs() and Driver::buildJobsForAction() to include a const OutputMode& parameter.
Updated Driver::buildJobsForAction() to set an additional swiftmodule output on Jobs generated from a CompileJobAction if the OutputMode says the driver should generate a module.
This change now causes frontend invocations to pass “-emit-module -module-output-path <path>” when a module is requested, though the partial modules are not yet properly merged.

Swift SVN r12495
2014-01-17 19:39:22 +00:00
Connor Wakamo
b94e9e3f76 [driver] Slightly refactored Driver’s handling of OutputMode.
Instead of having buildActions() call the private Driver::getOutputMode() function, establish an OutputMode using a new Driver::buildOutputMode() function.
This change will allow the OutputMode to be more easily shared across functions without needing to generate it each time (though, at the moment, only buildActions() uses the OutputMode).

Swift SVN r12494
2014-01-17 19:39:22 +00:00
Connor Wakamo
e9599f249d [driver] Added support for adding a MergeModuleJobAction to the Action graph.
Updated Driver::OutputMode to also contain a ShouldGenerateModule field.
Updated Driver::getOutputMode() to set OutputMode::ShouldGenerateModule appropriately.
Updated Driver::buildActions() to insert a MergeModuleJobAction into the Action graph if the Driver’s OutputMode indicates that a module should be generated.

Swift SVN r12492
2014-01-17 19:39:21 +00:00
Connor Wakamo
c4a4ab3596 [driver] Added initial infrastructure for generating a Command which merges swiftmodule files.
Added a MergeModuleJobAction, which will be translated into a Command which merges swiftmodule files.
Added a MergeModule subclass of Tool, which will generate a Command which merges swiftmodule files. (Currently, it generates a Command which invokes “swift_driver -frontend -help”.)
Added ToolChain-level support for getting the MergeModule Tool.

Nothing produces MergeModuleJobActions yet; adding that to the Action dependency graph should be enough to get this going.

Swift SVN r12491
2014-01-17 19:39:20 +00:00
Connor Wakamo
824c0cb126 [driver] Reworked the CommandOutput class to add support for specifying additional outputs.
This will allow the driver to specify the location for, among other things, the partial swiftmodule generated by a single frontend invocation.

Swift SVN r12449
2014-01-17 01:11:55 +00:00
Connor Wakamo
2e7b5b7485 [driver] Added an implementation of struct DenseMapInfo<swift::driver::types::ID> so that a type ID can be used as a key in an llvm::DenseMap.
Swift SVN r12448
2014-01-17 01:11:54 +00:00
Connor Wakamo
097f0e6a65 [driver] Updated Compilation::performJobsInList() to properly handle Commands which depend on peers.
Across recursive calls to performJobsInList(), keep track of ScheduledCommands
and FinishedCommands, so we can do the following:

  - Don’t schedule a Command which is already scheduled (since it may be
    scheduled as a peer before we try to schedule it as an input).
  - Don’t schedule a Command whose inputs have not all finished.

Swift SVN r12444
2014-01-17 00:47:21 +00:00
Connor Wakamo
40b38c40b2 [driver] Reworked Driver::buildJobsForAction() so that it doesn’t create the same Job multiple times.
Since a Job may be reached through multiple paths in the dependency graph, we
need to include support for caching Jobs. (Currently, the cache maps
Action/ToolChain pairs to Jobs.)

As a result of these changes, Tool::constructJob() and
Driver::buildJobsForAction() return a plain Job *, instead of a
std::unique_ptr<Job>, since the Jobs returned by buildJobsForAction() no longer
need to be unique.

Swift SVN r12443
2014-01-17 00:47:21 +00:00
Connor Wakamo
e3ea68658c [driver] Added Action::addInput() for adding inputs after creation.
Swift SVN r12434
2014-01-16 23:42:55 +00:00
Connor Wakamo
d5f95cd574 [driver] Add a new -driver-skip-execution flag.
This instructs the driver to skip task execution by using a DummyTaskQueue in Compilation::performJobsInList().
This option should generally only be used for testing, as DummyTaskQueue may provide fake buffered output.

Swift SVN r12350
2014-01-15 21:27:56 +00:00
Connor Wakamo
3a1810336e [frontend] Implement support for emitting modules with the integrated frontend.
Added support for the -emit-module and -module-output-path options. -emit-module
and -module-output-path function similarly to -serialize-diagnostics and
-serialized-diagnostics-path: notably, -module-output-path implies -emit-module,
but -emit-module can be passed without -module-output-path and a default path
will be determined based on other inputs.

Added support for the -module-link-name option, which specifies the name of the
library to link against when importing the generated module.

Note that support for these options is only implemented in the integrated
frontend; driver-level support for these options is forthcoming.

Swift SVN r12301
2014-01-14 23:38:36 +00:00
Connor Wakamo
00f076daa5 [frontend] Implemented support for emitting serialized diagnostics.
Reworked the -serialize-diagnostics option, so that it is now just a flag
indicating that the frontend should generate serialized diagnostics. The path at
which the diagnostics will be serialized is now specified by the
-serialized-diagnostics-path option, which is a frontend-only option. (The
frontend treats -serialized-diagnostics-path as implying -serialize-diagnostics.)

If -serialize-diagnostics is passed but -serialized-diagnostics-path is not
passed, the frontend will choose an output path from a few default values:

- If the frontend has a non-stdout output path, replace that path's extension
  with .dia.
- If there is a primary input filename, use that input's base name as the base
  name for the serialized diagnostics file.
- Otherwise, use the module name as the base name for the serialized diagnostics
  file.

Added support for setting up a serialized diagnostics DiagnosticConsumer in
frontend_main() if FrontendOptions::SerializedDiagnosticsPath is non-empty.

Swift SVN r12251
2014-01-13 21:38:03 +00:00
Connor Wakamo
f0555a73a8 [driver] Add support for the -parse-sil option, including passing it through to the frontend.
Swift SVN r12175
2014-01-11 00:33:31 +00:00
Connor Wakamo
a7460947bd [frontend] Made -primary-file accept a value (instead of relying on relative position of arguments).
Also added a -primary-file= alias.

Swift SVN r12171
2014-01-11 00:06:24 +00:00
Connor Wakamo
8c04586911 [frontend] Add support for specifying the primary input with the -primary-file flag.
Swift SVN r12150
2014-01-10 22:39:05 +00:00
Connor Wakamo
24fad265a2 [driver] Removed Job::run() and Job::needsToRun().
Both of these functions are now handled by Compilation.

Swift SVN r12061
2014-01-08 19:10:43 +00:00
Connor Wakamo
163c0651f2 [driver] Added support for parallel execution.
In Compilation, perform Jobs by scheduling Commands which need to be run (currently
all Commands, but this can be refined later) on TaskQueues by doing the following:

1. Perform all inputs to all Jobs in the current JobList. (Treat a JobList as its
   own inputs for scheduling purposes.)
2. After each Command's inputs run, check to see if that Command needs to run.
   If so, schedule it for execution. (Currently, all Commands always need to run.)
3. Set up a TaskFinishedCallback which will check to see if any other Commands need
   to run as a result of executing a particular Command. (Currently, all Commands
   depend on all other Commands.) If a Command needs to run and it is not already
   scheduled for execution, schedule it for execution.
4. Ask the TaskQueue to execute. (This will call the TaskFinishedCallback as
   necessary).

Swift SVN r12060
2014-01-08 19:10:43 +00:00
Joe Groff
e06ee37dca Enable SIL protocol witnesses.
We should be able to cut out another layer of IRGen grime now.

This does XFAIL one test, test/Prototypes/TextFormatting.swift, which fails because of a weird archetype ordering in a nested substitution list. This should get sorted out by switching to interface types, so I'm going to let it go until then.

Swift SVN r11618
2013-12-24 04:36:03 +00:00
Connor Wakamo
0f6c51dd5b [frontend] Add support for -enable-dynamic-value-type-layout.
Swift SVN r11454
2013-12-18 23:42:53 +00:00
Connor Wakamo
19c9107fa5 [frontend] Add support for -disable-llvm-optzns.
Swift SVN r11453
2013-12-18 23:42:52 +00:00
Connor Wakamo
5303544046 [driver] Add support for passing -O to the integrated frontend.
Swift SVN r11451
2013-12-18 23:42:51 +00:00
Connor Wakamo
ab7fcaecc3 [driver] Make Command::getExecutable() return a const char *, since a Command’s executable must always be a null-terminated C string.
Swift SVN r11426
2013-12-18 18:06:04 +00:00
Connor Wakamo
5a603a3cd1 [driver] Add support for -emit-ir and -emit-bc.
Added driver-level support for generating commands with -emit-ir and -emit-bc as well integrated frontend support for handling -emit-ir and -emit-bc.

Swift SVN r11375
2013-12-17 02:43:40 +00:00
Connor Wakamo
3b80655e62 [driver] Switched from --help-hidden to -help-hidden.
Left --help-hidden in as an alias for consistency with clang, but -help-hidden is now the primary spelling of this option.

Swift SVN r11350
2013-12-16 19:23:16 +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
44971d2e5a [driver] Added support for specifying the number of commands to execute in parallel.
The driver does not yet support parallel execution, but this sets the Compilation up with the necessary information to execute commands in parallel.

Swift SVN r11333
2013-12-15 21:47:35 +00:00
Connor Wakamo
139ff7654d [frontend] Fix typo in the help text for -emit-verbose-sil.
Swift SVN r11327
2013-12-15 01:06:07 +00:00
Connor Wakamo
6127955b05 [driver] Add support for passing arguments after -- down to the frontend as-is if the driver is in immediate mode.
In Driver::translateInputArgs(), don’t break apart the OPT__DASH_DASH argument if we’re in immediate mode.
Mark OPT__DASH_DASH as being a FrontendOption.
In Swift::constructJob(), add support for types::TY_Nothing, and pass the argument for OPT__DASH_DASH as-is if the driver is invoking the frontend in immediate mode.

Swift SVN r11325
2013-12-15 00:58:27 +00:00
Connor Wakamo
25283a28d9 [driver] Fixed an issue where creating Commands with no output failed due to an attempt to initialize a StringRef with nullptr.
Swift SVN r11324
2013-12-15 00:58:26 +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
cc43e393bb [frontend] Restructure FrontendOptions.td into separate [FrontendOption, NoDriverOption] and [FrontendOption, NoDriverOption, HelpHidden] sections.
Swift SVN r11319
2013-12-14 23:52:12 +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
e6b0f16ad0 [frontend] Add support for -print-stats.
Swift SVN r11190
2013-12-12 17:44:51 +00:00
Connor Wakamo
23a60d60d8 [frontend] Added support for -delayed-function-body-parsing.
Swift SVN r11188
2013-12-12 17:32:02 +00:00
Connor Wakamo
a4f766e430 [frontend] Add support for -emit-sil-protocol-witness-tables.
Swift SVN r11187
2013-12-12 17:32:01 +00:00
John McCall
a55474bc49 Options.inc depends on FrontendOptions.td.
Swift SVN r11182
2013-12-12 04:30:48 +00:00
Connor Wakamo
adbd61d024 [frontend] Added support for -debug-constraints-attempt.
Swift SVN r11174
2013-12-12 03:17:44 +00:00
Connor Wakamo
b4ea0c8b73 [frontend] Added support for the -use-malloc flag.
Added a new static ParseLangArgs, which fills in a LangOptions object.
Also moved the handling of -debug-constraints out of the loop in CompilerInvocation::parseArgs() and into ParseLangArgs, now that it has a proper home.

Swift SVN r11172
2013-12-12 02:44:34 +00:00
Connor Wakamo
85c2afcd90 [driver] Added support for -Xfrontend, which passes arguments through to the frontend.
Swift SVN r11166
2013-12-12 01:14:06 +00:00
Connor Wakamo
ca7140ce18 Fixed a formatting issue in FrontendOptions.td.
Swift SVN r11162
2013-12-12 00:48:13 +00:00
Connor Wakamo
4ede1d0c23 [frontend] Added support for parsing the “-emit-verbose-sil” frontend argument.
This is not yet hooked up anywhere (beyond FrontendOptions), since the integrated frontend does not yet know how to emit SIL.

Swift SVN r11161
2013-12-12 00:48:13 +00:00
Connor Wakamo
7243a4c3b8 [driver] Updated the driver so that it accepts -module-name.
Also updated test/Driver/basic.swift to pass '-module-name basic', since the
inferred module name for the test is not a valid identifier.

Swift SVN r11111
2013-12-11 01:29:18 +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
Connor Wakamo
d456848811 [driver] Added support for differentiating SIL emitted by -emit-sil and -emit-silgen.
SIL emitted by -emit-silgen is treated internally as “raw-sil”, while SIL emitted by -emit-silgen is treated internally as “sil".
Externally, there are no changes; both kinds of SIL still have a “.sil” file extension.
Updated test/Driver/Actions.swift to account for the change in behavior with -emit-silgen.

Swift SVN r10947
2013-12-06 23:11:30 +00:00
Connor Wakamo
40bb91e479 [driver] Added options for -sdk and -g to Options.td.
Swift SVN r10946
2013-12-06 23:11:30 +00:00
Connor Wakamo
3d9f94e715 Properly implemented "swift_driver -driver-print-bindings".
This produces output similar to "clang -ccc-print-bindings".
Also added several tests to ensure that "swift_driver -driver-print-bindings"
behaves as expected.

Swift SVN r10935
2013-12-06 21:23:03 +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