[llvm-commits] CVS: llvm/tools/gccld/GenerateCode.cpp gccld.h gccld.cpp

Misha Brukman brukman at cs.uiuc.edu
Tue Apr 19 20:22:29 PDT 2005



Changes in directory llvm/tools/gccld:

GenerateCode.cpp updated: 1.45 -> 1.46
gccld.h updated: 1.13 -> 1.14
gccld.cpp updated: 1.97 -> 1.98
---
Log message:

* Print commands as we execute them with `-v'
* Add option `-save-temps'
Patch contributed by Markus Oberhumer.


---
Diffs of the changes:  (+44 -21)

 GenerateCode.cpp |   20 ++++++++++++++++----
 gccld.cpp        |   36 ++++++++++++++++++++++--------------
 gccld.h          |    9 ++++++---
 3 files changed, 44 insertions(+), 21 deletions(-)


Index: llvm/tools/gccld/GenerateCode.cpp
diff -u llvm/tools/gccld/GenerateCode.cpp:1.45 llvm/tools/gccld/GenerateCode.cpp:1.46
--- llvm/tools/gccld/GenerateCode.cpp:1.45	Sun Apr 10 15:58:21 2005
+++ llvm/tools/gccld/GenerateCode.cpp	Tue Apr 19 22:22:18 2005
@@ -120,6 +120,13 @@
   return;
 }
 
+static void dumpArgs(const char **args) {
+  std::cout << *args++;
+  while (*args)
+    std::cout << ' ' << *args++;
+  std::cout << '\n';
+}
+
 static inline void addPass(PassManager &PM, Pass *P) {
   // Add the pass to the pass manager...
   PM.add(P);
@@ -297,7 +304,8 @@
 ///
 int llvm::GenerateAssembly(const std::string &OutputFilename,
                            const std::string &InputFilename,
-                           const sys::Path &llc) {
+                           const sys::Path &llc,
+                           bool Verbose) {
   // Run LLC to convert the bytecode file into assembly code.
   std::vector<const char*> args;
   args.push_back(llc.c_str());
@@ -306,7 +314,7 @@
   args.push_back(OutputFilename.c_str());
   args.push_back(InputFilename.c_str());
   args.push_back(0);
-
+  if (Verbose) dumpArgs(&args[0]);
   return sys::Program::ExecuteAndWait(llc, &args[0]);
 }
 
@@ -314,7 +322,8 @@
 /// specified bytecode file.
 int llvm::GenerateCFile(const std::string &OutputFile,
                         const std::string &InputFile,
-                        const sys::Path &llc) {
+                        const sys::Path &llc,
+                        bool Verbose) {
   // Run LLC to convert the bytecode file into C.
   std::vector<const char*> args;
   args.push_back(llc.c_str());
@@ -324,6 +333,7 @@
   args.push_back(OutputFile.c_str());
   args.push_back(InputFile.c_str());
   args.push_back(0);
+  if (Verbose) dumpArgs(&args[0]);
   return sys::Program::ExecuteAndWait(llc, &args[0]);
 }
 
@@ -349,7 +359,8 @@
                          const sys::Path &gcc, char ** const envp,
                          bool Shared,
                          const std::string &RPath,
-                         const std::string &SOName) {
+                         const std::string &SOName,
+                         bool Verbose) {
   // Remove these environment variables from the environment of the
   // programs that we will execute.  It appears that GCC sets these
   // environment variables so that the programs it uses can configure
@@ -417,6 +428,7 @@
   args.push_back(0);
 
   // Run the compiler to assembly and link together the program.
+  if (Verbose) dumpArgs(&args[0]);
   return sys::Program::ExecuteAndWait(gcc, &args[0], (const char**)clean_env);
 }
 


Index: llvm/tools/gccld/gccld.h
diff -u llvm/tools/gccld/gccld.h:1.13 llvm/tools/gccld/gccld.h:1.14
--- llvm/tools/gccld/gccld.h:1.13	Mon Feb 28 02:45:35 2005
+++ llvm/tools/gccld/gccld.h	Tue Apr 19 22:22:18 2005
@@ -29,12 +29,14 @@
 int
 GenerateAssembly (const std::string & OutputFilename,
                   const std::string & InputFilename,
-                  const sys::Path & llc);
+                  const sys::Path & llc,
+                  bool Verbose=false);
 
 int 
 GenerateCFile (const std::string &OutputFile, 
                const std::string &InputFile,
-               const sys::Path &llc);
+               const sys::Path &llc,
+               bool Verbose=false);
 int
 GenerateNative (const std::string & OutputFilename,
                 const std::string & InputFilename,
@@ -44,6 +46,7 @@
                 char ** const envp,
                 bool Shared,
                 const std::string & RPath,
-                const std::string & SOName);
+                const std::string & SOName,
+                bool Verbose=false);
 
 } // End llvm namespace


Index: llvm/tools/gccld/gccld.cpp
diff -u llvm/tools/gccld/gccld.cpp:1.97 llvm/tools/gccld/gccld.cpp:1.98
--- llvm/tools/gccld/gccld.cpp:1.97	Mon Feb 28 02:45:35 2005
+++ llvm/tools/gccld/gccld.cpp	Tue Apr 19 22:22:18 2005
@@ -83,6 +83,10 @@
   cl::opt<bool>    
   NativeCBE("native-cbe",
             cl::desc("Generate a native binary with the C backend and GCC"));
+
+  cl::opt<bool>    
+  SaveTemps("save-temps",
+         cl::desc("Do not delete temporary files"));
             
   cl::opt<std::string>
   RPath("rpath",
@@ -300,16 +304,19 @@
 
       // Generate an assembly language file for the bytecode.
       if (Verbose) std::cout << "Generating Assembly Code\n";
-      GenerateAssembly(AssemblyFile.toString(), RealBytecodeOutput, llc);
+      GenerateAssembly(AssemblyFile.toString(), RealBytecodeOutput, llc, 
+                       Verbose);
       if (Verbose) std::cout << "Generating Native Code\n";
       GenerateNative(OutputFilename, AssemblyFile.toString(), 
                      LibPaths, Libraries, gcc, envp, LinkAsLibrary, RPath,
-                     SOName );
+                     SOName, Verbose);
 
-      // Remove the assembly language file.
-      AssemblyFile.destroyFile();
-      // Remove the bytecode language file.
-      sys::Path(RealBytecodeOutput).destroyFile();
+      if (!SaveTemps) {
+        // Remove the assembly language file.
+        AssemblyFile.destroyFile();
+        // Remove the bytecode language file.
+        sys::Path(RealBytecodeOutput).destroyFile();
+      }
     
     } else if (NativeCBE) {
       sys::Path CFile (OutputFilename);
@@ -329,18 +336,19 @@
         return PrintAndReturn(argv[0], "Failed to find gcc");
 
       // Generate an assembly language file for the bytecode.
-      if (Verbose) std::cout << "Generating Assembly Code\n";
-      GenerateCFile(CFile.toString(), RealBytecodeOutput, llc);
+      if (Verbose) std::cout << "Generating C Source Code\n";
+      GenerateCFile(CFile.toString(), RealBytecodeOutput, llc, Verbose);
       if (Verbose) std::cout << "Generating Native Code\n";
       GenerateNative(OutputFilename, CFile.toString(),
                      LibPaths, Libraries, gcc, envp, LinkAsLibrary, RPath,
-                     SOName );
+                     SOName, Verbose);
 
-      // Remove the assembly language file.
-      CFile.destroyFile();
-    
-      // Remove the bytecode language file.
-      sys::Path(RealBytecodeOutput).destroyFile();
+      if (!SaveTemps) {
+        // Remove the assembly language file.
+        CFile.destroyFile();
+        // Remove the bytecode language file.
+        sys::Path(RealBytecodeOutput).destroyFile();
+      }
 
     } else if (!LinkAsLibrary) {
       EmitShellScript(argv);






More information about the llvm-commits mailing list