For PR514:

* language specification files are no longer configured with "configure"
* add substitutions for %bindir%, %libdir%, and various llvmgcc related
  variables needed in the c and cpp spec files.
* Implement the stubstituions in the Compiler Driver.
* Move st.in to projects/Stacker/tools/stkrc where it belongs.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22128 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Reid Spencer 2005-05-19 00:52:28 +00:00
parent 8f9e21e3de
commit cc97cfc43e
9 changed files with 131 additions and 67 deletions

View File

@ -249,6 +249,14 @@ private:
} else } else
found = false; found = false;
break; 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': case 'd':
if (*PI == "%defs%") { if (*PI == "%defs%") {
StringVector::iterator I = Defines.begin(); StringVector::iterator I = Defines.begin();
@ -282,13 +290,35 @@ private:
found = false; found = false;
break; break;
case 'l': case 'l':
if (*PI == "%libs%") { 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 I = LibraryPaths.begin();
PathVector::iterator E = LibraryPaths.end(); PathVector::iterator E = LibraryPaths.end();
while (I != E) { while (I != E) {
action->args.push_back( std::string("-L") + I->toString() ); action->args.push_back( std::string("-L") + I->toString() );
++I; ++I;
} }
} else if (*PI == "%libdir%") {
std::string tmp(*PI);
tmp.replace(0,8,LLVM_LIBDIR);
action->args.push_back(tmp);
} else } else
found = false; found = false;
break; break;
@ -896,6 +926,8 @@ private:
CompilerDriver::~CompilerDriver() { CompilerDriver::~CompilerDriver() {
} }
CompilerDriver::ConfigDataProvider::~ConfigDataProvider() {}
CompilerDriver* CompilerDriver*
CompilerDriver::Get(ConfigDataProvider& CDP) { CompilerDriver::Get(ConfigDataProvider& CDP) {
return new CompilerDriverImpl(CDP); return new CompilerDriverImpl(CDP);

View File

@ -110,6 +110,7 @@ namespace llvm {
/// @brief Configuration Data Provider interface /// @brief Configuration Data Provider interface
class ConfigDataProvider { class ConfigDataProvider {
public: public:
virtual ~ConfigDataProvider();
virtual ConfigData* ProvideConfigData(const std::string& filetype) = 0; virtual ConfigData* ProvideConfigData(const std::string& filetype) = 0;
virtual void setConfigDir(const sys::Path& dirName) = 0; virtual void setConfigDir(const sys::Path& dirName) = 0;
}; };

View File

@ -48,53 +48,61 @@ class InputProvider {
extern InputProvider* ConfigLexerInput; extern InputProvider* ConfigLexerInput;
enum ConfigLexerTokens { enum ConfigLexerTokens {
EOFTOK = 0, ///< Returned by Configlex when we hit end of file EOFTOK = 0, ///< Returned by Configlex when we hit end of file
EOLTOK, ///< End of line EOLTOK, ///< End of line
ERRORTOK, ///< Error token ERRORTOK, ///< Error token
ARGS_SUBST, ///< THe substitution item %args% ARGS_SUBST, ///< The substitution item %args%
ASSEMBLY, ///< The value "assembly" (and variants) BINDIR_SUBST, ///< The substitution item %bindir%
ASSEMBLER, ///< The name "assembler" (and variants) ASSEMBLY, ///< The value "assembly" (and variants)
BYTECODE, ///< The value "bytecode" (and variants) ASSEMBLER, ///< The name "assembler" (and variants)
COMMAND, ///< The name "command" (and variants) BYTECODE, ///< The value "bytecode" (and variants)
DEFS_SUBST, ///< The substitution item %defs% COMMAND, ///< The name "command" (and variants)
EQUALS, ///< The equals sign, = DEFS_SUBST, ///< The substitution item %defs%
FALSETOK, ///< A boolean false value (false/no/off) EQUALS, ///< The equals sign, =
FOPTS_SUBST, ///< The substitution item %fOpts% FALSETOK, ///< A boolean false value (false/no/off)
IN_SUBST, ///< The substitution item %in% FOPTS_SUBST, ///< The substitution item %fOpts%
INCLS_SUBST, ///< The substitution item %incls% IN_SUBST, ///< The substitution item %in%
INTEGER, ///< An integer INCLS_SUBST, ///< The substitution item %incls%
LANG, ///< The name "lang" (and variants) INTEGER, ///< An integer
LIBPATHS, ///< The name "libpaths" (and variants) LANG, ///< The name "lang" (and variants)
LIBS, ///< The name "libs" (and variants) LIBDIR_SUBST, ///< The substitution item %libdir%
LIBS_SUBST, ///< The substitution item %libs% LIBPATHS, ///< The name "libpaths" (and variants)
LINKER, ///< The name "linker" (and variants) LIBS, ///< The name "libs" (and variants)
MOPTS_SUBST, ///< The substitution item %Mopts% LIBS_SUBST, ///< The substitution item %libs%
NAME, ///< The name "name" (and variants) LINKER, ///< The name "linker" (and variants)
OPT_SUBST, ///< The substitution item %opt% LLVMGCCDIR_SUBST, ///< The substitution item %llvmgccdir%
OPTIMIZER, ///< The name "optimizer" (and variants) LLVMGCCARCH_SUBST, ///< The substitution item %llvmgccarch%
OPTION, ///< A command line option LLVMGCC_SUBST, ///< The substitution item %llvmgcc%
OPT1, ///< The name "opt1" (and variants) LLVMGXX_SUBST, ///< The substitution item %llvmgxx%
OPT2, ///< The name "opt2" (and variants) LLVMCC1_SUBST, ///< The substitution item %llvmcc1%
OPT3, ///< The name "opt3" (and variants) LLVMCC1PLUS_SUBST, ///< The substitution item %llvmcc1plus%
OPT4, ///< The name "opt4" (and variants) MOPTS_SUBST, ///< The substitution item %Mopts%
OPT5, ///< The name "opt5" (and variants) NAME, ///< The name "name" (and variants)
OUT_SUBST, ///< The output substitution item %out% OPT_SUBST, ///< The substitution item %opt%
OUTPUT, ///< The name "output" (and variants) OPTIMIZER, ///< The name "optimizer" (and variants)
PREPROCESSES, ///< The name "preprocesses" (and variants) OPTION, ///< A command line option
PREPROCESSOR, ///< The name "preprocessor" (and variants) OPT1, ///< The name "opt1" (and variants)
REQUIRED, ///< The name "required" (and variants) OPT2, ///< The name "opt2" (and variants)
SEPARATOR, ///< A configuration item separator OPT3, ///< The name "opt3" (and variants)
SPACE, ///< Space between options OPT4, ///< The name "opt4" (and variants)
STATS_SUBST, ///< The stats substitution item %stats% OPT5, ///< The name "opt5" (and variants)
STRING, ///< A quoted string OUT_SUBST, ///< The output substitution item %out%
TARGET_SUBST, ///< The substitition item %target% OUTPUT, ///< The name "output" (and variants)
TIME_SUBST, ///< The substitution item %time% PREPROCESSES, ///< The name "preprocesses" (and variants)
TRANSLATES, ///< The name "translates" (and variants) PREPROCESSOR, ///< The name "preprocessor" (and variants)
TRANSLATOR, ///< The name "translator" (and variants) REQUIRED, ///< The name "required" (and variants)
TRUETOK, ///< A boolean true value (true/yes/on) SEPARATOR, ///< A configuration item separator
VERBOSE_SUBST,///< The substitution item %verbose% SPACE, ///< Space between options
VERSION_TOK, ///< The name "version" (and variants) STATS_SUBST, ///< The stats substitution item %stats%
WOPTS_SUBST, ///< The %WOpts% substitution STRING, ///< A quoted string
TARGET_SUBST, ///< The substitition item %target%
TIME_SUBST, ///< The substitution item %time%
TRANSLATES, ///< The name "translates" (and variants)
TRANSLATOR, ///< The name "translator" (and variants)
TRUETOK, ///< A boolean true value (true/yes/on)
VERBOSE_SUBST, ///< The substitution item %verbose%
VERSION_TOK, ///< The name "version" (and variants)
WOPTS_SUBST, ///< The %WOpts% substitution
}; };
extern ConfigLexerTokens Configlex(); extern ConfigLexerTokens Configlex();

View File

@ -163,10 +163,18 @@ White [ \t]*
{LINKER} { return handleNameContext(LINKER); } {LINKER} { return handleNameContext(LINKER); }
%args% { return handleSubstitution(ARGS_SUBST); } %args% { return handleSubstitution(ARGS_SUBST); }
%bindir% { return handleSubstitution(BINDIR_SUBST); }
%defs% { return handleSubstitution(DEFS_SUBST); } %defs% { return handleSubstitution(DEFS_SUBST); }
%in% { return handleSubstitution(IN_SUBST); } %in% { return handleSubstitution(IN_SUBST); }
%incls% { return handleSubstitution(INCLS_SUBST); } %incls% { return handleSubstitution(INCLS_SUBST); }
%libdir% { return handleSubstitution(LIBDIR_SUBST); }
%libs% { return handleSubstitution(LIBS_SUBST); } %libs% { return handleSubstitution(LIBS_SUBST); }
%llvmgccdir% { return handleSubstitution(LLVMGCCDIR_SUBST); }
%llvmgccarch% { return handleSubstitution(LLVMGCCARCH_SUBST); }
%llvmgcc% { return handleSubstitution(LLVMGCC_SUBST); }
%llvmgxx% { return handleSubstitution(LLVMGXX_SUBST); }
%llvmcc1% { return handleSubstitution(LLVMCC1_SUBST); }
%llvmcc1plus% { return handleSubstitution(LLVMCC1PLUS_SUBST); }
%opt% { return handleSubstitution(OPT_SUBST); } %opt% { return handleSubstitution(OPT_SUBST); }
%out% { return handleSubstitution(OUT_SUBST); } %out% { return handleSubstitution(OUT_SUBST); }
%stats% { return handleSubstitution(STATS_SUBST); } %stats% { return handleSubstitution(STATS_SUBST); }

View File

@ -167,9 +167,11 @@ namespace {
bool parseSubstitution(CompilerDriver::StringVector& optList) { bool parseSubstitution(CompilerDriver::StringVector& optList) {
switch (token) { switch (token) {
case ARGS_SUBST: optList.push_back("%args%"); break; case ARGS_SUBST: optList.push_back("%args%"); break;
case BINDIR_SUBST: optList.push_back("%bindir%"); break;
case DEFS_SUBST: optList.push_back("%defs%"); break; case DEFS_SUBST: optList.push_back("%defs%"); break;
case IN_SUBST: optList.push_back("%in%"); break; case IN_SUBST: optList.push_back("%in%"); break;
case INCLS_SUBST: optList.push_back("%incls%"); break; case INCLS_SUBST: optList.push_back("%incls%"); break;
case LIBDIR_SUBST: optList.push_back("%libdir%"); break;
case LIBS_SUBST: optList.push_back("%libs%"); break; case LIBS_SUBST: optList.push_back("%libs%"); break;
case OPT_SUBST: optList.push_back("%opt%"); break; case OPT_SUBST: optList.push_back("%opt%"); break;
case OUT_SUBST: optList.push_back("%out%"); break; case OUT_SUBST: optList.push_back("%out%"); break;

View File

@ -9,14 +9,27 @@
LEVEL = ../.. LEVEL = ../..
TOOLNAME = llvmc TOOLNAME = llvmc
USEDLIBS = LLVMBCReader LLVMCore LLVMSupport.a LLVMbzip2 LLVMSystem.a USEDLIBS = LLVMBCReader LLVMCore LLVMSupport.a LLVMbzip2 LLVMSystem.a
CONFIG_FILES = c cpp ll st CONFIG_FILES = c cpp ll
EXTRA_DIST = c cpp ll st EXTRA_DIST = c cpp ll
# The CompilerDriver needs to know the locations of several configured
# directories and paths. We define these as preprocessor symbols so they can
# be hard coded into the process based on the configuration. Only those
# configuration values not available in llvm/include/Config/config.h need to be
# specified here. These values are used as the replacements for the
# configuration file substitution variables such as %llvmgccdir%
CPPFLAGS = -DLLVMGCCDIR="\"$(LLVMGCCDIR)\"" \
-DLLVMGCCARCH="\"$(LLVMGCCARCH)\"" \
-DLLVMGCC="\"$(LLVMGCC)\"" \
-DLLVMGXX="\"$(LLVMGXX)\"" \
-DLLVMCC1="\"$(LLVMCC1)\"" \
-DLLVMCC1PLUS="$(LLVMCC1PLUS)"
include $(LEVEL)/Makefile.common include $(LEVEL)/Makefile.common
install:: install::
$(Echo) Installing additional C++ configuration clones $(Echo) Installing additional C++ configuration clones
$(Verb)$(DataInstall) $(PROJ_OBJ_DIR)/cpp $(PROJ_etcdir)/cc $(Verb)$(DataInstall) $(PROJ_SRC_DIR)/cpp $(PROJ_etcdir)/cc
$(Verb)$(DataInstall) $(PROJ_OBJ_DIR)/cpp $(PROJ_etcdir)/c++ $(Verb)$(DataInstall) $(PROJ_SRC_DIR)/cpp $(PROJ_etcdir)/c++
$(Verb)$(DataInstall) $(PROJ_OBJ_DIR)/cpp $(PROJ_etcdir)/cxx $(Verb)$(DataInstall) $(PROJ_SRC_DIR)/cpp $(PROJ_etcdir)/cxx
$(Verb)$(DataInstall) $(PROJ_OBJ_DIR)/cpp $(PROJ_etcdir)/C $(Verb)$(DataInstall) $(PROJ_SRC_DIR)/cpp $(PROJ_etcdir)/C

View File

@ -9,8 +9,8 @@
lang.opt3=-O3 lang.opt3=-O3
lang.opt4=-O3 lang.opt4=-O3
lang.opt5=-O3 lang.opt5=-O3
lang.libs=@LLVMGCCDIR@/lib @LLVMGCCDIR@/lib \ lang.libs=%llvmgccdir%/lib %llvmgccdir%/lib \
@LLVMGCCDIR@/lib/gcc/@LLVMGCCARCH@ %llvmgccdir%/lib/gcc/%llvmgccarch%
########################################################## ##########################################################
# Pre-processor definitions # Pre-processor definitions
@ -25,7 +25,7 @@
########################################################## ##########################################################
# To compile C source, just use llvm-gcc's cc1 # To compile C source, just use llvm-gcc's cc1
translator.command=@LLVMCC1@ -quiet %in% -o %out% \ translator.command=%llvmcc1% -quiet %in% -o %out% \
%opt% %incls% %defs% %WOpts% %fOpts% %MOpts% %args% \ %opt% %incls% %defs% %WOpts% %fOpts% %MOpts% %args% \
-D_GNU_SOURCE -D_GNU_SOURCE
@ -43,7 +43,7 @@
########################################################## ##########################################################
# Use gccas to clean up the generated code # Use gccas to clean up the generated code
optimizer.command=@LLVM_BINDIR@/gccas %in% -o %out% %args% optimizer.command=%bindir%/gccas %in% -o %out% %args%
optimizer.required = true optimizer.required = true
# gccas doesn't translate # gccas doesn't translate
@ -58,4 +58,4 @@
########################################################## ##########################################################
# Assembler definitions # Assembler definitions
########################################################## ##########################################################
assembler.command=@LLVM_BINDIR@/llc %in% -o %out% %target% %time% %stats% assembler.command=%bindir%/llc %in% -o %out% %target% %time% %stats%

View File

@ -9,8 +9,8 @@
lang.opt3=-O3 lang.opt3=-O3
lang.opt4=-O3 lang.opt4=-O3
lang.opt5=-O3 lang.opt5=-O3
lang.libs=@LLVMGCCDIR@/lib @LLVMGCCDIR@/lib \ lang.libs=%llvmgccdir%/lib %llvmgccdir%/lib \
@LLVMGCCDIR@/lib/gcc/@LLVMGCCARCH@ %llvmgccdir%/lib/gcc/%llvmgccarch%
########################################################## ##########################################################
# Pre-processor definitions # Pre-processor definitions
@ -25,7 +25,7 @@
########################################################## ##########################################################
# To compile C++ source, just use llvm-g++'s cc1 # To compile C++ source, just use llvm-g++'s cc1
translator.command=@LLVMCC1PLUS@ -quiet %in% -o %out% \ translator.command=%llvmcc1plus% -quiet %in% -o %out% \
%opt% %incls% %defs% %WOpts% %fOpts% %MOpts% %args% \ %opt% %incls% %defs% %WOpts% %fOpts% %MOpts% %args% \
-D_GNU_SOURCE -D_GNU_SOURCE
@ -43,7 +43,7 @@
########################################################## ##########################################################
# Use gccas to clean up the generated code # Use gccas to clean up the generated code
optimizer.command=@LLVM_BINDIR@/gccas %in% -o %out% %args% optimizer.command=%bindir%/gccas %in% -o %out% %args%
optimizer.required = true optimizer.required = true
# gccas doesn't translate # gccas doesn't translate
@ -58,4 +58,4 @@
########################################################## ##########################################################
# Assembler definitions # Assembler definitions
########################################################## ##########################################################
assembler.command=@LLVM_BINDIR@/llc %in% -o %out% %target% %time% %stats% assembler.command=%bindir%/llc %in% -o %out% %target% %time% %stats%

View File

@ -3,10 +3,10 @@
lang.name=LLVM Assembly lang.name=LLVM Assembly
preprocessor.command= preprocessor.command=
preprocessor.required=false preprocessor.required=false
translator.command=@bindir@/llvm-as %in% -o %out% translator.command=%bindir%/llvm-as %in% -o %out%
translator.optimizes=no translator.optimizes=no
translator.preprocesses=true translator.preprocesses=true
translator.required=TRUE translator.required=TRUE
optimizer.command=@bindir@/opt %in% -o %out% %opt% %args% optimizer.command=%bindir%/opt %in% -o %out% %opt% %args%
optimizer.translates=no optimizer.translates=no
assembler.command=@bindir@/llc %in% -o %out% assembler.command=%bindir%/llc %in% -o %out%