[llvm-commits] [llvm] r50722 - in /llvm/trunk: tools/llvmc2/Action.cpp tools/llvmc2/Action.h tools/llvmc2/AutoGenerated.cpp tools/llvmc2/AutoGenerated.h tools/llvmc2/CompilationGraph.cpp tools/llvmc2/CompilationGraph.h tools/llvmc2/Core.cpp tools/llvmc2/Core.h tools/llvmc2/Makefile tools/llvmc2/Tool.cpp tools/llvmc2/Tool.h tools/llvmc2/Tools.cpp tools/llvmc2/Tools.h tools/llvmc2/Utility.cpp tools/llvmc2/Utility.h tools/llvmc2/llvmc.cpp tools/llvmc2/llvmcc.cpp utils/TableGen/LLVMCCConfigurationEmitter.cpp

Mikhail Glushenkov foldr at codedgers.com
Tue May 6 09:34:12 PDT 2008


Author: foldr
Date: Tue May  6 11:34:12 2008
New Revision: 50722

URL: http://llvm.org/viewvc/llvm-project?rev=50722&view=rev
Log:
Code reorg

Added:
    llvm/trunk/tools/llvmc2/Action.cpp
    llvm/trunk/tools/llvmc2/Action.h
      - copied, changed from r50718, llvm/trunk/tools/llvmc2/Tools.h
    llvm/trunk/tools/llvmc2/AutoGenerated.cpp
      - copied, changed from r50718, llvm/trunk/tools/llvmc2/Tools.cpp
    llvm/trunk/tools/llvmc2/AutoGenerated.h
      - copied, changed from r50718, llvm/trunk/tools/llvmc2/Tools.h
    llvm/trunk/tools/llvmc2/CompilationGraph.cpp
      - copied, changed from r50718, llvm/trunk/tools/llvmc2/Core.cpp
    llvm/trunk/tools/llvmc2/CompilationGraph.h
    llvm/trunk/tools/llvmc2/Tool.cpp
      - copied, changed from r50718, llvm/trunk/tools/llvmc2/Tools.cpp
    llvm/trunk/tools/llvmc2/Tool.h
      - copied, changed from r50718, llvm/trunk/tools/llvmc2/Core.h
    llvm/trunk/tools/llvmc2/llvmc.cpp
      - copied, changed from r50718, llvm/trunk/tools/llvmc2/llvmcc.cpp
Removed:
    llvm/trunk/tools/llvmc2/Core.cpp
    llvm/trunk/tools/llvmc2/Core.h
    llvm/trunk/tools/llvmc2/Tools.cpp
    llvm/trunk/tools/llvmc2/Tools.h
    llvm/trunk/tools/llvmc2/Utility.cpp
    llvm/trunk/tools/llvmc2/Utility.h
    llvm/trunk/tools/llvmc2/llvmcc.cpp
Modified:
    llvm/trunk/tools/llvmc2/Makefile
    llvm/trunk/utils/TableGen/LLVMCCConfigurationEmitter.cpp

Added: llvm/trunk/tools/llvmc2/Action.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/Action.cpp?rev=50722&view=auto

==============================================================================
--- llvm/trunk/tools/llvmc2/Action.cpp (added)
+++ llvm/trunk/tools/llvmc2/Action.cpp Tue May  6 11:34:12 2008
@@ -0,0 +1,58 @@
+//===--- Tools.h - 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.
+//
+//===----------------------------------------------------------------------===//
+//
+//  Action class - implementation and auxiliary functions.
+//
+//===----------------------------------------------------------------------===//
+
+#include "Action.h"
+
+#include "llvm/Support/CommandLine.h"
+#include "llvm/System/Program.h"
+
+#include <iostream>
+#include <stdexcept>
+
+using namespace llvm;
+
+extern cl::opt<bool> VerboseMode;
+
+namespace {
+  int ExecuteProgram(const std::string& name,
+                     const std::vector<std::string>& args) {
+    sys::Path prog = sys::Program::FindProgramByName(name);
+
+    if (prog.isEmpty())
+      throw std::runtime_error("Can't find program '" + name + "'");
+    if (!prog.canExecute())
+      throw std::runtime_error("Program '" + name + "' is not executable.");
+
+    // Invoke the program
+    std::vector<const char*> argv((args.size()+2));
+    argv[0] = name.c_str();
+    for (unsigned i = 1; i <= args.size(); ++i)
+      argv[i] = args[i-1].c_str();
+    argv[args.size()+1] = 0;  // null terminate list.
+
+    return sys::Program::ExecuteAndWait(prog, &argv[0]);
+  }
+
+  void print_string (const std::string& str) {
+    std::cerr << str << ' ';
+  }
+}
+
+int llvmcc::Action::Execute() {
+  if (VerboseMode) {
+    std::cerr << Command_ << " ";
+    std::for_each(Args_.begin(), Args_.end(), print_string);
+    std::cerr << '\n';
+  }
+  return ExecuteProgram(Command_, Args_);
+}

Copied: llvm/trunk/tools/llvmc2/Action.h (from r50718, llvm/trunk/tools/llvmc2/Tools.h)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/Action.h?p2=llvm/trunk/tools/llvmc2/Action.h&p1=llvm/trunk/tools/llvmc2/Tools.h&r1=50718&r2=50722&rev=50722&view=diff

==============================================================================
--- llvm/trunk/tools/llvmc2/Tools.h (original)
+++ llvm/trunk/tools/llvmc2/Action.h Tue May  6 11:34:12 2008
@@ -7,20 +7,30 @@
 //
 //===----------------------------------------------------------------------===//
 //
-//  Auto-generated tool descriptions.
+//  Action - encapsulates a single shell command.
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_TOOLS_LLVMCC_TOOLS_H
-#define LLVM_TOOLS_LLVMCC_TOOLS_H
+#ifndef LLVM_TOOLS_LLVMC2_ACTION_H
+#define LLVM_TOOLS_LLVMC2_ACTION_H
 
-#include "Core.h"
+#include <string>
+#include <vector>
 
 namespace llvmcc {
 
-  void PopulateLanguageMap(LanguageMap& language_map);
-  void PopulateCompilationGraph(CompilationGraph& tools);
+  class Action {
+    std::string Command_;
+    std::vector<std::string> Args_;
+  public:
+    Action (std::string const& C,
+            std::vector<std::string> const& A)
+      : Command_(C), Args_(A)
+    {}
+
+    int Execute();
+  };
 
 }
 
-#endif //LLVM_TOOLS_LLVMCC_TOOLS_H
+#endif // LLVM_TOOLS_LLVMC2_ACTION_H

Copied: llvm/trunk/tools/llvmc2/AutoGenerated.cpp (from r50718, llvm/trunk/tools/llvmc2/Tools.cpp)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/AutoGenerated.cpp?p2=llvm/trunk/tools/llvmc2/AutoGenerated.cpp&p1=llvm/trunk/tools/llvmc2/Tools.cpp&r1=50718&r2=50722&rev=50722&view=diff

==============================================================================
--- llvm/trunk/tools/llvmc2/Tools.cpp (original)
+++ llvm/trunk/tools/llvmc2/AutoGenerated.cpp Tue May  6 11:34:12 2008
@@ -7,22 +7,20 @@
 //
 //===----------------------------------------------------------------------===//
 //
-//  Auto-generated tool descriptions.
+//  Auto-generated tool descriptions - implementation.
 //
 //===----------------------------------------------------------------------===//
 
-#include "Tools.h"
-#include "Core.h"
+#include "AutoGenerated.h"
+#include "CompilationGraph.h"
+#include "Tool.h"
 
-#include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/Support/CommandLine.h"
 
 #include <stdexcept>
-#include <string>
-#include <vector>
 
 using namespace llvm;
 using namespace llvmcc;
 
-// Include the auto-generated file
-#include "Tools.inc"
+// The auto-generated file
+#include "AutoGenerated.inc"

Copied: llvm/trunk/tools/llvmc2/AutoGenerated.h (from r50718, llvm/trunk/tools/llvmc2/Tools.h)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/AutoGenerated.h?p2=llvm/trunk/tools/llvmc2/AutoGenerated.h&p1=llvm/trunk/tools/llvmc2/Tools.h&r1=50718&r2=50722&rev=50722&view=diff

==============================================================================
--- llvm/trunk/tools/llvmc2/Tools.h (original)
+++ llvm/trunk/tools/llvmc2/AutoGenerated.h Tue May  6 11:34:12 2008
@@ -1,4 +1,4 @@
-//===--- Tools.h - The LLVM Compiler Driver ---------------------*- C++ -*-===//
+//===--- Tools.cpp - The LLVM Compiler Driver -------------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -7,20 +7,24 @@
 //
 //===----------------------------------------------------------------------===//
 //
-//  Auto-generated tool descriptions.
+//  Auto-generated tool descriptions - public interface.
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_TOOLS_LLVMCC_TOOLS_H
-#define LLVM_TOOLS_LLVMCC_TOOLS_H
+#ifndef LLVM_TOOLS_LLVMC2_AUTOGENERATED_H
+#define LLVM_TOOLS_LLVMC2_AUTOGENERATED_H
 
-#include "Core.h"
+#include "llvm/ADT/StringMap.h"
+
+#include <string>
 
 namespace llvmcc {
 
+  typedef llvm::StringMap<std::string> LanguageMap;
+  class CompilationGraph;
+
   void PopulateLanguageMap(LanguageMap& language_map);
   void PopulateCompilationGraph(CompilationGraph& tools);
-
 }
 
-#endif //LLVM_TOOLS_LLVMCC_TOOLS_H
+#endif // LLVM_TOOLS_LLVMC2_AUTOGENERATED_H

Copied: llvm/trunk/tools/llvmc2/CompilationGraph.cpp (from r50718, llvm/trunk/tools/llvmc2/Core.cpp)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/CompilationGraph.cpp?p2=llvm/trunk/tools/llvmc2/CompilationGraph.cpp&p1=llvm/trunk/tools/llvmc2/Core.cpp&r1=50718&r2=50722&rev=50722&view=diff

==============================================================================
--- llvm/trunk/tools/llvmc2/Core.cpp (original)
+++ llvm/trunk/tools/llvmc2/CompilationGraph.cpp Tue May  6 11:34:12 2008
@@ -1,4 +1,4 @@
-//===--- Core.cpp - The LLVM Compiler Driver --------------------*- C++ -*-===//
+//===--- CompilationGraph.cpp - The LLVM Compiler Driver --------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -7,42 +7,21 @@
 //
 //===----------------------------------------------------------------------===//
 //
-//  Core driver abstractions.
+//  Compilation graph - implementation.
 //
 //===----------------------------------------------------------------------===//
 
-#include "Core.h"
-#include "Utility.h"
+#include "CompilationGraph.h"
 
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/ADT/STLExtras.h"
 
-#include <algorithm>
-#include <iostream>
 #include <stdexcept>
 
 using namespace llvm;
-using namespace llvmcc;
 
 extern cl::list<std::string> InputFilenames;
 extern cl::opt<std::string> OutputFilename;
-extern cl::opt<bool> VerboseMode;
-
-namespace {
-  void print_string (const std::string& str) {
-    std::cerr << str << ' ';
-  }
-}
-
-int llvmcc::Action::Execute() {
-  if (VerboseMode) {
-    std::cerr << Command_ << " ";
-    std::for_each(Args_.begin(), Args_.end(), print_string);
-    std::cerr << '\n';
-  }
-  return ExecuteProgram(Command_, Args_);
-}
 
 int llvmcc::CompilationGraph::Build (const sys::Path& tempDir) const {
   sys::Path In(InputFilenames.at(0)), Out;
@@ -107,9 +86,3 @@
 
   return 0;
 }
-
-void llvmcc::Tool::UnpackValues (const std::string& from,
-                                 std::vector<std::string>& to) const {
-  SplitString(from, to, ",");
-}
-

Added: llvm/trunk/tools/llvmc2/CompilationGraph.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/CompilationGraph.h?rev=50722&view=auto

==============================================================================
--- llvm/trunk/tools/llvmc2/CompilationGraph.h (added)
+++ llvm/trunk/tools/llvmc2/CompilationGraph.h Tue May  6 11:34:12 2008
@@ -0,0 +1,36 @@
+//===--- CompilationGraph.h - 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.
+//
+//===----------------------------------------------------------------------===//
+//
+//  Compilation graph - definition.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TOOLS_LLVMC2_COMPILATION_GRAPH_H
+#define LLVM_TOOLS_LLVMC2_COMPILATION_GRAPH_H
+
+#include "AutoGenerated.h"
+#include "Tool.h"
+
+#include "llvm/ADT/StringMap.h"
+#include "llvm/System/Path.h"
+
+namespace llvmcc {
+
+  typedef std::vector<llvm::IntrusiveRefCntPtr<Tool> > ToolChain;
+  typedef llvm::StringMap<ToolChain> ToolChainMap;
+
+  struct CompilationGraph {
+    ToolChainMap ToolChains;
+    LanguageMap ExtsToLangs;
+
+    int Build(llvm::sys::Path const& tempDir) const;
+  };
+}
+
+#endif // LLVM_TOOLS_LLVMC2_COMPILATION_GRAPH_H

Removed: llvm/trunk/tools/llvmc2/Core.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/Core.cpp?rev=50721&view=auto

==============================================================================
--- llvm/trunk/tools/llvmc2/Core.cpp (original)
+++ llvm/trunk/tools/llvmc2/Core.cpp (removed)
@@ -1,115 +0,0 @@
-//===--- Core.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.
-//
-//===----------------------------------------------------------------------===//
-//
-//  Core driver abstractions.
-//
-//===----------------------------------------------------------------------===//
-
-#include "Core.h"
-#include "Utility.h"
-
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/StringExtras.h"
-#include "llvm/Support/CommandLine.h"
-
-#include <algorithm>
-#include <iostream>
-#include <stdexcept>
-
-using namespace llvm;
-using namespace llvmcc;
-
-extern cl::list<std::string> InputFilenames;
-extern cl::opt<std::string> OutputFilename;
-extern cl::opt<bool> VerboseMode;
-
-namespace {
-  void print_string (const std::string& str) {
-    std::cerr << str << ' ';
-  }
-}
-
-int llvmcc::Action::Execute() {
-  if (VerboseMode) {
-    std::cerr << Command_ << " ";
-    std::for_each(Args_.begin(), Args_.end(), print_string);
-    std::cerr << '\n';
-  }
-  return ExecuteProgram(Command_, Args_);
-}
-
-int llvmcc::CompilationGraph::Build (const sys::Path& tempDir) const {
-  sys::Path In(InputFilenames.at(0)), Out;
-
-  // Find out which language corresponds to the suffix of the first input file
-  LanguageMap::const_iterator Lang = ExtsToLangs.find(In.getSuffix());
-  if (Lang == ExtsToLangs.end())
-    throw std::runtime_error("Unknown suffix!");
-
-  // Find the toolchain corresponding to this language
-  ToolChainMap::const_iterator ToolsIt = ToolChains.find(Lang->second);
-  if (ToolsIt == ToolChains.end())
-    throw std::runtime_error("Unknown language!");
-  ToolChain Tools = ToolsIt->second;
-
-  PathVector JoinList;
-
-  for (cl::list<std::string>::const_iterator B = InputFilenames.begin(),
-        E = InputFilenames.end(); B != E; ++B) {
-    In = sys::Path(*B);
-
-    // Pass input file through the toolchain
-    for (ToolChain::const_iterator B = Tools.begin(), E = Tools.end();
-         B != E; ++B) {
-
-      const Tool* CurTool = B->getPtr();
-
-      // Is this the last step in the chain?
-      if (llvm::next(B) == E || CurTool->IsLast()) {
-        JoinList.push_back(In);
-        break;
-      }
-      else {
-        Out = tempDir;
-        Out.appendComponent(In.getBasename());
-        Out.appendSuffix(CurTool->OutputSuffix());
-        Out.makeUnique(true, NULL);
-        Out.eraseFromDisk();
-      }
-
-      if (CurTool->GenerateAction(In, Out).Execute() != 0)
-        throw std::runtime_error("Tool returned error code!");
-
-      In = Out; Out.clear();
-    }
-  }
-
-  // Pass .o files to linker
-  const Tool* JoinNode = (--Tools.end())->getPtr();
-
-  // If the final output name is empty, set it to "a.out"
-  if (!OutputFilename.empty()) {
-    Out = sys::Path(OutputFilename);
-  }
-  else {
-    Out = sys::Path("a");
-    Out.appendSuffix(JoinNode->OutputSuffix());
-  }
-
-  if (JoinNode->GenerateAction(JoinList, Out).Execute() != 0)
-    throw std::runtime_error("Tool returned error code!");
-
-  return 0;
-}
-
-void llvmcc::Tool::UnpackValues (const std::string& from,
-                                 std::vector<std::string>& to) const {
-  SplitString(from, to, ",");
-}
-

Removed: llvm/trunk/tools/llvmc2/Core.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/Core.h?rev=50721&view=auto

==============================================================================
--- llvm/trunk/tools/llvmc2/Core.h (original)
+++ llvm/trunk/tools/llvmc2/Core.h (removed)
@@ -1,83 +0,0 @@
-//===--- Core.h - 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.
-//
-//===----------------------------------------------------------------------===//
-//
-//  Core driver abstractions.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_TOOLS_LLVMCC_CORE_H
-#define LLVM_TOOLS_LLVMCC_CORE_H
-
-#include "Utility.h"
-
-#include "llvm/ADT/IntrusiveRefCntPtr.h"
-#include "llvm/ADT/StringMap.h"
-#include "llvm/System/Path.h"
-
-#include <stdexcept>
-#include <string>
-#include <vector>
-
-// Core functionality
-
-namespace llvmcc {
-
-  typedef std::vector<llvm::sys::Path> PathVector;
-  typedef llvm::StringMap<std::string> LanguageMap;
-
-  class Action {
-    std::string Command_;
-    std::vector<std::string> Args_;
-  public:
-    Action (std::string const& C,
-            std::vector<std::string> const& A)
-      : Command_(C), Args_(A)
-    {}
-
-    int Execute();
-  };
-
-  class Tool : public llvm::RefCountedBaseVPTR<Tool> {
-  public:
-    virtual Action GenerateAction (PathVector const& inFiles,
-                                  llvm::sys::Path const& outFile) const = 0;
-
-    virtual Action GenerateAction (llvm::sys::Path const& inFile,
-                                  llvm::sys::Path const& outFile) const = 0;
-
-    virtual std::string Name() const = 0;
-    virtual std::string InputLanguage() const = 0;
-    virtual std::string OutputLanguage() const = 0;
-    virtual std::string OutputSuffix() const = 0;
-
-    virtual bool IsLast() const = 0;
-    virtual bool IsJoin() const = 0;
-
-    // Helper function that is called by the auto-generated code
-    // Splits strings of the form ",-foo,-bar,-baz"
-    // TOFIX: find a better name
-    void UnpackValues (std::string const& from,
-                       std::vector<std::string>& to) const;
-
-    virtual ~Tool()
-    {}
-  };
-
-  typedef std::vector<llvm::IntrusiveRefCntPtr<Tool> > ToolChain;
-  typedef llvm::StringMap<ToolChain> ToolChainMap;
-
-  struct CompilationGraph {
-    ToolChainMap ToolChains;
-    LanguageMap ExtsToLangs;
-
-    int Build(llvm::sys::Path const& tempDir) const;
-  };
-}
-
-#endif // LLVM_TOOLS_LLVMCC_CORE_H

Modified: llvm/trunk/tools/llvmc2/Makefile
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/Makefile?rev=50722&r1=50721&r2=50722&view=diff

==============================================================================
--- llvm/trunk/tools/llvmc2/Makefile (original)
+++ llvm/trunk/tools/llvmc2/Makefile Tue May  6 11:34:12 2008
@@ -8,7 +8,7 @@
 ##===----------------------------------------------------------------------===##
 LEVEL = ../..
 TOOLNAME = llvmc2
-BUILT_SOURCES = Tools.inc
+BUILT_SOURCES = AutoGenerated.inc
 LINK_COMPONENTS = support system
 REQUIRES_EH := 1
 
@@ -23,10 +23,10 @@
 
 # TOFIX: integrate this part into Makefile.rules?
 # The degree of horrorshowness in that file is too much for me atm.
-$(ObjDir)/Tools.inc.tmp: $(TOOLS_SOURCE) $(ObjDir)/.dir
+$(ObjDir)/AutoGenerated.inc.tmp: $(TOOLS_SOURCE) $(ObjDir)/.dir
 	$(Echo) "Building LLVMCC configuration library with tblgen"
 	$(Verb) $(TableGen) -gen-llvmcc -o $(call SYSPATH, $@) $<
 
-Tools.inc : $(ObjDir)/Tools.inc.tmp
+AutoGenerated.inc : $(ObjDir)/AutoGenerated.inc.tmp
 	$(Verb) $(CMP) -s $@ $< || $(CP) $< $@
 

Copied: llvm/trunk/tools/llvmc2/Tool.cpp (from r50718, llvm/trunk/tools/llvmc2/Tools.cpp)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/Tool.cpp?p2=llvm/trunk/tools/llvmc2/Tool.cpp&p1=llvm/trunk/tools/llvmc2/Tools.cpp&r1=50718&r2=50722&rev=50722&view=diff

==============================================================================
--- llvm/trunk/tools/llvmc2/Tools.cpp (original)
+++ llvm/trunk/tools/llvmc2/Tool.cpp Tue May  6 11:34:12 2008
@@ -7,22 +7,15 @@
 //
 //===----------------------------------------------------------------------===//
 //
-//  Auto-generated tool descriptions.
+//  Tool abstract base class - implementation of the auxiliary functions.
 //
 //===----------------------------------------------------------------------===//
 
-#include "Tools.h"
-#include "Core.h"
+#include "Tool.h"
 
-#include "llvm/ADT/IntrusiveRefCntPtr.h"
-#include "llvm/Support/CommandLine.h"
+#include "llvm/ADT/StringExtras.h"
 
-#include <stdexcept>
-#include <string>
-#include <vector>
-
-using namespace llvm;
-using namespace llvmcc;
-
-// Include the auto-generated file
-#include "Tools.inc"
+void llvmcc::Tool::UnpackValues (const std::string& from,
+                                 std::vector<std::string>& to) {
+  llvm::SplitString(from, to, ",");
+}

Copied: llvm/trunk/tools/llvmc2/Tool.h (from r50718, llvm/trunk/tools/llvmc2/Core.h)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/Tool.h?p2=llvm/trunk/tools/llvmc2/Tool.h&p1=llvm/trunk/tools/llvmc2/Core.h&r1=50718&r2=50722&rev=50722&view=diff

==============================================================================
--- llvm/trunk/tools/llvmc2/Core.h (original)
+++ llvm/trunk/tools/llvmc2/Tool.h Tue May  6 11:34:12 2008
@@ -1,4 +1,4 @@
-//===--- Core.h - The LLVM Compiler Driver ----------------------*- C++ -*-===//
+//===--- Tools.h - The LLVM Compiler Driver ---------------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -7,41 +7,24 @@
 //
 //===----------------------------------------------------------------------===//
 //
-//  Core driver abstractions.
+//  Tool abstract base class - an interface to tool descriptions.
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_TOOLS_LLVMCC_CORE_H
-#define LLVM_TOOLS_LLVMCC_CORE_H
+#ifndef LLVM_TOOLS_LLVMC2_TOOL_H
+#define LLVM_TOOLS_LLVMC2_TOOL_H
 
-#include "Utility.h"
+#include "Action.h"
 
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
-#include "llvm/ADT/StringMap.h"
 #include "llvm/System/Path.h"
 
-#include <stdexcept>
 #include <string>
 #include <vector>
 
-// Core functionality
-
 namespace llvmcc {
 
   typedef std::vector<llvm::sys::Path> PathVector;
-  typedef llvm::StringMap<std::string> LanguageMap;
-
-  class Action {
-    std::string Command_;
-    std::vector<std::string> Args_;
-  public:
-    Action (std::string const& C,
-            std::vector<std::string> const& A)
-      : Command_(C), Args_(A)
-    {}
-
-    int Execute();
-  };
 
   class Tool : public llvm::RefCountedBaseVPTR<Tool> {
   public:
@@ -62,22 +45,13 @@
     // Helper function that is called by the auto-generated code
     // Splits strings of the form ",-foo,-bar,-baz"
     // TOFIX: find a better name
-    void UnpackValues (std::string const& from,
-                       std::vector<std::string>& to) const;
+    static void UnpackValues (std::string const& from,
+                              std::vector<std::string>& to);
 
     virtual ~Tool()
     {}
   };
 
-  typedef std::vector<llvm::IntrusiveRefCntPtr<Tool> > ToolChain;
-  typedef llvm::StringMap<ToolChain> ToolChainMap;
-
-  struct CompilationGraph {
-    ToolChainMap ToolChains;
-    LanguageMap ExtsToLangs;
-
-    int Build(llvm::sys::Path const& tempDir) const;
-  };
 }
 
-#endif // LLVM_TOOLS_LLVMCC_CORE_H
+#endif //LLVM_TOOLS_LLVMC2_TOOL_H

Removed: llvm/trunk/tools/llvmc2/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/Tools.cpp?rev=50721&view=auto

==============================================================================
--- llvm/trunk/tools/llvmc2/Tools.cpp (original)
+++ llvm/trunk/tools/llvmc2/Tools.cpp (removed)
@@ -1,28 +0,0 @@
-//===--- Tools.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.
-//
-//===----------------------------------------------------------------------===//
-//
-//  Auto-generated tool descriptions.
-//
-//===----------------------------------------------------------------------===//
-
-#include "Tools.h"
-#include "Core.h"
-
-#include "llvm/ADT/IntrusiveRefCntPtr.h"
-#include "llvm/Support/CommandLine.h"
-
-#include <stdexcept>
-#include <string>
-#include <vector>
-
-using namespace llvm;
-using namespace llvmcc;
-
-// Include the auto-generated file
-#include "Tools.inc"

Removed: llvm/trunk/tools/llvmc2/Tools.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/Tools.h?rev=50721&view=auto

==============================================================================
--- llvm/trunk/tools/llvmc2/Tools.h (original)
+++ llvm/trunk/tools/llvmc2/Tools.h (removed)
@@ -1,26 +0,0 @@
-//===--- Tools.h - 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.
-//
-//===----------------------------------------------------------------------===//
-//
-//  Auto-generated tool descriptions.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_TOOLS_LLVMCC_TOOLS_H
-#define LLVM_TOOLS_LLVMCC_TOOLS_H
-
-#include "Core.h"
-
-namespace llvmcc {
-
-  void PopulateLanguageMap(LanguageMap& language_map);
-  void PopulateCompilationGraph(CompilationGraph& tools);
-
-}
-
-#endif //LLVM_TOOLS_LLVMCC_TOOLS_H

Removed: llvm/trunk/tools/llvmc2/Utility.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/Utility.cpp?rev=50721&view=auto

==============================================================================
--- llvm/trunk/tools/llvmc2/Utility.cpp (original)
+++ llvm/trunk/tools/llvmc2/Utility.cpp (removed)
@@ -1,39 +0,0 @@
-//===--- Utility.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.
-//
-//===----------------------------------------------------------------------===//
-//
-//  Various helper and utility functions - implementation.
-//
-//===----------------------------------------------------------------------===//
-
-#include "Utility.h"
-
-#include "llvm/System/Program.h"
-
-#include <stdexcept>
-
-using namespace llvm;
-
-int llvmcc::ExecuteProgram(const std::string& name,
-                           const std::vector<std::string>& args) {
-  sys::Path prog = sys::Program::FindProgramByName(name);
-
-  if (prog.isEmpty())
-    throw std::runtime_error("Can't find program '" + name + "'");
-  if (!prog.canExecute())
-    throw std::runtime_error("Program '" + name + "' is not executable.");
-
-  // Invoke the program
-  std::vector<const char*> argv((args.size()+2));
-  argv[0] = name.c_str();
-  for (unsigned i = 1; i <= args.size(); ++i)
-    argv[i] = args[i-1].c_str();
-  argv[args.size()+1] = 0;  // null terminate list.
-
-  return sys::Program::ExecuteAndWait(prog, &argv[0]);
-}

Removed: llvm/trunk/tools/llvmc2/Utility.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/Utility.h?rev=50721&view=auto

==============================================================================
--- llvm/trunk/tools/llvmc2/Utility.h (original)
+++ llvm/trunk/tools/llvmc2/Utility.h (removed)
@@ -1,27 +0,0 @@
-//===--- Utility.h - 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.
-//
-//===----------------------------------------------------------------------===//
-//
-//  Various helper and utility functions.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_TOOLS_LLVMCC_UTILITY_H
-#define LLVM_TOOLS_LLVMCC_UTILITY_H
-
-#include <string>
-#include <vector>
-
-namespace llvmcc {
-
-  int ExecuteProgram (const std::string& name,
-                      const std::vector<std::string>& arguments);
-
-}
-
-#endif // LLVM_TOOLS_LLVMCC_UTILITY_H

Copied: llvm/trunk/tools/llvmc2/llvmc.cpp (from r50718, llvm/trunk/tools/llvmc2/llvmcc.cpp)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/llvmc.cpp?p2=llvm/trunk/tools/llvmc2/llvmc.cpp&p1=llvm/trunk/tools/llvmc2/llvmcc.cpp&r1=50718&r2=50722&rev=50722&view=diff

==============================================================================
--- llvm/trunk/tools/llvmc2/llvmcc.cpp (original)
+++ llvm/trunk/tools/llvmc2/llvmc.cpp Tue May  6 11:34:12 2008
@@ -14,9 +14,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "Core.h"
-#include "Utility.h"
-#include "Tools.h"
+#include "CompilationGraph.h"
+#include "Tool.h"
 
 #include "llvm/System/Path.h"
 #include "llvm/Support/CommandLine.h"
@@ -25,11 +24,11 @@
 #include <stdexcept>
 #include <string>
 
-using namespace llvm;
+namespace cl = llvm::cl;
+namespace sys = llvm::sys;
 using namespace llvmcc;
 
-// These variables are also used in Core.cpp,
-// so they should have external linkage.
+// External linkage here is intentional.
 cl::list<std::string> InputFilenames(cl::Positional,
                                      cl::desc("<input file>"), cl::OneOrMore);
 cl::opt<std::string> OutputFilename("o", cl::desc("Output file name"),

Removed: llvm/trunk/tools/llvmc2/llvmcc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/llvmcc.cpp?rev=50721&view=auto

==============================================================================
--- llvm/trunk/tools/llvmc2/llvmcc.cpp (original)
+++ llvm/trunk/tools/llvmc2/llvmcc.cpp (removed)
@@ -1,73 +0,0 @@
-//===--- llvmcc.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 tool provides a single point of access to the LLVM
-//  compilation tools.  It has many options. To discover the options
-//  supported please refer to the tools' manual page or run the tool
-//  with the --help option.
-//
-//===----------------------------------------------------------------------===//
-
-#include "Core.h"
-#include "Utility.h"
-#include "Tools.h"
-
-#include "llvm/System/Path.h"
-#include "llvm/Support/CommandLine.h"
-
-#include <iostream>
-#include <stdexcept>
-#include <string>
-
-using namespace llvm;
-using namespace llvmcc;
-
-// These variables are also used in Core.cpp,
-// so they should have external linkage.
-cl::list<std::string> InputFilenames(cl::Positional,
-                                     cl::desc("<input file>"), cl::OneOrMore);
-cl::opt<std::string> OutputFilename("o", cl::desc("Output file name"),
-                                    cl::value_desc("file"));
-cl::opt<bool> VerboseMode("v", cl::desc("Enable verbose mode"));
-
-
-namespace {
-  int BuildTargets(const CompilationGraph& graph) {
-    int ret;
-    sys::Path tempDir(sys::Path::GetTemporaryDirectory());
-
-    try {
-      ret = graph.Build(tempDir);
-    }
-    catch(...) {
-      tempDir.eraseFromDisk(true);
-      throw;
-    }
-
-    tempDir.eraseFromDisk(true);
-    return ret;
-  }
-}
-
-int main(int argc, char** argv) {
-  try {
-    CompilationGraph graph;
-
-    cl::ParseCommandLineOptions(argc, argv,
-                                "LLVM Compiler Driver(Work In Progress)");
-    PopulateCompilationGraph(graph);
-    return BuildTargets(graph);
-  }
-  catch(const std::exception& ex) {
-    std::cerr << ex.what() << '\n';
-  }
-  catch(...) {
-    std::cerr << "Unknown error!\n";
-  }
-}

Modified: llvm/trunk/utils/TableGen/LLVMCCConfigurationEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/LLVMCCConfigurationEmitter.cpp?rev=50722&r1=50721&r2=50722&view=diff

==============================================================================
--- llvm/trunk/utils/TableGen/LLVMCCConfigurationEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/LLVMCCConfigurationEmitter.cpp Tue May  6 11:34:12 2008
@@ -623,10 +623,10 @@
         << "::iterator B = " << D.GenVariableName() << ".begin(),\n"
         << Indent3 << "E = " << D.GenVariableName()
         << ".end(); B != E; ++B)\n"
-        << Indent4 << "UnpackValues(*B, vec);\n";
+        << Indent4 << "Tool::UnpackValues(*B, vec);\n";
     }
     else if (D.Type == OptionType::Prefix || D.Type == OptionType::Parameter){
-      O << Indent3 << "UnpackValues("
+      O << Indent3 << "Tool::UnpackValues("
         << D.GenVariableName() << ", vec);\n";
     }
     else {





More information about the llvm-commits mailing list