For PR514:
authorReid Spencer <rspencer@reidspencer.com>
Thu, 19 May 2005 00:52:28 +0000 (00:52 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Thu, 19 May 2005 00:52:28 +0000 (00:52 +0000)
* 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

12 files changed:
tools/llvmc/CompilerDriver.cpp
tools/llvmc/CompilerDriver.h
tools/llvmc/ConfigLexer.h
tools/llvmc/ConfigLexer.l
tools/llvmc/Configuration.cpp
tools/llvmc/Makefile
tools/llvmc/c [new file with mode: 0644]
tools/llvmc/c.in [deleted file]
tools/llvmc/cpp [new file with mode: 0644]
tools/llvmc/cpp.in [deleted file]
tools/llvmc/ll [new file with mode: 0644]
tools/llvmc/ll.in [deleted file]

index e7addf86e4ec0c3733fd0a0bdf8c4d1a92857df2..39a2989926121e14a789510cddc43bc6d362b2c5 100644 (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);
index 6f9d0f497accf79dd493f44884aa2d515b6bcd8d..1100e3e46f8b848100d67d2cd2ae00c929a28550 100644 (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;
       };
index 8d8205e18febc233b76888bf3d4645d2eaf54ad0..3e87fc1a58a746ff528d3f6a266c30662de38f3f 100644 (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();
index f65428ecd66a1737722ad6ea77ce7493c13e6fb2..ca21f4f64d24036d356dfd16a820a23e5054b219 100644 (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); }
index 2abf651d70210dfaa3c415b96e9973dc909912b0..3b9d221fe358dcad644c278c38b506ae24a1256a 100644 (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;
index 29ec6d9326a83e485dc86cb4e4251240f758ae33..d4b6275ce82f6c3491e970652906090133b91e10 100644 (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
diff --git a/tools/llvmc/c b/tools/llvmc/c
new file mode 100644 (file)
index 0000000..cbe6830
--- /dev/null
@@ -0,0 +1,61 @@
+# C configuration file for llvmc
+
+##########################################################
+# Language definitions
+##########################################################
+  lang.name=C
+  lang.opt1=-O1
+  lang.opt2=-O2
+  lang.opt3=-O3
+  lang.opt4=-O3
+  lang.opt5=-O3
+  lang.libs=%llvmgccdir%/lib %llvmgccdir%/lib \
+    %llvmgccdir%/lib/gcc/%llvmgccarch%
+
+##########################################################
+# Pre-processor definitions
+##########################################################
+
+  # We use gcc as our pre-processor
+  preprocessor.command=gcc -E %in% -o %out% %incls% %defs%
+  preprocessor.required=true
+
+##########################################################
+# Translator definitions
+##########################################################
+
+  # To compile C source, just use llvm-gcc's cc1
+  translator.command=%llvmcc1% -quiet %in% -o %out% \
+    %opt% %incls% %defs% %WOpts% %fOpts% %MOpts% %args% \
+    -D_GNU_SOURCE
+
+  # llvm-gcc does not pre-process
+  translator.preprocesses=false
+
+  # The translator is required to run.
+  translator.required=true
+
+  # Output of the translator is assembly
+  translator.output=assembly
+
+##########################################################
+# Optimizer definitions
+##########################################################
+  
+  # Use gccas to clean up the generated code
+  optimizer.command=%bindir%/gccas %in% -o %out% %args%
+  optimizer.required = true
+
+  # gccas doesn't translate
+  optimizer.translates = false
+
+  # gccas doesn't preprocess
+  optimizer.preprocesses=false
+
+  # gccas produces bytecode
+  optimizer.output = bytecode
+
+##########################################################
+# Assembler definitions
+##########################################################
+  assembler.command=%bindir%/llc %in% -o %out% %target% %time% %stats%
diff --git a/tools/llvmc/c.in b/tools/llvmc/c.in
deleted file mode 100644 (file)
index d1d151c..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-# C configuration file for llvmc
-
-##########################################################
-# Language definitions
-##########################################################
-  lang.name=C
-  lang.opt1=-O1
-  lang.opt2=-O2
-  lang.opt3=-O3
-  lang.opt4=-O3
-  lang.opt5=-O3
-  lang.libs=@LLVMGCCDIR@/lib @LLVMGCCDIR@/lib \
-    @LLVMGCCDIR@/lib/gcc/@LLVMGCCARCH@
-
-##########################################################
-# Pre-processor definitions
-##########################################################
-
-  # We use gcc as our pre-processor
-  preprocessor.command=gcc -E %in% -o %out% %incls% %defs%
-  preprocessor.required=true
-
-##########################################################
-# Translator definitions
-##########################################################
-
-  # To compile C source, just use llvm-gcc's cc1
-  translator.command=@LLVMCC1@ -quiet %in% -o %out% \
-    %opt% %incls% %defs% %WOpts% %fOpts% %MOpts% %args% \
-    -D_GNU_SOURCE
-
-  # llvm-gcc does not pre-process
-  translator.preprocesses=false
-
-  # The translator is required to run.
-  translator.required=true
-
-  # Output of the translator is assembly
-  translator.output=assembly
-
-##########################################################
-# Optimizer definitions
-##########################################################
-  
-  # Use gccas to clean up the generated code
-  optimizer.command=@LLVM_BINDIR@/gccas %in% -o %out% %args%
-  optimizer.required = true
-
-  # gccas doesn't translate
-  optimizer.translates = false
-
-  # gccas doesn't preprocess
-  optimizer.preprocesses=false
-
-  # gccas produces bytecode
-  optimizer.output = bytecode
-
-##########################################################
-# Assembler definitions
-##########################################################
-  assembler.command=@LLVM_BINDIR@/llc %in% -o %out% %target% %time% %stats%
diff --git a/tools/llvmc/cpp b/tools/llvmc/cpp
new file mode 100644 (file)
index 0000000..5f20fd8
--- /dev/null
@@ -0,0 +1,61 @@
+# C++ configuration file for llvmc
+
+##########################################################
+# Language definitions
+##########################################################
+  lang.name=C++
+  lang.opt1=-O1
+  lang.opt2=-O2
+  lang.opt3=-O3
+  lang.opt4=-O3
+  lang.opt5=-O3
+  lang.libs=%llvmgccdir%/lib %llvmgccdir%/lib \
+    %llvmgccdir%/lib/gcc/%llvmgccarch%
+
+##########################################################
+# Pre-processor definitions
+##########################################################
+
+  # We use g++ as our pre-processor
+  preprocessor.command=g++ -E %in% -o %out% %incls% %defs%
+  preprocessor.required=true
+
+##########################################################
+# Translator definitions
+##########################################################
+
+  # To compile C++ source, just use llvm-g++'s cc1
+  translator.command=%llvmcc1plus% -quiet %in% -o %out% \
+    %opt% %incls% %defs% %WOpts% %fOpts% %MOpts% %args% \
+    -D_GNU_SOURCE
+
+  # llvm-g++ does not pre-process
+  translator.preprocesses=false
+
+  # The translator is required to run.
+  translator.required=true
+
+  # Output of translator is assembly
+  translator.output=assembly
+
+##########################################################
+# Optimizer definitions
+##########################################################
+  
+  # Use gccas to clean up the generated code
+  optimizer.command=%bindir%/gccas %in% -o %out% %args%
+  optimizer.required = true
+
+  # gccas doesn't translate
+  optimizer.translates = false
+
+  # gccas doesn't preprocess
+  optimizer.preprocesses=false
+
+  # gccas produces bytecode
+  optimizer.output = bytecode
+
+##########################################################
+# Assembler definitions
+##########################################################
+  assembler.command=%bindir%/llc %in% -o %out% %target% %time% %stats%
diff --git a/tools/llvmc/cpp.in b/tools/llvmc/cpp.in
deleted file mode 100644 (file)
index a065f9c..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-# C++ configuration file for llvmc
-
-##########################################################
-# Language definitions
-##########################################################
-  lang.name=C++
-  lang.opt1=-O1
-  lang.opt2=-O2
-  lang.opt3=-O3
-  lang.opt4=-O3
-  lang.opt5=-O3
-  lang.libs=@LLVMGCCDIR@/lib @LLVMGCCDIR@/lib \
-    @LLVMGCCDIR@/lib/gcc/@LLVMGCCARCH@
-
-##########################################################
-# Pre-processor definitions
-##########################################################
-
-  # We use g++ as our pre-processor
-  preprocessor.command=g++ -E %in% -o %out% %incls% %defs%
-  preprocessor.required=true
-
-##########################################################
-# Translator definitions
-##########################################################
-
-  # To compile C++ source, just use llvm-g++'s cc1
-  translator.command=@LLVMCC1PLUS@ -quiet %in% -o %out% \
-    %opt% %incls% %defs% %WOpts% %fOpts% %MOpts% %args% \
-    -D_GNU_SOURCE
-
-  # llvm-g++ does not pre-process
-  translator.preprocesses=false
-
-  # The translator is required to run.
-  translator.required=true
-
-  # Output of translator is assembly
-  translator.output=assembly
-
-##########################################################
-# Optimizer definitions
-##########################################################
-  
-  # Use gccas to clean up the generated code
-  optimizer.command=@LLVM_BINDIR@/gccas %in% -o %out% %args%
-  optimizer.required = true
-
-  # gccas doesn't translate
-  optimizer.translates = false
-
-  # gccas doesn't preprocess
-  optimizer.preprocesses=false
-
-  # gccas produces bytecode
-  optimizer.output = bytecode
-
-##########################################################
-# Assembler definitions
-##########################################################
-  assembler.command=@LLVM_BINDIR@/llc %in% -o %out% %target% %time% %stats%
diff --git a/tools/llvmc/ll b/tools/llvmc/ll
new file mode 100644 (file)
index 0000000..9c5146c
--- /dev/null
@@ -0,0 +1,12 @@
+# LLVM Assembly Config File For llvmc
+  version="1.0"
+  lang.name=LLVM Assembly
+  preprocessor.command=
+  preprocessor.required=false
+  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.translates=no
+  assembler.command=%bindir%/llc %in% -o %out%
diff --git a/tools/llvmc/ll.in b/tools/llvmc/ll.in
deleted file mode 100644 (file)
index c6567a3..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-# LLVM Assembly Config File For llvmc
-  version="1.0"
-  lang.name=LLVM Assembly
-  preprocessor.command=
-  preprocessor.required=false
-  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.translates=no
-  assembler.command=@bindir@/llc %in% -o %out%