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
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();
@ -282,13 +290,35 @@ private:
found = false;
break;
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 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;
@ -896,6 +926,8 @@ private:
CompilerDriver::~CompilerDriver() {
}
CompilerDriver::ConfigDataProvider::~ConfigDataProvider() {}
CompilerDriver*
CompilerDriver::Get(ConfigDataProvider& CDP) {
return new CompilerDriverImpl(CDP);

View File

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

View File

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

View File

@ -163,10 +163,18 @@ White [ \t]*
{LINKER} { return handleNameContext(LINKER); }
%args% { return handleSubstitution(ARGS_SUBST); }
%bindir% { return handleSubstitution(BINDIR_SUBST); }
%defs% { return handleSubstitution(DEFS_SUBST); }
%in% { return handleSubstitution(IN_SUBST); }
%incls% { return handleSubstitution(INCLS_SUBST); }
%libdir% { return handleSubstitution(LIBDIR_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); }
%out% { return handleSubstitution(OUT_SUBST); }
%stats% { return handleSubstitution(STATS_SUBST); }

View File

@ -167,9 +167,11 @@ namespace {
bool parseSubstitution(CompilerDriver::StringVector& optList) {
switch (token) {
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 IN_SUBST: optList.push_back("%in%"); 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 OPT_SUBST: optList.push_back("%opt%"); break;
case OUT_SUBST: optList.push_back("%out%"); break;

View File

@ -9,14 +9,27 @@
LEVEL = ../..
TOOLNAME = llvmc
USEDLIBS = LLVMBCReader LLVMCore LLVMSupport.a LLVMbzip2 LLVMSystem.a
CONFIG_FILES = c cpp ll st
EXTRA_DIST = c cpp ll st
CONFIG_FILES = c cpp ll
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
install::
$(Echo) Installing additional C++ configuration clones
$(Verb)$(DataInstall) $(PROJ_OBJ_DIR)/cpp $(PROJ_etcdir)/cc
$(Verb)$(DataInstall) $(PROJ_OBJ_DIR)/cpp $(PROJ_etcdir)/c++
$(Verb)$(DataInstall) $(PROJ_OBJ_DIR)/cpp $(PROJ_etcdir)/cxx
$(Verb)$(DataInstall) $(PROJ_OBJ_DIR)/cpp $(PROJ_etcdir)/C
$(Verb)$(DataInstall) $(PROJ_SRC_DIR)/cpp $(PROJ_etcdir)/cc
$(Verb)$(DataInstall) $(PROJ_SRC_DIR)/cpp $(PROJ_etcdir)/c++
$(Verb)$(DataInstall) $(PROJ_SRC_DIR)/cpp $(PROJ_etcdir)/cxx
$(Verb)$(DataInstall) $(PROJ_SRC_DIR)/cpp $(PROJ_etcdir)/C

View File

@ -9,8 +9,8 @@
lang.opt3=-O3
lang.opt4=-O3
lang.opt5=-O3
lang.libs=@LLVMGCCDIR@/lib @LLVMGCCDIR@/lib \
@LLVMGCCDIR@/lib/gcc/@LLVMGCCARCH@
lang.libs=%llvmgccdir%/lib %llvmgccdir%/lib \
%llvmgccdir%/lib/gcc/%llvmgccarch%
##########################################################
# Pre-processor definitions
@ -25,7 +25,7 @@
##########################################################
# 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% \
-D_GNU_SOURCE
@ -43,7 +43,7 @@
##########################################################
# 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
# gccas doesn't translate
@ -58,4 +58,4 @@
##########################################################
# 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.opt4=-O3
lang.opt5=-O3
lang.libs=@LLVMGCCDIR@/lib @LLVMGCCDIR@/lib \
@LLVMGCCDIR@/lib/gcc/@LLVMGCCARCH@
lang.libs=%llvmgccdir%/lib %llvmgccdir%/lib \
%llvmgccdir%/lib/gcc/%llvmgccarch%
##########################################################
# Pre-processor definitions
@ -25,7 +25,7 @@
##########################################################
# 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% \
-D_GNU_SOURCE
@ -43,7 +43,7 @@
##########################################################
# 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
# gccas doesn't translate
@ -58,4 +58,4 @@
##########################################################
# 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
preprocessor.command=
preprocessor.required=false
translator.command=@bindir@/llvm-as %in% -o %out%
translator.command=%bindir%/llvm-as %in% -o %out%
translator.optimizes=no
translator.preprocesses=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
assembler.command=@bindir@/llc %in% -o %out%
assembler.command=%bindir%/llc %in% -o %out%