Add PrefixPrinter arguments to the dump routines for MachineFunction and
[oota-llvm.git] / include / llvm / CompilerDriver / Tool.h
1 //===--- Tool.h - The LLVM Compiler Driver ----------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open
6 // Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 //  Tool abstract base class - an interface to tool descriptions.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_INCLUDE_COMPILER_DRIVER_TOOL_H
15 #define LLVM_INCLUDE_COMPILER_DRIVER_TOOL_H
16
17 #include "llvm/CompilerDriver/Action.h"
18
19 #include "llvm/ADT/IntrusiveRefCntPtr.h"
20 #include "llvm/ADT/StringSet.h"
21 #include "llvm/System/Path.h"
22
23 #include <vector>
24
25 namespace llvmc {
26
27   class LanguageMap;
28   typedef std::vector<llvm::sys::Path> PathVector;
29   typedef llvm::StringSet<> InputLanguagesSet;
30
31   /// Tool - A class
32   class Tool : public llvm::RefCountedBaseVPTR<Tool> {
33   public:
34
35     virtual ~Tool() {}
36
37     virtual Action GenerateAction (const PathVector& inFiles,
38                                    bool  HasChildren,
39                                    const llvm::sys::Path& TempDir,
40                                    const InputLanguagesSet& InLangs,
41                                    const LanguageMap& LangMap) const = 0;
42
43     virtual Action GenerateAction (const llvm::sys::Path& inFile,
44                                    bool  HasChildren,
45                                    const llvm::sys::Path& TempDir,
46                                    const InputLanguagesSet& InLangs,
47                                    const LanguageMap& LangMap) const = 0;
48
49     virtual const char*  Name() const = 0;
50     virtual const char** InputLanguages() const = 0;
51     virtual const char*  OutputLanguage() const = 0;
52
53     virtual bool IsJoin() const = 0;
54
55   protected:
56     /// OutFileName - Generate the output file name.
57     llvm::sys::Path OutFilename(const llvm::sys::Path& In,
58                                 const llvm::sys::Path& TempDir,
59                                 bool StopCompilation,
60                                 const char* OutputSuffix) const;
61   };
62
63   /// JoinTool - A Tool that has an associated input file list.
64   class JoinTool : public Tool {
65   public:
66     void AddToJoinList(const llvm::sys::Path& P) { JoinList_.push_back(P); }
67     void ClearJoinList() { JoinList_.clear(); }
68     bool JoinListEmpty() const { return JoinList_.empty(); }
69
70     Action GenerateAction(bool  HasChildren,
71                           const llvm::sys::Path& TempDir,
72                           const InputLanguagesSet& InLangs,
73                           const LanguageMap& LangMap) const {
74       return GenerateAction(JoinList_, HasChildren, TempDir, InLangs, LangMap);
75     }
76     // We shouldn't shadow base class's version of GenerateAction.
77     using Tool::GenerateAction;
78
79   private:
80     PathVector JoinList_;
81   };
82
83 }
84
85 #endif // LLVM_INCLUDE_COMPILER_DRIVER_TOOL_H