diff options
author | Anton Korobeynikov <asl@math.spbu.ru> | 2008-05-04 06:19:55 +0000 |
---|---|---|
committer | Anton Korobeynikov <asl@math.spbu.ru> | 2008-05-04 06:19:55 +0000 |
commit | cae8ccd12d62a89a3c539ecb549a91a976f7f7b2 (patch) | |
tree | ea8de6f2e345d80c3ee1ce2c4ccf11e67904dd1b | |
parent | a9d9ca469fd2442e1352028a7a69d23de0a4cbd5 (diff) |
Drop llvmc also, it will be replaced by shiny new llvmc2
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50615 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | docs/CommandGuide/llvmc.pod | 431 | ||||
-rw-r--r-- | tools/llvmc/CompilerDriver.cpp | 1032 | ||||
-rw-r--r-- | tools/llvmc/CompilerDriver.h | 206 | ||||
-rw-r--r-- | tools/llvmc/ConfigLexer.cpp.cvs | 2900 | ||||
-rw-r--r-- | tools/llvmc/ConfigLexer.h | 113 | ||||
-rw-r--r-- | tools/llvmc/ConfigLexer.l | 201 | ||||
-rw-r--r-- | tools/llvmc/ConfigLexer.l.cvs | 201 | ||||
-rw-r--r-- | tools/llvmc/Configuration.cpp | 632 | ||||
-rw-r--r-- | tools/llvmc/Configuration.h | 62 | ||||
-rw-r--r-- | tools/llvmc/LICENSE.TXT | 6 | ||||
-rw-r--r-- | tools/llvmc/Makefile | 34 | ||||
-rw-r--r-- | tools/llvmc/c | 60 | ||||
-rw-r--r-- | tools/llvmc/cpp | 61 | ||||
-rw-r--r-- | tools/llvmc/ll | 11 | ||||
-rw-r--r-- | tools/llvmc/llvmc.cpp | 374 | ||||
-rw-r--r-- | tools/llvmc/st | 63 |
16 files changed, 0 insertions, 6387 deletions
diff --git a/docs/CommandGuide/llvmc.pod b/docs/CommandGuide/llvmc.pod deleted file mode 100644 index 5e6cc9513e..0000000000 --- a/docs/CommandGuide/llvmc.pod +++ /dev/null @@ -1,431 +0,0 @@ -=pod - -=head1 NAME - -llvmc - The LLVM Compiler Driver (experimental) - -=head1 SYNOPSIS - -B<llvmc> [I<options>] [I<filenames>...] - -=head1 DESCRIPTION - -B<llvmc> is a configurable driver for invoking other LLVM (and non-LLVM) tools -in order to compile, optimize and link software for multiple languages. For -those familiar with FSF's B<gcc> tool, it is very similar. Please note that -B<llvmc> is considered an experimental tool. B<llvmc> has the following goals: - -=over - -=item * provide a single point of access to the LLVM tool set, - -=item * hide the complexities of the LLVM tools through a single interface, - -=item * make integration of existing non-LLVM tools simple, - -=item * extend the capabilities of minimal front ends, and - -=item * make the interface for compiling consistent for all languages. - -=back - -The tool itself does nothing with a user's program. It merely invokes other -tools to get the compilation tasks done. - -The options supported by B<llvmc> generalize the compilation process and -provide a consistent and simple interface for multiple programming languages. -This makes it easier for developers to get their software compiled with LLVM. -Without B<llvmc>, developers would need to understand how to invoke the -front-end compiler, optimizer, assembler, and linker in order to compile their -programs. B<llvmc>'s sole mission is to trivialize that process. - -=head2 Basic Operation - -B<llvmc> always takes the following basic actions: - -=over - -=item * Command line options and filenames are collected. - -The command line options provide the marching orders to B<llvmc> on what actions -it should perform. This is the I<request> the user is making of B<llvmc> and it -is interpreted first. - -=item * Configuration files are read. - -Based on the options and the suffixes of the filenames presented, a set of -configuration files are read to configure the actions B<llvmc> will take. -Configuration files are provided by either LLVM or the front end compiler tools -that B<llvmc> invokes. Users generally don't need to be concerned with the -contents of the configuration files. - -=item * Determine actions to take. - -The tool chain needed to complete the task is determined. This is the primary -work of B<llvmc>. It breaks the request specified by the command line options -into a set of basic actions to be done: - -=over - -=item * Pre-processing: gathering/filtering compiler input (optional). - -=item * Translation: source language to bitcode conversion. - -=item * Assembly: bitcode to native code conversion. - -=item * Optimization: conversion of bitcode to something that runs faster. - -=item * Linking: combining multiple bitcode files to produce executable program. - -=back - -=item * Execute actions. - -The actions determined previously are executed sequentially and then -B<llvmc> terminates. - -=back - -=head1 OPTIONS - -=head2 Control Options - -Control options tell B<llvmc> what to do at a high level. The -following control options are defined: - -=over - -=item B<-c> or B<--compile> - -This option specifies that the linking phase is not to be run. All -previous phases, if applicable will run. This is generally how a given -bitcode file is compiled and optimized for a source language module. - -=item B<-k> or B<--link> or default - -This option (or the lack of any control option) specifies that all stages -of compilation, optimization, and linking should be attempted. Source files -specified on the command line will be compiled and linked with objects and -libraries also specified. - -=item B<-S> - -This option specifies that compilation should end in the creation of -an LLVM assembly file that can be later converted to an LLVM object -file. - -=item B<-E> - -This option specifies that no compilation or linking should be -performed. Only pre-processing, if applicable to the language being -compiled, is performed. For languages that support it, this will -result in the output containing the raw input to the compiler. - -=back - -=head2 Optimization Options - -Optimization with B<llvmc> is based on goals and specified with -the following -O options. The specific details of which -optimizations run is controlled by the configuration files because -each source language will have different needs. - -=over - -=item B<-O1> or B<-O0> (default, fast compilation) - -Only those optimizations that will hasten the compilation (mostly by reducing -the output) are applied. In general these are extremely fast and simple -optimizations that reduce emitted code size. The goal here is not to make the -resulting program fast but to make the compilation fast. If not specified, -this is the default level of optimization. - -=item B<-O2> (basic optimization) - -This level of optimization specifies a balance between generating good code -that will execute reasonably quickly and not spending too much time optimizing -the code to get there. For example, this level of optimization may include -things like global common sub-expression elimination, aggressive dead code -elimination, and scalar replication. - -=item B<-O3> (aggressive optimization) - -This level of optimization aggressively optimizes each set of files compiled -together. However, no link-time inter-procedural optimization is performed. -This level implies all the optimizations of the B<-O1> and B<-O2> optimization -levels, and should also provide loop optimizations and compile time -inter-procedural optimizations. Essentially, this level tries to do as much -as it can with the input it is given but doesn't do any link time IPO. - -=item B<-O4> (link time optimization) - -In addition to the previous three levels of optimization, this level of -optimization aggressively optimizes each program at link time. It employs -basic analysis and basic link-time inter-procedural optimizations, -considering the program as a whole. - -=item B<-O5> (aggressive link time optimization) - -This is the same as B<-O4> except it employs aggressive analyses and -aggressive inter-procedural optimization. - -=item B<-O6> (profile guided optimization: not implemented) - -This is the same as B<-O5> except that it employs profile-guided -re-optimization of the program after it has executed. Note that this implies -a single level of re-optimization based on run time profile analysis. Once -the re-optimization has completed, the profiling instrumentation is -removed and final optimizations are employed. - -=item B<-O7> (lifelong optimization: not implemented) - -This is the same as B<-O5> and similar to B<-O6> except that re-optimization -is performed through the life of the program. That is, each run will update -the profile by which future re-optimizations are directed. - -=back - -=head2 Input Options - -=over - -=item B<-l> I<LIBRARY> - -This option instructs B<llvmc> to locate a library named I<LIBRARY> and search -it for unresolved symbols when linking the program. - -=item B<-L> F<path> - -This option instructs B<llvmc> to add F<path> to the list of places in which -the linker will - -=item B<-x> I<LANGUAGE> - -This option instructs B<llvmc> to regard the following input files as -containing programs in the language I<LANGUAGE>. Normally, input file languages -are identified by their suffix but this option will override that default -behavior. The B<-x> option stays in effect until the end of the options or -a new B<-x> option is encountered. - -=back - -=head2 Output Options - -=over - -=item B<-m>I<arch> - -This option selects the back end code generator to use. The I<arch> portion -of the option names the back end to use. - -=item B<--native> - -Normally, B<llvmc> produces bitcode files at most stages of compilation. -With this option, B<llvmc> will arrange for native object files to be -generated with the B<-c> option, native assembly files to be generated -with the B<-S> option, and native executables to be generated with the -B<--link> option. In the case of the B<-E> option, the output will not -differ as there is no I<native> version of pre-processed output. - -=item B<-o> F<filename> - -Specify the output file name. The contents of the file depend on other -options. - -=back - -=head2 Information Options - -=over - -=item B<-n> or B<--no-op> - -This option tells B<llvmc> to do everything but actually execute the -resulting tools. In combination with the B<-v> option, this causes B<llvmc> -to merely print out what it would have done. - -=item B<-v> or B<--verbose> - -This option will cause B<llvmc> to print out (on standard output) each of the -actions it takes to accomplish the objective. The output will immediately -precede the invocation of other tools. - -=item B<--stats> - -Print all statistics gathered during the compilation to the standard error. -Note that this option is merely passed through to the sub-tools to do with -as they please. - -=item B<--time-passes> - -Record the amount of time needed for each optimization pass and print it -to standard error. Like B<--stats> this option is just passed through to -the sub-tools to do with as they please. - -=item B<--time-programs> - -Record the amount of time each program (compilation tool) takes and print -it to the standard error. - -=back - -=head2 Language Specific Options - -=over - -=item B<-T,pre>=I<options> - -Pass an arbitrary option to the pre-processor. - -=item B<-T,opt>=I<options> - -Pass an arbitrary option to the optimizer. - -=item B<-T,lnk>=I<options> - -Pass an arbitrary option to the linker. - -=item B<-T,asm>=I<options> - -Pass an arbitrary option to the code generator. - -=back - -=head2 C/C++ Specific Options - -=over - -=item B<-I>F<path> - -This option is just passed through to a C or C++ front end compiler to tell it -where include files can be found. - -=item B<-D>F<symbol> - -This option is just passed through to a C or C++ front end compiler to tell it -to define a symbol. - -=back - -=head2 Miscellaneous Options - -=over - -=item B<--help> - -Print a summary of command line options. - -=item B<--version> - -This option will cause B<llvmc> to print out its version number and terminate. - -=back - -=head2 Advanced Options - -You better know what you're doing if you use these options. Improper use -of these options can produce drastically wrong results. - -=over - -=item B<--config-dir> F<dirname> - -This option tells B<llvmc> to read configuration data from the I<directory> -named F<dirname>. Data from such directories will be read in the order -specified on the command line after all other standard configuration files have -been read. This allows users or groups of users to conveniently create -their own configuration directories in addition to the standard ones to which -they may not have write access. - -=back - - -=head2 Unimplemented Options - -The options below are not currently implemented in B<llvmc> but will be -eventually. They are documented here as "future design". - -=over - -=item B<--show-config> I<[suffixes...]> - -When this option is given, the only action taken by B<llvmc> is to show its -final configuration state in the form of a configuration file. No compilation -tasks will be conducted when this option is given; processing will stop once -the configuration has been printed. The optional (comma separated) list of -suffixes controls what is printed. Without any suffixes, the configuration -for all languages is printed. With suffixes, only the languages pertaining -to those file suffixes will be printed. The configuration information is -printed after all command line options and configuration files have been -read and processed. This allows the user to verify that the correct -configuration data has been read by B<llvmc>. - -=item B<--config> :I<section>:I<name>=I<value> - -This option instructs B<llvmc> to accept I<value> as the value for configuration -item I<name> in the section named I<section>. This is a quick way to override -a configuration item on the command line without resorting to changing the -configuration files. - -=item B<--config-only-from> F<dirname> - -This option tells B<llvmc> to skip the normal processing of configuration -files and only configure from the contents of the F<dirname> directory. Multiple -B<--config-only-from> options may be given in which case the directories are -read in the order given on the command line. - -=item B<--emit-raw-code> - -No optimization is done whatsoever. The compilers invoked by B<llvmc> with -this option given will be instructed to produce raw, unoptimized code. This -option is useful only to front end language developers and therefore does not -participate in the list of B<-O> options. This is distinctly different from -the B<-O0> option (a synonym for B<-O1>) because those optimizations will -reduce code size to make compilation faster. With B<--emit-raw-code>, only -the full raw code produced by the compiler will be generated. - -=back - - -=head1 EXIT STATUS - -If B<llvmc> succeeds, it will exit with 0. Otherwise, if an error -occurs, it will exit with a non-zero value and no compilation actions -will be taken. If one of the compilation tools returns a non-zero -status, pending actions will be discarded and B<llvmc> will return the -same result code as the failing compilation tool. - -=head1 DEFICIENCIES - -B<llvmc> is considered an experimental LLVM tool because it has these -deficiencies: - -=over - -=item Insufficient support for native linking - -Because B<llvm-ld> doesn't handle native linking, neither can B<llvmc> - -=item Poor configuration support - -The support for configuring new languages, etc. is weak. There are many -command line configurations that cannot be achieved with the current -support. Furthermore the grammar is cumbersome for configuration files. -Please see L<http://llvm.org/PR686> for further details. - -=item Does not handle target specific configurations - -This is one of the major deficiencies, also addressed in -L<http://llvm.org/PR686> - -=back - -=head1 SEE ALSO - -L<llvm-as|llvm-as>, L<llvm-dis|llvm-dis>, L<llc|llc>, L<llvm-link|llvm-link> - -=head1 AUTHORS - -Maintained by the LLVM Team (L<http://llvm.org>). - -=cut diff --git a/tools/llvmc/CompilerDriver.cpp b/tools/llvmc/CompilerDriver.cpp deleted file mode 100644 index 65684d65cd..0000000000 --- a/tools/llvmc/CompilerDriver.cpp +++ /dev/null @@ -1,1032 +0,0 @@ -//===- CompilerDriver.cpp - The LLVM Compiler Driver ------------*- C++ -*-===// -// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements the bulk of the LLVM Compiler Driver (llvmc). -// -//===----------------------------------------------------------------------===// - -#include "CompilerDriver.h" -#include "ConfigLexer.h" -#include "llvm/Module.h" -#include "llvm/ModuleProvider.h" -#include "llvm/Bitcode/ReaderWriter.h" -#include "llvm/Support/MemoryBuffer.h" -#include "llvm/Support/Timer.h" -#include "llvm/System/Signals.h" -#include "llvm/ADT/SetVector.h" -#include "llvm/ADT/StringExtras.h" -#include "llvm/Config/alloca.h" -#include <iostream> -using namespace llvm; - - -namespace { - -void WriteAction(CompilerDriver::Action* action ) { - std::cerr << action->program.c_str(); - std::vector<std::string>::const_iterator I = action->args.begin(); - while (I != action->args.end()) { - std::cerr << ' ' << *I; - ++I; - } - std::cerr << '\n'; -} - -void DumpAction(CompilerDriver::Action* action) { - std::cerr << "command = " << action->program.c_str(); - std::vector<std::string>::const_iterator I = action->args.begin(); - while (I != action->args.end()) { - std::cerr << ' ' << *I; - ++I; - } - std::cerr << '\n'; - std::cerr << "flags = " << action->flags << '\n'; -} - -void DumpConfigData(CompilerDriver::ConfigData* cd, const std::string& type ){ - std::cerr << "Configuration Data For '" << cd->langName << "' (" << type - << ")\n"; - std::cerr << "PreProcessor: "; - DumpAction(&cd->PreProcessor); - std::cerr << "Translator: "; - DumpAction(&cd->Translator); - std::cerr << "Optimizer: "; - DumpAction(&cd->Optimizer); - std::cerr << "Assembler: "; - DumpAction(&cd->Assembler); - std::cerr << "Linker: "; - DumpAction(&cd->Linker); -} - -static bool GetBitcodeDependentLibraries(const std::string &fname, - Module::LibraryListType& deplibs, - std::string* ErrMsg) { - ModuleProvider *MP = 0; - if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(fname)) { - MP = getBitcodeModuleProvider(Buffer); - if (MP == 0) delete Buffer; - } - if (!MP) { - deplibs.clear(); - return true; - } - deplibs = MP->getModule()->getLibraries(); - delete MP; - return false; -} - - -class CompilerDriverImpl : public CompilerDriver { -/// @name Constructors -/// @{ -public: - CompilerDriverImpl(ConfigDataProvider& confDatProv ) - : cdp(&confDatProv) - , finalPhase(LINKING) - , optLevel(OPT_FAST_COMPILE) - , Flags(0) - , machine() - , LibraryPaths() - , TempDir() - , AdditionalArgs() - { - AdditionalArgs.reserve(NUM_PHASES); - StringVector emptyVec; - for (unsigned i = 0; i < NUM_PHASES; ++i) - AdditionalArgs.push_back(emptyVec); - } - - virtual ~CompilerDriverImpl() { - cleanup(); - cdp = 0; - LibraryPaths.clear(); - IncludePaths.clear(); - Defines.clear(); - TempDir.clear(); - AdditionalArgs.clear(); - fOptions.clear(); - MOptions.clear(); - WOptions.clear(); - } - -/// @} -/// @name Methods -/// @{ -public: - virtual void setFinalPhase(Phases phase) { - finalPhase = phase; - } - - virtual void setOptimization(OptimizationLevels level) { - optLevel = level; - } - - virtual void setDriverFlags(unsigned flags) { - Flags = flags & DRIVER_FLAGS_MASK; - } - - virtual void setOutputMachine(const std::string& machineName) { - machine = machineName; - } - - virtual void setPhaseArgs(Phases phase, const StringVector& opts) { - assert(phase <= LINKING && phase >= PREPROCESSING); - AdditionalArgs[phase] = opts; - } - - virtual void setIncludePaths(const StringVector& paths) { - StringVector::const_iterator I = paths.begin(); - StringVector::const_iterator E = paths.end(); - while (I != E) { - sys::Path tmp; - tmp.set(*I); - IncludePaths.push_back(tmp); - ++I; - } - } - - virtual void setSymbolDefines(const StringVector& defs) { - Defines = defs; - } - - virtual void setLibraryPaths(const StringVector& paths) { - StringVector::const_iterator I = paths.begin(); - StringVector::const_iterator E = paths.end(); - while (I != E) { - sys::Path tmp; - tmp.set(*I); - LibraryPaths.push_back(tmp); - ++I; - } - } - - virtual void addLibraryPath(const sys::Path& libPath) { - LibraryPaths.push_back(libPath); - } - - virtual void addToolPath(const sys::Path& toolPath) { - ToolPaths.push_back(toolPath); - } - - virtual void setfPassThrough(const StringVector& fOpts) { - fOptions = fOpts; - } - - /// @brief Set the list of -M options to be passed through - virtual void setMPassThrough(const StringVector& MOpts) { - MOptions = MOpts; - } - - /// @brief Set the list of -W options to be passed through - virtual void setWPassThrough(const StringVector& WOpts) { - WOptions = WOpts; - } - -/// @} -/// @name Functions -/// @{ -private: - bool isSet(DriverFlags flag) { - return 0 != ((flag & DRIVER_FLAGS_MASK) & Flags); - } - - void cleanup() { - if (!isSet(KEEP_TEMPS_FLAG)) { - const sys::FileStatus *Status = TempDir.getFileStatus(); - if (Status && Status->isDir) - TempDir.eraseFromDisk(/*remove_contents=*/true); - } else { - std::cout << "Temporary files are in " << TempDir << "\n"; - } - } - - sys::Path MakeTempFile(const std::string& basename, - const std::string& suffix, - std::string* ErrMsg) { - if (TempDir.isEmpty()) { - TempDir = sys::Path::GetTemporaryDirectory(ErrMsg); - if (TempDir.isEmpty()) - return sys::Path(); - sys::RemoveDirectoryOnSignal(TempDir); - } - sys::Path result(TempDir); - if (!result.appendComponent(basename)) { - if (ErrMsg) - *ErrMsg = basename + ": can't use this file name"; - return sys::Path(); - } - if (!result.appendSuffix(suffix)) { - if (ErrMsg) - *ErrMsg = suffix + ": can't use this file suffix"; - return sys::Path(); - } - return result; - } - - Action* GetAction(ConfigData* cd, - const sys::Path& input, - const sys::Path& output, - Phases phase) - { - Action* pat = 0; ///< The pattern/template for the action - Action* action = new Action; ///< The actual action to execute - - // Get the action pattern - switch (phase) { - case PREPROCESSING: pat = &cd->PreProcessor; break; - case TRANSLATION: pat = &cd->Translator; break; - case OPTIMIZATION: pat = &cd->Optimizer; break; - case ASSEMBLY: pat = &cd->Assembler; break; - case LINKING: pat = &cd->Linker; break; - default: - assert(!"Invalid driver phase!"); - break; - } - assert(pat != 0 && "Invalid command pattern"); - - // Copy over some pattern things that don't need to change - action->flags = pat->flags; - - // See if program starts with wildcard... - std::string programName=pat->program.toString(); - if (programName[0] == '%' && programName.length() >2) { - switch(programName[1]){ - case 'b': - if (programName.substr(0,8) == "%bindir%") { - std::string tmp(LLVM_BINDIR); - tmp.append(programName.substr(8)); - pat->program.set(tmp); - } - break; - case 'l': - if (programName.substr(0,12) == "%llvmgccdir%"){ - std::string tmp(LLVMGCCDIR); - tmp.append(programName.substr(12)); - pat->program.set(tmp); - }else if (programName.substr(0,13) == "%llvmgccarch%"){ - std::string tmp(LLVMGCCARCH); - tmp.append(programName.substr(13)); - pat->program.set(tmp); - }else if (programName.substr(0,9) == "%llvmgcc%"){ - std::string tmp(LLVMGCC); - tmp.append(programName.substr(9)); - pat->program.set(tmp); - }else if (programName.substr(0,9) == "%llvmgxx%"){ - std::string tmp(LLVMGXX); - tmp.append(programName.substr(9)); - pat->program.set(tmp); - }else if (programName.substr(0,9) == "%llvmcc1%"){ - std::string tmp(LLVMCC1); - tmp.append(programName.substr(9)); - pat->program.set(tmp); - }else if (programName.substr(0,13) == "%llvmcc1plus%"){ - std::string tmp(LLVMCC1PLUS); - tmp.append(programName.substr(13)); - pat->program.set(tmp); - }else if (programName.substr(0,8) == "%libdir%") { - std::string tmp(LLVM_LIBDIR); - tmp.append(programName.substr(8)); - pat->program.set(tmp); - } - break; - } - } - action->program = pat->program; - - // Do the substitutions from the pattern to the actual - StringVector::iterator PI = pat->args.begin(); - StringVector::iterator PE = pat->args.end(); - while (PI != PE) { - if ((*PI)[0] == '%' && PI->length() >2) { - bool found = true; - switch ((*PI)[1]) { - case 'a': - if (*PI == "%args%") { - if (AdditionalArgs.size() > unsigned(phase)) - if (!AdditionalArgs[phase].empty()) { - // Get specific options for each kind of action type - StringVector& addargs = AdditionalArgs[phase]; - // Add specific options for each kind of action type - action->args.insert(action->args.end(), addargs.begin(), - addargs.end()); - } - } else - found = false; - break; - case 'b': - if (*PI == "%bindir%") { - std::string tmp(*PI); - tmp.replace(0,8,LLVM_BINDIR); - action->args.push_back(tmp); - } else - found = false; - break; - case 'd': - if (*PI == "%defs%") { - StringVector::iterator I = Defines.begin(); - StringVector::iterator E = Defines.end(); - while (I != E) { - action->args.push_back( std::string("-D") + *I); - ++I; - } - } else - found = false; - break; - case 'f': - if (*PI == "%fOpts%") { - if (!fOptions.empty()) - action->args.insert(action->args.end(), fOptions.begin(), - fOptions.end()); - } else - found = false; - break; - case 'i': - if (*PI == "%in%") { - action->args.push_back(input.toString()); - } else if (*PI == "%incls%") { - PathVector::iterator I = IncludePaths.begin(); - PathVector::iterator E = IncludePaths.end(); - while (I != E) { - action->args.push_back( std::string("-I") + I->toString() ); - ++I; - } - } else - found = false; - break; - case 'l': - if ((*PI)[1] == 'l') { - std::string tmp(*PI); - if (*PI == "%llvmgccdir%") - tmp.replace(0,12,LLVMGCCDIR); - else if (*PI == "%llvmgccarch%") - tmp.replace(0,13,LLVMGCCARCH); - else if (*PI == "%llvmgcc%") - tmp.replace(0,9,LLVMGCC); - else if (*PI == "%llvmgxx%") - tmp.replace(0,9,LLVMGXX); - else if (*PI == "%llvmcc1%") - tmp.replace(0,9,LLVMCC1); - else if (*PI == "%llvmcc1plus%") - tmp.replace(0,9,LLVMCC1); - else - found = false; - if (found) - action->args.push_back(tmp); - } else if (*PI == "%libs%") { - PathVector::iterator I = LibraryPaths.begin(); - PathVector::iterator E = LibraryPaths.end(); - while (I != E) { - action->args.push_back( std::string("-L") + I->toString() ); - ++I; - } - } else if (*PI == "%libdir%") { - std::string tmp(*PI); - tmp.replace(0,8,LLVM_LIBDIR); - action->args.push_back(tmp); - } else - found = false; - break; - case 'o': - if (*PI == "%out%") { - action->args.push_back(output.toString()); - } else if (*PI == "%opt%") { - if (!isSet(EMIT_RAW_FLAG)) { - if (cd->opts.size() > static_cast<unsigned>(optLevel) && - !cd->opts[optLevel].empty()) - action->args.insert(action->args.end(), - cd->opts[optLevel].begin(), - cd->opts[optLevel].end()); - else - throw std::string("Optimization options for level ") + - utostr(unsigned(optLevel)) + " were not specified"; - } - } else - found = false; - break; - case 's': - if (*PI == "%stats%") { - if (isSet(SHOW_STATS_FLAG)) - action->args.push_back("-stats"); - } else - found = false; - break; - case 't': - if (*PI == "%target%") { - action->args.push_back(std::string("-march=") + machine); - } else if (*PI == "%time%") { - if (isSet(TIME_PASSES_FLAG)) - action->args.push_back("-time-passes"); - } else - found = false; - break; - case 'v': - if (*PI == "%verbose%") { - if (isSet(VERBOSE_FLAG)) - action->args.push_back("-v"); - } else - found = false; - break; - case 'M': - if (*PI == "%Mopts%") { - if (!MOptions.empty()) - action->args.insert(action->args.end(), MOptions.begin(), - MOptions.end()); - } else - found = false; - break; - case 'W': - if (*PI == "%Wopts%") { - for (StringVector::iterator I = WOptions.begin(), - E = WOptions.end(); I != E ; ++I ) { - action->args.push_back(std::string("-W") + *I); - } - } else - found = false; - break; - default: - found = false; - break; - } - if (!found) { - // Did it even look like a substitution? - if (PI->length()>1 && (*PI)[0] == '%' && - (*PI)[PI->length()-1] == '%') { - throw std::string("Invalid substitution token: '") + *PI + - "' for command '" + pat->program.toString() + "'"; - } else if (!PI->empty()) { - // It's not a legal substitution, just pass it through - action->args.push_back(*PI); - } - } - } else if (!PI->empty()) { - // Its not a substitution, just put it in the action - action->args.push_back(*PI); - } - PI++; - } - - // Finally, we're done - return action; - } - - int DoAction(Action*action, std::string& ErrMsg) { - assert(action != 0 && "Invalid Action!"); - if (isSet(VERBOSE_FLAG)) - WriteAction(action); - if (!isSet(DRY_RUN_FLAG)) { - sys::Path |