[llvm-commits] [llvm] r50746 - 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/Tool.cpp tools/llvmc2/Tool.h tools/llvmc2/llvmc.cpp utils/TableGen/LLVMCCConfigurationEmitter.cpp
Mikhail Glushenkov
foldr at codedgers.com
Tue May 6 11:08:59 PDT 2008
Author: foldr
Date: Tue May 6 13:08:59 2008
New Revision: 50746
URL: http://llvm.org/viewvc/llvm-project?rev=50746&view=rev
Log:
Add output redirection, rename namespace llvmcc to namespace llvmc.
Modified:
llvm/trunk/tools/llvmc2/Action.cpp
llvm/trunk/tools/llvmc2/Action.h
llvm/trunk/tools/llvmc2/AutoGenerated.cpp
llvm/trunk/tools/llvmc2/AutoGenerated.h
llvm/trunk/tools/llvmc2/CompilationGraph.cpp
llvm/trunk/tools/llvmc2/CompilationGraph.h
llvm/trunk/tools/llvmc2/Tool.cpp
llvm/trunk/tools/llvmc2/Tool.h
llvm/trunk/tools/llvmc2/llvmc.cpp
llvm/trunk/utils/TableGen/LLVMCCConfigurationEmitter.cpp
Modified: llvm/trunk/tools/llvmc2/Action.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/Action.cpp?rev=50746&r1=50745&r2=50746&view=diff
==============================================================================
--- llvm/trunk/tools/llvmc2/Action.cpp (original)
+++ llvm/trunk/tools/llvmc2/Action.cpp Tue May 6 13:08:59 2008
@@ -20,12 +20,13 @@
#include <stdexcept>
using namespace llvm;
+using namespace llvmc;
extern cl::opt<bool> VerboseMode;
namespace {
int ExecuteProgram(const std::string& name,
- const std::vector<std::string>& args) {
+ const StringVector& args) {
sys::Path prog = sys::Program::FindProgramByName(name);
if (prog.isEmpty())
@@ -33,14 +34,27 @@
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.
+ const sys::Path* redirects[3] = {0,0,0};
+ sys::Path stdout_redirect;
- return sys::Program::ExecuteAndWait(prog, &argv[0]);
+ std::vector<const char*> argv;
+ argv.reserve((args.size()+2));
+ argv.push_back(name.c_str());
+
+ for (StringVector::const_iterator B = args.begin(), E = args.end();
+ B!=E; ++B) {
+ if (*B == ">") {
+ ++B;
+ stdout_redirect.set(*B);
+ redirects[1] = &stdout_redirect;
+ }
+ else {
+ argv.push_back((*B).c_str());
+ }
+ }
+ argv.push_back(0); // null terminate list.
+
+ return sys::Program::ExecuteAndWait(prog, &argv[0], 0, &redirects[0]);
}
void print_string (const std::string& str) {
@@ -48,7 +62,7 @@
}
}
-int llvmcc::Action::Execute() const {
+int llvmc::Action::Execute() const {
if (VerboseMode) {
std::cerr << Command_ << " ";
std::for_each(Args_.begin(), Args_.end(), print_string);
Modified: llvm/trunk/tools/llvmc2/Action.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/Action.h?rev=50746&r1=50745&r2=50746&view=diff
==============================================================================
--- llvm/trunk/tools/llvmc2/Action.h (original)
+++ llvm/trunk/tools/llvmc2/Action.h Tue May 6 13:08:59 2008
@@ -17,14 +17,16 @@
#include <string>
#include <vector>
-namespace llvmcc {
+namespace llvmc {
+
+ typedef std::vector<std::string> StringVector;
class Action {
std::string Command_;
std::vector<std::string> Args_;
public:
- Action (std::string const& C,
- std::vector<std::string> const& A)
+ Action (const std::string& C,
+ const StringVector& A)
: Command_(C), Args_(A)
{}
Modified: llvm/trunk/tools/llvmc2/AutoGenerated.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/AutoGenerated.cpp?rev=50746&r1=50745&r2=50746&view=diff
==============================================================================
--- llvm/trunk/tools/llvmc2/AutoGenerated.cpp (original)
+++ llvm/trunk/tools/llvmc2/AutoGenerated.cpp Tue May 6 13:08:59 2008
@@ -20,7 +20,7 @@
#include <stdexcept>
using namespace llvm;
-using namespace llvmcc;
+using namespace llvmc;
// The auto-generated file
#include "AutoGenerated.inc"
Modified: llvm/trunk/tools/llvmc2/AutoGenerated.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/AutoGenerated.h?rev=50746&r1=50745&r2=50746&view=diff
==============================================================================
--- llvm/trunk/tools/llvmc2/AutoGenerated.h (original)
+++ llvm/trunk/tools/llvmc2/AutoGenerated.h Tue May 6 13:08:59 2008
@@ -18,7 +18,7 @@
#include <string>
-namespace llvmcc {
+namespace llvmc {
typedef llvm::StringMap<std::string> LanguageMap;
class CompilationGraph;
Modified: llvm/trunk/tools/llvmc2/CompilationGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/CompilationGraph.cpp?rev=50746&r1=50745&r2=50746&view=diff
==============================================================================
--- llvm/trunk/tools/llvmc2/CompilationGraph.cpp (original)
+++ llvm/trunk/tools/llvmc2/CompilationGraph.cpp Tue May 6 13:08:59 2008
@@ -24,7 +24,7 @@
#include <stdexcept>
using namespace llvm;
-using namespace llvmcc;
+using namespace llvmc;
extern cl::list<std::string> InputFilenames;
extern cl::opt<std::string> OutputFilename;
@@ -215,6 +215,9 @@
return &getNode(ChooseEdge(TV)->ToolName());
}
+// TOFIX: merge some parts with PassThroughGraph.
+// Build the targets. Command-line options are passed through
+// temporary variables.
int CompilationGraph::Build (const sys::Path& TempDir) {
// For each input file:
@@ -234,12 +237,13 @@
// For all join nodes in topological order:
for (std::vector<const Node*>::iterator B = JTV.begin(), E = JTV.end();
B != E; ++B) {
- // TOFIX: more testing, merge some parts with PassThroughGraph.
+
sys::Path Out;
const Node* CurNode = *B;
JoinTool* JT = &dynamic_cast<JoinTool&>(*CurNode->ToolPtr.getPtr());
bool IsLast = false;
+ // Has files pending?
if (JT->JoinListEmpty())
continue;
@@ -277,7 +281,7 @@
namespace llvm {
template <>
- struct DOTGraphTraits<llvmcc::CompilationGraph*>
+ struct DOTGraphTraits<llvmc::CompilationGraph*>
: public DefaultDOTGraphTraits
{
Modified: llvm/trunk/tools/llvmc2/CompilationGraph.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/CompilationGraph.h?rev=50746&r1=50745&r2=50746&view=diff
==============================================================================
--- llvm/trunk/tools/llvmc2/CompilationGraph.h (original)
+++ llvm/trunk/tools/llvmc2/CompilationGraph.h Tue May 6 13:08:59 2008
@@ -26,7 +26,7 @@
#include <string>
-namespace llvmcc {
+namespace llvmc {
// An edge in the graph.
class Edge : public llvm::RefCountedBaseVPTR<Edge> {
@@ -255,10 +255,10 @@
namespace llvm {
template <>
- struct GraphTraits<llvmcc::CompilationGraph*> {
- typedef llvmcc::CompilationGraph GraphType;
- typedef llvmcc::Node NodeType;
- typedef llvmcc::NodeChildIterator ChildIteratorType;
+ struct GraphTraits<llvmc::CompilationGraph*> {
+ typedef llvmc::CompilationGraph GraphType;
+ typedef llvmc::Node NodeType;
+ typedef llvmc::NodeChildIterator ChildIteratorType;
static NodeType* getEntryNode(GraphType* G) {
return &G->getNode("root");
@@ -271,7 +271,7 @@
return ChildIteratorType(N, N->OutEdges.end());
}
- typedef llvmcc::NodesIterator nodes_iterator;
+ typedef llvmc::NodesIterator nodes_iterator;
static nodes_iterator nodes_begin(GraphType *G) {
return GraphBegin(G);
}
Modified: llvm/trunk/tools/llvmc2/Tool.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/Tool.cpp?rev=50746&r1=50745&r2=50746&view=diff
==============================================================================
--- llvm/trunk/tools/llvmc2/Tool.cpp (original)
+++ llvm/trunk/tools/llvmc2/Tool.cpp Tue May 6 13:08:59 2008
@@ -15,7 +15,7 @@
#include "llvm/ADT/StringExtras.h"
-void llvmcc::Tool::UnpackValues (const std::string& from,
+void llvmc::Tool::UnpackValues (const std::string& from,
std::vector<std::string>& to) {
llvm::SplitString(from, to, ",");
}
Modified: llvm/trunk/tools/llvmc2/Tool.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/Tool.h?rev=50746&r1=50745&r2=50746&view=diff
==============================================================================
--- llvm/trunk/tools/llvmc2/Tool.h (original)
+++ llvm/trunk/tools/llvmc2/Tool.h Tue May 6 13:08:59 2008
@@ -22,7 +22,7 @@
#include <string>
#include <vector>
-namespace llvmcc {
+namespace llvmc {
typedef std::vector<llvm::sys::Path> PathVector;
Modified: llvm/trunk/tools/llvmc2/llvmc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/llvmc.cpp?rev=50746&r1=50745&r2=50746&view=diff
==============================================================================
--- llvm/trunk/tools/llvmc2/llvmc.cpp (original)
+++ llvm/trunk/tools/llvmc2/llvmc.cpp Tue May 6 13:08:59 2008
@@ -1,4 +1,4 @@
-//===--- llvmcc.cpp - The LLVM Compiler Driver ------------------*- C++ -*-===//
+//===--- llvmc.cpp - The LLVM Compiler Driver ------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -26,7 +26,7 @@
namespace cl = llvm::cl;
namespace sys = llvm::sys;
-using namespace llvmcc;
+using namespace llvmc;
// Built-in command-line options.
// External linkage here is intentional.
Modified: llvm/trunk/utils/TableGen/LLVMCCConfigurationEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/LLVMCCConfigurationEmitter.cpp?rev=50746&r1=50745&r2=50746&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/LLVMCCConfigurationEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/LLVMCCConfigurationEmitter.cpp Tue May 6 13:08:59 2008
@@ -1,4 +1,4 @@
-//===- LLVMCConfigurationEmitter.cpp - Generate LLVMCC config -------------===//
+//===- LLVMCConfigurationEmitter.cpp - Generate LLVMC config --------------===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
-// This tablegen backend is responsible for emitting LLVMCC configuration code.
+// This tablegen backend is responsible for emitting LLVMC configuration code.
//
//===----------------------------------------------------------------------===//
@@ -848,7 +848,7 @@
throw std::string("Error in the language map definition!");
// Generate code
- O << "void llvmcc::PopulateLanguageMap(LanguageMap& language_map) {\n";
+ O << "void llvmc::PopulateLanguageMap(LanguageMap& language_map) {\n";
for (unsigned i = 0; i < LangsToSuffixesList->size(); ++i) {
Record* LangToSuffixes = LangsToSuffixesList->getElementAsRecord(i);
@@ -1040,7 +1040,7 @@
ListInit* edges = CompilationGraph->getValueAsListInit("edges");
// Generate code
- O << "void llvmcc::PopulateCompilationGraph(CompilationGraph& G) {\n"
+ O << "void llvmc::PopulateCompilationGraph(CompilationGraph& G) {\n"
<< Indent1 << "PopulateLanguageMap(G.ExtsToLangs);\n\n";
// Insert vertices
@@ -1085,7 +1085,7 @@
// Back-end entry point
void LLVMCCConfigurationEmitter::run (std::ostream &O) {
// Emit file header
- EmitSourceFileHeader("LLVMCC Configuration Library", O);
+ EmitSourceFileHeader("LLVMC Configuration Library", O);
// Get a list of all defined Tools
RecordVector Tools = Records.getAllDerivedDefinitions("Tool");
More information about the llvm-commits
mailing list